陈昶聿
2 天以前 fcb98e4558897945a316d04555923355b8e60605
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.dx.MessageSend;
import com.ruoyi.common.exception.base.BaseException;
@@ -29,6 +30,7 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
@@ -183,6 +185,8 @@
    @Autowired
    private IPatMedOuthospService patMedOuthospService;
    @Autowired
    private SysDept2Mapper sysDept2Mapper;
    @Value("${spring.profiles.active}")
    private String active;
@@ -409,6 +413,13 @@
                serviceSubtaskRes.setSendstateView(1L);
            if (serviceSubtaskRes.getSendstate() == 6) serviceSubtaskRes.setSendstateView(2L);
            if (serviceSubtaskRes.getSendstate() == 4) serviceSubtaskRes.setSendstateView(3L);
            // 填充当前补偿
            if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) {
                if (StringUtils.isNotEmpty(serviceSubtask.getPreachform())) {
                    //默认取第一个
                    serviceSubtaskRes.setCurrentPreachform(serviceSubtask.getPreachform().split(",")[0]);
                }
            }
            serviceSubtaskResList.add(serviceSubtaskRes);
        }
        return serviceSubtaskResList;
@@ -684,7 +695,10 @@
                serviceTask.setTemplatename(tempName);
            }
            serviceTask.setLeaveldeptcodes(serviceTaskVO.getLeaveldeptcodes());
            serviceTask.setLeavehospitaldistrictcode(serviceTask.getLeavehospitaldistrictcode());
            if (StringUtils.isEmpty(serviceTask.getLeavehospitaldistrictname()) && StringUtils.isNotEmpty(serviceTask.getLeavehospitaldistrictcode())) {
                SysDept sysDept = sysDept2Mapper.selectDeptByCode(serviceTask.getLeavehospitaldistrictcode(), null);
                serviceTask.setLeavehospitaldistrictname(sysDept.getDeptName());
            }
            if (serviceTaskVO.getLongTask() == 1) serviceTask.setSendState(2L);
            serviceTask.setCreateTime(new Date());
            serviceTask.setUpdateTime(new Date());
@@ -710,8 +724,8 @@
                    //南华附一的icd10code是有重复的,所以不能用南华附一的icd10code去查询
                    log.info("----serviceTaskdiag的值为:{}", serviceTaskdiag);
                    if (!StringUtils.isEmpty(serviceTaskVO.getIcd10name())) {
                        String[] Icd10Names = serviceTaskVO.getIcd10name().split("$");
                        String[] Icd10codes = serviceTaskVO.getIcd10code().split("$");
                        String[] Icd10Names = serviceTaskVO.getIcd10name().split(",");
                        String[] Icd10codes = serviceTaskVO.getIcd10code().split(",");
                        for (int i = 0; i < Icd10Names.length; i++) {
                            serviceTaskdiag.setIcd10code(Icd10codes[i]);
                            serviceTaskdiag.setIcd10name(Icd10Names[i]);
@@ -722,16 +736,27 @@
                    ServiceTaskoper serviceTaskoper = new ServiceTaskoper();
                    serviceTaskoper.setOpcode(serviceTaskVO.getOpcode());
                    serviceTaskoper.setOpdesc(serviceTaskVO.getOpdesc());
                    serviceTaskoper.setOplevelcode(serviceTaskVO.getOplevelcode());
//                    serviceTaskoper.setOplevelcode(serviceTaskVO.getOplevelcode());
                    serviceTaskoper.setTaskId(serviceTask.getTaskid());
                    serviceTaskoper.setTaskName(serviceTask.getTaskName());
                    serviceTaskoper.setLongtask(Long.valueOf(serviceTask.getLongTask()));
                    serviceTaskoper.setGuid(serviceTask.getGuid());
                    serviceTaskoper.setOrgid(serviceTask.getOrgid());
                    serviceTaskoper.setCreateTime(new Date());
                    //配置科室、病区
                    serviceTaskoper.setDeptCode(serviceTaskVO.getDeptcode());
                    serviceTaskoper.setDeptName(serviceTaskVO.getDeptname());
                    serviceTaskoper.setWardCode(serviceTaskVO.getLeavehospitaldistrictcode());
                    serviceTaskoper.setWardName(serviceTaskVO.getLeavehospitaldistrictname());
                    //多选手术等级
                    if (StringUtils.isNotEmpty(serviceTaskVO.getOplevelcode())) {
                        log.info("----serviceTaskoper的值为:{}", serviceTaskoper);
                        serviceTaskoperService.insertServiceTaskoper(serviceTaskoper);
                        String[] opLevelcodes = serviceTaskVO.getOplevelcode().split(",");
                        for (String opLevelcode : opLevelcodes) {
                            //先查询一下是否存在
                            log.info("----serviceTaskoper的值为:{}", serviceTaskoper);
                            serviceTaskoper.setOplevelcode(opLevelcode);
                            serviceTaskoperService.insertServiceTaskoper(serviceTaskoper);
                        }
                    }
                } else if (serviceTaskVO.getAppltype().equals("5")) {
@@ -2416,7 +2441,6 @@
            serviceSubtask.setRemark("电话接通成功,患者拒绝随访");
            serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid()));
            serviceSubtask.setSendstate(6L);
            serviceSubtask.setFinishtime(new Date());
            serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
