瀏覽代碼

动液面采集,无效数据处理。入库时记录入库时间

chenwen 1 年之前
父節點
當前提交
438b9c48e7

+ 9 - 9
src/main/java/com/hb/proj/gather/protocol/ZlA11MsgDecoder.java

@@ -24,19 +24,19 @@ public class ZlA11MsgDecoder extends ByteToMessageDecoder {
 	protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
 		
 		String hexmsg=ByteBufUtil.hexDump(byteBuf);
+		int beginIndex = byteBuf.readerIndex();
+		int byteCount=byteBuf.readableBytes();
+		ByteBuf outByteBuf=null;
 		
 		logger.debug("ZlA11MsgDecoder 解码前数据:{}", hexmsg);
 		
-		if(byteBuf.readableBytes()<2) {
+		if(byteCount<2) {
+			return;
+		}
+		if(byteCount>2 && !hexmsg.startsWith("0103")) { //定义为乱流,舍弃
+			byteBuf.readerIndex(beginIndex+byteCount);
 			return;
 		}
-		
-		int beginIndex = byteBuf.readerIndex();
-		
-		int byteCount=byteBuf.readableBytes();
-		
-		
-		ByteBuf outByteBuf=null;
 		
 		if(byteCount==2&&(!hexmsg.startsWith("0103"))) { //心跳
 			byteBuf.readerIndex(beginIndex+byteCount);
@@ -59,7 +59,7 @@ public class ZlA11MsgDecoder extends ByteToMessageDecoder {
 		}
 		
 		if(outByteBuf!=null) {
-			outByteBuf.retain();
+			outByteBuf.retain();  //避免引用计数为0,后面的处理器无法使用解码后的数据
 			out.add(outByteBuf);
 		}
 	

+ 2 - 2
src/main/java/com/hb/proj/gather/rep/GatherDataRepService.java

@@ -122,8 +122,8 @@ public class GatherDataRepService {
 	 */
 	public void save(LiquidPO  liquidPO) {
 		String sql="""
-				insert into tzl_gather_data_liquid(well_id,test_time,liquid_datas,hoop_datas,sound_speed_dev,liquid_depth_dev,casing_press_dev) 
-				values(?,?,?,?,?,?,?)
+				insert into tzl_gather_data_liquid(well_id,test_time,liquid_datas,hoop_datas,sound_speed_dev,liquid_depth_dev,casing_press_dev,create_time,del_if) 
+				values(?,?,?,?,?,?,?,now(),false)
 				""";
 		dao.exeUpdate(sql, liquidPO.getWellId(),liquidPO.getTestTime(),listNum2Str(liquidPO.getLiquidDatas()),listNum2Str(liquidPO.getHoopDatas()),
 				liquidPO.getSoundSpeedDev(),liquidPO.getLiquidDepthDev(),liquidPO.getCasingPressDev());