DLC 1 rok pred
rodič
commit
85e42baba2

+ 15 - 0
bs-common/src/main/java/com/rongwei/safecommon/utils/SaveConstans.java

@@ -153,6 +153,11 @@ public class SaveConstans {
          */
         public static final String EQU_SCRAP_TASK = "equscraptask";
 
+        /**
+         * 故障停机提醒
+         */
+        public static final String FAUL_STOP_REMIND = "faultstopremind";
+
     }
 
     public static class NotifyTitle {
@@ -238,6 +243,11 @@ public class SaveConstans {
          * 设备报废申请审批通过通知
          */
         public static final String EQU_SCRAP_TITLE = "设备报废申请审批通过通知";
+
+        /**
+         * 故障停机提醒
+         */
+        public static final String FAUL_STOP_TITLE = "故障停机提醒";
     }
 
     public static class NotifyContent {
@@ -321,6 +331,11 @@ public class SaveConstans {
          */
         public static final String DEVICE_REPEATEDLY_FAILS_CONTEXT = "近三个月内设备部位重复故障问题提醒说明(含三个厂,各自独立),单个工厂对相同问题重复发生请大家互相学习解决方案并加以改进,具体信息详见提醒内容中附件表格。";
 
+        /**
+         * 故障停机提醒
+         */
+        public static final String FAUL_STOP_CONTEXT = "【%s】【%s】在【%s】发生停机故障(问题说明:【%s】),请及时安排维修工程跟进处理,(申请人/时间:【%s】【%s】)";
+
     }
 
     /**

+ 1 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/EquipmentSendNotifyService.java

@@ -69,4 +69,5 @@ public interface EquipmentSendNotifyService {
      */
     R deviceRepeatedlyFailsNotify();
 
+    void sendFaultStopRemind(Map<String, String> parameter);
 }

+ 74 - 30
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquipmentSendNotifyServiceImpl.java

@@ -2,19 +2,15 @@ package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.io.resource.ClassPathResource;
 import com.rongwei.bscommon.sys.dao.CommonDao;
-import com.rongwei.bscommon.sys.service.AspCheckItemsService;
-import com.rongwei.bscommon.sys.service.EquLubricationTaskManagementService;
-import com.rongwei.bscommon.sys.service.EquMaintenanceOrderService;
-import com.rongwei.bscommon.sys.service.EquMaintenanceTaskService;
-import com.rongwei.bscommon.sys.service.EquipmentSendNotifyService;
+import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bscommon.sys.utils.ExcelUtils;
 import com.rongwei.bsentity.domain.AspCheckItems;
 import com.rongwei.bsentity.domain.EquLubricationTaskManagementDo;
 import com.rongwei.bsentity.domain.EquMaintenanceOrderDo;
 import com.rongwei.bsentity.domain.EquMaintenanceTaskDo;
 import com.rongwei.bsentity.dto.EquMaintenanceOrderSumDTO;
-import com.rongwei.bsentity.enums.PlantEnum;
 import com.rongwei.bsentity.dto.EquipmentDisposeDTO;
+import com.rongwei.bsentity.enums.PlantEnum;
 import com.rongwei.rwadmincommon.system.domain.SysDictDo;
 import com.rongwei.rwadmincommon.system.service.SysDictService;
 import com.rongwei.rwcommon.base.R;
@@ -28,8 +24,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.io.*;
-import java.text.SimpleDateFormat;
+import java.io.InputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -208,6 +203,11 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
                 null, userId.stream().distinct().collect(Collectors.toList()), fileItemId, MOBILE_PLANNING_TASK, true);
     }
 
+    /**
+     * 设备报废通知提醒
+     *
+     * @param equipmentDisposeDTO
+     */
     @Override
     public void equScrapAuditNotify(EquipmentDisposeDTO equipmentDisposeDTO) {
         String equid = equipmentDisposeDTO.getEquipmentId();
@@ -219,7 +219,7 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
         }
 
         // 发送人
