fwq
2024-08-16 810c6cebf3ffae3335ad9d974599b7639d8a4f23
新增用户科室关系从治疗单改成划扣单
4个文件已修改
162 ■■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/controller/deduction/DeductionController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/treat/TreatV3Service.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
@@ -118,16 +118,16 @@
        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();
        }
//新版本在执行划扣做这个科室关系的存储
//        //开启多线程处理用户科室关系
//        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
@@ -24,6 +24,9 @@
    /** 更新治疗单签名 */
    void updateSign(TreatSingle treatSingle, List<TreatSingleSign> signList, EmployeeRole employeeRole);
    /**处理用户科室关系*/
    /**处理用户科室关系-治疗单*/
    void doctorRoomHandler(String treatSingleId);
    /**处理用户科室关系-划扣单*/
    void doctorRoomHandlerByDeduction(String deductionSingleId);
}
phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java
@@ -18,6 +18,9 @@
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;
@@ -75,6 +78,12 @@
    private FamiliesRoomMapper familiesRoomMapper;
    @Resource
    private UserBeChangeLogMapper userBeChangeLogMapper;
    @Resource
    private DeductionSingleMapper deductionSingleMapper;
    @Resource
    private DeductionProjectMapper deductionProjectMapper;
    @Resource
    private DeductionJoinMapper deductionJoinMapper;
@@ -446,7 +455,7 @@
    }
    /**处理用户科室关系*/
    /**处理用户科室关系-治疗单*/
    @Override
    public void doctorRoomHandler(String treatSingleId) {
        logger.info("-----新增治疗单,多线程处理用户科室关系----");
@@ -552,6 +561,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());
            }
        }
    }
    ///////////////////////////////////////////////////////////////////////////////