94 Commits

Author SHA1 Message Date
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
hzj
ce861e1804 bug修改 2024-11-01 14:41:46 +08:00
xy
35d44dcc08 代码优化
1.公共方法提取
2.装置类型判断
2024-11-01 11:20:09 +08:00
xy
c3d87eca34 bug调整 2024-10-31 15:44:14 +08:00
xy
86c6c95777 bug调整 2024-10-31 14:07:52 +08:00
xy
f9d696faad bug调整 2024-10-31 13:42:53 +08:00
xy
c325301a8f bug调整 2024-10-30 16:09:20 +08:00
hzj
014370062a 波形下载接口开发 2024-10-30 11:28:41 +08:00
hzj
ada65fd40d 离线数据上传bug 2024-10-29 16:27:40 +08:00
hzj
a940d3961a 离线数据上传bug 2024-10-29 16:01:04 +08:00
hzj
4b7a60190c 历史趋势图添加二次值 2024-10-24 20:00:55 +08:00
xy
c0be7629dd 数据显示优化 2024-10-24 16:38:41 +08:00
hzj
5f82f65b8f 趋势图bug修改 2024-10-23 20:10:00 +08:00
xy
4e0b4b6b90 添加文件时间 2024-10-23 18:43:22 +08:00
hzj
ca9193b861 修改报表 2024-10-23 10:25:19 +08:00
hzj
469a4ba63e 组态bug修改 2024-10-23 08:48:33 +08:00
hzj
4316e72521 组态bug修改 2024-10-22 20:45:19 +08:00
hzj
f942be74f1 测试项限值生成 2024-10-22 18:11:34 +08:00
xy
b750064b16 微调 2024-10-22 10:39:55 +08:00
xy
b7c9cd2ee0 补召优化 2024-10-21 19:59:13 +08:00
hzj
6cca1cc74d 修改bug 2024-10-21 15:33:31 +08:00
hzj
a83ab8b141 修改bug 2024-10-21 11:40:33 +08:00
hzj
edc2453da2 修改bug 2024-10-17 13:53:06 +08:00
xy
cbc301da5f pom文件提交 2024-10-17 13:45:15 +08:00
xy
4142de1fcf 设备树调整 2024-10-17 10:10:23 +08:00
xy
78b9a98ab8 模板数据、设备信息初始化至内存 2024-10-16 18:53:19 +08:00
hzj
5169669b2b Merge remote-tracking branch 'origin/master' 2024-10-16 10:51:26 +08:00
hzj
10e0e96b65 修改bug 2024-10-16 10:50:58 +08:00
xy
cd35e67007 设备树显示调整 2024-10-16 10:32:40 +08:00
xy
eb7a1d9beb 优化 2024-10-15 18:30:27 +08:00
hzj
3059f5ac75 修改bug 2024-10-15 15:04:28 +08:00
hzj
346afef6d0 修改bug 2024-10-15 14:24:05 +08:00
hzj
2cf47ec3b3 修改bug 2024-10-15 12:30:59 +08:00
xy
83199f07b6 无线系统补召功能调整 2024-10-15 11:12:05 +08:00
hzj
8295801f16 修改bug 2024-10-11 19:19:57 +08:00
xy
306b426573 无线系统实时数据功能 2024-10-11 18:17:38 +08:00
hzj
3a60a05ea2 修改告警展示页面 2024-10-10 10:40:59 +08:00
xy
86108004d5 解决启动报错 2024-10-09 16:06:20 +08:00
xy
5ef232a485 模板适配调整 2024-10-09 14:57:29 +08:00
05112b5262 1.数据方案修改 2024-10-09 11:38:02 +08:00
hzj
2ca4ee702b 添加波形路径用于判断是否展示波形 2024-10-09 09:28:17 +08:00
xy
c95c1271c2 模板调整适配 2024-10-09 09:25:41 +08:00
hzj
105a5314cb 离线数据上传 2024-10-08 20:51:58 +08:00
121 changed files with 4226 additions and 802 deletions

View File

@@ -112,7 +112,7 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>pqs-influx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>

View File

@@ -6,6 +6,7 @@ import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@@ -18,7 +19,6 @@ import java.util.List;
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csline", fallbackFactory = CsLineClientFallbackFactory.class,contextId = "csline")
public interface CsLineFeignClient {
@PostMapping("/queryLineById")
HttpResult<List<CsLinePO>> queryLineById(@RequestParam("ids") List<String> ids );
@@ -36,4 +36,13 @@ public interface CsLineFeignClient {
@PostMapping("/updateLine")
HttpResult<String> updateLine(@RequestBody CsLineParam csLineParam);
@PostMapping("/updateIds")
HttpResult<Boolean> updateIds(@RequestBody @Validated CsLineParam csLineParam);
@PostMapping("/getById")
HttpResult<CsLinePO> getById(@RequestParam("lineId") String lineId);
@PostMapping("/getLinesByDevList")
HttpResult<List<CsLinePO>> getLinesByDevList(@RequestParam("ids") List<String> ids);
}

View File

@@ -5,7 +5,6 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.DataArrayFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.param.DataArrayParam;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@@ -22,13 +21,14 @@ import java.util.List;
public interface DataArrayFeignClient {
@PostMapping("/getArrayBySet")
HttpResult<List<CsDataArray>> getArrayBySet(@RequestBody List<CsDataSet> setList);
HttpResult<List<CsDataArray>> getArrayBySet(@RequestParam("dataSet") String dataSet);
@PostMapping("/getDataArray")
HttpResult<List<DataArrayTreeVO>> getDataArray(@RequestBody List<String> dataSetList);
@PostMapping("/getDataArrayById")
HttpResult<List<CsDataArray>> getDataArrayById(@RequestParam("pid") String pid, @RequestParam("name") String name);
@PostMapping("/getDataArrayByIds")
HttpResult<List<CsDataArray>> getDataArrayByIds(@RequestParam("ids") List<String> ids);

View File

@@ -1,10 +1,17 @@
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;
@@ -31,5 +38,13 @@ public interface DataSetFeignClient {
@PostMapping("/getDataSetBySetIds")
HttpResult<List<CsDataSet>> getDataSetBySetIds(@RequestBody List<String> lineIds);
@PostMapping("/getBaseDataSet")
HttpResult<CsDataSet> getBaseDataSet(@RequestParam("modelId") String modelId,@RequestParam("clDev") Integer clDev);
@PostMapping("/getHarmonicDataSet")
HttpResult<CsDataSet> getHarmonicDataSet(@RequestParam("modelId") String modelId,@RequestParam("clDev") Integer clDev,@RequestParam("target") Integer target);
@PostMapping("/getDataSetByIdx")
HttpResult<CsDataSet> getDataSetByIdx(@RequestParam("modelId") String modelId,@RequestParam("idx") Integer idx);
}

View File

@@ -1,16 +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.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.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -58,4 +53,7 @@ public interface EquipmentFeignClient {
@PostMapping("/getAll")
HttpResult<List<CsEquipmentDeliveryPO>> getAll();
@PostMapping("/judgeDevModel")
HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid);
}

View File

@@ -5,10 +5,13 @@ 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;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -41,4 +44,14 @@ public interface WlRecordFeignClient {
@PostMapping("/updateTestRecord")
HttpResult<Boolean> updateTestRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record);
@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);
}

View File

