40 Commits

Author SHA1 Message Date
xy
a6f424025a feat(harmonic): 添加稳态指标方案与监测点关联功能
- 新增根据名称查询稳态指标方案的接口和实现
- 添加方案与监测点关联的保存和删除接口
- 在设备交付服务中集成稳态指标方案配置功能
- 实现监测点创建时自动关联默认方案
- 完善相关Feign客户端和服务降级处理
- 优化方法命名规范统一小写开头
2026-05-27 18:10:44 +08:00
xy
f81be47e5f refactor(harmonic): 重构事件通知服务并迁移至系统模块
- 移除 AppNotificationService 和 SmsNotificationService 服务类
- 新增消息发送服务相关接口和实现类到系统模块
- 迁移 AsyncConfig 配置类到 cs-system 模块
- 新增事件用户关系表的 Mapper、Service 接口及实现类
- 更新 CsEventPO 添加 landPoint 字段用于存储事件落点信息
- 修改事件处理逻辑使用新的消息发送 Feign 客户端
- 集成事件原因分析功能并更新数据库字段映射
- 更新设备详情 DTO 添加 nDid 属性支持
- 优化事件通知和短信发送的消息内容格式
- 移除旧的设备消息客户端依赖并使用新服务接口
2026-05-27 11:12:32 +08:00
xy
202888ca14 refactor(data): 便携式设备数据补召功能重构
- 移除接口中的方法注释以简化代码结构
- 替换Spring事务注解为动态数据源事务注解
- 删除未使用的导入包和注释掉的代码行
- 简化数据拆分服务实现类中的复杂逻辑
- 添加时间间隔处理逻辑用于不同数据表的定时入库
- 优化数据映射过程中的null值处理机制
- 重构字段值设置方法以提高类型安全性和错误处理能力
2026-05-26 16:09:26 +08:00
xy
94929e66d5 fix(service): 修复设备消息服务中的监测点空值处理
- 注释掉CsDataSetServiceImpl中多余的数据类型过滤条件
- 移除DeviceMessageServiceImpl中未使用的BusinessException导入
- 为DeviceMessageServiceImpl添加Slf4j日志注解
- 修改监测点为空时的异常抛出逻辑为日志记录并返回
- 避免因监测点为空导致的服务异常中断
2026-05-26 10:53:38 +08:00
xy
4d5950d5ad 微调 2026-05-25 20:03:54 +08:00
xy
ff7b05bbb6 feat(device): 便携式设备数据补召功能重构,补召数据拆分到13张基础数据表中 2026-05-25 19:59:47 +08:00
xy
ea2962840c feat(topology): 添加拓扑图目标指标功能并重构数据处理逻辑
- 在AppLineTopologyDiagram相关类中添加target字段用于绑定指标
- 重构DeviceMessageClient的getLineInfo方法参数结构
- 实现CsLineTopologyFeignClient的queryTopologyDiagram接口及降级处理
- 更新MqttMessageHandler中拓扑图数据处理逻辑,支持自定义指标查询
- 添加PqdData数据拆分服务IPqdDataSplitService及其实现
- 优化PortableOfflLogServiceImpl中的数据入库逻辑
- 修复CsTerminalReplyServiceImpl中时间范围查询条件
- 移除未使用的导入和代码,优化服务依赖注入
2026-05-25 14:38:35 +08:00
xy
1d8d714d66 feat(event): 添加暂降原因和类型字段支持
- 在CsEventPO实体类中新增advanceReason和advanceType字段
- 修改AnalyseComtradeCfg中的数值类型标识为大写格式(MIN/MAX/AVG/CP95)
- 将相位类型从"M"更改为"T"
- 在事件服务实现中同步暂降原因和类型数据到数据库
2026-05-21 19:56:28 +08:00
xy
23574f0819 fix(data-task): 修复数据任务中的越限标签计算和报警处理逻辑
- 修复了buildOverlimitTag方法名拼写错误,统一为buildOverLimitTag
- 添加了lineInterval参数用于越限次数到分钟数的转换计算
- 将越限次数乘以统计间隔并限制最大值为1440分钟
- 优化了CsAlarmServiceImpl中的在线率和完整性异常判断逻辑
- 重构了报警VO的数据流处理方式
- 更新了CsHarmonicServiceImpl中的枚举映射配置
- 调整了设备消息接口的参数注解配置
- 清理了无用的Jackson依赖导入
- 移除了废弃的通信离线时段计算代码
2026-05-21 15:26:54 +08:00
xy
a82ea6b217 fix(data-service): 修复相位判断逻辑并优化数据查询配置
- 统一将相位判断条件从"M"改为"T"
- 修正CT/PT变比计算逻辑,增加二次变比处理
- 移除废弃的闪变数据过滤逻辑
- 更新InfluxDB数据表名和字段名配置
- 修改服务接口参数传递方式
- 优化相位数据显示逻辑,统一相位标识处理
2026-05-20 09:26:05 +08:00
xy
16724d7d79 feat(data): 添加InfluxDB存储名称映射功能
- 在CsDataArray实体类中新增influxDbName字段用于存储InfluxDB名称
- 集成字典数据和EPD服务实现数据映射逻辑
- 修改多个服务类中的数据查询逻辑以支持别名映射
- 统一数据类型转换为大写格式提升数据一致性
- 优化时间范围计算逻辑并移除无效的数据处理代码
- 清理无用的导入包和服务依赖项
2026-05-18 18:35:40 +08:00
xy
aa36c077f2 feat(alarm): 更新告警系统以支持在线率和完整性监控
- 移除原有的中断计数功能,改为在线率和完整性告警判断
- 新增CsAlarmData类用于存储在线率和完整性详细数据
- 更新AlarmVO数据结构,替换interruptCounts为onlineRateIsWarn和integrityIsWarn字段
- 修改告警服务实现,从JSON解析List<List<String>>改为解析CsAlarmData对象
- 新增channelRunDataAlarm方法用于运行数据告警算法,处理在线率和完整性阈值判断
- 实现完整的告警数据构建逻辑,包括设备在线率计算和监测点完整性评估
- 更新统计服务中的数据去重逻辑,避免重复计算设备和监测点数据
2026-05-14 09:22:26 +08:00
xy
82e5d6c8e2 refactor(data): 优化谐波和间谐波数据一二次值处理逻辑 2026-05-09 14:20:25 +08:00
xy
76000e4fff feat(alarm): 新增告警配置管理功能
- 实现CsAlarmSetController提供新增、修改、删除、查询等REST接口
- 修复设备消息推送中的参数描述错误,将isAdmin改为推送普通用户
2026-05-08 16:31:59 +08:00
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
190 changed files with 7942 additions and 2318 deletions

View File

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

View File

@@ -6,6 +6,7 @@ import com.njcn.csdevice.api.fallback.AppProjectClientFallbackFactory;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.po.AppProjectPO;
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;
@@ -25,7 +26,7 @@ public interface AppProjectFeignClient {
@PostMapping("/getProjectByName")
HttpResult<AppProjectPO> getProjectByName(@RequestParam("name") String name);
@PostMapping("/addAppProject")
HttpResult<AppProjectPO> addAppProject(@RequestBody AppProjectAddParm appProjectAddParm);
@PostMapping("/addPortableProject")
HttpResult<AppProjectPO> addPortableProject(@Validated @RequestBody AppProjectAddParm appProjectAddParm);
}

View File

