Andru
2023-12-22 7ee867936786bc685c26acd88c739f6eb58c32b9
添加撤销划扣发送消息给护士长
3个文件已修改
104 ■■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/controller/deduction/DeductionController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/deduction/DeductionSingleService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/deduction/impl/DeductionSingleServiceImpl.java 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/deduction/DeductionController.java
@@ -8,16 +8,13 @@
import com.hx.phiappt.common.DeductionSingleConstants;
import com.hx.phiappt.constants.tool.PerformanceInfoTool;
import com.hx.phiappt.constants.tool.user.UserProjectTool;
import com.hx.phiappt.dao.mapper.IntroProjectManualMapper;
import com.hx.phiappt.dao.mapper.NotificationLogMapper;
import com.hx.phiappt.dao.mapper.ProjectMapper;
import com.hx.phiappt.model.*;
import com.hx.phiappt.model.deduction.*;
import com.hx.phiappt.model.intro.IntroProjectManual;
import com.hx.phiappt.model.performance.PerformanceInfo;
import com.hx.phiappt.model.project.ProjectGeneral;
import com.hx.phip.config.CustomParameter;
import com.hx.phip.dao.mapper.ProjectGeneralMapper;
import com.hx.phip.dao.mapper.ShopMapper;
import com.hx.phip.dao.mapper.UserMapper;
import com.hx.phip.service.ComparePhotoRecordPicturesService;
@@ -424,6 +421,8 @@
        threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(deductionDto.getDeductionSingleId()));
        // 保妥适俱乐部撤回赠送优惠券
        threadPool.getThreadPool().execute(() -> deductionSingleService.cancelDeductionSingleCoupon(deductionDto.getDeductionSingleId()));
        // 作废划扣发通知给护士长
        threadPool.getThreadPool().execute(() -> deductionSingleService.cancelDeductionSingleSentNotice(deductionDto.getDeductionSingleId()));
        // 返回
        return Result.success();
    }
