32 Commits

Author SHA1 Message Date
xy
57cb6a2900 feat(communication): 添加装置数据查询功能并重构在线率统计逻辑 2026-05-08 10:29:24 +08:00
xy
3990ad2b9a fix(data): 修复事件统计查询和数据完整性处理问题
- 修正事件统计查询中allNum字段的计算逻辑,从COUNT(*)改为按特定标签求和
- 在事件详情VO中新增ITIC描述和F47描述字段
- 补充通信状态数据的第一条记录,确保从0点开始的数据连续性
- 修复数据完整性服务中线路间隔为null或0时的处理逻辑,设置默认值为1
2026-04-30 15:49:08 +08:00
xy
a054a20e8a fix(service): 解决监测位置字段空值处理问题
- 在CsLinePOServiceImpl中对position字段进行空字符串检查,避免保存空字符串值
- 在DeviceMessageServiceImpl中增加对position字段的空值和空字符串双重判断
- 防止因空字符串导致的数据处理异常和业务逻辑错误
2026-04-29 17:09:13 +08:00
xy
db2821347d fix(event): 修复事件详情波形路径更新逻辑
- 修正CsEventPOServiceImpl中wavePath更新时的对象引用错误
- 在EventDetailVO中新增startTime2字段用于显示不带毫秒的时间
- 优化DataTaskServiceImpl中的设备通信离线时段计算逻辑
- 完善DeviceMessageServiceImpl中设备消息映射的边界情况处理
2026-04-29 16:49:04 +08:00
caozehui
058229e8c4 升级功能调整 2026-04-29 08:52:07 +08:00
xy
13b9981c72 feat(device): 新增用户设备关系管理功能
- 在CsDeviceUserPOService中新增addRelation方法用于新增用户设备关系表数据
- 实现CsDeviceUserPOServiceImpl中的addRelation逻辑,支持新增主用户信息和已关联工程的用户设备关系
- 修改CsEquipmentDeliveryServiceImpl使用DSTransactional注解替代Transactional
- 更新CsEquipmentDeliveryServiceImpl中的saveCld方法,新增设备时同步创建用户设备关系
- 优化CsLedgerServiceImpl中便携式工程显示逻辑,增加空值检查
- 调整RoleEngineerDevServiceImpl中不同角色的设备权限查询逻辑
- 修改CsLinePOMapper.xml中的JOIN方式从LEFT JOIN改为RIGHT JOIN
2026-04-27 13:34:56 +08:00
xy
e364ca1cae fix(mapper): 修复设备事件查询中的线路关联条件
- 在 cs_line 表关联中添加 clDid 匹配条件
2026-04-24 11:28:12 +08:00
xy
8b183d84e9 feat(delivery): 添加监测点限值删除功能
- 在删除监测点表和拓扑图关系的同时删除对应的监测点限值数据
- 在三个不同的删除操作位置都添加了监测点限值的批量删除逻辑
- 确保设备数据缓存刷新时完整清理相关关联数据
2026-04-24 09:43:00 +08:00
caozehui
895755b7e1 微调 2026-04-23 09:09:26 +08:00
caozehui
87b91382a8 设备程序版本分页程序 2026-04-23 08:47:19 +08:00
caozehui
3df7d91e4c Merge remote-tracking branch 'origin/master' 2026-04-23 08:47:01 +08:00
xy
6bb9d932b8 feat(notification): 添加异步通知服务并重构事件处理逻辑
- 新增 AppNotificationService 处理应用内事件通知
- 新增 SmsNotificationService 处理短信通知功能
- 配置 AsyncConfig 异步执行器支持事件通知处理
- 重构 CsEventPOServiceImpl 事件处理逻辑,分离通知功能
- 添加 @EnableAsync 注解启用异步处理
- 优化 CsDeviceUserPOServiceImpl 用户查询返回空对象
- 修复 WlUserServiceImpl 中的空指针检查逻辑
2026-04-22 16:03:59 +08:00
caozehui
ae220ceeea Merge remote-tracking branch 'origin/master'
# Conflicts:
#	cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEdDataPO.java
#	cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java
2026-04-22 08:52:53 +08:00
xy
8841000989 refactor(service): 优化设备交付服务中的日志处理逻辑
- 移除未使用的 ICsTerminalLogsService 依赖注入
- 删除前置推送日志的清理代码,简化设备删除流程
- 在创建操作日志时添加UUID标识符
- 在终端日志服务中增加Redis缓存清理逻辑
- 为设备列表处理添加空值检查,避免空指针异常
- 重构设备分组和消息发送逻辑,提高代码可读性
2026-04-21 20:33:55 +08:00
xy
8559d7548a refactor(device): 优化设备交付服务和终端回复服务
- 移除未使用的 EngineeringFeignClient 和 IMqttUserService 依赖
- 添加 CsTerminalLogsService 用于管理前置推送日志
- 在删除设备时同步清理相关的前置推送日志记录
- 简化终端回复查询逻辑,移除不必要的分组判断
- 注释掉废弃的 queryReplyData 方法以提高代码整洁性
- 统一设备操作结果的消息返回格式
2026-04-21 19:47:29 +08:00
xy
d8b292d447 mqtt依赖包引入 2026-04-21 19:21:35 +08:00
xy
fed766bca4 短信服务集成 2026-04-21 16:10:01 +08:00
caozehui
00ccff18c0 设备程序版本分页程序 2026-04-20 14:19:55 +08:00
xy
353a4cc83b refactor(event): 重构事件统计功能并迁移消息推送服务
- 移除暂态事件统计相关接口和实现方法
- 删除EventStatisticsVo相关代码
- 将设备消息推送功能从CsEventPOServiceImpl迁移到新创建的DeviceMessageService
- 新增DeviceMessageFeignClient用于服务间调用
- 实现DeviceMessageController提供统一的消息推送接口
2026-04-17 16:19:10 +08:00
xy
9caaf9bea2 feat(alarm): 添加告警统计功能并优化设备管理
- 在AlarmVO中新增interruptCounts和warnCounts字段用于统计通信中断和终端告警次数
- 在CsAlarmServiceImpl中实现告警次数统计逻辑,解析告警事件数据并计算各类告警数量
- 重构CsEventUserPOServiceImpl中的查询逻辑,优化暂态事件详细信息查询接口
- 在CsEquipmentDeliveryServiceImpl中集成事件查询功能,实时获取设备告警状态
- 优化数据库查询语句,改进事件查询的排序和过滤逻辑
2026-04-16 16:14:10 +08:00
xy
e77108ebf5 feat(service): 实现分页功能并优化设备权限管理
- 在控制器层添加分页支持,将返回类型从 List 修改为 Page
- 实现服务层分页逻辑,集成 MyBatis Plus 分页插件
- 重构设备权限管理逻辑,区分超级管理员、普通用户和游客权限
- 添加营销用户和工程用户的特殊权限处理机制
- 迁移事件查询逻辑到统一的事件用户服务中
- 移除过时的设备用户映射器接口和 XML 查询方法
- 为暂降事件报告添加动态文件名生成功能
- 修复时间范围计算中的日期边界问题
- 优化台账树结构以支持多层级权限过滤
- 统计未读事件数量的查询逻辑优化
2026-04-14 19:09:23 +08:00
xy
460a10f3b5 微调 2026-04-08 15:14:41 +08:00
xy
f242e45c2f App事件一键已读功能调整 2026-04-08 14:31:39 +08:00
xy
45fd613e47 代码优化 2026-04-08 10:19:06 +08:00
xy
445f27143b 微调 2026-04-07 15:42:30 +08:00
xy
622d977d62 微调 2026-04-07 14:19:30 +08:00
xy
e7ba886b94 App消息推送调整 2026-04-07 09:15:25 +08:00
xy
c0cccc3479 微调 2026-04-02 09:33:33 +08:00
xy
dbe09d70f4 1、app消息数据查询重构
2、app消息已读未读方法重构
3、其余辅助功能添加
2026-04-01 20:28:04 +08:00
xy
33da822317 台账添加设备类型区分 2026-03-26 09:33:48 +08:00
xy
720afd42df app功能合并 2026-03-25 13:33:47 +08:00
xy
fc7694a1db 实体修改 2026-03-18 18:45:25 +08:00
251 changed files with 11383 additions and 2527 deletions

View File

@@ -59,6 +59,11 @@
<version>4.4.0</version> <version>4.4.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@@ -3,9 +3,12 @@ package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.AppProjectClientFallbackFactory; import com.njcn.csdevice.api.fallback.AppProjectClientFallbackFactory;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.po.AppProjectPO; import com.njcn.csdevice.pojo.po.AppProjectPO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
@@ -19,4 +22,11 @@ public interface AppProjectFeignClient {
@PostMapping("/queryProjectById") @PostMapping("/queryProjectById")
HttpResult<List<AppProjectPO>> queryProjectById(@RequestParam("ids") List<String> ids); HttpResult<List<AppProjectPO>> queryProjectById(@RequestParam("ids") List<String> ids);
@PostMapping("/getProjectByName")
HttpResult<AppProjectPO> getProjectByName(@RequestParam("name") String name);
@PostMapping("/addPortableProject")
HttpResult<AppProjectPO> addPortableProject(@Validated @RequestBody AppProjectAddParm appProjectAddParm);
} }

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory; import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory;
import com.njcn.csdevice.pojo.param.UserDevParam; import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO; import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -29,4 +30,13 @@ public interface CsDeviceUserFeignClient {
@PostMapping("/channelDevByUserId") @PostMapping("/channelDevByUserId")
HttpResult<List<String>> channelDevByUserId(@RequestBody UserDevParam param); HttpResult<List<String>> channelDevByUserId(@RequestBody UserDevParam param);
@PostMapping("/queryUserById")
HttpResult<DevUserVO> queryUserById(@RequestParam("devId") String devId);
@PostMapping("/getList")
HttpResult<List<CsDeviceUserPO>> getList(@RequestBody UserDevParam param);
@PostMapping("/getIdList")
HttpResult<List<String>> getIdList(@RequestParam("param") String param);
} }

View File

@@ -6,6 +6,8 @@ import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.po.CsEdDataPO; import com.njcn.csdevice.pojo.po.CsEdDataPO;
import com.njcn.csdevice.pojo.vo.CsEdDataVO; import com.njcn.csdevice.pojo.vo.CsEdDataVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -22,4 +24,7 @@ public interface CsEdDataFeignClient {
@PostMapping("/getAll") @PostMapping("/getAll")
HttpResult<List<CsEdDataPO>> getAll(@RequestParam("devType") String devType); HttpResult<List<CsEdDataPO>> getAll(@RequestParam("devType") String devType);
@GetMapping("/getById")
HttpResult<CsEdDataPO> getById(@RequestParam("id") String id);
} }

View File

