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);
|
}
|
}
|