| | |
| | | /** 新增治疗通知单 */ |
| | | @Override |
| | | public void add(TreatSingle treatSingle, List<TreatProject> projectList, VisitOrder visitOrder |
| | | , EmployeeRole employeeRole, Integer smsType, List<TreatSingleSign> signList) { |
| | | , EmployeeRole employeeRole, Integer isMicNotice, List<TreatSingleSign> signList) { |
| | | |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String, Object> values = new HashMap<>(); |
| | |
| | | //处理治疗单签名------------------------------------------------------------------------- |
| | | handleSignData(signList, treatSingle.getId(), false); |
| | | |
| | | //判断状态是如果是待发生短信状态,则发送短信------------------------------------------ |
| | | if (treatSingle.getStatus() == TreatSingleConstants.STATUS_WAIT_SEND_SMS) { |
| | | |
| | | //通过预约id查询到预约信息获取用户手机号 |
| | | values.put("commonId", treatSingle.getCommonId()); |
| | | sqlSentence.setSqlSentence("select u.tel from appointment a left join user u on u.id=a.userId where a.id =#{m.commonId} and u.isDel=0 and a.isDel=0 "); |
| | | Map<String, Object> map = userMapper.selectOneMap(sqlSentence); |
| | | //手机号不为空时 |
| | | if (map.containsKey("tel") && !StringUtils.isEmpty(map.get("tel").toString())) { |
| | | if (PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) { |
| | | map.put("treatSingleId", treatSingle.getId()); |
| | | JSONObject jsonObject = CrmUtil.sendCrmSMS(map, commonService, smsType); |
| | | //发送短信 |
| | | if (jsonObject.getInt("code") == 0) { |
| | | values.put("status", TreatSingleConstants.STATUS_WAIT_CONFIRM); |
| | | values.put("id", treatSingle.getId()); |
| | | sqlSentence.setM(values); |
| | | //判断返回结果发送成功修改状态为:待确认(已发送短信待客户确认) |
| | | sqlSentence.setSqlSentence("status=#{m.status} where id=#{m.id} "); |
| | | int u = treatSingleMapper.updateWhere(sqlSentence); |
| | | if (u < 1) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "状态更新失败"); |
| | | } |
| | | } |
| | | } else { |
| | | JSONObject jsonObject = null; |
| | | //发送短信 |
| | | jsonObject = SendSMSTool.msgSend("测试服假链接" + "https://wxaurl.cn/66666666", map.get("tel").toString(), "", 1); |
| | | |
| | | if (jsonObject == null || !jsonObject.containsKey("code") || jsonObject.getInt("code") != 0) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "发送短信失败"); |
| | | } |
| | | |
| | | values.clear(); |
| | | values.put("status", TreatSingleConstants.STATUS_WAIT_CONFIRM); |
| | | values.put("id", treatSingle.getId()); |
| | | sqlSentence.setM(values); |
| | | //判断返回结果发送成功修改状态为:待确认(已发送短信待客户确认) |
| | | sqlSentence.setSqlSentence("status=#{m.status} where id=#{m.id} "); |
| | | int u = treatSingleMapper.updateWhere(sqlSentence); |
| | | if (u < 1) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "状态更新失败"); |
| | | } |
| | | } |
| | | } else { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "客户手机号为空!"); |
| | | } |
| | | } |
| | | |
| | | //新增治疗单日志 |
| | | StringBuffer logInfo = TreatSingleLogTool.addLogInfo(treatSingle, projectList); |
| | | TreatSingleLogTool.addLog(commonService, TreatSingleConstants.LOG_TYPE_CREATE, treatSingle, employeeRole, logInfo.toString()); |
| | | |
| | | //所有状态下都发送治疗通知单给MIC |
| | | //发送企业微信通知MIC进行分配治疗(正式环境才发) |
| | | if (treatSingle != null && StringUtils.noNull(treatSingle.getCommonId()) && smsType == 0 |
| | | && PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) { |
| | | try{ |
| | | String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
| | | String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
| | | if(StringUtils.isEmpty(mpToken)){ |
| | | throw new TipsException("获取小程序Token异常!"); |
| | | } |
| | | if(StringUtils.isEmpty(corpMpToken)){ |
| | | throw new TipsException("获取企业应用小程序Token异常!"); |
| | | } |
| | | TreatUtil.sendTreatNoticeShopMic(commonService, visitOrder, TreatUtil.NOTICE_TYPE_ADD, "1000050", mpToken, corpMpToken, doctorName, projectNameSb.toString()); |
| | | // TreatUtil.sendTreatNoticeShopMic(visitOrder, customParameter, "add", commonService); |
| | | }catch (Exception e){ |
| | | logger.error("新增治疗单发送企业消息失败:{}", e.getMessage()); |
| | | logger.error(GlobalExceptionHandler.getExceptionInformation(e)); |
| | | } |
| | | } |
| | | |
| | | // //修改治疗通知单之前将被修改的医生、护士、mic发送企业微信通知 |
| | | // if (treatSingle != null && StringUtils.noNull(treatSingle.getCommonId()) && smsType == 1) { |
| | | // TreatUtil.editTreatNotice1(visitOrder, treatSingle, customParameter, commonService); |
| | | // //所有状态下都发送治疗通知单给MIC |
| | | // //发送企业微信通知MIC进行分配治疗(正式环境才发) |
| | | // if (isMicNotice == BaseEntity.YES && PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) { |
| | | // try{ |
| | | // String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
| | | // String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
| | | // if(StringUtils.isEmpty(mpToken)){ |
| | | // throw new TipsException("获取小程序Token异常!"); |
| | | // } |
| | | // if(StringUtils.isEmpty(corpMpToken)){ |
| | | // throw new TipsException("获取企业应用小程序Token异常!"); |
| | | // } |
| | | // TreatUtil.sendTreatNoticeShopMic(commonService, visitOrder, TreatUtil.NOTICE_TYPE_ADD, "1000050", mpToken, corpMpToken, doctorName, projectNameSb.toString()); |
| | | // }catch (Exception e){ |
| | | // logger.error("新增治疗单发送企业消息失败:{}", e.getMessage()); |
| | | // logger.error(GlobalExceptionHandler.getExceptionInformation(e)); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | |
| | | /** 编辑治疗通知单 */ |
| | |
| | | if ((treatSingle.getStatus()==TreatSingleConstants.STATUS_WAIT_CONFIRM |
| | | || treatSingle.getStatus() == TreatSingleConstants.STATUS_CONFIRM ) |
| | | && PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) { |
| | | // TreatUtil.editTreatNotice1(visitOrder, treatSingle, customParameter, commonService); |
| | | try{ |
| | | String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
| | | String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
| | |
| | | if(StringUtils.isEmpty(corpMpToken)){ |
| | | throw new TipsException("获取企业应用小程序Token异常!"); |
| | | } |
| | | TreatUtil.editTreatNotice1(commonService, visitOrder, treatSingle, TreatUtil.NOTICE_TYPE_EDIT |
| | | , customParameter.getCorpMpAppId(), "1000050", mpToken, corpMpToken |
| | | , MapUtil.getString(pMap, "doctorName"), MapUtil.getString(pMap, "projectName")); |
| | | TreatUtil.editTreatNotice2(commonService, visitOrder, treatSingle , customParameter.getCorpMpAppId(), corpMpToken); |
| | | }catch (Exception e){ |
| | | logger.error("编辑治疗单发送企业消息失败:{}", e.getMessage()); |
| | | logger.error(GlobalExceptionHandler.getExceptionInformation(e)); |