cuilei
7 天以前 1563fa33e203959c80ee713ffff3cad2f825b098
设备维修新增报修时触发消息推送(客户现场要求)
已修改1个文件
48 ■■■■■ 文件已修改
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java
@@ -20,13 +20,20 @@
import org.jeecg.modules.eam.request.EamReportRepairQuery;
import org.jeecg.modules.eam.service.IEamEquipmentExtendService;
import org.jeecg.modules.eam.service.IEamEquipmentFaultReasonService;
import org.jeecg.modules.eam.service.IEamEquipmentService;
import org.jeecg.modules.eam.service.IEamReportRepairService;
import org.jeecg.modules.eam.vo.EquipmentRepairListVO;
import org.jeecg.modules.eam.vo.EquipmentRepairStatistics;
import org.jeecg.modules.eam.vo.EquipmentRepairStatusStatistics;
import org.jeecg.modules.eam.vo.FaultTypeStatisticsVO;
import org.jeecg.modules.qywx.message.vo.TemplateCard;
import org.jeecg.modules.qywx.message.vo.TemplateCardEntity;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
import org.jeecg.modules.system.vo.UserSelector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
@@ -34,6 +41,7 @@
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @Description: 故障报修
@@ -49,6 +57,15 @@
    private IMdcProductionService mdcProductionService;
    @Autowired
    private IEamEquipmentFaultReasonService eamEquipmentFaultReasonService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private IEamEquipmentService eamEquipmentService;
    @Autowired
    private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
    @Value("${wechatEnterprise.cardActionUrl}")
    private String cardActionUrl;
    /**
     * 分页列表
@@ -198,9 +215,40 @@
        this.baseMapper.insert(eamReportRepair);
        //更新设备维修状态
        eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name());
        //推送企业微信消息
        sendQywxTemplateCardMessage(eamReportRepair);
        return eamReportRepair;
    }
    private void sendQywxTemplateCardMessage(EamReportRepair eamReportRepair) {
        TemplateCard templateCard = new TemplateCard();
        String equipmentId = eamReportRepair.getEquipmentId();
        EamEquipment equipment = eamEquipmentService.getById(equipmentId);
        if (equipment != null) {
            //查询有该设备权限的所有维修工
            String productionId = equipment.getOrgId();
            List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), productionId, BusinessCodeConst.PCR0002);
            String toUsers = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.joining(","));
            String touser = wechatEnterpriseService.getTouser(toUsers, false);
            templateCard.setTouser(touser);
            TemplateCardEntity templateCardEntity = new TemplateCardEntity();
            templateCard.setTemplate_card(templateCardEntity);
            templateCardEntity.setTask_id(eamReportRepair.getId());
            TemplateCardEntity.MainTitle mainTitle = new TemplateCardEntity.MainTitle();
            mainTitle.setTitle("设备维修");
            templateCardEntity.setMain_title(mainTitle);
            templateCardEntity.setSub_title_text("您有待领取维修工单,请进入系统领取");
            TemplateCardEntity.CardAction cardAction = new TemplateCardEntity.CardAction();
            cardAction.setType(1);
            cardAction.setUrl(cardActionUrl);
            templateCardEntity.setCard_action(cardAction);
            wechatEnterpriseService.sendTemplateCardMsg(templateCard, true);
        } else {
            log.error("报修工单: " + eamReportRepair.getId() + " 设备不存在,无法推送工单待领取提醒消息!");
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean edit(EamReportRepair eamReportRepair) {