Просмотр исходного кода

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

# Conflicts:
#	website/src/main/resources/templates/index.html
5 лет назад
Родитель
Сommit
7dce801869

+ 21 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldCycleRuntimeController.java

@@ -0,0 +1,21 @@
+package com.hssx.cloudmodel.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-28
+ */
+@RestController
+@RequestMapping("/mould-cycle-runtime")
+public class MouldCycleRuntimeController {
+
+}
+

+ 3 - 5
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldHistoryController.java

@@ -44,17 +44,15 @@ public class MouldHistoryController {
 
     /**
      * 获取云模盒的每日开合次数周期 (时间/周期)
-     * @param mouldHistoryTimeVO
-     *  参数:startTime 开始时间 2019-01-02
-     *        endTime 截止时间 2019-01-03
+     *  参数:time 时间点 如:2019-02-15
      *        equipmentNo 设备编号
      * @return
      */
     @ApiOperation("获取云模盒的每日开合次数周期 (时间/周期)")
     @RequestMapping("/openingAndClosingTimesChartCycle")
     @ResponseBody
-    public HttpRespMsg openingAndClosingTimesChartCycle(MouldHistoryTimeVO mouldHistoryTimeVO){
-        HttpRespMsg msg = mouldHistoryService.openingAndClosingTimesChartCycle(mouldHistoryTimeVO);
+    public HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo,String time){
+        HttpRespMsg msg = mouldHistoryService.openingAndClosingTimesChartCycle(equipmentNo, time);
         return msg;
     }
 

+ 107 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/MouldCycleRuntime.java

@@ -0,0 +1,107 @@
+package com.hssx.cloudmodel.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-28
+ */
+public class MouldCycleRuntime extends Model<MouldCycleRuntime> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 周期运行次数表主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 运行次数
+     */
+    @TableField("runtime")
+    private Integer runtime;
+
+    /**
+     * 时间段如00:00-01:00
+     */
+    @TableField("time_slot")
+    private String timeSlot;
+
+    /**
+     * 日期字符串(开合)
+     */
+    @TableField("date_str")
+    private String dateStr;
+
+    /**
+     * 云模盒编号ccid
+     */
+    @TableField("equipment_no")
+    private String equipmentNo;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getRuntime() {
+        return runtime;
+    }
+
+    public void setRuntime(Integer runtime) {
+        this.runtime = runtime;
+    }
+
+    public String getTimeSlot() {
+        return timeSlot;
+    }
+
+    public void setTimeSlot(String timeSlot) {
+        this.timeSlot = timeSlot;
+    }
+
+    public String getDateStr() {
+        return dateStr;
+    }
+
+    public void setDateStr(String dateStr) {
+        this.dateStr = dateStr;
+    }
+
+    public String getEquipmentNo() {
+        return equipmentNo;
+    }
+
+    public void setEquipmentNo(String equipmentNo) {
+        this.equipmentNo = equipmentNo;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+    @Override
+    public String toString() {
+        return "MouldCycleRuntime{" +
+        "id=" + id +
+        ", runtime=" + runtime +
+        ", timeSlot=" + timeSlot +
+        ", dateStr=" + dateStr +
+        ", equipmentNo=" + equipmentNo +
+        "}";
+    }
+}

+ 16 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/MouldCycleRuntimeMapper.java

@@ -0,0 +1,16 @@
+package com.hssx.cloudmodel.mapper;
+
+import com.hssx.cloudmodel.entity.MouldCycleRuntime;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-28
+ */
+public interface MouldCycleRuntimeMapper extends BaseMapper<MouldCycleRuntime> {
+
+}

+ 16 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/MouldCycleRuntimeService.java

@@ -0,0 +1,16 @@
+package com.hssx.cloudmodel.service;
+
+import com.hssx.cloudmodel.entity.MouldCycleRuntime;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-28
+ */
+public interface MouldCycleRuntimeService extends IService<MouldCycleRuntime> {
+
+}

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/MouldHistoryService.java

@@ -17,5 +17,5 @@ public interface MouldHistoryService extends IService<MouldHistory> {
 
     HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time);
 
-    HttpRespMsg openingAndClosingTimesChartCycle(MouldHistoryTimeVO mouldHistoryTimeVO);
+    HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo,String time);
 }

