109 Commits

Author SHA1 Message Date
xy
9d2b4b97f9 云前置改造 2025-09-23 16:34:24 +08:00
xy
ee07f7a5e2 组态调整 2025-09-23 16:32:35 +08:00
xy
214f297297 新增云前置相关功能 2025-09-18 15:03:27 +08:00
hzj
b908186758 修改兼容其他设备的bug 2025-09-18 10:03:56 +08:00
xy
0d1c142885 新增云前置相关功能 2025-09-17 20:15:48 +08:00
xy
43b8473976 新增云前置相关功能 2025-09-16 18:30:53 +08:00
xy
8c442d8897 1、新增云协议设备台账录入功能;
2、新增云协议设备实时数据请求功能
2025-09-04 13:58:30 +08:00
xy
066dceaeaf 代码优化 2025-08-22 12:31:12 +08:00
xy
9dca3408ae 新增标签 2025-08-04 09:57:22 +08:00
xy
0d7d1781e3 模块状态判断调整 2025-08-04 09:55:27 +08:00
xy
b794842d33 模块新增温度数据 2025-07-17 15:50:13 +08:00
xy
5e0c2d5cbc 模块新增温度数据 2025-07-17 15:46:48 +08:00
xy
6c9a33c05d 模块新增温度数据 2025-07-17 15:34:40 +08:00
xy
a847f541f1 微调 2025-07-17 10:42:25 +08:00
xy
94b5b92991 微调 2025-07-17 10:41:14 +08:00
xy
882d56a2c5 算法优化 2025-07-17 10:32:40 +08:00
xy
1629e1c4cc 功能调整 2025-07-17 09:05:16 +08:00
xy
45846e1889 功能调整 2025-07-16 17:50:53 +08:00
xy
030384333e 功能调整 2025-07-16 10:51:30 +08:00
xy
dc9958b249 功能调整 2025-07-16 09:37:18 +08:00
xy
a607437225 功能调整 2025-07-16 09:10:00 +08:00
xy
d277eba5fb 微调 2025-07-15 20:11:27 +08:00
xy
913c2ef262 微调 2025-07-15 20:04:35 +08:00
xy
0fe80e12b5 微调 2025-07-15 18:45:09 +08:00
xy
ffb6ead753 接口优化 2025-07-15 18:03:50 +08:00
xy
6782b19b7d 新增web端修改项目信息接口 2025-07-15 15:39:16 +08:00
xy
eeb22c749a 新增工程、项目信息修改功能 2025-07-15 13:27:56 +08:00
xy
31c21a43f4 新增工程、项目信息修改功能 2025-07-15 11:25:06 +08:00
xy
a923978f72 控制模块数据是否展示 2025-07-11 13:46:33 +08:00
xy
40588c6cd4 APF模块询问逻辑调整 2025-07-11 13:27:40 +08:00
xy
cb76943f0f 微调 2025-07-10 14:22:18 +08:00
xy
660925df31 半月报功能优化 2025-07-10 13:23:29 +08:00
xy
0ce5840d02 代码优化 2025-07-10 11:13:35 +08:00
xy
9bd6ca43e1 代码优化 2025-07-10 10:50:13 +08:00
xy
d6056e2cac 设备登记界面查询调整 2025-07-10 10:32:05 +08:00
xy
8d8eb4d274 事件添加模块信息 2025-07-10 08:49:07 +08:00
xy
b045860a43 事件添加模块信息 2025-07-09 16:45:22 +08:00
xy
c0c3ae4e41 微调 2025-07-09 15:36:00 +08:00
xy
443adfaa37 微调 2025-07-09 15:31:11 +08:00
xy
a314b3c862 新增模块数据展示 2025-07-09 15:20:21 +08:00
xy
282a592a13 调整台账树 2025-07-09 14:08:04 +08:00
xy
0f839dfd5b 微调 2025-07-08 14:02:48 +08:00
xy
45f706475b 定时任务时间调整 2025-07-08 10:11:14 +08:00
xy
0a06d2d5eb 功能优化 2025-07-08 09:40:02 +08:00
xy
bba6da3c7d 功能优化 2025-07-07 14:57:38 +08:00
xy
71d59528a3 功能优化 2025-07-07 14:10:09 +08:00
xy
06de2121f6 描述调整 2025-07-07 10:06:18 +08:00
xy
65d39224ed 新增半月报功能 2025-07-04 10:16:53 +08:00
xy
fda83a1bd9 新增定时任务和治理数据最新时间记录 2025-07-04 08:50:28 +08:00
xy
4ee41b833b 治理设备新增模块状态查询功能 2025-07-03 08:58:12 +08:00
hzj
cd07f8bee3 批量新增设备bug修改 2025-05-21 12:18:46 +08:00
xy
58a559b7b7 bug修改 2025-05-20 10:29:47 +08:00
hzj
52342d736d 批量新增设备bug修改 2025-05-19 10:58:35 +08:00
xy
6f5ffb8395 设备列表添加mqtt连接状态属性 2025-04-28 12:42:10 +08:00
hzj
ed7c02a116 批量新增设备bug修改 2025-04-28 09:42:36 +08:00
hzj
e12d23d4e1 批量新增设备bug修改 2025-04-28 08:41:24 +08:00
xy
0965eed31b 功能调整 2025-02-13 13:13:48 +08:00
xy
f754cf61c4 微调 2025-01-13 09:58:09 +08:00
xy
e32e820417 微调 2025-01-13 09:41:23 +08:00
xy
158917f2bc 新增测试项修改功能 2025-01-09 11:52:41 +08:00
xy
2df06d9597 代码优化 2025-01-08 15:44:26 +08:00
xy
81da6e54ca DVR界面添加条件筛选 2025-01-06 19:18:30 +08:00
xy
1f4e8c7e25 设备录入添加正则判断 2025-01-03 14:40:51 +08:00
xy
f90a3228b9 bug调整 2025-01-03 13:13:28 +08:00
xy
04cdb50b13 微调 2024-12-27 11:01:48 +08:00
b377ad7c95 1.sql调整 2024-12-24 14:27:47 +08:00
hzj
698c0a6eb0 添加ndid正则校验校验 2024-12-23 15:51:59 +08:00
xy
ada760eeb2 微调 2024-12-23 14:31:03 +08:00
xy
b22bd79750 代码优化 2024-12-23 11:35:45 +08:00
hzj
5f14f8fe2f 添加各种名称校验 2024-12-23 09:44:38 +08:00
xy
b93faee241 代码优化 2024-12-20 15:08:55 +08:00
xy
2191276185 添加测试项持续时间 2024-12-20 11:51:39 +08:00
xy
2206f203e8 添加版本信息 2024-12-20 11:26:01 +08:00
xy
c28724bb05 bug调整 2024-12-19 10:29:02 +08:00
hzj
86d21f984c 修改一次值二次值bug 2024-12-18 16:23:54 +08:00
hzj
6f38ddf068 修改bug 2024-12-17 20:36:54 +08:00
d1aefa92d8 1.新增测试项查询接口 2024-12-10 16:39:52 +08:00
51a22057a9 1.新增测试项查询接口 2024-12-10 15:07:44 +08:00
8055d08bda 1.新增测试项查询接口 2024-12-10 08:42:06 +08:00
xy
8a0e0d8c08 功能优化
1.优化界面描述显示;
2.新增测试项暂态事件
2024-12-06 15:24:31 +08:00
xy
3df2bedaa6 添加监测点统计间隔 2024-12-04 17:14:37 +08:00
xy
8e4adc58d4 添加接线方式 2024-12-02 19:04:54 +08:00
xy
98e880b68d 数据处理 2024-11-29 14:39:50 +08:00
xy
327923ba44 微调 2024-11-29 08:57:39 +08:00
xy
e37ace2fd7 代码优化 2024-11-28 17:34:37 +08:00
xy
ea3cff888b 新增数据集接线方式 2024-11-28 16:40:24 +08:00
xy
1f451f9d0e 1.模板调整;
2.新增装置排序
2024-11-28 16:29:28 +08:00
xy
b6c2675311 1.治理App版本信息添加
2.准实时数据接口调整
3.设备登记调整
4.设备接入调整
2024-11-28 08:43:54 +08:00
hzj
d0c7edff8a 补招日志问题修改 2024-11-27 15:57:07 +08:00
59a2bb5e62 1.添加对外接口 2024-11-15 16:12:49 +08:00
hzj
9c2b2dbd3e 补招添加测试项 2024-11-13 15:17:26 +08:00
hzj
be4f50fbc5 补招添加测试项 2024-11-13 13:04:55 +08:00
xy
625ed864c7 微调 2024-11-12 16:42:36 +08:00
xy
10910e36e0 微调 2024-11-12 16:33:18 +08:00
hzj
49d42328ff 修改批处理 2024-11-12 16:30:34 +08:00
xy
53debdf2ef 微调 2024-11-12 16:23:56 +08:00
xy
be6b29cbb7 微调 2024-11-12 14:59:53 +08:00
xy
c72882d023 微调 2024-11-12 14:42:44 +08:00
xy
5022aff834 微调 2024-11-12 14:33:27 +08:00
hzj
b2511aaaf5 将暂态文件路径:换成- 2024-11-12 13:32:10 +08:00
xy
75f07ac86f 实时数据调整 2024-11-12 13:19:33 +08:00
hzj
00b16325d6 数据解析bug 2024-11-11 16:11:53 +08:00
hzj
e09232dc55 接谐波解析bug 2024-11-11 15:50:22 +08:00
hzj
b8157f94c9 线电压项别错误 2024-11-11 14:44:49 +08:00
xy
5c50e18fc9 文件下载bug消缺 2024-11-08 14:05:39 +08:00
hzj
4b8e2488d2 添加告警,设备事件查询 2024-11-06 15:01:12 +08:00
hzj
a4acc4775a 添加告警,设备事件查询 2024-11-06 11:12:42 +08:00
hzj
c4803846a4 拓扑图数据展示 2024-11-05 10:48:46 +08:00
xy
66c54ac3eb 1.优化数据单位显示
2.优化补召功能
3.监测点数据完整性及装置在线率(未开发完)
2024-11-04 20:44:56 +08:00
158 changed files with 7859 additions and 1046 deletions

View File

@@ -0,0 +1,20 @@
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.CsCommunicateFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/pqsCommunicate", fallbackFactory = CsCommunicateFeignClientFallbackFactory.class,contextId = "pqsCommunicate")
public interface CsCommunicateFeignClient {
@PostMapping("/insertion")
HttpResult<String> insertion(@RequestBody PqsCommunicateDto pqsCommunicateDto);
}

View File

@@ -1,7 +1,11 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.fallback.CsLedgerFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
@@ -39,4 +43,9 @@ public interface CsLedgerFeignClient {
@PostMapping("/deviceTree")
@ApiOperation("三层设备树(装置层)")
HttpResult<List<CsLedgerVO>> getDeviceTree();
}
@PostMapping("/getAllLedger")
HttpResult<List<CsLedgerVO>> getAllLedger();
}

View File

@@ -1,10 +1,16 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
@@ -42,4 +48,7 @@ public interface CsLineFeignClient {
@PostMapping("/getById")
HttpResult<CsLinePO> getById(@RequestParam("lineId") String lineId);
@PostMapping("/getLinesByDevList")
HttpResult<List<CsLinePO>> getLinesByDevList(@RequestBody List<String> ids);
}

View File

@@ -1,17 +1,10 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.fallback.DataSetFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.vo.LineTargetVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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;

View File

@@ -10,10 +10,13 @@ import com.njcn.csdevice.api.fallback.EquipmentFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
@@ -61,4 +64,13 @@ public interface EquipmentFeignClient {
@PostMapping("/judgeDevModel")
HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid);
@PostMapping("/getDevByLineId")
HttpResult<CsEquipmentDeliveryPO> getDevByLineId(@RequestParam("lineId") String lineId);
@PostMapping("/updateCldDevStatus")
HttpResult<Boolean> updateCldDevStatus(@RequestParam("nodeId") String nodeId, @RequestParam("processNo") Integer processNo);
@PostMapping("/flipCldDevStatus")
HttpResult<Boolean> flipCldDevStatus(@RequestParam("devId") String devId, @RequestParam("status") Integer status);
}

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.IntegrityClientFallbackFactory;
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
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.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/rStatIntegrityD", fallbackFactory = IntegrityClientFallbackFactory.class,contextId = "rStatIntegrityD")
public interface IntegrityFeignClient {
@PostMapping("/list")
HttpResult<List<RStatIntegrityD>> list(@Validated @RequestParam("list") List<String> list, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime);
}

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.onlineRateClientFallbackFactory;
import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
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.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/rStatOnlineRateD", fallbackFactory = onlineRateClientFallbackFactory.class,contextId = "rStatOnlineRateD")
public interface OnlineRateFeignClient {
@PostMapping("/list")
HttpResult<List<RStatOnlineRateD>> list(@Validated @RequestParam("list") List<String> list, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime);
}

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.WlRecordClientFallbackFactory;
import com.njcn.csdevice.pojo.param.WlRecordParam;
import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.csdevice.pojo.vo.RecordVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@@ -45,6 +46,15 @@ public interface WlRecordFeignClient {
HttpResult<Boolean> updateTestRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record);
@GetMapping("/dayDealNoEndTimeEvent")
@PostMapping("/dayDealNoEndTimeEvent")
void dayDealNoEndTimeEvent(@RequestParam("date") String date);
@GetMapping("/getWlAssByWlId")
HttpResult<List<WlRecord>> getWlAssByWlId(@RequestParam("wlId")String wlId);
@PostMapping("/findDevBaseDataByLineId")
HttpResult<List<RecordVo>> findDevBaseDataByLineId(@RequestBody @Validated WlRecordParam.lineRecord param);
@GetMapping("/getTestRecordById")
HttpResult<RecordVo.RecordItemVo> getTestRecordById(@RequestParam("testRecordId") @Validated String testRecordId);
}

View File

