From 871c0fce344b24c8046ec01173eca79b9e60c1d7 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期六, 30 三月 2024 22:36:06 +0800
Subject: [PATCH] mdc提交1

---
 smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/AlarmServiceImpl.java |   95 ++++++++++++++++++++++++++---------------------
 1 files changed, 53 insertions(+), 42 deletions(-)

diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/AlarmServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/AlarmServiceImpl.java
index b7cdabe..4bf8b74 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/AlarmServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/AlarmServiceImpl.java
@@ -1,12 +1,9 @@
 package com.qianwen.smartman.modules.mdc.service.impl;
 
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.common.collect.Lists;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -15,13 +12,15 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.qianwen.smartman.common.constant.DateConstant;
-import com.qianwen.smartman.common.constant.ExcelConstant;
-import com.qianwen.smartman.common.utils.LocalDateTimeUtils;
-import com.qianwen.smartman.common.utils.LocalDateUtil;
-import com.qianwen.smartman.common.utils.MessageUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
 import com.qianwen.core.excel.util.ExcelUtil;
 import com.qianwen.core.mp.support.Condition;
 import com.qianwen.core.mp.support.Query;
@@ -29,11 +28,17 @@
 import com.qianwen.core.tool.utils.CollectionUtil;
 import com.qianwen.core.tool.utils.DateUtil;
 import com.qianwen.core.tool.utils.Func;
+import com.qianwen.smartman.common.constant.DateConstant;
+import com.qianwen.smartman.common.constant.ExcelConstant;
+import com.qianwen.smartman.common.utils.LocalDateTimeUtils;
+import com.qianwen.smartman.common.utils.LocalDateUtil;
+import com.qianwen.smartman.common.utils.MessageUtils;
 import com.qianwen.smartman.modules.cps.dto.ShiftInfoDTO;
 import com.qianwen.smartman.modules.cps.mapper.WorkstationMapper;
 import com.qianwen.smartman.modules.cps.service.IShiftDetailService;
 import com.qianwen.smartman.modules.cps.vo.WorkstationVO;
 import com.qianwen.smartman.modules.mdc.convert.AlarmConvert;
+import com.qianwen.smartman.modules.mdc.entity.SuperAggregate;
 import com.qianwen.smartman.modules.mdc.entity.SuperAlarm;
 import com.qianwen.smartman.modules.mdc.enums.OpenTypeEnums;
 import com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum;
@@ -50,11 +55,10 @@
 import com.qianwen.smartman.modules.mdc.vo.AlarmSummaryGraphVO;
 import com.qianwen.smartman.modules.mdc.vo.SplitFilterListVO;
 import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
+
+import cn.hutool.core.util.StrUtil;
 
 @Service
