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 { @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 empIds = notifyBusinessSend.getEmpIds(); List 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 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()); } }