235 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
caozehui
b7a90ebeb4 微调 2025-05-06 10:08:38 +08:00
caozehui
67665d3762 微调 2025-04-30 16:31:19 +08:00
caozehui
41252af4e9 复检时脚本查询结果错误bug 2025-04-30 10:27:11 +08:00
caozehui
2869f66154 闪变接收数据超时bug 2025-04-29 13:13:09 +08:00
wr
2bdaabac6e 优化数据源问题,删除检测脚本中值类型,由绑定检测计划中数据源来,获取是实时数据还是分钟数据 2025-04-29 11:36:04 +08:00
caozehui
4b41e2edd1 生成报告路径不包含设备类型 2025-04-29 09:07:36 +08:00
caozehui
5fa09bb41b 微调 2025-04-28 11:40:32 +08:00
caozehui
c96cadc5d1 暂态周波可以是小数 2025-04-25 14:34:00 +08:00
caozehui
b471a05181 微调 2025-04-24 11:39:18 +08:00
caozehui
e42a2c8309 微调 2025-04-23 15:30:24 +08:00
ea585a65ff 原始数据入库bug 2025-04-22 16:56:53 +08:00
wr
59ba5c0a0c 调整正式检测公式逻辑,优化绝对值,相对值信息 2025-04-22 15:02:38 +08:00
caozehui
99d43041cb 微调 2025-04-22 14:20:21 +08:00
wr
aa5f57a856 解决暂态下发幅值问题 2025-04-22 14:12:18 +08:00
caozehui
9fc0fbcbcf 微调 2025-04-21 19:22:25 +08:00
caozehui
434dc676ce 误差体系新增ValueType、errorUnit字段,并修改相关接口 2025-04-21 14:52:27 +08:00
ea83963d33 原始数据入库bug 2025-04-21 13:12:58 +08:00
caozehui
257df0a511 微调 2025-04-21 11:38:56 +08:00
496cff6c11 监测脚本排序调整 2025-04-21 11:31:08 +08:00
caozehui
484f9c9f4c 微调 2025-04-21 09:53:15 +08:00
wr
19b69eed0e Merge remote-tracking branch 'origin/master' 2025-04-21 09:08:45 +08:00
wr
b165365203 微调 2025-04-21 09:07:22 +08:00
caozehui
a42dcd1d4b 重新计算接口调整 2025-04-21 09:02:28 +08:00
caozehui
be3df5c497 微调 2025-04-18 15:59:05 +08:00
wr
7b951fa4b6 1.解决不可同时测试电压,电流问题 2025-04-18 15:34:49 +08:00
caozehui
89a7b5b8f6 微调 2025-04-18 14:25:50 +08:00
caozehui
102aa504e6 微调 2025-04-17 10:36:05 +08:00
d1cbfcedcc Merge remote-tracking branch 'origin/master' 2025-04-15 15:33:28 +08:00
116563f13e 优化部分代码 2025-04-15 15:33:19 +08:00
caozehui
55bf90d0af 日志导出csv功能、报告按照修改时间倒序排列 2025-04-15 10:14:52 +08:00
caozehui
7ac01b0f5e 微调 2025-04-14 19:12:59 +08:00
1a28d25026 优化部分代码 2025-04-14 18:38:08 +08:00
caozehui
92b0640f9c 微调 2025-04-14 14:47:51 +08:00
caozehui
4a2fb595d0 icd校验 2025-04-14 13:21:25 +08:00
56dd19b32e 调整方法名 2025-04-14 08:49:54 +08:00
caozehui
8460574f10 日志分页查询调整 2025-04-11 14:35:44 +08:00
6f890daad6 浙江报告与日志功能 2025-04-11 11:03:16 +08:00
caozehui
6727dee61e 建表语句调整 2025-04-10 16:08:21 +08:00
wr
3fcad5ff76 解决暂态测试项,icd分项和不分项功能优化 2025-04-10 15:25:02 +08:00
1fe7866970 监测脚本排序调整 2025-04-09 16:23:22 +08:00
caozehui
b96d0cdeb1 微调 2025-04-09 16:16:33 +08:00
0c30603f31 监测脚本排序调整 2025-04-09 15:04:19 +08:00
caozehui
64bdba9fa2 微调 2025-04-08 16:10:37 +08:00
caozehui
c7a45b5500 bug修复 2025-04-08 10:10:12 +08:00
42701db2d5 监测脚本排序调整 2025-04-07 10:23:24 +08:00
caozehui
6c34c4a968 微调 2025-04-03 08:37:50 +08:00
caozehui
186d701dcb 微调 2025-04-01 14:38:11 +08:00
caozehui
9b1b21dad5 代码调整 2025-04-01 09:50:53 +08:00
caozehui
00bda55ddd 微调 2025-04-01 09:48:17 +08:00
wr
593b7e9d7b 参数返回信息解决 2025-03-31 14:41:01 +08:00
f842886c00 测试提交 2025-03-31 13:53:37 +08:00
caozehui
af58306d96 微调 2025-03-31 11:25:06 +08:00
wr
09972e0764 新增检测详情参数组装接口 2025-03-31 10:06:48 +08:00
wr
7ba71562d8 正式检测检测结果增加单位信息 2025-03-28 15:24:55 +08:00
caozehui
71ba7fa139 代码调整 2025-03-28 15:06:57 +08:00
caozehui
48408859b1 代码调整、修改设备检测人bug 2025-03-28 09:32:50 +08:00
caozehui
fef01b692a 调整报告模板修改接口 2025-03-27 13:55:04 +08:00
caozehui
55208ecf69 整理代码、修改登录接口使用密文传输 2025-03-26 15:43:39 +08:00
caozehui
9a7d841d9c 整理代码 2025-03-26 10:01:56 +08:00
caozehui
4ef5c982de 微调 2025-03-26 08:52:14 +08:00
caozehui
22028fe7eb 调整检测计划导入、导出功能 2025-03-25 16:10:17 +08:00
wr
6ff3d7e336 1.添加相角启用配置和逻辑处理
2.修正数据处理逻辑以支持相角启用配置
2025-03-25 14:28:29 +08:00
fe7af8a632 小项结果汇集大项结果逻辑调整 2025-03-25 11:32:31 +08:00
caozehui
c67a2c8323 微调 2025-03-24 20:38:24 +08:00
wr
ce217b8b86 修正默认参与比较值逻辑,增加不参与误差比较状态 2025-03-24 18:56:03 +08:00
caozehui
ebc52eb8ba 微调 2025-03-24 15:43:20 +08:00
caozehui
0e1fb0e254 微调 2025-03-24 10:50:22 +08:00
caozehui
4d61cfc490 微调 2025-03-24 10:34:19 +08:00
caozehui
d0491b4850 微调 2025-03-24 10:34:07 +08:00
caozehui
610a3c1d13 微调 2025-03-24 08:58:37 +08:00
caozehui
ac0a9dd777 微调 2025-03-20 13:44:16 +08:00
caozehui
f294cb315f 微调 2025-03-20 11:15:20 +08:00
caozehui
051e7fe14a 微调 2025-03-20 09:02:21 +08:00
caozehui
38cbb22eff 微调 2025-03-18 13:49:46 +08:00
caozehui
423fa581b4 微调 2025-03-18 13:45:34 +08:00
caozehui
279a8a6e83 微调 2025-03-17 15:46:23 +08:00
caozehui
a108b295d1 复制误差体系 2025-03-17 11:18:44 +08:00
wr
04bd8a7db3 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java
2025-03-14 16:36:14 +08:00
wr
d084950090 解决精度问题 2025-03-14 16:32:47 +08:00
caozehui
ff53c91279 微调 2025-03-14 16:31:20 +08:00
wr
751dc56568 解决误差值问题 2025-03-14 16:12:32 +08:00
7f42a21536 系数代码提交 2025-03-14 13:32:57 +08:00
caozehui
8ca804283a 微调 2025-03-14 11:07:13 +08:00
wr
c43c5b4342 微调 2025-03-14 10:49:58 +08:00
wr
03ec551f71 Merge remote-tracking branch 'origin/master' 2025-03-13 19:59:26 +08:00
wr
0ddf98e1af 检测脚本增加额定电压和电流(取消装置层获取) 2025-03-13 19:58:28 +08:00
caozehui
1c014a75a7 微调 2025-03-12 15:04:01 +08:00
345 changed files with 15643 additions and 5261 deletions

View File

@@ -74,6 +74,56 @@
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>4.1.2</version> <version>4.1.2</version>
</dependency> </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>6.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.0</version> <!-- 您可以根据需要选择其他版本 -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<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> </dependencies>

View File

@@ -1,20 +1,13 @@
package com.njcn.gather.detection.controller; package com.njcn.gather.detection.controller;
import com.alibaba.fastjson.JSON;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.gather.detection.handler.SocketDevResponseService; import com.njcn.gather.detection.handler.SocketDevResponseService;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam; import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.gather.detection.service.PreDetectionService;
import com.njcn.gather.detection.service.impl.DetectionServiceImpl; import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
import com.njcn.gather.detection.util.socket.XiNumberManager;
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
@@ -27,11 +20,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author chendaofei
*/
@Slf4j @Slf4j
@Api(tags = "预检测") @Api(tags = "预检测")
@RestController @RestController
@@ -41,17 +33,9 @@ public class PreDetectionController extends BaseController {
private final PreDetectionService preDetectionService; private final PreDetectionService preDetectionService;
private final DetectionServiceImpl detectionServiceImpl;
private final IPqScriptDtlsService pqScriptDtlsService;
private final IPqDevService iPqDevService;
private final SocketDevResponseService socketDevResponseService;
/** /**
* 开始检测 * 开始检测通用入口
* @param param 实体参数
*/ */
@PostMapping("/startPreTest") @PostMapping("/startPreTest")
@OperateInfo @OperateInfo
@@ -63,6 +47,12 @@ public class PreDetectionController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
/**
* 程控源-源通讯校验
*
* @param param
* @return
*/
@PostMapping("/ytxCheckSimulate") @PostMapping("/ytxCheckSimulate")
@OperateInfo @OperateInfo
@ApiOperation("源通讯校验") @ApiOperation("源通讯校验")
@@ -74,7 +64,7 @@ public class PreDetectionController extends BaseController {
} }
/** /**
* 模拟检测 * 程控源检测
*/ */
@PostMapping("/startSimulateTest") @PostMapping("/startSimulateTest")
@OperateInfo @OperateInfo
@@ -87,7 +77,7 @@ public class PreDetectionController extends BaseController {
} }
/** /**
* 关闭检测 * 关闭检测-程控源
*/ */
@PostMapping("/closeSimulateTest") @PostMapping("/closeSimulateTest")
@OperateInfo @OperateInfo
@@ -139,37 +129,4 @@ public class PreDetectionController extends BaseController {
preDetectionService.restartTemTest(param); preDetectionService.restartTemTest(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
/**
* 测试
*/
@PostMapping("/startTest")
@OperateInfo
@ApiOperation("测试")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startTest(@RequestBody PreDetectionParam param) {
String methodDescribe = getMethodDescribe("startTest");
//preDetectionService.startTest(param);
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
XiNumberManager.xiDevList = pqDevList;
String s = param.getUserPageId() + "_Dev";
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
PreDetection preDetection = pqDevList.get(0);
Map<String, Object> map = new HashMap<>();
map.put("devIP", preDetection.getDevIP());
map.put("chnNum", preDetection.getDevChns());
socketMsg.setData(JSON.toJSONString(map));
NettyClient.socketClient("192.168.1.138", 61000, param, JSON.toJSONString(socketMsg), new NettyDevClientHandler(param, socketDevResponseService));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
} }

View File

@@ -1,41 +0,0 @@
package com.njcn.gather.detection.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
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.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author wr
* @description
* @date 2024/12/10 14:25
*/
@Slf4j
@Api(tags = "守时检测")
@RestController
@RequestMapping("/punctuality")
@RequiredArgsConstructor
public class PunctualityController extends BaseController {
// private final PunctualityService punctualityService;
@OperateInfo
@PostMapping("/deliveryTime")
@ApiOperation("下发守时检测")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<?> list(@RequestBody Object param) {
String methodDescribe = getMethodDescribe("list");
// punctualityService.triggerTimeMark();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

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.script.pojo.po.SourceIssue;
import com.njcn.gather.system.pojo.enums.DicDataEnum; import com.njcn.gather.system.pojo.enums.DicDataEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -64,6 +65,7 @@ public class SocketSourceResponseService {
if (ObjectUtil.isNotNull(param.getPlanId())) { if (ObjectUtil.isNotNull(param.getPlanId())) {
detectionDev(param, socketDataMsg); detectionDev(param, socketDataMsg);
} else { } else {
// 程控源-源通信校验
handleYtxjySimulate(param, socketDataMsg); handleYtxjySimulate(param, socketDataMsg);
} }
break; break;
@@ -132,16 +134,13 @@ public class SocketSourceResponseService {
CnSocketUtil.quitSendSource(param); CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break; break;
case UNKNOWN_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNABLE_TO_RESPOND: case UNABLE_TO_RESPOND:
CnSocketUtil.quitSendSource(param); CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break; break;
default: default:
CnSocketUtil.sendUnSocket(param.getUserPageId()); CnSocketUtil.sendUnSocket(param.getUserPageId());
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break; break;
} }
} }
@@ -195,8 +194,10 @@ public class SocketSourceResponseService {
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam(); DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
phaseSequenceParam.setMoniterIdList(monitorIdList); phaseSequenceParam.setMoniterIdList(monitorIdList);
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS")); phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS"));
phaseSequenceParam.setReadCount(10); // 读取3次数据用于系数计算
phaseSequenceParam.setIgnoreCount(7); phaseSequenceParam.setReadCount(7); //3
// 忽略前4次数据等待测量稳定
phaseSequenceParam.setIgnoreCount(3); //4
socketMsg.setData(JSON.toJSONString(phaseSequenceParam)); socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg)); SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
@@ -218,8 +219,8 @@ public class SocketSourceResponseService {
/** /**
* 装置检测(当源初始化成功后,直接向装置通道向装置服务器发送,装置检测) * 装置检测(当源初始化成功后,直接向装置通道向装置服务器发送,装置检测)
* *
* @param param * @param param 参数
* @param socketDataMsg * @param socketDataMsg 消息
*/ */
private void detectionDev(PreDetectionParam param, SocketDataMsg socketDataMsg) { private void detectionDev(PreDetectionParam param, SocketDataMsg socketDataMsg) {
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode()); SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
@@ -232,9 +233,9 @@ public class SocketSourceResponseService {
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
String s = param.getUserPageId() + DEV; 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<String, List<PreDetection>> map = new HashMap<>(1);
map.put("deviceList", devList); map.put("deviceList", FormalTestManager.devList);
String jsonString = JSON.toJSONString(map); String jsonString = JSON.toJSONString(map);
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue()); socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue()); socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
@@ -351,19 +352,15 @@ public class SocketSourceResponseService {
String s = param.getUserPageId() + DEV; String s = param.getUserPageId() + DEV;
SourceIssue sourceIssue = SocketManager.getSourceList().get(0); SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
List<String> comm = sourceIssue.getDevValueTypeList(); List<String> comm = sourceIssue.getDevValueTypeList(); //形如:类型&小项code这种形式。例如real$VRMS、real$IRMS
System.out.println("向装置下发的参数>>>>>>>>" + comm); System.out.println("向装置下发的参数>>>>>>>>" + comm);
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType()); socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
int ignoreCount; int ignoreCount;
int readData; int readData;
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) { if (DicDataEnum.F.getCode().equals(sourceIssue.getType())) {
ignoreCount = 1; ignoreCount = 1;
readData = 2; readData = 2;
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue()); socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
} else if (sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
ignoreCount = 2;
readData = 5;
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
} else if (DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())) { } else if (DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())) {
ignoreCount = 5; ignoreCount = 5;
readData = 1; readData = 1;
@@ -371,12 +368,18 @@ public class SocketSourceResponseService {
} else { } else {
ignoreCount = 5; ignoreCount = 5;
readData = 5; readData = 5;
//区分实时数据还是分钟数据
if ("real".equals(sourceIssue.getDataType())) {
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue()); socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
} else {
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
} }
}
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()); //List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam(); DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
phaseSequenceParam.setMoniterIdList(moniterIdList); phaseSequenceParam.setMoniterIdList(monitorIdList);
phaseSequenceParam.setDataType(comm); phaseSequenceParam.setDataType(comm);
phaseSequenceParam.setReadCount(readData); phaseSequenceParam.setReadCount(readData);
phaseSequenceParam.setIgnoreCount(ignoreCount); phaseSequenceParam.setIgnoreCount(ignoreCount);

View File

@@ -0,0 +1,22 @@
package com.njcn.gather.detection.pojo.constant;
/**
* 通信相关的常量
*
* @author hongawen
* @version 1.0
* @data 2025/4/15 14:11
*/
public interface DetectionCommunicateConstant {
String SOURCE_CHANNEL_NAME = "AUTO_DETECTION_SOURCE";
String DEVICE_CHANNEL_NAME = "AUTO_DETECTION_DEV";
String DEV = "_Dev";
String SOURCE = "_Source";
}

View File