@@ -35,6 +35,10 @@ public interface CsLedgerFeignClient {
@PostMapping("/queryDevDetail") @PostMapping("/queryDevDetail")
HttpResult<DevDetailDTO> queryDevDetail(@RequestParam("devId") String devId); HttpResult<DevDetailDTO> queryDevDetail(@RequestParam("devId") String devId);
@PostMapping("/lineTree")
@ApiOperation("五层设备树(监测点层,根节点为治理设备和便携式设备)")
HttpResult<List<CsLedgerVO>> lineTree();
@PostMapping("/deviceTree") @PostMapping("/deviceTree")
@ApiOperation("三层设备树(装置层)") @ApiOperation("三层设备树(装置层)")
HttpResult<List<CsLedgerVO>> getDeviceTree(); HttpResult<List<CsLedgerVO>> getDeviceTree();

View File

@@ -1,8 +1,13 @@
package com.njcn.csdevice.api; package com.njcn.csdevice.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory; import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -64,6 +69,9 @@ public interface CsLineFeignClient {
@PostMapping("/getAllLine") @PostMapping("/getAllLine")
HttpResult<List<String>> getAllLine(); HttpResult<List<String>> getAllLine();
@PostMapping("/getAllLineDetail")
HttpResult<List<CsLineDTO>> getAllLineDetail();
@PostMapping("/getOverLimitDataByIds") @PostMapping("/getOverLimitDataByIds")
HttpResult<List<Overlimit>> getOverLimitData(@RequestBody List<String> ids); HttpResult<List<Overlimit>> getOverLimitData(@RequestBody List<String> ids);

View File

@@ -0,0 +1,25 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsMarketDataClientFallbackFactory;
import com.njcn.csdevice.pojo.vo.CsMarketDataVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csMarketData", fallbackFactory = CsMarketDataClientFallbackFactory.class,contextId = "csMarketData")
public interface CsMarketDataFeignClient {
@PostMapping("/insert")
HttpResult<Boolean> insertData(@RequestParam("userId")String userId, @RequestParam("engineeringId")String engineeringId);
@PostMapping("/queryByUseId")
HttpResult<List<CsMarketDataVO>> queryByUseId(@RequestParam("userId")String userId);
}

View File

@@ -0,0 +1,22 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsUpgradeLogsClientFallbackFactory;
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author caozehui
* @data 2026-04-23
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csUpgradeLogs", fallbackFactory = CsUpgradeLogsClientFallbackFactory.class,contextId = "csSoftInfo")
public interface CsUpgradeLogsFeignClient {
@PostMapping("/add")
HttpResult add(@RequestBody CsUpgradeLogs csUpgradeLogs);
}

View File

@@ -0,0 +1,22 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.ProcessFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.po.CsUserPins;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csUserPins", fallbackFactory = ProcessFeignClientFallbackFactory.class,contextId = "csUserPins")
public interface CsUserPinsFeignClient {
@PostMapping("/getPinToTopList")
HttpResult<List<CsUserPins>> getPinToTopList();
}

View File

@@ -0,0 +1,34 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.DeviceMessageClientFallbackFactory;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.user.pojo.po.User;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/deviceMessage", fallbackFactory = DeviceMessageClientFallbackFactory.class,contextId = "deviceMessage")
public interface DeviceMessageFeignClient {
@PostMapping("/getEventUserByDeviceId")
@ApiOperation("根据设备获取需要推送的用户id")
HttpResult<List<String>> getEventUserByDeviceId(@RequestParam("devId") String devId, @RequestParam("isAdmin") Boolean isAdmin);
@PostMapping("/getSendUserByType")
@ApiOperation("根据事件类型和用户id查询打开推送的用户信息")
HttpResult<List<User>> getSendUserByType(@RequestBody DeviceMessageParam param);
@PostMapping("/getLineInfo")
@ApiOperation("获取监测点信息")
HttpResult<String> getLineInfo(@RequestParam("id") String id);
}

View File

@@ -0,0 +1,38 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.fallback.AppProjectClientFallbackFactory;
import com.njcn.csdevice.pojo.param.CsEngineeringAddParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/engineering", fallbackFactory = AppProjectClientFallbackFactory.class,contextId = "engineering")
public interface EngineeringFeignClient {
@PostMapping("/queryEngineering")
HttpResult<List<CsEngineeringVO>> queryEngineering(@Validated @RequestBody CsEngineeringQueryParm csEngineeringQueryParm);
@PostMapping("/getEngineeringByName")
HttpResult<CsEngineeringPO> getEngineeringByName(@RequestParam("name") String name);
@PostMapping("/addEngineering")
HttpResult<CsEngineeringPO> addEngineering(@Validated @RequestBody CsEngineeringAddParm csEngineeringAddParm);
}

View File

@@ -0,0 +1,23 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.SmsSendClientFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/sms", fallbackFactory = SmsSendClientFallbackFactory.class,contextId = "sms")
public interface SmsSendFeignClient {
@PostMapping("/send/simple")
@ApiOperation("发送短信(简化参数)")
HttpResult<String> sendSmsSimple(@RequestParam("receiver") String receiver
, @RequestParam("content") String content
, @RequestParam("messageType") String messageType);
}

View File

@@ -4,6 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.AppProjectFeignClient; import com.njcn.csdevice.api.AppProjectFeignClient;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.po.AppProjectPO; import com.njcn.csdevice.pojo.po.AppProjectPO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -32,6 +33,18 @@ public class AppProjectClientFallbackFactory implements FallbackFactory<AppProje
log.error("{}异常,降级处理,异常为:{}","获取项目详情接口异常",cause.toString()); log.error("{}异常,降级处理,异常为:{}","获取项目详情接口异常",cause.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<AppProjectPO> getProjectByName(String name) {
log.error("{}异常,降级处理,异常为:{}","根据项目名称获取项目信息异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<AppProjectPO> addPortableProject(AppProjectAddParm appProjectAddParm) {
log.error("{}异常,降级处理,异常为:{}","新增便携式项目",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -6,6 +6,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsDeviceUserFeignClient; import com.njcn.csdevice.api.CsDeviceUserFeignClient;
import com.njcn.csdevice.pojo.param.UserDevParam; import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO; import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -51,6 +52,24 @@ public class CsDeviceUserClientFallbackFactory implements FallbackFactory<CsDevi
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<DevUserVO> queryUserById(String devId) {
log.error("{}异常,降级处理,异常为:{}","获取设备主/子用户数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsDeviceUserPO>> getList(UserDevParam param) {
log.error("{}异常,降级处理,异常为:{}","根据设备集合获取数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> getIdList(String param) {
log.error("{}异常,降级处理,异常为:{}","获取事件id集合数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -39,6 +39,12 @@ public class CsEdDataFeignClientFallbackFactory implements FallbackFactory<CsEdD
log.error("{}异常,降级处理,异常为:{}","根据装置型号获取装置类型",cause.toString()); log.error("{}异常,降级处理,异常为:{}","根据装置型号获取装置类型",cause.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<CsEdDataPO> getById(String id) {
log.error("{}异常,降级处理,异常为:{}","根据id获取装置类型",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -57,6 +57,12 @@ public class CsLedgerFeignClientFallbackFactory implements FallbackFactory<CsLed
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<CsLedgerVO>> lineTree() {
log.error("{}异常,降级处理,异常为:{}","查询监测点数数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override @Override
public HttpResult<List<CsLedgerVO>> getDeviceTree() { public HttpResult<List<CsLedgerVO>> getDeviceTree() {
log.error("{}异常,降级处理,异常为:{}","查询设备树",cause.toString()); log.error("{}异常,降级处理,异常为:{}","查询设备树",cause.toString());

View File

@@ -4,6 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -103,6 +104,12 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<CsLineDTO>> getAllLineDetail() {
log.error("{}异常,降级处理,异常为:{}","获取系统中所有监测点id详情异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override @Override
public HttpResult<List<Overlimit>> getOverLimitData(List<String> ids) { public HttpResult<List<Overlimit>> getOverLimitData(List<String> ids) {
log.error("{}异常,降级处理,异常为:{}","根据监测点id集合获取国标限值异常",cause.toString()); log.error("{}异常,降级处理,异常为:{}","根据监测点id集合获取国标限值异常",cause.toString());

View File

@@ -0,0 +1,44 @@
package com.njcn.csdevice.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsMarketDataFeignClient;
import com.njcn.csdevice.pojo.vo.CsMarketDataVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class CsMarketDataClientFallbackFactory implements FallbackFactory<CsMarketDataFeignClient> {
@Override
public CsMarketDataFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsMarketDataFeignClient() {
@Override
public HttpResult<Boolean> insertData(String userId, String engineeringId) {
log.error("{}异常,降级处理,异常为:{}","根据用户、工程新增数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsMarketDataVO>> queryByUseId(String userId) {
log.error("{}异常,降级处理,异常为:{}","查询营销,工程数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,36 @@
package com.njcn.csdevice.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsUpgradeLogsFeignClient;
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author caozehui
* @data 2026-04-23
*/
@Slf4j
@Component
public class CsUpgradeLogsClientFallbackFactory implements FallbackFactory<CsUpgradeLogsFeignClient> {
@Override
public CsUpgradeLogsFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsUpgradeLogsFeignClient() {
@Override
public HttpResult add(CsUpgradeLogs csUpgradeLogs) {
log.error("{}异常,降级处理,异常为:{}", "新增升级日志异常", cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,43 @@
package com.njcn.csdevice.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsUserPinsFeignClient;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/4/10 20:09
*/
@Slf4j
@Component
public class CsUserPinsFeignClientFallbackFactory implements FallbackFactory<CsUserPinsFeignClient> {
@Override
public CsUserPinsFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsUserPinsFeignClient() {
@Override
public HttpResult<List<CsUserPins>> getPinToTopList() {
log.error("{}异常,降级处理,异常为:{}","获取用户置顶设备(工程)数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,50 @@
package com.njcn.csdevice.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.DeviceMessageFeignClient;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.user.pojo.po.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class DeviceMessageClientFallbackFactory implements FallbackFactory<DeviceMessageFeignClient> {
@Override
public DeviceMessageFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new DeviceMessageFeignClient() {
@Override
public HttpResult<List<String>> getEventUserByDeviceId(String devId, Boolean isAdmin) {
log.error("{}异常,降级处理,异常为:{}","根据设备获取需要推送的用户id数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<User>> getSendUserByType(DeviceMessageParam param) {
log.error("{}异常,降级处理,异常为:{}","根据事件类型和用户id查询打开推送的用户信息数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> getLineInfo(String id) {
log.error("{}异常,降级处理,异常为:{}","获取监测点信息数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,52 @@
package com.njcn.csdevice.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.EngineeringFeignClient;
import com.njcn.csdevice.pojo.param.CsEngineeringAddParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class EngineeringClientFallbackFactory implements FallbackFactory<EngineeringFeignClient> {
@Override
public EngineeringFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new EngineeringFeignClient() {
@Override
public HttpResult<List<CsEngineeringVO>> queryEngineering(CsEngineeringQueryParm csEngineeringQueryParm) {
log.error("{}异常,降级处理,异常为:{}","查询工程列表接口异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsEngineeringPO> getEngineeringByName(String name) {
log.error("{}异常,降级处理,异常为:{}","根据工程名称获取工程信息异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsEngineeringPO> addEngineering(CsEngineeringAddParm csEngineeringAddParm) {
log.error("{}异常,降级处理,异常为:{}","新增工程异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,34 @@
package com.njcn.csdevice.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.SmsSendFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class SmsSendClientFallbackFactory implements FallbackFactory<SmsSendFeignClient> {
@Override
public SmsSendFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new SmsSendFeignClient() {
@Override
public HttpResult<String> sendSmsSimple(String receiver, String content, String messageType) {
log.error("{}异常,降级处理,异常为:{}","发送短信(简化参数)数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,28 @@
package com.njcn.csdevice.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class CsUserPinsParam implements Serializable {
@ApiModelProperty("用户id")
@NotBlank(message = "用户id")
private String userId;
@ApiModelProperty("目标类型1-设备2-工程")
@NotNull(message = "目标类型1-设备2-工程")
private Integer targetType;
@ApiModelProperty("目标ID设备ID或工程ID")
@NotBlank(message = "目标ID设备ID或工程ID不能为空")
private String targetId;
}

View File

@@ -0,0 +1,20 @@
package com.njcn.csdevice.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author xy
*/
@Data
public class DeviceMessageParam {
@ApiModelProperty("用户id集合")
private List<String> userList;
@ApiModelProperty("事件类型 0:暂态 1:稳态 2:运行 3:告警")
private Integer eventType;
}

View File

@@ -0,0 +1,35 @@
package com.njcn.csdevice.pojo.dto;
/**
* @author caozehui
* @data 2026-03-31
*/
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
* 系统凭证请求 DTO
*
* @author msgpush
*/
@Data
public class CredentialReqDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 上游系统名称
*/
@NotEmpty(message = "上游系统名称不能为空")
private String systemName;
/**
* 密钥(用于生成凭证)
*/
@NotEmpty(message = "密钥不能为空")
private String secretKey;
}

View File

@@ -100,4 +100,24 @@ public class CsEquipmentDeliveryDTO {
private Integer moduleNumber; private Integer moduleNumber;
private Integer process; private Integer process;
/**
* 前置服务器IP
*/
private String nodeId;
/**
* 前置进程号
*/
private Integer nodeProcess;
/**
* 日志等级(NORMAL、DEBUG、WARN、ERROR)
*/
private String devLogLevel;
/**
* 设备软件信息id
*/
private String softinfoId;
} }

View File

@@ -0,0 +1,148 @@
package com.njcn.csdevice.pojo.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@NoArgsConstructor
public class CsLineDTO implements Serializable {
/**
* 监测点id
*/
private String lineId;
/**
* 装置id
*/
private String deviceId;
/**
* 装置id
*/
private String deviceType;
/**
* 监测点名称
*/
private String name;
/**
* 字典表:安装位置(负载侧,电网侧, 输出侧)
*/
private String position;
/**
* 数据集id
*/
private String dataSetId;
/**
* 模板id
*/
private String dataModelId;
/**
* 电压等级
*/
private Double volGrade;
/**
* PT变比
*/
private Double ptRatio;
/**
* PT2次变比
*/
private Double pt2Ratio;
/**
* CT变比
*/
private Double ctRatio;
/**
* CT2变比
*/
private Double ct2Ratio;
/**
* 状态(0删除 1正常)
*/
private Integer status;
/**
* 接线方式(0-星型 1-角型 2-V型)
*/
private Integer conType;
/**
* 逻辑子设备id(与模板对应)
*/
private Integer clDid;
/**
* 监测点统计间隔
*/
private Integer lineInterval;
/**
* 运行状态
*/
private Integer runStatus;
/**
* 监测点线路号
*/
private Integer lineNo;
/**
* 监测对象类型
*/
private String monitorObj;
/**
* 是否治理(0:未治理 1:已治理)
*/
private Integer govern;
private String monitorUser;
/**
* 短路容量
*/
private Double shortCircuitCapacity;
/**
* 设备容量
*/
private Double devCapacity;
/**
* 基准容量
*/
private Double basicCapacity;
/**
* 协议容量
*/
private Double protocolCapacity;
/**
* 治理报告文件路径
*/
private String reportFilePath;
/**
* 日志等级(NORMAL、DEBUG、WARN、ERROR)
*/
private String lineLogLevel;
/**
* 是否是主要监测点(0: 不是 1:是)
*/
private Integer isImportant;
}

View File

@@ -3,6 +3,8 @@ package com.njcn.csdevice.pojo.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* Description: * Description:
* Date: 2023/9/6 13:59【需求编号】 * Date: 2023/9/6 13:59【需求编号】
@@ -31,4 +33,13 @@ public class DevDetailDTO {
@ApiModelProperty(value = "设备名称") @ApiModelProperty(value = "设备名称")
private String equipmentName; private String equipmentName;
@ApiModelProperty(value = "设备通讯状态")
private Integer runStatus;
@ApiModelProperty(value = "设备MAC地址")
private String devMac;
@ApiModelProperty(value = "监测点id集合")
private List<String> lineList;
} }

View File

@@ -1,8 +1,12 @@
package com.njcn.csdevice.pojo.dto; package com.njcn.csdevice.pojo.dto;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List;
/** /**
* Description: * Description:
* Date: 2023/8/1 15:25【需求编号】 * Date: 2023/8/1 15:25【需求编号】
@@ -11,7 +15,7 @@ import lombok.Data;
* @version V1.0.0 * @version V1.0.0
*/ */
@Data @Data
public class LineParamDTO { public class LineParamDTO extends BaseParam implements Serializable {
@ApiModelProperty(value = "工程id") @ApiModelProperty(value = "工程id")
private String engineerId; private String engineerId;
@@ -26,4 +30,29 @@ public class LineParamDTO {
@ApiModelProperty(value = "监测点id") @ApiModelProperty(value = "监测点id")
private String lineId; private String lineId;
@ApiModelProperty(value = "时间类型 0:日报 1:月报")
private Integer timeType;
@ApiModelProperty(value = "时间")
private String time;
@ApiModelProperty(value = "起始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "集合")
private List<String> list;
@Data
public static class DevParamDTO {
@ApiModelProperty(value = "时间")
private String time;
@ApiModelProperty(value = "设备id集合")
private List<String> devList;
}
} }

View File

@@ -0,0 +1,21 @@
package com.njcn.csdevice.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
@AllArgsConstructor
public class SendResult implements Serializable {
private final boolean success;
private final String messageId;
private final String failReason;
private final boolean isTimeOut;
private final boolean unauthorized;
}

View File

@@ -67,7 +67,7 @@ public class CsEdDataAuditParm {
private String versionType; private String versionType;
@ApiModelProperty(value = "crc信息") @ApiModelProperty(value = "crc信息")
private String crcInfo; private String crc;
@ApiModelProperty(value="0删除 1正常") @ApiModelProperty(value="0删除 1正常")
private String status; private String status;
@ApiModelProperty(value = ".bin文件") @ApiModelProperty(value = ".bin文件")

View File

@@ -100,4 +100,15 @@ public class CsEquipmentDeliveryAddParm implements Serializable {
@ApiModelProperty(value="日志等级(NORMAL、DEBUG、WARN、ERROR)") @ApiModelProperty(value="日志等级(NORMAL、DEBUG、WARN、ERROR)")
private String devLogLevel; private String devLogLevel;
@ApiModelProperty(value="所属工程")
private String associatedEngineering;
@ApiModelProperty(value="所属项目")
private String associatedProject;
@ApiModelProperty(value="icd")
private String icd;
@ApiModelProperty(value="是否支持升级(0:否 1:是)")
private Integer upgrade;
} }

View File

@@ -104,4 +104,16 @@ public class CsEquipmentDeliveryAuditParm {
@ApiModelProperty(value="日志等级(NORMAL、DEBUG、WARN、ERROR)") @ApiModelProperty(value="日志等级(NORMAL、DEBUG、WARN、ERROR)")
private String devLogLevel; private String devLogLevel;
@ApiModelProperty(value="所属工程")
private String associatedEngineering;
@ApiModelProperty(value="所属项目")
private String associatedProject;
@ApiModelProperty(value="icd")
private String icd;
@ApiModelProperty(value="是否支持升级(0:否 1:是)")
private Integer upgrade;
} }

View File

@@ -2,6 +2,7 @@ package com.njcn.csdevice.pojo.param;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -40,4 +41,9 @@ public class CsEquipmentDeliveryQueryParm extends BaseParam {
@ApiModelProperty("物联通讯状态 0:未连接 1:已连接") @ApiModelProperty("物联通讯状态 0:未连接 1:已连接")
private Integer connectStatus; private Integer connectStatus;
@ApiModelProperty("ICD")
private String icd;
@ApiModelProperty("是否支持升级(0:否 1:是)")
private Integer upgrade;
} }

View File

@@ -0,0 +1,15 @@
package com.njcn.csdevice.pojo.param;
import com.njcn.web.pojo.param.BaseParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author caozehui
* @data 2026-04-07
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class DevVersionParam extends BaseParam {
private String keyword;
}

View File

@@ -28,26 +28,18 @@ public class AppProjectPO extends BaseEntity {
@TableId(value = "id", type = IdType.ASSIGN_UUID) @TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id; private String id;
/** /**
* 项目名称 * 项目名称
*/ */
@TableField(value = "name") @TableField(value = "name")
private String name; private String name;
// @TableField(value = "engineering_id")
// private String engineeringId;
/** /**
* 地市Id * 地市Id
*/ */
@TableField(value = "area") @TableField(value = "area")
private String area; private String area;
/** /**
* 0删除 1正常 * 0删除 1正常
*/ */

View File

@@ -7,10 +7,9 @@ import com.njcn.db.bo.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date; import java.time.LocalDateTime;
/** /**
*
* Description: * Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html * 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/7 11:29【需求编号】 * Date: 2023/4/7 11:29【需求编号】
@@ -62,7 +61,7 @@ public class CsEdDataPO extends BaseEntity {
* 版本日期 * 版本日期
*/ */
@TableField(value = "version_date") @TableField(value = "version_date")
private Date versionDate; private LocalDateTime versionDate;
/** /**
* 描述 * 描述
@@ -88,6 +87,11 @@ public class CsEdDataPO extends BaseEntity {
@TableField(value = "file_path") @TableField(value = "file_path")
private String filePath; private String filePath;
/**
* crc文件校验码
*/
@TableField(value = "crc")
private String crc;
} }

View File

@@ -136,4 +136,26 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
@TableField(value = "dev_log_level") @TableField(value = "dev_log_level")
private String devLogLevel; private String devLogLevel;
/**
* 所属工程
*/
@TableField(value = "associated_engineering")
private String associatedEngineering;
/**
* 所属项目
*/
@TableField(value = "associated_project")
private String associatedProject;
/**
* icd模型
*/
@TableField(value = "icd")
private String icd;
/**
* 是否支持升级(0:否 1:是)
*/
private Integer upgrade;
} }

View File

@@ -0,0 +1,45 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author xy
*/
@Data
@TableName("cs_sms_send_record")
public class CsSmsSendRecord implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
private String receiver;
private String content;
private String messageType;
private String credentialToken;
private Integer sendStatus;
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String failReason;
private Integer retryCount;
private Integer maxRetry;
private Long responseTime;
private LocalDateTime sendTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,75 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author caozehui
* @data 2026-04-23
* @description 设备升级日志
*/
@Data
@TableName(value = "cs_upgrade_logs")
public class CsUpgradeLogs {
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
/**
* 设备id
*/
@TableField(value = "dev_id")
private String devId;
/**
* 版本号
*/
@TableField(value = "version_no")
private String versionNo;
/**
* 升级结果(0:失败 1:成功)
*/
private Integer result;
/**
* 用户名称
*/
@TableField(value = "user_name")
private String userName;
/**
* 登录名称
*/
@TableField(value = "login_name")
private String loginName;
/**
* 创建用户
*/
@TableField(fill = FieldFill.INSERT, insertStrategy = FieldStrategy.IGNORED)
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT, insertStrategy = FieldStrategy.IGNORED)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 更新用户
*/
@TableField(fill = FieldFill.INSERT_UPDATE, insertStrategy = FieldStrategy.IGNORED)
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE, insertStrategy = FieldStrategy.IGNORED)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,44 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* <p>
* 用户置顶表
* </p>
*
* @author xy
* @since 2026-03-04
*/
@Getter
@Setter
@TableName("cs_user_pins")
public class CsUserPins extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private String id;
/**
* 用户ID
*/
private String userId;
/**
* 目标类型1-设备2-工程
*/
private Integer targetType;
/**
* 目标ID设备ID或工程ID
*/
private String targetId;
}

View File

@@ -31,7 +31,7 @@ public class CldLedgerVo implements Serializable {
private String engineeringDescription; private String engineeringDescription;
@ApiModelProperty(value = "项目信息") @ApiModelProperty(value = "项目信息")
private List<AppProjectPO> projectInfoList; private List<ProjectVO> projectInfoList;
@ApiModelProperty(value = "设备信息") @ApiModelProperty(value = "设备信息")
private List<CsEquipmentDeliveryPO> deviceInfoList; private List<CsEquipmentDeliveryPO> deviceInfoList;
@@ -39,4 +39,7 @@ public class CldLedgerVo implements Serializable {
@ApiModelProperty(value = "监测点信息") @ApiModelProperty(value = "监测点信息")
private List<CsLinePO> lineInfoList; private List<CsLinePO> lineInfoList;
@ApiModelProperty("工程排序")
private Integer sort;
} }

View File

@@ -70,12 +70,11 @@ public class CsEdDataVO extends BaseEntity {
@ApiModelProperty(value = "版本类型") @ApiModelProperty(value = "版本类型")
private String versionType; private String versionType;
@ApiModelProperty(value = "crc信息")
private String crcInfo;
@ApiModelProperty(value = ".bin文件") @ApiModelProperty(value = ".bin文件")
private String filePath; private String filePath;
@ApiModelProperty(value = "CRC校验")
private String crc;
} }

View File

@@ -67,5 +67,6 @@ public class CsEngineeringVO extends BaseEntity {
@ApiModelProperty(value = "状态") @ApiModelProperty(value = "状态")
private String status; private String status;
@ApiModelProperty(value = "排序")
private Integer sort;
} }

View File

@@ -94,4 +94,16 @@ public class CsEquipmentDeliveryVO extends BaseEntity {
@ApiModelProperty(value="前置服务器id") @ApiModelProperty(value="前置服务器id")
private String nodeId ; private String nodeId ;
@ApiModelProperty(value="所属工程id")
private String associatedEngineering;
@ApiModelProperty(value="所属工程名称")
private String associatedEngineeringName;
@ApiModelProperty(value="所属项目id")
private String associatedProject;
@ApiModelProperty(value="所属项目名称")
private String associatedProjectName;
} }

View File

@@ -69,6 +69,12 @@ public class CsLedgerVO implements Serializable {
@ApiModelProperty(name = "process",value = "流程状态") @ApiModelProperty(name = "process",value = "流程状态")
private Integer process; private Integer process;
@ApiModelProperty(name = "isTop",value = "是否置顶,默认不置顶")
private Integer isTop = 0;
@ApiModelProperty(name = "devConType",value = "设备连接方式 MQTT || CLD")
private String devConType;
@ApiModelProperty(name = "children",value = "子节点") @ApiModelProperty(name = "children",value = "子节点")
private List<CsLedgerVO> children = new ArrayList<>(); private List<CsLedgerVO> children = new ArrayList<>();

View File

@@ -4,6 +4,7 @@ import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@@ -15,54 +16,59 @@ import java.util.List;
*/ */
@Data @Data
public class DevCountVO { public class DevCountVO implements Serializable {
//
@ApiModelProperty(value = "设备在线总数") /** 所有工程相关数据 **/
private Integer onLineDevCount; @ApiModelProperty(value = "所有工程设备在线总数")
private Integer onLineDevCount = 0;
private List<CsEquipmentDeliveryPO> onLineDevs; private List<CsEquipmentDeliveryPO> onLineDevs;
@ApiModelProperty(value = "设备离线总数") @ApiModelProperty(value = "所有工程设备离线总数")
private Integer offLineDevCount; private Integer offLineDevCount = 0;
private List<CsEquipmentDeliveryPO> offLineDevs; private List<CsEquipmentDeliveryPO> offLineDevs;
@ApiModelProperty(value = "警告数")
private Integer alarmCount; @ApiModelProperty(value = "所有工程暂态事件数量(未读)")
@ApiModelProperty(value = "事件数") private Integer eventCount = 0;
private Integer eventCount;
@ApiModelProperty(value = "所有工程稳态事件数量(未读)")
private Integer harmonicCount = 0;
@ApiModelProperty(value = "所有工程运行告警数量(未读)")
private Integer alarmCount = 0;
@ApiModelProperty(value = "所有工程运行事件数量(未读)")
private Integer runCount = 0;
@ApiModelProperty(value = "工程个数") @ApiModelProperty(value = "工程个数")
private Integer eningerCount; private Integer eningerCount = 0;
@ApiModelProperty(value = "运行事件数")
private Integer runCount;
@ApiModelProperty(value = "稳态件数")
private Integer harmonicCount;
/** 当前工程相关数据 **/
@ApiModelProperty(value = "当前工程id") @ApiModelProperty(value = "当前工程id")
private String currentId; private String currentId;
@ApiModelProperty(value = "当前工程设备在线总数") @ApiModelProperty(value = "当前工程设备在线总数")
private Integer currentOnLineDevCount; private Integer currentOnLineDevCount = 0;
private List<CsEquipmentDeliveryPO> currentOnLineDevs; private List<CsEquipmentDeliveryPO> currentOnLineDevs;
@ApiModelProperty(value = "当前工程设备离线总数") @ApiModelProperty(value = "当前工程设备离线总数")
private Integer currentOffLineDevCount; private Integer currentOffLineDevCount = 0;
private List<CsEquipmentDeliveryPO> currentOffLineDevs; private List<CsEquipmentDeliveryPO> currentOffLineDevs;
@ApiModelProperty(value = "设备警告数") @ApiModelProperty(value = "当前工程暂态事件数量(未读)")
private Integer currentAlarmCount; private Integer currentEventCount = 0;
@ApiModelProperty(value = "暂态事件数")
private Integer currentEventCount; @ApiModelProperty(value = "当前工程稳态事件数量(未读)")
@ApiModelProperty(value = "运行事件数") private Integer currentHarmonicCount = 0;
private Integer currentRunCount;
@ApiModelProperty(value = "稳态件数") @ApiModelProperty(value = "当前工程运行告警数量(未读)")
private Integer currentHarmonicCount; private Integer currentAlarmCount = 0;
@ApiModelProperty(value = "当前工程运行事件数量(未读)")
private Integer currentRunCount = 0;
@ApiModelProperty(value = "当前项目数") @ApiModelProperty(value = "当前项目数")
private Integer currentProjectCount; private Integer currentProjectCount = 0;
@ApiModelProperty(value = "反馈数") @ApiModelProperty(value = "反馈数")
private Integer feedBackCount; private Integer feedBackCount = 0;
} }

View File

@@ -0,0 +1,100 @@
package com.njcn.csdevice.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author caozehui
* @data 2026-04-07
*/
@Data
public class DevVersionVO {
/**
* 设备Id
*/
private String id;
/**
* 设备名称
*/
private String name;
/**
* 版本号
*/
private String version;
/**
* 协议版本号
*/
private String protocolVersion;
/**
* 版本日期
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime versionDate;
/**
* 设备型号
*/
private String devModel;
/**
* 设备类型名称
*/
private String devModelName;
/**
* icd型号
*/
private String icd;
/**
* 所属工程
*/
private String associatedEngineering;
/**
* 所属项目
*/
private String associatedProject;
/**
* 装置启用状态(0:停用 1:启用)
*/
private Integer status;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
/**
* 修改人员
*/
private String updateBy;
/**
* 修改人名称
*/
private String updateByName;
/**
* 设备运行状态(0:删除 1:离线 2:在线)
*/
private Integer runStatus;
/**
* 是否支持升级(0:否 1:是)
*/
private Integer upgrade;
/**
* 设备与MQTT服务器连接状态 (0:未连接 1:已连接)
*/
private Integer connectStatus;
}

View File

@@ -0,0 +1,41 @@
package com.njcn.csdevice.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2026/3/5
*/
@Data
public class EngineeringHomePageVO implements Serializable {
@ApiModelProperty(name = "engineeringId",value = "工程id")
private String engineeringId;
@ApiModelProperty(name = "engineeringName",value = "工程名称")
private String engineeringName;
@ApiModelProperty(name = "devTotal",value = "设备总数")
private Integer devTotal = 0;
@ApiModelProperty(name = "onlineDevTotal",value = "在线设备数")
private Integer onlineDevTotal = 0;
@ApiModelProperty(name = "offlineDevTotal",value = "离线设备数")
private Integer offlineDevTotal = 0;
@ApiModelProperty(name = "alarmTotal",value = "告警数量(未读)")
private Integer alarmTotal = 0;
@ApiModelProperty(name = "isTop",value = "是否置顶 0:未置顶 1:已置顶")
private Integer isTop = 0;
@ApiModelProperty(name = "sort",value = "排序")
private Integer sort;
}

View File

@@ -0,0 +1,40 @@
package com.njcn.csdevice.pojo.vo;
import cn.hutool.core.lang.RegexPool;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @author caozehui
* @data 2026-02-27
*/
@Data
@Schema(description = "管理后台 - 消息记录发送 Request VO")
public class MessageRecordReqVO {
private String channel;
@Schema(description = "消息类型", example = "verify_code/order_notify/marketing/system_notify")
@NotBlank(message = "消息类型不能为空")
private String messageType;
@Schema(description = "接收者")
@NotBlank(message = "接收者不能为空")
@Pattern(regexp = RegexPool.EMAIL + "|" + RegexPool.MOBILE, message = "必须是有效的邮箱或手机号格式")
private String receiver;
@Schema(description = "标题")
private String title;
@Schema(description = "消息内容")
private String content;
@Schema(description = "模板编码")
private String templateCode;
@Schema(description = "模板参数")
private String templateParams;
}

View File

@@ -1,8 +1,11 @@
package com.njcn.csdevice.pojo.vo; package com.njcn.csdevice.pojo.vo;
import com.njcn.csdevice.pojo.po.CsLinePO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* *
* Description: * Description:
@@ -54,4 +57,19 @@ public class ProjectEquipmentVO {
@ApiModelProperty(value = "设备nDid") @ApiModelProperty(value = "设备nDid")
private String nDid; private String nDid;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "是否置顶(0:未置顶 1:置顶),默认是0")
private Integer isTop = 0;
@ApiModelProperty(value = "设备类型(监测设备:DEV_CLD 治理设备:Direct_Connected_Device)")
private String devType;
@ApiModelProperty(value = "是否存在告警(告警通过查询当日的未读的暂态事件判断)")
private Boolean isAlarm;
@ApiModelProperty(value = "监测点集合")
private List<CsLinePO> lineList;
} }

View File

@@ -0,0 +1,20 @@
package com.njcn.csdevice.pojo.vo;
import com.njcn.csdevice.pojo.po.AppProjectPO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author 徐扬
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ProjectVO extends AppProjectPO {
private String topoId;
}

View File

@@ -1,74 +1,74 @@
package com.njcn.csdevice.utils; //package com.njcn.csdevice.utils;
//
import org.eclipse.paho.client.mqttv3.*; //import org.eclipse.paho.client.mqttv3.*;
//
import java.io.File; //import java.io.File;
import java.io.FileInputStream; //import java.io.FileInputStream;
import java.io.FileOutputStream; //import java.io.FileOutputStream;
import java.io.IOException; //import java.io.IOException;
import java.nio.file.Files; //import java.nio.file.Files;
import java.nio.file.Paths; //import java.nio.file.Paths;
//
/** ///**
* Description: // * Description:
* Date: 2023/8/2 13:41【需求编号】 // * Date: 2023/8/2 13:41【需求编号】
* // *
* @author clam // * @author clam
* @version V1.0.0 // * @version V1.0.0
*/ // */
public class MqttTest { //public class MqttTest {
private static final String MQTT_BROKER = "tcp://192.168.1.13:1883"; // private static final String MQTT_BROKER = "tcp://192.168.1.13:1883";
private static final String MQTT_TOPIC = "file/upload"; // private static final String MQTT_TOPIC = "file/upload";
private static final String FILE_PATH = "C:\\Users\\无名\\Desktop\\111.json"; // Replace with the path to your file // private static final String FILE_PATH = "C:\\Users\\无名\\Desktop\\111.json"; // Replace with the path to your file
//
public static void main(String[] args) { // public static void main(String[] args) {
MqttClient mqttClient = null; // MqttClient mqttClient = null;
try { // try {
// Connect to the MQTT broker // // Connect to the MQTT broker
mqttClient = new MqttClient(MQTT_BROKER, MqttClient.generateClientId()); // mqttClient = new MqttClient(MQTT_BROKER, MqttClient.generateClientId());
MqttConnectOptions connOpts = new MqttConnectOptions(); // MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setUserName("t_user"); // connOpts.setUserName("t_user");
connOpts.setPassword("njcnpqs".toCharArray()); // connOpts.setPassword("njcnpqs".toCharArray());
//
mqttClient.connect(connOpts); // mqttClient.connect(connOpts);
//
// Read the file // // Read the file
File file = new File(FILE_PATH); // File file = new File(FILE_PATH);
FileInputStream fis = new FileInputStream(file); // FileInputStream fis = new FileInputStream(file);
byte[] fileContent = new byte[(int) file.length()]; // byte[] fileContent = new byte[(int) file.length()];
fis.read(fileContent); // fis.read(fileContent);
fis.close(); // fis.close();
//
// Create a new MQTT message // // Create a new MQTT message
MqttMessage message = new MqttMessage(fileContent); // MqttMessage message = new MqttMessage(fileContent);
//
// Set QoS level and retain flag as per your requirement // // Set QoS level and retain flag as per your requirement
message.setQos(1); // message.setQos(1);
// message.setRetained(false); //// message.setRetained(false);
//
// Record the start time // // Record the start time
long startTime = System.currentTimeMillis(); // long startTime = System.currentTimeMillis();
//
// Publish the message to the MQTT topic // // Publish the message to the MQTT topic
mqttClient.publish(MQTT_TOPIC, message); // mqttClient.publish(MQTT_TOPIC, message);
//
// Record the end time // // Record the end time
long endTime = System.currentTimeMillis(); // long endTime = System.currentTimeMillis();
//
System.out.println("File published successfully!"); // System.out.println("File published successfully!");
System.out.println("Time taken: " + (endTime - startTime) + " ms"); // System.out.println("Time taken: " + (endTime - startTime) + " ms");
} catch (MqttException | IOException e) { // } catch (MqttException | IOException e) {
e.printStackTrace(); // e.printStackTrace();
} finally { // } finally {
// Disconnect from the MQTT broker // // Disconnect from the MQTT broker
if (mqttClient != null && mqttClient.isConnected()) { // if (mqttClient != null && mqttClient.isConnected()) {
try { // try {
mqttClient.disconnect(); // mqttClient.disconnect();
} catch (MqttException e) { // } catch (MqttException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
} // }
} // }
//
} //}

View File

@@ -21,6 +21,10 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>com.github.tocrhz</groupId>
<artifactId>mqtt-spring-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-web</artifactId> <artifactId>common-web</artifactId>

View File

@@ -66,7 +66,5 @@ public class CsSoftInfoController extends BaseController {
csSoftInfoService.removeById(id); csSoftInfoService.removeById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
} }

View File

@@ -0,0 +1,56 @@
package com.njcn.csdevice.controller.equipment;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
import com.njcn.csdevice.service.CsUpgradeLogsService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.RequestUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author caozehui
* @data 2026-04-23
*/
@Slf4j
@RestController
@RequestMapping("/csUpgradeLogs")
@Api(tags = "装置升级日志")
@AllArgsConstructor
@Validated
public class CsUpgradeLogsController extends BaseController {
private final CsUpgradeLogsService csUpgradeLogsService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增升级日志")
@ApiImplicitParam(name = "csUpgradeLogs", value = "日志参数", required = true)
public HttpResult add(@RequestBody CsUpgradeLogs csUpgradeLogs) {
csUpgradeLogs.setUserName(RequestUtil.getUsername());
csUpgradeLogs.setLoginName(RequestUtil.getLoginName());
String methodDescribe = getMethodDescribe("add");
return HttpResultUtil.assembleCommonResponseResult(csUpgradeLogsService.save(csUpgradeLogs) ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, null, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
@GetMapping("/getByDevId")
@ApiOperation("查询指定devId的所有升级日志")
@ApiImplicitParam(name = "devId", value = "装置Id", required = true)
public HttpResult<List<CsUpgradeLogs>> getByDevId(@RequestBody String devId) {
String methodDescribe = getMethodDescribe("getByDevId");
List<CsUpgradeLogs> result = csUpgradeLogsService.lambdaQuery().eq(CsUpgradeLogs::getDevId, devId).list();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -23,6 +23,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* Description: * Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html * 接口文档访问地址http://serverIP:port/swagger-ui.html
@@ -64,7 +66,6 @@ public class DevModelController extends BaseController {
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryDevModelPage") @PostMapping("/queryDevModelPage")
@ApiOperation("设备模板分页查询") @ApiOperation("设备模板分页查询")
@@ -110,5 +111,4 @@ public class DevModelController extends BaseController {
CsDevModelPO po = csDevModelService.getModelById(id); CsDevModelPO po = csDevModelService.getModelById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
} }
} }

View File

@@ -11,16 +11,22 @@ import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevCountVO; import com.njcn.csdevice.pojo.vo.DevCountVO;
import com.njcn.csdevice.pojo.vo.DevUserVO; import com.njcn.csdevice.pojo.vo.DevUserVO;
import com.njcn.csdevice.service.CsDeviceUserPOService; import com.njcn.csdevice.service.CsDeviceUserPOService;
import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.web.advice.DeviceLog; import com.njcn.web.advice.DeviceLog;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.RequestUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
@@ -36,6 +42,8 @@ import java.util.List;
public class DeviceUserController extends BaseController { public class DeviceUserController extends BaseController {
private final CsDeviceUserPOService csDeviceUserPOService; private final CsDeviceUserPOService csDeviceUserPOService;
private final EventUserFeignClient eventUserFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新增设备扫码设备用户绑定") @ApiOperation("新增设备扫码设备用户绑定")
@@ -77,11 +85,13 @@ public class DeviceUserController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/devCount") @PostMapping("/devCount")
@ApiOperation("设备统计") @ApiOperation("设备统计")
@ApiImplicitParam(name = "id", value = "工程id", required = true) @ApiImplicitParams({
public HttpResult<DevCountVO> devCount(@RequestParam("id") String id){ @ApiImplicitParam(name = "id", value = "工程id"),
@ApiImplicitParam(name = "time", value = "时间")
})
public HttpResult<DevCountVO> devCount(@RequestParam("id") String id,@RequestParam("time") String time){
String methodDescribe = getMethodDescribe("devCount"); String methodDescribe = getMethodDescribe("devCount");
DevCountVO result = csDeviceUserPOService.devCount(id,time);
DevCountVO result = csDeviceUserPOService.devCount (id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@@ -161,4 +171,35 @@ public class DeviceUserController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getList")
@ApiOperation("根据设备集合获取数据")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<CsDeviceUserPO>> getList(@RequestBody UserDevParam param){
String methodDescribe = getMethodDescribe("getList");
List<CsDeviceUserPO> list = csDeviceUserPOService.getList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getIdList")
@ApiOperation("获取事件id集合")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<String>> getIdList(@RequestParam("param") String param){
String methodDescribe = getMethodDescribe("getIdList");
List<String> list = new ArrayList<>();
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(null);
param1.setEndTime(null);
param1.setEventIds(null);
if (Objects.equals(param, "1")) {
list = eventUserFeignClient.queryTempHarmonic(param1).getData();
} else if (Objects.equals(param, "3")) {
list = eventUserFeignClient.queryAlarmEvent(param1).getData();
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
} }

View File

@@ -14,7 +14,9 @@ import com.njcn.csdevice.enums.DeviceOperate;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.param.*; import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLogsPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO; import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO; import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.csdevice.service.CsDevModelRelationService; import com.njcn.csdevice.service.CsDevModelRelationService;
@@ -28,6 +30,7 @@ import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.web.advice.DeviceLog; import com.njcn.web.advice.DeviceLog;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -46,6 +49,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
* Description: * Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html * 接口文档访问地址http://serverIP:port/swagger-ui.html
@@ -416,4 +420,16 @@ public class EquipmentDeliveryController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/version/page")
@ApiOperation("查询设备版本信息")
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
public HttpResult<IPage<DevVersionVO>> versionPage(@RequestBody CsEquipmentDeliveryQueryParm baseParam) {
String methodDescribe = getMethodDescribe("versionPage");
IPage<DevVersionVO> list = csEquipmentDeliveryService.versionPage(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
} }

View File

@@ -54,18 +54,29 @@ public class CsLedgerController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/lineTree") @PostMapping("/lineTree")
@ApiOperation("五层设备树(监测点层,根节点为治理设备和便携式设备)") @ApiOperation("五层设备树(监测点层,根节点为治理设备和便携式设备)")
public HttpResult<List<CsLedgerVO>> lineTree(){ @ApiImplicitParam(name = "type", value = "台账树类型")
public HttpResult<List<CsLedgerVO>> lineTree(@RequestParam(required = false) @Validated String type){
String methodDescribe = getMethodDescribe("lineTree"); String methodDescribe = getMethodDescribe("lineTree");
List<CsLedgerVO> list = csLedgerService.getLineTree(); List<CsLedgerVO> list = csLedgerService.getLineTree(type);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/AppLineTree")
@ApiOperation("app端监测点树")
public HttpResult<List<CsLedgerVO>> appLineTree(){
String methodDescribe = getMethodDescribe("AppLineTree");
List<CsLedgerVO> list = csLedgerService.appLineTree();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deviceTree") @PostMapping("/deviceTree")
@ApiOperation("四层设备树(装置层,根节点为治理设备和便携式设备)") @ApiOperation("四层设备树(装置层,根节点为治理设备和便携式设备)")
public HttpResult<List<CsLedgerVO>> getDeviceTree(){ @ApiImplicitParam(name = "type", value = "台账树类型")
public HttpResult<List<CsLedgerVO>> getDeviceTree(@RequestParam(required = false) @Validated String type){
String methodDescribe = getMethodDescribe("getDeviceTree"); String methodDescribe = getMethodDescribe("getDeviceTree");
List<CsLedgerVO> list = csLedgerService.getDeviceTree(); List<CsLedgerVO> list = csLedgerService.getDeviceTree(type);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }

View File

@@ -7,6 +7,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -254,6 +255,15 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getAllLineDetail")
@ApiOperation("获取所有监测点id详情")
public HttpResult<List<CsLineDTO>> getAllLineDetail(){
String methodDescribe = getMethodDescribe("getAllLineDetail");
List<CsLineDTO> list = csLinePOService.getAllLineDetail();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getSimpleLine") @GetMapping("/getSimpleLine")
@ApiOperation("查询登录用户拥有的监测点台账") @ApiOperation("查询登录用户拥有的监测点台账")

View File

@@ -0,0 +1,80 @@
package com.njcn.csdevice.controller.message;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.csdevice.pojo.param.DataArrayParam;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerDetailVO;
import com.njcn.csdevice.service.DeviceMessageService;
import com.njcn.csdevice.service.ICsDataArrayService;
import com.njcn.user.pojo.po.User;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
* <p>
* 详细数据表 前端控制器
* </p>
*
* @author xuyang
* @since 2023-05-31
*/
@Slf4j
@RestController
@RequestMapping("/deviceMessage")
@Api(tags = "App消息推送管理")
@AllArgsConstructor
public class DeviceMessageController extends BaseController {
private final DeviceMessageService deviceMessageService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventUserByDeviceId")
@ApiOperation("根据设备获取需要推送的用户id")
@ApiImplicitParams({
@ApiImplicitParam(name = "devId", value = "设备id", required = true, paramType = "query"),
@ApiImplicitParam(name = "isAdmin", value = "是否需要推送给管理员", required = true, paramType = "query")
})
public HttpResult<List<String>> getEventUserByDeviceId(@RequestParam("devId") String devId, @RequestParam("isAdmin") Boolean isAdmin){
String methodDescribe = getMethodDescribe("getEventUserByDeviceId");
List<String> list = deviceMessageService.getEventUserByDeviceId(devId,isAdmin);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getSendUserByType")
@ApiOperation("根据事件类型和用户id查询打开推送的用户信息")
@ApiImplicitParam(name = "param", value = "参数", required = true, paramType = "query")
public HttpResult<List<User>> getSendUserByType(@RequestBody DeviceMessageParam param){
String methodDescribe = getMethodDescribe("getSendUserByType");
List<User> list = deviceMessageService.getSendUserByType(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLineInfo")
@ApiOperation("获取监测点信息")
@ApiImplicitParam(name = "id", value = "参数", required = true, paramType = "query")
public HttpResult<String> getLineInfo(@RequestParam("id") String id){
String methodDescribe = getMethodDescribe("getLineInfo");
deviceMessageService.getLineInfo(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
}
}

View File

@@ -0,0 +1,77 @@
package com.njcn.csdevice.controller.message;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.vo.MessageRecordReqVO;
import com.njcn.csdevice.service.ISmsSendService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
* @author xy
*/
@Slf4j
@RestController
@RequestMapping("/sms")
@Api(tags = "短信发送管理")
@AllArgsConstructor
public class SmsSendController extends BaseController {
private final ISmsSendService smsSendService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/send")
@ApiOperation("发送短信(同步,包含重试)")
public HttpResult<String> sendSms(@RequestBody MessageRecordReqVO vo) {
String methodDescribe = getMethodDescribe("sendSms");
try {
smsSendService.sendSmsWithRetry(vo);
return HttpResultUtil.assembleCommonResponseResult(
CommonResponseEnum.SUCCESS,
"短信发送成功",
methodDescribe
);
} catch (Exception e) {
log.error("短信发送失败", e);
return HttpResultUtil.assembleCommonResponseResult(
CommonResponseEnum.FAIL,
e.getMessage(),
methodDescribe
);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/send/simple")
@ApiOperation("发送短信(简化参数)")
public HttpResult<String> sendSmsSimple(
@RequestParam String receiver,
@RequestParam String content,
@RequestParam(defaultValue = "verify_code") String messageType) {
String methodDescribe = getMethodDescribe("sendSmsSimple");
try {
smsSendService.sendSmsWithRetry(receiver, content, messageType);
return HttpResultUtil.assembleCommonResponseResult(
CommonResponseEnum.SUCCESS,
"短信发送成功",
methodDescribe
);
} catch (Exception e) {
log.error("短信发送失败", e);
return HttpResultUtil.assembleCommonResponseResult(
CommonResponseEnum.FAIL,
e.getMessage(),
methodDescribe
);
}
}
}

View File

@@ -1,6 +1,5 @@
package com.njcn.csdevice.controller.project; package com.njcn.csdevice.controller.project;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
@@ -66,12 +65,21 @@ public class AppProjectController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addAppProject") @PostMapping("/addAppProject")
@ApiOperation("新增项目") @ApiOperation("新增项目")
public HttpResult<Boolean> addAppProject(@Validated AppProjectAddParm appProjectAddParm){ public HttpResult<AppProjectPO> addAppProject(@Validated AppProjectAddParm appProjectAddParm){
String methodDescribe = getMethodDescribe("addAppProject"); String methodDescribe = getMethodDescribe("addAppProject");
AppProjectPO po = appProjectService.addAppProject(appProjectAddParm); AppProjectPO po = appProjectService.addAppProject(appProjectAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ObjectUtil.isNotNull(po), methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addPortableProject")
@ApiOperation("新增便携式项目")
public HttpResult<AppProjectPO> addPortableProject(@Validated @RequestBody AppProjectAddParm appProjectAddParm){
String methodDescribe = getMethodDescribe("addPortableProject");
AppProjectPO po = appProjectService.addAppProject(appProjectAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/auditAppProject") @PostMapping("/auditAppProject")
@ApiOperation("修改/删除项目") @ApiOperation("修改/删除项目")
@@ -91,4 +99,14 @@ public class AppProjectController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getProjectByName")
@ApiOperation("根据项目名称获取项目信息")
@ApiImplicitParam(name = "name", value = "项目名称", required = true)
public HttpResult<AppProjectPO> getProjectByName(@RequestParam("name") String name){
String methodDescribe = getMethodDescribe("getProjectByName");
AppProjectPO po = appProjectService.getProjectByName(name);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
} }

View File

@@ -9,6 +9,7 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.param.CsEdDataAddParm; import com.njcn.csdevice.pojo.param.CsEdDataAddParm;
import com.njcn.csdevice.pojo.param.CsEdDataAuditParm; import com.njcn.csdevice.pojo.param.CsEdDataAuditParm;
import com.njcn.csdevice.pojo.param.CsEdDataQueryParm; import com.njcn.csdevice.pojo.param.CsEdDataQueryParm;
import com.njcn.csdevice.pojo.po.CsEdDataPO;
import com.njcn.csdevice.pojo.vo.CsEdDataVO; import com.njcn.csdevice.pojo.vo.CsEdDataVO;
import com.njcn.csdevice.service.CsEdDataService; import com.njcn.csdevice.service.CsEdDataService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
@@ -79,4 +80,14 @@ public class CsEdDataController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getById")
@ApiOperation("根据id查询")
@ApiImplicitParam(name = "id", value = "id", required = true)
public HttpResult<CsEdDataPO> getById(@Validated @RequestParam("id") String id){
String methodDescribe = getMethodDescribe("getById");
CsEdDataPO dataPO = csEdDataService.getById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dataPO, methodDescribe);
}
} }

View File

@@ -99,4 +99,13 @@ public class CsMarketDataController extends BaseController {
List<CsMarketDataVO> list = csMarketDataService.queryAllEnginner(userId); List<CsMarketDataVO> list = csMarketDataService.queryAllEnginner(userId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/insert")
@ApiOperation("根据用户、工程新增数据")
public HttpResult<Boolean> insertData(@RequestParam("userId")String userId, @RequestParam("engineeringId")String engineeringId){
String methodDescribe = getMethodDescribe("insertData");
Boolean result = csMarketDataService.insertData(userId,engineeringId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
} }

View File

@@ -61,7 +61,7 @@ public class CsTouristDataPOController extends BaseController {
@PostMapping("/queryAll") @PostMapping("/queryAll")
@ApiOperation("查询游客数据") @ApiOperation("查询游客数据")
public HttpResult<List<CsTouristDataParmVO>> queryAll(){ public HttpResult<List<CsTouristDataParmVO>> queryAll(){
String methodDescribe = getMethodDescribe("query"); String methodDescribe = getMethodDescribe("queryAll");
List<CsTouristDataParmVO> list = csTouristDataPOService.queryAll(); List<CsTouristDataParmVO> list = csTouristDataPOService.queryAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);

View File

@@ -0,0 +1,61 @@
package com.njcn.csdevice.controller.project;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.param.CsUserPinsParam;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.service.ICsUserPinsService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 用户置顶表 前端控制器
* </p>
*
* @author xy
* @since 2026-03-04
*/
@Slf4j
@RestController
@RequestMapping("/csUserPins")
@Api(tags = "置顶设备(工程)")
@AllArgsConstructor
public class CsUserPinsController extends BaseController {
private final ICsUserPinsService csUserPinsService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/engineeringPinToTop")
@ApiOperation("用户置顶工程(取消置顶)")
public HttpResult<Boolean> engineeringPinToTop(@Validated @RequestBody CsUserPinsParam param){
String methodDescribe = getMethodDescribe("engineeringPinToTop");
Boolean result = csUserPinsService.engineeringPinToTop(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getPinToTopList")
@ApiOperation("获取用户置顶设备(工程)")
public HttpResult<List<CsUserPins>> getPinToTopList(){
String methodDescribe = getMethodDescribe("getPinToTopList");
List<CsUserPins> result = csUserPinsService.getPinToTopList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -103,4 +103,15 @@ public class EngineeringController extends BaseController {
List<CsEngineeringPO> result = csEngineeringService.getUnlinkedEngineering(userId); List<CsEngineeringPO> result = csEngineeringService.getUnlinkedEngineering(userId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEngineeringByName")
@ApiOperation("根据工程名称获取工程信息")
@ApiImplicitParam(name = "name", value = "工程名称", required = true)
public HttpResult<CsEngineeringPO> getEngineeringByName(@RequestParam("name") String name){
String methodDescribe = getMethodDescribe("getEngineeringByName");
CsEngineeringPO po = csEngineeringService.getEngineeringByName(name);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
} }

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.mapper; package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -21,4 +22,6 @@ public interface CsLinePOMapper extends BaseMapper<CsLinePO> {
Map<String,String> getCustomDetailByLineId(@Param("lineId")String lineId); Map<String,String> getCustomDetailByLineId(@Param("lineId")String lineId);
List<CsLineDTO> findLineList();
} }

View File

@@ -0,0 +1,7 @@
package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.CsSmsSendRecord;
public interface CsSmsSendRecordMapper extends BaseMapper<CsSmsSendRecord> {
}

View File

@@ -0,0 +1,12 @@
package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
import org.apache.ibatis.annotations.Mapper;
/**
* @author caozehui
* @data 2026-04-23
*/
public interface CsUpgradeLogsMapper extends BaseMapper<CsUpgradeLogs> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.CsUserPins;
/**
* <p>
* 用户置顶表 Mapper 接口
* </p>
*
* @author xy
* @since 2026-03-04
*/
public interface CsUserPinsMapper extends BaseMapper<CsUserPins> {
}

View File

@@ -45,6 +45,7 @@
<if test="temp!=null and temp.searchValue != null and temp.searchValue !=''"> <if test="temp!=null and temp.searchValue != null and temp.searchValue !=''">
AND a.`name` like concat('%',#{temp.searchValue},'%') AND a.`name` like concat('%',#{temp.searchValue},'%')
</if> </if>
AND a.`name` != '便携式项目'
order by a.create_time desc order by a.create_time desc
</select> </select>
</mapper> </mapper>

View File

@@ -41,7 +41,9 @@
c.create_time createTime, c.create_time createTime,
c.run_status, c.run_status,
c.mac mac, c.mac mac,
c.process process c.process process,
c.sort sort,
c.dev_type devType
FROM FROM
(select * from cs_ledger where LEVEL = 0 and State =1 (select * from cs_ledger where LEVEL = 0 and State =1
) a, ) a,
@@ -97,9 +99,14 @@
<if test="queryParam.process != null and queryParam.process !=''"> <if test="queryParam.process != null and queryParam.process !=''">
and process = #{queryParam.process} and process = #{queryParam.process}
</if> </if>
<if test="queryParam.runStatus != null and queryParam.runStatus !=''"> <choose>
and run_status = #{queryParam.runStatus} <when test="queryParam.runStatus != null and queryParam.runStatus != ''">
</if> AND run_status = #{queryParam.runStatus}
</when>
<otherwise>
AND run_status IN (1,2)
</otherwise>
</choose>
<if test="queryParam.searchValue != null and queryParam.searchValue !=''"> <if test="queryParam.searchValue != null and queryParam.searchValue !=''">
and (name like concat('%',#{queryParam.searchValue},'%') or ndid like concat('%',#{queryParam.searchValue},'%')) and (name like concat('%',#{queryParam.searchValue},'%') or ndid like concat('%',#{queryParam.searchValue},'%'))
</if> </if>

View File

@@ -28,7 +28,7 @@
t1.* t1.*
from from
cs_equipment_delivery t0 cs_equipment_delivery t0
left join cs_line t1 on right join cs_line t1 on
t0.id = t1.device_id t0.id = t1.device_id
where where
t0.ndid = #{id} t0.ndid = #{id}
@@ -53,4 +53,15 @@
WHERE WHERE
line.line_id = #{lineId} line.line_id = #{lineId}
</select> </select>
<select id="findLineList" resultType="com.njcn.csdevice.pojo.dto.CsLineDTO">
SELECT
t1.*,
t2.dev_type deviceType
FROM
cs_line t1
LEFT JOIN cs_equipment_delivery t2 ON t1.device_id = t2.id
WHERE
t1.`status` = 1
</select>
</mapper> </mapper>

View File

@@ -62,4 +62,7 @@ public interface AppProjectService extends IService<AppProjectPO> {
AppProjectPO updateData(AppProjectAuditParm param); AppProjectPO updateData(AppProjectAuditParm param);
boolean delete(String id); boolean delete(String id);
AppProjectPO getProjectByName(String name);
} }

View File

@@ -1,25 +1,17 @@
package com.njcn.csdevice.service; package com.njcn.csdevice.service;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit; import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
public interface CsCommTerminalService { public interface CsCommTerminalService {
List<String> getLineIdsByUser(String userId); List<String> getLineIdsByUser(String userId);
List<String> getPqUserIdsByUser(String userId); List<String> getPqUserIdsByUser(String userId);
PqsDeviceUnit lineUnitDetail(String lineId); PqsDeviceUnit lineUnitDetail(String lineId);
List<String> commGetDevIds(String userId); List<String> commGetDevIds(String userId);
} }

View File

@@ -23,7 +23,7 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
Boolean share(List<String> ids); Boolean share(List<String> ids);
DevCountVO devCount(String id); DevCountVO devCount(String id,String time);
String isPrimaryUser(String deviceId); String isPrimaryUser(String deviceId);
@@ -53,4 +53,12 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
List<String> findDevByUserId(String userId); List<String> findDevByUserId(String userId);
void channelDevByUserId(UserDevParam param); void channelDevByUserId(UserDevParam param);
List<CsDeviceUserPO> getList(UserDevParam param);
/**
* 新增用户设备关系表数据 新增主用户信息 && 新增已关联工程的用户的设备关系
* @return
*/
Boolean addRelation(UserDevParam param);
} }

View File

@@ -48,5 +48,13 @@ public interface CsEdDataService extends IService<CsEdDataPO> {
* @author: xuyang * @author: xuyang
*/ */
CsEdDataVO findByDevTypeId(String devType); CsEdDataVO findByDevTypeId(String devType);
/**
* @Description: 根据装置型号和版本号获取装置类型
* @param devTypeId 装置型号
* @param versionNo 版本号
* @return
*/
CsEdDataPO findByDevTypeIdAndVersionNo(String devTypeId, String versionNo);
} }

View File

@@ -66,4 +66,6 @@ public interface CsEngineeringService extends IService<CsEngineeringPO>{
boolean deleteData(String id); boolean deleteData(String id);
CsEngineeringPO getEngineeringByName(String name);
} }

View File

@@ -3,14 +3,14 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm; import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLogsPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO; import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO; import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.web.pojo.param.BaseParam;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -196,4 +196,5 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
List<CsEquipmentDeliveryPO> getRunPortableDev(String userId); List<CsEquipmentDeliveryPO> getRunPortableDev(String userId);
IPage<DevVersionVO> versionPage(CsEquipmentDeliveryQueryParm baseParam);
} }

View File

@@ -2,6 +2,7 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -81,6 +82,8 @@ public interface CsLinePOService extends IService<CsLinePO>{
List<String> getAllLine(); List<String> getAllLine();
List<CsLineDTO> getAllLineDetail();
List<CsLinePO> getSimpleLine(); List<CsLinePO> getSimpleLine();
List<CsLinePO> getLineBySensitiveUser(List<String> list); List<CsLinePO> getLineBySensitiveUser(List<String> list);

View File

@@ -30,4 +30,6 @@ public interface CsMarketDataService extends IService<CsMarketData> {
List<CsMarketDataVO> queryAllEnginner(String userId); List<CsMarketDataVO> queryAllEnginner(String userId);
Boolean follow(EngineerIdParam engineerIdParams); Boolean follow(EngineerIdParam engineerIdParams);
Boolean insertData(String userId,String engineeringId);
} }

View File

@@ -0,0 +1,11 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
/**
* @author caozehui
* @data 2026-04-23
*/
public interface CsUpgradeLogsService extends IService<CsUpgradeLogs> {
}

View File

@@ -0,0 +1,19 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.user.pojo.po.User;
import java.util.List;
/**
* @author xy
*/
public interface DeviceMessageService {
List<String> getEventUserByDeviceId(String devId, Boolean isAdmin);
List<User> getSendUserByType(DeviceMessageParam param);
void getLineInfo(String id);
}

View File

@@ -3,6 +3,7 @@ package com.njcn.csdevice.service;
import com.njcn.csdevice.param.LineCountEvaluateParam; import com.njcn.csdevice.param.LineCountEvaluateParam;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto; import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.influx.pojo.po.PqsCommunicate;
import java.util.List; import java.util.List;
@@ -20,6 +21,13 @@ public interface ICsCommunicateService {
*/ */
List<PqsCommunicateDto> getRawDataLatest(LineCountEvaluateParam lineParam); List<PqsCommunicateDto> getRawDataLatest(LineCountEvaluateParam lineParam);
/**
* 取出第一条装置数据
* @param lineParam
* @return
*/
List<PqsCommunicateDto> getRawDataOne(LineCountEvaluateParam lineParam);
/** /**
* 获取时间范围数据 * 获取时间范围数据
* @param lineParam * @param lineParam
@@ -27,6 +35,8 @@ public interface ICsCommunicateService {
*/ */
List<PqsCommunicateDto> getRawData(LineCountEvaluateParam lineParam); List<PqsCommunicateDto> getRawData(LineCountEvaluateParam lineParam);
List<PqsCommunicateDto> getRawData2(LineCountEvaluateParam lineParam);
/** /**
*是否有当天最后一条数据 *是否有当天最后一条数据
* @param lineParam * @param lineParam

View File

@@ -29,13 +29,15 @@ public interface ICsLedgerService extends IService<CsLedger> {
* 获取终端台账树 * 获取终端台账树
* @return * @return
*/ */
List<CsLedgerVO> getLineTree(); List<CsLedgerVO> getLineTree(String type);
List<CsLedgerVO> appLineTree();
/** /**
* 终端三层树 * 终端三层树
* @return * @return
*/ */
List<CsLedgerVO> getDeviceTree(); List<CsLedgerVO> getDeviceTree(String type);
/** /**
* 新增台账数据 * 新增台账数据

View File

@@ -0,0 +1,35 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.param.CsUserPinsParam;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import java.util.List;
/**
* <p>
* 用户置顶表 服务类
* </p>
*
* @author xy
* @since 2026-03-04
*/
public interface ICsUserPinsService extends IService<CsUserPins> {
boolean engineeringPinToTop(CsUserPinsParam param);
List<CsUserPins> getPinToTopList();
/**
* 针对台账树中存在置顶的数据进行排序
*
* @param list 置顶数据
* @param tree 台账树
* @param level 树的层级
* 如果第一层不是工程并且是5层树level = 5 5层树层级必须是 0:设备类型 1:工程 2:项目 3:设备 4:监测点
* 如果第一层是工程level = 4 4层树层级必须是 0:工程 1:项目 2:设备 3:监测点其余层级的树也可以使用level = 4只要是工程、项目、设备、监测点这样的结构就行
*/
void channelTree(List<CsUserPins> list, List<CsLedgerVO> tree, Integer level);
}

View File

@@ -16,6 +16,19 @@ import java.util.List;
*/ */
public interface IRStatOnlineRateDService extends IService<RStatOnlineRateD> { public interface IRStatOnlineRateDService extends IService<RStatOnlineRateD> {
/**
* 1.查询该设备当前计算周期是否存在上下线记录
* 2.
* a.存在记录如果只有1条数据则根据这一条记录的状态计算在线时长如果是多条数据则根据上下线时间计算在线时长
* b.不存在记录,则需要借助历史记录判断:
* 1) 先查询设备第一条记录时间
* - 如果统计日期 < 第一条记录时间 → 设备未上线 → 离线
* 2) 再查询最新记录时间和状态
* - 如果统计日期 > 最新记录时间 → 延续最新状态
* * 最新是在线 → 全天在线
* * 最新是离线 → 全天离线
* @param param
*/
void addData(StatisticsDataParam param); void addData(StatisticsDataParam param);
List<RStatOnlineRateD> getData(List<String> list, String startTime, String endTime); List<RStatOnlineRateD> getData(List<String> list, String startTime, String endTime);

View File

@@ -0,0 +1,12 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.po.CsSmsSendRecord;
import com.njcn.csdevice.pojo.vo.MessageRecordReqVO;
public interface ISmsSendService extends IService<CsSmsSendRecord> {
void sendSmsWithRetry(String receiver, String content, String messageType);
void sendSmsWithRetry(MessageRecordReqVO messageRecordReqVO);
}

View File

@@ -2,6 +2,7 @@ package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.cloud.commons.lang.StringUtils; import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -57,10 +58,6 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AppProjectPO addAppProject(AppProjectAddParm appProjectAddOrAuditParm) { public AppProjectPO addAppProject(AppProjectAddParm appProjectAddOrAuditParm) {
AppProjectPO appProjectPO = new AppProjectPO ( ); AppProjectPO appProjectPO = new AppProjectPO ( );
// Boolean result = checkName (appProjectAddOrAuditParm.getUserId ( ), appProjectAddOrAuditParm.getName ( ));
// if (result) {
// throw new BusinessException (AlgorithmResponseEnum.PROJECT_COMMON_ERROR);
// }
if(checkName(appProjectAddOrAuditParm.getName(),"",appProjectAddOrAuditParm.getEngineeringId())){ if(checkName(appProjectAddOrAuditParm.getName(),"",appProjectAddOrAuditParm.getEngineeringId())){
throw new BusinessException(AlgorithmResponseEnum.PROJECT_COMMON_ERROR); throw new BusinessException(AlgorithmResponseEnum.PROJECT_COMMON_ERROR);
@@ -81,22 +78,8 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
appTopologyDiagramPO.setStatus ("1"); appTopologyDiagramPO.setStatus ("1");
appTopologyDiagramPO.setTopoId(temp); appTopologyDiagramPO.setTopoId(temp);
appTopologyDiagramService.save(appTopologyDiagramPO); appTopologyDiagramService.save(appTopologyDiagramPO);
//如何使用拓扑图模板生成监测点模版
// List<CsLineTopologyTemplateVO> csLineTopologyTemplateVOS = csLineTopologyDiagramTemplateService.queryByTopoId(temp);
// List<CsLineTopologyTemplate> collect = csLineTopologyTemplateVOS.stream().map(temp1 -> {
// CsLineTopologyTemplate csLineTopologyTemplate = new CsLineTopologyTemplate();
// BeanUtils.copyProperties(temp1, csLineTopologyTemplate);
// csLineTopologyTemplate.setId(null);
// csLineTopologyTemplate.setStatus("1");
// csLineTopologyTemplate.setTopoId(appTopologyDiagramPO.getId());
// return csLineTopologyTemplate;
// }).collect(Collectors.toList());
// csLineTopologyTemplates.addAll(collect);
}); });
csLineTopologyDiagramTemplateService.saveBatch(csLineTopologyTemplates); csLineTopologyDiagramTemplateService.saveBatch(csLineTopologyTemplates);
} }
if(Objects.nonNull( appProjectAddOrAuditParm.getFiles ( ))){ if(Objects.nonNull( appProjectAddOrAuditParm.getFiles ( ))){
for (int i = 0; i < appProjectAddOrAuditParm.getFiles ( ).length; i++) { for (int i = 0; i < appProjectAddOrAuditParm.getFiles ( ).length; i++) {
@@ -157,13 +140,6 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
QueryWrapper<AppProjectPO> queryWrapper = new QueryWrapper ( ); QueryWrapper<AppProjectPO> queryWrapper = new QueryWrapper ( );
queryWrapper.eq ("id", appProjectAuditParm.getId ( )); queryWrapper.eq ("id", appProjectAuditParm.getId ( ));
AppProjectPO appProjectPO1 = appProjectMapper.selectOne (queryWrapper); AppProjectPO appProjectPO1 = appProjectMapper.selectOne (queryWrapper);
// if (appProjectAuditParm.getUserId ( ) != null || appProjectAuditParm.getName ( ) != null) {
// Boolean result = checkName (appProjectAuditParm.getUserId ( ) != null ? appProjectAuditParm.getUserId ( ) : appProjectPO1.getUserId ( ),
// appProjectAuditParm.getName ( ) != null ? appProjectAuditParm.getName ( ) : appProjectPO1.getName ( ));
// if (result) {
// throw new BusinessException (AlgorithmResponseEnum.PROJECT_COMMON_ERROR);
// }
// }
//删除项目 //删除项目
if(Objects.equals("0",appProjectAuditParm.getStatus())){ if(Objects.equals("0",appProjectAuditParm.getStatus())){
QueryWrapper<CsLedger> queryWrapper1 = new QueryWrapper<>(); QueryWrapper<CsLedger> queryWrapper1 = new QueryWrapper<>();
@@ -175,38 +151,26 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
this.lambdaUpdate().eq(AppProjectPO::getId,appProjectAuditParm.getId()).set(AppProjectPO::getStatus,"0").update(); this.lambdaUpdate().eq(AppProjectPO::getId,appProjectAuditParm.getId()).set(AppProjectPO::getStatus,"0").update();
appTopologyDiagramService.lambdaUpdate().eq(AppTopologyDiagramPO::getProjectId,appProjectAuditParm.getId()).set(AppTopologyDiagramPO::getStatus,"0").update(); appTopologyDiagramService.lambdaUpdate().eq(AppTopologyDiagramPO::getProjectId,appProjectAuditParm.getId()).set(AppTopologyDiagramPO::getStatus,"0").update();
CsLedger csLedger1 = new CsLedger(); CsLedger csLedger1 = new CsLedger();
csLedger1.setId(appProjectAuditParm.getId()); csLedger1.setId(appProjectAuditParm.getId());
csLedger1.setState(0); csLedger1.setState(0);
csLedger1.setState(0); csLedger1.setState(0);
csLedgerMapper.updateById(csLedger1); csLedgerMapper.updateById(csLedger1);
} }
if(checkName(appProjectAuditParm.getName(),appProjectAuditParm.getId(),appProjectAuditParm.getEngineeringId())){ if(checkName(appProjectAuditParm.getName(),appProjectAuditParm.getId(),appProjectAuditParm.getEngineeringId())){
throw new BusinessException(AlgorithmResponseEnum.PROJECT_COMMON_ERROR); throw new BusinessException(AlgorithmResponseEnum.PROJECT_COMMON_ERROR);
} }
BeanUtils.copyProperties (appProjectAuditParm, appProjectPO); BeanUtils.copyProperties (appProjectAuditParm, appProjectPO);
UpdateWrapper<AppProjectPO> updateWrapper = new UpdateWrapper ( ); UpdateWrapper<AppProjectPO> updateWrapper = new UpdateWrapper ( );
updateWrapper.eq ("id", appProjectAuditParm.getId ( )); updateWrapper.eq ("id", appProjectAuditParm.getId ( ));
int i = appProjectMapper.update (appProjectPO, updateWrapper); int i = appProjectMapper.update (appProjectPO, updateWrapper);
// Boolean result = checkName (appProjectPO.getUserId ( ), appProjectPO.getName ( ));
// if (result) {
// throw new BusinessException (AlgorithmResponseEnum.PROJECT_COMMON_ERROR);
// }
//删除拓扑图 //删除拓扑图
if(CollectionUtils.isEmpty(appProjectAuditParm.getNewTopoIds())){ if(CollectionUtils.isEmpty(appProjectAuditParm.getNewTopoIds())){
appTopologyDiagramService.lambdaUpdate().eq(AppTopologyDiagramPO::getProjectId,appProjectAuditParm.getId()).set(AppTopologyDiagramPO::getStatus,"0").update(); appTopologyDiagramService.lambdaUpdate().eq(AppTopologyDiagramPO::getProjectId,appProjectAuditParm.getId()).set(AppTopologyDiagramPO::getStatus,"0").update();
}else { }else {
appTopologyDiagramService.lambdaUpdate().eq(AppTopologyDiagramPO::getProjectId,appProjectAuditParm.getId()).notIn(AppTopologyDiagramPO::getId,appProjectAuditParm.getNewTopoIds()).set(AppTopologyDiagramPO::getStatus,"0").update(); appTopologyDiagramService.lambdaUpdate().eq(AppTopologyDiagramPO::getProjectId,appProjectAuditParm.getId()).notIn(AppTopologyDiagramPO::getId,appProjectAuditParm.getNewTopoIds()).set(AppTopologyDiagramPO::getStatus,"0").update();
} }
//如何使用拓扑图模板则将拓扑图模板复制绑定 //如何使用拓扑图模板则将拓扑图模板复制绑定
@@ -227,26 +191,11 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
appTopologyDiagramPO.setStatus ("1"); appTopologyDiagramPO.setStatus ("1");
appTopologyDiagramPO.setTopoId(temp); appTopologyDiagramPO.setTopoId(temp);
appTopologyDiagramService.save(appTopologyDiagramPO); appTopologyDiagramService.save(appTopologyDiagramPO);
//如何使用拓扑图模板生成监测点模版
// List<CsLineTopologyTemplateVO> csLineTopologyTemplateVOS = csLineTopologyDiagramTemplateService.queryByTopoId(temp);
// List<CsLineTopologyTemplate> collect = csLineTopologyTemplateVOS.stream().map(temp1 -> {
// CsLineTopologyTemplate csLineTopologyTemplate = new CsLineTopologyTemplate();
// BeanUtils.copyProperties(temp1, csLineTopologyTemplate);
// csLineTopologyTemplate.setId(null);
// csLineTopologyTemplate.setStatus("1");
// csLineTopologyTemplate.setTopoId(appTopologyDiagramPO.getId());
// return csLineTopologyTemplate;
// }).collect(Collectors.toList());
// csLineTopologyTemplates.addAll(collect);
}); });
csLineTopologyDiagramTemplateService.saveBatch(csLineTopologyTemplates); csLineTopologyDiagramTemplateService.saveBatch(csLineTopologyTemplates);
} }
if(Objects.nonNull( appProjectAuditParm.getFiles ( ))){ if(Objects.nonNull( appProjectAuditParm.getFiles ( ))){
for (int k = 0; k < appProjectAuditParm.getFiles ( ).length; k++) { for (int k = 0; k < appProjectAuditParm.getFiles ( ).length; k++) {
AppTopologyDiagramAddParm appTopologyDiagramAddParm = new AppTopologyDiagramAddParm ( ); AppTopologyDiagramAddParm appTopologyDiagramAddParm = new AppTopologyDiagramAddParm ( );
appTopologyDiagramAddParm.setProjectId (appProjectPO.getId ( )); appTopologyDiagramAddParm.setProjectId (appProjectPO.getId ( ));
appTopologyDiagramAddParm.setTopologyDiagramName (appProjectAuditParm.getFiles ( )[k].getOriginalFilename ( )); appTopologyDiagramAddParm.setTopologyDiagramName (appProjectAuditParm.getFiles ( )[k].getOriginalFilename ( ));
@@ -255,10 +204,8 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
} }
} }
CsLedger csLedger2 = new CsLedger(); CsLedger csLedger2 = new CsLedger();
csLedger2.setId(appProjectAuditParm.getId()); csLedger2.setId(appProjectAuditParm.getId());
if(StringUtils.isNotBlank(appProjectAuditParm.getName())){ if(StringUtils.isNotBlank(appProjectAuditParm.getName())){
csLedger2.setName(appProjectAuditParm.getName()); csLedger2.setName(appProjectAuditParm.getName());
} }
@@ -403,5 +350,12 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
return this.update(queryWrapper); return this.update(queryWrapper);
} }
@Override
public AppProjectPO getProjectByName(String name) {
LambdaQueryWrapper<AppProjectPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AppProjectPO::getName,name).eq(AppProjectPO::getStatus,1);
return this.getOne(queryWrapper);
}
} }

View File

@@ -5,21 +5,23 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.csdevice.mapper.CsLinePOMapper; import com.njcn.csdevice.mapper.CsLinePOMapper;
import com.njcn.csdevice.mapper.PqsDeviceUnitMapper; import com.njcn.csdevice.mapper.PqsDeviceUnitMapper;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO; import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.service.CsCommTerminalService; import com.njcn.csdevice.pojo.vo.CsMarketDataVO;
import com.njcn.csdevice.service.CsDeviceUserPOService; import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
import com.njcn.csdevice.service.CsEquipmentDeliveryService; import com.njcn.csdevice.service.*;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit; import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.user.api.UserFeignClient; import com.njcn.user.api.UserFeignClient;
import com.njcn.user.enums.AppRoleEnum;
import com.njcn.user.pojo.constant.UserType; import com.njcn.user.pojo.constant.UserType;
import com.njcn.user.pojo.vo.UserVO; import com.njcn.user.pojo.vo.UserVO;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -38,6 +40,9 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
private final CsLinePOMapper csLinePOMapper; private final CsLinePOMapper csLinePOMapper;
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final CsEquipmentDeliveryService csEquipmentDeliveryService; private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final CsMarketDataService csMarketDataService;
private final ICsLedgerService csLedgerService;
private final CsTouristDataPOService csTouristDataPOService;
@Override @Override
@@ -88,15 +93,37 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
@Override @Override
public List<String> commGetDevIds(String userId) { public List<String> commGetDevIds(String userId) {
UserVO userVO = userFeignClient.getUserById(userId).getData(); UserVO userVO = userFeignClient.getUserById(userId).getData();
List<String> devIds; List<String> devIds = new ArrayList<>();
if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) { if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) {
devIds = csEquipmentDeliveryService.getAll().stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList()); devIds = csEquipmentDeliveryService.getAll().stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
} else { } else {
//note 黄是在cs_market_data写入数据是用户和工程的关系
// 但是权限根据用户和设备来判断会有问题,还需要用户和工程的关系(针对营销 工程用户),所以这边还要添加用户和工程的关系。
// 如果是营销 工程用户 没有配置相关工程,直接返回空的设备列表;如果有数据,也要判断下当前关注的工程里面是否包含主用户的设备,可能出现没有关注该工程,但是因为是设备的主用户导致数据统计错误
String roleString = RequestUtil.getUserRole();
if (roleString.contains(AppRoleEnum.MARKET_USER.getCode()) || roleString.contains(AppRoleEnum.ENGINEERING_USER.getCode())) {
List<CsMarketDataVO> list = csMarketDataService.queryByUseId(userId);
if (CollUtil.isNotEmpty(list)) {
List<String> engineerIds = list.stream().map(CsMarketDataVO::getEngineerId).distinct().collect(Collectors.toList());
List<DevDetailDTO> devs = csLedgerService.getDevInfoByEngineerIds(engineerIds);
devIds = devs.stream().map(DevDetailDTO::getEquipmentId).distinct().collect(Collectors.toList());
}
}
//note 如果是游客,则还需要加入系统配置的设备
else if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
devIds.addAll(csTouristDataPOService.queryAll().stream().map(CsTouristDataParmVO::getDeviceId).distinct().collect(Collectors.toList()));
}
//note 如果是普通用户,则需要根据用户权限来获取设备列表
else {
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId) List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
.and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId)) .and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId))
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list(); .eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList()); devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
} }
}
if (!CollUtil.isEmpty(devIds)) {
devIds = devIds.stream().distinct().collect(Collectors.toList());
}
return devIds; return devIds;
} }
} }

View File

@@ -4,38 +4,38 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper; import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper; import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
import com.njcn.csdevice.mapper.CsMarketDataMapper; import com.njcn.csdevice.mapper.CsMarketDataMapper;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.param.UserDevParam; import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.*; import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CsLedgerVO; import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
import com.njcn.csdevice.pojo.vo.DevCountVO; import com.njcn.csdevice.pojo.vo.DevCountVO;
import com.njcn.csdevice.pojo.vo.DevUserVO; import com.njcn.csdevice.pojo.vo.DevUserVO;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
import com.njcn.csharmonic.api.EventUserFeignClient; import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.harmonic.utils.PublicDataUtils;
import com.njcn.cssystem.api.FeedBackFeignClient;
import com.njcn.cssystem.pojo.param.CsFeedbackQueryParm;
import com.njcn.cssystem.pojo.vo.CsFeedbackVO;
import com.njcn.user.api.UserFeignClient; import com.njcn.user.api.UserFeignClient;
import com.njcn.user.enums.AppRoleEnum; import com.njcn.user.enums.AppRoleEnum;
import com.njcn.user.pojo.po.User; import com.njcn.user.pojo.po.User;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.util.Objects.isNull; import static java.util.Objects.isNull;
@@ -55,14 +55,12 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
private final CsDevModelRelationService csDevModelRelationService; private final CsDevModelRelationService csDevModelRelationService;
private final ICsLedgerService iCsLedgerService; private final ICsLedgerService iCsLedgerService;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper; private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final RoleEngineerDevService roleEngineerDevService;
private final AppLineTopologyDiagramService appLineTopologyDiagramService; private final AppLineTopologyDiagramService appLineTopologyDiagramService;
private final CsTouristDataPOService csTouristDataPOService; private final CsTouristDataPOService csTouristDataPOService;
private final CsLinePOService csLinePOService; private final CsLinePOService csLinePOService;
private final CsMarketDataMapper csMarketDataMapper; private final CsMarketDataMapper csMarketDataMapper;
private final EventUserFeignClient eventUserFeignClient; private final EventUserFeignClient eventUserFeignClient;
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final FeedBackFeignClient feedBackFeignClient;
private final IMqttUserService mqttUserService; private final IMqttUserService mqttUserService;
@Override @Override
@@ -122,114 +120,202 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
} }
@Override @Override
public DevCountVO devCount(String id) { public DevCountVO devCount(String id,String time) {
QueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new QueryWrapper<>(); DevCountVO vo = new DevCountVO();
//获取app用户的台账树包含四个层级 工程、项目、设备、监测点
DevCountVO devCountVO = new DevCountVO(); List<CsLedgerVO> appLedger = iCsLedgerService.appLineTree();
//判断当前用户,如果是游客,则需要筛选数据,只保留游客的数据
String userRole = RequestUtil.getUserRole(); String roleString = RequestUtil.getUserRole();
List<String> strings = JSONArray.parseArray(userRole, String.class); if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
if(CollectionUtils.isEmpty(strings)){ List<CsTouristDataParmVO> csTouristDataParmVOList = csTouristDataPOService.queryAll();
throw new BusinessException(AlgorithmResponseEnum.UNKNOW_ROLE); if (CollectionUtil.isNotEmpty(csTouristDataParmVOList)) {
List<String> devList = csTouristDataParmVOList.stream().map(CsTouristDataParmVO::getDeviceId).collect(Collectors.toList());
// 保留游客有权限的工程、项目、设备、监测点数据
appLedger = appLedger.stream()
.filter(engineering -> {
boolean hasValidProject = false;
if (CollectionUtil.isNotEmpty(engineering.getChildren())) {
List<CsLedgerVO> validProjects = engineering.getChildren().stream()
.filter(project -> {
boolean hasValidDevice = false;
if (CollectionUtil.isNotEmpty(project.getChildren())) {
List<CsLedgerVO> validDevices = project.getChildren().stream()
.filter(device -> devList.contains(device.getId()))
.collect(Collectors.toList());
project.setChildren(validDevices);
hasValidDevice = CollectionUtil.isNotEmpty(validDevices);
} }
userRole=strings.get(0); return hasValidDevice;
})
List<String> device = roleEngineerDevService.getDevice(); .collect(Collectors.toList());
if(CollectionUtils.isEmpty(device)){ engineering.setChildren(validProjects);
devCountVO.setOnLineDevCount(0); hasValidProject = CollectionUtil.isNotEmpty(validProjects);
devCountVO.setOnLineDevs(new ArrayList<>()); }
devCountVO.setOffLineDevCount(0); return hasValidProject;
devCountVO.setOffLineDevs(new ArrayList<>()); })
.collect(Collectors.toList());
} else { } else {
queryWrapper.clear(); // 如果游客没有配置任何数据权限,返回空列表
queryWrapper.in("id",device); appLedger = new ArrayList<>();
}
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectList(queryWrapper);
List<CsEquipmentDeliveryPO> collect = csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 1).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> collect2= csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 2).collect(Collectors.toList());
devCountVO.setOnLineDevCount(collect2.size());
devCountVO.setOnLineDevs(collect2);
devCountVO.setOffLineDevCount(collect.size());
devCountVO.setOffLineDevs(collect);
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
devCountVO.setEningerCount(roleengineer.size());
} }
List<CsLedgerVO> deviceTree = iCsLedgerService.getDeviceTree(); if (CollectionUtil.isNotEmpty(appLedger)) {
//由于多加了一程便携式设备 //获取第一层项目层级
List<String> collect1 = deviceTree.stream() List<CsLedgerVO> firstLevelList = new ArrayList<>();
.map(CsLedgerVO::getChildren).flatMap(Collection::stream) //获取第三层设备层级
.filter(temp -> temp.getId().equals(id)) List<CsLedgerVO> thirdLevelList = new ArrayList<>();
.map(CsLedgerVO::getChildren).flatMap(Collection::stream) //获取第四层设备层级
.map(CsLedgerVO::getChildren).flatMap(Collection::stream) List<CsLedgerVO> forthLevelList = new ArrayList<>();
.map(CsLedgerVO::getId).collect(Collectors.toList()); for (CsLedgerVO firstLevel : appLedger) {
//求交集 firstLevelList.add(firstLevel);
device.retainAll(collect1); if (CollectionUtil.isNotEmpty(firstLevel.getChildren())) {
if(CollectionUtils.isEmpty(device)){ for (CsLedgerVO secondLevel : firstLevel.getChildren()) {
devCountVO.setCurrentOnLineDevCount(0); if (CollectionUtil.isNotEmpty(secondLevel.getChildren())) {
devCountVO.setCurrentOnLineDevs(new ArrayList<>()); thirdLevelList.addAll(secondLevel.getChildren());
devCountVO.setCurrentOffLineDevCount(0); for (CsLedgerVO threeLevel : secondLevel.getChildren()) {
devCountVO.setCurrentOffLineDevs(new ArrayList<>()); if (CollectionUtil.isNotEmpty(threeLevel.getChildren())) {
devCountVO.setCurrentProjectCount(0); forthLevelList.addAll(threeLevel.getChildren());
}
}
}
}
}
}
//note 所有工程数据
//获取工程数量
if (CollectionUtil.isNotEmpty(firstLevelList)) {
vo.setEningerCount(firstLevelList.size());
}
//获取设备总数、在线设备、离线设备
if (CollectionUtil.isNotEmpty(thirdLevelList)) {
List<String> devIds = thirdLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryMapper.selectBatchIds(devIds);
//在线设备
List<CsEquipmentDeliveryPO> onlineDevs = devList.stream().filter(dev -> Objects.equals(dev.getRunStatus(), 2)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(onlineDevs)) {
vo.setOnLineDevCount(onlineDevs.size());
vo.setOnLineDevs(onlineDevs);
}
//离线设备
List<CsEquipmentDeliveryPO> offlineDevs = devList.stream().filter(dev -> Objects.equals(dev.getRunStatus(), 1)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(offlineDevs)) {
vo.setOffLineDevCount(offlineDevs.size());
vo.setOffLineDevs(offlineDevs);
}
} else { } else {
queryWrapper.clear(); return vo;
queryWrapper.in("id",device);
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectList(queryWrapper);
List<CsEquipmentDeliveryPO> collect = csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 1).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> collect2= csEquipmentDeliveryPOS.stream().filter(temp -> temp.getRunStatus() == 2).collect(Collectors.toList());
devCountVO.setCurrentOnLineDevCount(collect2.size());
devCountVO.setCurrentOnLineDevs(collect2);
devCountVO.setCurrentOffLineDevCount(collect.size());
devCountVO.setCurrentOffLineDevs(collect);
List<CsLedger> list = iCsLedgerService.lambdaQuery().eq(CsLedger::getPid, id).eq(CsLedger::getState, 1).list();
devCountVO.setCurrentProjectCount(list.size());
} }
CsEventUserQueryParam csEventUserQueryParam = new CsEventUserQueryParam(); //获取未读事件数量
csEventUserQueryParam.setStatus("0"); if (CollectionUtil.isNotEmpty(forthLevelList)) {
List<EventDetailVO> data = eventUserFeignClient.queryEventList(csEventUserQueryParam).getData(); CsEventUserQueryParam param1 = new CsEventUserQueryParam();
List<EventDetailVO> event = data.stream().filter(temp -> temp.getType() == 0).collect(Collectors.toList()); param1.setUserId(RequestUtil.getUserIndex());
List<EventDetailVO> harmonic = data.stream().filter(temp -> temp.getType() == 1).collect(Collectors.toList()); param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
List<EventDetailVO> alarm = data.stream().filter(temp -> temp.getType() == 3).collect(Collectors.toList()); param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(forthLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
if(Objects.equals(userRole, AppRoleEnum.APP_VIP_USER.getCode())){ List<String> eventCount = eventUserFeignClient.queryTempEvent(param1).getData();
alarm = alarm.stream().filter(temp -> Objects.equals("3", temp.getLevel())).collect(Collectors.toList()); vo.setEventCount(CollectionUtil.isNotEmpty(eventCount)?eventCount.size():0);
List<String> harmonicCount = eventUserFeignClient.queryTempHarmonic(param1).getData();
vo.setHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount)?harmonicCount.size():0);
} }
List<EventDetailVO> run = data.stream().filter(temp -> temp.getType() == 2).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(thirdLevelList)) {
if(Objects.equals(userRole,AppRoleEnum.APP_VIP_USER.getCode())||Objects.equals(userRole,AppRoleEnum.TOURIST.getCode()) CsEventUserQueryParam param1 = new CsEventUserQueryParam();
||Objects.equals(userRole,AppRoleEnum.MARKET_USER.getCode())){ param1.setUserId(RequestUtil.getUserIndex());
devCountVO.setFeedBackCount(0); param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(thirdLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
}else { List<String> alarmCount = eventUserFeignClient.queryAlarmEvent(param1).getData();
CsFeedbackQueryParm csFeedbackQueryParm = new CsFeedbackQueryParm(); vo.setAlarmCount(CollectionUtil.isNotEmpty(alarmCount)?alarmCount.size():0);
csFeedbackQueryParm.setPageNum(1); List<String> runCount = eventUserFeignClient.queryRunEvent(param1).getData();
csFeedbackQueryParm.setPageSize(100000); vo.setRunCount(CollectionUtil.isNotEmpty(runCount)?runCount.size():0);
csFeedbackQueryParm.setStatus("1");
Page<CsFeedbackVO> data1 = feedBackFeignClient.queryFeedBackPage(csFeedbackQueryParm).getData();
List<CsFeedbackVO> collect = data1.getRecords().stream().filter(temp -> !Objects.equals(temp.getUserId(), RequestUtil.getUserIndex())).collect(Collectors.toList());
devCountVO.setFeedBackCount(collect.size());
} }
//todo 后续添加警告数,事件数 //note 当前工程数据
devCountVO.setEventCount(event.size()); //当前工程id
devCountVO.setAlarmCount(alarm.size()); vo.setCurrentId(id);
devCountVO.setRunCount(run.size()); //设备集合
devCountVO.setHarmonicCount(harmonic.size()); List<String> currentDevIds = new ArrayList<>();
List<EventDetailVO> curEvent = event.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); //监测点集合
List<EventDetailVO> curHarmonic = harmonic.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); List<String> currentLineIds = new ArrayList<>();
List<EventDetailVO> curAlarm = alarm.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); //获取第一层项目层级
List<EventDetailVO> curRun = run.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); List<CsLedgerVO> currentProjectIds = new ArrayList<>();
// 遍历树结构,找到匹配的工程节点
devCountVO.setCurrentEventCount(curEvent.size()); for (CsLedgerVO engineering : appLedger) {
devCountVO.setCurrentAlarmCount(curAlarm.size()); if (id.equals(engineering.getId())) {
devCountVO.setCurrentRunCount(curRun.size()); // 找到工程节点,获取其子节点(项目层级)
devCountVO.setCurrentHarmonicCount(curHarmonic.size()); if (CollectionUtil.isNotEmpty(engineering.getChildren())) {
for (CsLedgerVO project : engineering.getChildren()) {
currentProjectIds.add(project);
return devCountVO; // 获取项目下的设备层级
if (CollectionUtil.isNotEmpty(project.getChildren())) {
currentDevIds.addAll(project.getChildren().stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
// 获取设备下的监测点层级
for (CsLedgerVO device : project.getChildren()) {
if (CollectionUtil.isNotEmpty(device.getChildren())) {
currentLineIds.addAll(device.getChildren().stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
} }
}
}
}
}
break;
}
}
//获取项目数量
if (CollectionUtil.isNotEmpty(currentProjectIds)) {
vo.setCurrentProjectCount(currentProjectIds.size());
}
//获取设备总数、在线设备、离线设备
if (CollectionUtil.isNotEmpty(currentDevIds)) {
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryMapper.selectBatchIds(currentDevIds);
//在线设备
List<CsEquipmentDeliveryPO> onlineDevs = devList.stream().filter(dev -> Objects.equals(dev.getRunStatus(), 2)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(onlineDevs)) {
vo.setCurrentOnLineDevCount(onlineDevs.size());
vo.setCurrentOnLineDevs(onlineDevs);
}
//离线设备
List<CsEquipmentDeliveryPO> offlineDevs = devList.stream().filter(dev -> Objects.equals(dev.getRunStatus(), 1)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(offlineDevs)) {
vo.setCurrentOffLineDevCount(offlineDevs.size());
vo.setCurrentOffLineDevs(offlineDevs);
}
}
//获取未读事件数量
if (CollectionUtil.isNotEmpty(currentLineIds)) {
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(currentLineIds);
List<String> eventCount2 = eventUserFeignClient.queryTempEvent(param1).getData();
vo.setCurrentEventCount(CollectionUtil.isNotEmpty(eventCount2)?eventCount2.size():0);
List<String> harmonicCount2 = eventUserFeignClient.queryTempHarmonic(param1).getData();
vo.setCurrentHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount2)?harmonicCount2.size():0);
}
if (CollectionUtil.isNotEmpty(currentDevIds)) {
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(currentDevIds);
List<String> alarmCount2 = eventUserFeignClient.queryAlarmEvent(param1).getData();
vo.setCurrentAlarmCount(CollectionUtil.isNotEmpty(alarmCount2)?alarmCount2.size():0);
List<String> runCount2 = eventUserFeignClient.queryRunEvent(param1).getData();
vo.setCurrentRunCount(CollectionUtil.isNotEmpty(runCount2)?runCount2.size():0);
}
}
return vo;
}
/** /**
* @Description: 判断当前用户是否是主用户 0-否1-是 * @Description: 判断当前用户是否是主用户 0-否1-是
* @Param: * @Param:
@@ -377,16 +463,16 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
@Override @Override
public DevUserVO queryUserById(String devId) { public DevUserVO queryUserById(String devId) {
DevUserVO devUser = new DevUserVO();
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, devId).eq(CsDeviceUserPO::getStatus, "1").list(); List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, devId).eq(CsDeviceUserPO::getStatus, "1").list();
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
throw new BusinessException(AlgorithmResponseEnum.DATA_ARRAY_MISSING); return devUser;
} }
List<String> collect = list.stream().map(CsDeviceUserPO::getSubUserId).distinct().collect(Collectors.toList()); List<String> collect = list.stream().map(CsDeviceUserPO::getSubUserId).distinct().collect(Collectors.toList());
List<User> data = userFeignClient.appuserByIdList(collect).getData(); List<User> data = userFeignClient.appuserByIdList(collect).getData();
String primaryUserId = list.get(0).getPrimaryUserId(); String primaryUserId = list.get(0).getPrimaryUserId();
List<User> subUser = data.stream().filter(temp -> !Objects.equals(temp.getId(), primaryUserId)).collect(Collectors.toList()); List<User> subUser = data.stream().filter(temp -> !Objects.equals(temp.getId(), primaryUserId)).collect(Collectors.toList());
List<User> primaryUser = data.stream().filter(temp -> Objects.equals(temp.getId(), primaryUserId)).collect(Collectors.toList()); List<User> primaryUser = data.stream().filter(temp -> Objects.equals(temp.getId(), primaryUserId)).collect(Collectors.toList());
DevUserVO devUser = new DevUserVO();
devUser.setDevId(devId); devUser.setDevId(devId);
devUser.setSubUsers(subUser); devUser.setSubUsers(subUser);
devUser.setMasterUser(primaryUser.get(0)); devUser.setMasterUser(primaryUser.get(0));
@@ -400,13 +486,33 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
if (CollectionUtil.isNotEmpty(list)){ if (CollectionUtil.isNotEmpty(list)){
result = list.stream().map(CsDeviceUserPO::getSubUserId).collect(Collectors.toList()); result = list.stream().map(CsDeviceUserPO::getSubUserId).collect(Collectors.toList());
} }
//获取关注设备的用户(工程用户、营销用户)
List<DevDetailDTO> ledger = iCsLedgerService.getInfoByIds(Collections.singletonList(devId));
if (CollectionUtil.isNotEmpty(ledger)) {
DevDetailDTO item = ledger.get(0);
LambdaQueryWrapper<CsMarketData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsMarketData::getEngineerId, item.getEngineeringid());
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(queryWrapper);
if (CollectionUtil.isNotEmpty(csMarketData)) {
List<String> collect = csMarketData.stream().map(CsMarketData::getUserId).collect(Collectors.toList());
result.addAll(collect);
}
}
if (CollectionUtil.isNotEmpty(result)) {
result = result.stream().distinct().collect(Collectors.toList());
}
return result; return result;
} }
@Override @Override
public List<String> findDevByUserId(String userId) { public List<String> findDevByUserId(String userId) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getPrimaryUserId,userId).list(); LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.and(wrapper ->
wrapper.eq(CsDeviceUserPO::getPrimaryUserId, userId)
.or()
.eq(CsDeviceUserPO::getSubUserId, userId));
List<CsDeviceUserPO> list = this.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)){ if (CollectionUtil.isNotEmpty(list)){
result = list.stream().map(CsDeviceUserPO::getDeviceId).collect(Collectors.toList()); result = list.stream().map(CsDeviceUserPO::getDeviceId).collect(Collectors.toList());
} }
@@ -416,8 +522,83 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
@Override @Override
public void channelDevByUserId(UserDevParam param) { public void channelDevByUserId(UserDevParam param) {
LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsDeviceUserPO::getPrimaryUserId,param.getUserId()) queryWrapper.and(wrapper ->
.in(CsDeviceUserPO::getDeviceId,param.getList()); wrapper.eq(CsDeviceUserPO::getPrimaryUserId, param.getUserId())
.or()
.eq(CsDeviceUserPO::getSubUserId, param.getUserId())
).in(CsDeviceUserPO::getDeviceId, param.getList());
this.remove(queryWrapper); this.remove(queryWrapper);
} }
@Override
public List<CsDeviceUserPO> getList(UserDevParam param) {
LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(param.getUserId())) {
queryWrapper.and(wrapper ->
wrapper.eq(CsDeviceUserPO::getPrimaryUserId, param.getUserId())
.or()
.eq(CsDeviceUserPO::getSubUserId, param.getUserId())
);
}
if (CollectionUtil.isNotEmpty(param.getList())) {
queryWrapper.in(CsDeviceUserPO::getDeviceId, param.getList());
}
queryWrapper.eq(CsDeviceUserPO::getStatus, "1");
return this.list(queryWrapper);
}
/**
*
* @param userId 这边放设备id
* @param list 这边放用户id集合
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addRelation(UserDevParam param) {
String userIndex;
CsDeviceUserPO existingRecord = this.lambdaQuery()
.eq(CsDeviceUserPO::getDeviceId, param.getUserId())
.one();
if (existingRecord != null && Objects.equals(existingRecord.getPrimaryUserId(), existingRecord.getSubUserId())) {
userIndex = existingRecord.getPrimaryUserId();
} else {
userIndex = RequestUtil.getUserIndex();
if (userIndex == null) {
throw new IllegalArgumentException("当前用户信息获取失败");
}
CsDeviceUserPO mainDeviceRelation = new CsDeviceUserPO();
mainDeviceRelation.setDeviceId(param.getUserId());
mainDeviceRelation.setPrimaryUserId(userIndex);
mainDeviceRelation.setSubUserId(userIndex);
mainDeviceRelation.setStatus("1");
boolean mainSaveSuccess = this.save(mainDeviceRelation);
if (!mainSaveSuccess) {
return false;
}
}
if (CollectionUtil.isNotEmpty(param.getList())) {
List<CsDeviceUserPO> batchRecords = param.getList().stream()
.filter(Objects::nonNull)
.filter(item -> !Objects.equals(item, userIndex))
.map(item -> {
CsDeviceUserPO relation = new CsDeviceUserPO();
relation.setDeviceId(param.getUserId());
relation.setPrimaryUserId(userIndex);
relation.setSubUserId(item);
relation.setStatus("1");
return relation;
})
.collect(Collectors.toList());
if (!batchRecords.isEmpty()) {
return this.saveBatch(batchRecords);
}
}
return true;
}
} }

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.service.impl; package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -42,7 +43,9 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
public boolean addEdData(CsEdDataAddParm csEdDataAddParm) { public boolean addEdData(CsEdDataAddParm csEdDataAddParm) {
CsEdDataPO csEdDataPO = new CsEdDataPO(); CsEdDataPO csEdDataPO = new CsEdDataPO();
BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO); BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO);
String filePath = fileStorageUtil.uploadMultipart (csEdDataAddParm.getFile (), OssPath.EDDATA); String remoteDir = StrUtil.SLASH + OssPath.EDDATA + csEdDataAddParm.getDevTypeName() + StrUtil.SLASH + csEdDataAddParm.getVersionNo() + StrUtil.SLASH;
String filePath = fileStorageUtil.uploadMultipart(csEdDataAddParm.getFile(), remoteDir, true);
csEdDataPO.setCrc(csEdDataAddParm.getCrcInfo());
csEdDataPO.setFilePath(filePath); csEdDataPO.setFilePath(filePath);
csEdDataPO.setStatus("1"); csEdDataPO.setStatus("1");
boolean save = this.save(csEdDataPO); boolean save = this.save(csEdDataPO);
@@ -55,7 +58,7 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
CsEdDataPO csEdDataPO = new CsEdDataPO(); CsEdDataPO csEdDataPO = new CsEdDataPO();
BeanUtils.copyProperties(csEdDataAuditParm, csEdDataPO); BeanUtils.copyProperties(csEdDataAuditParm, csEdDataPO);
if (!Objects.isNull(csEdDataAuditParm.getFile())) { if (!Objects.isNull(csEdDataAuditParm.getFile())) {
String filePath = fileStorageUtil.uploadMultipart (csEdDataAuditParm.getFile (), OssPath.EDDATA); String filePath = fileStorageUtil.uploadMultipart(csEdDataAuditParm.getFile(), StrUtil.SLASH + OssPath.EDDATA + csEdDataAuditParm.getDevTypeName() + StrUtil.SLASH + csEdDataAuditParm.getVersionNo() + StrUtil.SLASH, true);
csEdDataPO.setFilePath(filePath); csEdDataPO.setFilePath(filePath);
} }
boolean b = this.updateById(csEdDataPO); boolean b = this.updateById(csEdDataPO);
@@ -84,5 +87,11 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
BeanUtils.copyProperties(csEdDataPo, csEdDataVo); BeanUtils.copyProperties(csEdDataPo, csEdDataVo);
return csEdDataVo; return csEdDataVo;
} }
public CsEdDataPO findByDevTypeIdAndVersionNo(String devTypeId, String versionNo) {
return this.lambdaQuery().eq(CsEdDataPO::getDevType, devTypeId)
.eq(CsEdDataPO::getVersionNo, versionNo)
.eq(CsEdDataPO::getStatus, 1).one();
}
} }

View File

@@ -84,7 +84,7 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
csLedger1.setLevel(0); csLedger1.setLevel(0);
csLedger1.setName(csEngineeringPO.getName()); csLedger1.setName(csEngineeringPO.getName());
csLedger1.setState(1); csLedger1.setState(1);
csLedger1.setSort(0); csLedger1.setSort(csEngineeringAddParm.getSort());
csLedgerMapper.insert(csLedger1); csLedgerMapper.insert(csLedger1);
//绑定用户 //绑定用户
CsEngineeringUserPO po = new CsEngineeringUserPO(); CsEngineeringUserPO po = new CsEngineeringUserPO();
@@ -164,8 +164,9 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryParm.getProvince ()),"province",csEngineeringQueryParm.getProvince ()). queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryParm.getProvince ()),"province",csEngineeringQueryParm.getProvince ()).
eq (StringUtils.isNotBlank (csEngineeringQueryParm.getCity ()),"city",csEngineeringQueryParm.getCity ()). eq (StringUtils.isNotBlank (csEngineeringQueryParm.getCity ()),"city",csEngineeringQueryParm.getCity ()).
eq ("status","1" ). eq ("status","1" )
like (StringUtils.isNotBlank (csEngineeringQueryParm.getName ()),"name",csEngineeringQueryParm.getName ()).orderByDesc("create_time"); .ne("name","便携式工程").
like (StringUtils.isNotBlank (csEngineeringQueryParm.getName ()),"name",csEngineeringQueryParm.getName ()).orderByAsc("sort");
List<CsEngineeringPO> csEngineeringPOS = this.getBaseMapper ( ).selectList (queryWrapper); List<CsEngineeringPO> csEngineeringPOS = this.getBaseMapper ( ).selectList (queryWrapper);
csEngineeringVOList = csEngineeringPOS.stream ().map (temp->{ csEngineeringVOList = csEngineeringPOS.stream ().map (temp->{
CsEngineeringVO vo = new CsEngineeringVO(); CsEngineeringVO vo = new CsEngineeringVO();
@@ -196,6 +197,7 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getProvince ()),"province",csEngineeringQueryPageParm.getProvince ()). queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getProvince ()),"province",csEngineeringQueryPageParm.getProvince ()).
eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getCity ()),"city",csEngineeringQueryPageParm.getCity ()). eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getCity ()),"city",csEngineeringQueryPageParm.getCity ()).
eq ("status","1" ). eq ("status","1" ).
ne("name","便携式工程").
like (StringUtils.isNotBlank (csEngineeringQueryPageParm.getName ()),"name",csEngineeringQueryPageParm.getName ()).orderByDesc("create_time"); like (StringUtils.isNotBlank (csEngineeringQueryPageParm.getName ()),"name",csEngineeringQueryPageParm.getName ()).orderByDesc("create_time");
Page<CsEngineeringPO> csEngineeringPOPage = this.getBaseMapper ( ).selectPage (tempPage, queryWrapper); Page<CsEngineeringPO> csEngineeringPOPage = this.getBaseMapper ( ).selectPage (tempPage, queryWrapper);
List<CsEngineeringVO> collect = csEngineeringPOPage.getRecords ( ).stream ( ).map (temp -> { List<CsEngineeringVO> collect = csEngineeringPOPage.getRecords ( ).stream ( ).map (temp -> {
@@ -253,7 +255,9 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
CsEngineeringPO po = new CsEngineeringPO(); CsEngineeringPO po = new CsEngineeringPO();
po.setId(item.getEngineeringid()); po.setId(item.getEngineeringid());
po.setName(map.get(item.getEngineeringid()).getName()); po.setName(map.get(item.getEngineeringid()).getName());
if (!Objects.equals(po.getName(), "便携式工程")) {
result.add(po); result.add(po);
}
}); });
} }
} }
@@ -297,6 +301,12 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
return this.update(queryWrapper); return this.update(queryWrapper);
} }
@Override
public CsEngineeringPO getEngineeringByName(String name) {
LambdaQueryWrapper<CsEngineeringPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsEngineeringPO::getName,name).eq(CsEngineeringPO::getStatus,1);
return this.getOne(queryWrapper);
}
public String getAreaById(String id){ public String getAreaById(String id){

View File

@@ -5,14 +5,17 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.text.StrPool; import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -23,6 +26,7 @@ import com.njcn.access.api.AskDeviceDataFeignClient;
import com.njcn.access.utils.MqttUtil; import com.njcn.access.utils.MqttUtil;
import com.njcn.common.pojo.dto.DeviceLogDTO; import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsLogsFeignClient; import com.njcn.csdevice.api.CsLogsFeignClient;
import com.njcn.csdevice.constant.DataParam; import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.enums.AlgorithmResponseEnum;
@@ -30,16 +34,22 @@ import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
import com.njcn.csdevice.mapper.CsLedgerMapper; import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.mapper.CsSoftInfoMapper; import com.njcn.csdevice.mapper.CsSoftInfoMapper;
import com.njcn.csdevice.mapper.CsTerminalLogsMapper; import com.njcn.csdevice.mapper.CsTerminalLogsMapper;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto; import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.csdevice.pojo.param.*; import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.*; import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO; import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO; import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
import com.njcn.csdevice.util.QRCodeUtil; import com.njcn.csdevice.util.QRCodeUtil;
import com.njcn.csdevice.utils.ExcelStyleUtil; import com.njcn.csdevice.utils.ExcelStyleUtil;
import com.njcn.csdevice.utils.StringUtil; import com.njcn.csdevice.utils.StringUtil;
import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.device.biz.mapper.OverLimitWlMapper;
import com.njcn.oss.constant.OssPath; import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.redis.pojo.enums.AppRedisKey; import com.njcn.redis.pojo.enums.AppRedisKey;
@@ -48,10 +58,12 @@ import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.enums.DicTreeEnum;
import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO; import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.enums.AppRoleEnum; import com.njcn.user.enums.AppRoleEnum;
import com.njcn.user.pojo.po.User;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@@ -68,12 +80,13 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
*
* Description: * Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html * 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/3/30 16:23【需求编号】 * Date: 2023/3/30 16:23【需求编号】
@@ -99,7 +112,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final AskDeviceDataFeignClient askDeviceDataFeignClient; private final AskDeviceDataFeignClient askDeviceDataFeignClient;
private final RedisUtil redisUtil; private final RedisUtil redisUtil;
private final CsSoftInfoMapper csSoftInfoMapper; private final CsSoftInfoMapper csSoftInfoMapper;
private final IMqttUserService mqttUserService;
private final MqttUtil mqttUtil; private final MqttUtil mqttUtil;
private final CsLogsFeignClient csLogsFeignClient; private final CsLogsFeignClient csLogsFeignClient;
private final INodeService nodeService; private final INodeService nodeService;
@@ -107,6 +119,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final CsLedgerMapper csLedgerMapper; private final CsLedgerMapper csLedgerMapper;
private final CsTerminalLogsMapper csTerminalLogsMapper; private final CsTerminalLogsMapper csTerminalLogsMapper;
private final ICsCommunicateService csCommunicateService; private final ICsCommunicateService csCommunicateService;
private final ICsUserPinsService csUserPinsService;
private final CsEngineeringService csEngineeringService;
private final AppProjectService appProjectService;
private final CsEdDataService csEdDataService;
private final ICsSoftInfoService csSoftInfoService;
private final EventUserFeignClient eventUserFeignClient;
private final UserFeignClient userFeignClient;
private final OverLimitWlMapper overLimitWlMapper;
private final CsLedgerFeignClient csLedgerFeignClient;
@Override @Override
public void refreshDeviceDataCache() { public void refreshDeviceDataCache() {
@@ -120,11 +141,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) { public CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
boolean result; boolean result;
List<CsEquipmentDeliveryPO> one = this.lambdaQuery() List<CsEquipmentDeliveryPO> one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT").list();
.eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
.list();
if (CollUtil.isNotEmpty(one)) { if (CollUtil.isNotEmpty(one)) {
throw new BusinessException("设备名称不能重复"); throw new BusinessException("设备名称不能重复");
} }
@@ -138,12 +155,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentDeliveryPo.setStatus(1); csEquipmentDeliveryPo.setStatus(1);
csEquipmentDeliveryPo.setRunStatus(1); csEquipmentDeliveryPo.setRunStatus(1);
csEquipmentDeliveryPo.setUsageStatus(1); csEquipmentDeliveryPo.setUsageStatus(1);
String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode(); // String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode();
if (Objects.equals(DicDataEnum.PORTABLE.getCode(),code)) { // if (Objects.equals(DicDataEnum.PORTABLE.getCode(),code)) {
// csEquipmentDeliveryPo.setProcess(4);
// } else if (Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),code)) {
// csEquipmentDeliveryPo.setProcess(2);
// }
csEquipmentDeliveryPo.setProcess(4); csEquipmentDeliveryPo.setProcess(4);
} else if (Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),code)) {
csEquipmentDeliveryPo.setProcess(2);
}
//生成二维码文件 //生成二维码文件
String qr = this.createQr(csEquipmentDeliveryAddParm.getNdid()); String qr = this.createQr(csEquipmentDeliveryAddParm.getNdid());
csEquipmentDeliveryPo.setQrPath(qr); csEquipmentDeliveryPo.setQrPath(qr);
@@ -154,36 +172,55 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentProcess.setDevId(csEquipmentDeliveryAddParm.getNdid()); csEquipmentProcess.setDevId(csEquipmentDeliveryAddParm.getNdid());
csEquipmentProcess.setOperator(RequestUtil.getUserIndex()); csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
csEquipmentProcess.setStartTime(LocalDateTime.now()); csEquipmentProcess.setStartTime(LocalDateTime.now());
csEquipmentProcess.setProcess(1); csEquipmentProcess.setProcess(4);
csEquipmentProcess.setStatus(1); csEquipmentProcess.setStatus(1);
csEquipmentProcessPOService.save(csEquipmentProcess); csEquipmentProcessPOService.save(csEquipmentProcess);
result = this.save(csEquipmentDeliveryPo); result = this.save(csEquipmentDeliveryPo);
String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode();
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(), code) && Objects.equals(csEquipmentDeliveryAddParm.getDevAccessMethod(), "CLD")) {
//谁新建的设备,则认为是该设备的主用户,新建用户设备关系表数据
boolean addUser = csDeviceUserPOService.add(csEquipmentDeliveryPo.getId());
if (result && addUser) {
refreshDeviceDataCache();
}
} else {
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
}
return csEquipmentDeliveryPo; return csEquipmentDeliveryPo;
} }
@Override @Override
@DSTransactional
public Boolean AuditEquipmentDelivery(String id) { public Boolean AuditEquipmentDelivery(String id) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one();
//物理删除 //物理删除
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper(); boolean update = false;
wrapper.eq ("id", id); LambdaQueryWrapper<CsEquipmentDeliveryPO> wrapper = new LambdaQueryWrapper<>();
boolean update = this.remove (wrapper); wrapper.eq(CsEquipmentDeliveryPO::getId, id);
//删除deviceuser表里的设备游客数据设备,删除监测点相关数据 CsEquipmentDeliveryPO po = this.getOne(wrapper);
if (po != null) {
update = this.remove(wrapper);
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION + po.getNdid());
}
//删除监测点表、监测点拓扑图关系、监测点限值
List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list(); List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list();
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect); csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect);
csLinePOService.remove(csLinePOLambdaQueryWrapper); csLinePOService.remove(csLinePOLambdaQueryWrapper);
//删除监测点限值
overLimitWlMapper.deleteBatchIds(collect);
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
appLineTopologyDiagramPOQueryWrapper.clear(); appLineTopologyDiagramPOQueryWrapper.clear();
appLineTopologyDiagramPOQueryWrapper.in("line_id", collect); appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper); appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
// appLineTopologyDiagramService.lambdaUpdate().in(AppLineTopologyDiagramPO::getLineId,collect).set(AppLineTopologyDiagramPO::getStatus,0).update();
} }
//清空关系表
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getId, id); csLedgerLambdaQueryWrapper.eq(CsLedger::getId, id);
@@ -191,14 +228,20 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getPid, id); csLedgerLambdaQueryWrapper.eq(CsLedger::getPid, id);
csLedgerService.remove(csLedgerLambdaQueryWrapper); csLedgerService.remove(csLedgerLambdaQueryWrapper);
csDeviceUserPOService.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId,id).set(CsDeviceUserPO::getStatus,0).update(); //删除设备和模板的关系
LambdaQueryWrapper<CsDevModelRelationPO> csDevModelRelationPOQueryWrapper = new LambdaQueryWrapper<>();
csDevModelRelationPOQueryWrapper.clear();
csDevModelRelationPOQueryWrapper.eq(CsDevModelRelationPO::getDevId, id);
csDevModelRelationService.remove(csDevModelRelationPOQueryWrapper);
//删除设备/用户关系
QueryWrapper<CsDeviceUserPO> csDeviceUserPOQueryWrapper = new QueryWrapper<>();
csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("device_id", id);
csDeviceUserPOService.remove(csDeviceUserPOQueryWrapper);
//删除游客
QueryWrapper<CsTouristDataPO> queryWrap = new QueryWrapper<>(); QueryWrapper<CsTouristDataPO> queryWrap = new QueryWrapper<>();
queryWrap.eq("device_id", id); queryWrap.eq("device_id", id);
csTouristDataPOService.getBaseMapper().delete(queryWrap); csTouristDataPOService.getBaseMapper().delete(queryWrap);
/*后续徐那边做处理*/
// CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.getBaseMapper().selectById(id);
// mqttUserService.deleteUser(csEquipmentDeliveryPO.getNdid());
csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId,id).set(CsDevModelRelationPO::getStatus,0).update();
if (update) { if (update) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
@@ -213,6 +256,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return result; return result;
} }
BeanUtils.copyProperties(csEquipmentDeliveryPO, result); BeanUtils.copyProperties(csEquipmentDeliveryPO, result);
BeanUtils.copyProperties(csEquipmentDeliveryPO, result);
if (!Objects.isNull(csEquipmentDeliveryPO.getAssociatedEngineering()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedEngineering(), "")) {
result.setAssociatedEngineeringName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedEngineering()).getName());
}
if (!Objects.isNull(csEquipmentDeliveryPO.getAssociatedProject()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedProject(), "")) {
result.setAssociatedProjectName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedProject()).getName());
}
return result; return result;
} }
@@ -232,9 +282,55 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return returnpage; return returnpage;
} }
Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage, projectEquipmentQueryParm, device); Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage, projectEquipmentQueryParm, device);
list.getRecords().stream().forEach(temp->{ //根据设备id获取监测点id集合
List<CsLinePO> lineIds = csLinePOService.getLineByDev(device);
//根据设备获取当日是否存在未读取的暂态事件
CsEventUserQueryParam param = new CsEventUserQueryParam();
param.setUserId(RequestUtil.getUserIndex());
param.setStartTime(LocalDate.now().atStartOfDay().format(DatePattern.NORM_DATETIME_FORMATTER));
param.setEndTime(LocalDateTime.now().format(DatePattern.NORM_DATETIME_FORMATTER));
param.setEventIds(lineIds.stream().map(CsLinePO::getLineId).collect(Collectors.toList()));
List<CsEventPO> eventList = eventUserFeignClient.queryTempEventDetail(param).getData();
Map<String, List<CsEventPO>> eventMap = Optional.ofNullable(eventList).orElse(Collections.emptyList()).stream().collect(Collectors.groupingBy(CsEventPO::getDeviceId));
List<ProjectEquipmentVO> recordList = new ArrayList<>();
list.getRecords().forEach(temp -> {
temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId())); temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId()));
//获取设备类型
SysDicTreePO po = dictTreeFeignClient.queryById(temp.getDevType()).getData();
temp.setDevType(po.getCode());
temp.setLineList(lineIds.stream().filter(line -> line.getDevId().equals(temp.getEquipmentId())).sorted(Comparator.comparing(CsLinePO::getLineId)).collect(Collectors.toList()));
if (!Objects.equals(DicDataEnum.PORTABLE.getCode(), temp.getDevType())) {
recordList.add(temp);
}
//判断设备是否存在告警
temp.setIsAlarm(CollectionUtil.isNotEmpty(eventMap.get(temp.getEquipmentId())));
}); });
//获取用户置顶的设备
List<CsUserPins> topList = csUserPinsService.getPinToTopList();
List<String> targetIdList = topList.stream().filter(item -> Objects.equals(item.getTargetType(), 1)).map(CsUserPins::getTargetId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targetIdList)) {
List<ProjectEquipmentVO> matchedList = new ArrayList<>();
List<ProjectEquipmentVO> unmatchedList = new ArrayList<>();
for (ProjectEquipmentVO node : recordList) {
if (targetIdList.contains(node.getEquipmentId())) {
node.setIsTop(1);
matchedList.add(node);
} else {
unmatchedList.add(node);
}
}
// 根据 targetIdList 的顺序对匹配的节点进行排序
matchedList.sort(Comparator.comparingInt(node -> targetIdList.indexOf(node.getEquipmentId())));
// 未匹配的节点按照原有的 sort 字段排序,处理 null 值情况
unmatchedList.sort(Comparator.comparing(node -> node.getSort() != null ? node.getSort() : Integer.MAX_VALUE));
// 清空原列表并添加排序后的数据
recordList.clear();
recordList.addAll(matchedList);
recordList.addAll(unmatchedList);
list.setRecords(recordList);
}
return list; return list;
} }
@@ -244,9 +340,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid()); StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid());
boolean result; boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,csEquipmentDeliveryAuditParm.getNdid()) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
.in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3))
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
int countByAccount = this.count(lambdaQueryWrapper); int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复 //大于等于1个则表示重复
if (countByAccount >= 1) { if (countByAccount >= 1) {
@@ -255,11 +349,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2); CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
List<CsEquipmentDeliveryPO> list = this.lambdaQuery() List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()).ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId())
.ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid())
.eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException("设备名称不能重复"); throw new BusinessException("设备名称不能重复");
} }
@@ -308,11 +398,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
int total = this.baseMapper.getCounts(queryParam); int total = this.baseMapper.getCounts(queryParam);
if (total > 0) { if (total > 0) {
List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam); List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam);
//新增逻辑(针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入) //新增逻辑(针对便携式设备、监测设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
for (CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList) { for (CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList) {
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){ String code = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData().getCode();
if ((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)
|| (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)) {
csEquipmentDeliveryVO.setStatus(5); csEquipmentDeliveryVO.setStatus(5);
} else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) { } else if ((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)
|| (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)) {
csEquipmentDeliveryVO.setStatus(6); csEquipmentDeliveryVO.setStatus(6);
} }
//判断装置是否已经连接上mqtt服务器 //判断装置是否已经连接上mqtt服务器
@@ -325,11 +418,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
} }
} }
if (ObjectUtil.isNotNull(queryParam.getConnectStatus())) { if (ObjectUtil.isNotNull(queryParam.getConnectStatus())) {
recordList = recordList.stream() recordList = recordList.stream().filter(item -> queryParam.getConnectStatus() == 0 ? "未连接".equals(item.getConnectStatus()) : "已连接".equals(item.getConnectStatus())).collect(Collectors.toList());
.filter(item -> queryParam.getConnectStatus() == 0
? "未连接".equals(item.getConnectStatus())
: "已连接".equals(item.getConnectStatus()))
.collect(Collectors.toList());
} }
page.setTotal(CollectionUtil.isEmpty(recordList) ? 0 : recordList.size()); page.setTotal(CollectionUtil.isEmpty(recordList) ? 0 : recordList.size());
page.setRecords(recordList); page.setRecords(recordList);
@@ -385,7 +474,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
dataSet = csDataSetService.findDataSetByModelId(modelId, 2); dataSet = csDataSetService.findDataSetByModelId(modelId, 2);
} }
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo); setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
} else if(Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode()) || Objects.equals(devTypeCode, DicDataEnum.DEV_CLD.getCode())){ } else if (Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode())) {
List<CsDataSet> dataSet = new ArrayList<>(); List<CsDataSet> dataSet = new ArrayList<>();
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId); List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)) { if (CollUtil.isNotEmpty(modelId)) {
@@ -394,6 +483,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
} }
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo); setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
} }
} else if (Objects.equals(devTypeCode, DicDataEnum.DEV_CLD.getCode())) {
List<CsDataSet> dataSet = new ArrayList<>();
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)) {
for (CsDevModelRelationPO item : modelId) {
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId(), 1));
}
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
}
} }
} }
return deviceManagerVo; return deviceManagerVo;
@@ -423,9 +521,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//限制角色展示 //限制角色展示
String role = RequestUtil.getUserRole(); String role = RequestUtil.getUserRole();
List<String> strings = JSONArray.parseArray(role, String.class); List<String> strings = JSONArray.parseArray(role, String.class);
if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode()) if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode()) || strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) || strings.contains(AppRoleEnum.ROOT.getCode())) {
|| strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode())
|| strings.contains(AppRoleEnum.ROOT.getCode())) {
addDataSet(dataSetList, item, "模块数据", "moduleData"); addDataSet(dataSetList, item, "模块数据", "moduleData");
} }
} }
@@ -557,13 +653,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentDeliveryPO.setMac(path); csEquipmentDeliveryPO.setMac(path);
csEquipmentDeliveryPO.setRunStatus(1); csEquipmentDeliveryPO.setRunStatus(1);
csEquipmentDeliveryPO.setStatus(1); csEquipmentDeliveryPO.setStatus(1);
csEquipmentDeliveryPO.setProcess(2); // csEquipmentDeliveryPO.setProcess(2);
csEquipmentDeliveryPO.setProcess(4);
csEquipmentDeliveryPO.setSort(100); csEquipmentDeliveryPO.setSort(100);
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO(); CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
csEquipmentProcess.setDevId(csEquipmentDeliveryPO.getNdid()); csEquipmentProcess.setDevId(csEquipmentDeliveryPO.getNdid());
csEquipmentProcess.setOperator(RequestUtil.getUserIndex()); csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
csEquipmentProcess.setStartTime(LocalDateTime.now()); csEquipmentProcess.setStartTime(LocalDateTime.now());
csEquipmentProcess.setProcess(1); // csEquipmentProcess.setProcess(1);
csEquipmentProcess.setProcess(4);
csEquipmentProcess.setStatus(1); csEquipmentProcess.setStatus(1);
collect1.add(csEquipmentProcess); collect1.add(csEquipmentProcess);
return csEquipmentDeliveryPO; return csEquipmentDeliveryPO;
@@ -594,7 +692,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
* 6.删除cs_device_user * 6.删除cs_device_user
* */ * */
@Override @Override
@Transactional(rollbackFor = Exception.class) @DSTransactional
public void delete(String devId) { public void delete(String devId) {
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>(); QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
/** /**
@@ -621,6 +719,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csLinePOQueryWrapper.clear(); csLinePOQueryWrapper.clear();
csLinePOQueryWrapper.in("line_id", collect); csLinePOQueryWrapper.in("line_id", collect);
csLinePOService.remove(csLinePOQueryWrapper); csLinePOService.remove(csLinePOQueryWrapper);
//删除监测点限值
overLimitWlMapper.deleteBatchIds(collect);
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
appLineTopologyDiagramPOQueryWrapper.clear(); appLineTopologyDiagramPOQueryWrapper.clear();
appLineTopologyDiagramPOQueryWrapper.in("line_id", collect); appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
@@ -633,20 +734,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void testCompletion(String deviceId, Integer type, String remark) { public void testCompletion(String deviceId, Integer type, String remark) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one(); CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId,deviceId). this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId, deviceId).set(CsEquipmentDeliveryPO::getStatus, 1).set(CsEquipmentDeliveryPO::getRunStatus, 1).set(CsEquipmentDeliveryPO::getProcess, type + 1).update();
set(CsEquipmentDeliveryPO::getStatus,1).
set(CsEquipmentDeliveryPO::getRunStatus,1).
set(CsEquipmentDeliveryPO::getProcess,type+1).update();
this.delete(deviceId); this.delete(deviceId);
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()). List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
//获取最新一条数据; //获取最新一条数据;
CsEquipmentProcessPO csEquipmentProcessPO = list.get(0); CsEquipmentProcessPO csEquipmentProcessPO = list.get(0);
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId,csEquipmentProcessPO.getId()). csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).set(CsEquipmentProcessPO::getStatus, 1).set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).set(CsEquipmentProcessPO::getRemark, remark).update();
set(CsEquipmentProcessPO::getStatus,1).
set(CsEquipmentProcessPO::getEndTime,LocalDateTime.now()).
set(CsEquipmentProcessPO::getRemark,remark).
update();
} }
@Override @Override
@@ -657,24 +750,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
// set(CsEquipmentDeliveryPO::getRunStatus,1). // set(CsEquipmentDeliveryPO::getRunStatus,1).
set(CsEquipmentDeliveryPO::getProcess, type).update(); set(CsEquipmentDeliveryPO::getProcess, type).update();
this.delete(deviceId); this.delete(deviceId);
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()). List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
//获取最新一条数据; //获取最新一条数据;
CsEquipmentProcessPO csEquipmentProcessPO = list.get(0); CsEquipmentProcessPO csEquipmentProcessPO = list.get(0);
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId,csEquipmentProcessPO.getId()). csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).set(CsEquipmentProcessPO::getStatus, 0).set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).set(CsEquipmentProcessPO::getRemark, remark).update();
set(CsEquipmentProcessPO::getStatus,0).
set(CsEquipmentProcessPO::getEndTime,LocalDateTime.now()).
set(CsEquipmentProcessPO::getRemark,remark).
update();
} }
@Override @Override
public void updateSoftInfo(String nDid, String id) { public void updateSoftInfo(String nDid, String id) {
boolean result; boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid) lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).set(CsEquipmentDeliveryPO::getSoftinfoId, id);
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.set(CsEquipmentDeliveryPO::getSoftinfoId,id);
result = this.update(lambdaUpdateWrapper); result = this.update(lambdaUpdateWrapper);
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
@@ -685,9 +771,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateModuleNumber(String nDid, Integer number) { public void updateModuleNumber(String nDid, Integer number) {
boolean result; boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid) lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).set(CsEquipmentDeliveryPO::getModuleNumber, number);
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.set(CsEquipmentDeliveryPO::getModuleNumber,number);
result = this.update(lambdaUpdateWrapper); result = this.update(lambdaUpdateWrapper);
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
@@ -721,11 +805,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public List<CsEquipmentDeliveryPO> getAllOnline() { public List<CsEquipmentDeliveryPO> getAllOnline() {
return this.lambdaQuery() return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).isNotNull(CsEquipmentDeliveryPO::getNodeId).list();
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
.isNotNull(CsEquipmentDeliveryPO::getNodeId)
.list();
} }
@Override @Override
@@ -733,9 +813,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
boolean result = false; boolean result = false;
//获取装置id //获取装置id
CsEquipmentDeliveryPO po = findDevByNDid(nDid); CsEquipmentDeliveryPO po = findDevByNDid(nDid);
//设备型 //设备
String code = dictTreeFeignClient.queryById(po.getDevModel()).getData().getCode(); String code = dictTreeFeignClient.queryById(po.getDevType()).getData().getCode();
if (Objects.equals(DicTreeEnum.PQ_COM.getCode(),code)) { if (Objects.equals(DicDataEnum.DEV_CLD.getCode(), code) || Objects.equals(DicDataEnum.CONNECT_DEV.getCode(), code)) {
result = true; result = true;
} }
return result; return result;
@@ -751,10 +831,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) { public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) {
boolean result; boolean result;
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
if(Objects.nonNull (one)){
throw new BusinessException ("设备名称不能重复");
}
StringUtil.containsSpecialCharacters(param.getNdid()); StringUtil.containsSpecialCharacters(param.getNdid());
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid(param.getNdid()); CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid(param.getNdid());
if (!Objects.isNull(po)) { if (!Objects.isNull(po)) {
@@ -800,14 +876,37 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csLedger.setSort(0); csLedger.setSort(0);
int addLedger = csLedgerMapper.insert(csLedger); int addLedger = csLedgerMapper.insert(csLedger);
if (result && ObjectUtil.isNotNull(relation) && addLedger > 0) { //1.谁新建的设备,则认为是该设备的主用户,新建用户设备关系表数据
//2.获取当前工程已经关注的用户列表,新增用户和设备的关系
boolean addUser = false;
List<DevDetailDTO> devDetailList = csLedgerFeignClient.getDevInfoByEngineerIds(Collections.singletonList(param.getEngineeringId())).getData();
if (!CollectionUtils.isEmpty(devDetailList)) {
List<String> devIds = devDetailList.stream().map(DevDetailDTO::getEquipmentId).collect(Collectors.toList());
LambdaQueryWrapper<CsDeviceUserPO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CsDeviceUserPO::getDeviceId, devIds);
List<CsDeviceUserPO> csDeviceUserPOList = csDeviceUserPOService.list(wrapper);
if (!CollectionUtils.isEmpty(csDeviceUserPOList)) {
List<String> userIds = csDeviceUserPOList.stream().map(CsDeviceUserPO::getSubUserId).distinct().collect(Collectors.toList());
UserDevParam param1 = new UserDevParam();
param1.setUserId(csEquipmentDeliveryPo.getId());
param1.setList(userIds);
addUser = csDeviceUserPOService.addRelation(param1);
}
} else {
UserDevParam param1 = new UserDevParam();
param1.setUserId(csEquipmentDeliveryPo.getId());
param1.setList(null);
addUser = csDeviceUserPOService.addRelation(param1);
}
if (result && ObjectUtil.isNotNull(relation) && addLedger > 0 && addUser) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
return csEquipmentDeliveryPo; return csEquipmentDeliveryPo;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @DSTransactional
public Boolean delCldDev(String id) { public Boolean delCldDev(String id) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one(); CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one();
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -819,6 +918,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect); csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect);
csLinePOService.remove(csLinePOLambdaQueryWrapper); csLinePOService.remove(csLinePOLambdaQueryWrapper);
//删除监测点限值
overLimitWlMapper.deleteBatchIds(collect);
} }
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.clear();
@@ -831,6 +932,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if (update) { if (update) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
//删除用户设备关系表数据
LambdaQueryWrapper<CsDeviceUserPO> csDeviceUserPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
csDeviceUserPOLambdaQueryWrapper.eq(CsDeviceUserPO::getDeviceId, id);
csDeviceUserPOService.remove(csDeviceUserPOLambdaQueryWrapper);
//新增操作日志 //新增操作日志
CsTerminalLogs csTerminalLogs = new CsTerminalLogs(); CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
csTerminalLogs.setDeviceId(id); csTerminalLogs.setDeviceId(id);
@@ -859,9 +964,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
StringUtil.containsSpecialCharacters(param.getNdid()); StringUtil.containsSpecialCharacters(param.getNdid());
boolean result; boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,param.getNdid()) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, param.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, param.getId());
.in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3))
.ne(CsEquipmentDeliveryPO::getId, param.getId());
int countByAccount = this.count(lambdaQueryWrapper); int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复 //大于等于1个则表示重复
if (countByAccount >= 1) { if (countByAccount >= 1) {
@@ -870,11 +973,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId()); lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId());
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2); CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
List<CsEquipmentDeliveryPO> list = this.lambdaQuery() List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, param.getId()).ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()).eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
.ne(CsEquipmentDeliveryPO::getId, param.getId())
.ne(CsEquipmentDeliveryPO::getNdid, param.getNdid())
.eq(CsEquipmentDeliveryPO::getName, param.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException("设备名称不能重复"); throw new BusinessException("设备名称不能重复");
} }
@@ -926,8 +1025,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
state.add(9); state.add(9);
} }
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,id) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, id).in(ObjectUtil.isNotEmpty(state), CsEquipmentDeliveryPO::getUsageStatus, state).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD");
.in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state);
return this.list(lambdaQueryWrapper); return this.list(lambdaQueryWrapper);
} }
@@ -936,10 +1034,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateCldDevStatus(String nodeId, Integer processNo) { public void updateCldDevStatus(String nodeId, Integer processNo) {
//获取需要修改的设备信息 //获取需要修改的设备信息
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).eq(CsEquipmentDeliveryPO::getNodeProcess, processNo).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).eq(CsEquipmentDeliveryPO::getRunStatus, 2);
.eq(CsEquipmentDeliveryPO::getNodeProcess,processNo)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
.eq(CsEquipmentDeliveryPO::getRunStatus,2);
List<CsEquipmentDeliveryPO> devList = this.list(lambdaQueryWrapper); List<CsEquipmentDeliveryPO> devList = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(devList)) { if (CollectionUtil.isNotEmpty(devList)) {
//修改设备运行状态 //修改设备运行状态
@@ -955,9 +1050,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void flipCldDevStatus(String time, String devId, Integer status) { public void flipCldDevStatus(String time, String devId, Integer status) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId,devId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId, devId).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).ne(CsEquipmentDeliveryPO::getUsageStatus, 0);
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
.ne(CsEquipmentDeliveryPO::getUsageStatus,0);
CsEquipmentDeliveryPO po = this.getOne(lambdaQueryWrapper); CsEquipmentDeliveryPO po = this.getOne(lambdaQueryWrapper);
if (ObjectUtil.isNotNull(po)) { if (ObjectUtil.isNotNull(po)) {
po.setRunStatus(status); po.setRunStatus(status);
@@ -993,9 +1086,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo) { public List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD");
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod,"CLD");
if (ObjectUtil.isNotNull(processNo)) { if (ObjectUtil.isNotNull(processNo)) {
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeProcess, processNo); lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeProcess, processNo);
} }
@@ -1007,6 +1098,77 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId, devList).list(); return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId, devList).list();
} }
@Override
public IPage<DevVersionVO> versionPage(CsEquipmentDeliveryQueryParm baseParam) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(StrUtil.isNotBlank(baseParam.getDevModel()), CsEquipmentDeliveryPO::getDevModel, baseParam.getDevModel())
.eq(StrUtil.isNotBlank(baseParam.getIcd()), CsEquipmentDeliveryPO::getIcd, baseParam.getIcd())
.eq(ObjectUtil.isNotNull(baseParam.getUpgrade()), CsEquipmentDeliveryPO::getUpgrade, baseParam.getUpgrade())
.like(StrUtil.isNotBlank(baseParam.getSearchValue()), CsEquipmentDeliveryPO::getName, baseParam.getSearchValue());
Page<CsEquipmentDeliveryPO> page = this.page(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), wrapper);
List<DevVersionVO> records = new ArrayList<>();
List<DevVersionVO> finalRecords = records;
page.getRecords().forEach(item -> {
DevVersionVO devVersionVO = BeanUtil.copyProperties(item, DevVersionVO.class);
List<User> userData = userFeignClient.getUserByIdList(Collections.singletonList(item.getUpdateBy())).getData();
if (CollectionUtil.isNotEmpty(userData)) {
devVersionVO.setUpdateByName(userData.get(0).getName());
}
if (StrUtil.isNotBlank(item.getSoftinfoId())) {
CsSoftInfoPO softInfoPO = csSoftInfoService.getById(item.getSoftinfoId());
if (ObjectUtil.isNotNull(softInfoPO)) {
CsEdDataPO csEdDataPO = csEdDataService.findByDevTypeIdAndVersionNo(item.getDevModel(), softInfoPO.getAppVersion());
if (ObjectUtil.isNotNull(csEdDataPO)) {
devVersionVO.setVersion(csEdDataPO.getVersionNo());
devVersionVO.setProtocolVersion(csEdDataPO.getVersionAgreement());
devVersionVO.setVersionDate(csEdDataPO.getVersionDate());
}
}
}
devVersionVO.setStatus(item.getUsageStatus());
devVersionVO.setIcd(item.getIcd());
if (StrUtil.isNotBlank(item.getDevModel())) {
SysDicTreePO sysDicTreePO = dictTreeFeignClient.queryById(item.getDevModel()).getData();
if (ObjectUtil.isNotNull(sysDicTreePO)) {
devVersionVO.setDevModelName(sysDicTreePO.getName());
}
}
if (StrUtil.isNotBlank(item.getAssociatedEngineering())) {
devVersionVO.setAssociatedEngineering(csEngineeringService.getById(item.getAssociatedEngineering()).getName());
}
if (StrUtil.isNotBlank(item.getAssociatedProject())) {
devVersionVO.setAssociatedProject(appProjectService.getById(item.getAssociatedProject()).getName());
}
//判断装置是否已经连接上mqtt服务器
String clientName = "NJCN-" + item.getNdid().substring(item.getNdid().length() - 6);
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
if (mqttClient) {
devVersionVO.setConnectStatus(1);
} else {
devVersionVO.setConnectStatus(0);
}
finalRecords.add(devVersionVO);
});
Page<DevVersionVO> resultPage = new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam));
if (ObjectUtil.isNotNull(baseParam.getConnectStatus())) {
records = records.stream().filter(item -> baseParam.getConnectStatus().equals(item.getConnectStatus())).collect(Collectors.toList());
}
resultPage.setTotal(CollectionUtil.isEmpty(records) ? 0 : records.size());
resultPage.setRecords(records);
resultPage.setTotal(page.getTotal());
resultPage.setMaxLimit(page.getMaxLimit());
resultPage.setPages(page.getPages());
return resultPage;
}
@Override @Override
public List<CsEquipmentDeliveryPO> getRunPortableDev(String userId) { public List<CsEquipmentDeliveryPO> getRunPortableDev(String userId) {
List<CsEquipmentDeliveryPO> result = new ArrayList<>(); List<CsEquipmentDeliveryPO> result = new ArrayList<>();
@@ -1015,9 +1177,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
throw new BusinessException("便携式设备类型字典缺失"); throw new BusinessException("便携式设备类型字典缺失");
} }
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType,vo.getId()) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType, vo.getId()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getUsageStatus, 1);
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1);
//获取用户已经绑定的便携式设备 //获取用户已经绑定的便携式设备
List<String> devList = csDeviceUserPOService.findDevByUserId(userId); List<String> devList = csDeviceUserPOService.findDevByUserId(userId);
if (CollectionUtil.isNotEmpty(devList)) { if (CollectionUtil.isNotEmpty(devList)) {
@@ -1031,12 +1191,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
queryWrapper.in(CsLedger::getId, ids); queryWrapper.in(CsLedger::getId, ids);
List<CsLedger> list = csLedgerService.list(queryWrapper); List<CsLedger> list = csLedgerService.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
Set<String> idSet = list.stream() Set<String> idSet = list.stream().map(CsLedger::getId).collect(Collectors.toSet());
.map(CsLedger::getId) return result.stream().filter(data -> idSet.contains(data.getId())).collect(Collectors.toList());
.collect(Collectors.toSet()); } else {
return result.stream() result.clear();
.filter(data -> idSet.contains(data.getId())) return result;
.collect(Collectors.toList());
} }
} }
return result; return result;
@@ -1045,26 +1204,22 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//根据前置机id获取装置数量 //根据前置机id获取装置数量
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) { public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).in(CsEquipmentDeliveryPO::getRunStatus, Arrays.asList(1, 2));
.in(CsEquipmentDeliveryPO::getRunStatus,Arrays.asList(1,2));
return this.list(lambdaQueryWrapper); return this.list(lambdaQueryWrapper);
} }
public int findLeastFrequentProcess(List<CsEquipmentDeliveryPO> items, Integer process) { public int findLeastFrequentProcess(List<CsEquipmentDeliveryPO> items, Integer process) {
Map<Integer, Long> processCounts = items.stream() Map<Integer, Long> processCounts = items.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting()));
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting()));
for (int i = 1; i <= process; i++) { for (int i = 1; i <= process; i++) {
processCounts.putIfAbsent(i, 0L); processCounts.putIfAbsent(i, 0L);
} }
//如果列表为空默认返回1 //如果列表为空默认返回1
return processCounts.entrySet().stream() return processCounts.entrySet().stream().min(Comparator.comparingLong(Map.Entry::getValue)).map(Map.Entry::getKey).orElse(1);
.min(Comparator.comparingLong(Map.Entry::getValue))
.map(Map.Entry::getKey)
.orElse(1);
} }
/** /**
* 根据ndid生成二维码 * 根据ndid生成二维码
*
* @param ndid * @param ndid
* @return * @return
*/ */

View File

@@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
import com.njcn.csdevice.api.CsMarketDataFeignClient;
import com.njcn.csdevice.constant.DataParam; import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.LineBaseEnum; import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.*; import com.njcn.csdevice.mapper.*;
@@ -21,7 +23,7 @@ import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CsLedgerVO; import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient; import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.redis.utils.RedisUtil; import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.AreaFeignClient; import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
@@ -67,12 +69,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
private final CsDeviceUserPOMapper csDeviceUserPOMapper; private final CsDeviceUserPOMapper csDeviceUserPOMapper;
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient; private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final ICsUserPinsService csUserPinsService;
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
@Override @Override
public List<CsLedgerVO> getLedgerTree() { public List<CsLedgerVO> getLedgerTree() {
List<CsLedgerVO> list = new ArrayList<>(); List<CsLedgerVO> list = new ArrayList<>();
List<CsLedgerVO> engineeringList = getLineTree(); List<CsLedgerVO> engineeringList = getLineTree(null);
CsLedgerVO vo = new CsLedgerVO(); CsLedgerVO vo = new CsLedgerVO();
vo.setId("9999999"); vo.setId("9999999");
vo.setLevel(0); vo.setLevel(0);
@@ -85,7 +89,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
} }
@Override @Override
public List<CsLedgerVO> getLineTree() { public List<CsLedgerVO> getLineTree(String type) {
List<CsLedgerVO> engineeringList; List<CsLedgerVO> engineeringList;
List<CsLedgerVO> allList = this.baseMapper.getAll(); List<CsLedgerVO> allList = this.baseMapper.getAll();
/*获取用户工程,设备信息过滤*/ /*获取用户工程,设备信息过滤*/
@@ -93,6 +97,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<String> device = roleEngineerDevService.getDevice(); List<String> device = roleEngineerDevService.getDevice();
//区分治理装置和云前置装置 //区分治理装置和云前置装置
List<String> zhiLianDevice = new ArrayList<>(); List<String> zhiLianDevice = new ArrayList<>();
List<String> portableDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>(); List<String> cldDevice = new ArrayList<>();
if (CollectionUtil.isNotEmpty(device)) { if (CollectionUtil.isNotEmpty(device)) {
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectBatchIds(device); List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectBatchIds(device);
@@ -112,6 +117,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
.map(CsEquipmentDeliveryPO::getId) .map(CsEquipmentDeliveryPO::getId)
.forEach(zhiLianDevice::add) .forEach(zhiLianDevice::add)
); );
DictTreeVO vo3 = dictTreeFeignClient.queryByCode(DicDataEnum.PORTABLE.getCode()).getData();
Optional.ofNullable(vo3)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryPO::getId)
.forEach(portableDevice::add)
);
} }
engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList()); engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList()); List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
@@ -133,6 +146,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
item.setNDId(po.getNdid()); item.setNDId(po.getNdid());
item.setType("device"); item.setType("device");
item.setProcess(po.getProcess()); item.setProcess(po.getProcess());
item.setDevConType(po.getDevAccessMethod());
}) })
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1)) .filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort)) .sorted(Comparator.comparing(CsLedgerVO::getSort))
@@ -146,6 +160,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
item.setNDId(po.getNdid()); item.setNDId(po.getNdid());
item.setType("device"); item.setType("device");
item.setProcess(po.getProcess()); item.setProcess(po.getProcess());
item.setDevConType(po.getDevAccessMethod());
}) })
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1)) .filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort)) .sorted(Comparator.comparing(CsLedgerVO::getSort))
@@ -206,28 +221,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
portable.setPid("0"); portable.setPid("0");
portable.setId(IdUtil.simpleUUID()); portable.setId(IdUtil.simpleUUID());
//根据当前用户获取便携式设备 List<CsLedgerVO> ledger = allList.stream().filter(obj -> portableDevice.contains(obj.getId())).collect(Collectors.toList());
List<CsLedgerVO> ledger;
String role = RequestUtil.getUserRole();
List<String> roles = JSONArray.parseArray(role, String.class);
if(roles.contains(AppRoleEnum.ROOT.getCode()) || roles.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) || roles.contains(AppRoleEnum.REGULAR_USER.getCode())){
ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0"))
.collect(Collectors.toList());
} else {
LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsDeviceUserPO::getPrimaryUserId, RequestUtil.getUserIndex());
List<CsDeviceUserPO> list1 = csDeviceUserPOMapper.selectList(queryWrapper);
List<String> result = new ArrayList<>();
if (CollectionUtil.isNotEmpty(list1)) {
result = list1.stream().map(CsDeviceUserPO::getDeviceId).collect(Collectors.toList());
}
//针对未启用的装置判断
List<String> finalResult = result;
ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0") && finalResult.contains(item.getId()))
.collect(Collectors.toList());
}
Map<String, CsEquipmentDeliveryPO> poMap2 = ledger.stream() Map<String, CsEquipmentDeliveryPO> poMap2 = ledger.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
CsLedgerVO::getId, CsLedgerVO::getId,
@@ -243,6 +237,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
c.setType("device"); c.setType("device");
c.setName(po.getName()); c.setName(po.getName());
c.setSort(po.getSort()); c.setSort(po.getSort());
c.setDevConType(po.getDevAccessMethod());
}) })
.filter(c -> poMap2.get(c.getId()).getUsageStatus() == 1) .filter(c -> poMap2.get(c.getId()).getUsageStatus() == 1)
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -267,6 +262,58 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
cld.setChildren(engineeringList2); cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>(); List<CsLedgerVO> tree = new ArrayList<>();
//获取置顶的工程
List<CsUserPins> list = csUserPinsService.getPinToTopList();
if (Objects.equals(type,"engineering")) {
Map<String, CsLedgerVO> engineeringMap = new HashMap<>();
engineeringList1.forEach(eng -> {
CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
engineeringList2.forEach(eng -> {
CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
tree.addAll(new ArrayList<>(engineeringMap.values()));
if (CollUtil.isNotEmpty(portables)) {
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0);
portable1.setName("便携式工程");
portable1.setPid("0");
portable1.setId(id);
CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1);
portable2.setName("便携式项目");
portable2.setPid(id);
portable2.setId(IdUtil.simpleUUID());
portable2.setChildren(portables);
portable1.setChildren(Collections.singletonList(portable2));
tree.add(portable1);
}
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 4);
}
} else {
//按设备类型统计
if (CollUtil.isNotEmpty(portables)) { if (CollUtil.isNotEmpty(portables)) {
tree.add(portable); tree.add(portable);
} }
@@ -276,9 +323,178 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollUtil.isNotEmpty(cldDeviceList)) { if (CollUtil.isNotEmpty(cldDeviceList)) {
tree.add(cld); tree.add(cld);
} }
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 5);
}
}
return tree; return tree;
} }
@Override
public List<CsLedgerVO> appLineTree() {
//根据用户获取监测点
List<String> lineIds = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
List<String> engineeringIds = roleEngineerDevService.getRoleengineer();
if (CollectionUtil.isEmpty(lineIds) && CollectionUtil.isEmpty(engineeringIds)) {
return Collections.emptyList();
}
//获取所有台账数据
List<CsLedgerVO> allList = this.baseMapper.getAll();
if (CollectionUtil.isEmpty(allList)) {
return Collections.emptyList();
}
Set<String> resultEngineeringIds = new HashSet<>();
//1. 反推:从监测点向上找到所有相关的工程
if (CollectionUtil.isNotEmpty(lineIds)) {
//过滤出监测点数据 (level=3)
List<CsLedgerVO> lineList = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), LineBaseEnum.LINE_LEVEL.getCode()))
.filter(item -> lineIds.contains(item.getId()))
.collect(Collectors.toList());
//从监测点向上追溯到工程
lineList.forEach(line -> {
String[] pids = line.getPids().split(",");
//根据层级结构,工程 ID 在 pids 的第一个位置(索引为 1因为索引 0 是"0"
if (pids.length > LineBaseEnum.ENGINEERING_LEVEL.getCode() + 1) {
String engineeringId = pids[LineBaseEnum.ENGINEERING_LEVEL.getCode() + 1];
resultEngineeringIds.add(engineeringId);
}
});
}
//2. 正推:添加用户已有的工程 ID
if (CollectionUtil.isNotEmpty(engineeringIds)) {
resultEngineeringIds.addAll(engineeringIds);
}
if (CollectionUtil.isEmpty(resultEngineeringIds)) {
return Collections.emptyList();
}
//获取所有层级数据并排序
//监测点数据
List<CsLedgerVO> lineList = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), LineBaseEnum.LINE_LEVEL.getCode()))
.filter(item -> lineIds.contains(item.getId()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
//设备数据
List<CsLedgerVO> deviceList = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), LineBaseEnum.DEVICE_LEVEL.getCode()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
//项目数据
List<CsLedgerVO> projectList = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), LineBaseEnum.PROJECT_LEVEL.getCode()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
//工程数据,过滤掉名字是"便携式工程"的数据
List<CsLedgerVO> engineeringList = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), LineBaseEnum.ENGINEERING_LEVEL.getCode()))
.filter(item -> resultEngineeringIds.contains(item.getId()))
.filter(item -> !Objects.equals(item.getName(), "便携式工程"))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
//构建设备与监测点的关系
deviceList.forEach(device -> {
List<CsLedgerVO> children = lineList.stream()
.filter(line -> Objects.equals(line.getPid(), device.getId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(children)) {
device.setChildren(children);
}
});
//构建项目与设备的关系
projectList.forEach(project -> {
List<CsLedgerVO> children = deviceList.stream()
.filter(device -> Objects.equals(device.getPid(), project.getId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(children)) {
project.setChildren(children);
}
});
//构建工程与项目的关系
engineeringList.forEach(engineering -> {
List<CsLedgerVO> children = projectList.stream()
.filter(project -> Objects.equals(project.getPid(), engineering.getId()))
.collect(Collectors.toList());
//工程下面可以没有项目,所以即使 children 为空也要保留
engineering.setChildren(children);
});
return engineeringList;
}
/**
* 合并两个项目列表,根据项目 ID 去重并合并子节点
*/
private List<CsLedgerVO> mergeProjectList(List<CsLedgerVO> list1, List<CsLedgerVO> list2) {
if (CollectionUtil.isEmpty(list1)) {
return list2 != null ? new ArrayList<>(list2) : new ArrayList<>();
}
if (CollectionUtil.isEmpty(list2)) {
return new ArrayList<>(list1);
}
Map<String, CsLedgerVO> projectMap = new HashMap<>();
list1.forEach(project -> {
projectMap.put(project.getId(), cloneProject(project));
});
list2.forEach(project -> {
CsLedgerVO existingProject = projectMap.get(project.getId());
if (existingProject == null) {
projectMap.put(project.getId(), cloneProject(project));
} else {
List<CsLedgerVO> mergedDevices = new ArrayList<>();
if (existingProject.getChildren() != null) {
mergedDevices.addAll(existingProject.getChildren());
}
if (project.getChildren() != null) {
mergedDevices.addAll(project.getChildren());
}
existingProject.setChildren(mergedDevices);
}
});
return new ArrayList<>(projectMap.values());
}
/**
* 克隆项目对象,避免引用问题
*/
private CsLedgerVO cloneProject(CsLedgerVO project) {
CsLedgerVO cloned = new CsLedgerVO();
cloned.setId(project.getId());
cloned.setPid(project.getPid());
cloned.setLevel(project.getLevel());
cloned.setName(project.getName());
cloned.setType(project.getType());
cloned.setComFlag(project.getComFlag());
cloned.setNDId(project.getNDId());
cloned.setProcess(project.getProcess());
cloned.setLineType(project.getLineType());
cloned.setConType(project.getConType());
cloned.setSort(project.getSort());
if (project.getChildren() != null) {
cloned.setChildren(new ArrayList<>(project.getChildren()));
}
return cloned;
}
//剔除未接入的设备(根据status判断不太稳,所有这里直接判断该设备有没有对应的模板指标) //剔除未接入的设备(根据status判断不太稳,所有这里直接判断该设备有没有对应的模板指标)
private void checkDevSetData(List<CsLedgerVO> ledgerVOS) { private void checkDevSetData(List<CsLedgerVO> ledgerVOS) {
Iterator<CsLedgerVO> iterator = ledgerVOS.iterator(); Iterator<CsLedgerVO> iterator = ledgerVOS.iterator();
@@ -309,7 +525,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
@Override @Override
public List<CsLedgerVO> getDeviceTree() { public List<CsLedgerVO> getDeviceTree(String type) {
List<CsLedgerVO> engineeringList; List<CsLedgerVO> engineeringList;
List<CsLedgerVO> allList = this.baseMapper.getAll(); List<CsLedgerVO> allList = this.baseMapper.getAll();
/*获取用户工程,设备信息过滤*/ /*获取用户工程,设备信息过滤*/
@@ -317,6 +533,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<String> device = roleEngineerDevService.getDevice(); List<String> device = roleEngineerDevService.getDevice();
List<String> zhiLianDevice = new ArrayList<>(); List<String> zhiLianDevice = new ArrayList<>();
List<String> portableDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>(); List<String> cldDevice = new ArrayList<>();
if (CollectionUtil.isNotEmpty(device)) { if (CollectionUtil.isNotEmpty(device)) {
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectBatchIds(device); List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectBatchIds(device);
@@ -336,6 +553,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
.map(CsEquipmentDeliveryPO::getId) .map(CsEquipmentDeliveryPO::getId)
.forEach(zhiLianDevice::add) .forEach(zhiLianDevice::add)
); );
DictTreeVO vo3 = dictTreeFeignClient.queryByCode(DicDataEnum.PORTABLE.getCode()).getData();
Optional.ofNullable(vo3)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryPO::getId)
.forEach(portableDevice::add)
);
} }
engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList()); engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList());
@@ -359,6 +584,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
item.setNDId(po.getNdid()); item.setNDId(po.getNdid());
item.setType("device"); item.setType("device");
item.setProcess(po.getProcess()); item.setProcess(po.getProcess());
item.setDevConType(po.getDevAccessMethod());
}) })
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1)) .filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort)) .sorted(Comparator.comparing(CsLedgerVO::getSort))
@@ -386,6 +612,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
item.setNDId(po.getNdid()); item.setNDId(po.getNdid());
item.setType("device"); item.setType("device");
item.setProcess(po.getProcess()); item.setProcess(po.getProcess());
item.setDevConType(po.getDevAccessMethod());
}) })
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1)) .filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort)) .sorted(Comparator.comparing(CsLedgerVO::getSort))
@@ -411,28 +638,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
portable.setPid("0"); portable.setPid("0");
portable.setId(IdUtil.simpleUUID()); portable.setId(IdUtil.simpleUUID());
List<CsLedgerVO> ledger; List<CsLedgerVO> ledger = allList.stream().filter(obj -> portableDevice.contains(obj.getId())).collect(Collectors.toList());
String role = RequestUtil.getUserRole();
List<String> roles = JSONArray.parseArray(role, String.class);
if(roles.contains(AppRoleEnum.ROOT.getCode()) || roles.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) || roles.contains(AppRoleEnum.REGULAR_USER.getCode())){
ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0"))
.collect(Collectors.toList());
} else {
LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsDeviceUserPO::getPrimaryUserId, RequestUtil.getUserIndex());
List<CsDeviceUserPO> list1 = csDeviceUserPOMapper.selectList(queryWrapper);
List<String> result = new ArrayList<>();
if (CollectionUtil.isNotEmpty(list1)) {
result = list1.stream().map(CsDeviceUserPO::getDeviceId).collect(Collectors.toList());
}
//针对未启用的装置判断
List<String> finalResult = result;
ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0") && finalResult.contains(item.getId()))
.collect(Collectors.toList());
}
Map<String, CsEquipmentDeliveryPO> poMap2 = ledger.stream() Map<String, CsEquipmentDeliveryPO> poMap2 = ledger.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
CsLedgerVO::getId, CsLedgerVO::getId,
@@ -471,6 +677,59 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
cld.setChildren(engineeringList2); cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>(); List<CsLedgerVO> tree = new ArrayList<>();
List<CsUserPins> list = csUserPinsService.getPinToTopList();
if (Objects.equals(type,"engineering")) {
Map<String, CsLedgerVO> engineeringMap = new HashMap<>();
engineeringList1.forEach(eng -> {
CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
engineeringList2.forEach(eng -> {
CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
tree.addAll(new ArrayList<>(engineeringMap.values()));
if (CollUtil.isNotEmpty(portables)) {
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0);
portable1.setName("便携式工程");
portable1.setPid("0");
portable1.setId(id);
CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1);
portable2.setName("便携式项目");
portable2.setPid(id);
portable2.setId(IdUtil.simpleUUID());
portable2.setChildren(portables);
List<CsLedgerVO> portable2List = new ArrayList<>();
portable2List.add(portable2);
portable1.setChildren(portable2List);
tree.add(portable1);
}
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 4);
}
} else {
//按设备类型统计
if (CollUtil.isNotEmpty(portables)) { if (CollUtil.isNotEmpty(portables)) {
tree.add(portable); tree.add(portable);
} }
@@ -480,6 +739,10 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollUtil.isNotEmpty(cldDevList)) { if (CollUtil.isNotEmpty(cldDevList)) {
tree.add(cld); tree.add(cld);
} }
}
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 5);
}
return tree; return tree;
} }
@@ -575,10 +838,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
public DevDetailDTO queryDevDetail(String devId) { public DevDetailDTO queryDevDetail(String devId) {
DevDetailDTO device = new DevDetailDTO(); DevDetailDTO device = new DevDetailDTO();
CsLedger dev = this.findDataById(devId); CsLedger dev = this.findDataById(devId);
//获取设备mac
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(devId);
//如果是便携式设备pid为0,项目,工程都设置为/ //如果是便携式设备pid为0,项目,工程都设置为/
if (Objects.equals(dev.getPid(), "0")) { if (Objects.equals(dev.getPid(), "0")) {
device.setEquipmentName(dev.getName()); device.setEquipmentName(dev.getName());
device.setEquipmentId(devId); device.setEquipmentId(devId);
device.setDevMac(po.getMac());
device.setProjectId("/"); device.setProjectId("/");
device.setProjectName("/"); device.setProjectName("/");
device.setEngineeringid("/"); device.setEngineeringid("/");
@@ -586,11 +853,11 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
} else { } else {
device.setEquipmentName(dev.getName()); device.setEquipmentName(dev.getName());
device.setEquipmentId(devId); device.setEquipmentId(devId);
device.setDevMac(po.getMac());
CsLedger project = this.findDataById(dev.getPid()); CsLedger project = this.findDataById(dev.getPid());
if (ObjectUtil.isNotNull(project)) { if (ObjectUtil.isNotNull(project)) {
device.setProjectId(project.getId()); device.setProjectId(project.getId());
device.setProjectName(project.getName()); device.setProjectName(project.getName());
CsLedger engineer = this.findDataById(project.getPid()); CsLedger engineer = this.findDataById(project.getPid());
if (ObjectUtil.isNotNull(engineer)) { if (ObjectUtil.isNotNull(engineer)) {
device.setEngineeringid(engineer.getId()); device.setEngineeringid(engineer.getId());
@@ -788,78 +1055,6 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
return tree; return tree;
} }
// @Override
// public List<CsLedgerVO> getztProjectTree() {
// List<CsLedgerVO> engineeringList;
// List<CsLedgerVO> allList = this.baseMapper.getAll();
// /*获取用户工程,设备信息过滤*/
// List<String> roleengineer = roleEngineerDevService.getRoleengineer();
// List<String> device = roleEngineerDevService.getDevice();
// engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList());
// List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
//
// List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0")).
// peek(
// temp -> {
// CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(temp.getId());
// temp.setComFlag(po.getRunStatus());
// temp.setNDId(po.getNdid());
// temp.setType("device");
// }
// ).
// sorted(Comparator.comparing(CsLedgerVO::getSort))
// .collect(Collectors.toList());
// checkDevSetData(deviceList);
// projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
// engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
//
// //获取便携式项目数
// CsLedgerVO portable = new CsLedgerVO();
// portable.setLevel(0);
// portable.setName(DataParam.PORTABLE_SYSTEM);
// portable.setPid("0");
// portable.setId(IdUtil.simpleUUID());
//
// CsLedgerVO project = new CsLedgerVO();
// project.setLevel(1);
// project.setName(DataParam.WIRELESS_PROJECT);
// project.setPid("0");
// project.setId(DataParam.WIRELESS_PROJECT_ID);
//
// List<CsLedgerVO> portables = allList.stream().filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0")).collect(Collectors.toList());
// checkDevSetData(portables);
// for (CsLedgerVO c : portables) {
// c.setPid(project.getId());
// CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(c.getId());
// c.setComFlag(po.getRunStatus());
// c.setNDId(po.getNdid());
// c.setType("device");
// }
// project.setChildren(portables);
//
// List<CsLedgerVO> wxProjectList = new ArrayList<>();
// wxProjectList.add(project);
//
// portable.setChildren(wxProjectList);
//
//
// CsLedgerVO government = new CsLedgerVO();
// government.setLevel(0);
// government.setName(DataParam.GOVERNANCE_SYSTEM);
// government.setPid("0");
// government.setId(IdUtil.simpleUUID());
// government.setChildren(engineeringList);
// List<CsLedgerVO> tree = new ArrayList<>();
//
// if (CollUtil.isNotEmpty(portables)) {
// tree.add(portable);
// }
// if (CollUtil.isNotEmpty(deviceList)) {
// tree.add(government);
// }
//
// return tree;
// }
@Override @Override
public List<CsLedgerVO> objTree() { public List<CsLedgerVO> objTree() {
@@ -972,96 +1167,111 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
@Override @Override
public CsLedgerVO cldTree() { public CsLedgerVO cldTree() {
List<CsLedgerVO> engineerTree = new ArrayList<>();
List<CsLedgerVO> projectTree = new ArrayList<>();
List<CsLedgerVO> deviceTree = new ArrayList<>();
List<CsLedgerVO> lineTree = new ArrayList<>();
List<CsLedgerVO> allList = this.baseMapper.getAll(); List<CsLedgerVO> allList = this.baseMapper.getAll();
if (CollectionUtil.isNotEmpty(allList)) { if (CollectionUtil.isEmpty(allList)) {
//工程集合
List<CsLedgerVO> tree1 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).collect(Collectors.toList());
//项目集合
List<CsLedgerVO> tree2 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).collect(Collectors.toList());
//设备集合
List<CsLedgerVO> tree3 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).collect(Collectors.toList());
//监测点集合
List<CsLedgerVO> tree4 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).collect(Collectors.toList());
//筛选出云前置设备
if (CollectionUtil.isNotEmpty(tree3)) {
Set<String> list1 = new HashSet<>();
List<String> devList = tree3.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devList);
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
//list1是 cld设备
devs.forEach(item -> {
if (item.getDevType().equals(vo1.getId())) {
list1.add(item.getId());
}
});
//list2是 非cld设备
Set<String> list2 = devList.stream().filter(item -> !list1.contains(item)).collect(Collectors.toSet());
List<CsLedgerVO> tree5 = tree3.stream().filter(vo -> list2.contains(vo.getId())).collect(Collectors.toList());
Set<String> list3 = tree5.stream().map(CsLedgerVO::getPid).collect(Collectors.toSet());
projectTree = tree2.stream().filter(vo -> !list3.contains(vo.getId())).collect(Collectors.toList());
List<CsLedgerVO> tree6 = tree2.stream().filter(vo -> list3.contains(vo.getId())).collect(Collectors.toList());
Set<String> proList = tree6.stream().map(CsLedgerVO::getPid).collect(Collectors.toSet());
engineerTree = tree1.stream().filter(vo -> !proList.contains(vo.getId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(list1)) {
deviceTree = tree3.stream()
.filter(vo -> list1.contains(vo.getId()))
.peek(item -> {
CsEquipmentDeliveryPO dev = devsMap.get(item.getId());
if (dev != null) {
item.setComFlag(dev.getRunStatus());
}
})
.collect(Collectors.toList());
lineTree = tree4.stream()
.filter(vo -> list1.contains(vo.getPid()))
.peek(item -> {
CsEquipmentDeliveryPO dev = devsMap.get(item.getId());
if (dev != null) {
item.setComFlag(dev.getRunStatus());
}
})
.collect(Collectors.toList());
}
}
}
if (CollectionUtil.isNotEmpty(deviceTree)) {
List<CsLedgerVO> finalLineTree = lineTree;
deviceTree.forEach(item -> {
item.setChildren(getChildren(item, finalLineTree));
});
}
if (CollectionUtil.isNotEmpty(projectTree)) {
List<CsLedgerVO> finalDeviceTree = deviceTree;
projectTree.forEach(item -> {
item.setChildren(getChildren(item, finalDeviceTree));
});
}
if (CollectionUtil.isNotEmpty(engineerTree)) {
List<CsLedgerVO> finalProjectTree = projectTree;
engineerTree.forEach(item -> {
item.setChildren(getChildren(item, finalProjectTree));
});
}
CsLedgerVO government = new CsLedgerVO(); CsLedgerVO government = new CsLedgerVO();
government.setLevel(0); government.setLevel(-1);
government.setName(DataParam.cldDev); government.setName("台账树");
government.setPid("0"); government.setPid("0");
government.setId(IdUtil.simpleUUID()); government.setId(IdUtil.simpleUUID());
government.setChildren(engineerTree); government.setChildren(new ArrayList<>());
return government;
}
List<CsLedgerVO> engineeringList = allList.stream()
.filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream()
.filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> deviceList = allList.stream()
.filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> lineList = allList.stream()
.filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(deviceList)) {
CsLedgerVO government = new CsLedgerVO();
government.setLevel(-1);
government.setName("台账树");
government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
return government;
}
List<String> devIds = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devIds);
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
Map<String, String> lineDevMap = lineList.stream().collect(Collectors.toMap(CsLedgerVO::getId, CsLedgerVO::getPid));
Set<String> cldDevIds = devs.stream()
.map(CsEquipmentDeliveryPO::getId)
.collect(Collectors.toSet());
Map<String, List<CsLedgerVO>> projectToDeviceMap = deviceList.stream()
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
Map<String, List<CsLedgerVO>> deviceToLineMap = lineList.stream()
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
deviceList.forEach(device -> {
CsEquipmentDeliveryPO dev = devsMap.get(device.getId());
if (dev != null) {
device.setComFlag(dev.getRunStatus());
device.setDevConType(dev.getDevAccessMethod());
}
});
lineList.forEach(line -> {
String devId = lineDevMap.get(line.getId());
if (devId != null) {
CsEquipmentDeliveryPO dev = devsMap.get(devId);
if (dev != null) {
line.setComFlag(dev.getRunStatus());
}
}
});
engineeringList.forEach(engineering -> {
List<CsLedgerVO> sortedProjects = projectList.stream()
.filter(project -> project.getPid().equals(engineering.getId()))
.peek(project -> {
List<CsLedgerVO> projectDevices = projectToDeviceMap.getOrDefault(project.getId(), new ArrayList<>());
if (CollectionUtil.isNotEmpty(projectDevices)) {
List<CsLedgerVO> sortedDevices = projectDevices.stream()
.filter(device -> cldDevIds.contains(device.getId()))
.peek(device -> {
List<CsLedgerVO> sortedLines = deviceToLineMap.getOrDefault(device.getId(), new ArrayList<>())
.stream()
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
device.setChildren(sortedLines);
})
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
project.setChildren(sortedDevices);
}
})
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
engineering.setChildren(sortedProjects);
});
CsLedgerVO government = new CsLedgerVO();
government.setLevel(-1);
government.setName("台账树");
government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
return government; return government;
} }
@@ -1088,9 +1298,19 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollectionUtil.isNotEmpty(enginingeringIds)) { if (CollectionUtil.isNotEmpty(enginingeringIds)) {
List<CsLedger> engineer = this.listByIds(enginingeringIds); List<CsLedger> engineer = this.listByIds(enginingeringIds);
engineer.forEach(item -> { engineer.forEach(item -> {
List<String> devNames = new ArrayList<>();
List<String> devIds = new ArrayList<>();
DevDetailDTO detail = new DevDetailDTO(); DevDetailDTO detail = new DevDetailDTO();
detail.setEngineeringid(item.getId()); detail.setEngineeringid(item.getId());
detail.setEngineeringName(item.getName()); detail.setEngineeringName(item.getName());
ledgers.forEach(item2->{
if (item2.getPids().contains(item.getId())) {
devIds.add(item2.getId());
devNames.add(item2.getName());
}
});
detail.setEquipmentId(String.join(",", devIds));
detail.setEquipmentName(String.join(",", devNames));
details.add(detail); details.add(detail);
}); });
} }
@@ -1099,24 +1319,87 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
@Override @Override
public List<DevDetailDTO> getDevInfoByEngineerIds(List<String> list) { public List<DevDetailDTO> getDevInfoByEngineerIds(List<String> list) {
// 参数校验,确保 list 不为空
if (CollUtil.isEmpty(list)) {
return new ArrayList<>();
}
List<DevDetailDTO> details = new ArrayList<>(); List<DevDetailDTO> details = new ArrayList<>();
// 工程
LambdaQueryWrapper<CsLedger> queryWrapper0 = new LambdaQueryWrapper<>();
queryWrapper0.in(CsLedger::getId, list);
List<CsLedger> engineering = this.list(queryWrapper0);
if (CollUtil.isEmpty(engineering)) {
return details;
}
Map<String, CsLedger> engineeringMap = engineering.stream().collect(Collectors.toMap(CsLedger::getId, item -> item));
// 项目
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(CsLedger::getPid, list); queryWrapper.in(CsLedger::getPid, list);
List<CsLedger> project = this.list(queryWrapper); List<CsLedger> project = this.list(queryWrapper);
//工程id if (CollUtil.isEmpty(project)) {
return details;
}
Map<String, CsLedger> projectMap = project.stream().collect(Collectors.toMap(CsLedger::getId, item -> item));
// 设备
List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(projectIds)) {
LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(CsLedger::getPid, projectIds); queryWrapper2.in(CsLedger::getPid, projectIds);
List<CsLedger> dev = this.list(queryWrapper2); List<CsLedger> dev = this.list(queryWrapper2);
if (CollUtil.isNotEmpty(dev)) {
List<String> devIds = dev.stream().map(CsLedger::getId).collect(Collectors.toList());
//监测点
LambdaQueryWrapper<CsLedger> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.in(CsLedger::getPid, devIds);
List<CsLedger> line = this.list(queryWrapper3);
Map<String,List<CsLedger>> lineMap = line.stream().collect(Collectors.groupingBy(CsLedger::getPid));
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devIds);
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, item -> item));
dev.forEach(item -> { dev.forEach(item -> {
DevDetailDTO detail = new DevDetailDTO(); DevDetailDTO detail = new DevDetailDTO();
//监测点
List<CsLedger> lines = lineMap.get(item.getId());
if (CollUtil.isNotEmpty(lines)) {
detail.setLineList(lines.stream().map(CsLedger::getId).collect(Collectors.toList()));
}
detail.setEquipmentName(item.getName()); detail.setEquipmentName(item.getName());
detail.setEquipmentId(item.getId()); detail.setEquipmentId(item.getId());
CsLedger csLedger = projectMap.get(item.getPid());
if (csLedger != null) {
detail.setProjectId(csLedger.getId());
detail.setProjectName(csLedger.getName());
CsLedger csLedger1 = engineeringMap.get(csLedger.getPid());
if (csLedger1 != null) {
detail.setEngineeringid(csLedger1.getId());
detail.setEngineeringName(csLedger1.getName());
}
}
CsEquipmentDeliveryPO devInfo = devsMap.get(item.getId());
if (devInfo != null) {
detail.setRunStatus(devInfo.getRunStatus());
}
details.add(detail); details.add(detail);
}); });
}
}
return details; return details;
} }
@Override @Override
public List<DevDetailDTO> getEngineeringHaveDevs(List<String> list) { public List<DevDetailDTO> getEngineeringHaveDevs(List<String> list) {
List<DevDetailDTO> result = new ArrayList<>(); List<DevDetailDTO> result = new ArrayList<>();
@@ -1124,7 +1407,8 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsLedger::getPid, item); queryWrapper.eq(CsLedger::getPid, item);
List<CsLedger> project = this.list(queryWrapper); List<CsLedger> project = this.list(queryWrapper);
//工程id if (CollectionUtil.isNotEmpty(project)) {
//项目id
List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(CsLedger::getPid, projectIds); queryWrapper2.in(CsLedger::getPid, projectIds);
@@ -1134,6 +1418,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
dto.setEngineeringid(item); dto.setEngineeringid(item);
result.add(dto); result.add(dto);
} }
}
}); });
return result; return result;
} }

