Bladeren bron

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

# Conflicts:
#	website/src/main/resources/templates/index.html
5 jaren geleden
bovenliggende
commit
cd022912a2

+ 1 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/vo/MouldHistoryVO.java

@@ -12,4 +12,5 @@ import lombok.Data;
 @Data
 public class MouldHistoryVO extends MouldHistory {
     private String time;
+    private Integer cycle;
 }

+ 3 - 2
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/MouldHistoryTimeMapper.java

@@ -3,6 +3,7 @@ package com.hssx.cloudmodel.mapper;
 import com.hssx.cloudmodel.entity.MouldHistoryTime;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
+import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -16,6 +17,6 @@ import java.util.List;
  * @since 2019-10-12
  */
 public interface MouldHistoryTimeMapper extends BaseMapper<MouldHistoryTime> {
-    List<MouldHistoryTimeVO> getOpeningAndClosingTimesChartCycle(@Param("startTime") String startTime
-    ,@Param("endTime")String endTime,@Param("equipmentNo")String equipmentNo);
+
+    List<MouldHistoryVO> getOpeningAndClosingTimesChartCycle(@Param("time")String time,@Param("equipmentNo")String equipmentNo);
 }

+ 64 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldHistoryServiceImpl.java

@@ -41,7 +41,7 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
         List<MouldCycleRuntime> list = mouldCycleRuntimeMapper.selectList(new QueryWrapper<MouldCycleRuntime>().eq("equipment_no", equipmentNo).eq("date_str",time));
 //        List<MouldHistoryVO> list =  mouldHistoryMapper.selectOpeningAndClosingTimesChart(equipmentNo,time);
 //        Set<MouldHistoryVO> set = TimeAndCountUtil.getSet();
-//        Map<String, Integer> map = TimeAndCountUtil.getMap();
+        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()){
@@ -132,6 +132,68 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
     @Override
     public HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo,String time) {
         HttpRespMsg msg = new HttpRespMsg();
+        Map<String, Integer> map = TimeAndCountUtil.getMap();
+        List<MouldHistoryVO> list = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(equipmentNo,time);
+        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",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble()
+                                );
+            }else if("01".equals(entry.getKey())){
+                map.put("01:00-02:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("02".equals(entry.getKey())){
+                map.put("02:00-03:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("03".equals(entry.getKey())){
+                map.put("03:00-04:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("04".equals(entry.getKey())){
+                map.put("04:00-05:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("05".equals(entry.getKey())){
+                map.put("05:00-06:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("06".equals(entry.getKey())){
+                map.put("06:00-07:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("07".equals(entry.getKey())){
+                map.put("07:00-08:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("08".equals(entry.getKey())){
+                map.put("08:00-09:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("09".equals(entry.getKey())){
+                map.put("09:00-10:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("10".equals(entry.getKey())){
+                map.put("10:00-11:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("11".equals(entry.getKey())){
+                map.put("11:00-12:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("12".equals(entry.getKey())){
+                map.put("12:00-13:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("13".equals(entry.getKey())){
+                map.put("13:00-14:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("14".equals(entry.getKey())){
+                map.put("14:00-15:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("15".equals(entry.getKey())){
+                map.put("15:00-16:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("16".equals(entry.getKey())){
+                map.put("16:00-17:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("17".equals(entry.getKey())){
+                map.put("17:00-18:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("18".equals(entry.getKey())){
+                map.put("18:00-19:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("19".equals(entry.getKey())){
+                map.put("19:00-20:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("20".equals(entry.getKey())){
+                map.put("20:00-21:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("21".equals(entry.getKey())){
+                map.put("21:00-22:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("22".equals(entry.getKey())){
+                map.put("22:00-23:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }else if("23".equals(entry.getKey())){
+                map.put("23:00-24:00",(int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            }
+        }
+        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);
 //        mouldHistoryTimeVO.setStartTime(mouldHistoryTimeVO.getStartTime()+" 00:00:00");
 //        mouldHistoryTimeVO.setEndTime(mouldHistoryTimeVO.getEndTime()+" 23:59:59");
 //        List<MouldHistoryTimeVO> list  = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(mouldHistoryTimeVO.getStartTime(),mouldHistoryTimeVO.getEndTime(),mouldHistoryTimeVO.getEquipmentNo());
@@ -151,6 +213,7 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
 //        resultList = resultList.stream().sorted(Comparator.comparing(MouldHistoryTimeVO::getTime)).collect(Collectors.toList());
 //        System.out.println("排序后的resultList===>"+resultList);
 //        msg.data = resultList;
+        msg.data = result;
         return msg;
     }
 

+ 1 - 1
cloud-model/src/main/resources/application.properties

@@ -13,7 +13,7 @@ spring.thymeleaf.jackson.date-format=yyyy-MM-dd HH:mm:ss
 # ####################################################################################################
 # Êý¾ÝÔ´ÅäÖÃ
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.url=jdbc:mysql://118.190.47.230:3306/new_cloud_model?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+spring.datasource.url=jdbc:mysql://118.190.47.230:3306/cloud_model_test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 spring.datasource.username=root
 spring.datasource.password=p011430seya1026
 #spring.datasource.druid.test-on-borrow=true

+ 7 - 13
cloud-model/src/main/resources/mapper/MouldHistoryTimeMapper.xml

@@ -11,13 +11,8 @@
         <result column="time_cost" property="timeCost"/>
         <result column="equipment_no" property="equipmentNo"/>
     </resultMap>
-    <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO">
-        <result column="history_id" property="historyId"/>
-        <result column="seq" property="seq"/>
-        <result column="close_time" property="closeTime"/>
-        <result column="open_time" property="openTime"/>
-        <result column="time_cost" property="timeCost"/>
-        <result column="equipment_no" property="equipmentNo"/>
+    <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.MouldHistoryVO">
+        <result column="run_cnt" property="runCnt"/>
         <result column="time" property="time"/>
     </resultMap>
 
@@ -27,17 +22,16 @@
     </sql>
     <select id="getOpeningAndClosingTimesChartCycle" resultMap="BaseResultMapVO">
         select
-        DATE_FORMAT(open_time,'%Y-%m-%d') time ,time_cost
+        DATE_FORMAT(open_time,'%H') time ,time_cost run_cnt
         from
         `mould_history_time`
         <where>
             equipment_no = #{equipmentNo}
-            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
-                and DATE_FORMAT(open_time,'%Y-%m-%d %H:%i:%s')
-                between concat(#{startTime},' 00:00:00') and
-                concat(#{endTime},' 23:59:59')
+            <if test="time != null and time != ''">
+               AND DATE_FORMAT(open_time,'%Y-%m-%d') = #{time}
             </if>
-            and time_cost &gt; 0
+            and BETWEEN 30000 AND 50000
         </where>
+        ORDER BY open_time
     </select>
 </mapper>