Bläddra i källkod

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 år sedan
förälder
incheckning
84dfe5931c

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

@@ -90,7 +90,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_name equipmentName,
         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,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY open_time DESC LIMIT 1) lastopentime
+        tbmp.lng,tbmp.lat,tbmp.stage,(SELECT indate FROM `mould_history` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime
         ,(SELECT battery  FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
         (SELECT temperature  FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
         from
@@ -139,7 +139,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,tbm.oc_cycle oc_cycle,tbm.creator_id creator_id,tbmp.equipment_name equipmentName,
         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,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY open_time DESC LIMIT 1) lastopentime,
+        tbmp.lng,tbmp.lat,tbmp.stage,(SELECT indate FROM `mould_history` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime,
         (SELECT battery  FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
         (SELECT temperature  FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
         from

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

@@ -49,4 +49,6 @@ public interface MouldHistoryTimeMapper {
 	 * @mbg.generated  Thu Aug 22 16:38:14 CST 2019
 	 */
 	int updateByExample(@Param("record") MouldHistoryTime record, @Param("example") MouldHistoryTimeExample example);
+
+	List<MouldHistoryTime> selectByEquipmentNoAndThanZero(@Param("equipmentNo") String equipmentNo);
 }

+ 4 - 0
cloud-socket/src/com/js/kbt/mapper/MouldHistoryTimeMapper.xml

@@ -240,4 +240,8 @@
       <include refid="Update_By_Example_Where_Clause" />
     </if>
   </update>
+  <select id="selectByEquipmentNoAndThanZero" resultMap="BaseResultMap">
+  select  history_id, seq, close_time, open_time, time_cost, equipment_no
+  from mould_history_time where equipment_no = #{equipmentNo} and time_cost &gt; 0
+  </select>
 </mapper>

+ 19 - 6
cloud-socket/src/com/js/kbt/socket/UserHandler.java

@@ -23,6 +23,7 @@ import com.js.kbt.mapper.TimeCalibrationRecordMapper;
 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.TbMould;
@@ -126,8 +127,9 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 		item.setWifiBbsid(input.substring(52 * 2, 58 * 2));
 		String temp = "0x" + input.substring(58 * 2, 59 * 2);
 		System.out.println(temp);
-		int i = Integer.decode(temp);
+		int i = Integer.decode(temp)-40;
 		System.out.println(i);
+		logger.info("温度-----------》: " + i);
 		item.setTemperature(i);
 		item.setBattery(Integer.decode("0x" + input.substring(59 * 2, 60 * 2)));
 		item.setSig2g(Integer.decode("0x" + input.substring(60 * 2, 61 * 2)));
@@ -150,7 +152,11 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 		}
 		String crcStr = input.substring(input.length() - 4);
 		item.setCrcCode("" + reverseParseHex(crcStr));
+		//找寻上一条最新记录
+		MouldHistoryExample mExp = new MouldHistoryExample();
+		mExp.createCriteria().andEquipmentNoEqualTo(value)
 		// 存入数据库
+		mouldHistoryMapper.selectByExample(example);
 		mouldHistoryMapper.insertSelective(item);
 		logger.info("添加数据完成了-----------》: " + item);
 		// 模具开合记录
@@ -183,22 +189,29 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			logger.info("本次开合模次数==0");
 		}
 		// 统计该模盒的平均开合周期
-		MouldHistoryTimeExample exp = new MouldHistoryTimeExample();
-		exp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andTimeCostGreaterThanOrEqualTo(0);
-		List<MouldHistoryTime> list = mouldHistoryTimeMapper.selectByExample(exp);
+		MouldHistoryExample exp = new MouldHistoryExample();
+		exp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andRunCntEqualTo(item.getRunCnt());
+//		List<MouldHistoryTime> list = mouldHistoryTimeMapper.selectByEquipmentNoAndThanZero(item.getEquipmentNo());
+		List<MouldHistory> list = mouldHistoryMapper.selectByExample(exp);
 		int avgTime = 0;
 		int totalTime = 0;
-		for (MouldHistoryTime t : list) {
+		if(list.size()==1){
+			//证明盒子动了,找寻上一条记录
+			
+		}
+		for (MouldHistory t : list) {
 				//删选掉负值的数据
+//			logger.info("第i条数据开合模周期耗时-------------》》"+t.getTimeCost());
 				totalTime += t.getTimeCost();
-			
 		}
+//		logger.info("开合模周期总耗时次数==》"+totalTime);
 		if (list.size() == 0) {
 			avgTime = 0;
 		} else {
 				avgTime = totalTime / list.size();
 			
 		}
+//		logger.info("开合模平均周期耗时次数==》"+avgTime);
 		handleModLogic(item, avgTime);
 		// 判断预留字节的
 		if ("02".equals(mobilePart)) {

+ 2 - 2
target/classes/main/resources/mapper/MouldMapper.xml

@@ -90,7 +90,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_name equipmentName,
         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,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY open_time DESC LIMIT 1) lastopentime
+        tbmp.lng,tbmp.lat,tbmp.stage,(SELECT indate FROM `mould_history` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime
         ,(SELECT battery  FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
         (SELECT temperature  FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
         from
@@ -139,7 +139,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,tbm.oc_cycle oc_cycle,tbm.creator_id creator_id,tbmp.equipment_name equipmentName,
         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,(SELECT open_time FROM `mould_history_time` WHERE equipment_no=equipmentNo ORDER BY open_time DESC LIMIT 1) lastopentime,
+        tbmp.lng,tbmp.lat,tbmp.stage,(SELECT indate FROM `mould_history` WHERE equipment_no=equipmentNo ORDER BY indate DESC LIMIT 1) lastopentime,
         (SELECT battery  FROM `mould_history` WHERE equipmentNo = equipment_no ORDER BY indate DESC LIMIT 1) hill_number,
         (SELECT temperature  FROM `mould_history` WHERE equipment_no = equipmentNo ORDER BY indate DESC LIMIT 1) temperature
         from