@@ -0,0 +1,40 @@
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.CsCommunicateFeignClient;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/4/10 20:09
*/
@Slf4j
@Component
public class CsCommunicateFeignClientFallbackFactory implements FallbackFactory<CsCommunicateFeignClient> {
@Override
public CsCommunicateFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsCommunicateFeignClient() {
@Override
public HttpResult<String> insertion(PqsCommunicateDto pqsCommunicateDto) {
log.error("{}异常,降级处理,异常为:{}","新增记录",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -62,6 +62,12 @@ public class CsLedgerFeignClientFallbackFactory implements FallbackFactory<CsLed
log.error("{}异常,降级处理,异常为:{}","查询设备树",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsLedgerVO>> getAllLedger() {
log.error("{}异常,降级处理,异常为:{}","获取台账树所有数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -74,6 +74,12 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
log.error("{}异常,降级处理,异常为:{}","根据监测点id获取监测点详情",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsLinePO>> getLinesByDevList(List<String> ids) {
log.error("{}异常,降级处理,异常为:{}","根据装置id集合获取监测点id集合",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -83,6 +83,25 @@ public class EquipmentFeignClientFallbackFactory implements FallbackFactory<Equi
log.error("{}异常,降级处理,异常为:{}","判断设备型号",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsEquipmentDeliveryPO> getDevByLineId(String lineId) {
log.error("{}异常,降级处理,异常为:{}","根据监测点id查询装置信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> updateCldDevStatus(String nodeId, Integer processNo) {
log.error("{}异常,降级处理,异常为:{}","云前置心跳丢失切换设备状态",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> flipCldDevStatus(String devId, Integer status) {
log.error("{}异常,降级处理,异常为:{}","云前置设备状态翻转",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,37 @@
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.IntegrityFeignClient;
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class IntegrityClientFallbackFactory implements FallbackFactory<IntegrityFeignClient> {
@Override
public IntegrityFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new IntegrityFeignClient() {
@Override
public HttpResult<List<RStatIntegrityD>> list(List<String> list, String startTime, String endTime) {
log.error("{}异常,降级处理,异常为:{}","查询数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -6,6 +6,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.WlRecordFeignClient;
import com.njcn.csdevice.pojo.param.WlRecordParam;
import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.csdevice.pojo.vo.RecordVo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -57,6 +58,24 @@ public class WlRecordClientFallbackFactory implements FallbackFactory<WlRecordFe
log.error("{}异常,降级处理,异常为:{}","每日处理没有结束时间的测试基础数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<WlRecord>> getWlAssByWlId(String wlId) {
log.error("{}异常,降级处理,异常为:{}","根据测试项id获取测试项详细条目",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<RecordVo>> findDevBaseDataByLineId(WlRecordParam.lineRecord param) {
log.error("{}异常,降级处理,异常为:{}","根据监测点id查询装置基础数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<RecordVo.RecordItemVo> getTestRecordById(String testRecordId) {
log.error("{}异常,降级处理,异常为:{}","根据测试项ID查询测试项信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,37 @@
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.OnlineRateFeignClient;
import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class onlineRateClientFallbackFactory implements FallbackFactory<OnlineRateFeignClient> {
@Override
public OnlineRateFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new OnlineRateFeignClient() {
@Override
public HttpResult<List<RStatOnlineRateD>> list(List<String> list, String startTime, String endTime) {
log.error("{}异常,降级处理,异常为:{}","查询数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -58,6 +58,8 @@ public interface DataParam {
String GOVERNANCE_SYSTEM = "治理系统";
String cldDev = "云前置设备";
String EvtParamPhase = "Evt_Param_Phase";
String EvtParamDepth = "Evt_Param_VVaDepth";

View File

@@ -35,7 +35,6 @@ public enum AlgorithmResponseEnum {
CHIRLDREN2_EXIST("A00514","项目下存在设备,不能删除"),
CHIRLDREN3_EXIST("A00516","存在设备使用拓扑图,不能删除"),
DATA_ARRAY_MISSING("A00515","详细数据为空"),
UNKNOW_ROLE("A00515","角色无权限操作"),
DATA_MISSING("A00516","数据缺失"),
@@ -48,6 +47,13 @@ public enum AlgorithmResponseEnum {
RECORD_FILE_LOST("A00516","record.bin文件缺失请检查上传文件夹"),
LINE_NUM_MISMATCH("A00516","上传文件的监测点序号和选择的监测点不匹配,请检查"),
DEV_OFFLINE("A00516","装置未连接MQTT服务器"),
OVER_MAX_DEV_COUNT("A00517","前置机超出最大支持装置数"),
DEV_OLD_DATA("A00519","进程数修改失败,原进程数下存在装置,请修改装置进程号"),
DEV_EXIST_DATA("A00520","删除失败,前置机下存在装置"),
CLD_MODEL_MISSING("A00521","云前置模板缺失,请检查模板信息"),
CLD_MODEL_MORE("A00521","存在多个云前置模板,请检查模板信息"),
;

View File

@@ -0,0 +1,44 @@
package com.njcn.csdevice.param;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAddParm;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
import com.njcn.csdevice.pojo.param.CsLineParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author xy
*/
@Data
public class IcdLedgerParam implements Serializable {
@ApiModelProperty("工程索引")
private String engineeringIndex;
@ApiModelProperty("项目索引")
private String projectIndex;
@ApiModelProperty("设备id")
private String devIndex;
@ApiModelProperty("设备和mac关系")
private Map<String,String> devMacMap;
@ApiModelProperty("工程信息")
private CsEngineeringAddParm engineering;
@ApiModelProperty("项目信息")
private AppProjectAddParm project;
@ApiModelProperty("装置信息")
private List<CsEquipmentDeliveryAddParm> device;
@ApiModelProperty("监测点信息")
private List<CsLineParam> line;
}

View File

@@ -0,0 +1,26 @@
package com.njcn.csdevice.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @author xy
*/
@Data
public class IcdParam implements Serializable {
@ApiModelProperty("前置ip不传时查询所有的终端台账信息")
@NotBlank(message = "前置ip不可为空")
private String ip;
@ApiModelProperty("终端运行状态,不传则查询所有的终端信息 (0运行1检修2停运3调试4退运)")
private List<Integer> runFlag;
@ApiModelProperty("终端型号(集合为空查询所有icd模型)")
private List<String> devType;
}

View File

@@ -0,0 +1,70 @@
package com.njcn.csdevice.param;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 监测点有效数值统计数据评估入参
*
* @author hongawen
* @version 1.0
* @data 2024/11/6 20:36
*/
@Data
public class LineCountEvaluateParam implements Serializable {
/**
* 监测点编号集合
*/
private List<String> lineId;
/**
* 表名
*/
private String tableName;
/**
* 相别集合
*/
private List<String> phasicType;
/**
* 值类型
*/
private List<String> valueType;
/**
* 异常数据时间集合
* Map<String,List<String>> key:监测点id value:异常时间集合
*/
private Map<String, List<String>> abnormalTime;
/**
* 列名
*/
private String columnName;
/**
* 最小值 >=
*/
private String ge;
/**
* 最大值 <=
*/
private String lt;
/**
* 数据类型 判断获取数据是否排除暂态异常数据
*/
private Boolean dataType = true;
private String startTime;
private String endTime;
}

View File

@@ -0,0 +1,24 @@
package com.njcn.csdevice.pojo.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Description:
* @Author: wr
* @Date: 2025/3/10 10:01
*/
@Data
public class PqsCommunicateDto implements Serializable {
private String time;
private String devId;
private String description;
private Integer type;
}

View File

@@ -5,7 +5,6 @@ import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
@@ -20,16 +19,16 @@ import java.util.List;
@Data
public class AppProjectAddParm {
private String description;
@ApiModelProperty(value="项目名称")
@NotBlank(message="项目名称不能为空!")
private String name;
@NotBlank(message="工程id不能为空")
//@NotBlank(message="工程id不能为空")
private String engineeringId;
private String icdEngineeringId;
/**
* 地市Id

View File

@@ -47,7 +47,8 @@ public class CsDevModelQueryParm {
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private String versionEndDate;
@ApiModelProperty(value = "装置型号")
private String devType;

View File

@@ -1,12 +1,11 @@
package com.njcn.csdevice.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
*
@@ -19,8 +18,7 @@ import java.util.Date;
*/
@Data
public class CsEquipmentDeliveryAddParm{
public class CsEquipmentDeliveryAddParm implements Serializable {
/**
* 装置名称
@@ -34,13 +32,13 @@ public class CsEquipmentDeliveryAddParm{
*/
@ApiModelProperty(value="网络设备ID")
@NotBlank(message="网络设备ID不能为空")
@Pattern(regexp = "^[A-Za-z0-9]{6,32}$", message = "网络设备ID只可为数字或字母,长度至少为6位")
private String ndid;
/**
* 装置mac地址
*/
@ApiModelProperty(value="装置mac地址")
// @NotBlank(message="装置mac地址不能为空")
private String mac;
/**
@@ -57,56 +55,12 @@ public class CsEquipmentDeliveryAddParm{
@NotBlank(message="装置型号不能为空!")
private String devModel;
// /**
// * 装置程序版本
// */
// @ApiModelProperty(value="装置程序版本")
// @NotBlank(message="装置程序版本不能为空!")
// private String programVersion;
// /**
// * 调试人员
// */
// @ApiModelProperty(value="调试人员")
// @NotBlank(message="调试人员不能为空!")
// private String debugPerson;
//
// /**
// * 出厂日期
// */
// @ApiModelProperty(value="出厂日期")
// @NotNull(message="出厂日期不能为空!")
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
// private Date producteTime;
//
// /**
// * 检修日期
// */
// @ApiModelProperty(value="检修日期")
// @NotNull(message="检修日期不能为空!")
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
// private Date checkTime;
//
// /**
// * 调试日期
// */
// @ApiModelProperty(value="调试日期")
// @NotNull(message="调试日期不能为空!")
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
// private Date debugTime;
/**
* 合同号
*/
@ApiModelProperty(value="合同号")
private String cntractNo;
// /**
// * 营销经理
// */
// @ApiModelProperty(value="营销经理")
// private String salesManager;
/**
* 装置接入方式
*/
@@ -125,4 +79,22 @@ public class CsEquipmentDeliveryAddParm{
@ApiModelProperty(value="模块个数")
private Integer modelNumber;
@ApiModelProperty(value="排序")
private Integer sort;
@ApiModelProperty(value="前置机id")
private String nodeId;
@ApiModelProperty(value="前置机进程号")
private Integer nodeProcess;
@ApiModelProperty(value="模板id")
private String modelId;
@ApiModelProperty(value="工程id")
private String engineeringId;
@ApiModelProperty(value="项目id")
private String projectId;
}

View File

@@ -1,12 +1,11 @@
package com.njcn.csdevice.pojo.param;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import javax.validation.constraints.Pattern;
/**
*
@@ -34,6 +33,7 @@ public class CsEquipmentDeliveryAuditParm {
* 网关识别码
*/
@ApiModelProperty(value="网关识别码")
@Pattern(regexp = "^[A-Za-z0-9]{1,32}$", message = "网络设备ID只可为(数字,字母)")
private String ndid;
/**
@@ -60,51 +60,12 @@ public class CsEquipmentDeliveryAuditParm {
@ApiModelProperty(value="装置接入方式")
private String devAccessMethod;
// /**
// * 装置程序版本
// */
// @ApiModelProperty(value="装置程序版本")
// private String programVersion;
// /**
// * 调试人员
// */
// @ApiModelProperty(value="调试人员")
// private String debugPerson;
//
// /**
// * 出厂日期
// */
// @ApiModelProperty(value="出厂日期")
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
// private Date producteTime;
//
// /**
// * 检修日期
// */
// @ApiModelProperty(value="检修日期")
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
// private Date checkTime;
//
// /**
// * 调试日期
// */
// @ApiModelProperty(value="调试日期")
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
// private Date debugTime;
/**
* 合同号
*/
@ApiModelProperty(value="合同号")
private String cntractNo;
// /**
// * 营销经理
// */
// @ApiModelProperty(value="营销经理")
// private String salesManager;
/**
* 状态
*/
@@ -128,4 +89,16 @@ public class CsEquipmentDeliveryAuditParm {
*/
@ApiModelProperty(value="模块个数")
private Integer modelNumber;
@ApiModelProperty(value="装置使用状态(0:停用 1:启用)")
private Integer usageStatus;
@ApiModelProperty(value="排序")
private Integer sort;
@ApiModelProperty(value="前置机id")
private String nodeId;
@ApiModelProperty(value="前置机进程号")
private Integer nodeProcess;
}

View File

@@ -34,4 +34,10 @@ public class CsEquipmentDeliveryQueryParm extends BaseParam {
@ApiModelProperty("运行状态 1:离线 2:在线")
private Integer runStatus;
@ApiModelProperty("流程步骤")
private Integer process;
@ApiModelProperty("物联通讯状态 0:未连接 1:已连接")
private Integer connectStatus;
}

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.pojo.param;
import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -18,25 +19,71 @@ public class CsLineParam extends BaseEntity {
private String lineId;
/**
* 监测点名称
*/
private String name;
@ApiModelProperty(value="工程id")
private String engineeringId;
@ApiModelProperty(value="项目id")
private String projectId;
/**
* 装置id
*/
private String devId;
/**
* 装置mac
*/
private String devMac;
/**
* 电压等级
*/
private Double volGrade;
/**
* PT变比
* 接线方式
*/
private Integer conType;
/**
* PT一次变比
*/
private Double ptRatio;
/**
* CT变比
* PT二次变比
*/
private Double pt2Ratio;
/**
* CT一次变比
*/
private Double ctRatio;
/**
* 接线方式
* CT二次变比
*/
private Integer conType;
private Double ct2Ratio;
/**
* 逻辑子设备id
*/
private Integer clDid;
/**
* 监测点线路号
*/
private Integer lineNo;
/**
* 统计间隔
*/
private Integer lineInterval;
/**
* 模板id
@@ -48,4 +95,8 @@ public class CsLineParam extends BaseEntity {
*/
private String dataSetId;
/**
* 运行状态0运行1检修2停运3调试4退运
*/
private Integer runStatus;
}

View File

@@ -24,4 +24,7 @@ public class DataArrayParam {
@ApiModelProperty("数据类型")
private String statMethod;
@ApiModelProperty("数据集编号")
private Integer idx;
}

View File

@@ -0,0 +1,104 @@
package com.njcn.csdevice.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.web.constant.ValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
/**
* pqs
*
* @author cdf
* @date 2022/1/14
*/
@Data
@ApiModel
public class NodeParam {
/**
* 名称
*/
@ApiModelProperty(name = "name",value = "前置服务器名称")
@NotBlank(message = "前置机名称不能为空")
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = ValidMessage.NAME_FORMAT_ERROR)
private String name;
/**
* 服务器IP
*/
@ApiModelProperty(name = "ip",value = "服务器IP")
@NotBlank(message = "前置机IP不能为空")
@Pattern(regexp = PatternRegex.IP_REGEX, message = ValidMessage.IP_FORMAT_ERROR)
private String ip;
/**
* 描述
*/
@ApiModelProperty(name = "remark",value = "描述")
private String remark;
/**
* 状态 前置等级
*/
@ApiModelProperty(name = "nodeGrade",value = "前置等级")
@NotNull(message = "前置机等级不可为空")
private Integer nodeGrade;
/**
* 前置机支持最大装置数
*/
@ApiModelProperty(name = "nodeDevNum",value = "前置机支持最大装置数")
@NotNull(message = "前置机支持最大装置数不可为空")
@Min(value = 1, message = "装置数不可小于1")
@Max(value = 1000, message = "装置数不可大于1000")
private Integer nodeDevNum;
/**
* 前置机支持最大进程数量
*/
@ApiModelProperty(name = "nodeDevNum",value = "前置机支持最大进程数量")
@NotNull(message = "前置机支持最大进程数量")
@Min(value = 1, message = "最大进程数量不可小于1")
@Max(value = 10, message = "最大进程数量不可大于10")
private Integer maxProcessNum;
/**
* 排序
*/
@ApiModelProperty(name = "sort",value = "排序")
@NotNull(message = "排序不可为空")
private Integer sort;
/**
* 更新操作实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class NodeUpdateParam extends NodeParam {
/**
* 表Id
*/
@ApiModelProperty("id")
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
private String id;
}
/**
* 前置查询
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class NodeQueryParam extends BaseParam {
@ApiModelProperty("前置等级")
private Integer nodeGrade;
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -34,9 +35,11 @@ public class WlRecordParam {
private String lineId;
@ApiModelProperty("项目起始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime proStartTime;
@ApiModelProperty("项目结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime proEndTime;
@ApiModelProperty("测试项名称")
@@ -99,4 +102,23 @@ public class WlRecordParam {
private String id;
}
@Data
@EqualsAndHashCode(callSuper = true)
public static class lineRecord extends WlRecordParam {
@ApiModelProperty("监测点id")
private String lineId;
@ApiModelProperty("测试项起始时间")
private String itemStartTime;
@ApiModelProperty("测试项结束时间")
private String itemEndTime;
@ApiModelProperty("数据来源 0:补召 1:在线监测 ")
private Integer dataSource;
}
}

View File

@@ -80,4 +80,8 @@ public class CsDataSet extends BaseEntity {
*/
private String dataLevel;
/**
* 接线方式
*/
private Integer conType;
}

View File

@@ -64,8 +64,6 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
@TableField(value = "dev_access_method")
private String devAccessMethod;
/**
* 合同号
*/
@@ -108,4 +106,28 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
@TableField(value = "process")
private Integer process;
/**
* 装置使用状态(0:停用 1:启用)
*/
@TableField(value = "usage_status")
private Integer usageStatus;
/**
* 排序
*/
@TableField(value = "sort")
private Integer sort;
/**
* 前置服务器IP
*/
@TableField(value = "node_id")
private String nodeId;
/**
* 前置进程号
*/
@TableField(value = "node_process")
private Integer nodeProcess;
}

View File

@@ -66,12 +66,24 @@ public class CsLinePO extends BaseEntity {
@TableField(value = "pt_ratio")
private Double ptRatio;
/**
* PT2次变比
*/
@TableField(value = "pt2_ratio")
private Double pt2Ratio;
/**
* CT变比
*/
@TableField(value = "ct_ratio")
private Double ctRatio;
/**
* CT2变比
*/
@TableField(value = "ct2_ratio")
private Double ct2Ratio;
/**
* 状态(0删除 1正常)
*/
@@ -86,13 +98,28 @@ public class CsLinePO extends BaseEntity {
/**
* 逻辑子设备id(与模板对应)
* 治理监测点 0
* 负载监测点 1
* 电网监测点 2
*/
@TableField(value = "clDid")
private Integer clDid;
@TableField(value = "device_id")
private String deviceId;
/**
* 监测点统计间隔
*/
@TableField(value = "line_interval")
private Integer lineInterval;
/**
* 运行状态
*/
@TableField(value = "run_status")
private Integer runStatus;
/**
* 监测点线路号
*/
@TableField(value = "line_no")
private Integer lineNo;
}

View File

@@ -0,0 +1,70 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author xy
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pq_node")
public class Node extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 前置序号
*/
private String id;
/**
* 名称
*/
private String name;
/**
* 服务器IP
*/
private String ip;
/**
* 描述
*/
private String remark;
/**
* 状态 0-删除1-正常;默认正常
*/
private Integer state;
/**
* 状态 前置等级
*/
private Integer nodeGrade;
/**
* 前置机支持最大装置数
*/
private Integer nodeDevNum;
/**
* 前置机支持最大进程数量
*/
private Integer maxProcessNum;
/**
* 排序
*/
private Integer sort;
}

View File

@@ -0,0 +1,35 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
/**
* <p>
* 数据完整性日表
* </p>
*
* @author xy
* @since 2025-06-23
*/
@Data
@TableName("r_stat_integrity_d")
public class RStatIntegrityD implements Serializable {
private static final long serialVersionUID = 1L;
@MppMultiId
private LocalDate timeId;
@MppMultiId
private String lineIndex;
private Integer dueTime;
private Integer realTime;
}

View File

@@ -0,0 +1,35 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
/**
* <p>
* 在线率日表
* </p>
*
* @author xy
* @since 2025-06-23
*/
@Data
@TableName("r_stat_onlinerate_d")
public class RStatOnlineRateD implements Serializable {
private static final long serialVersionUID = 1L;
@MppMultiId
private LocalDate timeId;
@MppMultiId
private String devIndex;
private Integer onlineMin;
private Integer offlineMin;
}

View File

@@ -150,4 +150,10 @@ public class WlRecord extends BaseEntity {
*/
private String gcDataPath;
/**
* 数据类型(Primary:一次值 Secondary:二次值)
*/
@TableField(exist = false)
private String dataLevel;
}

View File

@@ -0,0 +1,42 @@
package com.njcn.csdevice.pojo.vo;
import com.njcn.csdevice.pojo.po.AppProjectPO;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author xy
*/ //台账信息
@Data
public class CldLedgerVo implements Serializable {
@ApiModelProperty("工程id")
private String engineeringId;
@ApiModelProperty(value = "工程名称")
private String engineeringName;
@ApiModelProperty(value = "")
private String province;
@ApiModelProperty(value = "")
private String city;
@ApiModelProperty(value = "工程描述")
private String engineeringDescription;
@ApiModelProperty(value = "项目信息")
private List<AppProjectPO> projectInfoList;
@ApiModelProperty(value = "设备信息")
private List<CsEquipmentDeliveryPO> deviceInfoList;
@ApiModelProperty(value = "监测点信息")
private List<CsLinePO> lineInfoList;
}

View File

@@ -83,4 +83,15 @@ public class CsEquipmentDeliveryVO extends BaseEntity {
@ApiModelProperty(value="设备当前流程状态")
private Integer process ;
@ApiModelProperty(value="装置使用状态(0:停用 1:启用)")
private Integer usageStatus ;
@ApiModelProperty(value="装置与MQTT服务器连接状态")
private String connectStatus ;
private Integer sort;
@ApiModelProperty(value="前置服务器id")
private String nodeId ;
}

View File

@@ -23,13 +23,25 @@ public class CsLedgerVO implements Serializable {
@ApiModelProperty(name = "pid",value = "父id")
private String pid;
@ApiModelProperty(name = "pids",value = "父id集合")
private String pids;
@ApiModelProperty(name = "name",value = "名称")
private String name;
@ApiModelProperty(name = "path",value = "拓扑图路径")
private String path;
@ApiModelProperty(name = "provinceId",value = "省Id")
private String provinceId;
@ApiModelProperty(name = "cityId",value = "市Id")
private String cityId;
@ApiModelProperty(name = "area",value = "区域")
private String area;
@ApiModelProperty(name = "remark",value = "备注")
private String remark;
@@ -48,6 +60,15 @@ public class CsLedgerVO implements Serializable {
@ApiModelProperty(name = "type",value = "类型 项目 工程 装置 监测点")
private String type;
@ApiModelProperty(name = "lineType",value = "监测点类型 0:治理监测点 1:电能质量监测点")
private Integer lineType;
@ApiModelProperty(name = "conType",value = "接线方式 0-星型 1-角型 2-V型")
private Integer conType;
@ApiModelProperty(name = "process",value = "流程状态")
private Integer process;
@ApiModelProperty(name = "children",value = "子节点")
private List<CsLedgerVO> children = new ArrayList<>();

View File

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
/**
@@ -12,7 +13,7 @@ import java.time.LocalDateTime;
* @date 2023/6/19
*/
@Data
public class DataGroupEventVO {
public class DataGroupEventVO {
@ApiModelProperty("id")
private String id;
@@ -26,6 +27,12 @@ public class DataGroupEventVO {
@ApiModelProperty("监测点名称")
private String lineName;
@ApiModelProperty("装置ID")
private String deviceId;
@ApiModelProperty("装置名称")
private String devName;
@ApiModelProperty("项目名称")
private String projectName;

View File

@@ -0,0 +1,69 @@
package com.njcn.csdevice.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
//台账信息
@Data
public class DeviceInfo implements Serializable {
@ApiModelProperty("终端索引")
private String id;
@ApiModelProperty("终端mac")
private String ip;
@ApiModelProperty("终端型号")
private String devType;
@ApiModelProperty("终端名称")
private String name;
@ApiModelProperty("前置机序号")
private Integer node;
@ApiModelProperty("监测点集合")
private List<MonitorInfo> monitorData;
//终端下的监测点信息
@Data
public static class MonitorInfo implements Serializable {
@ApiModelProperty("监测点索引")
private String id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("监测点逻辑号")
private String lineNo;
@ApiModelProperty("监测点电压等级")
private String voltageLevel;
@ApiModelProperty("监测点运行状态 0运行1检修2停运3调试4退运")
private Integer status;
@ApiModelProperty("监测点接线方式 0-星型 1-角型 2-V型")
private String ptType;
@ApiModelProperty("装置id")
private String deviceId;
@ApiModelProperty("pt1")
private Double pt1;
@ApiModelProperty("pt2")
private Double pt2;
@ApiModelProperty("ct1")
private Double ct1;
@ApiModelProperty("ct2")
private Double ct2;
}
}

View File

@@ -0,0 +1,68 @@
package com.njcn.csdevice.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author xy
*/
@Data
public class EachModuleVO implements Serializable {
@ApiModelProperty("模块名称")
private String moduleName;
@ApiModelProperty("模块状态")
private String moduleState;
@ApiModelProperty("模块运行状态数据")
List<HarmonicVo> dataList;
@ApiModelProperty("负载电流数据")
List<DataVo> loadList;
@ApiModelProperty("模块输出电流")
List<DataVo> modOutList;
@ApiModelProperty("模块温度")
List<DataVo> temperatureList;
@Data
public static class HarmonicVo implements Serializable {
@ApiModelProperty("稳态数据时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime time;
@ApiModelProperty("模块状态 0-离线1-运行2-停止3-故障")
private String stateDesc;
@ApiModelProperty("数据类型 0-稳态数据 1-事件数据 2-主动触发")
private Integer dataType;
@ApiModelProperty("事件code")
private String eventCode;
@ApiModelProperty("事件名称")
private String eventName;
}
@Data
public static class DataVo implements Serializable {
@ApiModelProperty("稳态数据时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime time;
@ApiModelProperty("相别")
private String phasicType;
@ApiModelProperty("数据")
private Double data;
}
}

View File

@@ -22,6 +22,9 @@ public class RecordVo {
@ApiModelProperty("名称")
private String itemName;
@ApiModelProperty("监测点id")
private String lineId;
@ApiModelProperty("数据起始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
@@ -30,6 +33,9 @@ public class RecordVo {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
@ApiModelProperty("持续时间")
private String lastTime;
@ApiModelProperty("测试位置")
private String location;

View File

@@ -0,0 +1,30 @@
package com.njcn.csdevice.utils;
import com.njcn.common.pojo.exception.BusinessException;
import java.util.regex.Pattern;
/**
* Description:
* Date: 2024/12/17 14:29【需求编号】
*
* @author clam
* @version V1.0.0
*/
public class StringUtil {
public static void containsSpecialCharacters(String str) {
// 定义包含特殊字符的正则表达式
String specialChars = "[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";
// 创建Pattern对象
Pattern pattern = Pattern.compile(specialChars);
// 使用Pattern对象的matcher方法检查字符串
if(pattern.matcher(str).find()){
throw new BusinessException("存在特殊字符[<>\"'%;()&+//\\-———|@*_?#$!,.html]");
}
}
public static void main(String[] args) {
StringUtil.containsSpecialCharacters("*");
}
}

View File

@@ -76,8 +76,7 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>user-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
@@ -92,8 +91,7 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>cs-warn-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
<version>${project.version}</version>
</dependency>
<!-- zxing生成二维码 -->
@@ -107,9 +105,6 @@
<groupId>com.njcn</groupId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
@@ -139,8 +134,7 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>cs-harmonic-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>com.njcn</groupId>
@@ -151,20 +145,14 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>cs-system-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>access-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>

View File

@@ -0,0 +1,20 @@
package com.njcn.csdevice.controller.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* 动态注解类
*
* @author hongawen
* @version 1.0
* @data 2024/11/7 11:00
*/
@Target({ElementType.TYPE,ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface InsertBean {
}

View File

@@ -0,0 +1,20 @@
package com.njcn.csdevice.controller.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* 动态注解类
*
* @author hongawen
* @version 1.0
* @data 2024/11/7 11:00
*/
@Target({ElementType.TYPE,ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface QueryBean {
}

View File

@@ -0,0 +1,78 @@
package com.njcn.csdevice.controller.bean;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.controller.annotation.InsertBean;
import com.njcn.csdevice.controller.annotation.QueryBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Field;
/**
* @author hongawen
* @version 1.0
* @data 2024/11/7 11:31
*/
@Component
public class DynamicBeanProcessor implements BeanPostProcessor {
@Autowired
private ApplicationContext context;
/**
* 查询配置
*/
@Value("${data.source.query:Influxdb}")
private String queryParam;
/**
* 插入配置
*/
@Value("${data.source.insert:Relation}")
private String insertParam;
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean.getClass().isAnnotationPresent(Controller.class) || bean.getClass().isAnnotationPresent(RestController.class) || bean.getClass().isAnnotationPresent(Service.class)) {
processFields(bean);
}
return bean;
}
private void processFields(Object bean) {
Field[] fields = bean.getClass().getDeclaredFields();
for (Field field : fields) {
String beanId;
Class<?> type = field.getType();
// 判断是否是接口类型,并且是否是注解指定类库
if (type.isInterface() && (field.isAnnotationPresent(QueryBean.class) || field.isAnnotationPresent(InsertBean.class))) {
String name = type.getName();
beanId = name.substring(name.lastIndexOf(".") + 2);
if (field.isAnnotationPresent(QueryBean.class)) {
beanId = queryParam + beanId + "Impl";
} else if (field.isAnnotationPresent(InsertBean.class)) {
beanId = insertParam + beanId + "Impl";
}
try {
field.setAccessible(true);
field.set(bean, context.getBean(beanId));
} catch (IllegalAccessException e) {
throw new BusinessException("获取动态实现类失败");
}
}
}
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
}

View File

@@ -0,0 +1,78 @@
package com.njcn.csdevice.controller.data;
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.controller.annotation.QueryBean;
import com.njcn.csdevice.param.LineCountEvaluateParam;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.csdevice.service.ICsCommunicateService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author hongawen
* @version 1.0
* @data 2024/11/6 19:48
*/
@Validated
@Slf4j
@Controller
@RestController
@RequestMapping("/pqsCommunicate")
@Api(tags = "获取装置上下线记录")
public class PqsCommunicateController extends BaseController {
@QueryBean
private ICsCommunicateService pqsCommunicateCvtQuery;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getRawDataLatest")
@ApiOperation("获取取出最新装置数据")
public HttpResult<List<PqsCommunicateDto>> getRawDataLatest(@RequestBody LineCountEvaluateParam lineParam) {
String methodDescribe = getMethodDescribe("getRawDataLatest");
List<PqsCommunicateDto> rawData = pqsCommunicateCvtQuery.getRawDataLatest(lineParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rawData, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getRawData")
@ApiOperation("获取原始数据")
public HttpResult<List<PqsCommunicateDto>> getRawData(@RequestBody LineCountEvaluateParam lineParam) {
String methodDescribe = getMethodDescribe("getRawData");
List<PqsCommunicateDto> rawData = pqsCommunicateCvtQuery.getRawData(lineParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rawData, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getRawDataEnd")
@ApiOperation("获取是否有当天最后一条数据")
public HttpResult<List<PqsCommunicateDto>> getRawDataEnd(@RequestBody LineCountEvaluateParam lineParam) {
String methodDescribe = getMethodDescribe("getRawData");
List<PqsCommunicateDto> rawData = pqsCommunicateCvtQuery.getRawDataEnd(lineParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rawData, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
@PostMapping("/insertion")
@ApiOperation("插入数据")
public HttpResult<String> insertion(@RequestBody PqsCommunicateDto pqsCommunicateDto) {
String methodDescribe = getMethodDescribe("insertion");
pqsCommunicateCvtQuery.insertion(pqsCommunicateDto);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -0,0 +1,60 @@
package com.njcn.csdevice.controller.data;
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.po.RStatIntegrityD;
import com.njcn.csdevice.service.IRStatIntegrityDService;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.web.controller.BaseController;
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;
/**
* <p>
* 数据完整性日表 前端控制器
* </p>
*
* @author xy
* @since 2025-06-23
*/
@Slf4j
@RestController
@RequestMapping("/rStatIntegrityD")
@Api(tags = "数据完整性接口")
@AllArgsConstructor
public class RStatIntegrityDController extends BaseController {
private final IRStatIntegrityDService irStatIntegrityDService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add")
@ApiOperation("新增数据完整性(可根据时间段进行补召)")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> addData(@RequestBody @Validated StatisticsDataParam param){
String methodDescribe = getMethodDescribe("addData");
irStatIntegrityDService.addData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/list")
@ApiOperation("获取数据")
public HttpResult<List<RStatIntegrityD>> list(@Validated @RequestParam("list") List<String> list, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime){
String methodDescribe = getMethodDescribe("list");
List<RStatIntegrityD> result = irStatIntegrityDService.getData(list,startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -0,0 +1,60 @@
package com.njcn.csdevice.controller.data;
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.po.RStatOnlineRateD;
import com.njcn.csdevice.service.IRStatOnlineRateDService;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.web.controller.BaseController;
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;
/**
* <p>
* 在线率日表 前端控制器
* </p>
*
* @author xy
* @since 2025-06-23
*/
@Slf4j
@RestController
@RequestMapping("/rStatOnlineRateD")
@Api(tags = "终端在线率接口")
@AllArgsConstructor
public class RStatOnlineRateDController extends BaseController {
private final IRStatOnlineRateDService rStatOnlineRateDService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add")
@ApiOperation("新增终端在线率(可根据时间段进行补召)")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> addData(@RequestBody @Validated StatisticsDataParam param){
String methodDescribe = getMethodDescribe("addData");
rStatOnlineRateDService.addData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/list")
@ApiOperation("获取数据")
public HttpResult<List<RStatOnlineRateD>> list(@Validated @RequestParam("list") List<String> list, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime){
String methodDescribe = getMethodDescribe("list");
List<RStatOnlineRateD> result = rStatOnlineRateDService.getData(list,startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -54,7 +54,7 @@ public class DevModelController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/AuditDevModel")
@ApiOperation("更新/删除出厂设备")
@ApiOperation("更新/删除设备模板参数")
@ApiImplicitParam(name = "csDevModelAuditParm", value = "更新/删除设备模板参数", required = true)
public HttpResult<Boolean> AuditDevModel(@RequestBody @Validated CsDevModelAuditParm csDevModelAuditParm ){
String methodDescribe = getMethodDescribe("AuditDevModel");

View File

@@ -1,18 +1,16 @@
package com.njcn.csdevice.controller.equipment;
import cn.hutool.core.collection.CollectionUtil;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
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.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.service.DeviceFtpService;
import com.njcn.csharmonic.pojo.vo.MakeUpVo;
import com.njcn.redis.utils.RedisUtil;
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;
@@ -25,7 +23,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
/**
* @author xy
@@ -63,9 +60,6 @@ public class DeviceFtpController extends BaseController {
public HttpResult<List<MakeUpVo>> askDeviceFileOrDir(@RequestParam("nDid") String nDid, @RequestParam("name") String name, @RequestParam("type") String type){
String methodDescribe = getMethodDescribe("askDeviceFileOrDir");
List<MakeUpVo> list = deviceFtpService.askDeviceFileOrDir(nDid,name,type);
if (CollectionUtil.isEmpty(list) && Objects.equals(type,"file")) {
throw new BusinessException(AlgorithmResponseEnum.ASK_DEVICE_DIR_ERROR);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@@ -79,7 +73,7 @@ public class DeviceFtpController extends BaseController {
@ApiImplicitParam(name = "fileCheck", value = "文件校验码", required = true)
})
public HttpResult<String> downloadFile(@RequestParam("nDid") String nDid, @RequestParam("name") String name, @RequestParam("size") Integer size, @RequestParam("fileCheck") String fileCheck){
String methodDescribe = getMethodDescribe("downloadFile");
redisUtil.saveByKeyWithExpire("fileDownUserId"+nDid+name,RequestUtil.getUserIndex(),600L);
deviceFtpService.downloadFile(nDid,name,size,fileCheck);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "文件下载中,请稍等");
}

View File

@@ -9,7 +9,6 @@ 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.constant.DataParam;
import com.njcn.csdevice.enums.DeviceOperate;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.param.*;
@@ -23,6 +22,9 @@ import com.njcn.csdevice.service.IMqttUserService;
import com.njcn.csdevice.utils.ExcelStyleUtil;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.poi.util.PoiUtil;
import com.njcn.system.api.DictTreeFeignClient;
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 io.swagger.annotations.*;
@@ -30,6 +32,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -37,10 +40,11 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
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
@@ -55,21 +59,20 @@ import java.util.stream.Stream;
@Api(tags = " 出厂设备")
@AllArgsConstructor
public class EquipmentDeliveryController extends BaseController {
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final IMqttUserService mqttUserService;
private final CsDevModelRelationService csDevModelRelationService;
private final DictTreeFeignClient dictTreeFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addEquipmentDelivery")
@ApiOperation("新增出厂设备")
@ApiImplicitParam(name = "csEquipmentDeliveryAddParm", value = "新增项目参数", required = true)
@DeviceLog(operateType = DeviceOperate.ADD)
public HttpResult<Boolean> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm){
public HttpResult<CsEquipmentDeliveryPO> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm){
String methodDescribe = getMethodDescribe("addEquipmentDelivery");
Boolean flag = csEquipmentDeliveryService.save(csEquipmentDeliveryAddParm);
if (flag){
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.save(csEquipmentDeliveryAddParm);
if (Objects.nonNull(po)){
//查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAddParm.getNdid());
if (result){
@@ -77,10 +80,9 @@ public class EquipmentDeliveryController extends BaseController {
mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid());
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/AuditEquipmentDelivery")
@ApiOperation("删除出厂设备")
@@ -99,19 +101,24 @@ public class EquipmentDeliveryController extends BaseController {
public HttpResult<Boolean> updateEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm ){
String methodDescribe = getMethodDescribe("updateEquipmentDelivery");
Boolean flag = csEquipmentDeliveryService.updateEquipmentDelivery(csEquipmentDeliveryAuditParm);
if (flag){
//查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAuditParm.getNdid());
if (result){
//初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(csEquipmentDeliveryAuditParm.getNdid());
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryEquipmentByndid")
@ApiOperation("通过ndid查询出厂设备")
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
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);
}
@@ -133,11 +140,12 @@ 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);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryEquipmentById")
@ApiOperation("设备查询通过id获取")
@@ -162,12 +170,6 @@ public class EquipmentDeliveryController extends BaseController {
public HttpResult<Page<CsEquipmentDeliveryVO>> list(@RequestBody CsEquipmentDeliveryQueryParm param){
String methodDescribe = getMethodDescribe("list");
Page<CsEquipmentDeliveryVO> page = csEquipmentDeliveryService.list(param);
//新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){
csEquipmentDeliveryVO.setStatus(5);
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@@ -210,17 +212,21 @@ public class EquipmentDeliveryController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@ResponseBody
@ApiOperation("导出设备模板")
@GetMapping(value = "getExcelTemplate")
public HttpResult<String> getExcelTemplate(HttpServletResponse response) {
String methodDescribe = getMethodDescribe("getExcelTemplate");
ExportParams exportParams = new ExportParams("批量导入模板(请严格按照模板标准填入数据)", "终端入网检测录入信息");
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceExcelTemplete.class, new ArrayList<DeviceExcelTemplete>());
ExcelUtil.selectList(workbook, 2, 2, Stream.of("直连设备","网关设备").collect(Collectors.toList()).toArray(new String[]{}));
List<SysDicTreePO> deviceType = dictTreeFeignClient.queryByCodeList(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData();
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[]{}));
String fileName = "设备模板.xlsx";
ExportParams exportExcel = new ExportParams("设备模板", "设备模板");
@@ -233,9 +239,20 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping(value = "importEquipment")
public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importEquipment");
csEquipmentDeliveryService.importEquipment(file, response);
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.importEquipment(file, response);
if (!CollectionUtils.isEmpty(csEquipmentDeliveryPOS)){
csEquipmentDeliveryPOS.forEach(temp->{
//查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(temp.getNdid());
if (result){
//初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(temp.getNdid());
}
});
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@ResponseBody
@ApiOperation("联调完成")
@PostMapping(value = "testcompletion")
@@ -258,8 +275,8 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/updateSoftInfo")
@ApiOperation("更新设备软件信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "nDid", value = "网络设备码", required = true),
@ApiImplicitParam(name = "id", value = "软件信息id", required = true)
@ApiImplicitParam(name = "nDid", value = "网络设备码", required = true),
@ApiImplicitParam(name = "id", value = "软件信息id", required = true)
})
@ApiIgnore
public HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid,@RequestParam("id") String id){
@@ -282,7 +299,6 @@ public class EquipmentDeliveryController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/rebootDevice")
@ApiOperation("重启设备")
@@ -315,4 +331,74 @@ public class EquipmentDeliveryController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDevByLineId")
@ApiOperation("根据监测点id查询装置信息")
public HttpResult<CsEquipmentDeliveryPO> getDevByLineId(@RequestParam("lineId") String lineId){
String methodDescribe = getMethodDescribe("getDevByLineId");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.getDevByLineId(lineId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addCldDev")
@ApiOperation("新增云前置设备")
@ApiImplicitParam(name = "param", value = "参数", required = true)
@DeviceLog(operateType = DeviceOperate.ADD)
public HttpResult<CsEquipmentDeliveryPO> addCldDev(@RequestBody @Validated CsEquipmentDeliveryAddParm param){
String methodDescribe = getMethodDescribe("addCldDev");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.saveCld(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/delCldDev")
@ApiOperation("删除云前置设备")
@ApiImplicitParam(name = "id", value = "id", required = true)
@DeviceLog(operateType = DeviceOperate.DELETE)
public HttpResult<Boolean> delCldDev(@RequestBody @Validated String id){
String methodDescribe = getMethodDescribe("delCldDev");
boolean result = csEquipmentDeliveryService.delCldDev(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateCldDev")
@ApiOperation("修改云前置设备")
@ApiImplicitParam(name = "param", value = "参数", required = true)
@DeviceLog(operateType = DeviceOperate.UPDATE)
public HttpResult<Boolean> updateCldDev(@RequestBody @Validated CsEquipmentDeliveryAuditParm param){
String methodDescribe = getMethodDescribe("updateCldDev");
boolean result = csEquipmentDeliveryService.updateCldDev(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateCldDevStatus")
@ApiOperation("云前置心跳丢失切换设备状态")
@ApiImplicitParams({
@ApiImplicitParam(name = "nodeId", value = "前置服务器id", required = true),
@ApiImplicitParam(name = "processNo", value = "进程号", required = true)
})
@ApiIgnore
public HttpResult<Boolean> updateCldDevStatus(@RequestParam("nodeId") String nodeId, @RequestParam("processNo") Integer processNo){
String methodDescribe = getMethodDescribe("updateCldDevStatus");
csEquipmentDeliveryService.updateCldDevStatus(nodeId,processNo);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/flipCldDevStatus")
@ApiOperation("云前置设备状态翻转")
@ApiImplicitParams({
@ApiImplicitParam(name = "devId", value = "设备id", required = true),
@ApiImplicitParam(name = "status", value = "状态", required = true)
})
@ApiIgnore
public HttpResult<Boolean> flipCldDevStatus(@RequestParam("devId") String devId, @RequestParam("status") Integer status){
String methodDescribe = getMethodDescribe("flipCldDevStatus");
csEquipmentDeliveryService.flipCldDevStatus(devId,status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -0,0 +1,67 @@
package com.njcn.csdevice.controller.icd;
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.IcdLedgerParam;
import com.njcn.csdevice.param.IcdParam;
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
import com.njcn.csdevice.pojo.vo.DeviceInfo;
import com.njcn.csdevice.service.IcdService;
import com.njcn.web.controller.BaseController;
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 xy
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/icd")
@Api(tags = "云前置改造")
@AllArgsConstructor
public class IcdController extends BaseController {
private final IcdService icdService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLedgerInfo")
@ApiOperation("获取台账信息")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<DeviceInfo>> getLedgerInfo(@RequestBody @Validated IcdParam param){
String methodDescribe = getMethodDescribe("getLedgerInfo");
List<DeviceInfo> result = icdService.getLedgerInfo(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addLedgerInfo")
@ApiOperation("新增台账信息")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<DeviceInfo>> addLedgerInfo(@RequestBody @Validated IcdLedgerParam param){
String methodDescribe = getMethodDescribe("addLedgerInfo");
icdService.addLedgerInfo(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLedgerById")
@ApiOperation("根据Id获取台账信息")
@ApiImplicitParam(name = "id", value = "id", required = true)
public HttpResult<CldLedgerVo> getLedgerById(@RequestParam String id){
String methodDescribe = getMethodDescribe("getLedgerById");
CldLedgerVo vo = icdService.getLedgerById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
}
}

View File

@@ -0,0 +1,163 @@
package com.njcn.csdevice.controller.icd;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.param.NodeParam;
import com.njcn.csdevice.pojo.po.Node;
import com.njcn.csdevice.service.INodeService;
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.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 前置程序控制器
* @author xy
*/
@Slf4j
@Api(tags = "前置机管理")
@RestController
@RequestMapping("node")
@RequiredArgsConstructor
public class NodeController extends BaseController {
private final INodeService iNodeService;
/**
* 新增前置机
* @author cdf
* @date 2021/6/23
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
@ApiOperation("新增前置机")
@ApiImplicitParam(value = "前置机信息",name = "nodeParam",required = true)
@PostMapping("addNode")
public HttpResult<Boolean> addNode(@Validated @RequestBody NodeParam nodeParam){
String methodDescribe = getMethodDescribe("addNode");
boolean result = iNodeService.addNode(nodeParam);
if (result){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
/**
* 修改前置机
* @author cdf
* @date 2021/6/23
*/
@ApiOperation("修改前置机")
@ApiImplicitParam(value = "前置机信息",name = "updateNodeParam",required = true)
@PutMapping("updateNode")
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
public HttpResult<Boolean> updateNode(@Validated @RequestBody NodeParam.NodeUpdateParam updateNodeParam){
String methodDescribe = getMethodDescribe("updateNode");
boolean result = iNodeService.updateNode(updateNodeParam);
if (result){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
/**
* 删除前置
* @author cdf
* @date 2021/6/23
*/
@ApiOperation(value = "删除前置机")
@ApiImplicitParam(value = "前置机id",name = "id",required = true)
@PostMapping("delNode")
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE)
public HttpResult<Boolean> delNode(@Validated @NotNull(message = "id不可为空") @RequestParam("id")String id){
String methodDescribe = getMethodDescribe("delNode");
boolean result = iNodeService.delNode(id);
if (result){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
/**
* 变更前置机状态
* @author cdf
* @date 2021/6/23
*/
@ApiOperation(value = "变更前置机状态")
@ApiImplicitParams({
@ApiImplicitParam(value = "前置机id",name = "id",required = true ),
@ApiImplicitParam(value = "前置机状态",name = "state",required = true )
})
@PostMapping("updateNodeState")
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
public HttpResult<Boolean> updateNodeState(@Validated @NotNull(message = "id不可为空") @RequestParam("id")String id,@NotNull(message = "状态不为空") @RequestParam("state")Integer state){
String methodDescribe = getMethodDescribe("updateNodeState");
boolean result = iNodeService.updateNodeState(id,state);
if (result){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
/**
* 获取全部前置机分页
* @author cdf
* @date 2021/6/23
*/
@ApiOperation("获取全部前置机")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@PostMapping("nodeList")
public HttpResult<Page<Node>> nodeList(@RequestBody NodeParam.NodeQueryParam nodeQueryParam){
String methodDescribe = getMethodDescribe("nodeList");
Page<Node> page = iNodeService.nodeList(nodeQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
/**
* 获取全部前置机不分页
* @author cdf
* @date 2021/6/23
*/
@ApiOperation("获取全部前置机")
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@GetMapping("/nodeAllList")
public HttpResult<List<Node>> nodeAllList(){
String methodDescribe = getMethodDescribe("nodeAllList");
List<Node> resList = iNodeService.nodeAllList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resList, methodDescribe);
}
/**
* 根据id获取前置机
* @author cdf
* @date 2021/6/23
*/
@ApiOperation("根据id获取前置机")
@ApiImplicitParam(value = "前置机id",name = "id",required = true)
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@GetMapping("/getNodeById")
public HttpResult<Node> getNodeById(@Validated @NotNull(message = "id不可为空") @RequestParam("id")String id){
String methodDescribe = getMethodDescribe("getNodeById");
Node node = iNodeService.getNodeById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, node, methodDescribe);
}
}

View File

@@ -6,6 +6,7 @@ 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.mapper.CsLedgerMapper;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.param.CsLedgerParam;
@@ -39,6 +40,7 @@ import java.util.List;
public class CsLedgerController extends BaseController {
private final ICsLedgerService csLedgerService;
private final CsLedgerMapper csLedgerMapper;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/tree")
@@ -145,5 +147,14 @@ public class CsLedgerController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, details, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getAllLedger")
@ApiOperation("获取台账树所有数据")
public HttpResult<List<CsLedgerVO>> getAllLedger(){
String methodDescribe = getMethodDescribe("getAllLedger");
List<CsLedgerVO> allList = csLedgerMapper.getAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, allList, methodDescribe);
}
}

View File

@@ -6,7 +6,6 @@ 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.mapper.CsLinePOMapper;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
@@ -41,9 +40,7 @@ import java.util.List;
public class CslineController extends BaseController {
private final CsLinePOService csLinePOService;
private final OverlimitMapper overlimitMapper;
private final CsLinePOMapper csLinePOMapper;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLineById")
@@ -92,16 +89,6 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @PostMapping("/addLineList")
// @ApiOperation("批量新增监测点及绑定关系")
// @ApiImplicitParam(name = "list", value = "监测点数据集", required = true)
// public HttpResult<String> addLines(@RequestBody List<CsLineParm> list){
// String methodDescribe = getMethodDescribe("addLines");
// csLinePOService.addLines(list);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
// }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/findByNdid")
@ApiOperation("根据ndid查询监测点")
@@ -139,7 +126,6 @@ public class CslineController extends BaseController {
@PostMapping("/getById")
@ApiOperation("根据监测点id获取监测点详情")
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true)
@ApiIgnore
public HttpResult<CsLinePO> getById(@RequestParam String lineId) {
String methodDescribe = getMethodDescribe("getById");
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
@@ -158,4 +144,54 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @PostMapping("/getLinesByDevList")
// @ApiOperation("根据装置id集合获取监测点id集合")
// @ApiImplicitParam(name = "ids", value = "装置id集合", required = true)
// public HttpResult<List<CsLinePO>> getLinesByDevList(@RequestParam("ids") List<String> ids) {
// String methodDescribe = getMethodDescribe("getLinesByDevList");
// List<CsLinePO> list = csLinePOService.getLinesByDevList(ids);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
// }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLinesByDevList")
@ApiOperation("根据装置id集合获取监测点id集合")
@ApiImplicitParam(name = "ids", value = "装置id集合", required = true)
public HttpResult<List<CsLinePO>> getLinesByDevList(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("getLinesByDevList");
List<CsLinePO> list = csLinePOService.getLinesByDevList(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addCldLine")
@ApiOperation("新增云前置监测点")
@ApiImplicitParam(name = "param", value = "param", required = true)
public HttpResult<List<CsLinePO>> addCldLine(@RequestBody @Validated CsLineParam param) {
String methodDescribe = getMethodDescribe("addCldLine");
csLinePOService.addCldLine(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateCldLine")
@ApiOperation("修改云前置监测点")
@ApiImplicitParam(name = "param", value = "param", required = true)
public HttpResult<List<CsLinePO>> updateCldLine(@RequestBody CsLineParam param) {
String methodDescribe = getMethodDescribe("updateCldLine");
csLinePOService.updateCldLine(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/delCldLine")
@ApiOperation("删除云前置监测点")
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
public HttpResult<List<CsLinePO>> delCldLine(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("delCldLine");
csLinePOService.deleteCldLine(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.controller.project;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
@@ -68,8 +69,8 @@ public class AppProjectController extends BaseController {
public HttpResult<Boolean> addAppProject(@Validated AppProjectAddParm appProjectAddParm){
String methodDescribe = getMethodDescribe("addAppProject");
Boolean flag = appProjectService.addAppProject(appProjectAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
AppProjectPO po = appProjectService.addAppProject(appProjectAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ObjectUtil.isNotNull(po), methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/auditAppProject")
@@ -80,4 +81,14 @@ public class AppProjectController extends BaseController {
Boolean flag = appProjectService.AuditAppProject(appProjectAuditParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateProject")
@ApiOperation("web修改项目信息")
public HttpResult<Boolean> updateProject(@RequestBody @Validated AppProjectAuditParm appProjectAuditParm){
String methodDescribe = getMethodDescribe("updateProject");
Boolean flag = appProjectService.updateProject(appProjectAuditParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
}

View File

@@ -11,6 +11,7 @@ import com.njcn.csdevice.pojo.param.CsEngineeringAuditParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryPageParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import com.njcn.csdevice.service.CsEngineeringService;
import com.njcn.web.controller.BaseController;
@@ -20,10 +21,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -42,10 +40,8 @@ import java.util.List;
@AllArgsConstructor
public class EngineeringController extends BaseController {
private final CsEngineeringService csEngineeringService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addEngineering")
@ApiOperation("新增工程")
@@ -88,4 +84,14 @@ public class EngineeringController extends BaseController {
IPage<CsEngineeringVO> page = csEngineeringService.queryEngineeringPage(csEngineeringQueryPageParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryEngineeringById")
@ApiOperation("工程查询通过id获取")
@ApiImplicitParam(name = "id", value = "工程id", required = true)
public HttpResult<CsEngineeringPO> queryEngineeringById(@RequestParam String id){
String methodDescribe = getMethodDescribe("queryEngineeringById");
CsEngineeringPO po = csEngineeringService.queryEngineeringById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
}

View File

@@ -64,7 +64,7 @@ public class WlRecordController extends BaseController {
@GetMapping("/getTestRecordById")
@ApiOperation("根据测试项ID查询测试项信息")
@ApiImplicitParam(name = "testRecordId", value = "测试项ID", required = true)
public HttpResult<RecordVo.RecordItemVo> getTestRecordById(@RequestParam @Validated String testRecordId) {
public HttpResult<RecordVo.RecordItemVo> getTestRecordById(@RequestParam("testRecordId") @Validated String testRecordId) {
String methodDescribe = getMethodDescribe("getTestRecordById");
LogUtil.njcnDebug(log, "{}测试项id为{}", methodDescribe, testRecordId);
RecordVo.RecordItemVo result = wlRecordService.getTestRecordById(testRecordId);
@@ -127,6 +127,20 @@ public class WlRecordController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 修改测试项日志
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/updateRecordData")
@ApiOperation("修改测试项日志")
@ApiImplicitParam(name = "record", value = "测试项日志信息", required = true)
public HttpResult<Boolean> updateRecordData(@RequestBody @Validated WlRecordParam.UpdateRecord record) {
String methodDescribe = getMethodDescribe("updateRecordData");
LogUtil.njcnDebug(log, "{},修改的测试项日志信息:{}", methodDescribe, record);
wlRecordService.updateRecordData(record);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 新增或修改方案
*/
@@ -168,6 +182,20 @@ public class WlRecordController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 删除装置测试项
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/deleteItem")
@ApiOperation("删除装置测试项")
@ApiImplicitParam(name = "id", value = "装置测试项Id", required = true)
public HttpResult<Boolean> deleteItem(@RequestParam @Validated String id) {
String methodDescribe = getMethodDescribe("deleteItem");
LogUtil.njcnDebug(log, "{}装置测试项Id为{}", methodDescribe, id);
wlRecordService.deleteItem(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 查询测试项时间段实时数据
*/
@@ -195,6 +223,19 @@ public class WlRecordController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, record, methodDescribe);
}
/**
* 根据监测点id查询装置基础数据
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
@PostMapping("/findDevBaseDataByLineId")
@ApiOperation("根据监测点id查询装置基础数据")
@ApiImplicitParam(name = "param", value = "查询条件", required = true)
public HttpResult<List<RecordVo>> findDevBaseDataByLineId(@RequestBody @Validated WlRecordParam.lineRecord param) {
String methodDescribe = getMethodDescribe("findDevBaseDataByLineId");
LogUtil.njcnDebug(log, "{},查询对象为:{}", methodDescribe, param);
List<RecordVo> record = wlRecordService.findDevBaseDataByLineId(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, record, methodDescribe);
}
/**
@@ -207,5 +248,17 @@ public class WlRecordController extends BaseController {
String methodDescribe = getMethodDescribe("dayDealNoEndTimeEvent");
wlRecordService.dayDealNoEndTimeEvent(date);
}
/**
* 根据测试项获取测试项绑定测点数据
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getWlAssByWlId")
@ApiOperation("根据测试项获取测试项绑定测点数据")
public HttpResult<List<WlRecord>> getWlAssByWlId(@RequestParam("wlId") String wlId) {
String methodDescribe = getMethodDescribe("getWlAssByWlId");
List<WlRecord> result = wlRecordService.getWlAssByWlId(wlId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -0,0 +1,62 @@
package com.njcn.csdevice.job;
import cn.hutool.core.date.DatePattern;
import com.njcn.csdevice.service.IRStatIntegrityDService;
import com.njcn.csdevice.service.IRStatOnlineRateDService;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author xy
*/
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class DayDataJob {
private final IRStatIntegrityDService statIntegrityDService;
private final IRStatOnlineRateDService statOnlineRateDService;
/**
* 每天1点计算治理设备的完整性
*
* @date 2025/7/1
*/
@Scheduled(cron = "0 0 1 * * ?")
public void lineIntegrityJob() {
StatisticsDataParam param = new StatisticsDataParam();
LocalDate yesterday = LocalDate.now().minusDays(1);
LocalDateTime start = yesterday.atStartOfDay();
LocalDateTime end = yesterday.atTime(23, 59, 59);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN);
param.setStartTime(start.format(formatter));
param.setEndTime(end.format(formatter));
statIntegrityDService.addData(param);
}
/**
* 每天2点计算治理设备的在线率
*
* @date 2025/7/1
*/
@Scheduled(cron = "0 30 1 * * ?")
public void devOnlineRateJob() {
StatisticsDataParam param = new StatisticsDataParam();
LocalDate yesterday = LocalDate.now().minusDays(1);
LocalDateTime start = yesterday.atStartOfDay();
LocalDateTime end = yesterday.atTime(23, 59, 59);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN);
param.setStartTime(start.format(formatter));
param.setEndTime(end.format(formatter));
statOnlineRateDService.addData(param);
}
}

View File

@@ -1,8 +1,10 @@
package com.njcn.csdevice.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
@@ -20,10 +22,17 @@ import java.util.List;
* @author clam
* @version V1.0.0
*/
@DS("master")
public interface CsEquipmentDeliveryMapper extends BaseMapper<CsEquipmentDeliveryPO> {
Page<ProjectEquipmentVO> queryProjectEquipmentVO(Page<ProjectEquipmentVO> returnpage,@Param("projectEquipmentQueryParm")ProjectEquipmentQueryParm projectEquipmentQueryParm,@Param("device")List<String> device);
Page<CsEquipmentDeliveryVO> page(Page<CsEquipmentDeliveryPO> returnpage, @Param("ew") QueryWrapper<CsEquipmentDeliveryPO> queryWrapper);
//获取符合条件的设备列表
List<CsEquipmentDeliveryVO> getList(@Param("queryParam") CsEquipmentDeliveryQueryParm queryParam);
//获取符合条件的设备数量
int getCounts(@Param("queryParam") CsEquipmentDeliveryQueryParm queryParam);
int getListByNodeProcess(@Param("nodeId")String nodeId,@Param("process")Integer process);
}

View File

@@ -0,0 +1,25 @@
package com.njcn.csdevice.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.param.IcdParam;
import com.njcn.csdevice.pojo.po.Node;
import com.njcn.csdevice.pojo.vo.DeviceInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author cdf
* @since 2022-01-04
*/
@DS("sjzx")
public interface NodeMapper extends BaseMapper<Node> {
List<DeviceInfo> nodeDeviceList(@Param("nodeDeviceParam") IcdParam icdParam);
}

View File

@@ -0,0 +1,18 @@
package com.njcn.csdevice.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 数据完整性日表 Mapper 接口
* </p>
*
* @author xy
* @since 2025-06-23
*/
@Mapper
public interface RStatIntegrityDMapper extends MppBaseMapper<RStatIntegrityD> {
}

View File

@@ -0,0 +1,18 @@
package com.njcn.csdevice.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 在线率日表 Mapper 接口
* </p>
*
* @author xy
* @since 2025-06-23
*/
@Mapper
public interface RStatOnlineRateDMapper extends MppBaseMapper<RStatOnlineRateD> {
}

View File

@@ -48,4 +48,6 @@ public interface WlRecordMapper extends BaseMapper<WlRecord> {
List<CsLedgerVO> getAll();
List<CsLedgerVO> getAllLine(@Param("devId") String devId);
List<WlRecord> getWlAssByWlId(@Param("wlId") String wlId);
}

View File

@@ -106,6 +106,7 @@
and t1.did = #{param.did}
and t3.cl_dev = #{param.cldId}
and (t3.data_type = 'Stat' or t3.data_type is NULL)
and t3.idx = #{param.idx}
and t4.stat_method = #{param.statMethod}
order by t4.sort
</select>

View File

@@ -14,7 +14,7 @@
where
pid = #{modelId}
and cl_dev = #{clDev}
and data_type in ('Stat',NULL)
and (data_type = 'Stat' or data_type IS NULL)
order by type,cl_dev
</select>

View File

@@ -19,28 +19,28 @@
<!--@mbg.generated-->
id, dev_type, version_no, version_date, file_path, create_by, create_time, update_by,
update_time, `status`
</sql><select id="getPage" resultType="com.njcn.csdevice.pojo.vo.CsDevModelPageVO">
SELECT a.*
FROM cs_dev_model a
WHERE
1 = 1 And a.`status`='1'
<if test="csDevModelQueryParm.versionStartDate != null and csDevModelQueryParm.versionStartDate != ''">
AND a.version_date &gt;= #{csDevModelQueryParm.versionStartDate }
</if>
<if test="csDevModelQueryParm.versionEndDate != null and csDevModelQueryParm.versionEndDate != ''">
AND a.version_date &lt;= #{csDevModelQueryParm.versionEndDate }
</if>
</sql>
<select id="getPage" resultType="com.njcn.csdevice.pojo.vo.CsDevModelPageVO">
SELECT a.*
FROM cs_dev_model a
WHERE
1 = 1 And a.`status`='1'
<if test="csDevModelQueryParm.versionStartDate != null and csDevModelQueryParm.versionStartDate != ''">
AND a.version_date &gt;= #{csDevModelQueryParm.versionStartDate }
</if>
<if test="csDevModelQueryParm.versionEndDate != null and csDevModelQueryParm.versionEndDate != ''">
AND a.version_date &lt;= #{csDevModelQueryParm.versionEndDate }
</if>
<if test="csDevModelQueryParm.devName != null and csDevModelQueryParm.devName != ''">
AND a.dev_type_name LIKE concat('%',#{csDevModelQueryParm.devName},'%')
</if>
<!-- <if test="csDevModelQueryParm.devType != null and csDevModelQueryParm.devType != ''">-->
<!-- AND a.dev_type = #{csDevModelQueryParm.devType}-->
<!-- </if>-->
<if test="csDevModelQueryParm.name != null and csDevModelQueryParm.name != ''">
AND a.name = #{csDevModelQueryParm.name}
</if>
</select><select id="queryOne" resultType="com.njcn.csdevice.pojo.vo.CsDevModelPageVO">
<if test="csDevModelQueryParm.devName != null and csDevModelQueryParm.devName != ''">
AND a.dev_type_name = #{csDevModelQueryParm.devName}
</if>
<if test="csDevModelQueryParm.name != null and csDevModelQueryParm.name != ''">
AND a.name LIKE concat('%',#{csDevModelQueryParm.name},'%')
</if>
order by a.version_date desc
</select>
<select id="queryOne" resultType="com.njcn.csdevice.pojo.vo.CsDevModelPageVO">
SELECT a.*
FROM cs_dev_model a
WHERE

View File

@@ -87,5 +87,54 @@
</where>
</select>
<select id="getList" resultType="CsEquipmentDeliveryVO">
select
*
from
cs_equipment_delivery
<where>
1=1
<if test="queryParam.process != null and queryParam.process !=''">
and process = #{queryParam.process}
</if>
<if test="queryParam.runStatus != null and queryParam.runStatus !=''">
and run_status = #{queryParam.runStatus}
</if>
<if test="queryParam.searchValue != null and queryParam.searchValue !=''">
and (name like concat('%',#{queryParam.searchValue},'%') or ndid like concat('%',#{queryParam.searchValue},'%'))
</if>
</where>
</select>
<select id="getCounts" resultType="int">
select
count(1)
from
cs_equipment_delivery
<where>
1=1
<if test="queryParam.process != null and queryParam.process !=''">
and process = #{queryParam.process}
</if>
<if test="queryParam.runStatus != null and queryParam.runStatus !=''">
and run_status = #{queryParam.runStatus}
</if>
<if test="queryParam.searchValue != null and queryParam.searchValue !=''">
and (name like concat('%',#{queryParam.searchValue},'%') or ndid like concat('%',#{queryParam.searchValue},'%'))
</if>
</where>
</select>
<select id="getListByNodeProcess" resultType="int">
select
count(1)
from
cs_equipment_delivery
where
node_id = #{nodeId} and run_status != 0
<if test="process != null and process !=''">
and node_process > #{process}
</if>
</select>
</mapper>

View File

@@ -32,7 +32,7 @@
</resultMap>
<select id="getAll" resultType="CsLedgerVO">
select
id,pid,name,level,sort
id,pid,pids,name,level,sort
from
cs_ledger
where

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.csdevice.mapper.NodeMapper">
<select id="nodeDeviceList" resultType="com.njcn.csdevice.pojo.vo.DeviceInfo">
SELECT
pq_device.Id id,
pq_device.IP ip,
s1.Name devType,
pq_device.Port port,
pq_line.Name name,
sub.Name subName,
pq_device.Update_Time updateTime,
s2.Name manufacturer,
pq_device.Com_Flag status,
pq_device.Series series,
pq_device_process.process_no processNo,
pq_device.Dev_Key devKey,
pq_node.max_Process_Num maxProcessNum
FROM
pq_device
LEFT JOIN pq_node ON pq_node.Id = pq_device.Node_Id
LEFT JOIN pq_line on pq_device.id = pq_line.id
LEFT JOIN pq_line sub on pq_line.pid = sub.id
LEFT JOIN pq_device_process on pq_device_process.id = pq_device.id
LEFT JOIN pq_dev_type s1 ON pq_device.Dev_Type = s1.id
LEFT JOIN sys_dict_data s2 ON pq_device.Manufacturer = s2.id
<where>
<if test="nodeDeviceParam.ip!=null and nodeDeviceParam.ip != ''">
pq_node.ip=#{nodeDeviceParam.ip}
</if>
<if test="nodeDeviceParam.devId!=null and nodeDeviceParam.devId != ''">
pq_device.id=#{nodeDeviceParam.devId}
</if>
<if test="nodeDeviceParam.runFlag!=null and nodeDeviceParam.runFlag.size()!=0">
AND pq_device.Run_Flag in
<foreach collection="nodeDeviceParam.runFlag" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>

View File

@@ -64,7 +64,7 @@
</if>
exists
(select 1 from wl_record_test_data wd where wd.test_item_id = #{wlRecordPageParam.id} and wd.data_id = a.id)
order by a.start_time asc
order by a.start_time desc
</select>
<select id="getAll" resultType="com.njcn.csdevice.pojo.vo.CsLedgerVO">
@@ -93,4 +93,55 @@
)
order by start_time
</select>
<select id="getWlAssByWlId" resultType="com.njcn.csdevice.pojo.po.WlRecord">
SELECT
a.id,
a.start_time,
a.end_time,
a.line_id,
a.type,
c.data_level AS dataLevel,
b.ct_ratio AS ct,
b.pt_ratio AS pt,
NULL AS itemName,
NULL AS voltageLevel,
NULL AS capacitySscb,
NULL AS capacitySscmin,
NULL AS capacitySt,
NULL AS capacitySi
FROM
wl_record a
INNER JOIN cs_line b ON a.line_id = b.line_id
INNER JOIN cs_data_set c ON b.data_set_id = c.id
WHERE
a.type = 1
AND a.id IN (
SELECT
data_id
FROM
wl_record_test_data
WHERE
test_item_id = #{wlId} )
UNION
SELECT
a.id,
a.start_time,
a.end_time,
a.line_id,
a.type,
NULL AS dataLevel,
(a.ct / a.ct1) AS ct,
(a.pt / a.pt1) AS pt,
a.item_name,
a.voltage_level,
a.capacity_sscb,
a.capacity_sscmin,
a.capacity_st,
a.capacity_si
FROM
wl_record a
WHERE
a.id = #{wlId}
</select>
</mapper>

View File

@@ -27,8 +27,8 @@ public interface AppProjectService extends IService<AppProjectPO> {
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/3/27
*/
Boolean addAppProject(AppProjectAddParm appProjectAddOrAuditParm);
*/
AppProjectPO addAppProject(AppProjectAddParm appProjectAddOrAuditParm);
/**
* @Description: AuditAppProject
* @Param: [appProjectAuditParm]
@@ -37,6 +37,9 @@ public interface AppProjectService extends IService<AppProjectPO> {
* @Date: 2023/3/27
*/
Boolean AuditAppProject(AppProjectAuditParm appProjectAuditParm);
Boolean updateProject(AppProjectAuditParm appProjectAuditParm);
/**
* @Description: queryProject
* @Param: [appProjectQueryParm]

View File

@@ -76,4 +76,10 @@ public interface CsDevModelService extends IService<CsDevModelPO>{
*/
CsDevModelPO getModelById(String id);
/**
* 获取云前置模板
* @return
*/
CsDevModelPO getCldModel();
}

View File

@@ -55,4 +55,6 @@ public interface CsEngineeringService extends IService<CsEngineeringPO>{
* @return
*/
List<CsEngineeringPO> getEngineerings(List<String> list);
CsEngineeringPO queryEngineeringById(String id);
}

View File

@@ -11,6 +11,7 @@ import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@@ -32,30 +33,30 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
*/
void refreshDeviceDataCache();
/**
* @Description: save
* @Param: [csEquipmentDeliveryAddParm]
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/3/31
*/
Boolean save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm);
/**
* @Description: AuditEquipmentDelivery
* @Param: [id]
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/3/31
*/
Boolean AuditEquipmentDelivery(String id);
/**
* @Description: queryEquipmentByndid
* @Param: [ndid]
* @return: com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO
* @Author: clam
* @Date: 2023/3/31
*/
CsEquipmentDeliveryVO queryEquipmentByndid(String ndid);
/**
* @Description: save
* @Param: [csEquipmentDeliveryAddParm]
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/3/31
*/
CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm);
/**
* @Description: AuditEquipmentDelivery
* @Param: [id]
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/3/31
*/
Boolean AuditEquipmentDelivery(String id);
/**
* @Description: queryEquipmentByndid
* @Param: [ndid]
* @return: com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO
* @Author: clam
* @Date: 2023/3/31
*/
CsEquipmentDeliveryVO queryEquipmentByndid(String ndid);
/**
* @Description: queryEquipmentByProject
* @Param: [projectEquipmentQueryParm]
@@ -99,7 +100,7 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
*/
CsEquipmentDeliveryPO findDevByNDid(String nDid);
void importEquipment(MultipartFile file, HttpServletResponse response);
List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response);
void delete(String devId);
@@ -133,4 +134,53 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
* 判断设备型号
*/
boolean judgeDevModel(String nDid);
CsEquipmentDeliveryPO getDevByLineId(String lineId);
/**
* 新增云前置设备
* @param param
* @return
*/
CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param);
/**
* 删除云前置设备
* @param id
* @return
*/
Boolean delCldDev(String id);
/**
* 更新云前置设备
* @param param
* @return
*/
Boolean updateCldDev(CsEquipmentDeliveryAuditParm param);
/**
* 根据前置ip和运行状态获取装置数据
* @param id
* @param runFlag
* @return
*/
List<CsEquipmentDeliveryPO> getCldDevByIp(String id, List<Integer> runFlag);
/**
* 根据前置id和进程号修改设备状态同时修改设备下的监测点的状态
*/
void updateCldDevStatus(String nodeId, Integer processNo);
/**
* 根据设备id和状态来修改设备运行状态同时修改设备下的监测点的状态
* @param devId
* @param status
*/
void flipCldDevStatus(String devId, Integer status);
/**
* 根据项目id获取设备列表
*/
List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId);
}

View File

@@ -45,4 +45,19 @@ public interface CsLinePOService extends IService<CsLinePO>{
* @param csLineParam
*/
void updateIds(CsLineParam csLineParam);
List<CsLinePO> getLinesByDevList(List<String> list);
void addCldLine(CsLineParam param);
void updateCldLine(CsLineParam param);
void deleteCldLine(String id);
/**
* 修改监测点状态为停运
* @param lineList 监测点集合
* @param status 运行状态
*/
void updateCldLineStatus(List<CsLinePO> lineList, Integer status);
}

View File

@@ -0,0 +1,38 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.param.LineCountEvaluateParam;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import java.util.List;
/**
* @Description:
* @Author: wr
* @Date: 2025/3/6 10:22
*/
public interface ICsCommunicateService {
/**
* 取出最新装置数据
* @param lineParam
* @return
*/
List<PqsCommunicateDto> getRawDataLatest(LineCountEvaluateParam lineParam);
/**
* 获取时间范围数据
* @param lineParam
* @return
*/
List<PqsCommunicateDto> getRawData(LineCountEvaluateParam lineParam);
/**
*是否有当天最后一条数据
* @param lineParam
* @return
*/
List<PqsCommunicateDto> getRawDataEnd(LineCountEvaluateParam lineParam);
void insertion(PqsCommunicateDto pqsCommunicateDto);
}

View File

@@ -76,4 +76,11 @@ public interface ICsLedgerService extends IService<CsLedger> {
DevDetailDTO queryDevDetail(String devId);
List<CsLedgerVO> getztProjectTree();
/**
* 根据设备集合获取项目和工程
* @param id
* @return
*/
List<CsLedgerVO> getProAndEngineer(List<String> id);
}

View File

@@ -0,0 +1,79 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.param.NodeParam;
import com.njcn.csdevice.pojo.po.Node;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author cdf
* @since 2022-01-07
*/
public interface INodeService extends IService<Node> {
/**
* 新增前置机
* @author cdf
* @date 2021/6/23
*/
boolean addNode(NodeParam nodeParam);
/**
* 修改前置机
* @author cdf
* @date 2021/6/23
*/
boolean updateNode(NodeParam.NodeUpdateParam nodeParam);
/**
* 删除前置机
* @author cdf
* @date 2021/6/23
*/
boolean delNode(String id);
/**
* 修改前置机状态
* @author cdf
* @date 2021/6/23
*/
boolean updateNodeState(String id, Integer state);
/**
* 查询前置机列表
* @author cdf
* @date 2021/6/23
*/
Page<Node> nodeList(NodeParam.NodeQueryParam nodeQueryParam);
/**
* 查询前置机列表不分页
* @author cdf
* @date 2021/6/23
*/
List<Node> nodeAllList();
/**
* 根据前置机id获取前置机
* @author cdf
* @date 2021/6/23
*/
Node getNodeById(String id);
/**
* 根据前置机名称获取详细信息
* @param nodeName 前置机名称
* @return 前置信息
*/
Node getNodeByNodeName(String nodeName);
Node getNodeByIp(String ip);
}

View File

@@ -0,0 +1,23 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import java.util.List;
/**
* <p>
* 数据完整性日表 服务类
* </p>
*
* @author xy
* @since 2025-06-23
*/
public interface IRStatIntegrityDService extends IService<RStatIntegrityD> {
void addData(StatisticsDataParam param);
List<RStatIntegrityD> getData(List<String> list, String startTime, String endTime);
}

View File

@@ -0,0 +1,23 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import java.util.List;
/**
* <p>
* 在线率日表 服务类
* </p>
*
* @author xy
* @since 2025-06-23
*/
public interface IRStatOnlineRateDService extends IService<RStatOnlineRateD> {
void addData(StatisticsDataParam param);
List<RStatOnlineRateD> getData(List<String> list, String startTime, String endTime);
}

View File

@@ -63,6 +63,8 @@ public interface IWlRecordService extends IService<WlRecord> {
*/
void updateTestRecord(WlRecordParam.UpdateRecord record);
void updateRecordData(WlRecordParam.UpdateRecord record);
/**
* 新增或修改方案
* @param record
@@ -102,10 +104,14 @@ public interface IWlRecordService extends IService<WlRecord> {
*/
WlRecord findDevBaseData(WlRecordParam.Record param);
List<RecordVo> findDevBaseDataByLineId(WlRecordParam.lineRecord param);
/**
* 每日处理没有结束时间的测试基础数据
*/
void dayDealNoEndTimeEvent(String date);
List<WlRecord> getWlAssByWlId(String wlId);
void deleteItem(String id);
}

View File

@@ -0,0 +1,18 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.param.IcdLedgerParam;
import com.njcn.csdevice.param.IcdParam;
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
import com.njcn.csdevice.pojo.vo.DeviceInfo;
import java.util.List;
public interface IcdService {
List<DeviceInfo> getLedgerInfo(IcdParam param);
void addLedgerInfo(IcdLedgerParam param);
CldLedgerVo getLedgerById(String id);
}

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.stream.CollectorUtil;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -55,7 +56,7 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addAppProject(AppProjectAddParm appProjectAddOrAuditParm) {
public AppProjectPO addAppProject(AppProjectAddParm appProjectAddOrAuditParm) {
AppProjectPO appProjectPO = new AppProjectPO ( );
// Boolean result = checkName (appProjectAddOrAuditParm.getUserId ( ), appProjectAddOrAuditParm.getName ( ));
// if (result) {
@@ -109,19 +110,33 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
}
}
CsLedger csLedger = csLedgerMapper.selectById(appProjectAddOrAuditParm.getEngineeringId());
Optional.ofNullable(csLedger).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ENGINEERING_DATA_ERROR));
CsLedger csLedger1 = new CsLedger();
csLedger1.setId(appProjectPO.getId());
csLedger1.setPid(appProjectAddOrAuditParm.getEngineeringId());
csLedger1.setPids(csLedger.getPids()+ ","+appProjectAddOrAuditParm.getEngineeringId());
csLedger1.setLevel(1);
csLedger1.setName(appProjectPO.getName());
csLedger1.setState(1);
csLedger1.setSort(0);
csLedgerMapper.insert(csLedger1);
return save;
//云协议工程
if (Objects.nonNull(appProjectAddOrAuditParm.getIcdEngineeringId())){
CsLedger csLedger1 = new CsLedger();
csLedger1.setId(appProjectPO.getId());
csLedger1.setPid(appProjectAddOrAuditParm.getEngineeringId());
csLedger1.setPids("0,"+appProjectAddOrAuditParm.getEngineeringId());
csLedger1.setLevel(1);
csLedger1.setName(appProjectPO.getName());
csLedger1.setState(1);
csLedger1.setSort(0);
csLedgerMapper.insert(csLedger1);
}
//其他工程
else {
CsLedger csLedger = csLedgerMapper.selectById(appProjectAddOrAuditParm.getEngineeringId());
Optional.ofNullable(csLedger).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ENGINEERING_DATA_ERROR));
CsLedger csLedger1 = new CsLedger();
csLedger1.setId(appProjectPO.getId());
csLedger1.setPid(appProjectAddOrAuditParm.getEngineeringId());
csLedger1.setPids(csLedger.getPids()+ ","+appProjectAddOrAuditParm.getEngineeringId());
csLedger1.setLevel(1);
csLedger1.setName(appProjectPO.getName());
csLedger1.setState(1);
csLedger1.setSort(0);
csLedgerMapper.insert(csLedger1);
}
return appProjectPO;
}
private Boolean checkName( String name,String id,String engineeringId) {
@@ -132,7 +147,7 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
// eq ("user_id", userId).
eq ("name", name);
Integer integer = csLedgerMapper.selectCount (queryWrapper);
return integer > 0 ? true : false;
return integer > 0;
}
@Override
@@ -249,7 +264,25 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
csLedger2.setName(appProjectAuditParm.getName());
}
csLedgerMapper.updateById(csLedger2);
return i == 1 ? true : false;
return i == 1;
}
@Override
@Transactional(rollbackFor = BusinessException.class)
public Boolean updateProject(AppProjectAuditParm appProjectAuditParm) {
//修改项目表
this.lambdaUpdate().set(AppProjectPO::getName,appProjectAuditParm.getName())
.set(AppProjectPO::getArea,appProjectAuditParm.getArea())
.set(AppProjectPO::getDescription,appProjectAuditParm.getDescription())
.eq(AppProjectPO::getId,appProjectAuditParm.getId())
.eq(AppProjectPO::getStatus,"1")
.update();
//修改台账表
CsLedger csLedger = new CsLedger();
csLedger.setId(appProjectAuditParm.getId());
csLedger.setName(appProjectAuditParm.getName());
csLedgerMapper.updateById(csLedger);
return true;
}
@Override
@@ -324,10 +357,14 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
@Override
public List<AppProjectPO> getProjectByEngineering(List<String> list) {
List<AppProjectPO> result = new ArrayList<>();
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper();
csLedgerQueryWrapper.lambda().in(CsLedger::getPid, list).eq(CsLedger::getState,1);
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
return this.lambdaQuery().in(AppProjectPO::getId,collect).list();
if (CollectionUtil.isNotEmpty(csLedgers)) {
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
result = this.lambdaQuery().in(AppProjectPO::getId,collect).list();
}
return result;
}
}

View File

@@ -9,7 +9,6 @@ import com.njcn.csdevice.service.ICsDataSetService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -40,7 +39,7 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
.in(CsDataSet::getType, Arrays.asList(0,2))
.eq(CsDataSet::getStoreFlag,1)
.and(i->i.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
.orderByAsc(CsDataSet::getType,CsDataSet::getClDev)
.orderByAsc(CsDataSet::getIdx)
.list();
}
@@ -77,11 +76,11 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType));
//谐波电压含有率
if (target == 0) {
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmV$01");
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmV$0".concat(clDev.toString()));
} else if (target == 1) {
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmI$01");
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmI$0".concat(clDev.toString()));
} else if (target == 2) {
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$InHarmV$01");
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$InHarmV$0".concat(clDev.toString()));
}
return this.baseMapper.selectOne(wrapper);
}

View File

@@ -1,37 +1,37 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsDevModelMapper;
import com.njcn.csdevice.pojo.dto.CsDevModelDto;
import com.njcn.csdevice.pojo.param.CsDevModelAddParm;
import com.njcn.csdevice.pojo.param.CsDevModelAuditParm;
import com.njcn.csdevice.pojo.param.CsDevModelQueryListParm;
import com.njcn.csdevice.pojo.param.CsDevModelQueryParm;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.po.CsDevModelPO;
import com.njcn.csdevice.pojo.vo.CsDevModelPageVO;
import com.njcn.csdevice.service.CsDevModelService;
import com.njcn.csdevice.service.ICsDataArrayService;
import com.njcn.csdevice.service.ICsDataSetService;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicTreeEnum;
import com.njcn.system.pojo.po.SysDicTreePO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
*
@@ -50,6 +50,7 @@ public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevMo
private final ICsDataSetService csDataSetService;
private final ICsDataArrayService csDataArrayService;
private final RedisUtil redisUtil;
private final DictTreeFeignClient dictTreeFeignClient;
@Override
public void refreshDevModelCache() {
@@ -128,7 +129,14 @@ public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevMo
@Override
public IPage<CsDevModelPageVO> queryPage(CsDevModelQueryParm csDevModelQueryParm) {
Page<CsDevModelPageVO> returnpage = new Page<> (csDevModelQueryParm.getPageNum ( ), csDevModelQueryParm.getPageSize ( ));
if (Objects.nonNull (csDevModelQueryParm.getDevType()) && StringUtils.isNotBlank(csDevModelQueryParm.getDevType())) {
SysDicTreePO po = dictTreeFeignClient.queryById(csDevModelQueryParm.getDevType()).getData();
if (Objects.isNull (po)) {
throw new BusinessException("装置型号字典缺失");
} else {
csDevModelQueryParm.setDevName(po.getName());
}
}
returnpage = this.getBaseMapper ().getPage(returnpage,csDevModelQueryParm);
return returnpage;
}
@@ -154,4 +162,20 @@ public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevMo
return this.lambdaQuery().eq(CsDevModelPO::getId,id).one();
}
@Override
public CsDevModelPO getCldModel() {
List<CsDevModelPO> list = this.lambdaQuery()
.eq(CsDevModelPO::getDevTypeName, DicDataEnum.DEV_CLD.getCode())
.eq(CsDevModelPO::getStatus,1)
.list();
if (CollectionUtil.isEmpty(list)) {
throw new BusinessException(AlgorithmResponseEnum.CLD_MODEL_MISSING);
} else {
if (list.size() > 1) {
throw new BusinessException(AlgorithmResponseEnum.CLD_MODEL_MORE);
}
}
return list.get(0);
}
}

View File

@@ -217,6 +217,11 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
return this.lambdaQuery().in(CsEngineeringPO::getId,list).eq(CsEngineeringPO::getStatus,"1").list();
}
@Override
public CsEngineeringPO queryEngineeringById(String id) {
return this.lambdaQuery().eq(CsEngineeringPO::getId,id).eq(CsEngineeringPO::getStatus,"1").one();
}
public String getAreaById(String id){

View File

@@ -6,9 +6,10 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -18,10 +19,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.access.api.AskDeviceDataFeignClient;
import com.njcn.access.utils.MqttUtil;
import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLogsFeignClient;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.mapper.CsSoftInfoMapper;
import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.*;
@@ -31,7 +36,7 @@ import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.csdevice.service.*;
import com.njcn.csdevice.util.QRCodeUtil;
import com.njcn.csdevice.utils.ExcelStyleUtil;
import com.njcn.db.constant.DbConstant;
import com.njcn.csdevice.utils.StringUtil;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.redis.pojo.enums.AppRedisKey;
@@ -39,9 +44,10 @@ import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.enums.DicTreeEnum;
import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.web.factory.PageFactory;
import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.user.enums.AppRoleEnum;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
@@ -61,9 +67,8 @@ import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
*
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/3/30 16:23【需求编号】
@@ -74,7 +79,6 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliveryMapper, CsEquipmentDeliveryPO> implements CsEquipmentDeliveryService{
private final CsDevModelRelationService csDevModelRelationService;
private final ICsDataSetService csDataSetService;
private final ICsLedgerService csLedgerService;
@@ -90,6 +94,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final AskDeviceDataFeignClient askDeviceDataFeignClient;
private final RedisUtil redisUtil;
private final CsSoftInfoMapper csSoftInfoMapper;
private final IMqttUserService mqttUserService;
private final MqttUtil mqttUtil;
private final CsLogsFeignClient csLogsFeignClient;
private final INodeService nodeService;
private final CsDevModelService csDevModelService;
private final CsLedgerMapper csLedgerMapper;
@Override
public void refreshDeviceDataCache() {
@@ -101,8 +112,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
public CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
boolean result;
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
if(Objects.nonNull (one)){
throw new BusinessException ("设备名称不能重复");
}
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAddParm.getNdid());
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (csEquipmentDeliveryAddParm.getNdid());
if(!Objects.isNull (po)){
throw new BusinessException (AlgorithmResponseEnum.NDID_ERROR);
@@ -111,6 +127,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
BeanUtils.copyProperties (csEquipmentDeliveryAddParm,csEquipmentDeliveryPo);
csEquipmentDeliveryPo.setStatus (1);
csEquipmentDeliveryPo.setRunStatus(1);
csEquipmentDeliveryPo.setUsageStatus(1);
String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode();
if (Objects.equals(DicDataEnum.PORTABLE.getCode(),code)) {
csEquipmentDeliveryPo.setProcess(4);
@@ -129,17 +146,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentProcess.setStartTime(LocalDateTime.now());
csEquipmentProcess.setProcess(1);
csEquipmentProcess.setStatus (1);
csEquipmentProcessPOService.save(csEquipmentProcess);
result = this.save (csEquipmentDeliveryPo);
if (result) {
refreshDeviceDataCache();
}
return result;
return csEquipmentDeliveryPo;
}
@Override
// @Transactional(rollbackFor = {Exception.class}, propagation = Propagation.REQUIRED)
public Boolean AuditEquipmentDelivery(String id) {
//物理删除
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper();
@@ -172,8 +187,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
/*后续徐那边做处理*/
// CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.getBaseMapper().selectById(id);
// mqttUserService.deleteUser(csEquipmentDeliveryPO.getNdid());
csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId,id).set(CsDevModelRelationPO::getStatus,0).update();
if (update) {
refreshDeviceDataCache();
@@ -191,6 +204,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
BeanUtils.copyProperties (csEquipmentDeliveryPO,result);
return result;
}
public CsEquipmentDeliveryPO queryEquipmentPOByndid(String ndid) {
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper();
wrapper.eq ("ndid", ndid);
@@ -206,7 +220,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if(CollectionUtils.isEmpty(device)){
return returnpage;
}
Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage,projectEquipmentQueryParm,device);
list.getRecords().stream().forEach(temp->{
temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId()));
@@ -215,22 +228,49 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) {
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid());
boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,csEquipmentDeliveryAuditParm.getNdid())
.in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3))
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
.in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3))
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
}
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
List<CsEquipmentDeliveryPO> list = this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId())
.ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid())
.eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if(!CollectionUtils.isEmpty (list)){
throw new BusinessException ("设备名称不能重复");
}
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
result = this.updateById(csEquipmentDeliveryPo);
//修改台账树中的设备名称
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
BeanUtils.copyProperties (csLedger, csLedgerParam);
csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
csLedgerService.updateLedgerTree(csLedgerParam);
if (result) {
refreshDeviceDataCache();
if (!Objects.equals(po.getUsageStatus(),csEquipmentDeliveryAuditParm.getUsageStatus())) {
DeviceLogDTO dto = new DeviceLogDTO();
dto.setUserName(RequestUtil.getUsername());
dto.setOperate("设备使用状态被修改");
dto.setResult(1);
dto.setLoginName(RequestUtil.getLoginName());
csLogsFeignClient.addUserLog(dto);
}
}
return result;
}
@@ -248,54 +288,44 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
public Page<CsEquipmentDeliveryVO> list(CsEquipmentDeliveryQueryParm queryParam) {
QueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new QueryWrapper<CsEquipmentDeliveryPO>();
if (ObjectUtil.isNotNull(queryParam)) {
//查询参数不为空,进行条件填充
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
//部门根据名称模糊查询
queryWrapper
.and(param -> param.like("cs_equipment_delivery.name", queryParam.getSearchValue())
.or().like("cs_equipment_delivery.ndid", queryParam.getSearchValue())
.or().like("cs_equipment_delivery.mac", queryParam.getSearchValue()));
Page<CsEquipmentDeliveryVO> page = new Page<> ();
page.setCurrent(queryParam.getPageNum());
page.setSize(queryParam.getPageSize());
queryParam.setPageNum((queryParam.getPageNum()-1)*queryParam.getPageSize());
int total = this.baseMapper.getCounts(queryParam);
if (total > 0) {
List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam);
//新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList){
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){
csEquipmentDeliveryVO.setStatus(5);
} else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) {
csEquipmentDeliveryVO.setStatus(6);
}
//判断装置是否已经连接上mqtt服务器
String clientName = "NJCN-" + csEquipmentDeliveryVO.getNdid().substring(csEquipmentDeliveryVO.getNdid().length() - 6);
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
if (mqttClient) {
csEquipmentDeliveryVO.setConnectStatus("已连接");
} else {
csEquipmentDeliveryVO.setConnectStatus("未连接");
}
}
//排序
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
} else {
//默认根据创建时间排序
queryWrapper.orderBy(true, false, "create_time");
if (ObjectUtil.isNotNull(queryParam.getConnectStatus())) {
recordList = recordList.stream()
.filter(item -> queryParam.getConnectStatus() == 0
? "未连接".equals(item.getConnectStatus())
: "已连接".equals(item.getConnectStatus()))
.collect(Collectors.toList());
}
page.setTotal(CollectionUtil.isEmpty(recordList) ? 0 : recordList.size());
page.setRecords(recordList);
}
if (StrUtil.isNotBlank(queryParam.getDevType()) && !Objects.isNull(queryParam.getDevType())){
queryWrapper.eq("cs_equipment_delivery.dev_type", queryParam.getDevType());
}
if (StrUtil.isNotBlank(queryParam.getDevModel()) && !Objects.isNull(queryParam.getDevModel())){
queryWrapper.eq("cs_equipment_delivery.dev_model", queryParam.getDevModel());
}
if (StrUtil.isNotBlank(queryParam.getDevAccessMethod()) && !Objects.isNull(queryParam.getDevAccessMethod())){
queryWrapper.eq("cs_equipment_delivery.dev_access_method", queryParam.getDevAccessMethod());
}
if (!Objects.isNull(queryParam.getStatus())){
queryWrapper.eq("cs_equipment_delivery.status", queryParam.getStatus());
} else {
queryWrapper.in("cs_equipment_delivery.status", Arrays.asList(1,2,3));
}
if (!Objects.isNull(queryParam.getRunStatus())){
queryWrapper.eq("cs_equipment_delivery.run_status", queryParam.getRunStatus());
} else {
queryWrapper.in("cs_equipment_delivery.run_status", Arrays.asList(1,2));
}
Page<CsEquipmentDeliveryVO> page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
page.getRecords().forEach(item->{
if (!Objects.isNull(item.getQrPath())){
item.setQrPath(item.getQrPath());
}
});
return page;
}
@Override
public DeviceManagerVO getDeviceData(String deviceId, String type, String lineId) {
public DeviceManagerVO getDeviceData(String deviceId, String type, String lineId) {
DeviceManagerVO deviceManagerVo = new DeviceManagerVO();
List<DeviceManagerVO.DataSetVO> dataSetList = new ArrayList<>();
CsEquipmentDeliveryPO csEquipmentDeliveryPo = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
@@ -328,17 +358,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
List<CsDataSet> dataSet = new ArrayList<>();
//治理监测点
if (Objects.equals(code, DicDataEnum.OUTPUT_SIDE.getCode())){
// select
// t1.id
// from
// cs_dev_model_relation t0
// left join cs_dev_model t1 on
// t0.model_id = t1.id
// where
// t0.status="1" and
// t0.dev_id = #{devId} and t1.`type` = #{type}
modelId = csDevModelRelationService.getModelByType(deviceId,0);
//select * from cs_data_set where pid = modelId and clDev = 0
dataSet = csDataSetService.findDataSetByModelId(modelId,0);
}
//电网侧监测点
@@ -352,7 +372,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
dataSet = csDataSetService.findDataSetByModelId(modelId,2);
}
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
}else if(Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode())){
} else if(Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode()) || Objects.equals(devTypeCode, DicDataEnum.DEV_CLD.getCode())){
List<CsDataSet> dataSet = new ArrayList<>();
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)){
@@ -369,43 +389,44 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private void setDataSetValues(CsEquipmentDeliveryPO csEquipmentDeliveryPo, List<CsDataSet> dataSet, List<DeviceManagerVO.DataSetVO> dataSetList, String type, DeviceManagerVO deviceManagerVo) {
BeanUtils.copyProperties(csEquipmentDeliveryPo, deviceManagerVo);
if (CollUtil.isNotEmpty(dataSet)) {
for (CsDataSet item : dataSet) {
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
dataSetVO.setId(item.getId());
dataSetVO.setName("history".equals(type) ? "准实时数据":item.getAnotherName());
dataSetVO.setType("rt");
dataSetList.add(dataSetVO);
deviceManagerVo.setDataLevel(item.getDataLevel());
if (Objects.equals(type, "history")) {
//历史数据tab
DeviceManagerVO.DataSetVO dataSetVo2 = new DeviceManagerVO.DataSetVO();
dataSetVo2.setId(item.getId());
dataSetVo2.setName("历史统计数据");
dataSetVo2.setType("history");
dataSetList.add(dataSetVo2);
if (Objects.equals(type, "rt")) {
for (CsDataSet item : dataSet) {
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
dataSetVO.setId(item.getId());
dataSetVO.setName(item.getAnotherName());
dataSetVO.setType("rt");
dataSetList.add(dataSetVO);
deviceManagerVo.setDataLevel(item.getDataLevel());
//下面这些tab仅仅只限于设备监控的便携式设备才会有
if(DataParam.portableDevType.equals(csEquipmentDeliveryPo.getDevType())){
//趋势数据tab
DeviceManagerVO.DataSetVO dataSetVo3 = new DeviceManagerVO.DataSetVO();
dataSetVo3.setId(item.getId());
dataSetVo3.setName("历史趋势");
dataSetVo3.setType("trenddata");
dataSetList.add(dataSetVo3);
//实时数据tab
DeviceManagerVO.DataSetVO dataSetVo4 = new DeviceManagerVO.DataSetVO();
dataSetVo4.setId(item.getId());
dataSetVo4.setName("实时数据");
dataSetVo4.setType("realtimedata");
dataSetList.add(dataSetVo4);
//暂态事件tab
DeviceManagerVO.DataSetVO dataSetVo5 = new DeviceManagerVO.DataSetVO();
dataSetVo5.setId(item.getId());
dataSetVo5.setName("暂态事件");
dataSetVo5.setType("event");
dataSetList.add(dataSetVo5);
}
} else {
CsDataSet item = dataSet.get(0);
boolean isPortableDevice = DataParam.portableDevType.equals(csEquipmentDeliveryPo.getDevType());
boolean isCLdDevice = DicDataEnum.DEV_CLD.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryPo.getDevType()).getData().getCode());
addDataSet(dataSetList, item, "最新数据", "rt");
addDataSet(dataSetList, item, "历史统计数据", "history");
addDataSet(dataSetList, item, "历史趋势", "trenddata");
if (item.getClDev() == 0 && item.getType() == 0) {
//限制角色展示
String role = RequestUtil.getUserRole();
List<String> strings = JSONArray.parseArray(role, String.class);
if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode())
|| strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode())
|| strings.contains(AppRoleEnum.ROOT.getCode())) {
addDataSet(dataSetList, item, "模块数据", "moduleData");
}
}
if (isPortableDevice) {
// 便携式设备特有的数据集
addDataSet(dataSetList, item, "实时数据", "realtimedata");
addDataSet(dataSetList, item, "暂态事件", "event");
addDataSet(dataSetList, item, "测试项日志", "items");
}
if (isCLdDevice) {
// 云前置数据集
addDataSet(dataSetList, item, "实时数据", "realtimedata");
}
deviceManagerVo.setDataLevel(item.getDataLevel());
}
deviceManagerVo.setDataSetList(dataSetList);
List<CsLinePO> csLinePOS = csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid());
@@ -415,6 +436,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
}
private void addDataSet(List<DeviceManagerVO.DataSetVO> dataSetList, CsDataSet item, String name, String type) {
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
dataSetVO.setId(item.getId());
dataSetVO.setName(name);
dataSetVO.setType(type);
dataSetList.add(dataSetVO);
}
@Override
public void updateSoftInfoBynDid(String nDid, String id, Integer module) {
boolean result;
@@ -433,21 +462,28 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
@Transactional(rollbackFor = Exception.class)
public void importEquipment(MultipartFile file, HttpServletResponse response) {
public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) {
ImportParams params = new ImportParams ( );
params.setHeadRows(1);
params.setTitleRows(1);
//第一个sheet为台账信息
params.setStartSheetIndex(0);
params.setSheetNum(1);
String regex = "^[A-Za-z0-9]{6,32}$";
try {
ExcelImportResult<DeviceExcelTemplete> terminalBaseList = ExcelImportUtil.importExcelMore (file.getInputStream ( ), DeviceExcelTemplete.class, params);
//如果存在非法数据,将不合格的数据导出
List<DeviceExcelTemplete> trueCollect = new ArrayList<> ( );
List<DeviceExcelTemplete.IllegalityDeviceExcelTemplete> falseCollect = new ArrayList<> ( );
for (int i = 0; i < terminalBaseList.getList ( ).size ( ); i++) {
DeviceExcelTemplete deviceExcelTemplete = terminalBaseList.getList ( ).get (i);
if(!deviceExcelTemplete.getNdid().matches(regex)){
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
idlegalityDeviceException.setMsg("网络设备ID只可为数字或字母,长度至少为6位");
falseCollect.add(idlegalityDeviceException);
continue;
}
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (deviceExcelTemplete.getNdid ( ));
if(!Objects.isNull (po)){
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
@@ -456,42 +492,43 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
falseCollect.add(idlegalityDeviceException);
continue;
}
if(Objects.equals(deviceExcelTemplete.getDevType(),DicDataEnum.GATEWAY_DEV.getName())){
DictTreeVO data = dictTreeFeignClient.queryByCode(DicDataEnum.GATEWAY_DEV.getCode()).getData();
deviceExcelTemplete.setDevType(data.getId());
List<DictTreeVO> data1 = dictTreeFeignClient.query(data.getId()).getData();
Map<String, DictTreeVO> collect = data1.stream().collect(Collectors.toMap(DictTreeVO::getCode, dictTreeVO -> dictTreeVO));
if(collect.containsKey(deviceExcelTemplete.getDevModel())){
deviceExcelTemplete.setDevModel(collect.get(deviceExcelTemplete.getDevModel()).getId());
trueCollect.add(deviceExcelTemplete);
}else {
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
idlegalityDeviceException.setMsg("装置型号不正确");
falseCollect.add(idlegalityDeviceException);
}
} else if (Objects.equals(deviceExcelTemplete.getDevType(),DicDataEnum.CONNECT_DEV.getName())) {
DictTreeVO data = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
deviceExcelTemplete.setDevType(data.getId());
List<DictTreeVO> data1 = dictTreeFeignClient.query(data.getId()).getData();
Map<String, DictTreeVO> collect = data1.stream().collect(Collectors.toMap(DictTreeVO::getCode, dictTreeVO -> dictTreeVO));
if(collect.containsKey(deviceExcelTemplete.getDevModel())){
deviceExcelTemplete.setDevModel(collect.get(deviceExcelTemplete.getDevModel()).getId());
trueCollect.add(deviceExcelTemplete);
}else {
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
idlegalityDeviceException.setMsg("装置型号不正确");
falseCollect.add(idlegalityDeviceException);
}
}else {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, deviceExcelTemplete.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
if(Objects.nonNull (one)){
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
idlegalityDeviceException.setMsg("装置类型不正确");
idlegalityDeviceException.setMsg("NDID重复");
falseCollect.add(idlegalityDeviceException);
continue;
}
List<SysDicTreePO> deviceType = dictTreeFeignClient.queryByCodeList(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData();
//设备类型
List<SysDicTreePO> children = deviceType.get(0).getChildren();
Map<String, SysDicTreePO> map = children.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO));
List<SysDicTreePO> collect = children.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevType())).collect(Collectors.toList());
SysDicTreePO sysDicTreePO = map.get(deviceExcelTemplete.getDevType());
if(CollectionUtils.isEmpty(collect)){
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
idlegalityDeviceException.setMsg("设备类型不正确");
falseCollect.add(idlegalityDeviceException);
continue;
}else {
deviceExcelTemplete.setDevType(map.get(deviceExcelTemplete.getDevType()).getId());
}
//设备型号
List<SysDicTreePO> children1 = sysDicTreePO.getChildren();
Map<String, SysDicTreePO> map2 = children1.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO));
List<SysDicTreePO> collect2 = children1.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevModel())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(collect2)){
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
idlegalityDeviceException.setMsg("设备类型与设备型号不匹配");
falseCollect.add(idlegalityDeviceException);
continue;
}else {
deviceExcelTemplete.setDevModel(map2.get(deviceExcelTemplete.getDevModel()).getId());
trueCollect.add(deviceExcelTemplete);
}
}
if (!CollectionUtils.isEmpty (trueCollect)) {
List<CsEquipmentProcessPO> collect1 = new ArrayList<>();
@@ -505,7 +542,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentDeliveryPO.setRunStatus(1);
csEquipmentDeliveryPO.setStatus(1);
csEquipmentDeliveryPO.setProcess(2);
csEquipmentDeliveryPO.setSort(100);
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
csEquipmentProcess.setDevId(csEquipmentDeliveryPO.getNdid());
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
@@ -517,27 +554,29 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}).collect (Collectors.toList ( ));
csEquipmentProcessPOService.saveBatch(collect1,500);
this.saveOrUpdateBatch (collect, 500);
return collect;
}
if (!CollectionUtils.isEmpty (falseCollect)) {
ExportParams exportExcel = new ExportParams ("批量导入模板(请严格按照模板标准填入数据)", "非法设备信息");
Workbook workbook = ExcelExportUtil.exportExcel (exportExcel, DeviceExcelTemplete.IllegalityDeviceExcelTemplete.class, falseCollect);
ExcelStyleUtil.exportFileByWorkbook (workbook, "非法设备信息.xlsx", response);
return null;
}
} catch (Exception e) {
e.printStackTrace ( );
}
return null;
}
/*
* 物理删除设备相关数据
*
* 2.删除cs_ledger
* 3.删除cs_dev_model_relation
* 4.删除cs_line
* 5.删除cs_line_topology_diagram
* 6.删除cs_device_user
* */
* 物理删除设备相关数据
*
* 2.删除cs_ledger
* 3.删除cs_dev_model_relation
* 4.删除cs_line
* 5.删除cs_line_topology_diagram
* 6.删除cs_device_user
* */
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String devId) {
@@ -597,11 +636,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
public void deleteTest(String deviceId, Integer type ,String remark) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId,deviceId).
// set(CsEquipmentDeliveryPO::getStatus,1).
// set(CsEquipmentDeliveryPO::getRunStatus,1).
set(CsEquipmentDeliveryPO::getProcess,type).update();
set(CsEquipmentDeliveryPO::getProcess,type).update();
this.delete(deviceId);
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).
eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
@@ -619,8 +657,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid)
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.set(CsEquipmentDeliveryPO::getSoftinfoId,id);
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.set(CsEquipmentDeliveryPO::getSoftinfoId,id);
result = this.update(lambdaUpdateWrapper);
if (result) {
refreshDeviceDataCache();
@@ -678,6 +716,247 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return result;
}
@Override
public CsEquipmentDeliveryPO getDevByLineId(String lineId) {
CsLinePO linePO = csLinePOService.getById(lineId);
return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId,linePO.getDeviceId()).ne(CsEquipmentDeliveryPO::getRunStatus,0).one();
}
@Override
@Transactional(rollbackFor = Exception.class)
public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) {
boolean result;
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
if(Objects.nonNull (one)){
throw new BusinessException ("设备名称不能重复");
}
StringUtil.containsSpecialCharacters(param.getNdid());
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (param.getNdid());
if(!Objects.isNull (po)){
throw new BusinessException (AlgorithmResponseEnum.NDID_ERROR);
}
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (param,csEquipmentDeliveryPo);
csEquipmentDeliveryPo.setStatus(3);
csEquipmentDeliveryPo.setRunStatus(1);
csEquipmentDeliveryPo.setUsageStatus(1);
csEquipmentDeliveryPo.setProcess(4);
csEquipmentDeliveryPo.setMac(param.getMac());
//这边自动分配前置机进程号,需要做判断 1.新增装置时判断是否已经是最大装置数量2.根据进程号,选择最少的分配
csEquipmentDeliveryPo.setNodeId(param.getNodeId());
//判断1
Node node = nodeService.getNodeById(param.getNodeId());
List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
}
//判断2
int process = findLeastFrequentProcess(devList,node.getMaxProcessNum());
csEquipmentDeliveryPo.setNodeProcess(process);
result = this.save(csEquipmentDeliveryPo);
//新增设备与模板之间的关系 获取云前置模板
CsDevModelPO csDevModelPO = csDevModelService.getCldModel();
CsDevModelRelationAddParm relationAddParam = new CsDevModelRelationAddParm();
relationAddParam.setDevId(csEquipmentDeliveryPo.getId());
relationAddParam.setModelId(csDevModelPO.getId());
relationAddParam.setDid(1);
CsDevModelRelationPO relation = csDevModelRelationService.addDevModelRelation(relationAddParam);
//新增台账数据
CsLedger csLedger = new CsLedger();
csLedger.setId(csEquipmentDeliveryPo.getId());
csLedger.setPid(param.getProjectId());
csLedger.setPids("0," + param.getEngineeringId() + "," + param.getProjectId());
csLedger.setLevel(2);
csLedger.setName(param.getName());
csLedger.setState(1);
csLedger.setSort(0);
int addLedger = csLedgerMapper.insert(csLedger);
if (result && ObjectUtil.isNotNull(relation) && addLedger > 0) {
refreshDeviceDataCache();
}
return csEquipmentDeliveryPo;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean delCldDev(String id) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId,id);
boolean update = this.remove(lambdaQueryWrapper);
List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list();
if(!CollectionUtils.isEmpty(list)){
List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId,collect);
csLinePOService.remove(csLinePOLambdaQueryWrapper);
}
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getId,id);
csLedgerService.remove(csLedgerLambdaQueryWrapper);
csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getPid,id);
csLedgerService.remove(csLedgerLambdaQueryWrapper);
csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId,id).set(CsDevModelRelationPO::getStatus,0).update();
if (update) {
refreshDeviceDataCache();
}
return true;
}
@Override
public Boolean updateCldDev(CsEquipmentDeliveryAuditParm param) {
//云前置设备判断,修改云前置判断设备是否达到上限
if(ObjectUtil.isNotNull(param.getNodeId())){
Node node = nodeService.getNodeById(param.getNodeId());
List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
}
//自动分配进程号
int process = findLeastFrequentProcess(devList,node.getMaxProcessNum());
param.setNodeProcess(process);
}
StringUtil.containsSpecialCharacters(param.getNdid());
boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,param.getNdid())
.in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3))
.ne(CsEquipmentDeliveryPO::getId, param.getId());
int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
}
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId());
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
List<CsEquipmentDeliveryPO> list = this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getId, param.getId())
.ne(CsEquipmentDeliveryPO::getNdid, param.getNdid())
.eq(CsEquipmentDeliveryPO::getName, param.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if(!CollectionUtils.isEmpty (list)){
throw new BusinessException ("设备名称不能重复");
}
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (param, csEquipmentDeliveryPo);
String path = this.createPath(param.getNdid());
csEquipmentDeliveryPo.setMac(path);
result = this.updateById(csEquipmentDeliveryPo);
//修改台账树中的设备名称
CsLedger csLedger = csLedgerService.findDataById(param.getId());
if (!Objects.isNull(csLedger)) {
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
BeanUtils.copyProperties (csLedger, csLedgerParam);
csLedgerParam.setName(param.getName());
csLedgerService.updateLedgerTree(csLedgerParam);
}
if (result) {
refreshDeviceDataCache();
if (!Objects.equals(po.getUsageStatus(),param.getUsageStatus())) {
DeviceLogDTO dto = new DeviceLogDTO();
dto.setUserName(RequestUtil.getUsername());
dto.setOperate("设备使用状态被修改");
dto.setResult(1);
dto.setLoginName(RequestUtil.getLoginName());
csLogsFeignClient.addUserLog(dto);
}
}
return result;
}
@Override
public List<CsEquipmentDeliveryPO> getCldDevByIp(String id, List<Integer> runFlag) {
//运行状态转换
List<Integer> state = new ArrayList<>();
if (CollectionUtil.isNotEmpty(runFlag)) {
if (runFlag.contains(0)) {
state.add(1);
}
if (runFlag.contains(2)) {
state.add(0);
}
//fixme 目前治理设备只有启用和停用,没有那么多状态,如果前置传递其他状态,先设置一个不存在的状态
state.add(9);
}
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,id)
.in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state);
return this.list(lambdaQueryWrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateCldDevStatus(String nodeId, Integer processNo) {
//获取需要修改的设备信息
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId)
.eq(CsEquipmentDeliveryPO::getNodeProcess,processNo)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
.eq(CsEquipmentDeliveryPO::getRunStatus,2);
List<CsEquipmentDeliveryPO> devList = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(devList)) {
//修改设备运行状态
devList.forEach(item->{item.setRunStatus(1);});
this.updateBatchById(devList);
//修改监测点运行状态
List<String> devIdList = devList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(devIdList);
csLinePOService.updateCldLineStatus(lineList,2);
}
}
@Override
public void flipCldDevStatus(String devId, Integer status) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId,devId)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
.ne(CsEquipmentDeliveryPO::getUsageStatus,0);
CsEquipmentDeliveryPO po = this.getOne(lambdaQueryWrapper);
if (ObjectUtil.isNotNull(po)) {
po.setRunStatus(status);
this.updateById(po);
//修改监测点运行状态
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(Collections.singletonList(po.getId()));
csLinePOService.updateCldLineStatus(lineList,status==1?2:0);
}
}
@Override
public List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId) {
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper();
csLedgerQueryWrapper.lambda().eq(CsLedger::getPid, projectId).eq(CsLedger::getState,1);
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,collect).list();
}
//根据前置机id获取装置数量
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId)
.in(CsEquipmentDeliveryPO::getRunStatus,Arrays.asList(1,2));
return this.list(lambdaQueryWrapper);
}
public int findLeastFrequentProcess(List<CsEquipmentDeliveryPO> items, Integer process) {
Map<Integer, Long> processCounts = items.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting()));
for (int i = 1; i <= process; i++) {
processCounts.putIfAbsent(i, 0L);
}
//如果列表为空默认返回1
return processCounts.entrySet().stream()
.min(Comparator.comparingLong(Map.Entry::getValue))
.map(Map.Entry::getKey)
.orElse(1);
}
/**
* 根据ndid生成二维码
* @param ndid
@@ -697,7 +976,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
e.printStackTrace();
}
return filePath;
}
public InputStream bufferedImageToInputStream(BufferedImage image) {
@@ -711,6 +989,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
return null;
}
/*将ndid转成mac地址*/
public String createPath(String nDid) {
// 使用StringBuilder来构建新的字符串
@@ -732,4 +1011,4 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
return output.toString();
}
}
}

View File

@@ -323,6 +323,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
}).collect(Collectors.toList());
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
@@ -332,38 +333,102 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
vo.setStatMethod(temp.getValueType());
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
if(temp.getValue()!=null) {
double re;
double re = 0;
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
vo.setUnit(epdPqd.getUnit());
} else {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct) / 1000;
vo.setStatisticalData(Double.valueOf(df.format(re)));
vo.setUnit("k" + epdPqd.getUnit());
re = Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue() / 1000));
vo.setStatisticalData(re);
unit = "k" + epdPqd.getUnit();
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
vo.setUnit(epdPqd.getUnit());
vo.setStatisticalData(Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue())));
unit = epdPqd.getUnit();
}
} else {
if(Objects.nonNull(epdPqd.getPrimaryFormula())){
switch (epdPqd.getPrimaryFormula()) {
case "*PT":
re = temp.getValue() * pt / 1000;
unit = "k" + epdPqd.getUnit();
break;
case "*CT":
re = temp.getValue() * ct;
unit = epdPqd.getUnit();
break;
case "*PT*CT":
re = temp.getValue() * pt * ct / 1000;
unit = "k" + epdPqd.getUnit();
break;
default:
re = temp.getValue();
unit = epdPqd.getUnit();
break;
}
vo.setStatisticalData(Double.valueOf(df.format(re)));
}else {
re = temp.getValue();
unit = epdPqd.getUnit();
vo.setStatisticalData(Double.valueOf(df.format(re)));
}
}
} else {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = DataChangeUtil.primaryToSecondary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct);
if(Objects.nonNull(epdPqd.getPrimaryFormula())){
switch (epdPqd.getPrimaryFormula()) {
case "*PT":
re = temp.getValue() / pt;
break;
case "*CT":
re = temp.getValue() / ct;
break;
case "*PT*CT":
re = temp.getValue() / pt / ct;
break;
default:
re = temp.getValue();
break;
}
vo.setStatisticalData(Double.valueOf(df.format(re)));
}else {
re = temp.getValue();
vo.setStatisticalData(Double.valueOf(df.format(re)));
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
vo.setUnit(epdPqd.getUnit());
}
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
}
vo.setUnit(epdPqd.getUnit());
unit = epdPqd.getUnit();
}
} else {
vo.setStatisticalData(null);
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
unit = epdPqd.getUnit();
} else {
if(Objects.nonNull(epdPqd.getPrimaryFormula())){
switch (epdPqd.getPrimaryFormula()) {
case "*PT":
unit = "k" + epdPqd.getUnit();
break;
case "*CT":
unit = epdPqd.getUnit();
break;
case "*PT*CT":
unit = "k" + epdPqd.getUnit();
break;
default:
unit = epdPqd.getUnit();
break;
}
}else {
unit = epdPqd.getUnit();
}
}
} else {
unit = epdPqd.getUnit();
}
}
vo.setUnit(unit);
vo.setStatisticalIndex(epdPqd.getId());
vo.setStatisticalName(epdPqd.getName());
vo.setAnotherName(epdPqd.getShowName());

View File

@@ -4,27 +4,32 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.*;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
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.service.*;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.Area;
import com.njcn.system.pojo.vo.DictTreeVO;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -39,19 +44,18 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> implements ICsLedgerService {
private final ICsEngineeringUserService csEngineeringUserService;
private final AreaFeignClient areaFeignClient;
private final RedisUtil redisUtil;
private final AppTopologyDiagramMapper appTopologyDiagramMapper;
private final AppProjectMapper appProjectMapper;
private final CsEngineeringMapper csEngineeringMapper;
private final CsLinePOService csLinePOService;
private final DicDataFeignClient dicDataFeignClient;
private final FileStorageUtil fileStorageUtil;
private final RoleEngineerDevService roleEngineerDevService;
private final CsDevModelRelationService csDevModelRelationService;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final ICsDataSetService csDataSetService;
private final EquipmentFeignClient equipmentFeignClient;
private final DictTreeFeignClient dictTreeFeignClient;
@Override
public List<CsLedgerVO> getLedgerTree() {
@@ -75,42 +79,145 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
/*获取用户工程,设备信息过滤*/
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
List<String> device = roleEngineerDevService.getDevice();
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
//区分治理装置和云前置装置
List<String> zhiLianDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>();
List<CsEquipmentDeliveryDTO> csEquipmentDeliveryPOS = equipmentFeignClient.queryDeviceById(device).getData();
if (CollectionUtil.isNotEmpty(csEquipmentDeliveryPOS)) {
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
Optional.ofNullable(vo1)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(cldDevice::add)
);
DictTreeVO vo2 = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
Optional.ofNullable(vo2)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(zhiLianDevice::add)
);
}
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(),"0")).
peek(
temp->{
CsEquipmentDeliveryPO csEquipmentDeliveryPO = csEquipmentDeliveryMapper.selectById(temp.getId());
temp.setComFlag(csEquipmentDeliveryPO.getRunStatus());
temp.setType("device");
}
).
sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
Map<String, CsEquipmentDeliveryPO> poMap = allList.stream()
.filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.map(CsLedgerVO::getId)
.distinct()
.collect(Collectors.toMap(
Function.identity(),
csEquipmentDeliveryMapper::selectById
));
List<CsLedgerVO> deviceList = allList.stream()
.filter(item -> zhiLianDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> cldDeviceList = allList.stream()
.filter(item -> cldDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> finalLineList = allList.stream()
.filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.peek(item -> item.setType("line"))
.peek(
item -> {
item.setType("line");
String index = item.getId().substring(item.getId().length()-1);
if (Objects.equals(index,"0")) {
item.setLineType(0);
} else {
item.setLineType(1);
}
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsLinePO::getLineId,item.getId()).eq(CsLinePO::getStatus,1);
CsLinePO po = csLinePOService.getOne(queryWrapper);
item.setConType(po.getConType());
}
)
.collect(Collectors.toList());
checkDevSetData(deviceList);
deviceList.forEach(dev -> dev.setChildren(getChildren(dev, finalLineList)));
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
List<CsLedgerVO> engineeringList1 = new ArrayList<>();
List<CsLedgerVO> projectList1 = new ArrayList<>();
List<String> dev = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger1 = getProAndEngineer(dev);
if (CollectionUtil.isNotEmpty(ledger1)) {
deviceList.forEach(dev1 -> dev1.setChildren(getChildren(dev1, finalLineList)));
engineeringList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
List<CsLedgerVO> finalProjectList = projectList1;
engineeringList1.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
checkDevSetData(cldDeviceList);
List<CsLedgerVO> engineeringList2 = new ArrayList<>();
List<CsLedgerVO> projectList2 = new ArrayList<>();
List<String> dev2 = cldDeviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger2 = getProAndEngineer(dev2);
if (CollectionUtil.isNotEmpty(ledger2)) {
cldDeviceList.forEach(dev1 -> dev1.setChildren(getChildren(dev1, finalLineList)));
engineeringList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2.forEach(pro -> pro.setChildren(getChildren(pro, cldDeviceList)));
List<CsLedgerVO> finalProjectList = projectList2;
engineeringList2.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取便携式设备树
CsLedgerVO portable = new CsLedgerVO();
portable.setLevel(0);
portable.setName(DataParam.portableDev);
portable.setPid("0");
portable.setId(IdUtil.simpleUUID());
List<CsLedgerVO> portables = allList.stream().filter(item->Objects.equals(item.getLevel(),2) && Objects.equals(item.getPid(),"0")).collect(Collectors.toList());
for(CsLedgerVO c : portables){
c.setPid(portable.getId());
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(c.getId());
c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid());
c.setType("device");
}
portables.forEach(dev -> dev.setChildren(getChildren(dev, finalLineList)));
//针对未启用的装置判断
List<CsLedgerVO> ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0"))
.collect(Collectors.toList());
Map<String, CsEquipmentDeliveryPO> poMap2 = ledger.stream()
.collect(Collectors.toMap(
CsLedgerVO::getId,
csEquipmentDeliveryMapper::selectById,
(existing, replacement) -> existing
));
List<CsLedgerVO> portables = ledger.stream()
.peek(c -> {
CsEquipmentDeliveryPO po = poMap2.get(c.getId());
c.setPid(portable.getId());
c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid());
c.setType("device");
c.setName(po.getName());
c.setSort(po.getSort());
})
.filter(c -> poMap2.get(c.getId()).getUsageStatus() == 1)
.collect(Collectors.toList());
portables = portables.stream().sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
portables.forEach(dev3 -> dev3.setChildren(getChildren(dev3, finalLineList)));
checkDevSetData(portables);
portable.setChildren(portables);
@@ -119,7 +226,16 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
government.setName(DataParam.governmentDev);
government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
government.setChildren(engineeringList1);
//获取云前置设备树
CsLedgerVO cld = new CsLedgerVO();
cld.setLevel(0);
cld.setName(DataParam.cldDev);
cld.setPid("0");
cld.setId(IdUtil.simpleUUID());
cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
@@ -127,6 +243,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
if (CollUtil.isNotEmpty(cldDeviceList)) {
tree.add(cld);
}
return tree;
}
//剔除未接入的设备(根据status判断不太稳,所有这里直接判断该设备有没有对应的模板指标)
@@ -165,22 +284,93 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
/*获取用户工程,设备信息过滤*/
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
List<String> device = roleEngineerDevService.getDevice();
List<String> zhiLianDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>();
List<CsEquipmentDeliveryDTO> csEquipmentDeliveryPOS = equipmentFeignClient.queryDeviceById(device).getData();
if (CollectionUtil.isNotEmpty(csEquipmentDeliveryPOS)) {
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
Optional.ofNullable(vo1)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(cldDevice::add)
);
DictTreeVO vo2 = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
Optional.ofNullable(vo2)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(zhiLianDevice::add)
);
}
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(),"0")).
peek(
temp->{
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(temp.getId());
temp.setComFlag(po.getRunStatus());
temp.setNDId(po.getNdid());
temp.setType("device");
}
).
sorted(Comparator.comparing(CsLedgerVO::getSort))
Map<String, CsEquipmentDeliveryPO> poMap = allList.stream()
.filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.map(CsLedgerVO::getId)
.distinct()
.collect(Collectors.toMap(
Function.identity(),
csEquipmentDeliveryMapper::selectById
));
//获取治理设备
List<CsLedgerVO> deviceList = allList.stream()
.filter(item -> zhiLianDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> engineeringList1 = new ArrayList<>();
List<CsLedgerVO> projectList1 = new ArrayList<>();
checkDevSetData(deviceList);
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
List<String> dev = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger1 = getProAndEngineer(dev);
if (CollectionUtil.isNotEmpty(ledger1)) {
engineeringList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
List<CsLedgerVO> finalProjectList = projectList1;
engineeringList1.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取云前置设备
List<CsLedgerVO> cldDevList = allList.stream()
.filter(item -> cldDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
checkDevSetData(cldDevList);
List<CsLedgerVO> engineeringList2 = new ArrayList<>();
List<CsLedgerVO> projectList2 = new ArrayList<>();
List<String> dev2 = cldDevList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger2 = getProAndEngineer(dev2);
if (CollectionUtil.isNotEmpty(ledger2)) {
engineeringList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2.forEach(pro -> pro.setChildren(getChildren(pro, cldDevList)));
List<CsLedgerVO> finalProjectList = projectList2;
engineeringList2.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取便携式设备树
CsLedgerVO portable = new CsLedgerVO();
@@ -188,15 +378,31 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
portable.setName(DataParam.portableDev);
portable.setPid("0");
portable.setId(IdUtil.simpleUUID());
List<CsLedgerVO> portables = allList.stream().filter(item->Objects.equals(item.getLevel(),2) && Objects.equals(item.getPid(),"0")).collect(Collectors.toList());
checkDevSetData(portables);
for(CsLedgerVO c : portables){
c.setPid(portable.getId());
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(c.getId());
c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid());
c.setType("device");
}
//针对未启用的装置判断
List<CsLedgerVO> ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0"))
.collect(Collectors.toList());
Map<String, CsEquipmentDeliveryPO> poMap2 = ledger.stream()
.collect(Collectors.toMap(
CsLedgerVO::getId,
csEquipmentDeliveryMapper::selectById,
(existing, replacement) -> existing
));
List<CsLedgerVO> portables = ledger.stream()
.peek(c -> {
CsEquipmentDeliveryPO po = poMap2.get(c.getId());
c.setPid(portable.getId());
c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid());
c.setType("device");
c.setName(po.getName());
c.setSort(po.getSort());
})
.filter(c -> poMap2.get(c.getId()).getUsageStatus() == 1)
.collect(Collectors.toList());
portables = portables.stream().sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
portable.setChildren(portables);
CsLedgerVO government = new CsLedgerVO();
@@ -204,7 +410,16 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
government.setName(DataParam.governmentDev);
government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
government.setChildren(engineeringList1);
//获取云前置设备树
CsLedgerVO cld = new CsLedgerVO();
cld.setLevel(0);
cld.setName(DataParam.cldDev);
cld.setPid("0");
cld.setId(IdUtil.simpleUUID());
cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
@@ -212,6 +427,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
if (CollUtil.isNotEmpty(cldDevList)) {
tree.add(cld);
}
return tree;
}
@@ -288,10 +506,13 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
engineeringList.forEach(eng -> {
CsEngineeringPO csEngineeringPO = csEngineeringMapper.selectById(eng.getId());
eng.setArea(this.getAreaById(csEngineeringPO.getProvince())+this.getAreaById(csEngineeringPO.getCity()));
eng.setProvinceId(csEngineeringPO.getProvince());
eng.setCityId(csEngineeringPO.getCity());
eng.setRemark(csEngineeringPO.getDescription());
eng.setChildren(getChildren(eng, projectList));
}
);
return engineeringList;
}
@@ -403,6 +624,32 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
return tree;
}
@Override
public List<CsLedgerVO> getProAndEngineer(List<String> id) {
List<CsLedgerVO> result = new ArrayList<>();
List<CsLedgerVO> allList = this.baseMapper.getAll();
Set<String> idSet = new HashSet<>(id);
if (CollectionUtil.isNotEmpty(id)) {
id.forEach(item->{
allList.forEach(item2->{
if (Objects.equals(item2.getId(),item)) {
idSet.addAll(Arrays.asList(item2.getPids().split( ",")));
}
});
});
}
if (CollectionUtil.isNotEmpty(idSet)) {
idSet.forEach(item->{
allList.forEach(item2->{
if (Objects.equals(item2.getId(),item)) {
result.add(item2);
}
});
});
}
return result;
}
/**
* 获取子节点
*/

View File

@@ -1,19 +1,36 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.mapper.CsLinePOMapper;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.po.CsDevModelPO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.service.CsDevModelService;
import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.service.ICsDataSetService;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.biz.utils.COverlimitUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.pojo.constant.FunctionState;
import com.njcn.user.pojo.po.Function;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
@@ -28,7 +45,12 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> implements CsLinePOService{
private final CsLedgerMapper csLedgerMapper;
private final CsDevModelService csDevModelService;
private final ICsDataSetService csDataSetService;
private final DicDataFeignClient dicDataFeignClient;
private final OverlimitMapper overlimitMapper;
@Override
public List<CsLinePO> getLineByDev(List<String> list) {
@@ -67,7 +89,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
.set(CsLinePO::getVolGrade,csLineParam.getVolGrade())
.set(CsLinePO::getPtRatio,csLineParam.getPtRatio())
.set(CsLinePO::getCtRatio,csLineParam.getCtRatio())
.set(CsLinePO::getConType,csLineParam.getConType());
.set(CsLinePO::getConType,csLineParam.getConType())
.set(CsLinePO::getLineInterval,csLineParam.getLineInterval());
this.update(lambdaUpdateWrapper);
}
@@ -81,6 +104,94 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
this.update(lambdaUpdateWrapper);
}
@Override
public List<CsLinePO> getLinesByDevList(List<String> list) {
return this.lambdaQuery().in(CsLinePO::getDeviceId,list).eq(CsLinePO::getStatus,1).list();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addCldLine(CsLineParam param) {
String lineId = param.getDevMac().replace(":","") + param.getLineNo();
CsLinePO po = new CsLinePO();
//1.新增监测点信息
BeanUtils.copyProperties(param,po);
po.setStatus(1);
po.setRunStatus(2);
po.setLineId(param.getDevMac().replace(":","") + param.getLineNo());
//模板id
CsDevModelPO po1 = csDevModelService.getCldModel();
po.setDataModelId(po1.getId());
//设备id
po.setDeviceId(param.getDevId());
//数据集id
List<CsDataSet> list = csDataSetService.findDataSetByModelId(po1.getId());
if (CollectionUtil.isNotEmpty(list)) {
po.setDataSetId(list.get(0).getId());
po.setClDid(list.get(0).getClDev());
}
//监测位置
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
po.setPosition(data.getId());
this.save(po);
//2.新增台账树信息
CsLedger csLedger = new CsLedger();
csLedger.setId(lineId);
csLedger.setPid(param.getDevId());
csLedger.setPids("0," + param.getEngineeringId() + "," + param.getProjectId() + "," + param.getDevId());
csLedger.setName(param.getName());
csLedger.setLevel(3);
csLedger.setState(1);
csLedger.setSort(0);
csLedgerMapper.insert(csLedger);
//3.新增监测点限值
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1);
overlimit.setId(lineId);
overlimitMapper.deleteById(lineId);
overlimitMapper.insert(overlimit);
}
@Override
public void updateCldLine(CsLineParam param) {
LambdaQueryWrapper<CsLinePO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsLinePO::getDeviceId,param.getDevId())
.ne(CsLinePO::getLineId,param.getLineId())
.eq(CsLinePO::getStatus,1)
.eq(CsLinePO::getClDid,param.getClDid());
List<CsLinePO> lineList = this.list(wrapper);
if (CollectionUtil.isNotEmpty(lineList)) {
throw new BusinessException("监测点线路号重复,请调整!");
}
LambdaUpdateWrapper<CsLinePO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsLinePO::getLineId,param.getLineId())
.eq(CsLinePO::getStatus,1)
.set(CsLinePO::getVolGrade,param.getVolGrade())
.set(CsLinePO::getConType,param.getConType())
.set(CsLinePO::getPtRatio,param.getPtRatio())
.set(CsLinePO::getPt2Ratio,param.getPt2Ratio())
.set(CsLinePO::getCtRatio,param.getCtRatio())
.set(CsLinePO::getCt2Ratio,param.getCt2Ratio())
.set(CsLinePO::getClDid,param.getClDid())
.set(CsLinePO::getLineInterval,param.getLineInterval())
.set(CsLinePO::getRunStatus,param.getRunStatus());
this.update(lambdaUpdateWrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteCldLine(String id) {
this.removeById(id);
csLedgerMapper.deleteById(id);
}
@Override
public void updateCldLineStatus(List<CsLinePO> lineList, Integer status) {
lineList.forEach(item->{item.setRunStatus(status);});
this.updateBatchById(lineList);
}
// /**
// * 1.平台端默认配置拓扑图模板,包含拓扑图信息(cs_topology_diagram_template)和拓扑图上监测点的点位信息(cs_line_topology_template)
// *

View File

@@ -45,7 +45,10 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
public MakeUpVo askDeviceRootPath(String nDid) {
MakeUpVo makeUpVo = new MakeUpVo();
try {
judgeClientOnline(nDid);
boolean mqttClient = judgeClientOnline(nDid);
if (!mqttClient){
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
}
redisUtil.delete(AppRedisKey.DEVICE_ROOT_PATH + nDid);
askDeviceDataFeignClient.askDeviceRootPath(nDid);
Thread.sleep(3000);
@@ -55,7 +58,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
makeUpVo.setType("dir");
}
} catch (Exception e) {
throw new BusinessException(AlgorithmResponseEnum.ASK_DEVICE_DIR_ROOT_ERROR);
throw new BusinessException(e.getMessage());
}
return makeUpVo;
}
@@ -64,7 +67,10 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
public List<MakeUpVo> askDeviceFileOrDir(String nDid, String name, String type) {
List<MakeUpVo> result = new ArrayList<>();
try {
judgeClientOnline(nDid);
boolean mqttClient = judgeClientOnline(nDid);
if (!mqttClient){
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
}
// 删除旧的缓存信息
redisUtil.delete(AppRedisKey.PROJECT_INFO + nDid);
// 请求设备文件或目录信息
@@ -78,7 +84,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
}
} catch (Exception e) {
// 捕获特定异常并抛出运行时异常
throw new BusinessException(AlgorithmResponseEnum.ASK_DEVICE_DIR_ERROR);
throw new BusinessException(e.getMessage());
}
if (CollUtil.isNotEmpty(result)) {
result.stream().sorted(Comparator.comparing(MakeUpVo::getType)).collect(Collectors.toList());
@@ -89,7 +95,10 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
@Override
@Async
public void downloadFile(String nDid, String name, Integer size, String fileCheck) {
judgeClientOnline(nDid);
boolean mqttClient = judgeClientOnline(nDid);
if (!mqttClient) {
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
}
Object task = redisUtil.getObjectByKey("fileDowning:"+nDid);
if (Objects.nonNull(task)) {
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
@@ -104,7 +113,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
} catch (Exception e) {
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete("fileCheck"+nDid+name);
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
throw new BusinessException(e.getMessage());
}
}
@@ -119,6 +128,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
redisUtil.delete("fileCheck"+nDid+name);
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete(AppRedisKey.FILE_PART.concat(name));
redisUtil.delete("fileDownUserId"+nDid+name);
return result;
}
@@ -134,7 +144,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
result = true;
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage());
}
return result;
}
@@ -151,7 +161,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
result = true;
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage());
}
return result;
}
@@ -198,13 +208,10 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
return vo;
}
public void judgeClientOnline(String nDid) {
public boolean judgeClientOnline(String nDid) {
//判断客户端是否在线
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
if (!mqttClient){
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
}
return mqttUtil.judgeClientOnline(clientName);
}

View File

@@ -0,0 +1,349 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.access.utils.ChannelObjectUtil;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.param.IcdLedgerParam;
import com.njcn.csdevice.param.IcdParam;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
import com.njcn.csdevice.pojo.vo.DeviceInfo;
import com.njcn.csdevice.service.*;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.SysDicTreePO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
class IcdServiceImpl implements IcdService {
private final INodeService nodeService;
private final ChannelObjectUtil channelObjectUtil;
private final RedisUtil redisUtil;
private final CsEngineeringService csEngineeringService;
private final AppProjectService appProjectService;
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final CsLinePOService csLinePOService;
private final ICsLedgerService csLedgerService;
private final MqttPublisher publisher;
@Override
public List<DeviceInfo> getLedgerInfo(IcdParam param) {
//获取装置型号
Map<String,SysDicTreePO> sysDicTreeMap = new HashMap<>();
List<SysDicTreePO> dictTreeList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.DICT_TREE),SysDicTreePO.class);
SysDicTreePO po = dictTreeList.stream().filter(item -> Objects.equals(item.getCode(), DicDataEnum.DEV_CLD.getCode())).findFirst().orElse(null);
if (ObjectUtil.isNotNull(po)) {
String id = po.getId();
List<SysDicTreePO> cldDevType = dictTreeList.stream().filter(item->Objects.equals(item.getPid(),id)).collect(Collectors.toList());
sysDicTreeMap = cldDevType.stream().collect(Collectors.toMap(SysDicTreePO::getId, Function.identity()));
}
List<DeviceInfo> result = new ArrayList<>();
//根据ip获取前置机信息
Node node = nodeService.getNodeByIp(param.getIp());
if (ObjectUtil.isNotNull(node)) {
//根据前置机ip获取装置信息
List<CsEquipmentDeliveryPO> poList = csEquipmentDeliveryService.getCldDevByIp(node.getId(),param.getRunFlag());
if (CollectionUtil.isNotEmpty(poList)) {
//获取监测点集合
List<String> devList = poList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(devList);
Map<String,List<CsLinePO>> lineMap = lineList.stream().collect(Collectors.groupingBy(CsLinePO::getDeviceId));
//组装返回结构体
Map<String, SysDicTreePO> finalSysDicTreeMap = sysDicTreeMap;
poList.forEach(dev->{
DeviceInfo detail = new DeviceInfo();
detail.setId(dev.getId());
detail.setName(dev.getName());
detail.setIp(dev.getMac());
detail.setDevType(Objects.isNull(finalSysDicTreeMap.get(dev.getDevModel())) ? "/":finalSysDicTreeMap.get(dev.getDevModel()).getCode());
detail.setNode(dev.getNodeProcess());
// 只获取当前设备的监测点数据
List<CsLinePO> lines = lineMap.get(dev.getId());
if (CollectionUtil.isNotEmpty(lines)) {
List<DeviceInfo.MonitorInfo> monitorInfos = new ArrayList<>();
lines.forEach(line->{
DeviceInfo.MonitorInfo monitorInfo = new DeviceInfo.MonitorInfo();
monitorInfo.setDeviceId(dev.getId());
monitorInfo.setId(line.getLineId());
monitorInfo.setName(line.getName());
monitorInfo.setLineNo(String.valueOf(line.getLineNo()));
monitorInfo.setVoltageLevel(line.getVolGrade() + "kV");
monitorInfo.setStatus(line.getRunStatus());
monitorInfo.setPtType(String.valueOf(line.getConType()));
monitorInfo.setPt1(line.getPtRatio());
monitorInfo.setPt2(line.getPt2Ratio());
monitorInfo.setCt1(line.getCtRatio());
monitorInfo.setCt2(line.getCt2Ratio());
monitorInfos.add(monitorInfo);
});
detail.setMonitorData(monitorInfos);
}
result.add(detail);
});
}
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addLedgerInfo(IcdLedgerParam param) {
// 第一种:全流程创建
if (isAllIndicesNull(param)) {
handleFullProcessCreation(param);
}
// 第二种:从工程创建
else if (ObjectUtil.isNotNull(param.getEngineeringIndex())) {
handleFromEngineeringCreation(param);
}
// 第三种:从项目创建
else if (ObjectUtil.isNotNull(param.getProjectIndex())) {
handleFromProjectCreation(param);
}
// 第四种:从设备创建
else if (CollectionUtil.isNotEmpty(param.getDevice())) {
handleFromDeviceCreation(param);
//todo 新增完监测点后,需要通知前置修改台账信息
}
}
@Override
public CldLedgerVo getLedgerById(String id) {
CldLedgerVo vo = new CldLedgerVo();
CsLedger csLedger = csLedgerService.findDataById(id);
if (ObjectUtil.isNull(csLedger)) {
return vo;
}
Integer level = csLedger.getLevel();
String[] pids = csLedger.getPids().split(StrUtil.COMMA);
// 设置工程信息(所有级别都需要)
setEngineeringInfo(vo, level, pids, id);
// 根据级别设置不同的业务数据
switch (level) {
case 0:
handleLevel0(vo, id);
break;
case 1:
handleLevel1(vo, id, pids);
break;
case 2:
handleLevel2(vo, id, pids);
break;
case 3:
handleLevel3(vo, id, pids);
break;
default:
log.warn("Unknown ledger level: {}", level);
}
return vo;
}
/**
* 设置工程信息
*/
private void setEngineeringInfo(CldLedgerVo vo, Integer level, String[] pids, String id) {
String engineeringId;
if (level == 0) {
// 0级本身就是工程
engineeringId = id;
} else if (level >= 1 && pids.length > 1) {
// 1-3级的工程ID在pids[1]位置
engineeringId = pids[1];
} else {
return;
}
CsEngineeringPO po = csEngineeringService.queryEngineeringById(engineeringId);
if (po != null) {
vo.setEngineeringId(po.getId());
vo.setEngineeringName(po.getName());
vo.setProvince(po.getProvince());
vo.setCity(po.getCity());
vo.setEngineeringDescription(po.getDescription());
}
}
/**
* 处理0级数据工程级别
*/
private void handleLevel0(CldLedgerVo vo, String id) {
List<AppProjectPO> projectInfoList = appProjectService.getProjectByEngineering(Collections.singletonList(id));
vo.setProjectInfoList(projectInfoList);
}
/**
* 处理1级数据项目级别
*/
private void handleLevel1(CldLedgerVo vo, String id, String[] pids) {
// 设置项目信息
List<AppProjectPO> appProjectPOS = appProjectService.listByIds(Collections.singletonList(id));
vo.setProjectInfoList(appProjectPOS);
// 设置设备信息
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getDevListByProjectId(id);
vo.setDeviceInfoList(devList);
}
/**
* 处理2级数据设备级别
*/
private void handleLevel2(CldLedgerVo vo, String id, String[] pids) {
// 设置项目信息项目ID在pids[2]位置)
if (pids.length > 2) {
String projectId = pids[2];
List<AppProjectPO> project = appProjectService.listByIds(Collections.singletonList(projectId));
vo.setProjectInfoList(project);
}
// 设置设备信息
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(id));
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
// 设置线路信息
List<CsLinePO> list = csLinePOService.queryByDevId(id);
vo.setLineInfoList(list);
}
/**
* 处理3级数据线路级别
*/
private void handleLevel3(CldLedgerVo vo, String id, String[] pids) {
// 设置项目信息项目ID在pids[2]位置)
if (pids.length > 2) {
String projectId = pids[2];
List<AppProjectPO> appProjectPOS = appProjectService.listByIds(Collections.singletonList(projectId));
vo.setProjectInfoList(appProjectPOS);
}
// 设置设备信息设备ID在pids[3]位置)
if (pids.length > 3) {
String deviceId = pids[3];
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(deviceId));
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
}
// 设置线路信息
List<CsLinePO> line = csLinePOService.listByIds(Collections.singletonList(id));
vo.setLineInfoList(line);
}
public void sendFrontLedger() {
}
private boolean isAllIndicesNull(IcdLedgerParam param) {
return ObjectUtil.isNull(param.getEngineeringIndex())
&& ObjectUtil.isNull(param.getProjectIndex())
&& ObjectUtil.isNull(param.getDevIndex());
}
private void handleFullProcessCreation(@NotNull IcdLedgerParam param) {
if (ObjectUtil.isNotNull(param.getEngineering())) {
CsEngineeringPO po1 = csEngineeringService.addEngineering(param.getEngineering());
param.setEngineeringIndex(po1.getId());
createProjectAndDevices(param);
}
}
private void handleFromEngineeringCreation(IcdLedgerParam param) {
createProjectAndDevices(param);
}
private void handleFromProjectCreation(IcdLedgerParam param) {
saveDevicesAndLines(param);
}
private void handleFromDeviceCreation(IcdLedgerParam param) {
saveLines(param);
}
private void createProjectAndDevices(IcdLedgerParam param) {
AppProjectAddParm project = param.getProject();
if (ObjectUtil.isNotNull(project)) {
project.setEngineeringId(param.getEngineeringIndex());
project.setIcdEngineeringId(param.getEngineeringIndex());
AppProjectPO po2 = appProjectService.addAppProject(project);
param.setProjectIndex(po2.getId());
}
saveDevicesAndLines(param);
}
private void saveDevicesAndLines(IcdLedgerParam param) {
List<CsEquipmentDeliveryAddParm> devList = param.getDevice();
if (CollectionUtil.isNotEmpty(devList)) {
Map<String,String> devMacMap = new HashMap<>();
for (CsEquipmentDeliveryAddParm dev : devList) {
dev.setEngineeringId(param.getEngineeringIndex());
dev.setProjectId(param.getProjectIndex());
CsEquipmentDeliveryPO po3 = csEquipmentDeliveryService.saveCld(dev);
devMacMap.put(dev.getMac(),po3.getId());
}
param.setDevMacMap(devMacMap);
}
saveLines(param);
}
private void saveLines(IcdLedgerParam param) {
List<CsLineParam> lineList = param.getLine();
if (CollectionUtil.isNotEmpty(lineList)) {
boolean result = checkAndAlertDuplicates(lineList);
if (result) {
throw new BusinessException("监测点线路号重复,请调整!");
}
for (CsLineParam line : lineList) {
line.setEngineeringId(param.getEngineeringIndex());
line.setProjectId(param.getProjectIndex());
if (Objects.isNull(param.getDevIndex())) {
line.setDevId(param.getDevMacMap().get(line.getDevMac()));
} else {
LambdaQueryWrapper<CsLinePO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsLinePO::getDeviceId,param.getDevIndex()).eq(CsLinePO::getLineNo,line.getLineNo()).eq(CsLinePO::getStatus,1);
CsLinePO po4 = csLinePOService.getOne(wrapper);
if (ObjectUtil.isNotNull(po4)) {
throw new BusinessException("监测点线路号重复,请调整!");
}
line.setDevId(param.getDevIndex());
}
csLinePOService.addCldLine(line);
}
}
}
//判断相同设备不能存在相同的线路号监测点
public boolean checkAndAlertDuplicates(List<CsLineParam> devices) {
// 使用Set来记录已经出现过的devMac+clDid组合
Set<String> seenCombinations = new HashSet<>();
List<CsLineParam> duplicates = new ArrayList<>();
for (CsLineParam device : devices) {
String combination = device.getDevMac() + "-" + device.getLineNo();
if (seenCombinations.contains(combination)) {
// 发现重复,添加到重复列表
duplicates.add(device);
} else {
seenCombinations.add(combination);
}
}
return !duplicates.isEmpty();
}
}

