feat(event): 新增暂态事件列表功能

- 新增事件列表控制器,提供分页查询、详情查看和导出功能
- 实现事件列表服务和数据访问层,支持多条件查询
- 添加台账链路查询功能,关联工程、项目、设备和监测点信息
- 实现事件数据的Excel导出功能,包含完整的字段映射
- 添加相关索引优化查询性能
- 集成台账服务,支持通过台账路径筛选事件数据
This commit is contained in:
2026-05-09 13:16:56 +08:00
parent c3b074db26
commit 6f5d8dc45a
19 changed files with 1009 additions and 0 deletions

View File

@@ -1,7 +1,9 @@
package com.njcn.gather.tool.addledger.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerLinePathQueryParam;
import com.njcn.gather.tool.addledger.pojo.po.AddLedgerLinePO;
import com.njcn.gather.tool.addledger.pojo.vo.AddLedgerLinePathVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -17,5 +19,9 @@ public interface AddLedgerLineMapper extends BaseMapper<AddLedgerLinePO> {
@Param("lineNo") Integer lineNo,
@Param("lineId") String lineId);
List<AddLedgerLinePathVO> selectLinePathByLineIds(@Param("lineIds") List<String> lineIds);
List<AddLedgerLinePathVO> selectLinePathByQuery(@Param("param") AddLedgerLinePathQueryParam param);
int softDeleteByIds(@Param("ids") List<String> ids, @Param("updateBy") String updateBy);
}

View File