//            int startIndex = phoneCallRecordVO.getRecord_path().indexOf("voice") + "voice".length() + 1;  // 加1是跳过/符号
//            int endIndex = phoneCallRecordVO.getRecord_path().lastIndexOf("/");
@@ -2919,15 +2943,15 @@
                //首次出院随访
                if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
                    //首次应随访
                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                    if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L)) {
                        serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
                    }
                    //首次待随访
                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
                        serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L);
                    //首次无需随访
                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(4L)) {
                        serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                    }
                    //首次随访失败(包括随访失败+人工超时)
                    if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 5 || serviceSubtask.getSendstate() == 7)) {
                    if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(5L) || serviceSubtask.getSendstate().equals(7L))) {
                        serviceSubtaskStatistic.setFollowUpFail(serviceSubtaskStatistic.getFollowUpFail() + 1L);
                    }
                    /**
@@ -2937,6 +2961,10 @@
                        //首次随访成功
                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L))) {
                            serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L);
                        }
                        //首次无需随访
                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
                            serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                        }
                        //首次随访人工 (不统计不执行)
                        if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
@@ -2959,6 +2987,10 @@
                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L))) {
                            serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L);
                        }
                        //首次无需随访
                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
                            serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                        }
                        //首次随访人工 (只统计已完成)
                        if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
                            serviceSubtaskStatistic.setManual(serviceSubtaskStatistic.getManual() + 1L);
@@ -2979,6 +3011,10 @@
                        //首次随访成功 - 统计时候加上不执行的,已发送的
                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L) || serviceSubtask.getSendstate().equals(3L) || serviceSubtask.getSendstate().equals(4L))) {
                            serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L);
                        }
                        //首次无需随访
                        if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
                            serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                        }
                        //首次随访人工 (统计不执行)
                        if (serviceSubtask.getSendstate() != null && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
@@ -3012,6 +3048,10 @@
                    //再次应随访
                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                        serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
                    }
                    //再次无需随访
                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) {
                        serviceSubtaskStatistic.setNonFollowUpAgain(serviceSubtaskStatistic.getNonFollowUpAgain() + 1L);
                    }
                    //再次待随访
                    if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
@@ -3163,6 +3203,10 @@
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                    serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L);
                }
                //首次无需随访
                if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) {
                    serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L);
                }
                //首次待随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
                    serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L);
@@ -3309,6 +3353,10 @@
                //再次应随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
                    serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
                }
                //再次无需随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) {
                    serviceSubtaskStatistic.setNonFollowUpAgain(serviceSubtaskStatistic.getNonFollowUpAgain() + 1L);
                }
                //再次待随访
                if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
@@ -3731,7 +3779,7 @@
        Map<String, String> map = new HashMap<>();
        map.put("phone", serviceSubtask.getPhone());
        map.put("content", sendMagParam.getContent());
        String result = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map));
        HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map));
        redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES);
        if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
            serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功");
@@ -4567,6 +4615,29 @@
    }
    @Override
    public List<ServiceSubtask> gethelibraryCountHyperlink(HeLibraryCountVO heLibraryCountVO){
        String hyperLinkInfoType = heLibraryCountVO.getHyperLinkInfoType();
        if(StringUtils.isNotEmpty(hyperLinkInfoType)){
            heLibraryCountVO.setSendstate(null);
            heLibraryCountVO.setIsFinished(null);
            switch (hyperLinkInfoType) {
                case "totalCountInfo":
                    break;
                case "sendSuccessCountInfo":
                    heLibraryCountVO.setSendstate(6L);
                    break;
                case "readCountInfo":
                    heLibraryCountVO.setIsFinished("1");
                    break;
                default:
                    break;
            }
        }
        List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.gethelibraryCountHyperlink(heLibraryCountVO);
        return serviceSubtasks;
    }
    @Override
    public Map<String, Object> smsSubTask(Long subid) {
        log.info("smsSubTask的入参为:{}", subid);
        Map<String, Object> resultMap = new HashMap<>();
@@ -4621,6 +4692,11 @@
        return resultMap;
    }
    @Override
    public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startOutHospTime, Date endOutHospTime) {
        return serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime);
    }
    private Boolean saveServiceSubtaskDetail(ServiceSubtask serviceSubtask) {
        Boolean result = true;
        //3.4 如果3.1或3.2为true的话,根据type判断什么类型