@@ -20,7 +20,7 @@ public enum DetectionCodeEnum {
I2_50("I2-50", "谐波电流"), I2_50("I2-50", "谐波电流"),
P2_50("P2-50", "谐波有功功率"), P2_50("P2-50", "谐波有功功率"),
SV_1_49("SV_1-49", "间谐波电压"), SV_1_49("SV_1-49", "间谐波电压"),
SI_1_49("SI_1-49", "间谐波电"), SI_1_49("SI_1-49", "间谐波电"),
MAG("MAG", "电压幅值"), MAG("MAG", "电压幅值"),
DUR("DUR", "持续时间"), DUR("DUR", "持续时间"),
IRMS("IRMS", "电流有效值"), IRMS("IRMS", "电流有效值"),
@@ -28,6 +28,7 @@ public enum DetectionCodeEnum {
V_UNBAN("V_UNBAN", "三相电压负序不平衡度"), V_UNBAN("V_UNBAN", "三相电压负序不平衡度"),
I_UNBAN("I_UNBAN", "三相电流负序不平衡度"), I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
PST("PST", "短时间闪变"), PST("PST", "短时间闪变"),
P("P", "功率"),
I1("I1", "基波电流"), I1("I1", "基波电流"),

View File

@@ -9,11 +9,15 @@ import lombok.Getter;
@Getter @Getter
public enum DetectionResponseEnum { public enum DetectionResponseEnum {
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"), PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
SCRIPT_PATTERN_NOT("A020001", "检测脚本查询为空"),
SOURCE_INFO_NOT("A020002", "源表信息不存在"), SOURCE_INFO_NOT("A020002", "源表信息不存在"),
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"), PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
ITEM_TEST_NOT("A020004", "检测项为空"), ITEM_TEST_NOT("A020004", "检测项为空"),
PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复"), PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复"),
SOURCE_NOT_CONNECT("A020006", "源未连接"); SOURCE_NOT_CONNECT("A020006", "源未连接"),
SCRIPT_CHECK_DATA_NOT_EXIST("A020040","测试脚本项暂无配置" );
private final String code; private final String code;
private final String message; private final String message;

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,6 @@
package com.njcn.gather.detection.pojo.param; package com.njcn.gather.detection.pojo.param;
import com.njcn.gather.script.pojo.constant.PqScriptValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.gather.source.pojo.constant.PqSourceValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@@ -31,12 +29,12 @@ public class SimulateDetectionParam {
*/ */
private String scriptId; private String scriptId;
@NotNull(message = PqScriptValidMessage.INDEX_NOT_NULL) @NotNull(message = DetectionValidMessage.INDEX_NOT_NULL)
private Integer scriptIndex; private Integer scriptIndex;
/** /**
* 源id * 源id
*/ */
@NotBlank(message = PqSourceValidMessage.ID_NOT_BLANK) @NotBlank(message = DetectionValidMessage.SOURCE_ID_NOT_BLANK)
private String sourceId; private String sourceId;
} }

View File

@@ -0,0 +1,29 @@
package com.njcn.gather.detection.pojo.po;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author caozehui
* @data 2025-04-10
*/
@NoArgsConstructor
@Data
public class IcdCheckData {
private String icdType;
private List<ResultData> resultData;
@NoArgsConstructor
@Data
public static class ResultData {
private String type;
private String desc;
private DevData.SqlDataDTO.ListDTO phaseResult;
}
}

View File

@@ -3,6 +3,8 @@ package com.njcn.gather.detection.pojo.vo;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
/** /**
* @author wr * @author wr
* @description * @description
@@ -18,7 +20,7 @@ public class DetectionData {
private Double num; private Double num;
/** /**
* 是否是符合数据 * 1.合格 2.不合格 3.网络超时 4.无法处理 5.不参与误差比较
*/ */
private Integer isData; private Integer isData;
@@ -37,4 +39,13 @@ public class DetectionData {
*/ */
private String radius; private String radius;
/**
* 误差值
*/
private BigDecimal errorData;
/**
* 单位
*/
private String unit;
} }

View File

@@ -24,9 +24,6 @@ public interface PreDetectionService {
void coefficientCheck(PreDetectionParam param); void coefficientCheck(PreDetectionParam param);
boolean startTest(PreDetectionParam param);
boolean temStopTest(); boolean temStopTest();

View File

@@ -1,14 +0,0 @@
package com.njcn.gather.detection.service;
/**
* @Description: 守时检测流程
* @Author: wr
* @Date: 2024/12/10 14:23
*/
public interface PunctualityService {
/**
* 触发时间标识
*/
void triggerTimeMark();
}

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.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.po.DevData; import com.njcn.gather.detection.pojo.po.DevData;
import com.njcn.gather.detection.pojo.vo.DetectionData; 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.param.PqErrSysParam;
import com.njcn.gather.err.pojo.po.PqErrSysDtls; import com.njcn.gather.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO; 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.AdHarmonicResult;
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
import com.njcn.gather.storage.service.DetectionDataDealService; 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 com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@@ -32,9 +36,11 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.*; import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author wr * @author wr
* @description * @description
@@ -47,6 +53,7 @@ public class DetectionServiceImpl {
private final IPqErrSysDtlsService pqErrSysDtlsService; private final IPqErrSysDtlsService pqErrSysDtlsService;
private final IPqScriptCheckDataService pqScriptCheckDataService; private final IPqScriptCheckDataService pqScriptCheckDataService;
private final DetectionDataDealService detectionDataDealService; private final DetectionDataDealService detectionDataDealService;
private final ISysTestConfigService sysTestConfigService;
private final String TYPE_A = "A"; private final String TYPE_A = "A";
private final String TYPE_B = "B"; private final String TYPE_B = "B";
@@ -63,6 +70,7 @@ public class DetectionServiceImpl {
/** /**
* 开始处理指标类型 * 开始处理指标类型
* 一共20组数据开始处理格式 * 一共20组数据开始处理格式
* 返回值key为设备id_通道号value为检测结果
*/ */
public Map<String, Integer> processing(List<DevData> dev, PreDetectionParam detection, Map<String, String> devIdMapComm, SourceIssue issue, DictDataEnum dataRule) { public Map<String, Integer> processing(List<DevData> dev, PreDetectionParam detection, Map<String, String> devIdMapComm, SourceIssue issue, DictDataEnum dataRule) {
Map<String, List<DevData>> devDataMap = dev.stream().collect(Collectors.groupingBy(DevData::getId)); Map<String, List<DevData>> devDataMap = dev.stream().collect(Collectors.groupingBy(DevData::getId));
@@ -111,45 +119,21 @@ public class DetectionServiceImpl {
case I_ABSOLUTELY: case I_ABSOLUTELY:
return isQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, code); return isQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, code);
/** /**
* 谐波电压 * 谐波
*/ */
case HV: case HV:
AdHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 2);
if (ObjectUtil.isNotNull(harmV)) {
detectionDataDealService.acceptAdResult(Arrays.asList(harmV), code);
return harmV.getResultFlag();
}
return 4;
/**
* 谐波电流
*/
case HI: case HI:
AdHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 2);
AdHarmonicResult harmI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 2); AdHarmonicResult harmI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 2);
if (ObjectUtil.isNotNull(harmI)) { return resultFlag(harmV, harmI, code);
detectionDataDealService.acceptAdResult(Arrays.asList(harmI), code);
return harmI.getResultFlag();
}
return 4;
/** /**
* 间谐波电压 * 间谐波
*/ */
case HSV: case HSV:
AdHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 1);
if (ObjectUtil.isNotNull(harmInV)) {
detectionDataDealService.acceptAdResult(Arrays.asList(harmInV), code);
return harmInV.getResultFlag();
}
return 4;
/**
* 间谐波电流
*/
case HSI: case HSI:
AdHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 1);
AdHarmonicResult harmInI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 1); AdHarmonicResult harmInI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 1);
if (ObjectUtil.isNotNull(harmInI)) { return resultFlag(harmInV, harmInI, code);
detectionDataDealService.acceptAdResult(Arrays.asList(harmInI), code);
return harmInI.getResultFlag();
}
return 4;
/** /**
* 三相电压不平衡度 * 三相电压不平衡度
*/ */
@@ -201,6 +185,21 @@ public class DetectionServiceImpl {
} }
} }
public Integer resultFlag(AdHarmonicResult v, AdHarmonicResult i, String code) {
List<AdHarmonicResult> info = new ArrayList<>();
if (ObjectUtil.isNotNull(v)) {
info.add(v);
}
if (ObjectUtil.isNotNull(i)) {
info.add(i);
}
if (CollUtil.isNotEmpty(info)) {
detectionDataDealService.acceptAdResult(info, code);
return getInteger(info.stream().map(x -> x.getResultFlag()).distinct().collect(Collectors.toList()));
}
return 4;
}
public Integer isUnknownQualified(List<DevData> dev, public Integer isUnknownQualified(List<DevData> dev,
Map<String, String> devIdMapComm, Map<String, String> devIdMapComm,
List<ErrDtlsCheckDataVO> errDtlsCheckData, List<ErrDtlsCheckDataVO> errDtlsCheckData,
@@ -225,10 +224,14 @@ public class DetectionServiceImpl {
result.setMonitorId(devID + "_" + split[1]); result.setMonitorId(devID + "_" + split[1]);
result.setScriptId(sourceIssue.getScriptId()); result.setScriptId(sourceIssue.getScriptId());
result.setSort(sourceIssue.getIndex()); result.setSort(sourceIssue.getIndex());
result.setDataType("avg"); result.setDataType(sourceIssue.getDataType());
Integer isQualified;
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList()); List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
if (CollUtil.isNotEmpty(dtlsCheckData)) { if (CollUtil.isNotEmpty(dtlsCheckData)) {
result.setAdType(dtlsCheckData.get(0).getValueType()); result.setAdType(dtlsCheckData.get(0).getValueType());
isQualified = dtlsCheckData.get(0).getIsQualified();
} else {
isQualified = 4;
} }
List<DetectionData> resultFlag = new ArrayList<>(); List<DetectionData> resultFlag = new ArrayList<>();
map.forEach((key, value) -> { map.forEach((key, value) -> {
@@ -236,9 +239,9 @@ public class DetectionServiceImpl {
if (CollUtil.isNotEmpty(checkData)) { if (CollUtil.isNotEmpty(checkData)) {
DetectionData detectionData; DetectionData detectionData;
if (DUR.equals(devIndex)) { if (DUR.equals(devIndex)) {
detectionData = rangeDURComparisonList(value, new ArrayList<>(), sourceIssue.getFFreq(), checkData.get(0).getValue(), dataRule); detectionData = rangeDURComparisonList(value, isQualified, new ArrayList<>(), sourceIssue.getFFreq(), checkData.get(0).getValue(), dataRule);
} else { } else {
detectionData = rangeComparisonList(value, new ArrayList<>(), null, checkData.get(0).getValue(), dataRule); detectionData = rangeComparisonList(value, isQualified, new ArrayList<>(), null, checkData.get(0).getValue(), dataRule);
} }
if (key.equals(TYPE_T)) { if (key.equals(TYPE_T)) {
result.setTValue(JSON.toJSONString(detectionData)); result.setTValue(JSON.toJSONString(detectionData));
@@ -279,7 +282,6 @@ public class DetectionServiceImpl {
} }
if (devIndex.contains("I")) { if (devIndex.contains("I")) {
fundCode = DetectionCodeEnum.I1.getCode(); fundCode = DetectionCodeEnum.I1.getCode();
;
type = I; type = I;
fData = sourceIssue.getFIn(); fData = sourceIssue.getFIn();
if (devIndex.contains("50")) { if (devIndex.contains("50")) {
@@ -292,7 +294,7 @@ public class DetectionServiceImpl {
if (devIndex.contains("P")) { if (devIndex.contains("P")) {
type = P; type = P;
harmCode = DetectionCodeEnum.P2_50.getCode(); harmCode = DetectionCodeEnum.P2_50.getCode();
fData = sourceIssue.getFIn() * sourceIssue.getFUn() * 0.01; fData = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
} }
Map<String, Map<Double, List<Double>>> devHarmMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num); Map<String, Map<Double, List<Double>>> devHarmMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num);
if (CollUtil.isNotEmpty(devHarmMap)) { if (CollUtil.isNotEmpty(devHarmMap)) {
@@ -302,15 +304,20 @@ public class DetectionServiceImpl {
harmonicResult.setMonitorId(devID + "_" + split[1]); harmonicResult.setMonitorId(devID + "_" + split[1]);
harmonicResult.setScriptId(sourceIssue.getScriptId()); harmonicResult.setScriptId(sourceIssue.getScriptId());
harmonicResult.setSort(sourceIssue.getIndex()); harmonicResult.setSort(sourceIssue.getIndex());
Integer isQualified;
String valueTypeCode;
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList()); List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
if (CollUtil.isNotEmpty(dtlsCheckData)) { if (CollUtil.isNotEmpty(dtlsCheckData)) {
harmonicResult.setAdType(dtlsCheckData.get(0).getValueType()); harmonicResult.setAdType(dtlsCheckData.get(0).getValueType());
isQualified = dtlsCheckData.get(0).getIsQualified();
} else {
isQualified = 4;
} }
//电压下百分比给百分比直接算 电流是是下百分比给的是幅值要转换算 //电压下百分比给百分比直接算 电流是是下百分比给的是幅值要转换算
List<DetectionData> integerBooleanA = harmRangeComparison(new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num); List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num);
List<DetectionData> integerBooleanB = harmRangeComparison(new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num); List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num);
List<DetectionData> integerBooleanC = harmRangeComparison(new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num); List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num);
harmonicResult.setDataType("avg"); harmonicResult.setDataType(sourceIssue.getDataType());
reflectHarmonic("a", integerBooleanA, harmonicResult, num); reflectHarmonic("a", integerBooleanA, harmonicResult, num);
reflectHarmonic("b", integerBooleanB, harmonicResult, num); reflectHarmonic("b", integerBooleanB, harmonicResult, num);
reflectHarmonic("c", integerBooleanC, harmonicResult, num); reflectHarmonic("c", integerBooleanC, harmonicResult, num);
@@ -355,6 +362,7 @@ public class DetectionServiceImpl {
List<AdNonHarmonicResult> info = new ArrayList<>(); List<AdNonHarmonicResult> info = new ArrayList<>();
List<String> devValueTypeList = sourceIssue.getDevValueTypeList(); List<String> devValueTypeList = sourceIssue.getDevValueTypeList();
for (String s : devValueTypeList) { for (String s : devValueTypeList) {
// 根据数据处理规则取值。key为相别value为值列表
Map<String, List<Double>> map = devListMap(dev, dataRule, s.split("\\$")[1]); Map<String, List<Double>> map = devListMap(dev, dataRule, s.split("\\$")[1]);
Double fData = 1.0; Double fData = 1.0;
if (U.equals(type)) { if (U.equals(type)) {
@@ -372,12 +380,14 @@ public class DetectionServiceImpl {
result.setMonitorId(devID + "_" + split[1]); result.setMonitorId(devID + "_" + split[1]);
result.setScriptId(sourceIssue.getScriptId()); result.setScriptId(sourceIssue.getScriptId());
result.setSort(sourceIssue.getIndex()); result.setSort(sourceIssue.getIndex());
result.setDataType("avg"); result.setDataType(sourceIssue.getDataType());
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>(); List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
Integer isQualified = 4;
if (CollUtil.isNotEmpty(errDtlsCheckData)) { if (CollUtil.isNotEmpty(errDtlsCheckData)) {
List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList()); List<ErrDtlsCheckDataVO> dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(s.split("\\$")[1])).collect(Collectors.toList());
if (CollUtil.isNotEmpty(dtlsCheckData)) { if (CollUtil.isNotEmpty(dtlsCheckData)) {
result.setAdType(dtlsCheckData.get(0).getValueType()); result.setAdType(dtlsCheckData.get(0).getValueType());
isQualified = dtlsCheckData.get(0).getIsQualified();
if (CollUtil.isNotEmpty(dtlsCheckData.get(0).getErrSysDtls())) { if (CollUtil.isNotEmpty(dtlsCheckData.get(0).getErrSysDtls())) {
pqErrSysDtls = dtlsCheckData.get(0).getErrSysDtls(); pqErrSysDtls = dtlsCheckData.get(0).getErrSysDtls();
} }
@@ -385,30 +395,35 @@ public class DetectionServiceImpl {
if (map.containsKey(TYPE_T)) { if (map.containsKey(TYPE_T)) {
List<ErrDtlsCheckDataVO> checkDataT = dtlsCheckData.stream().filter(x -> TYPE_T.equals(x.getPhase())).collect(Collectors.toList()); List<ErrDtlsCheckDataVO> checkDataT = dtlsCheckData.stream().filter(x -> TYPE_T.equals(x.getPhase())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(checkDataT)) { if (CollUtil.isNotEmpty(checkDataT)) {
DetectionData t = rangeComparisonList(map.get(TYPE_T), pqErrSysDtls, fData, checkDataT.get(0).getValue(), dataRule); DetectionData t = rangeComparisonList(map.get(TYPE_T), isQualified, pqErrSysDtls, fData, checkDataT.get(0).getValue(), dataRule);
result.setTValue(JSON.toJSONString(t)); result.setTValue(JSON.toJSONString(t));
result.setResultFlag(t.getIsData()); result.setResultFlag(t.getIsData());
} }
} else { } else {
List<DetectionData> resultFlag = new ArrayList<>(); List<DetectionData> resultFlag = new ArrayList<>();
//取出源所对应的相别信息 Map<String, BiConsumer<AdNonHarmonicResult, DetectionData>> setters = new HashMap<>();
List<ErrDtlsCheckDataVO> checkDataA = dtlsCheckData.stream().filter(x -> TYPE_A.equals(x.getPhase())).collect(Collectors.toList()); setters.put(TYPE_A, (r, d) -> r.setAValue(JSON.toJSONString(d)));
if (CollUtil.isNotEmpty(checkDataA)) { setters.put(TYPE_B, (r, d) -> r.setBValue(JSON.toJSONString(d)));
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, checkDataA.get(0).getValue(), dataRule); setters.put(TYPE_C, (r, d) -> r.setCValue(JSON.toJSONString(d)));
resultFlag.add(a);
result.setAValue(JSON.toJSONString(a)); List<String> phases = Arrays.asList(TYPE_A, TYPE_B, TYPE_C);
for (String phase : phases) {
List<ErrDtlsCheckDataVO> checkData = dtlsCheckData.stream()
.filter(x -> phase.equals(x.getPhase()))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(checkData)) {
List<Double> phaseValue = map.get(phase);
// 注意如果map中不存在该phase的键phaseValue可能为null需确保map包含该键
DetectionData detectionData = rangeComparisonList(phaseValue, isQualified, pqErrSysDtls, fData, checkData.get(0).getValue(), dataRule);
resultFlag.add(detectionData);
BiConsumer<AdNonHarmonicResult, DetectionData> setter = setters.get(phase);
if (setter != null) {
setter.accept(result, detectionData);
} else {
// 处理未定义的setter的情况
throw new IllegalArgumentException("Setter not defined for phase: " + phase);
} }
List<ErrDtlsCheckDataVO> checkDataB = dtlsCheckData.stream().filter(x -> TYPE_B.equals(x.getPhase())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(checkDataB)) {
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, checkDataB.get(0).getValue(), dataRule);
resultFlag.add(b);
result.setBValue(JSON.toJSONString(b));
} }
List<ErrDtlsCheckDataVO> checkDataC = dtlsCheckData.stream().filter(x -> TYPE_C.equals(x.getPhase())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(checkDataC)) {
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, checkDataC.get(0).getValue(), dataRule);
resultFlag.add(c);
result.setCValue(JSON.toJSONString(c));
} }
result.setResultFlag(setResultFlag(resultFlag)); result.setResultFlag(setResultFlag(resultFlag));
} }
@@ -417,7 +432,7 @@ public class DetectionServiceImpl {
} }
if (CollUtil.isNotEmpty(info)) { if (CollUtil.isNotEmpty(info)) {
detectionDataDealService.acceptAdNonResult(info, code); detectionDataDealService.acceptAdNonResult(info, code);
List<Integer> resultFlag = info.stream().filter(x -> 4 != x.getResultFlag()).map(AdNonHarmonicResult::getResultFlag).distinct().collect(Collectors.toList()); List<Integer> resultFlag = info.stream().map(AdNonHarmonicResult::getResultFlag).distinct().collect(Collectors.toList());
return getInteger(resultFlag); return getInteger(resultFlag);
} }
return 4; return 4;
@@ -456,7 +471,6 @@ public class DetectionServiceImpl {
if (I.equals(type)) { if (I.equals(type)) {
fData = sourceIssue.getFIn(); fData = sourceIssue.getFIn();
fundCode = DetectionCodeEnum.I1.getCode(); fundCode = DetectionCodeEnum.I1.getCode();
;
if (num == 1) { if (num == 1) {
harmCode = DetectionCodeEnum.SI_1_49.getCode(); harmCode = DetectionCodeEnum.SI_1_49.getCode();
} else { } else {
@@ -464,7 +478,7 @@ public class DetectionServiceImpl {
} }
} }
if (P.equals(type)) { if (P.equals(type)) {
fData = sourceIssue.getFIn() * sourceIssue.getFUn() * 0.01; fData = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
harmCode = DetectionCodeEnum.P2_50.getCode(); harmCode = DetectionCodeEnum.P2_50.getCode();
} }
Map<String, Map<Double, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num); Map<String, Map<Double, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, fundCode, harmCode, num);
@@ -476,23 +490,27 @@ public class DetectionServiceImpl {
harmonicResult.setScriptId(sourceIssue.getScriptId()); harmonicResult.setScriptId(sourceIssue.getScriptId());
harmonicResult.setSort(sourceIssue.getIndex()); harmonicResult.setSort(sourceIssue.getIndex());
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>(); List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
Integer isQualified = 4;
if (CollUtil.isNotEmpty(errDtlsCheckData)) { if (CollUtil.isNotEmpty(errDtlsCheckData)) {
harmonicResult.setAdType(errDtlsCheckData.get(0).getValueType()); String finalHarmCode = harmCode;
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) { List<ErrDtlsCheckDataVO> adDtlsCheckData = errDtlsCheckData.stream().filter(x -> finalHarmCode.equals(x.getValueTypeCode())).collect(Collectors.toList());
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls(); harmonicResult.setAdType(adDtlsCheckData.get(0).getValueType());
isQualified = adDtlsCheckData.get(0).getIsQualified();
if (CollUtil.isNotEmpty(adDtlsCheckData.get(0).getErrSysDtls())) {
pqErrSysDtls = adDtlsCheckData.get(0).getErrSysDtls();
} }
} }
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num); List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num); List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num); List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
harmonicResult.setDataType("avg"); harmonicResult.setDataType(sourceIssue.getDataType());
reflectHarmonic("a", integerBooleanA, harmonicResult, num); reflectHarmonic("a", integerBooleanA, harmonicResult, num);
reflectHarmonic("b", integerBooleanB, harmonicResult, num); reflectHarmonic("b", integerBooleanB, harmonicResult, num);
reflectHarmonic("c", integerBooleanC, harmonicResult, num); reflectHarmonic("c", integerBooleanC, harmonicResult, num);
List<DetectionData> list = new ArrayList<>(); List<DetectionData> list = new ArrayList<>();
list.addAll(integerBooleanA.stream().distinct().collect(Collectors.toList())); list.addAll(integerBooleanA.stream().filter(x -> 1 != x.getNum()).distinct().collect(Collectors.toList()));
list.addAll(integerBooleanB.stream().distinct().collect(Collectors.toList())); list.addAll(integerBooleanB.stream().filter(x -> 1 != x.getNum()).distinct().collect(Collectors.toList()));
list.addAll(integerBooleanC.stream().distinct().collect(Collectors.toList())); list.addAll(integerBooleanC.stream().filter(x -> 1 != x.getNum()).distinct().collect(Collectors.toList()));
harmonicResult.setResultFlag(setResultFlag(list)); harmonicResult.setResultFlag(setResultFlag(list));
return harmonicResult; return harmonicResult;
} }
@@ -537,31 +555,33 @@ public class DetectionServiceImpl {
result.setScriptId(sourceIssue.getScriptId()); result.setScriptId(sourceIssue.getScriptId());
result.setSort(sourceIssue.getIndex()); result.setSort(sourceIssue.getIndex());
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>(); List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
Integer isQualified = 4;
if (CollUtil.isNotEmpty(errDtlsCheckData)) { if (CollUtil.isNotEmpty(errDtlsCheckData)) {
result.setAdType(errDtlsCheckData.get(0).getValueType()); result.setAdType(errDtlsCheckData.get(0).getValueType());
isQualified = errDtlsCheckData.get(0).getIsQualified();
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) { if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls(); pqErrSysDtls = errDtlsCheckData.get(0).getErrSysDtls();
} }
} }
result.setDataType("avg"); result.setDataType(sourceIssue.getDataType());
if (StrUtil.isBlank(type)) { if (StrUtil.isBlank(type)) {
//取出源所对应的相别信息 //取出源所对应的相别信息
List<PqScriptCheckData> channelTypeAList = checkData.stream() List<PqScriptCheckData> channelTypeAList = checkData.stream()
.filter(x -> TYPE_A.equals(x.getPhase())) .filter(x -> TYPE_A.equals(x.getPhase()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getValue(), dataRule); DetectionData a = rangeComparisonList(map.get(TYPE_A), isQualified, pqErrSysDtls, fData, channelTypeAList.get(0).getValue(), dataRule);
result.setAValue(JSON.toJSONString(a)); result.setAValue(JSON.toJSONString(a));
List<PqScriptCheckData> channelTypeBList = checkData.stream() List<PqScriptCheckData> channelTypeBList = checkData.stream()
.filter(x -> TYPE_B.equals(x.getPhase())) .filter(x -> TYPE_B.equals(x.getPhase()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule); DetectionData b = rangeComparisonList(map.get(TYPE_B), isQualified, pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
result.setBValue(JSON.toJSONString(b)); result.setBValue(JSON.toJSONString(b));
List<PqScriptCheckData> channelTypeCList = checkData.stream() List<PqScriptCheckData> channelTypeCList = checkData.stream()
.filter(x -> TYPE_C.equals(x.getPhase())) .filter(x -> TYPE_C.equals(x.getPhase()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule); DetectionData c = rangeComparisonList(map.get(TYPE_C), isQualified, pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
result.setCValue(JSON.toJSONString(c)); result.setCValue(JSON.toJSONString(c));
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c))); result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
@@ -569,7 +589,7 @@ public class DetectionServiceImpl {
List<PqScriptCheckData> channelTypeBList = checkData.stream() List<PqScriptCheckData> channelTypeBList = checkData.stream()
.filter(x -> TYPE_T.equals(x.getPhase())) .filter(x -> TYPE_T.equals(x.getPhase()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData t = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule); DetectionData t = rangeComparisonList(map.get(TYPE_B), isQualified, pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
result.setTValue(JSON.toJSONString(t)); result.setTValue(JSON.toJSONString(t));
result.setResultFlag(setResultFlag(Arrays.asList(t))); result.setResultFlag(setResultFlag(Arrays.asList(t)));
} }
@@ -581,6 +601,14 @@ public class DetectionServiceImpl {
/** /**
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(暂态) * 判断值是否在误差范围内,有则进行判断否则则不进行计算(暂态)
* <p>
* (假如都符合,则选取最开始合格的,都不合格,取最开始不合格的)
* 方案一 分项问题
* 分别计算各个相别是否合格
* 不合格电压幅值的层级最高
* <p>
* 方案二 不分项问题
* 以电压幅值最低的作为比较相别
* *
* @param dev 处理过后的数据 * @param dev 处理过后的数据
* @param errDtlsCheckData 误差体系 * @param errDtlsCheckData 误差体系
@@ -604,14 +632,80 @@ public class DetectionServiceImpl {
//暂态电压下多少就是多少 //暂态电压下多少就是多少
List<ErrDtlsCheckDataVO> magErrList = errDtlsCheckData.stream().filter(x -> MAG.equals(x.getValueTypeCode())).collect(Collectors.toList()); List<ErrDtlsCheckDataVO> magErrList = errDtlsCheckData.stream().filter(x -> MAG.equals(x.getValueTypeCode())).collect(Collectors.toList());
List<ErrDtlsCheckDataVO> durErrList = errDtlsCheckData.stream().filter(x -> DUR.equals(x.getValueTypeCode())).collect(Collectors.toList()); List<ErrDtlsCheckDataVO> durErrList = errDtlsCheckData.stream().filter(x -> DUR.equals(x.getValueTypeCode())).collect(Collectors.toList());
AdNonHarmonicResult magResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, mag, magErrList, sourceIssue.getFUn(), MAG); AdNonHarmonicResult magResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, mag, magErrList, sourceIssue.getFUn(), MAG);
AdNonHarmonicResult durResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, dur, durErrList, sourceIssue.getFFreq(), DUR); AdNonHarmonicResult durResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, dur, durErrList, sourceIssue.getFFreq(), DUR);
if (CollUtil.isNotEmpty(mag.get(TYPE_B)) && CollUtil.isNotEmpty(mag.get(TYPE_C))) {
conclusion(magResult, durResult);
}
detectionDataDealService.acceptAdNonResult(Arrays.asList(magResult, durResult), code); detectionDataDealService.acceptAdNonResult(Arrays.asList(magResult, durResult), code);
List<Integer> numbers = Arrays.asList(magResult.getResultFlag(), durResult.getResultFlag()).stream().filter(x -> 4 != x).distinct().collect(Collectors.toList()); List<Integer> numbers = Arrays.asList(magResult.getResultFlag(), durResult.getResultFlag()).stream().distinct().collect(Collectors.toList());
return getInteger(numbers); return getInteger(numbers);
} }
/**
* @param magResult 电压幅值结果
* @param durResult 持续时间结果
* @Description:
* @Author: wr
* @Date: 2025/4/9 18:54
*/
private void conclusion(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
if (magResult.getResultFlag() == 1) {
if (durResult.getResultFlag() != 2) {
setTValueBasedOnAValue(magResult, durResult);
} else {
setTValueBasedOnAValue(magResult, durResult, false);
}
} else if (magResult.getResultFlag() == 2) {
setTValueBasedOnAValue(magResult, durResult, true);
} else {
setTValueBasedOnAValue(magResult, durResult);
}
}
private void setTValueBasedOnAValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult, Boolean isMag) {
DetectionData a;
DetectionData b;
DetectionData c;
if (isMag) {
a = JSON.parseObject(magResult.getAValue(), DetectionData.class);
b = JSON.parseObject(magResult.getBValue(), DetectionData.class);
c = JSON.parseObject(magResult.getCValue(), DetectionData.class);
} else {
a = JSON.parseObject(durResult.getAValue(), DetectionData.class);
b = JSON.parseObject(durResult.getBValue(), DetectionData.class);
c = JSON.parseObject(durResult.getCValue(), DetectionData.class);
}
if (a.getIsData() == 2) {
setTValueBasedOnAValue(magResult, durResult);
} else if (b.getIsData() == 2) {
setTValueBasedOnBValue(magResult, durResult);
} else if (c.getIsData() == 2) {
setTValueBasedOnCValue(magResult, durResult);
}
}
/**
* @param magResult 电压幅值结果
* @param durResult 持续时间结果
* @Description:
* @Author: wr
*/
private void setTValueBasedOnAValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
magResult.setTValue(magResult.getAValue());
durResult.setTValue(durResult.getAValue());
}
private void setTValueBasedOnBValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
magResult.setTValue(magResult.getBValue());
durResult.setTValue(durResult.getBValue());
}
private void setTValueBasedOnCValue(AdNonHarmonicResult magResult, AdNonHarmonicResult durResult) {
magResult.setTValue(magResult.getCValue());
durResult.setTValue(durResult.getCValue());
}
/** /**
* @param devId 装置监测点id(ip_通道) * @param devId 装置监测点id(ip_通道)
* @param devIdMapComm ip_通道,装置名称 * @param devIdMapComm ip_通道,装置名称
@@ -640,69 +734,100 @@ public class DetectionServiceImpl {
result.setMonitorId(devID + "_" + split[1]); result.setMonitorId(devID + "_" + split[1]);
result.setScriptId(sourceIssue.getScriptId()); result.setScriptId(sourceIssue.getScriptId());
result.setSort(sourceIssue.getIndex()); result.setSort(sourceIssue.getIndex());
result.setDataType("avg"); result.setDataType(sourceIssue.getDataType());
List<PqErrSysDtls> magErrList = new ArrayList<>(); List<PqErrSysDtls> magErrList = new ArrayList<>();
Integer isQualified = 4;
if (CollUtil.isNotEmpty(errDtlsCheckData)) { if (CollUtil.isNotEmpty(errDtlsCheckData)) {
result.setAdType(errDtlsCheckData.get(0).getValueType()); result.setAdType(errDtlsCheckData.get(0).getValueType());
isQualified = errDtlsCheckData.get(0).getIsQualified();
if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) { if (CollUtil.isNotEmpty(errDtlsCheckData.get(0).getErrSysDtls())) {
magErrList = errDtlsCheckData.get(0).getErrSysDtls(); magErrList = errDtlsCheckData.get(0).getErrSysDtls();
} }
} }
//取出源所对应的相别信息
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
.filter(x -> ("Ua").equals(x.getChannelType()))
.collect(Collectors.toList());
DetectionData a = setDetectionData(dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A);
result.setAValue(JSON.toJSONString(a));
List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream() List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream()
.filter(x -> ("Ub").equals(x.getChannelType())) .filter(x -> ("Ub").equals(x.getChannelType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData b = setDetectionData(dataRule, mag, fData, dur, magErrList, channelTypeBList, TYPE_B); DetectionData b = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeBList, TYPE_B);
result.setBValue(JSON.toJSONString(b)); result.setBValue(JSON.toJSONString(b));
List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream() List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream()
.filter(x -> ("Uc").equals(x.getChannelType())) .filter(x -> ("Uc").equals(x.getChannelType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData c = setDetectionData(dataRule, mag, fData, dur, magErrList, channelTypeCList, TYPE_C); DetectionData c = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeCList, TYPE_C);
result.setCValue(JSON.toJSONString(c)); result.setCValue(JSON.toJSONString(c));
if (CollUtil.isNotEmpty(mag.get(TYPE_B)) && CollUtil.isNotEmpty(mag.get(TYPE_C))) {
//取出源所对应的相别信息
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
.filter(x -> ("Ua").equals(x.getChannelType()))
.collect(Collectors.toList());
DetectionData a = setDetectionData(isQualified, dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A);
result.setAValue(JSON.toJSONString(a));
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c))); result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
} else {
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
.filter(x -> x.getChannelType().contains("Ua"))
.sorted(Comparator.comparing(
x -> Optional.ofNullable(x.getDipData())
.map(SourceIssue.ChannelListDTO.DipDataDTO::getFTransValue)
.orElse(Double.NaN)
))
.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());
}
return result; return result;
} }
private DetectionData setDetectionData(DictDataEnum dataRule, Map<String, List<Double>> mag, Double fData, String dur, List<PqErrSysDtls> magErrList, List<SourceIssue.ChannelListDTO> channelTypeCList, String typeC) { private DetectionData setDetectionData(Integer isQualified,
DetectionData c; DictDataEnum dataRule,
Map<String, List<Double>> mag,
Double fData,
String dur,
List<PqErrSysDtls> magErrList,
List<SourceIssue.ChannelListDTO> channelTypeCList,
String type) {
DetectionData data;
if (DUR.equals(dur)) { if (DUR.equals(dur)) {
c = rangeDURComparisonList(mag.get(typeC), magErrList, fData, channelTypeCList.get(0).getDipData().getRetainTime(), dataRule); data = rangeDURComparisonList(mag.get(type), isQualified, magErrList, fData, channelTypeCList.get(0).getDipData().getRetainTime(), dataRule);
} else { } else {
List<Double> ampData = mag.get(typeC).stream() data = rangeComparisonList(mag.get(type), isQualified, magErrList, fData, channelTypeCList.get(0).getDipData().getFTransValue(), dataRule);
.filter(x -> ObjectUtil.isNotNull(x))
.map(x -> x * channelTypeCList.get(0).getFAmp() * 0.01)
.collect(Collectors.toList());
c = rangeComparisonList(ampData, magErrList, fData, channelTypeCList.get(0).getDipData().getFTransValue(), dataRule);
} }
return c; return data;
} }
private Integer setResultFlag(List<DetectionData> numbers) { private Integer setResultFlag(List<DetectionData> numbers) {
List<Integer> isData = numbers.stream().filter(x -> ObjectUtil.isNotNull(x.getData())).filter(x -> 4 != x.getIsData()).map(DetectionData::getIsData).distinct().collect(Collectors.toList()); List<Integer> isData = numbers.stream().filter(x -> ObjectUtil.isNotNull(x.getData())).map(DetectionData::getIsData).distinct().collect(Collectors.toList());
return getInteger(isData); return getInteger(isData);
} }
private static Integer getInteger(List<Integer> isData) { private static Integer getInteger(List<Integer> isData) {
if (CollUtil.isNotEmpty(isData)) { if (CollUtil.isNotEmpty(isData)) {
if (isData.size() > 1) { List<Integer> isQualified = isData.stream().filter(x -> 1 == x || 2 == x).collect(Collectors.toList());
if (isData.contains(2)) { if (CollUtil.isNotEmpty(isQualified)) {
if (isQualified.size() > 1) {
if (isQualified.contains(2)) {
return 2; return 2;
} }
} }
return isData.get(0); return isQualified.get(0);
} else { } else {
if (isData.contains(4)) {
return 4; return 4;
} }
if (isData.contains(5)) {
return 5;
}
}
}
return 4;
} }
/** /**
@@ -795,10 +920,11 @@ public class DetectionServiceImpl {
* @param sourceIssue 源下发的值(谐波) * @param sourceIssue 源下发的值(谐波)
* @param dataRule 数据处理原则 * @param dataRule 数据处理原则
* @param devMap * @param devMap
* @param fData * @param fData 额定值
* @return * @return
*/ */
public List<DetectionData> harmRangeComparison(List<PqErrSysDtls> pqErrSysDtls, public List<DetectionData> harmRangeComparison(Integer isQualified,
List<PqErrSysDtls> pqErrSysDtls,
String type, String type,
String phase, String phase,
SourceIssue sourceIssue, SourceIssue sourceIssue,
@@ -828,12 +954,12 @@ public class DetectionServiceImpl {
issueHarmMap = sourceIssue.getChannelList().stream() issueHarmMap = sourceIssue.getChannelList().stream()
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType())) .filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
.flatMap(x -> x.getInharmList().stream()) .flatMap(x -> x.getInharmList().stream())
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> x.getFAmp() * percent)); .collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> BigDecimal.valueOf(x.getFAmp()).multiply(BigDecimal.valueOf(percent)).doubleValue()));
} else { } else {
issueHarmMap = sourceIssue.getChannelList().stream() issueHarmMap = sourceIssue.getChannelList().stream()
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType())) .filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
.flatMap(x -> x.getHarmList().stream()) .flatMap(x -> x.getHarmList().stream())
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> x.getFAmp() * percent)); .collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> BigDecimal.valueOf(x.getFAmp()).multiply(BigDecimal.valueOf(percent)).doubleValue()));
} }
} }
Map<Double, PqErrSysDtls> errSysDtlMap = new LinkedHashMap<>(); Map<Double, PqErrSysDtls> errSysDtlMap = new LinkedHashMap<>();
@@ -854,19 +980,22 @@ public class DetectionServiceImpl {
devMap.forEach((harm, harmDataList) -> { devMap.forEach((harm, harmDataList) -> {
PqErrSysDtls errSysDtl = errSysDtlMap.get(harm); PqErrSysDtls errSysDtl = errSysDtlMap.get(harm);
DetectionData data = new DetectionData(); DetectionData data = new DetectionData();
data.setIsData(4); data.setIsData(isQualified);
data.setNum(harm); data.setNum(harm);
data.setData(harmDataList.get(0)); if (CollUtil.isNotEmpty(harmDataList)) {
Double v = issueHarmMap.get(harm); SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
data.setResultData(v); 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);
if (ObjectUtil.isNotNull(errSysDtl)) { if (ObjectUtil.isNotNull(errSysDtl)) {
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class); PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
errSys.setMaxErrorValue(maxErrorMultiply(errSys.getMaxErrorValue(), fData, issueHarmMap.get(harm), errSys.getErrorValueType())); errSys.setMaxErrorValue(maxErrorMultiply(errSys, fData, issueHarmMap.get(harm)));
NumberFormat nf = NumberFormat.getInstance(); data.setUnit(errSysDtl.getErrorUnit());
nf.setMaximumFractionDigits(6); data.setRadius(-errSys.getMaxErrorValue() + "~" + errSys.getMaxErrorValue());
nf.setGroupingUsed(false); setDetection(dataRule, harmDataList, errSys, data, channelData, fData);
data.setRadius(nf.format(-errSys.getMaxErrorValue()) + "~" + nf.format(errSys.getMaxErrorValue()));
setDetection(dataRule, harmDataList, errSys, data, v);
} }
info.add(data); info.add(data);
}); });
@@ -879,25 +1008,57 @@ public class DetectionServiceImpl {
* @param harmDataList 原始数据集合 * @param harmDataList 原始数据集合
* @param errSysDtl 误差体系 * @param errSysDtl 误差体系
* @param data 初始化原始数据 * @param data 初始化原始数据
* @param v 源下发的数据 * @param channelData 源下发的数据
* @param ratedValue 额定值
* @Description: * @Description:
* @Author: wr * @Author: wr
* @Date: 2024/12/29 18:10 * @Date: 2024/12/29 18:10
*/ */
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double v) { 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() List<Double> qualifiedList = harmDataList.stream()
.filter(x -> v == 0 ? NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()), .filter(x -> channelData == 0 ? NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, oneConfig.getScale()),
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()), BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
BigDecimal.valueOf(errSysDtl.getMaxErrorValue())) : BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()), :
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, oneConfig.getScale()),
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()), BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList()); BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
if (CollUtil.isNotEmpty(qualifiedList)) {
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, oneConfig.getScale()));
}
isData(dataRule, harmDataList, data, qualifiedList); isData(dataRule, harmDataList, data, qualifiedList);
} }
}
private void isData(DictDataEnum dataRule, List<Double> harmDataList, DetectionData data, List<Double> qualifiedList) { private void isData(DictDataEnum dataRule, List<Double> harmDataList, DetectionData data, List<Double> qualifiedList) {
if (CollUtil.isNotEmpty(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) { switch (dataRule) {
case AT_WILL_VALUE: case AT_WILL_VALUE:
case CP95_VALUE: case CP95_VALUE:
@@ -913,6 +1074,10 @@ public class DetectionServiceImpl {
if (qualifiedList.size() == harmDataList.size()) { if (qualifiedList.size() == harmDataList.size()) {
data.setIsData(1); data.setIsData(1);
} else { } 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); data.setIsData(2);
} }
break; break;
@@ -1020,11 +1185,14 @@ public class DetectionServiceImpl {
* @param dataRule 数据处理原则 * @param dataRule 数据处理原则
* @returnd * @returnd
*/ */
public DetectionData rangeComparisonList(List<Double> list, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) { public DetectionData rangeComparisonList(List<Double> list, Integer isQualified, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
DetectionData detectionData = new DetectionData(); DetectionData detectionData = new DetectionData();
detectionData.setIsData(4); detectionData.setIsData(isQualified);
if (CollUtil.isNotEmpty(list)) { 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); detectionData.setResultData(channelData);
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
//获得误差体系 //获得误差体系
@@ -1035,22 +1203,23 @@ public class DetectionServiceImpl {
channelData)).collect(Collectors.toList()); channelData)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(errSysDtls)) { if (CollUtil.isNotEmpty(errSysDtls)) {
PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class); PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class);
NumberFormat nf = NumberFormat.getInstance(); detectionData.setUnit(errSysDtl.getErrorUnit());
nf.setMaximumFractionDigits(6); errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl, data, channelData));
nf.setGroupingUsed(false); detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType())); setDetection(dataRule, list, errSysDtl, detectionData, channelData, data);
detectionData.setRadius(nf.format(-errSysDtl.getMaxErrorValue()) + "~" + nf.format(errSysDtl.getMaxErrorValue()));
setDetection(dataRule, list, errSysDtl, detectionData, channelData);
} }
} }
return detectionData; return detectionData;
} }
public DetectionData rangeDURComparisonList(List<Double> list, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) { public DetectionData rangeDURComparisonList(List<Double> list, Integer isQualified, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
DetectionData detectionData = new DetectionData(); DetectionData detectionData = new DetectionData();
detectionData.setIsData(4); detectionData.setIsData(isQualified);
if (CollUtil.isNotEmpty(list)) { 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); detectionData.setResultData(BigDecimal.valueOf(1.0 / data).doubleValue() * channelData);
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
@@ -1065,14 +1234,24 @@ public class DetectionServiceImpl {
NumberFormat nf = NumberFormat.getInstance(); NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(6); nf.setMaximumFractionDigits(6);
nf.setGroupingUsed(false); nf.setGroupingUsed(false);
detectionData.setRadius(nf.format(BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue()))) detectionData.setUnit(errSysDtl.getErrorUnit());
+ "~" + nf.format(BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue())))); detectionData.setRadius(nf.format(BigDecimal.valueOf(-1.0 / data))
+ "~" + nf.format(BigDecimal.valueOf(1.0 / data)));
List<Double> qualifiedList = list.stream() List<Double> qualifiedList = list.stream()
.filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()), .filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()),
BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())), BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())),
BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue()))) BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue())))
).collect(Collectors.toList()); ).collect(Collectors.toList());
isData(dataRule, qualifiedList, detectionData, qualifiedList); if (CollUtil.isNotEmpty(qualifiedList)) {
BigDecimal subtract = BigDecimal.valueOf(qualifiedList.get(0))
.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))).setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
detectionData.setErrorData(subtract);
}
isData(dataRule, list, detectionData, qualifiedList);
} }
} }
return detectionData; return detectionData;
@@ -1088,7 +1267,8 @@ public class DetectionServiceImpl {
* @param devData 装置上送值 * @param devData 装置上送值
* @return * @return
*/ */
public Boolean rangeComparison(Double startValue, Integer startFlag, Double endValue, Integer endFlag, Double devData) { public Boolean rangeComparison(Double startValue, Integer startFlag, Double endValue, Integer endFlag, Double
devData) {
Boolean minBool = null; Boolean minBool = null;
Boolean maxBool = null; Boolean maxBool = null;
if (ObjectUtil.isNotNull(startValue)) { if (ObjectUtil.isNotNull(startValue)) {
@@ -1120,38 +1300,37 @@ public class DetectionServiceImpl {
} }
/** /**
* 技术数据误差值(装置返回的值 - 源通道下发的值) * 计算数据误差值(装置返回的值 - 源通道下发的值)
* *
* @param devData * @param devData 装置返回值
* @param channelData * @param channelData 通道值
* @param errorValueType * @param ratedValue 额定值
* @param error
* @param scale 小数点位数
* @return * @return
*/ */
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Integer errorValueType) { public BigDecimal devSubtractChannelData(Double devData, Double channelData, Double ratedValue, PqErrSysDtls error, Integer scale) {
if (devData - channelData != 0) { //计算装置值返回值 - 源下发值的数据 = 差值
switch (errorValueType) { BigDecimal subtract = BigDecimal.valueOf(devData).setScale(scale, RoundingMode.HALF_UP).subtract(BigDecimal.valueOf(channelData));
case 2: //只有相对值需要%比较,绝对值直接相减就行
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/下发的幅值 if (2 == error.getValueType()) {
return BigDecimal.valueOf(devData - channelData) switch (error.getErrorValueType()) {
.divide(BigDecimal.valueOf(channelData), 4, RoundingMode.HALF_UP); case 0:
case 3: //下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/ 额定值
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/装置返回值 return subtract.multiply(BigDecimal.valueOf(100))
return BigDecimal.valueOf(devData - channelData) .divide(BigDecimal.valueOf(ratedValue), scale, RoundingMode.HALF_UP);
.divide(BigDecimal.valueOf(devData), 4, RoundingMode.HALF_UP); case 1:
//todo 当谐波电压和间谐波电压默认都是按照相对值误差进行计算(用户关心的是含有率)
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/ 下发的幅值
return subtract.multiply(BigDecimal.valueOf(100))
.divide(BigDecimal.valueOf(channelData), scale, RoundingMode.HALF_UP);
} }
return BigDecimal.valueOf(devData - channelData);
} }
return BigDecimal.valueOf(0); return subtract;
}
public BigDecimal divide(Double devData, Double channelData) {
return BigDecimal.valueOf(devData)
.divide(BigDecimal.valueOf(channelData), 4, RoundingMode.HALF_UP);
} }
/** /**
* 用于计算误差体系的范围的 * 用于计算误差体系的范围的0标称值 1谐波值 2值类型
* *
* @param value 误差值 * @param value 误差值
* @param ratedData 额定值 * @param ratedData 额定值
@@ -1160,14 +1339,15 @@ public class DetectionServiceImpl {
* @return * @return
*/ */
public Double startRadiusEnd(Double value, Double ratedData, Double harmData, Integer type) { public Double startRadiusEnd(Double value, Double ratedData, Double harmData, Integer type) {
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
if (ObjectUtil.isNotNull(value)) { if (ObjectUtil.isNotNull(value)) {
switch (type) { switch (type) {
case 0: case 0:
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(ratedData)) return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(ratedData))
.setScale(4, RoundingMode.HALF_UP).doubleValue(); .setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
case 1: case 1:
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(harmData)) return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(harmData))
.setScale(4, RoundingMode.HALF_UP).doubleValue(); .setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
default: default:
return value; return value;
} }
@@ -1178,27 +1358,38 @@ public class DetectionServiceImpl {
/** /**
* 用于计算最大误差值的范围的 * 用于计算最大误差值的范围的
* 2绝对值-值比较(默认) 0绝对值-标称值(额定电压) 1绝对值-标准值(源下发直谐波如:H2 0相对值-标称值 1相对值-标准值)
* *
* @param errorValue 误差值 * @param error 最大误差值对象
* @param ratedData 额定值 * @param ratedData 额定值
* @param harmData 谐波下发值(百分数->含油率) * @param harmData 谐波下发值(百分数->含油率)
* @param type 误差值类型
* @return * @return
*/ */
public Double maxErrorMultiply(Double errorValue, Double ratedData, Double harmData, Integer type) { public Double maxErrorMultiply(PqErrSysDtls error, Double ratedData, Double harmData) {
if (ObjectUtil.isNotNull(errorValue)) { SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
switch (type) { Double errorValue = error.getMaxErrorValue();
//1绝对值
if (1 == error.getValueType()) {
switch (error.getErrorValueType()) {
//绝对值-标称值= 最大误差值 * 额定电压
case 0: case 0:
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(ratedData)) return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(ratedData))
.setScale(4, RoundingMode.HALF_UP).doubleValue(); .setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
case 2: //绝对值-标准值 = 最大误差值 * 谐波下发值
case 3: case 1:
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(harmData)) return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(harmData))
.setScale(4, RoundingMode.HALF_UP).doubleValue(); .setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
default: }
return errorValue; }
//2相对值
if (2 == error.getValueType()) {
switch (error.getErrorValueType()) {
//相对值-标称值 | 相对值-标准值 = 最大误差值 * 100
case 0:
case 1:
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(100))
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
} }
} }
return errorValue; return errorValue;
} }
@@ -1218,7 +1409,9 @@ public class DetectionServiceImpl {
* @param harm 基波信息 * @param harm 基波信息
* @param fund 2-50次谐波信息 * @param fund 2-50次谐波信息
*/ */
public void harmPut(String type, Map<String, Map<Double, List<Double>>> map, List<Double> harmNum, DevData.SqlDataHarmDTO harm, String fund, Integer num) { public void harmPut(String
type, Map<String, Map<Double, List<Double>>> map, List<Double> harmNum, DevData.SqlDataHarmDTO
harm, String fund, Integer num) {
if (map.containsKey(type)) { if (map.containsKey(type)) {
Map<Double, List<Double>> integerListMap = map.get(type); Map<Double, List<Double>> integerListMap = map.get(type);
for (Double i : harmNum) { for (Double i : harmNum) {

View File

@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.detection.handler.SocketDevResponseService; import com.njcn.gather.detection.handler.SocketDevResponseService;
import com.njcn.gather.detection.handler.SocketSourceResponseService; import com.njcn.gather.detection.handler.SocketSourceResponseService;
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum; import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam; import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
import com.njcn.gather.detection.pojo.vo.SocketMsg; import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.gather.detection.service.PreDetectionService;
import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
import com.njcn.gather.detection.util.socket.CnSocketUtil; import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.FormalTestManager; import com.njcn.gather.detection.util.socket.FormalTestManager;
import com.njcn.gather.detection.util.socket.SocketManager; import com.njcn.gather.detection.util.socket.SocketManager;
@@ -41,7 +43,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -52,8 +53,6 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class PreDetectionServiceImpl implements PreDetectionService { public class PreDetectionServiceImpl implements PreDetectionService {
private final String source = "_Source";
private final String dev = "_Dev";
private final String stepTag = "&&"; private final String stepTag = "&&";
private final String handlerSourceStr = "_Source"; private final String handlerSourceStr = "_Source";
@@ -79,13 +78,18 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override @Override
public void sourceCommunicationCheck(PreDetectionParam param) { public void sourceCommunicationCheck(PreDetectionParam param) {
commCheck(param); // 参数校验目前仅检查IP是否重复后续可在里面扩展
specialDeal(param); checkDevIp(param);
//用于处理异常导致的socket通道未关闭socket交互异常
DetectionCommunicateUtil.checkCommunicateChannel(param);
/* /*
先组装源通讯协议 先组装源通讯协议
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源) 查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
*/ */
AdPlan plan = iAdPlanService.getById(param.getPlanId()); AdPlan plan = iAdPlanService.getById(param.getPlanId());
param.setScriptId(plan.getScriptId());
param.setErrorSysId(plan.getErrorSysId());
param.setCode(String.valueOf(plan.getCode()));
if (ObjectUtil.isNotNull(plan)) { if (ObjectUtil.isNotNull(plan)) {
String code = dictDataService.getDictDataById(plan.getPattern()).getCode(); String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code); DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
@@ -106,7 +110,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override @Override
public void coefficientCheck(PreDetectionParam param) { public void coefficientCheck(PreDetectionParam param) {
specialDeal(param); // 检测是否存在连接的通道,后期需要做成动态,如果组合中不是第一位,则不需要关闭,也不用初始化 todo....
DetectionCommunicateUtil.checkCommunicateChannel(param);
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>() AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
.eq(AdPlanSource::getPlanId, param.getPlanId()) .eq(AdPlanSource::getPlanId, param.getPlanId())
); );
@@ -132,13 +137,11 @@ public class PreDetectionServiceImpl implements PreDetectionService {
private void sendYtxSocket(PreDetectionParam param) { 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())); AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
param.setSourceId(planSource.getSourceId()); param.setSourceId(planSource.getSourceId());
param.setScriptId(plan.getScriptId());
param.setErrorSysId(plan.getErrorSysId());
param.setCode(String.valueOf(plan.getCode()));
if (ObjectUtil.isNotNull(planSource)) { if (ObjectUtil.isNotNull(planSource)) {
//获取源初始化参数
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId()); SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
if (ObjectUtil.isNotNull(sourceParam)) { if (ObjectUtil.isNotNull(sourceParam)) {
//开始组装socket报文请求头 //开始组装socket报文请求头
@@ -148,6 +151,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue()); socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue()); socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
socketMsg.setData(JSON.toJSONString(sourceParam)); socketMsg.setData(JSON.toJSONString(sourceParam));
//建立与源控程序的socket连接
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService)); NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
} else { } else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT); throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
@@ -162,9 +166,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
param.setSourceId(sourceParam.getSourceId()); param.setSourceId(sourceParam.getSourceId());
WebServiceManager.addPreDetectionParam(param); WebServiceManager.addPreDetectionParam(param);
if (ObjectUtil.isNotNull(sourceParam)) { if (ObjectUtil.isNotNull(sourceParam)) {
//开始组装socket报文请求头
//socketDevResponseService.initList(param);
//socketSourceResponseService.initList(param);
SocketMsg<String> socketMsg = new SocketMsg<>(); SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue()); socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue()); socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
@@ -175,15 +176,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
} }
} }
@Override
public boolean startTest(PreDetectionParam param) {
socketDevResponseService.initList(param);
NettyClient.socketClient(ip, port, param, "start\n", new NettySourceClientHandler(param, sourceResponseService));
return true;
}
@Override @Override
public boolean temStopTest() { public boolean temStopTest() {
FormalTestManager.stopFlag = true; FormalTestManager.stopFlag = true;
@@ -201,7 +193,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue()); xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
xuMsg.setData(JSON.toJSONString(sourceIssues)); xuMsg.setData(JSON.toJSONString(sourceIssues));
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType()); xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(xuMsg)); SocketManager.sendMsg(param.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
} else { } else {
//TODO 是否最终检测完成需要推送给用户 //TODO 是否最终检测完成需要推送给用户
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam(); PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
@@ -209,7 +201,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
checkDataParam.setIsValueTypeName(false); checkDataParam.setIsValueTypeName(false);
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam); List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode()); iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
CnSocketUtil.quitSend(param); CnSocketUtil.quitSend(param);
} }
@@ -223,26 +215,13 @@ public class PreDetectionServiceImpl implements PreDetectionService {
preDetectionParam.setUserPageId(param.getUserPageId()); preDetectionParam.setUserPageId(param.getUserPageId());
preDetectionParam.setSendWebMsg(true); preDetectionParam.setSendWebMsg(true);
specialDealSimulate(preDetectionParam); DetectionCommunicateUtil.checkCommunicateChannel(preDetectionParam);
// String code = dictDataService.getDictDataById(param.getPattern()).getCode();
// DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
// switch (dictDataEnumByCode) {
// case DIGITAL:
// case SIMULATE:
// sendYtxSocketSimulate(preDetectionParam);
// break;
// case CONTRAST:
// break;
// default:
// throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT);
// }
sendYtxSocketSimulate(preDetectionParam); sendYtxSocketSimulate(preDetectionParam);
} }
@Override @Override
public void sendScript(SimulateDetectionParam param) { public void sendScript(SimulateDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source); Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
if (Objects.isNull(channel) || !channel.isActive()) { if (Objects.isNull(channel) || !channel.isActive()) {
// 进行源通信连接 // 进行源通信连接
PreDetectionParam preDetectionParam = new PreDetectionParam(); PreDetectionParam preDetectionParam = new PreDetectionParam();
@@ -253,9 +232,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
} }
//组装源控制脚本 //组装源控制脚本
PqScriptIssueParam issueParam = new PqScriptIssueParam(); PqScriptIssueParam issueParam = new PqScriptIssueParam();
//issueParam.setPlanId(param.getPlanId());
issueParam.setSourceId(param.getSourceId()); issueParam.setSourceId(param.getSourceId());
//issueParam.setDevIds(param.getDevIds());
issueParam.setScriptId(param.getScriptId()); issueParam.setScriptId(param.getScriptId());
issueParam.setType(1); issueParam.setType(1);
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue()); issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
@@ -263,7 +240,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam); List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
sourceIssues = sourceIssues.stream() sourceIssues = sourceIssues.stream()
.filter(s -> s.getIndex().equals(param.getScriptIndex())) .filter(s -> s.getIndex().equals(param.getScriptIndex()))
.sorted(Comparator.comparing(SourceIssue::getIndex))
.collect(Collectors.toList()); .collect(Collectors.toList());
SourceIssue sourceIssue = sourceIssues.get(0); SourceIssue sourceIssue = sourceIssues.get(0);
@@ -279,7 +255,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override @Override
public void closeTestSimulate(SimulateDetectionParam param) { public void closeTestSimulate(SimulateDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source); Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
if (Objects.isNull(channel) || !channel.isActive()) { if (Objects.isNull(channel) || !channel.isActive()) {
throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT); throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT);
} }
@@ -288,72 +264,14 @@ public class PreDetectionServiceImpl implements PreDetectionService {
preDetectionParam.setSourceId(sourceParam.getSourceId()); preDetectionParam.setSourceId(sourceParam.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId()); preDetectionParam.setUserPageId(param.getUserPageId());
CnSocketUtil.quitSendSource(preDetectionParam); CnSocketUtil.quitSendSource(preDetectionParam);
WebServiceManager.removePreDetectionParam(); WebServiceManager.removePreDetectionParam();
} }
/**
* 对重复发起或者异常发起的检测进行关闭源操作
*
* @param param
*/
private void specialDeal(PreDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
Channel channelDev = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
if (Objects.nonNull(channel) && channel.isActive()) {
System.out.println("发送关闭源指令。。。。。。。。");
CnSocketUtil.quitSendSource(param);
}
if (Objects.nonNull(channelDev) && channelDev.isActive()) {
System.out.println("发送关闭设备通讯指令。。。。。。。。");
CnSocketUtil.quitSend(param);
}
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
SocketManager.removeUser(param.getUserPageId() + source);
SocketManager.removeUser(param.getUserPageId() + dev);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
/** /**
* 对重复发起或者异常发起的检测进行关闭源操作-模拟检测 * 校验被检设备中是否存在IP重复的
*
* @param param
*/ */
private void specialDealSimulate(PreDetectionParam param) { private void checkDevIp(PreDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
if (Objects.nonNull(channel) && channel.isActive()) {
System.out.println("发送关闭源指令。。。。。。。。");
CnSocketUtil.quitSendSource(param);
}
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
SocketManager.removeUser(param.getUserPageId() + source);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
/**
* 校验
*/
private void commCheck(PreDetectionParam param) {
List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds()); List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds());
List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList()); List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList());
if (ipList.size() != param.getDevIds().size()) { if (ipList.size() != param.getDevIds().size()) {

View File

@@ -0,0 +1,57 @@
package com.njcn.gather.detection.util.business;
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.SocketManager;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import java.util.Objects;
/**
* 检测通讯工具类
*
* @author hongawen
* @version 1.0
* @data 2025/4/15 15:24
*/
@Slf4j
public class DetectionCommunicateUtil {
/**
* 检测是否存在连接的源、设备通讯的模块通道
* 有则强行关闭
*/
public static void checkCommunicateChannel(PreDetectionParam param) {
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);
}
if (Objects.nonNull(channelDev) && channelDev.isActive()) {
System.out.println("发送关闭设备通讯指令。。。。。。。。");
CnSocketUtil.quitSend(param);
}
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
SocketManager.removeUser(param.getUserPageId() + DetectionCommunicateConstant.DEV);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
}

View File

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

View File

@@ -66,4 +66,10 @@ public class FormalTestManager {
public static Integer stopTime = 0; public static Integer stopTime = 0;
/**
* 强行赋值关系
*/
public static Map<String,String> harmonicRelationMap = new HashMap<>();
} }

