瀏覽代碼

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 年之前
父節點
當前提交
9d26a7281f

+ 4 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/MouldEquipment.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 
 /**
@@ -37,12 +39,14 @@ public class MouldEquipment extends Model<MouldEquipment> {
      * 启动时间
      */
     @TableField("start_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime startTime;
 
     /**
      * 结束时间
      */
     @TableField("end_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime endTime;
 
     /**

+ 2 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/vo/MouldVO.java

@@ -18,6 +18,8 @@ public class MouldVO extends Mould {
     private String projectName;
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime endTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime lastOpenTime;
     private String mangerName;
     private String equipmentNo;
     private String hillNumber;

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

@@ -32,7 +32,7 @@ public class UserVO extends User {
     private String startTime;
     private String endTime;
     private Integer mouleMap;//用于过滤地图概览
-    private Integer type;
+    private Integer type;//用于控制运行监测的模具列表
     /**
      */
     private Integer dwgType;

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

@@ -36,6 +36,7 @@
         <result column="equipment_no" property="equipmentNo" />
         <result column="is_use" property="isUse" />
         <result column="hill_number" property="hillNumber" />
+        <result column="temperature" property="temperature" />
         <result column="modelNo" property="modelNo" />
         <result column="agent" property="agent" />
         <result column="modelName" property="modelName" />
@@ -66,9 +67,12 @@
     </select>
     <select id="getList" resultMap="BaseResultMapVO">
         select
-        tbme.id id, tbme.equipment_name equipment_name, tbme.start_time start_time, tbme.end_time end_time,tbme.agent,
+        tbme.id id, tbme.equipment_no,tbme.equipment_name equipment_name, tbme.start_time start_time, tbme.end_time end_time,tbme.agent,
         tbme.use_life use_life, tbme.belong_company_id belong_company_id, tbme.equipment_no equipment_no,tbme.sim sim,
-        tbme.is_use, tbme.hill_number,tbc.company_name companyName,tbm.model_no modelNo,tbm.model_name modelName,tbme.stage
+        tbme.is_use, (SELECT battery  FROM `mould_history` WHERE tbme.equipment_no = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
+        (SELECT temperature  FROM `mould_history` WHERE equipment_no = tbme.equipment_no ORDER BY indate DESC LIMIT 1) temperature,tbc.company_name companyName,
+        tbm.model_no modelNo,
+        tbm.model_name modelName,tbme.stage
         from
         tb_mould_equipment tbme
         left join

+ 3 - 2
cloud-model/src/main/resources/mapper/MouldMapper.xml

@@ -67,6 +67,7 @@
         <result column="equipmentNo" property="equipmentNo"/>
         <result column="stage" property="stage"/>
         <result column="endTime" property="endTime"/>
+        <result column="lastopentime" property="lastOpenTime"/>
         <result column="hillNumber" property="hillNumber"/>
         <result column="ownerCompanyName" property="ownerCompanyName"/>
         <result column="companyName" property="companyName"/>
@@ -87,7 +88,7 @@
         tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbco.company_name produceCompany,tbm.pre_update_id,
         tbp.manager mangerName,tbco.company_address area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbp.manager_id managerId,
         tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
-        tbmp.lng,tbmp.lat,tbmp.stage
+        tbmp.lng,tbmp.lat,tbmp.stage,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime
         from
         tb_mould tbm
         left join
@@ -133,7 +134,7 @@
         tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbm.holes,tbm.pre_update_id,tbco.company_name produceCompany,
         tbp.manager mangerName,tbco.company_address area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbm.creator_id creator_id,
         tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times,
-        tbmp.lng,tbmp.lat,tbmp.stage
+        tbmp.lng,tbmp.lat,tbmp.stage,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime
         from
         tb_mould tbm
         left join

+ 1 - 1
cloud-socket/.settings/org.eclipse.wst.common.component

@@ -2,7 +2,7 @@
     <wb-module deploy-name="JSKBT">
         <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
-        <property name="context-root" value="JSKBT"/>
         <property name="java-output-path" value="/JSKBT/build/classes"/>
+        <property name="context-root" value="JSKBT"/>
     </wb-module>
 </project-modules>

+ 21 - 9
cloud-socket/src/com/js/kbt/controller/WeiXinUserInfoController.java

@@ -26,6 +26,7 @@ import com.js.kbt.model.MouldDownPacket;
 import com.js.kbt.model.MouldDownPacketExample;
 import com.js.kbt.model.TbUser;
 import com.js.kbt.model.TbUserExample;
+import com.js.kbt.util.CRC16Util;
 import com.js.kbt.util.MD5Util;
 import com.js.kbt.util.ProjectConst;
 import com.js.kbt.util.WeiXinUtils;
@@ -259,6 +260,7 @@ public class WeiXinUserInfoController {
 	@RequestMapping("/setPacket")
 	public void bindAccount(HttpServletResponse response,String lowPowerLimit,String hotAlarmLimit,String equipmentNo) {
 		HttpRespMsg msg = new HttpRespMsg();
+		System.out.println("lowPowerLimit"+lowPowerLimit+"hotAlarmLimit"+hotAlarmLimit);
 		String setPacketMessage = "";
 		MouldDownPacket mouldDownPacket = new MouldDownPacket();
 		MouldDownPacketExample exp = new MouldDownPacketExample();
@@ -280,6 +282,7 @@ public class WeiXinUserInfoController {
 				mouldDownPacketMapper.insertSelective(mouldDownPacket);
 			}
 		}
+		msg.data = setPacketMessage;
 		response.setContentType("application/json");
 		response.setCharacterEncoding("UTF-8");
 		try {
@@ -298,15 +301,13 @@ public class WeiXinUserInfoController {
 			if("23".equals(hotAlarmLimit)){
 				hotAlarmLimit="24";
 			}
-			String ret = "FA AF 00 07 02 1e 78 lowPowerLimit hotAlarmLimit 00 3C";
-			ret.replace("lowPowerLimit", lowPowerLimit);
-			ret.replace("hotAlarmLimit", hotAlarmLimit);
-			ret.replaceAll(" ", "");
-			//16 位 CRC 校验(低位在前;高位在后)
-			int crc = reverseParseHex(ret);
-			String crcString = crc + "";
-			ret = ret + crcString;
-			return ret;
+			String ret = "FA AF 00 07 02 1e 78 "+lowPowerLimit+" "+hotAlarmLimit+" 00 3C";
+			ret = ret.replaceAll(" ", "");
+			String crcCode = CRC16Util.getCRC(ret);
+			System.out.println("ret===>"+ret);
+			String lastPart = (ret + crcCode).replaceAll("23", "24").replaceAll(" ", "");
+			System.out.println("lastPart===>"+lastPart);
+			return lastPart;
 		}
 		
 		/**
@@ -322,6 +323,17 @@ public class WeiXinUserInfoController {
 				sb.append(rHex.substring((size - i - 1) * 2, (size - i) * 2));
 			}
 			String str = sb.toString();
+			System.out.println("str"+str);
 			return Integer.parseInt(str, 16);
 		}
+		
+		public static void main(String[] args) {
+			String ret = "D5 37";
+			ret = ret.replaceAll(" ", "");
+			System.out.println(ret);
+//			int parseInt = Integer.parseInt(ret, 16);
+//			int crc = reverseParseHex(ret);
+//			System.out.println(crc);
+//			System.out.println(parseInt);
+		}
 }

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

@@ -0,0 +1,71 @@
+package com.js.kbt.util;
+public class CRC16Util {
+    /**
+     * 计算CRC16校验码
+     *
+     * @param data 需要校验的字符串
+     * @return 校验码
+     */
+    public static String getCRC(String data) {
+        data = data.replace(" ", "");
+        int len = data.length();
+        if (!(len % 2 == 0)) {
+            return "0000";
+        }
+        int num = len / 2;
+        byte[] para = new byte[num];
+        for (int i = 0; i < num; i++) {
+            int value = Integer.valueOf(data.substring(i * 2, 2 * (i + 1)), 16);
+            para[i] = (byte) value;
+        }
+        return getCRC(para);
+    }
+ 
+ 
+    /**
+     * 计算CRC16校验码
+     *
+     * @param bytes 字节数组
+     * @return {@link String} 校验码
+     * @since 1.0
+     */
+    public static String getCRC(byte[] bytes) {
+        //CRC寄存器全为1
+        int CRC = 0x0000ffff;
+        //多项式校验值
+        int POLYNOMIAL = 0x0000a001;
+        int i, j;
+        for (i = 0; i < bytes.length; i++) {
+            CRC ^= ((int) bytes[i] & 0x000000ff);
+            for (j = 0; j < 8; j++) {
+                if ((CRC & 0x00000001) != 0) {
+                    CRC >>= 1;
+                    CRC ^= POLYNOMIAL;
+                } else {
+                    CRC >>= 1;
+                }
+            }
+        }
+        //结果转换为16进制
+        String result = Integer.toHexString(CRC).toUpperCase();
+        if (result.length() != 4) {
+            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);//高位在前,低位在后
+    }
+ 
+ 
+    public static void main(String[] args) {
+        //01 03 20 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 8C 45
+        //01 03 00 00 00 08 44 0C
+        //01 03 10 00 8F 02 4E 00 91 02 44 00 92 02 5A 00 8B 02 47 40 D8
+//        System.out.println(getCRC("01 03 20 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF 7F FF"));
+//        System.out.println(getCRC("01 03 00 00 00 08"));
+//        System.out.println(getCRC("01 03 10 00 8F 02 4E 00 91 02 44 00 92 02 5A 00 8B 02 47"));
+    	String crc = getCRC("FA AF 00 07 02 1e 78"+" 1e"+" "+"50"+" 00 3C");
+        System.out.println(crc);
+    }
+}

+ 6 - 2
target/classes/main/resources/mapper/MouldEquipmentMapper.xml

@@ -36,6 +36,7 @@
         <result column="equipment_no" property="equipmentNo" />
         <result column="is_use" property="isUse" />
         <result column="hill_number" property="hillNumber" />
+        <result column="temperature" property="temperature" />
         <result column="modelNo" property="modelNo" />
         <result column="agent" property="agent" />
         <result column="modelName" property="modelName" />
@@ -66,9 +67,12 @@
     </select>
     <select id="getList" resultMap="BaseResultMapVO">
         select
-        tbme.id id, tbme.equipment_name equipment_name, tbme.start_time start_time, tbme.end_time end_time,tbme.agent,
+        tbme.id id, tbme.equipment_no,tbme.equipment_name equipment_name, tbme.start_time start_time, tbme.end_time end_time,tbme.agent,
         tbme.use_life use_life, tbme.belong_company_id belong_company_id, tbme.equipment_no equipment_no,tbme.sim sim,
-        tbme.is_use, tbme.hill_number,tbc.company_name companyName,tbm.model_no modelNo,tbm.model_name modelName,tbme.stage
+        tbme.is_use, (SELECT battery  FROM `mould_history` WHERE tbme.equipment_no = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
+        (SELECT temperature  FROM `mould_history` WHERE equipment_no = tbme.equipment_no ORDER BY indate DESC LIMIT 1) temperature,tbc.company_name companyName,
+        tbm.model_no modelNo,
+        tbm.model_name modelName,tbme.stage
         from
         tb_mould_equipment tbme
         left join