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/EfficiencyAnalysisServiceImpl.java |  144 ++++++++++++++++++++----------------------------
 1 files changed, 60 insertions(+), 84 deletions(-)

diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/EfficiencyAnalysisServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/EfficiencyAnalysisServiceImpl.java
index 66156a0..2164fe8 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/EfficiencyAnalysisServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/EfficiencyAnalysisServiceImpl.java
@@ -1,12 +1,5 @@
 package com.qianwen.smartman.modules.mdc.service.impl;
 
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.google.common.collect.Lists;
-import java.lang.invoke.SerializedLambda;
 import java.math.BigDecimal;
 import java.time.DayOfWeek;
 import java.time.LocalDate;
@@ -17,20 +10,28 @@
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
+
 import javax.servlet.http.HttpServletResponse;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.qianwen.smartman.common.constant.CommonConstant;
-import com.qianwen.smartman.common.constant.MdcConstant;
-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.core.toolkit.Wrappers;
+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;
 import com.qianwen.core.oss.model.BladeFile;
 import com.qianwen.core.tool.utils.DateUtil;
 import com.qianwen.core.tool.utils.Func;
+import com.qianwen.smartman.common.constant.CommonConstant;
+import com.qianwen.smartman.common.constant.MdcConstant;
+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.convert.WorkstationConvert;
 import com.qianwen.smartman.modules.cps.dto.ShiftInfoDTO;
 import com.qianwen.smartman.modules.cps.entity.Workstation;
@@ -60,8 +61,8 @@
 import com.qianwen.smartman.modules.mdc.vo.StatisticsVO;
 import com.qianwen.smartman.modules.mdc.wrapper.StatisticsWrapper;
 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/EfficiencyAnalysisServiceImpl.class */
@@ -80,52 +81,6 @@
     private final Integer SHIFT3 = 3;
     private final Integer SHIFT4 = 4;
 