View File

@@ -1,22 +1,11 @@
package com.njcn.gather.detection.util.socket; package com.njcn.gather.detection.util.socket;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.po.DevData;
import com.njcn.gather.detection.pojo.vo.SocketDataMsg; import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
import java.lang.reflect.Field;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author wr * @author wr
@@ -76,103 +65,4 @@ public class MsgUtil {
} }
return JSON.toJSONString(socketDataMsg); return JSON.toJSONString(socketDataMsg);
} }
public static List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm, boolean containBaseHarm) {
List<DevData> info = new ArrayList<>();
// if (CollUtil.isNotEmpty(nonHarm)) {
if (CollUtil.isNotEmpty(nonHarm)) {
Map<String, List<AdNonHarmonicResult>> noHarmMap = nonHarm.stream()
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)) + "_" + x.getSort()));
noHarmMap.forEach((key, value) -> {
String[] split = key.split("_");
DevData data = new DevData();
data.setTime(split[2]);
data.setId(split[0] + "_" + split[1]);
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
DevData.SqlDataDTO sqlDataDTO;
for (AdNonHarmonicResult result : value) {
sqlDataDTO = new DevData.SqlDataDTO();
sqlDataDTO.setType(result.getDataType());
sqlDataDTO.setDesc(result.getAdType());
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
listDTO.setA(StrUtil.isNotBlank(result.getAValue()) ? Double.valueOf(result.getAValue()) : null);
listDTO.setB(StrUtil.isNotBlank(result.getBValue()) ? Double.valueOf(result.getBValue()) : null);
listDTO.setC(StrUtil.isNotBlank(result.getCValue()) ? Double.valueOf(result.getCValue()) : null);
listDTO.setT(StrUtil.isNotBlank(result.getTValue()) ? Double.valueOf(result.getTValue()) : null);
sqlDataDTO.setList(listDTO);
sqlDataDTOS.add(sqlDataDTO);
}
data.setSqlData(sqlDataDTOS);
info.add(data);
});
}
if (CollUtil.isNotEmpty(harm)) {
Map<String, List<AdHarmonicResult>> harmMap = harm.stream()
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN))));
harmMap.forEach((key, value) -> {
List<DevData> collect = info.stream().filter(x -> key.equals(x.getId() + "_" + x.getTime())).collect(Collectors.toList());
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
DevData.SqlDataDTO sqlDataDTO;
List<DevData.SqlDataHarmDTO> sqlDataHarmDTOS = new ArrayList<>();
DevData.SqlDataHarmDTO dataHarmDTO;
for (AdHarmonicResult harmonicResult : value) {
if (containBaseHarm) {
sqlDataDTO = new DevData.SqlDataDTO();
sqlDataDTO = new DevData.SqlDataDTO();
sqlDataDTO.setType(harmonicResult.getDataType());
sqlDataDTO.setDesc(harmonicResult.getAdType());
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
listDTO.setA(StrUtil.isNotBlank(harmonicResult.getAValue1()) ? Double.valueOf(harmonicResult.getAValue1()) : null);
listDTO.setB(StrUtil.isNotBlank(harmonicResult.getBValue1()) ? Double.valueOf(harmonicResult.getBValue1()) : null);
listDTO.setC(StrUtil.isNotBlank(harmonicResult.getCValue1()) ? Double.valueOf(harmonicResult.getCValue1()) : null);
sqlDataDTO.setList(listDTO);
sqlDataDTOS.add(sqlDataDTO);
}
dataHarmDTO = new DevData.SqlDataHarmDTO();
dataHarmDTO.setType(harmonicResult.getDataType());
dataHarmDTO.setDesc(harmonicResult.getAdType());
dataHarmDTO.setNum(containBaseHarm ? 49 : 50);
DevData.SqlDataHarmDTO.ListDTO listHarmDTO = new DevData.SqlDataHarmDTO.ListDTO();
listHarmDTO.setA(reflectHarmonicValue("a", harmonicResult, containBaseHarm));
listHarmDTO.setB(reflectHarmonicValue("b", harmonicResult, containBaseHarm));
listHarmDTO.setC(reflectHarmonicValue("c", harmonicResult, containBaseHarm));
dataHarmDTO.setList(listHarmDTO);
sqlDataHarmDTOS.add(dataHarmDTO);
}
if (CollUtil.isNotEmpty(collect)) {
collect.get(0).setSqlDataHarm(sqlDataHarmDTOS);
} else {
String[] split = key.split("_");
DevData data = new DevData();
data.setTime(split[2]);
data.setId(split[0] + "_" + split[1]);
data.setSqlData(sqlDataDTOS);
data.setSqlDataHarm(sqlDataHarmDTOS);
info.add(data);
}
});
}
// }
return info;
}
private static List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult, boolean notContainBaseHarm) {
List<String> info = new ArrayList<>();
for (int i = notContainBaseHarm ? 2 : 1; i <= 50; i++) {
String fieldName = phase + "Value" + i;
try {
Field idField = AdHarmonicResult.class.getDeclaredField(fieldName);
idField.setAccessible(true);
String value = idField.get(adHarmonicResult) + "";
info.add(value);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return info;
}
} }

View File

