| | |
| | | package com.hx.phip.service.treat.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.hx.common.dao.CommonDao; |
| | | import com.hx.common.service.CommonService; |
| | | import com.hx.exception.TipsException; |
| | |
| | | private TreatProjectDoctorMapper treatProjectDoctorMapper; |
| | | @Resource |
| | | private TreatBodyPartMapper treatBodyPartMapper; |
| | | @Resource |
| | | private UserFamiliesRoomMapper userFamiliesRoomMapper; |
| | | @Resource |
| | | private FamiliesRoomMapper familiesRoomMapper; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | /**处理用户科室关系*/ |
| | | @Override |
| | | public void doctorRoomHandler(String treatSingleId) { |
| | | logger.info("-----新增治疗单,多线程处理用户科室关系----"); |
| | | TreatSingle treatSingle = treatSingleMapper.selectOneByKey(treatSingleId); |
| | | if (treatSingle == null){ |
| | | logger.error("新增治疗单处理科室关系,查询治疗单失败"+treatSingleId); |
| | | return; |
| | | } |
| | | if (StringUtils.isEmpty(treatSingle.getUserId())){ |
| | | logger.error("新增治疗单处理科室关系,用户id为空"); |
| | | return; |
| | | } |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> sqlMap = new HashMap<>(); |
| | | sqlMap.put("isDel",BaseEntity.NO); |
| | | sqlMap.put("userId",treatSingle.getUserId()); |
| | | sqlMap.put("treatSingleId",treatSingleId); |
| | | sqlMap.put("type","doctor"); |
| | | 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 treat_project_doctor WHERE isDel = #{m.isDel} " + |
| | | " AND treatSingleId = #{m.treatSingleId} AND type = #{m.type} ",sqlMap); |
| | | List<TreatProjectDoctor> treatProjectDoctorList = treatProjectDoctorMapper.selectList(sqlSentence); |
| | | if (treatProjectDoctorList != null && treatProjectDoctorList.size() > 0){ |
| | | for (TreatProjectDoctor treatProjectDoctor : treatProjectDoctorList) { |
| | | if (StringUtils.isEmpty(treatProjectDoctor.getDepartmentId())){ |
| | | continue; |
| | | } |
| | | UserFamiliesRoom mapData = dataMap.get(treatProjectDoctor.getDepartmentId()); |
| | | if (mapData == null){ |
| | | //没有科室关系,创建科室关系 |
| | | FamiliesRoom familiesRoom = familiesRoomMapper.selectOneByKey(treatProjectDoctor.getDepartmentId()); |
| | | //找不到科室信息不处理 |
| | | if (familiesRoom == null){ |
| | | continue; |
| | | } |
| | | //不是皮肤科和注射科不处理 |
| | | if (!"注射科".equals(familiesRoom.getFamiliesRoomName()) && !"皮肤科".equals(familiesRoom.getFamiliesRoomName())){ |
| | | continue; |
| | | } |
| | | UserFamiliesRoom userFamiliesRoom = new UserFamiliesRoom(); |
| | | userFamiliesRoom.setUserId(treatSingle.getUserId()); |
| | | userFamiliesRoom.setFamiliesRoomId(treatProjectDoctor.getDepartmentId()); |
| | | userFamiliesRoom.setFamiliesRoomName(familiesRoom.getFamiliesRoomName()); |
| | | userFamiliesRoom.setDoctorId(treatProjectDoctor.getCommonId()); |
| | | Employee employee = employeeMapper.selectOneByKey(treatProjectDoctor.getCommonId()); |
| | | if (employee != null){ |
| | | userFamiliesRoom.setDoctorName(employee.getCnName()); |
| | | } |
| | | userFamiliesRoom.setIsDefault(0); |
| | | if (userFamiliesRoomMapper.insert(userFamiliesRoom) != 1){ |
| | | throw new TipsException("新增失败!"+ JSON.toJSONString(userFamiliesRoom)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /////////////////////////////////////////////////////////////////////////////// |
| | | |