| | |
| | | } else if (heLibrary.getHetype().equals("2")) { |
| | | //通知 |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setContent(heLibrary.getPreachcontent()); |
| | | // 替换文本内容中的变量 |
| | | String content = getObject(serviceSubtask, heLibrary.getPreachcontent()); |
| | | sendMagParam.setContent(content); |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |