feat(device): 更新设备台账和事件查询功能

- 添加AppProjectService依赖以获取项目信息
- 修改项目数量获取逻辑,直接从接口获取项目信息而非设备关联数
- 在事件查询接口中添加线路ID参数支持
- 更新XML映射文件,添加线路ID过滤条件
- 修复便携式设备树结构中的固定ID分配
- 更新便携式工程和项目的固定ID为"1"和"2"
- 优化事件查询服务中的设备和线路ID处理逻辑
This commit is contained in:
xy
2026-07-13 16:35:48 +08:00
parent b265e95bdf
commit 4e7a10f46e
5 changed files with 40 additions and 19 deletions

View File

@@ -60,6 +60,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final IMqttUserService mqttUserService; private final IMqttUserService mqttUserService;
private final CsCommTerminalFeignClient commTerminalService; private final CsCommTerminalFeignClient commTerminalService;
private final AppProjectService appProjectService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@@ -272,9 +273,15 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
break; break;
} }
} }
//获取项目数量 //获取项目数量 这边可能项目下没有挂载设备,这边项目数量直接从接口获取
if (CollectionUtil.isNotEmpty(currentProjectIds)) { // if (CollectionUtil.isNotEmpty(currentProjectIds)) {
vo.setCurrentProjectCount(currentProjectIds.size()); // vo.setCurrentProjectCount(currentProjectIds.size());
// }
List<AppProjectPO> projectInfoList = appProjectService.getProjectByEngineering(Collections.singletonList(id));
if (CollectionUtil.isNotEmpty(projectInfoList)) {
vo.setCurrentProjectCount(projectInfoList.size());
} else {
vo.setCurrentProjectCount(0);
} }
//获取设备总数、在线设备、离线设备 //获取设备总数、在线设备、离线设备
if (CollectionUtil.isNotEmpty(currentDevIds)) { if (CollectionUtil.isNotEmpty(currentDevIds)) {

View File

@@ -300,7 +300,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<CsLedgerVO> portables = ledger.stream() List<CsLedgerVO> portables = ledger.stream()
.peek(c -> { .peek(c -> {
CsEquipmentDeliveryPO po = poMap2.get(c.getId()); CsEquipmentDeliveryPO po = poMap2.get(c.getId());
c.setPid(portable.getId()); c.setPid("2");
c.setComFlag(po.getRunStatus()); c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid()); c.setNDId(po.getNdid());
c.setType("device"); c.setType("device");
@@ -365,13 +365,13 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
portable1.setLevel(0); portable1.setLevel(0);
portable1.setName("便携式工程"); portable1.setName("便携式工程");
portable1.setPid("0"); portable1.setPid("0");
portable1.setId(id); portable1.setId("1");
CsLedgerVO portable2 = new CsLedgerVO(); CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1); portable2.setLevel(1);
portable2.setName("便携式项目"); portable2.setName("便携式项目");
portable2.setPid(id); portable2.setPid("1");
portable2.setId(IdUtil.simpleUUID()); portable2.setId("2");
portable2.setChildren(portables); portable2.setChildren(portables);
portable1.setChildren(Collections.singletonList(portable2)); portable1.setChildren(Collections.singletonList(portable2));
@@ -719,7 +719,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<CsLedgerVO> portables = ledger.stream() List<CsLedgerVO> portables = ledger.stream()
.peek(c -> { .peek(c -> {
CsEquipmentDeliveryPO po = poMap2.get(c.getId()); CsEquipmentDeliveryPO po = poMap2.get(c.getId());
c.setPid(portable.getId()); c.setPid("2");
c.setComFlag(po.getRunStatus()); c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid()); c.setNDId(po.getNdid());
c.setType("device"); c.setType("device");
@@ -776,18 +776,17 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
tree.addAll(new ArrayList<>(engineeringMap.values())); tree.addAll(new ArrayList<>(engineeringMap.values()));
if (CollUtil.isNotEmpty(portables)) { if (CollUtil.isNotEmpty(portables)) {
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO(); CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0); portable1.setLevel(0);
portable1.setName("便携式工程"); portable1.setName("便携式工程");
portable1.setPid("0"); portable1.setPid("0");
portable1.setId(id); portable1.setId("1");
CsLedgerVO portable2 = new CsLedgerVO(); CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1); portable2.setLevel(1);
portable2.setName("便携式项目"); portable2.setName("便携式项目");
portable2.setPid(id); portable2.setPid("1");
portable2.setId(IdUtil.simpleUUID()); portable2.setId("2");
portable2.setChildren(portables); portable2.setChildren(portables);
List<CsLedgerVO> portable2List = new ArrayList<>(); List<CsLedgerVO> portable2List = new ArrayList<>();

View File

@@ -36,7 +36,7 @@ public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds); Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds);
Page<EventDetailVO> queryEventPageWeb(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("devIds") List<String> collect); Page<EventDetailVO> queryEventPageWeb(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("devIds") List<String> collect,@Param("lineIds") List<String> collect2);
Page<EventDetailVO> queryEventPageWebDvr(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("lineIds") List<String> collect); Page<EventDetailVO> queryEventPageWebDvr(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("lineIds") List<String> collect);

View File

@@ -267,6 +267,12 @@
<foreach collection="devIds" index="index" item="item" open="(" separator="," close=")"> <foreach collection="devIds" index="index" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
<if test="lineIds != null and lineIds.size() > 0">
AND b.line_id IN
<foreach collection="lineIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''">
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type == 3 "> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.type == 3 ">
AND b.type in (2,3) and b.level in (1,2,3,6,7) AND b.type in (2,3) and b.level in (1,2,3,6,7)

View File

@@ -415,11 +415,17 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
cldDevTree = cldDevTree.get(0).getChildren(); cldDevTree = cldDevTree.get(0).getChildren();
} }
if (ObjectUtil.isNull(csEventUserQueryPage.getDeviceId()) || StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())) { if (ObjectUtil.isNull(csEventUserQueryPage.getDeviceId()) || StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())) {
//便携式就1层下边就是设备 //便携式就1层下边就是设备 这边给便携式设备添加了假的工程和项目id是写死的
List<String> portableDevIds = portableDevTree.stream().filter( List<String> portableDevIds = new ArrayList<>();
temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) || if (Objects.equals(csEventUserQueryPage.getEngineeringid(),"1")
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId()) || Objects.equals(csEventUserQueryPage.getProjectId(),"2")
).map(CsLedgerVO::getId).collect(Collectors.toList()); || !ObjectUtil.isNull(csEventUserQueryPage.getLineId())
|| !StringUtils.isEmpty(csEventUserQueryPage.getLineId())) {
portableDevIds = portableDevTree.stream().map(CsLedgerVO::getId).filter(
id -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) ||
Objects.equals(id, csEventUserQueryPage.getDeviceId())
).collect(Collectors.toList());
}
List<String> governmentDevIds = governmentDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())|| List<String> governmentDevIds = governmentDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid())) Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter( .map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
@@ -454,6 +460,9 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
if (CollectionUtils.isEmpty(devIds)){ if (CollectionUtils.isEmpty(devIds)){
return returnpage; return returnpage;
} }
if (!ObjectUtil.isNull(csEventUserQueryPage.getLineId()) && !StringUtils.isEmpty(csEventUserQueryPage.getLineId())) {
lineIds.add(csEventUserQueryPage.getLineId());
}
} }
//获取tag //获取tag
if (Objects.equals(csEventUserQueryPage.getType(), "0")) { if (Objects.equals(csEventUserQueryPage.getType(), "0")) {
@@ -479,7 +488,7 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
if (!Objects.isNull(csEventUserQueryPage.getIsDvr()) && csEventUserQueryPage.getIsDvr() == 1) { if (!Objects.isNull(csEventUserQueryPage.getIsDvr()) && csEventUserQueryPage.getIsDvr() == 1) {
returnpage = this.getBaseMapper().queryEventPageWebDvr(returnpage,csEventUserQueryPage,lineIds); returnpage = this.getBaseMapper().queryEventPageWebDvr(returnpage,csEventUserQueryPage,lineIds);
} else { } else {
returnpage = this.getBaseMapper().queryEventPageWeb(returnpage,csEventUserQueryPage,devIds); returnpage = this.getBaseMapper().queryEventPageWeb(returnpage,csEventUserQueryPage,devIds,lineIds);
} }
returnpage.getRecords().forEach(temp->{ returnpage.getRecords().forEach(temp->{
CsLineDTO dto = map.get(temp.getLineId()); CsLineDTO dto = map.get(temp.getLineId());