fhx
2023-12-08 1c1cdff2c35f93adab954a6f8413f8cfd79c444d
1.修改治疗单发送通知逻辑
5个文件已修改
414 ■■■■■ 已修改文件
phi_platform_common/src/main/resources/mapper/platform/TreatSingleMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/treat/TreatV3Service.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java 98 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/util/api/TreatUtil.java 286 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/resources/mapper/platform/TreatSingleMapper.xml
@@ -8,7 +8,7 @@
    <!-- 整个实体类修改,表字段=实体类字段-->
    <sql id="Update_Column_All">
        <trim prefixOverrides=",">
            ,type = #{type},commonId = #{commonId},signData = #{signData},treatData = #{treatData},shopId = #{shopId},shopName = #{shopName},operatorId = #{operatorId},operatorName = #{operatorName},developerShopId = #{developerShopId},developerShopName = #{developerShopName},developerId = #{developerId},developerName = #{developerName},remarkInfo = #{remarkInfo},status = #{status},isLedProduct = #{isLedProduct},treatSingleNo = #{treatSingleNo},visitOrderId = #{visitOrderId},userConsultantId = #{userConsultantId},userConsultantName = #{userConsultantName},orderClassify = #{orderClassify},isKnow = #{isKnow},drugStatus = #{drugStatus},userId = #{userId},allergyInfo = #{allergyInfo},isWillPhoto = #{isWillPhoto},isFirstFm = #{isFirstFm},isRd = #{isRd},aDoctorId = #{aDoctorId},aDoctorName = #{aDoctorName},aNurseId = #{aNurseId},aNurseName = #{aNurseName},aMicId = #{aMicId},aRemark = #{aRemark},roomName = #{roomName},aTime = #{aTime},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime}
            ,type = #{type},commonId = #{commonId},signData = #{signData},treatData = #{treatData},shopId = #{shopId},shopName = #{shopName},operatorId = #{operatorId},operatorName = #{operatorName},developerShopId = #{developerShopId},developerShopName = #{developerShopName},developerId = #{developerId},developerName = #{developerName},remarkInfo = #{remarkInfo},status = #{status},isLedProduct = #{isLedProduct},treatSingleNo = #{treatSingleNo},visitOrderId = #{visitOrderId},userConsultantId = #{userConsultantId},userConsultantName = #{userConsultantName},orderClassify = #{orderClassify},isKnow = #{isKnow},drugStatus = #{drugStatus},userId = #{userId},allergyInfo = #{allergyInfo},isWillPhoto = #{isWillPhoto},isFirstFm = #{isFirstFm},isRd = #{isRd},anStatus = #{anStatus},aDoctorId = #{aDoctorId},aDoctorName = #{aDoctorName},aNurseId = #{aNurseId},aNurseName = #{aNurseName},aMicId = #{aMicId},aRemark = #{aRemark},roomName = #{roomName},aTime = #{aTime},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime}
        </trim>
    </sql>
     
