| | |
| | | |
| | | @Override |
| | | public Integer saveQuestionAnswer(ServiceSubTaskAnswerReq serviceSubTaskAnswerReq, Long flag) { |
| | | //参数解密 |
| | | Long tid = null; |
| | | Long pid = null; |
| | | Long subid = null; |
| | | Double score = null; |
| | | Long isabno = 0L; |
| | | Set<String> allKeys = redisCache.getAllKeys(); |
| | | if (ObjectUtils.isNotEmpty(serviceSubTaskAnswerReq)) { |
| | | //需要立即执行 |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | |
| | | if (flag == 0) { |
| | |
| | | pid = Long.valueOf(serviceSubTaskAnswerReq.getParam2()); |
| | | subid = Long.valueOf(serviceSubTaskAnswerReq.getParam6()); |
| | | } |
| | | if (serviceSubTaskAnswerReq.getType() != null && serviceSubTaskAnswerReq.getType() == 2) { |
| | | allKeys = new HashSet<>(); |
| | | allKeys.add(pid + "-" + tid + "-" + subid + "-WJscriptCache"); |
| | | } else if (serviceSubTaskAnswerReq.getType() != null && serviceSubTaskAnswerReq.getType() == 1) { |
| | | allKeys = new HashSet<>(); |
| | | allKeys.add(pid + "-" + tid + "-" + subid + "-SFscriptCache"); |
| | | } |
| | | |
| | | //根据 PID、TID、SUBID 构建需要处理的 cache key |
| | | String scriptCacheKeyPrefix = pid + "-" + tid + "-" + subid; |
| | | Set<String> targetKeys = new HashSet<>(); |
| | | |
| | | if (serviceSubTaskAnswerReq != null && serviceSubTaskAnswerReq.getType() != null) { |
| | | if (serviceSubTaskAnswerReq.getType() == 2) { |
| | | targetKeys.add(scriptCacheKeyPrefix + "-WJscriptCache"); |
| | | } else if (serviceSubTaskAnswerReq.getType() == 1) { |
| | | targetKeys.add(scriptCacheKeyPrefix + "-SFscriptCache"); |
| | | } |
| | | } else { |
| | | //如果没有 type,则遍历所有 key(保留原有兼容性) |
| | | Set<String> allKeys = redisCache.getAllKeys(); |
| | | for (String key : allKeys) { |
| | | try { |
| | | if (key.contains(scriptCacheKeyPrefix) && (key.endsWith("-WJscriptCache") || key.endsWith("-SFscriptCache"))) { |
| | | targetKeys.add(key); |
| | | } |
| | | } catch (Exception e) { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //用于批量更新的子任务列表(避免在循环中重复查询) |
| | | Map<String, ServiceSubtask> subtaskCache = new HashMap<>(); |
| | | String subtaskCacheKey = subid != null ? subid.toString() : pid + "-" + tid; |
| | | |
| | | //先查询一次子任务信息 |
| | | ServiceSubtaskEntity ssVO = new ServiceSubtaskEntity(); |
| | | if (subid != null) { |
| | | ssVO.setSubId(subid); |
| | | } else { |
| | | ssVO.setTaskid(tid); |
| | | ssVO.setPatid(pid); |
| | | } |
| | | List<ServiceSubtask> initialSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(ssVO); |
| | | if (CollectionUtils.isNotEmpty(initialSubtaskList)) { |
| | | subtaskCache.put(subtaskCacheKey, initialSubtaskList.get(0)); |
| | | } |
| | | |
| | | String score = "0"; |
| | | Long nextScriptno = null; |
| | | aa: |
| | | for (String key : allKeys) { |
| | | for (String key : targetKeys) { |
| | | String[] split = key.split("-"); |
| | | //先判断,是不是当前提交人的,不是当前提交人的,跳过 |
| | | try { |
| | |
| | | if (map == null) continue aa; |
| | | if (!Objects.isNull(map.get("nextScriptNo"))) |
| | | nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | if (score == null) { |
| | | score = Double.valueOf(map.get("score")); |
| | | if (score == null || score.isEmpty()) { |
| | | score = map.get("score"); |
| | | } else { |
| | | score = score + Double.valueOf(map.get("score")); |
| | | score = String.valueOf(Double.parseDouble(score) + Double.parseDouble(map.get("score"))); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (!Objects.isNull(map.get("nextScriptNo"))) |
| | | nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | if (score == null) { |
| | | score = Double.valueOf(map.get("score")); |
| | | score = map.get("score"); |
| | | } else { |
| | | score = score + Double.valueOf(map.get("score")); |
| | | score = String.valueOf(Double.parseDouble(score) + Double.parseDouble(map.get("score"))); |
| | | } |
| | | } |
| | | } |
| | |
| | | Map<String, String> map = setSFInfo(ivrTaskTemplateScriptVO, tid, pid, subid); |
| | | if (!Objects.isNull(map.get("nextScriptNo"))) |
| | | nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | if (score == null) { |
| | | score = Double.valueOf(map.get("score")); |
| | | if (score == null || score.isEmpty()) { |
| | | score = map.get("score"); |
| | | } else { |
| | | score = score + Double.valueOf(map.get("score")); |
| | | score = String.valueOf(Double.parseDouble(score) + Double.parseDouble(map.get("score"))); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (!Objects.isNull(map.get("nextScriptNo"))) |
| | | nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | if (score == null) { |
| | | score = Double.valueOf(map.get("score")); |
| | | score = map.get("score"); |
| | | } else { |
| | | score = score + Double.valueOf(map.get("score")); |
| | | score = String.valueOf(Double.parseDouble(score) + Double.parseDouble(map.get("score"))); |
| | | } |
| | | } |
| | | } |
| | |
| | | //将该key和value从redis中,删除 |
| | | redisCache.deleteObject(key); |
| | | |
| | | //查询出该任务中正在执行的患者信息 |
| | | ServiceSubtaskEntity ssVO = new ServiceSubtaskEntity(); |
| | | ssVO.setTaskid(tid); |
| | | ssVO.setPatid(pid); |
| | | // ssVO.setSendstate(3L); |
| | | List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(ssVO); |
| | | //查询出该任务中正在执行的患者信息(使用缓存) |
| | | String currentSubtaskKey = subid != null ? subid.toString() : pid + "-" + tid; |
| | | ServiceSubtask serviceSubtask; |
| | | |
| | | ServiceSubtask serviceSubtask = new ServiceSubtask(); |
| | | serviceSubtask.setTaskid(tid); |
| | | serviceSubtask.setPatid(pid); |
| | | serviceSubtask.setSubmit(1L); |
| | | if (!subtaskCache.containsKey(currentSubtaskKey)) { |
| | | ServiceSubtaskEntity serviceSubtaskEntity = new ServiceSubtaskEntity(); |
| | | if (subid != null) { |
| | | serviceSubtaskEntity.setSubId(subid); |
| | | } else { |
| | | serviceSubtaskEntity.setTaskid(tid); |
| | | serviceSubtaskEntity.setPatid(pid); |
| | | } |
| | | // ssVO.setSendstate(3L); |
| | | List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskEntity); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { |
| | | serviceSubtask = serviceSubtaskList.get(0); |
| | | subtaskCache.put(currentSubtaskKey, serviceSubtask); |
| | | } else { |
| | | continue; |
| | | } |
| | | } else { |
| | | serviceSubtask = subtaskCache.get(currentSubtaskKey); |
| | | } |
| | | |
| | | serviceSubtask.setIsabnormal(serviceSubTaskAnswerReq.getIsabnormal()); |
| | | serviceSubtask.setSendstate(6L); |
| | | serviceSubtask.setExcep(serviceSubTaskAnswerReq.getExcep()); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtask.setUpdateTime(new Date()); |
| | | log.error("将该key和value从redis中,serviceSubtask的值为--------:{}", serviceSubtask); |
| | | if (score != null) serviceSubtask.setScore(BigDecimal.valueOf(score)); |
| | | if (score != null && !score.isEmpty()) serviceSubtask.setScore(score); |
| | | serviceSubtaskMapper.updateServiceSubtaskByCondition(serviceSubtask); |
| | | //修改住院满意度状态(避免重复查询) |
| | | if (serviceSubtask.getServiceType() != null && "6".equals(serviceSubtask.getServiceType())) { |
| | | Long inhospid = serviceSubtask.getInhospid(); |
| | | if (inhospid != null) { |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setInhospMydFlag("1"); |
| | | patMedInhosp.setInhospid(inhospid); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp); |
| | | } |
| | | } |
| | | |
| | | //将当前发送状态改成9完成 |
| | | //将当前发送状态改成 9 完成(缓存 preachform 查询) |
| | | String currentPreachform = serviceSubtask.getCurrentPreachform(); |
| | | if (StringUtils.isNotEmpty(currentPreachform)) { |
| | | ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform(); |
| | | serviceSubtaskPreachform.setPreachform(serviceSubtaskList.get(0).getCurrentPreachform()); |
| | | serviceSubtaskPreachform.setSubid(serviceSubtask.getId()); |
| | | serviceSubtaskPreachform.setTaskid(serviceSubtask.getTaskid()); |
| | | serviceSubtaskPreachform.setPreachform(currentPreachform); |
| | | if (subid != null) { |
| | | serviceSubtaskPreachform.setSubid(subid); |
| | | } else { |
| | | Long id = serviceSubtask.getId(); |
| | | Long tid_ = serviceSubtask.getTaskid(); |
| | | if (id != null) { |
| | | serviceSubtaskPreachform.setSubid(id); |
| | | } else if (tid_ != null) { |
| | | serviceSubtaskPreachform.setTaskid(tid_); |
| | | } |
| | | } |
| | | List<ServiceSubtaskPreachform> serviceSubtaskPreachforms = serviceSubtaskPreachformMapper.selectServiceSubtaskPreachformList(serviceSubtaskPreachform); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskPreachforms)) { |
| | | ServiceSubtaskPreachform ssp = serviceSubtaskPreachforms.get(0); |
| | | ssp.setSendstate("9"); |
| | | serviceSubtaskPreachformMapper.updateServiceSubtaskPreachform(ssp); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | Long tid = Long.valueOf(serviceSubTaskCacheReq.getParam1()); |
| | | Long pid = Long.valueOf(serviceSubTaskCacheReq.getParam2()); |
| | | Long subid = Long.valueOf(serviceSubTaskCacheReq.getParam6()); |
| | | Double score = null; |
| | | String score = "0"; |
| | | if (ObjectUtils.isNotEmpty(serviceSubTaskCacheReq)) { |
| | | Long nextScriptno = null; |
| | | String isabnormalFlag = "0"; |
| | |
| | | nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | |
| | | if (score == null) { |
| | | score = Double.valueOf(map.get("score")); |
| | | score = map.get("score"); |
| | | } else { |
| | | score = score + Double.valueOf(map.get("score")); |
| | | score = String.valueOf(Double.parseDouble(score) + Double.parseDouble(map.get("score"))); |
| | | } |
| | | isabnormalFlag = map.get("isabnormal"); |
| | | } |
| | |
| | | if (!Objects.isNull(map.get("nextScriptNo"))) |
| | | nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | if (score == null) { |
| | | score = Double.valueOf(map.get("score")); |
| | | score = map.get("score"); |
| | | } else { |
| | | score = score + Double.valueOf(map.get("score")); |
| | | score = String.valueOf(Double.parseDouble(score) + Double.parseDouble(map.get("score"))); |
| | | } |
| | | isabnormalFlag = map.get("isabnormal"); |
| | | } |
| | |
| | | serviceSubtask.setExcep(isabnormalFlag); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtask.setUpdateTime(new Date()); |
| | | if (score != null) serviceSubtask.setScore(BigDecimal.valueOf(score)); |
| | | if (score != null && !score.isEmpty()) serviceSubtask.setScore(score); |
| | | serviceSubtaskMapper.updateServiceSubtaskByCondition(serviceSubtask); |
| | | |
| | | //将当前发送状态改成9完成 |
| | |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(serviceSubTaskMYDAnswerReq.getSvyTaskTemplateScriptVOS())) { |
| | | Double score = null; |
| | | String score = "0"; |
| | | List<SvyTaskTemplateScriptVO> svyTaskTemplateScriptVOS = serviceSubTaskMYDAnswerReq.getSvyTaskTemplateScriptVOS(); |
| | | Long nextScriptno = null; |
| | | |
| | |
| | | if (map == null) continue; |
| | | |
| | | log.error("nextScriptNo 的信息为:{}", map.get("nextScriptNo")); |
| | | if (!Objects.isNull(map.get("nextScriptNo"))) |
| | | nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | if (!Objects.isNull(map.get("nextScriptNo"))) nextScriptno = Long.valueOf(map.get("nextScriptNo")); |
| | | |
| | | if (score == null) { |
| | | score = Double.valueOf(map.get("score")); |
| | | if (score == null || score.isEmpty()) { |
| | | score = map.get("score"); |
| | | } else { |
| | | score = score + Double.valueOf(map.get("score")); |
| | | score = String.valueOf(Double.parseDouble(score) + Double.parseDouble(map.get("score"))); |
| | | } |
| | | |
| | | if (!Objects.isNull(map.get("id"))) { |
| | |
| | | serviceSubtask.setUpdateTime(new Date()); |
| | | serviceSubtask.setCreateTime(new Date()); |
| | | serviceSubtask.setVisitTime(new Date()); |
| | | if (score != null) serviceSubtask.setScore(BigDecimal.valueOf(score)); |
| | | if (score != null && !score.isEmpty()) serviceSubtask.setScore(score); |
| | | serviceSubtaskMapper.insertServiceSubtask(serviceSubtask); |
| | | //将当前发送状态改成9完成 |
| | | ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform(); |
| | |
| | | //获取一下问题选项 |
| | | SvyTaskTemplateTargetoption stt = null; |
| | | Long isabnormalFlag = 0L; |
| | | String scriptResultRaw = svyTaskTemplateScriptVO.getScriptResult(); |
| | | //去除中文双引号和英文双引号以及空白字符 |
| | | String scriptResult = scriptResultRaw != null ? scriptResultRaw.replaceAll("^[\"\"]|[\"\"]$", "").trim() : null; |
| | | for (SvyTaskTemplateTargetoption svyTaskTemplateTargetoption : svyTaskTemplateScriptVO.getSvyTaskTemplateTargetoptions()) { |
| | | if (StringUtils.isNotEmpty(svyTaskTemplateTargetoption.getOptioncontent()) && svyTaskTemplateTargetoption.getOptioncontent().trim().equals(svyTaskTemplateScriptVO.getScriptResult())) |
| | | String optionContent = svyTaskTemplateTargetoption.getOptioncontent(); |
| | | if (StringUtils.isNotEmpty(optionContent) && StringUtils.isNotEmpty(scriptResult)) { |
| | | //去除两端空白并处理特殊字符进行比较 |
| | | if (optionContent.trim().replaceAll("\\s+", "").equals(scriptResult.replaceAll("\\s+", ""))) { |
| | | stt = svyTaskTemplateTargetoption; |
| | | log.error("找到匹配的选项"); |
| | | break; // 找到匹配项后跳出循环 |
| | | } |
| | | } |
| | | } |
| | | |
| | | //判断一下当前的问题是不是满意度问题,并且dutyDeptCode是否有值,并且选项是不是异常选项,如果全符合,则往满意度问题异常表新增 |
| | | if (StringUtils.isNotEmpty(svyTaskTemplateScriptVO.getDutyDeptCode()) && stt != null && 1 == stt.getIsabnormal()) { |
| | | if (StringUtils.isNotEmpty(svyTaskTemplateScriptVO.getDutyDeptCode()) && stt != null && Long.valueOf(1L).equals(stt.getIsabnormal()) || StringUtils.isNotEmpty(svyTaskTemplateScriptVO.getDutyDeptCode()) && StringUtils.isNotEmpty(svyTaskTemplateScriptVO.getIsMydException())) { |
| | | isabnormalFlag = 1L; |
| | | ServiceSubtaskDetailTrace subtaskDetailTrace = new ServiceSubtaskDetailTrace(); |
| | | subtaskDetailTrace.setDetailId(serviceSubtaskDetail.getId()); |
| | |
| | | subtaskDetailTrace.setTaskid(serviceSubtaskDetailVO.getTaskid()); |
| | | subtaskDetailTrace.setTemplateid(StringUtils.isNotEmpty(serviceSubtaskDetailVO.getTemplateid()) ? Long.valueOf(serviceSubtaskDetailVO.getTemplateid()) : null); |
| | | subtaskDetailTrace.setTemplatequestionnum(svyTaskTemplateScriptVO.getScriptid()); |
| | | subtaskDetailTrace.setSwitchid(stt.getId()); |
| | | subtaskDetailTrace.setSwitchid(stt != null ? stt.getId() : null); |
| | | subtaskDetailTrace.setQuestiontext(svyTaskTemplateScriptVO.getScriptContent()); |
| | | subtaskDetailTrace.setQuestionvoice(null); |
| | | subtaskDetailTrace.setCategoryname(svyTaskTemplateScriptVO.getCategoryName()); |
| | | subtaskDetailTrace.setCategoryid(svyTaskTemplateScriptVO.getCategoryid()); |
| | | //获取所有选项 |
| | | subtaskDetailTrace.setTargetid(stt.getId()); |
| | | subtaskDetailTrace.setTargetid(stt != null ? stt.getId() : null); |
| | | subtaskDetailTrace.setTargetvalue(serviceSubtaskDetailVO.getTargetvalue()); |
| | | subtaskDetailTrace.setMatchedtext(stt.getOptioncontent()); |
| | | subtaskDetailTrace.setMatchedtext(stt != null ? stt.getOptioncontent() : svyTaskTemplateScriptVO.getIsMydException()); |
| | | subtaskDetailTrace.setGuid(svyTaskTemplateScriptVO.getGuid()); |
| | | subtaskDetailTrace.setValueType(serviceSubtaskDetail.getValueType()); |
| | | subtaskDetailTrace.setIsMydException(svyTaskTemplateScriptVO.getIsMydException()); |
| | | subtaskDetailTrace.setTemplateType(2); |
| | | |
| | | SvyLibScriptCategory svyLibScriptCategory = svyLibScriptCategoryMapper.selectSvyLibScriptCategoryById(svyTaskTemplateScriptVO.getCategoryid()); |
| | | subtaskDetailTrace.setType(svyLibScriptCategory != null ? svyLibScriptCategory.getType() : null); |
| | | |
| | | subtaskDetailTrace.setScriptid(svyTaskTemplateScriptVO.getId()); |
| | | subtaskDetailTrace.setAsrtext(stt.getOptioncontent()); |
| | | subtaskDetailTrace.setAsrtext(stt != null ? stt.getOptioncontent() : svyTaskTemplateScriptVO.getIsMydException()); |
| | | subtaskDetailTrace.setRecordpath(null); |
| | | subtaskDetailTrace.setPatid(selectServiceSubtaskList.get(0).getPatid()); |
| | | JSONObject patdescJson1 = new JSONObject(); |
| | |
| | | subtaskDetailTrace.setId(existTraceId); |
| | | traceService.updateServiceSubtaskDetailTtrace(subtaskDetailTrace); |
| | | } else traceService.insertServiceSubtaskDetailTtrace(subtaskDetailTrace); |
| | | } else if (ObjectUtils.isNotEmpty(stt) && stt.getIsabnormal() != 1L) { |
| | | } else if (ObjectUtils.isNotEmpty(stt) && !Long.valueOf(1L).equals(stt.getIsabnormal())) { |
| | | //这里主要是怕医护人员把异常选项改成了非异常的,这里就需要查一下这条数据是不是在满意度异常表,如果在,则要删除 |
| | | Long existTraceId = existingTraceIdMap.get(svyTaskTemplateScriptVO.getId()); |
| | | if (existTraceId != null) { |
| | |
| | | |
| | | |
| | | //判断一下当前的问题是不是满意度问题,并且dutyDeptCode是否有值,并且选项是不是异常选项,如果全符合,则往满意度问题异常表新增 |
| | | if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getDutyDeptCode()) && 1 == stt.getIsabnormal()) { |
| | | if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getDutyDeptCode()) && 1 == stt.getIsabnormal() || StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getDutyDeptCode()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIsMydException())) { |
| | | isabnormalFlag = "1"; |
| | | ServiceSubtaskDetailTrace subtaskDetailTrace = new ServiceSubtaskDetailTrace(); |
| | | subtaskDetailTrace.setDetailId(serviceSubtaskDetail.getId()); |
| | | subtaskDetailTrace.setSubId(serviceSubtaskDetailVO.getSubId()); |
| | | subtaskDetailTrace.setTaskid(serviceSubtaskDetailVO.getTaskid()); |
| | | subtaskDetailTrace.setIsMydException(serviceSubtaskDetailVO.getIsMydException()); |
| | | subtaskDetailTrace.setTemplateid(ivrTaskTemplateScriptVO.getTemplateID() != null ? Long.valueOf(ivrTaskTemplateScriptVO.getTemplateID()) : null); |
| | | subtaskDetailTrace.setTemplatequestionnum(ivrTaskTemplateScriptVO.getSort() == null ? null : Long.valueOf(ivrTaskTemplateScriptVO.getSort())); |
| | | |
| | |
| | | ivrLibaScriptAssort = ivrLibaScriptAssortMapper.selectIvrLibaScriptAssortById(ivrTaskTemplateScriptVO.getScriptAssortid()); |
| | | |
| | | //获取用户选出的选项的ID |
| | | subtaskDetailTrace.setSwitchid(stt.getId()); |
| | | subtaskDetailTrace.setSwitchid(stt != null ? stt.getId() : null); |
| | | subtaskDetailTrace.setQuestiontext(ivrTaskTemplateScriptVO.getScriptContent()); |
| | | subtaskDetailTrace.setQuestionvoice(null); |
| | | subtaskDetailTrace.setCategoryname(StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getScriptAssortname()) ? ivrTaskTemplateScriptVO.getScriptAssortname() : (ivrLibaScriptAssort != null ? ivrLibaScriptAssort.getIndexAssortName() : "")); |