瀏覽代碼

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

# Conflicts:
#	target/classes/main/resources/mapper/MouldEquipmentMapper.xml
#	target/classes/main/resources/mapper/MouldMapper.xml
5 年之前
父節點
當前提交
bcdc252f83

+ 18 - 7
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldHistoryController.java

@@ -1,6 +1,8 @@
 package com.hssx.cloudmodel.controller;
 
 
+import com.hssx.cloudmodel.entity.MouldHistoryTime;
+import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
 import com.hssx.cloudmodel.service.MouldHistoryService;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 import io.swagger.annotations.ApiOperation;
@@ -39,13 +41,22 @@ public class MouldHistoryController {
         HttpRespMsg msg = mouldHistoryService.getOpeningAndClosingTimesChart(equipmentNo, time);
         return msg;
     }
-//    @ApiOperation("获取云模盒的每日开合次数图标 (时间/次数)")
-//    @RequestMapping("/openingAndClosingTimesChart")
-//    @ResponseBody
-//    public HttpRespMsg openingAndClosingTimesChart(String equipmentNo,String time){
-//        HttpRespMsg msg = mouldHistoryService.getOpeningAndClosingTimesChart(equipmentNo, time);
-//        return msg;
-//    }
+
+    /**
+     * 获取云模盒的每日开合次数周期 (时间/周期)
+     * @param mouldHistoryTimeVO
+     *  参数:startTime 开始时间 2019-01-02
+     *        endTime 截止时间 2019-01-03
+     *        equipmentNo 设备编号
+     * @return
+     */
+    @ApiOperation("获取云模盒的每日开合次数周期 (时间/周期)")
+    @RequestMapping("/openingAndClosingTimesChartCycle")
+    @ResponseBody
+    public HttpRespMsg openingAndClosingTimesChartCycle(MouldHistoryTimeVO mouldHistoryTimeVO){
+        HttpRespMsg msg = mouldHistoryService.openingAndClosingTimesChartCycle(mouldHistoryTimeVO);
+        return msg;
+    }
 
 }
 

+ 20 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/vo/MouldHistoryTimeVO.java

@@ -0,0 +1,20 @@
+package com.hssx.cloudmodel.entity.vo;
+
+import com.hssx.cloudmodel.entity.MouldHistoryTime;
+import lombok.Data;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 10 - 12 11:19
+ * Description:<描述>
+ * Version: 1.0
+ */
+@Data
+public class MouldHistoryTimeVO extends MouldHistoryTime {
+    private String startTime;
+    private String endTime;
+    private String time;//返回给前端的年月日字符串(2019-01-02)
+    private Double avgCycle;
+    private Integer minCycle;
+    private Integer maxCycle;
+}

+ 6 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/MouldHistoryTimeMapper.java

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

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

