| | |
| | | } else if (heLibrary.getHetype().equals("2")) { |
| | | //通知 |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setContent(heLibrary.getPreachcontent()); |
| | | // 替换文本内容中的变量 |
| | | String content = getObject(serviceSubtask, heLibrary.getPreachcontent()); |
| | | sendMagParam.setContent(content); |
| | | } |
| | | |
| | | } |
| | |
| | | Optional<Long> currentSort = serviceSubtaskPreachforms.stream().filter(item -> serviceSubtask.getCurrentPreachform().equals(item.getPreachform())).map(ServiceSubtaskPreachform::getSort).findFirst(); |
| | | |
| | | if (currentSort.isPresent()) { |
| | | //微信已发送、已领取视为发送成功,不再进行补偿 -丽水中医院 |
| | | if(active.equals("47231022633110211A2101")){ |
| | | //获取当前发送方式 |
| | | ServiceSubtaskPreachform currentServiceSubtaskPreachform = serviceSubtaskPreachforms.stream().filter(item -> item.getSort().equals(currentSort.get())).findFirst().orElse(new ServiceSubtaskPreachform()); |
| | | if(currentServiceSubtaskPreachform.getPreachform().equals("5") |
| | | && (currentServiceSubtaskPreachform.getSendstate().equals("2") |
| | | || currentServiceSubtaskPreachform.getSendstate().equals("3"))){ |
| | | return "-1"; |
| | | } |
| | | } |
| | | |
| | | // 检查是否所有sendstate不等于9 |
| | | boolean allSendStateNot1AndNot9 = serviceSubtaskPreachforms.stream().allMatch(item -> !item.getSendstate().equals("9")); |
| | | if (!allSendStateNot1AndNot9) { |
| | |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 通配符变量替换 |
| | | * |
| | | * @param serviceSubtask |
| | | * @param scriptContent |
| | | * @return |
| | | */ |
| | | private String getObject(ServiceSubtask serviceSubtask, String scriptContent) { |
| | | Map<String, Map<String, String>> param = getParam(serviceSubtask.getTaskid()); |
| | | for (Map<String, String> map : param.values()) { |
| | | for (String key : map.keySet()) { |
| | | scriptContent = scriptContent.replace(key, StringUtils.isNotEmpty(map.get(key)) ? map.get(key) : ""); |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(scriptContent)) { |
| | | return scriptContent; |
| | | } |
| | | scriptContent = scriptContent.replace("${name}", StringUtils.isNotEmpty(serviceSubtask.getSendname()) ? serviceSubtask.getSendname() : ""); |
| | | scriptContent = scriptContent.replace("${dzz}", StringUtils.isNotEmpty(serviceSubtask.getAddr()) ? serviceSubtask.getAddr() : ""); |
| | | scriptContent = scriptContent.replace("${phone}", StringUtils.isNotEmpty(serviceSubtask.getTelcode()) ? serviceSubtask.getTelcode() : ""); |
| | | |
| | | return scriptContent; |
| | | } |
| | | |
| | | /** |
| | | * 获取任务里的通配符 |
| | | * |
| | | * @param taskId |
| | | * @return |
| | | */ |
| | | private Map<String, Map<String, String>> getParam(Long taskId) { |
| | | ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(taskId); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | Map<String, Map<String, String>> serviceTaskMap = null; |
| | | try { |
| | | serviceTaskMap = objectMapper.readValue(serviceTask.getTextParam(), Map.class); |
| | | } catch (JsonProcessingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return serviceTaskMap; |
| | | } |
| | | |
| | | } |