yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
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
package com.qianwen.smartman.modules.notify.business;
 
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import org.jeewx.api.core.util.DateUtils;
import com.qianwen.smartman.common.constant.DateConstant;
import com.qianwen.smartman.common.constant.NotifyConstant;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.andon.dto.AndonMessageDTO;
import com.qianwen.smartman.modules.andon.dto.AndonMessageSendDTO;
import com.qianwen.smartman.modules.andon.vo.AndonMessageSendVO;
import com.qianwen.smartman.modules.notify.dto.NotifyBusinessSendDTO;
import com.qianwen.smartman.modules.notify.dto.NotifySendDTO;
import com.qianwen.smartman.modules.notify.service.IBusinessNotifyService;
import com.qianwen.smartman.modules.notify.service.IBusinessNotifyStateService;
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/AndonTakeOverSend.class */
public class AndonTakeOverSend implements BusinessSend<AndonMessageSendVO> {
    @Autowired
    private IBusinessNotifyService businessNotifyService;
    @Autowired
    private TemplateEngine templateEngine;
    @Autowired
    private IBusinessNotifyStateService businessNotifyStateService;
 
    @Override // org.springblade.modules.notify.business.BusinessSend
    public void saveState(AndonMessageSendVO andonMessageSendVO, NotifyBusinessSendDTO notifyBusinessSend) {
        String reasons;
        String workstationCode = Func.isNotBlank(andonMessageSendVO.getWorkstationCode()) ? andonMessageSendVO.getWorkstationCode() : "-";
        String workstationName = Func.isNotBlank(andonMessageSendVO.getWorkstationName()) ? andonMessageSendVO.getWorkstationName() : "-";
        String typeCode = Func.isNotBlank(andonMessageSendVO.getTypeCode()) ? andonMessageSendVO.getTypeCode() : "-";
        String typeName = Func.isNotBlank(andonMessageSendVO.getTypeName()) ? andonMessageSendVO.getTypeName() : "-";
        if (Func.isNotEmpty(andonMessageSendVO.getReasonList())) {
            reasons = (String) andonMessageSendVO.getReasonList().stream().map(s -> {
                return "(" + s.getReasonCode() + ")" + s.getReasonName();
            }).collect(Collectors.joining(";"));
        } else {
            reasons = "-";
        }
        String callEmpName = Func.isNotBlank(andonMessageSendVO.getCallEmpName()) ? andonMessageSendVO.getCallEmpName() : "-";
        String callTime = DateUtils.datetoStr(andonMessageSendVO.getCallTime(), DateConstant.PATTERN_DATE_TIME);
        List<Long> empIds = notifyBusinessSend.getEmpIds();
        List<Long> orgIds = notifyBusinessSend.getOrgIds();
        AndonMessageSendDTO andonMessageSendDTO = new AndonMessageSendDTO();
        andonMessageSendDTO.setWorkstationName("(" + workstationCode + ")" + workstationName).setTypeName("(" + typeCode + ")" + typeName).setReasons(reasons).setCallEmpName(callEmpName).setCallTime(callTime);
        AndonMessageDTO andonMessageDTO = new AndonMessageDTO();
        andonMessageDTO.setWorkstationName("(" + workstationCode + ")" + workstationName).setTypeName("(" + typeCode + ")" + typeName).setReasons(reasons).setCallEmpName(callEmpName).setCallTime(callTime);
        List<AndonMessageDTO> messages = new LinkedList<>();
        messages.add(andonMessageDTO);
        Context context = new Context();
        context.setVariable("andonCallTable", messages);
        String andonHtml = this.templateEngine.process("andonCallTable", context);
        andonMessageSendDTO.setAndonCallTable(andonHtml);
        NotifySendDTO notifySendDTO = new NotifySendDTO();
        notifySendDTO.setData(BeanUtils.beanToMap(andonMessageSendDTO));
        notifySendDTO.setEmpIds(empIds);
        notifySendDTO.setOrgIds(orgIds);
        notifySendDTO.setBusinessKey(NotifyConstant.ANDON_TAKE_OVER);
        this.businessNotifyService.sendMessage(notifySendDTO);
    }
 
    @Override // org.springblade.modules.notify.business.BusinessSend
    @Async
    public void sendMessage(AndonMessageSendVO andonMessageSendVO, NotifyBusinessSendDTO notifyBusinessSend) {
        Long businessId = andonMessageSendVO.getId();
        this.businessNotifyStateService.saveBatchByIds(NotifyConstant.MAINTENANCE_WARNING, businessId, notifyBusinessSend.getEmpIds(), notifyBusinessSend.getOrgIds());
    }
}