设备详情

This commit is contained in:
xusd 2024-09-27 15:12:25 +08:00
parent cf373ca5fd
commit 711e5b5675
19 changed files with 438 additions and 84 deletions

View File

@ -104,4 +104,16 @@ public class AlarmDataController {
BeanUtils.toBean(list, AlarmDataRespVO.class));
}
@GetMapping("/getAlarmCountByEquipId/{equipId}")
@Operation(summary = "根据设备id获取报警次数")
public CommonResult<Long> getAlarmCountByEquipId(@PathVariable("equipId") String equipId){
return success(alarmDataService.getAlarmCountByEquipId(equipId));
}
@Operation(summary = "根据设备id获取故障次数")
@GetMapping("/getAlarmDataTimeLineByEquipId/{equipId}")
public CommonResult<List<AlarmDataTimeLineVO>> getAlarmDataTimeLineByEquipId(@PathVariable("equipId") String equipId) {
return success(alarmDataService.getAlarmDataTimeLineByEquipId(equipId));
}
}

View File

@ -0,0 +1,43 @@
package com.inspur.module.system.controller.admin.alarm.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.inspur.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
/**
* 报警数据时间轴
*
* @Author xusd
* @Date 2024/9/27 10:31
**/
@Data
public class AlarmDataTimeLineVO {
/**
* 报警id
*/
private String alarmDataId;
/**
* 报警内容
*/
private String content;
/**
* 报警规则信息名称
*/
private String alarmName;
/**
* 报警时间
*/
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
private Date alarmTime;
/**
* 状态
*/
private Integer status;
}

View File

@ -144,4 +144,11 @@ public class EquipInfoController {
return equipInfoService.cascader();
}
@GetMapping("/details/{id}")
@PreAuthorize("@ss.hasPermission('imt:equip-info:query')")
@Operation(summary = "设备详情")
public CommonResult<EquipInfoDetailsVO> getEquipInfoDetailsById(@PathVariable("id") String id) {
return success(equipInfoService.getEquipInfoDetailsById(id));
}
}

View File

@ -0,0 +1,56 @@
package com.inspur.module.system.controller.equip.vo;
import lombok.Data;
import java.util.List;
/**
* 设备详情
*
* @Author xusd
* @Date 2024/9/26 15:18
**/
@Data
public class EquipInfoDetailsVO {
/**
* 设备id
*/
private String equipId;
/**
* 设备编号
*/
private String equipNo;
/**
* 客户信息id
*/
private String customerId;
/**
* 客户信息
*/
private String customerName;
/**
* 机床型号id
*/
private String modelId;
/**
* 机床型号
*/
private String modelName;
/**
* 机床状态
*/
private Integer status;
/**
* 技术参数
*/
private List<EquipTechnologyParamVO> paramList;
}

View File

@ -0,0 +1,22 @@
package com.inspur.module.system.controller.equip.vo;
import lombok.Data;
/**
* 技术参数
*
* @Author xusd
* @Date 2024/9/27 14:44
**/
@Data
public class EquipTechnologyParamVO {
/**
* 参数名
*/
private String name;
/**
* 参数值
*/
private String value;
}

View File

@ -115,4 +115,10 @@ public class MaintenanceOrderController {
return maintenanceOrderService.submitApprove(id);
}
@Operation(summary = "根据设备id获取故障次数")
@GetMapping("/getMaintenanceCountByEquipId/{equipId}")
public CommonResult<Long> getMaintenanceCountByEquipId(@PathVariable("equipId") String equipId){
return success(maintenanceOrderService.getMaintenanceCountByEquipId(equipId));
}
}

View File