@@ -25,6 +25,62 @@
</if>
</select>
<select id="selectLinePathByLineIds" resultType="com.njcn.gather.tool.addledger.pojo.vo.AddLedgerLinePathVO">
SELECT engineering.id AS engineeringId,
engineering.name AS engineeringName,
project.id AS projectId,
project.name AS projectName,
equipment.id AS equipmentId,
equipment.name AS equipmentName,
line.line_id AS lineId,
line.name AS lineName
FROM cs_line line
INNER JOIN cs_equipment_delivery equipment ON equipment.id = line.device_id
INNER JOIN cs_project project ON project.id = equipment.associated_project
INNER JOIN cs_engineering engineering ON engineering.id = equipment.associated_engineering
WHERE line.status = 1
AND equipment.run_status &lt;&gt; 0
AND project.status = 1
AND engineering.status = 1
AND line.line_id IN
<foreach collection="lineIds" item="lineId" open="(" separator="," close=")">
#{lineId}
</foreach>
</select>
<select id="selectLinePathByQuery" resultType="com.njcn.gather.tool.addledger.pojo.vo.AddLedgerLinePathVO">
SELECT engineering.id AS engineeringId,
engineering.name AS engineeringName,
project.id AS projectId,
project.name AS projectName,
equipment.id AS equipmentId,
equipment.name AS equipmentName,
line.line_id AS lineId,
line.name AS lineName
FROM cs_line line
INNER JOIN cs_equipment_delivery equipment ON equipment.id = line.device_id
INNER JOIN cs_project project ON project.id = equipment.associated_project
INNER JOIN cs_engineering engineering ON engineering.id = equipment.associated_engineering
WHERE line.status = 1
AND equipment.run_status &lt;&gt; 0
AND project.status = 1
AND engineering.status = 1
<if test="param.engineeringName != null and param.engineeringName != ''">
AND engineering.name LIKE CONCAT('%', #{param.engineeringName}, '%')
</if>
<if test="param.projectName != null and param.projectName != ''">
AND project.name LIKE CONCAT('%', #{param.projectName}, '%')
</if>
<if test="param.equipmentName != null and param.equipmentName != ''">
AND equipment.name LIKE CONCAT('%', #{param.equipmentName}, '%')
</if>
<if test="param.lineName != null and param.lineName != ''">
AND line.name LIKE CONCAT('%', #{param.lineName}, '%')
</if>
ORDER BY engineering.name ASC, project.name ASC, equipment.name ASC, line.name ASC
LIMIT #{param.limit}
</select>
<update id="softDeleteByIds">
UPDATE cs_line
SET status = 0,

View File

@@ -0,0 +1,26 @@
package com.njcn.gather.tool.addledger.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 监测点台账链路检索参数。
*/
@Data
public class AddLedgerLinePathQueryParam {
@ApiModelProperty("工程名称关键字")
private String engineeringName;
@ApiModelProperty("项目名称关键字")
private String projectName;
@ApiModelProperty("设备名称关键字")
private String equipmentName;
@ApiModelProperty("监测点名称关键字")
private String lineName;
@ApiModelProperty("最大返回监测点数量")
private Integer limit;
}

View File

@@ -0,0 +1,30 @@
package com.njcn.gather.tool.addledger.pojo.vo;
import lombok.Data;
import java.io.Serializable;
/**
* 监测点所属台账链路。
*/
@Data
public class AddLedgerLinePathVO implements Serializable {
private static final long serialVersionUID = 1L;
private String engineeringId;
private String engineeringName;
private String projectId;
private String projectName;
private String equipmentId;
private String equipmentName;
private String lineId;
private String lineName;
}

View File

@@ -2,12 +2,15 @@ package com.njcn.gather.tool.addledger.service;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerEngineeringSaveParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerEquipmentSaveParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerLinePathQueryParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerLineSaveParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerProjectSaveParam;
import com.njcn.gather.tool.addledger.pojo.vo.AddLedgerDetailVO;
import com.njcn.gather.tool.addledger.pojo.vo.AddLedgerLinePathVO;
import com.njcn.gather.tool.addledger.pojo.vo.AddLedgerTreeNodeVO;
import java.util.List;
import java.util.Map;
/**
* 数据台账服务。
@@ -28,5 +31,9 @@ public interface AddLedgerService {
List<Integer> availableLineNos(String deviceId, String lineId);
Map<String, AddLedgerLinePathVO> listLinePathByLineIds(List<String> lineIds);
List<String> listLineIdsByPathQuery(AddLedgerLinePathQueryParam param);
boolean deleteNode(String id, Integer level);
}

View File

@@ -10,6 +10,7 @@ import com.njcn.gather.tool.addledger.mapper.AddLedgerProjectMapper;
import com.njcn.gather.tool.addledger.pojo.constant.AddLedgerConst;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerEngineeringSaveParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerEquipmentSaveParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerLinePathQueryParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerLineSaveParam;
import com.njcn.gather.tool.addledger.pojo.param.AddLedgerProjectSaveParam;
import com.njcn.gather.tool.addledger.pojo.po.AddLedgerEngineeringPO;
@@ -18,6 +19,7 @@ import com.njcn.gather.tool.addledger.pojo.po.AddLedgerLedgerPO;
import com.njcn.gather.tool.addledger.pojo.po.AddLedgerLinePO;
import com.njcn.gather.tool.addledger.pojo.po.AddLedgerProjectPO;
import com.njcn.gather.tool.addledger.pojo.vo.AddLedgerDetailVO;
import com.njcn.gather.tool.addledger.pojo.vo.AddLedgerLinePathVO;
import com.njcn.gather.tool.addledger.pojo.vo.AddLedgerTreeNodeVO;
import com.njcn.gather.tool.addledger.service.AddLedgerService;
import com.njcn.gather.tool.addledger.util.AddLedgerIdUtil;
@@ -29,7 +31,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 数据台账服务实现。
@@ -38,6 +43,9 @@ import java.util.List;
@RequiredArgsConstructor
public class AddLedgerServiceImpl implements AddLedgerService {
private static final int DEFAULT_LINE_PATH_QUERY_LIMIT = 1000;
private static final int MAX_LINE_PATH_QUERY_LIMIT = 5000;
private final AddLedgerEngineeringMapper engineeringMapper;
private final AddLedgerProjectMapper projectMapper;
private final AddLedgerEquipmentMapper equipmentMapper;
@@ -220,6 +228,43 @@ public class AddLedgerServiceImpl implements AddLedgerService {
return AddLedgerLineNoUtil.resolveAvailableLineNos(usedLineNos, null);
}
@Override
public Map<String, AddLedgerLinePathVO> listLinePathByLineIds(List<String> lineIds) {
List<String> normalizedLineIds = normalizeIds(lineIds);
if (normalizedLineIds.isEmpty()) {
return Collections.emptyMap();
}
List<AddLedgerLinePathVO> linePaths = lineMapper.selectLinePathByLineIds(normalizedLineIds);
Map<String, AddLedgerLinePathVO> result = new LinkedHashMap<String, AddLedgerLinePathVO>();
for (AddLedgerLinePathVO linePath : linePaths) {
if (linePath != null && !isBlank(linePath.getLineId())) {
result.put(linePath.getLineId(), linePath);
}
}
return result;
}
@Override
public List<String> listLineIdsByPathQuery(AddLedgerLinePathQueryParam param) {
if (!hasPathKeyword(param)) {
return Collections.emptyList();
}
AddLedgerLinePathQueryParam queryParam = new AddLedgerLinePathQueryParam();
queryParam.setEngineeringName(trimToNull(param.getEngineeringName()));
queryParam.setProjectName(trimToNull(param.getProjectName()));
queryParam.setEquipmentName(trimToNull(param.getEquipmentName()));
queryParam.setLineName(trimToNull(param.getLineName()));
queryParam.setLimit(normalizeLimit(param.getLimit()));
List<AddLedgerLinePathVO> linePaths = lineMapper.selectLinePathByQuery(queryParam);
List<String> lineIds = new ArrayList<String>();
for (AddLedgerLinePathVO linePath : linePaths) {
if (linePath != null && !isBlank(linePath.getLineId())) {
lineIds.add(linePath.getLineId());
}
}
return lineIds;
}
@Override
@Transactional
public boolean deleteNode(String id, Integer level) {
@@ -487,6 +532,35 @@ public class AddLedgerServiceImpl implements AddLedgerService {
return trimToNull(value) == null;
}
private List<String> normalizeIds(List<String> ids) {
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
List<String> normalizedIds = new ArrayList<String>();
for (String id : ids) {
String normalizedId = trimToNull(id);
if (normalizedId != null && !normalizedIds.contains(normalizedId)) {
normalizedIds.add(normalizedId);
}
}
return normalizedIds;
}
private boolean hasPathKeyword(AddLedgerLinePathQueryParam param) {
return param != null
&& (trimToNull(param.getEngineeringName()) != null
|| trimToNull(param.getProjectName()) != null
|| trimToNull(param.getEquipmentName()) != null
|| trimToNull(param.getLineName()) != null);
}
private int normalizeLimit(Integer limit) {
if (limit == null || limit <= 0) {
return DEFAULT_LINE_PATH_QUERY_LIMIT;
}
return Math.min(limit, MAX_LINE_PATH_QUERY_LIMIT);
}
private String currentUserId() {
try {
String userId = RequestUtil.getUserId();