Bläddra i källkod

提交之前未提交的

wutt 5 år sedan
förälder
incheckning
b137d0f6e8

+ 33 - 33
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/ProjectMapper.java

@@ -1,33 +1,33 @@
-package com.hssx.cloudmodel.mapper;
-
-import com.hssx.cloudmodel.entity.Project;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.hssx.cloudmodel.entity.User;
-import com.hssx.cloudmodel.entity.vo.ProjectVO;
-import com.hssx.cloudmodel.entity.vo.UserVO;
-import com.hssx.cloudmodel.util.HttpRespMsg;
-import com.hssx.cloudmodel.util.PageUtil;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author 吴涛涛
- * @since 2019-07-27
- */
-public interface ProjectMapper extends BaseMapper<Project> {
-
-    List<ProjectVO> getProjectListByUid(@Param("keyName") String keyName, @Param("currentUser") User currentUser);
-
-    ProjectVO getProjectById(@Param("id")Integer id);
-
-    List<User> getProjectUserById(@Param("id")Integer id);
-
-    List<ProjectVO> selectUserPowerList(@Param("user") UserVO user, @Param("type") Integer type);
-
-    List<ProjectVO> getProjectListByUidInProjectIds(@Param("keyName")String keyName, @Param("list")List<Integer> projectIds);
-}
+package com.hssx.cloudmodel.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hssx.cloudmodel.entity.Project;
+import com.hssx.cloudmodel.entity.User;
+import com.hssx.cloudmodel.entity.vo.ProjectVO;
+import com.hssx.cloudmodel.entity.vo.UserVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-07-27
+ */
+public interface ProjectMapper extends BaseMapper<Project> {
+
+    List<ProjectVO> getProjectListByUid(@Param("keyName") String keyName, @Param("currentUser") User currentUser);
+
+    ProjectVO getProjectById(@Param("id")Integer id);
+
+    List<User> getProjectUserById(@Param("id")Integer id);
+
+    List<ProjectVO> selectUserPowerList(@Param("user") UserVO user, @Param("type") Integer type);
+
+    List<ProjectVO> selectUserPowerList1(@Param("user") UserVO user, @Param("type") Integer type);
+
+    List<ProjectVO> getProjectListByUidInProjectIds(@Param("keyName")String keyName, @Param("list")List<Integer> projectIds);
+}

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

@@ -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);
+    }
+}

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 652 - 654
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldServiceImpl.java


+ 49 - 50
cloud-model/src/main/java/com/hssx/cloudmodel/util/TimeAndCountUtil.java

@@ -1,50 +1,49 @@
-package com.hssx.cloudmodel.util;
-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 java.sql.SQLOutput;
-import java.util.*;
-
-/**
- * Author: 吴涛涛 cuiyi@itany.com
- * Date : 2019 - 10 - 12 16:34
- * Description:<描述>
- * Version: 1.0
- */
-public class TimeAndCountUtil {
-    public static Map<String,MouldCycleRuntime> getSet(){
-        Map<String,MouldCycleRuntime> map = new HashMap<>();
-        for(int i=0 ;i<=23 ;i++){
-            MouldCycleRuntime vo = new MouldCycleRuntime();
-            vo.setRuntime(0);
-            String iStr = i<10 ? ("0"+i):i+"";
-            int i1 = i+1;
-            String iStrAfterOne = (i1)<10 ? ("0"+i1):i1+"";
-            map.put(iStr+":00-"+iStrAfterOne+":00",vo);
-        }
-        return map;
-    }
-    public static Map<String,MouldHistoryTimeVO> getMap(){
-        Map<String,MouldHistoryTimeVO> 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",new MouldHistoryTimeVO());
-        }
-        return map;
-    }
-
-    public static void main(String[] args) {
-
-        Map<String, MouldHistoryTimeVO> runtimeResult = new LinkedHashMap<>();
-        TimeAndCountUtil.getMap().entrySet().stream().sorted(Map.Entry.<String, MouldHistoryTimeVO>comparingByKey())
-                .forEachOrdered(e -> runtimeResult.put(e.getKey(), e.getValue()));
-
-        System.out.println(runtimeResult);
-    }
-}
+package com.hssx.cloudmodel.util;
+import com.hssx.cloudmodel.entity.MouldCycleRuntime;
+import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
+import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 10 - 12 16:34
+ * Description:<描述>
+ * Version: 1.0
+ */
+public class TimeAndCountUtil {
+    public static Map<String,MouldCycleRuntime> getSet(){
+        Map<String,MouldCycleRuntime> map = new HashMap<>();
+        for(int i=0 ;i<=23 ;i++){
+            MouldCycleRuntime vo = new MouldCycleRuntime();
+            vo.setRuntime(0);
+            String iStr = i<10 ? ("0"+i):i+"";
+            int i1 = i+1;
+            String iStrAfterOne = (i1)<10 ? ("0"+i1):i1+"";
+            map.put(iStr+":00-"+iStrAfterOne+":00",vo);
+        }
+        return map;
+    }
+    public static Map<String,MouldHistoryTimeVO> getMap(){
+        Map<String,MouldHistoryTimeVO> 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",new MouldHistoryTimeVO());
+        }
+        return map;
+    }
+
+    public static void main(String[] args) {
+
+        Map<String, MouldHistoryTimeVO> runtimeResult = new LinkedHashMap<>();
+        TimeAndCountUtil.getMap().entrySet().stream().sorted(Map.Entry.<String, MouldHistoryTimeVO>comparingByKey())
+                .forEachOrdered(e -> runtimeResult.put(e.getKey(), e.getValue()));
+
+        System.out.println(runtimeResult);
+    }
+}