@@ -6,7 +6,6 @@ import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory;
import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
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;
@@ -36,6 +35,8 @@ public interface CsDeviceUserFeignClient {
HttpResult<DevUserVO> queryUserById(@RequestParam("devId") String devId);
@PostMapping("/getList")
@ApiOperation("根据设备集合获取数据")
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.vo.CsEdDataVO;
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.RequestParam;
@@ -14,7 +16,7 @@ import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/edData", fallbackFactory = CsEdDataFeignClientFallbackFactory.class,contextId = "edData")
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/edData", fallbackFactory = CsEdDataFeignClientFallbackFactory.class, contextId = "edData")
public interface CsEdDataFeignClient {
@PostMapping("/findByDevTypeId")
@@ -22,4 +24,7 @@ public interface CsEdDataFeignClient {
@PostMapping("/getAll")
HttpResult<List<CsEdDataPO>> getAll(@RequestParam("devType") String devType);
@GetMapping("/getById")
HttpResult<CsEdDataPO> getById(@RequestParam("id") String id);
}

View File

@@ -4,9 +4,12 @@ import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsLineTopologyClientFallbackFactory;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
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;
@@ -19,4 +22,8 @@ public interface CsLineTopologyFeignClient {
@PostMapping("/addList")
HttpResult<String> addList(@RequestBody List<AppLineTopologyDiagramPO> list);
@PostMapping("/queryTopologyDiagram")
@ApiOperation("查询装置拓扑图")
HttpResult<AppTopologyDiagramVO> queryTopologyDiagram(@RequestParam(value="devId") String devId);
}

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,35 @@
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.csdevice.param.LineInfoParam;
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(@RequestBody LineInfoParam param);
}

View File

@@ -51,9 +51,6 @@ public interface EquipmentFeignClient {
@PostMapping("/updateModuleNumber")
HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid,@RequestParam("number") Integer number);
@PostMapping("/updateLedger")
HttpResult<String> updateLedger(@RequestParam("nDid") String nDid,@RequestParam("engineeringId") String engineeringId,@RequestParam("projectId") String projectId);
@PostMapping("/getAll")
HttpResult<List<CsEquipmentDeliveryPO>> getAll();

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

@@ -41,8 +41,8 @@ public class AppProjectClientFallbackFactory implements FallbackFactory<AppProje
}
@Override
public HttpResult<AppProjectPO> addAppProject(AppProjectAddParm appProjectAddParm) {
log.error("{}异常,降级处理,异常为:{}","新增项目异常",cause.toString());
public HttpResult<AppProjectPO> addPortableProject(AppProjectAddParm appProjectAddParm) {
log.error("{}异常,降级处理,异常为:{}","新增便携式项目",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};

View File

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

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsLineTopologyFeignClient;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -33,6 +34,12 @@ public class CsLineTopologyClientFallbackFactory implements FallbackFactory<CsLi
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<AppTopologyDiagramVO> queryTopologyDiagram(String devId) {
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,51 @@
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.csdevice.param.LineInfoParam;
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(LineInfoParam param) {
log.error("{}异常,降级处理,异常为:{}","获取监测点信息数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -72,12 +72,6 @@ public class EquipmentFeignClientFallbackFactory implements FallbackFactory<Equi
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> updateLedger(String nDid, String engineeringId, String projectId) {
log.error("{}异常,降级处理,异常为:{}","更新设备预设工程和项目id数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsEquipmentDeliveryPO>> getAll() {
log.error("{}异常,降级处理,异常为:{}","获取所有装置",cause.toString());

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,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,21 @@
package com.njcn.csdevice.param;
import com.njcn.csdevice.pojo.po.CsLinePO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author xy
*/
@Data
public class LineInfoParam {
@ApiModelProperty("nDid")
private String nDid;
@ApiModelProperty("监测点集合")
List<CsLinePO> list;
}

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

@@ -115,4 +115,9 @@ public class CsEquipmentDeliveryDTO {
* 日志等级(NORMAL、DEBUG、WARN、ERROR)
*/
private String devLogLevel;
/**
* 设备软件信息id
*/
private String softinfoId;
}

View File

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

View File

@@ -1,8 +1,10 @@
package com.njcn.csdevice.pojo.dto;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
@@ -13,7 +15,7 @@ import java.util.List;
* @version V1.0.0
*/
@Data
public class LineParamDTO {
public class LineParamDTO extends BaseParam implements Serializable {
@ApiModelProperty(value = "工程id")
private String engineerId;

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

@@ -44,5 +44,6 @@ public class AppLineTopologyDiagramParm extends BaseEntity {
private Double lat;
private String target;
}

View File

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

View File

@@ -106,4 +106,9 @@ public class CsEquipmentDeliveryAddParm implements Serializable {
@ApiModelProperty(value="所属项目")
private String associatedProject;
@ApiModelProperty(value="icd")
private String icd;
@ApiModelProperty(value="是否支持升级(0:否 1:是)")
private Integer upgrade;
}

View File

@@ -110,4 +110,10 @@ public class CsEquipmentDeliveryAuditParm {
@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 io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -40,4 +41,9 @@ public class CsEquipmentDeliveryQueryParm extends BaseParam {
@ApiModelProperty("物联通讯状态 0:未连接 1:已连接")
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

@@ -45,5 +45,7 @@ public class AppLineTopologyDiagramPO extends BaseEntity {
@TableField(value = "lat")
private Double lat;
@TableField(value = "target")
private String target;
}

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
@@ -43,6 +44,12 @@ public class CsDataArray extends BaseEntity {
*/
private String anotherName;
/**
* influxdb 存储的名称
*/
@TableField(exist = false)
private String influxDbName;
/**
* 字典序号
*/

View File

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

View File

@@ -148,4 +148,14 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
@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

@@ -1,8 +1,6 @@
package com.njcn.csdevice.pojo.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -43,5 +41,6 @@ public class AppLineTopologyDiagramVO {
private String linePostion;
@ApiModelProperty(value="绑定的指标")
private String target;
}

View File

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

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,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

@@ -66,6 +66,9 @@ public class ProjectEquipmentVO {
@ApiModelProperty(value = "设备类型(监测设备:DEV_CLD 治理设备:Direct_Connected_Device)")
private String devType;
@ApiModelProperty(value = "是否存在告警(告警通过查询当日的未读的暂态事件判断)")
private Boolean isAlarm;
@ApiModelProperty(value = "监测点集合")
private List<CsLinePO> lineList;

View File

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

View File

@@ -21,6 +21,10 @@
</properties>
<dependencies>
<dependency>
<groupId>com.github.tocrhz</groupId>
<artifactId>mqtt-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-web</artifactId>
@@ -163,6 +167,11 @@
<artifactId>message-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>event-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>

View File

@@ -66,7 +66,5 @@ public class CsSoftInfoController extends BaseController {
csSoftInfoService.removeById(id);
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.web.bind.annotation.*;
import java.util.List;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
@@ -45,9 +47,9 @@ public class DevModelController extends BaseController {
@ApiOperation("新增设备模板")
@ApiImplicitParam(name = "csDevModelAddParm", value = "新增设备模板参数", required = true)
@Deprecated
public HttpResult<CsDevModelPO> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm){
public HttpResult<CsDevModelPO> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm) {
String methodDescribe = getMethodDescribe("addDevModel");
CsDevModelPO flag = csDevModelService.addDevModel (csDevModelAddParm);
CsDevModelPO flag = csDevModelService.addDevModel(csDevModelAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@@ -56,7 +58,7 @@ public class DevModelController extends BaseController {
@PostMapping("/AuditDevModel")
@ApiOperation("更新/删除设备模板参数")
@ApiImplicitParam(name = "csDevModelAuditParm", value = "更新/删除设备模板参数", required = true)
public HttpResult<Boolean> AuditDevModel(@RequestBody @Validated CsDevModelAuditParm csDevModelAuditParm ){
public HttpResult<Boolean> AuditDevModel(@RequestBody @Validated CsDevModelAuditParm csDevModelAuditParm) {
String methodDescribe = getMethodDescribe("AuditDevModel");
Boolean flag = csDevModelService.AuditDevModel(csDevModelAuditParm);
@@ -64,15 +66,14 @@ public class DevModelController extends BaseController {
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryDevModelPage")
@ApiOperation("设备模板分页查询")
@ApiImplicitParam(name = "csDevModelQueryParm", value = "设备模板查询参数", required = true)
public HttpResult<IPage<CsDevModelPageVO>> queryDevModelPage(@RequestBody @Validated CsDevModelQueryParm csDevModelQueryParm ){
public HttpResult<IPage<CsDevModelPageVO>> queryDevModelPage(@RequestBody @Validated CsDevModelQueryParm csDevModelQueryParm) {
String methodDescribe = getMethodDescribe("queryDevModelPage");
IPage<CsDevModelPageVO> page = csDevModelService.queryPage (csDevModelQueryParm);
IPage<CsDevModelPageVO> page = csDevModelService.queryPage(csDevModelQueryParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@@ -80,10 +81,10 @@ public class DevModelController extends BaseController {
@PostMapping("/queryDevModelOne")
@ApiOperation("设备模板查询")
@ApiImplicitParam(name = "csDevModelQueryListParm", value = "设备模板信息", required = true)
public HttpResult<CsDevModelPageVO> queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm){
public HttpResult<CsDevModelPageVO> queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm) {
String methodDescribe = getMethodDescribe("queryDevModelOne");
CsDevModelPageVO csDevModelPageVO = csDevModelService.queryDevModelOne(csDevModelQueryListParm);
CsDevModelPageVO csDevModelPageVO = csDevModelService.queryDevModelOne(csDevModelQueryListParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDevModelPageVO, methodDescribe);
}
@@ -91,13 +92,13 @@ public class DevModelController extends BaseController {
@PostMapping("/findModel")
@ApiOperation("根据条件查询模板")
@ApiImplicitParams({
@ApiImplicitParam(name = "devType", value = "装置类型", required = true),
@ApiImplicitParam(name = "version", value = "版本", required = true),
@ApiImplicitParam(name = "time", value = "时间", required = true)
@ApiImplicitParam(name = "devType", value = "装置类型", required = true),
@ApiImplicitParam(name = "version", value = "版本", required = true),
@ApiImplicitParam(name = "time", value = "时间", required = true)
})
public HttpResult<CsDevModelPO> findModel(@RequestParam("devType") String devType,@RequestParam("version") String version,@RequestParam("time") String time){
public HttpResult<CsDevModelPO> findModel(@RequestParam("devType") String devType, @RequestParam("version") String version, @RequestParam("time") String time) {
String methodDescribe = getMethodDescribe("findModel");
CsDevModelPO csDevModelPo = csDevModelService.findModel(devType,version,time);
CsDevModelPO csDevModelPo = csDevModelService.findModel(devType, version, time);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDevModelPo, methodDescribe);
}
@@ -105,10 +106,9 @@ public class DevModelController extends BaseController {
@PostMapping("/getModelById")
@ApiOperation("根据模板Id获取模板数据")
@ApiImplicitParam(name = "id", value = "模板id", required = true)
public HttpResult<CsDevModelPO> getModelById(@RequestParam("id") String id){
public HttpResult<CsDevModelPO> getModelById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getModelById");
CsDevModelPO po = csDevModelService.getModelById(id);
CsDevModelPO po = csDevModelService.getModelById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
}

View File

@@ -11,8 +11,11 @@ import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevCountVO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
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.controller.BaseController;
import com.njcn.web.utils.RequestUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -21,7 +24,9 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
@@ -37,6 +42,8 @@ import java.util.List;
public class DeviceUserController extends BaseController {
private final CsDeviceUserPOService csDeviceUserPOService;
private final EventUserFeignClient eventUserFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add")
@ApiOperation("新增设备扫码设备用户绑定")
@@ -174,4 +181,25 @@ public class DeviceUserController extends BaseController {
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.param.*;
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.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
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.web.advice.DeviceLog;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -46,6 +49,7 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
@@ -63,20 +67,20 @@ public class EquipmentDeliveryController extends BaseController {
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final IMqttUserService mqttUserService;
private final CsDevModelRelationService csDevModelRelationService;
private final DictTreeFeignClient dictTreeFeignClient;
private final DictTreeFeignClient dictTreeFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addEquipmentDelivery")
@ApiOperation("新增出厂设备")
@ApiImplicitParam(name = "csEquipmentDeliveryAddParm", value = "新增项目参数", required = true)
@DeviceLog(operateType = DeviceOperate.ADD)
public HttpResult<CsEquipmentDeliveryPO> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm){
public HttpResult<CsEquipmentDeliveryPO> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
String methodDescribe = getMethodDescribe("addEquipmentDelivery");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.save(csEquipmentDeliveryAddParm);
if (Objects.nonNull(po)){
if (Objects.nonNull(po)) {
//查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAddParm.getNdid());
if (result){
if (result) {
//初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid());
}
@@ -88,7 +92,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/AuditEquipmentDelivery")
@ApiOperation("删除出厂设备")
@DeviceLog(operateType = DeviceOperate.DELETE)
public HttpResult<Boolean> AuditEquipmentDelivery(@RequestParam("id")String id ){
public HttpResult<Boolean> AuditEquipmentDelivery(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("AuditEquipmentDelivery");
Boolean flag = csEquipmentDeliveryService.AuditEquipmentDelivery(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
@@ -99,13 +103,13 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("修改出厂设备")
@DeviceLog(operateType = DeviceOperate.UPDATE)
@ApiImplicitParam(name = "csEquipmentDeliveryAuditParm", value = "新增项目参数", required = true)
public HttpResult<Boolean> updateEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm ){
public HttpResult<Boolean> updateEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) {
String methodDescribe = getMethodDescribe("updateEquipmentDelivery");
Boolean flag = csEquipmentDeliveryService.updateEquipmentDelivery(csEquipmentDeliveryAuditParm);
if (flag){
if (flag) {
//查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAuditParm.getNdid());
if (result){
if (result) {
//初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(csEquipmentDeliveryAuditParm.getNdid());
}
@@ -117,9 +121,9 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/queryEquipmentByndid")
@ApiOperation("通过ndid查询出厂设备")
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid")String ndid){
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid") String ndid) {
String methodDescribe = getMethodDescribe("queryEquipmentByndid");
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentByndid (ndid);
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentByndid(ndid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryVO, methodDescribe);
}
@@ -127,9 +131,9 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/queryEquipmentByProject")
@ApiOperation("通过项目查询出厂设备")
@ApiImplicitParam(name = "projectEquipmentQueryParm", value = "项目信息", required = true)
public HttpResult<IPage<ProjectEquipmentVO>> queryEquipmentByProject(@RequestBody ProjectEquipmentQueryParm projectEquipmentQueryParm){
public HttpResult<IPage<ProjectEquipmentVO>> queryEquipmentByProject(@RequestBody ProjectEquipmentQueryParm projectEquipmentQueryParm) {
String methodDescribe = getMethodDescribe("queryEquipmentByProject");
IPage<ProjectEquipmentVO> projectEquipmentVos = csEquipmentDeliveryService.queryEquipmentByProject(projectEquipmentQueryParm);
IPage<ProjectEquipmentVO> projectEquipmentVos = csEquipmentDeliveryService.queryEquipmentByProject(projectEquipmentQueryParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, projectEquipmentVos, methodDescribe);
}
@@ -141,9 +145,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "status", value = "状态", required = true)
})
@DeviceLog(operateType = DeviceOperate.UPDATESTATUSBYNDID)
public HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status){
public HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid, @RequestParam("status") Integer status) {
String methodDescribe = getMethodDescribe("updateStatusBynDid");
csEquipmentDeliveryService.updateStatusBynDid(nDid,status);
csEquipmentDeliveryService.updateStatusBynDid(nDid, status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -151,7 +155,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/queryEquipmentById")
@ApiOperation("设备查询通过id获取")
@ApiImplicitParam(name = "ids", value = "设备id集合", required = true)
public HttpResult<List<CsEquipmentDeliveryDTO>> queryEquipmentById(@RequestParam List<String> ids){
public HttpResult<List<CsEquipmentDeliveryDTO>> queryEquipmentById(@RequestParam List<String> ids) {
String methodDescribe = getMethodDescribe("queryEquipmentById");
if (CollectionUtil.isEmpty(ids)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
@@ -171,7 +175,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/list")
@ApiOperation("出厂设备列表")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<CsEquipmentDeliveryVO>> list(@RequestBody CsEquipmentDeliveryQueryParm param){
public HttpResult<Page<CsEquipmentDeliveryVO>> list(@RequestBody CsEquipmentDeliveryQueryParm param) {
String methodDescribe = getMethodDescribe("list");
Page<CsEquipmentDeliveryVO> page = csEquipmentDeliveryService.list(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
@@ -185,9 +189,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "type", value = "类型", required = true),
@ApiImplicitParam(name = "lineId", value = "监测点id", required = false)
})
public HttpResult<DeviceManagerVO> getDeviceData(@RequestParam String deviceId,@RequestParam String type,@RequestParam String lineId){
public HttpResult<DeviceManagerVO> getDeviceData(@RequestParam String deviceId, @RequestParam String type, @RequestParam String lineId) {
String methodDescribe = getMethodDescribe("getDeviceData");
DeviceManagerVO vo = csEquipmentDeliveryService.getDeviceData(deviceId,type,lineId);
DeviceManagerVO vo = csEquipmentDeliveryService.getDeviceData(deviceId, type, lineId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
}
@@ -200,9 +204,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "module", value = "模块个数", required = true)
})
@Deprecated
public HttpResult<Boolean> updateSoftInfoBynDid(@RequestParam("nDId") String nDid,@RequestParam("id") String id,@RequestParam("module") Integer module){
public HttpResult<Boolean> updateSoftInfoBynDid(@RequestParam("nDId") String nDid, @RequestParam("id") String id, @RequestParam("module") Integer module) {
String methodDescribe = getMethodDescribe("updateSoftInfoBynDid");
csEquipmentDeliveryService.updateSoftInfoBynDid(nDid,id,module);
csEquipmentDeliveryService.updateSoftInfoBynDid(nDid, id, module);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -210,9 +214,9 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/findDevByNDid")
@ApiOperation("通过nDid查询设备信息")
@ApiImplicitParam(name = "nDid", value = "网关识别码", required = true)
public HttpResult<CsEquipmentDeliveryPO> findDevByNDid(@RequestParam("nDid")String nDid){
public HttpResult<CsEquipmentDeliveryPO> findDevByNDid(@RequestParam("nDid") String nDid) {
String methodDescribe = getMethodDescribe("findDevByNDid");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.findDevByNDid(nDid);
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.findDevByNDid(nDid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@@ -225,13 +229,13 @@ public class EquipmentDeliveryController extends BaseController {
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceExcelTemplete.class, new ArrayList<DeviceExcelTemplete>());
List<SysDicTreePO> deviceType = dictTreeFeignClient.queryByCodeList(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData();
if(!CollectionUtils.isEmpty(deviceType)){
if (!CollectionUtils.isEmpty(deviceType)) {
List<String> collect = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getName).collect(Collectors.toList());
ExcelUtil.selectList(workbook, 2, 2, collect.toArray(new String[]{}));
List<String> collect2 = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getChildren).flatMap(Collection::stream).map(SysDicTreePO::getName).collect(Collectors.toList());
ExcelUtil.selectList(workbook, 3, 3, collect2.toArray(new String[]{}));
}
ExcelUtil.selectList(workbook, 4, 4, Stream.of("MQTT","CLD").collect(Collectors.toList()).toArray(new String[]{}));
ExcelUtil.selectList(workbook, 4, 4, Stream.of("MQTT", "CLD").collect(Collectors.toList()).toArray(new String[]{}));
String fileName = "设备模板.xlsx";
ExportParams exportExcel = new ExportParams("设备模板", "设备模板");
PoiUtil.exportFileByWorkbook(workbook, fileName, response);
@@ -244,11 +248,11 @@ public class EquipmentDeliveryController extends BaseController {
public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importEquipment");
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.importEquipment(file, response);
if (!CollectionUtils.isEmpty(csEquipmentDeliveryPOS)){
csEquipmentDeliveryPOS.forEach(temp->{
if (!CollectionUtils.isEmpty(csEquipmentDeliveryPOS)) {
csEquipmentDeliveryPOS.forEach(temp -> {
//查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(temp.getNdid());
if (result){
if (result) {
//初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(temp.getNdid());
}
@@ -260,18 +264,18 @@ public class EquipmentDeliveryController extends BaseController {
@ResponseBody
@ApiOperation("联调完成")
@PostMapping(value = "testcompletion")
public HttpResult<String> testCompletion(@RequestParam("deviceId") String deviceId,@RequestParam("type") Integer type,@RequestParam("remark") String remark){
public HttpResult<String> testCompletion(@RequestParam("deviceId") String deviceId, @RequestParam("type") Integer type, @RequestParam("remark") String remark) {
String methodDescribe = getMethodDescribe("testCompletion");
csEquipmentDeliveryService.testCompletion(deviceId,type, remark);
csEquipmentDeliveryService.testCompletion(deviceId, type, remark);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@ResponseBody
@ApiOperation("取消联调")
@PostMapping(value = "deleteTest")
public HttpResult<String> deleteTest(@RequestParam("deviceId") String deviceId,@RequestParam("type") Integer type,@RequestParam("remark") String remark){
public HttpResult<String> deleteTest(@RequestParam("deviceId") String deviceId, @RequestParam("type") Integer type, @RequestParam("remark") String remark) {
String methodDescribe = getMethodDescribe("deleteTest");
csEquipmentDeliveryService.deleteTest(deviceId,type, remark);
csEquipmentDeliveryService.deleteTest(deviceId, type, remark);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -283,9 +287,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "id", value = "软件信息id", required = true)
})
@ApiIgnore
public HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid,@RequestParam("id") String id){
public HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid, @RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("updateSoftInfo");
csEquipmentDeliveryService.updateSoftInfo(nDid,id);
csEquipmentDeliveryService.updateSoftInfo(nDid, id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -297,23 +301,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "number", value = "模块个数", required = true)
})
@ApiIgnore
public HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid,@RequestParam("number") Integer number){
public HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid, @RequestParam("number") Integer number) {
String methodDescribe = getMethodDescribe("updateModuleNumber");
csEquipmentDeliveryService.updateModuleNumber(nDid,number);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateLedger")
@ApiOperation("更新设备预设工程和项目id")
@ApiImplicitParams({
@ApiImplicitParam(name = "nDid", value = "网络设备码", required = true),
@ApiImplicitParam(name = "engineeringId", value = "工程id", required = true),
@ApiImplicitParam(name = "projectId", value = "项目id", required = true)
})
public HttpResult<String> updateLedger(@RequestParam("nDid") String nDid,@RequestParam("engineeringId") String engineeringId,@RequestParam("projectId") String projectId){
String methodDescribe = getMethodDescribe("updateLedger");
csEquipmentDeliveryService.updateLedger(nDid,engineeringId,projectId);
csEquipmentDeliveryService.updateModuleNumber(nDid, number);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -321,7 +311,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/rebootDevice")
@ApiOperation("重启设备")
@ApiImplicitParam(name = "nDid", value = "nDid", required = true)
public HttpResult<String> rebootDevice(@RequestParam("nDid") String nDid){
public HttpResult<String> rebootDevice(@RequestParam("nDid") String nDid) {
String methodDescribe = getMethodDescribe("rebootDevice");
boolean result = csEquipmentDeliveryService.rebootDevice(nDid);
if (result) {
@@ -334,7 +324,7 @@ public class EquipmentDeliveryController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getAll")
@ApiOperation("获取所有装置")
public HttpResult<List<CsEquipmentDeliveryPO>> getAll(){
public HttpResult<List<CsEquipmentDeliveryPO>> getAll() {
String methodDescribe = getMethodDescribe("getAll");
List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -343,7 +333,7 @@ public class EquipmentDeliveryController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/judgeDevModel")
@ApiOperation("判断设备型号")
public HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid){
public HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid) {
String methodDescribe = getMethodDescribe("judgeDevModel");
boolean result = csEquipmentDeliveryService.judgeDevModel(nDid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -352,7 +342,7 @@ public class EquipmentDeliveryController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDevByLineId")
@ApiOperation("根据监测点id查询装置信息")
public HttpResult<CsEquipmentDeliveryPO> getDevByLineId(@RequestParam("lineId") String lineId){
public HttpResult<CsEquipmentDeliveryPO> getDevByLineId(@RequestParam("lineId") String lineId) {
String methodDescribe = getMethodDescribe("getDevByLineId");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.getDevByLineId(lineId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
@@ -363,7 +353,7 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("新增云前置设备")
@ApiImplicitParam(name = "param", value = "参数", required = true)
@DeviceLog(operateType = DeviceOperate.ADD)
public HttpResult<CsEquipmentDeliveryPO> addCldDev(@RequestBody @Validated CsEquipmentDeliveryAddParm param){
public HttpResult<CsEquipmentDeliveryPO> addCldDev(@RequestBody @Validated CsEquipmentDeliveryAddParm param) {
String methodDescribe = getMethodDescribe("addCldDev");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.saveCld(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
@@ -374,7 +364,7 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("删除云前置设备")
@ApiImplicitParam(name = "id", value = "id", required = true)
@DeviceLog(operateType = DeviceOperate.DELETE)
public HttpResult<Boolean> delCldDev(@RequestParam("id") String id){
public HttpResult<Boolean> delCldDev(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("delCldDev");
boolean result = csEquipmentDeliveryService.delCldDev(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -385,7 +375,7 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("修改云前置设备")
@ApiImplicitParam(name = "param", value = "参数", required = true)
@DeviceLog(operateType = DeviceOperate.UPDATE)
public HttpResult<Boolean> updateCldDev(@RequestBody @Validated CsEquipmentDeliveryAuditParm param){
public HttpResult<Boolean> updateCldDev(@RequestBody @Validated CsEquipmentDeliveryAuditParm param) {
String methodDescribe = getMethodDescribe("updateCldDev");
boolean result = csEquipmentDeliveryService.updateCldDev(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -399,9 +389,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "processNo", value = "进程号", required = true)
})
@ApiIgnore
public HttpResult<Boolean> updateCldDevStatus(@RequestParam("nodeId") String nodeId, @RequestParam("processNo") Integer processNo){
public HttpResult<Boolean> updateCldDevStatus(@RequestParam("nodeId") String nodeId, @RequestParam("processNo") Integer processNo) {
String methodDescribe = getMethodDescribe("updateCldDevStatus");
csEquipmentDeliveryService.updateCldDevStatus(nodeId,processNo);
csEquipmentDeliveryService.updateCldDevStatus(nodeId, processNo);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -409,14 +399,14 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/flipCldDevStatus")
@ApiOperation("云前置设备状态翻转")
@ApiImplicitParams({
@ApiImplicitParam(name = "date", value = "时间", required = true),
@ApiImplicitParam(name = "devId", value = "设备id", required = true),
@ApiImplicitParam(name = "status", value = "状态", required = true)
@ApiImplicitParam(name = "date", value = "时间", required = true),
@ApiImplicitParam(name = "devId", value = "设备id", required = true),
@ApiImplicitParam(name = "status", value = "状态", required = true)
})
@ApiIgnore
public HttpResult<Boolean> flipCldDevStatus(@RequestParam("date") String date, @RequestParam("devId") String devId, @RequestParam("status") Integer status){
public HttpResult<Boolean> flipCldDevStatus(@RequestParam("date") String date, @RequestParam("devId") String devId, @RequestParam("status") Integer status) {
String methodDescribe = getMethodDescribe("flipCldDevStatus");
csEquipmentDeliveryService.flipCldDevStatus(date,devId,status);
csEquipmentDeliveryService.flipCldDevStatus(date, devId, status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -424,10 +414,22 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/getRunPortableDev")
@ApiOperation("获取用户未绑定的在运的便携式设备")
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
public HttpResult<List<CsEquipmentDeliveryPO>> getRunPortableDev(@RequestParam("userId") String userId){
public HttpResult<List<CsEquipmentDeliveryPO>> getRunPortableDev(@RequestParam("userId") String userId) {
String methodDescribe = getMethodDescribe("getRunPortableDev");
List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getRunPortableDev(userId);
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

@@ -65,7 +65,7 @@ public class CsLedgerController extends BaseController {
@PostMapping("/AppLineTree")
@ApiOperation("app端监测点树")
public HttpResult<List<CsLedgerVO>> appLineTree(){
String methodDescribe = getMethodDescribe("AppLineTree");
String methodDescribe = getMethodDescribe("appLineTree");
List<CsLedgerVO> list = csLedgerService.appLineTree();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -0,0 +1,75 @@
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.param.LineInfoParam;
import com.njcn.csdevice.service.DeviceMessageService;
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 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 = "param", value = "参数", required = true)
public HttpResult<String> getLineInfo(@RequestBody LineInfoParam param){
String methodDescribe = getMethodDescribe("getLineInfo");
deviceMessageService.getLineInfo(param.getNDid(),param.getList());
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

@@ -65,12 +65,21 @@ public class AppProjectController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addAppProject")
@ApiOperation("新增项目")
public HttpResult<AppProjectPO> addAppProject(@Validated @RequestBody AppProjectAddParm appProjectAddParm){
public HttpResult<AppProjectPO> addAppProject(@Validated AppProjectAddParm appProjectAddParm){
String methodDescribe = getMethodDescribe("addAppProject");
AppProjectPO po = appProjectService.addAppProject(appProjectAddParm);
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)
@PostMapping("/auditAppProject")
@ApiOperation("修改/删除项目")

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.CsEdDataAuditParm;
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.service.CsEdDataService;
import com.njcn.web.controller.BaseController;
@@ -79,4 +80,14 @@ public class CsEdDataController extends BaseController {
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

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

View File

@@ -2,9 +2,6 @@ package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
@@ -15,17 +12,4 @@ import java.util.List;
* @version V1.0.0
*/
public interface CsDeviceUserPOMapper extends BaseMapper<CsDeviceUserPO> {
//查询暂态事件(未读)
int queryTempEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
//查询稳态事件(未读)
int queryTempHarmonic(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
//查询告警事件(未读)
int queryAlarmEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
//查询运行事件(未读)
int queryRunEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
}

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

@@ -16,72 +16,4 @@
<!--@mbg.generated-->
primary_user_id, sub_user_id, device_id, create_by, create_time, update_by, update_time
</sql>
<select id="queryTempEvent" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
and t2.type = 0
<if test="ids != null and ids.size > 0">
and t2.line_id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="queryAlarmEvent" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
cs_event_user t1 right join cs_alarm t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
<if test="ids != null and ids.size > 0">
and (
<foreach collection="ids" item="tag" separator=" OR ">
FIND_IN_SET(#{tag}, t2.dev_list) > 0
</foreach>
)
</if>
</select>
<select id="queryRunEvent" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
and t2.type = 2
<if test="ids != null and ids.size > 0">
and t2.device_id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="queryTempHarmonic" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
cs_event_user t1 right join cs_harmonic t2 on t1.event_id = t2.id
WHERE
t1.user_id = #{userId}
and t1.`status`= 0
<if test="ids != null and ids.size > 0">
and t2.line_id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>

View File

@@ -28,7 +28,7 @@
t1.*
from
cs_equipment_delivery t0
left join cs_line t1 on
right join cs_line t1 on
t0.id = t1.device_id
where
t0.ndid = #{id}

View File

@@ -55,4 +55,10 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
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
*/
CsEdDataVO findByDevTypeId(String devType);
/**
* @Description: 根据装置型号和版本号获取装置类型
* @param devTypeId 装置型号
* @param versionNo 版本号
* @return
*/
CsEdDataPO findByDevTypeIdAndVersionNo(String devTypeId, String versionNo);
}

View File

@@ -3,14 +3,14 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
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.param.*;
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.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
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.multipart.MultipartFile;
@@ -122,8 +122,6 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
*/
void updateModuleNumber(String nDid, Integer number);
void updateLedger(String nDid,String engineeringId,String projectId);
boolean rebootDevice(String nDid);
/**
@@ -198,4 +196,5 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
List<CsEquipmentDeliveryPO> getRunPortableDev(String userId);
IPage<DevVersionVO> versionPage(CsEquipmentDeliveryQueryParm baseParam);
}

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,20 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
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,List<CsLinePO> list);
}

View File

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

View File

@@ -0,0 +1,17 @@
package com.njcn.csdevice.service;
import com.njcn.influx.pojo.po.cs.PqdData;
import java.util.List;
import java.util.Map;
/**
* PqdData数据拆分服务
*
* @author system
* @since 2026-05-22
*/
public interface IPqdDataSplitService {
Map<String, Object> splitPqdData(List<PqdData> pqdDataList);
}

View File

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

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.mapper.AppLineTopologyDiagramMapper;
import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryParm;
import com.njcn.csdevice.pojo.param.LinePostionParam;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
@@ -13,11 +12,14 @@ import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.AppLineTopologyDiagramVO;
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
import com.njcn.csdevice.service.AppLineTopologyDiagramService;
import com.njcn.csdevice.service.AppTopologyDiagramService;
import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.service.ICsLedgerService;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.pojo.vo.DictTreeVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -41,6 +43,9 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopolo
private final CsLinePOService csLinePOService;
private final AppTopologyDiagramService appTopologyDiagramService;
private final ICsLedgerService iCsLedgerService;
private final RedisUtil redisUtil;
private final DictTreeFeignClient dictTreeFeignClient;
@Override
public AppTopologyDiagramVO query(String devId) {
CsLedger one = iCsLedgerService.lambdaQuery().eq(CsLedger::getId, devId).eq(CsLedger::getState,1).one();
@@ -73,7 +78,7 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopolo
}
public List<AppLineTopologyDiagramVO> queryByLineIds(List<String> lineIds) {
List<AppLineTopologyDiagramVO> result = new ArrayList<>();
if (lineIds != null && lineIds.size() > 0) {
if (lineIds != null && !lineIds.isEmpty()) {
result = this.getBaseMapper().queryByLineIds( lineIds);
}
return result;
@@ -83,15 +88,22 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopolo
@Override
@Transactional(rollbackFor = Exception.class)
public void auditList(LinePostionParam linePostionParam) {
linePostionParam.getPointList().forEach(temp->{
csLinePOService.lambdaUpdate().eq(CsLinePO::getLineId,temp.getLineId()).set(CsLinePO::getName,temp.getName()).set(CsLinePO::getPosition,temp.getLinePostion()).update();
this.lambdaUpdate().eq(AppLineTopologyDiagramPO::getId,temp.getId()).
eq(AppLineTopologyDiagramPO::getLineId,temp.getLineId()).set(AppLineTopologyDiagramPO::getLat,temp.getLat()).
set(AppLineTopologyDiagramPO::getLng,temp.getLng()).set(AppLineTopologyDiagramPO::getId,linePostionParam.getId()).update();
iCsLedgerService.lambdaUpdate().eq(CsLedger::getId,temp.getLineId()).set(CsLedger::getName,temp.getName()).update();
set(AppLineTopologyDiagramPO::getLng,temp.getLng()).set(AppLineTopologyDiagramPO::getId,linePostionParam.getId())
.set(AppLineTopologyDiagramPO::getTarget,temp.getTarget())
.update();
iCsLedgerService.lambdaUpdate().eq(CsLedger::getId,temp.getLineId()).set(CsLedger::getName,temp.getName()).update();
});
//修改指标后,删除缓存数据
String deviceId = csLinePOService.getById(linePostionParam.getPointList().get(0).getLineId()).getDeviceId();
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode("baseData").getData();
String key = deviceId + "#";
if (dictTreeVO != null) {
key = deviceId + "#" + dictTreeVO.getId();
}
redisUtil.delete(key);
}
}

View File

@@ -93,27 +93,33 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
@Override
public List<String> commGetDevIds(String userId) {
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)) {
devIds = csEquipmentDeliveryService.getAll().stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
} else {
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
.and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId))
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
//note 黄是在cs_market_data写入数据是用户和工程的关系
// 但是权限根据用户和设备来判断会有问题,还需要用户和工程的关系(针对营销 工程用户),所以这边还要添加用户和工程的关系
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.addAll(devs.stream().map(DevDetailDTO::getEquipmentId).distinct().collect(Collectors.toList()));
// 但是权限根据用户和设备来判断会有问题,还需要用户和工程的关系(针对营销 工程用户),所以这边还要添加用户和工程的关系
// 如果是营销 工程用户 没有配置相关工程,直接返回空的设备列表;如果有数据,也要判断下当前关注的工程里面是否包含主用户的设备,可能出现没有关注该工程,但是因为是设备的主用户导致数据统计错误
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 如果是游客,则还需要加入系统配置的设备
String roleString = RequestUtil.getUserRole();
if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
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)
.and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId))
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
}
}
if (!CollUtil.isEmpty(devIds)) {
devIds = devIds.stream().distinct().collect(Collectors.toList());

View File

@@ -1,22 +1,26 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsDataArrayMapper;
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
import com.njcn.csdevice.pojo.param.DataArrayParam;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerDetailVO;
import com.njcn.csdevice.service.ICsDataArrayService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -33,6 +37,7 @@ import java.util.stream.Collectors;
public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDataArray> implements ICsDataArrayService {
private final EpdFeignClient epdFeignClient;
private final DicDataFeignClient dicDataFeignClient;
@Override
public List<CsDataArray> getArrayBySet(String dataSet) {
@@ -52,7 +57,7 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
for (Map.Entry<String, List<EleEpdPqd>> entry : map.entrySet()) {
DeviceManagerDetailVO vo = new DeviceManagerDetailVO();
EleEpdPqd eleEpdPqd = entry.getValue().get(0);
if (Objects.equals(eleEpdPqd.getPhase(),"M")){
if (Objects.equals(eleEpdPqd.getPhase(),"T")){
vo.setPhasic("/");
} else {
vo.setPhasic(entry.getValue().stream().map(EleEpdPqd::getPhase).collect(Collectors.joining(",")));
@@ -104,7 +109,7 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
DataArrayTreeVO vo3 = new DataArrayTreeVO();
vo3.setId(item.getDataSetId() + item.getDataArrayName()+item2);
vo3.setName(item2);
if (Objects.equals(item2,"M")){
if (Objects.equals(item2,"T")){
vo3.setShowName("无相别");
} else {
vo3.setShowName(item2);
@@ -173,7 +178,34 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
@Override
public List<CsDataArray> findListByParam(DataArrayParam param) {
return this.baseMapper.findListByParam(param);
List<CsDataArray> list = this.baseMapper.findListByParam(param);
if (!CollectionUtils.isEmpty(list)) {
DictData pqd = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
if (ObjectUtil.isNotNull(pqd) && ObjectUtil.isNotNull(pqd.getId())) {
List<EleEpdPqd> epdList = epdFeignClient.dictMarkByDataType(pqd.getId()).getData();
if (!CollectionUtils.isEmpty(epdList)) {
Map<String, EleEpdPqd> epdPqdMap = epdList.stream().collect(Collectors.toMap(EleEpdPqd::getId, Function.identity()));
list.forEach(item->{
EleEpdPqd epdPqd = epdPqdMap.get(item.getDataId());
if (!Objects.isNull(epdPqd)) {
if (epdPqd.getOtherName() == null || epdPqd.getOtherName().isEmpty()) {
item.setInfluxDbName(epdPqd.getName());
} else {
String[] parts = item.getName().split("_");
String lastPart = parts[parts.length - 1];
boolean isLastNumeric = lastPart.matches("\\d+");
if (isLastNumeric) {
item.setInfluxDbName(epdPqd.getOtherName() + "_" + lastPart);
} else {
item.setInfluxDbName(epdPqd.getOtherName());
}
}
}
});
}
}
}
return list;
}
@Override

View File

@@ -38,7 +38,7 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
.eq(CsDataSet::getPid,modelId)
.in(CsDataSet::getType, Arrays.asList(0,2))
.eq(CsDataSet::getStoreFlag,1)
.and(i->i.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
// .and(i->i.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
.orderByAsc(CsDataSet::getIdx)
.list();
}

View File

@@ -10,14 +10,16 @@ import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
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.po.*;
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.DevUserVO;
import com.njcn.csdevice.service.*;
import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.cssystem.api.FeedBackFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.harmonic.utils.PublicDataUtils;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.enums.AppRoleEnum;
@@ -30,8 +32,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import static java.util.Objects.isNull;
@@ -51,14 +55,12 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
private final CsDevModelRelationService csDevModelRelationService;
private final ICsLedgerService iCsLedgerService;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final RoleEngineerDevService roleEngineerDevService;
private final AppLineTopologyDiagramService appLineTopologyDiagramService;
private final CsTouristDataPOService csTouristDataPOService;
private final CsLinePOService csLinePOService;
private final CsMarketDataMapper csMarketDataMapper;
private final EventUserFeignClient eventUserFeignClient;
private final UserFeignClient userFeignClient;
private final FeedBackFeignClient feedBackFeignClient;
private final IMqttUserService mqttUserService;
@Override
@@ -122,17 +124,61 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
DevCountVO vo = new DevCountVO();
//获取app用户的台账树包含四个层级 工程、项目、设备、监测点
List<CsLedgerVO> appLedger = iCsLedgerService.appLineTree();
//判断当前用户,如果是游客,则需要筛选数据,只保留游客的数据
String roleString = RequestUtil.getUserRole();
if (roleString.contains(AppRoleEnum.TOURIST.getCode())) {
List<CsTouristDataParmVO> csTouristDataParmVOList = csTouristDataPOService.queryAll();
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);
}
return hasValidDevice;
})
.collect(Collectors.toList());
engineering.setChildren(validProjects);
hasValidProject = CollectionUtil.isNotEmpty(validProjects);
}
return hasValidProject;
})
.collect(Collectors.toList());
} else {
// 如果游客没有配置任何数据权限,返回空列表
appLedger = new ArrayList<>();
}
}
if (CollectionUtil.isNotEmpty(appLedger)) {
//获取第一层项目层级
List<CsLedgerVO> firstLevelList = new ArrayList<>();
//获取第三层设备层级
List<CsLedgerVO> thirdLevelList = new ArrayList<>();
//获取第四层设备层级
List<CsLedgerVO> forthLevelList = new ArrayList<>();
for (CsLedgerVO firstLevel : appLedger) {
firstLevelList.add(firstLevel);
if (CollectionUtil.isNotEmpty(firstLevel.getChildren())) {
for (CsLedgerVO secondLevel : firstLevel.getChildren()) {
if (CollectionUtil.isNotEmpty(secondLevel.getChildren())) {
thirdLevelList.addAll(secondLevel.getChildren());
for (CsLedgerVO threeLevel : secondLevel.getChildren()) {
if (CollectionUtil.isNotEmpty(threeLevel.getChildren())) {
forthLevelList.addAll(threeLevel.getChildren());
}
}
}
}
}
@@ -159,19 +205,34 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
vo.setOffLineDevCount(offlineDevs.size());
vo.setOffLineDevs(offlineDevs);
}
} else {
return vo;
}
//获取未读事件数量
int eventCount = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setEventCount(eventCount);
if (CollectionUtil.isNotEmpty(forthLevelList)) {
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(forthLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
int harmonicCount = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setHarmonicCount(harmonicCount);
List<String> eventCount = eventUserFeignClient.queryTempEvent(param1).getData();
vo.setEventCount(CollectionUtil.isNotEmpty(eventCount)?eventCount.size():0);
List<String> harmonicCount = eventUserFeignClient.queryTempHarmonic(param1).getData();
vo.setHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount)?harmonicCount.size():0);
}
if (CollectionUtil.isNotEmpty(thirdLevelList)) {
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(thirdLevelList.stream().map(CsLedgerVO::getId).collect(Collectors.toList()));
int alarmCount = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setAlarmCount(alarmCount);
int runCount = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
vo.setRunCount(runCount);
List<String> alarmCount = eventUserFeignClient.queryAlarmEvent(param1).getData();
vo.setAlarmCount(CollectionUtil.isNotEmpty(alarmCount)?alarmCount.size():0);
List<String> runCount = eventUserFeignClient.queryRunEvent(param1).getData();
vo.setRunCount(CollectionUtil.isNotEmpty(runCount)?runCount.size():0);
}
//note 当前工程数据
//当前工程id
@@ -226,143 +287,35 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
}
//获取未读事件数量
if (CollectionUtil.isNotEmpty(currentLineIds)) {
int eventCount2 = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
vo.setCurrentEventCount(eventCount2);
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(currentLineIds);
int harmonicCount2 = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
vo.setCurrentHarmonicCount(harmonicCount2);
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)) {
int alarmCount2 = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
vo.setCurrentAlarmCount(alarmCount2);
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
param1.setUserId(RequestUtil.getUserIndex());
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
param1.setEndTime(PublicDataUtils.calculateMonthEnd(time));
param1.setEventIds(currentDevIds);
int runCount2 = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
vo.setCurrentRunCount(runCount2);
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;
}
// @Override
// public DevCountVO devCount(String id,String time) {
// QueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new QueryWrapper<>();
//
// DevCountVO devCountVO = new DevCountVO();
//
// String userRole = RequestUtil.getUserRole();
// List<String> strings = JSONArray.parseArray(userRole, String.class);
// if(CollectionUtils.isEmpty(strings)){
// throw new BusinessException(AlgorithmResponseEnum.UNKNOW_ROLE);
//
// }
// userRole=strings.get(0);
//
// List<String> device = roleEngineerDevService.getDevice();
// if(CollectionUtils.isEmpty(device)){
// devCountVO.setOnLineDevCount(0);
// devCountVO.setOnLineDevs(new ArrayList<>());
// devCountVO.setOffLineDevCount(0);
// devCountVO.setOffLineDevs(new ArrayList<>());
// }else {
// queryWrapper.clear();
// 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.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(null);
// //由于多加了一程便携式设备
// List<String> collect1 = deviceTree.stream()
// .map(CsLedgerVO::getChildren).flatMap(Collection::stream)
// .filter(temp -> temp.getId().equals(id))
// .map(CsLedgerVO::getChildren).flatMap(Collection::stream)
// .map(CsLedgerVO::getChildren).flatMap(Collection::stream)
// .map(CsLedgerVO::getId).collect(Collectors.toList());
// //求交集
// device.retainAll(collect1);
// if(CollectionUtils.isEmpty(device)){
// devCountVO.setCurrentOnLineDevCount(0);
// devCountVO.setCurrentOnLineDevs(new ArrayList<>());
// devCountVO.setCurrentOffLineDevCount(0);
// devCountVO.setCurrentOffLineDevs(new ArrayList<>());
// devCountVO.setCurrentProjectCount(0);
//
// }else {
// queryWrapper.clear();
// 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");
//
// //查询暂态事件、运行事件还是使用之前的方法
// List<EventDetailVO> data = eventUserFeignClient.queryEventList(csEventUserQueryParam).getData();
// //查询稳态事件 先获取监测点id
// csLinePOService.getLinesByDevList(device);
//
//
// //查询运行告警事件
//
//
//
//
// List<EventDetailVO> event = data.stream().filter(temp -> temp.getType() == 0).collect(Collectors.toList());
// List<EventDetailVO> harmonic = data.stream().filter(temp -> temp.getType() == 1).collect(Collectors.toList());
// List<EventDetailVO> alarm = data.stream().filter(temp -> temp.getType() == 3).collect(Collectors.toList());
//
// if(Objects.equals(userRole, AppRoleEnum.APP_VIP_USER.getCode())){
// alarm = alarm.stream().filter(temp -> Objects.equals("3", temp.getLevel())).collect(Collectors.toList());
// }
// List<EventDetailVO> run = data.stream().filter(temp -> temp.getType() == 2).collect(Collectors.toList());
// if(Objects.equals(userRole,AppRoleEnum.APP_VIP_USER.getCode())||Objects.equals(userRole,AppRoleEnum.TOURIST.getCode())
// ||Objects.equals(userRole,AppRoleEnum.MARKET_USER.getCode())){
// devCountVO.setFeedBackCount(0);
//
// }else {
// CsFeedbackQueryParm csFeedbackQueryParm = new CsFeedbackQueryParm();
// csFeedbackQueryParm.setPageNum(1);
// csFeedbackQueryParm.setPageSize(100000);
// 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 后续添加警告数,事件数
// devCountVO.setEventCount(event.size());
// devCountVO.setAlarmCount(alarm.size());
// devCountVO.setRunCount(run.size());
// devCountVO.setHarmonicCount(harmonic.size());
// 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<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());
//
// devCountVO.setCurrentEventCount(curEvent.size());
// devCountVO.setCurrentAlarmCount(curAlarm.size());
// devCountVO.setCurrentRunCount(curRun.size());
// devCountVO.setCurrentHarmonicCount(curHarmonic.size());
//
//
// return devCountVO;
// }
/**
* @Description: 判断当前用户是否是主用户 0-否1-是
* @Param:
@@ -510,16 +463,16 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
@Override
public DevUserVO queryUserById(String devId) {
DevUserVO devUser = new DevUserVO();
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, devId).eq(CsDeviceUserPO::getStatus, "1").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<User> data = userFeignClient.appuserByIdList(collect).getData();
String primaryUserId = list.get(0).getPrimaryUserId();
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());
DevUserVO devUser = new DevUserVO();
devUser.setDevId(devId);
devUser.setSubUsers(subUser);
devUser.setMasterUser(primaryUser.get(0));
@@ -533,6 +486,21 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
if (CollectionUtil.isNotEmpty(list)){
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;
}
@@ -578,4 +546,59 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
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;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -40,33 +41,35 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
@Override
@Transactional(rollbackFor = {Exception.class})
public boolean addEdData(CsEdDataAddParm csEdDataAddParm) {
CsEdDataPO csEdDataPO = new CsEdDataPO ();
BeanUtils.copyProperties (csEdDataAddParm, csEdDataPO);
String filePath = fileStorageUtil.uploadMultipart (csEdDataAddParm.getFile (), OssPath.EDDATA);
csEdDataPO.setFilePath (filePath);
csEdDataPO.setStatus ("1");
boolean save = this.save (csEdDataPO);
CsEdDataPO csEdDataPO = new CsEdDataPO();
BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO);
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.setStatus("1");
boolean save = this.save(csEdDataPO);
return save;
}
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean auditEdData(CsEdDataAuditParm csEdDataAuditParm) {
CsEdDataPO csEdDataPO = new CsEdDataPO ();
BeanUtils.copyProperties (csEdDataAuditParm, csEdDataPO);
if(!Objects.isNull (csEdDataAuditParm.getFile ())){
String filePath = fileStorageUtil.uploadMultipart (csEdDataAuditParm.getFile (), OssPath.EDDATA);
csEdDataPO.setFilePath (filePath);
CsEdDataPO csEdDataPO = new CsEdDataPO();
BeanUtils.copyProperties(csEdDataAuditParm, csEdDataPO);
if (!Objects.isNull(csEdDataAuditParm.getFile())) {
String filePath = fileStorageUtil.uploadMultipart(csEdDataAuditParm.getFile(), StrUtil.SLASH + OssPath.EDDATA + csEdDataAuditParm.getDevTypeName() + StrUtil.SLASH + csEdDataAuditParm.getVersionNo() + StrUtil.SLASH, true);
csEdDataPO.setFilePath(filePath);
}
boolean b = this.updateById (csEdDataPO);
boolean b = this.updateById(csEdDataPO);
return b;
}
@Override
public IPage<CsEdDataVO> queryEdDataPage(CsEdDataQueryParm csEdDataQueryParm) {
Page<CsEdDataVO> returnpage = new Page<> (csEdDataQueryParm.getPageNum ( ), csEdDataQueryParm.getPageSize ( ));
Page<CsEdDataVO> returnpage = new Page<>(csEdDataQueryParm.getPageNum(), csEdDataQueryParm.getPageSize());
returnpage = this.getBaseMapper ().getPage(returnpage,csEdDataQueryParm);
returnpage = this.getBaseMapper().getPage(returnpage, csEdDataQueryParm);
return returnpage;
}
@@ -74,15 +77,21 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
public CsEdDataVO findByDevTypeId(String devType) {
CsEdDataPO csEdDataPo = new CsEdDataPO();
LambdaQueryWrapper<CsEdDataPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEdDataPO::getDevType,devType);
lambdaQueryWrapper.eq(CsEdDataPO::getStatus,1);
lambdaQueryWrapper.eq(CsEdDataPO::getDevType, devType);
lambdaQueryWrapper.eq(CsEdDataPO::getStatus, 1);
List<CsEdDataPO> list = this.baseMapper.selectList(lambdaQueryWrapper);
if (!CollectionUtils.isEmpty(list)){
if (!CollectionUtils.isEmpty(list)) {
csEdDataPo = list.get(0);
}
CsEdDataVO csEdDataVo = new CsEdDataVO();
BeanUtils.copyProperties(csEdDataPo,csEdDataVo);
BeanUtils.copyProperties(csEdDataPo, 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

@@ -255,7 +255,9 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
CsEngineeringPO po = new CsEngineeringPO();
po.setId(item.getEngineeringid());
po.setName(map.get(item.getEngineeringid()).getName());
result.add(po);
if (!Objects.equals(po.getName(), "便携式工程")) {
result.add(po);
}
});
}
}

View File

@@ -316,8 +316,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = finalCsLinePOList.get(0).getCtRatio();
Double pt = finalCsLinePOList.get(0).getPtRatio();
Double ct = finalCsLinePOList.get(0).getCtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getCt2Ratio())?1.0:finalCsLinePOList.get(0).getCt2Ratio());
Double pt = finalCsLinePOList.get(0).getPtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getPt2Ratio())?1.0:finalCsLinePOList.get(0).getPt2Ratio());
if(CollectionUtil.isNotEmpty(commonStatisticalQueryParam.getList())){
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
@@ -327,13 +327,17 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
commonQueryParam.setColumnName(epdPqd.getName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
} else {
commonQueryParam.setColumnName(epdPqd.getOtherName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
}
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(commonStatisticalQueryParam.getStartTime(),DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
commonQueryParam.setEndTime(DateUtil.format(DateUtil.endOfDay(DateUtil.parse(commonStatisticalQueryParam.getEndTime(),DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN));
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType().toUpperCase());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
return commonQueryParam;
@@ -343,7 +347,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -451,21 +455,6 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
vo.setAnotherName(epdPqd.getShowName());
return vo;
}).collect(Collectors.toList());
//长时闪变
if (Objects.equals(epdPqd.getOtherName(), "plt")) {
List<Instant> timeInstants = getTimeInstants(commonStatisticalQueryParam.getStartTime(), commonStatisticalQueryParam.getEndTime(), 2, ChronoUnit.HOURS, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
//短时闪变 || 电压波动
else if (Objects.equals(epdPqd.getOtherName(), "pst") || Objects.equals(epdPqd.getOtherName(), "fluc")) {
List<Instant> timeInstants = getTimeInstants(commonStatisticalQueryParam.getStartTime(), commonStatisticalQueryParam.getEndTime(), 10, ChronoUnit.MINUTES, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
result.addAll(collect1);
});
}
@@ -493,8 +482,13 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency);
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency);
} else {
commonQueryParam.setColumnName(epdPqd.getOtherName()+ finalFrequency);
}
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType() == null ? DataParam.portableDevStatisticalMethods:commonStatisticalQueryParam.getValueType());
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType() == null ? DataParam.portableDevStatisticalMethods.toUpperCase():commonStatisticalQueryParam.getValueType().toUpperCase());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
return commonQueryParam;
@@ -503,7 +497,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -587,11 +581,10 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<Instant> instants = new ArrayList<>();
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
// 转换为指定时区的 ZonedDateTime
ZonedDateTime current = startDate.atStartOfDay(zone);
ZonedDateTime endDateTime = endDate.atTime(23, 59, 59).atZone(zone);
while (!current.isAfter(endDateTime)) {
instants.add(current.toInstant());
ZonedDateTime endDateTime = endDate.plusDays(1).atStartOfDay(zone);
while (current.isBefore(endDateTime)) {
instants.add(current.toInstant().plusSeconds(zone.getRules().getOffset(current.toInstant()).getTotalSeconds()));
current = current.plus(interval, unit);
}
return instants;
@@ -659,7 +652,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -759,7 +752,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -838,8 +831,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())) {
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = finalCsLinePO.getCtRatio();
Double pt = finalCsLinePO.getPtRatio();
Double ct = finalCsLinePO.getCtRatio() / (Objects.isNull(finalCsLinePO.getCt2Ratio())?1.0:finalCsLinePO.getCt2Ratio());
Double pt = finalCsLinePO.getPtRatio() / (Objects.isNull(finalCsLinePO.getPt2Ratio())?1.0:finalCsLinePO.getPt2Ratio());
if(CollectionUtil.isNotEmpty(trendDataQueryParam.getList())) {
for (TrendDataQueryParam param : trendDataQueryParam.getList()) {
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
@@ -847,14 +840,16 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(finalCsLinePO.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
commonQueryParam.setColumnName(epdPqd.getName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
} else {
commonQueryParam.setColumnName(epdPqd.getOtherName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
}
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(trendDataQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
commonQueryParam.setEndTime(DateUtil.format(DateUtil.endOfDay(DateUtil.parse(trendDataQueryParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN));
commonQueryParam.setDataType(trendDataQueryParam.getValueType());
commonQueryParam.setDataType(trendDataQueryParam.getValueType().toUpperCase());
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(finalCsLinePO.getLineId()));
List<StatisticalDataDTO> deviceRtData = commonService.getNewDeviceRtDataByTime(Collections.singletonList(commonQueryParam));
@@ -862,7 +857,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M", temp.getPhaseType()) ? null : temp.getPhaseType());
vo.setPhase(Objects.equals("T", temp.getPhaseType()) ? null : temp.getPhaseType());
String position = finalCsLinePO.getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -970,21 +965,6 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
vo.setAnotherName(epdPqd.getShowName());
return vo;
}).collect(Collectors.toList());
//长时闪变
if (Objects.equals(epdPqd.getOtherName(), "plt")) {
List<Instant> timeInstants = getTimeInstants(trendDataQueryParam.getSearchBeginTime(), trendDataQueryParam.getSearchEndTime(), 2, ChronoUnit.HOURS, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
//短时闪变 || 电压波动
else if (Objects.equals(epdPqd.getOtherName(), "pst") || Objects.equals(epdPqd.getOtherName(), "fluc")) {
List<Instant> timeInstants = getTimeInstants(trendDataQueryParam.getSearchBeginTime(), trendDataQueryParam.getSearchEndTime(), 10, ChronoUnit.MINUTES, DEFAULT_ZONE);
collect1 = collect1.stream()
.filter(vo -> timeInstants.contains(vo.getTime()))
.collect(Collectors.toList());
}
result.addAll(collect1);
}
}
@@ -1000,9 +980,10 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = finalCsLinePO.getCtRatio();
Double pt = finalCsLinePO.getPtRatio();
// String position = finalCsLinePO.getPosition();
Double ct = finalCsLinePO.getCtRatio() / (Objects.isNull(finalCsLinePO.getCt2Ratio())?1.0:finalCsLinePO.getCt2Ratio());
Double pt = finalCsLinePO.getPtRatio() / (Objects.isNull(finalCsLinePO.getPt2Ratio())?1.0:finalCsLinePO.getPt2Ratio());
// String position = finalCsLinePO.getPosition();
Overlimit overlimit = overLimitWlMapper.selectById(finalCsLinePO.getLineId());
if (Objects.isNull(overlimit)) {
throw new BusinessException("当前测点限值信息缺失,请联系管理员排查");
@@ -1038,7 +1019,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
// vo.setLineName(finalCsLinePO.getName());
vo.setPhase(Objects.equals("M", temp.getPhaseType()) ? null : temp.getPhaseType());
vo.setPhase(Objects.equals("T", temp.getPhaseType()) ? null : temp.getPhaseType());
// vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(commonQueryParam.getDataType());
@@ -1208,7 +1189,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
TrendDataQueryParam trendDataQueryParam = new TrendDataQueryParam();
trendDataQueryParam.setSearchBeginTime(param.getSearchBeginTime());
trendDataQueryParam.setSearchEndTime(param.getSearchEndTime());
trendDataQueryParam.setValueType(param.getValueType());
trendDataQueryParam.setValueType(param.getValueType().toUpperCase());
trendDataQueryParam.setDataLevel(param.getDataLevel());
List<SensitiveUserTrendDataQueryParam> paramList = param.getList();
List<TrendDataQueryParam> indexList = paramList.stream().map(item -> {

View File

@@ -21,7 +21,6 @@ import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.param.CsLedgerParam;
import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.CsMarketDataVO;
import com.njcn.csdevice.service.*;
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
@@ -72,7 +71,6 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
private final UserFeignClient userFeignClient;
private final ICsUserPinsService csUserPinsService;
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
private final CsMarketDataFeignClient csMarketDataFeignClient;
@Override
@@ -292,22 +290,24 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
tree.addAll(new ArrayList<>(engineeringMap.values()));
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0);
portable1.setName("便携式工程");
portable1.setPid("0");
portable1.setId(id);
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);
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);
portable1.setChildren(Collections.singletonList(portable2));
tree.add(portable1);
}
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 4);
@@ -704,24 +704,26 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
tree.addAll(new ArrayList<>(engineeringMap.values()));
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0);
portable1.setName("便携式工程");
portable1.setPid("0");
portable1.setId(id);
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);
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);
List<CsLedgerVO> portable2List = new ArrayList<>();
portable2List.add(portable2);
portable1.setChildren(portable2List);
tree.add(portable1);
}
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 4);
@@ -844,6 +846,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
device.setEquipmentName(dev.getName());
device.setEquipmentId(devId);
device.setDevMac(po.getMac());
device.setNDid(po.getNdid());
device.setProjectId("/");
device.setProjectName("/");
device.setEngineeringid("/");
@@ -852,6 +855,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
device.setEquipmentName(dev.getName());
device.setEquipmentId(devId);
device.setDevMac(po.getMac());
device.setNDid(po.getNdid());
CsLedger project = this.findDataById(dev.getPid());
if (ObjectUtil.isNotNull(project)) {
device.setProjectId(project.getId());
@@ -1296,9 +1300,19 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollectionUtil.isNotEmpty(enginingeringIds)) {
List<CsLedger> engineer = this.listByIds(enginingeringIds);
engineer.forEach(item -> {
List<String> devNames = new ArrayList<>();
List<String> devIds = new ArrayList<>();
DevDetailDTO detail = new DevDetailDTO();
detail.setEngineeringid(item.getId());
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);
});
}
@@ -1341,11 +1355,25 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
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 -> {
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.setEquipmentId(item.getId());
@@ -1381,15 +1409,17 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsLedger::getPid, item);
List<CsLedger> project = this.list(queryWrapper);
//工程id
List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(CsLedger::getPid, projectIds);
List<CsLedger> dev = this.list(queryWrapper2);
if (CollectionUtil.isNotEmpty(dev)) {
DevDetailDTO dto = new DevDetailDTO();
dto.setEngineeringid(item);
result.add(dto);
if (CollectionUtil.isNotEmpty(project)) {
//项目id
List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(CsLedger::getPid, projectIds);
List<CsLedger> dev = this.list(queryWrapper2);
if (CollectionUtil.isNotEmpty(dev)) {
DevDetailDTO dto = new DevDetailDTO();
dto.setEngineeringid(item);
result.add(dto);
}
}
});
return result;

View File

@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.access.api.CsLineLatestDataFeignClient;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
@@ -24,7 +23,11 @@ import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO;
import com.njcn.csdevice.service.CsDevModelService;
import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.service.ICsDataSetService;
import com.njcn.csharmonic.api.CsHarmonicPlanFeignClient;
import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
@@ -64,7 +67,6 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
private final ICsDataSetService csDataSetService;
private final DicDataFeignClient dicDataFeignClient;
private final CsTerminalLogsMapper csTerminalLogsMapper;
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
private final FileStorageUtil fileStorageUtil;
@@ -72,6 +74,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
private final DictTreeFeignClient dictTreeFeignClient;
private final CsHarmonicPlanFeignClient csHarmonicPlanFeignClient;
private final CsHarmonicPlanLineFeignClient csHarmonicPlanLineFeignClient;
@Override
@@ -158,7 +162,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
po.setClDid(param.getLineNo());
//监测位置
//DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
po.setPosition(param.getPosition());
po.setPosition(param.getPosition().isEmpty()?null:param.getPosition());
this.save(po);
//2.新增台账树信息
@@ -171,6 +175,17 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
csLedger.setState(1);
csLedger.setSort(0);
csLedgerMapper.insert(csLedger);
//3.新增稳态事件指标配置
csHarmonicPlanLineFeignClient.deleteByLineIds(Collections.singletonList(lineId));
List<CsHarmonicPlan> planList = csHarmonicPlanFeignClient.getByName("通用方案").getData();
if (CollectionUtil.isNotEmpty(planList)) {
CsHarmonicPlan plan = planList.get(0);
CsHarmonicPlanLineParam param1 = new CsHarmonicPlanLineParam();
param1.setId(plan.getId());
param1.setLineIds(Collections.singletonList(lineId));
csHarmonicPlanLineFeignClient.savePlanLines(param1);
}
return po;
}
@@ -234,6 +249,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
this.removeById(id);
csLedgerMapper.deleteById(id);
//删除稳态事件指标配置
csHarmonicPlanLineFeignClient.deleteByLineIds(Collections.singletonList(id));
//新增台账日志
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();

View File

@@ -66,6 +66,8 @@ public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper,
wrapper.eq(CsTerminalLogs::getIsPush, 0);
List<CsTerminalLogs> list = this.list(wrapper);
if (CollectionUtil.isNotEmpty(list)) {
//先清空缓存
redisUtil.delete(RequestUtil.getUserIndex()+"reply");
//新增台账集合
List<String> addList = new ArrayList<>();
//修改台账集合
@@ -97,42 +99,44 @@ public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper,
});
//整合后 所有设备的id
List<String> devList = Stream.of(addList, updateList, deleteList).flatMap(List::stream).collect(Collectors.toList());
//获取设备集合
List<CsEquipmentDeliveryPO> deviceList = csEquipmentDeliveryService.listByIds(devList);
//按照前置机id分组
Map<String,List<CsEquipmentDeliveryPO>> nodeMap = deviceList.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
nodeMap.forEach((k,v)->{
int maxProcessNum = nodeService.getNodeById(k).getMaxProcessNum();
//按照进程号分组
Map<Integer,List<CsEquipmentDeliveryPO>> nodeProcessMap = v.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess));
nodeProcessMap.forEach((k1,v1)->{
if (v1.size() > 10) {
//一个进程下修改的设备数量超过10台重启该进程号下的前置
CldControlMessage cldControlMessage = new CldControlMessage();
cldControlMessage.setGuid(IdUtil.simpleUUID());
cldControlMessage.setCode("set_process");
cldControlMessage.setProcessNo(k1);
cldControlMessage.setFun("delete");
cldControlMessage.setProcessNum(maxProcessNum);
controlMessageTemplate.sendMember(cldControlMessage,k);
}
if (CollectionUtil.isNotEmpty(devList)) {
//获取设备集合
List<CsEquipmentDeliveryPO> deviceList = csEquipmentDeliveryService.listByIds(devList);
//按照前置机id分组
Map<String,List<CsEquipmentDeliveryPO>> nodeMap = deviceList.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
nodeMap.forEach((k,v)->{
int maxProcessNum = nodeService.getNodeById(k).getMaxProcessNum();
//按照进程号分组
Map<Integer,List<CsEquipmentDeliveryPO>> nodeProcessMap = v.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess));
nodeProcessMap.forEach((k1,v1)->{
if (v1.size() > 10) {
//一个进程下修改的设备数量超过10台重启该进程号下的前置
CldControlMessage cldControlMessage = new CldControlMessage();
cldControlMessage.setGuid(IdUtil.simpleUUID());
cldControlMessage.setCode("set_process");
cldControlMessage.setProcessNo(k1);
cldControlMessage.setFun("delete");
cldControlMessage.setProcessNum(maxProcessNum);
controlMessageTemplate.sendMember(cldControlMessage,k);
}
});
});
});
if (CollectionUtil.isNotEmpty(addList)) {
sendMessage(addList, deviceList, "add_terminal");
}
if (CollectionUtil.isNotEmpty(updateList)) {
sendMessage(updateList, deviceList, "ledger_modify");
}
if (CollectionUtil.isNotEmpty(deleteList)) {
sendDeleteMessage(deleteList, list, "delete_terminal");
}
if (CollectionUtil.isNotEmpty(addList)) {
sendMessage(addList, deviceList, "add_terminal");
}
if (CollectionUtil.isNotEmpty(updateList)) {
sendMessage(updateList, deviceList, "ledger_modify");
}
if (CollectionUtil.isNotEmpty(deleteList)) {
sendDeleteMessage(deleteList, list, "delete_terminal");
}
//推送完将数据改成推送
LambdaUpdateWrapper<CsTerminalLogs> wrapper2 = new LambdaUpdateWrapper<>();
wrapper2.set(CsTerminalLogs::getIsPush, 1);
this.update(wrapper2);
//推送完将数据改成推送
LambdaUpdateWrapper<CsTerminalLogs> wrapper2 = new LambdaUpdateWrapper<>();
wrapper2.set(CsTerminalLogs::getIsPush, 1);
this.update(wrapper2);
}
} else {
return "暂无需要推送的数据";
}

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -57,53 +58,98 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
List<String> redisList = Stream.of(object.toString().split(",")).collect(Collectors.toList());
List<CsTerminalReply> list = this.lambdaQuery().in(CsTerminalReply::getReplyId,redisList).orderByAsc(CsTerminalReply::getCreateTime).list();
if (CollectionUtil.isNotEmpty(list)) {
Map<Integer,List<CsTerminalReply>> map = list.stream().collect(Collectors.groupingBy(CsTerminalReply::getIsReceived));
List<CsTerminalReply> list1 = map.get(1);
if (CollectionUtil.isEmpty(list1)) {
String key = "更新失败,未收到前置应答,请查看应答报文是否发送";
result.add(key);
//将cs_terminal_logs数据置为未发送
list.forEach(item->{
list.forEach(item->{
String key;
String code = "";
if (Objects.equals(item.getCode(), "add_terminal")) {
code = "新增";
} else if (Objects.equals(item.getCode(), "ledger_modify")) {
code = "修改";
} else if (Objects.equals(item.getCode(), "delete_terminal")){
code = "删除";
}
String nodeName = nodeService.getNodeById(item.getNodeId()).getName();
List<CsEquipmentDeliveryPO> devList1 = csEquipmentDeliveryService.getAll();
List<CsEquipmentDeliveryPO> devList2 = devList1.stream().filter(item1 -> Objects.equals(item1.getId(), item.getDeviceId())).collect(Collectors.toList());
List<String> devNameList = devList2.stream().map(CsEquipmentDeliveryPO::getName).collect(Collectors.toList());
String devNameListString;
if (CollectionUtil.isNotEmpty(devNameList)) {
devNameListString = devNameList.toString();
} else {
devNameListString = "[" + item.getDeviceName() + "]";
}
if (item.getIsReceived() == 0) {
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备未收到应答";
//将cs_terminal_logs数据置为未发送
csTerminalLogsService.updateLaterData(item.getDeviceId(),item.getCode());
});
} else {
list.forEach(item->{
String key;
String code = "";
if (Objects.equals(item.getCode(), "add_terminal")) {
code = "新增";
} else if (Objects.equals(item.getCode(), "ledger_modify")) {
code = "修改";
} else if (Objects.equals(item.getCode(), "delete_terminal")){
code = "删除";
}
String nodeName = nodeService.getNodeById(item.getNodeId()).getName();
List<CsEquipmentDeliveryPO> devList1 = csEquipmentDeliveryService.getAll();
List<CsEquipmentDeliveryPO> devList2 = devList1.stream().filter(item1 -> Objects.equals(item1.getId(), item.getDeviceId())).collect(Collectors.toList());
List<String> devNameList = devList2.stream().map(CsEquipmentDeliveryPO::getName).collect(Collectors.toList());
String devNameListString;
if (CollectionUtil.isNotEmpty(devNameList)) {
devNameListString = devNameList.toString();
} else {
devNameListString = "[" + item.getDeviceName() + "]";
}
if (item.getIsReceived() == 0) {
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备未收到应答";
//将cs_terminal_logs数据置为未发送
csTerminalLogsService.updateLaterData(item.getDeviceId(),item.getCode());
} else if (item.getIsReceived() == 1){
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据成功";
} else {
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据失败";
}
result.add(key);
});
}
} else if (item.getIsReceived() == 1){
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据成功";
} else {
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据失败";
}
result.add(key);
});
}
}
return result;
}
// @Override
// public List<String> queryReplyData() {
// List<String> result = new ArrayList<>();
// Object object = redisUtil.getObjectByKey(RequestUtil.getUserIndex()+"reply");
// if (object != null) {
// List<String> redisList = Stream.of(object.toString().split(",")).collect(Collectors.toList());
// List<CsTerminalReply> list = this.lambdaQuery().in(CsTerminalReply::getReplyId,redisList).orderByAsc(CsTerminalReply::getCreateTime).list();
// if (CollectionUtil.isNotEmpty(list)) {
// Map<Integer,List<CsTerminalReply>> map = list.stream().collect(Collectors.groupingBy(CsTerminalReply::getIsReceived));
// List<CsTerminalReply> list1 = map.get(1);
// if (CollectionUtil.isEmpty(list1)) {
// String key = "更新失败,未收到前置应答,请查看应答报文是否发送";
// result.add(key);
// //将cs_terminal_logs数据置为未发送
// list.forEach(item->{
// csTerminalLogsService.updateLaterData(item.getDeviceId(),item.getCode());
// });
// } else {
// list.forEach(item->{
// String key;
// String code = "";
// if (Objects.equals(item.getCode(), "add_terminal")) {
// code = "新增";
// } else if (Objects.equals(item.getCode(), "ledger_modify")) {
// code = "修改";
// } else if (Objects.equals(item.getCode(), "delete_terminal")){
// code = "删除";
// }
// String nodeName = nodeService.getNodeById(item.getNodeId()).getName();
// List<CsEquipmentDeliveryPO> devList1 = csEquipmentDeliveryService.getAll();
// List<CsEquipmentDeliveryPO> devList2 = devList1.stream().filter(item1 -> Objects.equals(item1.getId(), item.getDeviceId())).collect(Collectors.toList());
// List<String> devNameList = devList2.stream().map(CsEquipmentDeliveryPO::getName).collect(Collectors.toList());
// String devNameListString;
// if (CollectionUtil.isNotEmpty(devNameList)) {
// devNameListString = devNameList.toString();
// } else {
// devNameListString = "[" + item.getDeviceName() + "]";
// }
// if (item.getIsReceived() == 0) {
// key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备未收到应答";
// //将cs_terminal_logs数据置为未发送
// csTerminalLogsService.updateLaterData(item.getDeviceId(),item.getCode());
// } else if (item.getIsReceived() == 1){
// key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据成功";
// } else {
// key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据失败";
// }
// result.add(key);
// });
// }
// }
// }
// return result;
// }
@Override
public void updateReplyData(IcdBzReplyParam param) {
LambdaUpdateWrapper<CsTerminalReply> wrapper = new LambdaUpdateWrapper<>();
@@ -132,27 +178,10 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
QueryWrapper<CsTerminalReply> queryWrapper = new QueryWrapper<>();
if (StrUtil.isNotBlank(param.getSearchValue())) {
queryWrapper.like("cs_terminal_reply.line_id", param.getSearchValue());
// //获取监测点id
// List<CsLinePO> list = csLinePOService.getLineByName(param.getSearchValue());
// if (CollectionUtil.isEmpty(list)) {
// return page;
// } else {
// queryWrapper.and(pr -> {
// // 获取所有 lineId
// List<String> lineIds = list.stream()
// .map(CsLinePO::getLineId)
// .collect(Collectors.toList());
// // 使用 OR 条件连接多个 lineId
// for (int i = 0; i < lineIds.size(); i++) {
// if (i == 0) {
// pr.like("cs_terminal_reply.line_id", lineIds.get(i));
// } else {
// pr.or().like("cs_terminal_reply.line_id", lineIds.get(i));
// }
// }
// });
// }
}
queryWrapper.between("cs_terminal_reply.Create_Time"
, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()))
, DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
//排序
queryWrapper.orderBy(true, false, "cs_terminal_reply.create_time");
queryWrapper.in("cs_terminal_reply.code", Arrays.asList("allFile", "allEvent", "oneFile"));

View File

@@ -0,0 +1,15 @@
package com.njcn.csdevice.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.mapper.CsUpgradeLogsMapper;
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
import com.njcn.csdevice.service.CsUpgradeLogsService;
import org.springframework.stereotype.Service;
/**
* @author caozehui
* @data 2026-04-23
*/
@Service
public class CsUpgradeLogsServiceImpl extends ServiceImpl<CsUpgradeLogsMapper, CsUpgradeLogs> implements CsUpgradeLogsService {
}

View File

@@ -99,6 +99,10 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
if (!mqttClient) {
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
}
//判断文件如果过大,不给下载
if (size > 15728640) {
throw new BusinessException("文件过大(超过15M),暂不支持下载!");
}
Object task = redisUtil.getObjectByKey("fileDowning:"+nDid);
if (Objects.nonNull(task)) {
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);

View File

@@ -0,0 +1,121 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
import com.njcn.csdevice.param.DeviceMessageParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.service.DeviceMessageService;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.AppInfoSetFeignClient;
import com.njcn.user.api.AppUserFeignClient;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.pojo.po.User;
import com.njcn.user.pojo.po.app.AppInfoSet;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Slf4j
class DeviceMessageServiceImpl implements DeviceMessageService {
private final AppUserFeignClient appUserFeignClient;
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
private final AppInfoSetFeignClient appInfoSetFeignClient;
private final UserFeignClient userFeignClient;
private final CsLinePOService csLinePOService;
private final DicDataFeignClient dicDataFeignClient;
private final RedisUtil redisUtil;
@Override
public List<String> getEventUserByDeviceId(String devId, Boolean isAdmin) {
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
if (isAdmin) {
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
List<String> result = new ArrayList<>(list);
adminList.addAll(result);
}
if (CollectionUtil.isNotEmpty(adminList)) {
adminList = adminList.stream().distinct().collect(Collectors.toList());
}
return adminList;
}
@Override
public List<User> getSendUserByType(DeviceMessageParam param) {
List<User> users = new ArrayList<>();
List<String> result = new ArrayList<>();
List<AppInfoSet> appInfoSet = appInfoSetFeignClient.getListById(param.getUserList()).getData();
switch (param.getEventType()) {
case 0:
result = appInfoSet.stream()
.filter(person -> person.getEventInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
case 1:
result = appInfoSet.stream()
.filter(person -> person.getHarmonicInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
case 2:
result = appInfoSet.stream()
.filter(person -> person.getRunInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
case 3:
result = appInfoSet.stream()
.filter(person -> person.getAlarmInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
default:
break;
}
if (CollectionUtil.isNotEmpty(result)){
users = userFeignClient.appuserByIdList(result).getData();
}
return users;
}
@Override
public void getLineInfo(String id, List<CsLinePO> list) {
Map<Integer,String> map = new HashMap<>();
List<CsLinePO> lineList;
if (CollectionUtil.isNotEmpty(list) && list != null) {
lineList = list;
} else {
lineList = csLinePOService.findByNdid(id);
}
if (CollectionUtil.isEmpty(lineList)){
log.error("监测点为空");
return;
}
for (CsLinePO item : lineList) {
if (Objects.isNull(item.getPosition()) || item.getPosition().isEmpty()){
map.put(item.getClDid(),item.getLineId());
} else {
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
map.put(0,item.getLineId());
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
map.put(1,item.getLineId());
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
map.put(2,item.getLineId());
} else {
map.put(item.getClDid(),item.getLineId());
}
}
}
redisUtil.saveByKey(AppRedisKey.LINE_POSITION+id,map);
}
}

View File

@@ -183,7 +183,7 @@ public class EngineeringProjectServiceImpl implements IEngineeringProjectService
//查询所有拓扑图
LambdaQueryWrapper<AppTopologyDiagramPO> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.eq(AppTopologyDiagramPO::getStatus,"1");
queryWrapper3.eq(AppTopologyDiagramPO::getStatus,1);
List<AppTopologyDiagramPO> list3 = appTopologyDiagramService.list(queryWrapper3);
Map<String,AppTopologyDiagramPO> map3 = list3.stream().collect(Collectors.toMap(AppTopologyDiagramPO::getProjectId, item->item));

View File

@@ -27,7 +27,6 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -67,6 +66,27 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
return result;
}
@Override
public List<PqsCommunicateDto> getRawDataOne(LineCountEvaluateParam lineParam) {
List<PqsCommunicateDto> result = new ArrayList<>();
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
influxQueryWrapper.regular(PqsCommunicate::getDevId, lineParam.getLineId())
.select(PqsCommunicate::getTime)
.select(PqsCommunicate::getDevId)
.select(PqsCommunicate::getDescription)
.select(PqsCommunicate::getType)
.timeAsc()
.limit(1);
List<PqsCommunicate> list = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
list.forEach(item -> {
PqsCommunicateDto dto = new PqsCommunicateDto();
BeanUtils.copyProperties(item, dto);
dto.setTime(DATE_TIME_FORMATTER.format(item.getTime()));
result.add(dto);
});
return result;
}
/**
* @Description: 获取时间段内的数据
* @Param:
@@ -88,6 +108,18 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
return result;
}
@Override
public List<PqsCommunicateDto> getRawData2(LineCountEvaluateParam lineParam) {
List<PqsCommunicateDto> result = new ArrayList<>();
List<PqsCommunicate> list = getPqsCommunicateData(lineParam);
if (CollectionUtil.isNotEmpty(list)) {
list.forEach(item -> {
result.add(convertToDto(item));
});
}
return result;
}
/**
* 处理有数据的情况
*/
@@ -95,6 +127,20 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
List<PqsCommunicateDto> result = new ArrayList<>();
int lastIndex = list.size() - 1;
// 获取第一条数据补充0点数据状态与第一条相反
PqsCommunicate firstItem = list.get(0);
PqsCommunicateDto firstData = new PqsCommunicateDto();
firstData.setTime(lineParam.getStartTime() + " 00:00:00");
firstData.setDevId(lineParam.getLineId().get(0));
if (Objects.equals(firstItem.getType(), 0)) {
firstData.setType(1);
firstData.setDescription("通讯正常");
} else {
firstData.setType(0);
firstData.setDescription("通讯中断");
}
result.add(firstData);
for (int i = 0; i < list.size(); i++) {
PqsCommunicate item = list.get(i);
PqsCommunicateDto dto = convertToDto(item);
@@ -106,10 +152,10 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
result.add(endData);
}
}
return result;
}
/**
* 处理无数据的情况
*/

View File

@@ -2,27 +2,27 @@ package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.IdUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.advance.api.EventCauseFeignClient;
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.PortableOfflLogMapper;
import com.njcn.csdevice.param.UploadDataParam;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
import com.njcn.csdevice.pojo.po.PortableOfflLog;
import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.service.IPortableOfflLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.param.UploadDataParam;
import com.njcn.csdevice.service.IWlRecordService;
import com.njcn.csdevice.service.PortableOffMainLogService;
import com.njcn.csdevice.service.*;
import com.njcn.csdevice.util.InfluxDbParamUtil;
import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.api.OfflineDataUploadFeignClient;
@@ -36,13 +36,17 @@ import com.njcn.csharmonic.offline.mincfg.AnalyseComtradeCfg;
import com.njcn.csharmonic.offline.mincfg.vo.CmnModeCfg;
import com.njcn.csharmonic.offline.vo.Response;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.influx.imapper.EvtDataMapper;
import com.njcn.influx.imapper.PqdDataMapper;
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.influx.imapper.*;
import com.njcn.influx.pojo.po.*;
import com.njcn.influx.pojo.po.cs.EntData;
import com.njcn.influx.pojo.po.cs.PqdData;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.web.pojo.param.BaseParam;
import lombok.RequiredArgsConstructor;
@@ -50,11 +54,10 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.math.BigDecimal;
import java.text.DecimalFormat;
@@ -81,29 +84,37 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
private final DecimalFormat df = new DecimalFormat("#0.000");
private final FileStorageUtil fileStorageUtil;
private final DicDataFeignClient dicDataFeignClient;
private final OfflineDataUploadFeignClient offlineDataUploadFeignClient;
private final EleEvtFeignClient eleEvtFeignClient;
private final EventFeignClient eventFeignClient;
private final EquipmentFeignClient equipmentFeignClient;
private final InfluxDbParamUtil influxDbParamUtil;
private final PqdDataMapper pqdDataMapper;
private final EvtDataMapper evtDataMapper;
private final DataVMapper dataVMapper;
private final DataIMapper dataIMapper;
private final DataHarmRateVMapper dataHarmRateV;
private final DataHarmRateIMapper dataHarmRateI;
private final DataInHarmVMapper dataInHarmV;
private final DataHarmPowerPMapper dataHarmPowerP;
private final DataHarmPowerQMapper dataHarmPowerQ;
private final DataHarmPowerSMapper dataHarmPowerS;
private final DataFlickerMapper dataFlicker;
private final DataFlucMapper dataFluc;
private final DataPltMapper dataPlt;
private final DataHarmPhasicVMapper dataHarmPhasicV;
private final DataHarmPhasicIMapper dataHarmPhasicI;
private final IPqdDataSplitService pqdDataSplitService;
private final MqttPublisher publisher;
private final PortableOffMainLogService portableOffMainLogService;
private final IWlRecordService wlRecordService;
private final CsLinePOService csLinePOService;
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
private final EventCauseFeignClient eventCauseFeignClient;
@Override
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
@@ -177,7 +188,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
}
@Override
@Transactional(rollbackFor = {Exception.class})
@DSTransactional
public void importEquipment(UploadDataParam uploadDataParam){
String lineId = uploadDataParam.getLineId();
//获取监测点信息
@@ -337,7 +348,6 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
.eq(WlRecord::getEndTime,wlRecord.getEndTime()).update();
wlRecordService.save(wlRecord);
//如果明确返回了state 那么当前文件解析出错
if(response.getState() != null){
portableOfflLog.setState(response.getState());
@@ -353,7 +363,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
List<List<PqdData>> partition = ListUtils.partition(pqdData, 1500);
for (List<PqdData> sliceList : partition) {
List<PqdData> sublistAsOriginalListType = new ArrayList<>(sliceList);
pqdDataMapper.insertBatch(sublistAsOriginalListType);
Map<String, Object> map = pqdDataSplitService.splitPqdData(sublistAsOriginalListType);
insertData(map);
}
//min结果集解析入库后就不需要在解析了
minFlag = false;
@@ -381,6 +392,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
}
List<NewTaglogbuffer> newTaglogbuffers = (List<NewTaglogbuffer>) response.getObj();
if(newTaglogbuffers != null && !newTaglogbuffers.isEmpty()){
List<DictData> list1 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
List<DictData> list2 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
//否则正常标记为成功解析
portableOfflLog.setState(1);
portableOfflLog.setAllCount(newTaglogbuffers.size());
@@ -451,14 +464,32 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
}
}
csEventPO.setWavePath(wavePath);
if (Objects.equals(csEventPO.getTag(),DataParam.dipStrName)) {
EventAnalysisDTO var1 = new EventAnalysisDTO();
var1.setWlFilePath(wavePath);
EventAnalysisDTO dto = eventCauseFeignClient.analysisCauseAndType(var1).getData();
String id1 = list1.stream()
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getCause()))
.map(DictData::getId)
.findFirst()
.orElse(null);
csEventPO.setAdvanceReason(id1);
String id2 = list2.stream()
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getType()))
.map(DictData::getId)
.findFirst()
.orElse(null);
csEventPO.setAdvanceType(id2);
}
//默认暂态事件
csEventPO.setType(0);
String clDid = influxDbParamUtil.getClDidByLineId(uploadDataParam.getLineId());
csEventPO.setClDid(clDid == null ? null : Integer.parseInt(clDid));
csEventPO.setProcess(csEquipmentDeliveryDTO.getProcess());
csEventPOS.add(csEventPO);
EntData entData = new EntData();
entData.setUuid(csEventPO.getId());
entData.setTime(new Date().toInstant());
@@ -503,12 +534,19 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
log.info("类型log,插入infulxDb的evtData");
try {
evtDataMapper.insertOne(entData);
//添加其余数据
csEventPO.setPhase(entData.getEvtParamPhase());
csEventPO.setPersistTime(entData.getEvtParamTm());
csEventPO.setAmplitude(entData.getEvtParamVVaDepth());
csEventPOS.add(csEventPO);
} catch (Exception e) {
e.printStackTrace();
}
}
log.info("类型log,插入mysql事件表cs_event");
eventFeignClient.saveBatchEventList(csEventPOS);
//同步数据到 r_mp_event_detail
csEventPOS.forEach(this::insertEvent);
}
}
}
@@ -529,6 +567,62 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
portableOffMainLogService.save(portableOffMainLog);
}
public void insertEvent(CsEventPO item) {
RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO();
rmpEventDetailPo.setEventId(item.getId());
rmpEventDetailPo.setMeasurementPointId(item.getLineId());
rmpEventDetailPo.setStartTime(item.getStartTime());
rmpEventDetailPo.setEventType(getEventType(item.getTag()));
rmpEventDetailPo.setFeatureAmplitude(item.getAmplitude());
rmpEventDetailPo.setDuration(item.getPersistTime());
rmpEventDetailPo.setEventDescribe(getTag(item.getTag()));
rmpEventDetailPo.setDealFlag(0);
rmpEventDetailPo.setFileFlag(0);
rmpEventDetailPo.setPhase(item.getPhase());
rmpEventDetailPo.setAdvanceReason(item.getAdvanceReason());
rmpEventDetailPo.setAdvanceType(item.getAdvanceType());
wlRmpEventDetailMapper.insert(rmpEventDetailPo);
}
public String getTag(String tag) {
switch (tag) {
case "Evt_Sys_DipStr":
tag = DicDataEnum.VOLTAGE_DIP.getCode();
break;
case "Evt_Sys_SwlStr":
tag = DicDataEnum.VOLTAGE_RISE.getCode();
break;
case "Evt_Sys_IntrStr":
tag = DicDataEnum.SHORT_INTERRUPTIONS.getCode();
break;
default:
tag = "Un_Know";
break;
}
return tag;
}
public String getEventType(String tag) {
switch (tag) {
case "Evt_Sys_DipStr":
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
tag = dip.getId();
break;
case "Evt_Sys_SwlStr":
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
tag = rise.getId();
break;
case "Evt_Sys_IntrStr":
DictData interruptions = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
tag = interruptions.getId();
break;
default:
tag = "Un_Know";
break;
}
return tag;
}
@Override
public Page<PortableOffMainLog> queryMainLogPage(BaseParam baseParam) {
Page<PortableOffMainLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
@@ -587,7 +681,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
String dictDataCode = null;
switch (volConType) {
case 0:
dictDataCode = "star";
dictDataCode = "Trans_Business";
break;
case 1:
dictDataCode = "Star_Triangle";
@@ -604,4 +698,87 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
}
return Objects.isNull(result)?null:result;
}
public void insertData(Map<String, Object> map) {
//13张表
map.forEach((key, value) -> {
switch (key) {
case "data_v":
dataVMapper.insertBatch((List<DataV>) value);
break;
case "data_i":
dataIMapper.insertBatch((List<DataI>) value);
break;
case "data_flicker":
//10分钟入一组
List<DataFlicker> list = (List<DataFlicker>) value;
if (!CollectionUtils.isEmpty(list)) {
list.forEach(item->{
Instant time = getTime(item.getTime(),600);
item.setTime(time);
});
dataFlicker.insertBatch(list);
}
break;
case "data_fluc":
//10分钟入一组
List<DataFluc> list2 = (List<DataFluc>) value;
if (!CollectionUtils.isEmpty(list2)) {
list2.forEach(item->{
Instant time = getTime(item.getTime(),600);
item.setTime(time);
});
dataFluc.insertBatch(list2);
}
break;
case "data_harmphasic_i":
dataHarmPhasicI.insertBatch((List<DataHarmPhasicI>) value);
break;
case "data_harmphasic_v":
dataHarmPhasicV.insertBatch((List<DataHarmPhasicV>) value);
break;
case "data_harmpower_p":
dataHarmPowerP.insertBatch((List<DataHarmPowerP>) value);
break;
case "data_harmpower_q":
dataHarmPowerQ.insertBatch((List<DataHarmPowerQ>) value);
break;
case "data_harmpower_s":
dataHarmPowerS.insertBatch((List<DataHarmPowerS>) value);
break;
case "data_harmrate_v":
dataHarmRateV.insertBatch((List<DataHarmRateV>) value);
break;
case "data_harmrate_i":
dataHarmRateI.insertBatch((List<DataHarmRateI>) value);
break;
case "data_inharm_v":
dataInHarmV.insertBatch((List<DataInHarmV>) value);
break;
case "data_plt":
//2小时入一组
List<DataPlt> list3 = (List<DataPlt>) value;
if (!CollectionUtils.isEmpty(list3)) {
list3.forEach(item->{
Instant time = getTime(item.getTime(),7200);
item.setTime(time);
});
dataPlt.insertBatch(list3);
}
break;
case "pqd_data":
pqdDataMapper.insertBatch((List<PqdData>) value);
break;
default:
log.warn("不支持的目标表: {}", key);
break;
}
});
}
public Instant getTime(Instant time, Integer interval) {
long originalTimeSec = time.getEpochSecond();
long newTimeSec = (originalTimeSec / interval) * interval;
return Instant.ofEpochSecond(newTimeSec);
}
}

View File

@@ -0,0 +1,470 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.njcn.csdevice.service.IPqdDataSplitService;
import com.njcn.influx.pojo.po.*;
import com.njcn.influx.pojo.po.cs.PqdData;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* PqdData数据拆分服务实现
*
* @author system
* @since 2026-05-22
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class PqdDataSplitServiceImpl implements IPqdDataSplitService {
private final RedisUtil redisUtil;
private final EpdFeignClient epdFeignClient;
private final DicDataFeignClient dicDataFeignClient;
@Override
public Map<String, Object> splitPqdData(List<PqdData> pqdDataList) {
//获取表映射关系
Map<String,String> map1 = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD)), Map.class);
//获取字段映射关系
DictData pqd = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
List<EleEpdPqdListVO> list = epdFeignClient.selectAll().getData();
List<EleEpdPqd> epdList = list.stream().filter(item -> Objects.equals(item.getDataType(), pqd.getId()))
.findFirst()
.map(EleEpdPqdListVO::getEleEpdPqdVOS)
.orElse(new ArrayList<>());
// 处理 harmStart 和 harmEnd
List<EleEpdPqd> resultList = epdList.stream()
.flatMap(item -> {
if (item.getHarmStart() != null && item.getHarmEnd() != null) {
List<EleEpdPqd> expandedList = new ArrayList<>();
for (int i = item.getHarmStart(); i <= item.getHarmEnd(); i++) {
EleEpdPqd newItem = copyEleEpdPqd(item);
newItem.setName(item.getName() + "_" + i);
newItem.setOtherName(item.getOtherName() + "_" + i);
expandedList.add(newItem);
}
return expandedList.stream();
} else {
return Stream.of(item);
}
})
.collect(Collectors.toList());
Map<String,List<EleEpdPqd>> map2 = resultList.stream().collect(Collectors.groupingBy(EleEpdPqd::getName,LinkedHashMap::new,Collectors.toList()));
Map<String,Object> map3 = new HashMap<>();
List<Object> list1 = new ArrayList<>();
List<Object> list2 = new ArrayList<>();
List<Object> list3 = new ArrayList<>();
List<Object> list4 = new ArrayList<>();
List<Object> list5 = new ArrayList<>();
List<Object> list6 = new ArrayList<>();
List<Object> list7 = new ArrayList<>();
List<Object> list8 = new ArrayList<>();
List<Object> list9 = new ArrayList<>();
List<Object> list10 = new ArrayList<>();
List<Object> list11 = new ArrayList<>();
List<Object> list12 = new ArrayList<>();
List<Object> list13 = new ArrayList<>();
List<Object> list14 = new ArrayList<>();
for (PqdData item : pqdDataList) {
Map<String, Object> map = extractFieldValues(item);
DataV dataV = new DataV();
dataV.setTime(item.getTime());
dataV.setLineId(item.getLineId());
dataV.setPhaseType(item.getPhaseType());
dataV.setValueType(item.getValueType());
dataV.setClDid(item.getClDid());
dataV.setProcess(item.getProcess());
dataV.setQualityFlag("0");
DataI dataI = new DataI();
dataI.setTime(item.getTime());
dataI.setLineId(item.getLineId());
dataI.setPhaseType(item.getPhaseType());
dataI.setValueType(item.getValueType());
dataI.setClDid(item.getClDid());
dataI.setProcess(item.getProcess());
dataI.setQualityFlag("0");
DataFlicker dataFlicker = new DataFlicker();
dataFlicker.setTime(item.getTime());
dataFlicker.setLineId(item.getLineId());
dataFlicker.setPhaseType(item.getPhaseType());
dataFlicker.setValueType(item.getValueType());
dataFlicker.setClDid(item.getClDid());
dataFlicker.setProcess(item.getProcess());
dataFlicker.setQualityFlag("0");
DataFluc dataFluc = new DataFluc();
dataFluc.setTime(item.getTime());
dataFluc.setLineId(item.getLineId());
dataFluc.setPhaseType(item.getPhaseType());
dataFluc.setValueType(item.getValueType());
dataFluc.setClDid(item.getClDid());
dataFluc.setProcess(item.getProcess());
dataFluc.setQualityFlag("0");
DataHarmPhasicI dataHarmPhasicI = new DataHarmPhasicI();
dataHarmPhasicI.setTime(item.getTime());
dataHarmPhasicI.setLineId(item.getLineId());
dataHarmPhasicI.setPhaseType(item.getPhaseType());
dataHarmPhasicI.setValueType(item.getValueType());
dataHarmPhasicI.setClDid(item.getClDid());
dataHarmPhasicI.setProcess(item.getProcess());
dataHarmPhasicI.setQualityFlag("0");
DataHarmPhasicV dataHarmPhasicV = new DataHarmPhasicV();
dataHarmPhasicV.setTime(item.getTime());
dataHarmPhasicV.setLineId(item.getLineId());
dataHarmPhasicV.setPhaseType(item.getPhaseType());
dataHarmPhasicV.setValueType(item.getValueType());
dataHarmPhasicV.setClDid(item.getClDid());
dataHarmPhasicV.setProcess(item.getProcess());
dataHarmPhasicV.setQualityFlag("0");
DataHarmPowerP dataHarmPowerP = new DataHarmPowerP();
dataHarmPowerP.setTime(item.getTime());
dataHarmPowerP.setLineId(item.getLineId());
dataHarmPowerP.setPhaseType(item.getPhaseType());
dataHarmPowerP.setValueType(item.getValueType());
dataHarmPowerP.setClDid(item.getClDid());
dataHarmPowerP.setProcess(item.getProcess());
dataHarmPowerP.setQualityFlag("0");
DataHarmPowerQ dataHarmPowerQ = new DataHarmPowerQ();
dataHarmPowerQ.setTime(item.getTime());
dataHarmPowerQ.setLineId(item.getLineId());
dataHarmPowerQ.setPhaseType(item.getPhaseType());
dataHarmPowerQ.setValueType(item.getValueType());
dataHarmPowerQ.setClDid(item.getClDid());
dataHarmPowerQ.setProcess(item.getProcess());
dataHarmPowerQ.setQualityFlag("0");
DataHarmPowerS dataHarmPowerS = new DataHarmPowerS();
dataHarmPowerS.setTime(item.getTime());
dataHarmPowerS.setLineId(item.getLineId());
dataHarmPowerS.setPhaseType(item.getPhaseType());
dataHarmPowerS.setValueType(item.getValueType());
dataHarmPowerS.setClDid(item.getClDid());
dataHarmPowerS.setProcess(item.getProcess());
dataHarmPowerS.setQualityFlag("0");
DataHarmRateV dataHarmRateV = new DataHarmRateV();
dataHarmRateV.setTime(item.getTime());
dataHarmRateV.setLineId(item.getLineId());
dataHarmRateV.setPhaseType(item.getPhaseType());
dataHarmRateV.setValueType(item.getValueType());
dataHarmRateV.setClDid(item.getClDid());
dataHarmRateV.setProcess(item.getProcess());
dataHarmRateV.setQualityFlag("0");
DataHarmRateI dataHarmRateI = new DataHarmRateI();
dataHarmRateI.setTime(item.getTime());
dataHarmRateI.setLineId(item.getLineId());
dataHarmRateI.setPhaseType(item.getPhaseType());
dataHarmRateI.setValueType(item.getValueType());
dataHarmRateI.setClDid(item.getClDid());
dataHarmRateI.setProcess(item.getProcess());
dataHarmRateI.setQualityFlag("0");
DataInHarmV dataInHarmV = new DataInHarmV();
dataInHarmV.setTime(item.getTime());
dataInHarmV.setLineId(item.getLineId());
dataInHarmV.setPhaseType(item.getPhaseType());
dataInHarmV.setValueType(item.getValueType());
dataInHarmV.setClDid(item.getClDid());
dataInHarmV.setProcess(item.getProcess());
dataInHarmV.setQualityFlag("0");
DataPlt dataPlt = new DataPlt();
dataPlt.setTime(item.getTime());
dataPlt.setLineId(item.getLineId());
dataPlt.setPhaseType(item.getPhaseType());
dataPlt.setValueType(item.getValueType());
dataPlt.setClDid(item.getClDid());
dataPlt.setProcess(item.getProcess());
dataPlt.setQualityFlag("0");
PqdData pqdData = new PqdData();
pqdData.setTime(item.getTime());
pqdData.setLineId(item.getLineId());
pqdData.setPhaseType(item.getPhaseType());
pqdData.setValueType(item.getValueType());
pqdData.setClDid(item.getClDid());
pqdData.setProcess(item.getProcess());
pqdData.setQualityFlag("0");
boolean hasDataV = false;
boolean hasDataI = false;
boolean hasData1 = false;
boolean hasData2 = false;
boolean hasData3 = false;
boolean hasData4 = false;
boolean hasData5 = false;
boolean hasData6 = false;
boolean hasData7 = false;
boolean hasData8 = false;
boolean hasData9 = false;
boolean hasData10 = false;
boolean hasData11 = false;
boolean hasData12 = false;
for (Map.Entry<String, Object> entry : map.entrySet()) {
String fieldName = entry.getKey();
Object value = entry.getValue();
String capitalizedFieldName = StringUtils.capitalize(fieldName);
// 跳过公共字段和 null 值
if (isCommonField(fieldName) || value == null) {
continue;
}
String table = map1.get(capitalizedFieldName);
if (StrUtil.isBlank(table)) {
continue;
}
List<EleEpdPqd> epdPqdList = map2.get(capitalizedFieldName);
if (CollectionUtils.isEmpty(epdPqdList)) {
continue;
}
String influxdbName2 = epdPqdList.get(0).getOtherName();
if (StrUtil.isBlank(influxdbName2) || influxdbName2.equals(capitalizedFieldName)) {
influxdbName2 = capitalizedFieldName;
}
if (Objects.equals(table, "data_v")) {
setFieldValue(dataV, influxdbName2, value, true);
hasDataV = true;
}
if (Objects.equals(table, "data_i")) {
setFieldValue(dataI, influxdbName2, value, true);
hasDataI = true;
}
if (Objects.equals(table, "data_flicker")) {
setFieldValue(dataFlicker, influxdbName2, value, true);
hasData1 = true;
}
if (Objects.equals(table, "data_fluc")) {
setFieldValue(dataFluc, influxdbName2, value, true);
hasData2 = true;
}
if (Objects.equals(table, "data_harmphasic_i")) {
setFieldValue(dataHarmPhasicI, influxdbName2, value, true);
hasData3 = true;
}
if (Objects.equals(table, "data_harmphasic_v")) {
setFieldValue(dataHarmPhasicV, influxdbName2, value, true);
hasData4 = true;
}
if (Objects.equals(table, "data_harmpower_p")) {
setFieldValue(dataHarmPowerP, influxdbName2, value, true);
hasData5 = true;
}
if (Objects.equals(table, "data_harmpower_q")) {
setFieldValue(dataHarmPowerQ, influxdbName2, value, true);
hasData6 = true;
}
if (Objects.equals(table, "data_harmpower_s")) {
setFieldValue(dataHarmPowerS, influxdbName2, value, true);
hasData7 = true;
}
if (Objects.equals(table, "data_harmrate_v")) {
setFieldValue(dataHarmRateV, influxdbName2, value, true);
hasData8 = true;
}
if (Objects.equals(table, "data_harmrate_i")) {
setFieldValue(dataHarmRateI, influxdbName2, value, true);
hasData9 = true;
}
if (Objects.equals(table, "data_inharm_v")) {
setFieldValue(dataInHarmV, influxdbName2, value, true);
hasData10 = true;
}
if (Objects.equals(table, "data_plt")) {
setFieldValue(dataPlt, influxdbName2, value, true);
hasData11 = true;
}
if (Objects.equals(table, "pqd_data")) {
setFieldValue(pqdData, StringUtils.uncapitalize(influxdbName2), value, false);
hasData12 = true;
}
}
if (hasDataV) {
list1.add(dataV);
}
if (hasDataI) {
list2.add(dataI);
}
if (hasData1) {
list3.add(dataFlicker);
}
if (hasData2) {
list4.add(dataFluc);
}
if (hasData3) {
list5.add(dataHarmPhasicI);
}
if (hasData4) {
list6.add(dataHarmPhasicV);
}
if (hasData5) {
list7.add(dataHarmPowerP);
}
if (hasData6) {
list8.add(dataHarmPowerQ);
}
if (hasData7) {
list9.add(dataHarmPowerS);
}
if (hasData8) {
list10.add(dataHarmRateV);
}
if (hasData9) {
list11.add(dataHarmRateI);
}
if (hasData10) {
list12.add(dataInHarmV);
}
if (hasData11) {
list13.add(dataPlt);
}
if (hasData12) {
list14.add(pqdData);
}
}
map3.put("data_v", list1);
map3.put("data_i", list2);
map3.put("data_flicker", list3);
map3.put("data_fluc", list4);
map3.put("data_harmphasic_i", list5);
map3.put("data_harmphasic_v", list6);
map3.put("data_harmpower_p", list7);
map3.put("data_harmpower_q", list8);
map3.put("data_harmpower_s", list9);
map3.put("data_harmrate_v", list10);
map3.put("data_harmrate_i", list11);
map3.put("data_inharm_v", list12);
map3.put("data_plt", list13);
map3.put("pqd_data", list14);
return map3;
}
private Map<String, Object> extractFieldValues(PqdData pqdData) {
Map<String, Object> fieldValues = new HashMap<>();
Field[] fields = PqdData.class.getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
try {
Object value = field.get(pqdData);
if (value != null) {
fieldValues.put(field.getName(), value);
} else {
fieldValues.put(field.getName(), 0.0d);
}
} catch (IllegalAccessException e) {
log.warn("获取字段 {} 的值失败", field.getName(), e);
}
}
return fieldValues;
}
private boolean isCommonField(String fieldName) {
Set<String> commonFields = new HashSet<>(Arrays.asList(
"time", "lineId", "phasicType", "valueType", "clDid",
"process", "qualityFlag"
));
return commonFields.contains(fieldName);
}
private void setFieldValue(Object obj, String fieldName, Object value, boolean isCamelCase) {
try {
String camelCaseFieldName = fieldName;
if (isCamelCase) {
camelCaseFieldName = toCamelCase(fieldName);
}
Field field = obj.getClass().getDeclaredField(camelCaseFieldName);
field.setAccessible(true);
if (value == null) {
Class<?> fieldType = field.getType();
if (fieldType == Double.class || fieldType == double.class) {
value = 0.0D;
} else if (fieldType == Integer.class || fieldType == int.class) {
value = 0;
} else if (fieldType == Float.class || fieldType == float.class) {
value = 0.0F;
} else if (fieldType == Long.class || fieldType == long.class) {
value = 0L;
} else {
return;
}
}
field.set(obj, value);
} catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
log.warn("设置字段 {} 的值失败", fieldName, e);
}
}
public static String toCamelCase(String input) {
if (input == null || input.isEmpty()) {
return input;
}
StringBuilder result = new StringBuilder();
boolean toUpper = false;
for (char c : input.toCharArray()) {
if (c == '_') {
toUpper = true;
} else {
if (toUpper) {
result.append(Character.toUpperCase(c));
toUpper = false;
} else {
result.append(c);
}
}
}
// 确保首字母小写以匹配Java实体字段命名规范
if (result.length() > 0 && Character.isUpperCase(result.charAt(0))) {
result.setCharAt(0, Character.toLowerCase(result.charAt(0)));
}
return result.toString();
}
private EleEpdPqd copyEleEpdPqd(EleEpdPqd source) {
if (source == null) {
return null;
}
EleEpdPqd target = new EleEpdPqd();
BeanUtils.copyProperties(source, target);
return target;
}
}

View File

@@ -68,8 +68,8 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
List<CsLinePO> csLinePOList = csLineFeignClient.getLinesByDevList(devIdList).getData();
csLinePOList.forEach(item->{
//没有统计间隔就计算下一次监测点
if (Objects.isNull(item.getLineInterval())) {
return;
if (Objects.isNull(item.getLineInterval()) || item.getLineInterval() == 0) {
item.setLineInterval(1);
}
//应收数据
int dueCount = 1440 / item.getLineInterval();
@@ -79,16 +79,16 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
RStatIntegrityD data = new RStatIntegrityD();
//治理监测点
if (item.getClDid() == 0) {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"apf_data","Apf_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"apf_data","Apf_Freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
else {
//云前置监测点
if (ObjectUtil.isNotNull(item.getLineNo())) {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
//治理、无线监测点
else {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"pqd_data","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
}
data.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));

View File

@@ -16,13 +16,10 @@ import com.njcn.csdevice.service.ICsCommunicateService;
import com.njcn.csdevice.service.IRStatOnlineRateDService;
import com.njcn.csdevice.util.TimeUtil;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.influx.deprecated.InfluxDBPublicParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
@@ -62,48 +59,95 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
return;
}
if (CollectionUtil.isNotEmpty(devList)) {
//获取需要计算的时间
List<String> dateRange = TimeUtil.getDateRangeAsString(param.getStartTime(), param.getEndTime());
for (String time : dateRange) {
List<PqsCommunicateDto> outCommunicateData = new ArrayList<>();
int onlineMinutes = 0;
//获取需要计算的时间
List<String> dateRange = TimeUtil.getDateRangeAsString(param.getStartTime(), param.getEndTime());
for (String time : dateRange) {
Date statDate = DateUtil.parse(time);
// 按设备分别统计
for (CsEquipmentDeliveryPO device : devList) {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(time + " 00:00:00");
lineParam.setEndTime(time + " 23:59:59");
for (CsEquipmentDeliveryPO s : devList) {
lineParam.setLineId(Collections.singletonList(s.getId()));
List<PqsCommunicateDto> data = pqsCommunicateService.getRawDataLatest(lineParam);
if (CollectionUtil.isEmpty(data)) {
PqsCommunicateDto dto = new PqsCommunicateDto();
dto.setTime(time + " 00:00:00");
dto.setDevId(s.getId());
if (s.getRunStatus() == 1) {
dto.setType(0);
dto.setDescription("通讯中断");
} else if (s.getRunStatus() == 2) {
dto.setType(1);
dto.setDescription("通讯正常");
lineParam.setLineId(Collections.singletonList(device.getId()));
lineParam.setStartTime(time);
lineParam.setEndTime(time);
List<PqsCommunicateDto> dayData = pqsCommunicateService.getRawData2(lineParam);
if (CollectionUtil.isNotEmpty(dayData)) {
if (dayData.size() == 1) {
PqsCommunicateDto singleRecord = dayData.get(0);
long minutesFromMidnight = DateUtil.between(statDate, DateUtil.parse(singleRecord.getTime()), DateUnit.MINUTE);
if (online.equals(singleRecord.getType())) {
// 如果是在线状态,则从该时间点之后都在线
onlineMinutes = 1440 - (int) minutesFromMidnight;
} else {
// 如果是离线状态,则从该时间点之前都在线(假设之前是在线的)
onlineMinutes = (int) minutesFromMidnight;
}
outCommunicateData.add(dto);
} else {
// 多条记录,逐段计算
long totalOnlineMinutes = 0L;
Date lastTime = statDate;
for (int i = 0; i < dayData.size(); i++) {
PqsCommunicateDto current = dayData.get(i);
Date currentTime = DateUtil.parse(current.getTime());
long intervalMinutes = DateUtil.between(lastTime, currentTime, DateUnit.MINUTE);
if (i == 0) {
// 处理第一段从0点到第一条记录
// 如果第一条记录是离线(type=0),则之前是在线;如果第一条是在线(type=1),则之前是离线
if (!online.equals(current.getType())) {
totalOnlineMinutes += intervalMinutes;
}
} else {
// 处理后续段:根据上一条记录的状态判断
if (online.equals(dayData.get(i - 1).getType())) {
totalOnlineMinutes += intervalMinutes;
}
}
lastTime = currentTime;
}
// 处理最后一段:从最后一条记录到当天结束
Date endOfDay = DateUtil.beginOfDay(DateUtil.offsetDay(statDate, 1));
long lastInterval = DateUtil.between(lastTime, endOfDay, DateUnit.MINUTE);
if (online.equals(dayData.get(dayData.size() - 1).getType())) {
totalOnlineMinutes += lastInterval;
}
onlineMinutes = (int) Math.min(totalOnlineMinutes, 1440);
}
} else {
List<PqsCommunicateDto> firstData = pqsCommunicateService.getRawDataOne(lineParam);
if (CollectionUtil.isNotEmpty(firstData)) {
Date statDate2 = DateUtil.parse(firstData.get(0).getTime());
if (statDate.before(statDate2)) {
onlineMinutes = 0;
} else {
List<PqsCommunicateDto> latestData = pqsCommunicateService.getRawDataLatest(lineParam);
if (online.equals(latestData.get(0).getType())){
onlineMinutes = 1440;
} else {
onlineMinutes = 0;
}
}
} else {
//如果设备连一条记录没有,那就根本没接入,不需要统计
continue;
}
outCommunicateData.addAll(data);
}
Date dateOut = DateUtil.parse(time);
for (PqsCommunicateDto pqsCommunicate : outCommunicateData) {
RStatOnlineRateD po = new RStatOnlineRateD();
Date newDate = DateUtil.parse(pqsCommunicate.getTime());
lineParam.setLineId(Collections.singletonList(pqsCommunicate.getDevId()));
RStatOnlineRateD onLineRate = onLineMinute(newDate, dateOut, pqsCommunicate.getType(), lineParam);
po.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));
po.setDevIndex(pqsCommunicate.getDevId());
po.setOnlineMin(onLineRate.getOnlineMin());
po.setOfflineMin(onLineRate.getOfflineMin());
list.add(po);
}
RStatOnlineRateD po = new RStatOnlineRateD();
po.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));
po.setDevIndex(device.getId());
po.setOnlineMin(onlineMinutes);
po.setOfflineMin(1440 - onlineMinutes);
list.add(po);
}
}
if (CollectionUtil.isNotEmpty(list)) {
this.saveOrUpdateBatchByMultiId(list,1000);
this.saveOrUpdateBatchByMultiId(list, 1000);
}
}
@@ -114,97 +158,4 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
.between(RStatOnlineRateD::getTimeId,startTime,endTime)
.list();
}
/**
* new的时间和当前统计时间 不是/是 同一天
*/
private RStatOnlineRateD onLineMinute(Date newDate, Date date, Integer type, LineCountEvaluateParam lineParam) {
RStatOnlineRateD onLineRate = new RStatOnlineRateD();
Integer minute = 0;
/*new的时间和当前统计时间是同一天*/
if (DateUtil.isSameDay(newDate, date)) {
minute = processData(newDate, date, type, lineParam);
} else {
/*new的时间和当前统计时间不是同一天*/
Date nowDate = new Date();
/*数据补招的情况下*/
if (DateUtil.between(date, nowDate, DateUnit.DAY) > DateUtil.between(newDate, nowDate, DateUnit.DAY)) {
minute = processData(newDate, date, null, lineParam);
} else {
if (online.equals(type)) {
minute = InfluxDBPublicParam.DAY_MINUTE;
}
}
}
onLineRate.setOnlineMin(minute);
onLineRate.setOfflineMin(InfluxDBPublicParam.DAY_MINUTE - minute);
return onLineRate;
}
private Integer processData(Date newDate, Date date, Integer type,LineCountEvaluateParam lineParam) {
int minute = 0;
List<PqsCommunicateDto> communicateData = pqsCommunicateService.getRawData(lineParam);
/*当前统计时间内存在多条数据*/
if (communicateData.size() > 1) {
Date lastTime = null;
long onlineTime = 0;
long offlineTime = 0;
for (int i = 0; i < communicateData.size(); i++) {
long differ;
if (i == 0) {
/*首次比较取统计时间*/
differ = DateUtil.between(date, DateUtil.parse(communicateData.get(i).getTime()), DateUnit.MINUTE);
} else {
/*后续取上一次数据时间*/
differ = DateUtil.between(lastTime, DateUtil.parse(communicateData.get(i).getTime()), DateUnit.MINUTE);
}
if (online.equals(communicateData.get(i).getType())) {
offlineTime = offlineTime + differ;
} else {
onlineTime = onlineTime + differ;
}
lastTime = DateUtil.parse(communicateData.get(i).getTime());
}
if (online.equals(communicateData.get(communicateData.size() - 1).getType())) {
minute = InfluxDBPublicParam.DAY_MINUTE - (int) offlineTime;
} else {
minute = (int) onlineTime;
}
}
/*当前统计时间内仅有一条数据*/
else {
if (type != null) {
long differ = DateUtil.between(date, newDate, DateUnit.MINUTE);
if (online.equals(type)) {
minute = InfluxDBPublicParam.DAY_MINUTE - (int) differ;
} else {
minute = (int) differ;
}
} else {
List<PqsCommunicateDto> communicateDataOld = pqsCommunicateService.getRawDataEnd(lineParam);
// if (!communicateDataOld.isEmpty()){
// if (online.equals(communicateDataOld.get(0).getType())){
// minute = InfluxDBPublicParam.DAY_MINUTE;
// }
// }
if (!communicateDataOld.isEmpty()){
try {
if (online.equals(communicateDataOld.get(0).getType())){
minute = (int) DateUtil.between(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(communicateDataOld.get(0).getTime()), new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(lineParam.getEndTime()), DateUnit.MINUTE);
} else {
minute = (int) DateUtil.between(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(lineParam.getStartTime()), new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(communicateDataOld.get(0).getTime()), DateUnit.MINUTE);
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
} else {
minute = InfluxDBPublicParam.DAY_MINUTE;
}
}
}
return minute;
}
}

View File

@@ -47,7 +47,24 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
List<String> collect = new ArrayList<>();
if(Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER_8000.getCode())){
if ( Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())||
Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
csMarketDataQueryWrapper.eq("user_id", userIndex);
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);
collect = csMarketData.stream().map(CsMarketData::getEngineerId).collect(Collectors.toList());
} else if (Objects.equals(role,AppRoleEnum.TOURIST.getCode())) {
//todo查询配置的游客工程
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getEnginerId).distinct().collect(Collectors.toList());
}
// ||Objects.equals(role,"bxs_user")
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode()) || Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())){
List<CsEngineeringPO> csEngineeringPOS = csEngineeringMapper.selectList(null);
collect =csEngineeringPOS.stream().filter(temp->Objects.equals(temp.getStatus(),"1")).map(CsEngineeringPO::getId).collect(Collectors.toList());
} else {
csDeviceUserPOQueryWrapper.clear();
csEngineeringUserPOQueryWrapper.clear();
csLedgerQueryWrapper.clear();
@@ -79,24 +96,6 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
collect = collect.stream().distinct().collect(Collectors.toList());
}
return collect;
} else if ( Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())||
Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
csMarketDataQueryWrapper.eq("user_id", userIndex);
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);
collect = csMarketData.stream().map(CsMarketData::getEngineerId).collect(Collectors.toList());
} else if (Objects.equals(role,AppRoleEnum.TOURIST.getCode())) {
//todo查询配置的游客工程
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getEnginerId).distinct().collect(Collectors.toList());
}
// ||Objects.equals(role,"bxs_user")
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode()) || Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER.getCode()) ){
List<CsEngineeringPO> csEngineeringPOS = csEngineeringMapper.selectList(null);
collect =csEngineeringPOS.stream().filter(temp->Objects.equals(temp.getStatus(),"1")).map(CsEngineeringPO::getId).collect(Collectors.toList());
}
return collect;
@@ -115,36 +114,11 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
List<String> collect = new ArrayList<>();
if(
Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER_8000.getCode()) || Objects.equals(role,"bxs_user")){
csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
wq.eq("primary_user_id", userIndex)
.or()
.eq("sub_user_id",userIndex);
});
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
if(CollectionUtils.isEmpty(csDeviceUserPOS)){
return new ArrayList<>();
}
List<String> collect1 = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
return collect1;
}
//fix 新需求 工程用户可以看到关注工程的设备和对应的主用户和子用户的设备
else if (Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
//note 这边工程用户不查询主设备,只看关注的工程,做下调整,不然会出现工程用户未关注任何工程,但是有一台主设备,导致界面有数据
if (Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
List<String> sumDevId = new ArrayList<>();
csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
wq.eq("primary_user_id", userIndex)
.or()
.eq("sub_user_id",userIndex);
});
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
if(!CollectionUtils.isEmpty(csDeviceUserPOS)){
sumDevId = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
}
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
csMarketDataQueryWrapper.eq("user_id", userIndex);
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);
@@ -197,15 +171,25 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getDeviceId).distinct().collect(Collectors.toList());
}
// ||Objects.equals(role,"bxs_user")
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER.getCode())){
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())){
csLedgerQueryWrapper.clear();
csLedgerQueryWrapper.eq("level",2).eq("state",1);
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
collect = csLedgers.stream().map(CsLedger::getId).distinct().collect(Collectors.toList());
} else {
csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
wq.eq("primary_user_id", userIndex)
.or()
.eq("sub_user_id",userIndex);
});
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
if(CollectionUtils.isEmpty(csDeviceUserPOS)){
return new ArrayList<>();
}
List<String> collect1 = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
return collect1;
}
return collect;
}

View File

@@ -0,0 +1,417 @@
package com.njcn.csdevice.service.impl;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.mapper.CsSmsSendRecordMapper;
import com.njcn.csdevice.pojo.dto.CredentialReqDTO;
import com.njcn.csdevice.pojo.dto.SendResult;
import com.njcn.csdevice.pojo.po.CsSmsSendRecord;
import com.njcn.csdevice.pojo.vo.MessageRecordReqVO;
import com.njcn.csdevice.service.ISmsSendService;
import com.njcn.redis.utils.RedisUtil;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
/**
* @author xy
*/
@Slf4j
@Service
@AllArgsConstructor
@RequiredArgsConstructor
public class SmsSendServiceImpl extends ServiceImpl<CsSmsSendRecordMapper, CsSmsSendRecord> implements ISmsSendService {
@Value("${msg.credential_url:http://192.168.2.126:48083/admin-api/push/credential/generate}")
private String CREDENTIAL_URL;
@Value("${msg.sms_send_url:http://192.168.2.126:48083/admin-api/push/message/send/sms}")
private String SMS_SEND_URL;
@Value("${msg.connect_timeout:5000}")
private Integer CONNECT_TIMEOUT;
@Value("${msg.read_timeout:30000}")
private Integer READ_TIMEOUT;
@Value("${msg.system_name:NPQS-9500}")
private String SYSTEM_NAME;
@Value("${msg.secret_key:123456}")
private String SECRET_KEY;
private static final int[] RETRY_DELAYS = {1, 2, 3};
private static final int MAX_RETRY = 3;
private static final String CREDENTIAL_CACHE_KEY = "SMS_CREDENTIAL_TOKEN";
private static final Gson GSON = new Gson();
@Resource
private RedisUtil redisUtil;
@Override
public void sendSmsWithRetry(String receiver, String content, String messageType) {
MessageRecordReqVO vo = new MessageRecordReqVO();
vo.setReceiver(receiver);
vo.setContent(content);
vo.setMessageType(messageType);
sendSmsWithRetry(vo);
}
@Override
public void sendSmsWithRetry(MessageRecordReqVO messageRecordReqVO) {
CsSmsSendRecord record = initRecord(messageRecordReqVO);
this.save(record);
try {
String credentialToken = getOrRefreshCredentialWithRetry(record);
if (credentialToken == null) {
record.setSendStatus(0);
record.setFailReason("获取凭证失败已重试3次");
log.error("获取凭证失败,短信未发送,接收者: {}", messageRecordReqVO.getReceiver());
this.updateById(record);
throw new BusinessException("获取凭证失败已重试3次");
}
record.setCredentialToken(credentialToken);
record.setSendTime(LocalDateTime.now());
this.updateById(record);
boolean success = attemptSendWithRetry(messageRecordReqVO, credentialToken, record);
if (success) {
record.setSendStatus(1);
record.setFailReason(null);
log.info("短信发送成功,接收者: {}", messageRecordReqVO.getReceiver());
} else {
record.setSendStatus(0);
if (record.getFailReason() == null) {
record.setFailReason("超过最大重试次数,发送失败");
}
log.error("短信发送失败,接收者: {},已重试{}次,原因: {}",
messageRecordReqVO.getReceiver(), record.getRetryCount(), record.getFailReason());
throw new BusinessException("短信发送失败: " + record.getFailReason());
}
} catch (BusinessException e) {
record.setSendStatus(0);
record.setFailReason(e.getMessage());
log.error("短信发送业务异常,接收者: {}", messageRecordReqVO.getReceiver(), e);
this.updateById(record);
throw e;
} catch (Exception e) {
record.setSendStatus(0);
record.setFailReason("发送异常: " + e.getMessage());
log.error("短信发送异常,接收者: {}", messageRecordReqVO.getReceiver(), e);
this.updateById(record);
throw new BusinessException("短信发送异常: " + e.getMessage());
} finally {
this.updateById(record);
}
}
private CsSmsSendRecord initRecord(MessageRecordReqVO vo) {
CsSmsSendRecord record = new CsSmsSendRecord();
record.setReceiver(vo.getReceiver());
record.setContent(vo.getContent());
record.setMessageType(vo.getMessageType());
record.setSendStatus(-1);
record.setRetryCount(0);
record.setMaxRetry(MAX_RETRY);
record.setCreateTime(LocalDateTime.now());
return record;
}
private String getOrRefreshCredentialWithRetry(CsSmsSendRecord record) {
Object cachedToken = redisUtil.getObjectByKey(CREDENTIAL_CACHE_KEY);
if (cachedToken != null) {
log.info("使用缓存的凭证令牌");
return cachedToken.toString();
}
log.info("缓存中无凭证开始获取新凭证最多重试3次");
for (int i = 1; i <= 3; i++) {
try {
String token = fetchNewCredential();
log.info("第{}次尝试获取凭证成功", i);
return token;
} catch (Exception e) {
log.warn("第{}次获取凭证失败: {}", i, e.getMessage());
record.setFailReason("获取凭证第" + i + "次失败: " + e.getMessage());
this.updateById(record);
try {
int waitSeconds = i * 10;
log.info("等待{}秒后重试...", waitSeconds);
TimeUnit.SECONDS.sleep(waitSeconds);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
log.error("凭证获取重试被中断");
record.setFailReason("获取凭证实例被中断");
this.updateById(record);
return null;
}
}
}
log.error("获取凭证失败已重试3次");
return null;
}
private String fetchNewCredential() {
CredentialReqDTO reqDTO = new CredentialReqDTO();
reqDTO.setSystemName(SYSTEM_NAME);
reqDTO.setSecretKey(SECRET_KEY);
HttpURLConnection connection = null;
try {
URL url = new URL(CREDENTIAL_URL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setConnectTimeout(CONNECT_TIMEOUT);
connection.setReadTimeout(READ_TIMEOUT);
connection.setDoOutput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(GSON.toJson(reqDTO).getBytes(StandardCharsets.UTF_8));
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
if (responseCode != 200) {
throw new BusinessException("获取凭证失败HTTP响应码: " + responseCode);
}
BufferedReader reader = new BufferedReader(
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
StringBuilder response = new StringBuilder();
String inputLine;
while ((inputLine = reader.readLine()) != null) {
response.append(inputLine);
}
reader.close();
JsonObject jsonResponse = GSON.fromJson(response.toString(), JsonObject.class);
int code = jsonResponse.get("code").getAsInt();
if (code != 0) {
String msg = jsonResponse.has("msg") ? jsonResponse.get("msg").getAsString() : "未知错误";
throw new BusinessException("获取凭证失败,错误码: " + code + ",错误信息: " + msg);
}
JsonObject data = jsonResponse.getAsJsonObject("data");
String token = data.get("credentialToken").getAsString();
long expiresTimestamp = data.get("expiresTime").getAsLong();
LocalDateTime expiresTime = LocalDateTime.ofInstant(
Instant.ofEpochMilli(expiresTimestamp),
ZoneId.systemDefault()
);
long expireSeconds = calculateExpireSeconds(expiresTime);
redisUtil.saveByKeyWithExpire(CREDENTIAL_CACHE_KEY, token, expireSeconds);
log.info("获取新凭证成功,过期时间: {},缓存有效期: {}秒", expiresTime, expireSeconds);
return token;
} catch (SocketTimeoutException e) {
throw new BusinessException("获取凭证超时(30秒),请检查网络连接");
} catch (ConnectException e) {
throw new BusinessException("无法连接到凭证服务,请检查服务是否启动和网络是否正常");
} catch (IOException e) {
throw new BusinessException("获取凭证IO异常: " + e.getMessage());
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
private long calculateExpireSeconds(LocalDateTime expiresTime) {
long expireSeconds = java.time.Duration.between(
LocalDateTime.now(),
expiresTime
).getSeconds();
expireSeconds = expireSeconds - 60;
return Math.max(expireSeconds, 60);
}
private boolean attemptSendWithRetry(MessageRecordReqVO vo, String token, CsSmsSendRecord record) {
for (int attempt = 0; attempt <= MAX_RETRY; attempt++) {
if (attempt > 0) {
int delayMinutes = RETRY_DELAYS[attempt - 1];
log.info("第{}次重试,等待{}分钟后发送...", attempt, delayMinutes);
try {
TimeUnit.MINUTES.sleep(delayMinutes);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("重试等待被中断", e);
record.setFailReason("重试等待被中断");
return false;
}
record.setRetryCount(attempt);
}
SendResult result = executeSendSms(vo, token, record);
if (result.isSuccess()) {
record.setFailReason(null);
log.info("第{}次尝试发送成功消息ID: {}", attempt, result.getMessageId());
return true;
}
record.setFailReason(result.getFailReason());
if (result.isUnauthorized()) {
log.warn("凭证失效(401),重新获取凭证后重试...");
String newToken = getOrRefreshCredentialWithRetry(record);
if (newToken == null) {
record.setFailReason("凭证刷新失败,无法重新获取凭证");
return false;
}
token = newToken;
record.setCredentialToken(newToken);
this.updateById(record);
continue;
}
if (!result.isTimeOut()) {
log.warn("发送失败且非超时,不再重试,原因: {},响应时间: {}ms",
result.getFailReason(), record.getResponseTime());
return false;
}
log.warn("第{}次发送超时,将重试,响应时间: {}ms",
attempt, record.getResponseTime());
}
record.setFailReason("超过最大重试次数,发送超时");
return false;
}
private SendResult executeSendSms(MessageRecordReqVO vo, String token, CsSmsSendRecord record) {
HttpURLConnection connection = null;
long startTime = System.currentTimeMillis();
try {
URL url = new URL(SMS_SEND_URL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("X-Credential-Token", token);
connection.setConnectTimeout(CONNECT_TIMEOUT);
connection.setReadTimeout(READ_TIMEOUT);
connection.setDoOutput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(GSON.toJson(Collections.singletonList(vo)).getBytes(StandardCharsets.UTF_8));
outputStream.flush();
outputStream.close();
int responseCode = connection.getResponseCode();
long responseTime = System.currentTimeMillis() - startTime;
record.setResponseTime(responseTime);
BufferedReader reader = new BufferedReader(
new InputStreamReader(
responseCode == 200 ? connection.getInputStream() : connection.getErrorStream(),
StandardCharsets.UTF_8
)
);
StringBuilder response = new StringBuilder();
String inputLine;
while ((inputLine = reader.readLine()) != null) {
response.append(inputLine);
}
reader.close();
if (responseCode != 200) {
String failReason = "HTTP响应码异常: " + responseCode;
if (response.length() > 0) {
failReason += ",响应: " + response.toString();
}
record.setFailReason(failReason);
return new SendResult(false, null, failReason, false, false);
}
JsonObject jsonResponse = GSON.fromJson(response.toString(), JsonObject.class);
int code = jsonResponse.get("code").getAsInt();
if (code == 401) {
String failReason = "凭证失效(HTTP 401)";
record.setFailReason(failReason);
redisUtil.delete(CREDENTIAL_CACHE_KEY);
return new SendResult(false, null, failReason, false, true);
} else {
if (code != 0) {
String msg = jsonResponse.has("msg") ? jsonResponse.get("msg").getAsString() : "未知错误";
String failReason = "业务错误码: " + code + ",错误信息: " + msg;
record.setFailReason(failReason);
return new SendResult(false, null, failReason, false, false);
}
}
JsonObject firstResult = jsonResponse.getAsJsonArray("data").get(0).getAsJsonObject();
boolean result = firstResult.get("result").getAsBoolean();
String messageId = firstResult.has("messageId") ? firstResult.get("messageId").getAsString() : null;
String detail = firstResult.has("detail") ? firstResult.get("detail").getAsString() : null;
if (result) {
log.info("短信发送成功,接收者: {}消息ID: {},详情: {},耗时: {}ms",
vo.getReceiver(), messageId, detail, responseTime);
return new SendResult(true, messageId, null, false, false);
} else {
String failReason = "发送失败: " + detail;
record.setFailReason(failReason);
return new SendResult(false, messageId, failReason, false, false);
}
} catch (SocketTimeoutException e) {
long responseTime = System.currentTimeMillis() - startTime;
record.setResponseTime(responseTime);
String failReason = "请求超时(30秒)";
record.setFailReason(failReason);
log.warn("短信发送超时,接收者: {},耗时: {}ms", vo.getReceiver(), responseTime);
return new SendResult(false, null, failReason, true, false);
} catch (ConnectException e) {
long responseTime = System.currentTimeMillis() - startTime;
record.setResponseTime(responseTime);
String failReason = "无法连接到短信服务";
record.setFailReason(failReason);
log.error("短信服务连接失败,接收者: {}", vo.getReceiver(), e);
return new SendResult(false, null, failReason, false, false);
} catch (IOException e) {
long responseTime = System.currentTimeMillis() - startTime;
record.setResponseTime(responseTime);
String failReason = "IO异常: " + e.getMessage();
record.setFailReason(failReason);
log.error("短信发送IO异常接收者: {},耗时: {}ms", vo.getReceiver(), responseTime, e);
return new SendResult(false, null, failReason, false, false);
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
}

View File

@@ -482,11 +482,15 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
} else {
commonQueryParam.setColumnName(epdPqd.getOtherName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
}
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(LocalDateTimeUtil.format(wl.getStartTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setEndTime(LocalDateTimeUtil.format(wl.getEndTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType().toUpperCase());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
return commonQueryParam;
@@ -500,7 +504,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -677,13 +681,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
if(Objects.isNull(list.get(i).getEndTime())){
LocalDateTime now = LocalDateTime.now();
String sqlNow = now.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("data_v",StatisticalDataDTO.class);
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
.select(StatisticalDataDTO::getPhaseType)
.select(StatisticalDataDTO::getValueType)
.last("Pq_Freq")
.last("freq")
.eq(InfluxDBTableConstant.LINE_ID,lineId)
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
.eq(InfluxDBTableConstant.PHASIC_TYPE,"T")
.between(InfluxDBTableConstant.TIME,startSql,sqlNow);
System.out.println(influxQueryWrapper.generateSql());
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);
@@ -704,13 +708,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
//如果不存在结束时间,则取后面一条的起始时间作为结束判断标识
if(Objects.isNull(list.get(i).getEndTime())){
String end = list.get(i+1).getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("data_v",StatisticalDataDTO.class);
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
.select(StatisticalDataDTO::getPhaseType)
.select(StatisticalDataDTO::getValueType)
.last("Pq_Freq")
.last("freq")
.eq(InfluxDBTableConstant.LINE_ID,lineId)
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
.eq(InfluxDBTableConstant.PHASIC_TYPE,"T")
.between(InfluxDBTableConstant.TIME,startSql,end);
System.out.println(influxQueryWrapper.generateSql());
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);

View File

@@ -0,0 +1,28 @@
package com.njcn.csharmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.CsHarmonicPlanFeignClientFallbackFactory;
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csHarmonicPlan", fallbackFactory = CsHarmonicPlanFeignClientFallbackFactory.class,contextId = "csHarmonicPlan")
public interface CsHarmonicPlanFeignClient {
@GetMapping("/getById")
@ApiOperation("根据ID查询稳态指标方案")
HttpResult<CsHarmonicPlan> getById(@RequestParam("id") String id);
@GetMapping("/getByName")
@ApiOperation("根据名称查询稳态指标方案")
HttpResult<List<CsHarmonicPlan>> getByName(@RequestParam("name") String name);
}

View File

@@ -0,0 +1,35 @@
package com.njcn.csharmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.CsHarmonicPlanLineFeignClientFallbackFactory;
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
import io.swagger.annotations.ApiOperation;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csHarmonicPlanLine", fallbackFactory = CsHarmonicPlanLineFeignClientFallbackFactory.class,contextId = "csHarmonicPlanLine")
public interface CsHarmonicPlanLineFeignClient {
@GetMapping("/getPlanIdByLineId")
@ApiOperation("根据监测点ID查询方案ID")
HttpResult<String> getPlanIdByLineId(@RequestParam("lineId") String lineId);
@PostMapping("/savePlanLines")
@ApiOperation("新增方案与监测点关联")
HttpResult<Boolean> savePlanLines(@RequestBody @Validated CsHarmonicPlanLineParam param);
@PostMapping("/deleteByLineIds")
@ApiOperation("根据监测点ID集合删除关联")
HttpResult<Boolean> deleteByLineIds(@RequestBody List<String> lineIds);
}

View File

@@ -1,11 +1,18 @@
package com.njcn.csharmonic.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.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
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;
@@ -27,4 +34,24 @@ public interface EventUserFeignClient {
@PostMapping("/deleteByIds")
HttpResult<Boolean> deleteByIds(@RequestBody List<String> eventList);
@PostMapping("/queryTempEvent")
@ApiOperation("查询暂态事件(未读)")
HttpResult<List<String>> queryTempEvent(@RequestBody CsEventUserQueryParam param);
@PostMapping("/queryTempEventDetail")
@ApiOperation("查询暂态事件详细信息(未读)")
HttpResult<List<CsEventPO>> queryTempEventDetail(@RequestBody CsEventUserQueryParam param);
@PostMapping("/queryTempHarmonic")
@ApiOperation("查询稳态事件(未读)")
HttpResult<List<String>> queryTempHarmonic(@RequestBody CsEventUserQueryParam param);
@PostMapping("/queryAlarmEvent")
@ApiOperation("查询告警事件(未读)")
HttpResult<List<String>> queryAlarmEvent(@RequestBody CsEventUserQueryParam param);
@PostMapping("/queryRunEvent")
@ApiOperation("查询运行事件(未读)")
HttpResult<List<String>> queryRunEvent(@RequestBody CsEventUserQueryParam param);
}

View File

@@ -0,0 +1,43 @@
package com.njcn.csharmonic.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.csharmonic.api.CsHarmonicPlanFeignClient;
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class CsHarmonicPlanFeignClientFallbackFactory implements FallbackFactory<CsHarmonicPlanFeignClient> {
@Override
public CsHarmonicPlanFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsHarmonicPlanFeignClient() {
@Override
public HttpResult<CsHarmonicPlan> getById(String id) {
log.error("{}异常,降级处理,异常为:{}","根据ID查询稳态指标方案异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsHarmonicPlan>> getByName(String name) {
log.error("{}异常,降级处理,异常为:{}","根据名称查询稳态指标方案异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,48 @@
package com.njcn.csharmonic.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.csharmonic.api.CsHarmonicPlanLineFeignClient;
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class CsHarmonicPlanLineFeignClientFallbackFactory implements FallbackFactory<CsHarmonicPlanLineFeignClient> {
@Override
public CsHarmonicPlanLineFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsHarmonicPlanLineFeignClient() {
@Override
public HttpResult<String> getPlanIdByLineId(String lineId) {
log.error("{}异常,降级处理,异常为:{}","根据监测点ID查询方案ID异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> savePlanLines(CsHarmonicPlanLineParam param) {
log.error("{}异常,降级处理,异常为:{}","新增方案与监测点关联异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> deleteByLineIds(List<String> lineIds) {
log.error("{}异常,降级处理,异常为:{}","根据监测点ID集合删除关联异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import feign.hystrix.FallbackFactory;
@@ -45,6 +46,36 @@ public class EventUserFeignClientFallbackFactory implements FallbackFactory<Even
log.error("{}异常,降级处理,异常为:{}","根据id删除数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> queryTempEvent(CsEventUserQueryParam param) {
log.error("{}异常,降级处理,异常为:{}","查询暂态事件(未读)异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsEventPO>> queryTempEventDetail(CsEventUserQueryParam param) {
log.error("{}异常,降级处理,异常为:{}","查询暂态事件详细信息(未读)异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> queryTempHarmonic(CsEventUserQueryParam param) {
log.error("{}异常,降级处理,异常为:{}","查询稳态事件(未读)异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> queryAlarmEvent(CsEventUserQueryParam param) {
log.error("{}异常,降级处理,异常为:{}","查询告警事件(未读)异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> queryRunEvent(CsEventUserQueryParam param) {
log.error("{}异常,降级处理,异常为:{}","查询运行事件(未读)异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -57,10 +57,10 @@ public class AnalyseComtradeCfg {
List<PqdData> result = new ArrayList<>();
minDataHashMap.forEach((dateTime,data)->{
List<PqdData> pqdDataA = convertDataByValueType(data.getMin(), "min",dateTime);
List<PqdData> pqdDataB = convertDataByValueType(data.getMax(), "max",dateTime);
List<PqdData> pqdDataC = convertDataByValueType(data.getAvg(), "avg",dateTime);
List<PqdData> pqdDataT = convertDataByValueType(data.getCp95(), "cp95",dateTime);
List<PqdData> pqdDataA = convertDataByValueType(data.getMin(), "MIN",dateTime);
List<PqdData> pqdDataB = convertDataByValueType(data.getMax(), "MAX",dateTime);
List<PqdData> pqdDataC = convertDataByValueType(data.getAvg(), "AVG",dateTime);
List<PqdData> pqdDataT = convertDataByValueType(data.getCp95(), "CP95",dateTime);
result.addAll(pqdDataA);
result.addAll(pqdDataB);
result.addAll(pqdDataC);
@@ -91,7 +91,7 @@ public class AnalyseComtradeCfg {
hashMapC.put("time",dateTime.toInstant());
HashMap hashMapM = new HashMap<>();
hashMapM.put("phaseType","M");
hashMapM.put("phaseType","T");
hashMapM.put("valueType",valueType);
hashMapM.put("time",dateTime.toInstant());

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