Compare commits
3 Commits
5abebfbc30
...
05d1931c2f
Author | SHA1 | Date | |
---|---|---|---|
05d1931c2f | |||
1edca208be | |||
7a44b8351f |
@ -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<EquipInfoDO> 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<String, Object> diffDataMap = new HashMap<>();
|
||||
Map<String, Object> diffDataMap1= selectDiffDataByColumnNameandDate(null, "gateway_channel_temp_data", "x_bear_temp", beginTime, endTime);
|
||||
Map<String, Object> 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"));
|
||||
for (EquipInfoDO equipInfoDO : equipInfoList) {
|
||||
String equid = equipInfoDO.getEquipId();
|
||||
List<AlarmRulesRespDTO> rules = alarmRulesApi.selectAlarmRulesListByCatch(equid);
|
||||
if(rules != null && rules.size() > 0){//预警规则过滤
|
||||
rules = rules.stream().filter(ruleData->ruleData.getType() == 1).collect(Collectors.toList());
|
||||
Map<String, Object> diffDataMap = new HashMap<>();
|
||||
rules.forEach(ruleData->{
|
||||
Map<String, Object> 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);
|
||||
logger.info("本次趋势报警产生预警{}条",alarmNum);
|
||||
}
|
||||
}
|
||||
// Map<String, Object> diffDataMap = new HashMap<>();
|
||||
// Map<String, Object> diffDataMap1= selectDiffDataByColumnNameandDate(null, "gateway_channel_temp_data", "x_bear_temp", beginTime, endTime);
|
||||
// Map<String, Object> 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<AlarmRulesRespDTO> rules = alarmRulesApi.selectAlarmRulesListByCatch(equid);
|
||||
// if(rules != null && rules.size() > 0){//预警规则过滤
|
||||
// int alarmNum = alarmRulesApi.trendAlarmRulesFilter(diffDataMap, rules);
|
||||
// logger.info("本次趋势报警产生预警{}条",alarmNum);
|
||||
// }
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
@ -74,5 +74,8 @@ public class AlarmRulesRespDTO {
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -62,4 +62,6 @@ public class AlarmRulesSaveReqVO {
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "influxdb表名")
|
||||
private String tableName;
|
||||
}
|
@ -93,4 +93,8 @@ public class AlarmRulesDO extends BaseDO {
|
||||
* 租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
}
|
@ -103,4 +103,9 @@ public class AlarmRulesDTO {
|
||||
* 组件名
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ public interface AlarmRulesMapper extends BaseMapperX<AlarmRulesDO> {
|
||||
return selectJoinOne(AlarmRulesDTO.class,new MPJLambdaWrapperX<AlarmRulesDO>()
|
||||
.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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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("新增维修工单通知");
|
||||
|
@ -15,15 +15,73 @@
|
||||
v-loading="formLoading"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-col :span="10">
|
||||
<el-form-item
|
||||
label="机床设备"
|
||||
prop="equipId"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.equipName"
|
||||
:disabled="true"
|
||||
placeholder="请选择机床设备"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"> <el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleSeclectInfo"
|
||||
>
|
||||
选择机床
|
||||
</el-button></el-col>
|
||||
<el-col :span="10">
|
||||
<el-form-item
|
||||
label="机床组件"
|
||||
prop="componentId"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.componentName"
|
||||
:disabled="true"
|
||||
placeholder="请输入机床组件"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"> <el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleSeclectComponent"
|
||||
>
|
||||
选择组件
|
||||
</el-button></el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item
|
||||
label="规则关键字"
|
||||
prop="alarmNameKey"
|
||||
>
|
||||
<el-input
|
||||
<!-- <el-input
|
||||
v-model="formData.alarmNameKey"
|
||||
placeholder="请输入规则关键字"
|
||||
/>
|
||||
/> -->
|
||||
<div
|
||||
v-if="!this.formData.alarmNameKey"
|
||||
class="block"
|
||||
>
|
||||
<el-cascader
|
||||
v-model="paramsData"
|
||||
:disabled="this.formData.equipId == null"
|
||||
:options="options"
|
||||
:props="paramsProps"
|
||||
collapse-tagss
|
||||
@change="paramsSelectChange"
|
||||
placeholder="请先选择设备,再选择参数"
|
||||
style="width:100%"
|
||||
></el-cascader>
|
||||
</div>
|
||||
<div v-else><span>{{ this.selectedNameKey }}</span> <el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
@click="changeNameKey"
|
||||
>修改</el-button></div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -67,44 +125,6 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<el-form-item
|
||||
label="机床设备"
|
||||
prop="equipId"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.equipNo"
|
||||
:disabled="true"
|
||||
placeholder="请输入机床设备"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"> <el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleSeclectInfo"
|
||||
>
|
||||
选择机床
|
||||
</el-button></el-col>
|
||||
<el-col :span="10">
|
||||
<el-form-item
|
||||
label="机床组件"
|
||||
prop="componentId"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.componentName"
|
||||
:disabled="true"
|
||||
placeholder="请输入机床组件"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2"> <el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleSeclectComponent"
|
||||
>
|
||||
选择组件
|
||||
</el-button></el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item
|
||||
label="规则描述"
|
||||
@ -270,6 +290,7 @@ import * as AlarmRulesApi from "@/api/system/alarm/alarmrules";
|
||||
import EquipInfoTable from "./EquipInfoTable.vue";
|
||||
import ComponentInfoTable from "./ComponentInfoTable.vue";
|
||||
import Editor from "@/components/Editor";
|
||||
import { getGatewayCardTree } from "@/api/system/gatewayinfo/card";
|
||||
export default {
|
||||
name: "AlarmRulesForm",
|
||||
props: {
|
||||
@ -306,6 +327,7 @@ export default {
|
||||
referenceCon: undefined,
|
||||
alarmLevel: undefined,
|
||||
sort: undefined,
|
||||
tableName: undefined,
|
||||
},
|
||||
// 表单校验
|
||||
formRules: {
|
||||
@ -402,9 +424,41 @@ export default {
|
||||
openComp: false,
|
||||
// 弹出组件层标题
|
||||
titleComp: "",
|
||||
options: [],
|
||||
paramsProps: {},
|
||||
paramsData: [],
|
||||
selectedNameKey: "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeNameKey() {
|
||||
this.formData.alarmNameKey = null;
|
||||
},
|
||||
paramsSelectChange(e) {
|
||||
if (this.paramsData && this.paramsData[1]) {
|
||||
this.formData.alarmNameKey = this.selectedNameKey =
|
||||
this.ruleType == "threshold"
|
||||
? this.paramsData[1]
|
||||
: this.paramsData[1] + "_diff";
|
||||
// this.formData.alarmNameKey = this.paramsData[1];
|
||||
this.formData.tableName = this.paramsData[0];
|
||||
} else {
|
||||
this.$message({
|
||||
message: "选择的参数无效,请重新选择参数或者重选设备",
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
},
|
||||
async getParamsTree(equipId) {
|
||||
const cardTree = await getGatewayCardTree(equipId);
|
||||
var treeData = [];
|
||||
this.options = cardTree.data;
|
||||
// this.options.forEach((e) => {
|
||||
// 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");
|
||||
},
|
||||
},
|
||||
|
@ -521,7 +521,11 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if (this.$route.query.orderId) {
|
||||
this.getQueryData();
|
||||
} else {
|
||||
this.getList();
|
||||
}
|
||||
this.initSelection();
|
||||
},
|
||||
methods: {
|
||||
@ -637,6 +641,16 @@ export default {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
/**跳转查询 */
|
||||
async getQueryData() {
|
||||
this.loading = true;
|
||||
const res = await RemoteMaintenanceOrderApi.getRemoteMaintenanceOrder(
|
||||
this.$route.query.orderId
|
||||
);
|
||||
this.list = [res.data];
|
||||
this.total = this.list.length;
|
||||
this.loading = false;
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNo = 1;
|
||||
|
@ -108,6 +108,7 @@
|
||||
label="发送时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
sortable
|
||||
width="180"
|
||||
>
|
||||
<template v-slot="scope">
|
||||
@ -195,9 +196,16 @@
|
||||
v-show="scope.row.orderId && scope.row.type === 3"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-check"
|
||||
icon="el-icon-tickets"
|
||||
@click="handle2MaintenanceOrder(scope.row.orderId)"
|
||||
>维修工单</el-button>
|
||||
<el-button
|
||||
v-show="scope.row.orderId && scope.row.type === 4"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-tickets"
|
||||
@click="handle2InspectionOrder(scope.row.orderId)"
|
||||
>点检工单</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -299,6 +307,12 @@ export default {
|
||||
query: { orderId: orderId },
|
||||
});
|
||||
},
|
||||
handle2InspectionOrder(orderId) {
|
||||
this.$router.push({
|
||||
path: "/maintenance/inspection-info",
|
||||
query: { orderId: orderId },
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user