修改告警导出 新增公共档案

This commit is contained in:
15666619788
2025-08-02 17:05:55 +08:00
parent 6bc5fcb2aa
commit 1e7df355fa
14 changed files with 506 additions and 24 deletions

View File

@@ -61,8 +61,8 @@ public class TestController2 {
AlertLog alertLog = new AlertLog();
alertLog.setSerialNumber(deviceNumber);
alertLog.setAlertName("温度告警测试");
alertLog.setAlertLevel(1L);
alertLog.setStatus(1);
alertLog.setAlertLevel("1");
alertLog.setStatus("1");
alertLog.setProductId(1L);
alertLog.setDetail("111");
alertLog.setCreateTime(new Date());

View File

@@ -392,7 +392,7 @@ public class SceneContext {
private boolean checkDeviceAlerting(Long sceneId, String deviceNum) {
AlertLog alertLog = new AlertLog();
alertLog.setSerialNumber(deviceNum);
alertLog.setStatus(2);
alertLog.setStatus("2");
alertLog.setCreateBy(sceneId.toString());
Long count = alertLogService.selectSceneAlertLogListCount(alertLog);
// 查询设备告警对应的场景是否有未处理告警
@@ -437,7 +437,7 @@ public class SceneContext {
AlertLog alertLog = new AlertLog();
alertLog.setCreateBy(scriptTemplate.getRecoverId().toString());
alertLog.setSerialNumber(deviceNum);
alertLog.setStatus(2);
alertLog.setStatus("2");
//自动设置告警处理状态
alertLogService.updateAlertLogStatus(alertLog);
//如果存在延时确认任务,则删除
@@ -529,14 +529,14 @@ public class SceneContext {
private AlertLog getTerminalUserAlertLog(SceneTerminalUserVO sceneTerminalUserVO, Device device, SceneThingsModelItem sceneThingsModelItem) {
AlertLog alertLog = new AlertLog();
alertLog.setAlertName("设备告警");
alertLog.setAlertLevel(1L);
alertLog.setAlertLevel("1");
alertLog.setSerialNumber(sceneThingsModelItem.getDeviceNumber());
alertLog.setProductId(sceneThingsModelItem.getProductId());
alertLog.setDeviceName(device.getDeviceName());
alertLog.setUserId(sceneTerminalUserVO.getUserId());
alertLog.setCreateBy(sceneThingsModelItem.getSceneId().toString());
// 统一未处理
alertLog.setStatus(2);
alertLog.setStatus("2");
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", sceneThingsModelItem.getId());
jsonObject.put("value", sceneThingsModelItem.getValue());
@@ -564,7 +564,7 @@ public class SceneContext {
alertLog.setUserId(device.getTenantId());
alertLog.setCreateBy(sceneThingsModelItem.getSceneId().toString());
// 统一未处理
alertLog.setStatus(2);
alertLog.setStatus("2");
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", sceneThingsModelItem.getId());
jsonObject.put("value", sceneThingsModelItem.getValue());

View File

@@ -73,17 +73,17 @@ public class AlertLogController extends BaseController
{
Map<String,Integer> map = new HashMap<>();
AlertLog alertLog = new AlertLog();
alertLog.setStatus(2);
alertLog.setStatus("2");
List<AlertLog> list = alertLogService.selectAlertLogList(alertLog);
//1=提醒通知2=轻微问题3=严重警告
List<AlertLog> tlist =list.stream()
.filter(log -> log.getAlertLevel() == 1)
.filter(log -> log.getAlertLevel() == "1")
.collect(Collectors.toList());
List<AlertLog> qlist =list.stream()
.filter(log -> log.getAlertLevel() == 2)
.filter(log -> log.getAlertLevel() == "2")
.collect(Collectors.toList());
List<AlertLog> ylist =list.stream()
.filter(log -> log.getAlertLevel() == 3)
.filter(log -> log.getAlertLevel() == "3")
.collect(Collectors.toList());
map.put("tx",tlist.size());
map.put("qw",qlist.size());

View File

@@ -0,0 +1,110 @@
package com.xinda.data.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinda.common.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.iot.domain.PubDoc;
import com.xinda.iot.service.IPubDocService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;
/**
* 公共档案Controller
*
* @author kerwincui
* @date 2025-08-02
*/
@RestController
@RequestMapping("/iot/pubDoc")
@Api(tags = "公共档案")
public class PubDocController extends BaseController
{
@Autowired
private IPubDocService pubDocService;
/**
* 查询公共档案列表
*/
@PreAuthorize("@ss.hasPermi('iot:pubDoc:list')")
@GetMapping("/list")
@ApiOperation("查询公共档案列表")
public TableDataInfo list(PubDoc pubDoc)
{
startPage();
List<PubDoc> list = pubDocService.selectPubDocList(pubDoc);
return getDataTable(list);
}
/**
* 导出公共档案列表
*/
@ApiOperation("导出公共档案列表")
@PreAuthorize("@ss.hasPermi('iot:pubDoc:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, PubDoc pubDoc)
{
List<PubDoc> list = pubDocService.selectPubDocList(pubDoc);
ExcelUtil<PubDoc> util = new ExcelUtil<PubDoc>(PubDoc.class);
util.exportExcel(response, list, "公共档案数据");
}
/**
* 获取公共档案详细信息
*/
@PreAuthorize("@ss.hasPermi('iot:pubDoc:query')")
@GetMapping(value = "/{id}")
@ApiOperation("获取公共档案详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(pubDocService.selectPubDocById(id));
}
/**
* 新增公共档案
*/
@PreAuthorize("@ss.hasPermi('iot:pubDoc:add')")
@PostMapping
@ApiOperation("新增公共档案")
public AjaxResult add(@RequestBody PubDoc pubDoc)
{
return toAjax(pubDocService.insertPubDoc(pubDoc));
}
/**
* 修改公共档案
*/
@PreAuthorize("@ss.hasPermi('iot:pubDoc:edit')")
@PutMapping
@ApiOperation("修改公共档案")
public AjaxResult edit(@RequestBody PubDoc pubDoc)
{
return toAjax(pubDocService.updatePubDoc(pubDoc));
}
/**
* 删除公共档案
*/
@PreAuthorize("@ss.hasPermi('iot:pubDoc:remove')")
@DeleteMapping("/{ids}")
@ApiOperation("删除公共档案")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(pubDocService.deletePubDocByIds(ids));
}
}

View File

@@ -166,7 +166,7 @@ public class DeviceJob {
alertPushParams.setNotifyTemplateId(alertNotifyTemplate.getNotifyTemplateId());
notifySendService.alertSend(alertPushParams);
}
List<AlertLog> alist = alertLogService.selectAlertLogListByCreateBy(alertlog.getSceneId().toString(), alertlog.getId(), 2);
List<AlertLog> alist = alertLogService.selectAlertLogListByCreateBy(alertlog.getSceneId().toString(), alertlog.getId(), "2");
if (alist.isEmpty()) {
AlertLog alertLog = buildAlertLog(alertSceneSendVO, device, alertlog);
alertLogList.add(alertLog);
@@ -190,7 +190,7 @@ public class DeviceJob {
alertLog.setProductId(device.getProductId());
alertLog.setDeviceName(device.getDeviceName());
alertLog.setUserId(device.getTenantId());
alertLog.setStatus(2);
alertLog.setStatus("2");
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", Item.getId());

View File

@@ -27,7 +27,8 @@ public class AlertLog extends BaseEntity
/** 告警ID */
@ApiModelProperty("告警ID")
private Long alertLogId;
@Excel(name = "设备名称")
private String deviceName;
/** 告警名称 */
@ApiModelProperty("告警名称")
@Excel(name = "告警名称")
@@ -35,17 +36,17 @@ public class AlertLog extends BaseEntity
/** 告警级别1=提醒通知2=轻微问题3=严重警告4=场景联动) */
@ApiModelProperty("告警级别1=提醒通知2=轻微问题3=严重警告4=场景联动)")
@Excel(name = "告警级别", readConverterExp = "1==提醒通知2=轻微问题3=严重警告4=场景联动")
private Long alertLevel;
@Excel(name = "告警级别", readConverterExp = "1=提醒通知,2=轻微问题,3=严重警告,4=场景联动")
private String alertLevel;
/** 处理状态(1=不需要处理,2=未处理,3=已处理) */
@ApiModelProperty("处理状态(1=不需要处理,2=未处理,3=已处理)")
@Excel(name = "处理状态(1=不需要处理,2=未处理,3=已处理)")
private Integer status;
@Excel(name = "处理状态", readConverterExp ="1=不需要处理,2=未处理,3=已处理)")
private String status;
/** 产品ID */
@ApiModelProperty("产品ID")
@Excel(name = "产品ID")
// @Excel(name = "产品ID")
private Long productId;
/** 设备编号 */
@@ -62,7 +63,7 @@ public class AlertLog extends BaseEntity
private Long orderId;
private RepairOrder order;
private String deviceName;
private Long deviceId;
private Long sceneId;

View File

@@ -0,0 +1,56 @@
package com.xinda.iot.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
/**
* 公共档案对象 iot_pub_doc
*
* @author kerwincui
* @date 2025-08-02
*/
@ApiModel(value = "PubDoc",description = "公共档案 iot_pub_doc")
@Data
public class PubDoc extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id唯一标识 */
private Long id;
/** 机构id */
@Excel(name = "机构id")
@ApiModelProperty("机构id")
private Long deptId;
/** 机构名称 */
@Excel(name = "机构名称")
@ApiModelProperty("机构名称")
private String deptName;
/** 文件名称 */
@Excel(name = "文件名称")
@ApiModelProperty("文件名称")
private String fileName;
/** 资源请求路径 */
@Excel(name = "资源请求路径")
@ApiModelProperty("资源请求路径")
private String resourceUrl;
/** 租户id */
@Excel(name = "租户id")
@ApiModelProperty("租户id")
private Long tenantId;
/** 租户名称 */
@Excel(name = "租户名称")
@ApiModelProperty("租户名称")
private String tenantName;
}

View File

@@ -0,0 +1,61 @@
package com.xinda.iot.mapper;
import java.util.List;
import com.xinda.iot.domain.PubDoc;
/**
* 公共档案Mapper接口
*
* @author kerwincui
* @date 2025-08-02
*/
public interface PubDocMapper
{
/**
* 查询公共档案
*
* @param id 公共档案主键
* @return 公共档案
*/
public PubDoc selectPubDocById(Long id);
/**
* 查询公共档案列表
*
* @param pubDoc 公共档案
* @return 公共档案集合
*/
public List<PubDoc> selectPubDocList(PubDoc pubDoc);
/**
* 新增公共档案
*
* @param pubDoc 公共档案
* @return 结果
*/
public int insertPubDoc(PubDoc pubDoc);
/**
* 修改公共档案
*
* @param pubDoc 公共档案
* @return 结果
*/
public int updatePubDoc(PubDoc pubDoc);
/**
* 删除公共档案
*
* @param id 公共档案主键
* @return 结果
*/
public int deletePubDocById(Long id);
/**
* 批量删除公共档案
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deletePubDocByIds(Long[] ids);
}

View File

@@ -29,7 +29,7 @@ public class AlertSceneSendVO {
/**
* 告警级别1=提醒通知2=轻微问题3=严重警告)
*/
private Long alertLevel;
private String alertLevel;
}

View File

@@ -30,7 +30,7 @@ public interface IAlertLogService
* @return 设备告警集合
*/
public List<AlertLog> selectAlertLogList(AlertLog alertLog);
public List<AlertLog> selectAlertLogListByCreateBy(String createBy, String remark, Integer status);
public List<AlertLog> selectAlertLogListByCreateBy(String createBy, String remark, String status);
/**
* 查询设备告警列表总数
*

View File

@@ -0,0 +1,61 @@
package com.xinda.iot.service;
import java.util.List;
import com.xinda.iot.domain.PubDoc;
/**
* 公共档案Service接口
*
* @author kerwincui
* @date 2025-08-02
*/
public interface IPubDocService
{
/**
* 查询公共档案
*
* @param id 公共档案主键
* @return 公共档案
*/
public PubDoc selectPubDocById(Long id);
/**
* 查询公共档案列表
*
* @param pubDoc 公共档案
* @return 公共档案集合
*/
public List<PubDoc> selectPubDocList(PubDoc pubDoc);
/**
* 新增公共档案
*
* @param pubDoc 公共档案
* @return 结果
*/
public int insertPubDoc(PubDoc pubDoc);
/**
* 修改公共档案
*
* @param pubDoc 公共档案
* @return 结果
*/
public int updatePubDoc(PubDoc pubDoc);
/**
* 批量删除公共档案
*
* @param ids 需要删除的公共档案主键集合
* @return 结果
*/
public int deletePubDocByIds(Long[] ids);
/**
* 删除公共档案信息
*
* @param id 公共档案主键
* @return 结果
*/
public int deletePubDocById(Long id);
}

View File

@@ -92,7 +92,7 @@ public class AlertLogServiceImpl implements IAlertLogService {
}
@Override
public List<AlertLog> selectAlertLogListByCreateBy(String createBy, String remark, Integer status) {
public List<AlertLog> selectAlertLogListByCreateBy(String createBy, String remark, String status) {
AlertLog alertLog = new AlertLog();
alertLog.setCreateBy(createBy);
alertLog.setStatus(status);
@@ -187,7 +187,7 @@ public class AlertLogServiceImpl implements IAlertLogService {
alertLog.setUpdateTime(DateUtils.getNowDate());
if (alertLog.getRemark().length() > 0) {
// 1=不需要处理,2=未处理,3=已处理
alertLog.setStatus(3);
alertLog.setStatus("3");
}
if (alertLog.getEnable()==1) {
RepairOrder order = alertLog.getOrder();

View File

@@ -0,0 +1,96 @@
package com.xinda.iot.service.impl;
import java.util.List;
import com.xinda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinda.iot.mapper.PubDocMapper;
import com.xinda.iot.domain.PubDoc;
import com.xinda.iot.service.IPubDocService;
/**
* 公共档案Service业务层处理
*
* @author kerwincui
* @date 2025-08-02
*/
@Service
public class PubDocServiceImpl implements IPubDocService
{
@Autowired
private PubDocMapper pubDocMapper;
/**
* 查询公共档案
*
* @param id 公共档案主键
* @return 公共档案
*/
@Override
public PubDoc selectPubDocById(Long id)
{
return pubDocMapper.selectPubDocById(id);
}
/**
* 查询公共档案列表
*
* @param pubDoc 公共档案
* @return 公共档案
*/
@Override
public List<PubDoc> selectPubDocList(PubDoc pubDoc)
{
return pubDocMapper.selectPubDocList(pubDoc);
}
/**
* 新增公共档案
*
* @param pubDoc 公共档案
* @return 结果
*/
@Override
public int insertPubDoc(PubDoc pubDoc)
{
pubDoc.setCreateTime(DateUtils.getNowDate());
return pubDocMapper.insertPubDoc(pubDoc);
}
/**
* 修改公共档案
*
* @param pubDoc 公共档案
* @return 结果
*/
@Override
public int updatePubDoc(PubDoc pubDoc)
{
pubDoc.setUpdateTime(DateUtils.getNowDate());
return pubDocMapper.updatePubDoc(pubDoc);
}
/**
* 批量删除公共档案
*
* @param ids 需要删除的公共档案主键
* @return 结果
*/
@Override
public int deletePubDocByIds(Long[] ids)
{
return pubDocMapper.deletePubDocByIds(ids);
}
/**
* 删除公共档案信息
*
* @param id 公共档案主键
* @return 结果
*/
@Override
public int deletePubDocById(Long id)
{
return pubDocMapper.deletePubDocById(id);
}
}

View File

@@ -0,0 +1,97 @@
<?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.xinda.iot.mapper.PubDocMapper">
<resultMap type="PubDoc" id="PubDocResult">
<result property="id" column="id" />
<result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" />
<result property="fileName" column="file_name" />
<result property="resourceUrl" column="resource_url" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPubDocVo">
select id, dept_id, dept_name, file_name, resource_url, tenant_id, tenant_name, create_by, create_time, update_by, update_time from iot_pub_doc
</sql>
<select id="selectPubDocList" parameterType="PubDoc" resultMap="PubDocResult">
<include refid="selectPubDocVo"/>
<where>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="resourceUrl != null and resourceUrl != ''"> and resource_url = #{resourceUrl}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
</where>
</select>
<select id="selectPubDocById" parameterType="Long" resultMap="PubDocResult">
<include refid="selectPubDocVo"/>
where id = #{id}
</select>
<insert id="insertPubDoc" parameterType="PubDoc" useGeneratedKeys="true" keyProperty="id">
insert into iot_pub_doc
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptId != null">dept_id,</if>
<if test="deptName != null">dept_name,</if>
<if test="fileName != null">file_name,</if>
<if test="resourceUrl != null">resource_url,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null">tenant_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptId != null">#{deptId},</if>
<if test="deptName != null">#{deptName},</if>
<if test="fileName != null">#{fileName},</if>
<if test="resourceUrl != null">#{resourceUrl},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null">#{tenantName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updatePubDoc" parameterType="PubDoc">
update iot_pub_doc
<trim prefix="SET" suffixOverrides=",">
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="deptName != null">dept_name = #{deptName},</if>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="resourceUrl != null">resource_url = #{resourceUrl},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null">tenant_name = #{tenantName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deletePubDocById" parameterType="Long">
delete from iot_pub_doc where id = #{id}
</delete>
<delete id="deletePubDocByIds" parameterType="String">
delete from iot_pub_doc where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>