liusheng
2026-04-30 ba8b51763d81a089a9c560a578f7b68441446494
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -16,6 +16,7 @@
import com.smartor.config.PhoneUtils;
import com.smartor.domain.DTO.ServiceSubtaskDetailDTO;
import com.smartor.domain.*;
import com.smartor.domain.VO.HeLibraryCountVO;
import com.smartor.domain.VO.ServiceSubtaskCotinueCountVO;
import com.smartor.domain.entity.ServiceSubtaskEntity;
import com.smartor.mapper.*;
@@ -31,6 +32,7 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -162,6 +164,12 @@
    private Integer phoneUpEveryHour;
    @Value("${phoneEndHour}")
    private Integer phoneEndHour;
    @Autowired
    private Icd10Mapper icd10Mapper;
    @Value("${spring.profiles.active}")
    private String active;
    /**
     * 查询单一任务(随访)
@@ -613,10 +621,19 @@
                    ServiceTaskdiag serviceTaskdiag = new ServiceTaskdiag();
                    serviceTaskdiag.setTaskId(serviceTask.getTaskid());
                    serviceTaskdiag.setTaskName(serviceTask.getTaskName());
                    serviceTaskdiag.setServiceType(serviceTaskVO.getServiceType());
                    serviceTaskdiag.setLongtask(Long.valueOf(serviceTask.getLongTask()));
                    if (serviceTaskVO.getLongTask() == 1) serviceTaskdiag.setLongtask(1L);
                    serviceTaskdiag.setIcd10code(serviceTaskVO.getIcd10code());
                    serviceTaskdiag.setIcd10name(serviceTaskVO.getIcd10name());
                    //南华附一的icd10code是有重复的,所以不能用南华附一的icd10code去查询
                    if (!active.equals("nhfy") && StringUtils.isEmpty(serviceTaskVO.getIcd10name())) {
                        Icd10 icd10 = new Icd10();
                        icd10.setIcdcode(serviceTaskVO.getIcd10code());
                        List<Icd10> icd10s = icd10Mapper.selectIcd10List(icd10);
                        if (CollectionUtils.isNotEmpty(icd10s))
                            serviceTaskdiag.setIcd10name(icd10s.get(0).getIcdname());
                    }
                    serviceTaskdiag.setGuid(serviceTask.getGuid());
                    serviceTaskdiag.setOrgid(serviceTask.getOrgid());
                    serviceTaskdiag.setCreateTime(new Date());
@@ -754,7 +771,8 @@
                }
            }
        } else if (serviceTaskVO.getIsoperation() != null && serviceTaskVO.getIsoperation() == 2) {
        }
        else if (serviceTaskVO.getIsoperation() != null && serviceTaskVO.getIsoperation() == 2) {
            //任务修改
            if (ObjectUtils.isNotEmpty(serviceTaskVO.getSendTimeslot()))
                serviceTask.setSendTimeSlot(JSON.toJSONString(serviceTaskVO.getSendTimeslot()));
@@ -3589,7 +3607,8 @@
        map.put("content", sendMagParam.getContent());
        String result = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map));
        redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES);
        if (StringUtils.isNotEmpty(serviceSubtask.getRemark())) serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功");
        if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
            serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功");
        else serviceSubtask.setRemark("短信补偿发送成功");
        serviceSubtask.setSendstate(3L);
        serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
@@ -4172,6 +4191,38 @@
        }
    }
    @Override
    public Map<String, Object> getHeLibraryCount(@RequestBody HeLibraryCountVO heLibraryCountVO) {
        if (ObjectUtils.isEmpty(heLibraryCountVO)) {
            return new HashMap<>();
        }
        // 1. 查询分组统计(发送总量、发送成功量、已读量)
        List<Map<String, Object>> groupStats = serviceSubtaskMapper.getHeLibraryCount(heLibraryCountVO);
        // 2. 计算各组的发送成功率和已读率
        List<Map<String, Object>> result = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(groupStats)) {
            for (Map<String, Object> row : groupStats) {
                long totalCount = row.get("totalCount") != null ? ((Number) row.get("totalCount")).longValue() : 0L;
                long sendSuccessCount = row.get("sendSuccessCount") != null ? ((Number) row.get("sendSuccessCount")).longValue() : 0L;
                long readCount = row.get("readCount") != null ? ((Number) row.get("readCount")).longValue() : 0L;
                // 发送成功率
                double sendSuccessRate = totalCount > 0 ? (double) sendSuccessCount / totalCount : 0.0;
                // 已读率(基于发送成功的数量计算)
                double readRate = sendSuccessCount > 0 ? (double) readCount / sendSuccessCount : 0.0;
                row.put("sendSuccessRate", sendSuccessRate);
                row.put("readRate", readRate);
                result.add(row);
            }
        }
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("list", result);
        resultMap.put("total", result.size());
        return resultMap;
    }
    private Boolean saveServiceSubtaskDetail(ServiceSubtask serviceSubtask) {
        Boolean result = true;
        //3.4 如果3.1或3.2为true的话,根据type判断什么类型