| | |
| | | import com.smartor.common.SendService; |
| | | import com.smartor.config.RobotPhoneUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.PatArchiveMapper; |
| | | import com.smartor.mapper.ServiceSubtaskMapper; |
| | | import com.smartor.mapper.ServiceTaskMapper; |
| | | import com.smartor.service.IBaseSmsaccountService; |
| | |
| | | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | |
| | | private ServiceTaskMapper ivrTaskMapper; |
| | | |
| | | @Autowired |
| | | private SendService sendService; |
| | | private PatArchiveMapper patArchiveMapper; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | |
| | | |
| | | @Value("${xhsmsPath}") |
| | | private String xhsmsPath; |
| | | |
| | | @Value("${appid}") |
| | | private String appid; |
| | | |
| | | // 创建固定大小的线程池 |
| | | private static final ExecutorService executorService = Executors.newFixedThreadPool(10); |
| | |
| | | try { |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | log.info("链接完整路径:{}", ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | //这个模板ID先写死,后面做成可选 |
| | | sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | Map map = new HashMap(); |
| | | map.put("first", ivrTask1.getTaskName()); |
| | | sendMagParam.setContent(JSON.toJSONString(map)); |
| | | sendMagParam.setOpenid(serviceSubtask.getOpenid()); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | String url = null; |
| | | |
| | | //// if (type == 1) { |
| | | //// url = ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | //// } else if (type == 2) { |
| | | //// url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | //// } else if (type == 3) { |
| | | //// url = ip + ":" + req_path + "/outsideChainxj?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | //// } |
| | | // if (type == 1) { |
| | | // //随访 |
| | | // ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | // serviceOutPath.setParam1(taskId); |
| | | // serviceOutPath.setParam2(patid); |
| | | // serviceOutPath.setCreateTime(new Date()); |
| | | // iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // String format = String.format("%03X", serviceOutPath.getId()); |
| | | // serviceOutPath.setRadix(format); |
| | | // serviceOutPath.setUpdateTime(new Date()); |
| | | // iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | //// sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | // url = ip + ":" + req_path + "/sf?p=" + format; |
| | | // } else if (type == 2) { |
| | | // //问券 |
| | | // ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | // serviceOutPath.setParam1(taskId); |
| | | // serviceOutPath.setParam2(patid); |
| | | //// serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | // serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | // serviceOutPath.setCreateTime(new Date()); |
| | | // iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // String format = String.format("%03X", serviceOutPath.getId()); |
| | | // serviceOutPath.setRadix(format); |
| | | // serviceOutPath.setUpdateTime(new Date()); |
| | | // iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | //// sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"); |
| | | // url = ip + ":" + req_path + "/wt?p=" + format; |
| | | // } else if (type == 3) { |
| | | // //宣教 |
| | | // ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | // serviceOutPath.setParam1(taskId); |
| | | // serviceOutPath.setParam2(patid); |
| | | //// serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | // serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | // serviceOutPath.setCreateTime(new Date()); |
| | | // iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // String format = String.format("%03X", serviceOutPath.getId()); |
| | | // serviceOutPath.setRadix(format); |
| | | // serviceOutPath.setUpdateTime(new Date()); |
| | | // iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | // url = ip + ":" + req_path + "/xj?p=" + format; |
| | | // } |
| | | // sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | // log.info("链接完整路径:{}", ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | // //这个模板ID先写死,后面做成可选 |
| | | // sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | // Map map = new HashMap(); |
| | | // map.put("first", ivrTask1.getTaskName()); |
| | | // sendMagParam.setContent(JSON.toJSONString(map)); |
| | | // sendMagParam.setOpenid(serviceSubtask.getOpenid()); |
| | | // Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | // |
| | | // String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), "无"); |
| | | // Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class); |
| | | // if (!map.isEmpty()) { |
| | | serviceSubtask.setResult("success"); |
| | | serviceSubtask.setSendstate(3L); |
| | | if (aBoolean == false) { |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | | serviceSubtaskRecord.setSubtaskId(serviceSubtask.getId()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); |
| | | serviceSubtaskRecord.setPreachform("5"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setRemark(map.get("msg").toString()); |
| | | lssubIds.add(serviceSubtask.getId()); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | continue; |
| | | } |
| | | |
| | | // if (type == 1) { |
| | | // url = ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | // } else if (type == 2) { |
| | | // url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | // } else if (type == 3) { |
| | | // url = ip + ":" + req_path + "/outsideChainxj?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | // } |
| | | String url = null; |
| | | Boolean aBoolean = false; |
| | | if (type == 1) { |
| | | //随访 |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | url = ip + ":" + req_path + "/sf?p=" + format; |
| | | } else if (type == 2) { |
| | | //问券 |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | // serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | url = ip + ":" + req_path + "/wt?p=" + format; |
| | | } else if (type == 3) { |
| | | //宣教 |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | url = ip + ":" + req_path + "/xj?p=" + format; |
| | | } |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(serviceSubtask.getPatid()); |
| | | String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), null,null,patArchive.getPatientno()); |
| | | Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class); |
| | | if (!map.isEmpty()) { |
| | | serviceSubtask.setResult("success"); |
| | | serviceSubtask.setSendstate(3L); |
| | | if (aBoolean == false) { |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | | serviceSubtaskRecord.setSubtaskId(serviceSubtask.getId()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); |
| | | serviceSubtaskRecord.setPreachform("5"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setRemark(map.get("msg").toString()); |
| | | lssubIds.add(serviceSubtask.getId()); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | continue; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | |
| | | return key; |
| | | } |
| | | |
| | | private String getWXCode(String idcard, String url, String taskName, String taskDesc, String submitprompt) { |
| | | private String getWXCode(String idcard, String url, String taskName, String taskDesc, String Medcardno, String setPatientname, String setPatientid) { |
| | | XinHuaWXReq xinHuaWXReq = new XinHuaWXReq(); |
| | | xinHuaWXReq.setIdcard(idcard); |
| | | xinHuaWXReq.setUrl(url); |
| | | xinHuaWXReq.setKeyword1("浙中医大二院出院随访"); |
| | | xinHuaWXReq.setKeyword2(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | xinHuaWXReq.setKeyword3(taskName); |
| | | xinHuaWXReq.setKeyword4("疾病康复注意事项"); |
| | | xinHuaWXReq.setPatientid(setPatientid); |
| | | xinHuaWXReq.setPatientname(setPatientname); |
| | | xinHuaWXReq.setMobile(taskName); |
| | | xinHuaWXReq.setMedcardno(Medcardno); |
| | | xinHuaWXReq.setTitlename(taskName); |
| | | xinHuaWXReq.setContent(taskDesc); |
| | | xinHuaWXReq.setAppid(appid); |
| | | |
| | | String result = HttpUtils.sendPost(thirdWXUrl, new Gson().toJson(xinHuaWXReq)); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |