|
@@ -4,10 +4,14 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import com.hb.proj.allconfig.BusinessException;
|
|
|
+import com.hb.proj.analysis.service.ProduceParamService;
|
|
|
import com.hb.proj.model.LiquidPO;
|
|
|
import com.hb.proj.model.LiquidVO;
|
|
|
import com.hb.xframework.dao.core.SpringJdbcDAO;
|
|
@@ -19,6 +23,8 @@ public class LiquidService {
|
|
|
@Autowired
|
|
|
private SpringJdbcDAO dao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProduceParamService produceParamService;
|
|
|
|
|
|
/**
|
|
|
* 分页查询指定井的动液面数据 目前不用del_if过滤
|
|
@@ -34,9 +40,7 @@ public class LiquidService {
|
|
|
select w.well_name,data_id,test_time,liquid_depth,compute_mode,sound_speed_dev,liquid_depth_dev,casing_press_dev,
|
|
|
battery_voltage,sound_speed_factor,sound_speed_calc,sound_speed,
|
|
|
|
|
|
- (select sound_speed_factor from tzl_gather_data_liquid d2 where d2.well_id=d.well_id and d2.del_if=false
|
|
|
- and d2.compute_mode='sound_speed' and d2.test_time between date_sub(d.test_time,interval 3 month )
|
|
|
- and d.test_time order by d2.test_time desc limit 1) pre_sound_speed_factor
|
|
|
+ liquid_depth_static,liquid_depth_static_convert,liquid_depth_convert,static_calc_if
|
|
|
|
|
|
from tzl_gather_data_liquid d
|
|
|
left join tzl_well w on d.well_id=w.well_id
|
|
@@ -46,6 +50,41 @@ public class LiquidService {
|
|
|
return dao.queryForPagedData(sql, pageNo, pageSize, LiquidVO.class, wellId,startTime,endTime);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得动液面单个记录明细数据
|
|
|
+ * @param dataId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public LiquidPO getDtl(String dataId) {
|
|
|
+ return dao.queryForPojo("select * from tzl_gather_data_liquid where data_id=?", LiquidPO.class, dataId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得动液面单个记录明细数据(含音速法相关数据)
|
|
|
+ * @param dataId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public LiquidPO getHadSound(String dataId) {
|
|
|
+ String sql="""
|
|
|
+ select data_id,well_id,test_time,liquid_depth,sound_speed,sound_speed_factor,sound_interval,
|
|
|
+ compute_mode,sound_speed_dev,sound_speed_calc,liquid_depth_dev,casing_press_dev,liquid_depth_static,
|
|
|
+ liquid_depth_static_convert,liquid_depth_convert,static_calc_if
|
|
|
+ from tzl_gather_data_liquid
|
|
|
+ where data_id=?
|
|
|
+ """;
|
|
|
+ return dao.queryForPojo(sql, LiquidPO.class, dataId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 逻辑删除动液面记录
|
|
|
+ * @param dataId
|
|
|
+ */
|
|
|
+ public void delete(String dataId) {
|
|
|
+ dao.exeUpdate("update tzl_gather_data_liquid set del_if=true where data_id=?", dataId);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存收到计算结果
|
|
|
* @param liquid
|
|
@@ -68,8 +107,9 @@ public class LiquidService {
|
|
|
args.addAll(Arrays.asList(liquid.getHoopStartPos(),liquid.getHoopEndPos(),liquid.getAvgLengthPipe(),liquid.getHoopCount(),liquid.getSoundSpeedCalc()));
|
|
|
}
|
|
|
else if(liquid.getComputeMode().equals(LiquidPO.MODE_SOUND_SPEED)) {
|
|
|
- sql+=",sound_speed=?,sound_speed_factor=?";
|
|
|
+ sql+=",sound_speed=?,sound_speed_calc=?,sound_speed_factor=?";
|
|
|
args.add(liquid.getSoundSpeed());
|
|
|
+ args.add(liquid.getSoundSpeed()); //音速法计算时,输入音速作为校正音速
|
|
|
args.add(liquid.getSoundSpeedFactor());
|
|
|
}
|
|
|
else if(liquid.getComputeMode().equals(LiquidPO.MODE_SOUND_MARK)) {
|
|
@@ -85,22 +125,125 @@ public class LiquidService {
|
|
|
dao.exeUpdate(sql, args.toArray());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * 获得动液面单个记录明细数据
|
|
|
+ * 标记为静液面测算记录
|
|
|
* @param dataId
|
|
|
- * @return
|
|
|
*/
|
|
|
- public LiquidPO getDtl(String dataId) {
|
|
|
- return dao.queryForPojo("select * from tzl_gather_data_liquid where data_id=?", LiquidPO.class, dataId);
|
|
|
+ public void saveStaticCalcTag(String dataId) {
|
|
|
+ dao.exeUpdate("update tzl_gather_data_liquid set static_calc_if=true where data_id=?", dataId);
|
|
|
+
|
|
|
+ //标记后要进行静液面相关数据同步
|
|
|
+ LiquidPO liquid=getHadSound(dataId);
|
|
|
+ if(liquid==null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ liquid.setStaticCalcIf(true);
|
|
|
+ updateStaticLiquid(liquid);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2023.10.10
|
|
|
+ * 校正液面深度更新时(手动计算后,用音速法)---继承k系数进行默认校正深度、校正音速计算
|
|
|
+ * 仅限于当前液面之后的记录,直到下个用音速法计算的记录前,且校正液面深度无值
|
|
|
+ * 公式:
|
|
|
+ * 默认校正深度=液面深度(设备采集值)*k(本记录之前最新的k系数) 【后期有更新的k系数也不再重复计算】
|
|
|
+ * 默认校正音速=被继承记录输入音速
|
|
|
+ * @param liquid
|
|
|
+ * @return 参与同步更新的记录id
|
|
|
+ */
|
|
|
+ public Set<String> addDefDepthForCorrect(LiquidPO liquid) {
|
|
|
+ if(!liquid.getComputeMode().equals(LiquidPO.MODE_SOUND_SPEED)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql="""
|
|
|
+ select min(test_time) from tzl_gather_data_liquid
|
|
|
+ where well_id=? and test_time>? and compute_mode=?
|
|
|
+ """;
|
|
|
+
|
|
|
+ LiquidPO endLiquid=dao.queryForPojo(sql, LiquidPO.class, liquid.getWellId(),liquid.getTestTime(),LiquidPO.MODE_SOUND_SPEED);
|
|
|
+ Date endTime=endLiquid!=null && endLiquid.getTestTime()!=null?endLiquid.getTestTime():new Date();
|
|
|
+
|
|
|
+ //参与更新记录的id
|
|
|
+ sql="""
|
|
|
+ select data_id,'1' tag from tzl_gather_data_liquid
|
|
|
+ where well_id=? and liquid_depth is null
|
|
|
+ and test_time>? and test_time<?
|
|
|
+ """;
|
|
|
+ Map<String,Object> dataIdMap=dao.queryForMapping(sql, "data_id", "tag", liquid.getWellId(),liquid.getTestTime(),endTime);
|
|
|
+
|
|
|
+ if(dataIdMap==null || dataIdMap.size()==0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ sql="""
|
|
|
+ update tzl_gather_data_liquid set liquid_depth=liquid_depth_dev*?,sound_speed_calc=?
|
|
|
+ where well_id=? and liquid_depth is null
|
|
|
+ and test_time>?
|
|
|
+ and test_time<?
|
|
|
+ """;
|
|
|
+ dao.exeUpdate(sql, liquid.getSoundSpeedFactor(),liquid.getSoundSpeed(), liquid.getWellId(),liquid.getTestTime(),endTime);
|
|
|
+
|
|
|
+ return dataIdMap.keySet();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 逻辑删除动液面记录
|
|
|
- * @param dataId
|
|
|
+ * 2023.10.10
|
|
|
+ * 校正液面深度更新时(手动计算后,不限计算方法)---更新当前及继承记录的折算液面深度、静液面深度、折算静深度
|
|
|
+ * 若当前记录没有用过静液面测算,则只同步更新当前记录折算液面深度
|
|
|
+ * 若当前记录用过过静液面测算,则更新当前记录折算液面深度,同时更新当前液面之后的记录的静液面深度、折算静深度,直到下个使用过静液面测算的记录前
|
|
|
+ * 公式: 静液面深度=校正液面深度
|
|
|
+ * 折算静深度=折算液面深度
|
|
|
+ * @param liquid
|
|
|
*/
|
|
|
- public void delete(String dataId) {
|
|
|
- dao.exeUpdate("update tzl_gather_data_liquid set del_if=true where data_id=?", dataId);
|
|
|
+ public void updateConvertAndStatic(LiquidPO liquid) {
|
|
|
+
|
|
|
+ //根据新的校正液面深度计算新的折算动液面深度
|
|
|
+ Double newConvertLiquid=LiquidCalculator.calcConvertLiquidDepth(liquid, produceParamService.getLastMeasureBefore(liquid.getWellId(),liquid.getTestTime()));
|
|
|
+ if(newConvertLiquid==null) {
|
|
|
+ throw new BusinessException("更新折算液面深度失败,请检测相关参数设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新当前记录的折算液面深度
|
|
|
+ String sql="""
|
|
|
+ update tzl_gather_data_liquid set liquid_depth_convert=?
|
|
|
+ where data_id=?
|
|
|
+ """;
|
|
|
+ dao.exeUpdate(sql, newConvertLiquid,liquid.getDataId());
|
|
|
+
|
|
|
+
|
|
|
+ if(!liquid.isStaticCalcIf()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ liquid.setLiquidDepthConvert(newConvertLiquid);
|
|
|
+ updateStaticLiquid(liquid);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当前是静液面测算记录,同步本记录和继承该记录的 静液面深度、折算静深度
|
|
|
+ * @param liquid
|
|
|
+ */
|
|
|
+ public void updateStaticLiquid(LiquidPO liquid) {
|
|
|
+ String sql="""
|
|
|
+ select min(test_time) from tzl_gather_data_liquid
|
|
|
+ where well_id=? and test_time>? and static_calc_if=true
|
|
|
+ """;
|
|
|
+
|
|
|
+ LiquidPO endLiquid=dao.queryForPojo(sql, LiquidPO.class, liquid.getWellId(),liquid.getTestTime());
|
|
|
+ Date endTime=endLiquid!=null && endLiquid.getTestTime()!=null?endLiquid.getTestTime():new Date();
|
|
|
+
|
|
|
+ sql="""
|
|
|
+ update tzl_gather_data_liquid set liquid_depth_static=?,liquid_depth_static_convert=?
|
|
|
+ where well_id=? and test_time>=? and test_time<?
|
|
|
+ """;
|
|
|
+ dao.exeUpdate(sql, liquid.getLiquidDepth(),liquid.getLiquidDepthConvert(), liquid.getWellId(),liquid.getTestTime(),endTime);
|
|
|
}
|
|
|
}
|