| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.core.service.IConfigService; |
| | | import com.ruoyi.common.dx.MessageSend; |
| | | import com.ruoyi.common.enums.WxGZHEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.common.utils.sms.smsUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.MessageDigest; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.hutool.core.convert.Convert.toHex; |
| | | |
| | | /** |
| | | * 单一任务(随访)Service业务层处理 |
| | |
| | | String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key); |
| | | String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key); |
| | | |
| | | //丽水中医院发送的是微信公众号 |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getOrgid()) && serviceSubtask.getOrgid().equals("47231022633110211A2101")) { |
| | | resultMap = wechatSubTask(subid); |
| | | return resultMap; |
| | | } |
| | | |
| | | //发送数据的封装 |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | |
| | | return resultMap; |
| | | } |
| | | |
| | | public Map<String,Object> wechatSubTask(Long subid){ |
| | | log.info("wechatSubTask的入参为:{}", subid); |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | resultMap.put("code", "500"); |
| | | resultMap.put("msg", "发送失败"); |
| | | try{ |
| | | //获取随访的基本信息 |
| | | ServiceSubtask serviceSubtask = selectServiceSubtaskById(subid); |
| | | //获取患者信息 |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(serviceSubtask.getPatid()); |
| | | |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key); |
| | | String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key); |
| | | String url = localIP + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" |
| | | + URLEncoder.encode(serviceSubtask.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false" |
| | | + "$param6=" + subId; |
| | | |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setParam3(serviceSubtask.getTaskName()); |
| | | serviceOutPath.setParam6(subId); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(url); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | |
| | | |
| | | //获取微信公众号请求信息根据机构ID |
| | | List<String> wxqqxx = WxGZHEnum.getDescByCode(serviceSubtask.getOrgid()); |
| | | if (CollectionUtils.isEmpty(wxqqxx) || wxqqxx.size() < 4) { |
| | | resultMap.put("code", -1); |
| | | resultMap.put("message", "发送异常:" + "【公众号】该机构的公众号配置信息不全,无法通过公众号发送"); |
| | | return resultMap; |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(serviceSubtask.getPatidHis())) { |
| | | resultMap.put("code", -1); |
| | | resultMap.put("message", "发送异常:" + "【公众号】公众号发送失败,his系统的患者id为空"); |
| | | return resultMap; |
| | | } |
| | | String wxCode = ""; |
| | | wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), patArchive.getTelcode(), serviceSubtask.getSendname(), patArchive.getPatidHis(), wxqqxx); |
| | | Map map = JSONObject.parseObject(wxCode, Map.class); |
| | | Boolean wxCodeSuccess = false; |
| | | if (!map.isEmpty() && map.get("succ") != null) { |
| | | wxCodeSuccess = (boolean) map.get("succ"); |
| | | } |
| | | |
| | | //发送完成后,修改状态 |
| | | serviceSubtask.setSendstate(3L); |
| | | if (wxCodeSuccess) { |
| | | serviceSubtask.setResult("success"); |
| | | resultMap.put("code", "200"); |
| | | resultMap.put("msg", "发送成功"); |
| | | } else { |
| | | log.error("【sfHandlle】公众号发送失败,患者信息:{},错误信息:{}", serviceSubtask, map.get("msg")); |
| | | resultMap.put("code", -1); |
| | | resultMap.put("message", "【公众号】公众号发送失败"); |
| | | return resultMap; |
| | | } |
| | | } catch (Exception e) { |
| | | String guid = UUID.randomUUID().toString(); |
| | | log.error("【sfHandlle】长期任务公众号发送失败,原因:{},GUID:{}", e.getMessage(), guid); |
| | | resultMap.put("code", -1); |
| | | resultMap.put("message", "【公众号】长期任务公众号发送失败,原因:" + e.getMessage()); |
| | | return resultMap; |
| | | } |
| | | return resultMap; |
| | | } |
| | | @Override |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startFinishTime, Date endFinishTime, Date startOutHospTime, Date endOutHospTime, String scriptContent, Double scoreStart, Double scoreEnd, String valueType) { |
| | | //先清理一下重复数据 |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private String getWXCode(String idcard, String url, String taskName, String taskDesc, String phone, String setPatientname, String setPatientid, List<String> wxqqxx) { |
| | | XinHuaWXReq xinHuaWXReq = new XinHuaWXReq(); |
| | | xinHuaWXReq.setIdcard(idcard); |
| | | xinHuaWXReq.setUrl(url); |
| | | xinHuaWXReq.setPatientid(setPatientid); |
| | | xinHuaWXReq.setPatientname(setPatientname); |
| | | xinHuaWXReq.setMobile(phone); |
| | | xinHuaWXReq.setMedcardno(null); |
| | | xinHuaWXReq.setTitlename(taskName); |
| | | xinHuaWXReq.setContent(taskDesc); |
| | | xinHuaWXReq.setAppid(wxqqxx.get(1)); |
| | | log.info("【getWXCode】微信公众号请求参数:{}", xinHuaWXReq); |
| | | String body = new Gson().toJson(xinHuaWXReq); |
| | | String encode = encode(wxqqxx.get(2).concat(body)); |
| | | Map<String, String> headerMap = new HashMap<>(); |
| | | headerMap.put("sign", encode); |
| | | String result = HttpUtils.sendPostByHeader(wxqqxx.get(3), body, headerMap); |
| | | log.info("【getWXCode】微信公众号返回参数:{}", result); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | String code = (String) jsonObject.toString(); |
| | | return code; |
| | | } |
| | | public String encode(String arg) { |
| | | if (arg == null) { |
| | | arg = ""; |
| | | } |
| | | MessageDigest md5 = null; |
| | | try { |
| | | md5 = MessageDigest.getInstance("MD5"); |
| | | md5.update(arg.getBytes("UTF-8")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return toHex(md5.digest()); |
| | | } |
| | | } |