liusheng
2 天以前 3ede859fc8cd6068ea91f66553d38f5b510af3ef
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -13,6 +13,7 @@
import com.smartor.common.FtpService;
import com.smartor.config.PhoneUtils;
import com.smartor.domain.*;
import com.smartor.domain.VO.ServiceSubtaskCotinueCountVO;
import com.smartor.domain.entity.ServiceSubtaskEntity;
import com.smartor.mapper.*;
import com.smartor.service.*;
@@ -411,18 +412,18 @@
        // 处理空异常
        if (MapUtils.isEmpty(result)) {
            result = new HashMap<>();
            // 确保所有 key 都有值,避免空指针异常
            // MyBatis 的 SUM 在没有匹配行时会返回 null
            result.putIfAbsent("wzx", 0);
            result.putIfAbsent("ysf", 0);
            result.putIfAbsent("yc", 0);
            result.putIfAbsent("jg", 0);
            result.putIfAbsent("fssb", 0);
            result.putIfAbsent("yfs", 0);
            result.putIfAbsent("blq", 0);
            result.putIfAbsent("dsf", 0);
            result.putIfAbsent("total", 0);
        }
        // 确保所有 key 都有值,避免空指针异常
        // MyBatis 的 SUM 在没有匹配行时会返回 null
        result.putIfAbsent("wzx", 0);
        result.putIfAbsent("ysf", 0);
        result.putIfAbsent("yc", 0);
        result.putIfAbsent("jg", 0);
        result.putIfAbsent("fssb", 0);
        result.putIfAbsent("yfs", 0);
        result.putIfAbsent("blq", 0);
        result.putIfAbsent("dsf", 0);
        return result;
    }
@@ -1982,7 +1983,7 @@
//        if (existSize > 0) return pullTaskVOList;
        int count = 0;
        long size = listOps.size("cache-0");
        log.error("---------打电话之前缓存中的数据量:{}", size);
        log.info("---------打电话之前缓存中的数据量:{}", size);
        if (size > 0) {
            //phoneCount()  通过给出的每个小时需要打出的电话量,算出到晚上8点一点能打出多少个电话,获取到总量
            //如果需要立即执行的数据量大于一天要执行的上限,则只取上限的数量,其它的则放回redis中
@@ -2031,7 +2032,7 @@
            }
        }
//        if (existList.size() != 0) redisCache.setCacheListRight("cache-exist", existList);
        log.error("-----------实际拉取的电话数据量:{}", CollectionUtils.isNotEmpty(pullTaskVOList) ? pullTaskVOList.size() : null);
        log.info("-----------实际拉取的电话数据量:{}", CollectionUtils.isNotEmpty(pullTaskVOList) ? pullTaskVOList.size() : null);
        return pullTaskVOList;
    }