-        List<String> userId = new ArrayList<>();
+        List<String> userId;
         List<String> useDeptRoleUserIds = commonDao.getRoleUserIds("'车间主任','车间维修主管','车间保养主管'", "so.ID='" + aspCheckItems.getUsedeptid() + "'");
         List<String> factoryRoleUserIds = commonDao.getRoleUserIds("'设备部部门长'", "(so.FULLPID like '," + aspCheckItems.getTenantid() + "%' or so.ID='" + aspCheckItems.getTenantid() + "')");
         if (useDeptRoleUserIds.size() > 0 && factoryRoleUserIds.size() > 0) {
@@ -244,6 +244,7 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
 
     /**
      * 设备部位重复故障问题提醒
+     *
      * @return
      */
     @Override
@@ -252,21 +253,61 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
         Date startDate = getBeforeThreeMonthDate();
         //查询维修单汇总数据:根据故障发生时间自动查询每个工厂近3个月内 (以本月在往前倒推三个月至当前时间)所有 除去 无需维修、已关闭  且  维修对象分类 为 档案设备、工装 的 维修任务记录中,
         // 然后根据所属工厂、设备类型、发生部位 分组查询对应分组类型的 数量记录 中 > 1的记录
-        List<EquMaintenanceOrderSumDTO> list= equMaintenanceOrderService.selectOrderSummaryData(startDate,new Date());
+        List<EquMaintenanceOrderSumDTO> list = equMaintenanceOrderService.selectOrderSummaryData(startDate, new Date());
         if (list.isEmpty()) {
             log.info("记录为空,则不生成附件,也不生成提醒信息");
             return R.ok();
         }
         //2.生成excel 文件
-        String id=  generateDeviceRepeatedlyFailsExcel(list);
-            //3.消息提醒
+        String id = generateDeviceRepeatedlyFailsExcel(list);
+        //3.消息提醒
         generateDeviceRepeatedlyFailsNotify(id);
 
         return R.ok();
     }
 
+    /**
+     * 故障停机提醒
+     *
+     * @param parameter
+     * @return
+     */
+    @Override
+    public void sendFaultStopRemind(Map<String, String> parameter) {
+        String dataId = parameter.get("id");
+        EquMaintenanceOrderDo equMaintenanceOrderDo = equMaintenanceOrderService.getById(dataId);
+
+        if (null == equMaintenanceOrderDo) {
+            log.info("无法通过id:{}获取到维修申请信息信息", dataId);
+            return;
+        }
+
+        // 发送人
+        List<String> userId;
+        List<String> useDeptRoleUserIds = commonDao.getRoleUserIds("'车间主任','车间维修主管'", "so.ID='" + equMaintenanceOrderDo.getWorkshopid() + "'");
+        List<String> factoryRoleUserIds = commonDao.getRoleUserIds("'设备部部门长','设备部维修主管'", "(so.FULLPID like '," + equMaintenanceOrderDo.getTenantid() + "%' or so.ID='" + equMaintenanceOrderDo.getTenantid() + "')");
+        if (useDeptRoleUserIds.size() > 0 && factoryRoleUserIds.size() > 0) {
+            userId = Stream.of(useDeptRoleUserIds, factoryRoleUserIds).flatMap(Collection::stream).distinct().collect(Collectors.toList());
+        } else if (useDeptRoleUserIds.size() == 0) {
+            userId = factoryRoleUserIds;
+        } else {
+            userId = useDeptRoleUserIds;
+        }
+
+        if (userId.isEmpty()) {
+            log.info("id为{}的任务无提醒人", dataId);
+            return;
+        }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 发送内容
+        String context = String.format(FAUL_STOP_CONTEXT, equMaintenanceOrderDo.getEquipmentname(), equMaintenanceOrderDo.getEquipmentnumber(), simpleDateFormat.format(equMaintenanceOrderDo.getIncidenttime()), equMaintenanceOrderDo.getFaultcondition(), equMaintenanceOrderDo.getCreateusername(), simpleDateFormat.format(equMaintenanceOrderDo.getRepairtime()));
+
+        CXCommonUtils.sendNotify(FAUL_STOP_TITLE, context, null, userId.stream().distinct().collect(Collectors.toList()), dataId, FAUL_STOP_REMIND, true);
+    }
+
     /**
      * 生成设备部位重复故障问题提醒
+     *
      * @param id
      */
     private void generateDeviceRepeatedlyFailsNotify(String id) {
@@ -278,12 +319,13 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
         }
 
         CXCommonUtils.sendNotify(DEVICE_REPEATEDLY_FAILS_TITLE, DEVICE_REPEATEDLY_FAILS_CONTEXT, null, userId.stream().distinct().collect(Collectors.toList()),
-               id, DEVICE_REPEATEDLY_FAILS_NOTICETYPE, true);
+                id, DEVICE_REPEATEDLY_FAILS_NOTICETYPE, true);
     }
 
 
     /**
      * 生成 备部位重复故障问题 excel 记录
+     *
      * @param
      * @return
      */
