|
@@ -157,13 +157,13 @@ public class DeviceEventListener extends EventListener { //
|
|
|
|
|
|
//铁口出铁状态
|
|
|
//1 出铁中 0 出铁结束
|
|
|
- private AtomicDouble ironLoading1 = new AtomicDouble(0);
|
|
|
+ private AtomicDouble ironLoading1 = new AtomicDouble(-1);
|
|
|
//
|
|
|
- private AtomicDouble ironLoading2 = new AtomicDouble(0);
|
|
|
+ private AtomicDouble ironLoading2 = new AtomicDouble(-1);
|
|
|
//
|
|
|
- private AtomicDouble ironLoading3 = new AtomicDouble(0);
|
|
|
+ private AtomicDouble ironLoading3 = new AtomicDouble(-1);
|
|
|
//
|
|
|
- private AtomicDouble ironLoading4 = new AtomicDouble(0);
|
|
|
+ private AtomicDouble ironLoading4 = new AtomicDouble(-1);
|
|
|
|
|
|
//出铁步骤
|
|
|
private List<IronStepVO> mSteps;
|
|
@@ -218,6 +218,12 @@ public class DeviceEventListener extends EventListener { //
|
|
|
//实时出铁总重量/总流量
|
|
|
private BigDecimal mTotalWeight = BigDecimal.ZERO;
|
|
|
|
|
|
+ // 分别记录两个鱼雷罐车的最大值和当前递增值
|
|
|
+ private BigDecimal ironWeight11Max = BigDecimal.ZERO;
|
|
|
+ private BigDecimal ironWeight12Max = BigDecimal.ZERO;
|
|
|
+ private BigDecimal ironWeight11Current = BigDecimal.ZERO;
|
|
|
+ private BigDecimal ironWeight12Current = BigDecimal.ZERO;
|
|
|
+
|
|
|
//出铁耗时(单位:秒)
|
|
|
private AtomicInteger mSecondsElapsed = new AtomicInteger(0);
|
|
|
|
|
@@ -225,7 +231,7 @@ public class DeviceEventListener extends EventListener { //
|
|
|
private static final int MAX_REDIS_COUNT = 50;
|
|
|
|
|
|
//上次出铁量
|
|
|
- private OPCData mIronOPCData;
|
|
|
+// private OPCData mIronOPCData;
|
|
|
|
|
|
//实时出铁数据
|
|
|
private TIronData mTIronData;
|
|
@@ -255,8 +261,13 @@ public class DeviceEventListener extends EventListener { //
|
|
|
if ("1".equals(scheduleOpcdasubscribe.getStatus())) {
|
|
|
//程序启动后隔断时间启动订阅
|
|
|
scheduledTaskManager.addTask(scheduleOpcdasubscribe.getName(), scheduleOpcdasubscribe.getDelay(), scheduleOpcdasubscribe.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
- log.info("opcdaService subscribe available");
|
|
|
- opcuaService.subscribeAvailable();
|
|
|
+ if ("prod".equals(activeProfiles)) {
|
|
|
+ log.info("hdService subscribe available");
|
|
|
+ hdService.subscribeAvailable();
|
|
|
+ } else {
|
|
|
+ log.info("opcdaService subscribe available");
|
|
|
+ opcuaService.subscribeAvailable();
|
|
|
+ }
|
|
|
scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_OPCDASUBSCRIBE);
|
|
|
});
|
|
|
}
|
|
@@ -280,8 +291,6 @@ public class DeviceEventListener extends EventListener { //
|
|
|
|
|
|
private TIronModel modelClosurePredict;
|
|
|
|
|
|
- private ClosurePredictInfo mClosurePredictInfo;
|
|
|
-
|
|
|
|
|
|
/***
|
|
|
* 更新模型
|
|
@@ -300,31 +309,6 @@ public class DeviceEventListener extends EventListener { //
|
|
|
modelTappingWarn = modelMap.get(ModelConstants.tapping_warn);
|
|
|
modelClosurePredict = modelMap.get(ModelConstants.closure_predict);
|
|
|
|
|
|
- if (null != modelClosurePredict && "1".equals(modelClosurePredict.getStatus())) {
|
|
|
- String modelExpression = modelClosurePredict.getModelExpression();
|
|
|
- if (null != modelExpression) {
|
|
|
- mClosurePredictInfo = new Gson().fromJson(modelExpression, ClosurePredictInfo.class);
|
|
|
- if (null != mClosurePredictInfo) {
|
|
|
- totalHitTime = new Random().nextInt(mClosurePredictInfo.getPredMax() - mClosurePredictInfo.getPredMin() + 1) + mClosurePredictInfo.getPredMin();
|
|
|
- scheduledTaskManager.cancelTask(modelClosurePredict.getModelName());
|
|
|
- scheduledTaskManager.addTask(modelClosurePredict.getModelName(), 0, mClosurePredictInfo.getInterval(), TimeUnit.SECONDS, () -> {
|
|
|
- if (mMaxSpeed != 0 && ironLoading1.get() > 0) {
|
|
|
- if (this.mLastSpeed == 0) {
|
|
|
- this.mLastSpeed = mMaxSpeed;
|
|
|
- } else if (mMaxSpeed > this.mLastSpeed) {
|
|
|
- mDiffCloseTime.set(mDiffCloseTime.get() + mClosurePredictInfo.getDecrMinute());
|
|
|
- this.mLastSpeed = mMaxSpeed;
|
|
|
- } else if (mMaxSpeed < this.mLastSpeed) {
|
|
|
- mDiffCloseTime.set(mDiffCloseTime.get() - mClosurePredictInfo.getIncrMinute());
|
|
|
- this.mLastSpeed = mMaxSpeed;
|
|
|
- }
|
|
|
- getCloseTime();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void getAudios() {
|
|
@@ -383,20 +367,29 @@ public class DeviceEventListener extends EventListener { //
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //堵口预警
|
|
|
private TIronSchedule scheduleClosureWarn;
|
|
|
+ //开口预警
|
|
|
private TIronSchedule scheduleOpenWarn;
|
|
|
+ //出铁预警
|
|
|
private TIronSchedule scheduleTappingWarn;
|
|
|
+ //出铁超时预警
|
|
|
private TIronSchedule scheduleTappingTimeoutWarn;
|
|
|
+ //出铁后多长时间打泥量计算
|
|
|
private TIronSchedule scheduleHitMud;
|
|
|
+ //出铁计时开始
|
|
|
private TIronSchedule scheduleTappingConsttime;
|
|
|
+ //出铁诊断
|
|
|
private TIronSchedule scheduleTappingTest;
|
|
|
+ //程序启动后多长时间开始订阅
|
|
|
private TIronSchedule scheduleOpcdasubscribe;
|
|
|
+ //堵口预测
|
|
|
+ private TIronSchedule scheduleClosurePredict;
|
|
|
|
|
|
/***
|
|
|
* 定时任务
|
|
|
*/
|
|
|
private void getSchedules() {
|
|
|
-
|
|
|
Map<String, TIronSchedule> modelMap = iTIronScheduleService.lambdaQuery().list().stream().collect(Collectors.toMap(
|
|
|
TIronSchedule::getName, // 键映射函数
|
|
|
schedule -> schedule, // 值映射函数
|
|
@@ -410,6 +403,7 @@ public class DeviceEventListener extends EventListener { //
|
|
|
scheduleTappingConsttime = modelMap.get(TaskNameConstants.TASKNAME_TAPPING_CONSTTIME);
|
|
|
scheduleTappingTest = modelMap.get(TaskNameConstants.TASKNAME_TAPPING_TEST);
|
|
|
scheduleOpcdasubscribe = modelMap.get(TaskNameConstants.TASKNAME_OPCDASUBSCRIBE);
|
|
|
+ scheduleClosurePredict = modelMap.get(TaskNameConstants.TASKNAME_CLOSURE_PREDICT);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -464,7 +458,7 @@ public class DeviceEventListener extends EventListener { //
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
- * 显示“铁量差在合理范围内”
|
|
|
+ * 显示"铁量差在合理范围内"
|
|
|
* @param latest2DataList
|
|
|
*/
|
|
|
private void getTheoryWeight(List<TL2Data> latest2DataList) {
|
|
@@ -544,164 +538,198 @@ public class DeviceEventListener extends EventListener { //
|
|
|
|
|
|
}
|
|
|
|
|
|
- private int totalHitTime;
|
|
|
+ //总堵口时间
|
|
|
+ private int mTotalCloseTime;
|
|
|
+
|
|
|
//代表要减去的时间,非剩余时间
|
|
|
private AtomicInteger mDiffCloseTime = new AtomicInteger(0);
|
|
|
|
|
|
private void getCloseTime() {
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
- realtimeData.setValue(Math.max(totalHitTime - getIronElapsedMinute() - mDiffCloseTime.get(), 0));
|
|
|
+ realtimeData.setValue(Math.max(mTotalCloseTime - getIronElapsedMinute() - mDiffCloseTime.get(), 0));
|
|
|
realtimeData.setDesc("距离堵口预计还剩");
|
|
|
realtimeData.setUnit("分钟");
|
|
|
PushData.send2CloseTime(realtimeData);
|
|
|
}
|
|
|
|
|
|
- //1号铁口正在出铁的操作项目
|
|
|
+ /**
|
|
|
+ * 1号铁口正在出铁的操作项目(由 0-> 1 表明1号铁口开始出铁)
|
|
|
+ * 处理出铁开始事件
|
|
|
+ * 1. 关闭定时任务 -> 出铁诊断(执行一次)、出铁预警、开口预警
|
|
|
+ * 2. 开启定时任务 -> 出铁超时报警、堵口预警、打泥量选择计算、出铁计时(按秒计时)
|
|
|
+ * 3. 清空出铁总量
|
|
|
+ */
|
|
|
private void taphole1Start() {
|
|
|
- //关闭定时任务:出铁预警、开口预警
|
|
|
- //开启定时任务:出铁超时报警、堵口预警、打泥量选择计算、
|
|
|
-
|
|
|
mTIronData = new TIronData();
|
|
|
mTIronData.setId(ToolUtils.makeUUID());
|
|
|
mTIronData.setIronStarttime(LocalDateUtils.formatDate(new Date()));
|
|
|
ironDataService.saveOrUpdate(mTIronData);
|
|
|
|
|
|
- //清空出铁总量、出铁计时
|
|
|
- mTotalWeight = BigDecimal.ZERO;
|
|
|
- mSecondsElapsed.set(0);
|
|
|
- //生成 170 到 210 的随机数
|
|
|
-
|
|
|
- scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_TAPPING_WARN);
|
|
|
- scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_TAPPING_TIMEOUT_WARN);
|
|
|
+ synchronized (scheduledTaskManager) {
|
|
|
+ //清空出铁总量
|
|
|
+ mTotalWeight = BigDecimal.ZERO;
|
|
|
+ //重置出铁计时
|
|
|
+ mSecondsElapsed.set(0);
|
|
|
+
|
|
|
+ scheduledTaskManager.cancelTask(scheduleClosureWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleOpenWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingTimeoutWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleHitMud.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingConsttime.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingTest.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleClosurePredict.getName());
|
|
|
|
|
|
- if ("1".equals(scheduleTappingConsttime.getStatus())) {
|
|
|
//出铁计时
|
|
|
- scheduledTaskManager.addTask(scheduleTappingConsttime.getName(), scheduleTappingConsttime.getDelay(), scheduleTappingConsttime.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
- getIronTime();
|
|
|
- mSecondsElapsed.incrementAndGet();
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
+ if ("1".equals(scheduleTappingConsttime.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(scheduleTappingConsttime.getName(), scheduleTappingConsttime.getDelay(), scheduleTappingConsttime.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ getIronTime();
|
|
|
+ mSecondsElapsed.incrementAndGet();
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- //模型四:堵口模型
|
|
|
- if ("1".equals(scheduleClosureWarn.getStatus())) {
|
|
|
- //堵口预警
|
|
|
- scheduledTaskManager.addTask(scheduleClosureWarn.getName(), scheduleClosureWarn.getDelay(), scheduleClosureWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ //模型四:堵口模型
|
|
|
+ if ("1".equals(scheduleClosureWarn.getStatus())) {
|
|
|
//堵口预警
|
|
|
- String modelExpression1 = modelClosureWarn1.getModelExpression();
|
|
|
-
|
|
|
- Expression expression1 = mParser.parseExpression(modelExpression1);
|
|
|
-
|
|
|
- StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
- // 设置占位符对应的值
|
|
|
- boolean result1 = expression1.getValue(context, Boolean.class);
|
|
|
-
|
|
|
- log.info("1号车受铁速度:{}", speed1.get());
|
|
|
- log.info("2号车受铁速度:{}", speed2.get());
|
|
|
- log.info("标准受铁速度:{},", STANDARD_SPEED.get());
|
|
|
- log.info("1号铁口出铁状态:{}", ironLoading1.get());
|
|
|
- log.info("2号铁口出铁状态:{}", ironLoading2.get());
|
|
|
- log.info("3号铁口出铁状态:{}", ironLoading3.get());
|
|
|
- log.info("4号铁口出铁状态:{}", ironLoading4.get());
|
|
|
-
|
|
|
- if (result1) {
|
|
|
- //流速过大可能是由于铁口深度不足或发生跑大流问题,则提示将当前铁口堵口
|
|
|
- PushData.send2Warn(WarnData.warnClose("流速过快,请将当前铁口堵口", closureAlarmUrl));
|
|
|
- taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过快,请将当前铁口堵口").build());
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- String modelExpression2 = modelClosureWarn2.getModelExpression();
|
|
|
- Expression expression2 = mParser.parseExpression(modelExpression2);
|
|
|
- boolean result2 = expression2.getValue(context, Boolean.class);
|
|
|
- if (result2) {
|
|
|
- //若流速过小,但其它铁口正在出铁,则提示将当前铁口堵口
|
|
|
- PushData.send2Warn(WarnData.warnClose("流速过小,请将当前铁口堵口", closureAlarmUrl));
|
|
|
- taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过小,请将当前铁口堵口").build());
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
+ scheduledTaskManager.addTask(scheduleClosureWarn.getName(), scheduleClosureWarn.getDelay(), scheduleClosureWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ //堵口预警
|
|
|
+ String modelExpression1 = modelClosureWarn1.getModelExpression();
|
|
|
|
|
|
- String modelExpression3 = modelClosureWarn3.getModelExpression();
|
|
|
- Expression expression3 = mParser.parseExpression(modelExpression3);
|
|
|
- boolean result3 = expression3.getValue(context, Boolean.class);
|
|
|
+ Expression expression1 = mParser.parseExpression(modelExpression1);
|
|
|
|
|
|
- if (result3) {
|
|
|
- PushData.send2Warn(WarnData.warnClose("流速过小且其他铁口均未出铁,请先将其它铁口打开,再进行堵口", closureAlarmUrl));
|
|
|
- taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过小且其他铁口均未出铁,请先将其它铁口打开,再进行堵口").build());
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
+ StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
+ // 设置占位符对应的值
|
|
|
+ boolean result1 = expression1.getValue(context, Boolean.class);
|
|
|
+
|
|
|
+ log.info("1号车受铁速度:{}", speed1.get());
|
|
|
+ log.info("2号车受铁速度:{}", speed2.get());
|
|
|
+ log.info("标准受铁速度:{},", STANDARD_SPEED.get());
|
|
|
+ log.info("1号铁口出铁状态:{}", ironLoading1.get());
|
|
|
+ log.info("2号铁口出铁状态:{}", ironLoading2.get());
|
|
|
+ log.info("3号铁口出铁状态:{}", ironLoading3.get());
|
|
|
+ log.info("4号铁口出铁状态:{}", ironLoading4.get());
|
|
|
+
|
|
|
+ if (result1) {
|
|
|
+ //流速过大可能是由于铁口深度不足或发生跑大流问题,则提示将当前铁口堵口
|
|
|
+ PushData.send2Warn(WarnData.warnClose("流速过快,请将当前铁口堵口", closureAlarmUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过快,请将当前铁口堵口").build());
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ String modelExpression2 = modelClosureWarn2.getModelExpression();
|
|
|
+ Expression expression2 = mParser.parseExpression(modelExpression2);
|
|
|
+ boolean result2 = expression2.getValue(context, Boolean.class);
|
|
|
+ if (result2) {
|
|
|
+ //若流速过小,但其它铁口正在出铁,则提示将当前铁口堵口
|
|
|
+ PushData.send2Warn(WarnData.warnClose("流速过小,请将当前铁口堵口", closureAlarmUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过小,请将当前铁口堵口").build());
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //模型二:打泥量选择模型
|
|
|
- if ("1".equals(scheduleHitMud.getStatus())) {
|
|
|
- //xxx分钟出铁后开始计算打泥量,通过打泥量公式
|
|
|
- //打泥量公式关联因素:铁口深度、钻杆直径、调用打泥量模型,计算预计使用多少打泥量进行堵口
|
|
|
- scheduledTaskManager.addTask(scheduleHitMud.getName(), scheduleHitMud.getDelay(), scheduleHitMud.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
- log.info("打泥量预计:{}", modelHitMud);
|
|
|
- TL2Data tappingData = tl2DataService.getLatestData();
|
|
|
- if (ObjectUtils.isNotEmpty(tappingData) && ObjectUtils.isNotEmpty(modelHitMud)) {
|
|
|
- log.info("开口深度openDepth(mm):{}", tappingData.getOpenDepth());
|
|
|
- log.info("Tap对应铁水估计铁量rtIronWeight(t): {}", mTotalWeight.doubleValue());
|
|
|
- log.info("出铁时间rtIronCosttime(min): {}", getIronElapsedMinute());
|
|
|
- log.info("平均流速rtIronSpeed(t/s): {}", speed1.get() > speed2.get() ? speed1.get() : speed2.get());
|
|
|
+ String modelExpression3 = modelClosureWarn3.getModelExpression();
|
|
|
+ Expression expression3 = mParser.parseExpression(modelExpression3);
|
|
|
+ boolean result3 = expression3.getValue(context, Boolean.class);
|
|
|
|
|
|
- try {
|
|
|
- String modelExpression = modelHitMud.getModelExpression();
|
|
|
+ if (result3) {
|
|
|
+ PushData.send2Warn(WarnData.warnClose("流速过小且其他铁口均未出铁,请先将其它铁口打开,再进行堵口", closureAlarmUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过小且其他铁口均未出铁,请先将其它铁口打开,再进行堵口").build());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- Expression expression = mParser.parseExpression(modelExpression);
|
|
|
- // 设置占位符对应的值
|
|
|
- mContext.setVariable(ExpressionConstants.openDepth, tappingData.getOpenDepth());
|
|
|
- mContext.setVariable(ExpressionConstants.rtIronWeight, mTotalWeight.doubleValue());
|
|
|
- mContext.setVariable(ExpressionConstants.rtIronCosttime, getIronElapsedMinute());
|
|
|
- //计算打泥量
|
|
|
- int result = (int) ((double) expression.getValue(mContext));
|
|
|
- // 使用 DecimalFormat 保留两位小数
|
|
|
-// DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
-// String formattedResult = decimalFormat.format(result);
|
|
|
- log.info("计算结果: {}", result);
|
|
|
- PushData.send2IronHitMud(result);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ //模型二:打泥量选择模型
|
|
|
+ if ("1".equals(scheduleHitMud.getStatus())) {
|
|
|
+ //xxx分钟出铁后开始计算打泥量,通过打泥量公式
|
|
|
+ //打泥量公式关联因素:铁口深度、钻杆直径、调用打泥量模型,计算预计使用多少打泥量进行堵口
|
|
|
+ scheduledTaskManager.addTask(scheduleHitMud.getName(), scheduleHitMud.getDelay(), scheduleHitMud.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ log.info("打泥量预计:{}", modelHitMud);
|
|
|
+ TL2Data tappingData = tl2DataService.getLatestData();
|
|
|
+ if (ObjectUtils.isNotEmpty(tappingData) && ObjectUtils.isNotEmpty(modelHitMud)) {
|
|
|
+ log.info("开口深度openDepth(mm):{}", tappingData.getOpenDepth());
|
|
|
+ log.info("Tap对应铁水估计铁量rtIronWeight(t): {}", mTotalWeight.doubleValue());
|
|
|
+ log.info("出铁时间rtIronCosttime(min): {}", getIronElapsedMinute());
|
|
|
+ log.info("平均流速rtIronSpeed(t/s): {}", speed1.get() > speed2.get() ? speed1.get() : speed2.get());
|
|
|
+
|
|
|
+ try {
|
|
|
+ String modelExpression = modelHitMud.getModelExpression();
|
|
|
+
|
|
|
+ Expression expression = mParser.parseExpression(modelExpression);
|
|
|
+ // 设置占位符对应的值
|
|
|
+ mContext.setVariable(ExpressionConstants.openDepth, tappingData.getOpenDepth());
|
|
|
+ mContext.setVariable(ExpressionConstants.rtIronWeight, mTotalWeight.doubleValue());
|
|
|
+ mContext.setVariable(ExpressionConstants.rtIronCosttime, getIronElapsedMinute());
|
|
|
+ //计算打泥量
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(expression.getValue(mContext).toString());
|
|
|
+ String formattedResult = bigDecimal.toBigInteger().toString();
|
|
|
+ log.info("计算结果: {}", formattedResult);
|
|
|
+ PushData.send2IronHitMud(formattedResult);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- scheduledTaskManager.cancelTask(scheduleHitMud.getName());
|
|
|
- });
|
|
|
- }
|
|
|
+ scheduledTaskManager.cancelTask(scheduleHitMud.getName());
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ //出铁超时报警
|
|
|
+ if ("1".equals(scheduleTappingTimeoutWarn.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(scheduleTappingTimeoutWarn.getName(), scheduleTappingTimeoutWarn.getDelay(), scheduleTappingTimeoutWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ // log.info("已出铁时间(秒):{},标准出铁时间(秒):{}", seconds, STANDARD_IRON_TIME.get());
|
|
|
+ if (getIronElapsedMinute() > STANDARD_IRON_TIME.get()) {
|
|
|
+ PushData.send2Warn(WarnData.warnTappingTimeout("出铁时间超时", tappingTimeoutAlramUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("2").exceptionDesc("出铁时间超过设定时间").build());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- //出铁超时报警
|
|
|
- if ("1".equals(scheduleTappingTimeoutWarn.getStatus())) {
|
|
|
- scheduledTaskManager.addTask(scheduleTappingTimeoutWarn.getName(), scheduleTappingTimeoutWarn.getDelay(), scheduleTappingTimeoutWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
- // log.info("已出铁时间(秒):{},标准出铁时间(秒):{}", seconds, STANDARD_IRON_TIME.get());
|
|
|
- if (getIronElapsedMinute() > STANDARD_IRON_TIME.get()) {
|
|
|
- PushData.send2Warn(WarnData.warnTappingTimeout("出铁时间超时", tappingTimeoutAlramUrl));
|
|
|
- taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("2").exceptionDesc("出铁时间超过设定时间").build());
|
|
|
- });
|
|
|
+ if (null != modelClosurePredict && "1".equals(modelClosurePredict.getStatus())) {
|
|
|
+ String modelExpression = modelClosurePredict.getModelExpression();
|
|
|
+ if (null != modelExpression) {
|
|
|
+ ClosurePredictInfo mClosurePredictInfo = new Gson().fromJson(modelExpression, ClosurePredictInfo.class);
|
|
|
+ if (null != mClosurePredictInfo) {
|
|
|
+ if ("1".equals(scheduleClosurePredict.getStatus())) {
|
|
|
+ mTotalCloseTime = new Random().nextInt(mClosurePredictInfo.getPredMax() - mClosurePredictInfo.getPredMin() + 1) + mClosurePredictInfo.getPredMin();
|
|
|
+ mLastSpeed = mMaxSpeed = 0;
|
|
|
+ mDiffCloseTime.set(0);
|
|
|
+ log.info("预计总时间:{}", mTotalCloseTime);
|
|
|
+ scheduledTaskManager.addTask(scheduleClosurePredict.getName(), scheduleClosurePredict.getDelay(), scheduleClosurePredict.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ if (mMaxSpeed != 0 && ironLoading1.get() > 0) {
|
|
|
+ if (this.mLastSpeed == 0) {
|
|
|
+ this.mLastSpeed = mMaxSpeed;
|
|
|
+ } else if (mMaxSpeed > this.mLastSpeed) {
|
|
|
+ mDiffCloseTime.set(mDiffCloseTime.get() + mClosurePredictInfo.getDecrMinute());
|
|
|
+ this.mLastSpeed = mMaxSpeed;
|
|
|
+ } else if (mMaxSpeed < this.mLastSpeed) {
|
|
|
+ mDiffCloseTime.set(mDiffCloseTime.get() - mClosurePredictInfo.getIncrMinute());
|
|
|
+ this.mLastSpeed = mMaxSpeed;
|
|
|
+ }
|
|
|
+ getCloseTime();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- scheduledTaskManager.addTask(TaskNameConstants.TASKNAME_CLOSETIME, 0, 1 * 60, TimeUnit.SECONDS, () -> {
|
|
|
- // log.info("已出铁时间(秒):{},标准出铁时间(秒):{}", seconds, STANDARD_IRON_TIME.get());
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
- //1号铁口结束出铁的操作项目
|
|
|
+ /**
|
|
|
+ * 1号铁口结束出铁的操作项目(由 1-> 0 表明1号铁口结束出铁)
|
|
|
+ * 处理出铁开始事件
|
|
|
+ * 1. 关闭定时任务 -> 出铁超时报警、堵口预警、打泥量选择计算、出铁计时
|
|
|
+ * 2. 开启定时任务 -> 出铁诊断(执行一次)、出铁预警、开口预警
|
|
|
+ * 3. 清空出铁总量
|
|
|
+ */
|
|
|
private void taphole1End() {
|
|
|
- //由 1-> 0 表明1号铁口结束出铁
|
|
|
if (null != mTIronData) {
|
|
|
mTIronData.setIronCosttime(getIronElapsedMinute());
|
|
|
mTIronData.setIronWeight(mTotalWeight.doubleValue());
|
|
@@ -709,123 +737,115 @@ public class DeviceEventListener extends EventListener { //
|
|
|
ironDataService.saveOrUpdate(mTIronData);
|
|
|
}
|
|
|
|
|
|
- mLastSpeed = mMaxSpeed = 0;
|
|
|
- mDiffCloseTime.set(0);
|
|
|
- if (null != mClosurePredictInfo) {
|
|
|
- totalHitTime = new Random().nextInt(mClosurePredictInfo.getPredMax() - mClosurePredictInfo.getPredMin() + 1) + mClosurePredictInfo.getPredMin();
|
|
|
- }
|
|
|
-
|
|
|
- scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_CLOSURE_WARN);
|
|
|
- scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_HIT_MUD);
|
|
|
- scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_TAPPING_CONSTTIME);
|
|
|
- scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_TAPPING_TIMEOUT_WARN);
|
|
|
- scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_CLOSETIME);
|
|
|
+ synchronized (scheduledTaskManager) {
|
|
|
+ scheduledTaskManager.cancelTask(scheduleClosureWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleOpenWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingTimeoutWarn.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleHitMud.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingConsttime.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingTest.getName());
|
|
|
+ scheduledTaskManager.cancelTask(scheduleClosurePredict.getName());
|
|
|
+
|
|
|
+ PushData.send2CostTime(new RealtimeData());
|
|
|
+ PushData.send2CloseTime(new RealtimeData());
|
|
|
+
|
|
|
+ //尝试重新获取一次新的铁次号码
|
|
|
+ getIronTimeNo();
|
|
|
+ mSteps = ironStepService.getTreeSteps();
|
|
|
|
|
|
- PushData.send2CostTime(new RealtimeData());
|
|
|
- PushData.send2CloseTime(new RealtimeData());
|
|
|
+ //开口
|
|
|
+ //PushData.send2CancelWarn(WarnData.warnOpen("", ""));
|
|
|
+ //堵口
|
|
|
+ PushData.send2CancelWarn(WarnData.warnClose("出铁结束", ""));
|
|
|
+ //出铁预警
|
|
|
+ PushData.send2CancelWarn(WarnData.warnTapping("出铁结束", ""));
|
|
|
+ //清空打泥量
|
|
|
+ PushData.send2IronHitMud("");
|
|
|
+
|
|
|
+ //模型一 : 出铁工作诊断模型
|
|
|
+ if ("1".equals(scheduleTappingTest.getStatus())) {
|
|
|
+ //获取开口耗时、出铁时间、实际出铁量、平均铁水流速、平均铁水温度等数据,进行阈值判定,诊断出铁是否正常
|
|
|
+ //结束后xxx秒后诊断
|
|
|
+ scheduledTaskManager.addTask(scheduleTappingTest.getName(), scheduleTappingTest.getDelay(), scheduleTappingTest.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ //堵口预警
|
|
|
+ log.info("出铁结束,定时任务:{},出铁诊断", TaskNameConstants.TASKNAME_TAPPING_TEST);
|
|
|
+ TL2Data fixedLatestElement = (TL2Data) RedisUtils.getFixedLatestElement(IRON_ELEMENT);
|
|
|
|
|
|
- //尝试重新获取一次新的铁次号码
|
|
|
- getIronTimeNo();
|
|
|
- mSteps = ironStepService.getTreeSteps();
|
|
|
-
|
|
|
-
|
|
|
- //开口
|
|
|
-// PushData.send2CancelWarn(WarnData.warnOpen("", ""));
|
|
|
- //堵口
|
|
|
- PushData.send2CancelWarn(WarnData.warnClose("出铁结束", ""));
|
|
|
- //出铁预警
|
|
|
- PushData.send2CancelWarn(WarnData.warnTapping("出铁结束", ""));
|
|
|
- //清空打泥量
|
|
|
- PushData.send2IronHitMud("");
|
|
|
-
|
|
|
-// recordAfter();
|
|
|
-// recordBlock();
|
|
|
-
|
|
|
- //模型一 : 出铁工作诊断模型
|
|
|
- if ("1".equals(scheduleTappingTest.getStatus())) {
|
|
|
- //获取开口耗时、出铁时间、实际出铁量、平均铁水流速、平均铁水温度等数据,进行阈值判定,诊断出铁是否正常
|
|
|
- //结束后xxx秒后诊断
|
|
|
- scheduledTaskManager.addTask(scheduleTappingTest.getName(), scheduleTappingTest.getDelay(), scheduleTappingTest.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
- //堵口预警
|
|
|
- log.info("出铁结束,定时任务:{},出铁诊断", TaskNameConstants.TASKNAME_TAPPING_TEST);
|
|
|
- TL2Data fixedLatestElement = (TL2Data) RedisUtils.getFixedLatestElement(IRON_ELEMENT);
|
|
|
+ try {
|
|
|
+ String modelExpression = modelTappingTest.getModelExpression();
|
|
|
+ if (ObjectUtils.isNotEmpty(modelExpression)) {
|
|
|
+ log.info("出铁诊断计算公式:{}", modelExpression);
|
|
|
+ // 设置占位符对应的值
|
|
|
+ mContext.setVariable(ExpressionConstants.rtIronCosttime, getIronElapsedMinute());
|
|
|
+ mContext.setVariable(ExpressionConstants.avgIronSpeed, mTotalWeight.doubleValue() / (getIronElapsedMinute() == 0 ? 1 : getIronElapsedMinute()));
|
|
|
+ // 使用 DecimalFormat 保留两位小数
|
|
|
+ //DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
+ //String formattedResult = decimalFormat.format(result);
|
|
|
+ String testResultStr = "";
|
|
|
+
|
|
|
+ String[] split = modelExpression.split("&&");
|
|
|
+ boolean ironTimeBool = mParser.parseExpression(split[0]).getValue(mContext, Boolean.class);
|
|
|
+
|
|
|
+ if (ironTimeBool) {
|
|
|
+ testResultStr += "出铁时间符合预期,";
|
|
|
+ } else {
|
|
|
+ testResultStr += "出铁时间不符合预期,";
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
- String modelExpression = modelTappingTest.getModelExpression();
|
|
|
- if (ObjectUtils.isNotEmpty(modelExpression)) {
|
|
|
- log.info("出铁诊断计算公式:{}", modelExpression);
|
|
|
- // 设置占位符对应的值
|
|
|
- mContext.setVariable(ExpressionConstants.rtIronCosttime, getIronElapsedMinute());
|
|
|
- mContext.setVariable(ExpressionConstants.avgIronSpeed, mTotalWeight.doubleValue() / (getIronElapsedMinute() == 0 ? 1 : getIronElapsedMinute()));
|
|
|
- // 使用 DecimalFormat 保留两位小数
|
|
|
-// DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
-// String formattedResult = decimalFormat.format(result);
|
|
|
- String testResultStr = "";
|
|
|
-
|
|
|
- String[] split = modelExpression.split("&&");
|
|
|
- boolean ironTimeBool = mParser.parseExpression(split[0]).getValue(mContext, Boolean.class);
|
|
|
-
|
|
|
- if (ironTimeBool) {
|
|
|
- testResultStr += "出铁时间符合预期,";
|
|
|
- } else {
|
|
|
- testResultStr += "出铁时间不符合预期,";
|
|
|
- }
|
|
|
+ boolean ironWeightBool = mParser.parseExpression(split[1]).getValue(mContext, Boolean.class);
|
|
|
+ if (ironWeightBool) {
|
|
|
+ testResultStr += "出铁量符合预期,";
|
|
|
+ } else {
|
|
|
+ testResultStr += "出铁量不符合预期,";
|
|
|
+ }
|
|
|
|
|
|
- boolean ironWeightBool = mParser.parseExpression(split[1]).getValue(mContext, Boolean.class);
|
|
|
- if (ironWeightBool) {
|
|
|
- testResultStr += "出铁量符合预期,";
|
|
|
- } else {
|
|
|
- testResultStr += "出铁量不符合预期,";
|
|
|
- }
|
|
|
+ boolean ironSpeedBool = mParser.parseExpression(split[2]).getValue(mContext, Boolean.class);
|
|
|
+ if (ironSpeedBool) {
|
|
|
+ testResultStr += "出铁流速符合预期,";
|
|
|
+ } else {
|
|
|
+ testResultStr += "出铁流速不符合预期,";
|
|
|
+ }
|
|
|
|
|
|
- boolean ironSpeedBool = mParser.parseExpression(split[2]).getValue(mContext, Boolean.class);
|
|
|
- if (ironSpeedBool) {
|
|
|
- testResultStr += "出铁流速符合预期,";
|
|
|
- } else {
|
|
|
- testResultStr += "出铁流速不符合预期,";
|
|
|
+ boolean ironTempChangeBool = mParser.parseExpression(split[3]).getValue(mContext, Boolean.class);
|
|
|
+ if (ironTempChangeBool) {
|
|
|
+ testResultStr += "铁水温度变化符合预期。";
|
|
|
+ } else {
|
|
|
+ testResultStr += "铁水温度变化不符合预期。";
|
|
|
+ }
|
|
|
+ TIronTest ironTest = new TIronTest();
|
|
|
+ String testStatus = (ironTimeBool && ironWeightBool && ironSpeedBool && ironTempChangeBool) ? "1" : "0";
|
|
|
+ ironTest.setTestStatus(testStatus);
|
|
|
+ ironTest.setTestDesc(testResultStr);
|
|
|
+ iTIronTestService.save(ironTest);
|
|
|
+ log.info("出铁诊断结果:{}", testResultStr);
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ scheduledTaskManager.cancelTask(scheduleTappingTest.getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- boolean ironTempChangeBool = mParser.parseExpression(split[3]).getValue(mContext, Boolean.class);
|
|
|
- if (ironTempChangeBool) {
|
|
|
- testResultStr += "铁水温度变化符合预期。";
|
|
|
+ //模型三:预警出铁模型
|
|
|
+ if ("1".equals(scheduleTappingWarn.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(scheduleTappingWarn.getName(), scheduleTappingWarn.getDelay(), scheduleTappingWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ String modelExpression = modelTappingWarn.getModelExpression();
|
|
|
+ if (ObjectUtils.isNotEmpty(modelExpression)) {
|
|
|
+ Expression expression = mParser.parseExpression(modelExpression);
|
|
|
+ // 设置占位符对应的值
|
|
|
+ Boolean result = expression.getValue(mContext, Boolean.class);
|
|
|
+ if (result) {
|
|
|
+ PushData.send2Warn(WarnData.warnTapping("压差超过阈值,请出铁", tappingAlramUrl));
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("压差超过阈值,请出铁").build());
|
|
|
} else {
|
|
|
- testResultStr += "铁水温度变化不符合预期。";
|
|
|
+ PushData.send2CancelWarn(WarnData.warnTapping("压差正常", ""));
|
|
|
}
|
|
|
- TIronTest ironTest = new TIronTest();
|
|
|
- String testStatus = (ironTimeBool && ironWeightBool && ironSpeedBool && ironTempChangeBool) ? "1" : "0";
|
|
|
- ironTest.setTestStatus(testStatus);
|
|
|
- ironTest.setTestDesc(testResultStr);
|
|
|
- iTIronTestService.save(ironTest);
|
|
|
- log.info("出铁诊断结果:{}", testResultStr);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- scheduledTaskManager.cancelTask(scheduleTappingTest.getName());
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- //模型三:预警出铁模型
|
|
|
- if ("1".equals(scheduleTappingWarn.getStatus())) {
|
|
|
- scheduledTaskManager.addTask(scheduleTappingWarn.getName(), scheduleTappingWarn.getDelay(), scheduleTappingWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
- String modelExpression = modelTappingWarn.getModelExpression();
|
|
|
- if (ObjectUtils.isNotEmpty(modelExpression)) {
|
|
|
- Expression expression = mParser.parseExpression(modelExpression);
|
|
|
- // 设置占位符对应的值
|
|
|
- Boolean result = expression.getValue(mContext, Boolean.class);
|
|
|
- if (result) {
|
|
|
- PushData.send2Warn(WarnData.warnTapping("压差超过阈值,请出铁", tappingAlramUrl));
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("压差超过阈值,请出铁").build());
|
|
|
- } else {
|
|
|
- PushData.send2CancelWarn(WarnData.warnTapping("压差正常", ""));
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//出铁后,记录炉次、开口时间、鱼雷罐车车号、铁口深度、铁水流速
|
|
@@ -877,24 +897,39 @@ public class DeviceEventListener extends EventListener { //
|
|
|
realtimeData.setUnit("t/s");
|
|
|
|
|
|
RealtimeData ironSpeed = (RealtimeData) mRealtimeData.get(IRON_SPEED);
|
|
|
- RealtimeData[] speeds = null;
|
|
|
+ List<RealtimeData> speeds = null;
|
|
|
+
|
|
|
if (ObjectUtils.isEmpty(ironSpeed)) {
|
|
|
ironSpeed = new RealtimeData();
|
|
|
ironSpeed.setDesc("铁水流速");
|
|
|
- speeds = new RealtimeData[2];
|
|
|
+
|
|
|
+ // 初始化包含两个默认元素的 List
|
|
|
+ speeds = new ArrayList<>();
|
|
|
+ speeds.add(null); // index 0
|
|
|
+ speeds.add(null); // index 1
|
|
|
+
|
|
|
ironSpeed.setValue(speeds);
|
|
|
mRealtimeData.put(IRON_SPEED, ironSpeed);
|
|
|
} else {
|
|
|
- speeds = (RealtimeData[]) ironSpeed.getValue();
|
|
|
+ speeds = (List<RealtimeData>) ironSpeed.getValue();
|
|
|
}
|
|
|
|
|
|
if (opcData.getPointName().contains(SubscribeTagConstants.TAG_CAR11(opcData.getServerType()))) {
|
|
|
realtimeData.setDesc("1号车");
|
|
|
- speeds[0] = realtimeData;
|
|
|
+ if (speeds.size() > 0) {
|
|
|
+ speeds.set(0, realtimeData);
|
|
|
+ } else {
|
|
|
+ speeds.add(realtimeData); // 如果不够长度,就添加
|
|
|
+ }
|
|
|
speed1 = new AtomicDouble(Double.parseDouble(opcData.getData().toString()));
|
|
|
} else {
|
|
|
realtimeData.setDesc("2号车");
|
|
|
- speeds[1] = realtimeData;
|
|
|
+ if (speeds.size() > 1) {
|
|
|
+ speeds.set(1, realtimeData);
|
|
|
+ } else {
|
|
|
+ while (speeds.size() < 1) speeds.add(null); // 补足长度
|
|
|
+ speeds.add(realtimeData);
|
|
|
+ }
|
|
|
speed2 = new AtomicDouble(Double.parseDouble(opcData.getData().toString()));
|
|
|
}
|
|
|
mMaxSpeed = Math.max(speed1.get(), speed2.get());
|
|
@@ -902,8 +937,8 @@ public class DeviceEventListener extends EventListener { //
|
|
|
|
|
|
//只在两个都有数据的时候才添加
|
|
|
if (ObjectUtils.isNotEmpty(speeds)
|
|
|
- && ObjectUtils.isNotEmpty(speeds[0]) && ObjectUtils.isNotEmpty(speeds[0].getValue())
|
|
|
- && ObjectUtils.isNotEmpty(speeds[1]) && ObjectUtils.isNotEmpty(speeds[1].getValue())
|
|
|
+ && ObjectUtils.isNotEmpty(speeds.get(0)) && ObjectUtils.isNotEmpty(speeds.get(0).getValue())
|
|
|
+ && ObjectUtils.isNotEmpty(speeds.get(1)) && ObjectUtils.isNotEmpty(speeds.get(1).getValue())
|
|
|
) {
|
|
|
ironSpeed.setTime(LocalDateUtils.formatDate(opcData.getServerTime()));
|
|
|
}
|
|
@@ -916,16 +951,29 @@ public class DeviceEventListener extends EventListener { //
|
|
|
mRealtimeStatus.put(IRON_STATUS, realtimeData);
|
|
|
|
|
|
double currentVal = Double.parseDouble(opcData.getData().toString());
|
|
|
+// double oldVal = ironLoading1.get();
|
|
|
+//
|
|
|
+// log.info("设置前 - currentVal:{}, ironLoading1_value:{}, thread:{}", currentVal, oldVal, Thread.currentThread().getName());
|
|
|
+//
|
|
|
+ ironLoading1.set(currentVal);
|
|
|
+//
|
|
|
+// log.info("设置后 - currentVal:{}, ironLoading1_value:{}, thread:{}", currentVal, ironLoading1.get(), Thread.currentThread().getName());
|
|
|
+//
|
|
|
+// boolean compareResult = Double.compare(oldVal, currentVal) != 0;
|
|
|
+// boolean greaterThanZero = currentVal > 0;
|
|
|
+//
|
|
|
+// log.info("条件判断详情 - compareResult:{}, greaterThanZero:{}, 最终结果:{}",
|
|
|
+// compareResult, greaterThanZero, (compareResult && greaterThanZero));
|
|
|
|
|
|
- if (ironLoading1.get() <= 0 && currentVal > 0) {
|
|
|
+ if (currentVal > 0) {
|
|
|
+ log.info("准备调用taphole1Start()");
|
|
|
taphole1Start();
|
|
|
- } else if (ironLoading1.get() > 0 && currentVal <= 0) {
|
|
|
+ } else if (currentVal <= 0) {
|
|
|
+ log.info("准备调用taphole1End()");
|
|
|
taphole1End();
|
|
|
}
|
|
|
-
|
|
|
- ironLoading1.set(Double.parseDouble(opcData.getData().toString()));
|
|
|
- mContext.setVariable(ExpressionConstants.rtIron01State, ironLoading1.get());
|
|
|
-
|
|
|
+
|
|
|
+ mContext.setVariable(ExpressionConstants.rtIron01State, currentVal);
|
|
|
} else if (opcData.getPointName().contains(SubscribeTagConstants.TAG_TAPHOLE2_STATUS(opcData.getServerType()))) {
|
|
|
ironLoading2.set(Double.parseDouble(opcData.getData().toString()));
|
|
|
mContext.setVariable(ExpressionConstants.rtIron02State, ironLoading2.get());
|
|
@@ -935,24 +983,33 @@ public class DeviceEventListener extends EventListener { //
|
|
|
} else if (opcData.getPointName().contains(SubscribeTagConstants.TAG_TAPHOLE4_STATUS(opcData.getServerType()))) {
|
|
|
ironLoading4.set(Double.parseDouble(opcData.getData().toString()));
|
|
|
mContext.setVariable(ExpressionConstants.rtIron04State, ironLoading4.get());
|
|
|
- } else if (opcData.getPointName().contains(SubscribeTagConstants.TAG_IRON_WEIGHT11(opcData.getServerType())) || opcData.getPointName().contains(SubscribeTagConstants.TAG_IRON_WEIGHT12(opcData.getServerType()))) {
|
|
|
- //铁水流量
|
|
|
- RealtimeData ironWeight = new RealtimeData();
|
|
|
- ironWeight.setDesc("铁水流量");
|
|
|
- ironWeight.setUnit("t");
|
|
|
- if (ObjectUtils.isEmpty(mIronOPCData) || !opcData.getData().equals(mIronOPCData.getData())) {
|
|
|
- mIronOPCData = opcData;
|
|
|
+ } else if (opcData.getPointName().contains(SubscribeTagConstants.TAG_IRON_WEIGHT11(opcData.getServerType()))) {
|
|
|
+ // 1号车铁水流量递增值
|
|
|
+ BigDecimal bigDecimalNew = new BigDecimal(opcData.getData().toString());
|
|
|
+ if (bigDecimalNew.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ ironWeight11Current = bigDecimalNew;
|
|
|
+ if (bigDecimalNew.compareTo(ironWeight11Max) > 0) {
|
|
|
+ ironWeight11Max = bigDecimalNew;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 罐车卸载,累计最大值到总量
|
|
|
+ mTotalWeight = mTotalWeight.add(ironWeight11Max);
|
|
|
+ ironWeight11Max = BigDecimal.ZERO;
|
|
|
+ ironWeight11Current = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ } else if (opcData.getPointName().contains(SubscribeTagConstants.TAG_IRON_WEIGHT12(opcData.getServerType()))) {
|
|
|
+ // 2号车铁水流量递增值
|
|
|
+ BigDecimal bigDecimalNew = new BigDecimal(opcData.getData().toString());
|
|
|
+ if (bigDecimalNew.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ ironWeight12Current = bigDecimalNew;
|
|
|
+ if (bigDecimalNew.compareTo(ironWeight12Max) > 0) {
|
|
|
+ ironWeight12Max = bigDecimalNew;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mTotalWeight = mTotalWeight.add(ironWeight12Max);
|
|
|
+ ironWeight12Max = BigDecimal.ZERO;
|
|
|
+ ironWeight12Current = BigDecimal.ZERO;
|
|
|
}
|
|
|
- BigDecimal bigDecimalNew = new BigDecimal(mIronOPCData.getData().toString());
|
|
|
- mTotalWeight = mTotalWeight.add(bigDecimalNew);
|
|
|
- ironWeight.setValue(mTotalWeight);
|
|
|
- mRealtimeData.put(IRON_WEIGHT, ironWeight);
|
|
|
-// log.info(">>>>>>>>>>>>>{}:{},total:{}", opcData.getPointName(), opcData.getData(), totalWeight.toPlainString());
|
|
|
- ironWeight.setTime(LocalDateUtils.formatDate(opcData.getServerTime()));
|
|
|
-
|
|
|
-
|
|
|
- mContext.setVariable(ExpressionConstants.rtIronWeight, mTotalWeight.doubleValue());
|
|
|
-
|
|
|
} else if (opcData.getPointName().contains(SubscribeTagConstants.TAG_FLUSH_STATUS(opcData.getServerType()))) {
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
realtimeData.setValue(opcData.getData());
|
|
@@ -1000,6 +1057,18 @@ public class DeviceEventListener extends EventListener { //
|
|
|
mRealtimeData.put(IRON_ELEMENT, realtimeData3);
|
|
|
}
|
|
|
|
|
|
+ // 实时计算总和并推送
|
|
|
+ mTotalWeight = ironWeight11Current.add(ironWeight12Current);
|
|
|
+ RealtimeData ironWeight = new RealtimeData();
|
|
|
+ ironWeight.setDesc("铁水累计流量");
|
|
|
+ ironWeight.setUnit("t");
|
|
|
+ ironWeight.setValue(mTotalWeight);
|
|
|
+ ironWeight.setTime(LocalDateUtils.formatDate(opcData.getServerTime()));
|
|
|
+ mRealtimeData.put(IRON_WEIGHT, ironWeight);
|
|
|
+ mContext.setVariable(ExpressionConstants.rtIronWeight, mTotalWeight.doubleValue());
|
|
|
+
|
|
|
+ //log.info("实时数据:{}", mRealtimeData);
|
|
|
+ //log.info("实时状态:{}", mRealtimeStatus);
|
|
|
//推送实时数据
|
|
|
PushData.send2RealtimeData(mRealtimeData);
|
|
|
//推送实时状态
|