Browse Source

定时任务处理丢包

wutt 5 năm trước cách đây
mục cha
commit
35bf2ff5a0

+ 7 - 10
cloud-socket/src/com/js/kbt/UserTempGenConfig.xml

@@ -1,23 +1,20 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
 <generatorConfiguration >
-	<properties resource="jdbc.properties" />
-	<classPathEntry location="${classPath}"/>
+	<!-- <properties resource="jdbc.properties" />
+	<classPathEntry location="${classPath}"/> -->
 	<!-- 下面这行相当于以上两行 -->
-	<!-- <classPathEntry location="D:/mysql-connector-java-5.1.31-bin.jar"/> -->
+	<classPathEntry location="D:/mysql-connector-java-5.1.31-bin.jar"/>
   <context id="context1" targetRuntime="MyBatis3">
   
-    <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://118.190.47.230:3306/cloud_model"
-     userId="root" password="p011430seya1026" >
+    <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://47.100.37.243:7644/cloud_mould"
+     userId="root" password="Hssx2018.!">
     </jdbcConnection>
-     <!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/cloud_mould"
-     userId="root" password="102345.." > 
-    </jdbcConnection> -->
     <javaModelGenerator targetPackage="com.js.kbt.model" targetProject="cloud-socket" />
     <sqlMapGenerator targetPackage="com.js.kbt.mapper" targetProject="cloud-socket" />
     <javaClientGenerator targetPackage="com.js.kbt.mapper" targetProject="cloud-socket" type="XMLMAPPER" />
-    <table schema="cloud_mould" tableName="equipment_send_command" >
-    	<generatedKey column="id" identity="true" sqlStatement="SELECT LAST_INSERT_ID()"/>
+    <table schema="cloud_mould" tableName="mould_history_time" >
+    	<!-- <generatedKey column="id" identity="true" sqlStatement="SELECT LAST_INSERT_ID()"/> -->
     </table>
 <!--     <table schema="cloud_model" tableName="tb_mould_equipment" > -->
 <!--     	<generatedKey column="id" identity="true" sqlStatement="SELECT LAST_INSERT_ID()"/> -->

+ 7 - 7
cloud-socket/src/com/js/kbt/mapper/MouldHistoryTimeMapper.java

@@ -10,44 +10,44 @@ public interface MouldHistoryTimeMapper {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	long countByExample(MouldHistoryTimeExample example);
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	int deleteByExample(MouldHistoryTimeExample example);
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	int insert(MouldHistoryTime record);
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	int insertSelective(MouldHistoryTime record);
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	List<MouldHistoryTime> selectByExample(MouldHistoryTimeExample example);
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	int updateByExampleSelective(@Param("record") MouldHistoryTime record,
 			@Param("example") MouldHistoryTimeExample example);
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	int updateByExample(@Param("record") MouldHistoryTime record, @Param("example") MouldHistoryTimeExample example);
 

+ 28 - 17
cloud-socket/src/com/js/kbt/mapper/MouldHistoryTimeMapper.xml

@@ -5,7 +5,7 @@
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     <result column="history_id" jdbcType="BIGINT" property="historyId" />
     <result column="seq" jdbcType="INTEGER" property="seq" />
@@ -13,12 +13,13 @@
     <result column="open_time" jdbcType="TIMESTAMP" property="openTime" />
     <result column="time_cost" jdbcType="INTEGER" property="timeCost" />
     <result column="equipment_no" jdbcType="VARCHAR" property="equipmentNo" />
+    <result column="is_true" jdbcType="INTEGER" property="isTrue" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     <where>
       <foreach collection="oredCriteria" item="criteria" separator="or">
@@ -52,7 +53,7 @@
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     <where>
       <foreach collection="example.oredCriteria" item="criteria" separator="or">
@@ -86,15 +87,15 @@
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
-    history_id, seq, close_time, open_time, time_cost, equipment_no
+    history_id, seq, close_time, open_time, time_cost, equipment_no, is_true
   </sql>
   <select id="selectByExample" parameterType="com.js.kbt.model.MouldHistoryTimeExample" resultMap="BaseResultMap">
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     select
     <if test="distinct">
@@ -113,7 +114,7 @@
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     delete from mould_history_time
     <if test="_parameter != null">
@@ -124,20 +125,20 @@
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     insert into mould_history_time (history_id, seq, close_time, 
-      open_time, time_cost, equipment_no
-      )
+      open_time, time_cost, equipment_no, 
+      is_true)
     values (#{historyId,jdbcType=BIGINT}, #{seq,jdbcType=INTEGER}, #{closeTime,jdbcType=TIMESTAMP}, 
-      #{openTime,jdbcType=TIMESTAMP}, #{timeCost,jdbcType=INTEGER}, #{equipmentNo,jdbcType=VARCHAR}
-      )
+      #{openTime,jdbcType=TIMESTAMP}, #{timeCost,jdbcType=INTEGER}, #{equipmentNo,jdbcType=VARCHAR}, 
+      #{isTrue,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="com.js.kbt.model.MouldHistoryTime">
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     insert into mould_history_time
     <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -159,6 +160,9 @@
       <if test="equipmentNo != null">
         equipment_no,
       </if>
