148 Commits

Author SHA1 Message Date
caozehui
3f1ae1886a Merge remote-tracking branch 'origin/qr_branch' into qr_branch 2025-12-19 16:17:40 +08:00
caozehui
af4863af65 2楼报告封面调整:装置编码改成装置编号 2025-12-19 16:17:33 +08:00
2012221b73 河北报告定制化改动 2025-12-02 13:37:35 +08:00
caozehui
f4df52dd1c 暂态只有a项时,当a相无数据时判断为不符合 2025-11-27 18:36:38 +08:00
41c557118c Merge remote-tracking branch 'origin/qr_branch' into qr_branch 2025-11-26 10:22:15 +08:00
6596a572d6 修复数模式的相序校验电流加量问题 2025-11-26 10:17:33 +08:00
caozehui
786bd5d660 报告调整 2025-11-19 13:20:35 +08:00
caozehui
21d2c2b7a7 报告调整 2025-11-19 13:20:17 +08:00
caozehui
48fa4c2390 报告日期格式根据参数动态变化 2025-11-19 10:43:52 +08:00
caozehui
9d15351fba 微调 2025-11-06 09:25:09 +08:00
caozehui
2339a006ec 补充源未知异常推送消息 2025-11-06 08:51:54 +08:00
caozehui
7fd904ab79 系数校准接收数据个数调整 2025-11-05 16:02:53 +08:00
caozehui
40cb153656 报告模板调整 2025-11-03 08:38:57 +08:00
caozehui
f922ee97aa 报告路径,报告名称修改 2025-10-30 09:06:40 +08:00
caozehui
26c5e933f5 微调 2025-10-29 09:01:45 +08:00
caozehui
c7d8fc3168 报告封面微调 2025-10-22 11:05:21 +08:00
caozehui
bb22857fc9 报告微调 2025-10-21 15:42:22 +08:00
caozehui
6ef908ff60 微调 2025-09-03 20:32:14 +08:00
caozehui
7461801657 微调 2025-09-03 16:18:52 +08:00
caozehui
4ecec5e6ef 新增PQ-COM设备类型报告模板、修改系数校准抛数据组数 2025-09-03 14:25:32 +08:00
caozehui
04a667531b 绝对值脚本-暂态bug 2025-08-04 09:56:51 +08:00
caozehui
a0f6846f53 微调 2025-07-31 13:26:01 +08:00
caozehui
a177d7991c 报告模板调整 2025-07-31 08:54:42 +08:00
caozehui
f8fb45cf6f 新增报告模板 2025-07-30 14:42:04 +08:00
caozehui
910069a463 微调 2025-07-25 09:31:46 +08:00
56477157aa 出厂检测检测报告改造 2025-07-24 16:29:31 +08:00
a6b0509179 二维码下装独立抽取 2025-07-18 14:38:02 +08:00
caozehui
b5e5286411 Merge remote-tracking branch 'origin/master' 2025-07-03 16:33:34 +08:00
caozehui
d01c0e14c0 切换不同设备类型时上送数据缺少部分通道的数据 2025-07-03 16:33:04 +08:00
hzj
0cf8bbc3d5 初始版本提交 2025-07-03 14:21:15 +08:00
hzj
3a239b5123 初始版本提交 2025-07-03 11:36:33 +08:00
hzj
0eabe977cb 初始版本提交 2025-07-03 11:13:17 +08:00
hzj
f1f86ea854 初始版本提交 2025-07-03 11:12:05 +08:00
caozehui
e048c92ad1 Merge remote-tracking branch 'origin/master' 2025-07-03 11:02:31 +08:00
caozehui
65f46a22f5 微调 2025-07-03 11:02:18 +08:00
5d4cce365e 超过1000条报错事件处理 2025-07-03 09:54:13 +08:00
caozehui
b4c9bd12c9 楼下封面模板修改 2025-07-03 09:37:58 +08:00
caozehui
8a11a9e5b1 楼下封面模板替换createId失败bug 2025-07-03 08:36:17 +08:00
hzj
b2738e1726 初始版本提交 2025-07-02 17:08:55 +08:00
hzj
5d16d6c494 初始版本提交 2025-07-02 13:23:41 +08:00
hzj
2693015dab 初始版本提交 2025-07-02 11:37:26 +08:00
hzj
3ecffc99b8 初始版本提交 2025-07-02 09:36:19 +08:00
9c02a7cb8e 调整 2025-07-01 21:00:38 +08:00
hzj
a4edf8b3f6 初始版本提交 2025-07-01 20:12:14 +08:00
8328d6c06e 调整 2025-07-01 19:04:32 +08:00
hzj
2ac33e8cec 初始版本提交 2025-07-01 18:44:08 +08:00
hzj
bbb911c917 初始版本提交 2025-07-01 18:28:19 +08:00
caozehui
bef9723255 微调 2025-07-01 15:10:54 +08:00
caozehui
47e3e5218d 切换场景 2025-07-01 14:44:38 +08:00
hzj
72800e1e44 初始版本提交 2025-07-01 13:50:09 +08:00
f6547b02a4 配置文件调整 2025-07-01 13:39:42 +08:00
hzj
8fb22017d3 初始版本提交 2025-07-01 11:24:58 +08:00
caozehui
6f8070c85f Merge remote-tracking branch 'origin/master' 2025-07-01 11:12:48 +08:00
c09a0f4b85 Merge remote-tracking branch 'origin/master' 2025-07-01 11:06:03 +08:00
ba22f2b796 代码调整 2025-07-01 11:05:52 +08:00
hzj
f62aa1f7f7 初始版本提交 2025-07-01 11:03:09 +08:00
caozehui
f19a467300 微调 2025-07-01 10:47:59 +08:00
hzj
f4550b9c76 初始版本提交 2025-07-01 09:32:52 +08:00
caozehui
a5791ef76b 通过尝试ftp连接将二维码文件下装到装置中 2025-07-01 08:46:01 +08:00
caozehui
dff4b556eb Merge remote-tracking branch 'origin/master' 2025-07-01 08:44:30 +08:00
hzj
c013cd2eac 初始版本提交 2025-06-30 20:52:31 +08:00
dc366ae1c3 Merge remote-tracking branch 'origin/master' 2025-06-30 16:08:37 +08:00
a9d2ba8dde 波形文件 2025-06-30 16:08:24 +08:00
hzj
de138328e9 初始版本提交 2025-06-30 16:02:49 +08:00
caozehui
757501efa8 二楼生成报告谐波电流值有误bug 2025-06-30 14:15:35 +08:00
hzj
73028c70d2 初始版本提交 2025-06-30 13:39:45 +08:00
hzj
bdb3efd81d 初始版本提交 2025-06-30 11:06:05 +08:00
20423028f7 代码调整 2025-06-30 10:18:44 +08:00
hzj
6442219087 初始版本提交 2025-06-30 10:15:06 +08:00
hzj
a0148badaf 初始版本提交 2025-06-30 09:53:52 +08:00
8745f8bbbe 代码调整 2025-06-30 09:47:54 +08:00
hzj
277b1710fa 初始版本提交 2025-06-30 08:59:02 +08:00
1115520106 远程通知反馈接口 2025-06-30 08:34:57 +08:00
hzj
c8b63a7a7a 初始版本提交 2025-06-27 16:27:51 +08:00
hzj
1ed27ed29f 初始版本提交 2025-06-27 14:18:04 +08:00
hzj
072a2b6bfc 初始版本提交 2025-06-27 14:16:42 +08:00
caozehui
b2bb7c3901 全局配置小数精度 2025-06-27 13:33:46 +08:00
hzj
ad2752197a 初始版本提交 2025-06-27 13:28:31 +08:00
424a81ac53 远程通知反馈接口 2025-06-27 10:19:59 +08:00
hzj
38332616fa 初始版本提交 2025-06-27 08:53:13 +08:00
118068bafe 实体提交 2025-06-26 15:08:36 +08:00
8103b45a61 暂降事件详情提交 2025-06-26 13:27:06 +08:00
caozehui
ef4c4a0a17 1、手动检测根据检测内容不同动态决定是否进行初始化操作
2、检测结果原始数据时间展示毫秒值
2025-06-26 13:18:01 +08:00
caozehui
31a2311698 原始数据时间戳问题 2025-06-26 10:52:12 +08:00
hzj
9937c3cb5f 初始版本提交 2025-06-26 09:23:55 +08:00
482d7f6ce5 暂降事件处理 2025-06-25 21:02:30 +08:00
hzj
5905c0b438 初始版本提交 2025-06-25 16:29:03 +08:00
594ac7d4d4 调整 2025-06-25 16:18:48 +08:00
9d2aad81e4 数据库分页,类型配置,默认mysql 2025-06-25 16:01:23 +08:00
6b1303d250 临时调整 2025-06-25 15:44:43 +08:00
c45800f6d5 权限控制 2025-06-25 09:06:22 +08:00
hzj
74cdfaf882 初始版本提交 2025-06-24 16:16:49 +08:00
caozehui
34ff162db1 正式检测之前清空保存数据的集合 2025-06-24 13:23:29 +08:00
hzj
bd6af21b99 初始版本提交 2025-06-24 10:32:12 +08:00
f0566a5969 权限控制 2025-06-24 08:50:54 +08:00
76a571921a 自动检测代码 2025-06-23 20:00:40 +08:00
512ed2a542 自动检测代码 2025-06-23 10:57:24 +08:00
caozehui
c2c5c9668e 微调 2025-06-23 09:26:02 +08:00
hzj
a0b0023def 初始版本提交 2025-06-20 15:52:59 +08:00
a11189d85c 调整二楼提出的意见 2025-06-20 14:21:41 +08:00
ed54f79983 配置提交 2025-06-20 09:10:53 +08:00
hzj
f03622ac5b 初始版本提交 2025-06-19 15:10:39 +08:00
hzj
bf3fe9450f 初始版本提交 2025-06-19 15:09:46 +08:00
b4e2727c58 二维码功能开发 2025-06-19 14:44:08 +08:00
977ab4bf1b socket通讯调整 2025-06-19 14:33:28 +08:00
d26504c841 socket通讯处理 2025-06-19 14:19:12 +08:00
418e17a427 添加暂降智能响应模块 2025-06-19 08:43:26 +08:00
4e0e50a4f8 二维码功能开发 2025-06-18 17:53:09 +08:00
e05403bfa7 优化部分代码 2025-06-12 15:47:22 +08:00
b1a2ccd018 优化部分代码 2025-06-12 14:54:58 +08:00
10f39b44a2 优化部分代码 2025-06-09 20:24:55 +08:00
9eca074ffb 优化部分代码 2025-06-09 20:09:35 +08:00
9820d0a915 优化部分代码 2025-06-06 11:34:02 +08:00
caozehui
525de0c24c 微调 2025-06-05 18:36:28 +08:00
caozehui
744c72dea2 微调 2025-06-04 22:15:17 +08:00
caozehui
b4114f19de 微调 2025-06-03 19:53:17 +08:00
caozehui
b0dde94314 微调 2025-06-03 11:31:56 +08:00
caozehui
da7015fd89 微调 2025-05-30 16:26:32 +08:00
caozehui
9058c9081b 微调 2025-05-30 15:48:59 +08:00
caozehui
34f317780e 微调 2025-05-29 10:50:17 +08:00
caozehui
708b40880e 微调 2025-05-27 15:54:31 +08:00
caozehui
bf661b5c1c 微调 2025-05-26 16:24:21 +08:00
caozehui
57b08a99c6 1、检测计划、被检设备导入导出功能调整
2、多台设备类型同时进行脚本与ICD检验时Socket异常中断
2025-05-26 15:21:21 +08:00
8bc8a97e83 优化部分代码 2025-05-26 14:26:57 +08:00
caozehui
53548aec32 监测计划导出bug 2025-05-23 16:33:04 +08:00
caozehui
1380af6d50 复检测试项bug、设备连接异常提示信息、心跳空指针异常 2025-05-23 15:34:01 +08:00
caozehui
21dcd87be2 1、切换误差体系后报告生成bug
2、正式检测时,内外数据结果不一致
2025-05-23 10:04:35 +08:00
caozehui
fb97e421bb 1、暂态-电压幅值单位问题
2、脚本与ICD校验时10500错误码
3、前端断开WebSocket连接后,后台服务没有关闭和源、设备的Socket连接问题
2025-05-22 20:01:58 +08:00
caozehui
4f2ae176fa 微调 2025-05-21 15:11:42 +08:00
caozehui
06e21711f2 微调 2025-05-20 16:26:50 +08:00
caozehui
95c564595f 微调 2025-05-16 16:12:47 +08:00
caozehui
e725cd8a60 归档前如果设备没有生成报告则自动生成报告 2025-05-16 10:35:14 +08:00
caozehui
8507ad8378 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java
2025-05-15 15:25:10 +08:00
caozehui
cb8495fb0d 数据处理原则-所有值入库数据bug 2025-05-15 15:24:17 +08:00
caozehui
8f8d3d38cc 数据处理原则-所有值入库数据bug 2025-05-15 15:10:09 +08:00
caozehui
7eb80121a1 省级平台在正式检测时增加温度、相对湿度参数 2025-05-15 08:57:36 +08:00
caozehui
3736082096 区分楼下、省级平台场景的报告路径 2025-05-14 09:07:38 +08:00
caozehui
2f303e63a3 检测计划新增数据处理原则字段、全局配置中移除数据处理原则字段 2025-05-14 08:57:24 +08:00
caozehui
ab2e5c346e 微调 2025-05-13 14:41:50 +08:00
caozehui
ebb45238b0 楼下模板表格过宽bug 2025-05-13 11:23:31 +08:00
caozehui
6763721043 脚本检测大项启用/禁用功能 2025-05-12 16:34:42 +08:00
caozehui
e235c3ef66 预检测在相序校验不合格时没有关闭源bug 2025-05-12 14:36:27 +08:00
caozehui
40b0e535cb 不合格项复检bug 2025-05-09 08:51:14 +08:00
caozehui
9438301ebd 微调 2025-05-08 16:07:39 +08:00
caozehui
bfed1b3e93 复检bug 2025-05-08 15:27:52 +08:00
caozehui
a9515f42b3 微调 2025-05-07 14:04:26 +08:00
caozehui
bbb62586f9 微调 2025-05-07 11:33:57 +08:00
caozehui
6aef21797d 微调 2025-05-06 10:43:19 +08:00
194 changed files with 7884 additions and 1761 deletions

View File

@@ -76,10 +76,25 @@
</dependency>
<!-- https://mvnrepository.com/artifact/org.docx4j/docx4j -->
<!-- <dependency>-->
<!-- <groupId>org.docx4j</groupId>-->
<!-- <artifactId>docx4j-core</artifactId>-->
<!-- <version>8.3.8</version>-->
<!-- </dependency>-->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.4</version>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@@ -97,6 +112,18 @@
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>RestTemplate-plugin</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.10.0</version>
</dependency>
</dependencies>

View File

