diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/job/TrendAlarmDataTimeoutJob.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/job/TrendAlarmDataTimeoutJob.java index 52bc822..612ac39 100644 --- a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/job/TrendAlarmDataTimeoutJob.java +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/job/TrendAlarmDataTimeoutJob.java @@ -2,23 +2,26 @@ package com.inspur.module.data.job; import com.inspur.framework.common.util.date.DateUtils; import com.inspur.framework.quartz.core.handler.JobHandler; -import com.inspur.framework.tenant.core.job.TenantJob; +import com.inspur.framework.tenant.core.aop.TenantIgnore; import com.inspur.module.data.service.InfluxDBService; import com.inspur.module.system.api.alarm.AlarmRulesApi; import com.inspur.module.system.api.alarm.dto.AlarmRulesRespDTO; +import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO; +import com.inspur.module.system.service.equip.EquipInfoService; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 趋势报警定时任务 @@ -37,28 +40,53 @@ public class TrendAlarmDataTimeoutJob implements JobHandler { @Resource private AlarmRulesApi alarmRulesApi; + @Resource + private EquipInfoService equipInfoService; + @Override + @TenantIgnore public String execute(String param) throws Exception { - String equid = "2e3d0190e63eda526da89d6c751f08f3";//TODO 固定 + List equipInfoList = equipInfoService.getAllEquipInfoList(); + if(equipInfoList.isEmpty()){ + return "没有可用设备!"; + } +// String equid = "2e3d0190e63eda526da89d6c751f08f3";//TODO 固定 +// ZoneId zoneId = ZoneId.systemDefault(); +// LocalDateTime now = LocalDateTime.now(zoneId); +// LocalDateTime onedayBefore = now.minusDays(1); + LocalDate today = LocalDate.now(); + LocalDate yesterday = today.minusDays(1); + LocalDateTime startOfYesterday = yesterday.atStartOfDay(); + LocalDateTime endOfYesterday = LocalDateTime.of(yesterday, LocalTime.MAX); + String beginTime = DateUtils.localDateTimeToUTC(startOfYesterday); + String endTime = DateUtils.localDateTimeToUTC(endOfYesterday); //读取并计算需要过滤的数据:如温度差 - ZoneId zoneId = ZoneId.systemDefault(); - LocalDateTime now = LocalDateTime.now(zoneId); - LocalDateTime onedayBefore = now.minusDays(1); - String beginTime = DateUtils.localDateTimeToUTC(onedayBefore); - String endTime = DateUtils.localDateTimeToUTC(now); - //TODO 最好是从数据库中读取(需要趋势报警的参数名,参数值等) - Map diffDataMap = new HashMap<>(); - Map diffDataMap1= selectDiffDataByColumnNameandDate(null, "gateway_channel_temp_data", "x_bear_temp", beginTime, endTime); - Map diffDataMap2 = selectDiffDataByColumnNameandDate(null, "gateway_channel_vibr_data", "x_entropy", beginTime, endTime); - diffDataMap.putAll(diffDataMap1); - diffDataMap.putAll(diffDataMap2); + for (EquipInfoDO equipInfoDO : equipInfoList) { + String equid = equipInfoDO.getEquipId(); + List rules = alarmRulesApi.selectAlarmRulesListByCatch(equid); + if(rules != null && rules.size() > 0){//预警规则过滤 + rules = rules.stream().filter(ruleData->ruleData.getType() == 1).collect(Collectors.toList()); + Map diffDataMap = new HashMap<>(); + rules.forEach(ruleData->{ + Map dataMap = selectDiffDataByColumnNameandDate(equid, ruleData.getTableName(), ruleData.getAlarmNameKey().substring(0,ruleData.getAlarmNameKey().lastIndexOf("_")), beginTime, endTime); + diffDataMap.putAll(dataMap); + }); + int alarmNum = alarmRulesApi.trendAlarmRulesFilter(diffDataMap, rules); + logger.info("本次趋势报警产生预警{}条",alarmNum); + } + } +// Map diffDataMap = new HashMap<>(); +// Map diffDataMap1= selectDiffDataByColumnNameandDate(null, "gateway_channel_temp_data", "x_bear_temp", beginTime, endTime); +// Map diffDataMap2 = selectDiffDataByColumnNameandDate(null, "gateway_channel_vibr_data", "x_entropy", beginTime, endTime); +// diffDataMap.putAll(diffDataMap1); +// diffDataMap.putAll(diffDataMap2); // logger.info("查询设备数据差值:" + diffDataMap.get("x_bear_temp_diff")); // logger.info("查询设备数据差值:" + diffDataMap.get("x_entropy_diff")); - List rules = alarmRulesApi.selectAlarmRulesListByCatch(equid); - if(rules != null && rules.size() > 0){//预警规则过滤 - int alarmNum = alarmRulesApi.trendAlarmRulesFilter(diffDataMap, rules); - logger.info("本次产生预警{}条",alarmNum); - } +// List rules = alarmRulesApi.selectAlarmRulesListByCatch(equid); +// if(rules != null && rules.size() > 0){//预警规则过滤 +// int alarmNum = alarmRulesApi.trendAlarmRulesFilter(diffDataMap, rules); +// logger.info("本次趋势报警产生预警{}条",alarmNum); +// } return "success"; } diff --git a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/api/alarm/dto/AlarmRulesRespDTO.java b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/api/alarm/dto/AlarmRulesRespDTO.java index c6fb7f2..150ad08 100644 --- a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/api/alarm/dto/AlarmRulesRespDTO.java +++ b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/api/alarm/dto/AlarmRulesRespDTO.java @@ -74,5 +74,8 @@ public class AlarmRulesRespDTO { * 排序 */ private Integer sort; - + /** + * 表名 + */ + private String tableName; } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesRespVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesRespVO.java index f6b5df9..1424a7b 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesRespVO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesRespVO.java @@ -84,6 +84,10 @@ public class AlarmRulesRespVO { @ExcelProperty("设备型号") private String equipNo; + @Schema(description = "设备名称") + @ExcelProperty("设备名称") + private String equipName; + @Schema(description = "客户名称") @ExcelProperty("客户名称") private String customerName; @@ -91,4 +95,8 @@ public class AlarmRulesRespVO { @Schema(description = "组件名称") @ExcelProperty("组件名称") private String componentName; + + @Schema(description = "表名") + @ExcelProperty("表名") + private String tableName; } \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesSaveReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesSaveReqVO.java index d54200d..9d4dfa6 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesSaveReqVO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/alarm/vo/AlarmRulesSaveReqVO.java @@ -62,4 +62,6 @@ public class AlarmRulesSaveReqVO { @Schema(description = "排序") private Integer sort; + @Schema(description = "influxdb表名") + private String tableName; } \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java index 081be56..7e6c34b 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java @@ -93,4 +93,8 @@ public class AlarmRulesDO extends BaseDO { * 租户编号 */ private Long tenantId; + /** + * 表名 + */ + private String tableName; } \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDTO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDTO.java index 91538e7..684e7a2 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDTO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDTO.java @@ -103,4 +103,9 @@ public class AlarmRulesDTO { * 组件名 */ private String componentName; + + /** + * 表名 + */ + private String tableName; } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmRulesMapper.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmRulesMapper.java index e2c3784..51d1266 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmRulesMapper.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/alarm/AlarmRulesMapper.java @@ -83,6 +83,7 @@ public interface AlarmRulesMapper extends BaseMapperX { return selectJoinOne(AlarmRulesDTO.class,new MPJLambdaWrapperX() .selectAll(AlarmRulesDO.class) .selectAs(EquipInfoDO::getEquipNo, AlarmRulesDTO::getEquipNo) + .selectAs(EquipInfoDO::getEquipName, AlarmRulesDTO::getEquipName) .selectAs(ModelInfoDO::getModelName, AlarmRulesDTO::getModelName) .selectAs(CustomerInfoDO::getCustomerName, AlarmRulesDTO::getCustomerName) .leftJoin(EquipInfoDO.class, EquipInfoDO::getEquipId, AlarmRulesDO::getEquipId) diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionInfoServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionInfoServiceImpl.java index 1e6db16..0d9011c 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionInfoServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/inspection/InspectionInfoServiceImpl.java @@ -8,15 +8,19 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.inspur.framework.common.exception.ServiceException; import com.inspur.framework.common.pojo.PageResult; +import com.inspur.framework.security.core.util.SecurityFrameworkUtils; import com.inspur.framework.tenant.core.aop.TenantIgnore; +import com.inspur.module.system.constant.NoticeType; import com.inspur.module.system.controller.inspection.vo.*; import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO; import com.inspur.module.system.dal.dataobject.inspection.InspectionInfoDO; import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceOrderDO; +import com.inspur.module.system.dal.dataobject.notify.NotifyMessageDO; import com.inspur.module.system.dal.mysql.inspection.InspectionInfoMapper; import com.inspur.module.system.service.alarm.AlarmDataService; import com.inspur.module.system.service.baseData.CustomerInfoService; import com.inspur.module.system.service.maintenance.MaintenanceOrderService; +import com.inspur.module.system.service.notify.NotifyMessageService; import org.aspectj.weaver.ast.Var; import org.springframework.stereotype.Service; @@ -56,6 +60,9 @@ public class InspectionInfoServiceImpl implements InspectionInfoService { @Resource private AlarmDataService alarmDataService; + @Resource + private NotifyMessageService notifyMessageService; + @Override @TenantIgnore public String createInspectionInfo(InspectionInfoSaveReqVO createReqVO) { @@ -71,6 +78,19 @@ public class InspectionInfoServiceImpl implements InspectionInfoService { inspectionInfo.setInspectionNo("DJGD" + DateUtil.format(new Date(),"yyyyMMddHHmmss") + RandomUtil.randomInt(1, 10)); inspectionInfo.setStatus(0); inspectionInfoMapper.insert(inspectionInfo); + + //消息推送 + NotifyMessageDO noticeMessageDO = new NotifyMessageDO() + .setOrderId(inspectionInfo.getInspectionId()) + .setTitle("新增点检工单通知") + .setContent("您有一个新的点检工单,请及时处理!") + .setType(NoticeType.INSPECTION_ORDER) + .setReadStatus(false) + .setUserId(SecurityFrameworkUtils.getLoginUserId()) + .setTemplateNickname(SecurityFrameworkUtils.getLoginUserNickname()) + .setTenantId(inspectionInfo.getTenantId()); + notifyMessageService.createNotifyMessage(noticeMessageDO); + // 返回 return inspectionInfo.getInspectionId(); } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java index 2207ae3..5a93b5d 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceOrderServiceImpl.java @@ -155,8 +155,6 @@ public class MaintenanceOrderServiceImpl implements MaintenanceOrderService { maintenanceOrderMapper.updateById(new MaintenanceOrderDO().setMaintenanceOrderId(remoteMaintenanceOrder.getMaintenanceOrderId()).setProcessInstanceId(processInstanceId)); } //消息推送 -// NoticeSaveReqVO noticeSaveReqVO = new NoticeSaveReqVO(null, "维修工单", NoticeType.MAINTENANCE_ORDER,"您有一个新的维修工单,请及时处理!", 0, remoteMaintenanceOrder.getTenantId(), remoteMaintenanceOrder.getMaintenanceOrderId()); -// noticeService.createNotice(noticeSaveReqVO); NotifyMessageDO noticeMessageDO = new NotifyMessageDO(); noticeMessageDO.setOrderId(remoteMaintenanceOrder.getMaintenanceOrderId()); noticeMessageDO.setTitle("新增维修工单通知"); diff --git a/imt-ui/src/views/system/alarm/alarmrules/AlarmRulesForm.vue b/imt-ui/src/views/system/alarm/alarmrules/AlarmRulesForm.vue index 0c9ac0b..c8666d9 100644 --- a/imt-ui/src/views/system/alarm/alarmrules/AlarmRulesForm.vue +++ b/imt-ui/src/views/system/alarm/alarmrules/AlarmRulesForm.vue @@ -15,15 +15,73 @@ v-loading="formLoading" label-width="100px" > + + + + + + + 选择机床 + + + + + + + + 选择组件 + - + /> --> +
+ +
+
{{ this.selectedNameKey }} 修改
@@ -67,44 +125,6 @@ - - - - - - - 选择机床 - - - - - - - - 选择组件 - { + // e.children = null; + // treeData.push(e); + // }); + // this.options = treeData; + }, /** 报警上限值校验 */ validateUpper(rule, value, callback) { if ( @@ -471,9 +525,11 @@ export default { }, /** 获取选中设备 */ getEqu(data) { - console.log("-->>选择的设备是", data); + // console.log("-->>选择的设备是", data); this.formData.equipId = data.equipId; this.formData.equipNo = data.equipNo; + this.formData.equipName = data.equipName; + this.getParamsTree(data.equipId); // this.form.equipOrder = data.equipOrder; // this.form.equipName = data.equipName; // this.form.equipId = data.id; @@ -502,6 +558,8 @@ export default { try { const res = await AlarmRulesApi.getAlarmRules(id); this.formData = res.data; + this.selectedNameKey = res.data.alarmNameKey; + this.dialogTitle = "修改机床报警规则"; } finally { this.formLoading = false; @@ -555,7 +613,9 @@ export default { sort: undefined, equipName: undefined, componentName: undefined, + tableName: undefined, }; + this.selectedNameKey = null; this.resetForm("formRef"); }, }, diff --git a/imt-ui/src/views/system/notify/my/index.vue b/imt-ui/src/views/system/notify/my/index.vue index d1d5699..1fcec67 100644 --- a/imt-ui/src/views/system/notify/my/index.vue +++ b/imt-ui/src/views/system/notify/my/index.vue @@ -199,6 +199,13 @@ icon="el-icon-tickets" @click="handle2MaintenanceOrder(scope.row.orderId)" >维修工单 + 点检工单 @@ -300,6 +307,12 @@ export default { query: { orderId: orderId }, }); }, + handle2InspectionOrder(orderId) { + this.$router.push({ + path: "/maintenance/inspection-info", + query: { orderId: orderId }, + }); + }, }, };