View File

@@ -0,0 +1,145 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.date.DatePattern;
import com.njcn.csdevice.param.LineCountEvaluateParam;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
import com.njcn.csdevice.service.ICsCommunicateService;
import com.njcn.influx.imapper.PqsCommunicateMapper;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.pojo.po.PqsCommunicate;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.influx.utils.InfluxDbUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.InfluxDB;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* @Description:
* @Author: wr
* @Date: 2025/3/7 10:13
*/
@Slf4j
@Service("InfluxdbCsCommunicateServiceImpl")
@AllArgsConstructor
public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
private final InfluxDbUtils influxDbUtils;
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
@Resource
private PqsCommunicateMapper pqsCommunicateMapper;
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
@Override
public List<PqsCommunicateDto> getRawDataLatest(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)
.timeDesc()
.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:
* @return: java.util.List<com.njcn.dataProcess.dto.DataVDTO>
* @Author: clam
* @Date: 2025/02/24
*/
@Override
public List<PqsCommunicateDto> getRawData(LineCountEvaluateParam lineParam) {
List<PqsCommunicateDto> result = new ArrayList<>();
List<PqsCommunicate> list = getPqsCommunicateData(lineParam);
list.forEach(item -> {
PqsCommunicateDto dto = new PqsCommunicateDto();
BeanUtils.copyProperties(item, dto);
dto.setTime(DATE_TIME_FORMATTER.format(item.getTime()));
result.add(dto);
});
return result;
}
@Override
public List<PqsCommunicateDto> getRawDataEnd(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)
.between(PqsCommunicate::getTime, lineParam.getStartTime(), lineParam.getEndTime())
.timeDesc()
.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;
}
@Override
public void insertion(PqsCommunicateDto pqsCommunicateDto) {
//根据NDID获取装置信息
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.findDevByNDid(pqsCommunicateDto.getDevId());
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
influxQueryWrapper.eq(PqsCommunicate::getDevId,po.getId()).timeDesc().limit(1);
List<PqsCommunicate> pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
//如果不存数据或者状态不一样则插入数据
if(CollectionUtils.isEmpty(pqsCommunicates) || !Objects.equals(pqsCommunicates.get(0).getType(),pqsCommunicateDto.getType())){
Map<String, String> tags = new HashMap<>();
tags.put("dev_id",po.getId());
Map<String,Object> fields = new HashMap<>();
fields.put("type",pqsCommunicateDto.getType());
fields.put("description",pqsCommunicateDto.getDescription());
long time = LocalDateTime.parse(pqsCommunicateDto.getTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
Point point = influxDbUtils.pointBuilder("pqs_communicate", time, TimeUnit.MILLISECONDS, tags, fields);
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
batchPoints.point(point);
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, Collections.singletonList(batchPoints.lineProtocol()));
}
}
public List<PqsCommunicate> getPqsCommunicateData(LineCountEvaluateParam lineParam) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
influxQueryWrapper.regular(PqsCommunicate::getDevId, lineParam.getLineId())
.select(PqsCommunicate::getTime)
.select(PqsCommunicate::getDevId)
.select(PqsCommunicate::getDescription)
.select(PqsCommunicate::getType)
.between(PqsCommunicate::getTime, lineParam.getStartTime(), lineParam.getEndTime())
.timeAsc();
return pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
}
}

