Ver Fonte

注释掉补包逻辑

wutt há 5 anos atrás
pai
commit
bdfcf7bb21
1 ficheiros alterados com 100 adições e 100 exclusões
  1. 100 100
      cloud-socket/src/com/js/kbt/socket/UserHandler.java

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

@@ -107,7 +107,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 	}
 
 	private String processMsg(String input) throws ParseException {
-		ScheduledExecutorService pool = Executors.newSingleThreadScheduledExecutor();
+//		ScheduledExecutorService pool = Executors.newSingleThreadScheduledExecutor();
 		String ret = "FA AF 00 07 02 1e 78 1e 50 00 3C";
 		ret.replaceAll(" ", "");
 		logger.info("=====接收到======" + input);
@@ -289,7 +289,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 			//用于接受第一包的开合时间与上次最新一包的开合时间差值
 			long openTimeDiff = 0L;
 			//用于接受第一包数据
-			MouldHistoryTime firstMouldHistoryTime = new MouldHistoryTime();
+//			MouldHistoryTime firstMouldHistoryTime = new MouldHistoryTime();
 			if (end - start * 2 >= 24) {// 时间最少6位,1位显示0x00,开合算两个时间,所以是6*2*2=24
 				// 本次运行周期内的开合模次数
 				int periodCnt = (end - start * 2) / 24;
@@ -297,7 +297,7 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 				logger.info("本次开合模次数==" + periodCnt);
 				long aHeadOpenTimeLongVal = 0L;
 				//用于接收判断是不是有包在当前包之后但已经发上来了,如16:11的开和数据先于16:10的数据先发上来
-				List<MouldHistoryTime> GreaterThanOpenTimeList = new ArrayList<>();
+//				List<MouldHistoryTime> GreaterThanOpenTimeList = new ArrayList<>();
 				for (int pos = 0; pos < periodCnt; pos++) {
 					// 合模时间
 					MouldHistoryTime time = new MouldHistoryTime();
@@ -314,10 +314,10 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 					if (pos == 0) {
 						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 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);
 						//小于当前开合时间的最新的一包开合数据
@@ -335,32 +335,32 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 					mouldHistoryTimeMapper.insertSelective(time);
 					// // 处理最后一包周期逻辑
 					aHeadOpenTimeLongVal = openTime.getTime();
-					if(pos==0){
-						firstMouldHistoryTime = time;
-					}
-				}
-				if(GreaterThanOpenTimeList.size()>0){
-					//当前数据为丢包重传的数据
-					logger.info("此包为之前丢的包...需要修改之前的第一包周期");
-					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){
-					logger.info("本次丢包数---->"+lossPacketCount+"_上一包开合数据数:"+historyList.size()+"_两包之间的时间差值:"+openTimeDiff);
-					if(historyList.size()>0){
-						//本次第一包开合时间与上一包最新开合数据的开合时间差值超过一分钟则判断为丢包了
-						if(openTimeDiff>60000){
-							logger.info("触发补充数据任务,时间:"+new SimpleDateFormat("yy-MM-dd,HH:mm:ss").format(new Date()));
-							//此时丢包了,丢了lossPacketCount个包,如果小于0则是第二包或者是之前的丢包补上来了
-							examineTask(item.getEquipmentNo(),lossPacketCount,firstMouldHistoryTime,historyList.get(0),pool);
-						}
-					}
+//					if(pos==0){
+//						firstMouldHistoryTime = time;
+//					}
 				}
+//				if(GreaterThanOpenTimeList.size()>0){
+//					//当前数据为丢包重传的数据
+//					logger.info("此包为之前丢的包...需要修改之前的第一包周期");
+//					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){
+//					logger.info("本次丢包数---->"+lossPacketCount+"_上一包开合数据数:"+historyList.size()+"_两包之间的时间差值:"+openTimeDiff);
+//					if(historyList.size()>0){
+//						//本次第一包开合时间与上一包最新开合数据的开合时间差值超过一分钟则判断为丢包了
+//						if(openTimeDiff>60000){
+//							logger.info("触发补充数据任务,时间:"+new SimpleDateFormat("yy-MM-dd,HH:mm:ss").format(new Date()));
+//							//此时丢包了,丢了lossPacketCount个包,如果小于0则是第二包或者是之前的丢包补上来了
+//							examineTask(item.getEquipmentNo(),lossPacketCount,firstMouldHistoryTime,historyList.get(0),pool);
+//						}
+//					}
+//				}
 
 			} else {
 				logger.info("本次开合模次数==0");
@@ -748,74 +748,74 @@ public class UserHandler extends SimpleChannelInboundHandler<String> {
 	 * @param pool 线程池
 	 */
 
-	public void examineTask(String equipmentNo,int loseCount,MouldHistoryTime firstMouldHistoryTime,MouldHistoryTime lastEndMouldHistoryTime,ScheduledExecutorService pool){
-		pool.schedule(new Runnable() {
-			@Override
-			public void run() {
-				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss");
-				logger.info("定时补充数据任务开始了,时间:"+sdf.format(new Date()));
-				MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
-				mhtExp.createCriteria().andOpenTimeGreaterThan(lastEndMouldHistoryTime.getOpenTime()).andOpenTimeLessThan(firstMouldHistoryTime.getOpenTime());
-				long count = mouldHistoryTimeMapper.countByExample(mhtExp);
-				logger.info(sdf.format(lastEndMouldHistoryTime.getOpenTime())+"--"+sdf.format(firstMouldHistoryTime.getOpenTime())+"时间段内丢包时间段上来了"+count+"条数据");
-				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);
-
-	}
+//	public void examineTask(String equipmentNo,int loseCount,MouldHistoryTime firstMouldHistoryTime,MouldHistoryTime lastEndMouldHistoryTime,ScheduledExecutorService pool){
+//		pool.schedule(new Runnable() {
+//			@Override
+//			public void run() {
+//				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss");
+//				logger.info("定时补充数据任务开始了,时间:"+sdf.format(new Date()));
+//				MouldHistoryTimeExample mhtExp = new MouldHistoryTimeExample();
+//				mhtExp.createCriteria().andOpenTimeGreaterThan(lastEndMouldHistoryTime.getOpenTime()).andOpenTimeLessThan(firstMouldHistoryTime.getOpenTime());
+//				long count = mouldHistoryTimeMapper.countByExample(mhtExp);
+//				logger.info(sdf.format(lastEndMouldHistoryTime.getOpenTime())+"--"+sdf.format(firstMouldHistoryTime.getOpenTime())+"时间段内丢包时间段上来了"+count+"条数据");
+//				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被激活时调用