-/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/mdc/service/impl/AlarmServiceImpl.class */
 public class AlarmServiceImpl implements IAlarmService {
     private static final Logger log = LoggerFactory.getLogger(AlarmServiceImpl.class);
     private final SuperAlarmMapper alarmMapper;
@@ -73,23 +77,23 @@
     @Override // org.springblade.modules.mdc.service.IAlarmService
     public IPage<AlarmDataSheetVO> pageAlarm(Query query, AlarmShiftSearchVO vo) {
         if (Func.isNull(vo.getWorkstationId())) {
-            return new Page();
+            return new Page<>();
         }
         LocalDate queryTime = vo.getQueryTime();
         List<SuperAlarm> list = this.alarmMapper.selectListAlarm(vo, DateUtil.format(queryTime, "yyyyMMdd"));
-        Map<String, List<SuperAlarm>> map = (Map) FilterOffUtils.filterOffDay(list, OpenTypeEnums.ALARM_ANALYSIS).stream().collect(Collectors.groupingBy(c -> {
+        Map<String, List<SuperAlarm>> map = FilterOffUtils.filterOffDay(list, OpenTypeEnums.ALARM_ANALYSIS).stream().collect(Collectors.groupingBy(c -> {
             return c.getCode() + c.getMessage();
         }));
         Integer size = query.getSize();
         Integer current = query.getCurrent();
-        Page page = new Page(current.intValue(), size.intValue(), map.size());
+        Page<AlarmDataSheetVO> page = new Page<>(current.intValue(), size.intValue(), map.size());
         if (map.size() == 0) {
             return page;
         }
         List<SuperAlarm> alarms = this.alarmMapper.selectListAlarm(vo, DateUtil.format(queryTime, "yyyyMMdd"));
         List<AlarmDataSheetVO> res = AlarmConvert.INSTANCE.convert(FilterOffUtils.filterOffDay(alarms, OpenTypeEnums.ALARM_ANALYSIS));
         List<AlarmDataSheetVO> alarmDataSheetVOS = new ArrayList<>();
-        Map<String, List<AlarmDataSheetVO>> resMap = (Map) res.stream().collect(Collectors.groupingBy(c2 -> {
+        Map<String, List<AlarmDataSheetVO>> resMap = res.stream().collect(Collectors.groupingBy(c2 -> {
             return c2.getAlarmCode() + c2.getAlarmMsg();
         }));
         resMap.values().forEach(alarmDataSheetVOList -> {
@@ -109,12 +113,19 @@
     @Override // org.springblade.modules.mdc.service.IAlarmService
     public BladeFile exportAlarm(AlarmShiftSearchExcelVO vo) {
         BladeFile bladeFile;
-        List<SuperAlarm> superAlarms = (List) FilterOffUtils.filterOffDay(this.alarmMapper.selectListAlarmByShift(LocalDateTimeUtils.formatTimeLocalDate(vo.getStartTime(), "yyyyMMdd"), LocalDateTimeUtils.formatTimeLocalDate(vo.getEndTime(), "yyyyMMdd"), vo.getWorkstationId()), OpenTypeEnums.ALARM_ANALYSIS).stream().sorted(Comparator.comparing((v0) -> {
+        
+        List<SuperAlarm> superAlarms = this.alarmMapper.selectListAlarmByShift(LocalDateTimeUtils.formatTimeLocalDate(vo.getStartTime(), "yyyyMMdd"), LocalDateTimeUtils.formatTimeLocalDate(vo.getEndTime(), "yyyyMMdd"), vo.getWorkstationId());
+        superAlarms = FilterOffUtils.filterOffDay(superAlarms, OpenTypeEnums.ALARM_ANALYSIS);
+        superAlarms.sort(Comparator.comparing(SuperAggregate::getFactoryDate));
+        Collections.reverse(superAlarms);
+        //superAlarms = superAlarms.stream().collect(Collectors.toList());
+        /*
+        List<SuperAlarm> superAlarms = FilterOffUtils.filterOffDay(this.alarmMapper.selectListAlarmByShift(LocalDateTimeUtils.formatTimeLocalDate(vo.getStartTime(), "yyyyMMdd"), LocalDateTimeUtils.formatTimeLocalDate(vo.getEndTime(), "yyyyMMdd"), vo.getWorkstationId()), OpenTypeEnums.ALARM_ANALYSIS).stream().sorted(Comparator.comparing((v0) -> {
             return v0.getFactoryDate();
-        }).reversed()).collect(Collectors.toList());
+        }).reversed()).collect(Collectors.toList());*/
         WorkstationVO workstationVO = (WorkstationVO) this.workstationMapper.queryWorkstationAndGroup(Condition.getPage(new Query().setSize(-1)), Lists.newArrayList(new Long[]{vo.getWorkstationId()})).getRecords().get(0);
         if (vo.getEnums().equals(StatisticalMethodEnum.SHIFT)) {
-            List<SuperAlarm> superAlarms2 = (List) superAlarms.stream().filter(s -> {
+            List<SuperAlarm> superAlarms2 = superAlarms.stream().filter(s -> {
                 return s.getShiftIndex().intValue() > 0;
             }).collect(Collectors.toList());
             List<ShiftInfoDTO> shiftInfoDtoList = this.shiftDetailService.getShiftInfoDtoList(Lists.newArrayList(new Long[]{vo.getWorkstationId()}), vo.getStartTime(), vo.getEndTime());
@@ -126,25 +137,25 @@
     }
 
     private BladeFile exportShift(List<SuperAlarm> superAlarms, WorkstationVO workstationVO, List<ShiftInfoDTO> shiftInfoDtoList) {
-        Map<String, List<SuperAlarm>> mapGroupByShift = (Map) superAlarms.stream().collect(Collectors.groupingBy(s -> {
+        Map<String, List<SuperAlarm>> mapGroupByShift = superAlarms.stream().collect(Collectors.groupingBy(s -> {
             return s.getFactoryDate() + "-" + s.getShiftIndex();
         }));
         List<AlarmDataSheetExcel> alarmDataSheetExcelList = new ArrayList<>();
         String shift = MessageUtils.message("mdc.excel.alarm.shift", new Object[0]);
-        Map<String, String> shiftIndexToName = (Map) shiftInfoDtoList.stream().collect(Collectors.toMap(s2 -> {
+        Map<String, String> shiftIndexToName = shiftInfoDtoList.stream().collect(Collectors.toMap(s2 -> {
             return s2.getDate().replace("-", "") + "-" + s2.getShiftIndex();
         }, (v0) -> {
             return v0.getIndexName();
         }));
         Map<String, List<SuperAlarm>> result = new LinkedHashMap<>();
         mapGroupByShift.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.reverseOrder())).forEachOrdered(x -> {
-            List list = (List) result.put(x.getKey(), x.getValue());
+            List<SuperAlarm> list = result.put(x.getKey(), x.getValue());
         });
-        result.forEach(k, v -> {
-            Map<String, List<SuperAlarm>> mapGroupByAlarmCodeAndMessage = (Map) v.stream().collect(Collectors.groupingBy(s3 -> {
+        result.forEach((k, v) -> {
+            Map<String, List<SuperAlarm>> mapGroupByAlarmCodeAndMessage = v.stream().collect(Collectors.groupingBy(s3 -> {
                 return s3.getCode() + "-" + s3.getMessage();
             }));
-            mapGroupByAlarmCodeAndMessage.forEach(key, value -> {
+            mapGroupByAlarmCodeAndMessage.forEach((key, value) -> {
                 String alarmMessage;
                 AlarmDataSheetExcel alarmDataSheetExcel = new AlarmDataSheetExcel();
                 String[] split = k.split("-");
@@ -177,15 +188,15 @@
         String the = MessageUtils.message("mdc.efficiency.analysis.the", new Object[0]);
         String week = MessageUtils.message("mdc.efficiency.analysis.week", new Object[0]);
         if (statisticalMethodEnum.equals(StatisticalMethodEnum.DAY)) {
-            map = (Map) superAlarms.stream().collect(Collectors.groupingBy(s -> {
+            map = superAlarms.stream().collect(Collectors.groupingBy(s -> {
                 return String.valueOf(s.getFactoryDate());
             }));
         } else if (statisticalMethodEnum.equals(StatisticalMethodEnum.WEEK)) {
-            map = (Map) superAlarms.stream().collect(Collectors.groupingBy(s2 -> {
+            map = superAlarms.stream().collect(Collectors.groupingBy(s2 -> {
                 return s2.getFactoryYear() + "-" + s2.getFactoryWeek();
             }));
         } else {
-            map = (Map) superAlarms.stream().collect(Collectors.groupingBy(s3 -> {
+            map = superAlarms.stream().collect(Collectors.groupingBy(s3 -> {
                 return s3.getFactoryYear() + "-" + s3.getFactoryMonth();
             }));
         }
@@ -194,11 +205,11 @@
         map.entrySet().stream().sorted(Map.Entry.comparingByKey(Comparator.reverseOrder())).forEachOrdered(x -> {
             List list = (List) result.put(x.getKey(), x.getValue());
         });
-        result.forEach(k, v -> {
-            Map<String, List<SuperAlarm>> mapGroupByAlarmCodeAndMessage = (Map) v.stream().collect(Collectors.groupingBy(s4 -> {
+        result.forEach((k, v) -> {
+            Map<String, List<SuperAlarm>> mapGroupByAlarmCodeAndMessage = v.stream().collect(Collectors.groupingBy(s4 -> {
                 return s4.getCode() + "-" + s4.getMessage();
             }));
-            mapGroupByAlarmCodeAndMessage.forEach(key, value -> {
+            mapGroupByAlarmCodeAndMessage.forEach((key, value) -> {
                 String alarmMessage;
                 String[] split = k.split("-");
                 AlarmDataSheetExcelForOther alarmDataSheetExcelForOther = new AlarmDataSheetExcelForOther();
@@ -236,7 +247,7 @@
             return new AlarmSummaryGraphVO();
         }
         List<SuperAlarm> alarms = this.alarmMapper.queryAlarm(null, vo, DateUtil.format(vo.getQueryTime(), "yyyyMMdd"));
-        Map<String, Integer> map = (Map) FilterOffUtils.filterOffDay(alarms, OpenTypeEnums.ALARM_ANALYSIS).stream().collect(Collectors.groupingBy((v0) -> {
+        Map<String, Integer> map = FilterOffUtils.filterOffDay(alarms, OpenTypeEnums.ALARM_ANALYSIS).stream().collect(Collectors.groupingBy((v0) -> {
             return v0.getCode();
         }, Collectors.reducing(0, e -> {
             return 1;
@@ -253,7 +264,7 @@
         if (Func.isEmpty(shiftInfoDtoList)) {
             return new ArrayList();
         }
-        return (List) shiftInfoDtoList.stream().map(shiftInfoDTO -> {
+        return shiftInfoDtoList.stream().map(shiftInfoDTO -> {
             AlarmDataSheetShiftVO alarmDataSheetShiftVO = new AlarmDataSheetShiftVO();
             vo.setShiftIndex(shiftInfoDTO.getShiftIndex());
             Query query = new Query();
@@ -272,9 +283,9 @@
         String shift = MessageUtils.message("mdc.excel.alarm.shift", new Object[0]);
         List<ShiftInfoDTO> shiftInfoDtoList = this.shiftDetailService.getShiftInfoDtoList(Lists.newArrayList(new Long[]{vo.getWorkstationId()}), vo.getQueryTime(), vo.getQueryTime());
         if (Func.isEmpty(shiftInfoDtoList)) {
-            return new ArrayList();
+            return new ArrayList<>();
         }
-        return (List) shiftInfoDtoList.stream().map(shiftInfoDTO -> {
+        return shiftInfoDtoList.stream().map(shiftInfoDTO -> {
             AlarmSummaryGraphShiftVO alarmSummaryGraphShiftVO = new AlarmSummaryGraphShiftVO();
             alarmSummaryGraphShiftVO.setShiftIndex(shiftInfoDTO.getShiftIndex());
             alarmSummaryGraphShiftVO.setShiftIndexName(Func.isNotEmpty(shiftInfoDTO.getIndexName()) ? shiftInfoDTO.getIndexName() : StrUtil.format("{}{}", new Object[]{shift, shiftInfoDTO.getShiftIndex()}));
@@ -295,7 +306,7 @@
                 set.add(i.getCode() + i.getMessage() + i.getFactoryDate());
             }
         });
-        Map<String, List<SuperAlarm>> countMap = (Map) tempList.stream().collect(Collectors.groupingBy(c -> {
+        Map<String, List<SuperAlarm>> countMap = tempList.stream().collect(Collectors.groupingBy(c -> {
             return c.getFactoryDate() + c.getCode();
         }));
         List<AlarmDataSheetExcelForOther> result = new ArrayList<>();
@@ -332,12 +343,12 @@
         });
         Map<String, List<SuperAlarm>> countMap = new HashMap<>();
         if (StatisticalMethodEnum.WEEK.equals(vo.getEnums())) {
-            countMap = (Map) tempList.stream().collect(Collectors.groupingBy(c -> {
+            countMap = tempList.stream().collect(Collectors.groupingBy(c -> {
                 return c.getFactoryYear() + "" + c.getFactoryWeek() + c.getCode();
             }));
         }
         if (StatisticalMethodEnum.MONTH.equals(vo.getEnums())) {
-            countMap = (Map) tempList.stream().collect(Collectors.groupingBy(c2 -> {
+            countMap = tempList.stream().collect(Collectors.groupingBy(c2 -> {
                 return c2.getFactoryYear() + "" + c2.getFactoryMonth() + c2.getCode();
             }));
         }
@@ -368,12 +379,12 @@
         splitFilterListVO.getItems().forEach(i -> {
             if (map.containsKey(i.getYear())) {
                 if (StatisticalMethodEnum.WEEK.equals(vo.getEnums())) {
-                    List<Integer> week = (List) map.get(i.getYear());
+                    List<Integer> week =  map.get(i.getYear());
                     week.add(i.getWeek());
                     map.put(i.getYear(), week);
                 }
                 if (StatisticalMethodEnum.MONTH.equals(vo.getEnums())) {
-                    List<Integer> month = (List) map.get(i.getYear());
+                    List<Integer> month =  map.get(i.getYear());
                     month.add(i.getMonth());
                     map.put(i.getYear(), month);
                     return;
@@ -381,12 +392,12 @@
                 return;
             }
             if (StatisticalMethodEnum.WEEK.equals(vo.getEnums())) {
-                ArrayList arrayList = new ArrayList();
+            	List<Integer> arrayList = new ArrayList<>();
                 arrayList.add(i.getWeek());
                 map.put(i.getYear(), arrayList);
             }
             if (StatisticalMethodEnum.MONTH.equals(vo.getEnums())) {
-                ArrayList arrayList2 = new ArrayList();
+            	List<Integer> arrayList2 = new ArrayList<>();
                 arrayList2.add(i.getMonth());
                 map.put(i.getYear(), arrayList2);
             }

--
Gitblit v1.9.3