@@ -1,7 +1,6 @@
package com.njcn.gather.detection.util.socket; package com.njcn.gather.detection.util.socket;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.script.pojo.po.SourceIssue; import com.njcn.gather.script.pojo.po.SourceIssue;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup;
@@ -19,7 +18,14 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/ */
public class SocketManager { public class SocketManager {
/**
* key为userIdxxx_Source、xxx_Devvalue为channel
*/
private static final Map<String, Channel> socketSessions = new ConcurrentHashMap<>(); private static final Map<String, Channel> socketSessions = new ConcurrentHashMap<>();
/**
* key为userIdxxx_Source、xxx_Devvalue为group
*/
private static final Map<String, NioEventLoopGroup> socketGroup = new ConcurrentHashMap<>(); private static final Map<String, NioEventLoopGroup> socketGroup = new ConcurrentHashMap<>();
public static void addUser(String userId, Channel channel) { public static void addUser(String userId, Channel channel) {

View File

@@ -0,0 +1,63 @@
package com.njcn.gather.detection.util.socket;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import java.util.Arrays;
/**
* @author wr
* @description
* @date 2025/3/27 14:58
*/
public class UnitUtil {
public static String unit(String code, Integer fly) {
String unit = "";
if (Arrays.asList(0, 1).contains(fly)) {
if (DetectionCodeEnum.FREQ.getCode().equals(code)) {
unit = "Hz";
}
if (DetectionCodeEnum.VRMS.getCode().equals(code)) {
unit = "V";
}
if (DetectionCodeEnum.IRMS.getCode().equals(code)) {
unit = "A";
}
if (DetectionCodeEnum.V2_50.getCode().equals(code) ||
DetectionCodeEnum.SV_1_49.getCode().equals(code)||
DetectionCodeEnum.V_UNBAN.getCode().equals(code) ||
DetectionCodeEnum.I_UNBAN.getCode().equals(code)
) {
unit = "%";
}
if (DetectionCodeEnum.I2_50.getCode().equals(code) ||
DetectionCodeEnum.SI_1_49.getCode().equals(code)
) {
unit = "A";
}
if (DetectionCodeEnum.P2_50.getCode().equals(code)) {
unit = "W";
}
if (DetectionCodeEnum.P.getCode().equals(code)) {
unit = "P";
}
if (DetectionCodeEnum.MAG.getCode().equals(code)) {
unit = "V";
}
if (DetectionCodeEnum.DUR.getCode().equals(code)) {
unit = "s";
}
if (DetectionCodeEnum.VA.getCode().equals(code) ||
DetectionCodeEnum.IA.getCode().equals(code)
) {
unit = "°";
}
if (DetectionCodeEnum.DELTA_V.getCode().equals(code)
) {
unit = "%";
}
}else{
unit = "%";
}
return unit;
}
}

View File

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

View File

@@ -28,7 +28,7 @@ public class XiNumberManager {
public static List<String> devXiList = new ArrayList<>(); public static List<String> devXiList = new ArrayList<>();
/** /**
* 最开始存储装置通道原始系数,后续存储大电压计算出来的系数 * 最开始存储装置通道原始系数,后续存储大电压计算出来的系数。key为装置ip
*/ */
public static Map<String, DevXiNumData> devXiNumDataMap = new ConcurrentHashMap<>(); public static Map<String, DevXiNumData> devXiNumDataMap = new ConcurrentHashMap<>();
@@ -43,6 +43,7 @@ public class XiNumberManager {
public static Integer stepNumber = 0; public static Integer stepNumber = 0;
// 存放大电压、小电压、大电流、小电流的数值
public static List<CoefficientVO.DevParameter> devParameterList = new ArrayList<>(); public static List<CoefficientVO.DevParameter> devParameterList = new ArrayList<>();

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

@@ -52,7 +52,7 @@ public class NettyClient {
// .addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS)) // .addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
.addLast(new StringDecoder(CharsetUtil.UTF_8)) .addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8)) .addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new HeartbeatHandler(param,source)) .addLast(new HeartbeatHandler(param, source))
.addLast(handler); .addLast(handler);
} else { } else {
ch.pipeline() ch.pipeline()
@@ -61,7 +61,7 @@ public class NettyClient {
.addLast(new LineBasedFrameDecoder(10240)) .addLast(new LineBasedFrameDecoder(10240))
.addLast(new StringDecoder(CharsetUtil.UTF_8)) .addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8)) .addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new HeartbeatHandler(param,dev)) .addLast(new HeartbeatHandler(param, dev))
//空闲状态的handler //空闲状态的handler
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS)) .addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
.addLast(handler); .addLast(handler);
@@ -73,22 +73,28 @@ public class NettyClient {
channelFuture.addListener((ChannelFutureListener) ch -> { channelFuture.addListener((ChannelFutureListener) ch -> {
if (!ch.isSuccess()) { if (!ch.isSuccess()) {
System.out.println("链接服务端失败..."); System.out.println("链接服务端失败...");
// 连接失败时关闭 group
group.shutdownGracefully();
} else { } else {
System.out.println("链接服务端成功..."); System.out.println("链接服务端成功...");
System.out.println("客户端向服务端发送消息:"+port+msg); if (handler instanceof NettySourceClientHandler) {
channelFuture.channel().writeAndFlush(msg+"\n"); 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) { } catch (Exception e) {
System.out.println("连接socket服务端发送异常............" + e.getMessage()); System.out.println("连接socket服务端发送异常............" + e.getMessage());
group.shutdownGracefully(); group.shutdownGracefully();
@@ -100,7 +106,7 @@ public class NettyClient {
socketDataMsg.setRequestId("connect"); socketDataMsg.setRequestId("connect");
if (handler instanceof NettySourceClientHandler) { if (handler instanceof NettySourceClientHandler) {
socketDataMsg.setOperateCode("Source"); socketDataMsg.setOperateCode("Source");
}else{ } else {
CnSocketUtil.quitSendSource(param); CnSocketUtil.quitSendSource(param);
socketDataMsg.setOperateCode("Dev"); socketDataMsg.setOperateCode("Dev");
} }

View File

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

View File

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

View File

@@ -1,12 +1,8 @@
package com.njcn.gather.device.controller; package com.njcn.gather.device.controller;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.constant.OperateType;
@@ -15,38 +11,26 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil; import com.njcn.common.utils.LogUtil;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.device.pojo.enums.PatternEnum;
import com.njcn.gather.device.pojo.param.PqDevParam; import com.njcn.gather.device.pojo.param.PqDevParam;
import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.CNDevExcel;
import com.njcn.gather.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.pojo.vo.PqDevVO; import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.type.pojo.po.DevType; import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.FileUtil; import com.njcn.web.utils.FileUtil;
import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -63,24 +47,8 @@ import java.util.Map;
public class PqDevController extends BaseController { public class PqDevController extends BaseController {
private final IPqDevService pqDevService; private final IPqDevService pqDevService;
private final IDictDataService dictDataService;
private final IDevTypeService devTypeService; private final IDevTypeService devTypeService;
@OperateInfo
@GetMapping("/aaa")
@ApiOperation("分页查询被检设备")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<List<PreDetection>> aaa() {
String methodDescribe = getMethodDescribe("list");
List<PreDetection> devInfo = pqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
Map<String, List<PreDetection>> map = new HashMap();
map.put("deviceList", devInfo);
String jsonString = JSON.toJSONString(map);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devInfo, methodDescribe);
}
@OperateInfo @OperateInfo
@PostMapping("/list") @PostMapping("/list")
@ApiOperation("分页查询被检设备") @ApiOperation("分页查询被检设备")
@@ -107,14 +75,14 @@ public class PqDevController extends BaseController {
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新增被检设备") @ApiOperation("新增被检设备")
@ApiImplicitParam(name = "pqDevParam", value = "被检设备", required = true) @ApiImplicitParam(name = "pqDevParam", value = "被检设备", required = true)
public HttpResult<Object> add(@RequestBody @Validated PqDevParam pqDevParam) { public HttpResult<Boolean> add(@RequestBody @Validated PqDevParam pqDevParam) {
String methodDescribe = getMethodDescribe("add"); String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, pqDevParam); LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, pqDevParam);
boolean result = pqDevService.addPqDev(pqDevParam); boolean result = pqDevService.addPqDev(pqDevParam);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -122,14 +90,14 @@ public class PqDevController extends BaseController {
@PostMapping("/update") @PostMapping("/update")
@ApiOperation("修改被检设备") @ApiOperation("修改被检设备")
@ApiImplicitParam(name = "updateParam", value = "被检设备", required = true) @ApiImplicitParam(name = "updateParam", value = "被检设备", required = true)
public HttpResult<Object> update(@RequestBody @Validated PqDevParam.UpdateParam updateParam) { public HttpResult<Boolean> update(@RequestBody @Validated PqDevParam.UpdateParam updateParam) {
String methodDescribe = getMethodDescribe("update"); String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam); LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
boolean result = pqDevService.updatePqDev(updateParam); boolean result = pqDevService.updatePqDev(updateParam);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -137,35 +105,25 @@ public class PqDevController extends BaseController {
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation("删除被检设备") @ApiOperation("删除被检设备")
@ApiImplicitParam(name = "ids", value = "被检设备id", required = true) @ApiImplicitParam(name = "ids", value = "被检设备id", required = true)
public HttpResult<Object> delete(@RequestBody @Validated PqDevParam.DeleteParam param) { public HttpResult<Boolean> delete(@RequestBody @Validated PqDevParam.DeleteParam param) {
String methodDescribe = getMethodDescribe("delete"); String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, param.getIds())); LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, param.getIds()));
boolean result = pqDevService.deletePqDev(param); boolean result = pqDevService.deletePqDev(param);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/export") @PostMapping("/export")
@ApiOperation("导出被检设备数据") @ApiOperation("批量导出被检设备")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true) @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public void export(@RequestBody @Validated PqDevParam.QueryParam queryParam) { public void exportDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("export"); String methodDescribe = getMethodDescribe("exportDev");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
DictData dictData = dictDataService.getDictDataById(queryParam.getPattern()); pqDevService.exportDev(queryParam);
if (ObjectUtil.isNotNull(dictData)) {
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
List<PqDevExcel.ContrastExportData> data = pqDevService.getContrastExportData(queryParam);
ExcelUtil.exportExcel("被检设备导出数据.xlsx", PqDevExcel.ContrastExportData.class, data);
} else {
List<PqDevExcel.SimulateOrDigitalExportData> data = pqDevService.getSimulateOrDigitExportData(queryParam);
ExcelUtil.exportExcel("被检设备导出数据.xlsx", PqDevExcel.SimulateOrDigitalExportData.class, data);
}
}
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@@ -176,105 +134,20 @@ public class PqDevController extends BaseController {
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping(value = "/importContrast") @PostMapping(value = "/import")
@ApiOperation("批量导入被检设备数据") @ApiOperation("批量导入被检设备")
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
public HttpResult<Object> importContrastData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importContrastData");
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
ImportParams params = new ImportParams();
params.setHeadRows(2);
params.setNeedVerify(true);
params.setStartSheetIndex(0);
params.setSheetNum(1);
try {
ExcelImportResult<PqDevExcel.ContrastImportData> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ContrastImportData.class, params);
//如果存在非法数据,将不合格的数据导出
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
Workbook failWorkbook = excelImportResult.getFailWorkbook();
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
} else {
//批量录入数据
List<PqDevExcel.ContrastImportData> list = excelImportResult.getList();
pqDevService.importContrastData(list);
}
} catch (Exception e) {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 导出灿能二楼设备
*
* @param queryParam
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/exportCNDev")
@ApiOperation("导出被检设备数据")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public void exportCNDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("exportCNDev");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
pqDevService.exportCNDev(queryParam);
}
/**
* 下载灿能二楼设备导入文件模板
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadCNDevTemplate")
@ApiOperation("下载被检设备导入文件模板")
public void downloadCNDevTemplate() {
pqDevService.downloadCNDevTemplate();
}
/**
* 导入灿能二楼设备
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping(value = "/importCNDev")
@ApiOperation("批量导入设备数据")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true), @ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
@ApiImplicitParam(name = "patternId", value = "模式id", required = true) @ApiImplicitParam(name = "patternId", value = "模式id", required = true)
}) })
public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file,@RequestParam("patternId") String patternId, HttpServletResponse response) { public HttpResult<Object> importDev(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importCNDev"); String methodDescribe = getMethodDescribe("importDev");
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename()); LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename()); boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
if (!fileType) { if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR); throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
} }
pqDevService.importDev(file, patternId, null, response);
ImportParams params = new ImportParams();
params.setStartSheetIndex(0);
params.setSheetNum(1);
params.setHeadRows(1);
params.setNeedVerify(true);
List<CNDevExcel> cnDevExcelList;
try {
ExcelImportResult<CNDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), CNDevExcel.class, params);
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
Workbook failWorkbook = excelImportResult.getFailWorkbook();
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
return null;
} else {
cnDevExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
}
if (ObjectUtil.isNotEmpty(cnDevExcelList)) {
pqDevService.importCNDev(cnDevExcelList, patternId, null);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -309,34 +182,4 @@ public class PqDevController extends BaseController {
}); });
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); 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<List<PqDev>> 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, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
// @OperateInfo(operateType = OperateType.UPDATE)
// @PostMapping("/bindDev")
// @ApiOperation("检测计划绑定设备")
// @ApiImplicitParam(name = "bindPlanParam", value = "绑定参数", required = true)
// public HttpResult<Object> bindDev(@RequestBody @Validated PqDevParam.BindPlanParam bindPlanParam) {
// String methodDescribe = getMethodDescribe("bindDev");
// LogUtil.njcnDebug(log, "{}绑定计划数据为planId={}, pqDevIds={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
// boolean result = pqDevService.bind(bindPlanParam.getPlanId(), bindPlanParam.getPqDevIds());
// if (result) {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
// } else {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
// }
// }
} }

View File

@@ -26,8 +26,27 @@ public interface PqDevMapper extends MPJBaseMapper<PqDev> {
void updateReportState(@Param("id")String id); void updateReportState(@Param("id")String id);
/**
* 修改检测计划的检测结果
*
* @param planId
* @param checkResult
*/
void updatePlanCheckResult(@Param("planId")String planId, @Param("checkResult")Integer checkResult); void updatePlanCheckResult(@Param("planId")String planId, @Param("checkResult")Integer checkResult);
/**
* 修改检测计划的检测状态
*
* @param planId
* @param testState
*/
void updatePlanTestState(@Param("planId")String planId, @Param("testState")Integer testState); void updatePlanTestState(@Param("planId")String planId, @Param("testState")Integer testState);
/**
* 根据计划id获取脚本id
*
* @param planId
*/
String getScriptIdByPlanId(String planId);
} }

View File

@@ -66,6 +66,8 @@
update ad_plan set Test_State = #{testState} where id = #{planId} update ad_plan set Test_State = #{testState} where id = #{planId}
</update> </update>
<select id="getScriptIdByPlanId" resultType="java.lang.String">
SELECT Script_Id FROM ad_plan WHERE id = #{planId}
</select>
</mapper> </mapper>

View File

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

View File

@@ -1,37 +0,0 @@
package com.njcn.gather.device.pojo.enums;
import lombok.Getter;
@Getter
public enum DevResponseEnum {
//NAME_REPEAT("A001001", "名称重复"),
IMPORT_DATA_FAIL("A001002", "导入数据失败"),
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "当为加密设备时,加密设备的序列号和设备密钥不能为空"),
PQ_SOURCE_GEN_NAME_ERROR("A001004", "检测源生成名称出错"),
ERR_SOURCE_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),
PQ_ERRSYS_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),
PLAN_HAS_DEVICE_BIND("A001006", "检测计划下已绑定设备,请先解绑设备"),
PQ_DEV_REPEAT("A001007", "重复的被检设备"),
PQ_DEV_HAS_MONITOR("A001008", "该设备下关联有监测点,请先移除监测点"),
HAS_NOT_UNCHECKED_DEVICE("A001009", "设备在检测中或已被检测过,请勿解除绑定"),
IMPORT_PLAN_DATA_FAIL("A001010", "导入的检测计划为空"),
IMPORT_DATA_FORMAT_FAIL("A001011", "导入数据格式错误"),
IMPORT_SOURCE_ERROR("A001012","当前模式下一个检测计划只能有一个检测源" ),
IMPORT_DATASOURCE_ERROR("A001013","当前模式下一个检测计划只能有一个数据源" ),
DEV_UN_CHECKED("A001013","装置还未检测完成!" ),
DEV_UN_REPORT("A001013","装置报告未生成!" ),
DEVICE_DIS_ERROR("A001014","装置配置异常" ),
DEVICE_DELETE("A001015","设备无法删除,已绑定计划!" )
;
private final String message;
private final String code;
DevResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -2,7 +2,7 @@ package com.njcn.gather.device.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.monitor.pojo.param.PqMonitorParam; import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
import com.njcn.gather.device.pojo.constant.DevValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid; import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -22,61 +22,55 @@ import java.util.List;
public class PqDevParam { public class PqDevParam {
@ApiModelProperty(value = "名称", required = true) @ApiModelProperty(value = "名称", required = true)
//@NotBlank(message = DevValidMessage.NAME_NOT_BLANK) @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
//@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
private String name; private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true) @ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK) @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
private String pattern; private String pattern;
@ApiModelProperty(value = "设备类型,字典表", required = true) @ApiModelProperty(value = "设备类型,字典表", required = true)
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_TYPE_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_TYPE_FORMAT_ERROR)
private String devType; private String devType;
@ApiModelProperty(value = "设备厂家,字典表", required = true) @ApiModelProperty(value = "设备厂家,字典表", required = true)
//@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR)
private String manufacturer; private String manufacturer;
@ApiModelProperty(value = "出厂日期", required = true) @ApiModelProperty(value = "出厂日期", required = true)
//@NotBlank(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
//@DateTimeStrValid(format = "yyyy-MM-dd", message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate; private String createDate;
@ApiModelProperty(value = "设备序列", required = true) @ApiModelProperty(value = "装置编", required = true)
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK) @NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_CREATE_ID_REGEX, message = DetectionValidMessage.DEV_CREATE_ID_FORMAT_ERROR)
private String createId; private String createId;
@ApiModelProperty(value = "固件版本", required = true) @ApiModelProperty(value = "固件版本", required = true)
//@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion; private String hardwareVersion;
@ApiModelProperty(value = "软件版本", required = true) @ApiModelProperty(value = "软件版本", required = true)
//@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion; private String softwareVersion;
@ApiModelProperty(value = "通讯协议", required = true) @ApiModelProperty(value = "通讯协议", required = true)
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK) @NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PROTOCOL_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PROTOCOL_FORMAT_ERROR)
private String protocol; private String protocol;
@ApiModelProperty(value = "IP地址", required = true) @ApiModelProperty(value = "IP地址", required = true)
@NotBlank(message = DevValidMessage.IP_NOT_BLANK) @NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR) @Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
private String ip; private String ip;
@ApiModelProperty(value = "端口号", required = true) @ApiModelProperty(value = "端口号", required = true)
@NotNull(message = DevValidMessage.PORT_NOT_NULL) @NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR) @Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
private Integer port; private Integer port;
@ApiModelProperty(value = "装置是否为加密版本", required = true) @ApiModelProperty(value = "装置是否为加密版本", required = true)
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL) @NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
@Min(value = 0, message = DevValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
@Max(value = 1, message = DevValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR) @Max(value = 1, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
private Integer encryptionFlag; private Integer encryptionFlag;
@ApiModelProperty("装置识别码3ds加密") @ApiModelProperty("装置识别码3ds加密")
@@ -89,7 +83,7 @@ public class PqDevParam {
private String sampleId; private String sampleId;
@ApiModelProperty(value = "送样日期") @ApiModelProperty(value = "送样日期")
@DateTimeStrValid(message = DevValidMessage.ARRIVE_DATE_FORMAT_ERROR) @DateTimeStrValid(message = DetectionValidMessage.ARRIVE_DATE_FORMAT_ERROR)
private String arrivedDate; private String arrivedDate;
@ApiModelProperty("所属地市名称") @ApiModelProperty("所属地市名称")
@@ -108,14 +102,12 @@ public class PqDevParam {
private String qrCode; private String qrCode;
@ApiModelProperty(value = "检测次数,默认为0", required = true) @ApiModelProperty(value = "检测次数,默认为0", required = true)
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL) @NotNull(message = DetectionValidMessage.RECHECK_NUM_NOT_NULL)
@Min(value = 0, message = DevValidMessage.RECHECK_NUM_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.RECHECK_NUM_FORMAT_ERROR)
private Integer reCheckNum; private Integer reCheckNum;
@ApiModelProperty("是否支持系数校准") @ApiModelProperty("是否支持系数校准")
@Min(value = 0, message = DevValidMessage.FACTOR_FLAG_FORMAT_ERROR) private Integer factorFlag;
@Max(value = 1, message = DevValidMessage.FACTOR_FLAG_FORMAT_ERROR)
private String factorFlag;
@ApiModelProperty("监测点台账列表") @ApiModelProperty("监测点台账列表")
@Valid @Valid
@@ -123,13 +115,13 @@ public class PqDevParam {
@ApiModelProperty("icdId") @ApiModelProperty("icdId")
private String icdId; private String icdId;
//
// @ApiModelProperty("power")
// private String power;
@ApiModelProperty("预投计划") @ApiModelProperty("预投计划")
private String preinvestmentPlan; private String preinvestmentPlan;
@ApiModelProperty("委托方")
private String delegate;
/** /**
* 更新操作实体 * 更新操作实体
*/ */
@@ -138,29 +130,9 @@ public class PqDevParam {
public static class UpdateParam extends PqDevParam { public static class UpdateParam extends PqDevParam {
@ApiModelProperty(value = "id", required = true) @ApiModelProperty(value = "id", required = true)
@NotBlank(message = DevValidMessage.ID_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id; private String id;
// @ApiModelProperty("检测状态")
// @Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
// @Max(value = 3, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
// private Integer checkState;
//
// @ApiModelProperty("检测结果")
// @Min(value = 0, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
// @Max(value = 2, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
// private Integer checkResult;
//
// @ApiModelProperty("报告状态")
// @Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
// private Integer reportState;
//
// @ApiModelProperty("归档状态")
// @Min(value = 0, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
// @Max(value = 1, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
// private Integer documentState;
} }
/** /**
@@ -170,7 +142,6 @@ public class PqDevParam {
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam { public static class QueryParam extends BaseParam {
@ApiModelProperty("名称") @ApiModelProperty("名称")
// @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
private String name; private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)") @ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)")
@@ -180,22 +151,21 @@ public class PqDevParam {
private String manufacturer; private String manufacturer;
@ApiModelProperty("检测计划ID") @ApiModelProperty("检测计划ID")
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
private String planId; private String planId;
@ApiModelProperty("检测状态列表") @ApiModelProperty("检测状态列表")
private List< private List<
@Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.CHECK_STATE_FORMAT_ERROR)
@Max(value = 3, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR) Integer> checkStateList; @Max(value = 3, message = DetectionValidMessage.CHECK_STATE_FORMAT_ERROR) Integer> checkStateList;
@ApiModelProperty("检测结果") @ApiModelProperty("检测结果")
@Min(value = 0, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.CHECK_RESULT_FORMAT_ERROR)
@Max(value = 2, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR) @Max(value = 2, message = DetectionValidMessage.CHECK_RESULT_FORMAT_ERROR)
private Integer checkResult; private Integer checkResult;
@ApiModelProperty("报告状态") @ApiModelProperty("报告状态")
@Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.REPORT_STATE_FORMAT_ERROR)
@Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR) @Max(value = 2, message = DetectionValidMessage.REPORT_STATE_FORMAT_ERROR)
private Integer reportState; private Integer reportState;
} }
@@ -203,23 +173,23 @@ public class PqDevParam {
@Data @Data
public static class DeleteParam { public static class DeleteParam {
@ApiModelProperty(value = "ids") @ApiModelProperty(value = "ids")
private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR) String> ids; private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR) String> ids;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true) @ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK) @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
private String pattern; private String pattern;
} }
@Data @Data
public static class BindPlanParam { public static class BindPlanParam {
@ApiModelProperty("检测计划ID") @ApiModelProperty("检测计划ID")
@NotNull(message = DevValidMessage.PLAN_ID_NOT_NULL) @NotNull(message = DetectionValidMessage.PLAN_ID_NOT_NULL)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PLAN_ID_FORMAT_ERROR)
private String planId; private String planId;
@ApiModelProperty("被检设备ID列表") @ApiModelProperty("被检设备ID列表")
@NotNull(message = DevValidMessage.PQ_DEV_IDS_NOT_NULL) @NotNull(message = DetectionValidMessage.PQ_DEV_IDS_NOT_NULL)
private List<String> pqDevIds; private List<String> pqDevIds;
} }
} }

View File

@@ -195,8 +195,25 @@ public class PqDev extends BaseEntity implements Serializable {
@TableField("Check_Time") @TableField("Check_Time")
private LocalDateTime checkTime; private LocalDateTime checkTime;
@TableField("Check_By")
private String checkBy;
@TableField("Preinvestment_Plan") @TableField("Preinvestment_Plan")
private String preinvestmentPlan; private String preinvestmentPlan;
/**
* 温度
*/
private Float temperature;
/**
* 相对湿度
*/
private Float humidity;
/**
* 委托方
*/
private String delegate;
} }

View File

@@ -2,9 +2,8 @@ package com.njcn.gather.device.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.Excel;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range; import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@@ -19,42 +18,42 @@ import javax.validation.constraints.Pattern;
public class CNDevExcel { public class CNDevExcel {
@Excel(name = "预投计划*", width = 20, orderNum = "1") @Excel(name = "预投计划*", width = 20, orderNum = "1")
@NotBlank(message = DevValidMessage.PREINVESTMENT_PLAN_NOT_BLANK) @NotBlank(message = DetectionValidMessage.PREINVESTMENT_PLAN_NOT_BLANK)
private String preinvestmentPlan; private String preinvestmentPlan;
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2") @Excel(name = "装置编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK) @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR) @Pattern(regexp = PatternRegex.CN_DEV_NAME_REGEX_IMPORT, message = DetectionValidMessage.CN_DEV_NAME_FORMAT_ERROR)
private String name; private String name;
@Excel(name = "设备类型*", width = 20, orderNum = "3") @Excel(name = "设备类型*", width = 20, orderNum = "3")
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
private String devType; private String devType;
@Excel(name = "通讯协议*", width = 15, orderNum = "4") @Excel(name = "通讯协议*", width = 15, orderNum = "4")
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK) @NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
private String protocol; private String protocol;
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "5") @Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "5")
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL) @NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryptionFlag; private Integer encryptionFlag;
@Excel(name = "识别码", width = 30, orderNum = "6") @Excel(name = "识别码(当加密时必填)", width = 30, orderNum = "6")
private String series; private String series;
@Excel(name = "秘钥", width = 30, orderNum = "7") @Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "7")
private String devKey; private String devKey;
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "8") @Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "8")
private Integer factorFlag; private Integer factorFlag;
@Excel(name = "IP地址*", width = 20, replace = {"否_0", "是_1"}, orderNum = "9") @Excel(name = "IP地址*", width = 20, orderNum = "9")
@NotBlank(message = DevValidMessage.IP_NOT_BLANK) @NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR) @Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
private String ip; private String ip;
@Excel(name = "端口号*", width = 15, orderNum = "10") @Excel(name = "端口号*", width = 15, orderNum = "10")
@NotNull(message = DevValidMessage.PORT_NOT_NULL) @NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR) @Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
private Integer port; private Integer port;
} }

View File

@@ -1,211 +0,0 @@
package com.njcn.gather.device.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
/**
* @author caozehui
* @data 2024/11/7
*/
@Data
public class PqDevExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "名称", width = 20, needMerge = true)
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
private String name;
@Excel(name = "设备类型", width = 20, orderNum = "2", needMerge = true)
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@Excel(name = "设备通道数", width = 20, orderNum = "3", needMerge = true)
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
private Integer devChns;
@Excel(name = "额定电压V", width = 15, orderNum = "4", needMerge = true)
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt;
@Excel(name = "额定电流A", width = 15, orderNum = "5", needMerge = true)
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr;
@Excel(name = "设备厂家", width = 20, orderNum = "6", needMerge = true)
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
@Excel(name = "设备序列号", width = 40, orderNum = "8", needMerge = true)
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
private String createId;
@Excel(name = "固件版本", width = 15, orderNum = "9", needMerge = true)
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion;
@Excel(name = "软件版本", width = 15, orderNum = "10", needMerge = true)
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion;
@Excel(name = "通讯协议", width = 15, orderNum = "11", needMerge = true)
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@Excel(name = "IP地址", width = 20, orderNum = "12", needMerge = true)
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
private String ip;
@Excel(name = "端口号", orderNum = "13", needMerge = true)
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
private Integer port;
@Excel(name = "是否为加密版本(否\\是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14", needMerge = true)
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryptionFlag;
@Excel(name = "识别码(当为加密版本时必填)", width = 30, orderNum = "15", needMerge = true)
private String series;
@Excel(name = "秘钥(当为加密版本时必填)", width = 30, orderNum = "16", needMerge = true)
private String devKey;
@Excel(name = "所属地市名称", width = 20, orderNum = "19", needMerge = true)
private String cityName;
@Excel(name = "所属供电公司名称", width = 20, orderNum = "20", needMerge = true)
private String gdName;
@Excel(name = "所属电站名称", width = 20, orderNum = "21", needMerge = true)
private String subName;
@Excel(name = "关键信息二维码", width = 20, orderNum = "30", needMerge = true)
private String qrCode;
@Excel(name = "检测次数", width = 15, orderNum = "31", needMerge = true)
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
private Integer reCheckNum;
@Data
@EqualsAndHashCode(callSuper = true)
public static class ExportData extends PqDevExcel {
@Excel(name = "设备模式", width = 20, orderNum = "1", needMerge = true)
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
private String pattern;
@Excel(name = "出厂日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "7", needMerge = true)
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
private LocalDate createDate;
@Excel(name = "是否支持系数校准(否\\是)", width = 15, replace = {"否_0", "是_1"}, orderNum = "22", needMerge = true)
private Integer factorFlag;
@Excel(name = "守时检测结果(不合格\\合格\\/", replace = {"不合格_0", "合格_1", "/_2"}, width = 15, orderNum = "23", needMerge = true)
private Integer timeCheckResult;
@Excel(name = "系数校准结果(不合格\\合格\\/", width = 15, replace = {"不合格_0", "合格_1", "/_2"}, orderNum = "24", needMerge = true)
private Integer factorCheckResult;
@Excel(name = "检测状态(未检\\检测中\\检测完成\\归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "25", needMerge = true)
private Integer checkState;
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 15, replace = {"不符合_0", "符合_1", "未检_2"}, orderNum = "26", needMerge = true)
private Integer checkResult;
@Excel(name = "报告状态(未生成\\已生成\\未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "27", needMerge = true)
private Integer reportState;
// @Excel(name = "归档状态(未归档\\归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "28", needMerge = true)
// private Integer documentState;
@Excel(name = "报告路径", width = 20, orderNum = "29", needMerge = true)
private String reportPath;
}
/**
* 模拟式和比对式设备导出数据
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class SimulateOrDigitalExportData extends ExportData {
@Excel(name = "样品编号", width = 40, orderNum = "17", needMerge = true)
private String sampleId;
@Excel(name = "送样日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "18", needMerge = true)
private LocalDate arrivedDate;
}
/**
* 比对式设备导出数据
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class ContrastExportData extends ExportData {
@ExcelCollection(name = "检测点台账", orderNum = "32")
List<PqMonitorExcel.ExportData> monitorList;
}
/**
* 被检设备导入数据
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class ImportData extends PqDevExcel {
@Excel(name = "出厂日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "7", needMerge = true)
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
@DateTimeStrValid(message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate;
@Excel(name = "是否支持系数校准(否\\是)", width = 15, replace = {"否_0", "是_1"}, orderNum = "22", needMerge = true)
@NotBlank(message = DevValidMessage.FACTOR_FLAG_NOT_BLANK)
private String factorFlag;
}
/**
* 模拟式和比对式设备导入数据
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class SimulateOrDigitalImportData extends ImportData {
@Excel(name = "样品编号", width = 40, orderNum = "17", needMerge = true)
private String sampleId;
@Excel(name = "送样日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "18", needMerge = true)
@DateTimeStrValid(message = DevValidMessage.ARRIVE_DATE_FORMAT_ERROR)
private String arrivedDate;
}
/**
* 对比式设备导入数据
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class ContrastImportData extends ImportData {
@ExcelCollection(name = "检测点台账", orderNum = "32")
List<PqMonitorExcel.ImportData> monitorList;
}
}

View File

@@ -0,0 +1,87 @@
package com.njcn.gather.device.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;
/**
* @author caozehui
* @data 2024/11/7
* @description 省级平台设备Excel导入导出实体类
*/
@Data
public class ProvinceDevExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "装置编号*", width = 20)
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
private String createId;
@Excel(name = "设备名称*", width = 20, orderNum = "2")
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
private String name;
@Excel(name = "设备类型*", width = 20, orderNum = "3")
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@Excel(name = "设备厂家*", width = 20, orderNum = "7")
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
@Excel(name = "出厂日期yyyy-MM-dd*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
@NotNull(message = DetectionValidMessage.CREATEDATETIME_NOT_NULL)
private LocalDate createDate;
@Excel(name = "固件版本", width = 15, orderNum = "9")
private String hardwareVersion;
@Excel(name = "软件版本", width = 15, orderNum = "10")
private String softwareVersion;
@Excel(name = "通讯协议*", width = 15, orderNum = "11")
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "12")
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryptionFlag;
@Excel(name = "识别码(当加密时必填)", width = 30, orderNum = "13")
private String series;
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "14")
private String devKey;
// @Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "15")
// private Integer factorFlag;
@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 = "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

@@ -2,15 +2,18 @@ package com.njcn.gather.device.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.common.pojo.poi.PullDown;
import com.njcn.gather.device.pojo.enums.TimeCheckResultEnum; import com.njcn.gather.device.pojo.enums.TimeCheckResultEnum;
import com.njcn.gather.device.pojo.param.PqDevParam; import com.njcn.gather.device.pojo.param.PqDevParam;
import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.CNDevExcel; import com.njcn.gather.device.pojo.vo.CNDevExcel;
import com.njcn.gather.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.pojo.vo.PqDevVO; import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.pojo.vo.PreDetection; import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -67,7 +70,7 @@ public interface IPqDevService extends IService<PqDev> {
* @param queryParam 查询参数 * @param queryParam 查询参数
* @return * @return
*/ */
List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam); //List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam);
/** /**
* 获取比对式设备导出时所需的数据 * 获取比对式设备导出时所需的数据
@@ -75,26 +78,21 @@ public interface IPqDevService extends IService<PqDev> {
* @param queryParam 查询参数 * @param queryParam 查询参数
* @return 比对式设备导出时所需的数据 * @return 比对式设备导出时所需的数据
*/ */
List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam); //List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam);
/**
* 下载模板文件
*/
void downloadTemplate();
/** /**
* 批量导入被检设备信息 * 批量导入被检设备信息
* *
* @param sgEventExcels 批量导入的数据 * @param sgEventExcels 批量导入的数据
*/ */
void importContrastData(List<PqDevExcel.ContrastImportData> sgEventExcels); //void importContrastData(List<PqDevExcel.ContrastImportData> sgEventExcels);
/** /**
* 批量导入被检设备信息 * 批量导入被检设备信息
* *
* @param sgEventExcels 批量导入的数据 * @param sgEventExcels 批量导入的数据
*/ */
void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels); //void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels);
/** /**
* 获取所有未绑定的设备 * 获取所有未绑定的设备
@@ -121,14 +119,6 @@ public interface IPqDevService extends IService<PqDev> {
*/ */
Integer bind(String planId, List<String> devIds); Integer bind(String planId, List<String> devIds);
/**
* 获取饼图数据
*
* @param planId 检测计划id
* @return 饼图数据
*/
//List<List<Map<String, Object>>> getPieData(String planId);
/** /**
* 根据id获取被检设备信息 * 根据id获取被检设备信息
* *
@@ -137,25 +127,6 @@ public interface IPqDevService extends IService<PqDev> {
*/ */
PqDevVO getPqDevById(String id); PqDevVO getPqDevById(String id);
/**
* 获取所有非未检测状态的设备
*
* @return 所有非未检测状态的设备列表
*/
List<PqDev> listUnchecked();
/**
* 可视化各种id回显字典值解码等操作
*
* @param sourceList
*/
void visualize(List<PqDev> sourceList);
/**
* 逆向可视化
*/
void reverseVisualize(List<PqDev> sourceList);
/** /**
* 获取装置信息和装置下监测点信息 * 获取装置信息和装置下监测点信息
* *
@@ -166,14 +137,6 @@ public interface IPqDevService extends IService<PqDev> {
*/ */
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds); List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
/**
* 设备归档操作
*
* @param id 设备id
* @return 归档成功返回true否则返回false
*/
boolean documented(List<String> id);
/** /**
* 正式监测完成,修改中断状态 * 正式监测完成,修改中断状态
@@ -181,35 +144,17 @@ public interface IPqDevService extends IService<PqDev> {
* @param ids * @param ids
* @param valueType * @param valueType
* @param code * @param code
* @param userId
* @param temperature
* @param humidity
* @return * @return
*/ */
boolean updateResult(List<String> ids, List<String> valueType, String code); boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity);
void updatePqDevReportState(String devId, int i); void updatePqDevReportState(String devId, int i);
int countUnReportDev(String planId); int countUnReportDev(String planId);
/**
* 导出灿能二楼设备数据
*
* @param queryParam
*/
void exportCNDev(PqDevParam.QueryParam queryParam);
/**
* 下载灿能二楼设备模板文件
*/
void downloadCNDevTemplate();
/**
* 导入灿能二楼设备数据
*
* @param cnDevExcelList 灿能二楼设备数据列表
* @param patternId 模式Id
* @param planId 计划Id
*/
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
/** /**
* 根据计划id列表获取设备列表 * 根据计划id列表获取设备列表
* *
@@ -218,6 +163,47 @@ public interface IPqDevService extends IService<PqDev> {
*/ */
List<PqDev> listByPlanIds(List<String> planIds); List<PqDev> listByPlanIds(List<String> planIds);
/**
* 导出设备数据
*
* @param queryParam
*/
void exportDev(PqDevParam.QueryParam queryParam);
/**
* 下载模板文件
*/
void downloadTemplate();
/**
* 导入设备数据
*
* @param file 上传的文件
* @param patternId 模式Id
* @param planId 计划Id
* @param response 响应
*/
void importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
/**
* 导入灿能二楼设备数据
*
* @param file 上传的文件
* @param patternId 模式Id
* @param planId 计划Id
* @param response 响应
*/
void importCNDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
/**
* 导入灿能二楼设备数据
*
* @param cnDevExcelList
* @param patternId
* @param planId
*/
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
/** /**
* 可视化-灿能二楼设备 * 可视化-灿能二楼设备
* *
@@ -232,4 +218,53 @@ public interface IPqDevService extends IService<PqDev> {
* @param patternId 模式Id * @param patternId 模式Id
*/ */
void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId); void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId);
/**
* 导入省级平台设备数据
*
* @param file 上传的文件
* @param patternId 模式Id
* @param planId 计划Id
* @param response 响应
*/
void importProvinceDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
/**
* 导入省级平台设备数据
*
* @param proviceDevExcelList
* @param patternId
* @param planId
*/
void importProvinceDev(List<ProvinceDevExcel> proviceDevExcelList, String patternId, String planId);
/**
* 可视化-省级平台设备
*
* @param pqDevs
*/
void visualizeProvinceDev(List<PqDev> pqDevs);
/**
* 逆向可视化-省级平台设备
*
* @param pqDevs 设备列表
* @param patternId 模式Id
*/
void reverseVisualizeProvinceDev(List<PqDev> pqDevs, String patternId);
/**
* 获取省级平台设备导出、导出文件模板的下拉列表
*
* @return
*/
List<PullDown> getProvinceDevPullDownList(int startCol);
/**
* 获取灿能二楼设备导出、导出文件模板的下拉列表
*
* @param startCol 开始列
* @return
*/
List<PullDown> getCNDevPullDownList(int startCol);
} }

