Compare commits

..

2 Commits

Author SHA1 Message Date
b83566427a 设备报警功能更新 2024-09-03 18:01:55 +08:00
a9d714211d 设备报警功能更新 2024-09-03 18:01:13 +08:00
23 changed files with 2023 additions and 26 deletions

View File

@ -175,5 +175,9 @@ public interface ErrorCodeConstants {
// ========== 设备管理模块 ==========
ErrorCode GATEWAY_INFO_NOT_EXISTS = new ErrorCode(1_002_029_000, "机床网关信息不存在");
ErrorCode ALARM_RULES_NOT_EXISTS = new ErrorCode(1_002_029_001, "机床报警规则不存在");
// ========== 报警管理模块 ==========
ErrorCode ALARM_RULES_NOT_EXISTS = new ErrorCode(1_002_030_000, "机床报警规则不存在");
ErrorCode EQUIP_ALARM_DATA_NOT_EXISTS = new ErrorCode(1_002_030_001, "机床报警数据不存在");
}

View File

@ -52,6 +52,16 @@ public class AlarmRulesController {
return success(true);
}
@PutMapping("/changeStatus")
@Operation(summary = "改变报警规则状态")
@PreAuthorize("@ss.hasPermission('imt:alarm-rules:change')")
public CommonResult<Boolean> changeAlarmRulesStatus(@Valid @RequestBody AlarmRulesSaveReqVO updateReqVO) {
AlarmRulesDO alarmRules = alarmRulesService.getAlarmRules(updateReqVO.getAlarmId());
updateReqVO.setStatus(alarmRules.getStatus() == 0 ? 1 : 0);
alarmRulesService.updateAlarmRules(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除机床报警规则")
@Parameter(name = "id", description = "编号", required = true)

View File

@ -0,0 +1,100 @@
package com.inspur.module.system.controller.admin.alarm;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.pojo.CommonResult.success;
import com.inspur.framework.excel.core.util.ExcelUtils;
import com.inspur.framework.apilog.core.annotation.ApiAccessLog;
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*;
import com.inspur.module.system.controller.admin.alarm.vo.*;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO;
import com.inspur.module.system.service.alarm.EquipAlarmDataService;
@Tag(name = "管理后台 - 机床设备报警数据")
@RestController
@RequestMapping("/imt/equip-alarm-data")
@Validated
public class EquipAlarmDataController {
@Resource
private EquipAlarmDataService equipAlarmDataService;
@PostMapping("/create")
@Operation(summary = "创建机床设备报警数据")
@PreAuthorize("@ss.hasPermission('imt:equip-alarm-data:create')")
public CommonResult<String> createEquipAlarmData(@Valid @RequestBody EquipAlarmDataSaveReqVO createReqVO) {
return success(equipAlarmDataService.createEquipAlarmData(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新机床设备报警数据")
@PreAuthorize("@ss.hasPermission('imt:equip-alarm-data:update')")
public CommonResult<Boolean> updateEquipAlarmData(@Valid @RequestBody EquipAlarmDataSaveReqVO updateReqVO) {
equipAlarmDataService.updateEquipAlarmData(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除机床设备报警数据")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('imt:equip-alarm-data:delete')")
public CommonResult<Boolean> deleteEquipAlarmData(@RequestParam("id") String id) {
equipAlarmDataService.deleteEquipAlarmData(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得机床设备报警数据")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('imt:equip-alarm-data:query')")
public CommonResult<EquipAlarmDataRespVO> getEquipAlarmData(@RequestParam("id") String id) {
EquipAlarmDataDO equipAlarmData = equipAlarmDataService.getEquipAlarmData(id);
return success(BeanUtils.toBean(equipAlarmData, EquipAlarmDataRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得机床设备报警数据分页")
@PreAuthorize("@ss.hasPermission('imt:equip-alarm-data:query')")
public CommonResult<PageResult<EquipAlarmDataRespVO>> getEquipAlarmDataPage(@Valid EquipAlarmDataPageReqVO pageReqVO) {
PageResult<EquipAlarmDataDO> pageResult = equipAlarmDataService.getEquipAlarmDataPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, EquipAlarmDataRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出机床设备报警数据 Excel")
@PreAuthorize("@ss.hasPermission('imt:equip-alarm-data:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportEquipAlarmDataExcel(@Valid EquipAlarmDataPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<EquipAlarmDataDO> list = equipAlarmDataService.getEquipAlarmDataPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "机床设备报警数据.xls", "数据", EquipAlarmDataRespVO.class,
BeanUtils.toBean(list, EquipAlarmDataRespVO.class));
}
}

View File

@ -0,0 +1,47 @@
package com.inspur.module.system.controller.admin.alarm.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.inspur.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 机床设备报警数据分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class EquipAlarmDataPageReqVO extends PageParam {
@Schema(description = "机床设备id")
private String equipId;
@Schema(description = "机床组件id")
private String componentId;
@Schema(description = "报警等级11级22级33级")
private Integer alarmLevel;
@Schema(description = "报警类型0阈值报警 1趋势报警")
private Integer alarmType;
@Schema(description = "首次报警时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] firstAlarmTime;
@Schema(description = "最新报警时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] latestAlarmTime;
@Schema(description = "状态0:待处理1已处理", example = "1")
private Integer status;
@Schema(description = "机床分析状态0正常1磨损中2磨损严重")
private Integer equipAnalyseStatus;
}

View File

@ -0,0 +1,72 @@
package com.inspur.module.system.controller.admin.alarm.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import com.inspur.framework.excel.core.annotations.DictFormat;
import com.inspur.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 机床设备报警数据 Response VO")
@Data
@ExcelIgnoreUnannotated
public class EquipAlarmDataRespVO {
@Schema(description = "设备预警信息主键", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("设备预警信息主键")
private String equipAlarmId;
@Schema(description = "机床设备id", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("机床设备id")
private String equipId;
@Schema(description = "机床组件id", example = "10773")
@ExcelProperty("机床组件id")
private String componentId;
@Schema(description = "报警等级11级22级33级")
@ExcelProperty(value = "报警等级11级22级33级", converter = DictConvert.class)
@DictFormat("alarm_level") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Integer alarmLevel;
@Schema(description = "首次报警时间")
@ExcelProperty("首次报警时间")
private LocalDateTime firstAlarmTime;
@Schema(description = "最新报警时间")
@ExcelProperty("最新报警时间")
private LocalDateTime latestAlarmTime;
@Schema(description = "状态0:待处理1已处理")
@ExcelProperty("状态0:待处理1已处理")
private Integer status;
@Schema(description = "机床分析状态0正常1磨损中2磨损严重")
@ExcelProperty("机床分析状态0正常1磨损中2磨损严重")
private Integer equipAnalyseStatus;
@Schema(description = "客户名")
@ExcelProperty("客户名")
private String customerName;
@Schema(description = "设备编号")
@ExcelProperty("设备编号")
private String equipNo;
@Schema(description = "设备型号")
@ExcelProperty("设备型号")
private String modelName;
@Schema(description = "组件名")
@ExcelProperty("组件名")
private String componentName;
}

View File

@ -0,0 +1,42 @@
package com.inspur.module.system.controller.admin.alarm.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 机床设备报警数据新增/修改 Request VO")
@Data
public class EquipAlarmDataSaveReqVO {
@Schema(description = "设备预警信息主键", requiredMode = Schema.RequiredMode.REQUIRED)
private String equipAlarmId;
@Schema(description = "机床设备id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "机床设备id不能为空")
private String equipId;
@Schema(description = "机床组件id", example = "10773")
private String componentId;
@Schema(description = "报警等级11级22级33级")
private Integer alarmLevel;
@Schema(description = "报警类型0阈值报警 1趋势报警")
private Integer alarmType;
@Schema(description = "首次报警时间")
private LocalDateTime firstAlarmTime;
@Schema(description = "最新报警时间")
private LocalDateTime latestAlarmTime;
@Schema(description = "状态0:待处理1已处理")
private Integer status;
@Schema(description = "机床分析状态0正常1磨损中2磨损严重")
private Integer equipAnalyseStatus;
}

View File

@ -0,0 +1,84 @@
package com.inspur.module.system.dal.dataobject.alarm;
import lombok.*;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.inspur.framework.mybatis.core.dataobject.BaseDO;
/**
* 机床设备报警数据 DO
*
* @author zjw
*/
@TableName("imt_equip_alarm_data")
@KeySequence("imt_equip_alarm_data_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EquipAlarmDataDO extends BaseDO {
/**
* 设备预警信息主键
*/
@TableId(type = IdType.ASSIGN_UUID)
private String equipAlarmId;
/**
* 机床设备id
*/
private String equipId;
/**
* 机床组件id
*/
private String componentId;
/**
* 报警等级11级22级33级
* <p>
* 枚举 {@link TODO alarm_level 对应的类}
*/
private Integer alarmLevel;
/**
* 报警类型0阈值报警 1趋势报警
*/
private Integer alarmType;
/**
* 首次报警时间
*/
private LocalDateTime firstAlarmTime;
/**
* 最新报警时间
*/
private LocalDateTime latestAlarmTime;
/**
* 状态0:待处理1已处理
*/
private Integer status;
/**
* 机床分析状态0正常1磨损中2磨损严重
*/
private Integer equipAnalyseStatus;
/**
* 客户名
*/
private String customerName;
/**
* 设备编号
*/
private String equipNo;
/**
* 设备型号
*/
private String modelName;
/**
* 组件名
*/
private String componentName;
}

View File

@ -45,5 +45,8 @@ public interface AlarmRulesMapper extends BaseMapperX<AlarmRulesDO> {
*/
public IPage<AlarmRulesDO> selectAlarmRulesList(IPage<AlarmRulesDO> page, @Param("reqVO") AlarmRulesPageReqVO reqVO);
/**
* 根据id查询报警规则
*/
public AlarmRulesDO selectAlarmRulesById(@Param("id") String id);
}

View File

@ -0,0 +1,43 @@
package com.inspur.module.system.dal.mysql.alarm;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.inspur.framework.mybatis.core.mapper.BaseMapperX;
import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO;
import org.apache.ibatis.annotations.Mapper;
import com.inspur.module.system.controller.admin.alarm.vo.*;
import org.apache.ibatis.annotations.Param;
/**
* 机床设备报警数据 Mapper
*
* @author zjw
*/
@Mapper
public interface EquipAlarmDataMapper extends BaseMapperX<EquipAlarmDataDO> {
default PageResult<EquipAlarmDataDO> selectPage(EquipAlarmDataPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<EquipAlarmDataDO>()
.eqIfPresent(EquipAlarmDataDO::getEquipId, reqVO.getEquipId())
.eqIfPresent(EquipAlarmDataDO::getComponentId, reqVO.getComponentId())
.eqIfPresent(EquipAlarmDataDO::getAlarmLevel, reqVO.getAlarmLevel())
.eqIfPresent(EquipAlarmDataDO::getAlarmType, reqVO.getAlarmType())
.betweenIfPresent(EquipAlarmDataDO::getFirstAlarmTime, reqVO.getFirstAlarmTime())
.betweenIfPresent(EquipAlarmDataDO::getLatestAlarmTime, reqVO.getLatestAlarmTime())
.eqIfPresent(EquipAlarmDataDO::getStatus, reqVO.getStatus())
.eqIfPresent(EquipAlarmDataDO::getEquipAnalyseStatus, reqVO.getEquipAnalyseStatus())
.orderByDesc(EquipAlarmDataDO::getEquipAlarmId));
}
/**
* 查询设备报警列表
*/
public IPage<EquipAlarmDataDO> selectEquipAlarmList(IPage<EquipAlarmDataDO> page, @Param("reqVO") EquipAlarmDataPageReqVO reqVO);
/**
* 根据id查询设备报警
*/
public EquipAlarmDataDO selectEquipAlarmById(@Param("id") String id);
}

View File

@ -56,14 +56,14 @@ public class AlarmRulesServiceImpl implements AlarmRulesService {
}
private void validateAlarmRulesExists(String id) {
if (alarmRulesMapper.selectById(id) == null) {
if (alarmRulesMapper.selectAlarmRulesById(id) == null) {
throw exception(ALARM_RULES_NOT_EXISTS);
}
}
@Override
public AlarmRulesDO getAlarmRules(String id) {
return alarmRulesMapper.selectById(id);
return alarmRulesMapper.selectAlarmRulesById(id);
}
@Override

View File

@ -0,0 +1,56 @@
package com.inspur.module.system.service.alarm;
import java.util.*;
import javax.validation.*;
import com.inspur.module.system.controller.admin.alarm.vo.*;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
/**
* 机床设备报警数据 Service 接口
*
* @author zjw
*/
public interface EquipAlarmDataService {
/**
* 创建机床设备报警数据
*
* @param createReqVO 创建信息
* @return 编号
*/
String createEquipAlarmData(@Valid EquipAlarmDataSaveReqVO createReqVO);
/**
* 更新机床设备报警数据
*
* @param updateReqVO 更新信息
*/
void updateEquipAlarmData(@Valid EquipAlarmDataSaveReqVO updateReqVO);
/**
* 删除机床设备报警数据
*
* @param id 编号
*/
void deleteEquipAlarmData(String id);
/**
* 获得机床设备报警数据
*
* @param id 编号
* @return 机床设备报警数据
*/
EquipAlarmDataDO getEquipAlarmData(String id);
/**
* 获得机床设备报警数据分页
*
* @param pageReqVO 分页查询
* @return 机床设备报警数据分页
*/
PageResult<EquipAlarmDataDO> getEquipAlarmDataPage(EquipAlarmDataPageReqVO pageReqVO);
}

View File

@ -0,0 +1,82 @@
package com.inspur.module.system.service.alarm;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.inspur.module.system.controller.admin.alarm.vo.*;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.util.object.BeanUtils;
import com.inspur.module.system.dal.mysql.alarm.EquipAlarmDataMapper;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.inspur.module.system.enums.ErrorCodeConstants.*;
/**
* 机床设备报警数据 Service 实现类
*
* @author zjw
*/
@Service
@Validated
public class EquipAlarmDataServiceImpl implements EquipAlarmDataService {
@Resource
private EquipAlarmDataMapper equipAlarmDataMapper;
@Override
public String createEquipAlarmData(EquipAlarmDataSaveReqVO createReqVO) {
// 插入
EquipAlarmDataDO equipAlarmData = BeanUtils.toBean(createReqVO, EquipAlarmDataDO.class);
equipAlarmDataMapper.insert(equipAlarmData);
// 返回
return equipAlarmData.getEquipAlarmId();
}
@Override
public void updateEquipAlarmData(EquipAlarmDataSaveReqVO updateReqVO) {
// 校验存在
validateEquipAlarmDataExists(updateReqVO.getEquipAlarmId());
// 更新
EquipAlarmDataDO updateObj = BeanUtils.toBean(updateReqVO, EquipAlarmDataDO.class);
equipAlarmDataMapper.updateById(updateObj);
}
@Override
public void deleteEquipAlarmData(String id) {
// 校验存在
validateEquipAlarmDataExists(id);
// 删除
equipAlarmDataMapper.deleteById(id);
}
private void validateEquipAlarmDataExists(String id) {
if (equipAlarmDataMapper.selectEquipAlarmById(id) == null) {
throw exception(EQUIP_ALARM_DATA_NOT_EXISTS);
}
}
@Override
public EquipAlarmDataDO getEquipAlarmData(String id) {
return equipAlarmDataMapper.selectEquipAlarmById(id);
}
@Override
public PageResult<EquipAlarmDataDO> getEquipAlarmDataPage(EquipAlarmDataPageReqVO pageReqVO) {
IPage<EquipAlarmDataDO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
equipAlarmDataMapper.selectEquipAlarmList(page, pageReqVO);
return new PageResult<>(page.getRecords(), page.getTotal());
}
}

View File

@ -26,7 +26,6 @@
<result property="equipNo" column="equip_no" />
<result property="customerName" column="customer_name" />
<result property="componentName" column="component_name" />
</resultMap>
<sql id="selectAlarmRulesVo">
@ -40,8 +39,7 @@
<include refid="selectAlarmRulesVo"/>
<where>
<if test="reqVO.alarmName != null and reqVO.alarmName != ''"> and iar.alarm_name like concat('%', #{reqVO.alarmName}, '%')</if>
<if test="reqVO.alarmNameKey != null and reqVO.alarmNameKey != ''"> and iar.alarm_name_key = #{reqVO.alarmNameKey}</if>
<if test="reqVO.alarmInfoUnit != null and reqVO.alarmInfoUnit != ''"> and iar.alarm_info_unit = #{reqVO.alarmInfoUnit}</if>
<if test="reqVO.alarmNameKey != null and reqVO.alarmNameKey != ''"> and iar.alarm_name_key like concat('%', #{reqVO.alarmNameKey}, '%')</if>
<if test="reqVO.equipId != null and reqVO.equipId != ''"> and iar.equip_id = #{reqVO.equipId}</if>
<if test="reqVO.type != null "> and iar.type = #{reqVO.type}</if>
<if test="reqVO.alarmLevel != null "> and iar.alarm_level = #{reqVO.alarmLevel}</if>
@ -49,4 +47,9 @@
order by iar.create_time desc
</select>
<select id="selectAlarmRulesById" parameterType="String" resultMap="AlarmRulesResult">
<include refid="selectAlarmRulesVo"/>
where alarm_id = #{id}
</select>
</mapper>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.inspur.module.system.dal.mysql.alarm.EquipAlarmDataMapper">
<resultMap type="com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO" id="EquipAlarmResult">
<result property="equipAlarmId" column="equip_alarm_id" />
<result property="equipId" column="equip_id" />
<result property="componentId" column="component_id" />
<result property="alarmLevel" column="alarm_level" />
<result property="alarmType" column="alarm_type" />
<result property="firstAlarmTime" column="first_alarm_time" />
<result property="latestAlarmTime" column="latest_alarm_time" />
<result property="status" column="status" />
<result property="equipAnalyseStatus" column="equip_analyse_status" />
<result property="customerName" column="customer_name" />
<result property="equipNo" column="equip_no" />
<result property="modelName" column="model_name" />
<result property="componentName" column="component_name" />
</resultMap>
<sql id="selectEquipAlarmVo">
select iead.equip_alarm_id, iead.equip_id, iead.component_id, iead.alarm_level, iead.alarm_type, iead.first_alarm_time, iead.latest_alarm_time, iead.status, iead.equip_analyse_status, cui.customer_name, ei.equip_no, imi.model_name, ci.component_name from imt_equip_alarm_data iead
left join imt_equip_info ei on iead.equip_id = ei.equip_id
left join imt_model_info imi on ei.model_id = imi.model_id
left join imt_component_info ci on iead.component_id = ci.component_id
left join imt_customer_info cui on ei.customer_id = cui.customer_id
</sql>
<select id="selectEquipAlarmList" resultMap="EquipAlarmResult">
<include refid="selectEquipAlarmVo"/>
<where>
<if test="reqVO.equipId != null and reqVO.equipId != ''"> and iead.equip_id = #{reqVO.equipId}</if>
<if test="reqVO.componentId != null and reqVO.componentId != ''"> and iead.component_id = #{reqVO.componentId}</if>
<if test="reqVO.alarmLevel != null and reqVO.alarmLevel != ''"> and iead.alarm_level = #{reqVO.alarmLevel}</if>
<if test="reqVO.alarmType != null and reqVO.alarmType != ''"> and iead.alarm_type = #{reqVO.alarmType}</if>
<if test="reqVO.firstAlarmTime != null "> and iead.first_alarm_time &gt;= #{reqVO.firstAlarmTime[0]} and iead.first_alarm_time &lt;= #{reqVO.firstAlarmTime[1]} </if>
</where>
order by iead.first_alarm_time desc
</select>
<select id="selectEquipAlarmById" parameterType="String" resultMap="EquipAlarmResult">
<include refid="selectEquipAlarmVo"/>
where iead.equip_alarm_id = #{id}
</select>
</mapper>

View File

@ -18,6 +18,15 @@ export function updateAlarmRules(data) {
});
}
// 更新机床报警规则
export function changeAlarmRulesStatus(data) {
return request({
url: "/imt/alarm-rules/changeStatus",
method: "put",
data: data,
});
}
// 删除机床报警规则
export function deleteAlarmRules(id) {
return request({

View File

@ -0,0 +1,53 @@
import request from "@/utils/request";
// 创建机床设备报警数据
export function createEquipAlarmData(data) {
return request({
url: "/imt/equip-alarm-data/create",
method: "post",
data: data,
});
}
// 更新机床设备报警数据
export function updateEquipAlarmData(data) {
return request({
url: "/imt/equip-alarm-data/update",
method: "put",
data: data,
});
}
// 删除机床设备报警数据
export function deleteEquipAlarmData(id) {
return request({
url: "/imt/equip-alarm-data/delete?id=" + id,
method: "delete",
});
}
// 获得机床设备报警数据
export function getEquipAlarmData(id) {
return request({
url: "/imt/equip-alarm-data/get?id=" + id,
method: "get",
});
}
// 获得机床设备报警数据分页
export function getEquipAlarmDataPage(params) {
return request({
url: "/imt/equip-alarm-data/page",
method: "get",
params,
});
}
// 导出机床设备报警数据 Excel
export function exportEquipAlarmDataExcel(params) {
return request({
url: "/imt/equip-alarm-data/export-excel",
method: "get",
params,
responseType: "blob",
});
}

View File

@ -24,6 +24,8 @@ export const DICT_TYPE = {
COMPONENT_TYPE: "component_type",
COMPONENT_STATUS: "component_status",
JUDGE_RULES: "judge_rules",
EQU_ALARM_STATUS: "equip_alarm_status",
TREND_ANALY_STATUS: "trend_analy_status",
// ========== SYSTEM 模块 ==========
SYSTEM_USER_SEX: "system_user_sex",
SYSTEM_MENU_TYPE: "system_menu_type",

View File

@ -73,7 +73,7 @@
prop="equipId"
>
<el-input
v-model="formData.equipName"
v-model="formData.equipNo"
:disabled="true"
placeholder="请输入机床设备"
/>

View File

@ -183,7 +183,20 @@
label="状态"
align="center"
prop="status"
/>
>
<template v-slot="scope">
<el-switch
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
:active-value="0"
:inactive-value="1"
active-text="开"
inactive-text="关"
@change="alarmStatusChange(scope.row)"
/>
</template>
</el-table-column>
<!-- <el-table-column
label="可能故障原因"
align="center"
@ -193,7 +206,12 @@
label="等级"
align="center"
prop="alarmLevel"
/>
><template v-slot="scope">
<dict-tag
:type="DICT_TYPE.ALARM_LEVEL"
:value="scope.row.alarmLevel"
/>
</template></el-table-column>
<!-- <el-table-column
label="备注"
align="center"
@ -279,12 +297,19 @@
label="机床设备"
prop="equipId"
>
<el-input
<el-select
v-model="queryParams.equipId"
placeholder="请输入机床设备id"
placeholder="请选择机床设备"
clearable
@keyup.enter.native="handleQuery"
/>
size="small"
>
<el-option
v-for="item in equipSelection"
:key="item.equipId"
:label="item.equipNo"
:value="item.equipId"
/>
</el-select>
</el-form-item>
<el-form-item
label="等级"
@ -362,14 +387,19 @@
prop="alarmInfoUnit"
/>
<el-table-column
label="机床设备"
label="客户名"
align="center"
prop="equipId"
prop="customerName"
/>
<el-table-column
label="机床型号"
align="center"
prop="equipNo"
/>
<el-table-column
label="机床组件"
align="center"
prop="componentId"
prop="componentName"
/>
<el-table-column
label="规则上限值"
@ -395,7 +425,20 @@
label="状态"
align="center"
prop="status"
/>
>
<template v-slot="scope">
<el-switch
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
:active-value="0"
:inactive-value="1"
active-text="开"
inactive-text="关"
@change="alarmStatusChange(scope.row)"
/>
</template>
</el-table-column>
<!-- <el-table-column
label="可能故障原因"
align="center"
@ -405,7 +448,14 @@
label="等级"
align="center"
prop="alarmLevel"
/>
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.ALARM_LEVEL"
:value="scope.row.alarmLevel"
/>
</template>
</el-table-column>
<!-- <el-table-column
label="备注"
align="center"
@ -417,6 +467,13 @@
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-document"
@click="openDetail(scope.row)"
v-hasPermi="['imt:alarm-rules:query']"
>详情</el-button>
<el-button
size="mini"
type="text"
@ -454,11 +511,93 @@
<el-dialog
:title="detailTitle"
:visible.sync="detailOpen"
width="80%"
width="40%"
:close-on-click-modal="false"
>
<div v-html="ruleContent"></div>
<el-form
:model="detailForm"
v-loading="detailLoading"
label-width="100px"
>
<el-col :span="12">
<el-form-item
label="客户名称"
prop="customerName"
>
{{ detailForm.customerName }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="设备型号"
prop="equipNo"
>
{{ detailForm.equipNo }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="规则名称"
prop="alarmName"
>
{{ detailForm.alarmName }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="规则单位"
prop="alarmInfoUnit"
>
{{ detailForm.alarmInfoUnit }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="判断规则"
prop="referenceCon"
>
{{ detailForm.referenceCon }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="规则描述"
prop="referenceName"
>
{{ detailForm.referenceName }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="规则上限"
prop="alertUpperBound"
>
{{ detailForm.alertUpperBound }}
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="规则下限"
prop="alertLowerBound"
>
{{ detailForm.alertLowerBound }}
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item
label="可能故障原因"
prop="reasonDescription"
>
<div v-html="detailForm.reasonDescription" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item
label="备注"
prop="remark"
>{{ detailForm.remark }}</el-form-item>
</el-col>
</el-form>
</el-dialog>
</div>
</template>
@ -515,24 +654,32 @@ export default {
equipSelection: [],
detailTitle: null,
detailOpen: false,
ruleContent: "",
ruleRemark: "",
detailForm: {},
detailLoading: false,
};
},
created() {
this.getList();
},
methods: {
alarmStatusChange(row) {
AlarmRulesApi.changeAlarmRulesStatus(row);
},
/**
* 打开详情
*/
openDetail(row) {
this.detailTitle = "规则详情";
this.detailForm = row;
this.detailForm.remark =
row.remark == null || row.remark == "" ? "空" : row.remark;
this.detailOpen = true;
this.ruleContent = row.reasonDescription;
},
/**tab点击切换 */
handleTabClick() {},
handleTabClick(tab) {
this.activeName = tab.name;
this.getList();
},
/** 查询列表 */
async getList() {
try {

View File

@ -0,0 +1,215 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
width="60%"
v-dialogDrag
append-to-body
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="100px"
>
<el-form-item
label="机床设备"
prop="equipId"
>
<el-input
v-model="formData.equipId"
placeholder="请输入机床设备id"
/>
</el-form-item>
<el-form-item
label="机床组件id"
prop="componentId"
>
<el-select
v-model="formData.componentId"
placeholder="请选择机床组件id"
>
<el-option
label="请选择字典生成"
value=""
/>
</el-select>
</el-form-item>
<el-form-item
label="报警等级11级22级33级"
prop="alarmLevel"
>
<el-select
v-model="formData.alarmLevel"
placeholder="请选择报警等级11级22级33级"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.ALARM_LEVEL)"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item
label="报警类型0阈值报警 1趋势报警"
prop="alarmType"
>
<el-input
v-model="formData.alarmType"
placeholder="请输入报警类型0阈值报警 1趋势报警"
/>
</el-form-item>
<el-form-item
label="首次报警时间"
prop="firstAlarmTime"
>
<el-date-picker
clearable
v-model="formData.firstAlarmTime"
type="date"
value-format="timestamp"
placeholder="选择首次报警时间"
/>
</el-form-item>
<el-form-item
label="最新报警时间"
prop="latestAlarmTime"
>
<el-date-picker
clearable
v-model="formData.latestAlarmTime"
type="date"
value-format="timestamp"
placeholder="选择最新报警时间"
/>
</el-form-item>
<el-form-item
label="状态0:待处理1已处理"
prop="status"
>
<el-radio-group v-model="formData.status">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label="机床分析状态0正常1磨损中2磨损严重"
prop="equipAnalyseStatus"
>
<el-radio-group v-model="formData.equipAnalyseStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submitForm"
:disabled="formLoading"
> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as EquipAlarmDataApi from "@/api/system/alarm/equipalarmdata";
export default {
name: "EquipAlarmDataForm",
components: {},
data() {
return {
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
formData: {
equipAlarmId: undefined,
equipId: undefined,
componentId: undefined,
alarmLevel: undefined,
alarmType: undefined,
firstAlarmTime: undefined,
latestAlarmTime: undefined,
status: undefined,
equipAnalyseStatus: undefined,
},
//
formRules: {
equipId: [
{ required: true, message: "机床设备id不能为空", trigger: "blur" },
],
},
};
},
methods: {
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;
this.reset();
//
if (id) {
this.formLoading = true;
try {
const res = await EquipAlarmDataApi.getEquipAlarmData(id);
this.formData = res.data;
this.title = "修改机床设备报警数据";
} finally {
this.formLoading = false;
}
}
this.title = "新增机床设备报警数据";
},
/** 提交按钮 */
async submitForm() {
//
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
const data = this.formData;
//
if (data.equipAlarmId) {
await EquipAlarmDataApi.updateEquipAlarmData(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit("success");
return;
}
//
await EquipAlarmDataApi.createEquipAlarmData(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit("success");
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
equipAlarmId: undefined,
equipId: undefined,
componentId: undefined,
alarmLevel: undefined,
alarmType: undefined,
firstAlarmTime: undefined,
latestAlarmTime: undefined,
status: undefined,
equipAnalyseStatus: undefined,
};
this.resetForm("formRef");
},
},
};
</script>

View File

@ -0,0 +1,377 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
style="text-align:right"
>
<el-form-item
label="机床设备"
prop="equipId"
>
<el-select
v-model="queryParams.equipId"
placeholder="请选择机床设备"
clearable
size="small"
>
<el-option
v-for="item in equipSelection"
:key="item.equipId"
:label="item.equipNo"
:value="item.equipId"
/>
</el-select>
</el-form-item>
<!-- <el-form-item
label="机床组件id"
prop="componentId"
>
<el-select
v-model="queryParams.componentId"
placeholder="请选择机床组件id"
clearable
size="small"
>
<el-option
label="请选择字典生成"
value=""
/>
</el-select>
</el-form-item> -->
<el-form-item
label="报警等级"
prop="alarmLevel"
>
<el-select
v-model="queryParams.alarmLevel"
placeholder="请选择报警等级"
clearable
size="small"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.ALARM_LEVEL)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item
label="首次报警时间"
prop="firstAlarmTime"
label-width="100px"
>
<el-date-picker
v-model="queryParams.firstAlarmTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
/>
</el-form-item>
<!-- <el-form-item
label="最新报警时间"
prop="latestAlarmTime"
>
<el-date-picker
v-model="queryParams.latestAlarmTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
/>
</el-form-item> -->
<!-- <el-form-item
label="机床分析状态0正常1磨损中2磨损严重"
prop="equipAnalyseStatus"
>
<el-select
v-model="queryParams.equipAnalyseStatus"
placeholder="请选择机床分析状态0正常1磨损中2磨损严重"
clearable
size="small"
>
<el-option
label="请选择字典生成"
value=""
/>
</el-select>
</el-form-item> -->
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
>搜索</el-button>
<el-button
icon="el-icon-refresh"
@click="resetQuery"
>重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="openForm(undefined)"
v-hasPermi="['imt:equip-alarm-data:create']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['imt:equip-alarm-data:export']"
>导出</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
>
<el-table-column
label="客户"
align="center"
prop="customerName"
/>
<el-table-column
label="机床型号"
align="center"
prop="modelName"
/>
<el-table-column
label="机床编号"
align="center"
prop="equipNo"
/>
<!-- <el-table-column
label="机床组件"
align="center"
prop="componentName"
/> -->
<el-table-column
label="报警等级"
align="center"
prop="alarmLevel"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.ALARM_LEVEL"
:value="scope.row.alarmLevel"
/>
</template>
</el-table-column>
<el-table-column
label="首次报警时间"
align="center"
prop="firstAlarmTime"
width="180"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.firstAlarmTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="最新报警时间"
align="center"
prop="latestAlarmTime"
width="180"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.latestAlarmTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="状态"
align="center"
prop="status"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.EQU_ALARM_STATUS"
:value="scope.row.status"
/>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="openForm(scope.row.equipAlarmId)"
v-hasPermi="['imt:equip-alarm-data:update']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['imt:equip-alarm-data:delete']"
>删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-data-analysis"
@click="openForm(scope.row.equipAlarmId)"
v-hasPermi="['imt:equip-alarm-data:update']"
>处理</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 对话框(添加 / 修改) -->
<EquipAlarmDataForm
ref="formRef"
@success="getList"
/>
</div>
</template>
<script>
import * as EquipAlarmDataApi from "@/api/system/alarm/equipalarmdata";
import EquipAlarmDataForm from "./EquipAlarmDataForm.vue";
import { getEquipSelection } from "@/api/system/equip/equipInfo";
export default {
name: "EquipAlarmData",
components: {
EquipAlarmDataForm,
},
data() {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
//
list: [],
//
isExpandAll: true,
//
refreshTable: true,
//
currentRow: {},
//
queryParams: {
pageNo: 1,
pageSize: 10,
equipId: null,
componentId: null,
alarmLevel: null,
alarmType: 0,
firstAlarmTime: [],
latestAlarmTime: [],
status: null,
equipAnalyseStatus: null,
},
equipSelection: [],
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
async getList() {
try {
this.loading = true;
const res = await EquipAlarmDataApi.getEquipAlarmDataPage(
this.queryParams
);
this.equipSelection = await getEquipSelection();
this.list = res.data.list;
this.total = res.data.total;
} finally {
this.loading = false;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 添加/修改操作 */
openForm(id) {
this.$refs["formRef"].open(id);
},
/** 删除按钮操作 */
async handleDelete(row) {
const equipAlarmId = row.equipAlarmId;
await this.$modal.confirm(
'是否确认删除机床设备报警数据编号为"' + equipAlarmId + '"的数据项?'
);
try {
await EquipAlarmDataApi.deleteEquipAlarmData(equipAlarmId);
await this.getList();
this.$modal.msgSuccess("删除成功");
} catch {}
},
/** 导出按钮操作 */
async handleExport() {
await this.$modal.confirm("是否确认导出所有机床设备报警数据数据项?");
try {
this.exportLoading = true;
const data = await EquipAlarmDataApi.exportEquipAlarmDataExcel(
this.queryParams
);
this.$download.excel(data, "机床设备报警数据.xls");
} catch {
} finally {
this.exportLoading = false;
}
},
},
};
</script>

View File

@ -0,0 +1,215 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
width="60%"
v-dialogDrag
append-to-body
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="100px"
>
<el-form-item
label="机床设备"
prop="equipId"
>
<el-input
v-model="formData.equipId"
placeholder="请输入机床设备id"
/>
</el-form-item>
<el-form-item
label="机床组件id"
prop="componentId"
>
<el-select
v-model="formData.componentId"
placeholder="请选择机床组件id"
>
<el-option
label="请选择字典生成"
value=""
/>
</el-select>
</el-form-item>
<el-form-item
label="报警等级11级22级33级"
prop="alarmLevel"
>
<el-select
v-model="formData.alarmLevel"
placeholder="请选择报警等级11级22级33级"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.ALARM_LEVEL)"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item
label="报警类型0阈值报警 1趋势报警"
prop="alarmType"
>
<el-input
v-model="formData.alarmType"
placeholder="请输入报警类型0阈值报警 1趋势报警"
/>
</el-form-item>
<el-form-item
label="首次报警时间"
prop="firstAlarmTime"
>
<el-date-picker
clearable
v-model="formData.firstAlarmTime"
type="date"
value-format="timestamp"
placeholder="选择首次报警时间"
/>
</el-form-item>
<el-form-item
label="最新报警时间"
prop="latestAlarmTime"
>
<el-date-picker
clearable
v-model="formData.latestAlarmTime"
type="date"
value-format="timestamp"
placeholder="选择最新报警时间"
/>
</el-form-item>
<el-form-item
label="状态0:待处理1已处理"
prop="status"
>
<el-radio-group v-model="formData.status">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label="机床分析状态0正常1磨损中2磨损严重"
prop="equipAnalyseStatus"
>
<el-radio-group v-model="formData.equipAnalyseStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submitForm"
:disabled="formLoading"
> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as EquipAlarmDataApi from "@/api/system/alarm/equipalarmdata";
export default {
name: "EquipAlarmDataForm",
components: {},
data() {
return {
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
formData: {
equipAlarmId: undefined,
equipId: undefined,
componentId: undefined,
alarmLevel: undefined,
alarmType: undefined,
firstAlarmTime: undefined,
latestAlarmTime: undefined,
status: undefined,
equipAnalyseStatus: undefined,
},
//
formRules: {
equipId: [
{ required: true, message: "机床设备id不能为空", trigger: "blur" },
],
},
};
},
methods: {
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;
this.reset();
//
if (id) {
this.formLoading = true;
try {
const res = await EquipAlarmDataApi.getEquipAlarmData(id);
this.formData = res.data;
this.title = "修改机床设备报警数据";
} finally {
this.formLoading = false;
}
}
this.title = "新增机床设备报警数据";
},
/** 提交按钮 */
async submitForm() {
//
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
const data = this.formData;
//
if (data.equipAlarmId) {
await EquipAlarmDataApi.updateEquipAlarmData(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit("success");
return;
}
//
await EquipAlarmDataApi.createEquipAlarmData(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit("success");
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
equipAlarmId: undefined,
equipId: undefined,
componentId: undefined,
alarmLevel: undefined,
alarmType: undefined,
firstAlarmTime: undefined,
latestAlarmTime: undefined,
status: undefined,
equipAnalyseStatus: undefined,
};
this.resetForm("formRef");
},
},
};
</script>

View File

@ -0,0 +1,389 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
style="text-align:right"
>
<el-form-item
label="机床设备"
prop="equipId"
>
<el-select
v-model="queryParams.equipId"
placeholder="请选择机床设备"
clearable
size="small"
>
<el-option
v-for="item in equipSelection"
:key="item.equipId"
:label="item.equipNo"
:value="item.equipId"
/>
</el-select>
</el-form-item>
<!-- <el-form-item
label="机床组件id"
prop="componentId"
>
<el-select
v-model="queryParams.componentId"
placeholder="请选择机床组件id"
clearable
size="small"
>
<el-option
label="请选择字典生成"
value=""
/>
</el-select>
</el-form-item> -->
<el-form-item
label="报警等级"
prop="alarmLevel"
>
<el-select
v-model="queryParams.alarmLevel"
placeholder="请选择报警等级"
clearable
size="small"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.ALARM_LEVEL)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item
label="首次报警时间"
prop="firstAlarmTime"
label-width="100px"
>
<el-date-picker
v-model="queryParams.firstAlarmTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
/>
</el-form-item>
<!-- <el-form-item
label="最新报警时间"
prop="latestAlarmTime"
>
<el-date-picker
v-model="queryParams.latestAlarmTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
/>
</el-form-item> -->
<!-- <el-form-item
label="机床分析状态0正常1磨损中2磨损严重"
prop="equipAnalyseStatus"
>
<el-select
v-model="queryParams.equipAnalyseStatus"
placeholder="请选择机床分析状态0正常1磨损中2磨损严重"
clearable
size="small"
>
<el-option
label="请选择字典生成"
value=""
/>
</el-select>
</el-form-item> -->
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
>搜索</el-button>
<el-button
icon="el-icon-refresh"
@click="resetQuery"
>重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="openForm(undefined)"
v-hasPermi="['imt:equip-alarm-data:create']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['imt:equip-alarm-data:export']"
>导出</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
>
<el-table-column
label="客户"
align="center"
prop="customerName"
/>
<el-table-column
label="机床型号"
align="center"
prop="modelName"
/>
<el-table-column
label="机床编号"
align="center"
prop="equipNo"
/>
<el-table-column
label="机床组件"
align="center"
prop="componentName"
/>
<el-table-column
label="报警等级"
align="center"
prop="alarmLevel"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.ALARM_LEVEL"
:value="scope.row.alarmLevel"
/>
</template>
</el-table-column>
<el-table-column
label="首次报警时间"
align="center"
prop="firstAlarmTime"
width="180"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.firstAlarmTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="最新报警时间"
align="center"
prop="latestAlarmTime"
width="180"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.latestAlarmTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="状态"
align="center"
prop="status"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.EQU_ALARM_STATUS"
:value="scope.row.status"
/>
</template>
</el-table-column>
<el-table-column
label="状态"
align="center"
prop="equipAnalyseStatus"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.TREND_ANALY_STATUS"
:value="scope.row.equipAnalyseStatus"
/>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="openForm(scope.row.equipAlarmId)"
v-hasPermi="['imt:equip-alarm-data:update']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['imt:equip-alarm-data:delete']"
>删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-data-analysis"
@click="openForm(scope.row.equipAlarmId)"
v-hasPermi="['imt:equip-alarm-data:update']"
>处理</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 对话框(添加 / 修改) -->
<EquipAlarmDataForm
ref="formRef"
@success="getList"
/>
</div>
</template>
<script>
import * as EquipAlarmDataApi from "@/api/system/alarm/equipalarmdata";
import EquipAlarmDataForm from "./EquipAlarmDataForm.vue";
import { getEquipSelection } from "@/api/system/equip/equipInfo";
export default {
name: "EquipAlarmData",
components: {
EquipAlarmDataForm,
},
data() {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
//
list: [],
//
isExpandAll: true,
//
refreshTable: true,
//
currentRow: {},
//
queryParams: {
pageNo: 1,
pageSize: 10,
equipId: null,
componentId: null,
alarmLevel: null,
alarmType: 1,
firstAlarmTime: [],
latestAlarmTime: [],
status: null,
equipAnalyseStatus: null,
},
equipSelection: [],
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
async getList() {
try {
this.loading = true;
const res = await EquipAlarmDataApi.getEquipAlarmDataPage(
this.queryParams
);
this.equipSelection = await getEquipSelection();
this.list = res.data.list;
this.total = res.data.total;
} finally {
this.loading = false;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 添加/修改操作 */
openForm(id) {
this.$refs["formRef"].open(id);
},
/** 删除按钮操作 */
async handleDelete(row) {
const equipAlarmId = row.equipAlarmId;
await this.$modal.confirm(
'是否确认删除机床设备报警数据编号为"' + equipAlarmId + '"的数据项?'
);
try {
await EquipAlarmDataApi.deleteEquipAlarmData(equipAlarmId);
await this.getList();
this.$modal.msgSuccess("删除成功");
} catch {}
},
/** 导出按钮操作 */
async handleExport() {
await this.$modal.confirm("是否确认导出所有机床设备报警数据数据项?");
try {
this.exportLoading = true;
const data = await EquipAlarmDataApi.exportEquipAlarmDataExcel(
this.queryParams
);
this.$download.excel(data, "机床设备报警数据.xls");
} catch {
} finally {
this.exportLoading = false;
}
},
},
};
</script>