View File

@@ -0,0 +1,166 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
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.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
import com.njcn.csdevice.mapper.NodeMapper;
import com.njcn.csdevice.pojo.param.NodeParam;
import com.njcn.csdevice.pojo.po.Node;
import com.njcn.csdevice.service.INodeService;
import com.njcn.db.constant.DbConstant;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.web.factory.PageFactory;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
/**
* <p>
* 服务实现类
* </p>
*
* @author cdf
* @since 2022-01-07
*/
@DS("sjzx")
@Service
@AllArgsConstructor
public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements INodeService {
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
@Override
public boolean addNode(NodeParam nodeParam) {
checkNode(nodeParam, false);
Node node = new Node();
BeanUtils.copyProperties(nodeParam, node);
node.setState(DataStateEnum.ENABLE.getCode());
this.save(node);
return true;
}
@Override
public boolean updateNode(NodeParam.NodeUpdateParam nodeParam) {
//修改最大进程时,需要判断,如果进程数减少,需要先将少的进程数下面的测点分配到其他进程下面
int count = csEquipmentDeliveryMapper.getListByNodeProcess(nodeParam.getId(),nodeParam.getMaxProcessNum());
if (count > 0) {
throw new BusinessException(AlgorithmResponseEnum.DEV_OLD_DATA);
}
checkNode(nodeParam, true);
Node node = new Node();
BeanUtils.copyProperties(nodeParam, node);
this.updateById(node);
return true;
}
@Override
public boolean delNode(String id) {
//删除前置机,如果前置机下有设备,不允许删除
int count = csEquipmentDeliveryMapper.getListByNodeProcess(id,null);
if (count > 0) {
throw new BusinessException(AlgorithmResponseEnum.DEV_EXIST_DATA);
}
return this.removeById(id);
}
@Override
public boolean updateNodeState(String id, Integer state) {
Node node = new Node();
node.setId(id);
node.setState(state);
return this.updateById(node);
}
@Override
public Page<Node> nodeList(NodeParam.NodeQueryParam nodeQueryParam) {
QueryWrapper<Node> queryWrapper = new QueryWrapper<>();
//查询参数不为空,进行条件填充
if (Objects.nonNull(nodeQueryParam)) {
if(Objects.nonNull(nodeQueryParam.getNodeGrade()) ){
queryWrapper.eq("pq_node.node_grade",nodeQueryParam.getNodeGrade());
}
if(Objects.nonNull(nodeQueryParam.getSearchState()) ){
queryWrapper.eq("pq_node.state",nodeQueryParam.getSearchState());
}
//模糊值查询
if (StrUtil.isNotBlank(nodeQueryParam.getSearchValue())) {
//仅提供名称、ip模糊查询
queryWrapper.and(param -> param.like("pq_node.name", nodeQueryParam.getSearchValue())
.or().like("pq_node.ip", nodeQueryParam.getSearchValue()));
}
//排序字段不为空
if (ObjectUtil.isAllNotEmpty(nodeQueryParam.getSortBy(), nodeQueryParam.getOrderBy())) {
queryWrapper.orderBy(true, nodeQueryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(nodeQueryParam.getSortBy()));
} else {
//没有排序参数默认根据sort字段排序没有排序字段的根据updateTime更新时间排序
queryWrapper.orderBy(true, true, "pq_node.sort");
}
}
return this.page(new Page<>(PageFactory.getPageNum(nodeQueryParam), PageFactory.getPageSize(nodeQueryParam)), queryWrapper);
}
@Override
public List<Node> nodeAllList(){
LambdaQueryWrapper<Node> nodeLambdaQueryWrapper = new LambdaQueryWrapper<>();
nodeLambdaQueryWrapper.eq(Node::getState,DataStateEnum.ENABLE.getCode()).orderByAsc(Node::getState);
return this.list(nodeLambdaQueryWrapper);
}
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public Node getNodeById(String id) {
return this.getById(id);
}
@Override
public Node getNodeByNodeName(String nodeName) {
LambdaQueryWrapper<Node> nodeLambdaQueryWrapper = new LambdaQueryWrapper<>();
nodeLambdaQueryWrapper.eq(Node::getName, nodeName)
.eq(Node::getState, DataStateEnum.ENABLE.getCode());
return this.baseMapper.selectOne(nodeLambdaQueryWrapper);
}
@Override
public Node getNodeByIp(String ip) {
LambdaQueryWrapper<Node> nodeLambdaQueryWrapper = new LambdaQueryWrapper<>();
nodeLambdaQueryWrapper.eq(Node::getIp, ip)
.eq(Node::getState, DataStateEnum.ENABLE.getCode());
return this.baseMapper.selectOne(nodeLambdaQueryWrapper);
}
/**
* 校验参数,检查是否存在相同编码的字典类型
*/
private void checkNode(NodeParam nodeParam, boolean isExcludeSelf) {
LambdaQueryWrapper<Node> nodeLambdaQueryWrapper = new LambdaQueryWrapper<>();
nodeLambdaQueryWrapper
.eq(Node::getIp, nodeParam.getIp())
.eq(Node::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (nodeParam instanceof NodeParam.NodeUpdateParam) {
nodeLambdaQueryWrapper.ne(Node::getId, ((NodeParam.NodeUpdateParam) nodeParam).getId());
}
}
int countByAccount = this.count(nodeLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(DeviceResponseEnum.NODE_IP_SAME);
}
}
}

