Quellcode durchsuchen

Merge branch 'master' of http://47.100.37.243:10080/ZHOU/yunsu

# Conflicts:
#	target/classes/main/resources/mapper/MouldEquipmentMapper.xml
#	target/classes/main/resources/mapper/MouldMapper.xml
vor 5 Jahren
Ursprung
Commit
ad6fbb37cc

+ 62 - 13
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldHistoryServiceImpl.java

@@ -9,6 +9,7 @@ import com.hssx.cloudmodel.mapper.MouldHistoryTimeMapper;
 import com.hssx.cloudmodel.service.MouldHistoryService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.TimeAndCountUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -32,21 +33,69 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
     @Override
     public HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time) {
         HttpRespMsg msg = new HttpRespMsg();
-        Map <String,Integer> map = new HashMap<>();
-        map.put("00:00-01:00",0);
-        map.put("01:00-02:00",0);
-        map.put("02:00-03:00",0);
-        map.put("03:00-04:00",0);
-        map.put("0:00-01:00",0);
-        map.put("00:00-01:00",0);
-        map.put("00:00-01:00",0);
        List<MouldHistoryVO> list =  mouldHistoryMapper.selectOpeningAndClosingTimesChart(equipmentNo,time);
-        list.stream().forEach(x ->{
-            if(Integer.parseInt(x.getTime()) <= 2){
-
+        Set<MouldHistoryVO> set = TimeAndCountUtil.getSet();
+        Map<String, Integer> map = TimeAndCountUtil.getMap();
+        Integer count = 0;
+        Map<String, List<MouldHistoryVO>> mapList = list.stream().collect(Collectors.groupingBy(MouldHistoryVO::getTime));
+        for(Map.Entry<String, List<MouldHistoryVO>> entry:mapList.entrySet()){
+            if("00".equals(entry.getKey())){
+                map.put("00:00-01:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("01".equals(entry.getKey())){
+                map.put("01:00-02:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("02".equals(entry.getKey())){
+                map.put("02:00-03:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("03".equals(entry.getKey())){
+                map.put("03:00-04:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("04".equals(entry.getKey())){
+                map.put("04:00-05:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("05".equals(entry.getKey())){
+                map.put("05:00-06:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("06".equals(entry.getKey())){
+                map.put("06:00-07:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("07".equals(entry.getKey())){
+                map.put("07:00-08:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("08".equals(entry.getKey())){
+                map.put("08:00-09:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("09".equals(entry.getKey())){
+                map.put("09:00-10:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("10".equals(entry.getKey())){
+                map.put("10:00-11:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("11".equals(entry.getKey())){
+                map.put("11:00-12:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("12".equals(entry.getKey())){
+                map.put("12:00-13:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("13".equals(entry.getKey())){
+                map.put("13:00-14:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("14".equals(entry.getKey())){
+                map.put("14:00-15:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("15".equals(entry.getKey())){
+                map.put("15:00-16:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("16".equals(entry.getKey())){
+                map.put("16:00-17:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("17".equals(entry.getKey())){
+                map.put("17:00-18:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("18".equals(entry.getKey())){
+                map.put("18:00-19:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("19".equals(entry.getKey())){
+                map.put("19:00-20:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("20".equals(entry.getKey())){
+                map.put("20:00-21:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("21".equals(entry.getKey())){
+                map.put("21:00-22:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("22".equals(entry.getKey())){
+                map.put("22:00-23:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
+            }else if("23".equals(entry.getKey())){
+                map.put("23:00-24:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
             }
-        });
-        msg.data=list;
+        }
+        System.out.println("原来的map===>"+map);
+        Map<String, Integer> 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);
+        msg.data=result;
         return msg;
     }
 

+ 25 - 5
cloud-model/src/main/java/com/hssx/cloudmodel/util/TimeAndCountUtil.java

@@ -1,9 +1,10 @@
 package com.hssx.cloudmodel.util;
-
-import com.hssx.cloudmodel.entity.MouldHistory;
 import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
 
+import java.sql.SQLOutput;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -13,13 +14,32 @@ import java.util.Set;
  * Version: 1.0
  */
 public class TimeAndCountUtil {
-    Set<MouldHistoryVO> set = new HashSet<>();
-    {
+    public static Set<MouldHistoryVO> getSet(){
+        Set<MouldHistoryVO> set = new HashSet<>();
         for(int i=0 ;i<=23 ;i++){
             MouldHistoryVO vo = new MouldHistoryVO();
             String iStr = i<10 ? ("0"+i):i+"";
-            String iStrAfterOne = (i+1)<10 ? ("0"+i):i+"";
+            int i1 = i+1;
+            String iStrAfterOne = (i1)<10 ? ("0"+i1):i1+"";
             vo.setTime(iStr+":00-"+iStrAfterOne+":00");
+            vo.setRunCnt(0);
+            set.add(vo);
+        }
+        return set;
+    }
+    public static Map<String,Integer> getMap(){
+        Map<String,Integer> map = new HashMap<>();
+        for(int i=0 ;i<=23 ;i++){
+            MouldHistoryVO vo = new MouldHistoryVO();
+            String iStr = i<10 ? ("0"+i):i+"";
+            int i1 = i+1;
+            String iStrAfterOne = (i1)<10 ? ("0"+i1):i1+"";
+            map.put(iStr+":00-"+iStrAfterOne+":00",0);
         }
+        return map;
+    }
+
+    public static void main(String[] args) {
+        System.out.println(TimeAndCountUtil.getMap());
     }
 }