yangys
2024-03-27 e48aa2ac8dea1be5db11c63edf0b912c4ad5ce65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.qianwen.smartman.modules.notify.business;
 
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import java.util.ArrayList;
import java.util.List;
import com.qianwen.smartman.common.constant.NotifyConstant;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.notify.dto.NotifyBusinessSendDTO;
import com.qianwen.smartman.modules.notify.dto.NotifySendDTO;
import com.qianwen.smartman.modules.notify.dto.RepairApplySendDTO;
import com.qianwen.smartman.modules.notify.dto.RepairMaintainDTO;
import com.qianwen.smartman.modules.notify.service.IBusinessNotifyService;
import com.qianwen.smartman.modules.tpm.entity.RepairApply;
import com.qianwen.smartman.modules.tpm.enums.UrgencyEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
 
@Component
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/business/RepairApplySend.class */
public class RepairApplySend implements BusinessSend<RepairApply> {
    @Autowired
    private IBusinessNotifyService businessNotifyService;
    @Autowired
    private TemplateEngine templateEngine;
 
    @Override // org.springblade.modules.notify.business.BusinessSend
    public void sendMessage(RepairApply repairApply, NotifyBusinessSendDTO notifyBusinessSendDTO) {
        String deviceCode = repairApply.getDeviceCode() != null ? repairApply.getDeviceCode() : "-";
        String deviceName = repairApply.getDeviceName() != null ? repairApply.getDeviceName() : "-";
        Integer urgency = repairApply.getUrgency();
        String description = Func.isNotBlank(repairApply.getDescription()) ? repairApply.getDescription() : "-";
        String code = repairApply.getApplyCode() != null ? repairApply.getApplyCode() : "-";
        String malfunctionName = Func.isNotBlank(repairApply.getMalfunctionName()) ? repairApply.getMalfunctionName() : "-";
        List<Long> empIds = notifyBusinessSendDTO.getEmpIds();
        List<Long> orgIds = notifyBusinessSendDTO.getOrgIds();
        String urgencyStr = "-";
        if (Func.isNotEmpty(urgency)) {
            if (urgency.equals(Integer.valueOf(UrgencyEnum.U1.getType()))) {
                urgencyStr = UrgencyEnum.U1.getDesc();
            } else if (urgency.equals(Integer.valueOf(UrgencyEnum.U2.getType()))) {
                urgencyStr = UrgencyEnum.U2.getDesc();
            } else {
                urgencyStr = UrgencyEnum.U3.getDesc();
            }
        }
        RepairApplySendDTO repairApplySendDTO = new RepairApplySendDTO();
        repairApplySendDTO.setCode(code);
        repairApplySendDTO.setDeviceCode(deviceCode);
        repairApplySendDTO.setDeviceName(deviceName);
        repairApplySendDTO.setUrgency(urgencyStr);
        repairApplySendDTO.setMalfunctionName(malfunctionName);
        repairApplySendDTO.setDescription(description);
        RepairMaintainDTO maintainDTO = new RepairMaintainDTO();
        maintainDTO.setDeviceCode(deviceCode);
        maintainDTO.setDeviceName(deviceName);
        maintainDTO.setUrgency(urgencyStr);
        maintainDTO.setDescription(description);
        maintainDTO.setMalfunctionName(malfunctionName);
        List<RepairMaintainDTO> maintains = new ArrayList<>();
        maintains.add(maintainDTO);
        Context context = new Context();
        context.setVariable("repairMaintainTable", maintains);
        String machinesHtml = this.templateEngine.process("repairMaintainTable", context);
        repairApplySendDTO.setRepairMaintainTable(machinesHtml);
        NotifySendDTO notifySendDTO = new NotifySendDTO();
        notifySendDTO.setData(BeanUtils.beanToMap(repairApplySendDTO));
        notifySendDTO.setEmpIds(empIds);
        notifySendDTO.setOrgIds(orgIds);
        notifySendDTO.setBusinessKey(NotifyConstant.MAINTENANCE_APPLY);
        this.businessNotifyService.sendMessage(notifySendDTO);
    }
 
    @Override // org.springblade.modules.notify.business.BusinessSend
    @Async
    public void saveState(RepairApply repairApply, NotifyBusinessSendDTO notifyBusinessSend) {
        sendMessage(repairApply, notifyBusinessSend);
    }
}