|
@@ -194,24 +194,6 @@ public class DeviceEventListener extends EventListener { //
|
|
|
|
|
|
private AtomicDouble speed2 = new AtomicDouble(0);
|
|
|
|
|
|
- //标准流速
|
|
|
- private String STANDARD_SPEED = "";
|
|
|
-
|
|
|
- //标准压差阈值
|
|
|
- private AtomicDouble STANDARD_PRESSURE_DIFF = new AtomicDouble(0);
|
|
|
-
|
|
|
- //标准出铁时间
|
|
|
- private String STANDARD_IRON_TIME = "";
|
|
|
-
|
|
|
- //标准温差阈值
|
|
|
- private String STANDARD_TEMP = "";
|
|
|
-
|
|
|
- //标准开口耗时
|
|
|
- private AtomicDouble STANDARD_OPEN_HOUR = new AtomicDouble(0);
|
|
|
-
|
|
|
- //标注出铁量
|
|
|
- private String STANDARD_IRON_WEIGHT = "";
|
|
|
-
|
|
|
|
|
|
//实时温度最大值
|
|
|
private AtomicDouble rtTempMax = new AtomicDouble(0);
|
|
@@ -242,11 +224,23 @@ public class DeviceEventListener extends EventListener { //
|
|
|
//实时出铁数据
|
|
|
private TIronData mTIronData;
|
|
|
|
|
|
+ //堵口模型连续计数
|
|
|
+ private Map<String, Integer> closureWarnCountMap = new ConcurrentHashMap<>();
|
|
|
+ //预警出铁模型连续计数
|
|
|
+ private Map<String, Integer> tappingWarnCountMap = new ConcurrentHashMap<>();
|
|
|
+
|
|
|
+ // 定时任务统一管理
|
|
|
+ private Map<String, TIronSchedule> scheduleMap = new ConcurrentHashMap<>();
|
|
|
+
|
|
|
+ // 模型统一管理
|
|
|
+ private Map<String, TIronModel> modelMap = new ConcurrentHashMap<>();
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
taskExecutor.submit(() -> {
|
|
|
mSteps = ironStepService.getTreeSteps();
|
|
|
});
|
|
|
+
|
|
|
taskExecutor.submit(() -> {
|
|
|
getIronParams();
|
|
|
|
|
@@ -256,22 +250,21 @@ public class DeviceEventListener extends EventListener { //
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
taskExecutor.submit(() -> {
|
|
|
getModels();
|
|
|
});
|
|
|
-// taskExecutor.submit(() -> {
|
|
|
-// getIronTimeNo();
|
|
|
-// });
|
|
|
+
|
|
|
taskExecutor.submit(() -> {
|
|
|
getSchedules();
|
|
|
- if ("1".equals(scheduleOpcdasubscribe.getStatus())) {
|
|
|
- //程序启动后隔断时间启动订阅
|
|
|
- scheduledTaskManager.addTask(scheduleOpcdasubscribe.getName(), scheduleOpcdasubscribe.getDelay(), scheduleOpcdasubscribe.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ TIronSchedule opcdasubscribe = scheduleMap.get(TaskNameConstants.TASKNAME_OPCDASUBSCRIBE);
|
|
|
+ if (opcdasubscribe != null && "1".equals(opcdasubscribe.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(opcdasubscribe.getName(), opcdasubscribe.getDelay(), opcdasubscribe.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
if ("prod".equals(activeProfiles)) {
|
|
|
- log.info("hdService subscribe available");
|
|
|
+ log.info("HDC subscribe available");
|
|
|
hdService.subscribeAvailable();
|
|
|
} else {
|
|
|
- log.info("opcdaService subscribe available");
|
|
|
+ log.info("DA subscribe available");
|
|
|
opcuaService.subscribeAvailable();
|
|
|
}
|
|
|
scheduledTaskManager.cancelTask(TaskNameConstants.TASKNAME_OPCDASUBSCRIBE);
|
|
@@ -281,40 +274,15 @@ public class DeviceEventListener extends EventListener { //
|
|
|
}
|
|
|
|
|
|
|
|
|
- //打泥量选择公式模型
|
|
|
- private TIronModel modelHitMud;
|
|
|
-
|
|
|
- // 堵口预警模型
|
|
|
- private TIronModel modelClosureWarn1;
|
|
|
- private TIronModel modelClosureWarn2;
|
|
|
- private TIronModel modelClosureWarn3;
|
|
|
-
|
|
|
- //出铁诊断模型
|
|
|
- private TIronModel modelTappingTest;
|
|
|
-
|
|
|
- //预警出铁模型
|
|
|
- private TIronModel modelTappingWarn;
|
|
|
-
|
|
|
- private TIronModel modelClosurePredict;
|
|
|
-
|
|
|
-
|
|
|
/***
|
|
|
* 更新模型
|
|
|
*/
|
|
|
private void getModels() {
|
|
|
- Map<String, TIronModel> modelMap = ironModelService.lambdaQuery().list().stream().collect(Collectors.toMap(
|
|
|
+ modelMap = ironModelService.lambdaQuery().list().stream().collect(Collectors.toMap(
|
|
|
TIronModel::getModelName, // 键映射函数
|
|
|
model -> model, // 值映射函数
|
|
|
(existing, replacement) -> existing // 合并函数
|
|
|
));
|
|
|
- modelHitMud = modelMap.get(ModelConstants.hit_mud);
|
|
|
- modelClosureWarn1 = modelMap.get(ModelConstants.closure_warn1);
|
|
|
- modelClosureWarn2 = modelMap.get(ModelConstants.closure_warn2);
|
|
|
- modelClosureWarn3 = modelMap.get(ModelConstants.closure_warn3);
|
|
|
- modelTappingTest = modelMap.get(ModelConstants.tapping_test);
|
|
|
- modelTappingWarn = modelMap.get(ModelConstants.tapping_warn);
|
|
|
- modelClosurePredict = modelMap.get(ModelConstants.closure_predict);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void getAudios() {
|
|
@@ -327,6 +295,8 @@ public class DeviceEventListener extends EventListener { //
|
|
|
tappingAlramUrl = SERVER_URL + "/" + GlobalConfig.publicPrefix + File.separator + tAudio.getPath();
|
|
|
} else if (Objects.equals(tAudio.getExceptionType(), "300")) {
|
|
|
tappingTimeoutAlramUrl = SERVER_URL + "/" + GlobalConfig.publicPrefix + File.separator + tAudio.getPath();
|
|
|
+ }else if (Objects.equals(tAudio.getExceptionType(), "300")) {
|
|
|
+ openAlarmUrl = SERVER_URL + "/" + GlobalConfig.publicPrefix + File.separator + tAudio.getPath();
|
|
|
}
|
|
|
}
|
|
|
log.info("openAlarmUrl: " + openAlarmUrl);
|
|
@@ -345,78 +315,50 @@ public class DeviceEventListener extends EventListener { //
|
|
|
if (ObjectUtils.isNotEmpty(mIronParams)) {
|
|
|
for (TIronParam mIronParam : mIronParams) {
|
|
|
if (Objects.equals(mIronParam.getParamName(), ParamsConstants.iron_speed)) {
|
|
|
- STANDARD_SPEED = mIronParam.getParamValue();
|
|
|
+ StandardConstans.STANDARD_SPEED = mIronParam.getParamValue();
|
|
|
} else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.pressure_diff_value)) {
|
|
|
- STANDARD_PRESSURE_DIFF = new AtomicDouble(Double.parseDouble(mIronParam.getParamValue()));
|
|
|
+ StandardConstans.STANDARD_PRESSURE_DIFF = new AtomicDouble(Double.parseDouble(mIronParam.getParamValue()));
|
|
|
} else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.iron_time)) {
|
|
|
- STANDARD_IRON_TIME = mIronParam.getParamValue();
|
|
|
+ StandardConstans.STANDARD_IRON_TIME = mIronParam.getParamValue();
|
|
|
} else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.server_url)) {
|
|
|
SERVER_URL = mIronParam.getParamValue();
|
|
|
} else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.ironwater_temp)) {
|
|
|
- STANDARD_TEMP = mIronParam.getParamValue();
|
|
|
+ StandardConstans.STANDARD_TEMP = mIronParam.getParamValue();
|
|
|
} else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.open_hour)) {
|
|
|
- STANDARD_OPEN_HOUR = new AtomicDouble(Double.parseDouble(mIronParam.getParamValue()));
|
|
|
+ StandardConstans.STANDARD_OPEN_HOUR = new AtomicDouble(Double.parseDouble(mIronParam.getParamValue()));
|
|
|
} else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.iron_weight)) {
|
|
|
- STANDARD_IRON_WEIGHT = mIronParam.getParamValue();
|
|
|
+ StandardConstans.STANDARD_IRON_WEIGHT = mIronParam.getParamValue();
|
|
|
}
|
|
|
// mContext.setVariable(ExpressionConstants.stdSpeed, STANDARD_SPEED.get());
|
|
|
- mContext.setVariable(ExpressionConstants.stdSpeedMin, Double.parseDouble(STANDARD_SPEED.split("-")[0]));
|
|
|
- mContext.setVariable(ExpressionConstants.stdSpeedMax, Double.parseDouble(STANDARD_SPEED.split("-")[1]));
|
|
|
- mContext.setVariable(ExpressionConstants.stdPressureDiff, STANDARD_PRESSURE_DIFF.get());
|
|
|
+ mContext.setVariable(ExpressionConstants.stdSpeedMin, Double.parseDouble(StandardConstans.STANDARD_SPEED.split("-")[0]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdSpeedMax, Double.parseDouble(StandardConstans.STANDARD_SPEED.split("-")[1]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdPressureDiff, StandardConstans.STANDARD_PRESSURE_DIFF.get());
|
|
|
// mContext.setVariable(ExpressionConstants.stdIronTime, STANDARD_IRON_TIME.get());
|
|
|
- mContext.setVariable(ExpressionConstants.stdIronTimeMin, Double.parseDouble(STANDARD_IRON_TIME.split("-")[0]));
|
|
|
- mContext.setVariable(ExpressionConstants.stdIronTimeMax, Double.parseDouble(STANDARD_IRON_TIME.split("-")[1]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdIronTimeMin, Double.parseDouble(StandardConstans.STANDARD_IRON_TIME.split("-")[0]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdIronTimeMax, Double.parseDouble(StandardConstans.STANDARD_IRON_TIME.split("-")[1]));
|
|
|
mContext.setVariable(ExpressionConstants.stdServerUrl, SERVER_URL);
|
|
|
// mContext.setVariable(ExpressionConstants.stdTemp, STANDARD_TEMP_DIFF);
|
|
|
- mContext.setVariable(ExpressionConstants.stdTempMin, Double.parseDouble(STANDARD_TEMP.split("-")[0]));
|
|
|
- mContext.setVariable(ExpressionConstants.stdTempMax, Double.parseDouble(STANDARD_TEMP.split("-")[1]));
|
|
|
- mContext.setVariable(ExpressionConstants.stdOpenHour, STANDARD_OPEN_HOUR);
|
|
|
+ mContext.setVariable(ExpressionConstants.stdTempMin, Double.parseDouble(StandardConstans.STANDARD_TEMP.split("-")[0]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdTempMax, Double.parseDouble(StandardConstans.STANDARD_TEMP.split("-")[1]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdOpenHour, StandardConstans.STANDARD_OPEN_HOUR);
|
|
|
// mContext.setVariable(ExpressionConstants.stdIronWeight, STANDARD_IRON_WEIGHT);
|
|
|
- mContext.setVariable(ExpressionConstants.stdIronWeightMin, Double.parseDouble(STANDARD_IRON_WEIGHT.split("-")[0]));
|
|
|
- mContext.setVariable(ExpressionConstants.stdIronWeightMax, Double.parseDouble(STANDARD_IRON_WEIGHT.split("-")[1]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdIronWeightMin, Double.parseDouble(StandardConstans.STANDARD_IRON_WEIGHT.split("-")[0]));
|
|
|
+ mContext.setVariable(ExpressionConstants.stdIronWeightMax, Double.parseDouble(StandardConstans.STANDARD_IRON_WEIGHT.split("-")[1]));
|
|
|
}
|
|
|
- log.info("STANDARD_SPEED: {},PRESSURE_DIFF_VALUE:{}", STANDARD_SPEED, STANDARD_PRESSURE_DIFF);
|
|
|
- log.info("IRON_TIME: {},SERVER_URL:{}", STANDARD_IRON_TIME, SERVER_URL);
|
|
|
+ log.info("STANDARD_SPEED: {},PRESSURE_DIFF_VALUE:{}", StandardConstans.STANDARD_SPEED, StandardConstans.STANDARD_PRESSURE_DIFF);
|
|
|
+ log.info("IRON_TIME: {},SERVER_URL:{}", StandardConstans.STANDARD_IRON_TIME, SERVER_URL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //堵口预警
|
|
|
- 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(
|
|
|
+ scheduleMap = iTIronScheduleService.lambdaQuery().list().stream().collect(Collectors.toMap(
|
|
|
TIronSchedule::getName, // 键映射函数
|
|
|
schedule -> schedule, // 值映射函数
|
|
|
(existing, replacement) -> existing // 合并函数
|
|
|
));
|
|
|
- scheduleOpenWarn = modelMap.get(TaskNameConstants.TASKNAME_OPEN_WARN);
|
|
|
- scheduleClosureWarn = modelMap.get(TaskNameConstants.TASKNAME_CLOSURE_WARN);
|
|
|
- scheduleTappingWarn = modelMap.get(TaskNameConstants.TASKNAME_TAPPING_WARN);
|
|
|
- scheduleTappingTimeoutWarn = modelMap.get(TaskNameConstants.TASKNAME_TAPPING_TIMEOUT_WARN);
|
|
|
- scheduleHitMud = modelMap.get(TaskNameConstants.TASKNAME_HIT_MUD);
|
|
|
- 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);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -435,6 +377,9 @@ public class DeviceEventListener extends EventListener { //
|
|
|
|
|
|
//异步保存OPC数据
|
|
|
taskExecutor.submit(() -> {
|
|
|
+ if(!"1".equals(opcData.getSaveDb())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (opcData.getPointName().contains(SubscribeTagConstants.TAG_TAPHOLE1_STATUS(opcData.getServerType()))) {
|
|
|
double currentVal = Double.parseDouble(opcData.getData().toString());
|
|
|
if (currentVal > 0) {
|
|
@@ -509,9 +454,6 @@ public class DeviceEventListener extends EventListener { //
|
|
|
for (IronStepVO child : stepDTO.getChilds()) {
|
|
|
if (StepConstans.STEP_TLC.equals(child.getIdentifier())) {
|
|
|
if (latest2DataList.size() >= 2) {
|
|
|
- HashMap[] hashMaps = new HashMap[6];
|
|
|
- child.setExtraInfo(hashMaps);
|
|
|
- //理论出铁量 = 矿批 × 综合品位 × 1.06
|
|
|
//铁量差 = 理论出铁量 - 实际出铁量
|
|
|
TL2Data tl2Data1Last = latest2DataList.get(0);
|
|
|
BigDecimal theoryWeightLast = new BigDecimal(tl2Data1Last.getTheoryWeight()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
@@ -519,8 +461,11 @@ public class DeviceEventListener extends EventListener { //
|
|
|
BigDecimal tlcLast = theoryWeightLast.subtract(ironWeightLast).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
TL2Data tl2Data1Grand = latest2DataList.get(1);
|
|
|
- BigDecimal theoryWeightGrand = new BigDecimal(tl2Data1Grand.getTheoryWeight()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal ironWeightGrand = new BigDecimal(tl2Data1Grand.getIronWeight()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //
|
|
|
+ BigDecimal theoryWeightGrand = new BigDecimal(tl2Data1Grand.getTheoryWeight()).add(theoryWeightLast).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //
|
|
|
+ BigDecimal ironWeightGrand = new BigDecimal(tl2Data1Grand.getIronWeight()).add(ironWeightLast).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //近两次铁量差=近两次
|
|
|
BigDecimal tlcGrand = theoryWeightGrand.subtract(ironWeightGrand).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
for (IronStepVO grandChild : child.getChilds()) {
|
|
@@ -600,95 +545,99 @@ public class DeviceEventListener extends EventListener { //
|
|
|
* 3. 清空出铁总量
|
|
|
*/
|
|
|
private void taphole1Start() {
|
|
|
-// mTIronData = new TIronData();
|
|
|
-// mTIronData.setId(ToolUtils.makeUUID());
|
|
|
-// mTIronData.setIronStarttime(LocalDateUtils.formatDate(new Date()));
|
|
|
-// ironDataService.saveOrUpdate(mTIronData);
|
|
|
-
|
|
|
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, () -> {
|
|
|
+ // 关闭所有相关定时任务
|
|
|
+ cancelAllTasks();
|
|
|
+
|
|
|
+ // 出铁计时
|
|
|
+ TIronSchedule tappingConsttime = scheduleMap.get(TaskNameConstants.TASKNAME_TAPPING_CONSTTIME);
|
|
|
+ if (tappingConsttime != null && "1".equals(tappingConsttime.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(tappingConsttime.getName(), tappingConsttime.getDelay(), tappingConsttime.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
getIronTime();
|
|
|
mSecondsElapsed.incrementAndGet();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- //模型四:堵口模型
|
|
|
- if ("1".equals(scheduleClosureWarn.getStatus())) {
|
|
|
- //堵口预警
|
|
|
- scheduledTaskManager.addTask(scheduleClosureWarn.getName(), scheduleClosureWarn.getDelay(), scheduleClosureWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ // 堵口模型
|
|
|
+ TIronSchedule closureWarn = scheduleMap.get(TaskNameConstants.TASKNAME_CLOSURE_WARN);
|
|
|
+ TIronModel modelClosureWarn1 = modelMap.get(ModelConstants.closure_warn1);
|
|
|
+ TIronModel modelClosureWarn2 = modelMap.get(ModelConstants.closure_warn2);
|
|
|
+ TIronModel modelClosureWarn3 = modelMap.get(ModelConstants.closure_warn3);
|
|
|
+ if (closureWarn != null && "1".equals(closureWarn.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(closureWarn.getName(), closureWarn.getDelay(), closureWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
//堵口预警
|
|
|
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);
|
|
|
- log.info("1号铁口出铁状态:{}", ironLoading1.get());
|
|
|
- log.info("2号铁口出铁状态:{}", ironLoading2.get());
|
|
|
- log.info("3号铁口出铁状态:{}", ironLoading3.get());
|
|
|
- log.info("4号铁口出铁状态:{}", ironLoading4.get());
|
|
|
-
|
|
|
+ String modelKey1 = modelClosureWarn1.getModelName();
|
|
|
+ int triggerCount1 = modelClosureWarn1.getTriggerCondCount() != null ? modelClosureWarn1.getTriggerCondCount() : 1;
|
|
|
if (result1) {
|
|
|
- //1.流速过大可能是由于铁口深度不足或发生跑大流问题,则提示将当前铁口堵口
|
|
|
- PushData.send2Warn(WarnData.warnClose("流速过快,请将当前铁口堵口", closureAlarmUrl));
|
|
|
- taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过快,请将当前铁口堵口").build());
|
|
|
- });
|
|
|
- return;
|
|
|
+ int count = closureWarnCountMap.getOrDefault(modelKey1, 0) + 1;
|
|
|
+ closureWarnCountMap.put(modelKey1, count);
|
|
|
+ if (count >= triggerCount1) {
|
|
|
+ PushData.send2Warn(WarnData.warnClose("铁水流速过快告警", closureAlarmUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("7000").exceptionDesc("铁水流速过快告警").build());
|
|
|
+ });
|
|
|
+ closureWarnCountMap.put(modelKey1, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ closureWarnCountMap.put(modelKey1, 0);
|
|
|
}
|
|
|
|
|
|
String modelExpression2 = modelClosureWarn2.getModelExpression();
|
|
|
Expression expression2 = mParser.parseExpression(modelExpression2);
|
|
|
boolean result2 = expression2.getValue(context, Boolean.class);
|
|
|
+ String modelKey2 = modelClosureWarn2.getModelName();
|
|
|
+ int triggerCount2 = modelClosureWarn2.getTriggerCondCount() != null ? modelClosureWarn2.getTriggerCondCount() : 1;
|
|
|
if (result2) {
|
|
|
- //2.若流速过小,但其它铁口正在出铁,则提示将当前铁口堵口
|
|
|
- PushData.send2Warn(WarnData.warnClose("流速过小,请将当前铁口堵口", closureAlarmUrl));
|
|
|
- taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过小,请将当前铁口堵口").build());
|
|
|
- });
|
|
|
- return;
|
|
|
+ int count = closureWarnCountMap.getOrDefault(modelKey2, 0) + 1;
|
|
|
+ closureWarnCountMap.put(modelKey2, count);
|
|
|
+ if (count >= triggerCount2) {
|
|
|
+ PushData.send2Warn(WarnData.warnClose("铁水流速过慢告警", closureAlarmUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("8000").exceptionDesc("铁水流速过慢告警").build());
|
|
|
+ });
|
|
|
+ closureWarnCountMap.put(modelKey2, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ closureWarnCountMap.put(modelKey2, 0);
|
|
|
}
|
|
|
|
|
|
String modelExpression3 = modelClosureWarn3.getModelExpression();
|
|
|
Expression expression3 = mParser.parseExpression(modelExpression3);
|
|
|
boolean result3 = expression3.getValue(context, Boolean.class);
|
|
|
-
|
|
|
+ String modelKey3 = modelClosureWarn3.getModelName();
|
|
|
+ int triggerCount3 = modelClosureWarn3.getTriggerCondCount() != null ? modelClosureWarn3.getTriggerCondCount() : 1;
|
|
|
if (result3) {
|
|
|
- //3.流速过小且其他铁口均未出铁,请先将其它铁口打开,再进行堵口
|
|
|
- PushData.send2Warn(WarnData.warnClose("流速过小且其他铁口均未出铁,请先将其它铁口打开,再进行堵口", closureAlarmUrl));
|
|
|
- taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("4").exceptionDesc("流速过小且其他铁口均未出铁,请先将其它铁口打开,再进行堵口").build());
|
|
|
- });
|
|
|
+ int count = closureWarnCountMap.getOrDefault(modelKey3, 0) + 1;
|
|
|
+ closureWarnCountMap.put(modelKey3, count);
|
|
|
+ if (count >= triggerCount3) {
|
|
|
+ PushData.send2Warn(WarnData.warnClose("铁水流速过慢告警", closureAlarmUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("8000").exceptionDesc("铁水流速过慢告警").build());
|
|
|
+ });
|
|
|
+ closureWarnCountMap.put(modelKey3, 0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ closureWarnCountMap.put(modelKey3, 0);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- //模型二:打泥量选择模型
|
|
|
- if ("1".equals(scheduleHitMud.getStatus())) {
|
|
|
- //xxx分钟出铁后开始计算打泥量,通过打泥量公式
|
|
|
- //打泥量公式关联因素:铁口深度、钻杆直径、调用打泥量模型,计算预计使用多少打泥量进行堵口
|
|
|
- scheduledTaskManager.addTask(scheduleHitMud.getName(), scheduleHitMud.getDelay(), scheduleHitMud.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ // 打泥量选择模型
|
|
|
+ TIronSchedule hitMud = scheduleMap.get(ModelConstants.hit_mud);
|
|
|
+ TIronModel modelHitMud = modelMap.get(ModelConstants.hit_mud);
|
|
|
+ if (hitMud != null && "1".equals(hitMud.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(hitMud.getName(), hitMud.getDelay(), hitMud.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
log.info("打泥量预计:{}", modelHitMud);
|
|
|
TL2Data tappingData = tl2DataService.getLatestData();
|
|
|
if (ObjectUtils.isNotEmpty(tappingData) && ObjectUtils.isNotEmpty(modelHitMud)) {
|
|
@@ -714,34 +663,38 @@ public class DeviceEventListener extends EventListener { //
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- scheduledTaskManager.cancelTask(scheduleHitMud.getName());
|
|
|
+ scheduledTaskManager.cancelTask(hitMud.getName());
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- //出铁超时报警
|
|
|
- if ("1".equals(scheduleTappingTimeoutWarn.getStatus())) {
|
|
|
- scheduledTaskManager.addTask(scheduleTappingTimeoutWarn.getName(), scheduleTappingTimeoutWarn.getDelay(), scheduleTappingTimeoutWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ // 出铁超时报警
|
|
|
+ TIronSchedule tappingTimeoutWarn = scheduleMap.get(TaskNameConstants.TASKNAME_TAPPING_TIMEOUT_WARN);
|
|
|
+ if (tappingTimeoutWarn != null && "1".equals(tappingTimeoutWarn.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(tappingTimeoutWarn.getName(), tappingTimeoutWarn.getDelay(), tappingTimeoutWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
// log.info("已出铁时间(秒):{},标准出铁时间(秒):{}", seconds, STANDARD_IRON_TIME.get());
|
|
|
- if (!RangeUtils.isInRange(STANDARD_IRON_TIME, getIronElapsedMinute())) {
|
|
|
- PushData.send2Warn(WarnData.warnTappingTimeout("出铁时间超时", tappingTimeoutAlramUrl));
|
|
|
+ if (!RangeUtils.isInRange(StandardConstans.STANDARD_IRON_TIME, getIronElapsedMinute())) {
|
|
|
+ PushData.send2Warn(WarnData.warnTappingTimeout("出铁时间过长告警", tappingTimeoutAlramUrl));
|
|
|
taskExecutor.submit(() -> {
|
|
|
- exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("2").exceptionDesc("出铁时间超过设定时间").build());
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("3000").exceptionDesc("出铁时间过长告警").build());
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- if (null != modelClosurePredict && "1".equals(modelClosurePredict.getStatus())) {
|
|
|
+ // 堵口预测
|
|
|
+ TIronSchedule closurePredict = scheduleMap.get(TaskNameConstants.TASKNAME_CLOSURE_PREDICT);
|
|
|
+ TIronModel modelClosurePredict = modelMap.get(ModelConstants.closure_predict);
|
|
|
+ if (null != modelClosurePredict && closurePredict != null && "1".equals(modelClosurePredict.getStatus()) && "1".equals(closurePredict.getStatus())) {
|
|
|
String modelExpression = modelClosurePredict.getModelExpression();
|
|
|
if (null != modelExpression) {
|
|
|
ClosurePredictInfo mClosurePredictInfo = new Gson().fromJson(modelExpression, ClosurePredictInfo.class);
|
|
|
if (null != mClosurePredictInfo) {
|
|
|
- if ("1".equals(scheduleClosurePredict.getStatus())) {
|
|
|
+ if ("1".equals(closurePredict.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, () -> {
|
|
|
+ scheduledTaskManager.addTask(closurePredict.getName(), closurePredict.getDelay(), closurePredict.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
if (mMaxSpeed != 0 && ironLoading1.get() > 0) {
|
|
|
if (this.mLastSpeed == 0) {
|
|
|
this.mLastSpeed = mMaxSpeed;
|
|
@@ -771,24 +724,9 @@ public class DeviceEventListener extends EventListener { //
|
|
|
* 3. 清空出铁总量
|
|
|
*/
|
|
|
private void taphole1End() {
|
|
|
- if (null != mTIronData) {
|
|
|
- mTIronData.setIronCosttime(getIronElapsedMinute());
|
|
|
- mTIronData.setIronWeight(mTotalWeight.doubleValue());
|
|
|
- mTIronData.setIronEndtime(LocalDateUtils.formatDate(new Date()));
|
|
|
- ironDataService.saveOrUpdate(mTIronData);
|
|
|
- //置空,防止和录入的数据干扰到周期出铁数据
|
|
|
- mTIronData = null;
|
|
|
- }
|
|
|
-
|
|
|
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());
|
|
|
+ // 关闭所有相关定时任务
|
|
|
+ cancelAllTasks();
|
|
|
|
|
|
PushData.send2CostTime(new RealtimeData());
|
|
|
PushData.send2CloseTime(new RealtimeData());
|
|
@@ -806,15 +744,13 @@ public class DeviceEventListener extends EventListener { //
|
|
|
//清空打泥量
|
|
|
PushData.send2IronHitMud("");
|
|
|
|
|
|
- //模型一 : 出铁工作诊断模型
|
|
|
- if ("1".equals(scheduleTappingTest.getStatus())) {
|
|
|
- //获取开口耗时、出铁时间、实际出铁量、平均铁水流速、平均铁水温度等数据,进行阈值判定,诊断出铁是否正常
|
|
|
- //结束后xxx秒后诊断
|
|
|
- scheduledTaskManager.addTask(scheduleTappingTest.getName(), scheduleTappingTest.getDelay(), scheduleTappingTest.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ // 出铁诊断模型
|
|
|
+ TIronSchedule tappingTest = scheduleMap.get(TaskNameConstants.TASKNAME_TAPPING_TEST);
|
|
|
+ TIronModel modelTappingTest = modelMap.get(ModelConstants.tapping_test);
|
|
|
+ if (tappingTest != null && "1".equals(tappingTest.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(tappingTest.getName(), tappingTest.getDelay(), tappingTest.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)) {
|
|
@@ -866,23 +802,32 @@ public class DeviceEventListener extends EventListener { //
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
- scheduledTaskManager.cancelTask(scheduleTappingTest.getName());
|
|
|
+ scheduledTaskManager.cancelTask(tappingTest.getName());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- //模型三:预警出铁模型
|
|
|
- if ("1".equals(scheduleTappingWarn.getStatus())) {
|
|
|
- scheduledTaskManager.addTask(scheduleTappingWarn.getName(), scheduleTappingWarn.getDelay(), scheduleTappingWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ // 预警出铁模型
|
|
|
+ TIronSchedule tappingWarn = scheduleMap.get(TaskNameConstants.TASKNAME_TAPPING_WARN);
|
|
|
+ TIronModel modelTappingWarn = modelMap.get(ModelConstants.tapping_warn);
|
|
|
+ if (tappingWarn != null && "1".equals(tappingWarn.getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(tappingWarn.getName(), tappingWarn.getDelay(), tappingWarn.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());
|
|
|
+ String modelKey = modelTappingWarn.getModelName();
|
|
|
+ int triggerCount = modelTappingWarn.getTriggerCondCount() != null ? modelTappingWarn.getTriggerCondCount() : 1;
|
|
|
+ if (Boolean.TRUE.equals(result)) {
|
|
|
+ int count = tappingWarnCountMap.getOrDefault(modelKey, 0) + 1;
|
|
|
+ tappingWarnCountMap.put(modelKey, count);
|
|
|
+ if (count >= triggerCount) {
|
|
|
+ PushData.send2Warn(WarnData.warnTapping("急需出铁告警", tappingAlramUrl));
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("10000").exceptionDesc("急需出铁告警").build());
|
|
|
+ tappingWarnCountMap.put(modelKey, 0);
|
|
|
+ }
|
|
|
} else {
|
|
|
+ tappingWarnCountMap.put(modelKey, 0);
|
|
|
PushData.send2CancelWarn(WarnData.warnTapping("压差正常", ""));
|
|
|
}
|
|
|
}
|
|
@@ -1059,11 +1004,11 @@ public class DeviceEventListener extends EventListener { //
|
|
|
realtimeData.setDesc("出渣状态");
|
|
|
mRealtimeStatus.put(CHUZ_STATUS, realtimeData);
|
|
|
} else if (opcData.getPointName().contains(SubscribeTagConstants.TAG_SZB_STATUS(opcData.getServerType()))
|
|
|
- || opcData.getPointName().contains(SubscribeTagConstants.TAG_CZF_STATUS(opcData.getServerType()))
|
|
|
+ || opcData.getPointName().contains(SubscribeTagConstants.TAG_CZF_STATUS(opcData.getServerType()))
|
|
|
) {
|
|
|
RealtimeData realtimeData = new RealtimeData();
|
|
|
Boolean value = mParser.parseExpression("#szxt999 > 0 and #szb999 > 0").getValue(mContext, Boolean.class);
|
|
|
- realtimeData.setValue(Boolean.TRUE.equals(value) ?"1":"0");
|
|
|
+ realtimeData.setValue(Boolean.TRUE.equals(value) ? "1" : "0");
|
|
|
realtimeData.setDesc("冲渣状态");
|
|
|
mRealtimeStatus.put(CHONGZ_STATUS, realtimeData);
|
|
|
}
|
|
@@ -1312,19 +1257,18 @@ public class DeviceEventListener extends EventListener { //
|
|
|
//
|
|
|
List<TL2Data> tl2DataList = tl2DataService.getTappedLatest2Datas();
|
|
|
getTheoryWeight(tl2DataList);
|
|
|
- } else if (StepConstans.STEP_YPQRCT.equals(stepDTO.getIdentifier()) && stepDTO.getPassResult() == 1) {
|
|
|
- //炉前在接受到炉内出铁要求后,10分钟内打开铁口,未打开系统告警并记录
|
|
|
-
|
|
|
- if ("1".equals(scheduleOpenWarn.getStatus())) {
|
|
|
-// scheduledTaskManager.addTask(scheduleOpenWarn.getName(), scheduleOpenWarn.getDelay(), scheduleOpenWarn.getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
-// log.info("开口预警");
|
|
|
-//
|
|
|
-// // 出铁预警,打开系统告警并记录
|
|
|
-// PushData.send2Warn(WarnData.warnOpen("请立即打开铁口", alarmUrlOpen));
|
|
|
-// taskExecutor.submit(() -> {
|
|
|
-// exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("1").exceptionDesc("打开铁口超时").build());
|
|
|
-// });
|
|
|
-// });
|
|
|
+ } else if (StepConstans.STEP_LQCTCZ.equals(stepDTO.getIdentifier()) && stepDTO.getPassResult() == 1) {
|
|
|
+
|
|
|
+ //炉前出铁操作,10分钟内打开铁口,未打开系统告警并记录
|
|
|
+ if ("1".equals(scheduleMap.get(TaskNameConstants.TASKNAME_OPEN_WARN).getStatus())) {
|
|
|
+ scheduledTaskManager.addTask(scheduleMap.get(TaskNameConstants.TASKNAME_OPEN_WARN).getName(), scheduleMap.get(TaskNameConstants.TASKNAME_OPEN_WARN).getDelay(), scheduleMap.get(TaskNameConstants.TASKNAME_OPEN_WARN).getPeriod(), TimeUnit.SECONDS, () -> {
|
|
|
+ log.info("开口预警");
|
|
|
+ // 出铁预警,打开系统告警并记录
|
|
|
+ PushData.send2Warn(WarnData.warnOpen("急需开口告警", openAlarmUrl));
|
|
|
+ taskExecutor.submit(() -> {
|
|
|
+ exceptionLogService.add(TExceptionLogCreateValidate.builder().exceptionType("12000").exceptionDesc("急需开口告警").build());
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1350,6 +1294,7 @@ public class DeviceEventListener extends EventListener { //
|
|
|
// realtimeData.setDesc("摆动溜嘴状态");
|
|
|
// mRealtimeStatus.put(BDLZ_STATUS, realtimeData);
|
|
|
// }
|
|
|
+
|
|
|
PushData.send2RealtimeStatus(mRealtimeStatus);
|
|
|
}
|
|
|
}
|
|
@@ -1394,17 +1339,6 @@ public class DeviceEventListener extends EventListener { //
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /***
|
|
|
- * 客户端主动获取出铁日期和次数
|
|
|
- * @param client
|
|
|
- */
|
|
|
- @OnEvent(value = PushData.IRON_TIME_NO)
|
|
|
- public void pushIronTimeNo(SocketIOClient client, String flag) {
|
|
|
- if (null == validateClientOnline(client)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
/***
|
|
|
* 用户端连接后进行开始
|
|
@@ -1423,7 +1357,7 @@ public class DeviceEventListener extends EventListener { //
|
|
|
PushData.send2RealtimeData(mRealtimeData);
|
|
|
//推送实时状态
|
|
|
PushData.send2RealtimeStatus(mRealtimeStatus);
|
|
|
- //获取出铁日期和次数
|
|
|
+ //获取最新出铁次数
|
|
|
getIronTimeNo();
|
|
|
}
|
|
|
|
|
@@ -1460,5 +1394,24 @@ public class DeviceEventListener extends EventListener { //
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 统一关闭所有相关定时任务的方法
|
|
|
+ private void cancelAllTasks() {
|
|
|
+ String[] taskNames = {
|
|
|
+ TaskNameConstants.TASKNAME_CLOSURE_WARN,
|
|
|
+ TaskNameConstants.TASKNAME_OPEN_WARN,
|
|
|
+ TaskNameConstants.TASKNAME_TAPPING_WARN,
|
|
|
+ TaskNameConstants.TASKNAME_TAPPING_TIMEOUT_WARN,
|
|
|
+ TaskNameConstants.TASKNAME_HIT_MUD,
|
|
|
+ TaskNameConstants.TASKNAME_TAPPING_CONSTTIME,
|
|
|
+ TaskNameConstants.TASKNAME_TAPPING_TEST,
|
|
|
+ TaskNameConstants.TASKNAME_CLOSURE_PREDICT
|
|
|
+ };
|
|
|
+ for (String name : taskNames) {
|
|
|
+ TIronSchedule schedule = scheduleMap.get(name);
|
|
|
+ if (schedule != null) {
|
|
|
+ scheduledTaskManager.cancelTask(schedule.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|