@@ -19,11 +19,11 @@
        <selectKey keyProperty="id" resultType="String" order="BEFORE">
               select replace(uuid(),'-','') from dual
        </selectKey>
        insert into treat_single (id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime)  values (#{id},#{type},#{commonId},#{signData},#{treatData},#{shopId},#{shopName},#{operatorId},#{operatorName},#{developerShopId},#{developerShopName},#{developerId},#{developerName},#{remarkInfo},#{status},#{isLedProduct},#{treatSingleNo},#{visitOrderId},#{userConsultantId},#{userConsultantName},#{orderClassify},#{isKnow},#{drugStatus},#{userId},#{allergyInfo},#{isWillPhoto},#{isFirstFm},#{isRd},#{aDoctorId},#{aDoctorName},#{aNurseId},#{aNurseName},#{aMicId},#{aRemark},#{roomName},#{aTime},#{isDel},#{createTime},#{editTime})
        insert into treat_single (id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,anStatus,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime)  values (#{id},#{type},#{commonId},#{signData},#{treatData},#{shopId},#{shopName},#{operatorId},#{operatorName},#{developerShopId},#{developerShopName},#{developerId},#{developerName},#{remarkInfo},#{status},#{isLedProduct},#{treatSingleNo},#{visitOrderId},#{userConsultantId},#{userConsultantName},#{orderClassify},#{isKnow},#{drugStatus},#{userId},#{allergyInfo},#{isWillPhoto},#{isFirstFm},#{isRd},#{anStatus},#{aDoctorId},#{aDoctorName},#{aNurseId},#{aNurseName},#{aMicId},#{aRemark},#{roomName},#{aTime},#{isDel},#{createTime},#{editTime})
    </insert>
    <insert id="insertById" parameterType="com.hx.phiappt.model.treat.TreatSingle">
        insert into treat_single (id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime)  values (#{id},#{type},#{commonId},#{signData},#{treatData},#{shopId},#{shopName},#{operatorId},#{operatorName},#{developerShopId},#{developerShopName},#{developerId},#{developerName},#{remarkInfo},#{status},#{isLedProduct},#{treatSingleNo},#{visitOrderId},#{userConsultantId},#{userConsultantName},#{orderClassify},#{isKnow},#{drugStatus},#{userId},#{allergyInfo},#{isWillPhoto},#{isFirstFm},#{isRd},#{aDoctorId},#{aDoctorName},#{aNurseId},#{aNurseName},#{aMicId},#{aRemark},#{roomName},#{aTime},#{isDel},#{createTime},#{editTime})
        insert into treat_single (id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,anStatus,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime)  values (#{id},#{type},#{commonId},#{signData},#{treatData},#{shopId},#{shopName},#{operatorId},#{operatorName},#{developerShopId},#{developerShopName},#{developerId},#{developerName},#{remarkInfo},#{status},#{isLedProduct},#{treatSingleNo},#{visitOrderId},#{userConsultantId},#{userConsultantName},#{orderClassify},#{isKnow},#{drugStatus},#{userId},#{allergyInfo},#{isWillPhoto},#{isFirstFm},#{isRd},#{anStatus},#{aDoctorId},#{aDoctorName},#{aNurseId},#{aNurseName},#{aMicId},#{aRemark},#{roomName},#{aTime},#{isDel},#{createTime},#{editTime})
    </insert>
    <select id="selectList" resultType="com.hx.phiappt.model.treat.TreatSingle" parameterType="com.hx.mybatisTool.SqlSentence" >
@@ -55,14 +55,14 @@
    <select id="selectOneByKey" resultType="com.hx.phiappt.model.treat.TreatSingle" parameterType="java.lang.Object" >
        select 
            id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime
            id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,anStatus,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime
        from treat_single
        WHERE id = #{value}
    </select>
    <select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.treat.TreatSingle" parameterType="java.lang.Object" >
        select 
            id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime
            id,type,commonId,signData,treatData,shopId,shopName,operatorId,operatorName,developerShopId,developerShopName,developerId,developerName,remarkInfo,status,isLedProduct,treatSingleNo,visitOrderId,userConsultantId,userConsultantName,orderClassify,isKnow,drugStatus,userId,allergyInfo,isWillPhoto,isFirstFm,isRd,anStatus,aDoctorId,aDoctorName,aNurseId,aNurseName,aMicId,aRemark,roomName,aTime,isDel,createTime,editTime
        from treat_single
        WHERE id = #{value}
    </select>
phi_platform_user/src/main/java/com/hx/phip/controller/treat/TreatController.java
@@ -92,6 +92,12 @@
        //校验参数
        checkTreatSingleParam(true, treatSingle, signList);
        //判断是否发送通知MIC分配治疗
        Integer isMicNotice = BaseEntity.NO;
//        if(reqVo.getIsMicNotice() != null && reqVo.getIsMicNotice() == BaseEntity.YES){
//            isMicNotice = BaseEntity.YES;
//        }
        //治疗单项目
        List<TreatProject> projectList = reqVo.getProjectList();
        if (projectList == null || projectList.size() == 0) {
@@ -113,7 +119,9 @@
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到到访订单信息");
        }
        treatSingle.setUserId(visitOrder.getUserId());
        treatV3Service.add(treatSingle, projectList, visitOrder, employeeRole,0, signList);
        treatV3Service.add(treatSingle, projectList, visitOrder, employeeRole, isMicNotice, signList);
        //返回id
        JSONObject data = new JSONObject();
@@ -152,6 +160,12 @@
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "未找到");
        }
//        //判断是否发送通知MIC分配治疗(如果治疗单分配医生不为空,则不继续通知MIC)
//        Integer isMicNotice = BaseEntity.NO;
//        if(reqVo.getIsMicNotice() != null && reqVo.getIsMicNotice() == BaseEntity.YES
//                && StringUtils.noNull(updateTreat.getaDoctorId())){
//            isMicNotice = BaseEntity.YES;
//        }
        if(updateTreat.getStatus() == TreatSingleConstants.STATUS_CANCEL){
            throwParamException("作废治疗通知单不可修改!");
@@ -173,6 +187,8 @@
        //修改
        treatSingle.setTreatSingleNo(updateTreat.getTreatSingleNo());
        treatSingle.setCommonId(updateTreat.getCommonId());
        treatSingle.setaNurseId(updateTreat.getaNurseId());
        treatSingle.setaDoctorId(updateTreat.getaDoctorId());
        treatV3Service.edit(treatSingle, projectList, visitOrder, employeeRole, updateTreat, signList);
        //当状态是 待确认 发送短信给客户确认
phi_platform_user/src/main/java/com/hx/phip/service/treat/TreatV3Service.java
@@ -14,7 +14,7 @@
    /** 新增治疗通知单 */
    void add(TreatSingle treatSingle, List<TreatProject> projectList, VisitOrder visitOrder
            , EmployeeRole employeeRole, Integer smsType, List<TreatSingleSign> signList);
            , EmployeeRole employeeRole, Integer isMicNotice, List<TreatSingleSign> signList);
    /** 编辑治疗通知单 */
    void edit(TreatSingle treatSingle, List<TreatProject> projectList, VisitOrder visitOrder
            , EmployeeRole employeeRole, TreatSingle updateTreat, List<TreatSingleSign> signList);
phi_platform_user/src/main/java/com/hx/phip/service/treat/impl/TreatV3ServiceImpl.java
@@ -80,7 +80,7 @@
    /** 新增治疗通知单 */
    @Override
    public void add(TreatSingle treatSingle, List<TreatProject> projectList, VisitOrder visitOrder
            , EmployeeRole employeeRole, Integer smsType, List<TreatSingleSign> signList) {
            , EmployeeRole employeeRole, Integer isMicNotice, List<TreatSingleSign> signList) {
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> values = new HashMap<>();
@@ -158,84 +158,29 @@
        //处理治疗单签名-------------------------------------------------------------------------
        handleSignData(signList, treatSingle.getId(), false);
        //判断状态是如果是待发生短信状态,则发送短信------------------------------------------
        if (treatSingle.getStatus() == TreatSingleConstants.STATUS_WAIT_SEND_SMS) {
            //通过预约id查询到预约信息获取用户手机号
            values.put("commonId", treatSingle.getCommonId());
            sqlSentence.setSqlSentence("select u.tel from appointment a  left join user u on u.id=a.userId where a.id =#{m.commonId} and u.isDel=0 and a.isDel=0 ");
            Map<String, Object> map = userMapper.selectOneMap(sqlSentence);
            //手机号不为空时
            if (map.containsKey("tel") && !StringUtils.isEmpty(map.get("tel").toString())) {
                if (PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) {
                    map.put("treatSingleId", treatSingle.getId());
                    JSONObject jsonObject = CrmUtil.sendCrmSMS(map, commonService, smsType);
                    //发送短信
                    if (jsonObject.getInt("code") == 0) {
                        values.put("status", TreatSingleConstants.STATUS_WAIT_CONFIRM);
                        values.put("id", treatSingle.getId());
                        sqlSentence.setM(values);
                        //判断返回结果发送成功修改状态为:待确认(已发送短信待客户确认)
                        sqlSentence.setSqlSentence("status=#{m.status} where id=#{m.id} ");
                        int u = treatSingleMapper.updateWhere(sqlSentence);
                        if (u < 1) {
                            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "状态更新失败");
                        }
                    }
                } else {
                    JSONObject jsonObject = null;
                    //发送短信
                    jsonObject = SendSMSTool.msgSend("测试服假链接" + "https://wxaurl.cn/66666666", map.get("tel").toString(), "", 1);
                    if (jsonObject == null || !jsonObject.containsKey("code") || jsonObject.getInt("code") != 0) {
                        throw new PlatTipsException(PlatformCode.ERROR_TIPS, "发送短信失败");
                    }
                    values.clear();
                    values.put("status", TreatSingleConstants.STATUS_WAIT_CONFIRM);
                    values.put("id", treatSingle.getId());
                    sqlSentence.setM(values);
                    //判断返回结果发送成功修改状态为:待确认(已发送短信待客户确认)
                    sqlSentence.setSqlSentence("status=#{m.status} where id=#{m.id} ");
                    int u = treatSingleMapper.updateWhere(sqlSentence);
                    if (u < 1) {
                        throw new PlatTipsException(PlatformCode.ERROR_TIPS, "状态更新失败");
                    }
                }
            } else {
                throw new PlatTipsException(PlatformCode.ERROR_TIPS, "客户手机号为空!");
            }
        }
        //新增治疗单日志
        StringBuffer logInfo = TreatSingleLogTool.addLogInfo(treatSingle, projectList);
        TreatSingleLogTool.addLog(commonService, TreatSingleConstants.LOG_TYPE_CREATE, treatSingle, employeeRole, logInfo.toString());
        //所有状态下都发送治疗通知单给MIC
        //发送企业微信通知MIC进行分配治疗(正式环境才发)
        if (treatSingle != null && StringUtils.noNull(treatSingle.getCommonId()) && smsType == 0
                && PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) {
            try{
                String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId());
                String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId());
                if(StringUtils.isEmpty(mpToken)){
                    throw new TipsException("获取小程序Token异常!");
                }
                if(StringUtils.isEmpty(corpMpToken)){
                    throw new TipsException("获取企业应用小程序Token异常!");
                }
                TreatUtil.sendTreatNoticeShopMic(commonService, visitOrder, TreatUtil.NOTICE_TYPE_ADD, "1000050", mpToken, corpMpToken, doctorName, projectNameSb.toString());
//                TreatUtil.sendTreatNoticeShopMic(visitOrder, customParameter, "add", commonService);
            }catch (Exception e){
                logger.error("新增治疗单发送企业消息失败:{}", e.getMessage());
                logger.error(GlobalExceptionHandler.getExceptionInformation(e));
            }
        }