View File

@@ -63,14 +63,14 @@ public class PqErrSysController extends BaseController {
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新增误差体系") @ApiOperation("新增误差体系")
@ApiImplicitParam(name = "param", value = "误差体系", required = true) @ApiImplicitParam(name = "param", value = "误差体系", required = true)
public HttpResult<Object> add(@RequestBody @Validated PqErrSysParam param) { public HttpResult<Boolean> add(@RequestBody @Validated PqErrSysParam param) {
String methodDescribe = getMethodDescribe("add"); String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = pqErrSysService.addPqErrSys(param); boolean result = pqErrSysService.addPqErrSys(param);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -78,14 +78,14 @@ public class PqErrSysController extends BaseController {
@PostMapping("/update") @PostMapping("/update")
@ApiOperation("修改误差体系") @ApiOperation("修改误差体系")
@ApiImplicitParam(name = "param", value = "误差体系", required = true) @ApiImplicitParam(name = "param", value = "误差体系", required = true)
public HttpResult<Object> update(@RequestBody @Validated PqErrSysParam.UpdateParam param) { public HttpResult<Boolean> update(@RequestBody @Validated PqErrSysParam.UpdateParam param) {
String methodDescribe = getMethodDescribe("update"); String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
boolean result = pqErrSysService.updatePqErrSys(param); boolean result = pqErrSysService.updatePqErrSys(param);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -93,14 +93,14 @@ public class PqErrSysController extends BaseController {
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation("删除误差体系") @ApiOperation("删除误差体系")
@ApiImplicitParam(name = "ids", value = "误差体系id", required = true) @ApiImplicitParam(name = "ids", value = "误差体系id", required = true)
public HttpResult<Object> delete(@RequestBody List<String> ids) { public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete"); String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids)); LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = pqErrSysService.deletePqErrSys(ids); boolean result = pqErrSysService.deletePqErrSys(ids);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -125,19 +125,19 @@ public class PqErrSysController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
// @OperateInfo(operateType = OperateType.ADD) @OperateInfo(operateType = OperateType.ADD)
// @GetMapping("/copy") @GetMapping("/copy")
// @ApiOperation("复制误差体系") @ApiOperation("复制误差体系")
// @ApiImplicitParam(name = "id", value = "误差体系id", required = true) @ApiImplicitParam(name = "id", value = "误差体系id", required = true)
// public HttpResult<Object> copy(@RequestParam("id") String id) { public HttpResult<Boolean> copy(@RequestParam("id") String id) {
// String methodDescribe = getMethodDescribe("copy"); String methodDescribe = getMethodDescribe("copy");
// LogUtil.njcnDebug(log, "{}复制ID为{}", methodDescribe, id); LogUtil.njcnDebug(log, "{}复制ID为{}", methodDescribe, id);
// boolean result = pqErrSysService.copyPqErrSys(id); boolean result = pqErrSysService.copyPqErrSys(id);
// if (result) { if (result) {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
// } else { } else {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
// } }
// } }
} }

View File

@@ -1,20 +0,0 @@
package com.njcn.gather.err.pojo.enums;
import lombok.Getter;
/**
* @author caozehui
* @data 2025-03-10
*/
@Getter
public enum ErrResponseEnum {
ERR_SYS_BOUND_NOT_DELETE("A100001","误差体系已被计划所绑定,无法删除!");
private String code;
private String message;
ErrResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.err.pojo.param; package com.njcn.gather.err.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -17,13 +17,13 @@ import javax.validation.constraints.Pattern;
public class PqErrSysDtlsParam { public class PqErrSysDtlsParam {
@ApiModelProperty(value = "误差项类型", required = true) @ApiModelProperty(value = "误差项类型", required = true)
@NotBlank(message = DevValidMessage.ERR_SYS_DTLS_ERROR_TYPE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ERR_SYS_DTLS_ERROR_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERR_SYS_DTLS_ERROR_TYPE_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ERR_SYS_DTLS_ERROR_TYPE_FORMAT_ERROR)
private String errorType; private String errorType;
@ApiModelProperty(value = "脚本项类型", required = true) @ApiModelProperty(value = "脚本项类型", required = true)
@NotBlank(message = DevValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR)
private String scriptType; private String scriptType;
@ApiModelProperty(value = "误差判断起始值", required = true) @ApiModelProperty(value = "误差判断起始值", required = true)
@@ -38,24 +38,25 @@ public class PqErrSysDtlsParam {
@ApiModelProperty(value = "是否包含结束值", required = true) @ApiModelProperty(value = "是否包含结束值", required = true)
private Integer endFlag; private Integer endFlag;
// @ApiModelProperty(value = "单位", required = true)
// @NotBlank(message = DeviceValidMessage.UNIT_NOT_BLANK)
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.UNIT_FORMAT_ERROR)
// private String unit;
@ApiModelProperty(value = "判断条件值类型", required = true) @ApiModelProperty(value = "判断条件值类型", required = true)
private Integer conditionType; private Integer conditionType;
@ApiModelProperty(value = "最大值误差", required = true) @ApiModelProperty(value = "最大值误差", required = true)
@NotNull(message = DevValidMessage.MAX_ERROR_VALUE_NOT_NULL) @NotNull(message = DetectionValidMessage.MAX_ERROR_VALUE_NOT_NULL)
private Double maxErrorValue; private Double maxErrorValue;
@ApiModelProperty(value = "误差值类型", required = true) @ApiModelProperty(value = "误差值类型", required = true)
@NotNull(message = DevValidMessage.ERROR_VALUE_TYPE_NOT_BLANK) @NotNull(message = DetectionValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
private Integer errorValueType; private Integer errorValueType;
@ApiModelProperty("排序") @ApiModelProperty("排序")
@NotNull(message = DevValidMessage.SORT_NOT_NULL) @NotNull(message = DetectionValidMessage.SORT_NOT_NULL)
private Integer sort; private Integer sort;
@ApiModelProperty("1绝对值、2相对值")
private Integer valueType;
@ApiModelProperty("误差单位")
private String errorUnit;
} }

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.err.pojo.param; package com.njcn.gather.err.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid; import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -20,39 +20,38 @@ import java.util.List;
public class PqErrSysParam { public class PqErrSysParam {
@ApiModelProperty(value = "参照标准名称", required = true) @ApiModelProperty(value = "参照标准名称", required = true)
@NotBlank(message = DevValidMessage.STANDARD_NAME_NOT_BLANK) @NotBlank(message = DetectionValidMessage.STANDARD_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.STANDARD_NAME_FORMAT_ERROR) @Pattern(regexp = PatternRegex.ERR_SYS_NAME_REGEX, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
private String standardName; private String standardName;
@ApiModelProperty(value = "标准实施年份", required = true) @ApiModelProperty(value = "标准实施年份", required = true)
@NotBlank(message = DevValidMessage.STANDARD_TIME_NOT_BLANK) @NotBlank(message = DetectionValidMessage.STANDARD_TIME_NOT_BLANK)
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR) @DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
private String standardTime; private String standardTime;
@ApiModelProperty(value = "设备等级", required = true) @ApiModelProperty(value = "设备等级", required = true)
@NotBlank(message = DevValidMessage.DEV_LEVEL_NOT_BLANK) @NotBlank(message = DetectionValidMessage.DEV_LEVEL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_LEVEL_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_LEVEL_FORMAT_ERROR)
private String devLevel; private String devLevel;
@ApiModelProperty("状态") @ApiModelProperty("状态")
@NotNull(message = DevValidMessage.ENABLE_NOT_NULL) @NotNull(message = DetectionValidMessage.ENABLE_NOT_NULL)
@Min(value = 0, message = DevValidMessage.ENABLE_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
@Max(value = 1, message = DevValidMessage.ENABLE_FORMAT_ERROR) @Max(value = 1, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
private Integer enable; private Integer enable;
@ApiModelProperty(value = "误差详情列表", required = true) @ApiModelProperty(value = "误差详情列表", required = true)
@Valid
private List<PqErrSysDtlsParam> pqErrSysDtlsList; private List<PqErrSysDtlsParam> pqErrSysDtlsList;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public static class QueryParam extends BaseParam { public static class QueryParam extends BaseParam {
@ApiModelProperty("标准实施年份") @ApiModelProperty("标准实施年份")
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR) @DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
private String standardTime; private String standardTime;
@ApiModelProperty("设备等级") @ApiModelProperty("设备等级")
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_LEVEL_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_LEVEL_FORMAT_ERROR)
private String devLevel; private String devLevel;
} }
@@ -60,14 +59,14 @@ public class PqErrSysParam {
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public static class UpdateParam extends PqErrSysParam { public static class UpdateParam extends PqErrSysParam {
@ApiModelProperty("id") @ApiModelProperty("id")
@NotBlank(message = DevValidMessage.ID_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id; private String id;
} }
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public static class DetectionParam{ public static class DetectionParam {
@ApiModelProperty("所属误差体系ID") @ApiModelProperty("所属误差体系ID")
private String errorSysId; private String errorSysId;

View File

@@ -60,10 +60,6 @@ public class PqErrSysDtls implements Serializable {
*/ */
private Integer endFlag; private Integer endFlag;
/**
* 单位
*/
// private String unit;
/** /**
* 判断条件值类型(包括值类型,绝对值、相对值) * 判断条件值类型(包括值类型,绝对值、相对值)
@@ -77,7 +73,7 @@ public class PqErrSysDtls implements Serializable {
private Double maxErrorValue; private Double maxErrorValue;
/** /**
* 误差值类型 * 误差值类型(绝对值:0:标称值 1:标准值 2:值比较 相对值:0标称值 1:标准值)
*/ */
private Integer errorValueType; private Integer errorValueType;
@@ -86,5 +82,14 @@ public class PqErrSysDtls implements Serializable {
*/ */
private Integer sort; private Integer sort;
/**
* 1绝对值、2相对值
*/
private Integer valueType;
/**
* 误差单位
*/
private String errorUnit;
} }

View File

@@ -38,6 +38,11 @@ public class ErrDtlsCheckDataVO implements Serializable {
*/ */
private String phase; private String phase;
/**
* 默认参与比较值4.不参与值 5.不参与误差比较)
*/
private Integer isQualified;
/** /**
* 误差体系 * 误差体系
*/ */

View File

@@ -78,5 +78,5 @@ public interface IPqErrSysService extends IService<PqErrSys> {
* @param id 误差体系id * @param id 误差体系id
* @return 成功返回true失败返回false * @return 成功返回true失败返回false
*/ */
//boolean copyPqErrSys(String id); boolean copyPqErrSys(String id);
} }

View File

@@ -44,7 +44,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean addPqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) { public boolean addPqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) {
List<PqErrSysDtls> data = new ArrayList<>(); List<PqErrSysDtls> data = new ArrayList<>();
for (PqErrSysDtlsParam param : list) { for (PqErrSysDtlsParam param : list) {
@@ -57,7 +57,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean updatePqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) { public boolean updatePqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) {
//先按照pqErrSysId全部删除 //先按照pqErrSysId全部删除
this.deletePqErrSysDtlsByPqErrSysId(Collections.singletonList(pqErrSysId)); this.deletePqErrSysDtlsByPqErrSysId(Collections.singletonList(pqErrSysId));
@@ -67,7 +67,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean deletePqErrSysDtlsByPqErrSysId(List<String> pqErrSysIds) { public boolean deletePqErrSysDtlsByPqErrSysId(List<String> pqErrSysIds) {
QueryWrapper<PqErrSysDtls> queryWrapper = new QueryWrapper<>(); QueryWrapper<PqErrSysDtls> queryWrapper = new QueryWrapper<>();
queryWrapper.in("pq_err_sys_dtls.Error_Sys_Id", pqErrSysIds); queryWrapper.in("pq_err_sys_dtls.Error_Sys_Id", pqErrSysIds);
@@ -94,34 +94,38 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
@Override @Override
public List<ErrDtlsCheckDataVO> listByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param) { public List<ErrDtlsCheckDataVO> listByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param) {
List<ErrDtlsCheckDataVO> info=new ArrayList<>(); List<ErrDtlsCheckDataVO> info = new ArrayList<>();
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam(); PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
checkDataParam.setScriptId(param.getScriptId()); checkDataParam.setScriptId(param.getScriptId());
checkDataParam.setIndex(param.getIndex()); checkDataParam.setIndex(param.getIndex());
//获取检测脚本中所有装置下发的测试项
List<PqScriptCheckData> list = pqScriptCheckDataService.listCheckDataCode(checkDataParam); List<PqScriptCheckData> list = pqScriptCheckDataService.listCheckDataCode(checkDataParam);
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId()); Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
List<String> valueType = list.stream().filter(x->x.getErrorFlag()!=0).map(PqScriptCheckData::getValueType).collect(Collectors.toList()); Map<String, Integer> valueType = list.stream().collect(Collectors.toMap(PqScriptCheckData::getValueType, PqScriptCheckData::getErrorFlag,
Map<String, List<PqErrSysDtls>> errMap =new HashMap<>(3); (key1, key2) -> key1));
if(CollUtil.isNotEmpty(valueType)){
//获取误差体系
Map<String, List<PqErrSysDtls>> errMap = new HashMap<>(3); //key为误差详情的ScriptTypevalue为List<PqErrSysDtls>
if (CollUtil.isNotEmpty(valueType)) {
List<PqErrSysDtls> errSysDtls = this.list(new MPJLambdaWrapper<PqErrSysDtls>().selectAll(PqErrSysDtls.class) List<PqErrSysDtls> errSysDtls = this.list(new MPJLambdaWrapper<PqErrSysDtls>().selectAll(PqErrSysDtls.class)
.selectAll(PqErrSysDtls.class) .selectAll(PqErrSysDtls.class)
.selectAs(DictTree::getCode, PqErrSysDtls::getScriptCode) .selectAs(DictTree::getCode, PqErrSysDtls::getScriptCode)
.leftJoin(DictTree.class, DictTree::getId, PqErrSysDtls::getScriptType) .leftJoin(DictTree.class, DictTree::getId, PqErrSysDtls::getScriptType)
.eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId()) .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
.in(PqErrSysDtls::getScriptType, valueType) .in(PqErrSysDtls::getScriptType, valueType.keySet())
); );
errMap= errSysDtls.stream().collect(Collectors.groupingBy(PqErrSysDtls::getScriptType)); errMap = errSysDtls.stream().collect(Collectors.groupingBy(PqErrSysDtls::getScriptType));
} }
ErrDtlsCheckDataVO dataVO; ErrDtlsCheckDataVO dataVO;
for (PqScriptCheckData script : list) { for (PqScriptCheckData script : list) {
dataVO=new ErrDtlsCheckDataVO(); dataVO = new ErrDtlsCheckDataVO();
dataVO.setCheckDataId(script.getScriptId()); dataVO.setCheckDataId(script.getScriptId());
dataVO.setValueTypeCode(script.getValueTypeCode()); dataVO.setValueTypeCode(script.getValueTypeCode());
dataVO.setValueType(script.getValueType()); dataVO.setValueType(script.getValueType());
dataVO.setValue(script.getValue()); dataVO.setValue(script.getValue());
dataVO.setPhase(script.getPhase()); dataVO.setPhase(script.getPhase());
if(isValueType){ if (isValueType) {
if (DetectionCodeEnum.VRMS.getCode().equals(script.getValueTypeCode())) { if (DetectionCodeEnum.VRMS.getCode().equals(script.getValueTypeCode())) {
BigDecimal volValue = new BigDecimal(script.getValue()); BigDecimal volValue = new BigDecimal(script.getValue());
BigDecimal result = volValue.multiply(new BigDecimal(param.getUn().toString())) BigDecimal result = volValue.multiply(new BigDecimal(param.getUn().toString()))
@@ -135,10 +139,18 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
dataVO.setValue(result.doubleValue()); dataVO.setValue(result.doubleValue());
} }
} }
if (valueType.containsKey(script.getValueType())) {
if(errMap.containsKey(script.getValueType())){ //默认值4.无法处理 5.不参与误差比较
Integer i = valueType.get(script.getValueType());
if (i == 1) { //参与误差比较
dataVO.setIsQualified(4);
if (errMap.containsKey(script.getValueType())) {
dataVO.setErrSysDtls(errMap.get(script.getValueType())); dataVO.setErrSysDtls(errMap.get(script.getValueType()));
} }
} else { //不参与误差比较
dataVO.setIsQualified(5);
}
}
info.add(dataVO); info.add(dataVO);
} }
return info; return info;

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.err.service.impl; package com.njcn.gather.err.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.text.StrPool; import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -8,14 +9,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.err.mapper.PqErrSysMapper; import com.njcn.gather.err.mapper.PqErrSysMapper;
import com.njcn.gather.err.pojo.enums.ErrResponseEnum; import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
import com.njcn.gather.err.pojo.param.PqErrSysParam; import com.njcn.gather.err.pojo.param.PqErrSysParam;
import com.njcn.gather.err.pojo.po.PqErrSys; import com.njcn.gather.err.pojo.po.PqErrSys;
import com.njcn.gather.err.pojo.po.PqErrSysDtls; import com.njcn.gather.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.err.pojo.vo.PqErrSysDtlsVO; import com.njcn.gather.err.pojo.vo.PqErrSysDtlsVO;
import com.njcn.gather.err.service.IPqErrSysDtlsService; import com.njcn.gather.err.service.IPqErrSysDtlsService;
import com.njcn.gather.err.service.IPqErrSysService; import com.njcn.gather.err.service.IPqErrSysService;
import com.njcn.gather.device.pojo.enums.DevResponseEnum; import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictDataService;
@@ -23,7 +24,6 @@ import com.njcn.gather.system.dictionary.service.IDictTreeService;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -65,8 +65,10 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean addPqErrSys(PqErrSysParam param) { public boolean addPqErrSys(PqErrSysParam param) {
param.setStandardName(param.getStandardName().trim());
this.checkRepeat(param, false);
PqErrSys pqErrSys = new PqErrSys(); PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys); BeanUtils.copyProperties(param, pqErrSys);
String id = UUID.randomUUID().toString().replaceAll("-", ""); String id = UUID.randomUUID().toString().replaceAll("-", "");
@@ -79,9 +81,12 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
return result1 && result2; return result1 && result2;
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) { public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
param.setStandardName(param.getStandardName().trim());
this.checkRepeat(param, true);
PqErrSys pqErrSys = new PqErrSys(); PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys); BeanUtils.copyProperties(param, pqErrSys);
pqErrSys.setName(generateErrSysName(param)); pqErrSys.setName(generateErrSysName(param));
@@ -92,11 +97,11 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean deletePqErrSys(List<String> ids) { public boolean deletePqErrSys(List<String> ids) {
Integer count = this.baseMapper.getCountBoundByIds(ids); Integer count = this.baseMapper.getCountBoundByIds(ids);
if (count > 0) { if (count > 0) {
throw new BusinessException(ErrResponseEnum.ERR_SYS_BOUND_NOT_DELETE); throw new BusinessException(DetectionResponseEnum.ERR_SYS_BOUND_NOT_DELETE);
} }
pqErrSysDtlsService.deletePqErrSysDtlsByPqErrSysId(ids); pqErrSysDtlsService.deletePqErrSysDtlsByPqErrSysId(ids);
this.lambdaUpdate().in(PqErrSys::getId, ids).set(PqErrSys::getState, DataStateEnum.DELETED.getCode()).update(); this.lambdaUpdate().in(PqErrSys::getId, ids).set(PqErrSys::getState, DataStateEnum.DELETED.getCode()).update();
@@ -122,7 +127,9 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
@Override @Override
public List<Map<String, Object>> listAllPqErrSys() { public List<Map<String, Object>> listAllPqErrSys() {
List<PqErrSys> pqErrSysList = this.lambdaQuery().eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).list(); List<PqErrSys> pqErrSysList = this.lambdaQuery()
.eq(PqErrSys::getEnable,DataStateEnum.ENABLE.getCode())
.eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).list();
List<Map<String, Object>> result = pqErrSysList.stream().map(pqErrSys -> { List<Map<String, Object>> result = pqErrSysList.stream().map(pqErrSys -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("id", pqErrSys.getId()); map.put("id", pqErrSys.getId());
@@ -186,29 +193,41 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
if (ObjectUtil.isNotNull(devLevelDictData)) { if (ObjectUtil.isNotNull(devLevelDictData)) {
return param.getStandardName() + "-" + param.getStandardTime() + "-" + devLevelDictData.getName(); return param.getStandardName() + "-" + param.getStandardTime() + "-" + devLevelDictData.getName();
} }
throw new BusinessException(DevResponseEnum.PQ_ERRSYS_GEN_NAME_ERROR); throw new BusinessException(DetectionResponseEnum.PQ_ERRSYS_GEN_NAME_ERROR);
} }
// @Override @Override
// public boolean copyPqErrSys(String id) { public boolean copyPqErrSys(String id) {
// PqErrSys pqErrSys = this.getPqErrSysById(id); PqErrSys pqErrSys = this.getPqErrSysById(id);
// pqErrSys.setId(UUID.randomUUID().toString().replaceAll("-", "")); pqErrSys.setId(UUID.randomUUID().toString().replaceAll("-", ""));
// pqErrSys.setName(pqErrSys.getName() + "_副本"); pqErrSys.setName(pqErrSys.getName() + "_copy");
// pqErrSys.setStandardTime(LocalDate.of(pqErrSys.getStandardTime().getYear(), 1, 1)); pqErrSys.setStandardName(pqErrSys.getStandardName() + "_copy");
// pqErrSys.getPqErrSysDtlsList().forEach(pqErrSysDtls -> pqErrSysDtls.setId(UUID.randomUUID().toString().replaceAll("-", ""))); pqErrSys.setStandardTime(LocalDate.of(pqErrSys.getStandardTime().getYear(), 1, 1));
// return this.save(pqErrSys); List<PqErrSysDtlsParam> pqErrSysDtlsParams = BeanUtil.copyToList(pqErrSys.getPqErrSysDtlsList(), PqErrSysDtlsParam.class);
// } pqErrSysDtlsService.addPqErrSysDtls(pqErrSys.getId(), pqErrSysDtlsParams);
return this.save(pqErrSys);
}
/** /**
* 生成误差体系名称(标准号+年份+设备等级) * 检查重复
* *
* @return 检测源名称 * @param param 检测参数
* @param isExcludeSelf 是否排除自己
*/ */
private String generatePqSourceName(PqErrSysParam param) { private void checkRepeat(PqErrSysParam param, boolean isExcludeSelf) {
DictData devLevel = dictDataService.getDictDataById(param.getDevLevel()); QueryWrapper<PqErrSys> wrapper = new QueryWrapper<>();
if (ObjectUtils.allNotNull(param.getStandardName(), param.getStandardTime(), devLevel)) { wrapper.eq("Standard_Name", param.getStandardName())
return param.getStandardName() + "-" + param.getStandardTime() + "-" + devLevel.getName(); .eq("Standard_Time",param.getStandardTime()+"-01-01")
.eq("Dev_Level",param.getDevLevel())
.eq("state", DataStateEnum.ENABLE.getCode());
if (isExcludeSelf) {
if(param instanceof PqErrSysParam.UpdateParam){
wrapper.ne("Id", ((PqErrSysParam.UpdateParam) param).getId());
}
}
int count = this.count(wrapper);
if (count > 0) {
throw new BusinessException(DetectionResponseEnum.ERR_SYS_REPEAT);
} }
throw new BusinessException(DevResponseEnum.ERR_SOURCE_GEN_NAME_ERROR);
} }
} }

View File

@@ -11,8 +11,6 @@ import com.njcn.common.utils.LogUtil;
import com.njcn.gather.icd.pojo.param.PqIcdPathParam; import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
import com.njcn.gather.icd.pojo.po.PqIcdPath; import com.njcn.gather.icd.pojo.po.PqIcdPath;
import com.njcn.gather.icd.service.IPqIcdPathService; import com.njcn.gather.icd.service.IPqIcdPathService;
import com.njcn.gather.type.pojo.param.DevTypeParam;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -27,16 +25,15 @@ import java.util.List;
/** /**
*
* @author caozehui * @author caozehui
* @date 2025-02-10 * @date 2025-02-10
*/ */
@Slf4j @Slf4j
@Api(tags="icd管理") @Api(tags = "icd管理")
@RestController @RestController
@RequestMapping("/icd") @RequestMapping("/icd")
@RequiredArgsConstructor @RequiredArgsConstructor
public class PqIcdPathController extends BaseController{ public class PqIcdPathController extends BaseController {
private final IPqIcdPathService pqIcdPathService; private final IPqIcdPathService pqIcdPathService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@@ -63,15 +60,15 @@ public class PqIcdPathController extends BaseController{
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新增icd") @ApiOperation("新增icd")
@ApiImplicitParam(name = "param", value = "icd新增参数", required = true) @ApiImplicitParam(name = "param", value = "icd新增参数", required = true)
public HttpResult<String> add(@RequestBody @Validated PqIcdPathParam param) { public HttpResult<Boolean> add(@RequestBody @Validated PqIcdPathParam param) {
String methodDescribe = getMethodDescribe("add"); String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = pqIcdPathService.addIcd(param); boolean result = pqIcdPathService.addIcd(param);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -79,15 +76,15 @@ public class PqIcdPathController extends BaseController{
@PostMapping("/update") @PostMapping("/update")
@ApiOperation("修改icd") @ApiOperation("修改icd")
@ApiImplicitParam(name = "param", value = "icd修改参数", required = true) @ApiImplicitParam(name = "param", value = "icd修改参数", required = true)
public HttpResult<String> update(@RequestBody @Validated PqIcdPathParam.UpdateParam param) { public HttpResult<Boolean> update(@RequestBody @Validated PqIcdPathParam.UpdateParam param) {
String methodDescribe = getMethodDescribe("update"); String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
boolean result = pqIcdPathService.updateIcd(param); boolean result = pqIcdPathService.updateIcd(param);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -95,14 +92,14 @@ public class PqIcdPathController extends BaseController{
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation("删除icd") @ApiOperation("删除icd")
@ApiImplicitParam(name = "ids", value = "icd的id列表", required = true) @ApiImplicitParam(name = "ids", value = "icd的id列表", required = true)
public HttpResult<String> delete(@RequestBody List<String> ids) { public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete"); String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{},删除数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids)); LogUtil.njcnDebug(log, "{},删除数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = pqIcdPathService.deleteIcd(ids); boolean result = pqIcdPathService.deleteIcd(ids);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }

View File

@@ -2,6 +2,7 @@ package com.njcn.gather.icd.mapper;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.icd.pojo.po.PqIcdPath; import com.njcn.gather.icd.pojo.po.PqIcdPath;
import org.apache.ibatis.annotations.Param;
/** /**
* @author caozehui * @author caozehui
@@ -9,5 +10,12 @@ import com.njcn.gather.icd.pojo.po.PqIcdPath;
*/ */
public interface PqIcdPathMapper extends MPJBaseMapper<PqIcdPath> { public interface PqIcdPathMapper extends MPJBaseMapper<PqIcdPath> {
/**
* 根据设备类型id获取Icd
*
* @param devTypeId
* @return
*/
PqIcdPath selectIcdByDevType(@Param("devTypeId") String devTypeId);
} }

View File

@@ -3,5 +3,11 @@
<mapper namespace="com.njcn.gather.icd.mapper.PqIcdPathMapper"> <mapper namespace="com.njcn.gather.icd.mapper.PqIcdPathMapper">
<select id="selectIcdByDevType" resultType="com.njcn.gather.icd.pojo.po.PqIcdPath">
select *
from pq_icd_path path
inner join pq_dev_type type on path.id = type.icd
where type.id = #{devTypeId}
</select>
</mapper> </mapper>

View File

@@ -1,12 +0,0 @@
package com.njcn.gather.icd.pojo.constant;
/**
* @author caozehui
* @data 2025-02-11
*/
public interface PqIcdPathValidMessage {
String ID_NOT_BLANK = "id不能为空请检查id参数";
String ID_FORMAT_ERROR = "id格式错误请检查id参数";
String NAME_NOT_BLANK = "名称不能为空";
String PATH_NOT_BLANK = "icd存储路径不能为空";
}

View File

@@ -1,21 +0,0 @@
package com.njcn.gather.icd.pojo.enums;
import lombok.Getter;
/**
* @author caozehui
* @data 2025-02-11
*/
@Getter
public enum IcdPathResponseEnum {
ICD_PATH_NAME_REPEAT("A004007", "icd名称重复");
private final String code;
private final String message;
IcdPathResponseEnum(String code, String message) {
this.message = message;
this.code = code;
}
}

View File

@@ -1,8 +1,7 @@
package com.njcn.gather.icd.pojo.param; package com.njcn.gather.icd.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.icd.pojo.constant.PqIcdPathValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.gather.type.pojo.constant.DevTypeValidMessage;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -18,11 +17,13 @@ import javax.validation.constraints.Pattern;
@Data @Data
public class PqIcdPathParam { public class PqIcdPathParam {
@ApiModelProperty(value = "名称", required = true) @ApiModelProperty(value = "名称", required = true)
@NotBlank(message = PqIcdPathValidMessage.NAME_NOT_BLANK) @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ICD_NAME_REGEX, message = DetectionValidMessage.ICD_NAME_FORMAT_ERROR)
private String name; private String name;
@ApiModelProperty(value = "存储路径", required = true) @ApiModelProperty(value = "存储路径", required = true)
@NotBlank(message = PqIcdPathValidMessage.PATH_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ICD_PATH_NOT_BLANK)
@Pattern(regexp = PatternRegex.ICD_PATH_REGEX, message = DetectionValidMessage.ICD_PATH_FORMAT_ERROR)
private String path; private String path;
/** /**
@@ -43,8 +44,8 @@ public class PqIcdPathParam {
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class UpdateParam extends PqIcdPathParam { public static class UpdateParam extends PqIcdPathParam {
@ApiModelProperty(value = "id", required = true) @ApiModelProperty(value = "id", required = true)
@NotBlank(message = PqIcdPathValidMessage.ID_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = PqIcdPathValidMessage.ID_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id; private String id;
} }
} }

View File

@@ -51,4 +51,12 @@ public interface IPqIcdPathService extends IService<PqIcdPath> {
* @return 成功返回true失败返回false * @return 成功返回true失败返回false
*/ */
boolean deleteIcd(List<String> ids); boolean deleteIcd(List<String> ids);
/**
* 根据设备类型id获取Icd
*
* @param devTypeId
* @return
*/
PqIcdPath getIcdByDevType(String devTypeId);
} }

View File

@@ -7,11 +7,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.icd.mapper.PqIcdPathMapper; import com.njcn.gather.icd.mapper.PqIcdPathMapper;
import com.njcn.gather.icd.pojo.enums.IcdPathResponseEnum;
import com.njcn.gather.icd.pojo.param.PqIcdPathParam; import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
import com.njcn.gather.icd.pojo.po.PqIcdPath; import com.njcn.gather.icd.pojo.po.PqIcdPath;
import com.njcn.gather.icd.service.IPqIcdPathService; import com.njcn.gather.icd.service.IPqIcdPathService;
import com.njcn.gather.type.pojo.po.DevType; import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -46,8 +45,9 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional
public boolean addIcd(PqIcdPathParam param) { public boolean addIcd(PqIcdPathParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, false); this.checkRepeat(param, false);
PqIcdPath pqIcdPath = new PqIcdPath(); PqIcdPath pqIcdPath = new PqIcdPath();
BeanUtils.copyProperties(param, pqIcdPath); BeanUtils.copyProperties(param, pqIcdPath);
@@ -56,8 +56,9 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean updateIcd(PqIcdPathParam.UpdateParam param) { public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, true); this.checkRepeat(param, true);
PqIcdPath pqIcdPath = new PqIcdPath(); PqIcdPath pqIcdPath = new PqIcdPath();
BeanUtils.copyProperties(param, pqIcdPath); BeanUtils.copyProperties(param, pqIcdPath);
@@ -65,11 +66,16 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean deleteIcd(List<String> ids) { public boolean deleteIcd(List<String> ids) {
return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update(); return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update();
} }
@Override
public PqIcdPath getIcdByDevType(String devTypeId) {
return this.baseMapper.selectIcdByDevType(devTypeId);
}
private void checkRepeat(PqIcdPathParam param, boolean isExcludeSelf) { private void checkRepeat(PqIcdPathParam param, boolean isExcludeSelf) {
LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PqIcdPath::getName, param.getName()) wrapper.eq(PqIcdPath::getName, param.getName())
@@ -81,7 +87,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
} }
int count = this.count(wrapper); int count = this.count(wrapper);
if (count > 0) { if (count > 0) {
throw new BusinessException(IcdPathResponseEnum.ICD_PATH_NAME_REPEAT); throw new BusinessException(DetectionResponseEnum.ICD_PATH_NAME_REPEAT);
} }
} }
} }

View File

@@ -1,10 +1,9 @@
package com.njcn.gather.monitor.pojo.param; package com.njcn.gather.monitor.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@@ -21,24 +20,24 @@ public class PqMonitorParam {
private String code; private String code;
@ApiModelProperty(value = "所属母线") @ApiModelProperty(value = "所属母线")
@NotBlank(message = DevValidMessage.BELONG_LINE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.BELONG_LINE_NOT_BLANK)
private String name; private String name;
@ApiModelProperty(value = "监测点序号") @ApiModelProperty(value = "监测点序号")
@NotNull(message = DevValidMessage.MONITOR_NUM_NOT_NULL) @NotNull(message = DetectionValidMessage.MONITOR_NUM_NOT_NULL)
private Integer num; private Integer num;
@ApiModelProperty(value = "PT变比") @ApiModelProperty(value = "PT变比")
@NotNull(message = DevValidMessage.PT_NOT_NULL) @NotNull(message = DetectionValidMessage.PT_NOT_NULL)
private Float pt; private Float pt;
@ApiModelProperty(value = "CT变比") @ApiModelProperty(value = "CT变比")
@NotNull(message = DevValidMessage.CT_NOT_NULL) @NotNull(message = DetectionValidMessage.CT_NOT_NULL)
private Float ct; private Float ct;
@ApiModelProperty(value = "接线方式") @ApiModelProperty(value = "接线方式")
@NotBlank(message = DevValidMessage.WIRING_TYPE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.WIRING_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.WIRING_TYPE_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.WIRING_TYPE_FORMAT_ERROR)
private String ptType; private String ptType;
} }

View File

@@ -2,7 +2,7 @@ package com.njcn.gather.monitor.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.Excel;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -18,24 +18,24 @@ import javax.validation.constraints.Pattern;
public class PqMonitorExcel { public class PqMonitorExcel {
@Excel(name = "监测点序号", width = 20, orderNum = "1") @Excel(name = "监测点序号", width = 20, orderNum = "1")
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MONITOR_NUM_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.MONITOR_NUM_FORMAT_ERROR)
private Integer num; private Integer num;
@Excel(name = "所属母线", width = 20, orderNum = "2") @Excel(name = "所属母线", width = 20, orderNum = "2")
@NotBlank(message = DevValidMessage.BELONG_LINE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.BELONG_LINE_NOT_BLANK)
private String name; private String name;
@Excel(name = "PT变比", width = 20, orderNum = "3") @Excel(name = "PT变比", width = 20, orderNum = "3")
@NotNull(message = DevValidMessage.PT_NOT_NULL) @NotNull(message = DetectionValidMessage.PT_NOT_NULL)
private Float pt; private Float pt;
@Excel(name = "CT变比", width = 20, orderNum = "4") @Excel(name = "CT变比", width = 20, orderNum = "4")
@NotNull(message = DevValidMessage.CT_NOT_NULL) @NotNull(message = DetectionValidMessage.CT_NOT_NULL)
private Float ct; private Float ct;
@Excel(name = "接线方式", width = 20, orderNum = "5") @Excel(name = "接线方式", width = 20, orderNum = "5")
@NotBlank(message = DevValidMessage.WIRING_TYPE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.WIRING_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.WIRING_TYPE_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.WIRING_TYPE_FORMAT_ERROR)
private String ptType; private String ptType;
@Data @Data

View File

@@ -3,7 +3,6 @@ package com.njcn.gather.monitor.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.monitor.mapper.PqMonitorMapper; import com.njcn.gather.monitor.mapper.PqMonitorMapper;
import com.njcn.gather.monitor.pojo.param.PqMonitorParam; import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
import com.njcn.gather.monitor.pojo.po.PqMonitor; import com.njcn.gather.monitor.pojo.po.PqMonitor;
@@ -33,7 +32,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList) { public boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList) {
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(pqMonitorParamList, PqMonitor.class); List<PqMonitor> pqMonitorList = BeanUtil.copyToList(pqMonitorParamList, PqMonitor.class);
pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId)); pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId));
@@ -41,7 +40,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean deletePqMonitorByDevId(String devId) { public boolean deletePqMonitorByDevId(String devId) {
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>(); QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
wrapper.eq("pq_monitor.Dev_Id", devId); wrapper.eq("pq_monitor.Dev_Id", devId);
@@ -49,7 +48,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList) { public boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList) {
// 先删除原有数据 // 先删除原有数据
this.deletePqMonitorByDevId(devId); this.deletePqMonitorByDevId(devId);

View File

@@ -1,9 +1,5 @@
package com.njcn.gather.plan.controller; package com.njcn.gather.plan.controller;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
@@ -13,24 +9,18 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil; import com.njcn.common.utils.LogUtil;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.device.pojo.vo.CNDevExcel;
import com.njcn.gather.plan.pojo.param.AdPlanParam; import com.njcn.gather.plan.pojo.param.AdPlanParam;
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
import com.njcn.gather.plan.pojo.vo.AdPlanVO; import com.njcn.gather.plan.pojo.vo.AdPlanVO;
import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.FileUtil; import com.njcn.web.utils.FileUtil;
import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -68,14 +58,14 @@ public class AdPlanController extends BaseController {
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新增检测计划") @ApiOperation("新增检测计划")
@ApiImplicitParam(name = "param", value = "检测计划", required = true) @ApiImplicitParam(name = "param", value = "检测计划", required = true)
public HttpResult<Object> add(@RequestBody @Validated AdPlanParam param) { public HttpResult<Boolean> add(@RequestBody @Validated AdPlanParam param) {
String methodDescribe = getMethodDescribe("add"); String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param); LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = adPlanService.addAdPlan(param); boolean result = adPlanService.addAdPlan(param);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -83,14 +73,14 @@ public class AdPlanController extends BaseController {
@PostMapping("/update") @PostMapping("/update")
@ApiOperation("修改检测计划") @ApiOperation("修改检测计划")
@ApiImplicitParam(name = "updateParam", value = "检测计划", required = true) @ApiImplicitParam(name = "updateParam", value = "检测计划", required = true)
public HttpResult<Object> update(@RequestBody @Validated AdPlanParam.UpdateParam updateParam) { public HttpResult<Boolean> update(@RequestBody @Validated AdPlanParam.UpdateParam updateParam) {
String methodDescribe = getMethodDescribe("update"); String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam); LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
boolean result = adPlanService.updateAdPlan(updateParam); boolean result = adPlanService.updateAdPlan(updateParam);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -98,14 +88,14 @@ public class AdPlanController extends BaseController {
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation("删除检测计划") @ApiOperation("删除检测计划")
@ApiImplicitParam(name = "ids", value = "检测计划id", required = true) @ApiImplicitParam(name = "ids", value = "检测计划id", required = true)
public HttpResult<Object> delete(@RequestBody List<String> ids) { public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete"); String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids)); LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = adPlanService.deleteAdPlan(ids); boolean result = adPlanService.deleteAdPlan(ids);
if (result) { if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else { } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
} }
} }
@@ -121,43 +111,32 @@ public class AdPlanController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
/**
* 二楼检测计划导出
*
* @param queryParam
*/
@OperateInfo(operateType = OperateType.DOWNLOAD) @OperateInfo(operateType = OperateType.DOWNLOAD)
@PostMapping("/exportCNPlan") @PostMapping("/export")
@ApiOperation("二楼导出检测计划") @ApiOperation("导出检测计划")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true) @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public void exportCNPlan(@RequestBody @Validated AdPlanParam.QueryParam queryParam) { public void exportPlan(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("export"); String methodDescribe = getMethodDescribe("exportPlan");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
adPlanService.exportCNPlan(queryParam); adPlanService.exportPlan(queryParam);
} }
/**
* 二楼检测计划导出模板
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadCNPlanTemplate") @PostMapping("/downloadTemplate")
@ApiOperation("下载二楼检测计划导出模板") @ApiOperation("下载检测计划导出模板")
public void downloadCNPlanTemplate() { public void downloadTemplate(@RequestBody AdPlanParam.QueryParam queryParam) {
adPlanService.downloadCNPlanTemplate(); adPlanService.downloadTemplate(queryParam.getPatternId());
} }
/**
* 二楼检测计划导入
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping(value = "/importCNPlan") @PostMapping(value = "/import")
@ApiOperation("二楼导入检测计划数据") @ApiOperation("导入检测计划数据")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true), @ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true) @ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
}) })
public HttpResult<String> importCNPlan(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) { public HttpResult<Object> importPlan(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importCNPlan"); String methodDescribe = getMethodDescribe("importCNPlan");
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename()); LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
@@ -165,86 +144,10 @@ public class AdPlanController extends BaseController {
if (!fileType) { if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR); throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
} }
adPlanService.importPlan(file, patternId, response);
ImportParams params = new ImportParams();
params.setStartSheetIndex(0);
params.setSheetNum(1);
params.setHeadRows(2);
params.setNeedVerify(true);
List<AdPlanExcel> planExcelList;
try {
ExcelImportResult<AdPlanExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.class, params);
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
Workbook failWorkbook = excelImportResult.getFailWorkbook();
PoiUtil.exportFileByWorkbook(failWorkbook, "非法检测计划数据.xlsx", response);
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
return null;
} else {
planExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
}
if (ObjectUtil.isNotEmpty(planExcelList)) {
adPlanService.importCNPlan(planExcelList, patternId);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
//
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
// @PostMapping(value = "/import")
// @ApiOperation("批量导入检测计划数据")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
// @ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
// })
// public HttpResult<String> importData(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
// String methodDescribe = getMethodDescribe("importData");
// LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为{}", methodDescribe, file.getOriginalFilename(), patternId);
//
// boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
// if (!fileType) {
// throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
// }
// ImportParams params = new ImportParams();
// params.setHeadRows(2);
// params.setNeedVerify(true);
// params.setStartSheetIndex(0);
// params.setSheetNum(1);
//
// List<AdPlanExcel.ImportData> adPlanExcelList = null;
// try {
// ExcelImportResult<AdPlanExcel.ImportData> adPlanExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.ImportData.class, params);
// if (adPlanExcelResult.isVerifyFail()) {
// // 此处前端要做特殊处理,具体可以参考技术监督的数据导入
// PoiUtil.exportFileByWorkbook(adPlanExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
// return null;
// } else {
// adPlanExcelList = adPlanExcelResult.getList();
// }
// } catch (Exception e) {
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL, e.getMessage());
// }
// if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
// adPlanService.importData(patternId, adPlanExcelList);
// }
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
// }
// @OperateInfo
// @GetMapping("/getPieData")
// @ApiOperation("获取饼状图数据")
// @ApiImplicitParam(name = "id", value = "检测计划id", required = true)
// public HttpResult<List<List<Map<String, Object>>>> getPieData(@RequestParam("planId") String planId) {
// String methodDescribe = getMethodDescribe("getPieData");
// LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
// List<List<Map<String, Object>>> result = pqDevService.getPieData(planId);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
// }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getBigTestItem") @PostMapping("/getBigTestItem")
@ApiOperation("获取检测大项数据") @ApiOperation("获取检测大项数据")
@@ -252,7 +155,7 @@ public class AdPlanController extends BaseController {
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) { public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) {
String methodDescribe = getMethodDescribe("getBigTestItem"); String methodDescribe = getMethodDescribe("getBigTestItem");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, checkParam); 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); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }

View File

@@ -2,6 +2,10 @@ package com.njcn.gather.plan.mapper;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.plan.pojo.po.AdPlan; 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 * @author caozehui
@@ -9,5 +13,29 @@ import com.njcn.gather.plan.pojo.po.AdPlan;
*/ */
public interface AdPlanMapper extends MPJBaseMapper<AdPlan> { public interface AdPlanMapper extends MPJBaseMapper<AdPlan> {
/**
* 根据名称和版本获取报告id
*
* @param name
* @param version
* @return
*/
String getReportIdByNameAndVersion(@Param("name") String name, @Param("version") String version);
/**
* 根据id获取报告模板
*
* @param id
* @return
*/
PqReport getPqReportById(String id);
/**
* 获取所有报告模板名称
*
* @return
*/
List<String> listAllReportTemplateName();
} }

View File

@@ -3,5 +3,24 @@
<mapper namespace="com.njcn.gather.plan.mapper.AdPlanMapper"> <mapper namespace="com.njcn.gather.plan.mapper.AdPlanMapper">
<select id="getReportIdByNameAndVersion" resultType="java.lang.String">
SELECT id
FROM pq_report
WHERE name = #{name}
AND version = #{version}
and state = 1
</select>
<select id="getPqReportById" resultType="com.njcn.gather.report.pojo.po.PqReport">
SELECT *
FROM pq_report
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> </mapper>

View File

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

View File

@@ -1,26 +0,0 @@
package com.njcn.gather.plan.pojo.enums;
import lombok.Getter;
/**
* @author caozehui
* @data 2025-01-16
*/
@Getter
public enum PlanResponseEnum {
PLAN_REPEATED("A003014", "当前模式下,该计划已存在"),
PLAN_NOT_EXIST("A003015", "该计划不存在"),
SCRIPT_RELATE_DICT_NOT_EXIST("A003016","脚本关联的字典不存在"),
NOT_CHECKED_PLAN_CANNOT_ANALYSE("A003017","只有检测状态为检测完成的计划才能进行统计分析" ),
CANNOT_CHANGE_SCRIPT_WHEN_CHECKING("A003018","只有检测状态为未检时,才能修改检测脚本" ),
CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING("A003019","只有检测状态为未检时,才能修改误差体系" );
private final String message;
private final String code;
PlanResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -1,12 +1,11 @@
package com.njcn.gather.plan.pojo.param; package com.njcn.gather.plan.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import java.util.List; import java.util.List;
@@ -19,47 +18,58 @@ import java.util.List;
public class AdPlanParam { public class AdPlanParam {
@ApiModelProperty(value = "名称", required = true) @ApiModelProperty(value = "名称", required = true)
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK) @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.PLAN_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR) @Pattern(regexp = PatternRegex.PLAN_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
private String name; private String name;
@ApiModelProperty(value = "模式", required = true) @ApiModelProperty(value = "模式", required = true)
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK) @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
private String pattern; private String pattern;
// @ApiModelProperty(value = "父计划ID") // @ApiModelProperty(value = "父计划ID")
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR) // @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
// private String fatherPlanId; // private String fatherPlanId;
@ApiModelProperty(value = "检测源ID列表",required = true) @ApiModelProperty(value = "检测源ID列表", required = true)
@NotEmpty(message = DevValidMessage.SOURCE_IDS_NOT_EMPTY) @NotEmpty(message = DetectionValidMessage.SOURCE_IDS_NOT_EMPTY)
private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.SOURCE_ID_FORMAT_ERROR)String> sourceIds; private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.SOURCE_ID_FORMAT_ERROR) String> sourceIds;
@ApiModelProperty(value = "数据源ID列表", required = true) @ApiModelProperty(value = "数据源ID列表", required = true)
@NotEmpty(message = DevValidMessage.DATASOURCE_ID_NOT_EMPTY) @NotEmpty(message = DetectionValidMessage.DATASOURCE_ID_NOT_EMPTY)
private List<String> datasourceIds; private List<String> datasourceIds;
@ApiModelProperty(value = "检测脚本ID", required = true) @ApiModelProperty(value = "检测脚本ID", required = true)
@NotBlank(message = DevValidMessage.SCRIPT_ID_NOT_BLANK) @NotBlank(message = DetectionValidMessage.SCRIPT_ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.SCRIPT_ID_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.SCRIPT_ID_FORMAT_ERROR)
private String scriptId; private String scriptId;
@ApiModelProperty(value = "误差体系ID", required = true) @ApiModelProperty(value = "误差体系ID", required = true)
@NotBlank(message = DevValidMessage.ERROR_SYS_ID_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ERROR_SYS_ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERROR_SYS_ID_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ERROR_SYS_ID_FORMAT_ERROR)
private String errorSysId; private String errorSysId;
@ApiModelProperty(value = "守时检测") @ApiModelProperty(value = "守时检测")
@NotNull(message = DevValidMessage.TIME_CHECK_NOT_NULL) @NotNull(message = DetectionValidMessage.TIME_CHECK_NOT_NULL)
@Min(value = 0, message = DevValidMessage.TIME_CHECK_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.TIME_CHECK_FORMAT_ERROR)
@Max(value = 1, message = DevValidMessage.TIME_CHECK_FORMAT_ERROR) @Max(value = 1, message = DetectionValidMessage.TIME_CHECK_FORMAT_ERROR)
private Integer timeCheck; private Integer timeCheck;
@ApiModelProperty("被检设备ID列表") @ApiModelProperty("被检设备ID列表")
@NotNull(message = DevValidMessage.PQ_DEV_IDS_NOT_NULL) @NotNull(message = DetectionValidMessage.PQ_DEV_IDS_NOT_NULL)
private List<String> devIds; 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;
/** /**
* 分页查询实体 * 分页查询实体
*/ */
@@ -67,27 +77,27 @@ public class AdPlanParam {
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam { public static class QueryParam extends BaseParam {
@ApiModelProperty("名称") @ApiModelProperty("名称")
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR) @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
private String name; private String name;
@ApiModelProperty(value = "模式,字典表(数字、模拟、比对)") @ApiModelProperty(value = "模式,字典表(数字、模拟、比对)")
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK) @NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
private String pattern; private String patternId;
@ApiModelProperty(value = "检测状态") @ApiModelProperty(value = "检测状态")
@Min(value = 0, message = DevValidMessage.TEST_STATE_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.TEST_STATE_FORMAT_ERROR)
@Max(value = 2, message = DevValidMessage.TEST_STATE_FORMAT_ERROR) @Max(value = 2, message = DetectionValidMessage.TEST_STATE_FORMAT_ERROR)
private Integer testState; private Integer testState;
@ApiModelProperty(value = "报告生成状态") @ApiModelProperty(value = "报告生成状态")
@Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.REPORT_STATE_FORMAT_ERROR)
@Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR) @Max(value = 2, message = DetectionValidMessage.REPORT_STATE_FORMAT_ERROR)
private Integer reportState; private Integer reportState;
@ApiModelProperty(value = "检测结果") @ApiModelProperty(value = "检测结果")
@Min(value = 0, message = DevValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR) @Min(value = 0, message = DetectionValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
@Max(value = 2, message = DevValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR) @Max(value = 2, message = DetectionValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
private Integer result; private Integer result;
} }
@@ -95,43 +105,16 @@ public class AdPlanParam {
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class UpdateParam extends AdPlanParam { public static class UpdateParam extends AdPlanParam {
@ApiModelProperty(value = "id", required = true) @ApiModelProperty(value = "id", required = true)
@NotBlank(message = DevValidMessage.ID_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id; private String id;
/**
* 检测状态,字典表(未检、检测中、检测完成)
*/
// @ApiModelProperty(value = "检测状态")
// @NotNull(message = DeviceValidMessage.TEST_STATE_NOT_NULL)
// @Min(value = 0, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR)
// private Integer testState;
/**
* 报告生成状态,字典表(未生成、部分生成、全部生成)
*/
// @ApiModelProperty(value = "报告生成状态")
// @NotNull(message = DeviceValidMessage.REPORT_STATE_NOT_NULL)
// @Min(value = 0, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR)
// private Integer reportState;
/**
* 检测结果,字典表(符合、不符合、/
*/
// @ApiModelProperty(value = "检测结果")
// @NotNull(message = DeviceValidMessage.CHECK_RESULT_STATE_NOT_NULL)
// @Min(value = 0, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
// @Max(value = 2, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
// private Integer result;
} }
@Data @Data
public static class CheckParam{ public static class CheckParam {
// 0:不合格项复检 1:全部复检 // 0:不合格项复检 1:全部复检
private Integer reCheckType; private Integer reCheckType;
private String planId; private String planId;
private String devId; private List<String> devIds;
} }
} }

View File

@@ -1,8 +1,9 @@
package com.njcn.gather.plan.pojo.po; package com.njcn.gather.plan.pojo.po;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity; import com.njcn.db.mybatisplus.bo.BaseEntity;
import io.swagger.models.auth.In;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -78,9 +79,25 @@ public class AdPlan extends BaseEntity implements Serializable {
*/ */
private Integer code; private Integer code;
/**
* 是否关联报告0-不关联 1-关联
*/
private Integer associateReport;
/**
* 报告模板ID关联PQ_Report表
*/
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String reportTemplateId;
/** /**
* 状态0-删除 1-正常 * 状态0-删除 1-正常
*/ */
private Integer state; private Integer state;
/**
* 数据处理原则。任意值、部分值、所有值、cp95值、平均值
*/
private String dataRule;
} }

View File

@@ -1,20 +1,11 @@
package com.njcn.gather.plan.pojo.vo; package com.njcn.gather.plan.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection; import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import com.njcn.gather.device.pojo.vo.CNDevExcel;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;
import java.util.List;
/** /**
* @author caozehui * @author caozehui
@@ -23,41 +14,49 @@ import java.util.List;
@Data @Data
public class AdPlanExcel { public class AdPlanExcel {
@Excel(name = "名称*", width = 40, needMerge = true, orderNum = "0") @Excel(name = "名称*", width = 40, needMerge = true, orderNum = "0")
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK) @NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
private String name; private String name;
@Excel(name = "检测源*", width = 40, needMerge = true, orderNum = "1") @Excel(name = "检测源*", width = 40, needMerge = true, orderNum = "1")
@NotBlank(message = DevValidMessage.SOURC_NOT_BLANK) @NotBlank(message = DetectionValidMessage.SOURC_NOT_BLANK)
private String source; private String source;
@Excel(name = "数据源*", width = 20, needMerge = true, orderNum = "2") @Excel(name = "数据源*", width = 20, needMerge = true, orderNum = "2")
@NotBlank(message = DevValidMessage.DATASOURCE_NOT_BLANK) @NotBlank(message = DetectionValidMessage.DATASOURCE_NOT_BLANK)
private String datasourceId; private String datasourceId;
@Excel(name = "脚本*", width = 50, needMerge = true, orderNum = "3") @Excel(name = "脚本*", width = 40, needMerge = true, orderNum = "3")
@NotBlank(message = DevValidMessage.SCRIPT_NOT_BLANK) @NotBlank(message = DetectionValidMessage.SCRIPT_NOT_BLANK)
private String scriptId; private String scriptId;
@Excel(name = "误差体系*", width = 30, needMerge = true, orderNum = "4") @Excel(name = "误差体系*", width = 40, needMerge = true, orderNum = "4")
@NotBlank(message = DevValidMessage.ERRORSYS_NOT_BLANK) @NotBlank(message = DetectionValidMessage.ERRORSYS_NOT_BLANK)
private String errorSysId; private String errorSysId;
@Excel(name = "是否做守时检测*", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5") @Excel(name = "数据处理原则*", width = 20, needMerge = true, orderNum = "5")
@NotNull(message = DevValidMessage.TIMECHECK_NOT_NULL) @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; private Integer timeCheck;
@Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6") @Excel(name = "关联报告模版*", width = 20, replace = {"_0", "_1"}, needMerge = true, orderNum = "7")
@NotNull(message = DevValidMessage.TEST_STATE_NOT_NULL) @NotNull(message = DetectionValidMessage.ASSOCIATE_REPORT_NOT_NULL)
private Integer testState; private Integer associateReport;
@Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7") @Excel(name = "报告模版(当关联报告模版为是时必填)", width = 40, needMerge = true, orderNum = "8")
@NotNull(message = DevValidMessage.REPORT_STATE_NOT_NULL) private String reportTemplateId;
private Integer reportState;
@Excel(name = "检测结果*", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8") // @Excel(name = "检测状态*", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "9")
@NotNull(message = DevValidMessage.CHECK_RESULT_STATE_NOT_NULL) // @NotNull(message = DetectionValidMessage.TEST_STATE_NOT_NULL)
private Integer result; // private Integer testState;
//
@ExcelCollection(name = "绑定的设备", orderNum = "9") // @Excel(name = "报告生成状态*", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "10")
private List<CNDevExcel> devices; // @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

@@ -1,5 +1,6 @@
package com.njcn.gather.plan.pojo.vo; package com.njcn.gather.plan.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -97,4 +98,16 @@ public class AdPlanVO {
* 创建时间 * 创建时间
*/ */
private String createTime; private String createTime;
/**
* 是否关联报告0-不关联 1-关联
*/
private Integer associateReport;
/**
* 报告模板名称
*/
private String reportTemplateName;
private String dataRule;
} }

View File

@@ -0,0 +1,19 @@
package com.njcn.gather.plan.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import com.njcn.gather.device.pojo.vo.CNDevExcel;
import lombok.Data;
import java.util.List;
/**
* @author caozehui
* @data 2025-03-25
*/
@Data
public class CNPlanExcel extends AdPlanExcel {
@ExcelCollection(name = "绑定的设备", orderNum = "9")
private List<CNDevExcel> devices;
}

View File

@@ -0,0 +1,19 @@
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;
import java.util.List;
/**
* @author caozehui
* @data 2025-03-25
*/
@Data
public class ProvincePlanExcel extends AdPlanExcel {
@ExcelCollection(name = "绑定的设备", orderNum = "9")
private List<ProvinceDevExcel> devices;
}

View File

@@ -6,7 +6,9 @@ import com.njcn.gather.plan.pojo.param.AdPlanParam;
import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.pojo.vo.AdPlanExcel; import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
import com.njcn.gather.plan.pojo.vo.AdPlanVO; import com.njcn.gather.plan.pojo.vo.AdPlanVO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -56,26 +58,6 @@ public interface IAdPlanService extends IService<AdPlan> {
*/ */
List<Map<String, Object>> listByPattern(String pattern); List<Map<String, Object>> listByPattern(String pattern);
/**
* 二楼下载检测计划模板
*/
void downloadCNPlanTemplate();
/**
* 二楼导出检测计划数据
*
* @param queryParam 查询参数
*/
void exportCNPlan(AdPlanParam.QueryParam queryParam);
/**
* 二楼导入检测计划
*
* @param planExcelList
* @param patternId
*/
void importCNPlan(List<AdPlanExcel> planExcelList, String patternId);
/** /**
* 可视化 * 可视化
* *
@@ -88,10 +70,10 @@ public interface IAdPlanService extends IService<AdPlan> {
* *
* @param reCheckType 0:不合格项复检 1:全部复检 * @param reCheckType 0:不合格项复检 1:全部复检
* @param planId 检测计划Id * @param planId 检测计划Id
* @param devId 设备Id * @param devIds 设备Id列表
* @return * @return
*/ */
List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, String devId); List<Map<String, String>> getBigTestItem(Integer reCheckType, String planId, List<String> devIds);
/** /**
* 修改计划状态 * 修改计划状态
@@ -119,4 +101,27 @@ public interface IAdPlanService extends IService<AdPlan> {
* @param ids * @param ids
*/ */
void analyse(List<String> ids); void analyse(List<String> ids);
/**
* 导出检测计划数据
*
* @param queryParam
*/
void exportPlan(AdPlanParam.QueryParam queryParam);
/**
* 下载检测计划模板
*
* @param patternId
*/
void downloadTemplate(String patternId);
/**
* 导入检测计划数据
*
* @param file
* @param patternId
* @param response
*/
void importPlan(MultipartFile file, String patternId, HttpServletResponse response);
} }

View File

@@ -1,6 +1,9 @@
package com.njcn.gather.plan.service.impl; package com.njcn.gather.plan.service.impl;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.CharsetUtil;
@@ -19,31 +22,34 @@ import com.njcn.gather.device.pojo.enums.*;
import com.njcn.gather.device.pojo.param.PqDevParam; import com.njcn.gather.device.pojo.param.PqDevParam;
import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.CNDevExcel; import com.njcn.gather.device.pojo.vo.CNDevExcel;
import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.err.pojo.po.PqErrSys; import com.njcn.gather.err.pojo.po.PqErrSys;
import com.njcn.gather.err.service.IPqErrSysService; import com.njcn.gather.err.service.IPqErrSysService;
import com.njcn.gather.plan.mapper.AdPlanMapper; import com.njcn.gather.plan.mapper.AdPlanMapper;
import com.njcn.gather.plan.pojo.enums.DataSourceEnum; import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum; import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum;
import com.njcn.gather.plan.pojo.enums.PlanResponseEnum;
import com.njcn.gather.plan.pojo.param.AdPlanParam; import com.njcn.gather.plan.pojo.param.AdPlanParam;
import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
import com.njcn.gather.plan.pojo.vo.AdPlanVO; import com.njcn.gather.plan.pojo.vo.AdPlanVO;
import com.njcn.gather.plan.pojo.vo.CNPlanExcel;
import com.njcn.gather.plan.pojo.vo.ProvincePlanExcel;
import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.plan.service.IAdPlanSourceService; 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.pojo.po.PqScriptDtls;
import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.gather.script.service.IPqScriptService; import com.njcn.gather.script.service.IPqScriptService;
import com.njcn.gather.source.pojo.po.PqSource; import com.njcn.gather.source.pojo.po.PqSource;
import com.njcn.gather.source.service.IPqSourceService; import com.njcn.gather.source.service.IPqSourceService;
import com.njcn.gather.storage.mapper.DetectionDataDealMapper;
import com.njcn.gather.storage.pojo.param.StorageParam; import com.njcn.gather.storage.pojo.param.StorageParam;
import com.njcn.gather.storage.service.AdHarmonicService; import com.njcn.gather.storage.service.AdHarmonicService;
import com.njcn.gather.storage.service.AdNonHarmonicService;
import com.njcn.gather.storage.service.TableGenService; import com.njcn.gather.storage.service.TableGenService;
import com.njcn.gather.system.config.pojo.po.SysTestConfig; import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
import com.njcn.gather.system.config.service.ISysTestConfigService; import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.pojo.po.DictType; import com.njcn.gather.system.dictionary.pojo.po.DictType;
@@ -55,6 +61,7 @@ import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.ExcelUtil; import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.HttpServletUtil; import com.njcn.web.utils.HttpServletUtil;
import com.njcn.web.utils.PoiUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
@@ -66,6 +73,7 @@ import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -106,6 +114,10 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
BeanUtil.copyProperties(adPlan, adPlanVO); BeanUtil.copyProperties(adPlan, adPlanVO);
adPlanVO.setCreateTime(adPlanVO.getCreateTime().replace("T", " ")); adPlanVO.setCreateTime(adPlanVO.getCreateTime().replace("T", " "));
adPlanVO.setDatasourceIds(Arrays.asList(adPlan.getDatasourceId().split(StrUtil.COMMA))); adPlanVO.setDatasourceIds(Arrays.asList(adPlan.getDatasourceId().split(StrUtil.COMMA)));
if (StrUtil.isNotBlank(adPlan.getReportTemplateId())) {
PqReport report = this.baseMapper.getPqReportById(adPlan.getReportTemplateId());
adPlanVO.setReportTemplateName(report.getName() + "_" + report.getVersion());
}
return adPlanVO; return adPlanVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
adPlanVOList.forEach(adPlanVO -> { adPlanVOList.forEach(adPlanVO -> {
@@ -126,11 +138,12 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean addAdPlan(AdPlanParam param) { public boolean addAdPlan(AdPlanParam param) {
this.checkRepeat(param, false); this.checkRepeat(param, false);
AdPlan adPlan = new AdPlan(); AdPlan adPlan = new AdPlan();
BeanUtil.copyProperties(param, adPlan); BeanUtil.copyProperties(param, adPlan);
adPlan.setName(param.getName().trim());
String planId = UUID.randomUUID().toString().replaceAll("-", ""); String planId = UUID.randomUUID().toString().replaceAll("-", "");
adPlan.setId(planId); adPlan.setId(planId);
@@ -144,6 +157,15 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
adPlan.setResult(CheckResultEnum.UNCHECKED.getValue()); adPlan.setResult(CheckResultEnum.UNCHECKED.getValue());
adPlan.setCode(this.generateCode()); adPlan.setCode(this.generateCode());
if (param.getAssociateReport() != null && param.getAssociateReport() == 1) {
String reportTemplateName = param.getReportTemplateName();
String[] split = reportTemplateName.split("_");
String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]);
if (StrUtil.isNotBlank(reportId)) {
adPlan.setReportTemplateId(reportId);
}
}
// 新增检测计划、检测源关联 // 新增检测计划、检测源关联
adPlanSourceService.addAdPlanSource(planId, param.getSourceIds()); adPlanSourceService.addAdPlanSource(planId, param.getSourceIds());
if (ObjectUtil.isNotEmpty(param.getDevIds())) { if (ObjectUtil.isNotEmpty(param.getDevIds())) {
@@ -162,18 +184,41 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean updateAdPlan(AdPlanParam.UpdateParam param) { public boolean updateAdPlan(AdPlanParam.UpdateParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, true); this.checkRepeat(param, true);
AdPlan plan1 = this.getById(param.getId()); AdPlan plan1 = this.getById(param.getId());
AdPlan plan2 = new AdPlan(); AdPlan plan2 = new AdPlan();
if (param.getAssociateReport() != null) {
if (param.getAssociateReport() == 1) {
String reportTemplateName = param.getReportTemplateName();
String[] split = reportTemplateName.split("_");
String reportId = this.baseMapper.getReportIdByNameAndVersion(split[0], split[1]);
// if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) {
// if (!reportId.equals(plan1.getReportTemplateId())) {
// throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
// }
// }
if (StrUtil.isNotBlank(reportId)) {
plan2.setReportTemplateId(reportId);
}
} else {
plan2.setReportTemplateId(null);
}
}
if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) { if (plan1.getTestState() != CheckStateEnum.UNCHECKED.getValue()) {
if (!plan1.getScriptId().equals(param.getScriptId())) { if (!plan1.getScriptId().equals(param.getScriptId())) {
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_SCRIPT_WHEN_CHECKING); throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_SCRIPT_WHEN_CHECKING);
} }
if (!plan1.getErrorSysId().equals(param.getErrorSysId())) { if (!plan1.getErrorSysId().equals(param.getErrorSysId())) {
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING); throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING);
} }
// if (param.getAssociateReport() != null && param.getAssociateReport() != plan1.getAssociateReport()) {
// throw new BusinessException(DetectionResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
// }
} }
BeanUtil.copyProperties(param, plan2); BeanUtil.copyProperties(param, plan2);
@@ -186,13 +231,13 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean deleteAdPlan(List<String> ids) { public boolean deleteAdPlan(List<String> ids) {
for (String id : ids) { for (String id : ids) {
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam(); PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
queryParam.setPlanId(id); queryParam.setPlanId(id);
if (ObjectUtils.isNotEmpty(pqDevService.listByPlanId(queryParam))) { if (ObjectUtils.isNotEmpty(pqDevService.listByPlanId(queryParam))) {
throw new BusinessException(DevResponseEnum.PLAN_HAS_DEVICE_BIND); throw new BusinessException(DetectionResponseEnum.PLAN_HAS_DEVICE_BIND);
} }
} }
// 删除检测计划、检测源关联 // 删除检测计划、检测源关联
@@ -240,96 +285,6 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
return result; return result;
} }
@Override
public void downloadCNPlanTemplate() {
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(), AdPlanExcel.class, Collections.emptyList());
}
@Override
public void exportCNPlan(AdPlanParam.QueryParam queryParam) {
List<AdPlan> planList = this.list(this.getQueryWrapper(queryParam));
this.visualize(planList);
List<AdPlanExcel> planExcelList = BeanUtil.copyToList(planList, AdPlanExcel.class);
for (int i = 0; i < planList.size(); i++) {
List<PqSource> pqSources = adPlanSourceService.listPqSourceByPlanId(planList.get(i).getId());
planExcelList.get(i).setSource(pqSources.stream().map(PqSource::getName).collect(Collectors.joining(StrUtil.COMMA)));
PqDevParam.QueryParam queryParam1 = new PqDevParam.QueryParam();
queryParam1.setPlanId(planList.get(i).getId());
List<PqDev> pqDevs = pqDevService.listByPlanId(queryParam1);
pqDevService.visualizeCNDev(pqDevs);
List<CNDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
planExcelList.get(i).setDevices(deviceExportData);
}
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(), AdPlanExcel.class, planExcelList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importCNPlan(List<AdPlanExcel> planExcelList, String patternId) {
List<AdPlan> adPlans = BeanUtil.copyToList(planExcelList, AdPlan.class);
String patternCode = dictDataService.getDictDataById(patternId).getCode();
for (int i = 0; i < adPlans.size(); i++) {
AdPlanExcel adPlanExcel = planExcelList.get(i);
AdPlanParam adPlanParam = new AdPlanParam();
adPlanParam.setName(adPlanExcel.getName());
adPlanParam.setPattern(patternId);
checkRepeat(adPlanParam, false);
String planId = UUID.randomUUID().toString().replaceAll("-", "");
adPlans.get(i).setId(planId);
adPlans.get(i).setPattern(patternId);
Integer code = this.generateCode();
adPlans.get(i).setCode(code);
tableGenService.deleteTable(Arrays.asList(code.toString()));
tableGenService.genAdNonHarmonicTable(code.toString());
String source = adPlanExcel.getSource();
String[] sourceNames = source.split(StrUtil.COMMA);
// 若非比对模式检测源、数据源有2个以上时不导入
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && sourceNames.length > 1) {
throw new BusinessException(DevResponseEnum.IMPORT_SOURCE_ERROR);
}
String datasource = adPlanExcel.getDatasourceId();
String[] datasourceIds = datasource.split(StrUtil.COMMA);
// 若非比对模式数据源有2个以上时不导入
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
throw new BusinessException(DevResponseEnum.IMPORT_DATASOURCE_ERROR);
}
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
adPlanSourceService.addAdPlanSource(planId, sourceIds);
List<CNDevExcel> cnDevExcelList = adPlanExcel.getDevices();
pqDevService.importCNDev(cnDevExcelList, patternId, planId);
}
// 逆向可视化
this.reverseVisualize(adPlans);
this.saveBatch(adPlans);
}
/**
* 获取查询条件wrapper
*
* @param queryParam 查询条件
* @return
*/
private Wrapper getQueryWrapper(AdPlanParam.QueryParam queryParam) {
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(queryParam)) {
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPattern()), "ad_plan.pattern", queryParam.getPattern())
.eq(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName())
.eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState())
.eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState())
.eq(ObjectUtil.isNotNull(queryParam.getResult()), "ad_plan.result", queryParam.getResult());
}
queryWrapper.eq("ad_plan.state", DataStateEnum.ENABLE.getCode()).orderByDesc("Create_Time");
return queryWrapper;
}
@Override @Override
public void visualize(List<AdPlan> planList) { public void visualize(List<AdPlan> planList) {
planList.forEach(adPlan -> { planList.forEach(adPlan -> {
@@ -352,15 +307,23 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
if (StrUtil.isNotBlank(adPlan.getErrorSysId())) { if (StrUtil.isNotBlank(adPlan.getErrorSysId())) {
adPlan.setErrorSysId(pqErrSysService.getPqErrSysById(adPlan.getErrorSysId()).getName()); 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 @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<>(); List<Map<String, String>> result = new ArrayList<>();
AdPlan adPlan = this.getById(planId); AdPlan adPlan = this.getById(planId);
if (ObjectUtil.isNull(adPlan)) { if (ObjectUtil.isNull(adPlan)) {
throw new BusinessException(PlanResponseEnum.PLAN_NOT_EXIST); throw new BusinessException(DetectionResponseEnum.PLAN_NOT_EXIST);
} }
String scriptId = adPlan.getScriptId(); String scriptId = adPlan.getScriptId();
@@ -378,10 +341,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
// //
// scriptDtlsList = scriptDtlsList.stream().filter(obj -> !sortSet.contains(obj.getScriptIndex())).collect(Collectors.toList()); // scriptDtlsList = scriptDtlsList.stream().filter(obj -> !sortSet.contains(obj.getScriptIndex())).collect(Collectors.toList());
// } // }
Set<Integer> indexes = new HashSet<>();
StorageParam storageParam = new StorageParam(); StorageParam storageParam = new StorageParam();
storageParam.setCode(Integer.valueOf(adPlan.getCode())); storageParam.setCode(adPlan.getCode() + "");
storageParam.setScriptId(adPlan.getScriptId()); 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()); scriptDtlsList = scriptDtlsList.stream().filter(obj -> indexes.contains(obj.getScriptIndex())).collect(Collectors.toList());
} }
@@ -397,7 +364,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
map.put("code", dictTree.getCode()); map.put("code", dictTree.getCode());
map.put("scriptName", dictTree.getName()); map.put("scriptName", dictTree.getName());
} else { } else {
throw new BusinessException(PlanResponseEnum.SCRIPT_RELATE_DICT_NOT_EXIST); throw new BusinessException(DetectionResponseEnum.SCRIPT_RELATE_DICT_NOT_EXIST);
} }
result.add(map); result.add(map);
}); });
@@ -460,7 +427,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
planList.forEach(plan -> { planList.forEach(plan -> {
if (!CheckStateEnum.CHECKED.getValue().equals(plan.getTestState())) { if (!CheckStateEnum.CHECKED.getValue().equals(plan.getTestState())) {
throw new BusinessException(PlanResponseEnum.NOT_CHECKED_PLAN_CANNOT_ANALYSE); throw new BusinessException(DetectionResponseEnum.NOT_CHECKED_PLAN_CANNOT_ANALYSE);
} }
}); });
@@ -509,6 +476,288 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
} }
} }
@Override
public void exportPlan(AdPlanParam.QueryParam queryParam) {
String currrentScene = sysTestConfigService.getCurrrentScene();
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
switch (sceneEnum) {
case PROVINCE_PLATFORM:
this.exportProvincePlan(queryParam);
break;
case LEAVE_FACTORY_TEST:
this.exportCNPlan(queryParam);
break;
case SELF_TEST:
break;
default:
break;
}
}
@Override
public void downloadTemplate(String patternId) {
String currrentScene = sysTestConfigService.getCurrrentScene();
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
switch (sceneEnum) {
case PROVINCE_PLATFORM:
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM, patternId), ProvincePlanExcel.class, Collections.emptyList());
break;
case LEAVE_FACTORY_TEST:
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划模板.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST, patternId), CNPlanExcel.class, Collections.emptyList());
break;
case SELF_TEST:
break;
default:
break;
}
}
@Override
public void importPlan(MultipartFile file, String patternId, HttpServletResponse response) {
String currrentScene = sysTestConfigService.getCurrrentScene();
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
switch (sceneEnum) {
case PROVINCE_PLATFORM:
this.importProvincePlan(file, patternId, response);
break;
case LEAVE_FACTORY_TEST:
this.importCNPlan(file, patternId, response);
break;
case SELF_TEST:
break;
default:
break;
}
}
/**
* 省级平台导出检测计划数据
*
* @param queryParam
*/
private void exportProvincePlan(AdPlanParam.QueryParam queryParam) {
List<AdPlan> planList = this.list(this.getQueryWrapper(queryParam));
this.visualize(planList);
List<ProvincePlanExcel> planExcelList = BeanUtil.copyToList(planList, ProvincePlanExcel.class);
for (int i = 0; i < planList.size(); i++) {
List<PqSource> pqSources = adPlanSourceService.listPqSourceByPlanId(planList.get(i).getId());
planExcelList.get(i).setSource(pqSources.stream().map(PqSource::getName).collect(Collectors.joining(StrUtil.COMMA)));
PqDevParam.QueryParam queryParam1 = new PqDevParam.QueryParam();
queryParam1.setPlanId(planList.get(i).getId());
List<PqDev> pqDevs = pqDevService.listByPlanId(queryParam1);
pqDevService.visualizeProvinceDev(pqDevs);
List<ProvinceDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, ProvinceDevExcel.class);
planExcelList.get(i).setDevices(deviceExportData);
}
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.PROVINCE_PLATFORM, queryParam.getPatternId()), ProvincePlanExcel.class, planExcelList);
}
/**
* 二楼导出检测计划数据
*
* @param queryParam 查询参数
*/
private void exportCNPlan(AdPlanParam.QueryParam queryParam) {
List<AdPlan> planList = this.list(this.getQueryWrapper(queryParam));
this.visualize(planList);
List<CNPlanExcel> planExcelList = BeanUtil.copyToList(planList, CNPlanExcel.class);
for (int i = 0; i < planList.size(); i++) {
List<PqSource> pqSources = adPlanSourceService.listPqSourceByPlanId(planList.get(i).getId());
planExcelList.get(i).setSource(pqSources.stream().map(PqSource::getName).collect(Collectors.joining(StrUtil.COMMA)));
PqDevParam.QueryParam queryParam1 = new PqDevParam.QueryParam();
queryParam1.setPlanId(planList.get(i).getId());
List<PqDev> pqDevs = pqDevService.listByPlanId(queryParam1);
pqDevService.visualizeCNDev(pqDevs);
List<CNDevExcel> deviceExportData = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
planExcelList.get(i).setDevices(deviceExportData);
}
ExcelUtil.exportExcelPullDown(new ExportParams(), "检测计划导出数据.xlsx", 2, this.getPullDownList(SceneEnum.LEAVE_FACTORY_TEST, queryParam.getPatternId()), CNPlanExcel.class, planExcelList);
}
@Transactional
public void importCNPlan(MultipartFile file, String patternId, HttpServletResponse response) {
ImportParams params = new ImportParams();
params.setStartSheetIndex(0);
params.setSheetNum(1);
params.setHeadRows(2);
params.setNeedVerify(true);
List<CNPlanExcel> planExcelList = null;
try {
ExcelImportResult<CNPlanExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), CNPlanExcel.class, params);
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
Workbook failWorkbook = excelImportResult.getFailWorkbook();
PoiUtil.exportFileByWorkbook(failWorkbook, "非法检测计划数据.xlsx", response);
} else {
planExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
}
if (ObjectUtil.isNotEmpty(planExcelList)) {
this.importCNPlan(planExcelList, patternId);
}
}
/**
* 二楼导入检测计划
*
* @param planExcelList
* @param patternId
*/
@Transactional
public void importCNPlan(List<CNPlanExcel> planExcelList, String patternId) {
List<AdPlan> adPlans = BeanUtil.copyToList(planExcelList, AdPlan.class);
String patternCode = dictDataService.getDictDataById(patternId).getCode();
for (int i = 0; i < adPlans.size(); i++) {
CNPlanExcel planExcel = planExcelList.get(i);
AdPlanParam adPlanParam = new AdPlanParam();
adPlanParam.setName(planExcel.getName());
adPlanParam.setPattern(patternId);
checkRepeat(adPlanParam, false);
String planId = UUID.randomUUID().toString().replaceAll("-", "");
adPlans.get(i).setId(planId);
adPlans.get(i).setPattern(patternId);
Integer code = this.generateCode();
adPlans.get(i).setCode(code);
String source = planExcel.getSource();
String[] sourceNames = source.split(StrUtil.COMMA);
// 若非比对模式检测源、数据源有2个以上时不导入
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && sourceNames.length > 1) {
throw new BusinessException(DetectionResponseEnum.IMPORT_SOURCE_ERROR);
}
String datasource = planExcel.getDatasourceId();
String[] datasourceIds = datasource.split(StrUtil.COMMA);
// 若非比对模式数据源有2个以上时不导入
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);
List<CNDevExcel> cnDevExcelList = planExcel.getDevices();
pqDevService.importCNDev(cnDevExcelList, patternId, planId);
tableGenService.deleteTable(Arrays.asList(code.toString()));
tableGenService.genAdNonHarmonicTable(code.toString());
}
// 逆向可视化
this.reverseVisualize(adPlans);
this.saveBatch(adPlans);
}
@Transactional
public void importProvincePlan(MultipartFile file, String patternId, HttpServletResponse response) {
ImportParams params = new ImportParams();
params.setStartSheetIndex(0);
params.setSheetNum(1);
params.setHeadRows(2);
params.setNeedVerify(true);
List<ProvincePlanExcel> planExcelList = null;
try {
ExcelImportResult<ProvincePlanExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), ProvincePlanExcel.class, params);
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
Workbook failWorkbook = excelImportResult.getFailWorkbook();
PoiUtil.exportFileByWorkbook(failWorkbook, "非法检测计划数据.xlsx", response);
} else {
planExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
}
if (ObjectUtil.isNotEmpty(planExcelList)) {
this.importProvincePlan(planExcelList, patternId);
}
}
/**
* 省级平台导入检测计划
*
* @param planExcelList
* @param patternId
*/
public void importProvincePlan(List<ProvincePlanExcel> planExcelList, String patternId) {
List<AdPlan> adPlans = BeanUtil.copyToList(planExcelList, AdPlan.class);
String patternCode = dictDataService.getDictDataById(patternId).getCode();
for (int i = 0; i < adPlans.size(); i++) {
ProvincePlanExcel planExcel = planExcelList.get(i);
AdPlanParam adPlanParam = new AdPlanParam();
adPlanParam.setName(planExcel.getName());
adPlanParam.setPattern(patternId);
checkRepeat(adPlanParam, false);
String planId = UUID.randomUUID().toString().replaceAll("-", "");
adPlans.get(i).setId(planId);
adPlans.get(i).setPattern(patternId);
Integer code = this.generateCode();
adPlans.get(i).setCode(code);
tableGenService.deleteTable(Arrays.asList(code.toString()));
tableGenService.genAdNonHarmonicTable(code.toString());
String source = planExcel.getSource();
String[] sourceNames = source.split(StrUtil.COMMA);
// 若非比对模式检测源、数据源有2个以上时不导入
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && sourceNames.length > 1) {
throw new BusinessException(DetectionResponseEnum.IMPORT_SOURCE_ERROR);
}
String datasource = planExcel.getDatasourceId();
String[] datasourceIds = datasource.split(StrUtil.COMMA);
// 若非比对模式数据源有2个以上时不导入
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);
}
// 逆向可视化
this.reverseVisualize(adPlans);
this.saveBatch(adPlans);
}
/**
* 获取查询条件wrapper
*
* @param queryParam 查询条件
* @return
*/
private Wrapper getQueryWrapper(AdPlanParam.QueryParam queryParam) {
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(queryParam)) {
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPatternId()), "ad_plan.pattern", queryParam.getPatternId())
.like(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName())
.eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState())
.eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState())
.eq(ObjectUtil.isNotNull(queryParam.getResult()), "ad_plan.result", queryParam.getResult());
}
queryWrapper.eq("ad_plan.state", DataStateEnum.ENABLE.getCode()).orderByDesc("Create_Time");
return queryWrapper;
}
/** /**
* 获取备注信息 * 获取备注信息
@@ -528,12 +777,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
} }
}); });
PqErrSys errSys = pqErrSysService.getById(plan.getErrorSysId()); PqErrSys errSys = pqErrSysService.getById(plan.getErrorSysId());
SysTestConfig config1 = sysTestConfigService.getConfig(); DictData dictData1 = dictDataService.getDictDataById(plan.getDataRule());
if (ObjectUtil.isNotNull(config1)) { if (ObjectUtil.isNotNull(dictData1) && ObjectUtil.isNotNull(errSys)) {
DictData dictData = dictDataService.getDictDataById(config1.getDataRule()); note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData1.getName() + "\"数据原则计算得出。");
if (ObjectUtil.isNotNull(errSys) && ObjectUtil.isNotNull(dictData)) {
note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData.getName() + "\"数据原则计算得出。");
}
} }
return note.toString(); return note.toString();
} }
@@ -596,13 +842,49 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
private void reverseVisualize(List<AdPlan> planList) { private void reverseVisualize(List<AdPlan> planList) {
planList.forEach(adPlan -> { planList.forEach(adPlan -> {
String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA); 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.setCode(this.generateCode());
adPlan.setState(DataStateEnum.ENABLE.getCode()); adPlan.setState(DataStateEnum.ENABLE.getCode());
// 默认为顶级检测计划 // 默认为顶级检测计划
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue()); adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
@@ -643,7 +925,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
} }
int count = this.count(queryWrapper); int count = this.count(queryWrapper);
if (count > 0) { if (count > 0) {
throw new BusinessException(PlanResponseEnum.PLAN_REPEATED); throw new BusinessException(DetectionResponseEnum.PLAN_REPEATED);
} }
} }
@@ -798,10 +1080,31 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
} }
} }
private List<PullDown> getPullDownList() { private List<PullDown> getPullDownList(SceneEnum scene, String patternId) {
List<PullDown> pullDowns = new ArrayList<>(); List<PullDown> pullDowns = new ArrayList<>();
PullDown pullDown = null; 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);
}
// 数据源
DictType dictType = dictTypeService.getByCode("Datasource");
if (ObjectUtil.isNotNull(dictType)) {
List<DictData> dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown();
pullDown.setFirstCol(2);
pullDown.setLastCol(2);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
}
// 检测脚本 // 检测脚本
List<Map<String, Object>> maps1 = pqScriptService.listAllPqScript(null); List<Map<String, Object>> maps1 = pqScriptService.listAllPqScript(null);
List<String> scriptNameList = maps1.stream().map(m -> (String) m.get("name")).collect(Collectors.toList()); List<String> scriptNameList = maps1.stream().map(m -> (String) m.get("name")).collect(Collectors.toList());
@@ -819,84 +1122,75 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
pullDown.setStrings(errSysNameList); pullDown.setStrings(errSysNameList);
pullDowns.add(pullDown); pullDowns.add(pullDown);
// 是否做守时检测 // 数据处理原则
dictType = dictTypeService.getByCode("Data_Rule");
if (ObjectUtil.isNotNull(dictType)) {
List<DictData> dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown(); pullDown = new PullDown();
pullDown.setFirstCol(5); pullDown.setFirstCol(5);
pullDown.setLastCol(5); pullDown.setLastCol(5);
pullDown.setStrings(Arrays.asList("", "")); pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDowns.add(pullDown); pullDowns.add(pullDown);
}
// 检测状态 // 是否做守时检测
pullDown = new PullDown(); pullDown = new PullDown();
pullDown.setFirstCol(6); pullDown.setFirstCol(6);
pullDown.setLastCol(6); pullDown.setLastCol(6);
pullDown.setStrings(Arrays.asList(CheckStateEnum.UNCHECKED.getMsg(), CheckStateEnum.CHECKING.getMsg(), CheckStateEnum.CHECKED.getMsg())); pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown); pullDowns.add(pullDown);
// 报告生成状态 // 是否关联报告模板
pullDown = new PullDown(); pullDown = new PullDown();
pullDown.setFirstCol(7); pullDown.setFirstCol(7);
pullDown.setLastCol(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); pullDowns.add(pullDown);
//检测结果 // 报告模板
List<String> strings = this.baseMapper.listAllReportTemplateName();
pullDown = new PullDown(); pullDown = new PullDown();
pullDown.setFirstCol(8); pullDown.setFirstCol(8);
pullDown.setLastCol(8); pullDown.setLastCol(8);
pullDown.setStrings(Arrays.asList(CheckResultEnum.UNCHECKED.getMsg(), CheckResultEnum.ACCORD.getMsg(), CheckResultEnum.UNCHECKED.getMsg())); pullDown.setStrings(strings);
pullDowns.add(pullDown); pullDowns.add(pullDown);
// 预投计划 // 检测状态
List<DictData> dictDataList = null; // pullDown = new 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);
DictType dictType = dictTypeService.getByCode("Preinvestment_Plan"); // 报告生成状态
if (ObjectUtil.isNotNull(dictType)) { // pullDown = new PullDown();
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId()); // 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(9); // pullDown = new PullDown();
pullDown.setLastCol(9); // pullDown.setFirstCol(11);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList())); // pullDown.setLastCol(11);
pullDowns.add(pullDown); // 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);
pullDowns.addAll(provinceDevPullDownList);
break;
case LEAVE_FACTORY_TEST:
List<PullDown> cnDevPullDownList = pqDevService.getCNDevPullDownList(9);
pullDowns.addAll(cnDevPullDownList);
break;
case SELF_TEST:
break;
default:
break;
} }
// 设备类型
pullDown = new PullDown();
pullDown.setFirstCol(11);
pullDown.setLastCol(11);
pullDown.setStrings(devTypeService.listAll().stream().map(DevType::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
// 通讯协议
dictType = dictTypeService.getByCode("Protocol");
if (ObjectUtil.isNotNull(dictType)) {
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown();
pullDown.setFirstCol(12);
pullDown.setLastCol(12);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
}
// 是否为加密版本
pullDown = new PullDown();
pullDown.setFirstCol(13);
pullDown.setLastCol(13);
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
// 是否支持系数校准
pullDown = new PullDown();
pullDown.setFirstCol(16);
pullDown.setLastCol(16);
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
return pullDowns; return pullDowns;
} }
} }

View File

@@ -32,7 +32,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdP
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean addAdPlanSource(String planId, List<String> sourceIds) { public boolean addAdPlanSource(String planId, List<String> sourceIds) {
List<AdPlanSource> adPlanSourceList = new ArrayList<>(); List<AdPlanSource> adPlanSourceList = new ArrayList<>();
for (String sourceId : sourceIds) { for (String sourceId : sourceIds) {
@@ -42,7 +42,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdP
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean deleteAdPlanSourceByPlanIds(List<String> planIds) { public boolean deleteAdPlanSourceByPlanIds(List<String> planIds) {
QueryWrapper<AdPlanSource> queryWrapper = new QueryWrapper<>(); QueryWrapper<AdPlanSource> queryWrapper = new QueryWrapper<>();
queryWrapper.in("ad_plan_source.Plan_Id", planIds); queryWrapper.in("ad_plan_source.Plan_Id", planIds);
@@ -50,7 +50,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdP
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional
public boolean updateAdPlanSource(String planId, List<String> sourceIds) { public boolean updateAdPlanSource(String planId, List<String> sourceIds) {
this.deleteAdPlanSourceByPlanIds(Collections.singletonList(planId)); this.deleteAdPlanSourceByPlanIds(Collections.singletonList(planId));
this.addAdPlanSource(planId, sourceIds); this.addAdPlanSource(planId, sourceIds);

View File

@@ -1,43 +1,45 @@
package com.njcn.gather.device.pojo.constant; package com.njcn.gather.pojo.constant;
/** /**
* @author caozehui * @author caozehui
* @date 2024/11/06 * @data 2025-03-28
*/ */
public interface DevValidMessage { public interface DetectionValidMessage {
String SOURCE_ID_NOT_BLANK = "检测源id不能为空";
String ID_NOT_BLANK = "id不能为空请检查id参数"; String ID_NOT_BLANK = "id不能为空请检查id参数";
String ID_FORMAT_ERROR = "id格式错误请检查id参数"; String ID_FORMAT_ERROR = "id格式错误请检查id参数";
String NAME_NOT_BLANK = "名称不能为空";
String ICD_NAME_FORMAT_ERROR = "名称格式错误只能包含字母、数字、中文、下划线、中划线、点号、空格、英文括号长度为1-32个字符";
String ICD_PATH_NOT_BLANK = "icd存储路径不能为空";
String ICD_PATH_FORMAT_ERROR = "ICD路径格式错误只能包含字母、数字、下划线、中划线、空格长度为1-50个字符";
String ICD_NOT_BLANK = "ICD不能为空";
String POWER_NOT_BLANK = "工作电源不能为空";
String VOLT_NOT_BLANK = "额定电压不能为空";
String CURR_NOT_BLANK = "额定电流不能为空";
String CHNS_NOT_BLANK = "通道数不能为空";
String DEV_CHNS_RANGE_ERROR = "通道数格式错误";
String INDEX_NOT_NULL = "index不能为空";
String VALUE_TYPE_NOT_BLANK = "脚本值类型不能为空";
String SCRIPT_NAME_FORMAT_ERROR = "脚本名称格式错误只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String SCRIPT_VOLT_FORMAT_ERROR = "检测脚本额定电压格式错误请检查ratedVolt参数";
String SCRIPT_CURR_FORMAT_ERROR = "检测脚本额定电流格式错误请检查ratedCurr参数";
String PORT_RANGE_ERROR = "端口号范围错误请检查port参数"; String PORT_RANGE_ERROR = "端口号范围错误请检查port参数";
String NAME_NOT_BLANK = "名称不能为空请检查name参数"; String NAME_FORMAT_ERROR = "名称格式错误只能包含字母、数字、中文、下划线、中划线、点号、空格长度为1-32个字符";
String NAME_FORMAT_ERROR = "名称格式错误请检查name参数"; String PATTERN_NOT_BLANK = "模式不能为空请检查patternId参数";
String PATTERN_NOT_BLANK = "模式不能为空请检查pattern参数";
String DEV_TYPE_NOT_BLANK = "设备类型不能为空"; String DEV_TYPE_NOT_BLANK = "设备类型不能为空";
String DEV_CHNS_NOT_NULL = "设备通道系数不能为空请检查devChns参数";
String DEV_VOLT_NOT_NULL = "额定电压不能为空请检查devVolt参数";
String DEV_CURR_NOT_NULL = "额定电流不能为空请检查devCurr参数";
String MANUFACTURER_NOT_BLANK = "设备厂家不能为空请检查manufacturer参数"; String MANUFACTURER_NOT_BLANK = "设备厂家不能为空请检查manufacturer参数";
String CREATEDATETIME_NOT_NULL = "出厂日期不能为空请检查producedDate参数"; String CREATEDATETIME_NOT_NULL = "出厂日期不能为空请检查producedDate参数";
String CREATEDATETIME_FORMAT_ERROR = "出厂日期格式错误请检查createDateTime参数";
String FACTORYNO_NOT_BLANK = "出厂编号不能为空请检查factoryNo参数"; String FACTORYNO_NOT_BLANK = "出厂编号不能为空请检查factoryNo参数";
String FIRMWARE_NOT_BLANK = "固件版本不能为空请检查firmware参数";
String SOFTWARE_NOT_BLANK = "软件版本不能为空请检查software参数";
String PROTOCOL_NOT_BLANK = "通讯协议不能为空请检查protocol参数"; String PROTOCOL_NOT_BLANK = "通讯协议不能为空请检查protocol参数";
String IP_NOT_BLANK = "IP地址不能为空请检查ip参数"; String IP_NOT_BLANK = "IP地址不能为空请检查ip参数";
@@ -60,7 +62,7 @@ public interface DevValidMessage {
String RECHECK_NUM_FORMAT_ERROR = "检测次数格式错误请检查recheckNum参数"; String RECHECK_NUM_FORMAT_ERROR = "检测次数格式错误请检查recheckNum参数";
String PATTERN_FORMAT_ERROR = "模式格式错误请检查pattern参数"; String PATTERN_FORMAT_ERROR = "模式格式错误请检查patternId参数";
String SOURCE_IDS_NOT_EMPTY = "检测源ID不能为空请检查sourceIds参数"; String SOURCE_IDS_NOT_EMPTY = "检测源ID不能为空请检查sourceIds参数";
@@ -74,15 +76,15 @@ public interface DevValidMessage {
String PLAN_ID_FORMAT_ERROR = "检测计划ID格式错误请检查planId参数"; String PLAN_ID_FORMAT_ERROR = "检测计划ID格式错误请检查planId参数";
String STANDARD_TIME_FORMAT_ERROR = "标准推行时间格式错误请检查standardTime参数"; String STANDARD_TIME_FORMAT_ERROR = "标准推行年份格式错误请检查standardTime参数";
String SCRIPT_TYPE_NOT_BLANK = "检测脚本类型不能为空请检查scriptType参数"; String SCRIPT_TYPE_NOT_BLANK = "检测脚本类型不能为空请检查scriptType参数";
String STANDARD_NAME_NOT_BLANK = "参照标准名称不能为空请检查standardName参数"; String STANDARD_NAME_NOT_BLANK = "标准号不能为空请检查standardName参数";
String STANDARD_NAME_FORMAT_ERROR = "参照标准名称格式错误请检查standardName参数"; String STANDARD_NAME_FORMAT_ERROR = "标准号格式错误只能包含字母、数字、中文、下划线、中划线、点号、空格、斜杠、反斜杠长度为1-32个字符";
String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空请检查standardTime参数"; String STANDARD_TIME_NOT_BLANK = "标准推行年份不能为空请检查standardTime参数";
String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误请检查scriptType参数"; String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误请检查scriptType参数";
@@ -102,18 +104,6 @@ public interface DevValidMessage {
String ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR = "脚本项类型格式错误请检查scriptType参数"; String ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR = "脚本项类型格式错误请检查scriptType参数";
String START_VALUE_NOT_NULL = "起始值不能为空请检查startValue参数";
String START_FLAG_NOT_NULL = "是否包含起始值不能为空请检查startFlag参数";
String END_VALUE_NOT_NULL = "结束值不能为空请检查endValue参数";
String END_FLAG_NOT_NULL = "是否包含结束值不能为空请检查endFlag参数";
String CONDITION_TYPE_NOT_BLANK = "判断条件类型不能为空请检查conditionType参数";
String ERROR_VALUE_FORMAT_ERROR = "误差值格式错误请检查errorValue参数";
String MAX_ERROR_VALUE_NOT_NULL = "最大误差值不能为空请检查maxErrorValue参数"; String MAX_ERROR_VALUE_NOT_NULL = "最大误差值不能为空请检查maxErrorValue参数";
String ERROR_VALUE_TYPE_NOT_BLANK = "误差值类型不能为空请检查errorValueType参数"; String ERROR_VALUE_TYPE_NOT_BLANK = "误差值类型不能为空请检查errorValueType参数";
@@ -124,18 +114,6 @@ public interface DevValidMessage {
String ENABLE_NOT_NULL = "状态不能为空请检查enable参数"; String ENABLE_NOT_NULL = "状态不能为空请检查enable参数";
String PQ_SOURCE_NAME_FORMAT_ERROR = "检测源名称格式错误请检查pqSourceName参数";
String PQ_SOURCE_PARAMETER_ID_NOT_BLANK = "检测源参数ID不能为空请检查pqSourceParameterId参数";
String PQ_SOURCE_PARAMETER_PID_NOT_BLANK = "检测源参数PID不能为空请检查pqSourceParameterId参数";
String PQ_SOURCE_PARAMETER_TYPE_NOT_BLANK = "检测源参数类型不能为空请检查pqSourceParameterType参数";
String PQ_SOURCE_PARAMETER_REMARK_NOT_BLANK = "检测源参数描述不能为空请检查pqSourceParameterRemark参数";
String PQ_SOURCE_PARAMETER_VALUE_NOT_BLANK = "参数值不能为空请检查pqSourceParameterValue参数";
String DEV_ID_NOT_BLANK = "设备ID不能为空"; String DEV_ID_NOT_BLANK = "设备ID不能为空";
String DEV_ID_FORMAT_ERROR = "设备ID格式错误"; String DEV_ID_FORMAT_ERROR = "设备ID格式错误";
@@ -180,10 +158,6 @@ public interface DevValidMessage {
String CHECK_RESULT_FORMAT_ERROR = "检测结果格式错误"; String CHECK_RESULT_FORMAT_ERROR = "检测结果格式错误";
String DOCUMENT_STATE_FORMAT_ERROR = "归档状态格式错误";
String MONITOR_CODE_FORMAT_ERROR = "监测点编码格式错误";
String MONITOR_NUM_NOT_NULL = "监测点序号不能为空"; String MONITOR_NUM_NOT_NULL = "监测点序号不能为空";
String FACTOR_FLAG_FORMAT_ERROR = "是否支持系数校准格式错误"; String FACTOR_FLAG_FORMAT_ERROR = "是否支持系数校准格式错误";
@@ -195,17 +169,16 @@ public interface DevValidMessage {
String DATASOURCE_NOT_BLANK = "数据源不能为空"; String DATASOURCE_NOT_BLANK = "数据源不能为空";
String SCRIPT_NOT_BLANK = "检测脚本不能为空"; String SCRIPT_NOT_BLANK = "检测脚本不能为空";
String ERRORSYS_NOT_BLANK = "误差体系不能为空"; String ERRORSYS_NOT_BLANK = "误差体系不能为空";
String TIMECHECK_NOT_BLANK = "是否做守时检测不能为空";
String FACTOR_FLAG_NOT_BLANK = "是否支持系数校准不能为空";
String CONDITION_TYPE_FORMAT_ERROR = "判断条件类型格式错误请检查conditionType参数";
String SORT_NOT_NULL = "排序不能为空"; String SORT_NOT_NULL = "排序不能为空";
String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空"; String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空";
String TIMECHECK_NOT_NULL = "是否做守时检测不能为空"; String TIMECHECK_NOT_NULL = "是否做守时检测不能为空";
String CREATEID_NOT_BLANK = "设备序列号不能为空"; String CN_DEV_NAME_FORMAT_ERROR = "设备名称格式错误只能包含数字、中划线长度为1-32个字符";
String DEV_CREATE_ID_FORMAT_ERROR = "装置编号格式错误只能包含字母、数字、中文、下划线、中划线、空格长度为1-32位";
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

@@ -0,0 +1,75 @@
package com.njcn.gather.pojo.enums;
import lombok.Getter;
/**
* @author caozehui
* @data 2025-03-26
*/
@Getter
public enum DetectionResponseEnum {
/**
* 检测模块异常响应码的范围:
* A02000 ~ A02
*/
DEV_TYPE_NAME_REPEAT("A02000", "设备类型名称重复"),
SOURCE_BOUND_NOT_DELETE("A02001", "源已被计划所绑定,无法删除!"),
SCRIPT_BOUND_NOT_DELETE("A02003", "脚本已被计划所绑定,无法删除!"),
RAW_DATA_NOT_EXIST("A02004", "原始数据不存在"),
PLAN_REPEATED("A02005", "当前模式下,该计划已存在"),
PLAN_NOT_EXIST("A02006", "该计划不存在"),
SCRIPT_RELATE_DICT_NOT_EXIST("A02007", "脚本关联的字典不存在"),
NOT_CHECKED_PLAN_CANNOT_ANALYSE("A02008", "只有检测状态为检测完成的计划才能进行统计分析"),
CANNOT_CHANGE_SCRIPT_WHEN_CHECKING("A02009", "只有检测状态为未检时,才能修改检测脚本"),
CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING("A02010", "只有检测状态为未检时,才能修改误差体系"),
CANNOT_CHANGE_REPORT_WHEN_CHECKING("A02011", "只有检测状态为未检时,才能修改绑定报告模板"),
ICD_PATH_NAME_REPEAT("A02012", "icd名称重复"),
ERR_SYS_BOUND_NOT_DELETE("A02013", "误差体系已被计划所绑定,无法删除!"),
ERR_SYS_REPEAT("A02014", "已存在相同标准号、标准推行年份、适用设备等级的误差体系!"),
SCRIPT_NAME_REPEAT("A02015", "脚本名称重复"),
IMPORT_DATA_FAIL("A02040", "导入数据失败"),
SERIES_AND_DEVKEY_NOT_BLANK("A02041", "当为加密设备时,加密设备的序列号和设备密钥不能为空"),
PQ_SOURCE_GEN_NAME_ERROR("A02042", "检测源生成名称出错"),
ERR_SOURCE_GEN_NAME_ERROR("A02043", "误差体系生成名称出错"),
PQ_ERRSYS_GEN_NAME_ERROR("A02044", "误差体系生成名称出错"),
PLAN_HAS_DEVICE_BIND("A02045", "检测计划下已绑定设备,请先解绑设备"),
PQ_DEV_REPEAT("A02046", "重复的被检设备"),
PQ_DEV_HAS_MONITOR("A02047", "该设备下关联有监测点,请先移除监测点"),
HAS_NOT_UNCHECKED_DEVICE("A02048", "设备在检测中或已被检测过,请勿解除绑定"),
IMPORT_PLAN_DATA_FAIL("A02049", "导入的检测计划为空"),
IMPORT_DATA_FORMAT_FAIL("A02050", "导入数据格式错误"),
IMPORT_SOURCE_ERROR("A02051", "当前模式下一个检测计划只能有一个检测源"),
IMPORT_DATASOURCE_ERROR("A02052", "当前模式下一个检测计划只能有一个数据源"),
DEV_UN_CHECKED("A02053", "装置还未检测完成!"),
DEV_UN_REPORT("A02054", "装置报告未生成!"),
DEVICE_DIS_ERROR("A02055", "装置配置异常"),
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位"),
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;
private final String message;
DetectionResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -1,11 +1,16 @@
package com.njcn.gather.report.controller; 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.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.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil; import com.njcn.common.utils.LogUtil;
import com.njcn.gather.report.pojo.DevReportParam; import com.njcn.gather.report.pojo.DevReportParam;
import com.njcn.gather.report.service.IReportService; import com.njcn.gather.report.pojo.param.ReportParam;
import com.njcn.gather.report.pojo.vo.PqReportVO;
import com.njcn.gather.report.service.IPqReportService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -13,9 +18,11 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
@@ -30,7 +37,7 @@ import javax.servlet.http.HttpServletResponse;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ReportController extends BaseController { public class ReportController extends BaseController {
private final IReportService reportService; private final IPqReportService pqReportService;
/** /**
* 此方法临时的,给楼下使用,实际需要优化 * 此方法临时的,给楼下使用,实际需要优化
@@ -44,7 +51,7 @@ public class ReportController extends BaseController {
public HttpResult<Object> generateReport(@RequestBody DevReportParam devReportParam) { public HttpResult<Object> generateReport(@RequestBody DevReportParam devReportParam) {
String methodDescribe = getMethodDescribe("generateReport"); String methodDescribe = getMethodDescribe("generateReport");
LogUtil.njcnDebug(log, "{},终端参数为:{}", methodDescribe, devReportParam); LogUtil.njcnDebug(log, "{},终端参数为:{}", methodDescribe, devReportParam);
reportService.generateReport(devReportParam); pqReportService.generateReport(devReportParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -58,9 +65,106 @@ public class ReportController extends BaseController {
public void downloadReport(@RequestBody DevReportParam devReportParam, HttpServletResponse response) { public void downloadReport(@RequestBody DevReportParam devReportParam, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("downloadReport"); String methodDescribe = getMethodDescribe("downloadReport");
LogUtil.njcnDebug(log, "{},终端参数为:{}", methodDescribe, devReportParam); LogUtil.njcnDebug(log, "{},终端参数为:{}", methodDescribe, devReportParam);
reportService.downloadReport(devReportParam,response); pqReportService.downloadReport(devReportParam, response);
} }
@OperateInfo
@PostMapping("/list")
@ApiOperation("分页查询报告模板")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<PqReportVO>> list(@RequestBody @Validated ReportParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询参数为:{}", methodDescribe, queryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.list(queryParam), methodDescribe);
}
@OperateInfo
@GetMapping("/getById")
@ApiOperation("查询报告模板详情")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<PqReportVO> getById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getById");
LogUtil.njcnDebug(log, "{},查询参数为:{}", methodDescribe, id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.getByReportId(id), methodDescribe);
}
@OperateInfo(operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增报告模板")
@ApiImplicitParam(name = "param", value = "报告模板参数", required = true)
public HttpResult<Boolean> add(ReportParam reportParam) {
String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增参数为:{}", methodDescribe, reportParam);
boolean result = pqReportService.add(reportParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("更新报告模板")
@ApiImplicitParam(name = "param", value = "报告模板参数", required = true)
public HttpResult<Boolean> update(ReportParam.UpdateParam reportParam) {
String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改参数为:{}", methodDescribe, reportParam);
boolean result = pqReportService.update(reportParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(operateType = OperateType.DELETE)
@PostMapping("/delete")
@ApiOperation("删除报告模板")
@ApiImplicitParam(name = "param", value = "报告模板参数", required = true)
public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{},删除参数为:{}", methodDescribe, ids);
boolean result = pqReportService.delete(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo
@GetMapping("/listAllName")
@ApiOperation("查询所有报告模板名称")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<List<String>> listAllName() {
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

@@ -0,0 +1,19 @@
package com.njcn.gather.report.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.report.pojo.po.PqReport;
import java.util.List;
/**
* @author makejava
* @date 2025-03-19
*/
public interface PqReportMapper extends MPJBaseMapper<PqReport> {
/**
* 获取所有已被计划绑定的报告模板id
* @return
*/
List<String> getBoundReportIds();
}

View File

@@ -0,0 +1,10 @@
<?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.report.mapper.PqReportMapper">
<select id="getBoundReportIds" resultType="java.lang.String">
select distinct Report_Template_Id from ad_plan where state = 1
</select>
</mapper>

View File

@@ -3,6 +3,7 @@ package com.njcn.gather.report.pojo;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* @author hongawen * @author hongawen
@@ -19,9 +20,20 @@ public class DevReportParam implements Serializable {
*/ */
private String planId; private String planId;
/**
* 计划所对应的表code
*/
private String planCode;
/**
* 脚本ID
*/
private String scriptId;
/** /**
* 被检设备ID * 被检设备ID
*/ */
private String devId; private String devId;
private List<String> devIdList;
} }

View File

@@ -0,0 +1,77 @@
package com.njcn.gather.report.pojo.constant;
import java.util.Arrays;
import java.util.List;
/**
* 电能质量指标常用的一些常量池
*
* @author hongawen
* @version 1.0
* @data 2025/3/27 11:11
*/
public interface PowerConstant {
/**
* 有三相的指标
*/
List<String> THREE_PHASE = Arrays.asList("V", "HV", "HI", "HP", "HSV", "HSI", "I", "P", "F");
/**
* T相指标
*/
List<String> T_PHASE = Arrays.asList("VOLTAGE", "IMBV", "IMBA", "FREQ");
/**
* 有次数的指标
*/
List<String> TIME = Arrays.asList("HV", "HI", "HP", "HSV", "HSI");
/**
* 没有次数的指标
*/
List<String> NO_TIME = Arrays.asList("V", "I", "P", "VOLTAGE", "IMBV", "IMBA", "F", "FREQ");
/**
* 有数据范围
*/
List<Integer> DATA_RANGE = Arrays.asList(1, 2);
/**
* 暂态符号
*/
String VOLTAGE = "VOLTAGE";
/**
* A相
*/
String PHASE_A = "A";
/**
* B相
*/
String PHASE_B = "B";
/**
* C相
*/
String PHASE_C = "C";
/**
* T相
*/
String PHASE_T = "T";
/**
* 电流单位
*/
String CURRENT_UNIT = "A";
/**
* 电压单位
*/
String VOLTAGE_UNIT = "V";
}

View File

@@ -0,0 +1,22 @@
package com.njcn.gather.report.pojo.constant;
/**
*
* 报告相关的一些常量
*
* @author hongawen
* @version 1.0
* @data 2025/4/3 13:44
*/
public interface ReportConstant {
/**
* docx文档后缀
*/
String DOCX = ".docx";
/**
* 报告模板中书签的起始标识
*/
String BOOKMARK_START = "#{";
}

View File

@@ -0,0 +1,43 @@
package com.njcn.gather.report.pojo.enums;
import lombok.Getter;
/**
* 影响量枚举
* @author hongawen
* @version 1.0
* @data 2025/3/27 21:07
*/
@Getter
public enum AffectEnum {
BASE("base", "额定工作条件下的检测"),
VOL("vol", "电压对XX测量的影响"),
FREQ("freq", "频率对XX测量的影响"),
HARM("harm", "谐波对XX测量的影响");
private String key;
private String desc;
AffectEnum(String key, String desc) {
this.key = key;
this.desc = desc;
}
/**
* 根据key找到适配的枚举
*
* @param key 枚举的key
* @return 匹配的枚举实例如果没有找到则返回null
*/
public static AffectEnum getByKey(String key) {
for (AffectEnum affectEnum : AffectEnum.values()) {
if (affectEnum.getKey().equalsIgnoreCase(key)) {
return affectEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,48 @@
package com.njcn.gather.report.pojo.enums;
import lombok.Getter;
/**
*
* 本枚举用于记录模板中关键字的含义
* 比如 ${manufacturer} 对应的设备厂家
*
* @author hongawen
* @version 1.0
* @data 2025/3/24 14:34
*
* */
@Getter
public enum BaseReportKeyEnum {
DEV_TYPE("devType","设备型号、规格"),
DEV_CODE("createId","装置编号"),
POWER("power","工作电源"),
DEV_CURR("devCurr","额定电流"),
DEV_VOLT("devVolt","额定电压"),
COUNT("count","通道数"),
MANUFACTURER("manufacturer","设备厂家、制造厂商"),
SAMPLE_ID("sampleId","样品编号"),
ARRIVED_DATE("arrivedDate","收样日期"),
TEST_DATE("testDate","检测日期"),
INSPECTOR("inspector","检测员"),
YEAR("year","年份"),
MONTH("month","月份"),
DAY("day",""),
YEAR_MONTH_DAY("year-month-day","年-月-日"),
TEMPERATURE("temp","温度"),
HUMIDITY("hum","相对湿度"),
DELEGATE("delegate","委托方"),
CREATEDATE("createDate","出厂日期"),
HW_VERSION("hardwareVersion","硬件版本"),
SW_VERSION("softwareVersion","软件版本");
private String key;
private String desc;
BaseReportKeyEnum(String key, String desc) {
this.key = key;
this.desc = desc;
}
}

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

@@ -0,0 +1,50 @@
package com.njcn.gather.report.pojo.enums;
import lombok.Getter;
/**
* 统计文档锚点类型
*
* @author hongawen
* @version 1.0
* @data 2025/3/24 18:42
*/
@Getter
public enum DocAnchorEnum {
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;
DocAnchorEnum(String key, String desc, Integer sort) {
this.key = key;
this.desc = desc;
this.sort = sort;
}
/**
* 根据key找到适配的枚举
*
* @param key 枚举的key
* @return 匹配的枚举实例如果没有找到则返回null
*/
public static DocAnchorEnum getByKey(String key) {
for (DocAnchorEnum docAnchorEnum : DocAnchorEnum.values()) {
if (docAnchorEnum.getKey().equalsIgnoreCase(key)) {
return docAnchorEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,71 @@
package com.njcn.gather.report.pojo.enums;
import lombok.Getter;
/**
* 检测项模版枚举
* @author hongawen
* @version 1.0
* @data 2025/3/27 10:24
*/
@Getter
public enum ItemReportKeyEnum {
NAME("name", "检测项,比如:频率"),
NAME_DETAIL("nameDetail", "检测项详细,比如:频率测量准确度"),
INFLUENCE("influence", "影响量的描述,比如额定工作条件、谐波对电压的影响等等"),
ERROR_SCOPE("errorScope", "误差范围,注:在段落中时需加上(),表格中无需添加"),
ERROR_SCOPE_MAG("errorScopeMag", "特征幅值:误差范围"),
ERROR_SCOPE_DUR("errorScopeDur", "持续时间:误差范围"),
SCRIPT_DETAIL("scriptDetail", "脚本输出明细。比如基波电压UN=57.74Vf=50Hz谐波含有率Uh=10%UN=5.774V"),
TIME("time", "次数"),
STANDARD("standard", "标准值"),
STANDARD_A("standardA", "A相标准值"),
STANDARD_B("standardB", "B相标准值"),
STANDARD_C("standardC", "C相标准值"),
STANDARD_MAG("standardMag", "特征幅值的标准值"),
STANDARD_DUR("standardDur_ms", "持续时间的标准值"),
TEST("test", "测试值"),
TEST_MAG("testMag", "特征幅值测试值"),
TEST_DUR("testDur_ms", "持续时间测试值"),
TEST_A("testA", "A相测试值"),
TEST_B("testB", "B相测试值"),
TEST_C("testC", "C相测试值"),
ERROR("error", "误差"),
ERROR_MAG("errorMag", "特征幅值误差"),
ERROR_DUR("errorDur_ms", "持续时间误差"),
ERROR_A("errorA", "A相误差"),
ERROR_B("errorB", "B相误差"),
ERROR_C("errorC", "C相误差"),
RESULT("result", "结论 比如:合格/不合格"),
RESULT_A("resultA", "结论 比如:合格/不合格"),
RESULT_B("resultB", "结论 比如:合格/不合格"),
RESULT_C("resultC", "结论 比如:合格/不合格"),
RESULT_MAG("resultMag", "特征幅值结论 比如:合格/不合格"),
RESULT_DUR("resultDur", "持续时间结论 比如:合格/不合格");
private String key;
private String desc;
ItemReportKeyEnum(String key, String desc) {
this.key = key;
this.desc = desc;
}
/**
* 根据key找到适配的枚举
*
* @param key 枚举的key
* @return 匹配的枚举实例如果没有找到则返回null
*/
public static ItemReportKeyEnum getByKey(String key) {
for (ItemReportKeyEnum itemReportKetEnum : ItemReportKeyEnum.values()) {
if (itemReportKetEnum.getKey().equalsIgnoreCase(key)) {
return itemReportKetEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,52 @@
package com.njcn.gather.report.pojo.enums;
import lombok.Getter;
/**
* 电能质量测试大项枚举
* @author hongawen
* @version 1.0
* @data 2025/3/27 18:29
*/
@Getter
public enum PowerIndexEnum {
UNKNOWN("UNKNOWN", "未知指标"),
FREQ("FREQ", "频率"),
V("V", "电压"),
I("I", "电流"),
IMBV("IMBV", "负序电压不平衡度"),
IMBA("IMBA", "负序电流不平衡度"),
F("F", "短时电压闪变"),
HP("HP", "谐波有功功率"),
HV("HV", "谐波电压"),
HI("HI", "谐波电流"),
HSV("HSV", "间谐波电压"),
HSI("HSI", "间谐波电流"),
VOLTAGE("VOLTAGE", "电压暂降、暂升及短时中断");
private String key;
private String desc;
PowerIndexEnum(String key, String desc) {
this.key = key;
this.desc = desc;
}
/**
* 根据key找到适配的枚举
*
* @param key 枚举的key
* @return 匹配的枚举实例如果没有找到则返回null
*/
public static PowerIndexEnum getByKey(String key) {
for (PowerIndexEnum powerIndexEnum : PowerIndexEnum.values()) {
if (powerIndexEnum.getKey().equalsIgnoreCase(key)) {
return powerIndexEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,36 @@
package com.njcn.gather.report.pojo.enums;
import lombok.Getter;
/**
* @author caozehui
* @data 2025-03-19
*/
@Getter
public enum ReportResponseEnum {
FILE_UPLOAD_FAILED("A012001", "文件上传失败"),
FILE_SUFFIX_ERROR("A012002", "文件后缀错误,请上传.docx文件"),
REPORT_REPEATED("A012003", "已存在相同版本、相同名称的报告"),
FILE_NOT_NULL("A012004", "上传的文件不能为空"),
DELETE_BOUND_REPORT_ERROR("A012005", "已被计划绑定模板的报告不能删除"),
FILE_NAME_SAME_ERROR("A012006", "文件名不能相同"),
DEVICE_NOT_EXIST("A012007", "请检查装置是否存在!"),
DEVICE_TYPE_NOT_EXIST("A012008", "设备类型缺失,请联系管理员!"),
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", "生成报告失败"),
FTP_CONNECTION_FAILED("A012016", "FTP连接失败无法将二维码文件上传至装置");
private String code;
private String message;
ReportResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -0,0 +1,47 @@
package com.njcn.gather.report.pojo.param;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.web.multipart.MultipartFile;
/**
* @author caozehui
* @data 2025-03-19
*/
@Data
public class ReportParam {
@ApiModelProperty(value = "报告模板名称", required = true)
private String name;
@ApiModelProperty(value = "版本号", required = true)
private String version;
@ApiModelProperty(value = "描述信息", required = true)
private String description;
@ApiModelProperty(value = "基础模板文件", required = true)
private MultipartFile baseFile;
@ApiModelProperty(value = "检测项模版文件", required = true)
private MultipartFile detailFile;
@Data
@EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam {
@ApiModelProperty(value = "报告模板名称", required = true)
private String name;
@ApiModelProperty(value = "版本号", required = true)
private String version;
}
@Data
@EqualsAndHashCode(callSuper = true)
public static class UpdateParam extends ReportParam {
@ApiModelProperty(value = "id", required = true)
private String id;
}
}

View File

@@ -0,0 +1,27 @@
package com.njcn.gather.report.pojo.po;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/**
* @author caozehui
* @data 2025-03-21
*/
@Data
@AllArgsConstructor
public class CellEntity {
private String cellValue;
private String width;
private int rowSpan;
private int colSpan;
/**
* 字体颜色 格式为rgb 例如FF0000
*/
private String color;
}

View File

@@ -0,0 +1,55 @@
package com.njcn.gather.report.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author makejava
* @date 2025-03-19
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pq_report")
public class PqReport extends BaseEntity implements Serializable {
private static final long serialVersionUID = 582972970946593407L;
/**
* 报告模板id
*/
private String id;
/**
* 报告模板名称
*/
private String name;
/**
* 版本号
*/
private String version;
/**
* 基础模板文件路径
*/
private String basePath;
/**
* 检测项模版文件路径
*/
private String detailPath;
/**
* 描述信息
*/
private String description;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -0,0 +1,40 @@
package com.njcn.gather.report.pojo.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
*
* 测试大项的检测结果
*
* @author hongawen
* @version 1.0
* @data 2025/4/7 20:17
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SingleTestResult implements Serializable {
/**
* 大项名称
*/
private String scriptCode;
/**
* 是否合格
*/
private boolean qualified;
/**
* 细节集合
*/
private Map<String, List<Map<String, List<Map<String, String>>>>> detail;
}

View File

@@ -0,0 +1,39 @@
package com.njcn.gather.report.pojo.vo;
import com.njcn.gather.report.pojo.enums.DocAnchorEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author hongawen
* @version 1.0
* @data 2025/4/7 15:36
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Bookmark implements Serializable,Comparable<Bookmark>{
/**
* 在文档中段落的索引
*/
private Integer index;
/**
* 对应枚举
*/
private DocAnchorEnum docAnchorEnum;
/**
* 根据书签的排序字段进行排序
* @param bookmark the object to be compared.
*/
@Override
public int compareTo(Bookmark bookmark) {
return Integer.compare(this.docAnchorEnum.getSort(), bookmark.docAnchorEnum.getSort());
}
}

View File

@@ -0,0 +1,68 @@
package com.njcn.gather.report.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author caozehui
* @data 2025-03-19
*/
@Data
public class PqReportVO {
/**
* 报告模板id
*/
private String id;
/**
* 报告模板名称
*/
private String name;
/**
* 版本号
*/
private String version;
/**
* 基础模板文件路径
*/
private FileVO baseFileVO;
/**
* 检测项模版文件路径
*/
private FileVO detailFileVO;
/**
* 描述信息
*/
private String description;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;
/**
* 状态0-删除 1-正常
*/
//private Integer state;
@Data
public static class FileVO{
private String name;
private String url;
}
}

View File

@@ -0,0 +1,86 @@
package com.njcn.gather.report.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.report.pojo.DevReportParam;
import com.njcn.gather.report.pojo.param.ReportParam;
import com.njcn.gather.report.pojo.po.PqReport;
import com.njcn.gather.report.pojo.vo.PqReportVO;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author makejava
* @date 2025-03-19
*/
public interface IPqReportService extends IService<PqReport> {
/**
* 分页查询报告列表
*
* @param queryParam
* @return
*/
Page<PqReportVO> list(ReportParam.QueryParam queryParam);
/**
* 根据id查询报告详情
*
* @param id
* @return
*/
PqReportVO getByReportId(String id);
/**
* 新增报告
*
* @param reportParam
* @return
*/
boolean add(ReportParam reportParam);
/**
* 修改报告
*
* @param reportParam
* @return
*/
boolean update(ReportParam.UpdateParam reportParam);
/**
* 批量删除报告
*
* @param ids
* @return
*/
boolean delete(List<String> ids);
/**
* 查询所有报告名称
*
* @return key为报告idvalue为报告名称
*/
List<String> listAllName();
void generateReport(DevReportParam devReportParam);
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
/**
* 设备归档操作
*
* @param id 设备id
* @return 归档成功返回true否则返回false
*/
boolean documented(List<String> id);
/**
* 批量上传检测报告到云端
*
* @param deviceIds 被检设备ID列表为空时上传所有已生成报告的设备
*/
void uploadReportToCloud(List<String> deviceIds);
}

View File

@@ -1,16 +0,0 @@
package com.njcn.gather.report.service;
import com.njcn.gather.report.pojo.DevReportParam;
import javax.servlet.http.HttpServletResponse;
/**
* @author hongawen
* @version 1.0
* @data 2025/1/9 20:59
*/
public interface IReportService {
void generateReport(DevReportParam devReportParam);
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
}

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