瀏覽代碼

动液面采集入库时增加对衍生参数的计算处理

chenwen 1 年之前
父節點
當前提交
6e62f38814

+ 34 - 0
src/main/java/com/hb/proj/gather/model/LiquidVO.java

@@ -0,0 +1,34 @@
+package com.hb.proj.gather.model;
+
+import lombok.Data;
+
+@Data
+public class LiquidVO {
+
+	private String wellId; 
+	
+	/**
+	 * 音速(手动计算音速法,输入值,作为音速法时的:校正音速)
+	 */
+	private Double soundSpeed;
+	
+	/**
+	 * 音速法  k系数
+	 */
+	private Double soundSpeedFactor;
+	
+	/**
+	 * 计算音速(校正音速,接箍法、音标法)
+	 */
+	private Double soundSpeedCalc;
+	
+	/**
+	 * 手动计算液面深度(校正深度。默认=设备液面深度*最新的k系数)
+	 */
+	private Double liquidDepth;
+	
+	/**
+	 * 折算动液面深度 单位 m
+	 */
+	private Double liquidDepthConvert;
+}

+ 81 - 0
src/main/java/com/hb/proj/gather/model/WellMeasurePO.java

@@ -0,0 +1,81 @@
+package com.hb.proj.gather.model;
+
+import java.util.Date;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+@Data
+public class WellMeasurePO {
+	
+	private String measureId;
+	
+	@NotBlank(message="缺少井号")
+	private String wellId;
+	
+	private Date createTime;
+	
+	private Date modifyTime;
+
+	private Boolean delIf;
+	
+	
+	private String modifyBy;
+	
+	private String createBy;
+	
+	
+	/**
+	 * 含水率
+	 */
+	private Double waterRatio;
+	
+	/**
+	 * 混液密度
+	 */
+	private Double mixLiquidDensity; 
+	
+	/**
+	 * 原油密度
+	 */
+	private Double crudeOilDensity; 
+	
+	/**
+	 * 水密度
+	 */
+	private Double waterDensity;
+	
+	/**
+	 * 弹性系数
+	 */
+	private Double elasticCoeff;
+	
+	/**
+	 * 重力加速度
+	 */
+	private Double gravity;  
+	
+	/**
+	 * 井下压缩系数
+	 */
+	private Double  wellBtmCompCoe;
+	
+	/**
+	 * 地表压缩系数=1/wellBtmCompCoe
+	 */
+	private Double surfaceCompCoe;
+	
+	/**
+	 * 测量液量
+	 */
+	private Double measureLiquidYield; 
+	
+	/**
+	 *  计量液量
+	 */
+	private Double meteredLiquidYield; 
+	
+	
+	
+	
+}

+ 50 - 0
src/main/java/com/hb/proj/gather/process/LiquidCalculator.java

@@ -0,0 +1,50 @@
+package com.hb.proj.gather.process;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hb.proj.gather.model.WellMeasurePO;
+
+
+/**
+ * 动液面相关数据计算
+ * @author cwen
+ *
+ */
+public class LiquidCalculator {
+	
+	private static final Logger logger=LoggerFactory.getLogger(LiquidCalculator.class);
+
+	/**
+	 * 计算折算动液面深度
+	 * 折算液面深度( m)=校正动液面深度(m)-(套压(动液面采集值MPa)/(混液密度(kg/l)*重力加速度(m/s2)))*1000
+	 * @param liquidDepth  校正动液面深度
+	 * @param casingPreDev 动液面采集套压
+	 * @param measure 测量数据对象
+	 * @return
+	 */
+	public static Double calcConvertLiquidDepth(Double liquidDepth,Double casingPreDev,WellMeasurePO measure) {
+		
+		if(liquidDepth==null || casingPreDev==null || measure==null) {
+			return null;
+		}
+		
+		if(measure==null || measure.getMixLiquidDensity()==null || measure.getGravity()==null) {
+			return null;
+		}
+		
+		try {
+			double rst=0;
+			rst=(casingPreDev*1000)/(measure.getMixLiquidDensity()*measure.getGravity());
+			rst=liquidDepth-rst;
+			rst=Math.round(rst*100)*0.01;
+			
+			return rst;
+		}
+		catch(Exception e) {
+			logger.error("折算动液面深度计算出错:{}",e.getMessage());
+			return null;
+		}
+		
+	}
+}

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

@@ -1,6 +1,7 @@
 package com.hb.proj.gather.rep;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
@@ -10,7 +11,10 @@ import org.springframework.stereotype.Service;
 import com.hb.proj.gather.model.AlarmLogVO;
 import com.hb.proj.gather.model.DiagramPO;
 import com.hb.proj.gather.model.LiquidPO;
+import com.hb.proj.gather.model.LiquidVO;
 import com.hb.proj.gather.model.SingleInsertPO;