//        //修改治疗通知单之前将被修改的医生、护士、mic发送企业微信通知
//        if (treatSingle != null && StringUtils.noNull(treatSingle.getCommonId()) && smsType == 1) {
//            TreatUtil.editTreatNotice1(visitOrder, treatSingle, customParameter, commonService);
//        //所有状态下都发送治疗通知单给MIC
//        //发送企业微信通知MIC进行分配治疗(正式环境才发)
//        if (isMicNotice == BaseEntity.YES  && PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) {
//            try{
//                String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId());
//                String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId());
//                if(StringUtils.isEmpty(mpToken)){
//                    throw new TipsException("获取小程序Token异常!");
//        }
//                if(StringUtils.isEmpty(corpMpToken)){
//                    throw new TipsException("获取企业应用小程序Token异常!");
//                }
//                TreatUtil.sendTreatNoticeShopMic(commonService, visitOrder, TreatUtil.NOTICE_TYPE_ADD, "1000050", mpToken, corpMpToken, doctorName, projectNameSb.toString());
//            }catch (Exception e){
//                logger.error("新增治疗单发送企业消息失败:{}", e.getMessage());
//                logger.error(GlobalExceptionHandler.getExceptionInformation(e));
//            }
//        }
    }
    /** 编辑治疗通知单 */