@ -82,4 +82,28 @@ public interface AlarmDataMapper extends BaseMapperX<AlarmDataDO> {
@TenantIgnore
List<ImtIndexAlarmListVO> selectListTop3();
/**
* 根据设备id获取报警次数
*
* @Author xusd
* @Date 10:15 2024/9/27
* @param equipId 设备id
* @return java.lang.Long
*/
@TenantIgnore
default Long getAlarmCountByEquipId(String equipId) {
return selectCount(AlarmDataDO::getEquipId, equipId);
}
/**
* 根据设备id获取故障次数
*
* @Author xusd
* @Date 10:37 2024/9/27
* @param equipId 设备id
* @return java.util.List<com.inspur.module.system.controller.admin.alarm.vo.AlarmDataTimeLineVO>
*/
@TenantIgnore
List<AlarmDataTimeLineVO> getAlarmDataTimeLineByEquipId(@Param("equipId") String equipId);
}

View File

@ -71,4 +71,24 @@ public interface AlarmDataService {
* @return 参数报警记录
*/
AlarmDataDTO getAlarmDataByRulesId(String ruleId);
/**
* 根据设备id获取报警次数
*
* @Author xusd
* @Date 10:13 2024/9/27
* @param equipId 设备id
* @return java.lang.Long
*/
Long getAlarmCountByEquipId(String equipId);
/**
* 根据设备id获取故障次数
*
* @Author xusd
* @Date 10:36 2024/9/27
* @param equipId 设备id
* @return java.util.List<com.inspur.module.system.controller.admin.alarm.vo.AlarmDataTimeLineVO>
*/
List<AlarmDataTimeLineVO> getAlarmDataTimeLineByEquipId(String equipId);
}

View File

@ -123,4 +123,14 @@ public class AlarmDataServiceImpl implements AlarmDataService {
public AlarmDataDTO getAlarmDataByRulesId(String ruleId){
return alarmDataMapper.selectAlarmDataByRulesId(ruleId);
}
@Override
public Long getAlarmCountByEquipId(String equipId) {
return alarmDataMapper.getAlarmCountByEquipId(equipId);
}
@Override
public List<AlarmDataTimeLineVO> getAlarmDataTimeLineByEquipId(String equipId) {
return alarmDataMapper.getAlarmDataTimeLineByEquipId(equipId);
}
}

View File

@ -1,10 +1,7 @@
package com.inspur.module.system.service.equip;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.module.system.controller.equip.vo.EquipCascaderVO;
import com.inspur.module.system.controller.equip.vo.EquipInfoPageReqVO;
import com.inspur.module.system.controller.equip.vo.EquipInfoSaveReqVO;
import com.inspur.module.system.controller.equip.vo.EquipSelectionVO;
import com.inspur.module.system.controller.equip.vo.*;
import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO;
import javax.validation.*;
@ -72,4 +69,14 @@ public interface EquipInfoService {
* @return java.util.List<com.inspur.module.system.controller.equip.vo.EquipCascaderVO>
*/
List<EquipCascaderVO> cascader();
/**
* 设备详情
*
* @Author xusd
* @Date 15:21 2024/9/26
* @param id 设备id
* @return com.inspur.module.system.controller.equip.vo.EquipInfoDetailsVO
*/
EquipInfoDetailsVO getEquipInfoDetailsById(String id);
}

View File