@@ -300,9 +342,9 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
             HSSFSheet sheet3 = workbook.getSheetAt(3);
             //2.填充数据
             //2.1 给第一页数据填充数据
-            for (int i=0;i<list.size()-1;i++){
+            for (int i = 0; i < list.size() - 1; i++) {
                 // 创建行
-                HSSFRow row = sheet0.createRow(i+1);
+                HSSFRow row = sheet0.createRow(i + 1);
                 row.createCell(0).setCellValue(list.get(i).getPlant()); // 所属工厂
                 row.createCell(1).setCellValue(list.get(i).getDevicetype());  //设备类型
                 row.createCell(2).setCellValue(list.get(i).getProblemlocation());  //发生部位
@@ -318,56 +360,58 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
             Map<String, List<EquMaintenanceOrderDo>> listMap = dos.stream()
                     .collect(Collectors.groupingBy(EquMaintenanceOrderDo::getTenantid));
             //2.2板材
-            fillPlantData(listMap.get( PlantEnum.CXBC.getId()),sheet1);
+            fillPlantData(listMap.get(PlantEnum.CXBC.getId()), sheet1);
             //2.3精铝
-            fillPlantData(listMap.get( PlantEnum.CXJL.getId()),sheet2);
+            fillPlantData(listMap.get(PlantEnum.CXJL.getId()), sheet2);
             //2.4箔材
-            fillPlantData(listMap.get( PlantEnum.CXLB.getId()),sheet3);
+            fillPlantData(listMap.get(PlantEnum.CXLB.getId()), sheet3);
             //3数据填充生成文件
-            String id = ExcelUtils.feginCommonUpload(workbook,  DEVICE_REPEATEDLY_FAILS_FILE_NAME.split("\\.")[0], "."+ DEVICE_REPEATEDLY_FAILS_FILE_NAME.split("\\.")[1]);
-            log.info("返回文件id:{}",id);
-            return id ;
+            String id = ExcelUtils.feginCommonUpload(workbook, DEVICE_REPEATEDLY_FAILS_FILE_NAME.split("\\.")[0], "." + DEVICE_REPEATEDLY_FAILS_FILE_NAME.split("\\.")[1]);
+            log.info("返回文件id:{}", id);
+            return id;
 
         } catch (Exception e) {
-            log.error("生成设备部位重复故障excel 失败:{}",e.getMessage());
+            log.error("生成设备部位重复故障excel 失败:{}", e.getMessage());
         }
         return "";
     }
 
     /**
      * 填充后3页工厂数据
+     *
      * @param list
      * @param sheet
      */
     private void fillPlantData(List<EquMaintenanceOrderDo> list, HSSFSheet sheet) {
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        for (int i=0;i<list.size()-1;i++){
+        for (int i = 0; i < list.size() - 1; i++) {
             // 创建行
-            HSSFRow row = sheet.createRow(i+1);
+            HSSFRow row = sheet.createRow(i + 1);
             row.createCell(0).setCellValue(list.get(i).getJobnumber()); //工单编号
             row.createCell(1).setCellValue(list.get(i).getPlant());  //所属工厂
             row.createCell(2).setCellValue(list.get(i).getWorkshop()); //使用车间
             row.createCell(3).setCellValue(list.get(i).getEquipmentname()); //设备名称
             row.createCell(4).setCellValue(list.get(i).getEquipmentnumber()); //设备编号
-            row.createCell(5).setCellValue(list.get(i).getIncidenttime()==null?"":dateFormat.format(list.get(i).getIncidenttime())); //故障发生时间
+            row.createCell(5).setCellValue(list.get(i).getIncidenttime() == null ? "" : dateFormat.format(list.get(i).getIncidenttime())); //故障发生时间
             row.createCell(6).setCellValue(list.get(i).getProblemlocation()); //问题发生部位
             row.createCell(7).setCellValue(list.get(i).getFaultcondition()); //设备故障情况
-            row.createCell(8).setCellValue(list.get(i).getIshalt()==null?"":sysDictService.getDictNameByValue("YORN",list.get(i).getIshalt())); //是否停机
-            row.createCell(9).setCellValue(list.get(i).getHalttime()==null?"":dateFormat.format(list.get(i).getHalttime())); //停机时间
+            row.createCell(8).setCellValue(list.get(i).getIshalt() == null ? "" : sysDictService.getDictNameByValue("YORN", list.get(i).getIshalt())); //是否停机
+            row.createCell(9).setCellValue(list.get(i).getHalttime() == null ? "" : dateFormat.format(list.get(i).getHalttime())); //停机时间
             row.createCell(10).setCellValue(list.get(i).getCreateusername()); //报修申请人
             row.createCell(11).setCellValue(list.get(i).getServiceperson()); //维修人
             row.createCell(12).setCellValue(list.get(i).getCausefailure()); //故障发生原因
             row.createCell(13).setCellValue(list.get(i).getResult()); //维修结果
-            row.createCell(14).setCellValue(list.get(i).getRepairstatus()==null?"":sysDictService.getDictNameByValue("maintenance_state",list.get(i).getRepairstatus()));  //维修状态
+            row.createCell(14).setCellValue(list.get(i).getRepairstatus() == null ? "" : sysDictService.getDictNameByValue("maintenance_state", list.get(i).getRepairstatus()));  //维修状态
         }
     }
 
 
     /**
      * 获取3月前的时间
+     *
      * @return
      */
-    private Date getBeforeThreeMonthDate(){
+    private Date getBeforeThreeMonthDate() {
         // 创建一个Calendar实例
         Calendar calendar = Calendar.getInstance();
         // 将Calendar实例设置为当前时间
@@ -381,7 +425,7 @@ public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyServic
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.MILLISECOND, 0);
-        log.info("开始时间{}",calendar.getTime());
+        log.info("开始时间{}", calendar.getTime());
         return calendar.getTime();
 
     }

+ 46 - 22
cx-equipment/cx-equipment-server/src/main/java/com/rongwei/bsserver/sys/controller/EquipmentSendNotifyController.java

@@ -35,21 +35,21 @@ public class EquipmentSendNotifyController {
      * @return {@link R}
      * @date 2024/1/18 17:16
      * @author shangmi
-     *
      */
 
     @PostMapping("/maintainCreateTaskNotify")
-    public R maintainCreateTaskNotify(@RequestBody IdGeneralDTO idGeneralDTO){
+    public R maintainCreateTaskNotify(@RequestBody IdGeneralDTO idGeneralDTO) {
         try {
-            log.info("进入接口:/send-notify/maintainCreateTaskNotify;入参为:{}",idGeneralDTO);
+            log.info("进入接口:/send-notify/maintainCreateTaskNotify;入参为:{}", idGeneralDTO);
             return sendNotifyService.maintainCreateTaskNotify(idGeneralDTO.getId());
-        }catch (Exception e){
-            ExceptionUtils.printExceptionDetail(e,"发送消息提醒失败,异常为:");
+        } catch (Exception e) {
+            ExceptionUtils.printExceptionDetail(e, "发送消息提醒失败,异常为:");
             log.info(e.getMessage());
             return R.error(e.getMessage());
         }
-    };
+    }
 
+    ;
 
 
     /**
@@ -59,20 +59,21 @@ public class EquipmentSendNotifyController {
      * @return {@link R}
      * @date 2024/1/18 17:16
      * @author shangmi
-     *
      */
 
     @PostMapping("/maintainVerifyTaskNotify")
-    public R maintainVerifyTaskNotify(@RequestBody IdGeneralDTO idGeneralDTO){
+    public R maintainVerifyTaskNotify(@RequestBody IdGeneralDTO idGeneralDTO) {
         try {
-            log.info("进入接口:/send-notify/maintainVerifyTaskNotify;入参为:{}",idGeneralDTO);
+            log.info("进入接口:/send-notify/maintainVerifyTaskNotify;入参为:{}", idGeneralDTO);
             return sendNotifyService.maintainVerifyTaskNotify(idGeneralDTO.getId());
-        }catch (Exception e){
-            ExceptionUtils.printExceptionDetail(e,"发送消息提醒失败,异常为:");
+        } catch (Exception e) {
+            ExceptionUtils.printExceptionDetail(e, "发送消息提醒失败,异常为:");
             log.info(e.getMessage());
             return R.error(e.getMessage());
         }
-    };
+    }
+
+    ;
 
     /**
      * 根据润滑任务ID发送验收 提醒
@@ -81,36 +82,59 @@ public class EquipmentSendNotifyController {
      * @return {@link R}
      * @date 2024/1/18 17:16
      * @author shangmi
-     *
      */
 
     @RequestMapping("/sendLubricationTaskNotifyByIds")
-    public R sendLubricationTaskNotifyByIds(@RequestBody Map<String, Object> parameter){
+    public R sendLubricationTaskNotifyByIds(@RequestBody Map<String, Object> parameter) {
         try {
-            log.info("进入接口:/send-notify/sendLubricationTaskNotifyByIds;入参任务taskIds为:{}",parameter);
+            log.info("进入接口:/send-notify/sendLubricationTaskNotifyByIds;入参任务taskIds为:{}", parameter);
             return sendNotifyService.sendLubricationTaskNotifyByIds(parameter);
-        }catch (Exception e){
-            ExceptionUtils.printExceptionDetail(e,"发送润滑任务消息提醒失败,异常为:");
+        } catch (Exception e) {
+            ExceptionUtils.printExceptionDetail(e, "发送润滑任务消息提醒失败,异常为:");
             log.info(e.getMessage());
             return R.error(e.getMessage());
         }
-    };
+    }
+
+    ;
 
 
     /**
      * 设备部位重复故障问题提醒 repeatEquipmentFaultNotify
+     *
      * @return
      */
     @PostMapping("/deviceRepeatedlyFailsNotify")
-    public R repeatEquipmentFaultNotify(){
+    public R repeatEquipmentFaultNotify() {
         try {
             log.info("进入接口:/send-notify/deviceRepeatedlyFailsNotify;");
             return sendNotifyService.deviceRepeatedlyFailsNotify();
-        }catch (Exception e){
-            ExceptionUtils.printExceptionDetail(e,"发送消息提醒失败,异常为:");
+        } catch (Exception e) {
+            ExceptionUtils.printExceptionDetail(e, "发送消息提醒失败,异常为:");
             log.info(e.getMessage());
             return R.error(e.getMessage());
         }
-    };
+    }
+
+    ;
+
+    /**
+     * 故障停机提醒
+     *
+     * @param parameter
+     * @return
+     */
+    @RequestMapping("/faultstopremind")
+    public void faultStopRemind(@RequestBody Map<String, String> parameter) {
+        try {
+            log.info("进入接口:/send-notify/faultStopRemind;入参任务taskIds为:{}", parameter);
+            sendNotifyService.sendFaultStopRemind(parameter);
+        } catch (Exception e) {
+            ExceptionUtils.printExceptionDetail(e, "发送故障停机提醒失败,异常为:");
+            log.info(e.getMessage());
+        }
+    }
+
+    ;
 
 }