Browse Source

导出功能和图表的整合

wutt 5 years ago
parent
commit
f5026454cb

+ 7 - 2
.idea/compiler.xml

@@ -11,11 +11,16 @@
         <module name="website" />
         <module name="website" />
       </profile>
       </profile>
     </annotationProcessing>
     </annotationProcessing>
-    <bytecodeTargetLevel>
+    <bytecodeTargetLevel target="8">
       <module name="cloud-model" target="1.8" />
       <module name="cloud-model" target="1.8" />
-      <module name="model" target="1.8" />
       <module name="website" target="1.8" />
       <module name="website" target="1.8" />
       <module name="yunsu" target="1.8" />
       <module name="yunsu" target="1.8" />
     </bytecodeTargetLevel>
     </bytecodeTargetLevel>
   </component>
   </component>
+  <component name="JavacSettings">
+    <option name="ADDITIONAL_OPTIONS_OVERRIDE">
+      <module name="cloud-model" options="-parameters" />
+      <module name="website" options="-parameters" />
+    </option>
+  </component>
 </project>
 </project>

+ 1 - 1
.idea/misc.xml

@@ -12,5 +12,5 @@
       </list>
       </list>
     </option>
     </option>
   </component>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8.0_171" project-jdk-type="JavaSDK" />
 </project>
 </project>

+ 12 - 6
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldHistoryController.java

@@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 /**
 /**
  * <p>
  * <p>
  *  前端控制器
  *  前端控制器
@@ -29,16 +32,19 @@ public class MouldHistoryController {
     private MouldHistoryService mouldHistoryService;
     private MouldHistoryService mouldHistoryService;
 
 
     /**
     /**
-     *  获取云模盒的每日开合次数图标 (时间/次数)
+     *
+     * 开合次数的excel导出/开合历史数据的excel导出
      * @param equipmentNo 设备编号
      * @param equipmentNo 设备编号
-     * @param time 时间点 如:2019-02-15
+     * @param startTime 时间点 如:2019-02-15
+     * @param endTime 时间点 如:2019-02-15
+     * @param type 0-开合次数数据,1-开合历史数据
      * @return
      * @return
      */
      */
-    @ApiOperation("获取云模盒的每日开合次数图表 (时间/次数)")
-    @RequestMapping("/openingAndClosingTimesChart")
+    @ApiOperation("开合次数的excel导出/开合历史数据的excel导出")
+    @RequestMapping("/exportExcel")
     @ResponseBody
     @ResponseBody
-    public HttpRespMsg openingAndClosingTimesChart(String equipmentNo,String time){
-        HttpRespMsg msg = mouldHistoryService.getOpeningAndClosingTimesChart(equipmentNo, time);
+    public HttpRespMsg openingAndClosingTimesChart(HttpServletResponse response, String equipmentNo, String startTime, String endTime, Integer type){
+        HttpRespMsg msg = mouldHistoryService.getOpeningAndClosingTimesChart(response,equipmentNo,startTime,endTime,type);
         return msg;
         return msg;
     }
     }
 
 

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

@@ -20,4 +20,7 @@ public interface MouldHistoryTimeMapper extends BaseMapper<MouldHistoryTime> {
 
 
     List<MouldHistoryVO> getOpeningAndClosingTimesChartCycle(@Param("time")String time,@Param("equipmentNo")String equipmentNo
     List<MouldHistoryVO> getOpeningAndClosingTimesChartCycle(@Param("time")String time,@Param("equipmentNo")String equipmentNo
     ,@Param("maxCycle")Integer maxCycle,@Param("minCycle")Integer minCycle);
     ,@Param("maxCycle")Integer maxCycle,@Param("minCycle")Integer minCycle);
+
+    List<MouldHistoryTime> getOpeningAndClosingTimesChartCycleExcel(@Param("startTime")String startTime,@Param("endTime")String time,@Param("equipmentNo")String equipmentNo
+            );
 }
 }

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

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
 import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 /**
 /**
  * <p>
  * <p>
  *  服务类
  *  服务类
@@ -15,7 +18,7 @@ import com.hssx.cloudmodel.util.HttpRespMsg;
  */
  */
 public interface MouldHistoryService extends IService<MouldHistory> {
 public interface MouldHistoryService extends IService<MouldHistory> {
 
 
-    HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time);
+    HttpRespMsg getOpeningAndClosingTimesChart(HttpServletResponse response, String equipmentNo, String startTime, String endTime, Integer type);
 
 
     HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo,String time);
     HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo,String time);
 }
 }

+ 151 - 176
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldHistoryServiceImpl.java

@@ -7,17 +7,23 @@ import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
 import com.hssx.cloudmodel.mapper.*;
 import com.hssx.cloudmodel.mapper.*;
 import com.hssx.cloudmodel.service.MouldHistoryService;
 import com.hssx.cloudmodel.service.MouldHistoryService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hssx.cloudmodel.util.ExcelUtil;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 import com.hssx.cloudmodel.util.TimeAndCountUtil;
 import com.hssx.cloudmodel.util.TimeAndCountUtil;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.text.SimpleDateFormat;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  * </p>
  *
  *
  * @author 吴涛涛
  * @author 吴涛涛
@@ -37,210 +43,179 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
     private MouldEquipmentMapper mouldEquipmentMapper;
     private MouldEquipmentMapper mouldEquipmentMapper;
     @Resource
     @Resource
     private InjectionMoldingMapper injectionMoldingMapper;
     private InjectionMoldingMapper injectionMoldingMapper;
