| | |
| | | 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.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.constant.ExcelConstant; |
| | | import com.qianwen.smartman.common.constant.MdcConstant; |
| | | import com.qianwen.smartman.common.constant.ShiftConstant; |
| | | import com.qianwen.smartman.common.utils.LocalDateTimeUtils; |
| | | 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.ExcelConstant; |
| | | import com.qianwen.smartman.common.constant.MdcConstant; |
| | | import com.qianwen.smartman.common.constant.ShiftConstant; |
| | | import com.qianwen.smartman.common.utils.LocalDateTimeUtils; |
| | | 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; |
| | |
| | | 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/OutputStatisticsServiceImpl.class */ |
| | |
| | | private static final Logger log = LoggerFactory.getLogger(OutputStatisticsServiceImpl.class); |
| | | private static final String FILENAME = String.format("%s-%s.xlsx", ExcelConstant.OUTPUT_ACCOUNT, DateUtil.time()); |
| | | |
| | | 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 OutputStatisticsServiceImpl(final IWorkstationService workstationService, final ISuperAggregateOutputService superAggregateOutputService, final StatisticsWrapper wrapper, final WorkstationMapper workstationMapper, final IShiftDetailService shiftDetailService, final OssBuilder ossBuilder, final IStatisticsService statisticsService) { |
| | | this.workstationService = workstationService; |
| | | this.superAggregateOutputService = superAggregateOutputService; |
| | |
| | | public StatisticsVO outputStatistics(StatisticsAnalysisQueryVO statisticsAnalysisQueryVO, Query query) { |
| | | 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()); |
| | |
| | | StatisticalMethodEnum statisticalMethod = analysisQueryVO.getStatisticalMethod(); |
| | | List<String> workStationIdList = analysisQueryVO.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(statisticalMethod); |
| | | } |
| | |
| | | List<WorkstationVO> workstationVOList = this.workstationMapper.queryWorkstationAndGroup(Condition.getPage(new Query().setSize(-1)), workstationIds).getRecords(); |
| | | if (StatisticalMethodEnum.SHIFT.equals(statisticalMethod)) { |
| | | List<ShiftInfoDTO> shiftInfoDtoList = this.shiftDetailService.getShiftInfoDtoList(workstationIds, analysisQueryVO.getStartDate(), analysisQueryVO.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(); |
| | |
| | | } |
| | | List<List<String>> heads = new ArrayList<>(); |
| | | List<List<Object>> columnData = new ArrayList<>(); |
| | | MultipartFile multipartFile = ExcelStrategyUtil.customerExport(FILENAME, ExcelConstant.OUTPUT_ACCOUNT, heads, columnData); |
| | | return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | | MultipartFile multipartFile; |
| | | try { |
| | | multipartFile = ExcelStrategyUtil.customerExport(FILENAME, ExcelConstant.OUTPUT_ACCOUNT, heads, columnData); |
| | | return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | | } catch (Exception e) { |
| | | log.error("导出错误",e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | private BladeFile exportOutputs(List<SuperAggregateOutput> aggregateOutputs, List<WorkstationVO> workstationVOList, StatisticsAnalysisQueryVO statisticsAnalysisQueryVO) { |
| | |
| | | Collection<SplitFilterVO> items = splitFilterListVO.getItems(); |
| | | buildExcelHeads(heads, items, statisticalMethod); |
| | | buildExcelData(columnData, workstationVOList, statisticsAnalysisQueryVO, items, aggregateOutputs); |
| | | MultipartFile multipartFile = ExcelStrategyUtil.customerExport(FILENAME, ExcelConstant.OUTPUT_ACCOUNT, heads, columnData); |
| | | return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | | try { |
| | | MultipartFile multipartFile = ExcelStrategyUtil.customerExport(FILENAME, ExcelConstant.OUTPUT_ACCOUNT, heads, columnData); |
| | | return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | | } catch (Exception e) { |
| | | log.error("导出错误",e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public BladeFile exportOutputShift(List<IntervalDateDto> intervalDates, List<SuperAggregate> superAggregates, List<WorkstationVO> workstationVOList, List<Integer> shiftIndexList, Map<String, String> shiftInfoMap) { |
| | | Map<String, List<SuperAggregate>> map = (Map) superAggregates.stream().collect(Collectors.groupingBy(s -> { |
| | | Map<String, List<SuperAggregate>> map =superAggregates.stream().collect(Collectors.groupingBy(s -> { |
| | | return s.getFactoryDate() + "-" + s.getWorkstationId() + "-" + s.getShiftIndex(); |
| | | })); |
| | | List<OutputShiftIndexSheetExcel> sheetExcels = new ArrayList<>(); |
| | |
| | | buildEmptyData(index, excel, MessageUtils.message("mdc.not.schedule", new Object[0])); |
| | | return; |
| | | } |
| | | List<SuperAggregate> superAggregateList = (List) map.get(intDayKey); |
| | | List<SuperAggregate> superAggregateList = map.get(intDayKey); |
| | | if (Func.isEmpty(superAggregateList)) { |
| | | buildData(index, excel, shiftName, ZERO); |
| | | return; |
| | |
| | | workstationVOList.forEach(workstationVO -> { |
| | | List<Long> keyList; |
| | | Map<Long, List<SuperAggregateOutput>> map; |
| | | ArrayList arrayList = new ArrayList(); |
| | | List<Object> arrayList = new ArrayList<>(); |
| | | arrayList.add(workstationVO.getGroupName()); |
| | | arrayList.add(workstationVO.getCode()); |
| | | arrayList.add(workstationVO.getName()); |
| | | |
| | | Long workstationId = workstationVO.getId(); |
| | | switch (statisticalMethod) { |
| | | case DAY: |
| | | keyList = (List) items.stream().map(s -> { |
| | | keyList = items.stream().map(s -> { |
| | | return Long.valueOf(workstationId.longValue() + Integer.parseInt(s.getDate().replace("-", ""))); |
| | | }).collect(Collectors.toList()); |
| | | map = (Map) aggregateOutputs.stream().collect(Collectors.groupingBy(s2 -> { |
| | | map = aggregateOutputs.stream().collect(Collectors.groupingBy(s2 -> { |
| | | return Long.valueOf(s2.getWorkstationId().longValue() + s2.getFactoryDate().intValue()); |
| | | })); |
| | | break; |
| | | case WEEK: |
| | | keyList = (List) items.stream().map(s3 -> { |
| | | keyList = items.stream().map(s3 -> { |
| | | return Long.valueOf(workstationId.longValue() + s3.getYear().intValue() + s3.getWeek().intValue()); |
| | | }).collect(Collectors.toList()); |
| | | map = (Map) aggregateOutputs.stream().collect(Collectors.groupingBy(s4 -> { |
| | | map = aggregateOutputs.stream().collect(Collectors.groupingBy(s4 -> { |
| | | return Long.valueOf(s4.getWorkstationId().longValue() + s4.getFactoryYear().intValue() + s4.getFactoryWeek().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) aggregateOutputs.stream().collect(Collectors.groupingBy(s6 -> { |
| | | map = aggregateOutputs.stream().collect(Collectors.groupingBy(s6 -> { |
| | | return Long.valueOf(s6.getWorkstationId().longValue() + s6.getFactoryYear().intValue() + s6.getFactoryMonth().intValue()); |
| | | })); |
| | | break; |
| | | } |
| | | Map<Long, List<SuperAggregateOutput>> finalMap = map; |
| | | keyList.forEach(key -> { |
| | | List<SuperAggregateOutput> superAggregateOutputs = (List) finalMap.get(key); |
| | | List<SuperAggregateOutput> superAggregateOutputs = finalMap.get(key); |
| | | if (Func.isEmpty(superAggregateOutputs)) { |
| | | arrayList.add(ZERO); |
| | | } else { |