@@ -28,7 +28,6 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsLineFeignClient() {
@Override
public HttpResult<List<CsLinePO>> queryLineById(List<String> ids) {
log.error("{}异常,降级处理,异常为:{}","查询监测点详情异常",cause.toString());
@@ -63,6 +62,24 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
log.error("{}异常,降级处理,异常为:{}","更新监测点信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> updateIds(CsLineParam csLineParam) {
log.error("{}异常,降级处理,异常为:{}","修改监测点模板id和数据集id",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsLinePO> getById(String lineId) {
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

@@ -6,7 +6,6 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.DataArrayFeignClient;
import com.njcn.csdevice.pojo.param.DataArrayParam;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
import feign.hystrix.FallbackFactory;
@@ -36,7 +35,7 @@ public class DataArrayFeignClientFallbackFactory implements FallbackFactory<Data
Enum<?> finalExceptionEnum = exceptionEnum;
return new DataArrayFeignClient() {
@Override
public HttpResult<List<CsDataArray>> getArrayBySet(List<CsDataSet> setList) {
public HttpResult<List<CsDataArray>> getArrayBySet(String dataSet) {
log.error("{}异常,降级处理,异常为:{}","根据数据集获取详细数据失败",cause.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -56,6 +56,24 @@ public class DataSetFeignClientFallbackFactory implements FallbackFactory<DataSe
log.error("{}异常,降级处理,异常为:{}","根据数据集ids获取数据集",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsDataSet> getBaseDataSet(String modelId, Integer clDev) {
log.error("{}异常,降级处理,异常为:{}","获取实时数据-基础数据集",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsDataSet> getHarmonicDataSet(String modelId, Integer clDev, Integer target) {
log.error("{}异常,降级处理,异常为:{}","获取实时数据-谐波数据集",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsDataSet> getDataSetByIdx(String modelId, Integer idx) {
log.error("{}异常,降级处理,异常为:{}","根据idx获取数据集数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -77,6 +77,12 @@ public class EquipmentFeignClientFallbackFactory implements FallbackFactory<Equi
log.error("{}异常,降级处理,异常为:{}","获取所有装置",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> judgeDevModel(String nDid) {
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;
@@ -51,6 +52,24 @@ public class WlRecordClientFallbackFactory implements FallbackFactory<WlRecordFe
log.error("{}异常,降级处理,异常为:{}","修改测试项",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public void dayDealNoEndTimeEvent(String date) {
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);
}
};
}
}

View File

@@ -48,8 +48,16 @@ public interface DataParam {
String portableDev = "便携式设备";
String PORTABLE_SYSTEM = "便携式系统";
String WIRELESS_PROJECT = "无线项目";
String WIRELESS_PROJECT_ID = "WIRELESS_PROJECT_ID";
String governmentDev = "治理设备";
String GOVERNANCE_SYSTEM = "治理系统";
String EvtParamPhase = "Evt_Param_Phase";
String EvtParamDepth = "Evt_Param_VVaDepth";

View File

@@ -47,6 +47,7 @@ public enum AlgorithmResponseEnum {
FILE_BUSY("A00516","正在进行其他文件操作,请稍后重试"),
RECORD_FILE_LOST("A00516","record.bin文件缺失请检查上传文件夹"),
LINE_NUM_MISMATCH("A00516","上传文件的监测点序号和选择的监测点不匹配,请检查"),
DEV_OFFLINE("A00516","装置未连接MQTT服务器"),
;

View File

@@ -0,0 +1,118 @@
package com.njcn.csdevice.pojo.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 初始化模板实体
* @author xy
*/
@Data
public class CsDevModelDto implements Serializable {
@ApiModelProperty("模板id")
private String id;
@ApiModelProperty("版本号")
private String versionNo;
@TableField("版本日期")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date versionDate;
@ApiModelProperty("模板名称")
private String name;
@ApiModelProperty("设备类型名称")
private String devTypeName;
@ApiModelProperty("模板存储路径")
private String filePath;
@ApiModelProperty("模板类型(0:治理类型 1:电能质量类型)")
private Integer type;
@ApiModelProperty("数据集")
private List<CsDataSet> dataSets;
@Data
public static class CsDataSet implements Serializable {
@ApiModelProperty("数据集id")
private String id;
@ApiModelProperty("模板id")
private String pid;
@ApiModelProperty("数据集名称")
private String name;
@ApiModelProperty("数据集别名")
private String anotherName;
@ApiModelProperty("数据集编号")
private Integer idx;
@ApiModelProperty("数据集类型")
private String dataType;
@ApiModelProperty("统计周期")
private Integer period;
@ApiModelProperty("是否存储 0:不存储 1:存储")
private Integer storeFlag;
@ApiModelProperty("逻辑子设备")
private Integer clDev;
@ApiModelProperty("数据集类型(0:主设备 1:子模块 2:监测设备)")
private Integer type;
@ApiModelProperty("数据类型(Primary:一次值 Secondary:二次值)")
private String dataLevel;
@ApiModelProperty("数据类型")
private List<CsDataArray> dataArrays;
}
@Data
public static class CsDataArray implements Serializable {
@ApiModelProperty("指标id")
private String id;
@ApiModelProperty("数据集id")
private String pid;
@ApiModelProperty("字典表id")
private String dataId;
@ApiModelProperty("数据集名称")
private String name;
@ApiModelProperty("数据集别名")
private String anotherName;
@ApiModelProperty("数据集编号")
private Integer idx;
@ApiModelProperty("数据统计方法(max、min、avg、cp95)")
private String statMethod;
@ApiModelProperty("数据类型")
private String dataType;
@ApiModelProperty("相别")
private String phase;
@ApiModelProperty("排序")
private Integer sort;
}
}

View File

@@ -1,9 +1,12 @@
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;
/**
*
@@ -36,8 +39,9 @@ public class CsDevModelAddParm {
/**
* 版本日期
*/
@ApiModelProperty(value = "版本日期")
private String time;
@TableField(value = "version_date")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date versionDate;
/**
* 装置模板文件路径

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,10 @@
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;
/**
*
@@ -34,6 +32,7 @@ public class CsEquipmentDeliveryAddParm{
*/
@ApiModelProperty(value="网络设备ID")
@NotBlank(message="网络设备ID不能为空")
@Pattern(regexp = "^[A-Za-z0-9]{6,32}$", message = "网络设备ID只可为数字或字母,长度至少为6位")
private String ndid;
/**
@@ -125,4 +124,7 @@ public class CsEquipmentDeliveryAddParm{
@ApiModelProperty(value="模块个数")
private Integer modelNumber;
@ApiModelProperty(value="排序")
private Integer sort;
}

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,10 @@ public class CsEquipmentDeliveryAuditParm {
*/
@ApiModelProperty(value="模块个数")
private Integer modelNumber;
@ApiModelProperty(value="装置使用状态(0:停用 1:启用)")
private Integer usageStatus;
@ApiModelProperty(value="排序")
private Integer sort;
}

View File

@@ -38,4 +38,19 @@ public class CsLineParam extends BaseEntity {
*/
private Integer conType;
/**
* 模板id
*/
private String modelId;
/**
* 数据集id
*/
private String dataSetId;
/**
* 统计间隔
*/
private Integer lineInterval;
}

View File

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

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

@@ -108,4 +108,16 @@ 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;
}

View File

@@ -95,4 +95,10 @@ public class CsLinePO extends BaseEntity {
@TableField(value = "device_id")
private String deviceId;
/**
* 监测点统计间隔
*/
@TableField(value = "line_interval")
private Integer lineInterval;
}

View File

@@ -0,0 +1,72 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2024/10/15 10:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@NoArgsConstructor
@TableName(value = "portable_off_main_log")
public class PortableOffMainLog extends BaseEntity {
/**
* 批次id
*/
@TableId(value = "id", type = IdType.INPUT)
private String id;
/**
* 导入开始时间
*/
@TableField(value = "start_time")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private LocalDateTime startTime;
/**
* 工程名称
*/
@TableField(value = "project_name")
private String projectName;
/**
* 导入结束时间
*/
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@TableField(value = "end_time")
private LocalDateTime endTime;
/**
* 成功解析数
*/
@TableField(value = "success_count")
private Integer successCount;
/**
* 状态(0删除 1正常)
*/
@TableField(value = "status")
private String status;
@TableField(exist = false)
private List<PortableOfflLog> portableOfflLogList;
}

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Getter;
@@ -21,6 +22,8 @@ public class PortableOfflLog extends BaseEntity {
private static final long serialVersionUID = 1L;
private String logsIndex;
@TableField( value = "log_main_id")
private String logMainId;
/**
* 文件名称
@@ -38,7 +41,7 @@ public class PortableOfflLog extends BaseEntity {
private String dataPath;
/**
* 0-解析 1-解析成功 2-解析失败 3-文件不存在
* 0-无需解析解析 1-解析成功 2-解析失败 3-文件不存在
*/
private Integer state;

View File

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

View File

@@ -83,4 +83,9 @@ public class CsEquipmentDeliveryVO extends BaseEntity {
@ApiModelProperty(value="设备当前流程状态")
private Integer process ;
@ApiModelProperty(value="装置使用状态(0:停用 1:启用)")
private Integer usageStatus ;
private Integer sort;
}

View File

@@ -45,6 +45,15 @@ public class CsLedgerVO implements Serializable {
@ApiModelProperty(name = "nDid",value = "nDid")
private String nDId;
@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 = "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;
@@ -53,4 +60,7 @@ public class DataGroupEventVO {
@ApiModelProperty("暂降幅值")
private Float featureAmplitude;
@ApiModelProperty("波形路径")
private String wavePath;
}

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;
@@ -66,6 +72,9 @@ public class RecordVo {
@ApiModelProperty("电压接线方式")
private String volConType;
@ApiModelProperty("基础数据集合ID")
private List<String> list;
@Data
public static class RecordItemVo{

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

@@ -83,5 +83,45 @@ public class CsDataSetController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getBaseDataSet")
@ApiOperation("获取实时数据-基础数据集")
@ApiImplicitParams({
@ApiImplicitParam(name = "modelId", value = "模板id", required = true),
@ApiImplicitParam(name = "clDev", value = "逻辑子设备标识", required = true)
})
public HttpResult<CsDataSet> getBaseDataSet(@RequestParam("modelId") String modelId,@RequestParam("clDev") Integer clDev){
String methodDescribe = getMethodDescribe("getBaseDataSet");
CsDataSet dataSet = csDataSetService.getBaseDataSet(modelId,clDev);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dataSet, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getHarmonicDataSet")
@ApiOperation("获取实时数据-谐波数据集")
@ApiImplicitParams({
@ApiImplicitParam(name = "modelId", value = "模板id", required = true),
@ApiImplicitParam(name = "clDev", value = "逻辑子设备标识", required = true),
@ApiImplicitParam(name = "target", value = "指标序号", required = true),
})
public HttpResult<CsDataSet> getHarmonicDataSet(@RequestParam("modelId") String modelId,@RequestParam("clDev") Integer clDev,@RequestParam("target") Integer target){
String methodDescribe = getMethodDescribe("getHarmonicDataSet");
CsDataSet dataSet = csDataSetService.getHarmonicDataSet(modelId,clDev,target);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dataSet, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDataSetByIdx")
@ApiOperation("根据idx获取数据集数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "modelId", value = "模板id", required = true),
@ApiImplicitParam(name = "idx", value = "数据集序号", required = true)
})
public HttpResult<CsDataSet> getDataSetByIdx(@RequestParam("modelId") String modelId,@RequestParam("idx") Integer idx){
String methodDescribe = getMethodDescribe("getDataSetByIdx");
CsDataSet csDataSet = csDataSetService.getDataSetByIdx(modelId,idx);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDataSet, methodDescribe);
}
}

View File

@@ -56,9 +56,10 @@ public class CsLogController extends BaseController {
@ApiOperation("查询日志")
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
public HttpResult<IPage<CsLogsPO>> queryLog(@RequestBody BaseParam baseParam){
IPage<CsLogsPO> list = csLogsPOService.queryPage(baseParam);
String methodDescribe = getMethodDescribe("queryLog");
IPage<CsLogsPO> list = csLogsPOService.queryPage(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -1,17 +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;
@@ -24,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
@@ -38,6 +36,7 @@ public class DeviceFtpController extends BaseController {
private final DeviceFtpService deviceFtpService;
private final RedisUtil redisUtil;
private final MqttPublisher publisher;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/askDeviceRootPath")
@@ -61,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);
}
@@ -77,16 +73,22 @@ 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");
String result = deviceFtpService.downloadFile(nDid,name,size,fileCheck);
redisUtil.delete("downloadFilePath:"+name);
redisUtil.delete("fileCheck"+name);
redisUtil.delete("fileDowning:"+nDid);
if (Objects.isNull(result)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
redisUtil.saveByKeyWithExpire("fileDownUserId"+nDid+name,RequestUtil.getUserIndex(),600L);
deviceFtpService.downloadFile(nDid,name,size,fileCheck);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "文件下载中,请稍等");
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDownloadFilePath")
@ApiOperation("获取文件下载路径")
@ApiImplicitParams({
@ApiImplicitParam(name = "nDid", value = "nDid", required = true),
@ApiImplicitParam(name = "name", value = "文件路径名", required = true)
})
public HttpResult<String> getDownloadFilePath(@RequestParam("nDid") String nDid, @RequestParam("name") String name){
String methodDescribe = getMethodDescribe("getDownloadFilePath");
String result = deviceFtpService.getDownloadFilePath(nDid,name);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)

View File

@@ -23,6 +23,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 +33,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,7 +41,9 @@ 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;
@@ -61,15 +67,17 @@ public class EquipmentDeliveryController extends BaseController {
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,7 +85,7 @@ public class EquipmentDeliveryController extends BaseController {
mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid());
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@@ -99,6 +107,14 @@ 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);
}
@@ -166,6 +182,8 @@ public class EquipmentDeliveryController extends BaseController {
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){
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);
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
@@ -220,7 +238,13 @@ public class EquipmentDeliveryController extends BaseController {
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("设备模板", "设备模板");
@@ -306,4 +330,13 @@ public class EquipmentDeliveryController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/judgeDevModel")
@ApiOperation("判断设备型号")
public HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid){
String methodDescribe = getMethodDescribe("judgeDevModel");
boolean result = csEquipmentDeliveryService.judgeDevModel(nDid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -9,10 +9,12 @@ 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.WlRecordTemplete;
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
import com.njcn.csdevice.pojo.po.PortableOfflLog;
import com.njcn.csdevice.service.IPortableOfflLogService;
import com.njcn.csdevice.utils.ExcelStyleUtil;
import com.njcn.csdevice.param.UploadDataParam;
import com.njcn.minioss.config.MinIossProperties;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.poi.util.PoiUtil;
@@ -55,7 +57,7 @@ public class PortableOfflLogController extends BaseController {
private final DicDataFeignClient dicDataFeignClient;
private final FileStorageUtil fileStorageUtil;
private final MinIossProperties minIossProperties;
@ResponseBody
@ApiOperation("导出设备基础数据模板")
@GetMapping(value = "getExcelTemplate")
@@ -80,6 +82,15 @@ public class PortableOfflLogController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryMainLogPage")
@ApiOperation("便携式设备解析日志")
public HttpResult<Page<PortableOffMainLog>> queryMainLogPage(@RequestBody BaseParam baseParam){
String methodDescribe = getMethodDescribe("queryMainLogPage");
Page<PortableOffMainLog> list = iPortableOfflLogService.queryMainLogPage(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("离线数据导入")
@PostMapping(value = "importEquipment")
@@ -110,7 +121,7 @@ public class PortableOfflLogController extends BaseController {
List<MultipartFile> excelreport = null;
try {
excelreport = fileStorageUtil.getAllFile("excelreport", path);
excelreport = fileStorageUtil.getAllFile(minIossProperties.getBucket(), path);
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@@ -67,6 +67,15 @@ public class CsLedgerController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getztProjectTree")
@ApiOperation("三层设备树(项目层根节点为治理系统和便携式系统组态)")
public HttpResult<List<CsLedgerVO>> getztProjectTree(){
String methodDescribe = getMethodDescribe("getProjectTree");
List<CsLedgerVO> list = csLedgerService.getztProjectTree();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add")
@ApiOperation("新增台账信息")

View File

@@ -1,10 +1,12 @@
package com.njcn.csdevice.controller.line;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.mapper.CsLinePOMapper;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
@@ -41,6 +43,7 @@ public class CslineController extends BaseController {
private final CsLinePOService csLinePOService;
private final OverlimitMapper overlimitMapper;
private final CsLinePOMapper csLinePOMapper;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLineById")
@@ -121,4 +124,47 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateIds")
@ApiOperation("修改监测点模板id和数据集id")
@ApiImplicitParam(name = "csLineParam", value = "监测点信息", required = true)
@ApiIgnore
public HttpResult<Boolean> updateIds(@RequestBody @Validated CsLineParam csLineParam) {
String methodDescribe = getMethodDescribe("updateIds");
csLinePOService.updateIds(csLineParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getById")
@ApiOperation("根据监测点id获取监测点详情")
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true)
public HttpResult<CsLinePO> getById(@RequestParam String lineId) {
String methodDescribe = getMethodDescribe("getById");
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsLinePO::getLineId,lineId).eq(CsLinePO::getStatus,1);
CsLinePO po = csLinePOService.getOne(queryWrapper);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getOverLimitData")
@ApiOperation("根据监测点id获取国标限值")
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
public HttpResult<Overlimit> getOverLimitData(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getOverLimitData");
Overlimit result = overlimitMapper.selectById(id);
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);
}
}

View File

@@ -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);
}
/**
@@ -203,9 +244,21 @@ public class WlRecordController extends BaseController {
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/dayDealNoEndTimeEvent")
@ApiOperation("每日处理没有结束时间的测试基础数据")
public void dayDealNoEndTimeEvent() {
public void dayDealNoEndTimeEvent(@RequestParam("date") String date) {
String methodDescribe = getMethodDescribe("dayDealNoEndTimeEvent");
wlRecordService.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,28 @@
package com.njcn.csdevice.init;
import com.njcn.csdevice.service.CsDevModelService;
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
/**
* 项目初始化缓存设备池,后续从缓存中获取设备数据
* @author xy
*/
@Slf4j
@Component
@AllArgsConstructor
public class InitData implements CommandLineRunner {
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final CsDevModelService csDevModelService;
@Override
public void run(String... args) {
csEquipmentDeliveryService.refreshDeviceDataCache();
csDevModelService.refreshDevModelCache();
}
}

View File

@@ -1,8 +1,10 @@
package com.njcn.csdevice.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import org.apache.ibatis.annotations.Mapper;
/**
@@ -13,6 +15,8 @@ import com.njcn.device.biz.pojo.po.Overlimit;
* @author cdf
* @since 2022-01-04
*/
@DS("sjzx")
@Mapper
public interface OverlimitMapper extends BaseMapper<Overlimit> {
}

View File

@@ -0,0 +1,15 @@
package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
/**
*
* Description:
* Date: 2024/10/15 10:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PortableOffMainLogMapper extends BaseMapper<PortableOffMainLog> {
}

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

@@ -105,6 +105,8 @@
t0.ndid = #{param.id}
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

@@ -12,7 +12,9 @@
from
cs_data_set
where
pid = #{modelId} and cl_dev = #{clDev}
pid = #{modelId}
and cl_dev = #{clDev}
and data_type in ('Stat',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

@@ -0,0 +1,9 @@
<?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.PortableOffMainLogMapper">
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, start_time, project_name, end_time, success_count, create_by, create_time, update_by,
update_time
</sql>
</mapper>

View File

@@ -64,6 +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 desc
</select>
<select id="getAll" resultType="com.njcn.csdevice.pojo.vo.CsLedgerVO">
@@ -92,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

@@ -20,6 +20,12 @@ import com.njcn.csdevice.pojo.vo.CsDevModelPageVO;
*/
public interface CsDevModelService extends IService<CsDevModelPO>{
/**
* 初始化缓存模板信息
* 想缓存模板,发现数据量太大,先按照之前的逻辑处理
*/
void refreshDevModelCache();
/**
* @Description: addDevModel
* @Param: [csDevModelAddParm]

View File

@@ -27,6 +27,11 @@ import java.util.List;
*/
public interface CsEquipmentDeliveryService extends IService<CsEquipmentDeliveryPO>{
/**
* 初始化缓存设备池
*/
void refreshDeviceDataCache();
/**
* @Description: save
* @Param: [csEquipmentDeliveryAddParm]
@@ -34,7 +39,7 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
* @Author: clam
* @Date: 2023/3/31
*/
Boolean save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm);
CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm);
/**
* @Description: AuditEquipmentDelivery
* @Param: [id]
@@ -123,4 +128,9 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
* @return
*/
List<CsEquipmentDeliveryPO> getAll();
/**
* 判断设备型号
*/
boolean judgeDevModel(String nDid);
}

View File

@@ -40,4 +40,11 @@ public interface CsLinePOService extends IService<CsLinePO>{
*/
void updateLine(CsLineParam csLineParam);
/**
* 修改监测点的数据集id和模板id
* @param csLineParam
*/
void updateIds(CsLineParam csLineParam);
List<CsLinePO> getLinesByDevList(List<String> list);
}

View File

@@ -10,7 +10,9 @@ public interface DeviceFtpService {
List<MakeUpVo> askDeviceFileOrDir(String nDid, String name, String type);
String downloadFile(String nDid, String name, Integer size, String fileCheck);
void downloadFile(String nDid, String name, Integer size, String fileCheck);
String getDownloadFilePath(String nDid, String name);
boolean createFile(String nDid, String path);

View File

@@ -50,4 +50,9 @@ public interface ICsDataArrayService extends IService<CsDataArray> {
* @return
*/
List<CsDataArray> findListByParam(DataArrayParam param);
/**
* 根据数据集id获取指标数据
*/
List<CsDataArray> getDataArrayByDataSetIds(List<String> dataSetIds);
}

View File

@@ -52,4 +52,21 @@ public interface ICsDataSetService extends IService<CsDataSet> {
* @return
*/
List<CsDataSet> getDataSetBySetIds(List<String> setIds);
CsDataSet getBaseDataSet(String modelId,Integer clDev);
CsDataSet getHarmonicDataSet(String modelId,Integer clDev,Integer target);
/**
* 根据模板和idx获取数据集数据
* @param modelId
* @param idx
* @return
*/
CsDataSet getDataSetByIdx(String modelId, Integer idx);
/**
* 根据模板id获取所有数据集
*/
List<CsDataSet> getDataSetByModelId(List<String> modelList);
}

View File

@@ -74,4 +74,6 @@ public interface ICsLedgerService extends IService<CsLedger> {
List<CsLedger> queryLine(LineParamDTO lineParamdto);
DevDetailDTO queryDevDetail(String devId);
List<CsLedgerVO> getztProjectTree();
}

View File

@@ -2,6 +2,7 @@ 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.po.PortableOffMainLog;
import com.njcn.csdevice.pojo.po.PortableOfflLog;
import com.njcn.csdevice.param.UploadDataParam;
import com.njcn.web.pojo.param.BaseParam;
@@ -19,4 +20,6 @@ public interface IPortableOfflLogService extends IService<PortableOfflLog> {
Page<PortableOfflLog> queryPage(BaseParam baseParam);
void importEquipment(UploadDataParam uploadDataParam);
Page<PortableOffMainLog> queryMainLogPage(BaseParam baseParam);
}

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();
void dayDealNoEndTimeEvent(String date);
List<WlRecord> getWlAssByWlId(String wlId);
void deleteItem(String id);
}

View File

@@ -0,0 +1,21 @@
package com.njcn.csdevice.service;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.njcn.device.biz.pojo.po.Overlimit;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.service.impl.OverlimitService;
/**
*
* Description:
* Date: 2024/10/22 14:14【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@DS("sjzx")
public class OverlimitServiceImpl extends ServiceImpl<OverlimitMapper, Overlimit> implements OverlimitService{
}

View File

@@ -0,0 +1,16 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2024/10/15 10:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PortableOffMainLogService extends IService<PortableOffMainLog>{
}

View File

@@ -6,6 +6,7 @@ import com.njcn.csdevice.mapper.CsDataArrayMapper;
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
import com.njcn.csdevice.pojo.param.DataArrayParam;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerDetailVO;
import com.njcn.csdevice.service.ICsDataArrayService;
@@ -174,4 +175,11 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
public List<CsDataArray> findListByParam(DataArrayParam param) {
return this.baseMapper.findListByParam(param);
}
@Override
public List<CsDataArray> getDataArrayByDataSetIds(List<String> dataSetIds) {
return this.lambdaQuery()
.in(CsDataArray::getPid,dataSetIds)
.list();
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.mapper.CsDataSetMapper;
import com.njcn.csdevice.pojo.po.CsDataSet;
@@ -8,7 +9,7 @@ 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;
/**
@@ -24,12 +25,22 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
@Override
public List<CsDataSet> findDataSetByModelId(String modelId, Integer clDev) {
return this.lambdaQuery().eq(CsDataSet::getPid,modelId).eq(CsDataSet::getClDev,clDev).list();
return this.lambdaQuery()
.eq(CsDataSet::getPid,modelId)
.eq(CsDataSet::getClDev,clDev)
.and(i->i.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
.list();
}
@Override
public List<CsDataSet> findDataSetByModelId(String modelId) {
return this.lambdaQuery().eq(CsDataSet::getPid,modelId).in(CsDataSet::getType, Arrays.asList(0,2)).orderByAsc(CsDataSet::getType,CsDataSet::getClDev).list();
return this.lambdaQuery()
.eq(CsDataSet::getPid,modelId)
.in(CsDataSet::getType, Arrays.asList(0,2))
.eq(CsDataSet::getStoreFlag,1)
.and(i->i.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
.orderByAsc(CsDataSet::getIdx)
.list();
}
@Override
@@ -47,4 +58,46 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
return this.lambdaQuery().in(CsDataSet::getId,setIds).list();
}
@Override
public CsDataSet getBaseDataSet(String modelId, Integer clDev) {
List<CsDataSet> list = this.lambdaQuery()
.eq(CsDataSet::getPid,modelId)
.eq(CsDataSet::getClDev,clDev)
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType))
.list();
return list.stream().min(Comparator.comparingInt(CsDataSet::getIdx)).get();
}
@Override
public CsDataSet getHarmonicDataSet(String modelId, Integer clDev,Integer target) {
LambdaQueryWrapper<CsDataSet> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsDataSet::getPid,modelId)
.eq(CsDataSet::getClDev,clDev)
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType));
//谐波电压含有率
if (target == 0) {
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmV$0".concat(clDev.toString()));
} else if (target == 1) {
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmI$0".concat(clDev.toString()));
} else if (target == 2) {
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$InHarmV$0".concat(clDev.toString()));
}
return this.baseMapper.selectOne(wrapper);
}
@Override
public CsDataSet getDataSetByIdx(String modelId, Integer idx) {
return this.lambdaQuery()
.eq(CsDataSet::getPid,modelId)
.in(CsDataSet::getIdx, idx)
.one();
}
@Override
public List<CsDataSet> getDataSetByModelId(List<String> modelList) {
return this.lambdaQuery()
.in(CsDataSet::getPid,modelList)
.list();
}
}

View File

@@ -4,6 +4,7 @@ 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.mapper.CsDevModelMapper;
import com.njcn.csdevice.pojo.param.CsDevModelAddParm;
import com.njcn.csdevice.pojo.param.CsDevModelAuditParm;
@@ -12,11 +13,20 @@ import com.njcn.csdevice.pojo.param.CsDevModelQueryParm;
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.utils.RedisUtil;
import com.njcn.system.api.DictTreeFeignClient;
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.Objects;
/**
*
@@ -27,16 +37,78 @@ import java.sql.Date;
* @author clam
* @version V1.0.0
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevModelPO> implements CsDevModelService{
private final ICsDataSetService csDataSetService;
private final ICsDataArrayService csDataArrayService;
private final RedisUtil redisUtil;
private final DictTreeFeignClient dictTreeFeignClient;
@Override
public void refreshDevModelCache() {
// List<CsDevModelDto> csDevModelDtoList = new ArrayList<>();
// List<CsDevModelDto.CsDataSet> csDataSetList = new ArrayList<>();
// List<CsDevModelDto.CsDataArray> csDataArrayList = new ArrayList<>();
// //获取系统所有模板
// LambdaQueryWrapper<CsDevModelPO> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(CsDevModelPO::getStatus,1);
// List<CsDevModelPO> list = this.list(queryWrapper);
// //根据模板ids获取数据集
// if (CollUtil.isNotEmpty(list)) {
// List<String> modelIds = list.stream().map(CsDevModelPO::getId).collect(Collectors.toList());
// List<CsDataSet> csDataSets = csDataSetService.getDataSetByModelId(modelIds);
// //根据数据集获取具体指标
// List<String> dataSetList = csDataSets.stream().map(CsDataSet::getId).collect(Collectors.toList());
// List<CsDataArray> csDataArrays = csDataArrayService.getDataArrayByDataSetIds(dataSetList);
//
// list.forEach(item->{
// CsDevModelDto dto = new CsDevModelDto();
// BeanUtils.copyProperties(item,dto);
// csDevModelDtoList.add(dto);
// });
// csDataSets.forEach(item->{
// CsDevModelDto.CsDataSet dto = new CsDevModelDto.CsDataSet();
// BeanUtils.copyProperties(item,dto);
// csDataSetList.add(dto);
// });
// csDataArrays.forEach(item->{
// CsDevModelDto.CsDataArray dto = new CsDevModelDto.CsDataArray();
// BeanUtils.copyProperties(item,dto);
// csDataArrayList.add(dto);
// });
//
// for (CsDevModelDto.CsDataSet item1 : csDataSetList) {
// List<CsDevModelDto.CsDataArray> list1 = new ArrayList<>();
// for (CsDevModelDto.CsDataArray item2 : csDataArrayList) {
// if (Objects.equals(item1.getId(),item2.getPid())) {
// list1.add(item2);
// }
// }
// item1.setDataArrays(list1);
// }
//
// for (CsDevModelDto item1 : csDevModelDtoList) {
// List<CsDevModelDto.CsDataSet> list1 = new ArrayList<>();
// for (CsDevModelDto.CsDataSet item2 : csDataSetList) {
// if (Objects.equals(item1.getId(),item2.getPid())) {
// list1.add(item2);
// }
// }
// item1.setDataSets(list1);
// redisUtil.saveByKey(AppRedisKey.DEV_MODEL.concat(item1.getId()),item1);
// }
// }
}
@Override
@Transactional(rollbackFor = Exception.class)
public CsDevModelPO addDevModel(CsDevModelAddParm csDevModelAddParm) {
CsDevModelPO csDevModelPO = new CsDevModelPO ();
BeanUtils.copyProperties (csDevModelAddParm, csDevModelPO);
csDevModelPO.setStatus ("1");
csDevModelPO.setVersionDate(Date.valueOf(csDevModelAddParm.getTime()));
this.save (csDevModelPO);
return csDevModelPO;
}
@@ -46,14 +118,20 @@ public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevMo
public Boolean AuditDevModel(CsDevModelAuditParm csDevModelAuditParm) {
CsDevModelPO csDevModelPO = new CsDevModelPO ();
BeanUtils.copyProperties (csDevModelAuditParm, csDevModelPO);
boolean b = this.updateById (csDevModelPO);
return b;
return this.updateById (csDevModelPO);
}
@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;
}
@@ -61,8 +139,7 @@ public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevMo
@Override
public CsDevModelPageVO queryDevModelOne(CsDevModelQueryListParm csDevModelQueryListParm) {
CsDevModelPageVO result = this.getBaseMapper ().queryOne(csDevModelQueryListParm);
return result;
return this.getBaseMapper ().queryOne(csDevModelQueryListParm);
}
@Override

View File

@@ -31,6 +31,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.csdevice.utils.StringUtil;
import com.njcn.db.constant.DbConstant;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
@@ -39,6 +40,9 @@ 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.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.RequestUtil;
@@ -90,9 +94,23 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final RedisUtil redisUtil;
private final CsSoftInfoMapper csSoftInfoMapper;
@Override
public void refreshDeviceDataCache() {
LambdaQueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ne(CsEquipmentDeliveryPO::getRunStatus,0);
List<CsEquipmentDeliveryPO> deliveryPOS = this.list(queryWrapper);
redisUtil.saveByKey(AppRedisKey.DEVICE_LIST,deliveryPOS);
}
@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);
@@ -101,6 +119,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);
@@ -121,7 +140,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentProcess.setStatus (1);
csEquipmentProcessPOService.save(csEquipmentProcess);
return this.save (csEquipmentDeliveryPo);
result = this.save (csEquipmentDeliveryPo);
if (result) {
refreshDeviceDataCache();
}
return csEquipmentDeliveryPo;
}
@Override
@@ -161,6 +184,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId,id).set(CsDevModelRelationPO::getStatus,0).update();
if (update) {
refreshDeviceDataCache();
}
return update;
}
@@ -199,6 +225,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
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))
@@ -208,16 +238,32 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if (countByAccount >= 1) {
throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
}
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);
return this.updateById (csEquipmentDeliveryPo);
result = this.updateById(csEquipmentDeliveryPo);
if (result) {
refreshDeviceDataCache();
}
return result;
}
@Override
public void updateStatusBynDid(String nDId,Integer status) {
boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getStatus,status).eq(CsEquipmentDeliveryPO::getNdid,nDId);
this.update(lambdaUpdateWrapper);
result = this.update(lambdaUpdateWrapper);
if (result) {
refreshDeviceDataCache();
}
}
@Override
@@ -343,43 +389,28 @@ 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());
addDataSet(dataSetList, item, "最新数据", "rt");
addDataSet(dataSetList, item, "历史统计数据", "history");
addDataSet(dataSetList, item, "历史趋势", "trenddata");
if (isPortableDevice) {
// 便携式设备特有的数据集
addDataSet(dataSetList, item, "实时数据", "realtimedata");
addDataSet(dataSetList, item, "暂态事件", "event");
addDataSet(dataSetList, item, "测试项日志", "items");
}
deviceManagerVo.setDataLevel(item.getDataLevel());
}
deviceManagerVo.setDataSetList(dataSetList);
List<CsLinePO> csLinePOS = csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid());
@@ -389,11 +420,23 @@ 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;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getSoftinfoId,id).set(CsEquipmentDeliveryPO::getModuleNumber,module).eq(CsEquipmentDeliveryPO::getNdid,nDid);
this.update(lambdaUpdateWrapper);
result = this.update(lambdaUpdateWrapper);
if (result) {
refreshDeviceDataCache();
}
}
@Override
@@ -410,6 +453,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//第一个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);
//如果存在非法数据,将不合格的数据导出
@@ -418,6 +462,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
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();
@@ -426,39 +479,47 @@ 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);
}
@@ -541,6 +602,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect);
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
}
refreshDeviceDataCache();
}
@Override
@@ -585,20 +647,28 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
public void updateSoftInfo(String nDid, String id) {
boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid)
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.set(CsEquipmentDeliveryPO::getSoftinfoId,id);
this.update(lambdaUpdateWrapper);
result = this.update(lambdaUpdateWrapper);
if (result) {
refreshDeviceDataCache();
}
}
@Override
public void updateModuleNumber(String nDid, Integer number) {
boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid)
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.set(CsEquipmentDeliveryPO::getModuleNumber,number);
this.update(lambdaUpdateWrapper);
result = this.update(lambdaUpdateWrapper);
if (result) {
refreshDeviceDataCache();
}
}
@Override
@@ -608,9 +678,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
askDeviceDataFeignClient.rebootDevice(nDid);
Thread.sleep(3000);
String key = AppRedisKey.CONTROL + nDid;
String value = redisUtil.getObjectByKey(key).toString();
if (Objects.equals(value,"success")) {
result = true;
Object object = redisUtil.getObjectByKey(key);
if (Objects.nonNull(object)) {
String value = object.toString();
if (Objects.equals(value,"success")) {
result = true;
}
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
@@ -623,6 +696,19 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus,0).list();
}
@Override
public boolean judgeDevModel(String nDid) {
boolean result = false;
//获取装置id
CsEquipmentDeliveryPO po = findDevByNDid(nDid);
//设备型号
String code = dictTreeFeignClient.queryById(po.getDevModel()).getData().getCode();
if (Objects.equals(DicTreeEnum.PQ_COM.getCode(),code)) {
result = true;
}
return result;
}
/**
* 根据ndid生成二维码
* @param ndid

View File

@@ -10,9 +10,7 @@ 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.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam;
@@ -26,19 +24,18 @@ import com.njcn.csdevice.pojo.vo.CsGroupVO;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
import com.njcn.csdevice.service.CsDevModelRelationService;
import com.njcn.csdevice.service.ICsDataArrayService;
import com.njcn.csdevice.service.ICsGroupService;
import com.njcn.csdevice.service.ICsLedgerService;
import com.njcn.csdevice.util.InfluxDbParamUtil;
import com.njcn.csdevice.utils.DataChangeUtil;
import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.constant.HarmonicConstant;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.influx.pojo.bo.CommonQueryParam;
import com.njcn.influx.pojo.dto.EventDataSetDTO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
@@ -53,6 +50,7 @@ import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
import lombok.AllArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -80,48 +78,24 @@ import java.util.stream.Stream;
public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> implements ICsGroupService {
private final ICsDataArrayService csDataArrayService;
private final CsGroArrMapper csGroArrMapper;
private final CsGroupMapper csGroupMapper;
private final CsDataArrayMapper csDataArrayMapper;
private final CommonService commonService;
private final EpdFeignClient epdFeignClient;
private final CsLineFeignClient csLineFeignClient;
private final ICsLedgerService iCsLedgerService;
private final DicDataFeignClient dicDataFeignClient;
private final EquipmentFeignClient equipmentFeignClient;
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
private final EvtDataService evtDataService;
private final DecimalFormat df = new DecimalFormat("#0.00");
private final EleEvtFeignClient eleEvtFeignClient;
private final OverlimitMapper overlimitMapper;
private final CsDataSetMapper csDataSetMapper;
private final EventFeignClient eventFeignClient;
private final InfluxDbParamUtil influxDbParamUtil;
private final Set<String> POWER_LIST = new HashSet<>(Arrays.asList(
"电网有功功率", "电网无功功率", "电网视在功率", "负载有功功率",
"负载无功功率", "负载视在功率", "有功功率", "无功功率",
"视在功率", "基波有功功率", "基波无功功率",
"基波视在功率", "三相总有功功率", "三相总无功功率",
"三相总视在功率"
));
@Override
@Transactional(rollbackFor = Exception.class)
public List<CsGroupVO> getGroupData(String dataSet) {
@@ -176,13 +150,13 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
}else {
re = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(), statisticalDataDTO.getValue(), csLinePO.getPtRatio(), csLinePO.getCtRatio());
}
if (changePower(vo.getAnotherName())) {
if (changePower(vo.getAnotherName()) && Objects.equals(dataLevel,"Primary")) {
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(re / 1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
} else {
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(re).setScale(2, RoundingMode.HALF_UP).doubleValue())));
}
} else {
if (changePower(vo.getAnotherName())) {
if (changePower(vo.getAnotherName()) && Objects.equals(dataLevel,"Primary")) {
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(statisticalDataDTO.getValue()/1000).setScale(2, RoundingMode.HALF_UP).doubleValue())));
} else {
vo.setDataValue(Double.valueOf(df.format(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(2, RoundingMode.HALF_UP).doubleValue())));
@@ -193,6 +167,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
}
if (vo.getAnotherName().contains("A相") || vo.getAnotherName().contains("B相") || vo.getAnotherName().contains("C相")) {
vo.setAnotherName(vo.getAnotherName().substring(0,2));
} else if (vo.getAnotherName().contains("AB") || vo.getAnotherName().contains("BC") || vo.getAnotherName().contains("CA")) {
vo.setAnotherName(vo.getAnotherName().substring(0,2).concat(""));
}
arrayList.add(vo);
}
@@ -319,6 +295,12 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> result = new ArrayList();
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(commonStatisticalQueryParam.getDevId()).collect(Collectors.toList())).getData();
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(commonStatisticalQueryParam.getLineId())).getData();
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePOList.get(0).getDataSetId()));
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = finalCsLinePOList.get(0).getCtRatio();
Double pt = finalCsLinePOList.get(0).getPtRatio();
if(CollectionUtil.isNotEmpty(commonStatisticalQueryParam.getList())){
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
@@ -328,7 +310,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
commonQueryParam.setColumnName(epdPqd.getName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(commonStatisticalQueryParam.getStartTime(),DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
@@ -340,18 +322,114 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
return commonQueryParam;
}).collect(Collectors.toList());
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
//List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(commonQueryParams);
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
String unit;
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(temp.getValueType());
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
if(temp.getValue()!=null) {
double re = 0;
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = Objects.isNull(temp.getValue()) ? 3.14159 : temp.getValue() / 1000;
vo.setStatisticalData(Double.valueOf(df.format(re)));
unit = "k" + epdPqd.getUnit();
} else {
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(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())));
}
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.setUnit(epdPqd.getUnit());
vo.setStatisticalName(epdPqd.getName());
vo.setAnotherName(epdPqd.getShowName());
return vo;
@@ -393,7 +471,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -421,9 +499,12 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
csEventVOPage.getRecords().forEach(temp->{
//事件描述、相别、暂降幅值,需要特殊处理赋值
//事件描述
CsLedger dataById = iCsLedgerService.findDataById(temp.getLineId());
temp.setLineName(dataById.getName());
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
if(ele!=null){
temp.setShowName(ele.getShowName());
//相别
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData();
List<EventDataSetDTO> eventDataSetDTOS = new ArrayList<>();
@@ -532,7 +613,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -632,7 +713,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -764,8 +845,6 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
//单位处理
public void getUnit(List<EnergyTemplateVO> energyTemplates, List<EleEpdPqd> eleEpdPqds, List<DataGroupTemplateVO> dataGroupTemplates, String type) {
List<String> pList = Arrays.asList("电网有功功率", "电网无功功率", "电网视在功率","负载有功功率","负载无功功率","负载视在功率"
,"有功功率","无功功率","视在功率","基波有功功率","基波无功功率","基波视在功率","三相总有功功率","三相总无功功率","三相总视在功率");
// 使用Map来存储EleEpdPqd的ID和Unit以便快速查找
Map<String, String> unitMap = new HashMap<>();
for (EleEpdPqd item : eleEpdPqds) {
@@ -790,7 +869,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
for (DataGroupTemplateVO dataGroupTemplate : dataGroupTemplates) {
EnergyTemplateVO energyTemplate = energyTemplateMap.get(dataGroupTemplate.getId());
if (energyTemplate != null && energyTemplate.getUnit() != null) {
if (changePower(dataGroupTemplate.getName())) {
if (changePower(dataGroupTemplate.getName()) && Objects.equals("Primary",type)) {
dataGroupTemplate.setName(dataGroupTemplate.getName() + "(k" + energyTemplate.getUnit() + ")");
} else {
dataGroupTemplate.setName(dataGroupTemplate.getName() + "(" + energyTemplate.getUnit() + ")");
@@ -800,9 +879,12 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
}
}
//判断功率是否需要转换
//判断指标是否需要转换
public boolean changePower(String name) {
return POWER_LIST.stream()
if(name.contains("相角")) {
return false;
}
return HarmonicConstant.POWER_LIST.stream()
.anyMatch(name::contains);
}

View File

@@ -4,6 +4,7 @@ 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.constant.DataParam;
@@ -15,16 +16,15 @@ 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.pojo.po.Area;
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,15 +39,12 @@ 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;
@@ -76,17 +73,48 @@ 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<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())).
peek(
temp->{
CsEquipmentDeliveryPO csEquipmentDeliveryPO = csEquipmentDeliveryMapper.selectById(temp.getId());
temp.setComFlag(csEquipmentDeliveryPO.getRunStatus());
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 -> device.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");
})
.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");
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());
}
).
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)).collect(Collectors.toList());
)
.collect(Collectors.toList());
checkDevSetData(deviceList);
deviceList.forEach(dev -> dev.setChildren(getChildren(dev, finalLineList)));
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
@@ -97,13 +125,29 @@ 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());
for(CsLedgerVO c : portables){
c.setPid(portable.getId());
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(c.getId());
c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid());
}
//针对未启用的装置判断
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(dev -> dev.setChildren(getChildren(dev, finalLineList)));
checkDevSetData(portables);
portable.setChildren(portables);
@@ -115,8 +159,12 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
List<CsLedgerVO> tree = new ArrayList<>();
tree.add(portable);
tree.add(government);
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
}
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
return tree;
}
//剔除未接入的设备(根据status判断不太稳,所有这里直接判断该设备有没有对应的模板指标)
@@ -157,15 +205,28 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<String> device = roleEngineerDevService.getDevice();
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId())).
peek(
temp->{
CsEquipmentDeliveryPO csEquipmentDeliveryPO = csEquipmentDeliveryMapper.selectById(temp.getId());
temp.setComFlag(csEquipmentDeliveryPO.getRunStatus());
temp.setNDId(csEquipmentDeliveryPO.getNdid());
}
).
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 -> device.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");
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
checkDevSetData(deviceList);
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
@@ -176,14 +237,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());
}
//针对未启用的装置判断
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();
@@ -193,8 +271,12 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
List<CsLedgerVO> tree = new ArrayList<>();
tree.add(portable);
tree.add(government);
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
}
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
return tree;
}
@@ -287,18 +369,105 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
public DevDetailDTO queryDevDetail(String devId) {
DevDetailDTO device = new DevDetailDTO();
CsLedger dev = this.findDataById(devId);
device.setEquipmentName(dev.getName());
device.setEquipmentId(devId);
CsLedger project = this.findDataById(dev.getPid());
device.setProjectId(project.getId());
device.setProjectName(project.getName());
CsLedger engineer = this.findDataById(project.getPid());
device.setEngineeringid(engineer.getId());
device.setEngineeringName(engineer.getName());
//如果是便携式设备pid为0,项目,工程都设置为/
if(Objects.equals(dev.getPid(),"0")){
device.setEquipmentName(dev.getName());
device.setEquipmentId(devId);
device.setProjectId("/");
device.setProjectName("/");
device.setEngineeringid("/");
device.setEngineeringName("/");
}else {
device.setEquipmentName(dev.getName());
device.setEquipmentId(devId);
CsLedger project = this.findDataById(dev.getPid());
device.setProjectId(project.getId());
device.setProjectName(project.getName());
CsLedger engineer = this.findDataById(project.getPid());
device.setEngineeringid(engineer.getId());
device.setEngineeringName(engineer.getName());
}
return device;
}
@Override
public List<CsLedgerVO> getztProjectTree() {
List<CsLedgerVO> engineeringList;
List<CsLedgerVO> allList = this.baseMapper.getAll();
/*获取用户工程,设备信息过滤*/
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
List<String> device = roleEngineerDevService.getDevice();
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(),"0")).
peek(
temp->{
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(temp.getId());
temp.setComFlag(po.getRunStatus());
temp.setNDId(po.getNdid());
temp.setType("device");
}
).
sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
checkDevSetData(deviceList);
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
//获取便携式项目数
CsLedgerVO portable = new CsLedgerVO();
portable.setLevel(0);
portable.setName(DataParam.PORTABLE_SYSTEM);
portable.setPid("0");
portable.setId(IdUtil.simpleUUID());
CsLedgerVO project = new CsLedgerVO();
project.setLevel(1);
project.setName(DataParam.WIRELESS_PROJECT);
project.setPid("0");
project.setId(DataParam.WIRELESS_PROJECT_ID);
List<CsLedgerVO> portables = allList.stream().filter(item->Objects.equals(item.getLevel(),2) && Objects.equals(item.getPid(),"0")).collect(Collectors.toList());
checkDevSetData(portables);
for(CsLedgerVO c : portables){
c.setPid(project.getId());
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(c.getId());
c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid());
c.setType("device");
}
project.setChildren(portables);
List<CsLedgerVO> wxProjectList = new ArrayList<>();
wxProjectList.add(project);
portable.setChildren(wxProjectList);
CsLedgerVO government = new CsLedgerVO();
government.setLevel(0);
government.setName(DataParam.GOVERNANCE_SYSTEM);
government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
}
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
return tree;
}
/**
* 获取子节点
*/

View File

@@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -67,10 +68,26 @@ 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);
}
@Override
public void updateIds(CsLineParam csLineParam) {
LambdaUpdateWrapper<CsLinePO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsLinePO::getLineId,csLineParam.getLineId())
.eq(CsLinePO::getStatus,1)
.set(CsLinePO::getDataSetId,csLineParam.getDataSetId())
.set(CsLinePO::getDataModelId,csLineParam.getModelId());
this.update(lambdaUpdateWrapper);
}
@Override
public List<CsLinePO> getLinesByDevList(List<String> list) {
return this.lambdaQuery().in(CsLinePO::getDevId,list).eq(CsLinePO::getStatus,1).list();
}
// /**
// * 1.平台端默认配置拓扑图模板,包含拓扑图信息(cs_topology_diagram_template)和拓扑图上监测点的点位信息(cs_line_topology_template)
// *

View File

@@ -46,8 +46,9 @@ public class CsLogsPOServiceImpl extends ServiceImpl<CsLogsPOMapper, CsLogsPO> i
String userRole = RequestUtil.getUserRole();
List<String> strings = JSONArray.parseArray(userRole, String.class);
QueryWrapper<CsLogsPO> csLogsPOQueryWrapper = new QueryWrapper<>();
csLogsPOQueryWrapper.lambda().eq(!strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()),CsLogsPO::getUserName, username).
ge(StringUtils.isNotBlank(baseParam.getSearchBeginTime()),CsLogsPO::getCreateTime,baseParam.getSearchBeginTime()).
csLogsPOQueryWrapper.lambda()
// .eq(!strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()),CsLogsPO::getUserName, username)
.ge(StringUtils.isNotBlank(baseParam.getSearchBeginTime()),CsLogsPO::getCreateTime,baseParam.getSearchBeginTime()).
le(StringUtils.isNotBlank(baseParam.getSearchEndTime()),CsLogsPO::getCreateTime,baseParam.getSearchEndTime()).orderByDesc(CsLogsPO::getCreateTime);
IPage<CsLogsPO> list = this.getBaseMapper().selectPage(returnpage,csLogsPOQueryWrapper);
return list;

View File

@@ -14,6 +14,7 @@ import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.time.Instant;
@@ -44,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);
@@ -54,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;
}
@@ -63,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);
// 请求设备文件或目录信息
@@ -77,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());
@@ -86,9 +93,12 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
}
@Override
public String downloadFile(String nDid, String name, Integer size, String fileCheck) {
String result = null;
judgeClientOnline(nDid);
@Async
public void downloadFile(String nDid, String name, Integer size, String fileCheck) {
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);
@@ -98,25 +108,27 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
throw new BusinessException(AlgorithmResponseEnum.FILE_BUSY);
}
try {
redisUtil.delete("downloadFilePath:"+name);
boolean file = askDeviceDataFeignClient.downloadFile(nDid,name,size,fileCheck).getData();
if (!file) {
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete("fileCheck"+name);
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOAD_ERROR);
}
Object object = redisUtil.getObjectByKey("downloadFilePath:"+name);
if (Objects.nonNull(object)) {
result = (String) object;
redisUtil.delete("downloadFilePath:"+name);
redisUtil.delete("fileCheck"+name);
redisUtil.delete("fileDowning:"+nDid);
}
redisUtil.delete("downloadFilePath:"+ nDid + name);
askDeviceDataFeignClient.downloadFile(nDid,name,size,fileCheck).getData();
} catch (Exception e) {
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete("fileCheck"+name);
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
redisUtil.delete("fileCheck"+nDid+name);
throw new BusinessException(e.getMessage());
}
}
@Override
public String getDownloadFilePath(String nDid, String name) {
String result = null;
Object object = redisUtil.getObjectByKey("downloadFilePath:" + nDid + name);
if (Objects.nonNull(object)) {
result = (String) object;
redisUtil.delete("downloadFilePath:" + nDid + name);
}
redisUtil.delete("fileCheck"+nDid+name);
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete(AppRedisKey.FILE_PART.concat(name));
redisUtil.delete("fileDownUserId"+nDid+name);
return result;
}
@@ -132,7 +144,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
result = true;
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage());
}
return result;
}
@@ -149,7 +161,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
result = true;
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage());
}
return result;
}
@@ -173,6 +185,13 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
vo.setPrjDataPath(item.getName());
vo.setType(item.getType());
vo.setSize(item.getSize());
if (item.getTime() == 0) {
vo.setStartTime("/");
} else {
LocalDateTime dateTime = Instant.ofEpochMilli((item.getTime()-8*3600)*1000).atZone(ZoneId.systemDefault()).toLocalDateTime();
String formattedDate = dateTime.format(formatter);
vo.setStartTime(formattedDate);
}
return vo;
}
@@ -180,7 +199,7 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
MakeUpVo vo = new MakeUpVo();
vo.setPrjDataPath(fileInfo.getName());
if (fileInfo.getFileTime() != 0) {
LocalDateTime dateTime = Instant.ofEpochMilli((fileInfo.getFileTime() - 3600*8) * 1000).atZone(ZoneId.systemDefault()).toLocalDateTime();
LocalDateTime dateTime = Instant.ofEpochMilli((fileInfo.getFileTime() - 8*3600) * 1000).atZone(ZoneId.systemDefault()).toLocalDateTime();
String formattedDate = dateTime.format(formatter);
vo.setStartTime(formattedDate);
vo.setSize(fileInfo.getFileSize());
@@ -189,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,17 @@
package com.njcn.csdevice.service.impl;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.biz.pojo.po.Overlimit;
/**
*
* Description:
* Date: 2024/10/22 14:14【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface OverlimitService extends IService<Overlimit>{
}

View File

@@ -0,0 +1,19 @@
package com.njcn.csdevice.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
import com.njcn.csdevice.mapper.PortableOffMainLogMapper;
import com.njcn.csdevice.service.PortableOffMainLogService;
/**
*
* Description:
* Date: 2024/10/15 10:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class PortableOffMainLogServiceImpl extends ServiceImpl<PortableOffMainLogMapper, PortableOffMainLog> implements PortableOffMainLogService{
}

View File

@@ -1,17 +1,28 @@
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;
import com.njcn.csharmonic.api.OfflineDataUploadFeignClient;
@@ -25,7 +36,6 @@ import com.njcn.csharmonic.offline.mincfg.AnalyseComtradeCfg;
import com.njcn.csharmonic.offline.mincfg.vo.CmnModeCfg;
import com.njcn.csharmonic.offline.vo.Response;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.imapper.EvtDataMapper;
import com.njcn.influx.imapper.PqdDataMapper;
import com.njcn.influx.pojo.po.cs.EntData;
@@ -37,14 +47,21 @@ import com.njcn.system.pojo.po.DictData;
import com.njcn.web.pojo.param.BaseParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.math.BigDecimal;
import java.text.DecimalFormat;
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;
@@ -83,6 +100,11 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
private final EvtDataMapper evtDataMapper;
private final MqttPublisher publisher;
private final PortableOffMainLogService portableOffMainLogService;
private final IWlRecordService wlRecordService;
private final CsLinePOService csLinePOService;
@Override
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
Page<PortableOfflLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
@@ -158,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(
@@ -238,10 +264,24 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
boolean minFlag = true;
//开始上传文件、记录上传日志、解析的文件结果入库
//最外层便利所有文件确保所有文件都上传及记录上传日志
int nowStep = uploadDataParam.getFiles().size();
PortableOffMainLog portableOffMainLog = new PortableOffMainLog();
portableOffMainLog.setId(IdUtil.fastSimpleUUID());
portableOffMainLog.setStartTime(LocalDateTime.now());
String paths = uploadDataParam.getFiles().stream().map(MultipartFile::getOriginalFilename)
.reduce((s1, s2) -> getCommonPrefix(s1, s2))
.orElse(null);
String[] split = paths.split("/");
portableOffMainLog.setProjectName(split.length>0?split[split.length-1]:"/");
int successcCount = 0;
portableOffMainLog.setStatus("1");
List<PortableOfflLog> portableOfflLogs = new ArrayList<>();
for(MultipartFile file : uploadDataParam.getFiles()){
//初始上传日志基本信息
PortableOfflLog portableOfflLog = new PortableOfflLog();
portableOfflLog.setLogMainId(portableOffMainLog.getId());
portableOfflLog.setName(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("/")+1));
portableOfflLog.setPath(file.getOriginalFilename());
portableOfflLog.setDataPath(fileStorageUtil.uploadMultipart(file, DataParam.wlRecordPath+uploadDataParam.getDevId()+"/"+uploadDataParam.getLineId()+"/"+getFolderName()+"/"));
@@ -250,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);
@@ -262,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());
@@ -269,11 +345,16 @@ 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){
log.info("类型min,插入infulxDb的pqdData");
pqdDataMapper.insertBatch(pqdData);
List<List<PqdData>> partition = ListUtils.partition(pqdData, 1500);
for (List<PqdData> sliceList : partition) {
List<PqdData> sublistAsOriginalListType = new ArrayList<>(sliceList);
pqdDataMapper.insertBatch(sublistAsOriginalListType);
}
//min结果集解析入库后就不需要在解析了
minFlag = false;
}
@@ -282,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 那么当前文件解析出错
@@ -349,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
@@ -433,8 +513,36 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
}
}
}
this.baseMapper.insert(portableOfflLog);
nowStep++;
String json = "{allStep:"+uploadDataParam.getFiles().size()*2+",nowStep:"+nowStep+"}";
publisher.send("/dataOnlineRecruitment/Progress/" + uploadDataParam.getLineId(), new Gson().toJson(json), 1, false);
//无需解析的不需要记录
if(portableOfflLog.getState()!=0){
this.baseMapper.insert(portableOfflLog);
successcCount++;
}
portableOfflLogs.add(portableOfflLog);
}
portableOffMainLog.setEndTime(LocalDateTime.now());
portableOffMainLog.setSuccessCount(successcCount);
portableOffMainLogService.save(portableOffMainLog);
}
@Override
public Page<PortableOffMainLog> queryMainLogPage(BaseParam baseParam) {
Page<PortableOffMainLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
QueryWrapper<PortableOffMainLog> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.ge(StringUtils.isNotBlank(baseParam.getSearchBeginTime()), PortableOffMainLog::getCreateTime,baseParam.getSearchBeginTime()+" 00:00:00")
.le(StringUtils.isNotBlank(baseParam.getSearchEndTime()),PortableOffMainLog::getCreateTime,baseParam.getSearchEndTime()+" 23:59:59").orderByDesc(PortableOffMainLog::getCreateTime);
Page<PortableOffMainLog> portableOffMainLogPage = portableOffMainLogService.getBaseMapper().selectPage(returnpage, queryWrapper);
portableOffMainLogPage.getRecords().forEach(temp->{
List<PortableOfflLog> list = this.lambdaQuery().eq(PortableOfflLog::getLogMainId, temp.getId()).list();
temp.setPortableOfflLogList(list);
});
return returnpage;
}
//根据文件全路径(包含文件夹)解析文件的分类
@@ -451,4 +559,49 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
return sdf.format(calendar.getTime());
}
private static String getCommonPrefix(String s1, String s2) {
for (int i = 0; i <= s1.length() && i <= s2.length(); i++) {
if (i == s1.length() || i == s2.length() || s1.charAt(i) != s2.charAt(i)) {
return s1.substring(0, i);
}
}
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;
}
}

View File

@@ -2,26 +2,29 @@ package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
import com.njcn.csdevice.mapper.CsDataSetMapper;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
import com.njcn.csdevice.mapper.CsLinePOMapper;
import com.njcn.csdevice.mapper.WlRecordMapper;
import com.njcn.csdevice.param.WlRecordPageParam;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.dto.CsEquipmentProcessDTO;
import com.njcn.csdevice.pojo.param.WlRecordParam;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo;
@@ -29,8 +32,13 @@ import com.njcn.csdevice.pojo.vo.RecordTreeVo;
import com.njcn.csdevice.pojo.vo.RecordVo;
import com.njcn.csdevice.service.IWlRecordService;
import com.njcn.csdevice.util.InfluxDbParamUtil;
import com.njcn.csdevice.utils.DataChangeUtil;
import com.njcn.csdevice.utils.StringUtil;
import com.njcn.csharmonic.constant.HarmonicConstant;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.biz.utils.COverlimitUtil;
import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.pojo.bo.CommonQueryParam;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
@@ -38,16 +46,20 @@ import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.influx.service.CommonService;
import com.njcn.system.api.CsStatisticalSetFeignClient;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.core.Local;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.text.DecimalFormat;
import java.time.*;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
@@ -77,17 +89,22 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
private final CommonMapper commonMapper;
private final CsDataSetMapper csDataSetMapper;
private final InfluxDbParamUtil influxDbParamUtil;
private final CsLinePOMapper csLinePOMapper;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final OverlimitService overlimitService;
private final DicDataFeignClient dicDataFeignClient;
private final DecimalFormat df = new DecimalFormat(DataParam.DecimalFormatStr);
@Override
@Transactional(rollbackFor = Exception.class)
// @Transactional(rollbackFor = Exception.class)
public void addRecord(WlRecordParam.AddRecord records) {
checkRecord(records);
//整理的方案下测试项集合(可能添加多个测试项)
List<WlRecord> insertList = new ArrayList<>();
//校验方案ID是否存在
@@ -113,10 +130,49 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
updateRecord.setId(record.getId());
updateRecord.setList(item.getList());
saveDataRecord(updateRecord);
//生成测试项限值,用于报表
DictData scaleResult = dicDataFeignClient.getDicDataById(record.getVoltageLevel()).getData();
if (Objects.isNull(scaleResult)) {
throw new BusinessException(CommonResponseEnum.DIC_DATA);
}
float voltageLevel = Float.parseFloat(scaleResult.getValue());
Overlimit overlimit = COverlimitUtil.globalAssemble(voltageLevel, record.getCapacitySi(), record.getCapacitySt(), record.getCapacitySscmin(), 1, 0);
overlimit.setId(id);
overlimitService.saveOrUpdate(overlimit);
});
this.saveBatch(insertList);
}
private void checkRecord(WlRecordParam record) {
if (record instanceof WlRecordParam.AddRecord) {
WlRecordParam.AddRecord temp =( WlRecordParam.AddRecord) record;
String itemName = temp.getRecords().get(0).getItemName();
StringUtil.containsSpecialCharacters(itemName);
if(StrUtil.isBlank(itemName)){
throw new BusinessException("测试项名称不能为空或空格");
}
List<WlRecord> list = this.lambdaQuery().eq(WlRecord::getPId, temp.getId()).eq(WlRecord::getState, 1).eq(WlRecord::getItemName, itemName).list();
if(!CollectionUtils.isEmpty(list)){
throw new BusinessException("数据列表中存在同名测试项");
}
}else if (record instanceof WlRecordParam.UpdateRecord) {
WlRecordParam.UpdateRecord temp =( WlRecordParam.UpdateRecord) record;
String itemName = temp.getItemName();
StringUtil.containsSpecialCharacters(itemName);
if(StrUtil.isBlank(itemName)){
throw new BusinessException("测试项名称不能为空或空格");
}
WlRecord one = this.lambdaQuery().eq(WlRecord::getId, temp.getId()).one();
List<WlRecord> list = this.lambdaQuery().eq(WlRecord::getPId, one.getPId()).ne(WlRecord::getId, temp.getId()).eq(WlRecord::getState, 1).eq(WlRecord::getItemName, itemName).list();
if(!CollectionUtils.isEmpty(list)){
throw new BusinessException("数据列表中存在同名测试项");
}
}
}
@Override
public void addBaseData(WlRecord wlRecord) {
this.save(wlRecord);
@@ -128,25 +184,59 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
}
@Override
@Transactional(rollbackFor = Exception.class)
// @Transactional(rollbackFor = Exception.class)
public void updateTestRecord(WlRecordParam.UpdateRecord record) {
checkRecord(record);
WlRecord wlRecord = new WlRecord();
BeanUtils.copyProperties(record, wlRecord);
wlRecord.setStartTime(record.getProStartTime());
wlRecord.setEndTime(record.getProEndTime());
this.updateById(wlRecord);
saveDataRecord(record);
//修改测试项限值,用于报表
DictData scaleResult = dicDataFeignClient.getDicDataById(record.getVoltageLevel()).getData();
if (Objects.isNull(scaleResult)) {
throw new BusinessException(CommonResponseEnum.DIC_DATA);
}
float voltageLevel = Float.parseFloat(scaleResult.getValue());
Overlimit overlimit = COverlimitUtil.globalAssemble(voltageLevel, record.getCapacitySi(), record.getCapacitySt(), record.getCapacitySscmin(), 1, 0);
overlimit.setId(record.getId());
overlimitService.saveOrUpdate(overlimit);
}
@Override
public void updateRecordData(WlRecordParam.UpdateRecord record) {
LambdaQueryWrapper<WlRecord> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WlRecord::getId, record.getId());
WlRecord wlRecord = this.getOne(queryWrapper);
if (Objects.isNull(wlRecord)) {
throw new BusinessException("测试项缺失!");
} else {
wlRecord.setStartTime(record.getProStartTime());
wlRecord.setEndTime(record.getProEndTime());
}
this.updateById(wlRecord);
}
@Override
public void updateSchemeRecord(WlRecordParam.UpdateRecord record) {
WlRecord wlRecord = new WlRecord();
checkString(record.getItemName());
if(record.getId()!=null){
BeanUtils.copyProperties(record, wlRecord);
LambdaQueryWrapper<WlRecord> qw = new LambdaQueryWrapper();
qw.eq(WlRecord::getItemName,record.getItemName()).isNull(WlRecord::getPId).eq(WlRecord::getType,0).eq(WlRecord::getState,1).ne(WlRecord::getId,record.getId());
List<WlRecord> wlRecordList = this.baseMapper.selectList(qw);
//方案名称重复校验
if(!wlRecordList.isEmpty()){
throw new BusinessException(LineBaseEnum.EXISTWLRECORD_FAIL.getMessage());
}
this.updateById(wlRecord);
}else{
LambdaQueryWrapper<WlRecord> qw = new LambdaQueryWrapper();
qw.eq(WlRecord::getItemName,record.getItemName()).eq(WlRecord::getType,0).eq(WlRecord::getState,1);
qw.eq(WlRecord::getItemName,record.getItemName()).isNull(WlRecord::getPId).eq(WlRecord::getType,0).eq(WlRecord::getState,1);
List<WlRecord> wlRecordList = this.baseMapper.selectList(qw);
//方案名称重复校验
if(!wlRecordList.isEmpty()){
@@ -160,6 +250,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
}
}
private void checkString(String itemName) {
StringUtil.containsSpecialCharacters(itemName);
if(StrUtil.isBlank(itemName)){
throw new BusinessException("测试项名称不能为空或空格");
}
}
@Override
public RecordVo.RecordItemVo getTestRecordById(String testRecordId) {
RecordVo.RecordItemVo recordItemVo = new RecordVo.RecordItemVo();
@@ -179,6 +276,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
wlRecord.setStartTime(getFirstTimeById(wlRecord.getId()));
wlRecord.setEndTime(getLastTimeById(wlRecord.getId()));
BeanUtils.copyProperties(wlRecord, recordVo);
recordVo.setList(this.baseMapper.getDataRecordBytestId(wlRecord.getId()));
recordVoList.add(recordVo);
}else{
//反之则是方案ID 则返回该方案下所有的测试项信息
@@ -192,6 +290,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
wl.setStartTime(getFirstTimeById(wl.getId()));
wl.setEndTime(getLastTimeById(wl.getId()));
BeanUtils.copyProperties(wl, recordVo);
recordVo.setList(this.baseMapper.getDataRecordBytestId(wl.getId()));
recordVoList.add(recordVo);
}
}
@@ -298,7 +397,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
}
@Override
@Transactional(rollbackFor = Exception.class)
// @Transactional(rollbackFor = Exception.class)
public void deleteRecord(String id) {
LambdaQueryWrapper<WlRecord> qw = new LambdaQueryWrapper();
qw.eq(WlRecord::getId,id).eq(WlRecord::getState,"1").eq(WlRecord::getType,"0");
@@ -315,6 +414,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
if(wlRecord.getPId() != null){
//方案关联的设备基础数据也删除
this.baseMapper.deleteDataRecord(id,null);
overlimitService.removeById(id);
}else{
//如果删除的是方案 那么连带方案下的所有测试项也要删除
qw = new LambdaQueryWrapper();
@@ -356,7 +456,8 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
List<WlRecord> data = new ArrayList<>();
if(wlRecord.getPId() == null){
//如果查询的是方案 则查询该方案下所有的测试项关联的设备基础数据
data = this.baseMapper.getDataRecordByTestId(wlRecord.getId(),1);
return null;
// data = this.baseMapper.getDataRecordByTestId(wlRecord.getId(),1);
}else{
//如果查询的是测试项 则查询该测试项下所有的关联的设备基础数据
data = this.baseMapper.getDataRecordByTestId(wlRecord.getId(),0);
@@ -367,53 +468,155 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
}
//格式化前端参数
formatQueryParamList(commonStatisticalQueryParam);
if(commonStatisticalQueryParam.getList() != null && commonStatisticalQueryParam.getList().size() > 0){
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
if(param.getStatisticalId() == null){
continue;
}
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
for(WlRecord wl : data){
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(wl.getLineId())).getData();
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(wl.getDevId()).collect(Collectors.toList())).getData();
eleEpdPqds.forEach(epdPqd->{
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(LocalDateTimeUtil.format(wl.getStartTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setEndTime(LocalDateTimeUtil.format(wl.getEndTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
return commonQueryParam;
}).collect(Collectors.toList());
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(temp.getValueType());
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
vo.setStatisticalIndex(epdPqd.getId());
vo.setUnit(epdPqd.getUnit());
vo.setStatisticalName(epdPqd.getName());
vo.setAnotherName(epdPqd.getShowName());
return vo;
}).collect(Collectors.toList());
result.addAll(collect1);
});
}
if(commonStatisticalQueryParam.getList() != null && !commonStatisticalQueryParam.getList().isEmpty()){
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
if(param.getStatisticalId() == null){
continue;
}
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
for(WlRecord wl : data){
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(wl.getLineId())).getData();
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePOList.get(0).getDataSetId()));
if(StrUtil.isBlank(csDataSet.getDataLevel())){
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
}
Double ct = Double.valueOf(wlRecord.getCt())/wlRecord.getCt1();
Double pt =Double.valueOf(wlRecord.getPt())/wlRecord.getPt1();
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(wl.getDevId()).collect(Collectors.toList())).getData();
eleEpdPqds.forEach(epdPqd->{
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
CommonQueryParam commonQueryParam = new CommonQueryParam();
commonQueryParam.setLineId(temp.getLineId());
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
commonQueryParam.setPhasic(epdPqd.getPhase());
commonQueryParam.setStartTime(LocalDateTimeUtil.format(wl.getStartTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setEndTime(LocalDateTimeUtil.format(wl.getEndTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
return commonQueryParam;
}).collect(Collectors.toList());
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
//此处设空时为了有多段时将线条断开前端显示
if(!CollectionUtils.isEmpty(deviceRtData)){
deviceRtData.get(deviceRtData.size()-1).setValue(null);
}
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());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(temp.getValueType());
if(temp.getValue()!=null) {
double re = 0;
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
vo.setStatisticalData(Double.valueOf(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(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())));
}
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());
return vo;
}).collect(Collectors.toList());
result.addAll(collect1);
});
}
}
}
return result;
}
@Override
public WlRecord findDevBaseData(WlRecordParam.Record param) {
LambdaQueryWrapper<WlRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -427,9 +630,38 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
}
@Override
public void dayDealNoEndTimeEvent() {
public List<RecordVo> findDevBaseDataByLineId(WlRecordParam.lineRecord param) {
List<RecordVo> result = new ArrayList<>();
LambdaQueryWrapper<WlRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(WlRecord::getType,1).eq(WlRecord::getState,DataStateEnum.ENABLE.getCode());
lambdaQueryWrapper.eq(WlRecord::getLineId,param.getLineId())
.between(WlRecord::getStartTime,param.getItemStartTime(),param.getItemEndTime())
.eq(WlRecord::getType,1)
.eq(WlRecord::getState,1)
.orderByDesc(WlRecord::getStartTime);
if (Objects.equals(param.getDataSource(),0)) {
lambdaQueryWrapper.eq(WlRecord::getItemName,"补召");
} else if (Objects.equals(param.getDataSource(),1)) {
lambdaQueryWrapper.eq(WlRecord::getItemName,"在线监测");
}
List<WlRecord> list = this.list(lambdaQueryWrapper);
if (CollUtil.isNotEmpty(list)) {
list.forEach(item->{
RecordVo vo = new RecordVo();
BeanUtils.copyProperties(item,vo);
result.add(vo);
});
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void dayDealNoEndTimeEvent(String date) {
DateTime dateEnd = DateUtil.parse(date,DatePattern.NORM_DATE_PATTERN);
DateTime dateStart = DateUtil.offsetDay(dateEnd,-30);
System.out.println("进入定时任务");
LambdaQueryWrapper<WlRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(WlRecord::getStartTime,dateStart,dateEnd).eq(WlRecord::getType,1).eq(WlRecord::getState,DataStateEnum.ENABLE.getCode());
List<WlRecord> wlRecordList = this.list(lambdaQueryWrapper);
if(CollUtil.isNotEmpty(wlRecordList)){
@@ -464,7 +696,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);
if(Objects.nonNull(statisticalDataDTO)){
LocalDateTime endTime = statisticalDataDTO.getTime().atOffset(ZoneOffset.ofHours(0)).toLocalDateTime();
Duration duration = Duration.between(now, endTime);
Duration duration = Duration.between(endTime,now);
long hour = duration.toHours();
if(hour>6){
WlRecord wlRecord = new WlRecord();
@@ -508,14 +740,25 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
});
if(CollUtil.isNotEmpty(poList)){
System.out.println("444");
//
this.updateBatchById(poList);
}
}
}
@Override
public List<WlRecord> getWlAssByWlId(String wlId) {
return this.baseMapper.getWlAssByWlId(wlId);
}
@Override
public void deleteItem(String id) {
LambdaUpdateWrapper<WlRecord> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(WlRecord::getId,id).set(WlRecord::getState,0);
this.update(lambdaUpdateWrapper);
}
/**
* 数据项内的时间进行覆盖:解决多个数据项的startTime及endTime之间存在时间冲突
* @param data 数据项

View File

@@ -36,7 +36,7 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>pqs-influx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -73,12 +73,11 @@ public interface HarmonicConstant {
String CTRL_DATA = "ctrl_data";
Set<String> POWER_LIST = new HashSet<>(Arrays.asList(
"电网有功功率", "电网无功功率", "电网视在功率", "负载有功功率",
"负载无功功率", "负载视在功率", "有功功率", "无功功率",
"视在功率", "基波有功功率", "基波无功功率",
"基波视在功率", "三相总有功功率", "三相总无功功率",
"三相总视在功率"
"三相总视在功率","相电压总有效值","线电压总有效值","相电压基波有效值","线电压基波有效值","电压正序分量"
));
}

View File

@@ -17,6 +17,7 @@ public enum CsHarmonicResponseEnum {
CS_DEVICE_COMMON_ERROR("A00600","治理稳态模块异常"),
BIND_TARGET_ERROR("A00601","指标参数绑定异常"),
MAKE_UP_ERROR("A00602","补招失败"),
RECORD_MISSING("A00602","record.bin文件缺失,补召失败")
;

View File

@@ -117,12 +117,12 @@ public class AnalyseComtradeCfg {
hashMapA.put("pq_RmsU",rms[0]);
hashMapB.put("pq_RmsU",rms[1]);
hashMapC.put("pq_RmsU",rms[2]);
hashMapA.put("pq_RmsU",rms[3]);
hashMapA.put("pq_RmsI",rms[3]);
hashMapB.put("pq_RmsI",rms[4]);
hashMapC.put("pq_RmsI",rms[5]);
hashMapA.put("pq_RmsLU",rms[6]);
hashMapB.put("pq_RmsLU",rms[7]);
hashMapC.put("pq_RmsLU",rms[8]);
hashMapAB.put("pq_RmsLU",rms[6]);
hashMapBC.put("pq_RmsLU",rms[7]);
hashMapCA.put("pq_RmsLU",rms[8]);
// pqdDataA.setpq_RmsU(rms[0]);
@@ -197,37 +197,37 @@ public class AnalyseComtradeCfg {
Float[][][] harmPower = min.getHarm_Power();
for (int i = 0; i < 49; i++) {
//电压含有率
hashMapA.put("pq_HarmU_"+(i+2),harmContain[0][i]);
hashMapB.put("pq_HarmU_"+(i+2),harmContain[1][i]);
hashMapC.put("pq_HarmU_"+(i+2),harmContain[2][i]);
hashMapA.put("pq_HarmU_"+(i+2),harmContain[0][i+1]);
hashMapB.put("pq_HarmU_"+(i+2),harmContain[1][i+1]);
hashMapC.put("pq_HarmU_"+(i+2),harmContain[2][i+1]);
//谐波相角
hashMapA.put("pq_HarmUAng_"+(i+2),fuHarmPhase[0][i]);
hashMapB.put("pq_HarmUAng_"+(i+2),fuHarmPhase[1][i]);
hashMapC.put("pq_HarmUAng_"+(i+2),fuHarmPhase[2][i]);
hashMapA.put("pq_HarmUAng_"+(i+2),fuHarmPhase[0][i+1]);
hashMapB.put("pq_HarmUAng_"+(i+2),fuHarmPhase[1][i+1]);
hashMapC.put("pq_HarmUAng_"+(i+2),fuHarmPhase[2][i+1]);
hashMapA.put("pq_HarmIAng_"+(i+2),fuHarmPhase[3][i]);
hashMapB.put("pq_HarmIAng_"+(i+2),fuHarmPhase[4][i]);
hashMapC.put("pq_HarmIAng_"+(i+2),fuHarmPhase[5][i]);
hashMapA.put("pq_HarmIAng_"+(i+2),fuHarmPhase[3][i+1]);
hashMapB.put("pq_HarmIAng_"+(i+2),fuHarmPhase[4][i+1]);
hashMapC.put("pq_HarmIAng_"+(i+2),fuHarmPhase[5][i+1]);
//电流幅值
hashMapA.put("pq_HarmI_"+(i+2),fuHarm[3][i]);
hashMapB.put("pq_HarmI_"+(i+2),fuHarm[4][i]);
hashMapC.put("pq_HarmI_"+(i+2),fuHarm[5][i]);
hashMapA.put("pq_HarmI_"+(i+2),fuHarm[3][i+1]);
hashMapB.put("pq_HarmI_"+(i+2),fuHarm[4][i+1]);
hashMapC.put("pq_HarmI_"+(i+2),fuHarm[5][i+1]);
//谐波功率
hashMapA.put("pq_HarmP_"+(i+2),harmPower[0][i][0]);
hashMapA.put("pq_HarmQ_"+(i+2),harmPower[0][i][1]);
hashMapA.put("pq_HarmS_"+(i+2),harmPower[0][i][2]);
hashMapA.put("pq_HarmP_"+(i+2),harmPower[0][i+1][0]);
hashMapA.put("pq_HarmQ_"+(i+2),harmPower[0][i+1][1]);
hashMapA.put("pq_HarmS_"+(i+2),harmPower[0][i+1][2]);
hashMapB.put("pq_HarmP_"+(i+2),harmPower[1][i][0]);
hashMapB.put("pq_HarmQ_"+(i+2),harmPower[1][i][1]);
hashMapB.put("pq_HarmS_"+(i+2),harmPower[1][i][2]);
hashMapB.put("pq_HarmP_"+(i+2),harmPower[1][i+1][0]);
hashMapB.put("pq_HarmQ_"+(i+2),harmPower[1][i+1][1]);
hashMapB.put("pq_HarmS_"+(i+2),harmPower[1][i+1][2]);
hashMapC.put("pq_HarmP_"+(i+2),harmPower[2][i][0]);
hashMapC.put("pq_HarmQ_"+(i+2),harmPower[2][i][1]);
hashMapC.put("pq_HarmS_"+(i+2),harmPower[2][i][2]);
hashMapC.put("pq_HarmP_"+(i+2),harmPower[2][i+1][0]);
hashMapC.put("pq_HarmQ_"+(i+2),harmPower[2][i+1][1]);
hashMapC.put("pq_HarmS_"+(i+2),harmPower[2][i+1][2]);
//M相目前没有
// hashMapT.put("pq_HarmP_"+(i+2),harmPower[3][i][0]);
// hashMapT.put("pq_HarmQ_"+(i+2),harmPower[3][i][1]);
@@ -239,6 +239,9 @@ public class AnalyseComtradeCfg {
for (int i = 0; i < 50; i++) {
//间谐波幅值
hashMapA.put("pq_InHarmUR_"+(i+1),inHarm[0][i]);
hashMapB.put("pq_InHarmUR_"+(i+1),inHarm[1][i]);
hashMapC.put("pq_InHarmUR_"+(i+1),inHarm[2][i]);
hashMapA.put("pq_InHarmIAmp_"+(i+1),inHarm[3][i]);
hashMapB.put("pq_InHarmIAmp_"+(i+1),inHarm[4][i]);
hashMapC.put("pq_InHarmIAmp_"+(i+1),inHarm[5][i]);
@@ -260,9 +263,9 @@ public class AnalyseComtradeCfg {
hashMapB.put("pq_S",totalPower[1][2]);
hashMapC.put("pq_S",totalPower[2][2]);
hashMapM.put("pq_TotHarmP",totalPower[3][0]);
hashMapM.put("pq_TotHarmQ",totalPower[3][1]);
hashMapM.put("pq_TotHarmS",totalPower[3][2]);
hashMapM.put("pq_TotP",totalPower[3][0]);
hashMapM.put("pq_TotQ",totalPower[3][1]);
hashMapM.put("pq_TotS",totalPower[3][2]);
/*todo 谐波畸变率,电压波动,电压闪变电压长闪变会根据监测点接线方式是星型存A,B,C相角型或者V型存ABBC,CA相目前全存在AB,C相*/
//谐波畸变率
@@ -294,9 +297,9 @@ public class AnalyseComtradeCfg {
hashMapC.put("pq_Fluct",uFluctuation[2]);
//电压闪变
Float[] uFlicker = min.getU_Flicker();
hashMapA.put("pq_Plt",uFlicker[0]);
hashMapB.put("pq_Plt",uFlicker[1]);
hashMapC.put("pq_Plt",uFlicker[2]);
hashMapA.put("pq_Pst",uFlicker[0]);
hashMapB.put("pq_Pst",uFlicker[1]);
hashMapC.put("pq_Pst",uFlicker[2]);
//电压长闪变
Float[] ulFlicker = min.getUL_Flicker();
hashMapA.put("pq_Plt",ulFlicker[0]);
@@ -679,7 +682,7 @@ public class AnalyseComtradeCfg {
strFileLine = sr.readLine(); // ⑩
comtradeCfg.setTimeStart(LocalDateTime.parse(strFileLine, sdf));
comtradeCfg.setTimeEnd(comtradeCfg.getTimeStart().plusSeconds(nMSTotal/1000L));;
comtradeCfg.setTimeEnd(LocalDateTime.parse(strFileLine, sdf).plusNanos(nMSTotal * 1000000));;
comtradeCfg.setPath(file.getOriginalFilename());
sr.close();

View File

@@ -23,6 +23,10 @@ public class CommonStatisticalQueryParam {
private String statisticalId;
@ApiModelProperty(value = "取值类型MaxMincp95avg")
private String valueType;
@ApiModelProperty(value = "一次值Primary;二次值Secondary")
private String dataLevel;
@ApiModelProperty(value = "频次2-50")
private String frequency;

View File

@@ -6,7 +6,6 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
*
@@ -29,6 +28,10 @@ public class CsEventUserQueryPage extends CsEventUserQueryParam{
@ApiModelProperty(value = "显示条数",name = "pageSize",dataType ="Integer",required = true)
private Integer pageSize;
@ApiModelProperty(value = "设备类型名称(便携式,治理)")
private String deviceTypeName;
@ApiModelProperty(value = "工程id")
private String engineeringid;
@@ -42,7 +45,4 @@ public class CsEventUserQueryPage extends CsEventUserQueryParam{
@ApiModelProperty(value = "测点id")
private String lineId;
}

View File

@@ -45,10 +45,14 @@ public class CsEventUserQueryParam {
private String level;
@ApiModelProperty(value="起始时间")
// @NotNull(message="起始时间不能为空!")
private String startTime;
@ApiModelProperty(value="结束时间")
// @NotNull(message="结束时间不能为空!")
private String endTime;
@ApiModelProperty(value = "事件类型 Evt_Sys_DipStr:电压暂降 Evt_Sys_SwlStr:电压暂升 Evt_Sys_IntrStr:电压中断")
private String eventType;
@ApiModelProperty(value = "位置 grid:电网侧 load:负载侧")
private String location;
}

View File

@@ -0,0 +1,32 @@
package com.njcn.csharmonic.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class DataParam implements Serializable {
@ApiModelProperty("起始时间")
private String startTime;
@ApiModelProperty("结束时间")
private String endTime;
@ApiModelProperty("监测点id")
private String lineId;
@ApiModelProperty("指标统计类型")
private String targetType;
@ApiModelProperty("数据标志")
private String dataLevel;
@ApiModelProperty("数据来源 0:补召 1:在线监测 ")
private Integer dataSource;
}

View File

@@ -0,0 +1,39 @@
package com.njcn.csharmonic.pojo.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author xy
*/
@Data
public class DownloadMakeUpDto implements Serializable {
/**
* 全文件大小
*/
private Integer allStep;
/**
* 监测点id
*/
private String lineId;
/**
* 装置id
*/
private String devId;
/**
* 文件工程名称
*/
private String engineeringName;
/**
* 需要补召的文件集合
*/
private List<String> fileList;
}

View File

@@ -0,0 +1,19 @@
package com.njcn.csharmonic.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class StatisticsDataParam implements Serializable {
@ApiModelProperty("起始时间")
private String startTime;
@ApiModelProperty("结束时间")
private String endTime;
}

View File

@@ -0,0 +1,33 @@
package com.njcn.csharmonic.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class LineIntegrityVo implements Serializable {
@ApiModelProperty("装置id")
private String devId;
@ApiModelProperty("装置名称")
private String devName;
@ApiModelProperty("监测点id")
private String lineId;
@ApiModelProperty("监测点名称")
private String lineName;
@ApiModelProperty("监测点数据完整性")
private Double lineIntegrity;
@ApiModelProperty("终端在线率")
private Double devOnlineRate;
}

View File

@@ -0,0 +1,53 @@
package com.njcn.csharmonic.pojo.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.njcn.influx.utils.InstantDateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.Instant;
/**
* @author xy
*/
@Data
public class RealTimeDataVo implements Serializable {
@ApiModelProperty("数据时间")
@JsonSerialize(using = InstantDateSerializer.class)
private Instant time;
@ApiModelProperty("指标id")
private String id;
@ApiModelProperty("指标名称")
private String name;
@ApiModelProperty("指标别名")
private String otherName;
@ApiModelProperty("相别")
private String phase;
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("排序")
private Integer sort;
@ApiModelProperty("平均值")
private Double avgValue;
@ApiModelProperty("A相值")
private Double valueA;
@ApiModelProperty("B相值")
private Double valueB;
@ApiModelProperty("C相值")
private Double valueC;
@ApiModelProperty("无相值")
private Double valueM;
}

View File

@@ -107,7 +107,12 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>access-api</artifactId>
<version>1.0.0</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>zl-event-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>

View File

@@ -22,6 +22,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
@@ -83,6 +84,16 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventVO, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getFileZip")
@ApiOperation("下载事件原始文件压缩包")
@ApiImplicitParam(name = "eventId", value = "暂态事件索引", required = true)
public void getFileZip(String eventId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("getFileZip");
csEventPOService.getFileZip(eventId,response);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/saveBatchEventList")
@ApiOperation("批量新增事件")

View File

@@ -0,0 +1,65 @@
package com.njcn.csharmonic.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csdevice.pojo.vo.RecordVo;
import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.vo.RealTimeDataVo;
import com.njcn.csharmonic.service.IDataService;
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.web.bind.annotation.*;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@RestController
@RequestMapping("/data")
@Api(tags = "装置数据")
@AllArgsConstructor
public class DataController extends BaseController {
private final IDataService dataService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/realTimeData")
@ApiOperation("设备监控-》准实时数据")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<RealTimeDataVo>> realTimeData(@RequestBody DataParam param) {
String methodDescribe = getMethodDescribe("realTimeData");
List<RealTimeDataVo> list = dataService.getRealTimeData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getTestData")
@ApiOperation("设备监控-》测试项数据")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<RecordVo>> getTestData(@RequestBody DataParam param) {
String methodDescribe = getMethodDescribe("getTestData");
List<RecordVo> list = dataService.getTestData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventByItem")
@ApiOperation("方案数据-》根据测试项获取暂态事件")
@ApiImplicitParam(name = "id", value = "id", required = true)
public HttpResult<List<DataGroupEventVO>> getEventByItem(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getEventByItem");
List<DataGroupEventVO> list = dataService.getEventByItem(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -59,13 +59,22 @@ public class EventUserController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryEventpage")
@ApiOperation("事件消息")
@ApiOperation("事件消息(app)")
@ApiImplicitParam(name = "csEventUserQueryPage", value = "暂降事件查询参数", required = true)
public HttpResult<Page<EventDetailVO>> queryEventpage(@RequestBody CsEventUserQueryPage csEventUserQueryPage) {
String methodDescribe = getMethodDescribe("queryEventpage");
Page<EventDetailVO> list = csEventUserPOService.queryEventpage(csEventUserQueryPage);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryEventpageWeb")
@ApiOperation("事件消息(web)")
@ApiImplicitParam(name = "csEventUserQueryPage", value = "暂降事件查询参数", required = true)
public HttpResult<Page<EventDetailVO>> queryEventpageWeb(@RequestBody CsEventUserQueryPage csEventUserQueryPage) {
String methodDescribe = getMethodDescribe("queryEventpageWeb");
Page<EventDetailVO> list = csEventUserPOService.queryEventPageWeb(csEventUserQueryPage);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateStatus")

View File

@@ -74,12 +74,16 @@ public class OfflineDataUploadController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping(value = "/makeUp")
@ApiOperation("设备补")
@ApiOperation("设备补")
@ApiImplicitParam(name = "param", value = "补招参数", required = true)
public HttpResult<String> makeUp(@RequestBody MakeUpParam param) {
String methodDescribe = getMethodDescribe("makeUp");
offlineDataUploadService.startMakeUpData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
boolean result = offlineDataUploadService.startMakeUpData(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "文件补召中,请稍后", methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "文件补召失败", methodDescribe);
}
}
}

View File

@@ -1,10 +1,23 @@
package com.njcn.csharmonic.controller;
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.csharmonic.service.RealDataService;
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;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -21,9 +34,40 @@ import org.springframework.web.bind.annotation.RestController;
@AllArgsConstructor
public class RealDataController extends BaseController {
private final RealDataService realDataService;
private final RedisUtil redisUtil;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getBaseRealData")
@ApiOperation("获取基础实时数据")
@ApiImplicitParam(name = "lineId", value = "监测点id")
public HttpResult<Boolean> getRealData(@RequestParam("lineId") String lineId) {
String methodDescribe = getMethodDescribe("getRealData");
boolean result = realDataService.getBaseRealData(lineId);
redisUtil.saveByKeyWithExpire("rtDataUserId:"+lineId, RequestUtil.getUserIndex(),600L);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getHarmRealData")
@ApiOperation("获取谐波实时数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "lineId", value = "监测点id"),
@ApiImplicitParam(name = "target", value = "指标名称 0:谐波电压含有率 1:谐波电流幅值 2:间谐波电压含有率"),
})
public HttpResult<Boolean> getHarmRealData(@RequestParam("lineId") String lineId, @RequestParam("target") Integer target) {
String methodDescribe = getMethodDescribe("getHarmRealData");
redisUtil.saveByKeyWithExpire("rtDataUserId:"+lineId, RequestUtil.getUserIndex(),600L);
boolean result = realDataService.getHarmRealData(lineId,target);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
}

View File

@@ -0,0 +1,45 @@
package com.njcn.csharmonic.controller;
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.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.csharmonic.pojo.vo.LineIntegrityVo;
import com.njcn.csharmonic.service.IStatisticsDataDataService;
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.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 xy
*/
@Slf4j
@RestController
@RequestMapping("/statisticsData")
@Api(tags = "统计数据")
@AllArgsConstructor
public class StatisticsDataDataController extends BaseController {
private final IStatisticsDataDataService statisticsDataDataService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/devData")
@ApiOperation("装置数据统计(监测点完整性、装置在线率)")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<LineIntegrityVo>> getDevData(@RequestBody StatisticsDataParam param) {
String methodDescribe = getMethodDescribe("getDevData");
List<LineIntegrityVo> list = statisticsDataDataService.getDevData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -2,11 +2,18 @@ package com.njcn.csharmonic.handler;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
import com.github.tocrhz.mqtt.annotation.NamedValue;
import com.github.tocrhz.mqtt.annotation.Payload;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.access.api.CsTopicFeignClient;
import com.njcn.access.utils.ChannelObjectUtil;
import com.njcn.access.utils.FileCommonUtils;
import com.njcn.csdevice.api.DevCapacityFeignClient;
import com.njcn.csdevice.api.DeviceFtpFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.param.FrequencyStatisticalQueryParam;
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
@@ -15,9 +22,12 @@ import com.njcn.csharmonic.service.ILineTargetService;
import com.njcn.csharmonic.service.StableDataService;
import com.njcn.csharmonic.service.TemperatureService;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.oss.constant.OssPath;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.CsStatisticalSetFeignClient;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.zlevent.api.FileFeignClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -44,7 +54,7 @@ import java.util.stream.Stream;
public class MqttMessageHandler {
private final MqttPublisher publisher;
private final FileCommonUtils fileCommonUtils;
private final ILineTargetService lineTargetService;
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
private final StableDataService stableDataService;
@@ -55,6 +65,13 @@ public class MqttMessageHandler {
private final DevCapacityFeignClient devCapacityFeignClient;
private final DecimalFormat df = new DecimalFormat("#0.000");
private final ChannelObjectUtil channelObjectUtil;
private final EquipmentFeignClient equipmentFeignClient;
private final CsTopicFeignClient csTopicFeignClient;
private final DeviceFtpFeignClient deviceFtpFeignClient;
private static Integer mid = 1;
private final FileFeignClient fileFeignClient;
/**
* 实时数据应答
*/
@@ -78,233 +95,216 @@ public class MqttMessageHandler {
/**
* 实时数据应答
*/
@MqttSubscribe(value = "/zl/askDevData/{devId}",qos = 1)
public void responseTopoData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
String topoDataJson =redisUtil.getStringByKey (devId);
if(StringUtils.isEmpty(topoDataJson)){
List<ThdDataVO> result = new ArrayList<>();
List<ThdDataVO> tempList = new ArrayList<>();
// @MqttSubscribe(value = "/zl/askDevData/{devId}",qos = 1)
// public void responseTopoData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
// String topoDataJson =redisUtil.getStringByKey (devId);
// if(StringUtils.isEmpty(topoDataJson)){
// List<ThdDataVO> result = new ArrayList<>();
// List<ThdDataVO> tempList = new ArrayList<>();
//
// //1.查询拓扑图配置的指标:拓扑图扑图配置7677f94c749dedaff30f911949cbd724
// List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect("b934664f9592d1c5e92caa90695b7103").getData();
// data.forEach(temp->{
// if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){
// FrequencyStatisticalQueryParam frequencyStatisticalQueryParam = new FrequencyStatisticalQueryParam();
// frequencyStatisticalQueryParam.setDevId(devId);
// frequencyStatisticalQueryParam.setStatisticalId(temp.getId());
// frequencyStatisticalQueryParam.setValueType("avg");
// frequencyStatisticalQueryParam.setFrequencyStart(temp.getHarmStart());
// frequencyStatisticalQueryParam.setFrequencyEnd(temp.getHarmEnd());
// List<ThdDataVO> thdDataVOList = stableDataService.QuerySqlData(frequencyStatisticalQueryParam);
// tempList.addAll(thdDataVOList);
//
// }else {
// CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam();
// commonStatisticalQueryParam.setDevId(devId);
// commonStatisticalQueryParam.setStatisticalId(temp.getId());
// commonStatisticalQueryParam.setValueType("avg");
// List<ThdDataVO> listFuture= stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
// tempList.addAll(listFuture);
// }
//
// });
// //过滤M相
// List<ThdDataVO> m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
// m.stream().forEach(temp->{
// Stream.of("A","B","C").forEach(phase->{
// ThdDataVO thdDataVO = new ThdDataVO();
// BeanUtils.copyProperties(temp,thdDataVO);
// thdDataVO.setPhase(phase);
// result.add(thdDataVO);
// });
// });
// List<ThdDataVO> apfThdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Load(%)")).collect(Collectors.toList());
// Map<String, List<ThdDataVO>> collect3 = apfThdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
// collect3.forEach((k,v)->{
// if(!CollectionUtil.isEmpty(v)){
// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
// ThdDataVO thdDataVO = new ThdDataVO();
// BeanUtils.copyProperties(v.get(0),thdDataVO);
// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
// thdDataVO.setPhase("avg");
// result.add(thdDataVO);
// }
// });
// List<ThdDataVO> apfRmsI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_RmsI_TolOut(A)")).collect(Collectors.toList());
// Map<String, List<ThdDataVO>> collect2 = apfRmsI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
// collect2.forEach((k,v)->{
// if(!CollectionUtil.isEmpty(v)){
// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
// ThdDataVO thdDataVO = new ThdDataVO();
// BeanUtils.copyProperties(v.get(0),thdDataVO);
// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
// thdDataVO.setPhase("avg");
// result.add(thdDataVO);
// }
// });
// List<ThdDataVO> apfThdISys = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Sys(%)")).collect(Collectors.toList());
// Map<String, List<ThdDataVO>> collect4 = apfThdISys.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
// collect4.forEach((k,v)->{
// if(!CollectionUtil.isEmpty(v)){
// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
// ThdDataVO thdDataVO = new ThdDataVO();
// BeanUtils.copyProperties(v.get(0),thdDataVO);
// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
// thdDataVO.setPhase("avg");
// result.add(thdDataVO);
//
// }
// });
// Double capacity = devCapacityFeignClient.getDevCapacity(devId).getData();
// apfRmsI.forEach(temp->{
// ThdDataVO thdDataVO = new ThdDataVO();
// BeanUtils.copyProperties(temp,thdDataVO);
// thdDataVO.setUnit("%");
// thdDataVO.setStatisticalName("load_Rate");
// thdDataVO.setAnotherName("负载率");
// if (capacity<=0){
// thdDataVO.setStatisticalData(3.1415926);
// }else {
// double v = temp.getStatisticalData()*100 / capacity;
// thdDataVO.setStatisticalData(Double.valueOf(df.format(v)));
// }
// result.add(thdDataVO);
// });
// List<ThdDataVO> notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
// result.addAll(notM);
// Gson gson = new Gson();
// topoDataJson = gson.toJson(result);
// redisUtil.saveByKeyWithExpire(devId, (Object) topoDataJson, 30L);
// }
// publisher.send("/zl/devData/"+devId,topoDataJson,1,false);
// }
/**
* 实时数据应答
*/
@MqttSubscribe(value = "/zl/askDevData/{devId}/{typeId}",qos = 1)
public void responseTopoDataByType(String topic, @NamedValue("devId") String devId,@NamedValue("typeId") String typeId, MqttMessage message, @Payload String payload) {
String topoDataJson =redisUtil.getStringByKey (devId+"#"+typeId);
if(StringUtils.isEmpty(topoDataJson)){
List<ThdDataVO> result = new ArrayList<>();
List<ThdDataVO> tempList = new ArrayList<>();
//1.查询拓扑图配置的指标:拓扑图扑图配置7677f94c749dedaff30f911949cbd724
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect("b934664f9592d1c5e92caa90695b7103").getData();
data.forEach(temp->{
if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){
FrequencyStatisticalQueryParam frequencyStatisticalQueryParam = new FrequencyStatisticalQueryParam();
frequencyStatisticalQueryParam.setDevId(devId);
frequencyStatisticalQueryParam.setStatisticalId(temp.getId());
frequencyStatisticalQueryParam.setValueType("avg");
frequencyStatisticalQueryParam.setFrequencyStart(temp.getHarmStart());
frequencyStatisticalQueryParam.setFrequencyEnd(temp.getHarmEnd());
List<ThdDataVO> thdDataVOList = stableDataService.QuerySqlData(frequencyStatisticalQueryParam);
tempList.addAll(thdDataVOList);
//1.查询拓扑图配置的指标:拓扑图扑图配置7677f94c749dedaff30f911949cbd724
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect(typeId).getData();
data.forEach(temp->{
if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){
FrequencyStatisticalQueryParam frequencyStatisticalQueryParam = new FrequencyStatisticalQueryParam();
frequencyStatisticalQueryParam.setDevId(devId);
frequencyStatisticalQueryParam.setStatisticalId(temp.getId());
frequencyStatisticalQueryParam.setValueType("avg");
frequencyStatisticalQueryParam.setFrequencyStart(temp.getHarmStart());
frequencyStatisticalQueryParam.setFrequencyEnd(temp.getHarmEnd());
List<ThdDataVO> thdDataVOList = stableDataService.QuerySqlData(frequencyStatisticalQueryParam);
tempList.addAll(thdDataVOList);
}else {
CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam();
commonStatisticalQueryParam.setDevId(devId);
commonStatisticalQueryParam.setStatisticalId(temp.getId());
commonStatisticalQueryParam.setValueType("avg");
List<ThdDataVO> listFuture= stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
tempList.addAll(listFuture);
}
}else {
CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam();
commonStatisticalQueryParam.setDevId(devId);
commonStatisticalQueryParam.setStatisticalId(temp.getId());
commonStatisticalQueryParam.setValueType("avg");
List<ThdDataVO> listFuture= stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
tempList.addAll(listFuture);
}
});
//过滤M相
List<ThdDataVO> m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
m.stream().forEach(temp->{
Stream.of("A","B","C").forEach(phase->{
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(temp,thdDataVO);
thdDataVO.setPhase(phase);
result.add(thdDataVO);
});
});
List<ThdDataVO> apfThdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Load(%)")).collect(Collectors.toList());
Map<String, List<ThdDataVO>> collect3 = apfThdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
collect3.forEach((k,v)->{
if(!CollectionUtil.isEmpty(v)){
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(v.get(0),thdDataVO);
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
thdDataVO.setPhase("avg");
result.add(thdDataVO);
}
});
List<ThdDataVO> apfRmsI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_RmsI_TolOut(A)")).collect(Collectors.toList());
Map<String, List<ThdDataVO>> collect2 = apfRmsI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
collect2.forEach((k,v)->{
if(!CollectionUtil.isEmpty(v)){
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(v.get(0),thdDataVO);
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
thdDataVO.setPhase("avg");
result.add(thdDataVO);
}
});
List<ThdDataVO> apfThdISys = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Sys(%)")).collect(Collectors.toList());
Map<String, List<ThdDataVO>> collect4 = apfThdISys.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
collect4.forEach((k,v)->{
if(!CollectionUtil.isEmpty(v)){
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(v.get(0),thdDataVO);
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
thdDataVO.setPhase("avg");
result.add(thdDataVO);
});
}
});
Double capacity = devCapacityFeignClient.getDevCapacity(devId).getData();
apfRmsI.forEach(temp->{
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(temp,thdDataVO);
thdDataVO.setUnit("%");
thdDataVO.setStatisticalName("load_Rate");
thdDataVO.setAnotherName("负载率");
if (capacity<=0){
thdDataVO.setStatisticalData(3.1415926);
}else {
double v = temp.getStatisticalData()*100 / capacity;
thdDataVO.setStatisticalData(Double.valueOf(df.format(v)));
}
result.add(thdDataVO);
});
List<ThdDataVO> notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
result.addAll(notM);
Gson gson = new Gson();
topoDataJson = gson.toJson(result);
redisUtil.saveByKeyWithExpire(devId, (Object) topoDataJson, 30L);
}
publisher.send("/zl/devData/"+devId,topoDataJson,1,false);
//过滤M相
List<ThdDataVO> m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
m.stream().forEach(temp->{
Stream.of("A","B","C").forEach(phase->{
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(temp,thdDataVO);
thdDataVO.setPhase(phase);
result.add(thdDataVO);
});
});
//如果是基础数据则添加拓扑图的数据
if(Objects.equals("fc8c86dbc3f2d9810f5cd8f53c295415",typeId)){
List<ThdDataVO> apfThdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Load(%)")).collect(Collectors.toList());
Map<String, List<ThdDataVO>> collect3 = apfThdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
collect3.forEach((k,v)->{
if(!CollectionUtil.isEmpty(v)){
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(v.get(0),thdDataVO);
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
thdDataVO.setPhase("avg");
result.add(thdDataVO);
}
});
List<ThdDataVO> apfRmsI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_RmsI_TolOut(A)")).collect(Collectors.toList());
Map<String, List<ThdDataVO>> collect2 = apfRmsI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
collect2.forEach((k,v)->{
if(!CollectionUtil.isEmpty(v)){
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(v.get(0),thdDataVO);
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
thdDataVO.setPhase("avg");
result.add(thdDataVO);
}
});
List<ThdDataVO> apfThdISys = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Sys(%)")).collect(Collectors.toList());
Map<String, List<ThdDataVO>> collect4 = apfThdISys.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
collect4.forEach((k,v)->{
if(!CollectionUtil.isEmpty(v)){
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(v.get(0),thdDataVO);
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
thdDataVO.setPhase("avg");
result.add(thdDataVO);
}
});
Double capacity = devCapacityFeignClient.getDevCapacity(devId).getData();
apfRmsI.forEach(temp->{
ThdDataVO thdDataVO = new ThdDataVO();
BeanUtils.copyProperties(temp,thdDataVO);
thdDataVO.setUnit("%");
thdDataVO.setStatisticalName("load_Rate");
thdDataVO.setAnotherName("负载率");
if (capacity<=0){
thdDataVO.setStatisticalData(3.1415926);
}else {
double v = temp.getStatisticalData()*100 / capacity;
thdDataVO.setStatisticalData(Double.valueOf(df.format(v)));
}
result.add(thdDataVO);
});
}
List<ThdDataVO> notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
result.addAll(notM);
Gson gson = new Gson();
topoDataJson = gson.toJson(result);
redisUtil.saveByKeyWithExpire(devId+"#"+typeId, (Object) topoDataJson, 30L);
}
publisher.send("/zl/devData/"+devId+"/"+typeId,topoDataJson,1,false);
}
// @MqttSubscribe(value = "/zl/askDvrData/{devId}",qos = 1)
// public void responseDvrData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
// String topoDataJson =redisUtil.getStringByKey (devId+"DVR");
// if(StringUtils.isEmpty(topoDataJson)){
// List<ThdDataVO> result = new ArrayList<>();
// List<ThdDataVO> tempList = new ArrayList<>();
//
//
// //1.查询DVR配置的指标:DVR配置9fc1de386b623a1339977e168a23ad97
// List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect("9fc1de386b623a1339977e168a23ad97").getData();
// data.forEach(temp->{
// if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){
//
// FrequencyStatisticalQueryParam frequencyStatisticalQueryParam = new FrequencyStatisticalQueryParam();
// frequencyStatisticalQueryParam.setDevId(devId);
// frequencyStatisticalQueryParam.setStatisticalId(temp.getId());
// frequencyStatisticalQueryParam.setValueType("avg");
// frequencyStatisticalQueryParam.setFrequencyStart(temp.getHarmStart());
// frequencyStatisticalQueryParam.setFrequencyEnd(temp.getHarmEnd());
// List<ThdDataVO> thdDataVOList = stableDataService.QuerySqlData(frequencyStatisticalQueryParam);
// tempList.addAll(thdDataVOList);
//
// }else {
// CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam();
// commonStatisticalQueryParam.setDevId(devId);
// commonStatisticalQueryParam.setStatisticalId(temp.getId());
// commonStatisticalQueryParam.setValueType("avg");
// List<ThdDataVO> listFuture= stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
// tempList.addAll(listFuture);
// }
//
// });
//
// //过滤M相
//// List<ThdDataVO> m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
//// m.stream().forEach(temp->{
//// Stream.of("A","B","C").forEach(phase->{
//// ThdDataVO thdDataVO = new ThdDataVO();
//// BeanUtils.copyProperties(temp,thdDataVO);
//// thdDataVO.setPhase(phase);
//// result.add(thdDataVO);
//// });
//// });
//// //过滤谐波电流,谐波电压畸变率求平均值
//// List<ThdDataVO> thdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Pq_ThdU(%)")).collect(Collectors.toList());
//// Map<String, List<ThdDataVO>> collect = thdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
//// collect.forEach((k,v)->{
//// if(!CollectionUtil.isEmpty(v)){
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
//// ThdDataVO thdDataVO = new ThdDataVO();
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
//// thdDataVO.setPhase("avg");
//// result.add(thdDataVO);
////
//// }
//// });
////
//// List<ThdDataVO> thdV = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Pq_ThdI(%)")).collect(Collectors.toList());
//// Map<String, List<ThdDataVO>> collect1 = thdV.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
//// collect1.forEach((k,v)->{
//// if(!CollectionUtil.isEmpty(v)){
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
//// ThdDataVO thdDataVO = new ThdDataVO();
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
//// thdDataVO.setPhase("avg");
//// result.add(thdDataVO);
////
//// }
//// });
//// List<ThdDataVO> apfThdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Load(%)")).collect(Collectors.toList());
//// Map<String, List<ThdDataVO>> collect3 = apfThdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
//// collect3.forEach((k,v)->{
//// if(!CollectionUtil.isEmpty(v)){
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
//// ThdDataVO thdDataVO = new ThdDataVO();
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
//// thdDataVO.setPhase("avg");
//// result.add(thdDataVO);
////
//// }
//// });
//// List<ThdDataVO> apfRmsI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_RmsI_TolOut(A)")).collect(Collectors.toList());
//// Map<String, List<ThdDataVO>> collect2 = apfRmsI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
//// collect2.forEach((k,v)->{
//// if(!CollectionUtil.isEmpty(v)){
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
//// ThdDataVO thdDataVO = new ThdDataVO();
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
//// thdDataVO.setPhase("avg");
//// result.add(thdDataVO);
////
//// }
//// });
//// List<ThdDataVO> apfThdISys = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Sys(%)")).collect(Collectors.toList());
//// Map<String, List<ThdDataVO>> collect4 = apfThdISys.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
//// collect4.forEach((k,v)->{
//// if(!CollectionUtil.isEmpty(v)){
//// double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
//// ThdDataVO thdDataVO = new ThdDataVO();
//// BeanUtils.copyProperties(v.get(0),thdDataVO);
//// thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
//// thdDataVO.setPhase("avg");
//// result.add(thdDataVO);
////
//// }
//// });
////
//// List<ThdDataVO> notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
//
// result.addAll(tempList);
//
//
//
// Gson gson = new Gson();
// topoDataJson = gson.toJson(result);
// redisUtil.saveByKeyWithExpire(devId+"DVR", (Object) topoDataJson,Long.valueOf(10*60));
// }
//
//
// publisher.send("/zl/DvrData/"+devId,topoDataJson,1,false);
// }
public String getCldidName( String cldid) {
@@ -357,4 +357,14 @@ public class MqttMessageHandler {
// return thdDataVOList;
// }
// }
/**
* 处理补召数据
*/
@MqttSubscribe(value = "/makeUpData/{nDid}/{lineId}",qos = 1)
public void responseRtData(String topic, @NamedValue("nDid") String nDid, @NamedValue("lineId") String lineId, MqttMessage message, @Payload String payload) {
//下载文件
fileFeignClient.downloadMakeUpFile(nDid);
}
}

View File

@@ -0,0 +1,16 @@
package com.njcn.csharmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.CsDataSet;
/**
* <p>
* 数据集表 Mapper 接口
* </p>
*
* @author xuyang
* @since 2023-05-31
*/
public interface CsDataSetMapper extends BaseMapper<CsDataSet> {
}

View File

@@ -24,4 +24,6 @@ public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
List<EventDetailVO> queryUserEventList(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag);
Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag);
Page<EventDetailVO> queryEventPageWeb(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("devIds") List<String> collect);
}

View File

@@ -117,4 +117,58 @@
</if>
order by b.start_time desc
</select>
<select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
select DISTINCT b.id id,
b.device_id deviceId,b.line_id lineId,b.code code,
b.start_time startTime,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 ">
,d.name lineName
</if>
from cs_event b
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 ">
inner join cs_equipment_delivery c on b.device_id=c.id inner join cs_line d on d.device_id=b.device_id and d.clDid=b.cl_did
</if>
where 1=1
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 ">
and b.process=c.process
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.endTime != null and csEventUserQueryPage.endTime !=''">
AND DATE(b.start_time) &lt;= DATE(#{csEventUserQueryPage.endTime})
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.startTime != null and csEventUserQueryPage.startTime !=''">
AND DATE(b.start_time) &gt;= DATE(#{csEventUserQueryPage.startTime})
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.target != null and csEventUserQueryPage.target.size()>0">
and b.tag in
<foreach collection="csEventUserQueryPage.target" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and b.device_id in
<foreach collection="devIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''">
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type == 3 ">
AND b.type in(2,3)
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 ">
AND b.type =#{ csEventUserQueryPage.type}
</if>
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
AND b.level = #{ csEventUserQueryPage.level}
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.eventType != null and csEventUserQueryPage.eventType !=''">
AND b.tag = #{csEventUserQueryPage.eventType}
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.location != null and csEventUserQueryPage.location !=''">
AND b.location = #{csEventUserQueryPage.location}
</if>
order by b.start_time desc
</select>
</mapper>

View File

@@ -10,6 +10,8 @@ import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -46,4 +48,8 @@ public interface CsEventPOService extends IService<CsEventPO>{
Page<DataGroupEventVO> pageQueryByLineId(CsEventUserQueryPage csEventUserQueryPage);
void saveBatchEventList(List<CsEventPO> csEventPOS);
void getFileZip(String eventId,HttpServletResponse response);
List<DataGroupEventVO> queryEventList(LocalDateTime startDate, LocalDateTime endDate, String lineId);
}

View File

@@ -27,4 +27,6 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
void updateStatus(CsEventUserQueryParam csEventUserQueryParam);
Page<EventDetailVO> queryEventpage(CsEventUserQueryPage csEventUserQueryPage);
Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage);
}

View File

@@ -0,0 +1,32 @@
package com.njcn.csharmonic.service;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csdevice.pojo.vo.RecordVo;
import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.vo.RealTimeDataVo;
import java.util.List;
/**
* @author xuyang
*/
public interface IDataService {
/**
* 获取设备准实时数据
* @param param
* @return
*/
List<RealTimeDataVo> getRealTimeData(DataParam param);
/**
* 获取监测点测试项信息
*/
List<RecordVo> getTestData(DataParam param);
/**
* 根据测试项id获取时间范围内的暂态事件
*/
List<DataGroupEventVO> getEventByItem(String id);
}

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