+    @Value("${upload.path}")
+    private String downloadPath;
+
     @Override
     @Override
-    public HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time) {
+    public HttpRespMsg getOpeningAndClosingTimesChart(HttpServletResponse response, String equipmentNo, String startTime, String endTime, Integer type) {
         HttpRespMsg msg = new HttpRespMsg();
         HttpRespMsg msg = new HttpRespMsg();
-        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);
-        list = list.stream().sorted(Comparator.comparing(MouldCycleRuntime::getTimeSlot)).collect(Collectors.toList());
-        msg.data=list;
+        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;
         return msg;
     }
     }
 
 
     @Override
     @Override
-    public HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo,String time) {
+    public HttpRespMsg openingAndClosingTimesChartCycle(String equipmentNo, String time) {
         HttpRespMsg msg = new HttpRespMsg();
         HttpRespMsg msg = new HttpRespMsg();
+        Map<String, Object> listMap = new HashMap<>();
         MouldEquipment mouldEquipment = mouldEquipmentMapper.selectOne(new QueryWrapper<MouldEquipment>().eq("equipment_no", equipmentNo));
         MouldEquipment mouldEquipment = mouldEquipmentMapper.selectOne(new QueryWrapper<MouldEquipment>().eq("equipment_no", equipmentNo));
         Mould mould = mouldMapper.selectOne(new QueryWrapper<Mould>().eq("equipment_id", mouldEquipment.getId()));
         Mould mould = mouldMapper.selectOne(new QueryWrapper<Mould>().eq("equipment_id", mouldEquipment.getId()));
         InjectionMolding molding = injectionMoldingMapper.selectOne(new QueryWrapper<InjectionMolding>().eq("mould_id", mould.getId()));
         InjectionMolding molding = injectionMoldingMapper.selectOne(new QueryWrapper<InjectionMolding>().eq("mould_id", mould.getId()));
         Integer cycle = 0;
         Integer cycle = 0;
-        if(molding != null){
-             cycle = (null == molding.getCycle())?40000:Integer.parseInt(molding.getCycle());
-        }else{
-             cycle = 40000;
+        if (molding != null) {
+            cycle = (null == molding.getCycle()) ? 40000 : Integer.parseInt(molding.getCycle());
+        } else {
+            cycle = 40000;
         }
         }
-        Integer maxCycle = cycle+10000;
-        Integer minCycle = cycle-10000;
-        Map<String,MouldHistoryTimeVO> map = TimeAndCountUtil.getMap();
-        List<MouldHistoryVO> list = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(time,equipmentNo,maxCycle,minCycle);
+        Integer maxCycle = cycle + 10000;
+        Integer minCycle = cycle - 10000;
+        Map<String, MouldHistoryTimeVO> map = TimeAndCountUtil.getMap();
+        List<MouldHistoryVO> list = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(time, equipmentNo, maxCycle, minCycle);
         Integer count = 0;
         Integer count = 0;
         Map<String, List<MouldHistoryVO>> mapList = list.stream().collect(Collectors.groupingBy(MouldHistoryVO::getTime));
         Map<String, List<MouldHistoryVO>> mapList = list.stream().collect(Collectors.groupingBy(MouldHistoryVO::getTime));
-        for(Map.Entry<String, List<MouldHistoryVO>> entry:mapList.entrySet()){
+        for (Map.Entry<String, List<MouldHistoryVO>> entry : mapList.entrySet()) {
             MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
             MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
             vo.setMinCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
             vo.setMinCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).min().getAsInt());
             vo.setMaxCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt());
             vo.setMaxCycle(entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).max().getAsInt());
-            vo.setAvgCycle((int)entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
+            vo.setAvgCycle((int) entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).average().getAsDouble());
             vo.setTheoryCycle(cycle);
             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);
+            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);
+        System.out.println("原来的map===>" + map);
         Map<String, MouldHistoryTimeVO> result = map.entrySet().stream()
         Map<String, MouldHistoryTimeVO> result = map.entrySet().stream()
                 .sorted(Map.Entry.comparingByKey())
                 .sorted(Map.Entry.comparingByKey())
                 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
                 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
                         (oleValue, newValue) -> oleValue, LinkedHashMap::new));
                         (oleValue, newValue) -> oleValue, LinkedHashMap::new));
-        System.out.println("排序后的map===>"+result);
+        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 = list.stream().sorted(Comparator.comparing(MouldCycleRuntime::getTimeSlot)).collect(Collectors.toList());
-//        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());
-//        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;
-        msg.data = 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());
+        listMap.put("runtime", cycleRuntime);
+        msg.data = map;
         return msg;
         return msg;
     }
     }
 
 
     public static void main(String[] args) {
     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());
+        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);
         System.out.println(primes);
     }
     }
 }
 }

+ 0 - 2
cloud-model/src/main/java/com/hssx/cloudmodel/util/ExcelUtil.java

@@ -8,9 +8,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
 
 
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
-import java.io.OutputStream;
 import java.net.URLEncoder;
 import java.net.URLEncoder;
 import java.util.List;
 import java.util.List;
 
 

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

@@ -34,4 +34,17 @@
         </where>
         </where>
         ORDER BY open_time
         ORDER BY open_time
     </select>
     </select>
+    <select id="getOpeningAndClosingTimesChartCycleExcel" resultMap="BaseResultMap">
+        select
+        history_id, seq, close_time, open_time, time_cost, equipment_no
+        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') between #{startTime} and #{endTime}
+            </if>
+        </where>
+        ORDER BY open_time
+    </select>
 </mapper>
 </mapper>