|
@@ -8,6 +8,7 @@ import com.cn.tianji.common.Result;
|
|
|
import com.cn.tianji.dto.ConditionDeterminationDto;
|
|
|
import com.cn.tianji.entity.*;
|
|
|
import com.cn.tianji.service.*;
|
|
|
+import com.cn.tianji.util.CommonUtil;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -15,12 +16,14 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -65,6 +68,16 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
private TorqueWarnLogService torqueWarnLogService;
|
|
|
|
|
|
@Resource
|
|
|
+ private YjWohWarnValueService wohWarnValueService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private YjTorqueWarnValueService torqueWarnValueService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private YjPumpingWarnValueService pumpingWarnValueService;
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
private RedisUtil redisUtil;
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
@@ -76,11 +89,11 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
@Override
|
|
|
public Result<?> workingConditionCalculation(String workingConditionCalculationLogId) {
|
|
|
WorkingConditionCalculationLog workingConditionCalculationLogModel = workingConditionCalculationLogService.getById(workingConditionCalculationLogId);
|
|
|
- String jh= workingConditionCalculationLogModel.getJh();
|
|
|
+ String jh = workingConditionCalculationLogModel.getJh();
|
|
|
String startTime = workingConditionCalculationLogModel.getStartTime();
|
|
|
String endTime = workingConditionCalculationLogModel.getEndTime();
|
|
|
String calculateType = workingConditionCalculationLogModel.getCalculateType();
|
|
|
- String isDelRedis=workingConditionCalculationLogModel.getIsDelRedis();
|
|
|
+ String isDelRedis = workingConditionCalculationLogModel.getIsDelRedis();
|
|
|
Result<Object> res = new Result<>();
|
|
|
switch (calculateType) {
|
|
|
case "0":
|
|
@@ -161,10 +174,10 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
ConditionDeterminationDto conditionDeterminationDto = conditionIdentificationService.conditionDetermination(calList, one);
|
|
|
nowPoint.setMotion(conditionDeterminationDto.getMotion());
|
|
|
nowPoint.setOperatingMode(conditionDeterminationDto.getOperatingMode());
|
|
|
- log.info("更新点位时间:{};工况:{},动作:{}",nowPoint.getTime(),nowPoint.getMotion(),nowPoint.getOperatingMode());
|
|
|
+ log.info("更新点位时间:{};工况:{},动作:{}", nowPoint.getTime(), nowPoint.getMotion(), nowPoint.getOperatingMode());
|
|
|
QueryWrapper<WellDrilling> wrapper1 = new QueryWrapper<>();
|
|
|
wrapper1.apply("TO_DATE(SUBSTR(TIME, 1, 19), 'yyyy-MM-dd HH24:mi:ss') = to_date({0},'yyyy-mm-dd hh24:mi:ss')", nowPoint.getTime());
|
|
|
- wellDrillingService.updateByTimeOrcale(jhTableName,conditionDeterminationDto.getMotion(), conditionDeterminationDto.getOperatingMode(), wrapper1);
|
|
|
+ wellDrillingService.updateByTimeOrcale(jhTableName, conditionDeterminationDto.getMotion(), conditionDeterminationDto.getOperatingMode(), wrapper1);
|
|
|
if ("1".equals(workingConditionCalculationLogModel.getIsCalculate())) {
|
|
|
workingConditionCalculationLogModel.setIsCalculate("2");
|
|
|
}
|
|
@@ -218,12 +231,12 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
log.info("钩载预警计算,当前点井深{};时间:{}", nowPoint.getBitdepth(), nowPoint.getTime());
|
|
|
if ("起下钻".equals(operatingMode)) {
|
|
|
redisHasKey = jh + "_hook_load_recalculate";
|
|
|
- drillingOutHookLoadService.hookLoadWarnCalculate(nowPoint, redisHasKey, warnValue, rodWeight);
|
|
|
+
|
|
|
} else {
|
|
|
redisHasKey = jh + "_drilling_hook_load_recalculate";
|
|
|
drillingHookloadService.hookLoadWarnCalculate(nowPoint, redisHasKey, warnValue);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
log.info("钩载预警计算,钻头位置小于500米;当前点井深{};时间:{}", nowPoint.getBitdepth(), nowPoint.getTime());
|
|
|
}
|
|
|
if ("1".equals(workingConditionCalculationLogModel.getIsCalculate())) {
|
|
@@ -274,11 +287,11 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
BigDecimal bitdepth = nowPoint.getBitdepth();
|
|
|
int bitdepthThreshold = bitdepth.compareTo(BigDecimal.valueOf(500));
|
|
|
if (bitdepthThreshold >= 0) {
|
|
|
- try {
|
|
|
- totalPoolVolumeService.totalPoolVolumeWarn(nowPoint, redisHasKey);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
if ("1".equals(workingConditionCalculationLogModel.getIsCalculate())) {
|
|
|
workingConditionCalculationLogModel.setIsCalculate("2");
|
|
@@ -321,10 +334,19 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
}
|
|
|
for (int i = 0; i < list.size() - 1; i++) {
|
|
|
WellDrilling nowPoint = list.get(i);
|
|
|
+ BigDecimal nowSpp = nowPoint.getSpp().setScale(2, RoundingMode.HALF_UP);
|
|
|
+ List<YjPumpingWarnValue> warnValueDatas = getPumpWarnValues(jh);
|
|
|
+ YjPumpingWarnValue warnValueData = filterPumpWarnData(nowSpp, warnValueDatas);
|
|
|
+ log.info("筛选后的阈值数据:{}",warnValueData);
|
|
|
+ BigDecimal pumpingWarnValue = warnValueData.getPumpingWarnValue();
|
|
|
+ BigDecimal sppWarnValue = warnValueData.getSppWarnValue();
|
|
|
+ BigDecimal warnBitdepth = warnValueData.getBitdepth();
|
|
|
BigDecimal bitdepth = nowPoint.getBitdepth();
|
|
|
- int bitdepthThreshold = bitdepth.compareTo(BigDecimal.valueOf(500));
|
|
|
+ log.info("当前点井深{};阈值井深:{},时间:{}", nowPoint.getBitdepth(), warnBitdepth, nowPoint.getTime());
|
|
|
+ int bitdepthThreshold = bitdepth.compareTo(warnBitdepth);
|
|
|
if (bitdepthThreshold >= 0) {
|
|
|
- pumpingPressureService.pumpingPressureCalculate(nowPoint, redisHasKey);
|
|
|
+ pumpingPressureService.pumpingPressureCalculate(nowPoint, redisHasKey, pumpingWarnValue, sppWarnValue);
|
|
|
+
|
|
|
}
|
|
|
if ("1".equals(workingConditionCalculationLogModel.getIsCalculate())) {
|
|
|
workingConditionCalculationLogModel.setIsCalculate("2");
|
|
@@ -367,13 +389,21 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
|
|
|
for (int i = 0; i < list.size() - 1; i++) {
|
|
|
WellDrilling nowPoint = list.get(i);
|
|
|
+ BigDecimal torque = nowPoint.getTorque();
|
|
|
+ List<YjTorqueWarnValue> warnValueDatas = getWarnValues(jh);
|
|
|
+ YjTorqueWarnValue yjTorqueWarnValue = filterWarnData(torque, warnValueDatas);
|
|
|
+ BigDecimal warnBitdepth = yjTorqueWarnValue.getBitdepth();
|
|
|
+
|
|
|
+ BigDecimal varianceWarnValue = yjTorqueWarnValue.getVarianceWarnValue();
|
|
|
+
|
|
|
+ BigDecimal fluctuateWarn = yjTorqueWarnValue.getFluctuateWarn();
|
|
|
BigDecimal bitdepth = nowPoint.getBitdepth();
|
|
|
- int bitdepthThreshold = bitdepth.compareTo(BigDecimal.valueOf(500));
|
|
|
+ log.info("当前点井深{};阈值井深:{},时间:{}", nowPoint.getBitdepth(), warnBitdepth, nowPoint.getTime());
|
|
|
+ int bitdepthThreshold = bitdepth.compareTo(warnBitdepth);
|
|
|
if (bitdepthThreshold >= 0) {
|
|
|
- log.info("当前点井深{};时间:{}", nowPoint.getBitdepth(), nowPoint.getTime());
|
|
|
- BigDecimal varianceWarnValue = BigDecimal.valueOf(0.5);
|
|
|
- BigDecimal fluctuateWarn = BigDecimal.valueOf(0.5);
|
|
|
- torqueService.torqueCalculate(nowPoint, redisHasKey,varianceWarnValue,fluctuateWarn);
|
|
|
+
|
|
|
+
|
|
|
+ torqueService.torqueCalculate(nowPoint, redisHasKey, varianceWarnValue, fluctuateWarn);
|
|
|
} else {
|
|
|
log.info("钻头位置小于500米;当前点井深{};时间:{}", nowPoint.getBitdepth(), nowPoint.getTime());
|
|
|
}
|
|
@@ -402,4 +432,113 @@ public class WorkingConditionCalculationServiceImpl implements WorkingConditionC
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ public String warnTorqueValueKey = "_torque_warn_value_con_key";
|
|
|
+
|
|
|
+ public List<YjTorqueWarnValue> getWarnValues(String jh) {
|
|
|
+ String warnKey = jh + warnTorqueValueKey;
|
|
|
+ boolean isWarnKey = redisUtil.hasKey(warnKey);
|
|
|
+ List<YjTorqueWarnValue> list = new ArrayList<>();
|
|
|
+ if (isWarnKey) {
|
|
|
+ Object o = redisUtil.get(warnKey);
|
|
|
+ list = CommonUtil.castList(o, YjTorqueWarnValue.class);
|
|
|
+ } else {
|
|
|
+ list = torqueWarnValueService.getListByJh(jh);
|
|
|
+ redisUtil.set(warnKey, list);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * @param nowTorque
|
|
|
+ * @param warnValueDatas
|
|
|
+ */
|
|
|
+ public YjTorqueWarnValue filterWarnData(BigDecimal nowTorque, List<YjTorqueWarnValue> warnValueDatas) {
|
|
|
+ AtomicReference<YjTorqueWarnValue> model = new AtomicReference<>(new YjTorqueWarnValue());
|
|
|
+ log.info("筛选的阈值数组:{}", warnValueDatas);
|
|
|
+ log.info("当前点扭矩:{}", nowTorque);
|
|
|
+ warnValueDatas.forEach(item -> {
|
|
|
+ BigDecimal torqueMin = item.getTorqueMin();
|
|
|
+ BigDecimal torqueMax = item.getTorqueMax();
|
|
|
+ Boolean minIsZero = torqueMin.compareTo(BigDecimal.ZERO) <= 0;
|
|
|
+ boolean maxIsZero = torqueMax.compareTo(BigDecimal.ZERO) > 0;
|
|
|
+ boolean isMin = nowTorque.compareTo(torqueMin) > 0;
|
|
|
+ boolean isMax = nowTorque.compareTo(torqueMax) <= 0;
|
|
|
+ log.info("最小值是否小于等于0:{}", minIsZero);
|
|
|
+ log.info("最大值是否大于0:{}", maxIsZero);
|
|
|
+ log.info("是否小于等于最大值:{};最大值:{}", isMax, torqueMax);
|
|
|
+ log.info("是否大于最小值:{};最小值:{}", isMin, torqueMin);
|
|
|
+ if (minIsZero) {
|
|
|
+ model.set(warnValueDatas.get(0));
|
|
|
+ } else {
|
|
|
+ if (maxIsZero) {
|
|
|
+ if (isMin && isMax) {
|
|
|
+ model.set(item);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isMin) {
|
|
|
+ model.set(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ log.info("筛选的阈值结果:{}", model.get());
|
|
|
+ return model.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ public String warnPumpValueKey = "_pump_warn_value_con_key";
|
|
|
+
|
|
|
+ public List<YjPumpingWarnValue> getPumpWarnValues(String jh) {
|
|
|
+ String warnKey = jh + warnPumpValueKey;
|
|
|
+ boolean isWarnKey = redisUtil.hasKey(warnKey);
|
|
|
+ List<YjPumpingWarnValue> list = new ArrayList<>();
|
|
|
+ if (isWarnKey) {
|
|
|
+ Object o = redisUtil.get(warnKey);
|
|
|
+ list = CommonUtil.castList(o, YjPumpingWarnValue.class);
|
|
|
+ } else {
|
|
|
+ list = pumpingWarnValueService.getListByJh(jh);
|
|
|
+ redisUtil.set(warnKey, list);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * @param nowSpp
|
|
|
+ * @param warnValueDatas
|
|
|
+ */
|
|
|
+ public YjPumpingWarnValue filterPumpWarnData(BigDecimal nowSpp, List<YjPumpingWarnValue> warnValueDatas) {
|
|
|
+ AtomicReference<YjPumpingWarnValue> model = new AtomicReference<>(new YjPumpingWarnValue());
|
|
|
+ log.info("当前点立压:{}", nowSpp);
|
|
|
+ warnValueDatas.forEach(item -> {
|
|
|
+ BigDecimal pumpingMin = item.getPumpingMin();
|
|
|
+ BigDecimal pumpingMax = item.getPumpingMax();
|
|
|
+ Boolean minIsZero = pumpingMin.compareTo(BigDecimal.ZERO) <= 0;
|
|
|
+ Boolean maxIsZero = pumpingMax.compareTo(BigDecimal.ZERO) > 0;
|
|
|
+ boolean isMin = nowSpp.compareTo(pumpingMin) > 0;
|
|
|
+ boolean isMax = nowSpp.compareTo(pumpingMax) <= 0;
|
|
|
+ log.info("最小值是否小于等于0:{}", minIsZero);
|
|
|
+ log.info("最大值是否大于0:{}", maxIsZero);
|
|
|
+ log.info("是否小于等于最大值:{};最大值:{}", isMax, pumpingMax);
|
|
|
+ log.info("是否大于最小值:{};最小值:{}", isMin, pumpingMin);
|
|
|
+ if (minIsZero) {
|
|
|
+ model.set(warnValueDatas.get(0));
|
|
|
+ } else {
|
|
|
+ if (maxIsZero) {
|
|
|
+ if (isMin && isMax) {
|
|
|
+ model.set(item);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isMin) {
|
|
|
+ log.info("最小值:{}",pumpingMin);
|
|
|
+ log.info("阈值数据:{}",item);
|
|
|
+ model.set(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ YjPumpingWarnValue yjPumpingWarnValue = model.get();
|
|
|
+ return yjPumpingWarnValue;
|
|
|
+ }
|
|
|
+
|
|
|
}
|