|
@@ -1,25 +1,60 @@
|
|
package com.js.kbt.socket;
|
|
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.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.ByteBuf;
|
|
import io.netty.buffer.Unpooled;
|
|
import io.netty.buffer.Unpooled;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
import io.netty.handler.timeout.IdleState;
|
|
import io.netty.handler.timeout.IdleState;
|
|
import io.netty.handler.timeout.IdleStateEvent;
|
|
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")
|
|
@Service("userHandler")
|
|
public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
@@ -71,6 +106,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
}
|
|
}
|
|
|
|
|
|
private String processMsg(String input) throws ParseException {
|
|
private String processMsg(String input) throws ParseException {
|
|
|
|
+ ScheduledExecutorService pool = Executors.newSingleThreadScheduledExecutor();
|
|
String ret = "FA AF 00 07 02 1e 78 1e 50 00 3C";
|
|
String ret = "FA AF 00 07 02 1e 78 1e 50 00 3C";
|
|
ret.replaceAll(" ", "");
|
|
ret.replaceAll(" ", "");
|
|
logger.info("=====接收到======" + input);
|
|
logger.info("=====接收到======" + input);
|
|
@@ -104,7 +140,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
// 获取设备编码15-24
|
|
// 获取设备编码15-24
|
|
String deviceNumPart = input.substring(5 * 2, 25 * 2);
|
|
String deviceNumPart = input.substring(5 * 2, 25 * 2);
|
|
deviceNum = getStringFromHexStr(deviceNumPart);
|
|
deviceNum = getStringFromHexStr(deviceNumPart);
|
|
- System.out.println("设备No=" + deviceNum);
|
|
|
|
|
|
+ logger.info("设备No=" + deviceNum);
|
|
item.setEquipmentNo(deviceNum);
|
|
item.setEquipmentNo(deviceNum);
|
|
// 发送数据包
|
|
// 发送数据包
|
|
MouldDownPacketExample pExp = new MouldDownPacketExample();
|
|
MouldDownPacketExample pExp = new MouldDownPacketExample();
|
|
@@ -116,7 +152,6 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
sendMsg(packet.getPacketStr());
|
|
sendMsg(packet.getPacketStr());
|
|
// 下发完就将数据删除(防止后续数据过大造成性能的影响)
|
|
// 下发完就将数据删除(防止后续数据过大造成性能的影响)
|
|
mouldDownPacketMapper.deleteByPrimaryKey(packet.getId());
|
|
mouldDownPacketMapper.deleteByPrimaryKey(packet.getId());
|
|
- logger.info("判断是否开启或关闭已结束==>");
|
|
|
|
}
|
|
}
|
|
pExp.clear();
|
|
pExp.clear();
|
|
pExp.createCriteria().andEquipmentNoEqualTo(deviceNum).andPacketStrEqualTo("CLEAR_PROTOCOL");
|
|
pExp.createCriteria().andEquipmentNoEqualTo(deviceNum).andPacketStrEqualTo("CLEAR_PROTOCOL");
|
|
@@ -215,10 +250,16 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
MouldHistoryExample mExp = new MouldHistoryExample();
|
|
MouldHistoryExample mExp = new MouldHistoryExample();
|
|
mExp.setOrderByClause("id desc limit 1");
|
|
mExp.setOrderByClause("id desc limit 1");
|
|
mExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo());
|
|
mExp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo());
|
|
- // 存入数据库
|
|
|
|
List<MouldHistory> newList = mouldHistoryMapper.selectByExample(mExp);
|
|
List<MouldHistory> newList = mouldHistoryMapper.selectByExample(mExp);
|
|
|
|
+ // 存入数据库
|
|
mouldHistoryMapper.insertSelective(item);
|
|
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();
|
|
// EquipmentSendCommandExample escExample = new EquipmentSendCommandExample();
|
|
// escExample.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andIsSendEqualTo(0);
|
|
// escExample.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andIsSendEqualTo(0);
|
|
@@ -232,7 +273,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
// equipmentSendCommand.setSendTime(new Date());
|
|
// equipmentSendCommand.setSendTime(new Date());
|
|
// equipmentSendCommandMapper.updateByPrimaryKeySelective(equipmentSendCommand);
|
|
// equipmentSendCommandMapper.updateByPrimaryKeySelective(equipmentSendCommand);
|
|
// }
|
|
// }
|
|
-//
|
|
|
|
|
|
+//
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// 模具开合记录
|
|
// 模具开合记录
|
|
@@ -242,12 +283,20 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
int end = input.length() - 4; // 最后2位 0xXX,0xXX ,是CRC校验位
|
|
int end = input.length() - 4; // 最后2位 0xXX,0xXX ,是CRC校验位
|
|
logger.info("时间信息==" + input.substring(start * 2, end));
|
|
logger.info("时间信息==" + input.substring(start * 2, end));
|
|
Integer thisOpenCounts = 0;
|
|
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
|
|
if (end - start * 2 >= 24) {// 时间最少6位,1位显示0x00,开合算两个时间,所以是6*2*2=24
|
|
// 本次运行周期内的开合模次数
|
|
// 本次运行周期内的开合模次数
|
|
int periodCnt = (end - start * 2) / 24;
|
|
int periodCnt = (end - start * 2) / 24;
|
|
thisOpenCounts = periodCnt;
|
|
thisOpenCounts = periodCnt;
|
|
logger.info("本次开合模次数==" + periodCnt);
|
|
logger.info("本次开合模次数==" + periodCnt);
|
|
long aHeadOpenTimeLongVal = 0L;
|
|
long aHeadOpenTimeLongVal = 0L;
|
|
|
|
+ //用于接收判断是不是有包在当前包之后但已经发上来了,如16:11的开和数据先于16:10的数据先发上来
|
|
|
|
+ List<MouldHistoryTime> GreaterThanOpenTimeList = new ArrayList<>();
|
|
for (int pos = 0; pos < periodCnt; pos++) {
|
|
for (int pos = 0; pos < periodCnt; pos++) {
|
|
// 合模时间
|
|
// 合模时间
|
|
MouldHistoryTime time = new MouldHistoryTime();
|
|
MouldHistoryTime time = new MouldHistoryTime();
|
|
@@ -261,12 +310,18 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
time.setOpenTime(openTime);
|
|
time.setOpenTime(openTime);
|
|
logger.info("第" + (pos + 1) + "包");
|
|
logger.info("第" + (pos + 1) + "包");
|
|
if (pos == 0) {
|
|
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) {
|
|
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 {
|
|
} else {
|
|
time.setTimeCost(0);
|
|
time.setTimeCost(0);
|
|
}
|
|
}
|
|
@@ -278,12 +333,30 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
mouldHistoryTimeMapper.insertSelective(time);
|
|
mouldHistoryTimeMapper.insertSelective(time);
|
|
// // 处理最后一包周期逻辑
|
|
// // 处理最后一包周期逻辑
|
|
aHeadOpenTimeLongVal = openTime.getTime();
|
|
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 {
|
|
} else {
|
|
logger.info("本次开合模次数==0");
|
|
logger.info("本次开合模次数==0");
|
|
}
|
|
}
|
|
@@ -303,7 +376,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
MouldHistoryTimeExample mtExp = new MouldHistoryTimeExample();
|
|
MouldHistoryTimeExample mtExp = new MouldHistoryTimeExample();
|
|
mtExp.setOrderByClause("seq");
|
|
mtExp.setOrderByClause("seq");
|
|
mtExp.createCriteria().andHistoryIdEqualTo(item.getId()).andTimeCostGreaterThan(0);
|
|
mtExp.createCriteria().andHistoryIdEqualTo(item.getId()).andTimeCostGreaterThan(0);
|
|
- List<MouldHistoryTime> historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
|
|
|
|
|
|
+ historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
|
|
int avgTime = 0;
|
|
int avgTime = 0;
|
|
int totalTime = 0;
|
|
int totalTime = 0;
|
|
// if (historyList.size() == 1) {
|
|
// if (historyList.size() == 1) {
|
|
@@ -467,7 +540,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
logger.info("准备更新运行次数:");
|
|
logger.info("准备更新运行次数:");
|
|
TbMould tm = tbMouldMapper.selectByExample(tExp).get(0);
|
|
TbMould tm = tbMouldMapper.selectByExample(tExp).get(0);
|
|
MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
|
|
MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
|
|
- //一次接受到数据,超过5次开合标记为运行状态
|
|
|
|
|
|
+ // 一次接受到数据,超过5次开合标记为运行状态
|
|
if (thisOpenCount > 5) {
|
|
if (thisOpenCount > 5) {
|
|
tm.setState(item.getStatus());
|
|
tm.setState(item.getStatus());
|
|
} else {
|
|
} else {
|
|
@@ -489,7 +562,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 低位在前的16进制解析
|
|
* 低位在前的16进制解析
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param rHex
|
|
* @param rHex
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -661,6 +734,81 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
ctx.writeAndFlush(bf);
|
|
ctx.writeAndFlush(bf);
|
|
// ctx.close();
|
|
// 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被激活时调用
|
|
* channel被激活时调用
|
|
@@ -753,7 +901,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 普通字符串转16进制字符串
|
|
* 普通字符串转16进制字符串
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param str
|
|
* @param str
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|