fhx
2024-08-01 7e52f375aea9e6315625d0ac0f7b69de199f433b
1.新增处理治疗单项目模式数据逻辑代码
3个文件已修改
92 ■■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java 22 ●●●●● 补丁 | 查看 | 原始文档 | 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 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java
@@ -122,9 +122,14 @@
        //开启多线程处理用户科室关系
        ExecutorServiceTool fixedThreadPool = new ExecutorServiceTool(1, 1);
        try {
            fixedThreadPool.getThreadPool().execute(() -> treatV3Service.doctorRoomHandler(treatSingle.getId()));
            fixedThreadPool.getThreadPool().execute(() ->{
                //处理用户科室关系
                treatV3Service.doctorRoomHandler(treatSingle.getId());
                //处理治疗单项目模式数据
                treatV3Service.handleModeData(projectList);
            });
        }catch (Exception e){
            logger.error("开启多线程处理用户科室关系失败"+ ExceptionTool.getExceptionInfo(e));
            logger.error("新增治疗单-开启多线程处理失败:"+ ExceptionTool.getExceptionInfo(e));
        }finally {
            fixedThreadPool.shutdown();
        }
@@ -204,6 +209,19 @@
            editSendMsg(treatSingle.getId(), visitOrder.getUserId());
        }
        //开启多线程处理
        ExecutorServiceTool fixedThreadPool = new ExecutorServiceTool(1, 1);
        try {
            fixedThreadPool.getThreadPool().execute(() ->{
                //处理治疗单项目模式数据
                treatV3Service.handleModeData(projectList);
            });
        }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
@@ -26,4 +26,7 @@
    /**处理用户科室关系*/
    void doctorRoomHandler(String treatSingleId);
    /** 处理治疗单模式数据 */
    void handleModeData(List<TreatProject> treatProjectList);
}
phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java
@@ -1,6 +1,8 @@
package com.hx.phip.service.treat.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hx.common.dao.CommonDao;
import com.hx.common.service.CommonService;
import com.hx.exception.TipsException;
@@ -20,6 +22,7 @@
import com.hx.phiappt.model.*;
import com.hx.phiappt.model.guide.VisitOrder;
import com.hx.phiappt.model.treat.*;
import com.hx.phiappt.vo.treat.TreatProjectModeDataVo;
import com.hx.phip.common.wx.corp.WeiXinCorpMpUtil;
import com.hx.phip.common.wx.corp.WeiXinMpUtil;
import com.hx.phip.config.CustomParameter;
@@ -77,7 +80,8 @@
    private UserBeChangeLogMapper userBeChangeLogMapper;
    @Resource
    private TreatSingleSignMapper treatSingleSignMapper;
    @Resource
    private SystemParameterMapper systemParameterMapper;
@@ -558,6 +562,67 @@
    }
    /** 处理治疗单模式数据 */
    public void handleModeData(List<TreatProject> treatProjectList){
        //先过滤出打法不为空的治疗单项目:项目名,打法
        Map<String, String> dataMap = treatProjectList.stream().filter(s->StringUtils.noNull(s.getItemMode())).collect(Collectors.toMap(TreatProject::getProjectName, TreatProject::getItemMode));
        if(dataMap == null || dataMap.size() < 1){
            return;
        }
        SystemParameter sp = systemParameterMapper.selectOneByName(SystemParameter.KEY_ZLD_PROJECT_MODE_DATA);
        List<TreatProjectModeDataVo> modeDataVoList = null;
        if(sp != null && StringUtils.isEmpty(sp.getParamValue())){
            modeDataVoList = JSONArray.parseArray(sp.getParamValue(), TreatProjectModeDataVo.class);
        }
        if(modeDataVoList == null){
            modeDataVoList = new ArrayList<>();
        }
        TreatProjectModeDataVo modeDataVo;
        for(Map.Entry<String, String> entry : dataMap.entrySet()){
            //没有时则
            if(modeDataVoList.size() == 0){
                modeDataVoList.add(new TreatProjectModeDataVo(entry.getKey(), entry.getValue()));
                continue;
            }
            for(int i = 0; i < modeDataVoList.size(); i++){
                modeDataVo = modeDataVoList.get(i);
                //有相同的项目名数据
                if(modeDataVo.getProjectName().equals(entry.getKey())){
                    //然后对应的打法不存在
                    if(!modeDataVo.getModeList().contains(entry.getValue())){
                        modeDataVo.getModeList().add(entry.getValue());
                        continue;
                    }
                }
                //最后一个时表示没匹配到,则新增
                if(i == modeDataVoList.size() - 1){
                    modeDataVoList.add(new TreatProjectModeDataVo(entry.getKey(), entry.getValue()));
                }
            }
        }
        if(modeDataVoList.size() < 1){
            return;
        }
        JSONArray arr = JSONArray.parseArray(JSONObject.toJSONString(modeDataVoList));
        if(sp == null){
            sp = new SystemParameter();
            sp.setParamName(SystemParameter.KEY_ZLD_PROJECT_MODE_DATA);
            sp.setParamValue(arr.toString());
            systemParameterMapper.insert(sp);
        }else{
            sp.setParamValue(arr.toString());
            systemParameterMapper.updateInfoById(sp);
        }
    }
    ///////////////////////////////////////////////////////////////////////////////
    //处理编辑治疗通知单时项目变动逻辑