@ -1,26 +1,24 @@
package com.inspur.module.system.service.equip;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.tenant.core.aop.TenantIgnore;
import com.inspur.module.system.controller.baseData.vo.CustomerInfoSelectionVO;
import com.inspur.module.system.controller.equip.vo.EquipCascaderVO;
import com.inspur.module.system.controller.equip.vo.EquipInfoPageReqVO;
import com.inspur.module.system.controller.equip.vo.EquipInfoSaveReqVO;
import com.inspur.module.system.controller.equip.vo.EquipSelectionVO;
import com.inspur.module.system.controller.equip.vo.*;
import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO;
import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO;
import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO;
import com.inspur.module.system.dal.mysql.equip.EquipInfoMapper;
import com.inspur.module.system.enums.ErrorCodeConstants;
import com.inspur.module.system.service.baseData.CustomerInfoService;
import com.inspur.module.system.service.baseData.ModelInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import com.inspur.framework.common.util.object.BeanUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -40,6 +38,9 @@ public class EquipInfoServiceImpl implements EquipInfoService {
@Resource
private CustomerInfoService customerInfoService;
@Resource
private ModelInfoService modelInfoService;
@Override
public String createEquipInfo(EquipInfoSaveReqVO createReqVO) {
// 插入
@ -121,4 +122,51 @@ public class EquipInfoServiceImpl implements EquipInfoService {
}
return list;
}
@Override
public EquipInfoDetailsVO getEquipInfoDetailsById(String id) {
EquipInfoDO equipInfoDO = equipInfoMapper.selectById(id);
if(Objects.nonNull(equipInfoDO)){
EquipInfoDetailsVO vo = BeanUtils.toBean(equipInfoDO, EquipInfoDetailsVO.class);
//设置客户名称
if (Objects.nonNull(vo.getCustomerId())){
CustomerInfoDO customerInfo = customerInfoService.getCustomerInfo(vo.getCustomerId());
if (Objects.nonNull(customerInfo)){
vo.setCustomerName(customerInfo.getCustomerName());
}
}
//设置设备型号
if (Objects.nonNull(vo.getModelId())){
ModelInfoDO modelInfo = modelInfoService.getModelInfo(vo.getModelId());
if (Objects.nonNull(modelInfo)){
//设置设备型号
vo.setModelName(modelInfo.getModelName());
//设置技术参数
String modelSpn = modelInfo.getModelSpn();
if (StrUtil.isNotBlank(modelSpn)){
List<String> split = Arrays.asList(modelSpn.split(";"));
if (CollUtil.isNotEmpty(split)){
List<EquipTechnologyParamVO> list = new ArrayList<>();
if (split.size() > 4) {
List<String> subList = split.subList(4, split.size());
subList.clear();
}
split.forEach(item->{
String[] strings = item.split(":");
if (strings.length == 2){
EquipTechnologyParamVO equipTechnologyParamVO = new EquipTechnologyParamVO();
equipTechnologyParamVO.setName(strings[0]);
equipTechnologyParamVO.setValue(strings[1]);
list.add(equipTechnologyParamVO);
}
});
vo.setParamList(list);
}
}
}
}
return vo;
}
throw exception(ErrorCodeConstants.EQUIP_INFO_NOT_EXISTS);
}
}

View File

@ -102,4 +102,14 @@ public interface MaintenanceOrderService {
* @return java.lang.Boolean
*/
Boolean submitApprove(String id);
/**
* 根据设备id获取故障次数
*
* @Author xusd
* @Date 10:08 2024/9/27
* @param equipId 设备id
* @return java.lang.Long
*/
Long getMaintenanceCountByEquipId(String equipId);
}

View File

@ -255,4 +255,9 @@ public class MaintenanceOrderServiceImpl implements MaintenanceOrderService {
.setStatus(1)
.setApproveStatus(1)) > 0;
}
@Override
public Long getMaintenanceCountByEquipId(String equipId) {
return maintenanceOrderMapper.selectCount(MaintenanceOrderDO::getEquipId,equipId);
}
}

View File

@ -72,4 +72,20 @@
ORDER BY ad.last_alarm_time desc
limit 3
</select>
<select id="getAlarmDataTimeLineByEquipId"
resultType="com.inspur.module.system.controller.admin.alarm.vo.AlarmDataTimeLineVO">
SELECT
iad.alarm_data_id AS alarmDataId,
iad.content AS content,
iad.first_alarm_time AS alarmTime,
iad.status AS status,
CONCAT( iar.alarm_name, '异常故障' ) AS alarmName
FROM
imt_alarm_data AS iad
LEFT JOIN imt_alarm_rules AS iar ON iar.alarm_id = iad.alarm_rules_id
WHERE
iad.equip_id = #{equipId}
ORDER BY alarmTime
limit 5
</select>
</mapper>

View File