+ 20 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldCycleRuntimeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.hssx.cloudmodel.service.impl;
+
+import com.hssx.cloudmodel.entity.MouldCycleRuntime;
+import com.hssx.cloudmodel.mapper.MouldCycleRuntimeMapper;
+import com.hssx.cloudmodel.service.MouldCycleRuntimeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-28
+ */
+@Service
+public class MouldCycleRuntimeServiceImpl extends ServiceImpl<MouldCycleRuntimeMapper, MouldCycleRuntime> implements MouldCycleRuntimeService {
+
+}

+ 111 - 109
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldHistoryServiceImpl.java

@@ -1,9 +1,12 @@
 package com.hssx.cloudmodel.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.hssx.cloudmodel.entity.MouldCycleRuntime;
 import com.hssx.cloudmodel.entity.MouldHistory;
 import com.hssx.cloudmodel.entity.MouldHistoryTime;
 import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
 import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
+import com.hssx.cloudmodel.mapper.MouldCycleRuntimeMapper;
 import com.hssx.cloudmodel.mapper.MouldHistoryMapper;
 import com.hssx.cloudmodel.mapper.MouldHistoryTimeMapper;
 import com.hssx.cloudmodel.service.MouldHistoryService;
@@ -30,125 +33,124 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
     private MouldHistoryMapper mouldHistoryMapper;
     @Resource
     private MouldHistoryTimeMapper mouldHistoryTimeMapper;