-    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
-        String implMethodName = lambda.getImplMethodName();
-        boolean z = true;
-        switch (implMethodName.hashCode()) {
-            case -75106384:
-                if (implMethodName.equals("getType")) {
-                    z = false;
-                    break;
-                }
-                break;
-            case 803533544:
-                if (implMethodName.equals("getStatus")) {
-                    z = true;
-                    break;
-                }
-                break;
-        }
-        switch (z) {
-            case false:
-                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/Workstation") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
-                    return (v0) -> {
-                        return v0.getType();
-                    };
-                }
-                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/Workstation") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
-                    return (v0) -> {
-                        return v0.getType();
-                    };
-                }
-                break;
-            case true:
-                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
-                    return (v0) -> {
-                        return v0.getStatus();
-                    };
-                }
-                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
-                    return (v0) -> {
-                        return v0.getStatus();
-                    };
-                }
-                break;
-        }
-        throw new IllegalArgumentException("Invalid lambda deserialization");
-    }
-
     public EfficiencyAnalysisServiceImpl(final ISuperAggregateStateService superAggregateStateService, final IWorkstationService workstationService, final StatisticsWrapper wrapper, final WorkstationMapper workstationMapper, final OssBuilder ossBuilder, final IShiftDetailService shiftDetailService, final IStatisticsService statisticsService) {
         this.superAggregateStateService = superAggregateStateService;
         this.workstationService = workstationService;
@@ -141,17 +96,19 @@
         List<SuperAggregateState> superAggregateStates;
         List<String> workStationIdList = statisticsAnalysisQueryVO.getWorkStationIdList();
         if (Func.isEmpty(workStationIdList)) {
+        	workStationIdList = this.workstationService.list(Wrappers.<Workstation>lambdaQuery().eq(Workstation::getType, WorkstationTypeEnum.MACHINE.getCode()).eq(Workstation::getStatus, CommonConstant.ENABLE)).stream().map(s -> Func.toStr(s.getId())).collect(Collectors.toList()); 
+        	/*
             workStationIdList = (List) this.workstationService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
                 return v0.getType();
             }, WorkstationTypeEnum.MACHINE.getCode())).eq((v0) -> {
                 return v0.getStatus();
             }, CommonConstant.ENABLE)).stream().map(s -> {
                 return Func.toStr(s.getId());
-            }).collect(Collectors.toList());
+            }).collect(Collectors.toList());*/
         }
         IPage<WorkstationVO> workstationVOPage = this.workstationMapper.queryWorkstationAndGroup(Condition.getPage(query), Func.toLongList(workStationIdList));
         IPage<Workstation> workstationPage = WorkstationConvert.INSTANCE.convert(workstationVOPage);
-        List<Long> workstationIds = (List) workstationPage.getRecords().stream().map((v0) -> {
+        List<Long> workstationIds = workstationPage.getRecords().stream().map((v0) -> {
             return v0.getId();
         }).collect(Collectors.toList());
         List<IntervalDateDto> intervalDates = LocalDateTimeUtils.getIntervalDate(statisticsAnalysisQueryVO.getStartDate(), statisticsAnalysisQueryVO.getEndDate());
@@ -160,7 +117,7 @@
         } else {
             superAggregateStates = this.superAggregateStateService.getStatusData(workstationIds, statisticsAnalysisQueryVO.getStatisticalMethod(), statisticsAnalysisQueryVO.getStartDate(), statisticsAnalysisQueryVO.getEndDate());
         }
-        List<SuperAggregate> superAggregateList = (List) superAggregateStates.stream().filter(x -> {
+        List<SuperAggregate> superAggregateList = superAggregateStates.stream().filter(x -> {
             return x.getWcs().intValue() > 0;
         }).collect(Collectors.toList());
         StatisticsWrapperDto statisticsWrapperDto = new StatisticsWrapperDto(superAggregateList, statisticsAnalysisQueryVO, intervalDates, workstationPage, MdcConstant.STATE);
@@ -222,15 +179,17 @@
         List<SuperAggregateState> superAggregateStates;
         List<String> workStationIdList = statisticsAnalysisQueryVO.getWorkStationIdList();
         if (Func.isEmpty(workStationIdList)) {
+        	workStationIdList = (List<String>)this.workstationService.list(Wrappers.<Workstation>lambdaQuery().eq(Workstation::getType, WorkstationTypeEnum.MACHINE.getCode()).eq(Workstation::getStatus, CommonConstant.ENABLE)).stream().map(s -> Func.toStr(s.getId())).collect(Collectors.toList()); 
+        	/*
             workStationIdList = (List) this.workstationService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
                 return v0.getType();
             }, WorkstationTypeEnum.MACHINE.getCode())).eq((v0) -> {
                 return v0.getStatus();
             }, CommonConstant.ENABLE)).stream().map(s -> {
                 return Func.toStr(s.getId());
-            }).collect(Collectors.toList());
+            }).collect(Collectors.toList());*/
         }
-        List<Long> workstationIds = (List) workStationIdList.stream().map(Long::valueOf).collect(Collectors.toList());
+        List<Long> workstationIds = workStationIdList.stream().map(Long::valueOf).collect(Collectors.toList());
         if (Func.isEmpty(workstationIds)) {
             return exportEmpty(statisticsAnalysisQueryVO.getStatisticalMethod(), statisticsAnalysisQueryVO.getProductivityType());
         }
@@ -240,13 +199,13 @@
         } else {
             superAggregateStates = this.superAggregateStateService.getStatusData(workstationIds, statisticsAnalysisQueryVO.getStatisticalMethod(), statisticsAnalysisQueryVO.getStartDate(), statisticsAnalysisQueryVO.getEndDate());
         }
-        List<SuperAggregateState> superAggregateStates2 = (List) superAggregateStates.stream().filter(x -> {
+        List<SuperAggregateState> superAggregateStates2 = superAggregateStates.stream().filter(x -> {
             return x.getWcs().intValue() > 0;
         }).collect(Collectors.toList());
         List<WorkstationVO> workstationVOList = this.workstationMapper.queryWorkstationAndGroup(Condition.getPage(new Query().setSize(-1)), workstationIds).getRecords();
         if (StatisticalMethodEnum.SHIFT.equals(statisticsAnalysisQueryVO.getStatisticalMethod())) {
             List<ShiftInfoDTO> shiftInfoDtoList = this.shiftDetailService.getShiftInfoDtoList(workstationIds, statisticsAnalysisQueryVO.getStartDate(), statisticsAnalysisQueryVO.getEndDate());
-            Map<String, String> shiftInfoMap = (Map) shiftInfoDtoList.stream().collect(Collectors.toMap(s2 -> {
+            Map<String, String> shiftInfoMap = shiftInfoDtoList.stream().collect(Collectors.toMap(s2 -> {
                 return s2.getDate() + "-" + s2.getWorkstationId() + "-" + s2.getShiftIndex();
             }, (v0) -> {
                 return v0.getIndexName();
@@ -267,8 +226,16 @@
         List<List<String>> head = new ArrayList<>();
         List<List<Object>> data = new ArrayList<>();
         String fileName2 = String.format("%s-%s.xlsx", name, DateUtil.time());
-        MultipartFile multipartFile2 = ExcelStrategyUtil.customerExport(fileName2, name, head, data);
-        return this.ossBuilder.tempTemplate().putFile(multipartFile2.getOriginalFilename(), multipartFile2);
+        MultipartFile multipartFile2;
+		try {
+			multipartFile2 = ExcelStrategyUtil.customerExport(fileName2, name, head, data);
+			return this.ossBuilder.tempTemplate().putFile(multipartFile2.getOriginalFilename(), multipartFile2);
+		} catch (Exception e) {
+			log.error("瀵煎嚭閿欒",e);
+			e.printStackTrace();
+			throw new RuntimeException(e);
+		}
+        
     }
 
     private BladeFile export(List<SuperAggregateState> superAggregateList, List<WorkstationVO> workstationVOList, StatisticsAnalysisQueryVO statisticsAnalysisQueryVO) {
@@ -286,50 +253,59 @@
         buildData(data, workstationVOList, statisticsAnalysisQueryVO, items, superAggregateList);
         String name = getName(statisticsAnalysisQueryVO.getProductivityType());
         String fileName = String.format("%s-%s.xlsx", name, DateUtil.time());
-        MultipartFile multipartFile = ExcelStrategyUtil.customerExport(fileName, name, head, data);
-        return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile);
+        try {
+	        MultipartFile multipartFile = ExcelStrategyUtil.customerExport(fileName, name, head, data);
+	        return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile);
+        } catch (Exception e) {
+			log.error("瀵煎嚭閿欒",e);
+			e.printStackTrace();
+			throw new RuntimeException(e);
+		}
     }
 
     private void buildData(List<List<Object>> data, List<WorkstationVO> workstationVOList, StatisticsAnalysisQueryVO statisticsAnalysisQueryVO, Collection<SplitFilterVO> items, List<SuperAggregateState> superAggregateList) {
         workstationVOList.forEach(workstationVO -> {
-            List<Long> keyList;
-            Map<Long, List<SuperAggregateState>> map;
-            ArrayList arrayList = new ArrayList();
+            //List<Long> keyList;
+            //Map<Long, List<SuperAggregateState>> map;
+            ArrayList<Object> arrayList = new ArrayList<>();
             arrayList.add(workstationVO.getGroupName());
             arrayList.add(workstationVO.getCode());
             arrayList.add(workstationVO.getName());
-            new ArrayList();
-            new HashMap();
+            
+            List<Long> keyList = new ArrayList<>();
+            Map<Long, List<SuperAggregateState>> map = new HashMap<>();
+            /*new ArrayList();
+            new HashMap();*/
             Long workstationId = workstationVO.getId();
             switch (statisticsAnalysisQueryVO.getStatisticalMethod()) {
                 case WEEK:
-                    keyList = (List) items.stream().map(s -> {
+                    keyList = items.stream().map(s -> {
                         return Long.valueOf(workstationId.longValue() + s.getYear().intValue() + s.getWeek().intValue());
                     }).collect(Collectors.toList());
-                    map = (Map) superAggregateList.stream().collect(Collectors.groupingBy(s2 -> {
+                    map = superAggregateList.stream().collect(Collectors.groupingBy(s2 -> {
                         return Long.valueOf(s2.getWorkstationId().longValue() + s2.getFactoryYear().intValue() + s2.getFactoryWeek().intValue());
                     }));
                     break;
                 case DAY:
-                    keyList = (List) items.stream().map(s3 -> {
+                    keyList = items.stream().map(s3 -> {
                         return Long.valueOf(workstationId.longValue() + Integer.parseInt(s3.getDate().replace("-", "")));
                     }).collect(Collectors.toList());
-                    map = (Map) superAggregateList.stream().collect(Collectors.groupingBy(s4 -> {
+                    map = superAggregateList.stream().collect(Collectors.groupingBy(s4 -> {
                         return Long.valueOf(s4.getWorkstationId().longValue() + s4.getFactoryDate().intValue());
                     }));
                     break;
                 default:
-                    keyList = (List) items.stream().map(s5 -> {
+                    keyList = items.stream().map(s5 -> {
                         return Long.valueOf(workstationId.longValue() + s5.getYear().intValue() + s5.getMonth().intValue());
                     }).collect(Collectors.toList());
-                    map = (Map) superAggregateList.stream().collect(Collectors.groupingBy(s6 -> {
+                    map =  superAggregateList.stream().collect(Collectors.groupingBy(s6 -> {
                         return Long.valueOf(s6.getWorkstationId().longValue() + s6.getFactoryYear().intValue() + s6.getFactoryMonth().intValue());
                     }));
                     break;
             }
             Map<Long, List<SuperAggregateState>> finalMap = map;
             keyList.forEach(key -> {
-                List<SuperAggregateState> superAggregateStates = (List) finalMap.get(key);
+                List<SuperAggregateState> superAggregateStates = finalMap.get(key);
                 if (Func.isEmpty(superAggregateStates)) {
                     arrayList.add(ZERO);
                     return;
@@ -365,7 +341,7 @@
 
     public BladeFile exportShift(List<IntervalDateDto> intervalDates, List<SuperAggregateState> superAggregateList, List<WorkstationVO> workstationVOList, List<Integer> shiftIndexList, ProductivityTypeEnum productivityTypeEnum, Map<String, String> shiftInfoMap) {
         String message = MessageUtils.message("mdc.not.schedule", new Object[0]);
-        Map<String, List<SuperAggregateState>> map = (Map) superAggregateList.stream().collect(Collectors.groupingBy(s -> {
+        Map<String, List<SuperAggregateState>> map = superAggregateList.stream().collect(Collectors.groupingBy(s -> {
             return s.getFactoryDate() + "-" + s.getWorkstationId() + "-" + s.getShiftIndex();
         }));
         List<EfficiencyAnalysisExport> efficiencyAnalysisExportList = new ArrayList<>();

--
Gitblit v1.9.3