@@ -2302,7 +2303,7 @@
            String deptcodes = CollectionUtils.isEmpty(request.getDeptcodes()) ? null : String.join(",", request.getDeptcodes());
            if (!request.getTimeType().equals("month")) {
                req.setBeginAdmitdate(DateUtils.parseDate(serviceStatisticsResponse.getTimePeriod()));
                req.setEndAdmitdate(DateUtils.parseDate(serviceStatisticsResponse.getTimePeriod()));
                req.setEndAdmitdate( DateUtils.addDays(DateUtils.parseDate(serviceStatisticsResponse.getTimePeriod()),1));
            } else {
                // year 类型:timePeriod 格式为 "yyyy-MM",取当月第一天和最后一天
                java.time.YearMonth ym = java.time.YearMonth.parse(serviceStatisticsResponse.getTimePeriod());
@@ -2370,13 +2371,13 @@
    public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) {
        log.info("getSfStatistics的入参为:{}", serviceSubtaskCountReq);
        String groupKey = "drcode";
        if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && !serviceSubtaskCountReq.getLeavehospitaldistrictcodes().isEmpty()) {
        if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 1) {
            if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
                groupKey = "drcode";
            } else {
                groupKey = "leavehospitaldistrictcode";
            }
        } else if (serviceSubtaskCountReq.getDeptcodes() != null && !serviceSubtaskCountReq.getDeptcodes().isEmpty()) {
        } else if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 2) {
            if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
                groupKey = "drcode";
            } else {
@@ -3847,7 +3848,7 @@
            if (serviceSubtaskPreachform1.getSort() == spSize.size() && failSendstate.equals("4")) {
                serviceSubtask.setCurrentPreachform(preachform);
                serviceSubtask.setSendstate(5L);
//                serviceSubtask.setRemark("setFailPreachForm方法 当前的preachform已经是最后一个了,全失败了");
                serviceSubtask.setRemark("所有发送方式均未获取结果,任务失败");
                serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                return true;
            }
@@ -4017,4 +4018,65 @@
    public Map<String, Object> getCurrentUserServiceSubtaskCount(ServiceSubtaskEntity entity) {
        return serviceSubtaskMapper.getCurrentUserServiceSubtaskCount(entity);
    }
    @Override
    public Map<String, Object> getContinueNurseCount(ServiceSubtaskCotinueCountVO vo) {
        boolean hasDistrict = !CollectionUtils.isEmpty(vo.getLeavehospitaldistrictcodes());
        boolean hasDept = !CollectionUtils.isEmpty(vo.getDeptcodes());
        List<Map<String, Object>> districtRows;
        List<Map<String, Object>> deptRows;
        if (hasDistrict) {
            // 只传了病区:仅按病区维度统计
            districtRows = serviceSubtaskMapper.getContinueNurseCount(vo);
            deptRows = Collections.emptyList();
        } else if (hasDept) {
            // 只传了科室:仅按科室维度统计
            districtRows = Collections.emptyList();
            deptRows = serviceSubtaskMapper.getContinueNurseCountByDept(vo);
        } else {
            // 都未传:病区和科室各统计一遍
            districtRows = serviceSubtaskMapper.getContinueNurseCount(vo);
            deptRows = serviceSubtaskMapper.getContinueNurseCountByDept(vo);
        }
        long totalNoContinue = 0L;
        long totalContinue = 0L;
        List<Map<String, Object>> detail = new ArrayList<>();
        for (Map<String, Object> row : districtRows) {
            String groupName = row.get("groupName") == null
                    ? (row.get("groupCode") == null ? "" : row.get("groupCode").toString())
                    : row.get("groupName").toString();
            long noCnt = row.get("noContinueCnt") == null ? 0L : Long.parseLong(row.get("noContinueCnt").toString());
            long yesCnt = row.get("continueCnt") == null ? 0L : Long.parseLong(row.get("continueCnt").toString());
            totalNoContinue += noCnt;
            totalContinue += yesCnt;
            Map<String, Object> item = new LinkedHashMap<>();
            item.put("未延续_" + groupName, noCnt);
            item.put("已延续_"+groupName, yesCnt);
            detail.add(item);
        }
        for (Map<String, Object> row : deptRows) {
            String groupName = row.get("groupName") == null
                    ? (row.get("groupCode") == null ? "" : row.get("groupCode").toString())
                    : row.get("groupName").toString();
            long noCnt = row.get("noContinueCnt") == null ? 0L : Long.parseLong(row.get("noContinueCnt").toString());
            long yesCnt = row.get("continueCnt") == null ? 0L : Long.parseLong(row.get("continueCnt").toString());
            totalNoContinue += noCnt;
            totalContinue += yesCnt;
            Map<String, Object> item = new LinkedHashMap<>();
            item.put("未延续_" + groupName, noCnt);
            item.put("已延续_" + groupName, yesCnt);
            detail.add(item);
        }
        Map<String, Object> result = new LinkedHashMap<>();
        result.put("未延续总数量", totalNoContinue);
        result.put("已延续总数量", totalContinue);
        result.put("详情", detail);
        return result;
    }
}