phi_platform_user/src/main/java/com/hx/phip/service/deduction/DeductionSingleService.java
@@ -63,4 +63,6 @@
    //作废划扣撤销保妥适俱乐部权益赠送的优惠券
    void cancelDeductionSingleCoupon(String deductionSingleId);
    void cancelDeductionSingleSentNotice(String deductionSingleId);
}
phi_platform_user/src/main/java/com/hx/phip/service/deduction/impl/DeductionSingleServiceImpl.java
@@ -4,14 +4,14 @@
import com.alibaba.fastjson.JSONObject;
import com.hx.common.service.CommonService;
import com.hx.exception.TipsException;
import com.hx.guide.model.VisitOrder;
import com.hx.guide.util.corp.messages.SendMessageToolV2;
import com.hx.mybatisTool.SqlSentence;
import com.hx.phiappt.common.*;
import com.hx.phiappt.constants.enums.WarehouseTypeEnum;
import com.hx.phiappt.constants.tool.CouponTool;
import com.hx.phiappt.constants.tool.PerformanceInfoTool;
import com.hx.phiappt.constants.tool.UserInfoTool;
import com.hx.phiappt.constants.tool.UserStatusTool;
import com.hx.phiappt.constants.tool.*;
import com.hx.phiappt.constants.tool.appointment.AppointmentTool;
import com.hx.phiappt.constants.tool.employee.EmployeeTool;
import com.hx.phiappt.constants.tool.user.UserLabelTool;
import com.hx.phiappt.constants.tool.user.UserLevelTool;
import com.hx.phiappt.dao.mapper.ProjectTypeMapper;
@@ -39,6 +39,8 @@
import com.hx.phiappt.model.warehouse.ShopWarehouseChange;
import com.hx.phiappt.model.warehouse.ShopWarehouseItem;
import com.hx.phiappt.model.warehouse.ShopWarehouseType;
import com.hx.phip.common.wx.corp.WeiXinCorpMpUtil;
import com.hx.phip.common.wx.corp.WeiXinMpUtil;
import com.hx.phip.config.BotoxClubConfig;
import com.hx.phip.config.CustomParameter;
import com.hx.phip.config.QuestionInvestigateConfig;
@@ -74,6 +76,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.MessageFormat;
import java.util.*;
@Transactional
@@ -4675,4 +4678,90 @@
            UserInfoTool.addUserUpdateLog(commonService, deductionSingle.getAppId(), user, shop.getId(), opEmployee.getId(), null, null, "调整用户科室关系数据", logArray, null, recordNo);
        }
    }
    /**
     * 作废划扣发通知给护士长
     * @param deductionSingleId 划扣编号
     */
    @Override
    public void cancelDeductionSingleSentNotice(String deductionSingleId) {
        try {
            // 判断划扣单
            DeductionSingle deductionSingle = deductionSingleMapper.selectOneByKey(deductionSingleId);
            if (deductionSingle == null) {
                throw new TipsException("划扣数据不存在!");
            }
            // 判断划扣项目
            DeductionProject deductionProject = this.getDeductionProjectBySingleId(deductionSingle.getId());
            if (deductionProject == null) {
                throw new TipsException("划扣项目数据不存在!");
            }
            // 判断划扣用户
            User user = commonService.selectOneByKey(UserMapper.class, deductionSingle.getUserId());
            if (user == null) {
                throw new TipsException("划扣用户数据不存在!");
            }
            // 判断是否有治疗单
            if (StringUtils.isEmpty(deductionSingle.getTreatSingleId())) {
                logger.info("作废划扣发通知给护士长提示,不存在治疗通知单!");
                return;
            }
            // 获取治疗单
            TreatSingle treatSingle = commonService.selectOneByKey(TreatSingleMapper.class, deductionSingle.getTreatSingleId());
            if (treatSingle == null) {
                throw new TipsException("划扣治疗单数据不存在!");
            }
            // 判断到访单
            if (StringUtils.isEmpty(treatSingle.getVisitOrderId())) {
                logger.info("作废划扣发通知给护士长提示,不存在到访单!");
                return;
            }
            // 获取到访单
            VisitOrder visitOrder = commonService.selectOneByKey(VisitOrderMapper.class, treatSingle.getVisitOrderId());
            if (visitOrder == null) {
                logger.info("作废划扣发通知给护士长提示,不存在到访单!");
                return;
            }
            // 获取执行护士
            String nurseInfo = null;
            DeductionJoin deductionName = this.getDeductionDoctorNameBySingleId(deductionSingleId, BaseEntity.NO);
            if (deductionName != null && !StringUtils.isEmpty(deductionName.getEmployeeName())) {
                nurseInfo = deductionName.getEmployeeName();
            }
            // 获取小程序消息token
            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异常!");
            }
            // 消息内容 作废划扣通知  客户, 项目,执行护士:
            String content;
            if (!StringUtils.isEmpty(nurseInfo)) {
                content = MessageFormat.format("作废划扣通知:{0},{1},{2}", user.getName(), deductionProject.getProjectName(), nurseInfo);
            } else {
                content = MessageFormat.format("作废划扣通知:{0},{1}", user.getName(), deductionProject.getProjectName());
            }
            // 发送企业微信通知给分配治疗药房
            if (!StringUtils.isEmpty(deductionSingle.getShopId())) {
                // 获取要发送的成员
                List<Employee> employees = EmployeeTool.getEmployeeByShopAndRoleList(commonService, deductionSingle.getShopId(), RoleType.UNIQUE_HEAD_NURSE);
                if (employees != null && employees.size() > 0) {
                    //发送企业微信通知药房
                    for (Employee employee : employees) {
                        // 企业服务消息提醒
                        String sendDate = SendMessageToolV2.sendDataByTreatOrderNoticeMic(visitOrder, employee, mpToken, "1000050", content);
                        if (StringUtils.isEmpty(sendDate)) {
                            continue;
                        }
                        SendMessageTool.sendMessge(sendDate, corpMpToken);
                    }
                }
            }
        } catch (Exception e) {
            logger.error("作废划扣发通知给护士长出错:", e);
        }
    }
}