From e8d223967ea612f4eb24603ed7ae941ec00fd76f Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期三, 13 三月 2024 11:33:07 +0800
Subject: [PATCH] 车间管理添加字段,算法bug修复

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java
index 08bc5a1..01e7d16 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java
@@ -1,11 +1,15 @@
 package org.jeecg.modules.mdc.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.modules.mdc.dto.MdcAlarmAnalyzeDto;
 import org.jeecg.modules.mdc.dto.MdcAlarmDto;
 import org.jeecg.modules.mdc.dto.MdcAlarmListDto;
 import org.jeecg.modules.mdc.dto.MdcAlarmTrendDto;
+import org.jeecg.modules.mdc.entity.MdcAlarmInfo;
+import org.jeecg.modules.mdc.entity.MdcEquipment;
 import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection;
+import org.jeecg.modules.mdc.service.IMdcAlarmInfoService;
 import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService;
 import org.jeecg.modules.mdc.service.IMdcEquipmentService;
 import org.jeecg.modules.mdc.service.MdcEquipmentAlarmAnalyzeService;
@@ -29,6 +33,9 @@
 
     @Resource
     private IMdcEquipmentService mdcEquipmentService;
+
+    @Resource
+    private IMdcAlarmInfoService mdcAlarmInfoService;
 
     @Override
     public List<MdcAlarmAnalyzeDto> alarmList(String userId, MdcAlarmAnalyzeQueryVo vo) {
@@ -77,6 +84,12 @@
                     mdcAlarmAnalyzeDto.setAlarmCode(mdcEquipmentRunningSection.getAlarm());
                     mdcAlarmAnalyzeDto.setCount(1);
                     mdcAlarmAnalyzeDto.setTimeCount(new BigDecimal(mdcEquipmentRunningSection.getDuration()));
+                    //鏌ヨ鎶ヨ鍙峰唴瀹�
+                    List<MdcEquipment> list = mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, mdcEquipmentRunningSection.getEquipmentId()));
+                    List<MdcAlarmInfo> mdcAlarmInfo = mdcAlarmInfoService.list(new LambdaQueryWrapper<MdcAlarmInfo>().eq(MdcAlarmInfo::getDriveType, list.get(0).getDriveType()).eq(MdcAlarmInfo::getAlarmCode, mdcEquipmentRunningSection.getAlarm()).eq(MdcAlarmInfo::getIsUse, 0));
+                    if (mdcAlarmInfo != null && !mdcAlarmInfo.isEmpty()) {
+                        mdcAlarmAnalyzeDto.setAlarmContent(mdcAlarmInfo.get(0).getAlarmContent());
+                    }
                     map.put(mdcEquipmentRunningSection.getAlarm(), mdcAlarmAnalyzeDto);
                 }
             }
@@ -121,8 +134,8 @@
             List<MdcAlarmDto> equipmentCountList = new ArrayList<>();
             String startDate = DateUtils.format(DateUtils.toDate(vo.getStartDate(), DateUtils.STRDATE), DateUtils.STR_DATE) + " 00:00:00";
             String endDate = DateUtils.format(DateUtils.addDays(DateUtils.toDate(vo.getEndDate(), DateUtils.STRDATE), 1), DateUtils.STR_DATE) + " 00:00:00";
-            List<MdcAlarmListDto> alarmList = mdcEquipmentRunningSectionService.selectAlarmList(vo, startDate, endDate);
-            result.setAlarmList(alarmList);
+            /*List<MdcAlarmListDto> alarmList = mdcEquipmentRunningSectionService.selectAlarmList(vo, startDate, endDate);
+            result.setAlarmList(alarmList);*/
             for (String equipmentId : result.getEquipmentList()) {
                 MdcAlarmDto mdcAlarmDto = new MdcAlarmDto();
                 mdcAlarmDto.setKey(equipmentId);
@@ -153,4 +166,39 @@
         result.setDateCountList(dateCountList);
         return result;
     }
+
+    @Override
+    public List<MdcAlarmListDto> equipmentAlarmList(String userId, MdcAlarmAnalyzeQueryVo vo) {
+        List<String> equipmentIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(vo.getParentId()) && StringUtils.isEmpty(vo.getEquipmentId())) {
+            if ("2".equals(vo.getTypeTree())) {
+                // 閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, vo.getParentId());
+            } else {
+                // 浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, vo.getParentId());
+            }
+        } else if (StringUtils.isNotEmpty(vo.getEquipmentId())) {
+            // 鍗曞彴璁惧淇℃伅
+            vo.setEquipmentIdList(Collections.singletonList(vo.getEquipmentId()));
+        } else {
+            // 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+            if ("2".equals(vo.getTypeTree())) {
+                // 閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+            } else {
+                // 浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+            }
+        }
+        if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) {
+            vo.setEquipmentIdList(equipmentIds);
+        }
+        if (vo.getEquipmentIdList() == null || vo.getEquipmentIdList().isEmpty()) {
+            return null;
+        }
+        String startDate = DateUtils.format(DateUtils.toDate(vo.getStartDate(), DateUtils.STRDATE), DateUtils.STR_DATE) + " 00:00:00";
+        String endDate = DateUtils.format(DateUtils.addDays(DateUtils.toDate(vo.getEndDate(), DateUtils.STRDATE), 1), DateUtils.STR_DATE) + " 00:00:00";
+        return mdcEquipmentRunningSectionService.selectAlarmList(vo, startDate, endDate);
+    }
 }

--
Gitblit v1.9.3