|
@@ -10,6 +10,7 @@ import com.platform.dao.dto.repair.RepairApplicationFormDTO;
|
|
|
import com.platform.dao.dto.upms.SysUserDTO;
|
|
|
import com.platform.dao.entity.repair.RepairApplicationForm;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
+import com.platform.dao.entity.upms.SysConfig;
|
|
|
import com.platform.dao.entity.upms.SysUser;
|
|
|
import com.platform.dao.enums.*;
|
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
@@ -18,6 +19,7 @@ import com.platform.dao.vo.sb.SbInfoVO;
|
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
|
import com.platform.service.repair.RepairApplicationFormService;
|
|
|
import com.platform.service.sb.SbInfoService;
|
|
|
+import com.platform.service.upms.SysConfigService;
|
|
|
import com.platform.service.upms.SysUserService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -56,6 +58,8 @@ public class RedisTaskService extends KeyExpirationEventMessageListener {
|
|
|
@Resource
|
|
|
private SysUserService sysUserService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
/**
|
|
|
* @param listenerContainer
|
|
|
*/
|
|
@@ -133,68 +137,77 @@ public class RedisTaskService extends KeyExpirationEventMessageListener {
|
|
|
if(repairApplicationForm.getStatus().compareTo(RepairApplicationFormStatusEnum.PROCESSING.getValue())>0){
|
|
|
return;
|
|
|
}
|
|
|
+ if(StringUtils.isBlank(sbInfoVO.getPositionId())){
|
|
|
+ logger.info("设备车间未设置,无法发送维修超时预警,设备Id" + sbInfoVO.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 超过3个小时没修好
|
|
|
if(expiredKeyArr[0].equalsIgnoreCase(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_FIRST)){
|
|
|
-
|
|
|
// 更新维修单状态为维修超时
|
|
|
repairApplicationForm.setRepairOvertime(true);
|
|
|
repairApplicationFormService.modModelByPrimaryKey(repairApplicationForm);
|
|
|
-
|
|
|
- logger.info("超时3小时发送给牛工");
|
|
|
- List<SysUser> userList = sysUserService.getRepairUser(new SysUserDTO());
|
|
|
- List<SysUser> filterUsers = userList.stream().filter(item -> item.getWorkFlag()).collect(Collectors.toList());
|
|
|
- if (CollectionUtil.isEmpty(filterUsers)) {
|
|
|
- filterUsers = userList.stream().filter(item -> item.getIdentityType().equals(SysUserIdentityType.WXZGMANAGER.getValue())).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (CollectionUtil.isEmpty(filterUsers)) {
|
|
|
- logger.info("超时3小时发送给牛工,维修主管领导身份未设置,无法发送消息,设备编号:" + sbInfoVO.getNo());
|
|
|
+ logger.info("处理第一阶段维修过期");
|
|
|
+ SysConfig sysConfig = sysConfigService.getByCode(SysConfigEnum.REPAIR_OVERTIME_MINUTE_FIRST.toString());
|
|
|
+ String description = sysConfig.getDescription();
|
|
|
+ if(StringUtils.isBlank(description)){
|
|
|
return;
|
|
|
- }else{
|
|
|
- SysUser user = filterUsers.get(0);
|
|
|
- // 通过给当天值班维修人员
|
|
|
- sendMessage(repairId, repairApplicationForm,BeanConverterUtil.copyObjectProperties(user, SysUserVO.class),sbInfoVO, "repairEmailOverTimeFirst.ftl");
|
|
|
+ }
|
|
|
+ String[] arr = description.split(";");
|
|
|
+ List<String> emailList = new ArrayList<String>();
|
|
|
+ for(String a: arr){
|
|
|
+ if(a.split(",")[0].equals(sbInfoVO.getPositionId())){
|
|
|
+ sendMessage(repairId, repairApplicationForm,a.split(",")[1],sbInfoVO, "repairEmailOverTimeFirst.ftl");
|
|
|
+ }
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- // 超过8个小时没修好,升级给相工,通过角色来查询
|
|
|
+ // 超过8个小时没修好
|
|
|
if(expiredKeyArr[0].equalsIgnoreCase(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_SECOND)){
|
|
|
- logger.info("处理第二阶段过期,发送消息给牛");
|
|
|
- List<SysUser> userList = sysUserService.getRepairUser(new SysUserDTO());
|
|
|
- List<SysUser> filterUsers = userList.stream().filter(item -> item.getWorkFlag()).collect(Collectors.toList());
|
|
|
- if (CollectionUtil.isEmpty(filterUsers)) {
|
|
|
- filterUsers = userList.stream().filter(item -> item.getIdentityType().equals(SysUserIdentityType.WXZGMANAGER.getValue())).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (CollectionUtil.isEmpty(filterUsers)) {
|
|
|
- logger.info("处理第三阶段过期,维修主管领导身份未设置,无法发送消息,设备编号:" + sbInfoVO.getNo());
|
|
|
+ logger.info("处理第二阶段维修过期");
|
|
|
+ SysConfig sysConfig = sysConfigService.getByCode(SysConfigEnum.REPAIR_OVERTIME_MINUTE_SECOND.toString());
|
|
|
+ String description = sysConfig.getDescription();
|
|
|
+ if(StringUtils.isBlank(description)){
|
|
|
return;
|
|
|
- }else{
|
|
|
- SysUser user = filterUsers.get(0);
|
|
|
- // 通过给当天值班维修人员
|
|
|
- sendMessage(repairId, repairApplicationForm,BeanConverterUtil.copyObjectProperties(user, SysUserVO.class),sbInfoVO, "repairEmailOverTimeSecond.ftl");
|
|
|
+ }
|
|
|
+ String[] arr = description.split(";");
|
|
|
+ List<String> emailList = new ArrayList<String>();
|
|
|
+ for(String a: arr){
|
|
|
+ if(a.split(",")[0].equals(sbInfoVO.getPositionId())){
|
|
|
+ sendMessage(repairId, repairApplicationForm,a.split(",")[1],sbInfoVO, "repairEmailOverTimeSecond.ftl");
|
|
|
+ }
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 超时超过24 没修好,升级给田总,通过角色来查询
|
|
|
+ // 超时超过24
|
|
|
if(expiredKeyArr[0].equalsIgnoreCase(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_THIRD)){
|
|
|
- logger.info("处理第二阶段过期,发送消息给牛");
|
|
|
- List<SysUser> userList = sysUserService.getRepairUser(new SysUserDTO());
|
|
|
- List<SysUser> filterUsers = userList.stream().filter(item -> item.getWorkFlag()).collect(Collectors.toList());
|
|
|
- if (CollectionUtil.isEmpty(filterUsers)) {
|
|
|
- filterUsers = userList.stream().filter(item -> item.getIdentityType().equals(SysUserIdentityType.WXZGMANAGER.getValue())).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (CollectionUtil.isEmpty(filterUsers)) {
|
|
|
- logger.info("处理第三阶段过期,维修主管领导身份未设置,无法发送消息,设备编号:" + sbInfoVO.getNo());
|
|
|
+ logger.info("处理第二阶段维修过期");
|
|
|
+ SysConfig sysConfig = sysConfigService.getByCode(SysConfigEnum.REPAIR_OVERTIME_MINUTE_THIRD.toString());
|
|
|
+ String description = sysConfig.getDescription();
|
|
|
+ if(StringUtils.isBlank(description)){
|
|
|
return;
|
|
|
- }else{
|
|
|
- SysUser user = filterUsers.get(0);
|
|
|
- // 通过给当天值班维修人员
|
|
|
- sendMessage(repairId, repairApplicationForm,BeanConverterUtil.copyObjectProperties(user, SysUserVO.class),sbInfoVO, "repairEmailOverTimeThird.ftl");
|
|
|
+ }
|
|
|
+ String[] arr = description.split(";");
|
|
|
+ List<String> emailList = new ArrayList<String>();
|
|
|
+ for(String a: arr){
|
|
|
+ if(a.split(",")[0].equals(sbInfoVO.getPositionId())){
|
|
|
+ sendMessage(repairId, repairApplicationForm,a.split(",")[1],sbInfoVO, "repairEmailOverTimeThird.ftl");
|
|
|
+ }
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 给系统用户发生通知和邮件
|
|
|
+ *
|
|
|
+ * @param repairId
|
|
|
+ * @param repairApplicationForm
|
|
|
+ * @param user
|
|
|
+ * @param sbInfoVO
|
|
|
+ * @param templateFileName
|
|
|
+ */
|
|
|
public void sendMessage(String repairId, RepairApplicationForm repairApplicationForm, SysUserVO user, SbInfoVO sbInfoVO, String templateFileName ){
|
|
|
String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
if(StringUtils.isBlank(domain)){
|
|
@@ -214,4 +227,34 @@ public class RedisTaskService extends KeyExpirationEventMessageListener {
|
|
|
)
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给指定邮箱发送邮件
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @param repairId
|
|
|
+ * @param repairApplicationForm
|
|
|
+ * @param email
|
|
|
+ * @param sbInfoVO
|
|
|
+ * @param templateFileName
|
|
|
+ */
|
|
|
+ public void sendMessage(String repairId, RepairApplicationForm repairApplicationForm, String email, SbInfoVO sbInfoVO, String templateFileName ){
|
|
|
+ String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
+ if(StringUtils.isBlank(domain)){
|
|
|
+ throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
|
|
|
+ }
|
|
|
+ if(!domain.endsWith("/")){
|
|
|
+ domain = domain + "/";
|
|
|
+ }
|
|
|
+ String repairUrl = domain + "repair/application/form/check?no=" + repairApplicationForm.getNo();
|
|
|
+ SpringContextHolder.publishEvent(
|
|
|
+ new WorkplaceBacklogEvent(
|
|
|
+ WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
+ repairId,
|
|
|
+ MessageTemplateUtil.getFreemarkerHtmlContent(repairUrl, BeanConverterUtil.copyObjectProperties(repairApplicationForm, RepairApplicationFormDTO.class),sbInfoVO, templateFileName),
|
|
|
+ repairId, null, ListUtils.newArrayList(email)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|