package com.qianwen.smartman.modules.mdc.service.impl;
|
|
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;
|
import java.util.LinkedHashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
import java.util.stream.Collectors;
|
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
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;
|
import com.qianwen.core.oss.model.BladeFile;
|
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;
|
import com.qianwen.smartman.modules.mdc.excel.AlarmDataSheetExcel;
|
import com.qianwen.smartman.modules.mdc.excel.AlarmDataSheetExcelForOther;
|
import com.qianwen.smartman.modules.mdc.mapper.SuperAlarmMapper;
|
import com.qianwen.smartman.modules.mdc.service.IAlarmService;
|
import com.qianwen.smartman.modules.mdc.utils.FilterOffUtils;
|
import com.qianwen.smartman.modules.mdc.vo.AlarmDataSheetShiftVO;
|
import com.qianwen.smartman.modules.mdc.vo.AlarmDataSheetVO;
|
import com.qianwen.smartman.modules.mdc.vo.AlarmShiftSearchExcelVO;
|
import com.qianwen.smartman.modules.mdc.vo.AlarmShiftSearchVO;
|
import com.qianwen.smartman.modules.mdc.vo.AlarmSummaryGraphShiftVO;
|
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 cn.hutool.core.util.StrUtil;
|
|
@Service
|
public class AlarmServiceImpl implements IAlarmService {
|
private static final Logger log = LoggerFactory.getLogger(AlarmServiceImpl.class);
|
private final SuperAlarmMapper alarmMapper;
|
private final OssBuilder ossBuilder;
|
private final IShiftDetailService shiftDetailService;
|
private final WorkstationMapper workstationMapper;
|
public final Integer LENGTH_1 = 1;
|
|
public AlarmServiceImpl(final SuperAlarmMapper alarmMapper, final OssBuilder ossBuilder, final IShiftDetailService shiftDetailService, final WorkstationMapper workstationMapper) {
|
this.alarmMapper = alarmMapper;
|
this.ossBuilder = ossBuilder;
|
this.shiftDetailService = shiftDetailService;
|
this.workstationMapper = workstationMapper;
|
}
|
|
@Override // org.springblade.modules.mdc.service.IAlarmService
|
public IPage<AlarmDataSheetVO> pageAlarm(Query query, AlarmShiftSearchVO vo) {
|
if (Func.isNull(vo.getWorkstationId())) {
|
return new Page<>();
|
}
|
LocalDate queryTime = vo.getQueryTime();
|
List<SuperAlarm> list = this.alarmMapper.selectListAlarm(vo, DateUtil.format(queryTime, "yyyyMMdd"));
|
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<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 = res.stream().collect(Collectors.groupingBy(c2 -> {
|
return c2.getAlarmCode() + c2.getAlarmMsg();
|
}));
|
resMap.values().forEach(alarmDataSheetVOList -> {
|
((AlarmDataSheetVO) alarmDataSheetVOList.get(0)).setCount(Integer.valueOf(alarmDataSheetVOList.size()));
|
alarmDataSheetVOS.add(alarmDataSheetVOList.get(0));
|
});
|
if (query.getSize().intValue() == -1) {
|
page.setRecords(alarmDataSheetVOS);
|
} else if (alarmDataSheetVOS.size() < ((query.getCurrent().intValue() - 1) * query.getSize().intValue()) + query.getSize().intValue()) {
|
page.setRecords(alarmDataSheetVOS.subList((query.getCurrent().intValue() - 1) * query.getSize().intValue(), alarmDataSheetVOS.size()));
|
} else {
|
page.setRecords(alarmDataSheetVOS.subList((query.getCurrent().intValue() - 1) * query.getSize().intValue(), ((query.getCurrent().intValue() - 1) * query.getSize().intValue()) + query.getSize().intValue()));
|
}
|
return page;
|
}
|
|
@Override // org.springblade.modules.mdc.service.IAlarmService
|
public BladeFile exportAlarm(AlarmShiftSearchExcelVO vo) {
|
BladeFile bladeFile;
|
|
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());*/
|
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 = 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());
|
bladeFile = exportShift(superAlarms2, workstationVO, shiftInfoDtoList);
|
} else {
|
bladeFile = export(superAlarms, workstationVO, vo.getEnums());
|
}
|
return bladeFile;
|
}
|
|
private BladeFile exportShift(List<SuperAlarm> superAlarms, WorkstationVO workstationVO, List<ShiftInfoDTO> shiftInfoDtoList) {
|
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 = 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<SuperAlarm> list = result.put(x.getKey(), x.getValue());
|
});
|
result.forEach((k, v) -> {
|
Map<String, List<SuperAlarm>> mapGroupByAlarmCodeAndMessage = v.stream().collect(Collectors.groupingBy(s3 -> {
|
return s3.getCode() + "-" + s3.getMessage();
|
}));
|
mapGroupByAlarmCodeAndMessage.forEach((key, value) -> {
|
String alarmMessage;
|
AlarmDataSheetExcel alarmDataSheetExcel = new AlarmDataSheetExcel();
|
String[] split = k.split("-");
|
alarmDataSheetExcel.setDate(LocalDateTimeUtils.formatTimeLocalDate(LocalDate.parse(split[0], DateTimeFormatter.ofPattern("yyyyMMdd")), DateConstant.PATTERN_DATE));
|
String indexName = (String) shiftIndexToName.get(k);
|
alarmDataSheetExcel.setShift(Func.isNotEmpty(indexName) ? indexName : StrUtil.format("{}{}", new Object[]{shift, split[1]}));
|
alarmDataSheetExcel.setWorkstationCode(workstationVO.getCode());
|
alarmDataSheetExcel.setWorkstationName(workstationVO.getName());
|
alarmDataSheetExcel.setWorkstationGroup(workstationVO.getGroupName());
|
String[] splitByMessage = key.split("-");
|
String alarmCode = splitByMessage[0];
|
if (splitByMessage.length > this.LENGTH_1.intValue()) {
|
alarmMessage = splitByMessage[1];
|
} else {
|
alarmMessage = "";
|
}
|
alarmDataSheetExcel.setAlarmCode(alarmCode);
|
alarmDataSheetExcel.setAlarmMsg(alarmMessage);
|
alarmDataSheetExcel.setCount(String.valueOf(value.size()));
|
alarmDataSheetExcelList.add(alarmDataSheetExcel);
|
});
|
});
|
String fileName = String.format("%s-%s.xlsx", ExcelConstant.ALARM, DateUtil.time());
|
MultipartFile multipartFile = ExcelUtil.exportToMultipartFile(fileName, ExcelConstant.ALARM, alarmDataSheetExcelList, AlarmDataSheetExcel.class);
|
return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile);
|
}
|
|
private BladeFile export(List<SuperAlarm> superAlarms, WorkstationVO workstationVO, StatisticalMethodEnum statisticalMethodEnum) {
|
Map<String, List<SuperAlarm>> map;
|
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 = superAlarms.stream().collect(Collectors.groupingBy(s -> {
|
return String.valueOf(s.getFactoryDate());
|
}));
|
} else if (statisticalMethodEnum.equals(StatisticalMethodEnum.WEEK)) {
|
map = superAlarms.stream().collect(Collectors.groupingBy(s2 -> {
|
return s2.getFactoryYear() + "-" + s2.getFactoryWeek();
|
}));
|
} else {
|
map = superAlarms.stream().collect(Collectors.groupingBy(s3 -> {
|
return s3.getFactoryYear() + "-" + s3.getFactoryMonth();
|
}));
|
}
|
List<AlarmDataSheetExcelForOther> alarmDataSheetExcelForOtherList = new ArrayList<>();
|
Map<String, List<SuperAlarm>> result = new LinkedHashMap<>();
|
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 = v.stream().collect(Collectors.groupingBy(s4 -> {
|
return s4.getCode() + "-" + s4.getMessage();
|
}));
|
mapGroupByAlarmCodeAndMessage.forEach((key, value) -> {
|
String alarmMessage;
|
String[] split = k.split("-");
|
AlarmDataSheetExcelForOther alarmDataSheetExcelForOther = new AlarmDataSheetExcelForOther();
|
if (statisticalMethodEnum.equals(StatisticalMethodEnum.DAY)) {
|
alarmDataSheetExcelForOther.setDate(LocalDateTimeUtils.formatTimeLocalDate(LocalDate.parse(k, DateTimeFormatter.ofPattern("yyyyMMdd")), DateConstant.PATTERN_DATE));
|
} else if (statisticalMethodEnum.equals(StatisticalMethodEnum.WEEK)) {
|
alarmDataSheetExcelForOther.setDate(StrUtil.format("{}-{}", new Object[]{split[0], StrUtil.format("{}{}{}", new Object[]{the, split[1], week})}));
|
} else {
|
alarmDataSheetExcelForOther.setDate(StrUtil.format("{}-{}", new Object[]{split[0], split[1]}));
|
}
|
alarmDataSheetExcelForOther.setWorkstationCode(workstationVO.getCode());
|
alarmDataSheetExcelForOther.setWorkstationName(workstationVO.getName());
|
alarmDataSheetExcelForOther.setWorkstationGroup(workstationVO.getGroupName());
|
String[] splitByMessage = key.split("-");
|
String alarmCode = splitByMessage[0];
|
if (splitByMessage.length > this.LENGTH_1.intValue()) {
|
alarmMessage = splitByMessage[1];
|
} else {
|
alarmMessage = "";
|
}
|
alarmDataSheetExcelForOther.setAlarmCode(alarmCode);
|
alarmDataSheetExcelForOther.setAlarmMsg(alarmMessage);
|
alarmDataSheetExcelForOther.setCount(String.valueOf(value.size()));
|
alarmDataSheetExcelForOtherList.add(alarmDataSheetExcelForOther);
|
});
|
});
|
String fileName = String.format("%s-%s.xlsx", ExcelConstant.ALARM, DateUtil.time());
|
MultipartFile multipartFile = ExcelUtil.exportToMultipartFile(fileName, ExcelConstant.ALARM, alarmDataSheetExcelForOtherList, AlarmDataSheetExcelForOther.class);
|
return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile);
|
}
|
|
@Override // org.springblade.modules.mdc.service.IAlarmService
|
public AlarmSummaryGraphVO summaryGraph(AlarmShiftSearchVO vo) {
|
if (Func.isNull(vo.getWorkstationId())) {
|
return new AlarmSummaryGraphVO();
|
}
|
List<SuperAlarm> alarms = this.alarmMapper.queryAlarm(null, vo, DateUtil.format(vo.getQueryTime(), "yyyyMMdd"));
|
Map<String, Integer> map = FilterOffUtils.filterOffDay(alarms, OpenTypeEnums.ALARM_ANALYSIS).stream().collect(Collectors.groupingBy((v0) -> {
|
return v0.getCode();
|
}, Collectors.reducing(0, e -> {
|
return 1;
|
}, (v0, v1) -> {
|
return Integer.sum(v0, v1);
|
})));
|
return AlarmSummaryGraphVO.builder().res(map).build();
|
}
|
|
@Override // org.springblade.modules.mdc.service.IAlarmService
|
public List<AlarmDataSheetShiftVO> listShiftAlarm(AlarmShiftSearchVO vo) {
|
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 shiftInfoDtoList.stream().map(shiftInfoDTO -> {
|
AlarmDataSheetShiftVO alarmDataSheetShiftVO = new AlarmDataSheetShiftVO();
|
vo.setShiftIndex(shiftInfoDTO.getShiftIndex());
|
Query query = new Query();
|
query.setSize(-1);
|
query.setCurrent(1);
|
List<AlarmDataSheetVO> alarmDataSheetVOList = pageAlarm(query, vo).getRecords();
|
alarmDataSheetShiftVO.setShiftIndex(shiftInfoDTO.getShiftIndex());
|
alarmDataSheetShiftVO.setShiftName(Func.isNotEmpty(shiftInfoDTO.getIndexName()) ? shiftInfoDTO.getIndexName() : StrUtil.format("{}{}", new Object[]{shift, shiftInfoDTO.getShiftIndex()}));
|
alarmDataSheetShiftVO.setAlarmDataSheetVOList(alarmDataSheetVOList);
|
return alarmDataSheetShiftVO;
|
}).collect(Collectors.toList());
|
}
|
|
@Override // org.springblade.modules.mdc.service.IAlarmService
|
public List<AlarmSummaryGraphShiftVO> summaryShiftGraph(AlarmShiftSearchVO vo) {
|
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 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()}));
|
vo.setShiftIndex(shiftInfoDTO.getShiftIndex());
|
AlarmSummaryGraphVO alarmSummaryGraphVO = summaryGraph(vo);
|
alarmSummaryGraphShiftVO.setRes(alarmSummaryGraphVO.getRes());
|
return alarmSummaryGraphShiftVO;
|
}).collect(Collectors.toList());
|
}
|
|
private List<AlarmDataSheetExcelForOther> getDayData(AlarmShiftSearchExcelVO vo, WorkstationVO workstationVO) {
|
List<SuperAlarm> list = this.alarmMapper.selectAllAlarm(vo, DateUtil.format(vo.getStartTime(), "yyyyMMdd"), DateUtil.format(vo.getEndTime(), "yyyyMMdd"), null, null);
|
List<SuperAlarm> tempList = new ArrayList<>();
|
Set<String> set = new HashSet<>();
|
list.forEach(i -> {
|
if (!set.contains(i.getCode() + i.getMessage() + i.getFactoryDate())) {
|
tempList.add(i);
|
set.add(i.getCode() + i.getMessage() + i.getFactoryDate());
|
}
|
});
|
Map<String, List<SuperAlarm>> countMap = tempList.stream().collect(Collectors.groupingBy(c -> {
|
return c.getFactoryDate() + c.getCode();
|
}));
|
List<AlarmDataSheetExcelForOther> result = new ArrayList<>();
|
for (Map.Entry<String, List<SuperAlarm>> entry : countMap.entrySet()) {
|
if (CollectionUtil.isNotEmpty(entry.getValue())) {
|
AlarmDataSheetExcelForOther alarmDataSheetExcelForOther = new AlarmDataSheetExcelForOther();
|
LocalDate localDate = LocalDateUtil.stringToLocalDate(String.valueOf(entry.getValue().get(0).getFactoryDate()), "yyyyMMdd");
|
alarmDataSheetExcelForOther.setDate(localDate.format(DateTimeFormatter.ofPattern(DateConstant.PATTERN_DATE)));
|
alarmDataSheetExcelForOther.setWorkstationGroup(workstationVO.getGroupName());
|
alarmDataSheetExcelForOther.setWorkstationCode(workstationVO.getCode());
|
alarmDataSheetExcelForOther.setWorkstationName(workstationVO.getName());
|
alarmDataSheetExcelForOther.setAlarmCode(entry.getValue().get(0).getCode());
|
alarmDataSheetExcelForOther.setAlarmMsg(entry.getValue().get(0).getMessage());
|
alarmDataSheetExcelForOther.setCount(String.valueOf(entry.getValue().size()));
|
result.add(alarmDataSheetExcelForOther);
|
}
|
}
|
return result;
|
}
|
|
/* JADX WARN: Multi-variable type inference failed */
|
private List<AlarmDataSheetExcelForOther> getMonthOrWeekDate(Map<Integer, List<Integer>> map, AlarmShiftSearchExcelVO vo, WorkstationVO workstationVO) {
|
List<SuperAlarm> list = new ArrayList<>();
|
for (Map.Entry<Integer, List<Integer>> entry : map.entrySet()) {
|
list.addAll(this.alarmMapper.selectAllAlarm(vo, null, null, entry.getKey(), entry.getValue()));
|
}
|
List<SuperAlarm> tempList = new ArrayList<>();
|
Set<String> set = new HashSet<>();
|
list.forEach(i -> {
|
if (!set.contains(i.getCode() + i.getMessage() + i.getFactoryDate())) {
|
tempList.add(i);
|
set.add(i.getCode() + i.getMessage() + i.getFactoryDate());
|
}
|
});
|
Map<String, List<SuperAlarm>> countMap = new HashMap<>();
|
if (StatisticalMethodEnum.WEEK.equals(vo.getEnums())) {
|
countMap = tempList.stream().collect(Collectors.groupingBy(c -> {
|
return c.getFactoryYear() + "" + c.getFactoryWeek() + c.getCode();
|
}));
|
}
|
if (StatisticalMethodEnum.MONTH.equals(vo.getEnums())) {
|
countMap = tempList.stream().collect(Collectors.groupingBy(c2 -> {
|
return c2.getFactoryYear() + "" + c2.getFactoryMonth() + c2.getCode();
|
}));
|
}
|
List<AlarmDataSheetExcelForOther> result = new ArrayList<>();
|
for (Map.Entry<String, List<SuperAlarm>> entry2 : countMap.entrySet()) {
|
if (CollectionUtil.isNotEmpty(entry2.getValue())) {
|
AlarmDataSheetExcelForOther alarmDataSheetExcelForOther = new AlarmDataSheetExcelForOther();
|
if (StatisticalMethodEnum.WEEK.equals(vo.getEnums())) {
|
alarmDataSheetExcelForOther.setDate(StrUtil.format("{}-第{}周", new Object[]{entry2.getValue().get(0).getFactoryYear(), entry2.getValue().get(0).getFactoryWeek()}));
|
}
|
if (StatisticalMethodEnum.MONTH.equals(vo.getEnums())) {
|
alarmDataSheetExcelForOther.setDate(StrUtil.format("{}-{}", new Object[]{entry2.getValue().get(0).getFactoryYear(), entry2.getValue().get(0).getFactoryMonth()}));
|
}
|
alarmDataSheetExcelForOther.setWorkstationGroup(workstationVO.getGroupName());
|
alarmDataSheetExcelForOther.setWorkstationCode(workstationVO.getCode());
|
alarmDataSheetExcelForOther.setWorkstationName(workstationVO.getName());
|
alarmDataSheetExcelForOther.setAlarmCode(entry2.getValue().get(0).getCode());
|
alarmDataSheetExcelForOther.setAlarmMsg(entry2.getValue().get(0).getMessage());
|
alarmDataSheetExcelForOther.setCount(String.valueOf(entry2.getValue().size()));
|
result.add(alarmDataSheetExcelForOther);
|
}
|
}
|
return result;
|
}
|
|
Map<Integer, List<Integer>> organizeQuery(SplitFilterListVO splitFilterListVO, AlarmShiftSearchExcelVO vo) {
|
Map<Integer, List<Integer>> map = new HashMap<>();
|
splitFilterListVO.getItems().forEach(i -> {
|
if (map.containsKey(i.getYear())) {
|
if (StatisticalMethodEnum.WEEK.equals(vo.getEnums())) {
|
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 = map.get(i.getYear());
|
month.add(i.getMonth());
|
map.put(i.getYear(), month);
|
return;
|
}
|
return;
|
}
|
if (StatisticalMethodEnum.WEEK.equals(vo.getEnums())) {
|
List<Integer> arrayList = new ArrayList<>();
|
arrayList.add(i.getWeek());
|
map.put(i.getYear(), arrayList);
|
}
|
if (StatisticalMethodEnum.MONTH.equals(vo.getEnums())) {
|
List<Integer> arrayList2 = new ArrayList<>();
|
arrayList2.add(i.getMonth());
|
map.put(i.getYear(), arrayList2);
|
}
|
});
|
return map;
|
}
|
}
|