|
@@ -1,237 +1,237 @@
|
|
|
-package com.hssx.cloudmodel.service.impl;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.hssx.cloudmodel.entity.*;
|
|
|
-import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
|
|
|
-import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
|
|
|
-import com.hssx.cloudmodel.mapper.*;
|
|
|
-import com.hssx.cloudmodel.service.MouldHistoryService;
|
|
|
-import com.hssx.cloudmodel.util.ExcelUtil;
|
|
|
-import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
|
-import com.hssx.cloudmodel.util.TimeAndCountUtil;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * <p>
|
|
|
- * 服务实现类
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @author 吴涛涛
|
|
|
- * @since 2019-10-11
|
|
|
- */
|
|
|
-@Service
|
|
|
-public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, MouldHistory> implements MouldHistoryService {
|
|
|
- @Resource
|
|
|
- private MouldHistoryMapper mouldHistoryMapper;
|
|
|
- @Resource
|
|
|
- private MouldHistoryTimeMapper mouldHistoryTimeMapper;
|
|
|
- @Resource
|
|
|
- private MouldCycleRuntimeMapper mouldCycleRuntimeMapper;
|
|
|
- @Resource
|
|
|
- private MouldMapper mouldMapper;
|
|
|
- @Resource
|
|
|
- private MouldEquipmentMapper mouldEquipmentMapper;
|
|
|
- @Resource
|
|
|
- private InjectionMoldingMapper injectionMoldingMapper;
|
|
|
- @Value("${upload.path}")
|
|
|
- private String downloadPath;
|
|
|
-
|
|
|
- @Override
|
|
|
- public HttpRespMsg getOpeningAndClosingTimesChart(HttpServletResponse response, String equipmentNo, String startTime, String endTime, Integer type) {
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
- if (type != null) {
|
|
|
- if (type == 0) {
|
|
|
- List<MouldCycleRuntime> cycleRuntimeList = mouldCycleRuntimeMapper.selectList(new QueryWrapper<MouldCycleRuntime>()
|
|
|
- .eq("equipment_no", equipmentNo).between("date_str", startTime, endTime));
|
|
|
- //给集合排序先按照日期,如果一样再按照时间段
|
|
|
- cycleRuntimeList = cycleRuntimeList.stream().sorted(Comparator.comparing(MouldCycleRuntime::getDateStr).thenComparing(MouldCycleRuntime::getTimeSlot)).collect(Collectors.toList());
|
|
|
- //数据已经查到,开始导出excel
|
|
|
- List<List<String>> list = new ArrayList<List<String>>();
|
|
|
- //标题
|
|
|
- List<String> titleList = new ArrayList<String>();
|
|
|
- titleList.add("设备编号");
|
|
|
- titleList.add("日期");
|
|
|
- titleList.add("时间段");
|
|
|
- titleList.add("运行次数");
|
|
|
- list.add(titleList);
|
|
|
- SimpleDateFormat dateSdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
|
|
|
- List<MouldOperationDynamics> mouldOperationDynamics = new ArrayList<>();
|
|
|
- for (MouldCycleRuntime cycleRuntime : cycleRuntimeList) {
|
|
|
- List<String> rowList = new ArrayList<String>();
|
|
|
- //设备编号
|
|
|
- rowList.add(cycleRuntime.getEquipmentNo());
|
|
|
- //日期
|
|
|
- rowList.add(cycleRuntime.getDateStr());
|
|
|
- //时间段
|
|
|
- rowList.add(cycleRuntime.getTimeSlot());
|
|
|
- //运行次数
|
|
|
- rowList.add(cycleRuntime.getRuntime() + "");
|
|
|
-// rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(dynamic.getIndate())
|
|
|
- list.add(rowList);
|
|
|
- }
|
|
|
- String fileUrl = ExcelUtil.exportGeneralExcelByTitleAndList(response, equipmentNo + "-周期运行次数" + dateSdf2.format(new Date()), list, downloadPath);
|
|
|
- msg.data = fileUrl;
|
|
|
- }else if(type == 1){
|
|
|
- List<MouldHistoryTime> mouldHistoryTimeList = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycleExcel(startTime, endTime, equipmentNo);
|
|
|
- //数据已经查到,开始导出excel
|
|
|
- List<List<String>> list = new ArrayList<List<String>>();
|
|
|
- //标题
|
|
|
- List<String> titleList = new ArrayList<String>();
|
|
|
- titleList.add("设备编号");
|
|
|
- titleList.add("开合次数");
|
|
|
- titleList.add("合模时间");
|
|
|
- titleList.add("开模时间");
|
|
|
- titleList.add("开模周期");
|
|
|
- list.add(titleList);
|
|
|
- SimpleDateFormat dateSdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
|
|
|
- List<MouldOperationDynamics> mouldOperationDynamics = new ArrayList<>();
|
|
|
- for (MouldHistoryTime mouldHistoryTime : mouldHistoryTimeList) {
|
|
|
- List<String> rowList = new ArrayList<String>();
|
|
|
- //设备编号
|
|
|
- rowList.add(mouldHistoryTime.getEquipmentNo());
|
|
|
- //开合次数
|
|
|
- rowList.add(mouldHistoryTime.getSeq()+"");
|
|
|
- //合模时间
|
|
|
- rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(mouldHistoryTime.getCloseTime()));
|
|
|
- //开模时间
|
|
|
- rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(mouldHistoryTime.getOpenTime()));
|
|
|
-// rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(dynamic.getIndate())
|
|
|
- //开模周期
|
|
|
- rowList.add(mouldHistoryTime.getTimeCost()+"");
|
|
|
- list.add(rowList);
|
|
|
- }
|
|
|
- String fileUrl = ExcelUtil.exportGeneralExcelByTitleAndList(response, equipmentNo + "-开合数据" + dateSdf2.format(new Date()), list, downloadPath);
|
|
|
- msg.data = fileUrl;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return msg;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo, String time) {
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
- Map<String, Object> listMap = new HashMap<>();
|
|
|
- MouldEquipment mouldEquipment = mouldEquipmentMapper.selectOne(new QueryWrapper<MouldEquipment>().eq("equipment_no", equipmentNo));
|
|
|
- Mould mould = mouldMapper.selectOne(new QueryWrapper<Mould>().eq("equipment_id", mouldEquipment.getId()));
|
|
|
- InjectionMolding molding = injectionMoldingMapper.selectOne(new QueryWrapper<InjectionMolding>().eq("mould_id", mould.getId()));
|
|
|
- Integer cycle = 0;
|
|
|
- if (molding != null) {
|
|
|
- cycle = (null == molding.getCycle()) ? 40000 : Integer.parseInt(molding.getCycle());
|
|
|
- } else {
|
|
|
- cycle = 40000;
|
|
|
- }
|
|
|
- //筛选10s-200s
|
|
|
- Integer maxCycle = 10000*200;
|
|
|
- Integer minCycle = 10000;
|
|
|
- Map<String, MouldHistoryTimeVO> map = TimeAndCountUtil.getMap();
|
|
|
- List<MouldHistoryVO> list = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(time, equipmentNo, maxCycle, minCycle);
|
|
|
- Integer count = 0;
|
|
|
- Map<String, List<MouldHistoryVO>> mapList = list.stream().collect(Collectors.groupingBy(MouldHistoryVO::getTime));
|
|
|
- for (Map.Entry<String, List<MouldHistoryVO>> entry : mapList.entrySet()) {
|
|
|
- MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
|
|
|
- vo.setMinCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
|
|
|
- vo.setMaxCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt());
|
|
|
- vo.setAvgCycle((int) entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
|
|
|
- vo.setTheoryCycle(cycle);
|
|
|
- if ("00".equals(entry.getKey())) {
|
|
|
- map.put("00:00-01:00", vo);
|
|
|
- } else if ("01".equals(entry.getKey())) {
|
|
|
- map.put("01:00-02:00", vo);
|
|
|
- } else if ("02".equals(entry.getKey())) {
|
|
|
- map.put("02:00-03:00", vo);
|
|
|
- } else if ("03".equals(entry.getKey())) {
|
|
|
- map.put("03:00-04:00", vo);
|
|
|
- } else if ("04".equals(entry.getKey())) {
|
|
|
- map.put("04:00-05:00", vo);
|
|
|
- } else if ("05".equals(entry.getKey())) {
|
|
|
- map.put("05:00-06:00", vo);
|
|
|
- } else if ("06".equals(entry.getKey())) {
|
|
|
- map.put("06:00-07:00", vo);
|
|
|
- } else if ("07".equals(entry.getKey())) {
|
|
|
- map.put("07:00-08:00", vo);
|
|
|
- } else if ("08".equals(entry.getKey())) {
|
|
|
- map.put("08:00-09:00", vo);
|
|
|
- } else if ("09".equals(entry.getKey())) {
|
|
|
- map.put("09:00-10:00", vo);
|
|
|
- } else if ("10".equals(entry.getKey())) {
|
|
|
- map.put("10:00-11:00", vo);
|
|
|
- } else if ("11".equals(entry.getKey())) {
|
|
|
- map.put("11:00-12:00", vo);
|
|
|
- } else if ("12".equals(entry.getKey())) {
|
|
|
- map.put("12:00-13:00", vo);
|
|
|
- } else if ("13".equals(entry.getKey())) {
|
|
|
- map.put("13:00-14:00", vo);
|
|
|
- } else if ("14".equals(entry.getKey())) {
|
|
|
- map.put("14:00-15:00", vo);
|
|
|
- } else if ("15".equals(entry.getKey())) {
|
|
|
- map.put("15:00-16:00", vo);
|
|
|
- } else if ("16".equals(entry.getKey())) {
|
|
|
- map.put("16:00-17:00", vo);
|
|
|
- } else if ("17".equals(entry.getKey())) {
|
|
|
- map.put("17:00-18:00", vo);
|
|
|
- } else if ("18".equals(entry.getKey())) {
|
|
|
- map.put("18:00-19:00", vo);
|
|
|
- } else if ("19".equals(entry.getKey())) {
|
|
|
- map.put("19:00-20:00", vo);
|
|
|
- } else if ("20".equals(entry.getKey())) {
|
|
|
- map.put("20:00-21:00", vo);
|
|
|
- } else if ("21".equals(entry.getKey())) {
|
|
|
- map.put("21:00-22:00", vo);
|
|
|
- } else if ("22".equals(entry.getKey())) {
|
|
|
- map.put("22:00-23:00", vo);
|
|
|
- } else if ("23".equals(entry.getKey())) {
|
|
|
- map.put("23:00-24:00", vo);
|
|
|
- }
|
|
|
- }
|
|
|
- System.out.println("原来的map===>" + map);
|
|
|
- Map<String, MouldHistoryTimeVO> result = map.entrySet().stream()
|
|
|
- .sorted(Map.Entry.comparingByKey())
|
|
|
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
- (oleValue, newValue) -> oleValue, LinkedHashMap::new));
|
|
|
- System.out.println("排序后的map===>" + result);
|
|
|
- listMap.put("cycle", result);
|
|
|
- //模具运行次数
|
|
|
- List<MouldCycleRuntime> cycleRuntime = mouldCycleRuntimeMapper.selectList(new QueryWrapper<MouldCycleRuntime>().eq("equipment_no", equipmentNo).eq("date_str", time));
|
|
|
- cycleRuntime = cycleRuntime.stream().sorted(Comparator.comparing(MouldCycleRuntime::getTimeSlot)).collect(Collectors.toList());
|
|
|
- Map<String, MouldCycleRuntime> set = TimeAndCountUtil.getSet();
|
|
|
- Map<String, List<MouldCycleRuntime>> collect = cycleRuntime.stream().collect(Collectors.groupingBy(MouldCycleRuntime::getTimeSlot));
|
|
|
- for (Map.Entry<String, List<MouldCycleRuntime>> entry : collect.entrySet()) {
|
|
|
- MouldCycleRuntime vo = new MouldCycleRuntime();
|
|
|
- if(entry.getValue().size()>0){
|
|
|
- vo.setDateStr(entry.getValue().get(0).getDateStr());
|
|
|
- vo.setEquipmentNo(entry.getValue().get(0).getEquipmentNo());
|
|
|
- vo.setRuntime(entry.getValue().get(0).getRuntime());
|
|
|
- vo.setTimeSlot(entry.getValue().get(0).getTimeSlot());
|
|
|
- set.put(entry.getKey(),vo);
|
|
|
- }
|
|
|
- }
|
|
|
- Map<String, MouldCycleRuntime> runtimeResult = new LinkedHashMap<>();
|
|
|
- //给map排序
|
|
|
- set.entrySet().stream().sorted(Map.Entry.<String, MouldCycleRuntime>comparingByKey().reversed())
|
|
|
- .forEachOrdered(e -> runtimeResult.put(e.getKey(), e.getValue()));
|
|
|
- listMap.put("runtime", runtimeResult);
|
|
|
- msg.data = listMap;
|
|
|
- return msg;
|
|
|
- }
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- List<Integer> primes = Arrays.asList(1, 2, 5, 6, 7, 3, 4, 8, 9, 10);
|
|
|
- primes = primes.stream().sorted(Comparator.comparing(x -> x)).collect(Collectors.toList());
|
|
|
- System.out.println(primes);
|
|
|
- }
|
|
|
-}
|
|
|
+package com.hssx.cloudmodel.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.hssx.cloudmodel.entity.*;
|
|
|
+import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
|
|
|
+import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
|
|
|
+import com.hssx.cloudmodel.mapper.*;
|
|
|
+import com.hssx.cloudmodel.service.MouldHistoryService;
|
|
|
+import com.hssx.cloudmodel.util.ExcelUtil;
|
|
|
+import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
|
+import com.hssx.cloudmodel.util.TimeAndCountUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author 吴涛涛
|
|
|
+ * @since 2019-10-11
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, MouldHistory> implements MouldHistoryService {
|
|
|
+ @Resource
|
|
|
+ private MouldHistoryMapper mouldHistoryMapper;
|
|
|
+ @Resource
|
|
|
+ private MouldHistoryTimeMapper mouldHistoryTimeMapper;
|
|
|
+ @Resource
|
|
|
+ private MouldCycleRuntimeMapper mouldCycleRuntimeMapper;
|
|
|
+ @Resource
|
|
|
+ private MouldMapper mouldMapper;
|
|
|
+ @Resource
|
|
|
+ private MouldEquipmentMapper mouldEquipmentMapper;
|
|
|
+ @Resource
|
|
|
+ private InjectionMoldingMapper injectionMoldingMapper;
|
|
|
+ @Value("${upload.path}")
|
|
|
+ private String downloadPath;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getOpeningAndClosingTimesChart(HttpServletResponse response, String equipmentNo, String startTime, String endTime, Integer type) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ if (type != null) {
|
|
|
+ if (type == 0) {
|
|
|
+ List<MouldCycleRuntime> cycleRuntimeList = mouldCycleRuntimeMapper.selectList(new QueryWrapper<MouldCycleRuntime>()
|
|
|
+ .eq("equipment_no", equipmentNo).between("date_str", startTime, endTime));
|
|
|
+ //给集合排序先按照日期,如果一样再按照时间段
|
|
|
+ cycleRuntimeList = cycleRuntimeList.stream().sorted(Comparator.comparing(MouldCycleRuntime::getDateStr).thenComparing(MouldCycleRuntime::getTimeSlot)).collect(Collectors.toList());
|
|
|
+ //数据已经查到,开始导出excel
|
|
|
+ List<List<String>> list = new ArrayList<List<String>>();
|
|
|
+ //标题
|
|
|
+ List<String> titleList = new ArrayList<String>();
|
|
|
+ titleList.add("设备编号");
|
|
|
+ titleList.add("日期");
|
|
|
+ titleList.add("时间段");
|
|
|
+ titleList.add("运行次数");
|
|
|
+ list.add(titleList);
|
|
|
+ SimpleDateFormat dateSdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
|
|
|
+ List<MouldOperationDynamics> mouldOperationDynamics = new ArrayList<>();
|
|
|
+ for (MouldCycleRuntime cycleRuntime : cycleRuntimeList) {
|
|
|
+ List<String> rowList = new ArrayList<String>();
|
|
|
+ //设备编号
|
|
|
+ rowList.add(cycleRuntime.getEquipmentNo());
|
|
|
+ //日期
|
|
|
+ rowList.add(cycleRuntime.getDateStr());
|
|
|
+ //时间段
|
|
|
+ rowList.add(cycleRuntime.getTimeSlot());
|
|
|
+ //运行次数
|
|
|
+ rowList.add(cycleRuntime.getRuntime() + "");
|
|
|
+// rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(dynamic.getIndate())
|
|
|
+ list.add(rowList);
|
|
|
+ }
|
|
|
+ String fileUrl = ExcelUtil.exportGeneralExcelByTitleAndList(response, equipmentNo + "-周期运行次数" + dateSdf2.format(new Date()), list, downloadPath);
|
|
|
+ msg.data = fileUrl;
|
|
|
+ }else if(type == 1){
|
|
|
+ List<MouldHistoryTime> mouldHistoryTimeList = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycleExcel(startTime, endTime, equipmentNo);
|
|
|
+ //数据已经查到,开始导出excel
|
|
|
+ List<List<String>> list = new ArrayList<List<String>>();
|
|
|
+ //标题
|
|
|
+ List<String> titleList = new ArrayList<String>();
|
|
|
+ titleList.add("设备编号");
|
|
|
+ titleList.add("开合次数");
|
|
|
+ titleList.add("合模时间");
|
|
|
+ titleList.add("开模时间");
|
|
|
+ titleList.add("开模周期");
|
|
|
+ list.add(titleList);
|
|
|
+ SimpleDateFormat dateSdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
|
|
|
+ List<MouldOperationDynamics> mouldOperationDynamics = new ArrayList<>();
|
|
|
+ for (MouldHistoryTime mouldHistoryTime : mouldHistoryTimeList) {
|
|
|
+ List<String> rowList = new ArrayList<String>();
|
|
|
+ //设备编号
|
|
|
+ rowList.add(mouldHistoryTime.getEquipmentNo());
|
|
|
+ //开合次数
|
|
|
+ rowList.add(mouldHistoryTime.getSeq()+"");
|
|
|
+ //合模时间
|
|
|
+ rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(mouldHistoryTime.getCloseTime()));
|
|
|
+ //开模时间
|
|
|
+ rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(mouldHistoryTime.getOpenTime()));
|
|
|
+// rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(dynamic.getIndate())
|
|
|
+ //开模周期
|
|
|
+ rowList.add(mouldHistoryTime.getTimeCost()+"");
|
|
|
+ list.add(rowList);
|
|
|
+ }
|
|
|
+ String fileUrl = ExcelUtil.exportGeneralExcelByTitleAndList(response, equipmentNo + "-开合数据" + dateSdf2.format(new Date()), list, downloadPath);
|
|
|
+ msg.data = fileUrl;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo, String time) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ Map<String, Object> listMap = new HashMap<>();
|
|
|
+ MouldEquipment mouldEquipment = mouldEquipmentMapper.selectOne(new QueryWrapper<MouldEquipment>().eq("equipment_no", equipmentNo));
|
|
|
+ Mould mould = mouldMapper.selectOne(new QueryWrapper<Mould>().eq("equipment_id", mouldEquipment.getId()));
|
|
|
+ InjectionMolding molding = injectionMoldingMapper.selectOne(new QueryWrapper<InjectionMolding>().eq("mould_id", mould.getId()));
|
|
|
+ Integer cycle = 0;
|
|
|
+ if (molding != null) {
|
|
|
+ cycle = (null == molding.getCycle()) ? 40000 : Integer.parseInt(molding.getCycle());
|
|
|
+ } else {
|
|
|
+ cycle = 40000;
|
|
|
+ }
|
|
|
+ //筛选10s-200s
|
|
|
+ Integer maxCycle = 10000*15;
|
|
|
+ Integer minCycle = 10000;
|
|
|
+ Map<String, MouldHistoryTimeVO> map = TimeAndCountUtil.getMap();
|
|
|
+ List<MouldHistoryVO> list = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(time, equipmentNo, maxCycle, minCycle);
|
|
|
+ Integer count = 0;
|
|
|
+ Map<String, List<MouldHistoryVO>> mapList = list.stream().collect(Collectors.groupingBy(MouldHistoryVO::getTime));
|
|
|
+ for (Map.Entry<String, List<MouldHistoryVO>> entry : mapList.entrySet()) {
|
|
|
+ MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
|
|
|
+ vo.setMinCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
|
|
|
+ vo.setMaxCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt());
|
|
|
+ vo.setAvgCycle((int) entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
|
|
|
+ vo.setTheoryCycle(cycle);
|
|
|
+ if ("00".equals(entry.getKey())) {
|
|
|
+ map.put("00:00-01:00", vo);
|
|
|
+ } else if ("01".equals(entry.getKey())) {
|
|
|
+ map.put("01:00-02:00", vo);
|
|
|
+ } else if ("02".equals(entry.getKey())) {
|
|
|
+ map.put("02:00-03:00", vo);
|
|
|
+ } else if ("03".equals(entry.getKey())) {
|
|
|
+ map.put("03:00-04:00", vo);
|
|
|
+ } else if ("04".equals(entry.getKey())) {
|
|
|
+ map.put("04:00-05:00", vo);
|
|
|
+ } else if ("05".equals(entry.getKey())) {
|
|
|
+ map.put("05:00-06:00", vo);
|
|
|
+ } else if ("06".equals(entry.getKey())) {
|
|
|
+ map.put("06:00-07:00", vo);
|
|
|
+ } else if ("07".equals(entry.getKey())) {
|
|
|
+ map.put("07:00-08:00", vo);
|
|
|
+ } else if ("08".equals(entry.getKey())) {
|
|
|
+ map.put("08:00-09:00", vo);
|
|
|
+ } else if ("09".equals(entry.getKey())) {
|
|
|
+ map.put("09:00-10:00", vo);
|
|
|
+ } else if ("10".equals(entry.getKey())) {
|
|
|
+ map.put("10:00-11:00", vo);
|
|
|
+ } else if ("11".equals(entry.getKey())) {
|
|
|
+ map.put("11:00-12:00", vo);
|
|
|
+ } else if ("12".equals(entry.getKey())) {
|
|
|
+ map.put("12:00-13:00", vo);
|
|
|
+ } else if ("13".equals(entry.getKey())) {
|
|
|
+ map.put("13:00-14:00", vo);
|
|
|
+ } else if ("14".equals(entry.getKey())) {
|
|
|
+ map.put("14:00-15:00", vo);
|
|
|
+ } else if ("15".equals(entry.getKey())) {
|
|
|
+ map.put("15:00-16:00", vo);
|
|
|
+ } else if ("16".equals(entry.getKey())) {
|
|
|
+ map.put("16:00-17:00", vo);
|
|
|
+ } else if ("17".equals(entry.getKey())) {
|
|
|
+ map.put("17:00-18:00", vo);
|
|
|
+ } else if ("18".equals(entry.getKey())) {
|
|
|
+ map.put("18:00-19:00", vo);
|
|
|
+ } else if ("19".equals(entry.getKey())) {
|
|
|
+ map.put("19:00-20:00", vo);
|
|
|
+ } else if ("20".equals(entry.getKey())) {
|
|
|
+ map.put("20:00-21:00", vo);
|
|
|
+ } else if ("21".equals(entry.getKey())) {
|
|
|
+ map.put("21:00-22:00", vo);
|
|
|
+ } else if ("22".equals(entry.getKey())) {
|
|
|
+ map.put("22:00-23:00", vo);
|
|
|
+ } else if ("23".equals(entry.getKey())) {
|
|
|
+ map.put("23:00-24:00", vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("原来的map===>" + map);
|
|
|
+ Map<String, MouldHistoryTimeVO> result = map.entrySet().stream()
|
|
|
+ .sorted(Map.Entry.comparingByKey())
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oleValue, newValue) -> oleValue, LinkedHashMap::new));
|
|
|
+ System.out.println("排序后的map===>" + result);
|
|
|
+ listMap.put("cycle", result);
|
|
|
+ //模具运行次数
|
|
|
+ List<MouldCycleRuntime> cycleRuntime = mouldCycleRuntimeMapper.selectList(new QueryWrapper<MouldCycleRuntime>().eq("equipment_no", equipmentNo).eq("date_str", time));
|
|
|
+ cycleRuntime = cycleRuntime.stream().sorted(Comparator.comparing(MouldCycleRuntime::getTimeSlot)).collect(Collectors.toList());
|
|
|
+ Map<String, MouldCycleRuntime> set = TimeAndCountUtil.getSet();
|
|
|
+ Map<String, List<MouldCycleRuntime>> collect = cycleRuntime.stream().collect(Collectors.groupingBy(MouldCycleRuntime::getTimeSlot));
|
|
|
+ for (Map.Entry<String, List<MouldCycleRuntime>> entry : collect.entrySet()) {
|
|
|
+ MouldCycleRuntime vo = new MouldCycleRuntime();
|
|
|
+ if(entry.getValue().size()>0){
|
|
|
+ vo.setDateStr(entry.getValue().get(0).getDateStr());
|
|
|
+ vo.setEquipmentNo(entry.getValue().get(0).getEquipmentNo());
|
|
|
+ vo.setRuntime(entry.getValue().get(0).getRuntime());
|
|
|
+ vo.setTimeSlot(entry.getValue().get(0).getTimeSlot());
|
|
|
+ set.put(entry.getKey(),vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, MouldCycleRuntime> runtimeResult = new LinkedHashMap<>();
|
|
|
+ //给map排序
|
|
|
+ set.entrySet().stream().sorted(Map.Entry.<String, MouldCycleRuntime>comparingByKey().reversed())
|
|
|
+ .forEachOrdered(e -> runtimeResult.put(e.getKey(), e.getValue()));
|
|
|
+ listMap.put("runtime", runtimeResult);
|
|
|
+ msg.data = listMap;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ List<Integer> primes = Arrays.asList(1, 2, 5, 6, 7, 3, 4, 8, 9, 10);
|
|
|
+ primes = primes.stream().sorted(Comparator.comparing(x -> x)).collect(Collectors.toList());
|
|
|
+ System.out.println(primes);
|
|
|
+ }
|
|
|
+}
|