fwq
2024-02-20 ef962a209dc322d971104c8359595af7b33e6772
治疗单处理用户科室关系
3个文件已修改
88 ■■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/treat/TreatV3Service.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java
@@ -12,6 +12,7 @@
import com.hx.phiappt.common.DeductionSingleConstants;
import com.hx.phiappt.common.RoleType;
import com.hx.phiappt.common.TreatSingleConstants;
import com.hx.phiappt.constants.tool.exception.ExceptionTool;
import com.hx.phiappt.dao.mapper.*;
import com.hx.phiappt.model.*;
import com.hx.phiappt.model.treat.TreatProject;
@@ -30,6 +31,7 @@
import com.hx.resultTool.Result;
import com.hx.util.DateUtil;
import com.hx.util.StringUtils;
import com.hx.util.thread.ExecutorServiceTool;
import com.platform.constants.PlatformPattern;
import com.platform.exception.PlatTipsException;
import com.platform.resultTool.PlatformCode;
@@ -121,10 +123,17 @@
        treatSingle.setUserId(visitOrder.getUserId());
        treatV3Service.add(treatSingle, projectList, visitOrder, employeeRole, isMicNotice, signList);
        //开启多线程处理用户科室关系
        ExecutorServiceTool fixedThreadPool = new ExecutorServiceTool(1, 1);
        try {
            fixedThreadPool.getThreadPool().execute(() -> treatV3Service.doctorRoomHandler(treatSingle.getId()));
        }catch (Exception e){
            logger.error("开启多线程处理用户科室关系失败"+ ExceptionTool.getExceptionInfo(e));
        }finally {
            fixedThreadPool.shutdown();
        }
        //返回id
        JSONObject data = new JSONObject();
        data.put("treatSingleId", treatSingle.getId());
phi_platform_user/src/main/java/com/hx/phip/service/treat/TreatV3Service.java
@@ -23,4 +23,7 @@
    /** 更新治疗单签名 */
    void updateSign(TreatSingle treatSingle, List<TreatSingleSign> signList, EmployeeRole employeeRole);
    /**处理用户科室关系*/
    void doctorRoomHandler(String treatSingleId);
}
phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java
@@ -1,5 +1,6 @@
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;
@@ -74,6 +75,11 @@
    private TreatProjectDoctorMapper treatProjectDoctorMapper;
    @Resource
    private TreatBodyPartMapper treatBodyPartMapper;
    @Resource
    private UserFamiliesRoomMapper userFamiliesRoomMapper;
    @Resource
    private FamiliesRoomMapper familiesRoomMapper;
@@ -444,6 +450,72 @@
    }
    /**处理用户科室关系*/
    @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));
                    }
                }
            }
        }
    }
    ///////////////////////////////////////////////////////////////////////////////