liusheng
11 小时以前 ab2884ade73fed97d1e7d7daf4b9b5b6dee83fdd
ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
@@ -101,11 +101,8 @@
import com.ruoyi.task.mapper.ServiceOutPathMapper;
import com.ruoyi.task.service.IServiceOutPathService;
import com.ruoyi.task.domain.ServiceSubtaskPreachform;
import com.ruoyi.task.api.spi.TaskPreachformPort;
import com.ruoyi.task.mapper.ServiceSubtaskPreachformMapper;
import com.ruoyi.task.api.spi.TaskArchivePort;
import com.ruoyi.task.api.spi.TaskFtpPort;
import com.ruoyi.task.api.spi.TaskSysConfigPort;
import com.ruoyi.task.api.spi.TaskSysDeptPort;
import com.ruoyi.task.common.ScheduleSubtaskBuilder;
import com.ruoyi.task.domain.ServiceTaskScheduleVO;
import com.ruoyi.task.service.IServiceSubtaskService;
@@ -124,6 +121,8 @@
import com.ruoyi.task.domain.ServiceSubtaskTemplateVO;
import com.ruoyi.task.domain.ServiceTaskVO;
import com.ruoyi.task.domain.VO.TransferDeptVO;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.mapper.ext.SysDept2Mapper;
/**
 * 单一任务(随访)Service业务层处理
@@ -166,7 +165,7 @@
    private ServiceSubtaskMapper serviceSubtaskMapper;
    @Autowired
    private TaskPreachformPort taskPreachformPort;
    private ServiceSubtaskPreachformMapper taskPreachformPort;
    @Autowired
    private ServiceSubtaskDetailMapper serviceSubtaskDetailMapper;
@@ -221,9 +220,6 @@
    @Autowired
    private ScheduleSubtaskBuilder scheduleSubtaskBuilder;
    @Autowired
    private TaskFtpPort taskFtpPort;
@@ -236,7 +232,7 @@
    @Autowired
    private TaskSysConfigPort taskSysConfigPort;
    private ISysConfigService sysConfigService;
    /**
     * 消息发送方工厂(短信/微信公众号),替代原来直接调用各站点发送代码的写法
@@ -255,7 +251,7 @@
    @Autowired
    private TaskSysDeptPort taskSysDeptPort;
    private SysDept2Mapper sysDept2Mapper;
    @Value("${spring.profiles.active}")
    private String active;
@@ -1085,7 +1081,7 @@
            }
            serviceTask.setLeaveldeptcodes(serviceTaskVO.getLeaveldeptcodes());
            if (StringUtils.isEmpty(serviceTask.getLeavehospitaldistrictname()) && StringUtils.isNotEmpty(serviceTask.getLeavehospitaldistrictcode())) {
                SysDept sysDept = taskSysDeptPort.selectDeptByCode(serviceTask.getLeavehospitaldistrictcode(), null);
                SysDept sysDept = sysDept2Mapper.selectDeptByCode(serviceTask.getLeavehospitaldistrictcode(), null);
                serviceTask.setLeavehospitaldistrictname(sysDept.getDeptName());
            }
            if (serviceTaskVO.getLongTask() == 1) serviceTask.setSendState(2L);
@@ -3574,6 +3570,55 @@
        return serviceSubtaskMapper.getCurrentUserServiceSubtaskCount(entity);
    }
    /**
     * 当前登录人待处理随访任务,按出院年月分组统计(出院随访、门诊随访分开计数)
     * <p>
     * 只返回有数据的月份,前端按「当月 + 前 3 个月」补齐,没有数据显示 0 个。
     */
    @Override
    public Map<String, Object> getPendingManualTaskMonthStats(ServiceSubtaskEntity entity) {
        List<Map<String, Object>> rows = serviceSubtaskMapper.countPendingManualTaskByMonth(entity);
        List<Map<String, Object>> months = new ArrayList<>();
        long total = 0L;
        if (rows != null) {
            for (Map<String, Object> row : rows) {
                if (row == null || row.get("month") == null) {
                    continue;
                }
                long dischargeCount = parsePendingCount(row.get("dischargeCnt"));
                long outpatientCount = parsePendingCount(row.get("outpatientCnt"));
                if (dischargeCount <= 0 && outpatientCount <= 0) {
                    continue;
                }
                Map<String, Object> item = new LinkedHashMap<>();
                item.put("month", row.get("month").toString());
                item.put("dischargeCount", dischargeCount);
                item.put("outpatientCount", outpatientCount);
                months.add(item);
                total += dischargeCount + outpatientCount;
            }
        }
        Map<String, Object> result = new LinkedHashMap<>();
        result.put("total", total);
        result.put("months", months);
        return result;
    }
    /**
     * 统计结果里的数量转 long,解析失败按 0 处理
     */
    private long parsePendingCount(Object value) {
        if (value == null) {
            return 0L;
        }
        try {
            return Long.parseLong(value.toString());
        } catch (NumberFormatException e) {
            log.warn("统计待处理随访任务失败,数量无法解析:{}", value);
            return 0L;
        }
    }
    @Override
    public Map<String, Object> getContinueNurseCount(ServiceSubtaskCotinueCountVO vo) {
        boolean hasDistrict = !CollectionUtils.isEmpty(vo.getLeavehospitaldistrictcodes());
@@ -3641,8 +3686,8 @@
    public void setFailSubTaskDefalutVal(Long failDay) {
        //1.先去sys_config中,获取哪些科室或病区需要默认问卷默认值
        IConfigService configService = SpringUtils.getBean(IConfigService.class);
        String deptConfigValue = taskSysConfigPort.selectConfigValue("hosp.default.dept");
        String wardConfigValue = taskSysConfigPort.selectConfigValue("hosp.default.ward");
        String deptConfigValue = sysConfigService.selectConfigByKey("hosp.default.dept");
        String wardConfigValue = sysConfigService.selectConfigByKey("hosp.default.ward");
        List<String> leaveWard = null;
        List<String> leaveDept = null;
        if (deptConfigValue != null && !deptConfigValue.isEmpty()) {
@@ -3870,8 +3915,8 @@
        // 参数值经端口取用(原为 sysConfigMapper.checkConfigKeyUnique + getConfigValue)。
        // 语义等价:原判定"行存在"、这里判定"值非 null",而 sys_config.config_value 是
        // varchar(500) NOT NULL DEFAULT '' ⇒ 二者不可能不同(详见 TaskSysConfigPort javadoc)。
        String smsContemt = taskSysConfigPort.findConfigValueByKey("wj.sms.template");
        // varchar(500) NOT NULL DEFAULT '' ⇒ 二者不可能不同(详见 ISysConfigService javadoc)。
        String smsContemt = sysConfigService.selectConfigByKey("wj.sms.template");
        if (smsContemt != null) {
            sendMagParam.setContent(smsContemt.replace("${wjurl}", sendMagParam.getUrl()));
@@ -4214,7 +4259,7 @@
            return null;
        }
        try {
            SysDept sysDept = taskSysDeptPort.selectDeptByCode(deptCode, orgid);
            SysDept sysDept = sysDept2Mapper.selectDeptByCode(deptCode, orgid);
            return sysDept == null ? null : sysDept.getCampusid();
        } catch (Exception e) {
            log.warn("按编码反查院区失败:deptCode={}, orgid={}, err={}", deptCode, orgid, e.getMessage());