|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|