+import com.hb.proj.gather.model.WellMeasurePO;
+import com.hb.proj.gather.process.LiquidCalculator;
 import com.hb.xframework.dao.core.SpringJdbcDAO;
 
 /**
@@ -24,6 +28,8 @@ public class GatherDataRepService {
 	@Autowired
 	private SpringJdbcDAO  dao;
 	
+	private  final String MODE_SOUND_SPEED="sound_speed";  //音速法
+	
 	/**
 	 * 报警日志记录入库
 	 * @param almlogs
@@ -118,15 +124,45 @@ public class GatherDataRepService {
 	
 	/**
 	 * 动液面采集数据入库
+	 * 入库前绑定扩展字段默认值(静液面深度、折算静深度、折算液面深度、校正深度、校正音速)2023.10.18
 	 * @param liquid
 	 */
 	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,create_time,del_if,battery_voltage) 
-				values(?,?,?,?,?,?,?,now(),false,?)
+				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,battery_voltage,
+				sound_speed_calc,liquid_depth,liquid_depth_convert,liquid_depth_static,liquid_depth_static_convert) 
+				values(?,?,?,?,?,?,?,now(),false,?,?,?,?,?,?)
 				""";
-		dao.exeUpdate(sql, liquidPO.getWellId(),liquidPO.getTestTime(),listNum2Str(liquidPO.getLiquidDatas()),listNum2Str(liquidPO.getHoopDatas()),
+		
+		
+		
+		List<Object> args=Arrays.asList(liquidPO.getWellId(),liquidPO.getTestTime(),listNum2Str(liquidPO.getLiquidDatas()),listNum2Str(liquidPO.getHoopDatas()),
 				liquidPO.getSoundSpeedDev(),liquidPO.getLiquidDepthDev(),liquidPO.getCasingPressDev(),liquidPO.getBatteryVoltage());
+		
+		
+		
+		LiquidVO lastSSLiquid=getLastLiquidCalcViaSoundSpeed(liquidPO.getWellId());
+		LiquidVO lastStaticLiquid=getLastLiquidStaticCalc(liquidPO.getWellId());
+		
+		//校正音速
+		Double	val=lastSSLiquid!=null && lastSSLiquid.getSoundSpeed()!=null?lastSSLiquid.getSoundSpeed():null;
+		args.add(val);
+				
+		//校正液面深度
+		val=liquidPO.getLiquidDepthDev()*(lastSSLiquid!=null && lastSSLiquid.getSoundSpeedFactor()!=null?lastSSLiquid.getSoundSpeedFactor():1);
+		args.add(val);
+		
+		//折算动液面深度
+		val=LiquidCalculator.calcConvertLiquidDepth(val, liquidPO.getCasingPressDev(), getLastMeasure(liquidPO.getWellId()));
+		args.add(val);
+		
+		//静液面深度
+		args.add(lastStaticLiquid!=null?lastStaticLiquid.getLiquidDepth():null);
+		
+		//折算静深度
+		args.add(lastStaticLiquid!=null?lastStaticLiquid.getLiquidDepthConvert():null);
+		
+		dao.exeUpdate(sql, args.toArray());
 	}
 	
 	private <T extends Number> String listNum2Str(List<T> datas) {
@@ -137,4 +173,54 @@ public class GatherDataRepService {
 		return strb.substring(1);
 	}
 	
+	
+	/**
+	 * 查找最新的音速法计算过的动液面记录2023.10.18
+	 * @param wellId
+	 * @return
+	 */
+	private LiquidVO getLastLiquidCalcViaSoundSpeed(String wellId) {
+		
+		String sql="""
+				select sound_speed_factor,sound_speed 
+				from tzl_gather_data_liquid 
+				where well_id=? and test_time<now() and compute_mode=?
+				order by test_time desc limit 1
+				""";
+		
+		return dao.queryForPojo(sql, LiquidVO.class,wellId,MODE_SOUND_SPEED);
+		
+	}
+	
+	/**
+	 * 查找最新的测算过静液面的动液面记录2023.10.18
+	 * @param wellId
+	 * @return
+	 */
+	private LiquidVO getLastLiquidStaticCalc(String wellId) {
+		String sql="""
+				select liquid_depth,liquid_depth_convert 
+				from tzl_gather_data_liquid 
+				where well_id=? and test_time<now() and static_calc_if=true
+				order by test_time desc limit 1
+				""";
+		
+		return dao.queryForPojo(sql, LiquidVO.class,wellId);
+	}
+	
+	
+	/**
+	 * 查找最新的测量数据2023.10.18
+	 * @param wellId
+	 * @return
+	 */
+	public WellMeasurePO  getLastMeasure(String wellId) {
+		String sql="""
+				select * from tzl_well_measure 
+				where del_if=false and well_id=? and create_time<now()
+				order by create_time desc limit 1
+				""";
+		return dao.queryForPojo(sql, WellMeasurePO.class, wellId);
+	}
+	
 }