+ 6 - 6
cloud-model/src/main/resources/mapper/ProjectMapper.xml

@@ -217,22 +217,22 @@
         on tbc.id = tbu.company_id
         <where>
             <if test="user.projectId != null">
-                tbpu.project_id = #{user.projectId}
+                or tbpu.project_id = #{user.projectId}
             </if>
             <if test="user.companyId != null">
-                tbu.company_id = #{user.companyId}
+                and tbu.company_id = #{user.companyId}
             </if>
             <if test="user.keyName != null and user.keyName != ''">
-                tbu.username like concat('%',#{user.keyName},'%')
+                and tbu.username like concat('%',#{user.keyName},'%')
             </if>
             <if test="type == 0">
-                tbp.creator_id = #{user.id}
+                and tbp.creator_id = #{user.id}
             </if>
             <if test="type == 1">
-                tbp.manager_id = #{user.id}
+                and tbp.manager_id = #{user.id}
             </if>
         </where>
-        GROUP BY tbpu.user_id ,tbpu.project_id;
+        GROUP BY tbpu.user_id ,tbpu.project_id
         order by tbpu.user_id
     </select>
 

+ 11 - 11
cloud-model/src/test/java/com/hssx/cloudmodel/CloudModelApplicationTests.java

@@ -1,20 +1,13 @@
 package com.hssx.cloudmodel;
 
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.hssx.cloudmodel.entity.CustomCompany;
-import com.hssx.cloudmodel.entity.ProjectUser;
-import com.hssx.cloudmodel.entity.User;
-import com.hssx.cloudmodel.mapper.CustomCompanyMapper;
+import com.hssx.cloudmodel.entity.vo.ProjectVO;
+import com.hssx.cloudmodel.entity.vo.UserVO;
+import com.hssx.cloudmodel.mapper.ProjectMapper;
 import com.hssx.cloudmodel.mapper.ProjectUserMapper;
 import com.hssx.cloudmodel.mapper.UserMapper;
-import com.hssx.cloudmodel.util.HttpKit;
-import com.hssx.cloudmodel.util.HttpRespMsg;
-import org.apache.commons.lang3.StringEscapeUtils;
-import org.json.JSONObject;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
@@ -30,11 +23,18 @@ public class CloudModelApplicationTests {
     @Resource
     UserMapper userMapper;
     @Resource
-    CustomCompanyMapper customCompanyMapper;
+    ProjectMapper  projectMapper;
     @Test
     public void contextLoads() {
 
         CustomCompany customCompany = new CustomCompany();
+        UserVO vo = new UserVO();
+        vo.setProjectId(5);
+        vo.setId(165);
+//        vo.setCompanyId(9);
+        vo.setKeyName("111");
+        List<ProjectVO> projectVOS = projectMapper.selectUserPowerList1(vo, 0);
+        System.out.println(projectVOS);
 //        customCompany.setCompanyId(10);
 //        customCompany.setProjectId(4);
 //        customCompanyMapper.update(customCompany,new QueryWrapper<CustomCompany>().eq("company_id",10));

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 809 - 843
cloud-socket/src/com/js/kbt/socket/UserHandler.java