@ -59,3 +59,19 @@ export function exportAlarmDataExcel(params) {
responseType: "blob",
});
}
// 根据设备id获取报警次数
export function getAlarmCountByEquipId(equipId) {
return request({
url: "/imt/alarm-data/getAlarmCountByEquipId/" + equipId,
method: "get",
});
}
// 根据设备id获取故障次数
export function getAlarmDataTimeLineByEquipId(equipId) {
return request({
url: "/imt/alarm-data/getAlarmDataTimeLineByEquipId/" + equipId,
method: "get",
});
}

View File

@ -67,3 +67,11 @@ export function getEquipCascader() {
method: 'get'
})
}
// 获得机床详情
export function getEquipInfoDetails(id) {
return request({
url: '/equip/equipInfo/details/' + id,
method: 'get'
})
}

View File

@ -76,3 +76,11 @@ export function submitMaintenanceApprove(id) {
method: 'get'
})
}
// 根据设备id获取故障次数
export function getMaintenanceCountByEquipId(equipId) {
return request({
url: '/maintenance/getMaintenanceCountByEquipId/' + equipId,
method: 'get'
})
}

View File

@ -80,6 +80,9 @@
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['imt:equip-info:delete']">删除
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDetails(scope.row.equipId)"
v-hasPermi="['imt:equip-info:query']">设备详情
</el-button>
</template>
</el-table-column>
</el-table>
@ -143,6 +146,9 @@ export default {
})
},
methods: {
handleDetails(equipId){
this.$router.push({ path: "/equip/equipdetails", query: { equipId: equipId}});
},
/** 查询列表 */
async getList() {
try {

View File

@ -60,6 +60,9 @@
<div>{{ item.value }}</div>
</div>
</div>
<div v-if="!techParamsList.length" style="text-align: center">
暂无数据
</div>
</div>
</div>
<div>
@ -158,8 +161,10 @@
<div class="main-column">
<div class="select-info">
<el-cascader
v-model="value"
v-model="cascaderValue"
:disabled="cascaderDisabled"
:options="options"
:props="{ value: 'id',label: 'name',children: 'children'}"
@change="handleChange"
style="width:50%"
></el-cascader>
@ -279,7 +284,7 @@
<div class="right-column">
<div>
<div class="item-title">
<div class="title"><span style="margin-left:3%">设备运行状态</span>
<div class="title"><span style="margin-left:3%">故障历史信息</span>
</div>
<div class="underline"></div>
</div>
@ -288,15 +293,18 @@
<el-timeline-item
v-for="(item,index) in timeLineList"
:key="index"
:timestamp="item.time"
:timestamp="item.alarmTime"
:type="tranStatusToType(item.status)"
placement="top"
>
<el-card>
<span style="font-weight:bolder;font-size:18px">{{ item.title }}</span>
<span style="font-weight:bolder;font-size:18px">{{ item.alarmName }}</span>
<p>{{ item.content }}</p>
</el-card>
</el-timeline-item>
<el-timeline-item v-if="!timeLineList.length">
暂无数据
</el-timeline-item>
<!-- <el-timeline-item
timestamp="2018/4/12"
placement="top"
@ -334,50 +342,22 @@
import { merge } from "lodash";
import * as EquipAlarmDataApi from "@/api/system/alarm/equipalarmdata";
import * as echarts from "echarts";
import {getEquipCascader, getEquipInfoDetails} from "@/api/system/equip/equipInfo";
import {getAlarmCountByEquipId, getAlarmDataTimeLineByEquipId} from "@/api/system/alarm/alarmdata";
import {getMaintenanceCountByEquipId} from "@/api/system/maintenance/maintenance";
export default {
name: "EquipDetail2",
dicts: ["equip_tags", "equip_class", "equip_status"],
data() {
return {
equipInfo: {
customerName: "智能车床",
modelName: "ZNCC001",
equipNo: "370020001",
status: 0,
},
alarmTimes: 183,
faultTimes: 165,
techParamsList: [
{
name: "技术参数1",
value: 1,
},
{
name: "技术参数2",
value: 2,
},
{
name: "技术参数3",
value: 3,
},
{
name: "技术参数4",
value: 4,
},
],
cascaderDisabled: false,
cascaderValue:{},
equipInfo: {},
alarmTimes: 0,
faultTimes: 0,
techParamsList: [],
equipAlarmList: [],
options: [
{
value: "1",
label: "客户1",
children: [
{
value: "",
label: "MK9820机床液压设备",
},
],
},
],
options: [],
echarts1: null,
echarts2: null,
echarts3: null,
@ -385,36 +365,12 @@ export default {
echarts5: null,
echarts6: null,
echarts7: null,
timeLineList: [
{
time: "2024/9/5 13:00:00",
status: 0,
title: "电流异常故障",
content: "X轴轴承温度超过报警值",
},
{
time: "2024/9/7 19:10:00",
status: 0,
title: "温度异常故障",
content: "Y轴排屑温度超过报警值",
},
{
time: "2024/9/9 15:23:20",
status: 0,
title: "温度异常故障",
content: "Z轴排屑温度超过报警值",
},
{
time: "2024/9/12 10:17:53",
status: 0,
title: "液压异常故障",
content: "X轴润滑液压超过报警值",
},
],
timeLineList: [],
};
},
created() {
this.getEquipAlarmList();
this.initEquipDetails();
},
mounted() {
this.initCharts();
@ -423,6 +379,63 @@ export default {
computed: {},
watch: {},
methods: {
initEquipDetails() {
getEquipCascader().then(res=>{
res.forEach(item=>{
if (item.children == null){
item.disabled = true;
}else {
item.disabled = false;
}
})
this.options = res;
if (this.$route.query.equipId != null){
this.cascaderValue = this.$route.query.equipId;
this.getEquipDetails(this.$route.query.equipId);
this.getAlarmCountByEquipId(this.$route.query.equipId);
this.getMaintenanceCountByEquipId(this.$route.query.equipId);
this.getAlarmDataTimeLineByEquipId(this.$route.query.equipId);
this.cascaderDisabled = true;
}else {
this.options.every(item => {
if (item.disabled === false) {
this.cascaderValue = item.children[0].id;
this.getEquipDetails(item.children[0].id);
this.getAlarmCountByEquipId(item.children[0].id);
this.getMaintenanceCountByEquipId(item.children[0].id);
this.getAlarmDataTimeLineByEquipId(item.children[0].id);
this.cascaderDisabled = false;
return false;
}
})
}
})
},
//
getMaintenanceCountByEquipId(equipId){
getMaintenanceCountByEquipId(equipId).then(res=>{
this.faultTimes = res.data;
})
},
//
getAlarmCountByEquipId(equipId){
getAlarmCountByEquipId(equipId).then(res=>{
this.alarmTimes = res.data;
})
},
//
getAlarmDataTimeLineByEquipId(equipId){
getAlarmDataTimeLineByEquipId(equipId).then(res=>{
this.timeLineList = res.data;
})
},
getEquipDetails(id) {
getEquipInfoDetails(id).then(res => {
console.log("res.data",res.data);
this.equipInfo = res.data;
this.techParamsList = res.data.paramList;
})
},
async getEquipAlarmList() {
var equipAlarmQuery = {
pageSize: 5,
@ -434,15 +447,32 @@ export default {
this.equipAlarmList = res.data.list;
},
handleChange() {},
handleChange(value) {
if (value.length > 0){
this.getEquipDetails(value[1])
this.getAlarmCountByEquipId(value[1]);
this.getMaintenanceCountByEquipId(value[1]);
this.getAlarmDataTimeLineByEquipId(value[1]);
}else {
this.$message.error("请选择一个设备");
}
},
tranStatusToType(status) {
// switch (status) {
// case 0:
// return "success";
// case 1:
// return "warning ";
// case 2:
// return "danger ";
// }
switch (status) {
case 0:
return "success";
return "danger";
case 1:
return "warning ";
return "success";
case 2:
return "danger ";
return "warning";
}
},
initCharts() {