+    @Resource
+    private MouldCycleRuntimeMapper mouldCycleRuntimeMapper;
     @Override
     public HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time) {
         HttpRespMsg msg = new HttpRespMsg();
-       List<MouldHistoryVO> list =  mouldHistoryMapper.selectOpeningAndClosingTimesChart(equipmentNo,time);
-        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).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("01".equals(entry.getKey())){
-                map.put("01:00-02:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("02".equals(entry.getKey())){
-                map.put("02:00-03:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("03".equals(entry.getKey())){
-                map.put("03:00-04:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("04".equals(entry.getKey())){
-                map.put("04:00-05:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("05".equals(entry.getKey())){
-                map.put("05:00-06:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("06".equals(entry.getKey())){
-                map.put("06:00-07:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("07".equals(entry.getKey())){
-                map.put("07:00-08:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("08".equals(entry.getKey())){
-                map.put("08:00-09:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("09".equals(entry.getKey())){
-                map.put("09:00-10:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("10".equals(entry.getKey())){
-                map.put("10:00-11:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("11".equals(entry.getKey())){
-                map.put("11:00-12:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("12".equals(entry.getKey())){
-                map.put("12:00-13:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("13".equals(entry.getKey())){
-                map.put("13:00-14:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("14".equals(entry.getKey())){
-                map.put("14:00-15:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("15".equals(entry.getKey())){
-                map.put("15:00-16:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("16".equals(entry.getKey())){
-                map.put("16:00-17:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("17".equals(entry.getKey())){
-                map.put("17:00-18:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("18".equals(entry.getKey())){
-                map.put("18:00-19:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("19".equals(entry.getKey())){
-                map.put("19:00-20:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("20".equals(entry.getKey())){
-                map.put("20:00-21:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("21".equals(entry.getKey())){
-                map.put("21:00-22:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("22".equals(entry.getKey())){
-                map.put("22:00-23:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }else if("23".equals(entry.getKey())){
-                map.put("23:00-24:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
-                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
-            }
-        }
-        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;
+        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();
+//        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).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("01".equals(entry.getKey())){
+//                map.put("01:00-02:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("02".equals(entry.getKey())){
+//                map.put("02:00-03:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("03".equals(entry.getKey())){
+//                map.put("03:00-04:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("04".equals(entry.getKey())){
+//                map.put("04:00-05:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("05".equals(entry.getKey())){
+//                map.put("05:00-06:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("06".equals(entry.getKey())){
+//                map.put("06:00-07:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("07".equals(entry.getKey())){
+//                map.put("07:00-08:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("08".equals(entry.getKey())){
+//                map.put("08:00-09:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("09".equals(entry.getKey())){
+//                map.put("09:00-10:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("10".equals(entry.getKey())){
+//                map.put("10:00-11:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("11".equals(entry.getKey())){
+//                map.put("11:00-12:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("12".equals(entry.getKey())){
+//                map.put("12:00-13:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("13".equals(entry.getKey())){
+//                map.put("13:00-14:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("14".equals(entry.getKey())){
+//                map.put("14:00-15:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("15".equals(entry.getKey())){
+//                map.put("15:00-16:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("16".equals(entry.getKey())){
+//                map.put("16:00-17:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("17".equals(entry.getKey())){
+//                map.put("17:00-18:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("18".equals(entry.getKey())){
+//                map.put("18:00-19:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("19".equals(entry.getKey())){
+//                map.put("19:00-20:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("20".equals(entry.getKey())){
+//                map.put("20:00-21:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("21".equals(entry.getKey())){
+//                map.put("21:00-22:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("22".equals(entry.getKey())){
+//                map.put("22:00-23:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }else if("23".equals(entry.getKey())){
+//                map.put("23:00-24:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt()
+//                                - entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
+//            }
+//        }
+//        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=list;
         return msg;
     }
 
     @Override
-    public HttpRespMsg openingAndClosingTimesChartCycle(MouldHistoryTimeVO mouldHistoryTimeVO) {
+    public HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo,String time) {
         HttpRespMsg msg = new HttpRespMsg();
-        mouldHistoryTimeVO.setStartTime(mouldHistoryTimeVO.getStartTime());
 //        mouldHistoryTimeVO.setStartTime(mouldHistoryTimeVO.getStartTime()+" 00:00:00");
-        System.out.println(mouldHistoryTimeVO.getStartTime());
 //        mouldHistoryTimeVO.setEndTime(mouldHistoryTimeVO.getEndTime()+" 23:59:59");
-        mouldHistoryTimeVO.setEndTime(mouldHistoryTimeVO.getEndTime());
-        System.out.println(mouldHistoryTimeVO.getEndTime());
-        List<MouldHistoryTimeVO> list  = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(mouldHistoryTimeVO.getStartTime(),mouldHistoryTimeVO.getEndTime(),mouldHistoryTimeVO.getEquipmentNo());
-        Map<String, List<MouldHistoryTimeVO>> map = list.stream().collect(Collectors.groupingBy(MouldHistoryTimeVO::getTime));
-        List<MouldHistoryTimeVO> resultList = new ArrayList<>();
-        for(Map.Entry<String, List<MouldHistoryTimeVO>> entry : map.entrySet()){
-            String mapKey = entry.getKey();
-            MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
-            vo.setTime(mapKey);
-            List<MouldHistoryTimeVO> mapValue = entry.getValue();
-            vo.setMinCycle(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).min().getAsInt());
-            vo.setMinCycle(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).max().getAsInt());
-            vo.setAvgCycle(0.1*(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).sum()/(mapValue.size()-1)));
-            resultList.add(vo);
-        }
-        System.out.println("原来的resultList===>"+resultList);
-        resultList = resultList.stream().sorted(Comparator.comparing(MouldHistoryTimeVO::getTime)).collect(Collectors.toList());
-        System.out.println("排序后的resultList===>"+resultList);
-        msg.data = resultList;
+//        List<MouldHistoryTimeVO> list  = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(mouldHistoryTimeVO.getStartTime(),mouldHistoryTimeVO.getEndTime(),mouldHistoryTimeVO.getEquipmentNo());
+//        Map<String, List<MouldHistoryTimeVO>> map = list.stream().collect(Collectors.groupingBy(MouldHistoryTimeVO::getTime));
+//        List<MouldHistoryTimeVO> resultList = new ArrayList<>();
+//        for(Map.Entry<String, List<MouldHistoryTimeVO>> entry : map.entrySet()){
+//            String mapKey = entry.getKey();
+//            MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
+//            vo.setTime(mapKey);
+//            List<MouldHistoryTimeVO> mapValue = entry.getValue();
+//            vo.setMinCycle(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).min().getAsInt());
+//            vo.setMinCycle(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).max().getAsInt());
+//            vo.setAvgCycle(0.1*(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).sum()/(mapValue.size()-1)));
+//            resultList.add(vo);
+//        }
+//        System.out.println("原来的resultList===>"+resultList);
+//        resultList = resultList.stream().sorted(Comparator.comparing(MouldHistoryTimeVO::getTime)).collect(Collectors.toList());
+//        System.out.println("排序后的resultList===>"+resultList);
+//        msg.data = resultList;
         return msg;
     }
 

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("mould_down_packet");
+        strategy.setInclude("mould_cycle_runtime");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 19 - 0
cloud-model/src/main/resources/mapper/MouldCycleRuntimeMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hssx.cloudmodel.mapper.MouldCycleRuntimeMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hssx.cloudmodel.entity.MouldCycleRuntime">
+        <id column="id" property="id" />
+        <result column="runtime" property="runtime" />
+        <result column="time_slot" property="timeSlot" />
+        <result column="date_str" property="dateStr" />
+        <result column="equipment_no" property="equipmentNo" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, runtime, time_slot, date_str, equipment_no
+    </sql>
+
+</mapper>

+ 135 - 0
cloud-socket/src/com/js/kbt/controller/FileController.java

@@ -2,8 +2,13 @@ package com.js.kbt.controller;
 
 import java.io.File;
 import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
 import java.util.UUID;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -13,6 +18,21 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
+import com.js.kbt.mapper.MouldCycleRuntimeMapper;
+import com.js.kbt.mapper.MouldDownPacketMapper;
+import com.js.kbt.mapper.MouldHistoryMapper;
+import com.js.kbt.mapper.MouldHistoryTimeMapper;
+import com.js.kbt.mapper.MouldHodingMapper;
+import com.js.kbt.mapper.TbFactoryMapper;
+import com.js.kbt.mapper.TbMouldEquipmentMapper;
+import com.js.kbt.mapper.TbMouldMapper;
+import com.js.kbt.mapper.TimeCalibrationRecordMapper;
+import com.js.kbt.model.MouldCycleRuntime;
+import com.js.kbt.model.MouldCycleRuntimeExample;
+import com.js.kbt.model.MouldHistory;
+import com.js.kbt.model.MouldHistoryExample;
+import com.js.kbt.model.MouldHistoryTime;
+import com.js.kbt.model.MouldHistoryTimeExample;
 import com.js.kbt.util.Constant;
 
 @Controller
@@ -20,6 +40,25 @@ public class FileController {
 
 	@Autowired
 	private HttpServletRequest request;
+	
+	@Resource
+	private MouldHistoryMapper mouldHistoryMapper;
+	@Resource
+	private MouldHistoryTimeMapper mouldHistoryTimeMapper;
+	@Resource
+	private TbMouldMapper tbMouldMapper;
+	@Resource
+	private TbMouldEquipmentMapper tbMouldEquipmentMapper;
+	@Resource
+	private TbFactoryMapper tbFactoryMapper;
+	@Resource
+	private MouldHodingMapper mouldHodingMapper;
+	@Resource
+	private MouldDownPacketMapper mouldDownPacketMapper;
+	@Resource
+	private TimeCalibrationRecordMapper timeCalibrationRecordMapper;
+	@Resource
+	private MouldCycleRuntimeMapper mouldCycleRuntimeMapper;
 	/**
 	 * 通用上传图片接口
 	 * @param pic
@@ -67,4 +106,100 @@ public class FileController {
 		response.setCharacterEncoding("UTF-8");
 		response.getWriter().println(msg.toJSONStr());
 	}
+	
+	@RequestMapping(value = "update")
+	public void update() throws ParseException{
+		List<MouldHistory> list = mouldHistoryMapper.selectByExample(new MouldHistoryExample());
+		for (MouldHistory mouldHistory : list) {
+			MouldHistoryTimeExample mExp = new MouldHistoryTimeExample();
+			mExp.createCriteria().andHistoryIdEqualTo(mouldHistory.getId());
+			List<MouldHistoryTime> tList = mouldHistoryTimeMapper.selectByExample(mExp);
+			for (MouldHistoryTime mouldHistoryTime : tList) {
+				handleMouldCycleRuntimeLogic(mouldHistoryTime.getOpenTime(),mouldHistory);
+				System.out.println("时间---》"+mouldHistoryTime.getOpenTime());
+			}
+			
+		}
+	}
+	
+	private void handleMouldCycleRuntimeLogic(Date openTime,MouldHistory item) throws ParseException{
+		MouldCycleRuntime mcr = new MouldCycleRuntime();
+		Integer hours = openTime.getHours();
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		mcr.setDateStr(sdf.format(openTime));
+		System.out.println("时间字符串----》"+mcr.getDateStr());
+		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:");
+		int housTime = openTime.getHours()-1;
+		openTime.setHours(housTime);
+		String lastOpenTime = sdf1.format(openTime);
+		Date lastOpenTimeDate = sdf1.parse(lastOpenTime+"59:59");
+		System.out.println("lastOpenTime-->"+lastOpenTimeDate);
+		MouldHistoryTimeExample mExp = new MouldHistoryTimeExample();
+		mExp.setOrderByClause("open_time desc limit 1");
+		mExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andOpenTimeLessThanOrEqualTo(lastOpenTimeDate);
+		List<MouldHistoryTime> list = mouldHistoryTimeMapper.selectByExample(mExp);
+		if(list.size()>0){
+			MouldHistory mouldHistory = mouldHistoryMapper.selectByPrimaryKey(list.get(0).getHistoryId());
+			mcr.setEquipmentNo(item.getEquipmentNo());
+			mcr.setRuntime(item.getRunCnt() - mouldHistory.getRunCnt());
+			if(hours==0){
+				mcr.setTimeSlot("00:00-01:00");
+			}else if(hours==1){
+				mcr.setTimeSlot("01:00-02:00");
+			}else if(hours==2){
+				mcr.setTimeSlot("02:00-03:00");
+			}else if(hours==3){
+				mcr.setTimeSlot("03:00-04:00");
+			}else if(hours==4){
+				mcr.setTimeSlot("04:00-05:00");
+			}else if(hours==5){
+				mcr.setTimeSlot("05:00-06:00");
+			}else if(hours==6){
+				mcr.setTimeSlot("06:00-07:00");
+			}else if(hours==7){
+				mcr.setTimeSlot("07:00-08:00");
+			}else if(hours==8){
+				mcr.setTimeSlot("08:00-09:00");
+			}else if(hours==9){
+				mcr.setTimeSlot("09:00-10:00");
+			}else if(hours==10){
+				mcr.setTimeSlot("10:00-11:00");
+			}else if(hours==11){
+				mcr.setTimeSlot("11:00-12:00");
+			}else if(hours==12){
+				mcr.setTimeSlot("12:00-13:00");
+			}else if(hours==13){
+				mcr.setTimeSlot("13:00-14:00");
+			}else if(hours==14){
+				mcr.setTimeSlot("14:00-15:00");
+			}else if(hours==15){
+				mcr.setTimeSlot("15:00-16:00");
+			}else if(hours==16){
+				mcr.setTimeSlot("16:00-17:00");
+			}else if(hours==17){
+				mcr.setTimeSlot("17:00-18:00");
+			}else if(hours==18){
+				mcr.setTimeSlot("18:00-19:00");
+			}else if(hours==19){
+				mcr.setTimeSlot("19:00-20:00");
+			}else if(hours==20){
+				mcr.setTimeSlot("20:00-21:00");
+			}else if(hours==21){
+				mcr.setTimeSlot("21:00-22:00");
+			}else if(hours==22){
+				mcr.setTimeSlot("22:00-23:00");
+			}else if(hours==23){
+				mcr.setTimeSlot("23:00-00:00");
+			}
+			MouldCycleRuntimeExample mcrExp = new MouldCycleRuntimeExample();
+			mcrExp.createCriteria().andDateStrEqualTo(mcr.getDateStr()).andEquipmentNoEqualTo(item.getEquipmentNo()).andTimeSlotEqualTo(mcr.getTimeSlot());
+			List<MouldCycleRuntime> mList = mouldCycleRuntimeMapper.selectByExample(mcrExp);
+			if(mList.size()>0){
+				mcr.setId(mList.get(0).getId());
+				mouldCycleRuntimeMapper.updateByPrimaryKeySelective(mcr);
+			}else{
+				mouldCycleRuntimeMapper.insertSelective(mcr);
+			}
+		}
+	}
 }

+ 1 - 1
cloud-socket/src/jdbc.properties

@@ -1,7 +1,7 @@
 classPath=D:/model/cloud-socket/WebContent/WEB-INF/lib/mysql-connector-java-5.1.31-bin.jar
 #classPath=D:/workspace/yunsu/cloud-socket/WebContent/WEB-INF/lib/mysql-connector-java-5.1.31-bin.jar
 driver=com.mysql.jdbc.Driver
-url=jdbc:mysql://118.190.47.230:3306/new_cloud_model?autoReconnect=true&rewriteBatchedStatements=TRUE&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8
+url=jdbc:mysql://118.190.47.230:3306/cloud_model_test?autoReconnect=true&rewriteBatchedStatements=TRUE&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8
 username=root
 password=p011430seya1026
 maxActive=255