| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.gson.Gson; |
| | |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.*; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.data.redis.core.ListOperations; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | |
| | | @Autowired |
| | | private IvrLibaExtemplatescriptMapper ivrLibaExtemplatescriptMapper; |
| | | |
| | | @Autowired |
| | | private ISvyTaskTemplateScriptService svyTaskTemplateScriptService; |
| | | |
| | | @Autowired |
| | | private IIvrTaskTemplateService ivrTaskTemplateService; |
| | |
| | | @Override |
| | | public ServiceSubtask selectServiceSubtaskById(Long id) { |
| | | return serviceSubtaskMapper.selectServiceSubtaskById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtask> selectServiceSubtaskByDiagname(ServiceSubtask serviceSubtask) { |
| | | return serviceSubtaskMapper.selectServiceSubtaskByDiagname(serviceSubtask); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | if (patMedInhospList.size() > 0) { |
| | | serviceSubtask1.setIsVisitAgain(2); |
| | | serviceSubtask1.setRemark(serviceSubtask1.getRemark()+";患者再入院了"); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1); |
| | | return "无需再次随访,患者再入院了"; |
| | | } else if (serviceSubtask1.getSendstate() == 4L) { |
| | | serviceSubtask1.setIsVisitAgain(2); |
| | | serviceSubtask1.setRemark(serviceSubtask1.getRemark()+";无需再次随访,任务被标记不在执行"); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1); |
| | | return "无需再次随访,任务被标记不在执行"; |
| | | } else if (StringUtils.isNotEmpty(patArchive.getNotrequiredFlag()) && patArchive.getNotrequiredFlag().equals("1")) { |
| | | serviceSubtask1.setIsVisitAgain(2); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1); |
| | | serviceSubtask1.setRemark(serviceSubtask1.getRemark()+";无需再次随访,患者被标记不需要被服务"); |
| | | return "无需再次随访,患者被标记不需要被服务"; |
| | | } else if (ObjectUtils.isNotEmpty(serviceSubtask1.getIsVisitAgain()) && serviceSubtask1.getIsVisitAgain() == 2) { |
| | | return "无需再次随访,该任务已经再次随访过了"; |
| | |
| | | serviceSubtask.setAddr(patTaskRelevance.getAddr()); |
| | | serviceSubtask.setPatid(patTaskRelevance.getPatid()); |
| | | serviceSubtask.setCreateTime(DateUtils.getNowDate()); |
| | | serviceSubtask.setInhospid(patTaskRelevance.getHospid()); |
| | | serviceSubtask.setSendstate(1L); |
| | | if (serviceTaskVO.getLongTask() != null && serviceTaskVO.getLongTask() == 1) |
| | | serviceSubtask.setSendstate(2L); |
| | |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | log.error("sfSend需要移除的subId为:{}", serviceSubtask.getId().toString()); |
| | | serviceSubtaskMapper.deleteServiceSubtaskById(serviceSubtask.getId()); |
| | | redisCache.removeElementFromList("cache-exist", serviceSubtask.getId().toString()); |
| | | // redisCache.removeElementFromList("cache-exist", serviceSubtask.getId().toString()); |
| | | redisCache.removeElementFromList("cache-0", serviceSubtask.getId().toString()); |
| | | redisCache.removeElementFromList("cache-1", serviceSubtask.getId().toString()); |
| | | redisCache.removeElementFromList("cache-2", serviceSubtask.getId().toString()); |
| | |
| | | @Override |
| | | public PhoneCallBackYQVO phoneCallBackYQ(PhoneCallReqYQVO phoneCallReqYQVO) { |
| | | //先把该subId从cache_exist中剔除,只要有回调就剔除(目的是,尽快让cache-exist为空,去缓存下一批要打的电话;这里剔除不影响电话的正常业务) |
| | | redisCache.removeElementFromList("cache-exist", phoneCallReqYQVO.getTaskid()); |
| | | // redisCache.removeElementFromList("cache-exist", phoneCallReqYQVO.getTaskid()); |
| | | |
| | | //判断是否挂机 |
| | | String hangupState = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- hangup"); |
| | |
| | | List<String> cacheList = new ArrayList<>(); |
| | | ListOperations<String, String> listOps = redisTemplate.opsForList(); |
| | | //必须等ache-exist全部打完才能拉取下一批(主要是怕所有的数据都堆在电话的缓存里,在规定的时间打不完) |
| | | long existSize = listOps.size("cache-exist"); |
| | | if (existSize > 0) return pullTaskVOList; |
| | | // long existSize = listOps.size("cache-exist"); |
| | | // if (existSize > 0) return pullTaskVOList; |
| | | int count = 0; |
| | | long size = listOps.size("cache-0"); |
| | | log.error("---------打电话之前缓存中的数据量:{}", size); |
| | |
| | | count = Math.min(phoneCount(), (int) size); |
| | | if (count != 0) { |
| | | cacheList = listOps.range("cache-0", 0, count - 1); |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | log.error("任务拉取cache-0的值是多少:{}", cacheList); |
| | | log.info("任务拉取cache-0的值是多少:{}", cacheList); |
| | | // cache-0为立即发起的,其它的先推迟 |
| | | if (!CollectionUtils.isEmpty(cacheList)) { |
| | | pullTaskVOList = getPullTaskList(cacheList, "cache-0"); |
| | | // 删除已处理的数据 |
| | | listOps.trim("cache-0", count, -1); |
| | | log.error("打电话之后缓存中的数据量---------:{}", listOps.size("cache-0")); |
| | | log.info("打电话之后缓存中的数据量---------:{}", listOps.size("cache-0")); |
| | | } else { |
| | | for (int i = 1; i < 6; i++) { |
| | | //取出从cache-1 到 cache-5的第一个子任务信息 |
| | |
| | | } |
| | | } |
| | | //existList用来记录接下来需要执行的子任务ID |
| | | List<String> existList = new ArrayList<>(); |
| | | // List<String> existList = new ArrayList<>(); |
| | | if (CollectionUtils.isNotEmpty(pullTaskVOList)) { |
| | | //给回调参数赋值 |
| | | for (PullTaskVO pullTaskVO : pullTaskVOList) { |
| | | existList.add(pullTaskVO.getTaskid()); |
| | | // existList.add(pullTaskVO.getTaskid()); |
| | | pullTaskVO.setAsrcallback(ASRCallBackPath); |
| | | } |
| | | } |
| | | if (existList.size() != 0) redisCache.setCacheListRight("cache-exist", existList); |
| | | // if (existList.size() != 0) redisCache.setCacheListRight("cache-exist", existList); |
| | | log.error("-----------实际拉取的电话数据量:{}", CollectionUtils.isNotEmpty(pullTaskVOList) ? pullTaskVOList.size() : null); |
| | | return pullTaskVOList; |
| | | } |
| | |
| | | } |
| | | //随访 |
| | | for (ServiceSubtaskDetail serviceSubtaskDetail : serviceSubTaskDetailReq.getServiceSubtaskDetailList()) { |
| | | if (serviceSubtaskDetail.getScriptid() != null) { |
| | | //设置一下问题分类 |
| | | IvrTaskTemplateScript ivrTaskTemplateScript = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptByID(serviceSubtaskDetail.getScriptid()); |
| | | if (ivrTaskTemplateScript != null) |
| | | serviceSubtaskDetail.setCategoryid(ivrTaskTemplateScript.getAssortid()); |
| | | } |
| | | |
| | | serviceSubtaskDetail.setSubId(selectServiceSubtaskList.get(0).getId()); |
| | | // serviceSubtaskDetail.setId(UUID.randomUUID().toString()); |
| | | serviceSubtaskDetail.setCreateTime(new Date()); |
| | |
| | | } else { |
| | | if (serviceSubTaskDetailReq != null && CollectionUtils.isNotEmpty(serviceSubTaskDetailReq.getServiceSubtaskDetailList())) { |
| | | for (ServiceSubtaskDetail serviceSubtaskDetail : serviceSubTaskDetailReq.getServiceSubtaskDetailList()) { |
| | | if (serviceSubtaskDetail.getScriptid() != null) { |
| | | //设置一下问题分类 |
| | | IvrTaskTemplateScript ivrTaskTemplateScript = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptByID(serviceSubtaskDetail.getScriptid()); |
| | | if (ivrTaskTemplateScript != null) |
| | | serviceSubtaskDetail.setCategoryid(ivrTaskTemplateScript.getAssortid()); |
| | | } |
| | | serviceSubtaskDetail.setCreateTime(new Date()); |
| | | serviceSubtaskDetail.setGuid(serviceSubTaskDetailReq.getGuid()); |
| | | serviceSubtaskDetail.setOrgid(serviceSubTaskDetailReq.getOrgid()); |
| | |
| | | //进行短信补偿 |
| | | // getSmsCompensate(Long.valueOf(phoneCallRecordVO.getTaskid())); |
| | | redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup"); |
| | | redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid()); |
| | | // redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid()); |
| | | } else if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("2")) { |
| | | // if (phoneCallRecordVO.getAnswered() != null && phoneCallRecordVO.getAnswered() == true) { |
| | | log.error("有人接电话了,并且完了"); |
| | |
| | | } else { |
| | | //患者拒绝随访 |
| | | //先把该subId从cache_exist中剔除,只要有回调就剔除(目的是,尽快让cache-exist为空,去缓存下一批要打的电话;这里剔除不影响电话的正常业务) |
| | | redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid()); |
| | | // redisCache.removeElementFromList("cache-exist", phoneCallRecordVO.getTaskid()); |
| | | ServiceSubtask serviceSubtask = new ServiceSubtask(); |
| | | serviceSubtask.setRemark("电话接通成功,患者拒绝随访"); |
| | | serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid())); |
| | |
| | | stringBuilder.append(timestamp + "之前携带医保卡或电子医保卡身份证凭此条短信到1号楼3楼南入院准备中心入院登记窗口,办理正式住院手续,完成各项检查后再到相应病区护士站报到。"); |
| | | stringBuilder.append("入院准备中心电话:89975977。入院办理须知:https://mp.weixin.qq.com/s/OCkotuRyQ8Ld2owFF0YErw"); |
| | | |
| | | String data = MessageSend.sendMsg(stringBuilder.toString(), "2", patArchiveSrmVO.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
| | | String data = MessageSend.sendMsg(stringBuilder.toString(), "6", patArchiveSrmVO.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
| | | if (StringUtils.isNotEmpty(data) && data.contains("result=0")) { |
| | | sendError.add(patArchiveSrmVO); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Cacheable(value = "sfStatistics", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()") |
| | | public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | log.error("getSfStatistics的入参为:{}", serviceSubtaskCountReq); |
| | | log.info("getSfStatistics的入参为:{}", serviceSubtaskCountReq); |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | | // List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | |
| | |
| | | return serviceSubtaskStatistics; |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskStatistic> getSfStatisticsExport(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | List<ServiceSubtaskStatistic> sfStatistics = getSfStatistics(serviceSubtaskCountReq); |
| | | // 添加总计行 |
| | | if (CollectionUtils.isNotEmpty(sfStatistics)) { |
| | | ServiceSubtaskStatistic totalRow = calculateTotalRow(sfStatistics); |
| | | totalRow.setLeavehospitaldistrictname("总计"); |
| | | totalRow.setDeptname("总计"); |
| | | sfStatistics.add(totalRow); |
| | | } |
| | | |
| | | return sfStatistics; |
| | | } |
| | | |
| | | /** |
| | | * 获取随访统计比例 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Cacheable(value = "sfStatisticsJoy", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()") |
| | | public List<ServiceSubtaskStatistic> getSfStatisticsJoy(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | log.error("getSfStatistics的入参为:{}", serviceSubtaskCountReq); |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | | |
| | | // 根据条件进行分组 |
| | | Map<String, List<ServiceSubtask>> collect = new HashMap<>(); |
| | | String orgid = null; |
| | | |
| | | if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && serviceSubtaskCountReq.getLeavehospitaldistrictcodes().size() > 0) { |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | |
| | | continue; |
| | | } |
| | | ServiceSubtaskStatistic statistic = getStatisticJoy(serviceSubtaskList, joySubCount); |
| | | if (statistic.getJoyCount() != 0 && statistic.getJoyAllCount() != 0) { |
| | | Double joyTotal = Double.parseDouble(statistic.getJoyCount() + "") / Double.parseDouble(statistic.getJoyAllCount() + "") * 100; |
| | | statistic.setJoyTotal(String.format("%.2f", joyTotal) + "%"); |
| | | } |
| | | //及时率 |
| | | ServiceSubtask ss = new ServiceSubtask(); |
| | | ss.setOrgid(serviceSubtaskList.get(0).getOrgid()); |
| | | orgid = serviceSubtaskList.get(0).getOrgid(); |
| | | ss.setOrgid(orgid); |
| | | |
| | | // 如果有医生编码,设置医生编码用于及时率查询 |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | |
| | | } |
| | | Double jsRate = serviceSubtaskMapper.selectTimelyRate(ss); |
| | | statistic.setRate(jsRate); |
| | | |
| | | if (ObjectUtils.isNotEmpty(statistic)) { |
| | | serviceSubtaskStatistics.add(statistic); |
| | | } |
| | | } |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskStatistics)) { |
| | | for (ServiceSubtaskStatistic serviceSubtaskStatistic : serviceSubtaskStatistics) { |
| | | //所有满意度数量 |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getDeptcodes())) { |
| | | Map<String, Object> satisfactionIndex = getSatisfactionIndex("1", serviceSubtaskStatistic.getDeptcode(), orgid, serviceSubtaskCountReq.getIvrCategoryid(), serviceSubtaskCountReq.getSvyCategoryid()); |
| | | serviceSubtaskStatistic.setJoyAllCount(satisfactionIndex.get("mydtmzl") != null ? (Integer) satisfactionIndex.get("mydtmzl") : 0); |
| | | serviceSubtaskStatistic.setJoyCount(satisfactionIndex.get("mydtbl") != null ? (Integer) satisfactionIndex.get("mydtbl") : 0); |
| | | serviceSubtaskStatistic.setJoyTotal((Double) satisfactionIndex.get("wcbl")); |
| | | } else if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getLeavehospitaldistrictcodes())) { |
| | | Map<String, Object> satisfactionIndex = getSatisfactionIndex("2", serviceSubtaskStatistic.getLeavehospitaldistrictcode(), orgid, serviceSubtaskCountReq.getIvrCategoryid(), serviceSubtaskCountReq.getSvyCategoryid()); |
| | | serviceSubtaskStatistic.setJoyAllCount(satisfactionIndex.get("mydtmzl") != null ? (Integer) satisfactionIndex.get("mydtmzl") : 0); |
| | | serviceSubtaskStatistic.setJoyCount(satisfactionIndex.get("mydtbl") != null ? (Integer) satisfactionIndex.get("mydtbl") : 0); |
| | | serviceSubtaskStatistic.setJoyTotal((Double) satisfactionIndex.get("wcbl")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return serviceSubtaskStatistics; |
| | | } |
| | | |
| | | /** |
| | | * 获取满意度题目总量 |
| | | * type : 1-科室 2病区 |
| | | * code: 科室或病区code |
| | | * |
| | | * @return |
| | | */ |
| | | private Map<String, Object> getSatisfactionIndex(String type, String code, String orgid, Long ivrCategoryid, Long svyCategoryid) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<ServiceTask> serviceTasks = null; |
| | | if (type.equals("1")) { |
| | | ServiceTask serviceTask = new ServiceTask(); |
| | | serviceTask.setDeptcode(code); |
| | | serviceTask.setOrgid(orgid); |
| | | serviceTasks = serviceTaskService.selectServiceTaskList(serviceTask); |
| | | } else if (type.equals("2")) { |
| | | ServiceTask serviceTask = new ServiceTask(); |
| | | serviceTask.setLeavehospitaldistrictcode(code); |
| | | serviceTask.setOrgid(orgid); |
| | | serviceTasks = serviceTaskService.selectServiceTaskList(serviceTask); |
| | | } |
| | | |
| | | //获取满意度题目总量 |
| | | BigDecimal mydtmzlsum = new BigDecimal(0); |
| | | //获取满意度题目填报量 |
| | | BigDecimal mydtblsum = new BigDecimal(0); |
| | | if (CollectionUtils.isNotEmpty(serviceTasks)) { |
| | | //获取满意度题目总量 |
| | | for (ServiceTask serviceTask : serviceTasks) { |
| | | if (serviceTask.getType().equals("1")) { |
| | | //语音 |
| | | Long templateid = serviceTask.getTemplateid(); |
| | | IvrTaskTemplateScript ivrTaskTemplateScript = new IvrTaskTemplateScript(); |
| | | ivrTaskTemplateScript.setTemplateID(templateid); |
| | | ivrTaskTemplateScript.setOrgid(serviceTask.getOrgid()); |
| | | //先默认为1吧,assortid=1 代表是满意度 |
| | | ivrTaskTemplateScript.setAssortid(ivrCategoryid); |
| | | List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript); |
| | | if (CollectionUtils.isNotEmpty(ivrTaskTemplateScripts)) { |
| | | //需要先计算出发送量,再乘以单个问券满意度题目数量,得到满意度题目总量(包含了未做的) |
| | | ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); |
| | | serviceSubtaskVO.setTaskid(serviceTask.getTaskid()); |
| | | List<Long> sendstates = new ArrayList<>(Arrays.asList(3L, 5L, 6L)); |
| | | serviceSubtaskVO.setSendstates(sendstates); |
| | | List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { |
| | | int mydtmzlCount = ivrTaskTemplateScripts.size() * serviceSubtaskList.size(); |
| | | mydtmzlsum.add(new BigDecimal(mydtmzlCount)); |
| | | } |
| | | |
| | | } |
| | | } else if (serviceTask.getType().equals("2")) { |
| | | //问卷 |
| | | SvyTaskTemplateScript svyTaskTemplateScript = new SvyTaskTemplateScript(); |
| | | svyTaskTemplateScript.setTemplateID(serviceTask.getTemplateid()); |
| | | svyTaskTemplateScript.setOrgid(serviceTask.getOrgid()); |
| | | svyTaskTemplateScript.setCategoryid(svyCategoryid); |
| | | List<SvyTaskTemplateScript> svyTaskTemplateScriptList = svyTaskTemplateScriptService.selectSvyTaskTemplateScriptList(svyTaskTemplateScript); |
| | | if (CollectionUtils.isNotEmpty(svyTaskTemplateScriptList)) { |
| | | ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); |
| | | serviceSubtaskVO.setTaskid(serviceTask.getTaskid()); |
| | | List<Long> sendstates = new ArrayList<>(Arrays.asList(3L, 5L, 6L)); |
| | | serviceSubtaskVO.setSendstates(sendstates); |
| | | List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { |
| | | int mydtmzlCount = svyTaskTemplateScriptList.size() * serviceSubtaskList.size(); |
| | | mydtmzlsum.add(new BigDecimal(mydtmzlCount)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //获取满意度题目填报量 |
| | | ServiceSubtaskDetail serviceSubtaskDetail = new ServiceSubtaskDetail(); |
| | | serviceSubtaskDetail.setTaskid(serviceTask.getTaskid()); |
| | | if (serviceTask.getType().equals("1")) serviceSubtaskDetail.setCategoryid(ivrCategoryid); |
| | | if (serviceTask.getType().equals("2")) serviceSubtaskDetail.setCategoryid(svyCategoryid); |
| | | serviceSubtaskDetail.setOrgid(serviceTask.getOrgid()); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetails = serviceSubtaskDetailMapper.selectServiceSubtaskDetailList(serviceSubtaskDetail); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskDetails)) |
| | | mydtblsum.add(new BigDecimal(serviceSubtaskDetails.size())); |
| | | } |
| | | |
| | | |
| | | } |
| | | //满意度题目总量 |
| | | map.put("mydtmzl", mydtmzlsum.intValue()); |
| | | map.put("mydtbl", mydtblsum.intValue()); |
| | | map.put("wcbl", 0.0); |
| | | if (mydtmzlsum.intValue() != 0) { |
| | | map.put("wcbl", mydtblsum.divide(mydtmzlsum, 2, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | private ServiceSubtaskStatistic getStatistic(List<ServiceSubtask> serviceSubtaskList) { |
| | | ServiceSubtaskStatistic serviceSubtaskStatistic = new ServiceSubtaskStatistic(); |
| | |
| | | serviceSubtaskStatistic.setDrname(serviceSubtaskList.get(0).getDrname()); |
| | | //出院人次 |
| | | serviceSubtaskStatistic.setDischargeCount(serviceSubtaskList.size()); |
| | | //记录过滤患者详情 |
| | | List<ServiceSubtask> filterServiceSubtasks = new ArrayList<>(); |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | //无需随访人次 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) { |
| | | serviceSubtaskStatistic.setNonFollowUp(serviceSubtaskStatistic.getNonFollowUp() + 1L); |
| | | if (serviceSubtask.getTaskSituation() !=null && serviceSubtask.getTaskSituation() == 6) { |
| | | serviceSubtaskStatistic.setFilterCount(serviceSubtaskStatistic.getFilterCount() + 1L); |
| | | filterServiceSubtasks.add(serviceSubtask); |
| | | } |
| | | } |
| | | //应随访人次 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | |
| | | if (serviceSubtask.getTaskSituation() != null && serviceSubtask.getTaskSituation() == 5) { |
| | | serviceSubtaskStatistic.setTaskSituation5(serviceSubtaskStatistic.getTaskSituation5() + 1); |
| | | } |
| | | if (serviceSubtask.getTaskSituation() != null && serviceSubtask.getTaskSituation() == 6) { |
| | | if (serviceSubtask.getTaskSituation() != null && serviceSubtask.getTaskSituation() == 7) { |
| | | serviceSubtaskStatistic.setTaskSituation6(serviceSubtaskStatistic.getTaskSituation6() + 1); |
| | | } |
| | | } |
| | | |
| | | serviceSubtaskStatistic.setFilterCountList(filterServiceSubtasks); |
| | | |
| | | return serviceSubtaskStatistic; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | return serviceSubtaskStatistic; |
| | | } |
| | |
| | | serviceSubtaskDetail.setAssigntime(System.currentTimeMillis()); |
| | | serviceSubtaskDetail.setStarttime(System.currentTimeMillis()); |
| | | serviceSubtaskDetail.setAnswertime(System.currentTimeMillis()); |
| | | serviceSubtaskDetail.setCategoryid(ivrTaskTemplateScriptVO.getAssortid()); |
| | | serviceSubtaskDetail.setAsrtext("无应答"); |
| | | if (StringUtils.isNotEmpty(phoneCallReqYQVO.getAsrtext())) |
| | | serviceSubtaskDetail.setAsrtext(phoneCallReqYQVO.getAsrtext()); |
| | |
| | | LocalTime currentTime = LocalTime.now(); |
| | | // 目标时间(晚上 8 点) |
| | | LocalTime targetTime = LocalTime.of(phoneEndHour, 0); |
| | | // 计算当前时间到目标时间的时长 |
| | | Duration duration = Duration.between(currentTime, targetTime); |
| | | // 获取剩余时间的小时数 |
| | | long remainingHours = 0; |
| | | long remainingMinutes = duration.toMinutes(); |
| | | //如果超过8点,就设置为0 |
| | | //距离结束时间小于20分钟,就不拉取了 |
| | | if (remainingMinutes < 20) remainingHours = 0; |
| | | else if (remainingMinutes < 60 && remainingMinutes > 20) remainingHours = 1; |
| | | else if (remainingMinutes > 60) remainingHours = remainingMinutes / 60; |
| | | // 计算剩余可以打的电话数 |
| | | int remainingCalls = (int) (remainingHours * phoneUpEveryHour); |
| | | return remainingCalls; |
| | | // // 计算当前时间到目标时间的时长 |
| | | // Duration duration = Duration.between(currentTime, targetTime); |
| | | // // 获取剩余时间的小时数 |
| | | // long remainingHours = 0; |
| | | // long remainingMinutes = duration.toMinutes(); |
| | | // //如果超过8点,就设置为0 |
| | | // //距离结束时间小于20分钟,就不拉取了 |
| | | // if (remainingMinutes < 20) remainingHours = 0; |
| | | // else if (remainingMinutes < 60 && remainingMinutes > 20) remainingHours = 1; |
| | | // else if (remainingMinutes > 60) remainingHours = remainingMinutes / 60; |
| | | // // 计算剩余可以打的电话数 |
| | | // int remainingCalls = (int) (remainingHours * phoneUpEveryHour); |
| | | // return remainingCalls; |
| | | if (currentTime.isBefore(targetTime)) { |
| | | //如果当前时间还在截止时间内,则继续发 |
| | | return phoneUpEveryHour; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public List<ServiceSubtaskCount> getSfStatisticsJoydetails(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | |
| | | } |
| | | return visitTime; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 计算总计行 |
| | | * @param statistics 统计数据列表 |
| | | * @return 总计行数据 |
| | | */ |
| | | private ServiceSubtaskStatistic calculateTotalRow(List<ServiceSubtaskStatistic> statistics) { |
| | | ServiceSubtaskStatistic total = new ServiceSubtaskStatistic(); |
| | | |
| | | // 初始化数值字段 |
| | | total.setDischargeCount(0); |
| | | total.setNonFollowUp(0L); |
| | | total.setFilterCount(0L); |
| | | total.setFollowUpNeeded(0L); |
| | | total.setNeedFollowUp(0L); |
| | | total.setPendingFollowUp(0L); |
| | | total.setFollowUpSuccess(0L); |
| | | total.setFollowUpFail(0L); |
| | | total.setManual(0L); |
| | | total.setSms(0L); |
| | | total.setWeChat(0L); |
| | | total.setAbnormal(0L); |
| | | total.setNeedFollowUpAgain(0L); |
| | | total.setPendingFollowUpAgain(0L); |
| | | total.setFollowUpSuccessAgain(0L); |
| | | total.setFollowUpFailAgain(0L); |
| | | total.setManualAgain(0L); |
| | | total.setSmsAgain(0L); |
| | | total.setWeChatAgain(0L); |
| | | total.setAbnormalAgain(0L); |
| | | total.setTaskSituation1(0); |
| | | total.setTaskSituation2(0); |
| | | total.setTaskSituation3(0); |
| | | total.setTaskSituation4(0); |
| | | total.setTaskSituation5(0); |
| | | total.setTaskSituation6(0); |
| | | |
| | | // 累加各个字段的值 |
| | | for (ServiceSubtaskStatistic stat : statistics) { |
| | | if (stat.getDischargeCount() != null) { |
| | | total.setDischargeCount(total.getDischargeCount() + stat.getDischargeCount()); |
| | | } |
| | | total.setNonFollowUp(total.getNonFollowUp() + (stat.getNonFollowUp() != null ? stat.getNonFollowUp() : 0L)); |
| | | total.setFilterCount(total.getFilterCount() + (stat.getFilterCount() != null ? stat.getFilterCount() : 0L)); |
| | | total.setFollowUpNeeded(total.getFollowUpNeeded() + (stat.getFollowUpNeeded() != null ? stat.getFollowUpNeeded() : 0L)); |
| | | total.setNeedFollowUp(total.getNeedFollowUp() + (stat.getNeedFollowUp() != null ? stat.getNeedFollowUp() : 0L)); |
| | | total.setPendingFollowUp(total.getPendingFollowUp() + (stat.getPendingFollowUp() != null ? stat.getPendingFollowUp() : 0L)); |
| | | total.setFollowUpSuccess(total.getFollowUpSuccess() + (stat.getFollowUpSuccess() != null ? stat.getFollowUpSuccess() : 0L)); |
| | | total.setFollowUpFail(total.getFollowUpFail() + (stat.getFollowUpFail() != null ? stat.getFollowUpFail() : 0L)); |
| | | total.setManual(total.getManual() + (stat.getManual() != null ? stat.getManual() : 0L)); |
| | | total.setSms(total.getSms() + (stat.getSms() != null ? stat.getSms() : 0L)); |
| | | total.setWeChat(total.getWeChat() + (stat.getWeChat() != null ? stat.getWeChat() : 0L)); |
| | | total.setAbnormal(total.getAbnormal() + (stat.getAbnormal() != null ? stat.getAbnormal() : 0L)); |
| | | total.setNeedFollowUpAgain(total.getNeedFollowUpAgain() + (stat.getNeedFollowUpAgain() != null ? stat.getNeedFollowUpAgain() : 0L)); |
| | | total.setPendingFollowUpAgain(total.getPendingFollowUpAgain() + (stat.getPendingFollowUpAgain() != null ? stat.getPendingFollowUpAgain() : 0L)); |
| | | total.setFollowUpSuccessAgain(total.getFollowUpSuccessAgain() + (stat.getFollowUpSuccessAgain() != null ? stat.getFollowUpSuccessAgain() : 0L)); |
| | | total.setFollowUpFailAgain(total.getFollowUpFailAgain() + (stat.getFollowUpFailAgain() != null ? stat.getFollowUpFailAgain() : 0L)); |
| | | total.setManualAgain(total.getManualAgain() + (stat.getManualAgain() != null ? stat.getManualAgain() : 0L)); |
| | | total.setSmsAgain(total.getSmsAgain() + (stat.getSmsAgain() != null ? stat.getSmsAgain() : 0L)); |
| | | total.setWeChatAgain(total.getWeChatAgain() + (stat.getWeChatAgain() != null ? stat.getWeChatAgain() : 0L)); |
| | | total.setAbnormalAgain(total.getAbnormalAgain() + (stat.getAbnormalAgain() != null ? stat.getAbnormalAgain() : 0L)); |
| | | total.setTaskSituation1(total.getTaskSituation1() + (stat.getTaskSituation1() != null ? stat.getTaskSituation1() : 0)); |
| | | total.setTaskSituation2(total.getTaskSituation2() + (stat.getTaskSituation2() != null ? stat.getTaskSituation2() : 0)); |
| | | total.setTaskSituation3(total.getTaskSituation3() + (stat.getTaskSituation3() != null ? stat.getTaskSituation3() : 0)); |
| | | total.setTaskSituation4(total.getTaskSituation4() + (stat.getTaskSituation4() != null ? stat.getTaskSituation4() : 0)); |
| | | total.setTaskSituation5(total.getTaskSituation5() + (stat.getTaskSituation5() != null ? stat.getTaskSituation5() : 0)); |
| | | total.setTaskSituation6(total.getTaskSituation6() + (stat.getTaskSituation6() != null ? stat.getTaskSituation6() : 0)); |
| | | } |
| | | |
| | | // 计算总计行的比率字段 |
| | | DecimalFormat percentFormat = new DecimalFormat("##.##%"); |
| | | if (total.getNeedFollowUp() > 0) { |
| | | double rate = (double) (total.getFollowUpSuccess() + total.getFollowUpFail()) / total.getNeedFollowUp(); |
| | | total.setFollowUpRate(percentFormat.format(rate)); |
| | | } else { |
| | | total.setFollowUpRate("0.00%"); |
| | | } |
| | | |
| | | if (total.getNeedFollowUpAgain() > 0) { |
| | | double rateAgain = (double) (total.getFollowUpSuccessAgain() + total.getFollowUpFailAgain()) / total.getNeedFollowUpAgain(); |
| | | total.setFollowUpRateAgain(percentFormat.format(rateAgain)); |
| | | } else { |
| | | total.setFollowUpRateAgain("0.00%"); |
| | | } |
| | | |
| | | return total; |
| | | } |
| | | } |