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
package com.qianwen.smartman.modules.notify.business;
 
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import com.qianwen.smartman.common.constant.NotifyConstant;
import com.qianwen.smartman.modules.notify.dto.MaintainPlanWarningSendDTO;
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 com.qianwen.smartman.modules.tpm.entity.MaintainPlan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
 
@Component
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/business/MaintenanceWarningSend.class */
public class MaintenanceWarningSend implements BusinessSend<MaintainPlan> {
    @Autowired
    private IBusinessNotifyService businessNotifyService;
    @Autowired
    private IBusinessNotifyStateService businessNotifyStateService;
 
    @Override // org.springblade.modules.notify.business.BusinessSend
    public void sendMessage(MaintainPlan maintainPlan, NotifyBusinessSendDTO notifyBusinessSend) {
        LocalDateTime maintainDate = maintainPlan.getMaintainDate();
        String code = maintainPlan.getCode() != null ? maintainPlan.getCode() : "-";
        List<Long> empIds = notifyBusinessSend.getEmpIds();
        List<Long> orgIds = notifyBusinessSend.getOrgIds();
        MaintainPlanWarningSendDTO maintainPlanSendDTO = new MaintainPlanWarningSendDTO();
        maintainPlanSendDTO.setCode(code);
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分");
        maintainPlanSendDTO.setNow(LocalDateTime.now().format(df));
        if (maintainDate != null) {
            long day = maintainDate.toLocalDate().toEpochDay() - LocalDateTime.now().toLocalDate().toEpochDay();
            if (day < 0) {
                day = 0;
            }
            maintainPlanSendDTO.setDay(String.valueOf(day));
        }
        NotifySendDTO notifySendDTO = new NotifySendDTO();
        notifySendDTO.setData(BeanUtils.beanToMap(maintainPlanSendDTO));
        notifySendDTO.setEmpIds(empIds);
        notifySendDTO.setOrgIds(orgIds);
        notifySendDTO.setBusinessKey(NotifyConstant.MAINTENANCE_WARNING);
        this.businessNotifyService.sendMessage(notifySendDTO);
    }
 
    @Override // org.springblade.modules.notify.business.BusinessSend
    @Async
    public void saveState(MaintainPlan maintainPlan, NotifyBusinessSendDTO notifyBusinessSend) {
        List<Long> empIds = notifyBusinessSend.getEmpIds();
        List<Long> orgIds = notifyBusinessSend.getOrgIds();
        Long businessId = maintainPlan.getId();
        this.businessNotifyStateService.saveBatchByIds(NotifyConstant.MAINTENANCE_WARNING, businessId, empIds, orgIds);
    }
}