|
@@ -272,9 +272,6 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
|
|
|
private List<Integer> tempList = new CopyOnWriteArrayList<>();
|
|
|
|
|
|
- private static final int warnCount = 3;
|
|
|
-
|
|
|
-
|
|
|
//系统启动后
|
|
|
@EventListener(ApplicationReadyEvent.class)
|
|
|
public void init() {
|
|
@@ -321,7 +318,7 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
|
|
|
|
|
|
/***
|
|
|
- * 更新模型
|
|
|
+ * 出铁模型
|
|
|
*/
|
|
|
private void getModels() {
|
|
|
modelMap = ironModelService.lambdaQuery().eq(TIronModel::getStatus, "1").list().stream().collect(Collectors.toMap(
|
|
@@ -331,6 +328,9 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ /***
|
|
|
+ * 预警音频
|
|
|
+ */
|
|
|
private void getAudios() {
|
|
|
audioMap = audioService.lambdaQuery().eq(TAudio::getStatus, "1").eq(TAudio::getDelFlag, "1").list().stream().collect(Collectors.toMap(
|
|
|
TAudio::getExceptionType, // 键映射函数
|
|
@@ -341,7 +341,7 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
|
|
|
|
|
|
/***
|
|
|
- * 更新参数
|
|
|
+ * 出铁参数
|
|
|
*/
|
|
|
private void getIronParams() {
|
|
|
List<TIronParam> mIronParams = ironParamService.lambdaQuery().eq(TIronParam::getStatus, "1").in(TIronParam::getParamType, "iron_judge", "iron_judge_extra", "server_info").orderByAsc(TIronParam::getSort).list();
|
|
@@ -376,6 +376,8 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
StandardConstans.STANDARD_OPEN_MACHINE_LOCATION = Double.parseDouble(mIronParam.getParamValue());
|
|
|
} else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.mud_machine_value)) {
|
|
|
StandardConstans.STANDARD_MUD_MACHINE_PRESSURE = Double.parseDouble(mIronParam.getParamValue());
|
|
|
+ }else if (Objects.equals(mIronParam.getParamName(), ParamsConstants.warn_count)) {
|
|
|
+ StandardConstans.WARN_COUNT = Integer.parseInt(mIronParam.getParamValue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1338,7 +1340,7 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
// 计算实际数据
|
|
|
int actualIronTime = getIronElapsedMinute();
|
|
|
double actualIronWeight = mTotalWeight.get().setScale(2, RoundingMode.DOWN).doubleValue();
|
|
|
- double actualIronSpeed = actualIronTime == 0 ? 0 : actualIronWeight / actualIronTime;
|
|
|
+ double actualIronSpeed = actualIronTime == 0 ? 0 : BigDecimal.valueOf(actualIronWeight).divide(BigDecimal.valueOf(actualIronTime)).setScale(2, RoundingMode.DOWN).doubleValue();
|
|
|
|
|
|
OptionalDouble averageTemp = tempList.stream()
|
|
|
.mapToInt(Integer::intValue)
|
|
@@ -1758,7 +1760,7 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
mWarnCountMap.put("tempMinWarn", count);
|
|
|
log.warn("检测到温度过低 - 当前: {}℃, 标准最低: {}℃, 连续异常次数: {}", tempNow, stdTempMin, count);
|
|
|
|
|
|
- if (count >= warnCount) {
|
|
|
+ if (count >= StandardConstans.WARN_COUNT) {
|
|
|
log.error("温度过低预警触发 - 连续3次异常,当前温度: {}℃", tempNow);
|
|
|
taskExecutor.submit(() -> {
|
|
|
try {
|
|
@@ -1785,7 +1787,7 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
mWarnCountMap.put("tempMaxWarn", count);
|
|
|
log.warn("检测到温度过高 - 当前: {}℃, 标准最高: {}℃, 连续异常次数: {}", tempNow, stdTempMax, count);
|
|
|
|
|
|
- if (count >= warnCount) {
|
|
|
+ if (count >= StandardConstans.WARN_COUNT) {
|
|
|
log.error("温度过高预警触发 - 连续3次异常,当前温度: {}℃", tempNow);
|
|
|
taskExecutor.submit(() -> {
|
|
|
try {
|
|
@@ -1862,7 +1864,7 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
mWarnCountMap.put("speedMinWarn", count);
|
|
|
log.info("流速过低计数: {}/3", count);
|
|
|
|
|
|
- if (count >= warnCount) {
|
|
|
+ if (count >= StandardConstans.WARN_COUNT) {
|
|
|
PushData.send2Warn(WarnData.warnTapping("铁水流速过慢", audioMap.get(ExceptionTypeEnum.IRON_SPEED_SLOW.getCode())));
|
|
|
log.error("触发流速过低预警");
|
|
|
saveException(ExceptionTypeEnum.IRON_SPEED_SLOW, String.format("流速%s吨/分钟", mMaxSpeed));
|
|
@@ -1877,7 +1879,7 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
int count = mWarnCountMap.getOrDefault("speedMaxWarn", 0) + 1;
|
|
|
mWarnCountMap.put("speedMaxWarn", count);
|
|
|
log.info("流速过高计数: {}/3", count);
|
|
|
- if (count >= warnCount) {
|
|
|
+ if (count >= StandardConstans.WARN_COUNT) {
|
|
|
log.error("触发流速过高预警");
|
|
|
PushData.send2Warn(WarnData.warnTapping("铁水流速过快", audioMap.get(ExceptionTypeEnum.IRON_SPEED_FAST.getCode())));
|
|
|
saveException(ExceptionTypeEnum.IRON_SPEED_FAST, String.format("流速%s吨/分钟", mMaxSpeed));
|
|
@@ -2006,10 +2008,10 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
// 温度队列管理
|
|
|
log.info("🌡️ 【温度队列状态】");
|
|
|
log.info(" ├─ 当前队列长度: {}", lastChuzTemps.size());
|
|
|
- log.info(" ├─ 最大队列长度: {}", warnCount);
|
|
|
+ log.info(" ├─ 最大队列长度: {}", StandardConstans.WARN_COUNT);
|
|
|
log.info(" ├─ 队列内容: {}", lastChuzTemps);
|
|
|
|
|
|
- if (lastChuzTemps.size() >= warnCount) {
|
|
|
+ if (lastChuzTemps.size() >= StandardConstans.WARN_COUNT) {
|
|
|
log.info(" ├─ 队列已满,移除最早数据: {}", lastChuzTemps.getFirst());
|
|
|
lastChuzTemps.removeFirst();
|
|
|
}
|
|
@@ -2378,18 +2380,32 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean isFoundFalsePass(IronStepVO stepDTO, boolean foundFalsePass) {
|
|
|
+ log.info("开始执行isFoundFalsePass方法 - 步骤验证与状态处理");
|
|
|
+ log.info(" ├─ 输入参数: stepId={}, identifier={}, stepName={}, 当前foundFalsePass={}",
|
|
|
+ stepDTO.getStepId(), stepDTO.getIdentifier(), stepDTO.getStepName(), foundFalsePass);
|
|
|
+
|
|
|
validateStepPass(stepDTO);
|
|
|
+ log.info(" ├─ validateStepPass执行完成 - stepId={}, passResult={}",
|
|
|
+ stepDTO.getStepId(), stepDTO.getPassResult());
|
|
|
+
|
|
|
if (!foundFalsePass && 0 == stepDTO.getPassResult()) {
|
|
|
foundFalsePass = true;
|
|
|
+ log.info(" ├─ 首次发现不通过步骤 - stepId={}, 设置foundFalsePass=true", stepDTO.getStepId());
|
|
|
}
|
|
|
+
|
|
|
//父项
|
|
|
if (foundFalsePass) {
|
|
|
+ log.info(" ├─ 存在不通过步骤,开始设置父项状态 - stepId={}, confirmMode={}",
|
|
|
+ stepDTO.getStepId(), stepDTO.getConfirmMode());
|
|
|
stepDTO.setPassResult(0);
|
|
|
if (Objects.equals(stepDTO.getConfirmMode(), "2")) {
|
|
|
//确认模式为手动确认,并且当前步骤不通过的时候重置data,让用户再次点击确认
|
|
|
stepDTO.setData("0");
|
|
|
+ log.info(" ├─ 手动确认模式重置数据 - stepId={}, data已重置为0", stepDTO.getStepId());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ log.info(" ├─ 开始异步记录步骤日志 - stepId={}", stepDTO.getStepId());
|
|
|
taskExecutor.execute(() -> {
|
|
|
//记录每个步骤
|
|
|
if (ObjectUtils.isNotEmpty(stepLogId)) {
|
|
@@ -2399,12 +2415,19 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
stepLog.setStepLogId(stepLogId);
|
|
|
BeanUtils.copyProperties(stepDTO, stepLog);
|
|
|
ironStepLogService.insertOrUpdate(stepLog);
|
|
|
+ log.info(" ├─ 步骤日志记录成功 - stepId={}, stepLogId={}", stepDTO.getStepId(), stepLogId);
|
|
|
} catch (Exception e) {
|
|
|
+ log.error(" ├─ 步骤日志记录失败 - stepId={}, error={}", stepDTO.getStepId(), e.getMessage());
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ log.warn(" ├─ 步骤日志记录跳过 - stepLogId为空");
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ log.info("isFoundFalsePass方法执行完成 - stepId={}, 最终返回foundFalsePass={}",
|
|
|
+ stepDTO.getStepId(), foundFalsePass);
|
|
|
return foundFalsePass;
|
|
|
}
|
|
|
|
|
@@ -2413,42 +2436,69 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
* 判断是否通过
|
|
|
* @param stepVO
|
|
|
*/
|
|
|
+ /***
|
|
|
+ * 判断是否通过
|
|
|
+ * @param stepVO
|
|
|
+ */
|
|
|
private void validateStepPass(IronStepVO stepVO) {
|
|
|
+ log.info("开始验证步骤: stepId={}, identifier={}, stepName={}, required={}",
|
|
|
+ stepVO.getStepId(), stepVO.getIdentifier(), stepVO.getStepName(), stepVO.getRequired());
|
|
|
+
|
|
|
String dataExpression = stepVO.getDataExpression();
|
|
|
if (ObjectUtils.isNotEmpty(dataExpression)) {
|
|
|
+ log.info("步骤 {} 存在数据表达式: {}", stepVO.getStepId(), dataExpression);
|
|
|
try {
|
|
|
Object value = mParser.parseExpression(dataExpression).getValue(mContext, Object.class);
|
|
|
stepVO.setData(value);
|
|
|
+ log.info("数据表达式执行成功: stepId={}, expression={}, result={}",
|
|
|
+ stepVO.getStepId(), dataExpression, value);
|
|
|
} catch (Exception e) {
|
|
|
- //log.info("{}执行失败", dataExpression);
|
|
|
+ log.error("数据表达式执行失败: stepId={}, expression={}, error={}",
|
|
|
+ stepVO.getStepId(), dataExpression, e.getMessage());
|
|
|
}
|
|
|
+ } else {
|
|
|
+ log.info("步骤 {} 无数据表达式,跳过数据解析", stepVO.getStepId());
|
|
|
}
|
|
|
|
|
|
//根据唯一名称设置环境变量
|
|
|
mContext.setVariable(stepVO.getIdentifier(), stepVO.getData());
|
|
|
+ log.info("设置环境变量: identifier={}, data={}", stepVO.getIdentifier(), stepVO.getData());
|
|
|
+
|
|
|
String flowName = "";
|
|
|
try {
|
|
|
if ("calc".equalsIgnoreCase(stepVO.getNodeType())) {
|
|
|
//含有表达式文字
|
|
|
+ log.info("步骤 {} 为计算类型,解析步骤名称表达式: {}", stepVO.getStepId(), stepVO.getStepNameExpression());
|
|
|
flowName = mParser.parseExpression(stepVO.getStepNameExpression()).getValue(mContext, String.class);
|
|
|
} else {
|
|
|
//纯文字
|
|
|
+ log.info("步骤 {} 为纯文本类型,使用原始步骤名称: {}", stepVO.getStepId(), stepVO.getStepName());
|
|
|
flowName = mParser.parseExpression("'" + stepVO.getStepName() + "'").getValue(mContext, String.class);
|
|
|
}
|
|
|
stepVO.setStepName(flowName);
|
|
|
+ log.info("步骤名称解析完成: stepId={}, finalStepName={}", stepVO.getStepId(), flowName);
|
|
|
} catch (Exception e) {
|
|
|
- //log.info("stepId:{},identifier:{},stepName:{}", stepVO.getStepId(), stepVO.getIdentifier(), flowName);
|
|
|
+ log.error("步骤名称解析失败: stepId={}, identifier={}, stepName={}, error={}",
|
|
|
+ stepVO.getStepId(), stepVO.getIdentifier(), stepVO.getStepName(), e.getMessage());
|
|
|
}
|
|
|
|
|
|
boolean result = true;
|
|
|
//通过条件不为空执行表达式
|
|
|
if (ObjectUtils.isNotEmpty(stepVO.getStepCondition())) {
|
|
|
+ log.info("步骤 {} 存在通过条件: {}", stepVO.getStepId(), stepVO.getStepCondition());
|
|
|
try {
|
|
|
result = mParser.parseExpression(stepVO.getStepCondition()).getValue(mContext, Boolean.class);
|
|
|
+ stepVO.setPassResult(result ? 1 : 0);
|
|
|
+ log.info("通过条件执行完成: stepId={}, condition={}, result={}, passResult={}",
|
|
|
+ stepVO.getStepId(), stepVO.getStepCondition(), result, stepVO.getPassResult());
|
|
|
} catch (Exception e) {
|
|
|
result = false;
|
|
|
+ stepVO.setPassResult(0);
|
|
|
+ log.error("通过条件执行异常: stepId={}, condition={}, error={}, 设置为不通过",
|
|
|
+ stepVO.getStepId(), stepVO.getStepCondition(), e.getMessage());
|
|
|
}
|
|
|
- stepVO.setPassResult(result ? 1 : 0);
|
|
|
+ } else {
|
|
|
+ log.info("步骤 {} 无通过条件,保持默认状态", stepVO.getStepId());
|
|
|
}
|
|
|
|
|
|
Map<String, Object> extraInfo = new HashMap<>();
|
|
@@ -2461,20 +2511,26 @@ public class DeviceEventListener extends AbstractEventListener { //
|
|
|
|| "ccfj".equals(stepVO.getIdentifier()) //除尘风机
|
|
|
|| "ccf".equals(stepVO.getIdentifier()) //除尘阀
|
|
|
) {
|
|
|
+ log.info("步骤 {} 为关键设备标识: {}, 设置颜色标记", stepVO.getStepId(), stepVO.getIdentifier());
|
|
|
if (result) {
|
|
|
extraInfo.put("colorFlag", 0);
|
|
|
+ log.info("设备状态正常: identifier={}, colorFlag=0", stepVO.getIdentifier());
|
|
|
} else {
|
|
|
extraInfo.put("colorFlag", -1);
|
|
|
+ log.warn("设备状态异常: identifier={}, colorFlag=-1", stepVO.getIdentifier());
|
|
|
}
|
|
|
}
|
|
|
stepVO.setExtraInfo(extraInfo);
|
|
|
-
|
|
|
+ log.info("额外信息设置完成: stepId={}, extraInfo={}", stepVO.getStepId(), extraInfo);
|
|
|
|
|
|
//非流程必须项,直接放行
|
|
|
if ("0".equals(stepVO.getRequired())) {
|
|
|
stepVO.setPassResult(1);
|
|
|
+ log.info("非必须步骤直接放行: stepId={}, required=0", stepVO.getStepId());
|
|
|
}
|
|
|
|
|
|
+ log.info("步骤验证完成: stepId={}, identifier={}, finalPassResult={}, stepName={}",
|
|
|
+ stepVO.getStepId(), stepVO.getIdentifier(), stepVO.getPassResult(), stepVO.getStepName());
|
|
|
}
|
|
|
|
|
|
/***
|