+      <if test="isTrue != null">
+        is_true,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="historyId != null">
@@ -179,13 +183,16 @@
       <if test="equipmentNo != null">
         #{equipmentNo,jdbcType=VARCHAR},
       </if>
+      <if test="isTrue != null">
+        #{isTrue,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.js.kbt.model.MouldHistoryTimeExample" resultType="java.lang.Long">
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     select count(*) from mould_history_time
     <if test="_parameter != null">
@@ -196,7 +203,7 @@
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     update mould_history_time
     <set>
@@ -218,6 +225,9 @@
       <if test="record.equipmentNo != null">
         equipment_no = #{record.equipmentNo,jdbcType=VARCHAR},
       </if>
+      <if test="record.isTrue != null">
+        is_true = #{record.isTrue,jdbcType=INTEGER},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -227,7 +237,7 @@
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
-      This element was generated on Thu Aug 22 16:38:14 CST 2019.
+      This element was generated on Fri Mar 20 18:04:50 CST 2020.
     -->
     update mould_history_time
     set history_id = #{record.historyId,jdbcType=BIGINT},
@@ -235,7 +245,8 @@
       close_time = #{record.closeTime,jdbcType=TIMESTAMP},
       open_time = #{record.openTime,jdbcType=TIMESTAMP},
       time_cost = #{record.timeCost,jdbcType=INTEGER},
-      equipment_no = #{record.equipmentNo,jdbcType=VARCHAR}
+      equipment_no = #{record.equipmentNo,jdbcType=VARCHAR},
+      is_true = #{record.isTrue,jdbcType=INTEGER}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>

+ 41 - 18
cloud-socket/src/com/js/kbt/model/MouldHistoryTime.java