View File

@@ -2,20 +2,26 @@ package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.IdUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
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.github.tocrhz.mqtt.publisher.MqttPublisher;
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.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.util.InfluxDbParamUtil;
import com.njcn.csharmonic.api.EventFeignClient;
@@ -50,9 +56,12 @@ 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;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -93,6 +102,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
private final MqttPublisher publisher;
private final PortableOffMainLogService portableOffMainLogService;
private final IWlRecordService wlRecordService;
private final CsLinePOService csLinePOService;
@Override
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
@@ -169,6 +180,10 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
@Transactional(rollbackFor = {Exception.class})
public void importEquipment(UploadDataParam uploadDataParam){
String lineId = uploadDataParam.getLineId();
//获取监测点信息
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsLinePO::getLineId,lineId).eq(CsLinePO::getStatus,1);
CsLinePO po = csLinePOService.getOne(queryWrapper);
String cdid = uploadDataParam.getLineId().substring(uploadDataParam.getLineId().length() - 1);
//第一步解析redcord.bin文件获取监测点序号做校验
List<MultipartFile> record = uploadDataParam.getFiles().stream().filter(
@@ -261,7 +276,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
int successcCount = 0;
portableOffMainLog.setStatus("1");
List<PortableOfflLog> portableOfflLogs = new ArrayList<>();
for(MultipartFile file : uploadDataParam.getFiles()){
//初始上传日志基本信息
@@ -275,11 +290,16 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
//默认总条数及入库数为0(防止解析的数据重复插入及上传的文件目录路径错误)
portableOfflLog.setAllCount(0);
portableOfflLog.setRealCount(0);
if(file.getOriginalFilename().contains("record.bin")){
portableOfflLog.setAllCount(1);
portableOfflLog.setState(1);
}
//开始匹配解析的文件结果入库
for(Response response : responses){
//min解析结果较为特殊所有的文件解析后只有一条结果
if(OfflineConstant.MIN.equals(response.getFilename()) && checkPrevsFolder(file.getOriginalFilename(),OfflineConstant.MIN)!=null){
if(OfflineConstant.MIN.equals(response.getFilename()) && checkPrevsFolder(file.getOriginalFilename(),OfflineConstant.MIN)!=null&&minFlag){
List<PqdData> pqdData = (List<PqdData>) response.getObj();
pqdData.forEach(temp->{
temp.setClDid(cdid);
@@ -287,6 +307,37 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
temp.setProcess(data1.get(0).getProcess()+"");
temp.setLineId(uploadDataParam.getLineId());
});
Instant instantMax = pqdData.stream().map(PqdData::getTime).max(Instant::compareTo).get();
Instant instantMin = pqdData.stream().map(PqdData::getTime).min(Instant::compareTo).get();
//插入测试项
WlRecord wlRecord = new WlRecord();
wlRecord.setId(IdUtil.fastSimpleUUID());
wlRecord.setItemName("补召");
wlRecord.setGcName("补召");
wlRecord.setDevId(csEquipmentDeliveryDTO.getId());
wlRecord.setLineId(lineId);
wlRecord.setStatisticalInterval(po.getLineInterval());
wlRecord.setPt(po.getPtRatio().intValue());
wlRecord.setCt(po.getCtRatio().intValue());
//电压等级
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(channelVol(new Float(po.getVolGrade())) + "kV","Dev_Voltage_Stand").getData();
wlRecord.setVoltageLevel(Objects.isNull(dictData)?null:dictData.getId());
//电压接线方式
wlRecord.setVolConType(getVolConType(po.getConType()));
wlRecord.setStartTime(instantMin.atZone(ZoneId.systemDefault()).toLocalDateTime());
wlRecord.setEndTime(instantMax.atZone(ZoneId.systemDefault()).toLocalDateTime());
wlRecord.setType(1);
wlRecord.setState(DataStateEnum.ENABLE.getCode());
wlRecordService.lambdaUpdate().set(WlRecord::getState,DataStateEnum.DELETED.getCode())
.eq(WlRecord::getLineId,lineId)
.eq(WlRecord::getStartTime,wlRecord.getStartTime())
.eq(WlRecord::getEndTime,wlRecord.getEndTime()).update();
wlRecordService.save(wlRecord);
//如果明确返回了state 那么当前文件解析出错
if(response.getState() != null){
portableOfflLog.setState(response.getState());
@@ -294,6 +345,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
if(pqdData != null && !pqdData.isEmpty()){
//否则正常标记为成功解析
portableOfflLog.setState(1);
portableOfflLog.setName("min文件夹");
portableOfflLog.setAllCount(pqdData.size());
portableOfflLog.setRealCount(pqdData.size());
if(minFlag){
@@ -311,17 +363,16 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
//判断当前解析的数据属于哪种结果(目前来说三种:comtrade、log、min(除外))
if(checkPrevsFolder(file.getOriginalFilename(),OfflineConstant.COMTRADE)!=null){ //cfg
//如果明确返回了state 那么当前文件解析出错
if(response.getState() != null){
portableOfflLog.setState(response.getState());
}
//由于dat文件不解析但是日志需要记载所以都设为1
TagComtradeCfg tagComtradeCfg = (TagComtradeCfg) response.getObj();
if(tagComtradeCfg != null){
//否则正常标记为成功解析
portableOfflLog.setState(1);
portableOfflLog.setAllCount(1);
portableOfflLog.setRealCount(1);
//否则正常标记为成功解析
portableOfflLog.setState(1);
portableOfflLog.setAllCount(1);
portableOfflLog.setRealCount(1);
//cfg入库
}
}
if(checkPrevsFolder(file.getOriginalFilename(),OfflineConstant.LOG)!=null){ //事件
//如果明确返回了state 那么当前文件解析出错
@@ -378,7 +429,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
for (Response res : cfgResponse) {
String cfg = res.getFilename();
String dat = cfg.substring(0,cfg.lastIndexOf("."))+OfflineConstant.DAT;
String sharPath = OfflineConstant.COMTRADE+"/"+csEquipmentDeliveryDTO.getMac()+"/";
String sharPath = OfflineConstant.COMTRADE+"/"+csEquipmentDeliveryDTO.getMac().replace(":", "-")+"/";
TagComtradeCfg sing = (TagComtradeCfg) res.getObj();
//如果匹配上则需要将当前cfg文件及对应的dat文件上传到comtrade文件夹中
if (sing!= null && sing.getTimeStart()!= null && sing.getTimeTrigger().compareTo(csEventPO.getStartTime())<=0
@@ -471,7 +522,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
this.baseMapper.insert(portableOfflLog);
successcCount++;
}
portableOfflLogs.add(portableOfflLog);
}
portableOffMainLog.setEndTime(LocalDateTime.now());
portableOffMainLog.setSuccessCount(successcCount);
@@ -517,4 +568,40 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
}
return s1;
}
/**
* 处理电压
* @param vol
* @return
*/
public String channelVol(Float vol) {
BigDecimal value = new BigDecimal(vol);
BigDecimal noZeros = value.stripTrailingZeros();
return noZeros.toPlainString();
}
// 0-星型, 1-角型, 2-V型
// star-星型、Star_Triangle-星三角、Open_Delta-开口三角
public String getVolConType(Integer volConType) {
String result = null;
String dictDataCode = null;
switch (volConType) {
case 0:
dictDataCode = "star";
break;
case 1:
dictDataCode = "Star_Triangle";
break;
case 2:
dictDataCode = "Open_Delta";
break;
default:
break;
}
if (!Objects.isNull(dictDataCode)) {
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(dictDataCode,"Dev_Connect").getData();
result = dictData.getId();
}
return Objects.isNull(result)?null:result;
}
}

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