|
@@ -96,7 +96,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
// 校准时间
|
|
|
timeCalibration();
|
|
|
//验证是否需要切换ip
|
|
|
- sendChangeIp();
|
|
|
+// sendChangeIp();
|
|
|
System.out.println("收到===" + arg1 + "\n");
|
|
|
String equipmentNo = processMsg(arg1);
|
|
|
// 以下是配置下行数据
|
|
@@ -234,17 +234,19 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
// 开模时间
|
|
|
Date openTime = parseDate(input, start, pos, 6);
|
|
|
time.setOpenTime(openTime);
|
|
|
+ logger.info("第"+(pos+1)+"包");
|
|
|
if (pos == 0) {
|
|
|
time.setTimeCost(0);
|
|
|
} else {
|
|
|
+ logger.info("本包开合时间戳--" + openTime.getTime());
|
|
|
logger.info("本次开合周期--" + (openTime.getTime() - aHeadOpenTimeLongVal));
|
|
|
time.setTimeCost((int) (openTime.getTime() - aHeadOpenTimeLongVal));
|
|
|
}
|
|
|
mouldHistoryTimeMapper.insertSelective(time);
|
|
|
// 处理最后一包周期逻辑
|
|
|
- if(pos==periodCnt-1){
|
|
|
+// if(pos==periodCnt-1){
|
|
|
handleMouldCycleRuntimeLogic(openTime, item);
|
|
|
- }
|
|
|
+// }
|
|
|
logger.info("mouldHistoryTime数据添加完毕");
|
|
|
aHeadOpenTimeLongVal = openTime.getTime();
|
|
|
logger.info("上一包数据的开合时间戳--" + aHeadOpenTimeLongVal);
|
|
@@ -253,22 +255,21 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
logger.info("本次开合模次数==0");
|
|
|
}
|
|
|
// 统计该模盒的平均开合周期
|
|
|
- MouldHistoryExample exp = new MouldHistoryExample();
|
|
|
- exp.setOrderByClause("id");
|
|
|
- exp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andRunCntEqualTo(item.getRunCnt());
|
|
|
+// MouldHistoryExample exp = new MouldHistoryExample();
|
|
|
+// exp.setOrderByClause("id");
|
|
|
+// exp.createCriteria().andEquipmentNoEqualTo(item.getEquipmentNo()).andRunCntEqualTo(item.getRunCnt());
|
|
|
// List<MouldHistoryTime> list =
|
|
|
// mouldHistoryTimeMapper.selectByEquipmentNoAndThanZero(item.getEquipmentNo());
|
|
|
- List<MouldHistory> list = mouldHistoryMapper.selectByExample(exp);
|
|
|
- List<Long> historyIds = new ArrayList<>();
|
|
|
- historyIds.add(-1L);
|
|
|
- for (MouldHistory mouldHistory : list) {
|
|
|
- historyIds.add(mouldHistory.getId());
|
|
|
- }
|
|
|
+// List<MouldHistory> list = mouldHistoryMapper.selectByExample(exp);
|
|
|
+// List<Long> historyIds = new ArrayList<>();
|
|
|
+// historyIds.add(-1L);
|
|
|
+// for (MouldHistory mouldHistory : list) {
|
|
|
+// historyIds.add(mouldHistory.getId());
|
|
|
+// }
|
|
|
MouldHistoryTimeExample mtExp = new MouldHistoryTimeExample();
|
|
|
mtExp.setOrderByClause("seq");
|
|
|
- mtExp.createCriteria().andHistoryIdIn(historyIds).andTimeCostGreaterThan(0);
|
|
|
+ mtExp.createCriteria().andHistoryIdEqualTo(item.getId()).andTimeCostGreaterThan(0);
|
|
|
List<MouldHistoryTime> historyList = mouldHistoryTimeMapper.selectByExample(mtExp);
|
|
|
-
|
|
|
int avgTime = 0;
|
|
|
int totalTime = 0;
|
|
|
// if (historyList.size() == 1) {
|
|
@@ -285,6 +286,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
// } else {
|
|
|
if (historyList.size() > 1) {
|
|
|
for (MouldHistoryTime mouldHistoryTime : historyList) {
|
|
|
+ logger.info("totalTime" + totalTime);
|
|
|
totalTime += mouldHistoryTime.getTimeCost();
|
|
|
}
|
|
|
logger.info("totalTime" + totalTime);
|
|
@@ -490,8 +492,9 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
private void handleMouldCycleRuntimeLogic(Date openTime, MouldHistory item) throws ParseException {
|
|
|
System.out.println("开始handleMouldCycleRuntimeLogic逻辑开合时间"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(openTime));
|
|
|
MouldCycleRuntime mcr = new MouldCycleRuntime();
|
|
|
- Integer hours = openTime.getHours();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ mcr.setDateStr(sdf.format(openTime));
|
|
|
+ Integer hours = openTime.getHours();
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:");
|
|
|
int housTime = openTime.getHours() - 1;
|
|
|
openTime.setHours(housTime);
|
|
@@ -506,7 +509,6 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
|
|
|
if (list.size() > 0) {
|
|
|
MouldHistory mouldHistory = mouldHistoryMapper.selectByPrimaryKey(list.get(0).getHistoryId());
|
|
|
logger.info("本次运行次数: " + item.getRunCnt()+" 上一小时的运行次数:"+mouldHistory.getRunCnt()+" 上一小时的historyId:"+mouldHistory.getId());
|
|
|
- mcr.setDateStr(sdf.format(openTime));
|
|
|
mcr.setEquipmentNo(item.getEquipmentNo());
|
|
|
mcr.setRuntime(item.getRunCnt() - mouldHistory.getRunCnt());
|
|
|
if (hours == 0) {
|