预警告警

This commit is contained in:
mashuai 2024-09-29 10:04:08 +08:00
parent 8436aeeb68
commit bf27ab07f8
6 changed files with 113 additions and 80 deletions

View File

@ -2,6 +2,7 @@ package com.bonus.base.controller;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.base.domain.TbDevAttribute;
import com.bonus.base.domain.TbDevDataRecord;
import com.bonus.base.service.TbDevAttributeService;
import com.bonus.base.vo.TbDevAttributeVo;
import com.bonus.common.core.utils.poi.ExcelUtil;
@ -55,18 +56,6 @@ public class TbDevAttributeController extends BaseController {
}
/**
* 编辑数据
*
* @param record 实体
* @return 编辑结果
*/
@PutMapping
public AjaxResult edit(@RequestBody TbDevAttribute record) {
return toAjax(tbDevAttributeService.updateByPrimaryKeySelective(record));
}
/**
* 删除数据
*/
@ -77,12 +66,12 @@ public class TbDevAttributeController extends BaseController {
/**
* 预警告警异常记录处理
* @param handle
* @param tbDevDataRecord
* @return
*/
@PostMapping("/handle")
public AjaxResult approve(@RequestBody TbDevAttribute handle) {
return tbDevAttributeService.handle(handle);
public AjaxResult approve(@RequestBody TbDevDataRecord tbDevDataRecord) {
return tbDevAttributeService.handle(tbDevDataRecord);
}
/**

View File

@ -0,0 +1,70 @@
package com.bonus.base.domain;
import lombok.Data;
import java.io.Serializable;
/**
* 设备检测记录表(TbDevDataRecord)实体类
*
* @author makejava
* @since 2024-09-29 09:57:11
*/
@Data
public class TbDevDataRecord implements Serializable {
private static final long serialVersionUID = -77473094132432756L;
/**
* id
*/
private Long id;
/**
* 数据json
*/
private String devJson;
/**
* 设备id
*/
private Long devId;
/**
* 设备名称
*/
private String devName;
/**
* 检测id
*/
private Long attributeId;
/**
* 检测名称
*/
private String attributeName;
/**
* 检测值
*/
private String attributeVal;
/**
* 合并项-同一批次 的此数据一致
*/
private String mergerId;
/**
* 是否告警
*/
private Integer isWarn;
/**
* 检测时间
*/
private String createTime;
/**
* 设备类型
*/
private String devType;
/**
* 0未处置 1已处置
*/
private Integer isDispose;
/**
* 处置内容
*/
private String remarks;
}

View File

@ -1,7 +1,7 @@
package com.bonus.base.mapper;
import com.bonus.base.domain.TbDevDataRecord;
import com.bonus.base.vo.TbDevAttributeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.bonus.base.domain.TbDevAttribute;
import java.util.List;
@ -30,7 +30,7 @@ public interface TbDevAttributeMapper {
/**
* update record selective
*/
int updateByPrimaryKeySelective(TbDevAttribute record);
int updateByPrimaryKeySelective(TbDevDataRecord tbDevDataRecord);
/**
* update record

View File

@ -2,6 +2,7 @@ package com.bonus.base.service;
import java.util.List;
import com.bonus.base.domain.TbDevAttribute;
import com.bonus.base.domain.TbDevDataRecord;
import com.bonus.base.vo.TbDevAttributeVo;
import com.bonus.common.core.web.domain.AjaxResult;
@ -20,8 +21,6 @@ public interface TbDevAttributeService{
TbDevAttribute selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TbDevAttribute record);
int updateByPrimaryKey(TbDevAttribute record);
int updateBatch(List<TbDevAttribute> list);
@ -30,8 +29,8 @@ public interface TbDevAttributeService{
/**
* 预警告警异常记录处理
* @param handle
* @param tbDevDataRecord
* @return
*/
AjaxResult handle(TbDevAttribute handle);
AjaxResult handle(TbDevDataRecord tbDevDataRecord);
}

View File

@ -1,6 +1,7 @@
package com.bonus.base.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.base.domain.TbDevDataRecord;
import com.bonus.base.vo.TbDevAttributeVo;
import com.bonus.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Service;
@ -49,11 +50,6 @@ public class TbDevAttributeServiceImpl implements TbDevAttributeService{
return tbDevAttributeMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(TbDevAttribute record) {
return tbDevAttributeMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(TbDevAttribute record) {
return tbDevAttributeMapper.updateByPrimaryKey(record);
@ -69,10 +65,10 @@ public class TbDevAttributeServiceImpl implements TbDevAttributeService{
List<TbDevAttributeVo> list = tbDevAttributeMapper.queryAll(record);
if (CollectionUtils.isNotEmpty(list)) {
for (TbDevAttributeVo attribute : list) {
if (attribute.getIsWarn() == 1) {
attribute.setWarnName(attribute.getJcName() + "超过阈值");
attribute.setWarnName(attribute.getDevName() + attribute.getJcName() + "检测异常");
if ("0".equals(attribute.getStatus())) {
attribute.setStatus("未处置");
} else {
} else if ("1".equals(attribute.getStatus())) {
attribute.setStatus("已处置");
}
}
@ -82,12 +78,12 @@ public class TbDevAttributeServiceImpl implements TbDevAttributeService{
/**
* 预警告警异常记录处理
* @param handle
* @param tbDevDataRecord
* @return
*/
@Override
public AjaxResult handle(TbDevAttribute handle) {
int result = tbDevAttributeMapper.updateByPrimaryKeySelective(handle);
public AjaxResult handle(TbDevDataRecord tbDevDataRecord) {
int result = tbDevAttributeMapper.updateByPrimaryKeySelective(tbDevDataRecord);
return result > 0 ? AjaxResult.success("处理成功") : AjaxResult.error("处理失败");
}
}

View File

@ -28,33 +28,33 @@
</select>
<select id="queryAll" resultType="com.bonus.base.vo.TbDevAttributeVo">
select tda.id as id,
tda.dev_id as devId,
td.dev_type as devType,
sdd.dict_label as devTypeName,
td.dev_code as devCode,
td.dev_name as devName,
tda.jc_name as jcName,
tda.jc_value as jcValue,
tda.jc_unit as jcUnit,
tda.logo_url as logoUrl,
tda.del_flag as delFlag,
tda.rel_code as relCode,
tda.is_warn as isWarn,
tda.jc_time as jcTime,
tda.remarks as remarks
from tb_dev_attribute tda
left join tb_device td on tda.dev_id = td.id and td.del_flag = 0
left join sys_dict_data sdd on sdd.dict_code = td.dev_type
where tda.del_flag = 0
SELECT
tddr.id AS id,
tddr.dev_id AS devId,
tddr.dev_type AS devType,
sdd.dict_label AS devTypeName,
td.dev_code AS devCode,
tddr.dev_name AS devName,
tddr.attribute_name AS jcName,
tddr.is_dispose AS STATUS,
tddr.is_warn AS isWarn,
tddr.create_time AS jcTime,
tddr.remark AS remarks
FROM
tb_dev_data_record tddr
LEFT JOIN tb_device td ON tddr.dev_id = td.id
AND td.del_flag = 0
LEFT JOIN sys_dict_data sdd ON sdd.dict_code = tddr.dev_type
WHERE
tddr.is_warn = '1'
<if test="devName != null and devName != ''">
and td.dev_name like concat('%',#{devName},'%')
and tddr.dev_name like concat('%',#{devName},'%')
</if>
<if test="devType != null and devType != ''">
and td.dev_type = #{devType}
and tddr.dev_type = #{devType}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[and tda.jc_time BETWEEN #{startTime} AND #{endTime} ]]>
<![CDATA[and tddr.create_time BETWEEN #{startTime} AND #{endTime} ]]>
</if>
</select>
@ -143,39 +143,18 @@
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.base.domain.TbDevAttribute">
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.base.domain.TbDevDataRecord">
<!--@mbg.generated-->
update tb_dev_attribute
update tb_dev_data_record
<set>
<if test="devId != null">
dev_id = #{devId,jdbcType=BIGINT},
</if>
<if test="jcName != null and jcName != ''">
jc_name = #{jcName,jdbcType=VARCHAR},
</if>
<if test="jcValue != null and jcValue != ''">
jc_value = #{jcValue,jdbcType=VARCHAR},
</if>
<if test="jcUnit != null and jcUnit != ''">
jc_unit = #{jcUnit,jdbcType=VARCHAR},
</if>
<if test="logoUrl != null and logoUrl != ''">
logo_url = #{logoUrl,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=INTEGER},
</if>
<if test="relCode != null and relCode != ''">
rel_code = #{relCode,jdbcType=VARCHAR},
</if>
<if test="isWarn != null">
is_warn = #{isWarn,jdbcType=INTEGER},
</if>
<if test="jcTime != null and jcTime != ''">
jc_time = #{jcTime,jdbcType=VARCHAR},
<if test="isDispose != null">
is_dispose = #{isDispose,jdbcType=INTEGER},
</if>
<if test="remarks != null and remarks != ''">
remarks = #{remarks},
remark = #{remarks},
</if>
</set>
where id = #{id,jdbcType=BIGINT}