@@ -34,7 +34,8 @@ public class PreDetectionController extends BaseController {
private final PreDetectionService preDetectionService;
/**
* 开始检测
* 开始检测通用入口
* @param param 实体参数
*/
@PostMapping("/startPreTest")
@OperateInfo

View File

@@ -18,6 +18,7 @@ import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.system.pojo.enums.DicDataEnum;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -133,16 +134,13 @@ public class SocketSourceResponseService {
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNKNOWN_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNABLE_TO_RESPOND:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
default:
CnSocketUtil.sendUnSocket(param.getUserPageId());
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
}
}
@@ -196,8 +194,10 @@ public class SocketSourceResponseService {
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
phaseSequenceParam.setMoniterIdList(monitorIdList);
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS"));
phaseSequenceParam.setReadCount(10);
phaseSequenceParam.setIgnoreCount(7);
// 读取3次数据用于系数计算
phaseSequenceParam.setReadCount(7); //3
// 忽略前4次数据等待测量稳定
phaseSequenceParam.setIgnoreCount(3); //4
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
@@ -219,8 +219,8 @@ public class SocketSourceResponseService {
/**
* 装置检测(当源初始化成功后,直接向装置通道向装置服务器发送,装置检测)
*
* @param param
* @param socketDataMsg
* @param param 参数
* @param socketDataMsg 消息
*/
private void detectionDev(PreDetectionParam param, SocketDataMsg socketDataMsg) {
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
@@ -233,9 +233,9 @@ public class SocketSourceResponseService {
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
String s = param.getUserPageId() + DEV;
//开始设备通讯检测(发送设备初始化)
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
//List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
Map<String, List<PreDetection>> map = new HashMap<>(1);
map.put("deviceList", devList);
map.put("deviceList", FormalTestManager.devList);
String jsonString = JSON.toJSONString(map);
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
@@ -375,9 +375,11 @@ public class SocketSourceResponseService {
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
}
}
List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
System.out.println("devList is empty:" + CollectionUtils.isEmpty(devList));
//List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
phaseSequenceParam.setMoniterIdList(moniterIdList);
phaseSequenceParam.setMoniterIdList(monitorIdList);
phaseSequenceParam.setDataType(comm);
phaseSequenceParam.setReadCount(readData);
phaseSequenceParam.setIgnoreCount(ignoreCount);

View File

@@ -13,6 +13,9 @@ public interface DetectionCommunicateConstant {
String DEVICE_CHANNEL_NAME = "AUTO_DETECTION_DEV";
String DEV = "_Dev";
String SOURCE = "_Source";

View File

@@ -55,11 +55,13 @@ public enum SourceOperateCodeEnum {
QUITE_SOURCE("close_source","关闭源通讯"),
ERROR_FLOW_END("error_flow_end","当前流程存在异常结束"),
YXT("yxt","心跳"),
REPORT_CAT("FTP_SEND$01","处理报告"),
UNKNOWN_OPERATE("unknown_operate","未知的操作返回,请联系管理员排查"),
SOCKET_TIMEOUT("socket_timeout","与源或者装置通讯等待超时"),
STOP_TIMEOUT("stop_timeout","暂停时间超过十分钟"),
SERVER_ERROR("server_error","服务端主动关闭连接,请稍后再试"),
DEVICE_ERROR("device_error","设备主动关闭连接,请稍后再试"),
@@ -68,17 +70,18 @@ public enum SourceOperateCodeEnum {
/**
*
*/
COEFFICIENT_TEST("0","系数校验"),
PRE_TEST("1","预检测"),
FORMAL_TEST("2","正式检测"),
TIME_TEST("3","守时检测"),
PHASE_TEST("4","相序检测"),
TEST_TEM_STOP("5","临时停止"),
TEST_TEM_START("6","继续检测"),
TEST_STOP("7","停止检测"),
RE_ERROR_TEST("8","不合格项复检"),
SIMULATE_TEST("9","模拟检测"),
// COEFFICIENT_TEST("0","系数校验"),
// PRE_TEST("1","预检测"),
// FORMAL_TEST("2","正式检测"),
// TIME_TEST("3","守时检测"),
// PHASE_TEST("4","相序检测"),
// TEST_TEM_STOP("5","临时停止"),
ALL_TEST("1","全部检测"),
RE_ERROR_TEST("2","不合格项复检"),
TEST_TEM_START("3","继续检测"),
SIMULATE_TEST("4","模拟检测"),
//TEST_STOP("7","停止检测"),
//FAST_TEST("10","一键检测"),
/**
* 系数校验步骤
@@ -93,6 +96,11 @@ public enum SourceOperateCodeEnum {
small_comp_end("small_comp_end","小电压校准结束"),
/**
* ftp文件传送指令
*/
FTP_SEND_01("FTP_SEND$01", "发送文件")
;

View File

@@ -13,6 +13,7 @@ public enum SourceResponseCodeEnum {
SUCCESS(10200, "请求成功"),
UNPROCESSED_BUSINESS(10201, "立即响应,业务还未处理,类似肯定应答"),
NORMAL_RESPONSE(10202, "正常响应中间状态码"),
ICD_NOT_FOUND(10500, "未找到对应ICD"),
MESSAGE_PARSING_ERROR(10520, "报文解析有误"),
CONTROLLED_SOURCE_ERROR(10521, "程控源参数有误"),
TEST_ITEM_PARSING_ERROR(10522, "测试项解析有误"),

View File

@@ -14,10 +14,7 @@ import java.util.List;
@Data
public class PreDetectionParam {
/**
* 操作类型 0.预检测 1.正式检测 2.系数校验
*/
private String operateType = "0";
private String operateType;
/**
* 检测计划id
@@ -65,4 +62,19 @@ public class PreDetectionParam {
private Boolean sendWebMsg;
private String userId;
/**
* 温度
*/
private Float temperature;
/**
* 相对湿度
*/
private Float humidity;
/**
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
*/
private List<Boolean> testItemList;
}

View File

@@ -12,6 +12,7 @@ import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.po.DevData;
import com.njcn.gather.detection.pojo.vo.DetectionData;
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
import com.njcn.gather.err.pojo.param.PqErrSysParam;
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
@@ -23,8 +24,11 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
import com.njcn.gather.storage.service.DetectionDataDealService;
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
@@ -49,6 +53,7 @@ public class DetectionServiceImpl {
private final IPqErrSysDtlsService pqErrSysDtlsService;
private final IPqScriptCheckDataService pqScriptCheckDataService;
private final DetectionDataDealService detectionDataDealService;
private final ISysTestConfigService sysTestConfigService;
private final String TYPE_A = "A";
private final String TYPE_B = "B";
@@ -762,7 +767,7 @@ public class DetectionServiceImpl {
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
} else {
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
.filter(x -> x.getChannelType().contains("U"))
.filter(x -> x.getChannelType().contains("Ua"))
.sorted(Comparator.comparing(
x -> Optional.ofNullable(x.getDipData())
.map(SourceIssue.ChannelListDTO.DipDataDTO::getFTransValue)
@@ -770,6 +775,9 @@ public class DetectionServiceImpl {
))
.collect(Collectors.toList());
DetectionData a = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A);
if (CollUtil.isEmpty(mag.get(TYPE_A))) {
a.setIsData(2);
}
result.setAValue(JSON.toJSONString(a));
result.setTValue(JSON.toJSONString(a));
result.setResultFlag(a.getIsData());
@@ -975,7 +983,10 @@ public class DetectionServiceImpl {
data.setIsData(isQualified);
data.setNum(harm);
if (CollUtil.isNotEmpty(harmDataList)) {
data.setData(harmDataList.get(0));
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
BigDecimal bd = BigDecimal.valueOf(harmDataList.get(0));
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
data.setData(bd.doubleValue());
}
Double channelData = issueHarmMap.get(harm);
data.setResultData(channelData);
@@ -1006,18 +1017,37 @@ public class DetectionServiceImpl {
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double channelData, Double ratedValue) {
if (CollUtil.isNotEmpty(harmDataList)) {
// 存放合格的数据
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
List<Double> qualifiedList = harmDataList.stream()
.filter(x -> channelData == 0 ? NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl),
.filter(x -> channelData == 0 ? NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, oneConfig.getScale()),
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))
:
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl),
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, oneConfig.getScale()),
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
if (CollUtil.isNotEmpty(qualifiedList)) {
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl));
switch (dataRule) {
case AT_WILL_VALUE:
case CP95_VALUE:
case AVG_VALUE:
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
break;
case SECTION_VALUE:
case Own_value:
if (qualifiedList.size() == harmDataList.size()) {
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
} else {
List<Double> subtract = CollectionUtils.subtract(harmDataList, qualifiedList).stream().collect(Collectors.toList());
BigDecimal bd = BigDecimal.valueOf(subtract.get(0));
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
data.setData(bd.doubleValue());
data.setErrorData(devSubtractChannelData(subtract.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
}
break;
}
} else {
data.setErrorData(devSubtractChannelData(harmDataList.get(0), channelData, ratedValue, errSysDtl));
data.setErrorData(devSubtractChannelData(harmDataList.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
}
isData(dataRule, harmDataList, data, qualifiedList);
}
@@ -1025,7 +1055,10 @@ public class DetectionServiceImpl {
private void isData(DictDataEnum dataRule, List<Double> harmDataList, DetectionData data, List<Double> qualifiedList) {
if (CollUtil.isNotEmpty(qualifiedList)) {
data.setData(qualifiedList.get(0));
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
BigDecimal bd = BigDecimal.valueOf(qualifiedList.get(0));
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
data.setData(bd.doubleValue());
switch (dataRule) {
case AT_WILL_VALUE:
case CP95_VALUE:
@@ -1041,6 +1074,10 @@ public class DetectionServiceImpl {
if (qualifiedList.size() == harmDataList.size()) {
data.setIsData(1);
} else {
List<Double> subtract = CollectionUtils.subtract(harmDataList, qualifiedList).stream().collect(Collectors.toList());
bd = BigDecimal.valueOf(subtract.get(0));
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
data.setData(bd.doubleValue());
data.setIsData(2);
}
break;
@@ -1152,7 +1189,10 @@ public class DetectionServiceImpl {
DetectionData detectionData = new DetectionData();
detectionData.setIsData(isQualified);
if (CollUtil.isNotEmpty(list)) {
detectionData.setData(list.get(0));
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
BigDecimal bd = BigDecimal.valueOf(list.get(0));
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
detectionData.setData(bd.doubleValue());
detectionData.setResultData(channelData);
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
//获得误差体系
@@ -1176,7 +1216,10 @@ public class DetectionServiceImpl {
DetectionData detectionData = new DetectionData();
detectionData.setIsData(isQualified);
if (CollUtil.isNotEmpty(list)) {
detectionData.setData(list.get(0));
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
BigDecimal bd = BigDecimal.valueOf(list.get(0));
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
detectionData.setData(bd.doubleValue());
detectionData.setResultData(BigDecimal.valueOf(1.0 / data).doubleValue() * channelData);
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
@@ -1201,11 +1244,11 @@ public class DetectionServiceImpl {
).collect(Collectors.toList());
if (CollUtil.isNotEmpty(qualifiedList)) {
BigDecimal subtract = BigDecimal.valueOf(qualifiedList.get(0))
.subtract(BigDecimal.valueOf(1.0 / data * (channelData)));
.subtract(BigDecimal.valueOf(1.0 / data * (channelData))).setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
detectionData.setErrorData(subtract);
} else {
BigDecimal subtract = BigDecimal.valueOf(list.get(0))
.subtract(BigDecimal.valueOf(1.0 / data * (channelData)));
.subtract(BigDecimal.valueOf(1.0 / data * (channelData))).setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
detectionData.setErrorData(subtract);
}
isData(dataRule, list, detectionData, qualifiedList);
@@ -1263,23 +1306,24 @@ public class DetectionServiceImpl {
* @param channelData 通道值
* @param ratedValue 额定值
* @param error
* @param scale 小数点位数
* @return
*/
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Double ratedValue, PqErrSysDtls error) {
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Double ratedValue, PqErrSysDtls error, Integer scale) {
//计算装置值返回值 - 源下发值的数据 = 差值
BigDecimal subtract = BigDecimal.valueOf(devData).subtract(BigDecimal.valueOf(channelData));
BigDecimal subtract = BigDecimal.valueOf(devData).setScale(scale, RoundingMode.HALF_UP).subtract(BigDecimal.valueOf(channelData));
//只有相对值需要%比较,绝对值直接相减就行
if (2 == error.getValueType()) {
switch (error.getErrorValueType()) {
case 0:
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/ 额定值
return subtract.multiply(BigDecimal.valueOf(100))
.divide(BigDecimal.valueOf(ratedValue), 4, RoundingMode.HALF_UP);
.divide(BigDecimal.valueOf(ratedValue), scale, RoundingMode.HALF_UP);
case 1:
//todo 当谐波电压和间谐波电压默认都是按照相对值误差进行计算(用户关心的是含有率)
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/ 下发的幅值
return subtract.multiply(BigDecimal.valueOf(100))
.divide(BigDecimal.valueOf(channelData), 4, RoundingMode.HALF_UP);
.divide(BigDecimal.valueOf(channelData), scale, RoundingMode.HALF_UP);
}
}
return subtract;
@@ -1295,14 +1339,15 @@ public class DetectionServiceImpl {
* @return
*/
public Double startRadiusEnd(Double value, Double ratedData, Double harmData, Integer type) {
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
if (ObjectUtil.isNotNull(value)) {
switch (type) {
case 0:
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(ratedData))
.setScale(4, RoundingMode.HALF_UP).doubleValue();
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
case 1:
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(harmData))
.setScale(4, RoundingMode.HALF_UP).doubleValue();
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
default:
return value;
}
@@ -1321,6 +1366,7 @@ public class DetectionServiceImpl {
* @return
*/
public Double maxErrorMultiply(PqErrSysDtls error, Double ratedData, Double harmData) {
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
Double errorValue = error.getMaxErrorValue();
//1绝对值
if (1 == error.getValueType()) {
@@ -1328,11 +1374,11 @@ public class DetectionServiceImpl {
//绝对值-标称值= 最大误差值 * 额定电压
case 0:
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(ratedData))
.setScale(4, RoundingMode.HALF_UP).doubleValue();
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
//绝对值-标准值 = 最大误差值 * 谐波下发值
case 1:
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(harmData))
.setScale(4, RoundingMode.HALF_UP).doubleValue();
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
}
}
//2相对值
@@ -1342,7 +1388,7 @@ public class DetectionServiceImpl {
case 0:
case 1:
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(100))
.setScale(4, RoundingMode.HALF_UP).doubleValue();
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
}
}
return errorValue;

View File

@@ -78,14 +78,18 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override
public void sourceCommunicationCheck(PreDetectionParam param) {
// 参数校验目前仅检查IP是否重复
// 参数校验目前仅检查IP是否重复,后续可在里面扩展
checkDevIp(param);
//用于处理异常导致的socket通道未关闭socket交互异常
DetectionCommunicateUtil.checkCommunicateChannel(param);
/*
先组装源通讯协议
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
*/
AdPlan plan = iAdPlanService.getById(param.getPlanId());
param.setScriptId(plan.getScriptId());
param.setErrorSysId(plan.getErrorSysId());
param.setCode(String.valueOf(plan.getCode()));
if (ObjectUtil.isNotNull(plan)) {
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
@@ -133,13 +137,11 @@ public class PreDetectionServiceImpl implements PreDetectionService {
private void sendYtxSocket(PreDetectionParam param) {
AdPlan plan = iAdPlanService.getById(param.getPlanId());
WebServiceManager.addPreDetectionParam(param);
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
param.setSourceId(planSource.getSourceId());
param.setScriptId(plan.getScriptId());
param.setErrorSysId(plan.getErrorSysId());
param.setCode(String.valueOf(plan.getCode()));
if (ObjectUtil.isNotNull(planSource)) {
//获取源初始化参数
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
if (ObjectUtil.isNotNull(sourceParam)) {
//开始组装socket报文请求头
@@ -149,6 +151,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
socketMsg.setData(JSON.toJSONString(sourceParam));
//建立与源控程序的socket连接
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
} else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
@@ -190,7 +193,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
xuMsg.setData(JSON.toJSONString(sourceIssues));
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
SocketManager.sendMsg(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME, JSON.toJSONString(xuMsg));
SocketManager.sendMsg(param.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
} else {
//TODO 是否最终检测完成需要推送给用户
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
@@ -198,7 +201,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
checkDataParam.setIsValueTypeName(false);
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(),param.getUserId());
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
CnSocketUtil.quitSend(param);
}
@@ -218,7 +221,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override
public void sendScript(SimulateDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
if (Objects.isNull(channel) || !channel.isActive()) {
// 进行源通信连接
PreDetectionParam preDetectionParam = new PreDetectionParam();
@@ -252,7 +255,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override
public void closeTestSimulate(SimulateDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
if (Objects.isNull(channel) || !channel.isActive()) {
throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT);
}

View File

@@ -10,7 +10,6 @@ import lombok.extern.slf4j.Slf4j;
import java.util.Objects;
/**
*
* 检测通讯工具类
*
* @author hongawen
@@ -26,8 +25,9 @@ public class DetectionCommunicateUtil {
* 有则强行关闭
*/
public static void checkCommunicateChannel(PreDetectionParam param) {
Channel channelSource = SocketManager.getChannelByUserId(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
Channel channelDev = SocketManager.getChannelByUserId(DetectionCommunicateConstant.DEVICE_CHANNEL_NAME);
Channel channelSource = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.DEV);
if (Objects.nonNull(channelSource) && channelSource.isActive()) {
System.out.println("发送关闭源指令。。。。。。。。");
CnSocketUtil.quitSendSource(param);
@@ -43,8 +43,8 @@ public class DetectionCommunicateUtil {
log.error(e.getMessage());
}
SocketManager.removeUser(DetectionCommunicateConstant.SOURCE_CHANNEL_NAME);
SocketManager.removeUser(DetectionCommunicateConstant.DEVICE_CHANNEL_NAME);
SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.DEV);
try {
Thread.sleep(2000);
@@ -54,5 +54,4 @@ public class DetectionCommunicateUtil {
}
}

View File

@@ -25,6 +25,7 @@ public class CnSocketUtil {
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
SocketManager.sendMsg(param.getUserPageId() + devTag, JSON.toJSONString(socketMsg));
WebServiceManager.removePreDetectionParam();
}
/**
@@ -38,6 +39,7 @@ public class CnSocketUtil {
jsonObject.put("sourceId", param.getSourceId());
socketMsg.setData(jsonObject.toJSONString());
SocketManager.sendMsg(param.getUserPageId() + sourceTag, JSON.toJSONString(socketMsg));
WebServiceManager.removePreDetectionParam();
}
/**

View File

@@ -55,6 +55,9 @@ public class WebServiceManager {
channel.writeAndFlush(wd);
}else {
log.error("{}-websocket推送消息失败;当前用户-{}-客户端已经断开连接", LocalDateTime.now(),userId);
// PreDetectionParam param = preDetectionParamMap.get("preDetectionParam");
// CnSocketUtil.quitSend(param);
// CnSocketUtil.quitSendSource(param);
}
}

View File

@@ -8,14 +8,11 @@ import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.MsgUtil;
import com.njcn.gather.detection.util.socket.SocketManager;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.RequiredArgsConstructor;
import java.time.LocalDateTime;
import java.util.concurrent.CompletableFuture;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -42,7 +39,7 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
private int consecutiveHeartbeatMisses = 0;
public HeartbeatHandler(PreDetectionParam param,String type){
public HeartbeatHandler(PreDetectionParam param, String type) {
this.param = param;
this.handlerType = type;
}
@@ -70,13 +67,13 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
msg.setRequestId("yxt");
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
msg.setData("");
ctx.channel().writeAndFlush(JSON.toJSONString(msg)+"\n");
ctx.channel().writeAndFlush(JSON.toJSONString(msg) + "\n");
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send"+LocalDateTime.now());
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send" + LocalDateTime.now());
consecutiveHeartbeatMisses++;
if (consecutiveHeartbeatMisses >= MAX_HEARTBEAT_MISSES) {
// 连续三次未收到心跳响应,断开连接
System.out.println(handlerType+"连续三次未收到心跳响应,断开连接");
System.out.println(handlerType + "连续三次未收到心跳响应,断开连接");
if (dev.equals(handlerType)) {
//CnSocketUtil.sendToWebSocket(param.getUserPageId(),);
CnSocketUtil.quitSend(param);
@@ -98,12 +95,11 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
// 过滤心跳包,避免进入业务逻辑
if (isHeartbeatPacket(msg)) {
System.out.println(handlerType+"♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response"+LocalDateTime.now());
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response" + LocalDateTime.now());
consecutiveHeartbeatMisses = 0;
return;
}
@@ -115,6 +111,6 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
private boolean isHeartbeatPacket(String msg) {
// 判断是否为心跳包
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
return socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
return !Objects.isNull(socketDataMsg.getOperateCode()) && socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
}
}

View File

@@ -49,10 +49,10 @@ public class NettyClient {
//空闲状态的handler
// 添加LineBasedFrameDecoder来按行分割数据
.addLast(new LineBasedFrameDecoder(10240))
// .addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
// .addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
.addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new HeartbeatHandler(param,source))
.addLast(new HeartbeatHandler(param, source))
.addLast(handler);
} else {
ch.pipeline()
@@ -61,7 +61,7 @@ public class NettyClient {
.addLast(new LineBasedFrameDecoder(10240))
.addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new HeartbeatHandler(param,dev))
.addLast(new HeartbeatHandler(param, dev))
//空闲状态的handler
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
.addLast(handler);
@@ -73,22 +73,28 @@ public class NettyClient {
channelFuture.addListener((ChannelFutureListener) ch -> {
if (!ch.isSuccess()) {
System.out.println("链接服务端失败...");
// 连接失败时关闭 group
group.shutdownGracefully();
} else {
System.out.println("链接服务端成功...");
System.out.println("客户端向服务端发送消息:"+port+msg);
channelFuture.channel().writeAndFlush(msg+"\n");
if (handler instanceof NettySourceClientHandler) {
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + source);
if(ObjectUtil.isNotNull(groupByUserId)){
groupByUserId.shutdownGracefully().sync();
}
SocketManager.addGroup(param.getUserPageId() + source, group);
} else {
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + dev);
if(ObjectUtil.isNotNull(groupByUserId)){
groupByUserId.shutdownGracefully().sync();
}
SocketManager.addGroup(param.getUserPageId() + dev, group);
}
System.out.println("客户端向服务端发送消息:" + port + msg);
channelFuture.channel().writeAndFlush(msg + "\n");
}
});
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + "_Dev");
if(ObjectUtil.isNotNull(groupByUserId)){
groupByUserId.shutdownGracefully();
}else{
if (handler instanceof NettySourceClientHandler) {
SocketManager.addGroup(param.getUserPageId()+source,group);
}else{
SocketManager.addGroup(param.getUserPageId()+dev,group);
}
}
} catch (Exception e) {
System.out.println("连接socket服务端发送异常............" + e.getMessage());
group.shutdownGracefully();
@@ -100,7 +106,7 @@ public class NettyClient {
socketDataMsg.setRequestId("connect");
if (handler instanceof NettySourceClientHandler) {
socketDataMsg.setOperateCode("Source");
}else{
} else {
CnSocketUtil.quitSendSource(param);
socketDataMsg.setOperateCode("Dev");
}

View File

@@ -146,6 +146,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
fly = true;
//为空则认为是常规步骤,设定一分钟超时
CnSocketUtil.quitSend(param);
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg(), null);
}
if (fly) {
socketResponseService.backCheckState(param);
@@ -185,7 +186,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
} else if (cause instanceof IOException) {
// 处理I/O异常例如读写错误
System.out.println("IOException caught: There was an I/O error.");
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getMsg(), null);
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
// 例如可以记录更详细的I/O错误信息
} else if (cause instanceof TimeoutException) {
@@ -199,9 +200,11 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
} else {
// 处理其他类型的异常
System.out.println("Unknown exception caught: " + cause.getMessage());
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
// 可以记录未知异常信息
}
CnSocketUtil.quitSend(param);
CnSocketUtil.quitSendSource(param);
socketResponseService.backCheckState(param);
ctx.close();
}

View File

@@ -122,6 +122,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
PreDetectionParam preDetectionParam = WebServiceManager.getPreDetectionParam();
if (ObjectUtil.isNotNull(preDetectionParam)) {
CnSocketUtil.quitSendSource(preDetectionParam); // 能否在这里关闭源socket连接
CnSocketUtil.quitSend(preDetectionParam);
} else {
preDetectionParam = new PreDetectionParam();
preDetectionParam.setUserPageId("cdf");

View File

@@ -182,19 +182,4 @@ public class PqDevController extends BaseController {
});
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/documented")
@ApiOperation("设备归档")
@ApiImplicitParam(name = "id", value = "设备id", required = true)
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("documented");
LogUtil.njcnDebug(log, "{}设备id为{}", methodDescribe, ids);
boolean result = pqDevService.documented(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
}

View File

@@ -10,6 +10,7 @@ import lombok.Getter;
public enum DevReportStateEnum {
NOT_GENERATED("未生成", 0),
GENERATED("已生成", 1),
GENERATED_UPLOADED("已生成且已上传", 3),
UNCHECKED("未检", 2);
private final Integer value;

View File

@@ -107,9 +107,7 @@ public class PqDevParam {
private Integer reCheckNum;
@ApiModelProperty("是否支持系数校准")
@Min(value = 0, message = DetectionValidMessage.FACTOR_FLAG_FORMAT_ERROR)
@Max(value = 1, message = DetectionValidMessage.FACTOR_FLAG_FORMAT_ERROR)
private String factorFlag;
private Integer factorFlag;
@ApiModelProperty("监测点台账列表")
@Valid
@@ -121,6 +119,9 @@ public class PqDevParam {
@ApiModelProperty("预投计划")
private String preinvestmentPlan;
@ApiModelProperty("委托方")
private String delegate;
/**
* 更新操作实体
*/

View File

@@ -201,5 +201,19 @@ public class PqDev extends BaseEntity implements Serializable {
@TableField("Preinvestment_Plan")
private String preinvestmentPlan;
/**
* 温度
*/
private Float temperature;
/**
* 相对湿度
*/
private Float humidity;
/**
* 委托方
*/
private String delegate;
}

View File

@@ -21,7 +21,7 @@ public class CNDevExcel {
@NotBlank(message = DetectionValidMessage.PREINVESTMENT_PLAN_NOT_BLANK)
private String preinvestmentPlan;
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
@Excel(name = "装置编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX_IMPORT, message = DetectionValidMessage.CN_DEV_NAME_FORMAT_ERROR)
private String name;

View File

@@ -39,7 +39,7 @@ public class ProvinceDevExcel implements Serializable {
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
@Excel(name = "出厂日期*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
@Excel(name = "出厂日期yyyy-MM-dd*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
@NotNull(message = DetectionValidMessage.CREATEDATETIME_NOT_NULL)
private LocalDate createDate;
@@ -63,16 +63,25 @@ public class ProvinceDevExcel implements Serializable {
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "14")
private String devKey;
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "15")
private Integer factorFlag;
// @Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "15")
// private Integer factorFlag;
@Excel(name = "IP地址*", width = 20, orderNum = "16")
@Excel(name = "IP地址*", width = 20, orderNum = "15")
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
private String ip;
@Excel(name = "端口号*", width = 15, orderNum = "17")
@Excel(name = "端口号*", width = 15, orderNum = "16")
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
private Integer port;
@Excel(name = "样品编号", width = 20, orderNum = "17")
private String sampleId;
@Excel(name = "送样日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "18")
private LocalDate arrivedDate;
@Excel(name="委托方", width = 40, orderNum = "19")
private String delegate;
}

View File

@@ -137,13 +137,6 @@ public interface IPqDevService extends IService<PqDev> {
*/
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
/**
* 设备归档操作
*
* @param id 设备id
* @return 归档成功返回true否则返回false
*/
boolean documented(List<String> id);
/**
* 正式监测完成,修改中断状态
@@ -152,9 +145,11 @@ public interface IPqDevService extends IService<PqDev> {
* @param valueType
* @param code
* @param userId
* @param temperature
* @param humidity
* @return
*/
boolean updateResult(List<String> ids, List<String> valueType, String code,String userId);
boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity);
void updatePqDevReportState(String devId, int i);

View File

@@ -82,10 +82,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
public Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam) {
Page<PqDev> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam));
page1.getRecords().forEach(p -> {
if (ObjectUtil.isNotNull(p.getSeries())) {
if (StrUtil.isNotBlank(p.getSeries())) {
p.setSeries(EncryptionUtil.decoderString(1, p.getSeries()));
}
if (ObjectUtil.isNotNull(p.getDevKey())) {
if (StrUtil.isNotBlank(p.getDevKey())) {
p.setDevKey(EncryptionUtil.decoderString(1, p.getDevKey()));
}
});
@@ -108,6 +108,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
@Transactional
public boolean addPqDev(PqDevParam pqDevParam) {
pqDevParam.setName(pqDevParam.getName().trim());
pqDevParam.setCreateId(pqDevParam.getCreateId().trim());
this.checkRepeat(pqDevParam, false);
PqDev pqDev = new PqDev();
@@ -174,6 +176,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
@Transactional
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
updateParam.setName(updateParam.getName().trim());
updateParam.setCreateId(updateParam.getCreateId().trim());
this.checkRepeat(updateParam, true);
PqDev pqDev = new PqDev();
@@ -347,7 +351,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
.like(StrUtil.isNotBlank(param.getName()), PqDev::getName, param.getName())
.in(ObjectUtil.isNotEmpty(param.getCheckStateList()), PqDev::getCheckState, param.getCheckStateList())
.eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult())
.eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult())
.eq(ObjectUtil.isNotNull(param.getReportState()), PqDev::getReportState, param.getReportState())
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
.orderByDesc(PqDev::getCreateTime)
@@ -376,7 +379,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
}
//计划检测中
List<String> checking = list.stream().filter(x -> x.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) &&
!CheckStateEnum.DOCUMENTED.getValue().equals(x.getReportState())
!CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())
).map(PqDev::getId).distinct().collect(Collectors.toList());
if (checking.size() == notUnchecked.size()) {
return CheckStateEnum.CHECKING.getValue();
@@ -485,43 +488,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
return preDetections;
}
@Override
@Transactional
public boolean documented(List<String> ids) {
if (CollUtil.isNotEmpty(ids)) {
for (String id : ids) {
// 只有检测完成的设备才可以进行归档
PqDev pqDev = this.getById(id);
if (ObjectUtil.isNotNull(pqDev)) {
// 只有检测完成、且已生成报告的设备才可以进行归档
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) || !pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
}
boolean update = this.lambdaUpdate()
.set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue())
.eq(PqDev::getId, id)
.update();
if (update) {
// 判断计划下所有设备是否都已归档,如果是则将计划改为已完成
// 查询该计划下所有设备的检测状态,是否有不为归档的
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId())
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
int count = this.count(queryWrapper);
if (count == 0) {
// 如果非归档状态的设备数量为0则更新计划已完成
this.baseMapper.finishPlan(pqDev.getPlanId());
}
}
}
}
}
return true;
}
@Override
public boolean updateResult(List<String> ids, List<String> valueType, String code, String userId) {
public boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity) {
if (CollUtil.isNotEmpty(ids)) {
SysTestConfig config = sysTestConfigService.getOneConfig();
Map<String, Integer> result = detectionDataDealService.devResult(ids, valueType, code);
@@ -533,9 +502,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
int i;
LambdaUpdateWrapper<PqDev> wrapper = new LambdaUpdateWrapper<PqDev>()
.set(PqDev::getCheckResult, result.get(pqDev.getId()))
.set(PqDev::getCheckBy, userId)
.set(StrUtil.isNotBlank(userId), PqDev::getCheckBy, userId)
.set(PqDev::getCheckTime, LocalDateTime.now())
.eq(PqDev::getId, pqDev.getId());
String currrentScene = sysTestConfigService.getCurrrentScene();
if (SceneEnum.PROVINCE_PLATFORM.getValue().equals(currrentScene)) {
wrapper.set(ObjectUtil.isNotNull(temperature), PqDev::getTemperature, temperature)
.set(ObjectUtil.isNotNull(humidity), PqDev::getHumidity, humidity);
}
if (pqDev.getReCheckNum() >= config.getMaxTime()) {
// 装置报告生成 todo...
//this.baseMapper.updateReportState(pqDev.getId());
@@ -713,6 +687,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
} else {
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
} else {
pqDev.setSeries(null);
pqDev.setDevKey(null);
}
String name = pqDev.getName();
@@ -755,9 +732,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
this.checkRepeat(param, false);
pqDev.setManufacturer("8fa73802c9e1abab973adcbeb0d58567"); // 南京灿能字典项目对应的id
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName()) && dev.getCreateId().equals(pqDev.getCreateId())).count();
if (count == 0) {
newDevList.add(pqDev);
} else {
throw new BusinessException(DetectionResponseEnum.NAME_OR_CREATEID_REPEAT);
}
}
});
@@ -777,8 +756,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
queryWrapper
.eq("state", DataStateEnum.ENABLE.getCode())
.eq("Dev_Type", param.getDevType())
.and(q -> q.eq("name", param.getName()).or()
.eq("Create_Id", param.getCreateId())); //设备序列号重复
.and(q -> q.eq("Create_Id", param.getCreateId())); //设备序列号重复,不管设备类型,原设备类型条件删除
// .eq("pattern", param.getPattern())
// .eq("manufacturer", param.getManufacturer())
// .eq("Dev_Type", param.getDevType()).or()
@@ -862,12 +840,17 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
// 是否支持系数校准
pullDown = new PullDown();
pullDown.setFirstCol(startCol + 11);
pullDown.setLastCol(startCol + 11);
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
// 委托方
dictType = dictTypeService.getByCode("Delegate");
if (ObjectUtil.isNotNull(dictType)) {
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown();
pullDown.setFirstCol(startCol + 15);
pullDown.setLastCol(startCol + 15);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
}
return pullDowns;
}
@@ -950,11 +933,26 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
*/
public void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId) {
pqDevs.forEach(pqDev -> {
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
DictData preinvestmentPlanDictData = dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan());
if (ObjectUtil.isNull(preinvestmentPlanDictData)) {
throw new BusinessException(DetectionResponseEnum.PREINVESTMENT_PLAN_NOT_EXIST);
} else {
pqDev.setPreinvestmentPlan(preinvestmentPlanDictData.getId());
}
DevType devType = devTypeService.getByName(pqDev.getDevType());
pqDev.setDevType(devType.getId());
if (ObjectUtil.isNull(devType)) {
throw new BusinessException(DetectionResponseEnum.DEV_TYPE_NOT_EXIST);
} else {
pqDev.setDevType(devType.getId());
}
pqDev.setPattern(patternId);
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
DictData protocolDictData = dictDataService.getDictDataByName(pqDev.getProtocol());
if (ObjectUtil.isNull(protocolDictData)) {
throw new BusinessException(DetectionResponseEnum.PROTOCOL_NOT_EXIST);
} else {
pqDev.setProtocol(protocolDictData.getId());
}
pqDev.setCreateDate(LocalDateTime.now().toLocalDate());
pqDev.setCreateId(pqDev.getName());
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
@@ -1035,6 +1033,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
} else {
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
} else {
pqDev.setSeries(null);
pqDev.setDevKey(null);
}
String name = pqDev.getName();
@@ -1076,9 +1077,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
param.setDevType(pqDev.getDevType());
this.checkRepeat(param, false);
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName()) || dev.getCreateId().equals(pqDev.getCreateId())).count();
if (count == 0) {
newDevList.add(pqDev);
} else {
throw new BusinessException(DetectionResponseEnum.NAME_OR_CREATEID_REPEAT);
}
}
});
@@ -1091,8 +1094,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
public void visualizeProvinceDev(List<PqDev> pqDevs) {
pqDevs.forEach(pqDev -> {
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
pqDev.setManufacturer(dictDataService.getDictDataById(pqDev.getManufacturer()).getName());
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
pqDev.setManufacturer(dictDataService.getDictDataById(pqDev.getManufacturer()).getName());
}
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
if (StrUtil.isNotBlank(pqDev.getDelegate())) {
pqDev.setDelegate(dictDataService.getDictDataById(pqDev.getDelegate()).getName());
}
});
}
@@ -1100,10 +1109,32 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
public void reverseVisualizeProvinceDev(List<PqDev> pqDevs, String patternId) {
pqDevs.forEach(pqDev -> {
DevType devType = devTypeService.getByName(pqDev.getDevType());
pqDev.setDevType(devType.getId());
if (ObjectUtil.isNull(devType)) {
throw new BusinessException(DetectionResponseEnum.DEV_TYPE_NOT_EXIST);
} else {
pqDev.setDevType(devType.getId());
}
pqDev.setPattern(patternId);
pqDev.setManufacturer(dictDataService.getDictDataByName(pqDev.getManufacturer()).getId());
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
DictData manufacturerDictData = dictDataService.getDictDataByName(pqDev.getManufacturer());
if (ObjectUtil.isNull(manufacturerDictData)) {
throw new BusinessException(DetectionResponseEnum.MANUFACTURER_NOT_EXIST);
} else {
pqDev.setManufacturer(manufacturerDictData.getId());
}
DictData protocolDictData = dictDataService.getDictDataByName(pqDev.getProtocol());
if (ObjectUtil.isNull(protocolDictData)) {
throw new BusinessException(DetectionResponseEnum.PROTOCOL_NOT_EXIST);
} else {
pqDev.setProtocol(protocolDictData.getId());
}
if (StrUtil.isNotBlank(pqDev.getDelegate())) {
DictData delegateDictData = dictDataService.getDictDataByName(pqDev.getDelegate());
if (ObjectUtil.isNull(delegateDictData)) {
throw new BusinessException(DetectionResponseEnum.DELEGATE_NOT_EXIST);
} else {
pqDev.setDelegate(delegateDictData.getId());
}
}
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());

View File

@@ -67,6 +67,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
@Override
@Transactional
public boolean addPqErrSys(PqErrSysParam param) {
param.setStandardName(param.getStandardName().trim());
this.checkRepeat(param, false);
PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys);
@@ -84,6 +85,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
@Override
@Transactional
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
param.setStandardName(param.getStandardName().trim());
this.checkRepeat(param, true);
PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys);

View File

@@ -47,6 +47,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
@Override
@Transactional
public boolean addIcd(PqIcdPathParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, false);
PqIcdPath pqIcdPath = new PqIcdPath();
BeanUtils.copyProperties(param, pqIcdPath);
@@ -57,6 +58,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
@Override
@Transactional
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, true);
PqIcdPath pqIcdPath = new PqIcdPath();
BeanUtils.copyProperties(param, pqIcdPath);

View File

@@ -125,8 +125,8 @@ public class AdPlanController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载检测计划导出模板")
public void downloadTemplate(@RequestBody String patternId) {
adPlanService.downloadTemplate(patternId);
public void downloadTemplate(@RequestBody AdPlanParam.QueryParam queryParam) {
adPlanService.downloadTemplate(queryParam.getPatternId());
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@@ -155,7 +155,7 @@ public class AdPlanController extends BaseController {
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) {
String methodDescribe = getMethodDescribe("getBigTestItem");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, checkParam);
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(), checkParam.getPlanId(), checkParam.getDevId());
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(), checkParam.getPlanId(), checkParam.getDevIds());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}

View File

@@ -5,6 +5,8 @@ import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.report.pojo.po.PqReport;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author caozehui
* @date 2024-12-09
@@ -27,5 +29,13 @@ public interface AdPlanMapper extends MPJBaseMapper<AdPlan> {
* @return
*/
PqReport getPqReportById(String id);
/**
* 获取所有报告模板名称
*
* @return
*/
List<String> listAllReportTemplateName();
}

View File

@@ -17,5 +17,10 @@
WHERE id = #{id}
and state = 1
</select>
<select id="listAllReportTemplateName" resultType="java.lang.String">
SELECT concat(name, '_', version) as name
FROM pq_report
WHERE state = 1
</select>
</mapper>

View File

@@ -8,13 +8,13 @@ import lombok.Getter;
*/
@Getter
public enum DataSourceEnum {
THREE_SENSE_ACTUAL_TIME_DATA("0", "3s实时数据"),
THREE_SENSE_ACTUAL_TIME_DATA("real", "3s实时数据"),
MINUTE_STATISTICS_MAX("1", "分钟统计数据-最大"),
MINUTE_STATISTICS_MIN("2", "分钟统计数据-最小"),
MINUTE_STATISTICS_AVG("3", "分钟统计数据-平均"),
MINUTE_STATISTICS_CP95("4", "分钟统计数据-CP95"),
RECORDED_DATA("5", "录播数据");
MINUTE_STATISTICS_MAX("max", "分钟统计数据-最大"),
MINUTE_STATISTICS_MIN("min", "分钟统计数据-最小"),
MINUTE_STATISTICS_AVG("avg", "分钟统计数据-平均"),
MINUTE_STATISTICS_CP95("cp95", "分钟统计数据-CP95"),
RECORDED_DATA("Recorded_data", "录播数据");
private String value;
private String msg;

View File

@@ -60,11 +60,16 @@ public class AdPlanParam {
private List<String> devIds;
@ApiModelProperty(value = "是否关联报告")
@NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL)
private Integer associateReport;
@ApiModelProperty(value = "报告模板名称")
private String reportTemplateName;
@ApiModelProperty(value = "数据处理原则")
@NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK)
private String dataRule;
/**
* 分页查询实体
*/
@@ -110,6 +115,6 @@ public class AdPlanParam {
// 0:不合格项复检 1:全部复检
private Integer reCheckType;
private String planId;
private String devId;
private List<String> devIds;
}
}

View File

@@ -94,5 +94,10 @@ public class AdPlan extends BaseEntity implements Serializable {
* 状态0-删除 1-正常
*/
private Integer state;
/**
* 数据处理原则。任意值、部分值、所有值、cp95值、平均值
*/
private String dataRule;
}

View File

@@ -25,27 +25,38 @@ public class AdPlanExcel {
@NotBlank(message = DetectionValidMessage.DATASOURCE_NOT_BLANK)
private String datasourceId;
@Excel(name = "脚本*", width = 100, needMerge = true, orderNum = "3")
@Excel(name = "脚本*", width = 40, needMerge = true, orderNum = "3")
@NotBlank(message = DetectionValidMessage.SCRIPT_NOT_BLANK)
private String scriptId;
@Excel(name = "误差体系*", width = 30, needMerge = true, orderNum = "4")
@Excel(name = "误差体系*", width = 40, needMerge = true, orderNum = "4")
@NotBlank(message = DetectionValidMessage.ERRORSYS_NOT_BLANK)
private String errorSysId;
@Excel(name = "是否做守时检测*", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
@Excel(name = "数据处理原则*", width = 20, needMerge = true, orderNum = "5")
@NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK)
private String dataRule;
@Excel(name = "是否做守时检测*", width = 20, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "6")
@NotNull(message = DetectionValidMessage.TIMECHECK_NOT_NULL)
private Integer timeCheck;
@Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
@NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL)
private Integer testState;
@Excel(name = "关联报告模版*", width = 20, replace = {"_0", "_1"}, needMerge = true, orderNum = "7")
@NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL)
private Integer associateReport;
@Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
@NotNull(message = DetectionValidMessage.REPORT_STATE_NOT_NULL)
private Integer reportState;
@Excel(name = "报告模版(当关联报告模版为是时必填)", width = 40, needMerge = true, orderNum = "8")
private String reportTemplateId;
@Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
@NotNull(message = DetectionValidMessage.CHECK_RESULT_STATE_NOT_NULL)
private Integer result;
// @Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "9")
// @NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL)
// private Integer testState;
//
// @Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "10")
// @NotNull(message = DetectionValidMessage.REPORT_STATE_NOT_NULL)
// private Integer reportState;
//
// @Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "11")
// @NotNull(message = DetectionValidMessage.CHECK_RESULT_STATE_NOT_NULL)
// private Integer result;
}

View File

@@ -108,4 +108,6 @@ public class AdPlanVO {
* 报告模板名称
*/
private String reportTemplateName;
private String dataRule;
}

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.plan.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
import lombok.Data;

View File

@@ -70,10 +70,10 @@ public interface IAdPlanService extends IService<AdPlan> {
*
* @param reCheckType 0:不合格项复检 1:全部复检
* @param planId 检测计划Id
* @param devId 设备Id
* @param devIds 设备Id列表
* @return
*/
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId);
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, List<String> devIds);
/**
* 修改计划状态

View File

@@ -38,6 +38,7 @@ import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.plan.service.IAdPlanSourceService;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.report.pojo.po.PqReport;
import com.njcn.gather.script.pojo.po.PqScript;
import com.njcn.gather.script.pojo.po.PqScriptDtls;
import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.gather.script.service.IPqScriptService;
@@ -142,6 +143,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
this.checkRepeat(param, false);
AdPlan adPlan = new AdPlan();
BeanUtil.copyProperties(param, adPlan);
adPlan.setName(param.getName().trim());
String planId = UUID.randomUUID().toString().replaceAll("-", "");
adPlan.setId(planId);
@@ -184,6 +186,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
@Override
@Transactional
public boolean updateAdPlan(AdPlanParam.UpdateParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, true);
AdPlan plan1 = this.getById(param.getId());
AdPlan plan2 = new AdPlan();
@@ -304,11 +307,19 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
if (StrUtil.isNotBlank(adPlan.getErrorSysId())) {
adPlan.setErrorSysId(pqErrSysService.getPqErrSysById(adPlan.getErrorSysId()).getName());
}
if (StrUtil.isNotBlank(adPlan.getDataRule())) {
String dataRule = adPlan.getDataRule();
adPlan.setDataRule(dictDataService.getDictDataById(dataRule).getName());
}
if (StrUtil.isNotBlank(adPlan.getReportTemplateId())) {
PqReport report = this.baseMapper.getPqReportById(adPlan.getReportTemplateId());
adPlan.setReportTemplateId(report.getName() + "_" + report.getVersion());
}
});
}
@Override
public List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId) {
public List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, List<String> devIds) {
List<Map<String, String>> result = new ArrayList<>();
AdPlan adPlan = this.getById(planId);
if (ObjectUtil.isNull(adPlan)) {
@@ -330,10 +341,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
//
// scriptDtlsList = scriptDtlsList.stream().filter(obj -> !sortSet.contains(obj.getScriptIndex())).collect(Collectors.toList());
// }
Set<Integer> indexes = new HashSet<>();
StorageParam storageParam = new StorageParam();
storageParam.setCode(adPlan.getCode() + "");
storageParam.setScriptId(adPlan.getScriptId());
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
devIds.forEach(devId -> {
storageParam.setDevId(devId);
indexes.addAll(adHarmonicService.getIndex(storageParam));
});
scriptDtlsList = scriptDtlsList.stream().filter(obj -> indexes.contains(obj.getScriptIndex())).collect(Collectors.toList());
}
@@ -624,6 +639,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR);
}
planExcel.setAssociateReport(0);
planExcel.setReportTemplateId(null);
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
adPlanSourceService.addAdPlanSource(planId, sourceIds);
@@ -704,11 +721,18 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
throw new BusinessException(DetectionResponseEnum.IMPORT_DATASOURCE_ERROR);
}
if ((planExcel.getAssociateReport().equals(1) && "".equals(planExcel.getReportTemplateId()))) {
throw new BusinessException(DetectionResponseEnum.IMPORT_REPORT_TEMPLATE_ERROR);
}
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
adPlanSourceService.addAdPlanSource(planId, sourceIds);
List<ProvinceDevExcel> cnDevExcelList = planExcel.getDevices();
ProvinceDevExcel provinceDevExcel = cnDevExcelList.get(0);
if (ObjectUtil.isNull(provinceDevExcel.getName())) {
cnDevExcelList.remove(0);
}
pqDevService.importProvinceDev(cnDevExcelList, patternId, planId);
}
// 逆向可视化
@@ -753,12 +777,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
}
});
PqErrSys errSys = pqErrSysService.getById(plan.getErrorSysId());
SysTestConfig config1 = sysTestConfigService.getConfig();
if (ObjectUtil.isNotNull(config1)) {
DictData dictData = dictDataService.getDictDataById(config1.getDataRule());
if (ObjectUtil.isNotNull(errSys) && ObjectUtil.isNotNull(dictData)) {
note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData.getName() + "\"数据原则计算得出。");
}
DictData dictData1 = dictDataService.getDictDataById(plan.getDataRule());
if (ObjectUtil.isNotNull(dictData1) && ObjectUtil.isNotNull(errSys)) {
note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData1.getName() + "\"数据原则计算得出。");
}
return note.toString();
}
@@ -821,13 +842,49 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
private void reverseVisualize(List<AdPlan> planList) {
planList.forEach(adPlan -> {
String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA);
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getValueByMsg(id)).collect(Collectors.joining(StrUtil.COMMA)));
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> {
String value = DataSourceEnum.getValueByMsg(id);
if (StrUtil.isBlank(value)) {
throw new BusinessException(DetectionResponseEnum.DATA_SOURCE_NOT_EXIST);
} else {
return value;
}
}).collect(Collectors.joining(StrUtil.COMMA)));
adPlan.setScriptId(pqScriptService.getPqScriptByName(adPlan.getScriptId()).getId());
PqScript pqScript = pqScriptService.getPqScriptByName(adPlan.getScriptId());
if (ObjectUtil.isNull(pqScript)) {
throw new BusinessException(DetectionResponseEnum.SCRIPT_NOT_EXIST);
} else {
adPlan.setScriptId(pqScript.getId());
}
adPlan.setErrorSysId(pqErrSysService.getPqErrSysByName(adPlan.getErrorSysId()).getId());
PqErrSys pqErrSys = pqErrSysService.getPqErrSysByName(adPlan.getErrorSysId());
if (ObjectUtil.isNull(pqErrSys)) {
throw new BusinessException(DetectionResponseEnum.ERROR_SYSTEM_NOT_EXIST);
} else {
adPlan.setErrorSysId(pqErrSys.getId());
}
DictData dataRuleDictData = dictDataService.getDictDataByName(adPlan.getDataRule());
if (ObjectUtil.isNull(dataRuleDictData)) {
throw new BusinessException(DetectionResponseEnum.DATA_RULE_NOT_EXIST);
} else {
adPlan.setDataRule(dataRuleDictData.getId());
}
if (adPlan.getAssociateReport().equals(0)) {
adPlan.setReportTemplateId(null);
}else if (StrUtil.isNotBlank(adPlan.getReportTemplateId())) {
String[] split = adPlan.getReportTemplateId().split("_");
String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]);
if (ObjectUtil.isNull(reportId)) {
throw new BusinessException(DetectionResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
} else {
adPlan.setReportTemplateId(reportId);
}
} else {
throw new BusinessException(DetectionResponseEnum.LACK_REPORT_TEMPLATE_ID);
}
adPlan.setCode(this.generateCode());
adPlan.setState(DataStateEnum.ENABLE.getCode());
// 默认为顶级检测计划
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
@@ -1027,14 +1084,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
List<PullDown> pullDowns = new ArrayList<>();
PullDown pullDown = null;
// List<Map<String, Object>> maps = pqSourceService.listAllPqSource(patternId);
// if (ObjectUtil.isNotEmpty(maps)) {
// pullDown = new PullDown();
// pullDown.setFirstCol(1);
// pullDown.setLastCol(1);
// pullDown.setStrings(maps.stream().map(m -> (String) m.get("name")).collect(Collectors.toList()));
// pullDowns.add(pullDown);
// }
List<Map<String, Object>> maps = pqSourceService.listAllPqSource(patternId);
if (ObjectUtil.isNotEmpty(maps)) {
pullDown = new PullDown();
pullDown.setFirstCol(1);
pullDown.setLastCol(1);
pullDown.setStrings(maps.stream().map(m -> (String) m.get("name")).collect(Collectors.toList()));
pullDowns.add(pullDown);
}
// 数据源
DictType dictType = dictTypeService.getByCode("Datasource");
@@ -1065,34 +1122,61 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
pullDown.setStrings(errSysNameList);
pullDowns.add(pullDown);
// 是否做守时检测
pullDown = new PullDown();
pullDown.setFirstCol(5);
pullDown.setLastCol(5);
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
// 数据处理原则
dictType = dictTypeService.getByCode("Data_Rule");
if (ObjectUtil.isNotNull(dictType)) {
List<DictData> dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
// 检测状态
pullDown = new PullDown();
pullDown.setFirstCol(5);
pullDown.setLastCol(5);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
}
// 是否做守时检测
pullDown = new PullDown();
pullDown.setFirstCol(6);
pullDown.setLastCol(6);
pullDown.setStrings(Arrays.asList(CheckStateEnum.UNCHECKED.getMsg(), CheckStateEnum.CHECKING.getMsg(), CheckStateEnum.CHECKED.getMsg()));
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
// 报告生成状态
// 是否关联报告模板
pullDown = new PullDown();
pullDown.setFirstCol(7);
pullDown.setLastCol(7);
pullDown.setStrings(Arrays.asList(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getMsg()));
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
//检测结果
// 报告模板
List<String> strings = this.baseMapper.listAllReportTemplateName();
pullDown = new PullDown();
pullDown.setFirstCol(8);
pullDown.setLastCol(8);
pullDown.setStrings(Arrays.asList(CheckResultEnum.UNCHECKED.getMsg(), CheckResultEnum.ACCORD.getMsg(), CheckResultEnum.UNCHECKED.getMsg()));
pullDown.setStrings(strings);
pullDowns.add(pullDown);
// 检测状态
// pullDown = new PullDown();
// pullDown.setFirstCol(9);
// pullDown.setLastCol(9);
// pullDown.setStrings(Arrays.asList(CheckStateEnum.UNCHECKED.getMsg(), CheckStateEnum.CHECKING.getMsg(), CheckStateEnum.CHECKED.getMsg()));
// pullDowns.add(pullDown);
// 报告生成状态
// pullDown = new PullDown();
// pullDown.setFirstCol(10);
// pullDown.setLastCol(10);
// pullDown.setStrings(Arrays.asList(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_PARTIALLY_GENERATED.getMsg(), PlanReportStateEnum.REPORT_STATE_ALL_GENERATED.getMsg()));
// pullDowns.add(pullDown);
//检测结果
// pullDown = new PullDown();
// pullDown.setFirstCol(11);
// pullDown.setLastCol(11);
// pullDown.setStrings(Arrays.asList(CheckResultEnum.UNCHECKED.getMsg(), CheckResultEnum.ACCORD.getMsg(), CheckResultEnum.UNCHECKED.getMsg()));
// pullDowns.add(pullDown);
switch (scene) {
case PROVINCE_PLATFORM:
List<PullDown> provinceDevPullDownList = pqDevService.getProvinceDevPullDownList(9);

View File

@@ -179,4 +179,6 @@ public interface DetectionValidMessage {
String DEV_TYPE_NAME_FORMAT_ERROR = "设备类型名称格式错误只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String REPORT_NAME_NOT_BLANK = "报告模板不能为空";
String DATA_RULE_NOT_BLANK = "数据处理原则不能为空";
String ASSOCIATE_REPORT_NOT_NULL = "是否关联报告模板不能为空";
}

View File

@@ -26,7 +26,7 @@ public enum DetectionResponseEnum {
ICD_PATH_NAME_REPEAT("A02012", "icd名称重复"),
ERR_SYS_BOUND_NOT_DELETE("A02013", "误差体系已被计划所绑定,无法删除!"),
ERR_SYS_REPEAT("A02014", "已存在相同标准号、标准推行年份、适用设备等级的误差体系!"),
SCRIPT_NAME_REPEAT("A02015","脚本名称重复"),
SCRIPT_NAME_REPEAT("A02015", "脚本名称重复"),
IMPORT_DATA_FAIL("A02040", "导入数据失败"),
@@ -48,8 +48,21 @@ public enum DetectionResponseEnum {
DEVICE_DELETE("A02056", "设备无法删除,已绑定计划!"),
CREATE_DIRECTORY_FAILED("A02057", "创建目录失败"),
DELETE_DIRECTORY_FAILED("A02058", "删除目录失败"),
CN_DEV_NAME_FORMAT_ERROR("A02059","设备名称格式错误只能包含数字长度为1-32位"),
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060","设备名称格式错误只能包含字母、数字、下划线、中划线、空格长度为1-32位" );
CN_DEV_NAME_FORMAT_ERROR("A02059", "设备名称格式错误只能包含数字长度为1-32位"),
PROVINCE_DEV_NAME_FORMAT_ERROR("A02060", "设备名称格式错误只能包含字母、数字、下划线、中划线、空格长度为1-32位"),
IMPORT_REPORT_TEMPLATE_ERROR("A02061", "当关联报告模板为是时,报告模板不能为空"),
DEV_TYPE_NOT_EXIST("A02062", "设备类型不存在,请先添加设备类型"),
MANUFACTURER_NOT_EXIST("A02063", "该设备厂家不存在,请先在\"设备厂家\"字典中添加"),
PROTOCOL_NOT_EXIST("A02064", "该协议不存在,请先在\"通讯协议\"字典中添加"),
DELEGATE_NOT_EXIST("A02065", "该委托方不存在,请先在\"委托方\"字典中添加"),
PREINVESTMENT_PLAN_NOT_EXIST("A02066", "该预投计划不存在,请先在\"预投计划\"字典中添加"),
DATA_SOURCE_NOT_EXIST("A02067", "该数据源不存在,请先在\"数据源\"字典中添加"),
SCRIPT_NOT_EXIST("A02068", "该脚本不存在,请先添加该脚本"),
ERROR_SYSTEM_NOT_EXIST("A02069", "该误差体系不存在,请先添加该误差体系"),
DATA_RULE_NOT_EXIST("A02070", "该数据处理原则不存在,请先在\"数据处理原则\"字典中添加"),
REPORT_TEMPLATE_NOT_EXIST("A02071", "该报告模板不存在,请先添加该报告模板"),
LACK_REPORT_TEMPLATE_ID("A02072","当关联报告模板为\"\"时,报告模板不能为空" ),
NAME_OR_CREATEID_REPEAT("A02073","名称或装置编号重复" );
private final String code;

View File

@@ -3,6 +3,7 @@ package com.njcn.gather.report.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
@@ -140,4 +141,30 @@ public class ReportController extends BaseController {
String methodDescribe = getMethodDescribe("listAllName");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/documented")
@ApiOperation("设备归档")
@ApiImplicitParam(name = "id", value = "设备id", required = true)
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("documented");
LogUtil.njcnDebug(log, "{}设备id为{}", methodDescribe, ids);
boolean result = pqReportService.documented(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo
@PostMapping("/uploadReportToCloud")
@ApiOperation("批量上传检测报告到云端")
@ApiImplicitParam(name = "deviceIds", value = "被检设备ID列表为空时上传所有已生成报告的设备", required = false)
public HttpResult<Object> uploadReportToCloud(@RequestBody(required = false) List<String> deviceIds) {
String methodDescribe = getMethodDescribe("uploadReportToCloud");
LogUtil.njcnDebug(log, "{}设备ID列表为{}", methodDescribe, deviceIds);
pqReportService.uploadReportToCloud(deviceIds);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -29,7 +29,13 @@ public enum BaseReportKeyEnum {
YEAR("year","年份"),
MONTH("month","月份"),
DAY("day",""),
YEAR_MONTH_DAY("year-month-day","年-月-日");
YEAR_MONTH_DAY("year-month-day","年-月-日"),
TEMPERATURE("temp","温度"),
HUMIDITY("hum","相对湿度"),
DELEGATE("delegate","委托方"),
CREATEDATE("createDate","出厂日期"),
HW_VERSION("hardwareVersion","硬件版本"),
SW_VERSION("softwareVersion","软件版本");
private String key;

View File

@@ -0,0 +1,56 @@
package com.njcn.gather.report.pojo.enums;
/**
* @author hongawen
* @version 1.0
* @data 2025/5/22 9:46
*/
import lombok.Getter;
/**
* 统计文档锚点类型
*
* @author hongawen
* @version 1.0
* @data 2025/3/24 18:42
*/
@Getter
public enum BookmarkEnum {
DATA_LINE("data_line", "准确度数据展示区域,以测试回路维度展示", 1),
DATA_SCRIPT("data_script", "准确度数据展示区域,以检测项维度展示", 1),
TEST_RESULT_DEV("testResult_dev", "检测结论,仅有设备结论", 2),
TEST_RESULT_LINE("testResult_line", "检测结论,仅有回路结论", 2),
TEST_RESULT_DETAIL("testResult_detail", "检测结论,包含回路、设备结论", 2),
CATALOG("catalog", "目录信息", 3);
private String key;
private String desc;
private Integer sort;
BookmarkEnum(String key, String desc, Integer sort) {
this.key = key;
this.desc = desc;
this.sort = sort;
}
/**
* 根据key找到适配的枚举
*
* @param key 枚举的key
* @return 匹配的枚举实例如果没有找到则返回null
*/
public static BookmarkEnum getByKey(String key) {
for (BookmarkEnum bookmarkEnum : BookmarkEnum.values()) {
if (bookmarkEnum.getKey().equalsIgnoreCase(key)) {
return bookmarkEnum;
}
}
return null;
}
}

View File

@@ -13,6 +13,7 @@ public enum ItemReportKeyEnum {
NAME("name", "检测项,比如:频率"),
NAME_DETAIL("nameDetail", "检测项详细,比如:频率测量准确度"),
INFLUENCE("influence", "影响量的描述,比如额定工作条件、谐波对电压的影响等等"),
ERROR_SCOPE("errorScope", "误差范围,注:在段落中时需加上(),表格中无需添加"),
ERROR_SCOPE_MAG("errorScopeMag", "特征幅值:误差范围"),
ERROR_SCOPE_DUR("errorScopeDur", "持续时间:误差范围"),

View File

@@ -16,9 +16,9 @@ public enum PowerIndexEnum {
FREQ("FREQ", "频率"),
V("V", "电压"),
I("I", "电流"),
IMBV("IMBV", "三相电压不平衡度"),
IMBA("IMBA", "三相电流不平衡度"),
F("F", "闪变"),
IMBV("IMBV", "负序电压不平衡度"),
IMBA("IMBA", "负序电流不平衡度"),
F("F", "短时电压闪变"),
HP("HP", "谐波有功功率"),
HV("HV", "谐波电压"),
HI("HI", "谐波电流"),

View File

@@ -20,11 +20,11 @@ public enum ReportResponseEnum {
REPORT_TEMPLATE_NOT_EXIST("A012009", "报告模板缺失,请联系管理员!"),
NO_CHECK_DATA("A012010", "没有检测数据,无法生成报告!"),
FILE_RENAME_FAILED("A012011", "文件重命名失败"),
REPORT_NAME_PATTERN_ERROR("A012012","报告名称格式错误可包含中文、字母、数字、中划线、点号、空格长度不能超过32个字符"),
REPORT_VERSION_PATTERN_ERROR("A012013","报告版本号格式错误可包含中文、字母、数字、中划线、点号、空格长度不能超过32个字符"),
FILE_SIZE_ERROR("A012014","文件大小不能超过5MB" ),
GENERATE_REPORT_ERROR("A012015","生成报告失败"),
;
REPORT_NAME_PATTERN_ERROR("A012012", "报告名称格式错误可包含中文、字母、数字、中划线、点号、空格长度不能超过32个字符"),
REPORT_VERSION_PATTERN_ERROR("A012013", "报告版本号格式错误可包含中文、字母、数字、中划线、点号、空格长度不能超过32个字符"),
FILE_SIZE_ERROR("A012014", "文件大小不能超过5MB"),
GENERATE_REPORT_ERROR("A012015", "生成报告失败"),
FTP_CONNECTION_FAILED("A012016", "FTP连接失败无法将二维码文件上传至装置");
private String code;
private String message;

View File

@@ -9,7 +9,6 @@ import com.njcn.gather.report.pojo.vo.PqReportVO;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* @author makejava
@@ -65,7 +64,23 @@ public interface IPqReportService extends IService<PqReport> {
void generateReport(DevReportParam devReportParam);
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
//Map<String, Object> getMap(DevReportParam devReportParam);
/**
* 设备归档操作
*
* @param id 设备id
* @return 归档成功返回true否则返回false
*/
boolean documented(List<String> id);
/**
* 批量上传检测报告到云端
*
* @param deviceIds 被检设备ID列表为空时上传所有已生成报告的设备
*/
void uploadReportToCloud(List<String> deviceIds);
}

View File

@@ -0,0 +1,296 @@
package com.njcn.gather.report.utils;
import com.njcn.gather.report.pojo.enums.BookmarkEnum;
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.wml.*;
import javax.xml.bind.JAXBElement;
import java.util.*;
/**
* 递归查找所有书签,并在书签处插入内容
*/
public class BookmarkUtil {
/**
* 书签信息
*/
public static class BookmarkInfo {
public CTBookmark bookmark;
public P parentParagraph;
public ContentAccessor parentContainer;
}
/**
* 递归查找所有书签
*/
public static List<BookmarkInfo> findAllBookmarks(ContentAccessor contentAccessor) {
List<BookmarkInfo> result = new ArrayList<>();
for (Object obj : contentAccessor.getContent()) {
Object realObj = (obj instanceof JAXBElement) ? ((JAXBElement<?>) obj).getValue() : obj;
if (realObj instanceof P) {
P p = (P) realObj;
for (Object o2 : p.getContent()) {
Object realO2 = (o2 instanceof JAXBElement) ? ((JAXBElement<?>) o2).getValue() : o2;
if (realO2 instanceof CTBookmark) {
BookmarkInfo info = new BookmarkInfo();
info.bookmark = (CTBookmark) realO2;
info.parentParagraph = p;
info.parentContainer = contentAccessor;
result.add(info);
}
}
} else if (realObj instanceof ContentAccessor) {
result.addAll(findAllBookmarks((ContentAccessor) realObj));
}
}
return result;
}
/**
* 在书签后插入段落
*/
public static void insertParagraphsAfter(BookmarkInfo info, P paragraph) {
List<Object> parentContent = info.parentContainer.getContent();
int idx = parentContent.indexOf(info.parentParagraph);
parentContent.add(idx + 1, paragraph);
}
/**
* 在书签后插入表格
*/
public static void insertTableAfter(BookmarkInfo info, Tbl table) {
List<Object> parentContent = info.parentContainer.getContent();
int idx = parentContent.indexOf(info.parentParagraph);
parentContent.add(idx + 1, table);
}
/**
* 在书签后插入元素,可能是段落、表格、图片、书签等
*/
public static void insertElement(BookmarkInfo info, List<Object> elements) {
List<Object> parentContent = info.parentContainer.getContent();
int idx = parentContent.indexOf(info.parentParagraph);
// 遍历元素,如果是通道回路这种大标题需要新起一个空的文档页
for (int i = 0; i < elements.size(); i++) {
Object element = elements.get(i);
if (element instanceof P) {
P p = (P) element;
String textFromP = Docx4jUtil.getTextFromP(p);
if (textFromP.contains("测量回路")) {
if (!textFromP.contains("1")) {
// 另起一页
P pagePara = Docx4jUtil.getPageBreak();
idx = idx + 1;
parentContent.add(idx, pagePara);
}
idx = idx + 1;
parentContent.add(idx, p);
}
// else if (textFromP.startsWith(PowerIndexEnum.IMBV.getDesc())
// || textFromP.startsWith(PowerIndexEnum.HV.getDesc())
// || textFromP.startsWith(PowerIndexEnum.HI.getDesc())
//
// ) {
// // 另起一页
// P pagePara = Docx4jUtil.getPageBreak();
// idx = idx + 1;
// parentContent.add(idx, pagePara);
// idx = idx + 1;
// parentContent.add(idx, element);
// }
else if(textFromP.startsWith("基波电流幅值5.000A基波频率50.0Hz,各次间谐波电流含有率均为3.0%。")){
idx = idx + 1;
parentContent.add(idx, element);
P pagePara = Docx4jUtil.getPageBreak();
idx = idx + 1;
parentContent.add(idx, pagePara);
}
else {
idx = idx + 1;
parentContent.add(idx, element);
}
} else {
idx = idx + 1;
parentContent.add(idx, element);
}
}
}
/**
* 删除文档中的空白页
* @param docx 要处理的Word文档
*/
public static void removeBlankPages(MainDocumentPart mainDocumentPart) {
// 获取文档主体
Document document = mainDocumentPart.getJaxbElement();
Body body = document.getBody();
// 获取所有段落
List<Object> paragraphs = body.getContent();
// 用于标记是否在空白页中
boolean inBlankPage = false;
// 用于存储要删除的段落
List<P> paragraphsToRemove = new ArrayList<>();
for (Object paragraph : paragraphs) {
if (paragraph instanceof P){
P paragraphtemp = (P) paragraph;
// 检查段落是否为空
boolean isEmpty = isParagraphEmpty(paragraphtemp);
if (isEmpty) {
if (!inBlankPage) {
inBlankPage = true;
}
paragraphsToRemove.add(paragraphtemp);
} else {
inBlankPage = false;
}
}
}
// 删除空白段落
for (P paragraph : paragraphsToRemove) {
body.getContent().remove(paragraph);
}
}
/**
* 检查段落是否为空
* @param paragraph 要检查的段落
* @return 如果段落为空返回true否则返回false
*/
private static boolean isParagraphEmpty(P paragraph) {
// 检查段落是否包含分节符
if (paragraph.getPPr() != null && paragraph.getPPr().getSectPr() != null) {
return false;
}
// 检查段落中的文本内容
for (Object obj : paragraph.getContent()) {
if (obj instanceof R) {
R run = (R) obj;
// 在3.3.4版本中使用getContent()获取文本内容
for (Object runContent : run.getContent()) {
if (runContent instanceof Text) {
Text text = (Text) runContent;
if (text.getValue() != null && !text.getValue().trim().isEmpty()) {
return false;
}
}
}
}
}
return true;
}
/**
* 在插入前检查目标位置是否有分页符
*
* @param position 目标位置
* @return 是否包含分页符
*/
private static boolean hasPageBreak(Object position) {
if (position instanceof P) {
P paragraph = (P) position;
for (Object run : paragraph.getContent()) {
if (run instanceof R) {
R r = (R) run;
for (Object element : r.getContent()) {
if (element instanceof Br && ((Br) element).getType() != null
&& ((Br) element).getType().equals("page")) {
return true;
}
}
}
}
return false;
}
return false;
}
/**
* 删除书签
*
* @param bookmarkInfo 书签信息
*/
public static void removeBookmark(BookmarkUtil.BookmarkInfo bookmarkInfo) {
try {
// 获取书签所在的段落
P paragraph = bookmarkInfo.parentParagraph;
// 遍历段落内容,找到并删除书签开始和结束标记
List<Object> paragraphContent = new ArrayList<>(paragraph.getContent());
for (Object obj : paragraphContent) {
if (obj instanceof JAXBElement) {
JAXBElement<?> element = (JAXBElement<?>) obj;
Object value = element.getValue();
// 删除书签开始标记
if (value instanceof CTBookmark) {
paragraph.getContent().remove(obj);
}
// 删除书签结束标记
else if (value instanceof CTMarkupRange) {
paragraph.getContent().remove(obj);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 使用 ObjectFactory 创建表格
*
* @param factory ObjectFactory 实例
* @param data 二维数组,表格内容
* @return Tbl 表格对象
*/
public static Tbl createTable(ObjectFactory factory, String[][] data) {
Tbl table = factory.createTbl();
for (String[] rowData : data) {
Tr row = factory.createTr();
for (String cellData : rowData) {
Tc cell = factory.createTc();
P para = factory.createP();
R run = factory.createR();
Text text = factory.createText();
text.setValue(cellData);
run.getContent().add(text);
para.getContent().add(run);
cell.getContent().add(para);
row.getContent().add(cell);
}
table.getContent().add(row);
}
return table;
}
/**
* 获取指定标签的标签信息
*
* @param key 标签名
* @param bookmarks 所有标签信息
*/
public static BookmarkInfo getBookmarkInfo(String key, List<BookmarkInfo> bookmarks) {
BookmarkUtil.BookmarkInfo bookmarkInfo = null;
for (BookmarkUtil.BookmarkInfo info : bookmarks) {
String name = info.bookmark.getName();
if (key.equalsIgnoreCase(name)) {
bookmarkInfo = info;
}
}
return bookmarkInfo;
}
}

View File

@@ -5,19 +5,12 @@ import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.StrUtil;
import com.njcn.gather.report.pojo.constant.ReportConstant;
import com.njcn.gather.report.pojo.enums.DocAnchorEnum;
import com.njcn.gather.report.pojo.vo.Bookmark;
import org.docx4j.XmlUtils;
import org.docx4j.jaxb.Context;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.wml.*;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;
import java.io.StringWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
@@ -244,13 +237,14 @@ public class Docx4jUtil {
/**
* 段落中添加内容
*/
public static void addPContent(ObjectFactory factory, P paragraph, String content, RPr rPr) {
public static void addPContent(ObjectFactory factory, P paragraph, String content, RPr rPr,PPr ppr) {
R run = factory.createR();
Text text = factory.createText();
text.setValue(content);
run.setRPr(rPr);
run.getContent().add(text);
paragraph.getContent().add(run);
paragraph.setPPr(ppr);
}
/**
@@ -328,17 +322,20 @@ public class Docx4jUtil {
}
/**
* 根据已知信息创建新
* 根据已知信息创建新
*
* @param factory 工厂
* @param valueMap 数据
* @param tableKeys keys
* @param trPr 行样式
* @param tcPr 单元格样式
* @param factory 工厂
* @param valueMap 数据
* @param tableKeys keys
* @param trPr 行样式
* @param tcPrList 每个单元格样式列表(用于保留各单元格独立的边框设置)
* @param templateRPr 模板中的字体样式可为null为null时使用默认宋体10号
* @param centerFlag 是否居中
*/
public static Tr createCustomRow(ObjectFactory factory, Map<String, String> valueMap, List<String> tableKeys, TrPr trPr, TcPr tcPr, boolean centerFlag) {
public static Tr createCustomRow(ObjectFactory factory, Map<String, String> valueMap, List<String> tableKeys, TrPr trPr, List<TcPr> tcPrList, RPr templateRPr, boolean centerFlag) {
Tr row = factory.createTr();
for (String tableKey : tableKeys) {
for (int i = 0; i < tableKeys.size(); i++) {
String tableKey = tableKeys.get(i);
Tc cell = factory.createTc();
P paragraph = factory.createP();
R run = factory.createR();
@@ -347,6 +344,41 @@ public class Docx4jUtil {
text.setValue(value);
run.getContent().add(text);
paragraph.getContent().add(run);
// 从模板复制字体样式
RPr rPr = factory.createRPr();
if (templateRPr != null) {
// 复制字体
if (templateRPr.getRFonts() != null) {
RFonts rFonts = factory.createRFonts();
rFonts.setEastAsia(templateRPr.getRFonts().getEastAsia());
rFonts.setAscii(templateRPr.getRFonts().getAscii());
rFonts.setHAnsi(templateRPr.getRFonts().getHAnsi());
rPr.setRFonts(rFonts);
}
// 复制字号
if (templateRPr.getSz() != null) {
HpsMeasure sz = factory.createHpsMeasure();
sz.setVal(templateRPr.getSz().getVal());
rPr.setSz(sz);
}
if (templateRPr.getSzCs() != null) {
HpsMeasure szCs = factory.createHpsMeasure();
szCs.setVal(templateRPr.getSzCs().getVal());
rPr.setSzCs(szCs);
}
} else {
// 默认使用宋体10号
RFonts rFonts = factory.createRFonts();
rFonts.setEastAsia("宋体");
rFonts.setAscii("宋体");
rFonts.setHAnsi("宋体");
rPr.setRFonts(rFonts);
HpsMeasure sz = factory.createHpsMeasure();
sz.setVal(new BigInteger("20"));
rPr.setSz(sz);
}
// 设置段落居中
if (centerFlag) {
PPr pPr = factory.createPPr();
@@ -355,16 +387,19 @@ public class Docx4jUtil {
pPr.setJc(jc);
paragraph.setPPr(pPr);
}
if (value.equals("不合格")) {
RPr rPr = factory.createRPr();
// 不合格标红
if (value != null && value.equals("不合格")) {
Color color = factory.createColor();
// 红色
color.setVal("FF0000");
rPr.setColor(color);
run.setRPr(rPr);
}
run.setRPr(rPr);
cell.getContent().add(paragraph);
cell.setTcPr(tcPr);
// 使用对应位置的单元格样式(保留边框设置)
if (tcPrList != null && i < tcPrList.size()) {
cell.setTcPr(tcPrList.get(i));
}
row.getContent().add(cell);
row.setTrPr(trPr);
}
@@ -372,20 +407,39 @@ public class Docx4jUtil {
}
/**
* 判断字符串是否包含中文
* @param str 需要判断的字符串
* @return 是否包含中文
*/
private static boolean containsChinese(String str) {
if (str == null) {
return false;
}
for (char c : str.toCharArray()) {
if (Character.UnicodeScript.of(c) == Character.UnicodeScript.HAN) {
return true;
}
}
return false;
}
/**
* 根据已知信息创建新行
*
* @param factory 工厂
* @param cellValues 数据
* @param factory 工厂
* @param cellValues 数据
* @param ascFontStyle 西文字体
* @param eastFontStyle 中文字体
* @param size 字体大小
* @param boldFlag 是否加粗
* @param centerFlag 是否居中
* @param eastFontStyle 中文字体
* @param size 字体大小
* @param boldFlag 是否加粗
* @param centerFlag 是否居中
*/
public static Tr createCustomRow(ObjectFactory factory, List<String> cellValues, String ascFontStyle,String eastFontStyle, Integer size, boolean boldFlag, boolean centerFlag) {
public static Tr createCustomRow(ObjectFactory factory, List<String> cellValues, String ascFontStyle, String eastFontStyle, Integer size, boolean boldFlag, List<Integer> centerFlag) {
Tr row = factory.createTr();
for (String value : cellValues) {
for (int i = 0; i < cellValues.size(); i++) {
String value = cellValues.get(i);
Tc cell = factory.createTc();
P paragraph = factory.createP();
R run = factory.createR();
@@ -394,7 +448,7 @@ public class Docx4jUtil {
run.getContent().add(text);
paragraph.getContent().add(run);
// 设置段落居中
if (centerFlag) {
if (!centerFlag.contains(i)) {
PPr pPr = factory.createPPr();
Jc jc = factory.createJc();
jc.setVal(JcEnumeration.CENTER);
@@ -408,7 +462,7 @@ public class Docx4jUtil {
color.setVal("FF0000");
rPr.setColor(color);
}
if(boldFlag){
if (boldFlag) {
BooleanDefaultTrue bold = factory.createBooleanDefaultTrue();
rPr.setB(bold);
}
@@ -425,9 +479,20 @@ public class Docx4jUtil {
rPr.setSz(fontSize);
// 中文字号
rPr.setSzCs(fontSize);
run.setRPr(rPr);
cell.getContent().add(paragraph);
// 设置单元格边距
TcPr cellProperties = factory.createTcPr();
cell.setTcPr(cellProperties);
// 设置单元格上下边距(单位:缇)
TcMar mar = factory.createTcMar();
TblWidth top = factory.createTblWidth();
top.setW(BigInteger.valueOf(100));
mar.setTop(top);
TblWidth bottom = factory.createTblWidth();
bottom.setW(BigInteger.valueOf(100));
mar.setBottom(bottom);
cellProperties.setTcMar(mar);
row.getContent().add(cell);
}
return row;
@@ -448,7 +513,6 @@ public class Docx4jUtil {
}
// 存储Heading 5及其子内容的辅助类
public static class HeadingContent {
private String headingText;
@@ -471,6 +535,38 @@ public class Docx4jUtil {
}
}
/**
* 获取指定书签在文档段落中的位置索引
*
* @param documentPart 主文档部分
* @param bookmarkName 书签名称
* @return 段落索引,找不到返回 -1
*/
public static int getParagraphPosition(MainDocumentPart documentPart, String bookmarkName) {
List<Object> content = documentPart.getContent();
for (int i = 0; i < content.size(); i++) {
Object obj = content.get(i);
// 只处理段落
if (obj instanceof P) {
P paragraph = (P) obj;
// 提取段落纯文本
String text = getTextFromP(paragraph).trim();
if (text.startsWith("#{") && text.endsWith("}")) {
// 提取书签名
String name = text.substring(2, text.length() - 1);
if (name.equals(bookmarkName)) {
// 返回段落索引
return i;
}
}
}
}
// 找不到返回 -1
return -1;
}
/**
* 获取段落在文档中的位置
*/
@@ -534,4 +630,27 @@ public class Docx4jUtil {
}
/**
* 获取分页符
*/
public static P getPageBreak() {
try {
ObjectFactory factory = new ObjectFactory();
// 创建分页符
R run = factory.createR();
Br br = factory.createBr();
br.setType(STBrType.PAGE);
// 直接添加 br 对象
run.getContent().add(br);
// 创建包含分页符的段落
P pageBreakParagraph = factory.createP();
pageBreakParagraph.getContent().add(run);
return pageBreakParagraph;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -14,11 +14,11 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.po.DevData;
import com.njcn.gather.detection.pojo.vo.DetectionData;
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.service.IAdPlanService;
@@ -36,6 +36,7 @@ import com.njcn.gather.result.pojo.vo.ResultVO;
import com.njcn.gather.result.pojo.vo.TreeDataVO;
import com.njcn.gather.result.service.IResultService;
import com.njcn.gather.script.mapper.PqScriptMapper;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.script.pojo.po.PqScriptDtls;
@@ -53,10 +54,10 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
import com.njcn.gather.storage.pojo.vo.RawDataVO;
import com.njcn.gather.storage.service.AdHarmonicService;
import com.njcn.gather.storage.service.AdNonHarmonicService;
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.dictionary.service.IDictTreeService;
import com.njcn.web.utils.ExcelUtil;
import lombok.RequiredArgsConstructor;
@@ -80,7 +81,6 @@ import java.util.stream.Collectors;
public class ResultServiceImpl implements IResultService {
private final IAdPlanService adPlanService;
private final ISysTestConfigService sysTestConfigService;
private final IPqDevService pqDevService;
private final AdNonHarmonicService adNonHarmonicService;
private final AdHarmonicService adHarmonicService;
@@ -90,6 +90,9 @@ public class ResultServiceImpl implements IResultService {
private final IPqScriptCheckDataService pqScriptCheckDataService;
private final TableGenMapper tableGenMapper;
private final DetectionServiceImpl detectionServiceImpl;
private final IDictDataService dictDataService;
private final IPqScriptCheckDataService iPqScriptCheckDataService;
private final IPqDevService iPqDevService;
/**
* 谐波类code取树形字典表中的code
@@ -108,7 +111,7 @@ public class ResultServiceImpl implements IResultService {
adPlanService.visualize(Collections.singletonList(plan));
}
formContentVO.setScriptName(plan.getScriptId());
formContentVO.setDataRule(sysTestConfigService.getConfig().getDataRule());
formContentVO.setDataRule(plan.getDataRule());
formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName());
List<Map<String, String>> chnList = new ArrayList<>();
@@ -350,7 +353,7 @@ public class ResultServiceImpl implements IResultService {
unit = ResultUnitEnum.V_ABSOLUTELY.getUnit();
}
List<PqScriptDtls> v = scriptDtlIndexList.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList());
dtlType.setScriptTypeName(dictTree.getName() + "=" + v.get(0).getValue().intValue() + unit);
dtlType.setScriptTypeName(dictTree.getName() + "=" + v.get(0).getValue() + unit);
break;
/**
* 电流
@@ -364,7 +367,7 @@ public class ResultServiceImpl implements IResultService {
unitI = ResultUnitEnum.I_ABSOLUTELY.getUnit();
}
List<PqScriptDtls> I = scriptDtlIndexList.stream().filter(x -> "CUR".equals(x.getValueType())).collect(Collectors.toList());
dtlType.setScriptTypeName(dictTree.getName() + "=" + I.get(0).getValue().intValue() + unitI);
dtlType.setScriptTypeName(dictTree.getName() + "=" + I.get(0).getValue() + unitI);
break;
/**
* 谐波电压
@@ -389,7 +392,7 @@ public class ResultServiceImpl implements IResultService {
+ "" + dictTree.getName()); // + "含有率为GB/T"
} else {
//叠加5%的2次谐波电压
dtlType.setScriptTypeName("叠加" + hv.get(0).getValue().intValue() + ResultUnitEnum.HV.getUnit() + "" + hv.get(0).getHarmNum().intValue() + "" + dictTree.getName());
dtlType.setScriptTypeName("叠加" + hv.get(0).getValue() + ResultUnitEnum.HV.getUnit() + "" + hv.get(0).getHarmNum().intValue() + "" + dictTree.getName());
}
break;
/**
@@ -423,7 +426,7 @@ public class ResultServiceImpl implements IResultService {
dtlType.setScriptTypeName(a.toString());
} else {
//叠加5%的2次谐波电压
dtlType.setScriptTypeName("叠加" + harmInNumList.get(0).getValue().intValue() + ResultUnitEnum.HV.getUnit() + "" + harmInNumList.get(0).getHarmNum() + "" + dictTree.getName());
dtlType.setScriptTypeName("叠加" + harmInNumList.get(0).getValue() + ResultUnitEnum.HV.getUnit() + "" + harmInNumList.get(0).getHarmNum() + "" + dictTree.getName());
}
break;
@@ -480,7 +483,7 @@ public class ResultServiceImpl implements IResultService {
});
} else {
PqScriptDtls dtls = harmNumVMap.entrySet().iterator().next().getValue().get(0);
a.append(dtls.getValue().intValue() + ResultUnitEnum.HV.getUnit() + "" + dtls.getHarmNum().intValue() + ResultUnitEnum.HV.getName());
a.append(dtls.getValue() + ResultUnitEnum.HV.getUnit() + "" + dtls.getHarmNum().intValue() + ResultUnitEnum.HV.getName());
}
a.append(",");
if (harmNumIMap.size() > 1) {
@@ -499,7 +502,7 @@ public class ResultServiceImpl implements IResultService {
});
} else {
PqScriptDtls dtls = harmNumIMap.entrySet().iterator().next().getValue().get(0);
a.append(dtls.getValue().intValue() + ResultUnitEnum.HI.getUnit() + "" + dtls.getHarmNum().intValue() + "" + ResultUnitEnum.HI.getName());
a.append(dtls.getValue() + ResultUnitEnum.HI.getUnit() + "" + dtls.getHarmNum().intValue() + "" + ResultUnitEnum.HI.getName());
}
dtlType.setScriptTypeName(a.toString());
break;
@@ -967,7 +970,7 @@ public class ResultServiceImpl implements IResultService {
// 暂态的valueType通常只有2个一个特征幅值一个持续时间
List<Map<String, String>> keyFillMapList = new ArrayList<>();
for (Integer sort : indexList) {
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, Collections.singletonList(sort));
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, valueTypeList, Collections.singletonList(sort));
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
if (CollUtil.isNotEmpty(nonHarmList)) {
Map<String, String> keyFillMap = new HashMap<>(16);
@@ -992,7 +995,7 @@ public class ResultServiceImpl implements IResultService {
// 查询结果数据经过上层处理谐波类此处的scriptIndex确保只有一个
if (indexList.size() == 1) {
// 获取谐波数据
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueType, indexList.get(0));
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, valueType, indexList.get(0));
AdHarmonicResult singleResult = adHarmonicService.getSingleResult(param);
// 注如果ABC的标准值一致则同步到standard中
Map<Double, List<PqScriptCheckData>> checkDataHarmNumMap = scriptCheckDataList.stream().collect(Collectors.groupingBy(PqScriptCheckData::getHarmNum));
@@ -1013,10 +1016,8 @@ public class ResultServiceImpl implements IResultService {
double timeDouble = Math.round(harmNum);
int timeInt = (int) timeDouble;
// 填充结果数据
fillThreePhaseData(singleResult, timeInt, keyFillMap);
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
keyFillMapList.add(keyFillMap);
}
fillThreePhaseData(singleResult, timeInt, keyFillMap, scriptCode);
keyFillMapList.add(keyFillMap);
});
if (CollUtil.isNotEmpty(keyFillMapList)) {
// 按次数排序
@@ -1037,16 +1038,14 @@ public class ResultServiceImpl implements IResultService {
// 非谐波的需要区分是否为ABC相还是T相
if (PowerConstant.THREE_PHASE.contains(scriptCode)) {
// 获取该三相的数据
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, Collections.singletonList(valueType), indexList);
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
if (CollUtil.isNotEmpty(nonHarmList)) {
List<Map<String, String>> keyFillMapList = new ArrayList<>();
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
Map<String, String> keyFillMap = new HashMap<>(16);
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap);
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
keyFillMapList.add(keyFillMap);
}
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap, scriptCode);
keyFillMapList.add(keyFillMap);
}
if (CollUtil.isNotEmpty(keyFillMapList)) {
// 需要对所有的填充进行按误差范围分组
@@ -1067,15 +1066,13 @@ public class ResultServiceImpl implements IResultService {
} else {
// 非三相且非暂态,通常只有一个数据,所以直接赋值即可
List<Map<String, String>> keyFillMapList = new ArrayList<>();
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
SingleNonHarmParam param = new SingleNonHarmParam(planCode, devId, lineNo, Collections.singletonList(valueType), indexList);
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
if (CollUtil.isNotEmpty(nonHarmList)) {
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
Map<String, String> keyFillMap = new HashMap<>(8);
fillTPhaseData(adNonHarmonicResult, null, keyFillMap);
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
keyFillMapList.add(keyFillMap);
}
keyFillMapList.add(keyFillMap);
}
}
if (CollUtil.isNotEmpty(keyFillMapList)) {
@@ -1118,7 +1115,7 @@ public class ResultServiceImpl implements IResultService {
* @param timeInt 谐波类需要传指定次数
* @param keyFillMap 待填充的集合Map
*/
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap, String scriptCode) {
DetectionData tempA = getResultData(singleResult, timeInt, PowerConstant.PHASE_A);
DetectionData tempB = getResultData(singleResult, timeInt, PowerConstant.PHASE_B);
DetectionData tempC = getResultData(singleResult, timeInt, PowerConstant.PHASE_C);
@@ -1127,50 +1124,65 @@ public class ResultServiceImpl implements IResultService {
testA = "/", testB = "/", testC = "/",
errorA = "/", errorB = "/", errorC = "/",
resultA = "/", resultB = "/", resultC = "/", result = "/",
errorScope = "/", unit = "";
errorScope = "/", unit = "", scriptDetail = "/";
if (Objects.nonNull(tempA) && (PowerConstant.DATA_RANGE.contains(tempA.getIsData()))) {
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData());
testA = PubUtils.doubleRoundStr(4, tempA.getData());
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
resultA = tempA.getIsData() == 1 ? "合格" : "不合格";
errorScope = tempA.getRadius();
unit = tempA.getUnit();
standard = PubUtils.doubleRoundStr(4, tempA.getResultData());
if (Objects.nonNull(tempA)) {
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
testA = PubUtils.doubleRoundStr(4, tempA.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getData());
if (Objects.nonNull(tempA.getErrorData())) {
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
}
resultA = tempA.getIsData() == 1 ? "合格" : tempA.getIsData() == 2 ? "不合格" : "/";
errorScope = tempA.getRadius() == null ? "/" : tempA.getRadius();
unit = tempA.getUnit() == null ? "" : tempA.getUnit();
standard = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
}
if (Objects.nonNull(tempB) && (PowerConstant.DATA_RANGE.contains(tempB.getIsData()))) {
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData());
testB = PubUtils.doubleRoundStr(4, tempB.getData());
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
resultB = tempB.getIsData() == 1 ? "合格" : "不合格";
if (Objects.nonNull(tempB)) {
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
testB = PubUtils.doubleRoundStr(4, tempB.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getData());
if (Objects.nonNull(tempB.getErrorData())) {
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
}
resultB = tempB.getIsData() == 1 ? "合格" : tempB.getIsData() == 2 ? "不合格" : "/";
if (errorScope.equals("/")) {
errorScope = tempB.getRadius();
errorScope = tempB.getRadius() == null ? "/" : tempB.getRadius();
}
if (StrUtil.isBlank(unit)) {
unit = tempB.getUnit();
unit = tempB.getUnit() == null ? "" : tempB.getUnit();
}
if (standard.equals("/")) {
standard = PubUtils.doubleRoundStr(4, tempB.getResultData());
standard = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
}
}
if (Objects.nonNull(tempC) && (PowerConstant.DATA_RANGE.contains(tempC.getIsData()))) {
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData());
testC = PubUtils.doubleRoundStr(4, tempC.getData());
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
resultC = tempC.getIsData() == 1 ? "合格" : "不合格";
if (Objects.nonNull(tempC)) {
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
testC = PubUtils.doubleRoundStr(4, tempC.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getData());
if (Objects.nonNull(tempC.getErrorData())) {
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
}
resultC = tempC.getIsData() == 1 ? "合格" : tempC.getIsData() == 2 ? "不合格" : "/";
if (errorScope.equals("/")) {
errorScope = tempC.getRadius();
errorScope = tempC.getRadius() == null ? "/" : tempC.getRadius();
}
if (StrUtil.isBlank(unit)) {
unit = tempC.getUnit();
unit = tempC.getUnit() == null ? "" : tempC.getUnit();
}
if (standard.equals("/")) {
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
standard = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
}
}
// 浙江脚本特殊处理
if (scriptCode.equalsIgnoreCase("I")) {
resultA = "/";
resultB = "/";
resultC = "/";
}
if (standardA.equals(standardB) && standardA.equals(standardC)) {
standard = standardA;
}
// 处理脚本输出
scriptDetail = dealScriptDetail(scriptCode, standard);
keyFillMap.put(ItemReportKeyEnum.SCRIPT_DETAIL.getKey(), scriptDetail);
// 标准值
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
@@ -1198,6 +1210,45 @@ public class ResultServiceImpl implements IResultService {
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
}
/**
* 针对浙江杭州处理脚本输出细节todo... 需要更改更合理的方式,现在算是写死的了部分
* 目前浙江这边就是(间)谐波电压/电流
*/
private String dealScriptDetail(String scriptCode, String standard) {
String scriptDetail = "";
PowerIndexEnum powerIndexEnum = PowerIndexEnum.getByKey(scriptCode);
if (powerIndexEnum != null) {
switch (powerIndexEnum) {
case HV:
case HSV:
// 注基波电压幅值57.74V基波频率50.0Hz。
scriptDetail = "基波电压幅值57.74V基波频率50.0Hz。";
break;
case HI:
// 电流是幅值需要与5A得出百分比
try {
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
scriptDetail = "基波电流幅值5.000A基波频率50.0Hz,各次谐波电流含有率均为" + temp + "%。";
} catch (Exception e) {
log.error("dealScriptDetail error:{}", e);
}
break;
case HSI:
// 电流是幅值需要与5A得出百分比
try {
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
scriptDetail = "基波电流幅值5.000A基波频率50.0Hz,各次间谐波电流含有率均为" + temp + "%。";
} catch (Exception e) {
log.error("dealScriptDetail error:{}", e);
}
break;
default:
break;
}
}
return scriptDetail;
}
/**
* T相的相关数据处理非暂态数据
@@ -1210,13 +1261,15 @@ public class ResultServiceImpl implements IResultService {
private void fillTPhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
String standard = "/", test = "/", error = "/", result = "/", errorScope = "/", unit = "";
DetectionData tempT = getResultData(singleResult, timeInt, PowerConstant.PHASE_T);
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
standard = PubUtils.doubleRoundStr(4, tempT.getResultData());
test = PubUtils.doubleRoundStr(4, tempT.getData());
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
result = tempT.getIsData() == 1 ? "合格" : "不合格";
unit = tempT.getUnit();
errorScope = tempT.getRadius();
if (Objects.nonNull(tempT)) {
standard = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
test = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
if (Objects.nonNull(tempT.getErrorData())) {
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
}
result = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 2 ? "不合格" : "/";
unit = tempT.getUnit() == null ? "" : tempT.getUnit();
errorScope = tempT.getRadius() == null ? "/" : tempT.getRadius();
}
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
keyFillMap.put(ItemReportKeyEnum.TEST.getKey(), test);
@@ -1247,11 +1300,13 @@ public class ResultServiceImpl implements IResultService {
DictTree temp = dictTreeService.getById(adType);
if (temp.getCode().equalsIgnoreCase("MAG")) {
// 特征幅值
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData());
testMag = PubUtils.doubleRoundStr(4, tempT.getData());
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
resultMag = tempT.getIsData() == 1 ? "合格" : "不合格";
if (Objects.nonNull(tempT)) {
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
testMag = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
if (Objects.nonNull(tempT.getErrorData())) {
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
}
resultMag = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 2 ? "不合格" : "/";
unitMag = tempT.getUnit();
errorScopeMag = tempT.getRadius();
}
@@ -1259,7 +1314,7 @@ public class ResultServiceImpl implements IResultService {
// 持续时间,需要注意时间单位处理,默认是秒
String timeUnit = "s";
for (String tableKey : tableKeys) {
if (tableKey.contains(ItemReportKeyEnum.STANDARD_DUR.getKey())) {
if (tableKey.contains("standardDur")) {
//截取单位
String[] tempStr = tableKey.split(StrPool.UNDERLINE);
if (tempStr.length > 1) {
@@ -1267,14 +1322,27 @@ public class ResultServiceImpl implements IResultService {
timeUnit = "ms";
}
}
break;
}
}
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
errorDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
unitDur = tempT.getUnit();
errorScopeDur = tempT.getRadius();
if (Objects.nonNull(tempT.getResultData())) {
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
}
if (Objects.nonNull(tempT.getData())) {
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
}
if (Objects.nonNull(tempT.getErrorData())) {
errorDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
}
if (Objects.nonNull(tempT.getIsData())) {
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
}
if (StrUtil.isNotBlank(tempT.getUnit())) {
unitDur = tempT.getUnit();
}
if (StrUtil.isNotBlank(tempT.getRadius())) {
errorScopeDur = tempT.getRadius();
}
if (timeUnit.equalsIgnoreCase("ms")) {
// 如果是ms上述的一些数据需要重新处理
if (!standardDur.equalsIgnoreCase("/")) {
@@ -1296,8 +1364,8 @@ public class ResultServiceImpl implements IResultService {
}
}
}
errorScopeMag = dealErrorScope(errorScopeMag).concat(unitMag);
errorScopeDur = dealErrorScope(errorScopeDur).concat(unitDur);
errorScopeMag = dealErrorScope(errorScopeMag).concat(StrUtil.isBlank(unitMag) ? "" : unitMag);
errorScopeDur = dealErrorScope(errorScopeDur).concat(StrUtil.isBlank(unitDur) ? "" : unitDur);
errorScope = "特征幅值:".concat(errorScopeMag).concat(StrPool.COMMA).concat("持续时间:").concat(errorScopeDur);
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
@@ -1331,6 +1399,9 @@ public class ResultServiceImpl implements IResultService {
* @param errorScope 误差范围
*/
private String dealErrorScope(String errorScope) {
if (StrUtil.isBlank(errorScope)) {
return "/";
}
if (errorScope.contains("~")) {
String[] split = errorScope.split("~");
String begin = split[0];
@@ -1466,7 +1537,7 @@ public class ResultServiceImpl implements IResultService {
}
String sql1 = "CREATE TABLE if not exists AD_Harmonic_Result_" + code + "(\n" +
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
" Time_Id DATETIME NULL COMMENT '时间',\n" +
" Time_Id DATETIME(3) NULL COMMENT '时间',\n" +
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id字典表',\n" +
" Sort int(5) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
" AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',\n" +
@@ -1510,12 +1581,19 @@ public class ResultServiceImpl implements IResultService {
// PqDev dev = pqDevService.getById(devId);
devIdMapComm.put(devId, devId);
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
DictDataEnum dataRule;
if (ObjectUtil.isNotNull(oneConfig)) {
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
// SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
// if (ObjectUtil.isNotNull(oneConfig)) {
// dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
// } else {
// dataRule = DictDataEnum.SECTION_VALUE;
// }
AdPlan plan = adPlanService.getById(planId);
DictData dictData = dictDataService.getDictDataById(plan.getDataRule());
if (ObjectUtil.isNotNull(dictData)) {
dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode());
} else {
dataRule = DictDataEnum.AT_WILL_VALUE;
dataRule = DictDataEnum.SECTION_VALUE;
}
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAllRawData(scriptId, oldCode, devId);
@@ -1533,7 +1611,7 @@ public class ResultServiceImpl implements IResultService {
issueParam.setDevIds(Arrays.asList(devId));
issueParam.setScriptId(scriptId);
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
sourceIssues.forEach(sourceIssue -> {
@@ -1553,6 +1631,13 @@ public class ResultServiceImpl implements IResultService {
detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
});
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
checkDataParam.setScriptId(scriptId);
checkDataParam.setIsValueTypeName(false);
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), null, param.getTemperature(), param.getHumidity());
}
private List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm, boolean containBaseHarm) {

View File

@@ -20,7 +20,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -34,14 +36,14 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataMapper, PqScriptCheckData> implements IPqScriptCheckDataService {
private final String SYMBOL="$";
private final String SYMBOL = "$";
private final DictTreeMapper dictTreeMapper;
@Override
public List<String> getValueType(PqScriptCheckDataParam param) {
String dataType = param.getDataType();
if(StrUtil.isNotBlank(dataType)){
if (StrUtil.isNotBlank(dataType)) {
String[] split = dataType.split(",");
if (split.length > 1) {
dataType = split[0];
@@ -60,7 +62,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
if (param.getIsValueTypeName()) {
final String finalDataType = dataType;
List<String> checkData = pqScriptCheckData.stream().map(x -> finalDataType + SYMBOL + x.getValueType()).distinct().collect(Collectors.toList());
String U = finalDataType + SYMBOL+ DetectionCodeEnum.U1.getCode();
String U = finalDataType + SYMBOL + DetectionCodeEnum.U1.getCode();
if (!checkData.contains(U)) {
if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.V2_50.getCode())) {
checkData.add(U);

View File

@@ -14,6 +14,7 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.plan.mapper.AdPlanMapper;
import com.njcn.gather.plan.pojo.po.AdPlan;
@@ -205,10 +206,10 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkDataParam.setScriptId(freqDtls.getScriptId());
checkDataParam.setIndex(freqDtls.getScriptIndex());
checkDataParam.setIsValueTypeName(true);
if(DicDataEnum.F.getCode().equals(issue.getType())||DicDataEnum.VOLTAGE.getCode().equals(issue.getType())){
if (DicDataEnum.F.getCode().equals(issue.getType()) || DicDataEnum.VOLTAGE.getCode().equals(issue.getType())) {
checkDataParam.setDataType("avg");
issue.setDataType("avg");
}else {
} else {
checkDataParam.setDataType(dataType);
issue.setDataType(dataType);
}
@@ -641,7 +642,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
return this.update(new LambdaUpdateWrapper<PqScriptDtls>()
.set(PqScriptDtls::getEnable, param.getEnable())
.eq(PqScriptDtls::getScriptId, param.getScriptId())
.eq(PqScriptDtls::getScriptIndex, param.getIndex())
.eq(ObjectUtil.isNotNull(param.getIndex()), PqScriptDtls::getScriptIndex, param.getIndex())
.eq(ObjectUtil.isNotNull(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
);
}
@@ -705,7 +707,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
issueParam.setSourceId(param.getSourceId());
issueParam.setDevIds(param.getDevIds());
issueParam.setScriptId(param.getScriptId());
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
List<SourceIssue> sourceIssues = this.listSourceIssue(issueParam);
Set<String> dataTypeSet = new HashSet<>();
@@ -885,6 +887,22 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
queryWrapper.eq(PqScriptDtls::getScriptIndex, -1)
.eq(PqScriptDtls::getEnable, 1);
pqScriptDtls = this.list(queryWrapper);
// 相序校验中电流需加量需要依据企标10650.2中章节5.5.3的描述过载能力2 倍额定电流连续10 倍额定电流持续 1 s。
// 考虑到有可能存在1A的额定电流本处做特殊处理加量分别为额定电流的0.2/0.4/0.6的标幺乘积加量
// 电压暂不做处理原因1、电压的企标描述过载能力为4倍空间较大2、额定电压比如57.74V为浮点数,存在不确定小数位,避免引起算术误差;
// 1. 获取额定电流,前端已做限制,相同额定电流才能一起检测
String deviceId = param.getDevIds().get(0);
PqDevVO pqDev = pqDevService.getPqDevById(deviceId);
String devTypeId = pqDev.getDevType();
DevType devType = devTypeService.getById(devTypeId);
Double devCurr = devType.getDevCurr();
for (int i = 0; i < pqScriptDtls.size(); i++) {
PqScriptDtls scriptDtls = pqScriptDtls.get(i);
// 注意此处scriptDtls.getValue() < 1.0,考虑到有些已经投入运行的地方,可能没有改库,避免不必要的异常
if(scriptDtls.getValueType().equalsIgnoreCase("CUR") && scriptDtls.getValue() < 1.0){
scriptDtls.setValue(devCurr * scriptDtls.getValue());
}
}
} else if (param.getIsPhaseSequence().equals(CommonEnum.COEFFICIENT_TEST.getValue())) {
//系数
queryWrapper.in(PqScriptDtls::getScriptIndex, param.getIndexList())
@@ -1014,11 +1032,12 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
PqScriptDtls dip = dipList.get(0);
dipDataDTO.setFTransValue(dip.getTransValue());
if (devFly) {
if (isValueType) {
// if (isValueType) {
dipDataDTO.setFTransValue(dip.getTransValue());
} else {
dipDataDTO.setFTransValue(NumberUtil.round(dip.getTransValue() / dtls.getValue(), 4).doubleValue());
}
// }
// else {
// dipDataDTO.setFTransValue(NumberUtil.round(dip.getTransValue() / dtls.getValue(), 4).doubleValue());
// }
}
// 1.0/频率*持续时间(周波)= 暂态持续时间s
dipDataDTO.setFRetainTime(NumberUtil.round(1.0 / fFreq * dip.getRetainTime(), 3).doubleValue());

View File

@@ -61,6 +61,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
@Override
@Transactional
public String addPqScript(PqScriptParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, false);
PqScript pqScript = new PqScript();
BeanUtils.copyProperties(param, pqScript);
@@ -73,6 +74,7 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
@Override
@Transactional
public boolean updatePqScript(PqScriptParam.UpdateParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, true);
PqScript pqScript = new PqScript();
BeanUtils.copyProperties(param, pqScript);

View File

@@ -91,7 +91,7 @@ public class ScriptDtlsDesc {
buffer.append(name + " ");
for (PqScriptDtls dtls : list) {
buffer.append(dtls.getPhase() + "相(暂态深度=" + dtls.getTransValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit()
+ ",暂态持续时间=" + (ObjectUtil.isNull(dtls.getRetainTime()) ? dtls.getRetainTime() : dtls.getRetainTime().intValue()) + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") ");
+ ",暂态持续时间=" + (ObjectUtil.isNull(dtls.getRetainTime()) ? "/" : dtls.getRetainTime().toString()) + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") ");
}
}
}

View File

@@ -96,7 +96,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
@Override
public List<Map<String, Object>> listAllPqSource(String patternId) {
List<PqSource> pqSourceList = this.lambdaQuery().eq(PqSource::getPattern, patternId).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).list();
List<PqSource> pqSourceList = this.lambdaQuery().eq(PqSource::getPattern, patternId).orderByAsc(PqSource::getCreateTime).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).list();
List<Map<String, Object>> result = pqSourceList.stream().map(pqSource -> {
Map<String, Object> map = new HashMap<>();
map.put("id", pqSource.getId());

View File

@@ -73,6 +73,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
@Override
@Transactional
public boolean addDevType(DevTypeParam addParam) {
addParam.setName(addParam.getName().trim());
this.checkRepeat(addParam, false);
DevType devType = new DevType();
BeanUtil.copyProperties(addParam, devType);
@@ -83,6 +84,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
@Override
@Transactional
public boolean updateDevType(DevTypeParam.UpdateParam updateParam) {
updateParam.setName(updateParam.getName().trim());
this.checkRepeat(updateParam, true);
DevType devType = new DevType();
BeanUtil.copyProperties(updateParam, devType);

View File

@@ -6,7 +6,7 @@ spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.24:13306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
url: jdbc:mysql://192.168.1.24:13306/pqs9100_bj?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
username: root
password: njcnpqs
# url: jdbc:mysql://localhost:3306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
@@ -49,10 +49,10 @@ phaseAngle:
socket:
source:
ip: 192.168.1.138
ip: 192.168.1.125
port: 62000
device:
ip: 192.168.1.138
ip: 192.168.1.125
port: 61000
# source:
# ip: 192.168.1.121
@@ -77,8 +77,8 @@ Dip:
Flicker:
waveFluType: SQU
waveType: CPM
waveFluType: CPM
waveType: SQU
fDutyCycle: 50f
log:
@@ -87,4 +87,19 @@ log:
report:
template: D:\template
reportDir: D:\report
dateFormat: yyyy年MM月dd日
qr:
cloud: http://pqmcc.com:18082/api/file
dev:
name: njcn
password: Pqs@12345678
port: 21
path: /etc/qrc.bin
gcDev:
name: root
password: Pqs@12345678
port: 21
path: /emmc/qrc.bin
db:
type: mysql

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3,13 +3,18 @@ package com.njcn;
import com.njcn.gather.EntranceApplication;
import com.njcn.gather.report.pojo.DevReportParam;
import com.njcn.gather.report.service.IPqReportService;
import com.njcn.http.util.RestTemplateUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.io.File;
import java.util.HashMap;
/**
* @author hongawen
@@ -24,14 +29,18 @@ public class BaseJunitTest {
@Autowired
private IPqReportService pqReportService;
@Autowired
private RestTemplateUtil restTemplateUtil;
@Test
public void test() {
DevReportParam devReportParam = new DevReportParam();
devReportParam.setPlanId("ad3df9e4a90b4c3c8ce7d21a84ce6f59");
devReportParam.setPlanCode("31");
devReportParam.setScriptId("810e4050e1d445e3542c998a077a263a");
devReportParam.setDevId("a46349a3b3cf4789a6b82690a6076afd");
pqReportService.generateReport(devReportParam);
File file = new File("D:\\report\\PQS_882B4\\5555.docx");
try{
ResponseEntity<String> stringResponseEntity = restTemplateUtil.uploadFile("http://localhost:18082/api/file/upload",file);
}catch (Exception runtimeException){
System.out.println(runtimeException.getMessage());
}
}
}

33
event_smart/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

166
event_smart/pom.xml Normal file
View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.gather</groupId>
<artifactId>CN_Gather</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>event_smart</artifactId>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>njcn-common</artifactId>
<version>0.0.1</version>
</dependency>
<!-- <dependency>
<groupId>com.njcn</groupId>
<artifactId>rocket-mq-springboot-starter</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<version>2.7.12</version>
</dependency>
<!-- 多数据源切换当数据源为oracle时需要使用 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>spingboot2.3.12</artifactId>
<version>2.3.12</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mybatis-plus</artifactId>
<version>0.0.1</version>
</dependency>
<!--oracle驱动-->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.6.0.0</version>
</dependency>
<dependency>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
<version>21.1.0.0</version> <!-- 版本号需要与你的ojdbc版本匹配 -->
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-event</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<artifactId>common-microservice</artifactId>
<groupId>com.njcn</groupId>
</exclusion>
<exclusion>
<artifactId>common-web</artifactId>
<groupId>com.njcn</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version> <!-- 使用最新稳定版 -->
</dependency>
</dependencies>
<build>
<finalName>event_smart</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@@ -0,0 +1,22 @@
package com.njcn.gather.event;
import com.njcn.event.file.component.WavePicComponent;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
@Slf4j
@SpringBootApplication(scanBasePackages = "com.njcn")
//@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WavePicComponent.class))
@MapperScan("com.njcn.**.mapper")
public class EventSmartApplication {
public static void main(String[] args) {
SpringApplication.run(EventSmartApplication.class, args);
}
}

View File

@@ -0,0 +1,20 @@
package com.njcn.gather.event.devcie.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.po.PqDevice;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
* Description:
* Date: 2025/06/19 下午 1:47【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PqDeviceMapper extends BaseMapper<PqDevice> {
List<DeviceDTO> queryListByIds(@Param("ids") List<Integer> ids);
}

View File

@@ -0,0 +1,22 @@
package com.njcn.gather.event.devcie.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.devcie.pojo.po.PqLine;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
* Description:
* Date: 2025/06/19 下午 1:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PqLineMapper extends BaseMapper<PqLine> {
List<LedgerBaseInfoDTO> getBaseLineInfo(@Param("ids")List<Integer> ids);
}

View File

@@ -0,0 +1,9 @@
package com.njcn.gather.event.devcie.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.gather.event.devcie.pojo.po.PqLinedetail;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PqLinedetailMapper extends BaseMapper<PqLinedetail> {
}

View File

@@ -0,0 +1,20 @@
package com.njcn.gather.event.devcie.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.gather.event.devcie.pojo.dto.SubstationDTO;
import com.njcn.gather.event.devcie.pojo.po.PqSubstation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
* Description:
* Date: 2025/06/19 下午 1:48【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PqSubstationMapper extends BaseMapper<PqSubstation> {
List<SubstationDTO> queryListByIds(@Param("ids")List<Integer> ids);
}

View File

@@ -0,0 +1,53 @@
<?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.gather.event.devcie.mapper.PqDeviceMapper">
<resultMap id="BaseResultMap" type="com.njcn.gather.event.devcie.pojo.po.PqDevice">
<!--@mbg.generated-->
<!--@Table PQ_DEVICE-->
<id column="DEV_INDEX" jdbcType="DECIMAL" property="devIndex" />
<result column="GD_INDEX" jdbcType="DECIMAL" property="gdIndex" />
<result column="SUB_INDEX" jdbcType="DECIMAL" property="subIndex" />
<result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="STATUS" jdbcType="DECIMAL" property="status" />
<result column="DEVTYPE" jdbcType="VARCHAR" property="devtype" />
<result column="LOGONTIME" jdbcType="TIMESTAMP" property="logontime" />
<result column="UPDATETIME" jdbcType="TIMESTAMP" property="updatetime" />
<result column="NODE_INDEX" jdbcType="DECIMAL" property="nodeIndex" />
<result column="PORTID" jdbcType="DECIMAL" property="portid" />
<result column="DEVFLAG" jdbcType="DECIMAL" property="devflag" />
<result column="DEV_SERIES" jdbcType="VARCHAR" property="devSeries" />
<result column="DEV_KEY" jdbcType="VARCHAR" property="devKey" />
<result column="IP" jdbcType="VARCHAR" property="ip" />
<result column="DEVMODEL" jdbcType="DECIMAL" property="devmodel" />
<result column="CALLFLAG" jdbcType="DECIMAL" property="callflag" />
<result column="DATATYPE" jdbcType="DECIMAL" property="datatype" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
DEV_INDEX, GD_INDEX, SUB_INDEX, "NAME", "STATUS", DEVTYPE, LOGONTIME, UPDATETIME,
NODE_INDEX, PORTID, DEVFLAG, DEV_SERIES, DEV_KEY, IP, DEVMODEL, CALLFLAG, DATATYPE
</sql>
<select id="queryListByIds" resultType="com.njcn.gather.event.devcie.pojo.dto.DeviceDTO">
select
pq_device.dev_index devId,
pq_device.name devName,
pq_device.UpdateTime updateTime,
pq_device.DevFlag devFlag,
pq_device.IP ip,
PQ_SUBSTATION.sub_index stationId,
PQ_SUBSTATION.name stationName,
PQ_GDINFORMATION.Name gdName
from
pq_device,
PQ_SUBSTATION,
PQ_GDINFORMATION
where
pq_device.SUB_INDEX = PQ_SUBSTATION.SUB_INDEX
and pq_device.GD_INDEX =PQ_GDINFORMATION.GD_INDEX
and pq_device.DEV_INDEX in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,59 @@
<?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.gather.event.devcie.mapper.PqLineMapper">
<resultMap id="BaseResultMap" type="com.njcn.gather.event.devcie.pojo.po.PqLine">
<!--@mbg.generated-->
<!--@Table PQ_LINE-->
<id column="LINE_INDEX" jdbcType="DECIMAL" property="lineIndex" />
<result column="GD_INDEX" jdbcType="DECIMAL" property="gdIndex" />
<result column="SUB_INDEX" jdbcType="DECIMAL" property="subIndex" />
<result column="SUBV_INDEX" jdbcType="DECIMAL" property="subvIndex" />
<result column="DEV_INDEX" jdbcType="DECIMAL" property="devIndex" />
<result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="PT1" jdbcType="FLOAT" property="pt1" />
<result column="PT2" jdbcType="FLOAT" property="pt2" />
<result column="CT1" jdbcType="FLOAT" property="ct1" />
<result column="CT2" jdbcType="FLOAT" property="ct2" />
<result column="DEVCMP" jdbcType="FLOAT" property="devcmp" />
<result column="DLCMP" jdbcType="FLOAT" property="dlcmp" />
<result column="JZCMP" jdbcType="FLOAT" property="jzcmp" />
<result column="XYCMP" jdbcType="FLOAT" property="xycmp" />
<result column="SUBV_NO" jdbcType="DECIMAL" property="subvNo" />
<result column="SCALE" jdbcType="VARCHAR" property="scale" />
<result column="SUBV_NAME" jdbcType="VARCHAR" property="subvName" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
LINE_INDEX, GD_INDEX, SUB_INDEX, SUBV_INDEX, DEV_INDEX, "NAME", PT1, PT2, CT1, CT2,
DEVCMP, DLCMP, JZCMP, XYCMP, SUBV_NO, "SCALE", SUBV_NAME
</sql>
<select id="getBaseLineInfo" resultType="com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO">
select
pq_line.line_index lineId,
pq_line.name lineName,
PQ_LINEDETAIL.objname objName,
PQ_SUBVOLTAGE.SUBV_INDEX busBarId,
PQ_SUBVOLTAGE.name busBarName,
pq_device.dev_index devId,
pq_device.name devName,
pq_device.Status runFlag,
PQ_SUBSTATION.sub_index stationId,
PQ_SUBSTATION.name stationName
from
pq_line,
PQ_LINEDETAIL,
PQ_SUBVOLTAGE,
pq_device,
PQ_SUBSTATION
where pq_line.line_index = PQ_LINEDETAIL.line_index
and pq_line.SUBV_INDEX = PQ_SUBVOLTAGE.SUBV_INDEX
and PQ_SUBVOLTAGE.DEV_INDEX = pq_device.DEV_INDEX
and pq_device.SUB_INDEX = PQ_SUBSTATION.SUB_INDEX
and pq_line.line_index in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,32 @@
<?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.gather.event.devcie.mapper.PqSubstationMapper">
<resultMap id="BaseResultMap" type="com.njcn.gather.event.devcie.pojo.po.PqSubstation">
<!--@mbg.generated-->
<!--@Table PQ_SUBSTATION-->
<id column="SUB_INDEX" jdbcType="DECIMAL" property="subIndex" />
<result column="GD_INDEX" jdbcType="DECIMAL" property="gdIndex" />
<result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="SCALE" jdbcType="VARCHAR" property="scale" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
SUB_INDEX, GD_INDEX, "NAME", "SCALE"
</sql>
<select id="queryListByIds" resultType="com.njcn.gather.event.devcie.pojo.dto.SubstationDTO">
select
PQ_SUBSTATION.sub_index stationId,
PQ_SUBSTATION.name stationName,
PQ_GDINFORMATION.Name gdName
from
PQ_SUBSTATION,
PQ_GDINFORMATION
where
PQ_SUBSTATION.GD_INDEX =PQ_GDINFORMATION.GD_INDEX
and PQ_SUBSTATION.SUB_INDEX in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,28 @@
package com.njcn.gather.event.devcie.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
* Description:
* Date: 2025/06/27 下午 3:25【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class DeviceDTO {
private Integer devId;
private String devName;
private Integer stationId;
private String stationName;
private String gdName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private String devFlag;
private String ip;
//通讯状态
private Integer runFlag=0;
}

View File

@@ -0,0 +1,34 @@
package com.njcn.gather.event.devcie.pojo.dto;
import lombok.Data;
/**
* @Author: cdf
* @CreateTime: 2025-06-25
* @Description:
*/
@Data
public class LedgerBaseInfoDTO {
private Integer lineId;
private String lineName;
private Integer busBarId;
private String busBarName;
private Integer devId;
private String devName;
private String objName;
private Integer stationId;
private String stationName;
//通讯状态
private Integer runFlag=0;
}

View File

@@ -0,0 +1,20 @@
package com.njcn.gather.event.devcie.pojo.dto;
import lombok.Data;
/**
* Description:
* Date: 2025/06/27 下午 3:37【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class SubstationDTO {
private Integer stationId;
private String stationName;
private String gdName;
private Integer runFlag=0;;
}

View File

@@ -0,0 +1,127 @@
package com.njcn.gather.event.devcie.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 lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2025/06/19 下午 1:47【需求编号】
*
* @author clam
* @version V1.0.0
*/
/**
* 靠靠?
*/
@Data
@NoArgsConstructor
@TableName(value = "PQ_DEVICE")
public class PqDevice {
/**
* 靠靠
*/
@TableId(value = "DEV_INDEX", type = IdType.INPUT)
private Integer devIndex;
/**
* 靠靠靠
*/
@TableField(value = "GD_INDEX")
private Integer gdIndex;
/**
* 靠靠?
*/
@TableField(value = "SUB_INDEX")
private Integer subIndex;
/**
* 靠靠
*/
@TableField(value = "\"NAME\"")
private String name;
/**
* 靠靠靠(0:靠;1:靠)
*/
@TableField(value = "\"STATUS\"")
private Short status;
/**
* (靠縋QS_Dicdata)靠靠Guid
*/
@TableField(value = "DEVTYPE")
private String devtype;
/**
* 靠靠
*/
@TableField(value = "LOGONTIME")
private LocalDateTime logontime;
/**
* 靠靠靠
*/
@TableField(value = "UPDATETIME")
private LocalDateTime updatetime;
/**
* 靠縉odeInformation)靠靠靠,靠靠靠靠靠靠靠?
*/
@TableField(value = "NODE_INDEX")
private Integer nodeIndex;
/**
* 靠ID,靠靠靠
*/
@TableField(value = "PORTID")
private Long portid;
/**
* 靠靠(0:靠;1:靠;2:靠)
*/
@TableField(value = "DEVFLAG")
private Short devflag;
/**
* 靠靠?靠3ds靠
*/
@TableField(value = "DEV_SERIES")
private String devSeries;
/**
* 靠靠,靠3ds靠
*/
@TableField(value = "DEV_KEY")
private String devKey;
/**
* IP靠
*/
@TableField(value = "IP")
private String ip;
/**
* 靠靠(0:靠靠;1:靠靠)
*/
@TableField(value = "DEVMODEL")
private Short devmodel;
/**
* 靠靠?
*/
@TableField(value = "CALLFLAG")
private Short callflag;
/**
* 靠靠(0:靠靠;1:靠靠;2:靠靠)
*/
@TableField(value = "DATATYPE")
private Short datatype;
}

View File

@@ -0,0 +1,126 @@
package com.njcn.gather.event.devcie.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 lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2025/06/19 下午 1:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
/**
* 靠靠?
*/
@Data
@NoArgsConstructor
@TableName(value = "PQ_LINE")
public class PqLine {
/**
* 靠靠
*/
@TableId(value = "LINE_INDEX", type = IdType.INPUT)
private Integer lineIndex;
/**
* 靠靠靠
*/
@TableField(value = "GD_INDEX")
private Integer gdIndex;
/**
* 靠靠?
*/
@TableField(value = "SUB_INDEX")
private Integer subIndex;
/**
* 靠靠
*/
@TableField(value = "SUBV_INDEX")
private Integer subvIndex;
/**
* 靠靠
*/
@TableField(value = "DEV_INDEX")
private Integer devIndex;
/**
* 靠靠
*/
@TableField(value = "\"NAME\"")
private String name;
/**
* PT靠靠
*/
@TableField(value = "PT1")
private Double pt1;
/**
* PT靠靠
*/
@TableField(value = "PT2")
private Double pt2;
/**
* CT靠靠
*/
@TableField(value = "CT1")
private Double ct1;
/**
* CT靠靠
*/
@TableField(value = "CT2")
private Double ct2;
/**
* 靠靠
*/
@TableField(value = "DEVCMP")
private Double devcmp;
/**
* 靠靠
*/
@TableField(value = "DLCMP")
private Double dlcmp;
/**
* 靠靠
*/
@TableField(value = "JZCMP")
private Double jzcmp;
/**
* 靠靠
*/
@TableField(value = "XYCMP")
private Double xycmp;
/**
* 靠?靠靠靠靠靠靠?
*/
@TableField(value = "SUBV_NO")
private Short subvNo;
/**
* (靠PQS_Dictionary?靠靠Guid
*/
@TableField(value = "\"SCALE\"")
private String scale;
/**
* 靠靠
*/
@TableField(value = "SUBV_NAME")
private String subvName;
}

View File

@@ -0,0 +1,52 @@
package com.njcn.gather.event.devcie.pojo.po;
/**
* @Author: cdf
* @CreateTime: 2025-06-26
* @Description:
*/
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
@TableName("PQ_LINEDETAIL")
public class PqLinedetail {
@TableId(value = "LINE_INDEX", type = IdType.INPUT)
private Integer lineIndex;
private Integer gdIndex;
private Integer subIndex;
private String lineName;
private Integer pttype;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date lastTime;
private Integer tinterval;
private String loadtype;
private String businesstype;
private String remark;
private String monitorId;
private Integer powerid;
private String objname;
@TableField(fill = FieldFill.INSERT)
private Integer statflag;
private String lineGrade;
private String powerSubstationName;
}

View File

@@ -0,0 +1,45 @@
package com.njcn.gather.event.devcie.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 lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2025/06/19 下午 1:48【需求编号】
*
* @author clam
* @version V1.0.0
*/
/**
* 靠靠靠
*/
@Data
@NoArgsConstructor
@TableName(value = "PQ_SUBSTATION")
public class PqSubstation {
/**
* 靠靠?
*/
@TableId(value = "SUB_INDEX", type = IdType.INPUT)
private Integer subIndex;
/**
* 靠靠靠
*/
@TableField(value = "GD_INDEX")
private Integer gdIndex;
/**
* 靠靠?
*/
@TableField(value = "\"NAME\"")
private String name;
@TableField(value = "\"SCALE\"")
private String scale;
}

View File

@@ -0,0 +1,33 @@
package com.njcn.gather.event.devcie.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 lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2025/06/19 下午 3:45【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@NoArgsConstructor
@TableName(value = "PQS_DEPTSLINE")
public class PqsDeptsline {
/**
* 部门表Guid
*/
@TableField(value = "DEPTS_INDEX")
private String deptsIndex;
@TableField(value = "LINE_INDEX")
private Integer lineIndex;
@TableField(value = "SYSTYPE")
private String systype;
}

View File

@@ -0,0 +1,21 @@
package com.njcn.gather.event.devcie.service;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.devcie.pojo.po.PqDevice;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
*
* Description:
* Date: 2025/06/19 下午 1:47【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PqDeviceService extends IService<PqDevice>{
List<DeviceDTO> queryListByIds(List<Integer> lineIds);
}

View File

@@ -0,0 +1,22 @@
package com.njcn.gather.event.devcie.service;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.devcie.pojo.po.PqLine;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
*
* Description:
* Date: 2025/06/19 下午 1:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PqLineService extends IService<PqLine>{
List<LedgerBaseInfoDTO> getBaseLineInfo(List<Integer> ids);
}

View File

@@ -0,0 +1,21 @@
package com.njcn.gather.event.devcie.service;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.dto.SubstationDTO;
import com.njcn.gather.event.devcie.pojo.po.PqSubstation;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
*
* Description:
* Date: 2025/06/19 下午 1:48【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PqSubstationService extends IService<PqSubstation>{
List<SubstationDTO> queryListByIds(List<Integer> lineIds);
}

View File

@@ -0,0 +1,16 @@
package com.njcn.gather.event.devcie.service;
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2025/06/19 下午 3:45【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PqsDeptslineService extends IService<PqsDeptsline>{
}

View File

@@ -0,0 +1,26 @@
package com.njcn.gather.event.devcie.service.impl;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.event.devcie.pojo.po.PqDevice;
import com.njcn.gather.event.devcie.mapper.PqDeviceMapper;
import com.njcn.gather.event.devcie.service.PqDeviceService;
/**
*
* Description:
* Date: 2025/06/19 下午 1:47【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class PqDeviceServiceImpl extends ServiceImpl<PqDeviceMapper, PqDevice> implements PqDeviceService{
@Override
public List<DeviceDTO> queryListByIds(List<Integer> lineIds) {
return this.baseMapper.queryListByIds(lineIds);
}
}

View File

@@ -0,0 +1,43 @@
package com.njcn.gather.event.devcie.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.event.devcie.mapper.PqLineMapper;
import com.njcn.gather.event.devcie.pojo.po.PqLine;
import com.njcn.gather.event.devcie.service.PqLineService;
/**
*
* Description:
* Date: 2025/06/19 下午 1:43【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class PqLineServiceImpl extends ServiceImpl<PqLineMapper, PqLine> implements PqLineService{
@Override
public List<LedgerBaseInfoDTO> getBaseLineInfo(List<Integer> ids){
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = new ArrayList<>();
if(ids.size()>1000){
List<List<Integer>> listIds = CollUtil.split(ids,1000);
for(List<Integer> itemIds : listIds){
List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLineInfo(itemIds);
ledgerBaseInfoDTOS.addAll(temp);
}
}else {
List<LedgerBaseInfoDTO> temp =this.baseMapper.getBaseLineInfo(ids);
ledgerBaseInfoDTOS.addAll(temp);
}
return ledgerBaseInfoDTOS;
};
}

View File

@@ -0,0 +1,26 @@
package com.njcn.gather.event.devcie.service.impl;
import com.njcn.gather.event.devcie.pojo.dto.SubstationDTO;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.event.devcie.pojo.po.PqSubstation;
import com.njcn.gather.event.devcie.mapper.PqSubstationMapper;
import com.njcn.gather.event.devcie.service.PqSubstationService;
/**
*
* Description:
* Date: 2025/06/19 下午 1:48【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class PqSubstationServiceImpl extends ServiceImpl<PqSubstationMapper, PqSubstation> implements PqSubstationService{
@Override
public List<SubstationDTO> queryListByIds(List<Integer> lineIds) {
return this.baseMapper.queryListByIds(lineIds);
}
}

View File

@@ -0,0 +1,19 @@
package com.njcn.gather.event.devcie.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.event.transientes.mapper.PqsDeptslineMapper;
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
import com.njcn.gather.event.devcie.service.PqsDeptslineService;
/**
*
* Description:
* Date: 2025/06/19 下午 3:45【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class PqsDeptslineServiceImpl extends ServiceImpl<PqsDeptslineMapper, PqsDeptsline> implements PqsDeptslineService{
}

View File

@@ -0,0 +1,289 @@
package com.njcn.gather.event.transientes.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.json.JSONObject;
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.event.file.pojo.dto.WaveDataDTO;
import com.njcn.gather.event.devcie.mapper.PqLineMapper;
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.gather.event.devcie.pojo.po.PqLine;
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
import com.njcn.gather.event.devcie.service.PqsDeptslineService;
import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam;
import com.njcn.gather.event.transientes.pojo.param.SimulationMsgParam;
import com.njcn.gather.event.transientes.pojo.po.*;
import com.njcn.gather.event.transientes.service.*;
import com.njcn.gather.event.transientes.service.impl.MsgEventInfoServiceImpl;
import com.njcn.gather.event.transientes.websocket.WebSocketServer;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Author: cdf
* @CreateTime: 2025-06-23
* @Description:
*/
@Api(tags = "暂降接收")
@RequestMapping("accept")
@RestController
@RequiredArgsConstructor
@Slf4j
public class EventGateController extends BaseController {
private final MsgEventInfoServiceImpl msgEventInfoServiceImpl;
@Value("${SYS_TYPE_ZT}")
private String sysTypeZt;
private final WebSocketServer webSocketServer;
private final PqsDeptslineService pqsDeptslineService;
private final PqsDeptsService pqsDeptsService;
private final PqsUserService pqsUserService;
private final PqsUsersetService pqsUsersetService;
private final PqLineMapper pqLineMapper;
private final EventGateService eventGateService;
private final MsgEventConfigService msgEventConfigService;
private final PqsEventdetailService pqsEventdetailService;
private final MsgEventInfoService msgEventInfoService;
@OperateInfo
@GetMapping("/eventMsg")
@ApiOperation("接收远程推送的暂态事件")
@ApiImplicitParam(name = "eventMsg", value = "暂态事件json字符", required = true)
public HttpResult<Object> eventMsg(@RequestParam("msg") String msg) {
String methodDescribe = getMethodDescribe("eventMsg");
System.out.println(msg);
JSONObject jsonObject;
try {
//下面一行代码正式环境需要放开
//jsonObject = new JSONObject(msg);
//下面一行代码正式环境需要放开
jsonObject = test();
if (msgEventConfigService.getEventType().contains(jsonObject.get("wavetype").toString())) {
webSocketServer.sendMessageToAll(jsonObject.toString());
}
//开始发送短信
sendMessage(jsonObject);
} catch (Exception e) {
log.error("暂降json格式异常!{}", e.getMessage());
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
//测试模拟,正式环境删除
private PqsEventdetail createEvent(JSONObject jsonObject, LocalDateTime now) {
PqsEventdetail pqsEventdetail = new PqsEventdetail();
pqsEventdetail.setEventdetailIndex(jsonObject.get("eventdetail_index").toString());
pqsEventdetail.setLineid(Integer.valueOf(jsonObject.get("lineid").toString()));
pqsEventdetail.setTimeid(now);
pqsEventdetail.setMs(new BigDecimal(jsonObject.get("ms").toString()));
pqsEventdetail.setWavetype(Integer.valueOf(jsonObject.get("wavetype").toString()));
pqsEventdetail.setPersisttime(Double.valueOf(jsonObject.get("persisttime").toString()));
pqsEventdetail.setEventvalue(Double.valueOf(jsonObject.get("eventvalue").toString()));
pqsEventdetail.setEventreason(jsonObject.get("eventreason").toString());
pqsEventdetail.setEventtype(jsonObject.get("eventtype").toString());
return pqsEventdetail;
}
//测试模拟,正式环境删除
private JSONObject test() {
/*----------------------------------------------------------------------------------------*/
//以下部分为测试数据后续删除
List<PqLine> pqLineList = pqLineMapper.selectList(new LambdaQueryWrapper<>());
List<Integer> lineList = pqLineList.stream().map(PqLine::getLineIndex).collect(Collectors.toList());
List<LedgerBaseInfoDTO> baseInfoDTOList = pqLineMapper.getBaseLineInfo(lineList);
Map<Integer, LedgerBaseInfoDTO> map = baseInfoDTOList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
Random random = new Random();
Integer lineId = lineList.get(random.nextInt(lineList.size()));
LedgerBaseInfoDTO dto = map.get(lineId);
LocalDateTime now = LocalDateTime.now();
String timeStr = DateUtil.format(now, DatePattern.NORM_DATETIME_PATTERN);
Long ms = (long) random.nextInt(999);
Integer[] temArr = new Integer[]{1, 3};
Integer wave = random.nextInt(2);
double min = 0.5;
double max = 10.0;
// 生成 (0.5, 10.0) 范围内的随机小数
Double perTem = min + (max - min) * Math.random();
Double per = new BigDecimal(perTem).setScale(2, RoundingMode.HALF_UP).doubleValue();
double minV = 0.1;
double maxV = 0.9;
Double eventValue = minV + (maxV - minV) * Math.random();
String id = IdUtil.simpleUUID();
JSONObject tem = new JSONObject();
tem.set("eventdetail_index", id);
tem.set("lineid", lineId.toString());
tem.set("timeid", timeStr);
tem.set("ms", ms.toString());
tem.set("wavetype", temArr[wave]);
tem.set("persisttime", per.toString());
tem.set("eventvalue", eventValue);
tem.set("eventreason", "97a56e0f-b546-4c1e-b27c-52463fc1d82f");
tem.set("eventtype", "676683a0-7f80-43e6-8df8-bea8ed235d67");
tem.set("gdname", "测试供电公司");
tem.set("bdname", dto.getStationName());
tem.set("pointname", dto.getLineName());
PqsEventdetail pqsEventdetail = createEvent(tem, now);
if (msgEventConfigService.getEventType().contains(tem.get("wavetype").toString())) {
webSocketServer.sendMessageToAll(tem.toString());
}
pqsEventdetailService.save(pqsEventdetail);
/*----------------------------------------------------------------------------------------*/
return tem;
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getTransientAnalyseWave")
@ApiOperation("暂态事件波形分析")
public HttpResult<WaveDataDTO> getTransientAnalyseWave(@RequestBody MonitorTerminalParam param) {
String methodDescribe = getMethodDescribe("getTransientAnalyseWave");
WaveDataDTO wave = eventGateService.getTransientAnalyseWave(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/simulationSend")
@ApiOperation("模拟发送短信")
public HttpResult<WaveDataDTO> simulationSend(@RequestBody @Validated SimulationMsgParam param) {
String methodDescribe = getMethodDescribe("simulationSend");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
private void sendMessage(JSONObject jsonObject) {
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqsDeptsline> pqLineDept = pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex, lineId).eq(PqsDeptsline::getSystype, sysTypeZt).list();
Set<String> deptIds = pqLineDept.stream().map(PqsDeptsline::getDeptsIndex).collect(Collectors.toSet());
Set<String> resultIds = getAllParentDeptIds(deptIds);
List<PqsUserSet> pqsUserSetList = pqsUsersetService.lambdaQuery().eq(PqsUserSet::getIsNotice, 1).in(PqsUserSet::getDeptsIndex, resultIds).list();
if (CollUtil.isEmpty(pqsUserSetList)) {
//当前事件未找到用户信息,判断为不需要发送短信用户
return;
}
List<PqsUser> pqsUserList = pqsUserService.lambdaQuery().select(PqsUser::getUserIndex,PqsUser::getPhone,PqsUser::getName).in(PqsUser::getUserIndex, pqsUserSetList.stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList())).list();
List<String> userIds = pqsUserList.stream().map(PqsUser::getUserIndex).collect(Collectors.toList());
List<PqsUserSet> poList = pqsUserSetList.stream().filter(it -> userIds.contains(it.getUserIndex())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(poList)) {
StringBuilder stringBuilder = new StringBuilder(jsonObject.get("timeid").toString());
List<LedgerBaseInfoDTO> list = pqLineMapper.getBaseLineInfo(Stream.of(lineId).collect(Collectors.toList()));
LedgerBaseInfoDTO ledgerBaseInfoDTO = list.get(0);
BigDecimal bigDecimal = new BigDecimal(jsonObject.get("eventvalue").toString()).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
stringBuilder.append(".").append(jsonObject.get("ms").toString()).append(", ").append(ledgerBaseInfoDTO.getStationName()).append(ledgerBaseInfoDTO.getLineName())
.append("发生暂降事件,事件特征幅值").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S");
//TODO 发送短信
// System.out.println(stringBuilder);
List<MsgEventInfo> resultList = new ArrayList<>();
for (PqsUser user : pqsUserList) {
MsgEventInfo msgEventInfo = new MsgEventInfo();
msgEventInfo.setEventIndex(jsonObject.get("eventdetail_index").toString());
msgEventInfo.setMsgContent(stringBuilder.toString());
msgEventInfo.setMsgIndex(IdUtil.simpleUUID());
msgEventInfo.setPhone(user.getPhone());
msgEventInfo.setSendResult(0);
msgEventInfo.setUserId(user.getUserIndex());
msgEventInfo.setUserName(user.getName());
msgEventInfo.setIsHandle(0);
msgEventInfo.setSendTime(LocalDateTime.now());
resultList.add(msgEventInfo);
}
msgEventInfoService.saveBatch(resultList);
}
}
/**
* 获取远程短信平台token
*/
private String apiToken() {
return "token";
}
private boolean apiSend(){
return false;
}
public Set<String> getAllParentDeptIds(Set<String> deptIds) {
// 首次获取直接父级
List<PqsDepts> allDeptList = pqsDeptsService.lambdaQuery().list();
// 递归获取所有父级
Set<String> result = recursivelyGetParentIds(deptIds, allDeptList);
return result;
}
/**
* 递归获取所有父级ID
*
* @param currentParentIds 当前层级的父级ID集合
* @return 所有层级的父级ID集合
*/
private Set<String> recursivelyGetParentIds(Set<String> currentParentIds, List<PqsDepts> allDeptList) {
Set<String> result = new HashSet<>(currentParentIds);
Set<String> nextLevelParentIds = new HashSet<>();
List<PqsDepts> parentDeptList = allDeptList.stream().filter(it -> currentParentIds.contains(it.getDeptsIndex())).collect(Collectors.toList());
for (PqsDepts pqsDepts : parentDeptList) {
if (!pqsDepts.getParentnodeid().equals("0")) {
nextLevelParentIds.add(pqsDepts.getParentnodeid());
}
}
// 如果有更高层级的父级,继续递归
if (!nextLevelParentIds.isEmpty()) {
Set<String> deeperParentIds = recursivelyGetParentIds(nextLevelParentIds, allDeptList);
result.addAll(deeperParentIds);
}
return result;
}
}

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