@@ -2,6 +2,7 @@ package com.hssx.cloudmodel.service;
 
 import com.hssx.cloudmodel.entity.MouldHistory;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 
 /**
@@ -15,4 +16,6 @@ import com.hssx.cloudmodel.util.HttpRespMsg;
 public interface MouldHistoryService extends IService<MouldHistory> {
 
     HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time);
+
+    HttpRespMsg openingAndClosingTimesChartCycle(MouldHistoryTimeVO mouldHistoryTimeVO);
 }

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

@@ -1,15 +1,19 @@
 package com.hssx.cloudmodel.service.impl;
 
 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.MouldHistoryMapper;
+import com.hssx.cloudmodel.mapper.MouldHistoryTimeMapper;
 import com.hssx.cloudmodel.service.MouldHistoryService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -23,6 +27,8 @@ import java.util.List;
 public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, MouldHistory> implements MouldHistoryService {
     @Resource
     private MouldHistoryMapper mouldHistoryMapper;
+    @Resource
+    private MouldHistoryTimeMapper mouldHistoryTimeMapper;
     @Override
     public HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -30,4 +36,39 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
         msg.data=list;
         return msg;
     }
+
+    @Override
+    public HttpRespMsg openingAndClosingTimesChartCycle(MouldHistoryTimeVO mouldHistoryTimeVO) {
+        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(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).average().getAsDouble());
+            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;
+    }
+
+    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);
+    }
 }

+ 1 - 1
cloud-model/src/main/resources/mapper/MouldHistoryMapper.xml

@@ -55,7 +55,7 @@
     </sql>
 
     <select id="selectOpeningAndClosingTimesChart" resultMap="BaseResultMapVO">
-      SELECT  DATE_FORMAT(indate,'%H:%i:%s') time ,  run_cnt FROM `mould_history`
+      SELECT  DATE_FORMAT(indate,'%H:%i:%s') time , run_cnt FROM `mould_history`
        WHERE `equipment_no`= #{equipmentNo} AND DATE_FORMAT(indate,'%Y-%m-%d') = #{time}
        ORDER BY indate
     </select>

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

@@ -4,17 +4,39 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.hssx.cloudmodel.entity.MouldHistoryTime">
-        <result column="history_id" property="historyId" />
-        <result column="seq" property="seq" />
-        <result column="close_time" property="closeTime" />
-        <result column="open_time" property="openTime" />
-        <result column="time_cost" property="timeCost" />
-        <result column="equipment_no" property="equipmentNo" />
+        <result column="history_id" property="historyId"/>
+        <result column="seq" property="seq"/>
+        <result column="close_time" property="closeTime"/>
+        <result column="open_time" property="openTime"/>
+        <result column="time_cost" property="timeCost"/>
+        <result column="equipment_no" property="equipmentNo"/>
+    </resultMap>
+    <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO">
+        <result column="history_id" property="historyId"/>
+        <result column="seq" property="seq"/>
+        <result column="close_time" property="closeTime"/>
+        <result column="open_time" property="openTime"/>
+        <result column="time_cost" property="timeCost"/>
+        <result column="equipment_no" property="equipmentNo"/>
+        <result column="time" property="time"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         history_id, seq, close_time, open_time, time_cost, equipment_no
     </sql>
-
+    <select id="getOpeningAndClosingTimesChartCycle" resultMap="BaseResultMapVO">
+        select
+        DATE_FORMAT(open_time,'%Y-%m-%d') time ,time_cost
+        from
+        `mould_history_time`
+        <where>
+            equipment_no = #{equipmentNo}
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                and DATE_FORMAT(open_time,'%Y-%m-%d %H:%i:%s')
+                between concat(#{startTime},' 00:00:00') and
+                concat(#{endTime},' 23:59:59')
+            </if>
+        </where>
+    </select>
 </mapper>

+ 0 - 1
cloud-socket/src/com/js/kbt/socket/CustomEncoder.java

@@ -2,7 +2,6 @@ package com.js.kbt.socket;
 
 import java.util.List;
 
-import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.string.StringEncoder;
 

+ 0 - 5
cloud-socket/src/com/js/kbt/socket/HelloServerInitializer.java

@@ -5,13 +5,8 @@ import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelPipeline;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.handler.codec.string.StringDecoder;
-import io.netty.handler.codec.string.StringEncoder;
-import io.netty.handler.timeout.IdleStateHandler;
-
 import java.nio.charset.Charset;
-
 import javax.annotation.Resource;
-
 import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Service;
 @Service("helloServerInitializer")

+ 1 - 2
cloud-socket/src/com/js/kbt/socket/UserHandler.java

@@ -30,7 +30,6 @@ import com.js.kbt.model.TbMouldEquipment;
 import com.js.kbt.model.TbMouldEquipmentExample;
 import com.js.kbt.model.TbMouldExample;
 import com.js.kbt.model.TimeCalibrationRecord;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
@@ -67,7 +66,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 	protected void channelRead0(ChannelHandlerContext arg0, String arg1) {
 		String pack = "FAAF0007001e781e50003C37D5";
 		//校准时间
-		timeCalibration();
+//		timeCalibration();
 		System.out.println("收到===" + arg1 + "\n");
 		String equipmentNo = processMsg(arg1);
 		//以下是配置下行数据

+ 3 - 3
cloud-socket/src/com/js/kbt/util/CRC16Util.java

@@ -54,9 +54,9 @@ public class CRC16Util {
             StringBuffer sb = new StringBuffer("0000");
             result = sb.replace(4 - result.length(), 4, result).toString();
         }
-        return result;
-        //交换高低位
-//        return result.substring(2, 4) + result.substring(0, 2);//高位在前,低位在后
+//        return result;
+//        交换高低位
+        return result.substring(2, 4) + result.substring(0, 2);//高位在前,低位在后
     }