@@ -343,7 +288,6 @@
        if ((treatSingle.getStatus()==TreatSingleConstants.STATUS_WAIT_CONFIRM
                || treatSingle.getStatus() == TreatSingleConstants.STATUS_CONFIRM )
             && PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) {
//                TreatUtil.editTreatNotice1(visitOrder, treatSingle, customParameter, commonService);
            try{
                String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId());
                String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId());
@@ -353,9 +297,7 @@
                if(StringUtils.isEmpty(corpMpToken)){
                    throw new TipsException("获取企业应用小程序Token异常!");
                }
                TreatUtil.editTreatNotice1(commonService, visitOrder, treatSingle, TreatUtil.NOTICE_TYPE_EDIT
                        , customParameter.getCorpMpAppId(), "1000050", mpToken, corpMpToken
                        , MapUtil.getString(pMap, "doctorName"), MapUtil.getString(pMap, "projectName"));
                TreatUtil.editTreatNotice2(commonService, visitOrder, treatSingle , customParameter.getCorpMpAppId(), corpMpToken);
            }catch (Exception e){
                logger.error("编辑治疗单发送企业消息失败:{}", e.getMessage());
                logger.error(GlobalExceptionHandler.getExceptionInformation(e));
phi_platform_user/src/main/java/com/hx/phip/util/api/TreatUtil.java
@@ -609,18 +609,170 @@
        }
    }
    /**
     * 修改治疗通知单之前将被修改的医生、护士、mic发送企业微信通知
     * 未获取到医生id时 拿到访单中的分诊医生id 若为空则拿预约单中的医生id 以上都为空时直接不发短信
     *
     */
    public static void editTreatNotice1(CommonService commonService, VisitOrder visitOrder,TreatSingle treatSingle
            , String noticeType, String corpMpAppId, String corpAgentId, String mpToken, String corpMpToken
            , String doctorName, String projectName) {
//    /**
//     * 修改治疗通知单之前将被修改的医生、护士、mic发送企业微信通知
//     * 未获取到医生id时 拿到访单中的分诊医生id 若为空则拿预约单中的医生id 以上都为空时直接不发短信
//     *
//     */
//    public static void editTreatNotice1(CommonService commonService, VisitOrder visitOrder,TreatSingle treatSingle
//            , String noticeType, String corpMpAppId, String corpAgentId, String mpToken, String corpMpToken
//            , String doctorName, String projectName) {
//
//        sendTreatNoticeShopMic(commonService, visitOrder, noticeType, corpAgentId, mpToken, corpMpToken, doctorName, projectName);
//
//        //---------------------------------------------------------------------------------------------------------------
//
//        SqlSentence sqlSentence = new SqlSentence();
//        Map<String, Object> map = new HashMap<>();
//        sqlSentence.setM(map);
//
//        //获取治疗通知单关联医生信息
//        map.put("treatSingleId", treatSingle.getId());
//        sqlSentence.setSqlSentence("SELECT * from treat_project_doctor WHERE isDel=0 and treatSingleId=#{m.treatSingleId} GROUP BY commonId ");
//        List<TreatProjectDoctor> treatProjectDoctors = commonService.selectList(TreatProjectDoctorMapper.class, sqlSentence);
//
//        //查看医生、护士、项目信息
//        Map<String, String> dataMap = selectProjectDoctorNurse(visitOrder.getAppointmentId(), visitOrder.getMicId() == null ? null : visitOrder.getMicId(), treatSingle, commonService);
//
//        //获取用户
//        User user = commonService.selectOneByKey(UserMapper.class, visitOrder.getUserId());
//        if (user == null) {
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单:发送企业微信通知:根据导医预约单用户标识找不到该用户");
//        }
//        //获取门店
//        Shop shop = commonService.selectOneByKey(ShopMapper.class, visitOrder.getShopId());
//        if (shop == null) {
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单:发送企业微信通知:根据该导医预约单门店标识找不到该门店信息");
//        }
//        //获取预约
//        Appointment appointment = commonService.selectOneByKeyBlob(AppointmentMapper.class, visitOrder.getAppointmentId());
//        if (appointment == null) {
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单:发送企业微信通知:根据该导医预约单预约标识查询不到预约单");
//        }
//
//        //定义常量
//        String sendDate;
//
//        //判断治疗单医生信息不为空时
//        if (treatProjectDoctors != null && treatProjectDoctors.size() > 0) {
//            //发送企业微信通知医生或者护士
//            for (TreatProjectDoctor treatProjectDoctor : treatProjectDoctors) {
//                if (StringUtils.noNull(treatProjectDoctor.getCommonId())) {
//                    //判断角色
//                    switch (treatProjectDoctor.getType()) {
//                        case RoleType.UNIQUE_STR_DOCTOR:
//                            //查询医生
//                            Employee doctorEmployee = commonService.selectOneByKey(EmployeeMapper.class, treatProjectDoctor.getCommonId());
//                            if (doctorEmployee != null) {
//                                sendDate = MessageContent.treatDoctor(doctorEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), dataMap.get("relatedName"), dataMap.get("remarkInfo"));
//                                SendMessageTool.sendMessge(sendDate, corpMpToken);
//
//
//                                //生成日志(最近记录)
//                                doctorEmployee.setRoleStr(RoleType.UNIQUE_STR_DOCTOR);
//                                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给医生", doctorEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//                                //导医记录
//                                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单发送通知医生", doctorEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//
//                            }
//                            break;
//                        case RoleType.UNIQUE_STR_NURSE:
//                            //查询护士
//                            Employee nurseEmployee = commonService.selectOneByKey(EmployeeMapper.class, treatProjectDoctor.getCommonId());
//                            if (nurseEmployee != null) {
//                                sendDate = MessageContent.treatNurse(nurseEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), dataMap.get("relatedName"), dataMap.get("remarkInfo"));
//                                SendMessageTool.sendMessge(sendDate, corpMpToken);
//
//                                //生成日志(最近记录)
//                                nurseEmployee.setRoleStr(RoleType.UNIQUE_STR_NURSE);
//                                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给护士", nurseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//                                //导医记录
//                                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单发送通知护士", nurseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//                            }
//                            break;
//                    }
//                }
//            }
//        }
//        //判断 治疗单关联医生信息为空时
//        else {
//
//            ///-----发送企业微信通知给医生  优先获取分诊时的医生id,如果分诊医生id为空时则获取预约单中的医生id,若两个都为空,则为null
//            String doctorId = null;
//            if (!StringUtils.isEmpty(visitOrder.geteDoctorId())) {
//                doctorId = visitOrder.geteDoctorId();
//            } else if (!StringUtils.isEmpty(visitOrder.gettDoctorId())) {
//                doctorId = visitOrder.gettDoctorId();
//            } else if (!StringUtils.isEmpty(appointment.getDoctorId())) {
//                doctorId = appointment.getDoctorId();
//            }
//
//            logger.info("修改治疗通知单发送企业微信通知获取医生id:---" + doctorId);
//
//            //判断是否为空
//            if (!StringUtils.isEmpty(doctorId)) {
//                //获取医生信息
//                Employee docEmployee = commonService.selectOneByKey(EmployeeMapper.class, doctorId);
//                if (docEmployee != null) {
//                    sendDate = MessageContent.treatDoctor(docEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), docEmployee.getCnName(), dataMap.get("remarkInfo"));
//                    SendMessageTool.sendMessge(sendDate, corpMpToken);
//
//                    //生成日志(最近记录)
//                    docEmployee.setRoleStr(RoleType.UNIQUE_STR_DOCTOR);
//                    addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给医生", docEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//                    //导医记录
//                    addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单,发送企业通知给医生", docEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//                }
//            }
//
//            ///-----发送企业微信通知给护士  优先获取分诊时的护士id,如果分诊护士id为空时则获取预约单中的护士id,若两个都为空,则为null
//            String nurseId = null;
//            if (!StringUtils.isEmpty(visitOrder.geteNurseId())) {
//                nurseId = visitOrder.geteNurseId();
//            } else if (!StringUtils.isEmpty(visitOrder.gettNurseId())) {
//                nurseId = visitOrder.gettNurseId();
//            } else if (!StringUtils.isEmpty(appointment.getNurseId())) {
//                nurseId = appointment.getNurseId();
//            }
//            logger.info("修改治疗通知单发送企业微信通知获取护士id:---" + nurseId);
//
//            if (!StringUtils.isEmpty(nurseId)) {
//                Employee nurEmployee = commonService.selectOneByKey(EmployeeMapper.class, nurseId);
//                if (nurEmployee != null) {
//                    sendDate = MessageContent.treatNurse(nurEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), nurEmployee.getCnName(), dataMap.get("remarkInfo"));
//                    SendMessageTool.sendMessge(sendDate, corpMpToken);
//
//                    //生成日志(最近记录)
//                    nurEmployee.setRoleStr(RoleType.UNIQUE_STR_NURSE);
//                    addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "发送企业通知", "修改治疗通知单:发送企业通知给护士,已成功发送给护士", nurEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//                    //导医记录
//                    addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单:发送企业通知给护士", nurEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//
//                }
//            }
//        }
//
//
//        // 发送企业微信通知给顾问  优先获取分诊时的顾问id,如果分诊顾问id为空时则获取预约单中的顾问id,若两个都为空,则为null
//        if (!StringUtils.isEmpty(visitOrder.getAdviserId())) {
//            Employee adviseEmployee = commonService.selectOneByKey(EmployeeMapper.class, visitOrder.getAdviserId());
//            if (adviseEmployee != null) {
//                sendDate = treatAdviser(adviseEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), adviseEmployee.getCnName(), dataMap.get("remarkInfo"));
//                SendMessageTool.sendMessge(sendDate, corpMpToken);
//
//                //生成日志(最近记录)
//                adviseEmployee.setRoleStr(RoleType.UNIQUE_STR_ADVISER_LEADER);
//                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "发送企业通知", "修改治疗通知单:发送企业通知给顾问,已成功发送给顾问", adviseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//                //导医记录
//                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单:发送企业通知给顾问", adviseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
//            }
//        }
//
//    }
        sendTreatNoticeShopMic(commonService, visitOrder, noticeType, corpAgentId, mpToken, corpMpToken, doctorName, projectName);
    public static void editTreatNotice2(CommonService commonService, VisitOrder visitOrder,TreatSingle treatSingle
            , String corpMpAppId, String corpMpToken) {
        //---------------------------------------------------------------------------------------------------------------
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> map = new HashMap<>();
@@ -652,119 +804,57 @@
        //定义常量
        String sendDate;
        Employee employee;
        //判断治疗单医生信息不为空时
        if (treatProjectDoctors != null && treatProjectDoctors.size() > 0) {
            //发送企业微信通知医生或者护士
            //发送企业微信通知医生或
            for (TreatProjectDoctor treatProjectDoctor : treatProjectDoctors) {
                if (StringUtils.noNull(treatProjectDoctor.getCommonId())) {
                    //判断角色
                    switch (treatProjectDoctor.getType()) {
                        case RoleType.UNIQUE_STR_DOCTOR:
                if (StringUtils.noNull(treatProjectDoctor.getCommonId()) && RoleType.UNIQUE_STR_DOCTOR.equals(treatProjectDoctor.getType())) {
                            //查询医生
                            Employee doctorEmployee = commonService.selectOneByKey(EmployeeMapper.class, treatProjectDoctor.getCommonId());
                            if (doctorEmployee != null) {
                                sendDate = MessageContent.treatDoctor(doctorEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), dataMap.get("relatedName"), dataMap.get("remarkInfo"));
                                SendMessageTool.sendMessge(sendDate, corpMpToken);
                                //生成日志(最近记录)
                                doctorEmployee.setRoleStr(RoleType.UNIQUE_STR_DOCTOR);
                                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给医生", doctorEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                                //导医记录
                                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单发送通知医生", doctorEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                            }
                            break;
                        case RoleType.UNIQUE_STR_NURSE:
                            //查询护士
                            Employee nurseEmployee = commonService.selectOneByKey(EmployeeMapper.class, treatProjectDoctor.getCommonId());
                            if (nurseEmployee != null) {
                                sendDate = MessageContent.treatNurse(nurseEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), dataMap.get("relatedName"), dataMap.get("remarkInfo"));
                    employee = commonService.selectOneByKey(EmployeeMapper.class, treatProjectDoctor.getCommonId());
                    if (employee != null) {
                        sendDate = MessageContent.treatDoctor(employee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), dataMap.get("relatedName"), dataMap.get("remarkInfo"));
                                SendMessageTool.sendMessge(sendDate, corpMpToken);
                                //生成日志(最近记录)
                                nurseEmployee.setRoleStr(RoleType.UNIQUE_STR_NURSE);
                                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给护士", nurseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                        employee.setRoleStr(RoleType.UNIQUE_STR_DOCTOR);
                        addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给医生", employee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                                //导医记录
                                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单发送通知护士", nurseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                            }
                            break;
                    }
                }
            }
        }
        //判断 治疗单关联医生信息为空时
        else {
                        addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单发送通知医生", employee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
            ///-----发送企业微信通知给医生  优先获取分诊时的医生id,如果分诊医生id为空时则获取预约单中的医生id,若两个都为空,则为null
            String doctorId = null;
            if (!StringUtils.isEmpty(visitOrder.geteDoctorId())) {
                doctorId = visitOrder.geteDoctorId();
            } else if (!StringUtils.isEmpty(visitOrder.gettDoctorId())) {
                doctorId = visitOrder.gettDoctorId();
            } else if (!StringUtils.isEmpty(appointment.getDoctorId())) {
                doctorId = appointment.getDoctorId();
                    }
                }
            }
            }
            logger.info("修改治疗通知单发送企业微信通知获取医生id:---" + doctorId);
            //判断是否为空
            if (!StringUtils.isEmpty(doctorId)) {
                //获取医生信息
                Employee docEmployee = commonService.selectOneByKey(EmployeeMapper.class, doctorId);
                if (docEmployee != null) {
                    sendDate = MessageContent.treatDoctor(docEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), docEmployee.getCnName(), dataMap.get("remarkInfo"));
        // 发送企业微信通知给分配治疗护士
        if (!StringUtils.isEmpty(treatSingle.getaNurseId())) {
            employee = commonService.selectOneByKey(EmployeeMapper.class, treatSingle.getaNurseId());
            if (employee != null) {
                sendDate = MessageContent.treatNurse(employee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), dataMap.get("relatedName"), dataMap.get("remarkInfo"));
                    SendMessageTool.sendMessge(sendDate, corpMpToken);
                    //生成日志(最近记录)
                    docEmployee.setRoleStr(RoleType.UNIQUE_STR_DOCTOR);
                    addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给医生", docEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                employee.setRoleStr(RoleType.UNIQUE_STR_NURSE);
                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "修改治疗通知单发送通知", "修改治疗通知单:已成功发送给护士", employee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                    //导医记录
                    addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单,发送企业通知给医生", docEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单发送通知护士", employee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                }
            }
            ///-----发送企业微信通知给护士  优先获取分诊时的护士id,如果分诊护士id为空时则获取预约单中的护士id,若两个都为空,则为null
            String nurseId = null;
            if (!StringUtils.isEmpty(visitOrder.geteNurseId())) {
                nurseId = visitOrder.geteNurseId();
            } else if (!StringUtils.isEmpty(visitOrder.gettNurseId())) {
                nurseId = visitOrder.gettNurseId();
            } else if (!StringUtils.isEmpty(appointment.getNurseId())) {
                nurseId = appointment.getNurseId();
            }
            logger.info("修改治疗通知单发送企业微信通知获取护士id:---" + nurseId);
            if (!StringUtils.isEmpty(nurseId)) {
                Employee nurEmployee = commonService.selectOneByKey(EmployeeMapper.class, nurseId);
                if (nurEmployee != null) {
                    sendDate = MessageContent.treatNurse(nurEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), nurEmployee.getCnName(), dataMap.get("remarkInfo"));
                    SendMessageTool.sendMessge(sendDate, corpMpToken);
                    //生成日志(最近记录)
                    nurEmployee.setRoleStr(RoleType.UNIQUE_STR_NURSE);
                    addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "发送企业通知", "修改治疗通知单:发送企业通知给护士,已成功发送给护士", nurEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                    //导医记录
                    addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单:发送企业通知给护士", nurEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                }
            }
        }
        // 发送企业微信通知给顾问  优先获取分诊时的顾问id,如果分诊顾问id为空时则获取预约单中的顾问id,若两个都为空,则为null
        if (!StringUtils.isEmpty(visitOrder.getAdviserId())) {
            Employee adviseEmployee = commonService.selectOneByKey(EmployeeMapper.class, visitOrder.getAdviserId());
            if (adviseEmployee != null) {
                sendDate = treatAdviser(adviseEmployee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), adviseEmployee.getCnName(), dataMap.get("remarkInfo"));
            employee = commonService.selectOneByKey(EmployeeMapper.class, visitOrder.getAdviserId());
            if (employee != null) {
                sendDate = treatAdviser(employee.getUserId(), corpMpAppId, visitOrder.getVisitNo(), user.getName(), shop.getName(), dataMap.get("projectName"), dataMap.get("num"), employee.getCnName(), dataMap.get("remarkInfo"));
                SendMessageTool.sendMessge(sendDate, corpMpToken);
                //生成日志(最近记录)
                adviseEmployee.setRoleStr(RoleType.UNIQUE_STR_ADVISER_LEADER);
                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "发送企业通知", "修改治疗通知单:发送企业通知给顾问,已成功发送给顾问", adviseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                employee.setRoleStr(RoleType.UNIQUE_STR_ADVISER_LEADER);
                addLatelyLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), "发送企业通知", "修改治疗通知单:发送企业通知给顾问,已成功发送给顾问", employee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                //导医记录
                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单:发送企业通知给顾问", adviseEmployee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
                addVGuideLogToEmployee(VisitOrderLogConstants.LOG_TYPE_NOTICE, visitOrder.getStatus(), visitOrder.getStatus(), visitOrder.getPreStartTime(), new Date(), 0, "修改治疗通知单:发送企业通知给顾问", employee, visitOrder.getId(), visitOrder.getShopId(), visitOrder.getUserId(), commonService);
            }
        }