View File

@@ -16,6 +16,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
import com.njcn.csdevice.enums.LineBaseEnum; import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.*; import com.njcn.csdevice.mapper.*;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.*; import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -24,7 +25,7 @@ import com.njcn.csdevice.service.CsDevModelService;
import com.njcn.csdevice.service.CsLinePOService; import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.service.ICsDataSetService; import com.njcn.csdevice.service.ICsDataSetService;
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient; import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.oss.constant.OssPath; import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
@@ -153,11 +154,11 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
List<CsDataSet> list = csDataSetService.findDataSetByModelId(po1.getId()); List<CsDataSet> list = csDataSetService.findDataSetByModelId(po1.getId());
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
po.setDataSetId(list.get(0).getId()); po.setDataSetId(list.get(0).getId());
po.setClDid(list.get(0).getClDev());
} }
po.setClDid(param.getLineNo());
//监测位置 //监测位置
//DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData(); //DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
po.setPosition(param.getPosition()); po.setPosition(param.getPosition().isEmpty()?null:param.getPosition());
this.save(po); this.save(po);
//2.新增台账树信息 //2.新增台账树信息
@@ -270,6 +271,11 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public List<CsLineDTO> getAllLineDetail() {
return this.baseMapper.findLineList();
}
@Override @Override
public List<CsLinePO> getSimpleLine() { public List<CsLinePO> getSimpleLine() {
List<String> devIds = commGetDevIds(RequestUtil.getUserIndex()); List<String> devIds = commGetDevIds(RequestUtil.getUserIndex());

Some files were not shown because too many files have changed in this diff Show More