@@ -6,39 +6,44 @@ public class MouldHistoryTime {
 
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column mould_history_time.history_id
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	private Long historyId;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column mould_history_time.seq
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	private Integer seq;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column mould_history_time.close_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	private Date closeTime;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column mould_history_time.open_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	private Date openTime;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column mould_history_time.time_cost
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	private Integer timeCost;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column mould_history_time.equipment_no
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	private String equipmentNo;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column mould_history_time.is_true
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
+	 */
+	private Integer isTrue;
 
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column mould_history_time.history_id
 	 * @return  the value of mould_history_time.history_id
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public Long getHistoryId() {
 		return historyId;
@@ -47,7 +52,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column mould_history_time.history_id
 	 * @param historyId  the value for mould_history_time.history_id
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setHistoryId(Long historyId) {
 		this.historyId = historyId;
@@ -56,7 +61,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column mould_history_time.seq
 	 * @return  the value of mould_history_time.seq
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public Integer getSeq() {
 		return seq;
@@ -65,7 +70,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column mould_history_time.seq
 	 * @param seq  the value for mould_history_time.seq
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setSeq(Integer seq) {
 		this.seq = seq;
@@ -74,7 +79,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column mould_history_time.close_time
 	 * @return  the value of mould_history_time.close_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public Date getCloseTime() {
 		return closeTime;
@@ -83,7 +88,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column mould_history_time.close_time
 	 * @param closeTime  the value for mould_history_time.close_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setCloseTime(Date closeTime) {
 		this.closeTime = closeTime;
@@ -92,7 +97,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column mould_history_time.open_time
 	 * @return  the value of mould_history_time.open_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public Date getOpenTime() {
 		return openTime;
@@ -101,7 +106,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column mould_history_time.open_time
 	 * @param openTime  the value for mould_history_time.open_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setOpenTime(Date openTime) {
 		this.openTime = openTime;
@@ -110,7 +115,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column mould_history_time.time_cost
 	 * @return  the value of mould_history_time.time_cost
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public Integer getTimeCost() {
 		return timeCost;
@@ -119,7 +124,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column mould_history_time.time_cost
 	 * @param timeCost  the value for mould_history_time.time_cost
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setTimeCost(Integer timeCost) {
 		this.timeCost = timeCost;
@@ -128,7 +133,7 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column mould_history_time.equipment_no
 	 * @return  the value of mould_history_time.equipment_no
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public String getEquipmentNo() {
 		return equipmentNo;
@@ -137,9 +142,27 @@ public class MouldHistoryTime {
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column mould_history_time.equipment_no
 	 * @param equipmentNo  the value for mould_history_time.equipment_no
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setEquipmentNo(String equipmentNo) {
 		this.equipmentNo = equipmentNo;
 	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column mould_history_time.is_true
+	 * @return  the value of mould_history_time.is_true
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
+	 */
+	public Integer getIsTrue() {
+		return isTrue;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column mould_history_time.is_true
+	 * @param isTrue  the value for mould_history_time.is_true
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
+	 */
+	public void setIsTrue(Integer isTrue) {
+		this.isTrue = isTrue;
+	}
 }

+ 76 - 16
cloud-socket/src/com/js/kbt/model/MouldHistoryTimeExample.java

@@ -7,23 +7,23 @@ import java.util.List;
 public class MouldHistoryTimeExample {
     /**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	protected String orderByClause;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	protected boolean distinct;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	protected List<Criteria> oredCriteria;
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public MouldHistoryTimeExample() {
 		oredCriteria = new ArrayList<Criteria>();
@@ -31,7 +31,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setOrderByClause(String orderByClause) {
 		this.orderByClause = orderByClause;
@@ -39,7 +39,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public String getOrderByClause() {
 		return orderByClause;
@@ -47,7 +47,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void setDistinct(boolean distinct) {
 		this.distinct = distinct;
@@ -55,7 +55,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public boolean isDistinct() {
 		return distinct;
@@ -63,7 +63,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public List<Criteria> getOredCriteria() {
 		return oredCriteria;
@@ -71,7 +71,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void or(Criteria criteria) {
 		oredCriteria.add(criteria);
@@ -79,7 +79,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public Criteria or() {
 		Criteria criteria = createCriteriaInternal();
@@ -89,7 +89,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public Criteria createCriteria() {
 		Criteria criteria = createCriteriaInternal();
@@ -101,7 +101,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	protected Criteria createCriteriaInternal() {
 		Criteria criteria = new Criteria();
@@ -110,7 +110,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This method was generated by MyBatis Generator. This method corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public void clear() {
 		oredCriteria.clear();
@@ -120,7 +120,7 @@ public class MouldHistoryTimeExample {
 
 	/**
 	 * This class was generated by MyBatis Generator. This class corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	protected abstract static class GeneratedCriteria {
 		protected List<Criterion> criteria;
@@ -532,11 +532,71 @@ public class MouldHistoryTimeExample {
 			addCriterion("equipment_no not between", value1, value2, "equipmentNo");
 			return (Criteria) this;
 		}
+
+		public Criteria andIsTrueIsNull() {
+			addCriterion("is_true is null");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueIsNotNull() {
+			addCriterion("is_true is not null");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueEqualTo(Integer value) {
+			addCriterion("is_true =", value, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueNotEqualTo(Integer value) {
+			addCriterion("is_true <>", value, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueGreaterThan(Integer value) {
+			addCriterion("is_true >", value, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueGreaterThanOrEqualTo(Integer value) {
+			addCriterion("is_true >=", value, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueLessThan(Integer value) {
+			addCriterion("is_true <", value, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueLessThanOrEqualTo(Integer value) {
+			addCriterion("is_true <=", value, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueIn(List<Integer> values) {
+			addCriterion("is_true in", values, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueNotIn(List<Integer> values) {
+			addCriterion("is_true not in", values, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueBetween(Integer value1, Integer value2) {
+			addCriterion("is_true between", value1, value2, "isTrue");
+			return (Criteria) this;
+		}
+
+		public Criteria andIsTrueNotBetween(Integer value1, Integer value2) {
+			addCriterion("is_true not between", value1, value2, "isTrue");
+			return (Criteria) this;
+		}
 	}
 
 	/**
 	 * This class was generated by MyBatis Generator. This class corresponds to the database table mould_history_time
-	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
+	 * @mbg.generated  Fri Mar 20 18:04:50 CST 2020
 	 */
 	public static class Criterion {
 		private String condition;

+ 180 - 32
cloud-socket/src/com/js/kbt/socket/UserHandler.java

@@ -1,25 +1,60 @@
 package com.js.kbt.socket;
 
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
 import com.alibaba.fastjson.JSONObject;
-import com.js.kbt.mapper.*;
-import com.js.kbt.model.*;
+import com.js.kbt.mapper.ChangeIpCommandMapper;
+import com.js.kbt.mapper.EquipmentSendCommandMapper;
+import com.js.kbt.mapper.LonLatRecordMapper;
+import com.js.kbt.mapper.MouldCycleRuntimeMapper;
+import com.js.kbt.mapper.MouldDownPacketMapper;
+import com.js.kbt.mapper.MouldHistoryMapper;
+import com.js.kbt.mapper.MouldHistoryTimeMapper;
+import com.js.kbt.mapper.MouldHodingMapper;
+import com.js.kbt.mapper.RecDataLogMapper;
+import com.js.kbt.mapper.SensorThresholdMapper;
+import com.js.kbt.mapper.TbFactoryMapper;
+import com.js.kbt.mapper.TbMouldEquipmentMapper;
+import com.js.kbt.mapper.TbMouldMapper;
+import com.js.kbt.mapper.TimeCalibrationRecordMapper;
+import com.js.kbt.model.ChangeIpCommand;
+import com.js.kbt.model.ChangeIpCommandExample;
+import com.js.kbt.model.LonLatRecord;
+import com.js.kbt.model.LonLatRecordExample;
+import com.js.kbt.model.MouldDownPacket;
+import com.js.kbt.model.MouldDownPacketExample;
+import com.js.kbt.model.MouldHistory;
+import com.js.kbt.model.MouldHistoryExample;
+import com.js.kbt.model.MouldHistoryTime;
+import com.js.kbt.model.MouldHistoryTimeExample;
+import com.js.kbt.model.RecDataLog;
+import com.js.kbt.model.TbMould;
+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 com.mysql.fabric.xmlrpc.base.Array;
+
+import edu.emory.mathcs.backport.java.util.concurrent.Executors;
+import edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
 import io.netty.handler.timeout.IdleState;
 import io.netty.handler.timeout.IdleStateEvent;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
 
 @Service("userHandler")
 public class UserHandler extends SimpleChannelInboundHandler<String> {
@@ -71,6 +106,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 	}
 
 	private String processMsg(String input) throws ParseException {
+		ScheduledExecutorService pool = Executors.newSingleThreadScheduledExecutor();
 		String ret = "FA AF 00 07 02 1e 78 1e 50 00 3C";
 		ret.replaceAll(" ", "");
 		logger.info("=====接收到======" + input);
@@ -104,7 +140,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			// 获取设备编码15-24
 			String deviceNumPart = input.substring(5 * 2, 25 * 2);
 			deviceNum = getStringFromHexStr(deviceNumPart);
-			System.out.println("设备No=" + deviceNum);
+			logger.info("设备No=" + deviceNum);
 			item.setEquipmentNo(deviceNum);
 			// 发送数据包
 			MouldDownPacketExample pExp = new MouldDownPacketExample();
@@ -116,7 +152,6 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 				sendMsg(packet.getPacketStr());
 				// 下发完就将数据删除(防止后续数据过大造成性能的影响)
 				mouldDownPacketMapper.deleteByPrimaryKey(packet.getId());
-				logger.info("判断是否开启或关闭已结束==>");
 			}
 			pExp.clear();
 			pExp.createCriteria().andEquipmentNoEqualTo(deviceNum).andPacketStrEqualTo("CLEAR_PROTOCOL");
@@ -215,10 +250,16 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			MouldHistoryExample mExp = new MouldHistoryExample();
 			mExp.setOrderByClause("id desc limit 1");
 			mExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo());
-			// 存入数据库
 			List<MouldHistory> newList = mouldHistoryMapper.selectByExample(mExp);
+			// 存入数据库
 			mouldHistoryMapper.insertSelective(item);
-			logger.info("添加数据完成了-----------》: " + item);
+			Integer differenceValue = 0;
+			//计算本次的运行次数和上次的差值
+			if(newList.size()==0){
+				differenceValue = item.getRunCnt();
+			}else{
+				differenceValue = item.getRunCnt() - newList.get(0).getRunCnt();
+			}
 			//发送清空次数和其他指定
 //			EquipmentSendCommandExample escExample = new EquipmentSendCommandExample();
 //			escExample.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andIsSendEqualTo(0);
@@ -232,7 +273,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 //						equipmentSendCommand.setSendTime(new Date());
 //						equipmentSendCommandMapper.updateByPrimaryKeySelective(equipmentSendCommand);
 //					}
-//					
+//
 //				}
 //			}
 			// 模具开合记录
@@ -242,12 +283,20 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			int end = input.length() - 4; // 最后2位 0xXX,0xXX ,是CRC校验位
 			logger.info("时间信息==" + input.substring(start * 2, end));
 			Integer thisOpenCounts = 0;
+			//用于接受上次最新的那一条开合数据
+			List<MouldHistoryTime> historyList = new ArrayList<>();
+			//用于接受第一包的开合时间与上次最新一包的开合时间差值
+			long openTimeDiff = 0L;
+			//用于接受第一包数据
+			MouldHistoryTime firstMouldHistoryTime = new MouldHistoryTime();
 			if (end - start * 2 >= 24) {// 时间最少6位,1位显示0x00,开合算两个时间,所以是6*2*2=24
 				// 本次运行周期内的开合模次数
 				int periodCnt = (end - start * 2) / 24;
 				thisOpenCounts = periodCnt;
 				logger.info("本次开合模次数==" + periodCnt);
 				long aHeadOpenTimeLongVal = 0L;
+				//用于接收判断是不是有包在当前包之后但已经发上来了,如16:11的开和数据先于16:10的数据先发上来
+				List<MouldHistoryTime> GreaterThanOpenTimeList = new ArrayList<>();
 				for (int pos = 0; pos < periodCnt; pos++) {
 					// 合模时间
 					MouldHistoryTime time = new MouldHistoryTime();
@@ -261,12 +310,18 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 					time.setOpenTime(openTime);
 					logger.info("第" + (pos + 1) + "包");
 					if (pos == 0) {
-						MouldHistoryTimeExample mtExp = new MouldHistoryTimeExample();
-						mtExp.setOrderByClause("open_time desc limit 1");
-						mtExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andOpenTimeLessThanOrEqualTo(openTime);
-						List<MouldHistoryTime> historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
+						MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
+						//查询当前包是否是之前丢的包,判断依据,看看有没有比当前开合日期更后的开合数据
+						mhtExp.setOrderByClause("open_time limit 1");
+						mhtExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andOpenTimeGreaterThanOrEqualTo(openTime).andIsTrueEqualTo(0);
+						GreaterThanOpenTimeList = mouldHistoryTimeMapper.selectByExample(mhtExp);
+						mhtExp.clear();
+						mhtExp.setOrderByClause("open_time desc limit 1");
+						mhtExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andOpenTimeLessThanOrEqualTo(openTime);
+						historyList = mouldHistoryTimeMapper.selectByExample(mhtExp);
 						if (historyList.size() > 0) {
-							time.setTimeCost((int) (openTime.getTime() - historyList.get(0).getOpenTime().getTime()));
+							openTimeDiff = openTime.getTime() - historyList.get(0).getOpenTime().getTime();
+							time.setTimeCost((int)openTimeDiff);
 						} else {
 							time.setTimeCost(0);
 						}
@@ -278,12 +333,30 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 					mouldHistoryTimeMapper.insertSelective(time);
 					// // 处理最后一包周期逻辑
 					aHeadOpenTimeLongVal = openTime.getTime();
-					// // if(pos==periodCnt-1){
-					// handleMouldCycleRuntimeLogic(openTime, item);
-					// // }
-					// logger.info("mouldHistoryTime数据添加完毕");
-					// logger.info("上一包数据的开合时间戳--" + aHeadOpenTimeLongVal);
+					if(pos==0){
+						firstMouldHistoryTime = time;
+					}
 				}
+				if(GreaterThanOpenTimeList.size()>0){
+					//当前数据为丢包重传的数据
+					MouldHistoryTime mouldHistoryTime = GreaterThanOpenTimeList.get(0);
+					mouldHistoryTime.setTimeCost((int) (mouldHistoryTime.getOpenTime().getTime() - aHeadOpenTimeLongVal));
+					MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
+					mhtExp.createCriteria().andHistoryIdEqualTo(mouldHistoryTime.getHistoryId()).andOpenTimeEqualTo(mouldHistoryTime.getOpenTime()).andEquipmentNoEqualTo(mouldHistoryTime.getEquipmentNo());
+					mouldHistoryTimeMapper.updateByExampleSelective(mouldHistoryTime, mhtExp);
+				}
+				//当前包为非丢包重传的数据
+				Integer lossPacketCount = differenceValue - thisOpenCounts;
+				if(lossPacketCount>0){
+					if(historyList.size()>0){
+						//本次第一包开合时间与上一包最新开合数据的开合时间差值超过一分钟则判断为丢包了
+						if(openTimeDiff>60000){
+							//此时丢包了,丢了lossPacketCount个包,如果小于0则是第二包或者是之前的丢包补上来了
+							examineTask(item.getEquipmentNo(),lossPacketCount,firstMouldHistoryTime,historyList.get(0),pool);
+						}
+					}
+				}
+
 			} else {
 				logger.info("本次开合模次数==0");
 			}
@@ -303,7 +376,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			MouldHistoryTimeExample mtExp = new MouldHistoryTimeExample();
 			mtExp.setOrderByClause("seq");
 			mtExp.createCriteria().andHistoryIdEqualTo(item.getId()).andTimeCostGreaterThan(0);
-			List<MouldHistoryTime> historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
+			historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
 			int avgTime = 0;
 			int totalTime = 0;
 			// if (historyList.size() == 1) {
@@ -467,7 +540,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 				logger.info("准备更新运行次数:");
 				TbMould tm = tbMouldMapper.selectByExample(tExp).get(0);
 				MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
-				//一次接受到数据,超过5次开合标记为运行状态
+				// 一次接受到数据,超过5次开合标记为运行状态
 				if (thisOpenCount > 5) {
 					tm.setState(item.getStatus());
 				} else {
@@ -489,7 +562,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 
 	/**
 	 * 低位在前的16进制解析
-	 * 
+	 *
 	 * @param rHex
 	 * @return
 	 */
@@ -661,6 +734,81 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 		ctx.writeAndFlush(bf);
 		// ctx.close();
 	}
+	//检查是否丢包,并插入丢包数据
+	/**
+	 * @param equipmentNo 云模合编号
+	 * @param loseCount 丢包数量
+	 * @param firstMouldHistoryTime 本次的第一条开合数据
+	 * @param lastEndMouldHistoryTime 上一包最后一条开合数据
+	 * @param pool 线程池
+	 */
+
+	public void examineTask(String equipmentNo,int loseCount,MouldHistoryTime firstMouldHistoryTime,MouldHistoryTime lastEndMouldHistoryTime,ScheduledExecutorService pool){
+		pool.schedule(new Runnable() {
+			@Override
+			public void run() {
+				logger.info("定时补充数据任务开始了,时间:"+new SimpleDateFormat("yy-MM-dd,HH:mm:ss").format(new Date()));
+				MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
+				mhtExp.createCriteria().andOpenTimeBetween(lastEndMouldHistoryTime.getOpenTime(), firstMouldHistoryTime.getOpenTime());
+				long count = mouldHistoryTimeMapper.countByExample(mhtExp);
+				if(count==loseCount){
+					return;
+				}else{
+					TbMouldEquipmentExample tExp = new TbMouldEquipmentExample();
+					tExp.createCriteria().andEquipmentNoEqualTo(equipmentNo);
+					List<TbMouldEquipment> equipments = tbMouldEquipmentMapper.selectByExample(tExp);
+					if(equipments.size()>0){
+						TbMouldExample tmExp = new TbMouldExample();
+						tmExp.createCriteria().andEquipmentIdEqualTo(equipments.get(0).getId());
+						List<TbMould> moulds = tbMouldMapper.selectByExample(tmExp);
+						MouldHistoryTime newMouldHistoryTime = new MouldHistoryTime();
+						if(moulds.size()>0){
+							//平均开合周期
+							int OcCycle = (int)moulds.get(0).getOcCycle().doubleValue()*1000;
+							long addPacketCount = loseCount-count;
+							logger.info("补包数->"+addPacketCount);
+							long openTime = 0L;
+							long closeTime = 0L;
+							if(addPacketCount<loseCount){
+								mhtExp.clear();
+								mhtExp.setOrderByClause("open_time desc limit 1");
+								mhtExp.createCriteria().andOpenTimeGreaterThanOrEqualTo(lastEndMouldHistoryTime.getOpenTime()).andOpenTimeLessThan(firstMouldHistoryTime.getOpenTime());
+								List<MouldHistoryTime> newMouldHistoryTimes = mouldHistoryTimeMapper.selectByExample(mhtExp);
+								newMouldHistoryTime = newMouldHistoryTimes.get(0);
+								openTime = newMouldHistoryTime.getOpenTime().getTime();
+								closeTime = newMouldHistoryTime.getCloseTime().getTime();
+							}else{
+								newMouldHistoryTime = lastEndMouldHistoryTime;
+								openTime = newMouldHistoryTime.getOpenTime().getTime();
+								closeTime = newMouldHistoryTime.getCloseTime().getTime();
+							}
+							for(int i=0;i<addPacketCount;i++){
+								MouldHistoryTime m = new MouldHistoryTime();
+								m.setCloseTime(new Date(closeTime+OcCycle));
+								m.setOpenTime(new Date(openTime+OcCycle));
+								m.setIsTrue(1);
+								m.setEquipmentNo(equipmentNo);
+								m.setHistoryId(newMouldHistoryTime.getHistoryId());
+								m.setSeq(i+1);
+								m.setTimeCost(OcCycle);
+								mouldHistoryTimeMapper.insertSelective(m);
+								openTime = m.getOpenTime().getTime();
+								closeTime = m.getCloseTime().getTime();
+								if(i==addPacketCount-1){
+									MouldHistoryTime mouldHistoryTime = firstMouldHistoryTime;
+									mouldHistoryTime.setTimeCost((int) (mouldHistoryTime.getOpenTime().getTime() - m.getOpenTime().getTime()));
+									MouldHistoryTimeExample exp = new MouldHistoryTimeExample();
+									exp.createCriteria().andHistoryIdEqualTo(mouldHistoryTime.getHistoryId()).andOpenTimeEqualTo(mouldHistoryTime.getOpenTime()).andEquipmentNoEqualTo(mouldHistoryTime.getEquipmentNo());
+									mouldHistoryTimeMapper.updateByExampleSelective(mouldHistoryTime, exp);
+								}
+							}
+						}
+					}
+				}
+			}
+		}, 2, TimeUnit.HOURS);
+
+	}
 
 	/**
 	 * channel被激活时调用
@@ -753,7 +901,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 
 	/**
 	 * 普通字符串转16进制字符串
-	 * 
+	 *
 	 * @param str
 	 * @return
 	 */