| | |
| | | package com.hx.phip.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.hx.common.service.CommonService; |
| | |
| | | import com.hx.phiappt.common.UserStatusConstants; |
| | | import com.hx.phiappt.constants.tool.UserInfoTool; |
| | | import com.hx.phiappt.constants.tool.UserStatusTool; |
| | | import com.hx.phiappt.constants.tool.exception.ExceptionTool; |
| | | import com.hx.phiappt.constants.tool.user.UserAgeTool; |
| | | import com.hx.phiappt.constants.tool.user.UserLevelTool; |
| | | import com.hx.phiappt.constants.tool.user.UserRegisterRecordTool; |
| | |
| | | import com.hx.phiappt.model.*; |
| | | import com.hx.phiappt.model.channels.Channels; |
| | | import com.hx.phiappt.model.memberLevel.MemberLevel; |
| | | import com.hx.phiappt.model.user.UserDiagnosisDoctor; |
| | | import com.hx.phiappt.model.user.UserDiagnosisDoctorItem; |
| | | import com.hx.phiappt.model.user.UserWakeUpLog; |
| | | import com.hx.phiappt.model.userLevel.UserLevelRecord; |
| | | import com.hx.phiappt.model.userLevel.UserLevelRule; |
| | |
| | | import com.hx.phiappt.util.UserPretriageAdminMpTool; |
| | | import com.hx.phip.config.CustomParameter; |
| | | import com.hx.phip.config.GlobalExceptionHandler; |
| | | import com.hx.phip.config.ProcessUserRoomBean; |
| | | import com.hx.phip.dao.mapper.*; |
| | | import com.hx.phip.entity.user.UserDto; |
| | | import com.hx.phip.service.SystemParameterService; |
| | | import com.hx.phip.service.UserService; |
| | | import com.hx.phip.service.UserUnionHisService; |
| | | import com.hx.phip.service.user.UserDoctorNewService; |
| | | import com.hx.resultTool.Result; |
| | | import com.hx.util.DateUtil; |
| | | import com.hx.util.SimpleTool; |
| | | import com.hx.util.StringUtils; |
| | | import com.hx.util.mysql.aes.MysqlHexAesTool; |
| | | import com.hx.util.thread.ExecutorServiceTool; |
| | | import com.hz.his.dto.marketing.common.*; |
| | | import com.hz.his.dto.user.UserParamDto; |
| | | import com.hz.his.dto.user.room.UserDoctorRoomDto; |
| | | import com.hz.his.dto.user.room.UserDoctorRoomItemDto; |
| | | import com.hz.his.dto.user.usercompleteInfo.UserInfoCompleteDto; |
| | | import com.hz.his.feign.service.dcp.SUserTagInfoService; |
| | | import com.hz.his.feign.service.marketing.MCommonService; |
| | | import com.hz.his.feign.service.sync.SyncUserService; |
| | | import com.hz.sms.dto.ContentItemDto; |
| | | import com.hz.sms.dto.TemplateMessageDto; |
| | | import com.hz.sms.dto.TemplateMsgDto; |
| | | import com.hz.sms.feign.FCorpWXSendService; |
| | | import com.platform.exception.PlatTipsException; |
| | | import com.platform.resultTool.PlatformCode; |
| | | import org.slf4j.Logger; |
| | |
| | | private UserAddressBookMapper userAddressBookMapper; |
| | | @Resource |
| | | private UserGeneralLabelMapper userGeneralLabelMapper; |
| | | |
| | | @Resource |
| | | private UserInterestsMapper userInterestsMapper; |
| | | @Resource |
| | |
| | | @Resource |
| | | private UserWakeUpLogMapper userWakeUpLogMapper; |
| | | @Resource |
| | | private FamiliesRoomMapper familiesRoomMapper; |
| | | private SUserTagInfoService sUserTagInfoService; |
| | | @Resource |
| | | private UserDiagnosisDoctorMapper userDiagnosisDoctorMapper; |
| | | @Resource |
| | | private UserFamiliesRoomMapper userFamiliesRoomMapper; |
| | | @Resource |
| | | private SUserTagInfoService sUserTagInfoService; |
| | | private FamiliesRoomMapper familiesRoomMapper; |
| | | @Resource |
| | | private UserDiagnosisDoctorItemMapper userDiagnosisDoctorItemMapper; |
| | | @Resource |
| | | private FCorpWXSendService fCorpWXSendService; |
| | | @Resource |
| | | private ProcessUserRoomBean processUserRoomBean; |
| | | @Resource |
| | | private MCommonService mCommonService; |
| | | |
| | | |
| | | /**查询列表*/ |
| | |
| | | /** |
| | | * 修改用户科室关系信息 |
| | | * @param userParamDto 参数 |
| | | * @param user 用户信息 |
| | | * @param opEmployee 操作人 |
| | | * @param userId 用户信息 |
| | | * @param employeeId 操作人 |
| | | */ |
| | | @Override |
| | | public void updateFamiliesRoom(UserParamDto userParamDto, User user, Employee opEmployee) { |
| | | public void updateFamiliesRoom(UserParamDto userParamDto,String userId,String employeeId) { |
| | | if (StringUtils.isEmpty(userParamDto.getUserId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请传用户id!"); |
| | | } |
| | | // 用户信息 |
| | | User user = userMapper.selectOneByKey(userParamDto.getUserId()); |
| | | if (user == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到用户!"); |
| | | } |
| | | if (StringUtils.isEmpty(userParamDto.getDepartmentJson())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请传科室关系参数!"); |
| | | } |
| | | if (StringUtils.isEmpty(userParamDto.getOpId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请传操作人id!"); |
| | | } |
| | | // 操作人信息 |
| | | Employee opEmployee = commonService.selectOneByKey(EmployeeMapper.class, userParamDto.getOpId()); |
| | | if (opEmployee == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到操作人信息!"); |
| | | } |
| | | // 科室数据 |
| | | List<UserFamiliesRoom> userFamiliesRoomList; |
| | | try { |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 新增点诊记录 |
| | | */ |
| | | @Override |
| | | public MarketingResultDto diagnosisDoctorCreate(UserDoctorRoomDto userDoctorRoomDto) { |
| | | if (StringUtils.isEmpty(userDoctorRoomDto.getUserId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "用户标识为空!"); |
| | | } |
| | | if (userDoctorRoomDto.getType() == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "类型为空!"); |
| | | } |
| | | User user = userMapper.selectOneByKey(userDoctorRoomDto.getUserId()); |
| | | if (user == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "用户标识错误,获取用户信息失败!"); |
| | | } |
| | | if (StringUtils.isEmpty(userDoctorRoomDto.getOpId(), userDoctorRoomDto.getOpName())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "操作人为空!"); |
| | | } |
| | | |
| | | List<UserDoctorRoomItemDto> roomList = userDoctorRoomDto.getRoomList(); |
| | | if (roomList == null || roomList.size() < 1) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "点诊数据为空!"); |
| | | } |
| | | for (UserDoctorRoomItemDto userDoctorRoomItemDto : roomList) { |
| | | if (StringUtils.isEmpty(userDoctorRoomItemDto.getDoctorId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "医生数据为空!"); |
| | | } |
| | | if (StringUtils.isEmpty(userDoctorRoomItemDto.getFamiliesRoomId())) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "科室数据为空!"); |
| | | } |
| | | Employee employee = employeeMapper.selectOneByKey(userDoctorRoomItemDto.getDoctorId()); |
| | | if (employee == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "医生标识错误,找不到医生信息!"); |
| | | } |
| | | if (StringUtils.isEmpty(userDoctorRoomItemDto.getDoctorName())) { |
| | | userDoctorRoomItemDto.setDoctorName(employee.getCnName()); |
| | | } |
| | | |
| | | FamiliesRoom familiesRoom = familiesRoomMapper.selectOneByKey(userDoctorRoomItemDto.getFamiliesRoomId()); |
| | | if (familiesRoom == null) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "科室标识错误,找不到科室信息!"); |
| | | } |
| | | if (StringUtils.isEmpty(userDoctorRoomItemDto.getFamiliesRoomName())) { |
| | | userDoctorRoomItemDto.setFamiliesRoomName(familiesRoom.getFamiliesRoomName()); |
| | | } |
| | | } |
| | | if (userDoctorRoomDto.getStartTime() == null) { |
| | | userDoctorRoomDto.setStartTime(DateUtil.parseString(DateUtil.dayToStart(new Date()), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | if (userDoctorRoomDto.getEndTime() == null) { |
| | | userDoctorRoomDto.setEndTime(DateUtil.parseString(DateUtil.dayToEnd(new Date()), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | |
| | | UserDiagnosisDoctor userDiagnosisDoctor = new UserDiagnosisDoctor(); |
| | | userDiagnosisDoctor.setApproveStatus(0); |
| | | userDiagnosisDoctor.setType(userDoctorRoomDto.getType()); |
| | | userDiagnosisDoctor.setStartTime(userDoctorRoomDto.getStartTime()); |
| | | userDiagnosisDoctor.setEndTime(userDoctorRoomDto.getEndTime()); |
| | | userDiagnosisDoctor.setReasonType(userDoctorRoomDto.getReasonType()); |
| | | |
| | | userDiagnosisDoctor.setOpId(userDoctorRoomDto.getOpId()); |
| | | userDiagnosisDoctor.setOpName(userDoctorRoomDto.getOpName()); |
| | | userDiagnosisDoctor.setOpShopId(userDoctorRoomDto.getOpShopId()); |
| | | userDiagnosisDoctor.setOpShopName(userDoctorRoomDto.getOpShopName()); |
| | | userDiagnosisDoctor.setOpRoleId(userDoctorRoomDto.getOpRoleId()); |
| | | userDiagnosisDoctor.setOpRoleName(userDoctorRoomDto.getOpRoleName()); |
| | | userDiagnosisDoctor.setOpRoleTypeId(userDoctorRoomDto.getOpRoleTypeId()); |
| | | userDiagnosisDoctor.setOpRoleStr(userDoctorRoomDto.getOpRoleStr()); |
| | | userDiagnosisDoctor.setOperatorRemark(userDoctorRoomDto.getOperatorRemark()); |
| | | userDiagnosisDoctor.setUserId(user.getId()); |
| | | userDiagnosisDoctor.setUserName(user.getName()); |
| | | userDiagnosisDoctor.setUserCiq(user.getCIQ()); |
| | | userDiagnosisDoctor.setUserNo(user.getMemberNO()); |
| | | userDiagnosisDoctor.setUserLevel(user.getUserLevel()); |
| | | if (StringUtils.noNull(user.getHisCorpUserId())) { |
| | | userDiagnosisDoctor.setUserCorpId(user.getHisCorpUserId()); |
| | | Employee coreUser = employeeMapper.selectOneByKey(user.getHisCorpUserId()); |
| | | if (coreUser != null) { |
| | | userDiagnosisDoctor.setUserCorpName(coreUser.getCnName()); |
| | | } |
| | | } |
| | | if (StringUtils.noNull(user.getShopId())) { |
| | | userDiagnosisDoctor.setUserShopId(user.getShopId()); |
| | | Shop shop = shopMapper.selectOneByKey(user.getShopId()); |
| | | if (shop != null) { |
| | | userDiagnosisDoctor.setUserShopName(shop.getName()); |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(userDiagnosisDoctor.getReasonType())) { |
| | | userDiagnosisDoctor.setReasonType("无"); |
| | | } |
| | | if (userDiagnosisDoctorMapper.insert(userDiagnosisDoctor) != 1) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "新增失败!"); |
| | | } |
| | | |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String, Object> values = new HashMap<>(); |
| | | values.put("isDel", BaseEntity.NO); |
| | | values.put("userId", userDoctorRoomDto.getUserId()); |
| | | sqlSentence.sqlSentence(" SELECT * from user_families_room WHERE isDel = 0 AND userId = #{m.userId} ORDER BY createTime DESC", values); |
| | | List<UserFamiliesRoom> oldList = commonService.selectList(UserFamiliesRoomMapper.class, sqlSentence); |
| | | |
| | | UserDiagnosisDoctorItem userDiagnosisDoctorItem; |
| | | for (UserDoctorRoomItemDto userDoctorRoomItemDto : roomList) { |
| | | userDiagnosisDoctorItem = new UserDiagnosisDoctorItem(); |
| | | userDiagnosisDoctorItem.setTemporaryId(userDiagnosisDoctor.getId()); |
| | | userDiagnosisDoctorItem.setDoctorId(userDoctorRoomItemDto.getDoctorId()); |
| | | userDiagnosisDoctorItem.setDoctorName(userDoctorRoomItemDto.getDoctorName()); |
| | | userDiagnosisDoctorItem.setRoomId(userDoctorRoomItemDto.getFamiliesRoomId()); |
| | | userDiagnosisDoctorItem.setRoomName(userDoctorRoomItemDto.getFamiliesRoomName()); |
| | | //旧的 |
| | | List<UserFamiliesRoom> rooms = oldList.stream().filter(a |
| | | -> (StringUtils.noNull(a.getFamiliesRoomId()) && a.getFamiliesRoomId().equals(userDoctorRoomItemDto.getFamiliesRoomId())) |
| | | ||(StringUtils.noNull(a.getFamiliesRoomName()) && a.getFamiliesRoomName().equals(userDoctorRoomItemDto.getFamiliesRoomName()))) |
| | | .collect(Collectors.toList()); |
| | | if (rooms.size() > 0){ |
| | | userDoctorRoomItemDto.setOldDoctorId(rooms.get(0).getDoctorId()); |
| | | userDoctorRoomItemDto.setOldDoctorName(rooms.get(0).getDoctorName()); |
| | | } |
| | | userDiagnosisDoctorItem.setOldDoctorId(userDoctorRoomItemDto.getOldDoctorId()); |
| | | userDiagnosisDoctorItem.setOldDoctorName(userDoctorRoomItemDto.getOldDoctorName()); |
| | | if (userDiagnosisDoctorItemMapper.insert(userDiagnosisDoctorItem) != 1) { |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "新增子项失败!"); |
| | | } |
| | | } |
| | | |
| | | //请求营销助手 |
| | | Result result = approveNewAdd(userDiagnosisDoctor.getId(), userDoctorRoomDto); |
| | | if (!result.checkCode()) { |
| | | logger.error("创建审核失败,入参{},返回{}", JSON.toJSONString(userDoctorRoomDto), JSON.toJSONString(result)); |
| | | throw new TipsException("创建营销助手审核失败" + result.getMsg()); |
| | | } |
| | | MarketingResultDto marketingResultDto = result.getObject(result.getData(), MarketingResultDto.class); |
| | | if (marketingResultDto == null) { |
| | | throw new TipsException("申请审核返回信息为空!"); |
| | | } |
| | | marketingResultDto.setUniqueId(userDiagnosisDoctor.getId()); |
| | | return marketingResultDto; |
| | | } |
| | | |
| | | /** |
| | | * 创建营销助手申请 |
| | | */ |
| | | private Result approveNewAdd(String uniqueId, UserDoctorRoomDto userDoctorRoomDto) { |
| | | //请求营销助手 |
| | | //---审核信息组拼 |
| | | MarketingTotalDto marketingTotalDto = new MarketingTotalDto(); |
| | | marketingTotalDto.setOperatorId(userDoctorRoomDto.getOpId()); |
| | | marketingTotalDto.setOpName(userDoctorRoomDto.getOpName()); |
| | | marketingTotalDto.setShopId(userDoctorRoomDto.getOpShopId()); |
| | | marketingTotalDto.setShopName(userDoctorRoomDto.getOpShopName()); |
| | | marketingTotalDto.setRoleId(userDoctorRoomDto.getOpRoleTypeId()); |
| | | marketingTotalDto.setRoleUniqueStr(userDoctorRoomDto.getOpRoleStr()); |
| | | marketingTotalDto.setUserId(userDoctorRoomDto.getUserId()); |
| | | marketingTotalDto.setRemark(userDoctorRoomDto.getOperatorRemark()); |
| | | //标识 |
| | | marketingTotalDto.setUniqueId(uniqueId); |
| | | |
| | | //旧医生 |
| | | StringBuilder oldDoctorStr = new StringBuilder(); |
| | | //新医生 |
| | | StringBuilder doctorStr = new StringBuilder(); |
| | | for (UserDoctorRoomItemDto userDoctorRoomItemDto : userDoctorRoomDto.getRoomList()) { |
| | | if (doctorStr.length() > 0) { |
| | | doctorStr.append(","); |
| | | } |
| | | doctorStr.append(userDoctorRoomItemDto.getFamiliesRoomName()).append(":").append(userDoctorRoomItemDto.getDoctorName()); |
| | | if (oldDoctorStr.length() > 0) { |
| | | oldDoctorStr.append(","); |
| | | } |
| | | oldDoctorStr.append(userDoctorRoomItemDto.getFamiliesRoomName()).append(":").append(userDoctorRoomItemDto.getOldDoctorName()); |
| | | } |
| | | //点诊 |
| | | if (UserDiagnosisDoctor.TYPE_DIAGNOSIS.equals(userDoctorRoomDto.getType())) { |
| | | //---审核信息组拼开始 |
| | | marketingTotalDto.setTitle(processUserRoomBean.getTwoTitle()); |
| | | marketingTotalDto.setType(processUserRoomBean.getTwoCode()); |
| | | marketingTotalDto.setCallbackUrl(processUserRoomBean.getUrl()); |
| | | |
| | | MarketingContentDto marketingContentDto = new MarketingContentDto(); |
| | | List<MarketingMsgItemDto> contentList = new ArrayList<>(); |
| | | MarketingMsgItemDto marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("当前科室医生"); |
| | | marketingMsgItemDto.setValue(oldDoctorStr.toString()); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("点诊科室医生"); |
| | | marketingMsgItemDto.setValue(doctorStr.toString()); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | if (StringUtils.noNull(userDoctorRoomDto.getOperatorRemark())) { |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("点诊备注"); |
| | | marketingMsgItemDto.setValue(userDoctorRoomDto.getOperatorRemark()); |
| | | contentList.add(marketingMsgItemDto); |
| | | } |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("点诊原因"); |
| | | marketingMsgItemDto.setValue(userDoctorRoomDto.getReasonType()); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("点诊时间"); |
| | | String timeStr = DateUtil.formatDate(userDoctorRoomDto.getStartTime(), "yyyy-MM-dd HH:mm:ss") |
| | | + "~" + DateUtil.formatDate(userDoctorRoomDto.getEndTime(), "yyyy-MM-dd HH:mm:ss"); |
| | | marketingMsgItemDto.setValue(timeStr); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | |
| | | marketingContentDto.setContentList(contentList); |
| | | marketingTotalDto.setMarketingContentDto(marketingContentDto); |
| | | //---审核信息组拼结束 |
| | | |
| | | //---企业微信信息组拼 |
| | | MarketingMsgDto marketingMsgDto = new MarketingMsgDto(); |
| | | marketingMsgDto.setEmphasisFirstItem(true); |
| | | List<MarketingMsgItemDto> contentItemList = new ArrayList<>(); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("审核主题"); |
| | | marketingMsgItemDto.setValue(processUserRoomBean.getTwoTitle()); |
| | | contentItemList.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("当前科室医生"); |
| | | marketingMsgItemDto.setValue(oldDoctorStr.toString()); |
| | | contentItemList.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("点诊科室医生"); |
| | | marketingMsgItemDto.setValue(doctorStr.toString()); |
| | | contentItemList.add(marketingMsgItemDto); |
| | | |
| | | if (StringUtils.noNull(userDoctorRoomDto.getOperatorRemark())) { |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("点诊备注"); |
| | | marketingMsgItemDto.setValue(userDoctorRoomDto.getOperatorRemark()); |
| | | contentItemList.add(marketingMsgItemDto); |
| | | } |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("点诊原因"); |
| | | marketingMsgItemDto.setValue(userDoctorRoomDto.getReasonType()); |
| | | contentItemList.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgDto.setContentItem(contentItemList); |
| | | marketingTotalDto.setMarketingMsgDto(marketingMsgDto); |
| | | //---企业微信信息组拼结束 |
| | | |
| | | } else if (UserDiagnosisDoctor.TYPE_NONE.equals(userDoctorRoomDto.getType())) { |
| | | //创建科室医生 |
| | | |
| | | //---审核信息组拼开始 |
| | | marketingTotalDto.setTitle(processUserRoomBean.getOneTitle()); |
| | | marketingTotalDto.setType(processUserRoomBean.getOneCode()); |
| | | marketingTotalDto.setCallbackUrl(processUserRoomBean.getUrl()); |
| | | |
| | | MarketingContentDto marketingContentDto = new MarketingContentDto(); |
| | | List<MarketingMsgItemDto> contentList = new ArrayList<>(); |
| | | MarketingMsgItemDto marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("原科室医生"); |
| | | marketingMsgItemDto.setValue("无"); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("新科室医生"); |
| | | marketingMsgItemDto.setValue(doctorStr.toString()); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | marketingContentDto.setContentList(contentList); |
| | | marketingTotalDto.setMarketingContentDto(marketingContentDto); |
| | | //---审核信息组拼结束 |
| | | |
| | | //---企业微信信息组拼 |
| | | MarketingMsgDto marketingMsgDto = new MarketingMsgDto(); |
| | | marketingMsgDto.setEmphasisFirstItem(true); |
| | | List<MarketingMsgItemDto> contentItem = new ArrayList<>(); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("审核主题"); |
| | | marketingMsgItemDto.setValue(processUserRoomBean.getOneTitle()); |
| | | contentItem.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("原科室医生"); |
| | | marketingMsgItemDto.setValue("无"); |
| | | contentItem.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("新科室医生"); |
| | | marketingMsgItemDto.setValue(doctorStr.toString()); |
| | | contentItem.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgDto.setContentItem(contentItem); |
| | | marketingTotalDto.setMarketingMsgDto(marketingMsgDto); |
| | | //---企业微信信息组拼结束 |
| | | } else if (UserDiagnosisDoctor.TYPE_DIAGNOSIS_CREATE.equals(userDoctorRoomDto.getType())) { |
| | | //点诊不足创建科室医生 |
| | | |
| | | //---审核信息组拼开始 |
| | | marketingTotalDto.setTitle(processUserRoomBean.getThreeTitle()); |
| | | marketingTotalDto.setType(processUserRoomBean.getThreeCode()); |
| | | marketingTotalDto.setCallbackUrl(processUserRoomBean.getUrl()); |
| | | |
| | | MarketingContentDto marketingContentDto = new MarketingContentDto(); |
| | | List<MarketingMsgItemDto> contentList = new ArrayList<>(); |
| | | |
| | | MarketingMsgItemDto marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("原科室医生"); |
| | | marketingMsgItemDto.setValue(oldDoctorStr.toString()); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("修改科室医生"); |
| | | marketingMsgItemDto.setValue(doctorStr.toString()); |
| | | contentList.add(marketingMsgItemDto); |
| | | |
| | | marketingContentDto.setContentList(contentList); |
| | | marketingTotalDto.setMarketingContentDto(marketingContentDto); |
| | | //---审核信息组拼结束 |
| | | |
| | | //---企业微信信息组拼 |
| | | MarketingMsgDto marketingMsgDto = new MarketingMsgDto(); |
| | | marketingMsgDto.setEmphasisFirstItem(true); |
| | | List<MarketingMsgItemDto> contentItem = new ArrayList<>(); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("审核主题"); |
| | | marketingMsgItemDto.setValue(processUserRoomBean.getThreeTitle()); |
| | | contentItem.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("原科室医生"); |
| | | marketingMsgItemDto.setValue(oldDoctorStr.toString()); |
| | | contentItem.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgItemDto = new MarketingMsgItemDto(); |
| | | marketingMsgItemDto.setKey("修改科室医生"); |
| | | marketingMsgItemDto.setValue(doctorStr.toString()); |
| | | contentItem.add(marketingMsgItemDto); |
| | | |
| | | marketingMsgDto.setContentItem(contentItem); |
| | | marketingTotalDto.setMarketingMsgDto(marketingMsgDto); |
| | | //---企业微信信息组拼结束 |
| | | } |
| | | logger.info("科室医生关系请求审核参数{}", JSON.toJSONString(marketingTotalDto)); |
| | | return mCommonService.commonApply(marketingTotalDto); |
| | | } |
| | | |
| | | /** |
| | | * 用户点诊记录回调修改 |
| | | */ |
| | | @Override |
| | | public void updateUserDoctorTemporary(UserParamDto userParamDto, MarketingReturnDto marketingReturnDto) { |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String, Object> sqlMap = new HashMap<>(); |
| | | sqlMap.put("id", marketingReturnDto.getUniqueId()); |
| | | if (marketingReturnDto.getResult().equals(MarketingReturnDto.AGREE)) { |
| | | sqlMap.put("approveStatus", 1); |
| | | } else if (marketingReturnDto.getResult().equals(MarketingReturnDto.REJECT)) { |
| | | sqlMap.put("approveStatus", 2); |
| | | } |
| | | sqlMap.put("approveId",marketingReturnDto.getApplyId()); |
| | | sqlSentence.sqlSentence(" approveStatus = #{m.approveStatus},approveId = #{m.approveId} " + |
| | | " WHERE id = #{m.id} AND approveStatus = 0 ", sqlMap); |
| | | if (userDiagnosisDoctorMapper.updateWhere(sqlSentence) != 1) { |
| | | logger.error("点诊记录回调,修改审核状态失败:" + JSON.toJSONString(marketingReturnDto)); |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "修改审核状态失败"); |
| | | } |
| | | UserDiagnosisDoctor userDiagnosisDoctor = userDiagnosisDoctorMapper.selectOneByKey(marketingReturnDto.getUniqueId()); |
| | | if (userDiagnosisDoctor == null) { |
| | | logger.error("点诊记录回调,查询记录信息失败:" + JSON.toJSONString(marketingReturnDto)); |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "获取记录信息失败!"); |
| | | } |
| | | //如果通过,修改科室关系 |
| | | if (!marketingReturnDto.getResult().equals(MarketingReturnDto.AGREE)) { |
| | | return; |
| | | } |
| | | //消息通知 |
| | | List<TemplateMessageDto> msgList = new ArrayList<>(); |
| | | //原科室关系 |
| | | sqlMap.put("userId", userDiagnosisDoctor.getUserId()); |
| | | sqlSentence.sqlSentence("SELECT * FROM user_families_room WHERE userId = #{m.userId}", sqlMap); |
| | | List<UserFamiliesRoom> userFamiliesRoomList = userFamiliesRoomMapper.selectList(sqlSentence); |
| | | Map<String, UserFamiliesRoom> map = new HashMap<>(); |
| | | for (UserFamiliesRoom userFamiliesRoom : userFamiliesRoomList) { |
| | | map.put(userFamiliesRoom.getFamiliesRoomId(), userFamiliesRoom); |
| | | } |
| | | //要修改的科室信息 |
| | | sqlMap.put("temporaryId", userDiagnosisDoctor.getId()); |
| | | sqlSentence.sqlSentence("SELECT * FROM user_diagnosis_doctor_item WHERE temporaryId = #{m.temporaryId}", sqlMap); |
| | | List<UserDiagnosisDoctorItem> diagnosisDoctorItemList = userDiagnosisDoctorItemMapper.selectList(sqlSentence); |
| | | |
| | | //点诊的通知 |
| | | if (userDiagnosisDoctor.getType().equals(UserDiagnosisDoctor.TYPE_DIAGNOSIS)) { |
| | | for (UserDiagnosisDoctorItem userDiagnosisDoctorItem : diagnosisDoctorItemList) { |
| | | //通知数据 |
| | | UserFamiliesRoom userFamiliesRoom = map.get(userDiagnosisDoctorItem.getRoomId()); |
| | | if (userFamiliesRoom != null) { |
| | | Employee employee = employeeMapper.selectOneByKey(userDiagnosisDoctorItem.getOldDoctorId()); |
| | | if (employee != null) { |
| | | addMsg(userDiagnosisDoctor.getUserName(),userDiagnosisDoctor.getUserCiq() |
| | | ,userDiagnosisDoctor.getUserLevel(),customParameter.getCorpAppId() |
| | | , customParameter.getCorpMpAppId(), msgList, employee.getUserId() |
| | | , "点诊医生通知", "开治疗单申请点诊医生" |
| | | , userFamiliesRoom.getFamiliesRoomName() + ":" + userFamiliesRoom.getDoctorName() |
| | | , userDiagnosisDoctorItem.getRoomName() + ":" + userDiagnosisDoctorItem.getDoctorName() |
| | | , 1,userDiagnosisDoctor.getOpName(),userDiagnosisDoctor.getReasonType()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //如果是需要修改科室的类型 |
| | | if (userDiagnosisDoctor.getType().equals(UserDiagnosisDoctor.TYPE_NONE) |
| | | || userDiagnosisDoctor.getType().equals(UserDiagnosisDoctor.TYPE_DIAGNOSIS_CREATE)) { |
| | | userParamDto.setUserId(userDiagnosisDoctor.getUserId()); |
| | | userParamDto.setOpId(userDiagnosisDoctor.getOpId()); |
| | | userParamDto.setIsEditFamiliesRoom(1); |
| | | List<UserFamiliesRoom> selectList = new ArrayList<>(); |
| | | UserFamiliesRoom selectRoom = null; |
| | | for (UserDiagnosisDoctorItem userDiagnosisDoctorItem : diagnosisDoctorItemList) { |
| | | selectRoom = new UserFamiliesRoom(); |
| | | selectRoom.setDoctorId(userDiagnosisDoctorItem.getDoctorId()); |
| | | selectRoom.setDoctorName(userDiagnosisDoctorItem.getDoctorName()); |
| | | selectRoom.setFamiliesRoomId(userDiagnosisDoctorItem.getRoomId()); |
| | | selectRoom.setFamiliesRoomName(userDiagnosisDoctorItem.getRoomName()); |
| | | selectList.add(selectRoom); |
| | | |
| | | //通知数据 |
| | | UserFamiliesRoom userFamiliesRoom = map.get(userDiagnosisDoctorItem.getRoomId()); |
| | | if (userFamiliesRoom != null) { |
| | | Employee employee = employeeMapper.selectOneByKey(userDiagnosisDoctorItem.getOldDoctorId()); |
| | | if (employee != null) { |
| | | addMsg(userDiagnosisDoctor.getUserName(),userDiagnosisDoctor.getUserCiq() |
| | | ,userDiagnosisDoctor.getUserLevel(),customParameter.getCorpAppId() |
| | | , customParameter.getCorpMpAppId(), msgList |
| | | , employee.getUserId(), "科室医生变更通知", "开治疗单变更科室医生" |
| | | , userFamiliesRoom.getFamiliesRoomName() + ":" + userFamiliesRoom.getDoctorName() |
| | | , userDiagnosisDoctorItem.getRoomName() + ":" + userDiagnosisDoctorItem.getDoctorName() |
| | | , 0,userDiagnosisDoctor.getOpName(),userDiagnosisDoctor.getOperatorRemark()); |
| | | } |
| | | } |
| | | } |
| | | userParamDto.setDepartmentJson(JSON.toJSONString(selectList)); |
| | | //请求修改 |
| | | updateFamiliesRoom(userParamDto, userParamDto.getUserId(), userParamDto.getOpId()); |
| | | } |
| | | |
| | | //发送企业消息 |
| | | if (msgList.size() > 0) { |
| | | //开启线程 |
| | | ExecutorServiceTool fixedThreadPool = new ExecutorServiceTool(2, 10); |
| | | try { |
| | | for (TemplateMessageDto templateMessageDto : msgList) { |
| | | fixedThreadPool.getThreadPool().execute(() -> { |
| | | Result result = fCorpWXSendService.sendNoticeSms(templateMessageDto); |
| | | logger.info("点诊回调发送通知消息发送返回:" + JSON.toJSONString(result)); |
| | | }); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("点诊回调发送通知消息发送,错误" + ExceptionTool.getExceptionInfo(e)); |
| | | } finally { |
| | | fixedThreadPool.shutdown(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改科室医生HIS助手通知消息添加 |
| | | * @param userName 客户名称 |
| | | * @param ciq 客户ciq |
| | | * @param userLevel 客户等级 |
| | | * @param corpId 企业 |
| | | * @param appId 小程序 |
| | | * @param touSer 发送人 |
| | | * @param title 标题 |
| | | * @param description 描述 |
| | | * @param oldDoctor 旧医生 |
| | | * @param newDoctor 医生 |
| | | * @param isDiagnosis 是否点诊 |
| | | * @param opMan 操作人 |
| | | * @param opReason 操作原因/备注 |
| | | * @param msgList 发送消息实体集合返回用 |
| | | */ |
| | | private void addMsg(String userName,String ciq,String userLevel,String corpId, String appId |
| | | , List<TemplateMessageDto> msgList, String touSer, String title, String description |
| | | , String oldDoctor, String newDoctor, Integer isDiagnosis,String opMan,String opReason) { |
| | | TemplateMessageDto templateMessageDto = new TemplateMessageDto(); |
| | | templateMessageDto.setCorpId(corpId); |
| | | templateMessageDto.setAppId(appId); |
| | | templateMessageDto.setTouSer(touSer); |
| | | templateMessageDto.setSendModel(TemplateMessageDto.SEND_TYPE_IMMEDIATELY); |
| | | |
| | | //子信息 |
| | | TemplateMsgDto templateMsgDto = new TemplateMsgDto(); |
| | | templateMsgDto.setAppId(appId); |
| | | templateMsgDto.setTitle(title); |
| | | templateMsgDto.setDescription(description); |
| | | |
| | | List<ContentItemDto> contentItemList = new ArrayList<>(); |
| | | |
| | | ContentItemDto contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("客户名称(CIQ)"); |
| | | if (!StringUtils.isEmpty(ciq)){ |
| | | contentItemDto.setValue(userName+"("+ciq+")"); |
| | | }else { |
| | | contentItemDto.setValue(userName+"()"); |
| | | } |
| | | contentItemList.add(contentItemDto); |
| | | |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("客户等级"); |
| | | contentItemDto.setValue(userLevel); |
| | | contentItemList.add(contentItemDto); |
| | | |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("原科室医生"); |
| | | contentItemDto.setValue(oldDoctor); |
| | | contentItemList.add(contentItemDto); |
| | | |
| | | if (isDiagnosis != null && isDiagnosis.equals(BaseEntity.YES)) { |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("点诊的医生"); |
| | | contentItemDto.setValue(newDoctor); |
| | | contentItemList.add(contentItemDto); |
| | | |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("申请原因"); |
| | | contentItemDto.setValue(opReason); |
| | | contentItemList.add(contentItemDto); |
| | | } else { |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("修改的医生"); |
| | | contentItemDto.setValue(newDoctor); |
| | | contentItemList.add(contentItemDto); |
| | | |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("申请备注"); |
| | | contentItemDto.setValue(opReason); |
| | | contentItemList.add(contentItemDto); |
| | | } |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("操作人"); |
| | | contentItemDto.setValue(opMan); |
| | | contentItemList.add(contentItemDto); |
| | | |
| | | contentItemDto = new ContentItemDto(); |
| | | contentItemDto.setKey("操作时间"); |
| | | contentItemDto.setValue(DateUtil.formatDate(new Date(), "yyyy-MM-dd HH:mm:dd")); |
| | | contentItemList.add(contentItemDto); |
| | | |
| | | templateMsgDto.setContentItem(contentItemList); |
| | | |
| | | templateMessageDto.setMinIProgramNotice(templateMsgDto); |
| | | msgList.add(templateMessageDto); |
| | | } |
| | | |
| | | |
| | | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| | | |
| | | /** 用户信息完善 处理标签信息**/ |