| | |
| | | import com.hx.phiappt.constants.tool.employee.EmployeeTool; |
| | | 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.phip.common.wx.corp.WeiXinCorpMpUtil; |
| | |
| | | private FamiliesRoomMapper familiesRoomMapper; |
| | | @Resource |
| | | private UserBeChangeLogMapper userBeChangeLogMapper; |
| | | @Resource |
| | | private DeductionSingleMapper deductionSingleMapper; |
| | | @Resource |
| | | private DeductionProjectMapper deductionProjectMapper; |
| | | @Resource |
| | | private DeductionJoinMapper deductionJoinMapper; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | /**处理用户科室关系*/ |
| | | /**处理用户科室关系-治疗单*/ |
| | | @Override |
| | | public void doctorRoomHandler(String treatSingleId) { |
| | | logger.info("-----新增治疗单,多线程处理用户科室关系----"); |
| | |
| | | } |
| | | } |
| | | |
| | | /**处理用户科室关系-划扣单*/ |
| | | @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()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /////////////////////////////////////////////////////////////////////////////// |
| | | |