浏览代码

动液面采集处理计算深度差时,先根据井斜数据转为垂直深度

chenwen 1 年之前
父节点
当前提交
d7545ff114

+ 16 - 2
src/main/java/com/hb/proj/gather/model/LiquidVO.java → src/main/java/com/hb/proj/gather/model/LiquidExtraVO.java

@@ -1,9 +1,13 @@
 package com.hb.proj.gather.model;
 
 import lombok.Data;
-
+/**
+ * 动液面衍生数据
+ * @author cwen
+ *
+ */
 @Data
-public class LiquidVO {
+public class LiquidExtraVO {
 
 	private String wellId; 
 	
@@ -42,4 +46,14 @@ public class LiquidVO {
 	 * 折算静液面深度 单位 m=最后一次静液测试时的折算静液面深度=最后一次静液测试时的折算动液面深度
 	 */
 	private Double liquidDepthStaticConvert;
+	
+	/**
+	 * 深度差m【折算动液面深度-折算静液面深度】
+	 */
+	private Double depthDiff;
+	
+	/**
+	 * 流动压差KPa【压力(KPa)=(深度差(m)*液体密度(Kg/L)*重力加速度(m/s2))】
+	 */
+	private Double flowPressDiff;
 }

+ 5 - 1
src/main/java/com/hb/proj/gather/model/LiquidPO.java

@@ -2,7 +2,11 @@ package com.hb.proj.gather.model;
 
 import java.util.ArrayList;
 import java.util.List;
-
+/**
+ * 动液面采集数据
+ * @author cwen
+ *
+ */
 public class LiquidPO {
 
 	private String wellId; 

+ 27 - 0
src/main/java/com/hb/proj/gather/model/WellDeviationPO.java

@@ -0,0 +1,27 @@
+package com.hb.proj.gather.model;
+
+import lombok.Data;
+
+@Data
+public class WellDeviationPO {
+
+	/**
+	 * 测量井深 m
+	 */
+	private Double measureDepth;
+	
+	/**
+	 * 井斜角
+	 */
+	private Double deviateAngle;
+	
+	/**
+	 * 方位角
+	 */
+	private Double azimuth;
+	
+	/**
+	 * 垂直井深 m(采用最小曲率法,根据测量井深及对应的井斜角、方位角计算出来的值)
+	 */
+	private Double verticalDepth;
+}

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

@@ -2,7 +2,6 @@ package com.hb.proj.gather.model;
 
 import java.util.Date;
 
-import jakarta.validation.constraints.NotBlank;
 import lombok.Data;
 
 @Data
@@ -10,7 +9,6 @@ public class WellMeasurePO {
 	
 	private String measureId;
 	
-	@NotBlank(message="缺少井号")
 	private String wellId;
 	
 	private Date createTime;

+ 86 - 2
src/main/java/com/hb/proj/gather/process/DataTransRepLiquidTask.java

@@ -1,10 +1,15 @@
 package com.hb.proj.gather.process;
 
+import java.util.List;
+
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.hb.proj.gather.model.LiquidExtraVO;
 import com.hb.proj.gather.model.LiquidPO;
+import com.hb.proj.gather.model.WellDeviationPO;
+import com.hb.proj.gather.model.WellMeasurePO;
 import com.hb.proj.gather.rep.GatherDataRepService;
 import com.hb.proj.gather.rep.WellConfigService;
 import com.hb.xframework.util.ApplicationContextUtils;
@@ -22,6 +27,7 @@ public class DataTransRepLiquidTask implements Runnable {
 	@Override
 	public void run() {
 		logger.info("开始动液面数据转换处理{}",po.getDevSerial());
+		long t1=System.currentTimeMillis();
 		try {
 			WellConfigService configService=ApplicationContextUtils.getBean("wellConfigService", WellConfigService.class);
 			String wellId=configService.getWellIdByDev(po.getDevSerial());
@@ -32,8 +38,11 @@ public class DataTransRepLiquidTask implements Runnable {
 			po.setWellId(wellId);
 			
 			GatherDataRepService repService=ApplicationContextUtils.getBean("gatherDataRepService", GatherDataRepService.class);
-			repService.save(po);
-			logger.info("动液面数据入库完成{}",po.getDevSerial());
+			
+			LiquidExtraVO  liquidExtra=calcExtra(po,repService);
+			
+			repService.save(po,liquidExtra);
+			logger.info("动液面数据入库完成{},耗时:{}",po.getDevSerial(),System.currentTimeMillis()-t1);
 		}
 		catch(Exception e) {
 			e.printStackTrace();
@@ -41,5 +50,80 @@ public class DataTransRepLiquidTask implements Runnable {
 		}
 
 	}
+	
+	/**
+	 * 动液面衍生数据计算
+	 * @param liquid
+	 * @param repService
+	 */
+	private LiquidExtraVO calcExtra(LiquidPO liquid,GatherDataRepService repService) {
+		LiquidExtraVO lastSSLiquid=repService.getLastLiquidCalcViaSoundSpeed(liquid.getWellId());
+		LiquidExtraVO lastStaticLiquid=repService.getLastLiquidStaticCalc(liquid.getWellId());
+		WellMeasurePO lastMeasure=repService.getLastMeasure(liquid.getWellId());
+		
+		//当前动液面数据对应的衍生数据对象
+		LiquidExtraVO curExtra=new LiquidExtraVO();
+		curExtra.setWellId(liquid.getWellId());
+		
+		//校正音速=最新一次手动音速法计算时设置的音速
+		Double	val=lastSSLiquid!=null && lastSSLiquid.getSoundSpeed()!=null?lastSSLiquid.getSoundSpeed():null;
+		curExtra.setSoundSpeedCalc(val);
+		
+		//校正液面深度=设备采集深度*最新手动音速法计算时设置的k系数
+		val=liquid.getLiquidDepthDev()*(lastSSLiquid!=null && lastSSLiquid.getSoundSpeedFactor()!=null?lastSSLiquid.getSoundSpeedFactor():1);
+		curExtra.setLiquidDepth(val);
+		
+		//折算动液面深度
+		val=LiquidCalculator.calcConvertLiquidDepth(curExtra.getLiquidDepth(), liquid.getCasingPressDev(), lastMeasure);
+		curExtra.setLiquidDepthConvert(val);
+		
+		//静液面深度=最近一次静液测算时的静液面深度=测算时的校正液面深度;
+		curExtra.setLiquidDepthStatic(lastStaticLiquid!=null?lastStaticLiquid.getLiquidDepthStatic():null);
+				
+		//折算静深度=最近一次静液测算的值=测算时的折算液面深度
+		curExtra.setLiquidDepthStaticConvert(lastStaticLiquid!=null?lastStaticLiquid.getLiquidDepthStaticConvert():null);
+		
+		//深度压差=折算动液面深度-折算静液面深度=折算动液面深度-最近一次静液测算折算静液面深度=折算动液面深度-最近一次静液测算时折算动液面深度
+		Double depth1=calcVDepth(curExtra.getLiquidDepthConvert(),liquid.getWellId(),repService);
+		Double depth2=calcVDepth(curExtra.getLiquidDepthStaticConvert(),liquid.getWellId(),repService);
+		
+		curExtra.setDepthDiff(LiquidCalculator.calcDepthDiff(depth1,depth2));
+		
+		//流动压差
+		curExtra.setFlowPressDiff(LiquidCalculator.calcFlowPreeDiff(curExtra.getDepthDiff(), lastMeasure));
+		
+		return curExtra;
+	}
+	
+	/**
+	 * 通过井斜数据插值计算指定值垂直深度
+	 * @param injectDepth
+	 * @param wellId
+	 * @param repService
+	 * @return
+	 */
+	private Double calcVDepth(Double injectDepth,String wellId,GatherDataRepService repService) {
+		Double vDepth=injectDepth;
+		List<WellDeviationPO> wds=repService.loadNearDeviation(wellId, injectDepth);
+		if(wds!=null && wds.size()==1) { //等于或超过最大井斜数据
+			if(injectDepth.doubleValue()==wds.get(0).getMeasureDepth().doubleValue()) { //等于最大斜深,直接取其垂深
+				vDepth=wds.get(0).getVerticalDepth();
+			}
+			else { 
+				wds=repService.loadNearDeviation(wellId, wds.get(0).getMeasureDepth().doubleValue()-10);  //超过最大斜深,取最后两个斜深记录
+				vDepth=DeviationCalculator.calc(wds.get(0), wds.get(1), injectDepth);
+			}
+		}
+		else if(wds!=null && wds.size()==2) { //找到前后插值
+			if(injectDepth.doubleValue()==wds.get(0).getMeasureDepth().doubleValue()) { //等于前一斜深,直接取其垂深
+				vDepth=wds.get(0).getVerticalDepth();
+			}
+			else { 
+				wds.get(1).setMeasureDepth(injectDepth); //根据插值公式要求,后一邻近值的测量深度替换为被插值
+				vDepth=DeviationCalculator.calc(wds.get(0), wds.get(1));
+			}
+		}
+		return vDepth;
+	}
 
 }

+ 88 - 0
src/main/java/com/hb/proj/gather/process/DeviationCalculator.java

@@ -0,0 +1,88 @@
+package com.hb.proj.gather.process;
+
+import com.hb.proj.gather.model.WellDeviationPO;
+
+/**
+ * 井斜数据计算工具
+ * @author cwen
+ *
+ */
+public class DeviationCalculator {
+	
+	private static final double PI=3.1415926;
+	
+	private static final double PJ=180;
+
+	/**
+	 * 垂深计算
+	 * 如果当前点与前一点井斜角差为0,则当前点垂深=当前点测量深度-前一点测量深度+前一点计算所得垂深
+	 * 如果当前点与前一点井斜角差不为0,则当前点垂深=
+	 * 测量深度差/(井斜角差)*(sin(当前井斜角*PI/180)-sin(前一井斜角*PI/180))*(180/pi)+前一点计算所得垂深
+	 * @param pre
+	 * @param cur
+	 */
+	public static double calc(WellDeviationPO pre,WellDeviationPO cur) {
+		double diffAngle=cur.getDeviateAngle()-pre.getDeviateAngle();
+		double verticalDepth=0;
+		if(diffAngle==0) {
+			verticalDepth=cur.getMeasureDepth()-pre.getMeasureDepth()+pre.getVerticalDepth();
+		}
+		else {
+			
+			double sin1=Math.sin(cur.getDeviateAngle()*PI/PJ);
+			double sin2=Math.sin(pre.getDeviateAngle()*PI/PJ);
+			
+			double diffMeasureDepth=cur.getMeasureDepth()-pre.getMeasureDepth();
+			verticalDepth=diffMeasureDepth/diffAngle;
+			
+			verticalDepth=verticalDepth*(sin1-sin2)*(PJ/PI)+pre.getVerticalDepth();
+		}
+		
+		return verticalDepth;
+		
+	}
+	
+	/**
+	 * 垂深计算(超过最大斜深)
+	 * @param pre
+	 * @param cur
+	 * @param depthGLMax
+	 * @return
+	 */
+	public static double calc(WellDeviationPO pre,WellDeviationPO cur,Double depthGLMax) {
+		double diffAngle=cur.getDeviateAngle()-pre.getDeviateAngle();
+		double verticalDepth=0;
+		if(diffAngle==0) {
+			verticalDepth=depthGLMax-cur.getMeasureDepth()+cur.getVerticalDepth();
+		}
+		else {
+			
+			double sin1=Math.sin(cur.getDeviateAngle()*PI/PJ);
+			double sin2=Math.sin(pre.getDeviateAngle()*PI/PJ);
+			
+			double diffMeasureDepth=depthGLMax-cur.getMeasureDepth();
+			verticalDepth=diffMeasureDepth/diffAngle;
+			
+			verticalDepth=verticalDepth*(sin1-sin2)*(PJ/PI)+cur.getVerticalDepth();
+		}
+		
+		return verticalDepth;
+		
+	}
+	
+	
+	public static void main(String[] args) {
+		WellDeviationPO pre=new WellDeviationPO();
+		pre.setDeviateAngle(0.0);
+		pre.setMeasureDepth(0.0);
+		pre.setVerticalDepth(0.0);
+		
+		WellDeviationPO cur=new WellDeviationPO();
+		cur.setDeviateAngle(0.5);
+		cur.setMeasureDepth(30.0);
+		cur.setVerticalDepth(null);
+		
+		calc(pre,cur);
+		
+	}
+}