phi_platform_common/src/main/java/com/hx/phip/dto/card/CardDto.java
@@ -1,13 +1,13 @@ package com.hx.phip.dto.card; import com.hx.phip.dto.PageDto; import com.hz.his.dto.card.CardQueryDto; /** * 卡项扩展 * * @author fwq */ public class CardDto extends PageDto { public class CardDto extends CardQueryDto { /**卡项标识*/ private String cardId; phi_platform_common/src/main/java/com/hx/phip/entity/user/UserUnionDto.java
@@ -26,6 +26,10 @@ /**平台的用户标识*/ private String merId; //---------------------额外想法参数字段-------------------------------- /**平台编码*/ private String appIdCode; public String getId() { return id; } @@ -89,4 +93,12 @@ public void setCorpUserId(String corpUserId) { this.corpUserId = corpUserId; } public String getAppIdCode() { return appIdCode; } public void setAppIdCode(String appIdCode) { this.appIdCode = appIdCode; } } phi_platform_user/src/main/java/com/hx/phip/controller/deduction/DeductionController.java
@@ -7,6 +7,7 @@ import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.common.DeductionSingleConstants; import com.hx.phiappt.constants.tool.PerformanceInfoTool; import com.hx.phiappt.constants.tool.exception.ExceptionTool; import com.hx.phiappt.constants.tool.user.UserProjectTool; import com.hx.phiappt.dao.mapper.*; import com.hx.phiappt.model.*; @@ -17,6 +18,7 @@ import com.hx.phip.service.ComparePhotoRecordPicturesService; import com.hx.phip.service.ComparePhotoRecordService; import com.hx.phip.service.deduction.*; import com.hx.phip.service.treat.TreatV3Service; import com.hx.resultTool.Result; import com.hx.util.HttpServletRequestUtil; import com.hx.util.StringUtils; @@ -75,6 +77,8 @@ private ComparePhotoRecordService comparePhotoRecordService; @Resource private ComparePhotoRecordPicturesService comparePhotoRecordPicturesService; @Resource private TreatV3Service treatV3Service; /** * 获取划扣清单id @@ -197,6 +201,12 @@ threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(id)); // 处理保妥适俱乐部权益 threadPool.getThreadPool().execute(() -> deductionSingleService.handleBotoxClub(id)); //开启多线程处理用户科室关系 try { threadPool.getThreadPool().execute(() -> treatV3Service.doctorRoomHandlerByDeduction(id)); }catch (Exception e){ logger.error("开启多线程处理用户科室关系失败"+ ExceptionTool.getExceptionInfo(e)); } // 返回id return Result.success(id); } phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java
@@ -122,7 +122,7 @@ try { fixedThreadPool.getThreadPool().execute(() ->{ //处理用户科室关系 treatV3Service.doctorRoomHandler(treatSingle.getId()); //treatV3Service.doctorRoomHandler(treatSingle.getId()); //处理治疗单项目模式数据 treatV3Service.handleModeData(projectList); }); phi_platform_user/src/main/java/com/hx/phip/controller/user/UserController.java
@@ -547,6 +547,11 @@ // 获取签名 appId String appId = request.getHeader("appId"); if(userDto.getUserUnion() != null){ userDto.getUserUnion().setAppIdCode(thirtApplication.getAppIdCode()); } // 返回新增加的用户id String userId = userService.insertInfo(userDto,appId); @@ -1021,7 +1026,18 @@ * 根据HisId更新unionId/opneId */ @RequestMapping("/unionId/edit") public Result unionIdEdit(@RequestBody(required = false) UserUnionDto userUnionDto){ public Result unionIdEdit(HttpServletRequest request,@RequestBody UserUnionDto userUnionDto){ // 获取用户信息 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if (thirtApplication == null) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败,请重新验签!"); } if (StringUtils.isEmpty(thirtApplication.getAppIdCode())) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "AppIdCode不能为空!"); } if(userUnionDto == null){ throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式错误"); } @@ -1041,6 +1057,8 @@ throw new PlatTipsException(PlatformCode.ERROR_TIPS, "hisId错误!"); } userUnionDto.setAppIdCode(thirtApplication.getAppIdCode()); userUnionHisService.insert(users.getId(),userUnionDto); return Result.success(); } phi_platform_user/src/main/java/com/hx/phip/service/impl/UserServiceImpl.java
@@ -311,6 +311,12 @@ user.setCreatePersonType(BaseEntity.NO); user.setCreatePersonId(userDto.getCreatePersonId()); user.setCreatePersonName(userDto.getCreatePersonName()); //“”值问题 if(StringUtils.isEmpty(user.getHisCorpUserId())){ user.setHisCorpUserId(null); } // 处理下用户渠道信息 UserInfoTool.handlerChanelInfo(commonService, user); // 添加用户 phi_platform_user/src/main/java/com/hx/phip/service/impl/UserUnionHisServiceImpl.java
@@ -2,11 +2,13 @@ import com.hx.common.service.CommonService; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.common.PlatformConstants; import com.hx.phiappt.dao.mapper.*; import com.hx.phiappt.model.BaseEntity; import com.hx.phiappt.model.Employee; import com.hx.phiappt.model.User; import com.hx.phiappt.model.UserUnionHis; import com.hx.phiappt.model.wechat.gzh.GzhFocusRecord; import com.hx.phip.common.wx.corp.WeiXinCorpMpUtil; import com.hx.phip.config.CustomParameter; import com.hx.phip.entity.user.UserUnionDto; @@ -95,15 +97,10 @@ Map<String, Object> sqlValues = new HashMap<>(); sqlValues.put("unionId", unionId); sqlValues.put("isDel", BaseEntity.NO); String sql = " unionid=#{m.unionId} AND (sysUserId IS NULL OR LENGTH(sysUserId) <= 0) AND isDel=#{m.isDel}"; sqlValues.put("userId", userId); String sql = " sysUserId=#{m.userId},editTime=NOW() WHERE unionid=#{m.unionId} AND isDel=#{m.isDel}"; sqlSentence.sqlSentence(sql, sqlValues); int count = commonService.selectCount(ContactExternalMapper.class, sqlSentence); if (count > 0) { sqlValues.put("userId", userId); sql = " sysUserId=#{m.userId},editTime=NOW() WHERE unionid=#{m.unionId} AND (sysUserId IS NULL OR LENGTH(sysUserId) <= 0) AND isDel=#{m.isDel}"; sqlSentence.sqlSentence(sql, sqlValues); commonService.updateWhere(ContactExternalMapper.class, sqlSentence); } commonService.updateWhere(ContactExternalMapper.class, sqlSentence); } /**新增*/ @@ -131,6 +128,11 @@ userUnionHis.setUserId(userId); //---先获取全部 List<UserUnionHis> userUnionHisList = userUnionHisMapper.getUserUnionHisList(userUnionHis.getFromCode(),userUnionHis.getOpenId()); //查看是否存在 SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); @@ -146,17 +148,48 @@ values.put("fromId",userUnionHis.getFromId()); values.put("editTime",new Date()); sqlSentence.sqlUpdate("userId = #{m.userId},fromName = #{m.fromName},fromAppId = #{m.fromAppId},unionId = #{m.unionId},openId = #{m.openId},hisId = #{m.hisId},fromId = #{m.fromId},editTime = #{m.editTime} " + " WHERE fromCode = #{m.fromCode} AND openId = #{m.openId}",values); " WHERE fromCode = #{m.fromCode} AND openId = #{m.openId} AND isDel = 0",values); //更新匹配记录的信息 userUnionHisMapper.updateWhere(sqlSentence); int updateNum = userUnionHisMapper.updateWhere(sqlSentence); if(updateNum == 0){ userUnionHisMapper.insert(userUnionHis); }else if(updateNum > 1){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"更新用户信息失败"); //更新被替换的记录用户 values.clear(); values.put("bindCRMTime",null); sqlSentence.sqlUpdate("bindCRMTime = #{m.bindCRMTime} WHERE id = #{m.id}",values); for(UserUnionHis userUnionHis1:userUnionHisList){ values.put("id",userUnionHis1.getUserId()); userMapper.updateWhere(sqlSentence); } // 公众号记录 sqlSentence.sqlUpdate("userId = #{m.userId},editTime=NOW() WHERE unionId=#{m.unionId} AND userId IS NULL AND isDel=0", values); gzhFocusRecordMapper.updateWhere(sqlSentence); //没有数据就新增 if(userUnionHisList.size() == 0){ userUnionHisMapper.insert(userUnionHis); } //查找公众关注信息 List<GzhFocusRecord> gzhFocusRecordList = gzhFocusRecordMapper.getGzhFocusRecordList(GzhFocusRecord.YES,null,null,userUnionHis.getUnionId()); Date bindGZHTime = null; if(gzhFocusRecordList.size() > 0){ bindGZHTime = gzhFocusRecordList.get(0).getBindTime(); // 更新公众号记录 sqlSentence.sqlUpdate("userId = #{m.userId},editTime=NOW() WHERE unionId=#{m.unionId} AND status = 1 AND isDel=0", values); gzhFocusRecordMapper.updateWhere(sqlSentence); } //更新用户信息,生成两个独立的对象 StringBuilder updateUserSql = new StringBuilder(); Map<String,Object> userValueMap = new HashMap<>(); //crm if(PlatformConstants.TYPE_PLATFORM_CRM.equals(userUnionDto.getAppIdCode())){ userValueMap.put("bindCRMTime", new Date()); updateUserSql.append("bindCRMTime = #{m.bindCRMTime},"); } if(bindGZHTime != null){ userValueMap.put("bindGZHTime",bindGZHTime); updateUserSql.append("bindGZHTime = #{m.bindGZHTime},"); } // 员工处理 if(StringUtils.noNull(userUnionDto.getCorpUserId())){ @@ -168,32 +201,38 @@ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"corpUserId错误"); } values.clear(); values.put("cUserId",userUnionDto.getCorpUserId()); values.put("bindCRMTime", new Date()); values.put("id",userId); userValueMap.put("cUserId",userUnionDto.getCorpUserId()); updateUserSql.append("cUserId = #{m.cUserId},"); //获取用户信息 User user = userMapper.selectOneByKey(userId); if (user == null) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "用户不存在"); } sqlSentence.sqlUpdate("cUserId = #{m.cUserId},bindCRMTime = #{m.bindCRMTime} WHERE id = #{m.id}",values); if(userMapper.updateWhere(sqlSentence) != 1){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"corpUserId更新失败!"); } if (StringUtils.isEmpty(user.getcUserId()) || !user.getcUserId().equals(userUnionDto.getCorpUserId())) { try { // 企业微信员工标识有更新时推送企业微信消息 // 获取token SysParameter sysParameter = WeiXinCorpMpUtil.getApplicationAccessToken(commonService,customParameter.getCorpAppId(), customParameter.getCorpSecret()); if (sysParameter != null) { String content = userUnionDto.getFromName() + "用户关联您的员工账号成功"; sendMsgTools.sendMsg(userUnionDto.getCorpUserId(), customParameter.getCorpAgentId(), content, sysParameter.getParamValue()); if(user != null){ if (StringUtils.isEmpty(user.getcUserId()) || !user.getcUserId().equals(userUnionDto.getCorpUserId())) { try { // 企业微信员工标识有更新时推送企业微信消息 // 获取token SysParameter sysParameter = WeiXinCorpMpUtil.getApplicationAccessToken(commonService,customParameter.getCorpAppId(), customParameter.getCorpSecret()); if (sysParameter != null) { String content = userUnionDto.getFromName() + "用户关联您的员工账号成功"; sendMsgTools.sendMsg(userUnionDto.getCorpUserId(), customParameter.getCorpAgentId(), content, sysParameter.getParamValue()); } } catch (Exception e) { logger.error("用户更新员工标识时推送企业微信消息失败:" + e.getMessage()); } } catch (Exception e) { logger.error("用户更新员工标识时推送企业微信消息失败:" + e.getMessage()); } } } if(updateUserSql.length() > 0){ //去除最后一个逗号 updateUserSql.delete(updateUserSql.length() - 1, updateUserSql.length()); //更新用户信息 updateUserSql.append(" WHERE id = #{m.id}"); userValueMap.put("id",userId); sqlSentence.sqlSentence(updateUserSql.toString(),userValueMap); userMapper.updateWhere(sqlSentence); } } /**新增*/ phi_platform_user/src/main/java/com/hx/phip/service/sync/impl/KoapSyncUserServiceImpl.java
@@ -365,6 +365,12 @@ } String birthday=jsonObject.getString("birthday"); user.setBirthDay(birthday);//生日 //“”值问题 if(StringUtils.isEmpty(user.getHisCorpUserId())){ user.setHisCorpUserId(null); } // user.setCIQ(jsonObject.getString("number"));//会员号 userMapper.insert(user); phi_platform_user/src/main/java/com/hx/phip/service/treat/TreatV3Service.java
@@ -25,7 +25,7 @@ /** 更新治疗单签名 */ void updateSign(TreatSingle treatSingle, List<TreatSingleSign> signList, EmployeeRole employeeRole); /**处理用户科室关系*/ /**处理用户科室关系-治疗单*/ void doctorRoomHandler(String treatSingleId); /** 批量新增治疗单 */ @@ -33,4 +33,7 @@ /** 处理治疗单模式数据 */ void handleModeData(List<TreatProject> treatProjectList); /**处理用户科室关系-划扣单*/ void doctorRoomHandlerByDeduction(String deductionSingleId); } phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java
@@ -22,6 +22,9 @@ import com.hx.phiappt.constants.tool.exception.ExceptionTool; import com.hx.phiappt.dao.mapper.*; import com.hx.phiappt.model.*; import com.hx.phiappt.model.deduction.DeductionJoin; import com.hx.phiappt.model.deduction.DeductionProject; import com.hx.phiappt.model.deduction.DeductionSingle; import com.hx.phiappt.model.guide.VisitOrder; import com.hx.phiappt.model.treat.*; import com.hx.phiappt.vo.treat.TreatProjectModeDataVo; @@ -81,6 +84,13 @@ private FamiliesRoomMapper familiesRoomMapper; @Resource private UserBeChangeLogMapper userBeChangeLogMapper; @Resource private DeductionSingleMapper deductionSingleMapper; @Resource private DeductionProjectMapper deductionProjectMapper; @Resource private DeductionJoinMapper deductionJoinMapper; @Resource private TreatSingleSignMapper treatSingleSignMapper; @Resource @@ -458,7 +468,7 @@ } /**处理用户科室关系*/ /**处理用户科室关系-治疗单*/ @Override public void doctorRoomHandler(String treatSingleId) { logger.info("-----新增治疗单,多线程处理用户科室关系----"); @@ -564,6 +574,122 @@ } } /**处理用户科室关系-划扣单*/ @Override public void doctorRoomHandlerByDeduction(String deductionSingleId) { logger.info("-----新增划扣,多线程处理用户科室关系----"); DeductionSingle deductionSingle = deductionSingleMapper.selectOneByKey(deductionSingleId); if (deductionSingle == null){ logger.info("新增划扣单处理科室关系,查询划扣单失败"+deductionSingle); return; } if (StringUtils.isEmpty(deductionSingle.getUserId())){ logger.info("新增划扣单处理科室关系,用户id为空"); return; } User user = userMapper.selectOneByKey(deductionSingle.getUserId()); if (user == null){ logger.info("新增划扣单处理科室关系,查询用户失败"+deductionSingle.getUserId()); return; } SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> sqlMap = new HashMap<>(); sqlMap.put("isDel",BaseEntity.NO); sqlMap.put("userId",deductionSingle.getUserId()); sqlMap.put("deductionSingleId",deductionSingleId); sqlMap.put("roleUniqueStr", RoleType.UNIQUE_STR_DOCTOR); //随机获取一个医生 sqlSentence.sqlSentence("SELECT * FROM deduction_join WHERE isDel = #{m.isDel} " + " AND deductionSingleId = #{m.deductionSingleId} AND roleUniqueStr = #{m.roleUniqueStr} ", sqlMap); List<DeductionJoin> deductionJoinList = deductionJoinMapper.selectList(sqlSentence); if (deductionJoinList == null || deductionJoinList.size() < 1) { logger.info("新增划扣单处理科室关系,无参与医生" + deductionSingle.getUserId()); return; } String doctorId = deductionJoinList.get(0).getEmployeeId(); //获取用户科室关系 sqlSentence.sqlSentence("SELECT * FROM user_families_room WHERE isDel = #{m.isDel} " + " AND userId = #{m.userId} AND familiesRoomName IN ('注射科','皮肤科') ",sqlMap); List<UserFamiliesRoom> userFamiliesRoomList = userFamiliesRoomMapper.selectList(sqlSentence); Map<String,UserFamiliesRoom> dataMap = new HashMap<>(); if (userFamiliesRoomList != null && userFamiliesRoomList.size() > 0){ for (UserFamiliesRoom userFamiliesRoom : userFamiliesRoomList) { dataMap.put(userFamiliesRoom.getFamiliesRoomId(),userFamiliesRoom); } } //查询执行的项目-科室 sqlSentence.sqlSentence("SELECT * FROM deduction_project WHERE isDel = #{m.isDel} AND deductionSingleId = #{m.deductionSingleId} ",sqlMap); List<DeductionProject> deductionProjectList = deductionProjectMapper.selectList(sqlSentence); if (deductionProjectList != null && deductionProjectList.size() > 0){ //去重map(科室标识,数据) List<String> checkList = new ArrayList<>(); for (DeductionProject deductionProject : deductionProjectList) { if (StringUtils.isEmpty(deductionProject.getDepartmentId())){ logger.info("新增划扣单处理科室关系,划扣项目无科室数据:"+deductionProject.getId()); continue; } if (checkList.contains(deductionProject.getDepartmentId())){ logger.info("新增划扣单处理科室关系,重复的科室关系,跳过处理:"+deductionProject.getDepartmentId()); continue; } //查询科室 UserFamiliesRoom mapData = dataMap.get(deductionProject.getDepartmentId()); if (mapData != null){ logger.info("新增划扣单处理科室关系,已存在科室关系,跳过处理:"+mapData.getFamiliesRoomName()); continue; } FamiliesRoom familiesRoom = familiesRoomMapper.selectOneByKey(deductionProject.getDepartmentId()); //找不到科室信息不处理 if (familiesRoom == null){ logger.info("新增划扣单处理科室关系,查询科室失败,跳过处理:"+deductionProject.getDepartmentId()); continue; } //不是皮肤科和注射科不处理 if (!"注射科".equals(familiesRoom.getFamiliesRoomName()) && !"皮肤科".equals(familiesRoom.getFamiliesRoomName())){ logger.info("新增划扣单处理科室关系,非注射科和皮肤科,跳过处理:"+familiesRoom.getFamiliesRoomName()); continue; } UserFamiliesRoom userFamiliesRoom = new UserFamiliesRoom(); userFamiliesRoom.setUserId(deductionSingle.getUserId()); userFamiliesRoom.setFamiliesRoomId(deductionProject.getDepartmentId()); userFamiliesRoom.setFamiliesRoomName(familiesRoom.getFamiliesRoomName()); userFamiliesRoom.setDoctorId(doctorId); Employee employee = employeeMapper.selectOneByKey(doctorId); if (employee != null){ userFamiliesRoom.setDoctorName(employee.getCnName()); } userFamiliesRoom.setIsDefault(0); if (userFamiliesRoomMapper.insert(userFamiliesRoom) != 1){ throw new TipsException("新增失败1!"+ JSON.toJSONString(userFamiliesRoom)); } //新增修改记录 UserBeChangeLog userBeChangeLog = new UserBeChangeLog(); userBeChangeLog.setUserId(user.getId()); userBeChangeLog.setUserName(user.getName()); userBeChangeLog.setUserLevel(user.getUserLevel()); userBeChangeLog.setUserType(user.getUserType()); userBeChangeLog.setUserStatus(user.getUserStatus()); userBeChangeLog.setHisCorpUserId(user.getHisCorpUserId()); userBeChangeLog.setBelongShopId(user.getShopId()); userBeChangeLog.setMemberNO(user.getMemberNO()); userBeChangeLog.setCIQ(user.getCIQ()); userBeChangeLog.setChangeType(UserBeChangeLog.CHANGE_TYPE_ROOM_DOCTOR); userBeChangeLog.setCommonId(doctorId); if (employee != null){ userBeChangeLog.setCommonValue(employee.getCnName()); } userBeChangeLog.setRoomId(deductionProject.getDepartmentId()); userBeChangeLog.setRoomName(familiesRoom.getFamiliesRoomName()); userBeChangeLog.setRemark("划扣单:"+deductionSingle.getRecordNo()); if (userBeChangeLogMapper.insert(userBeChangeLog) != 1){ throw new TipsException("新增失败2!"+ JSON.toJSONString(userBeChangeLog)); } checkList.add(deductionProject.getDepartmentId()); } } } /** 批量新增治疗单 */ phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java
@@ -2910,7 +2910,10 @@ sqlSentence.sqlSentence(" SELECT er.*,s.name AS shopName FROM employee_role AS er " + " LEFT JOIN shop AS s ON s.id = er.shopId WHERE er.id = #{m.id}",sqlMap); EmployeeRole employeeRole = commonService.selectOne(EmployeeRoleMapper.class,sqlSentence); //助手登录会更新Employee表的roleId字段,理论上应该要传操作人角色信息过来,而不是用这个字段 if (employeeRole == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"开单人角色信息获取异常,请联系管理员!"); } OrdersTotalDto ordersTotalDto=new OrdersTotalDto(); ordersTotalDto.setTotal(ordersTotal.getShouldTotal().add(ordersTotal.getDiscountTotal())); @@ -2984,6 +2987,10 @@ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"营销助手审批:未找到操作人员工信息!"); } EmployeeRole employeeRole = commonService.selectOneByKeyBlob(EmployeeRoleMapper.class, employee.getRoleId()); //助手登录会更新Employee表的roleId字段,理论上应该要传操作人角色信息过来,而不是用这个字段 if (employeeRole == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"开单人角色信息获取异常,请联系管理员!"); } OrdersTotalDto ordersTotalDto=new OrdersTotalDto(); ordersTotalDto.setTotal(ordersTotal.getShouldTotal().add(ordersTotal.getDiscountTotal()));