330 Commits

Author SHA1 Message Date
hzj
a27eb7e462 二次版本提交 2025-08-06 09:08:00 +08:00
hzj
f68d5da31e 二次版本提交 2025-08-05 10:37:43 +08:00
caozehui
2d889b07f7 比对相关代码 2025-08-04 10:27:00 +08:00
caozehui
417a53a835 Merge branch 'qr_branch' 2025-08-04 09:59:07 +08:00
caozehui
04a667531b 绝对值脚本-暂态bug 2025-08-04 09:56:51 +08:00
9ecfe4f59b 接口调整 2025-08-01 17:02:29 +08:00
hzj
0d80e33d13 二次版本提交 2025-08-01 16:35:39 +08:00
hzj
a2f7b1b9de 二次版本提交 2025-08-01 13:25:54 +08:00
ee96b8e56b 微调 2025-07-31 17:55:46 +08:00
caozehui
a0f6846f53 微调 2025-07-31 13:26:01 +08:00
hzj
6c88c54982 二次版本提交 2025-07-31 09:37:36 +08:00
caozehui
a177d7991c 报告模板调整 2025-07-31 08:54:42 +08:00
b2ff27b15c 添加右侧弹框接口 2025-07-30 16:36:32 +08:00
caozehui
f8fb45cf6f 新增报告模板 2025-07-30 14:42:04 +08:00
35a47b2fa3 右上角接口 2025-07-30 10:34:19 +08:00
hzj
4c0816a829 二次版本提交 2025-07-29 20:58:15 +08:00
hzj
1eb64fadae 二次版本提交 2025-07-29 20:11:24 +08:00
hzj
3ceb73d601 二次版本提交 2025-07-29 19:22:19 +08:00
hzj
9d701ad55e 二次版本提交 2025-07-29 14:34:53 +08:00
8453b1da95 右上角接口 2025-07-28 21:09:01 +08:00
hzj
ba2fec5ac0 二次版本提交 2025-07-28 14:34:36 +08:00
46a2e2068b redis调整 2025-07-28 09:40:40 +08:00
7336a0aaa8 1. 测试环境:创建logback-test.xml,使用固定配置
2. 生产环境:修改logback.xml,移除springProperty依赖,改用固定属性值
2025-07-25 10:50:05 +08:00
caozehui
910069a463 微调 2025-07-25 09:31:46 +08:00
56477157aa 出厂检测检测报告改造 2025-07-24 16:29:31 +08:00
caozehui
a67c5de69d 检测计划相关功能代码 2025-07-22 09:11:21 +08:00
caozehui
95d5396759 检测计划相关功能代码-补充 2025-07-21 08:42:37 +08:00
858fc9aa05 Merge remote-tracking branch 'origin/qr_branch'
# Conflicts:
#	entrance/src/main/resources/application.yml
2025-07-18 14:55:08 +08:00
a6b0509179 二维码下装独立抽取 2025-07-18 14:38:02 +08:00
caozehui
55793dcecd 检测计划相关功能代码 2025-07-18 10:04:43 +08:00
c9ac33864a 微调 2025-07-15 20:35:15 +08:00
6e4bbfc383 处理暂降持续时间 2025-07-14 15:39:55 +08:00
hzj
cb4d8d502a 初始版本提交 2025-07-14 11:02:23 +08:00
067f2235a7 调整 2025-07-11 13:15:39 +08:00
b42ede2853 Merge remote-tracking branch 'origin/master' 2025-07-11 09:24:17 +08:00
9a4ef6abb5 调整 2025-07-11 09:24:08 +08:00
hzj
af2b080ff5 初始版本提交 2025-07-11 09:23:46 +08:00
caozehui
0e056a7de1 比对式标准设备、被检设备、监测点功能 2025-07-09 20:07:23 +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
caozehui
c80ae2f95f 微调 2025-03-12 10:36:13 +08:00
wr
d633b0bd35 微调 2025-03-11 18:46:29 +08:00
wr
81645ae1ba 微调 2025-03-11 18:24:02 +08:00
caozehui
708a4e6fbd 脚本详情项禁用后,该脚本详情项的结果不参与装置的检测结果 2025-03-11 15:31:26 +08:00
caozehui
c60d41af10 微调 2025-03-11 09:31:21 +08:00
wr
91e2e9e7fe 微调 2025-03-11 09:00:02 +08:00
wr
d1101cd157 1.解决间谐波存值问题,取消基波存值
2.解决原始值和结果值入库不一致问题
2025-03-10 20:52:36 +08:00
wr
7594657021 Merge remote-tracking branch 'origin/master' 2025-03-10 18:57:59 +08:00
wr
9bef1331f2 解决间谐波检测脚本问题 2025-03-10 18:44:47 +08:00
caozehui
77e2a73345 微调 2025-03-10 18:38:41 +08:00
wr
1b518e508e 解决间谐波检测脚本问题 2025-03-10 18:08:53 +08:00
wr
1c12187d93 解决间谐波检测脚本问题 2025-03-10 16:49:02 +08:00
wr
67b6f822c3 调整检测详情展示单位 2025-03-10 10:51:55 +08:00
caozehui
337797b0ed 微调 2025-03-10 10:12:52 +08:00
caozehui
1075a72375 微调 2025-03-08 17:51:22 +08:00
caozehui
9fcf4e39a4 微调 2025-03-08 17:45:02 +08:00
caozehui
189ffad11d 微调 2025-03-08 16:49:54 +08:00
wr
efccaae69e 微调 2025-03-08 14:33:42 +08:00
caozehui
34d4321290 微调 2025-03-08 14:26:01 +08:00
caozehui
6cca428d62 微调 2025-03-08 10:13:35 +08:00
caozehui
653c556867 微调 2025-03-07 16:15:12 +08:00
caozehui
8c4ce5d8af 微调 2025-03-07 14:51:52 +08:00
caozehui
2261a786a4 微调 2025-03-07 14:30:02 +08:00
wr
1f5916e898 微调 2025-03-07 12:28:20 +08:00
wr
fe9a81a3a3 微调 2025-03-07 11:35:51 +08:00
wr
c0466ed189 Merge remote-tracking branch 'origin/master' 2025-03-07 11:24:34 +08:00
wr
bc37e47b43 微调 2025-03-07 11:22:29 +08:00
caozehui
6968bf437d 切换误差体系-未做完 2025-03-07 10:31:32 +08:00
caozehui
08be6c15fb 程控源功能 2025-03-07 09:16:18 +08:00
wr
1d7440b4f7 微调 2025-03-07 08:44:07 +08:00
wr
e0e1b6ea9e 微调 2025-03-06 16:00:15 +08:00
wr
646e33d93a 微调 2025-03-06 15:51:58 +08:00
wr
8419450427 微调 2025-03-06 08:46:15 +08:00
wr
ae94e35607 微调 2025-03-05 16:49:17 +08:00
wr
6fb6733727 增加部分教学模式,微调部分代码,增加原始数据转换工具类 2025-03-05 11:44:08 +08:00
caozehui
273dd18405 微调 2025-03-05 11:39:09 +08:00
caozehui
8e78ae4e4c 微调 2025-03-04 14:30:02 +08:00
caozehui
dda18320f8 微调 2025-03-04 14:10:44 +08:00
wr
993ac5f019 微调 2025-03-04 11:34:38 +08:00
caozehui
98dd7894b8 微调 2025-03-04 09:23:09 +08:00
wr
f34a996705 微调 2025-03-03 15:27:50 +08:00
caozehui
bc20fc0705 不合格项复检 2025-03-03 11:35:35 +08:00
5d606673a6 加固代码提交 2025-03-03 11:07:45 +08:00
wr
a4f5034c7f 1.增加脚本修改值类型 2025-02-27 16:23:59 +08:00
caozehui
6e6a6512c9 微调 2025-02-27 15:09:45 +08:00
wr
c7ac87c930 微调 2025-02-27 14:53:16 +08:00
wr
06b13fdfe1 微调 2025-02-27 14:51:50 +08:00
wr
a2ac240150 微调 2025-02-27 14:08:38 +08:00
wr
19e99fda9e 1.解决相对值脚本电压电流问题 2025-02-27 10:26:51 +08:00
wr
bf94ed37d9 1.微调 2025-02-26 20:09:31 +08:00
wr
5ee33fabdf 1.解决误差为0是不符合问题
2.优化检测脚本回显和通讯脚本默认值问题
3.调整三相不平衡度公式工具类
2025-02-25 20:57:41 +08:00
wr
d65b68bbf4 Merge remote-tracking branch 'origin/master' 2025-02-24 16:38:23 +08:00
wr
6fb57f8422 微调 2025-02-24 16:38:04 +08:00
caozehui
cbbf2db4eb 检测计划-检测中、检测完成不能修改脚本、误差体系,数据分析微调 2025-02-24 16:31:22 +08:00
837ea9e369 楼下报告调整 2025-02-24 11:02:59 +08:00
caozehui
496c7a7908 微调 2025-02-24 10:40:38 +08:00
caozehui
758b2a9033 微调 2025-02-24 10:00:58 +08:00
caozehui
913a86dcc7 调整使用RequestUtil工具类来获取登录用户的信息 2025-02-24 09:43:59 +08:00
wr
84879b8d18 1.微调 2025-02-21 15:59:29 +08:00
caozehui
79b89e7e8b 当检测计划的检测状态为检测完成时,才能进行数据分析 2025-02-21 13:55:15 +08:00
wr
cb06b77aef 1.解决mysql index关键字
2.增加通讯脚本相关接口
2025-02-21 10:41:57 +08:00
wr
b746a6445f 装置下发参数公式接口编写 2025-02-19 16:51:13 +08:00
caozehui
c062e2a47f 检测计划导出、导入功能调整 2025-02-19 08:42:52 +08:00
wr
5828a52329 微调 2025-02-18 15:40:33 +08:00
wr
bb9a0f586f 调整检测脚本新增,增加设定值表新增 2025-02-18 15:38:54 +08:00
8cef3c8358 加固代码提交 2025-02-18 14:58:52 +08:00
caozehui
0c012152bb 数据分析微调 2025-02-17 17:59:37 +08:00
wr
76ec26dca0 新增检测脚本,调整检测脚本返回值 2025-02-17 16:32:07 +08:00
caozehui
a5472781de 数据分析微调 2025-02-17 15:11:01 +08:00
caozehui
ff7fbf92e6 日志删除 2025-02-17 14:29:35 +08:00
158422860d 楼下报告调整 2025-02-17 11:28:05 +08:00
422645bcfd 楼下报告调整 2025-02-17 11:14:01 +08:00
caozehui
dd96bc4171 微调 2025-02-14 16:34:37 +08:00
caozehui
2c950b3ac5 微调 2025-02-14 16:24:13 +08:00
wr
25e975fbc8 Merge remote-tracking branch 'origin/master' 2025-02-14 10:59:22 +08:00
wr
a006c0df33 微调 2025-02-14 10:58:09 +08:00
caozehui
b5cee74731 微调 2025-02-14 10:32:31 +08:00
caozehui
801e17e274 移除headers中的Refresh-Token,添加Is-Refresh-Token 2025-02-13 21:04:55 +08:00
wr
93d649162d 微调 2025-02-13 16:25:23 +08:00
cc529b7e91 心跳日志注释 2025-02-13 16:19:49 +08:00
caozehui
8f719e5a73 调整复检次数 2025-02-12 15:22:24 +08:00
wr
8f8788b43c 正式检测系统加固 2025-02-12 15:14:29 +08:00
caozehui
04135f7044 日志相关 2025-02-12 14:44:29 +08:00
caozehui
aca953e827 微调-设备复检次数大于等于3次时,计划状态改为检测完成 2025-02-12 14:43:56 +08:00
454 changed files with 29089 additions and 6887 deletions

View File

@@ -74,6 +74,56 @@
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</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>

View File

@@ -3,15 +3,10 @@ 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.gather.detection.pojo.param.ContrastDetectionParam;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
import com.njcn.gather.detection.service.PreDetectionService;
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
import com.njcn.gather.detection.util.socket.MsgUtil;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
@@ -22,11 +17,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author chendaofei
*/
@Slf4j
@Api(tags = "预检测")
@RestController
@@ -36,30 +30,65 @@ public class PreDetectionController extends BaseController {
private final PreDetectionService preDetectionService;
private final DetectionServiceImpl detectionServiceImpl;
private final IPqScriptDtlsService pqScriptDtlsService;
private final IPqDevService iPqDevService;
/**
* 开始检测
* 开始检测通用入口
*
* @param param 实体参数
*/
@PostMapping("/startPreTest")
@OperateInfo
@ApiOperation("开始检测")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startPreTest(@RequestBody @Validated PreDetectionParam param){
public HttpResult<String> startPreTest(@RequestBody @Validated PreDetectionParam param) {
String methodDescribe = getMethodDescribe("startPreTest");
preDetectionService.sourceCommunicationCheck(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 程控源-源通讯校验
*
* @param param
* @return
*/
@PostMapping("/ytxCheckSimulate")
@OperateInfo
@ApiOperation("源通讯校验")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> ytxCheckSimulate(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("ytxCheckSimulate");
preDetectionService.ytxCheckSimulate(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 程控源检测
*/
@PostMapping("/startSimulateTest")
@OperateInfo
@ApiOperation("启动")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startTestSimulate(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("startTestSimulate");
preDetectionService.sendScript(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 关闭检测-程控源
*/
@PostMapping("/closeSimulateTest")
@OperateInfo
@ApiOperation("停止")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> closeSimulateTest(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("closeSimulateTest");
preDetectionService.closeTestSimulate(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 系数校验
*/
@@ -67,7 +96,7 @@ public class PreDetectionController extends BaseController {
@OperateInfo
@ApiOperation("系数校验")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> coefficientCheck(@RequestBody PreDetectionParam param){
public HttpResult<String> coefficientCheck(@RequestBody PreDetectionParam param) {
String methodDescribe = getMethodDescribe("coefficientCheck");
preDetectionService.coefficientCheck(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
@@ -81,7 +110,7 @@ public class PreDetectionController extends BaseController {
@OperateInfo
@ApiOperation("暂停检测")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> temStopTest(){
public HttpResult<String> temStopTest() {
String methodDescribe = getMethodDescribe("temStopTest");
preDetectionService.temStopTest();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
@@ -94,126 +123,23 @@ public class PreDetectionController extends BaseController {
@OperateInfo
@ApiOperation("重新开始检测")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> restartTemTest(@RequestBody PreDetectionParam param){
public HttpResult<String> restartTemTest(@RequestBody PreDetectionParam param) {
String methodDescribe = getMethodDescribe("restartTemTest");
preDetectionService.restartTemTest(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 测试
* 开始比对检测(包括预检测、正式检测)通用入口
*/
@PostMapping("/startTest")
@PostMapping("/startContrastTest")
@OperateInfo
@ApiOperation("")
@ApiOperation("开始比对检")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startTest(@RequestBody PreDetectionParam param){
String methodDescribe = getMethodDescribe("startTest");
//preDetectionService.startTest(param);
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:50.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:50.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:50.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:53.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:56.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:49:59.815\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:02.8\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:03\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:06\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:09\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:12\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:15\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:18\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:21\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:24\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:27\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:30\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:33\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:36\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:39\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:42.001\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_1\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_2\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_3\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001000\"}}],\"SqlDataHarm\":[]}");
MsgUtil.socketDataMsg("{\"Time\":\"2025-01-15T15:50:45.001\",\"ID\":\"172.17.102.204_4\",\"result\":false,\"SqlData\":[{\"type\":\"real\",\"desc\":\"FREQ\",\"list\":{\"A\":null,\"B\":null,\"C\":null,\"T\":\"50.001100\"}}],\"SqlDataHarm\":[]}");
PqScriptIssueParam issueParam = new PqScriptIssueParam();
issueParam.setPlanId(param.getPlanId());
issueParam.setSourceId(param.getSourceId());
issueParam.setDevIds(param.getDevIds());
issueParam.setScriptId("a303b2224845fcc6f60198b8ca23dca9");
//issueParam.setIsPhaseSequence(false);
SourceIssue sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam).get(0);
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
Map<String, String> devIdMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevId));
//detectionServiceImpl.processing(devDataList,param,devIdMapComm,sourceIssues, DictDataEnum.AT_WILL_VALUE);
public HttpResult<String> startContrastTest(@RequestBody @Validated ContrastDetectionParam param) {
String methodDescribe = getMethodDescribe("startContrastTest");
preDetectionService.startContrastTest(param);
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

@@ -1,5 +1,6 @@
package com.njcn.gather.detection.handler;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
@@ -10,10 +11,7 @@ import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.MsgUtil;
import com.njcn.gather.detection.util.socket.SocketManager;
import com.njcn.gather.detection.util.socket.WebServiceManager;
import com.njcn.gather.detection.util.socket.*;
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;
@@ -21,6 +19,7 @@ import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.system.pojo.enums.DicDataEnum;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -34,18 +33,9 @@ public class SocketSourceResponseService {
/**
* 向webSocket客户端发送消息
*/
private final SocketDevResponseService socketDevResponseService;
private final IPqDevService iPqDevService;
private final String DEV = "_Dev";
private final String source = "_Source";
private final String stepTag = "&&";
private final String stepBegin = "_Start";
private final String stepEnd = "_End";
@Value("${socket.device.ip}")
private String ip;
@@ -58,13 +48,18 @@ public class SocketSourceResponseService {
public void deal(PreDetectionParam param, String msg) throws Exception {
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
String[] tem = socketDataMsg.getRequestId().split(stepTag);
String[] tem = socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG);
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
if (ObjectUtil.isNotNull(enumByCode)) {
switch (enumByCode) {
//源初始化
case YJC_YTXJY:
detectionDev(param, socketDataMsg);
if (ObjectUtil.isNotNull(param.getPlanId())) {
detectionDev(param, socketDataMsg);
} else {
// 程控源-源通信校验
handleYtxjySimulate(param, socketDataMsg);
}
break;
//相序检测
case YJC_XUJY:
@@ -72,7 +67,11 @@ public class SocketSourceResponseService {
break;
//正式检测
case FORMAL_REAL:
senParamToDev(param, socketDataMsg);
if (ObjectUtil.isNotNull(param.getPlanId())) {
senParamToDev(param, socketDataMsg);
} else {
handleSimulateTest(param, socketDataMsg);
}
break;
//系数校验
case Coefficient_Check:
@@ -83,13 +82,92 @@ public class SocketSourceResponseService {
break;
case YXT:
break;
}
} else {
System.out.println("fggggggggggggggggggggg" + enumByCode);
}
}
private void handleYtxjySimulate(PreDetectionParam param, SocketDataMsg socketDataMsg) {
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
switch (dictDataEnumByCode) {
case SUCCESS:
if (param.getSendWebMsg()) {
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
}
System.out.println(param.getSendWebMsg() + "模拟检测-源初始化成功");
break;
case UNPROCESSED_BUSINESS:
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case SOURCE_CONNECTION_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case CONTROLLED_SOURCE_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case TEST_ITEM_PARSING_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case SOURCE_CONTROL_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case TARGET_SOURCE_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case NOT_INITIALIZED:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNKNOWN_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNABLE_TO_RESPOND:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
default:
CnSocketUtil.sendUnSocket(param.getUserPageId());
break;
}
}
}
/**
* 处理模拟检测时,通信模块返回报文
*
* @param param
* @param socketDataMsg
*/
private void handleSimulateTest(PreDetectionParam param, SocketDataMsg socketDataMsg) {
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
switch (dictDataEnumByCode) {
case SUCCESS:
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
System.out.println("模拟检测-源成功执行脚本" + JSON.toJSONString(socketDataMsg));
break;
case UNPROCESSED_BUSINESS:
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
default:
CnSocketUtil.quitSendSource(param);
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(socketDataMsg.getRequestId());
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
socketMsg.setData(dictDataEnumByCode.getMessage());
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketMsg));
break;
}
}
}
@@ -105,18 +183,17 @@ public class SocketSourceResponseService {
//向前端推送信息
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
String s = param.getUserPageId() + DEV;
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
phaseSequenceParam.setMoniterIdList(monitorIdList);
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS", "real$IRMS"));
phaseSequenceParam.setReadCount(10);
phaseSequenceParam.setIgnoreCount(7);
phaseSequenceParam.setReadCount(3);
phaseSequenceParam.setIgnoreCount(4);
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
break;
case UNPROCESSED_BUSINESS:
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
@@ -135,8 +212,8 @@ public class SocketSourceResponseService {
/**
* 装置检测(当源初始化成功后,直接向装置通道向装置服务器发送,装置检测)
*
* @param param
* @param socketDataMsg
* @param param 参数
* @param socketDataMsg 消息
*/
private void detectionDev(PreDetectionParam param, SocketDataMsg socketDataMsg) {
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
@@ -147,11 +224,11 @@ public class SocketSourceResponseService {
case SUCCESS:
//todo 前端推送收到的消息暂未处理好
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
String s = param.getUserPageId() + DEV;
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
//开始设备通讯检测(发送设备初始化)
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
//List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
Map<String, List<PreDetection>> map = new HashMap<>(1);
map.put("deviceList", devList);
map.put("deviceList", FormalTestManager.devList);
String jsonString = JSON.toJSONString(map);
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
@@ -166,6 +243,7 @@ public class SocketSourceResponseService {
case SOURCE_CONNECTION_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case CONTROLLED_SOURCE_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
@@ -216,7 +294,7 @@ public class SocketSourceResponseService {
//向前端推送信息
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
String s = param.getUserPageId() + DEV;
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
@@ -265,21 +343,17 @@ public class SocketSourceResponseService {
//向前端推送信息
// webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
String s = param.getUserPageId() + DEV;
String s = param.getUserPageId() + CnSocketUtil.DEV_TAG;
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);
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + sourceIssue.getType());
int ignoreCount;
int readData;
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
if (DicDataEnum.F.getCode().equals(sourceIssue.getType())) {
ignoreCount = 1;
readData = 2;
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())) {
ignoreCount = 5;
readData = 1;
@@ -287,12 +361,18 @@ public class SocketSourceResponseService {
} else {
ignoreCount = 5;
readData = 5;
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
//区分实时数据还是分钟数据
if ("real".equals(sourceIssue.getDataType())) {
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();
phaseSequenceParam.setMoniterIdList(moniterIdList);
phaseSequenceParam.setMoniterIdList(monitorIdList);
phaseSequenceParam.setDataType(comm);
phaseSequenceParam.setReadCount(readData);
phaseSequenceParam.setIgnoreCount(ignoreCount);
@@ -308,7 +388,7 @@ public class SocketSourceResponseService {
});
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
webSocketVO.setRequestId(socketDataMsg.getRequestId().split(stepTag)[1] + stepBegin);
webSocketVO.setRequestId(socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG)[1] + CnSocketUtil.START_TAG);
webSocketVO.setDesc(SocketManager.getSourceList().get(0).getDesc());
webSocketVO.setData(devListRes);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
@@ -336,15 +416,16 @@ public class SocketSourceResponseService {
switch (Objects.requireNonNull(dictDataEnumByCode)) {
case SUCCESS:
//通讯校验成功
SocketManager.removeUser(param.getUserPageId() + source);
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNPROCESSED_BUSINESS:
break;
case MESSAGE_PARSING_ERROR:
SocketManager.removeUser(param.getUserPageId() + source);
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
break;
case UNABLE_TO_RESPOND:
SocketManager.removeUser(param.getUserPageId() + source);
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
break;
default:
CnSocketUtil.quitSendSource(param);
@@ -361,6 +442,7 @@ public class SocketSourceResponseService {
this.monitorIdList = devList.stream().flatMap(x -> x.getMonitorList().stream())
.map(PreDetection.MonitorListDTO::getLineId)
.collect(Collectors.toList());
XiNumberManager.xiDevList = devList;
}
}

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

@@ -0,0 +1,54 @@
package com.njcn.gather.detection.pojo.enums;
import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;
/**
* @Description:
* @Author: wr
* @Date: 2025/2/12 10:15
*/
@Getter
public enum DetectionCodeEnum {
FREQ("FREQ", "频率"),
VRMS("VRMS", "相电压有效值"),
DELTA_V("DELTA_V", "电压偏差"),
VA("VA", "电压相角"),
U1("U1", "基波电压"),
V2_50("V2-50", "谐波电压"),
I2_50("I2-50", "谐波电流"),
P2_50("P2-50", "谐波有功功率"),
SV_1_49("SV_1-49", "间谐波电压"),
SI_1_49("SI_1-49", "间谐波电流"),
MAG("MAG", "电压幅值"),
DUR("DUR", "持续时间"),
IRMS("IRMS", "电流有效值"),
IA("IA", "电流相角"),
V_UNBAN("V_UNBAN", "三相电压负序不平衡度"),
I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
PST("PST", "短时间闪变"),
P_FUND("P_FUND", "功率"),
I1("I1", "基波电流"),
UNKNOWN_ERROR("-1", "未知异常"),
STAR("Star","星型接线"),
DELTA("Delta","角型接线");
private final String code;
private final String message;
DetectionCodeEnum(String code, String message) {
this.code = code;
this.message = message;
}
public static DetectionCodeEnum getDetectionCodeByCode(String code) {
for (DetectionCodeEnum detectionCodeEnum : DetectionCodeEnum.values()) {
if (ObjectUtil.equals(code, detectionCodeEnum.getCode())) {
return detectionCodeEnum;
}
}
return UNKNOWN_ERROR;
}
}

View File

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

View File

@@ -38,6 +38,8 @@ public enum SourceOperateCodeEnum {
DATA_CHNFACTOR$01("DATA_CHNFACTOR$01","校验系数获取"),
DATA_CHNFACTOR$02("DATA_CHNFACTOR$02","校验系数下发"),
VERIFY_MAPPING$01("VERIFY_MAPPING$01","脚本与icd校验"),
/**
* 请求操作类型对应实体中 requestId
@@ -46,17 +48,22 @@ public enum SourceOperateCodeEnum {
YJC_SBTXJY("yjc_sbtxjy", "设备通讯检测"),
YJC_XYJY("yjc_xyjy", "协议校验"),
YJC_XUJY("YJC_xujy", "相序校验"),
YJC_ALIGN("YJC_align","实时数据对齐校验"),
YJC_MXYZXJY("YJC_mxyzxjy", "模型一致性校验"),
FORMAL_REAL("formal_real","正式检测"),
// SIMULATE_REAL("simulate_real","模拟检测"),
Coefficient_Check("Coefficient_Check","系数校验"),
QUITE("quit","关闭设备通讯初始化"),
QUITE_SOURCE("close_source","关闭源通讯"),
ERROR_FLOW_END("error_flow_end","当前流程存在异常结束"),
YXT("yxt","心跳"),
REPORT_CAT("FTP_SEND$01","处理报告"),
UNKNOWN_OPERATE("unknown_operate","未知的操作返回,请联系管理员排查"),
SOCKET_TIMEOUT("socket_timeout","与源或者装置通讯等待超时"),
STOP_TIMEOUT("stop_timeout","暂停时间超过十分钟"),
SERVER_ERROR("server_error","服务端主动关闭连接,请稍后再试"),
DEVICE_ERROR("device_error","设备主动关闭连接,请稍后再试"),
@@ -65,16 +72,17 @@ public enum SourceOperateCodeEnum {
/**
*
*/
COEFFICIENT_TEST("0","系数校验"),
PRE_TEST("1","预检测"),
FORMAL_TEST("2","正式检测"),
TIME_TEST("3","守时检测"),
PHASE_TEST("4","相序检测"),
TEST_TEM_STOP("5","临时停止"),
TEST_TEM_START("6","继续检测"),
TEST_STOP("7","停止检测"),
RE_ERROR_TEST("8","不合格项复检"),
// COEFFICIENT_TEST("0","系数校验"),
// PRE_TEST("1","预检测"),
// FORMAL_TEST("2","正式检测"),
// TIME_TEST("3","守时检测"),
// PHASE_TEST("4","相序检测"),
// TEST_TEM_STOP("5","临时停止"),
ALL_TEST("1","全部检测"),
RE_ERROR_TEST("2","不合格项复检"),
SIMULATE_TEST("4","模拟检测"),
//TEST_STOP("7","停止检测"),
//FAST_TEST("10","一键检测"),
/**
* 系数校验步骤
@@ -89,8 +97,10 @@ public enum SourceOperateCodeEnum {
small_comp_end("small_comp_end","小电压校准结束"),
;
/**
* ftp文件传送指令
*/
FTP_SEND_01("FTP_SEND$01", "发送文件"),;
private final String value;
private final String msg;

View File

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

View File

@@ -0,0 +1,44 @@
package com.njcn.gather.detection.pojo.param;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Map;
/**
* @author caozehui
* @data 2025-07-18
*/
@Data
public class ContrastDetectionParam {
@ApiModelProperty("检测计划ID")
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_BLANK)
private String planId;
@ApiModelProperty("用户ID唯一标识")
private String userId;
@ApiModelProperty("被检设备ID列表")
@NotEmpty(message = DetectionValidMessage.DEV_IDS_NOT_EMPTY)
private List<String> devIds;
@ApiModelProperty("标准设备ID列表")
@NotEmpty(message = DetectionValidMessage.STANDARD_DEV_IDS_NOT_EMPTY)
private List<String> standardDevIds;
/**
* key为 标准设备ID_检测点序号、value为 被检设备ID_检测点序号
*/
@ApiModelProperty("配对关系")
@NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY)
private Map<String,String> pairs;
/**
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
*/
private List<Boolean> testItemList;
}

View File

@@ -14,10 +14,7 @@ import java.util.List;
@Data
public class PreDetectionParam {
/**
* 操作类型 0.预检测 1.正式检测 2.系数校验
*/
private String operateType = "0";
private String operateType;
/**
* 检测计划id
@@ -25,10 +22,6 @@ public class PreDetectionParam {
@NotBlank(message = "计划id不可为空")
private String planId;
/**
* 检测计划code
*/
private String planCode;
/**
* 数字、模拟、比对
@@ -65,4 +58,23 @@ public class PreDetectionParam {
* 自动生成,用于生成数据表后缀
*/
private String code;
private Boolean sendWebMsg;
private String userId;
/**
* 温度
*/
private Float temperature;
/**
* 相对湿度
*/
private Float humidity;
/**
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
*/
private List<Boolean> testItemList;
}

View File

@@ -0,0 +1,40 @@
package com.njcn.gather.detection.pojo.param;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author caozehui
* @data 2025-03-06
*/
@Data
public class SimulateDetectionParam {
/**
* 操作类型 9.模拟检测
*/
private String operateType = "9";
/**
* 用户功能组成唯一标识 zhangsan_test
*/
private String userPageId;
/**
* 检测脚本Id
*/
private String scriptId;
@NotNull(message = DetectionValidMessage.INDEX_NOT_NULL)
private Integer scriptIndex;
/**
* 源id
*/
@NotBlank(message = DetectionValidMessage.SOURCE_ID_NOT_BLANK)
private String sourceId;
}

View File

@@ -18,6 +18,9 @@ public class DevData {
@JSONField(name = "Time", ordinal = 1)
private String time;
/**
* 设备ip_通道号 这种形式
*/
@JSONField(name = "ID", ordinal = 2)
private String id;

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 java.math.BigDecimal;
/**
* @author wr
* @description
@@ -18,7 +20,7 @@ public class DetectionData {
private Double num;
/**
* 是否是符合数据
* 1.合格 2.不合格 3.网络超时 4.无法处理 5.不参与误差比较
*/
private Integer isData;
@@ -37,4 +39,13 @@ public class DetectionData {
*/
private String radius;
/**
* 误差值
*/
private BigDecimal errorData;
/**
* 单位
*/
private String unit;
}

View File

@@ -1,7 +1,8 @@
package com.njcn.gather.detection.service;
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
/**
@@ -13,7 +14,8 @@ public interface PreDetectionService {
/**
* 源通讯校验socket入参拼接
* @param param
*
* @param param
* @Author: wr
* @Date: 2024/12/11 13:26
*/
@@ -23,14 +25,35 @@ public interface PreDetectionService {
void coefficientCheck(PreDetectionParam param);
boolean startTest(PreDetectionParam param);
boolean temStopTest();
boolean restartTemTest(PreDetectionParam param);
/**
* 模拟测试-源通讯校验
*
* @param param
*/
void ytxCheckSimulate(SimulateDetectionParam param);
/**
* 模拟测试-向源发送脚本
*
* @param param
*/
void sendScript(SimulateDetectionParam param);
/**
* 模拟测试-停止
*
* @param param
*/
void closeTestSimulate(SimulateDetectionParam param);
/**
*
* @param param
*/
void startContrastTest(ContrastDetectionParam param);
}

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

@@ -1,55 +1,68 @@
package com.njcn.gather.detection.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.detection.handler.SocketContrastResponseService;
import com.njcn.gather.detection.handler.SocketDevResponseService;
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.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
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.util.business.DetectionCommunicateUtil;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.FormalTestManager;
import com.njcn.gather.detection.util.socket.SocketManager;
import com.njcn.gather.detection.util.socket.WebServiceManager;
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.pojo.po.AdPlanSource;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.plan.service.IAdPlanSourceService;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.gather.source.pojo.po.SourceInitialize;
import com.njcn.gather.source.service.IPqSourceService;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.pojo.po.AdPlanSource;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.plan.service.IAdPlanSourceService;
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import io.netty.channel.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Slf4j
public class PreDetectionServiceImpl implements PreDetectionService {
private final String source = "_Source";
private final String dev = "_Dev";
private final String stepTag = "&&";
private final String handlerSourceStr = "_Source";
private final IPqDevService iPqDevService;
private final IDictDataService dictDataService;
@@ -60,26 +73,32 @@ public class PreDetectionServiceImpl implements PreDetectionService {
private final SocketDevResponseService socketDevResponseService;
private final SocketSourceResponseService socketSourceResponseService;
private final SocketContrastResponseService socketContrastResponseService;
private final IPqScriptCheckDataService iPqScriptCheckDataService;
@Value("${socket.source.ip:192.168.1.136}")
@Value("${socket.source.ip:192.168.1.138}")
private String ip;
@Value("${socket.source.port:10086}")
@Value("${socket.source.port:61000}")
private Integer port;
private final SocketSourceResponseService sourceResponseService;
//private final SocketSourceResponseService sourceResponseService;
@Override
public void sourceCommunicationCheck(PreDetectionParam param) {
commCheck(param);
specialDeal(param);
// 参数校验目前仅检查IP是否重复后续可在里面扩展
checkDevIp(param.getDevIds());
//用于处理异常导致的socket通道未关闭socket交互异常
DetectionCommunicateUtil.checkCommunicateChannel(param);
/*
先组装源通讯协议
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
*/
AdPlan plan = iAdPlanService.getById(param.getPlanId());
param.setScriptId(plan.getScriptId());
param.setErrorSysId(plan.getErrorSysId());
param.setCode(String.valueOf(plan.getCode()));
if (ObjectUtil.isNotNull(plan)) {
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
@@ -100,7 +119,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override
public void coefficientCheck(PreDetectionParam param) {
specialDeal(param);
// 检测是否存在连接的通道,后期需要做成动态,如果组合中不是第一位,则不需要关闭,也不用初始化 todo....
DetectionCommunicateUtil.checkCommunicateChannel(param);
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
.eq(AdPlanSource::getPlanId, param.getPlanId())
);
@@ -115,7 +135,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
msg.setData(JSON.toJSONString(sourceParam));
param.setSourceId(sourceParam.getSourceId());
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
// NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, socketSourceResponseService));
} else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
}
@@ -126,24 +147,23 @@ public class PreDetectionServiceImpl implements PreDetectionService {
private void sendYtxSocket(PreDetectionParam param) {
AdPlan plan = iAdPlanService.getById(param.getPlanId());
WebServiceManager.addPreDetectionParam(param);
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
param.setSourceId(planSource.getSourceId());
param.setScriptId(plan.getScriptId());
param.setErrorSysId(plan.getErrorSysId());
param.setCode(String.valueOf(plan.getCode()));
if (ObjectUtil.isNotNull(planSource)) {
//获取源初始化参数
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
if (ObjectUtil.isNotNull(sourceParam)) {
//开始组装socket报文请求头
socketDevResponseService.initList(param);
socketSourceResponseService.initList(param);
SocketMsg<String> msg = new SocketMsg<>();
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
msg.setData(JSON.toJSONString(sourceParam));
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
socketMsg.setData(JSON.toJSONString(sourceParam));
//建立与源控程序的socket连接
// NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, socketSourceResponseService));
} else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
}
@@ -152,13 +172,19 @@ 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;
private void sendYtxSocketSimulate(PreDetectionParam param) {
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
param.setSourceId(sourceParam.getSourceId());
WebServiceManager.addPreDetectionParam(param);
if (ObjectUtil.isNotNull(sourceParam)) {
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
socketMsg.setData(JSON.toJSONString(sourceParam));
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, socketSourceResponseService));
} else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
}
}
@Override
@@ -170,6 +196,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override
public boolean restartTemTest(PreDetectionParam param) {
FormalTestManager.stopFlag = false;
socketDevResponseService.initRestart();
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
if (CollUtil.isNotEmpty(sourceIssueList)) {
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
@@ -177,56 +204,138 @@ public class PreDetectionServiceImpl implements PreDetectionService {
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
xuMsg.setData(JSON.toJSONString(sourceIssues));
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(xuMsg));
SocketManager.sendMsg(param.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
} else {
//TODO 是否最终检测完成需要推送给用户
PqScriptCheckDataParam checkDataParam=new PqScriptCheckDataParam();
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
checkDataParam.setScriptId(param.getScriptId());
checkDataParam.setIsValueTypeName(false);
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);
}
return true;
}
@Override
public void ytxCheckSimulate(SimulateDetectionParam param) {
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setSourceId(param.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId());
preDetectionParam.setSendWebMsg(true);
/**
* 对重复发起或者异常发起的检测进行关闭源操作
* @param param
*/
private void specialDeal(PreDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
if (Objects.nonNull(channel) && channel.isActive()) {
System.out.println("进入关闭源。。//////");
CnSocketUtil.quitSendSource(param);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
SocketManager.removeUser(param.getUserPageId() + source);
SocketManager.removeUser(param.getUserPageId() + dev);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
DetectionCommunicateUtil.checkCommunicateChannel(preDetectionParam);
sendYtxSocketSimulate(preDetectionParam);
}
@Override
public void sendScript(SimulateDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
if (Objects.isNull(channel) || !channel.isActive()) {
// 进行源通信连接
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setSourceId(param.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId());
preDetectionParam.setSendWebMsg(false);
this.sendYtxSocketSimulate(preDetectionParam);
}
//组装源控制脚本
PqScriptIssueParam issueParam = new PqScriptIssueParam();
issueParam.setSourceId(param.getSourceId());
issueParam.setScriptId(param.getScriptId());
issueParam.setType(1);
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
sourceIssues = sourceIssues.stream()
.filter(s -> s.getIndex().equals(param.getScriptIndex()))
.collect(Collectors.toList());
SourceIssue sourceIssue = sourceIssues.get(0);
List<String> comm = sourceIssue.getDevValueTypeList();
System.out.println("向装置下发的参数ddd>>>>>>>>" + comm);
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
}
@Override
public void closeTestSimulate(SimulateDetectionParam param) {
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + DetectionCommunicateConstant.SOURCE);
if (Objects.isNull(channel) || !channel.isActive()) {
throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT);
}
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setSourceId(sourceParam.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId());
CnSocketUtil.quitSendSource(preDetectionParam);
WebServiceManager.removePreDetectionParam();
}
@Override
public void startContrastTest(ContrastDetectionParam param) {
// 参数校验目前仅检查IP是否重复后续可在里面扩展
checkDevIp(param.getDevIds());
//用于处理异常导致的socket通道未关闭socket交互异常
DetectionCommunicateUtil.checkContrastCommunicateChannel(param.getUserId());
socketContrastResponseService.init(param);
// 和通信模块进行连接
this.sendContrastSocket(param);
}
/**
* 校验
* 比对式-与通信模块进行连接
*
* @param param
*/
private void commCheck(PreDetectionParam param){
List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds());
private void sendContrastSocket(ContrastDetectionParam param) {
String s = param.getUserId() + CnSocketUtil.DEV_TAG;
Map<String, List<PreDetection>> map = new HashMap<>(1);
List<PreDetection> preDetections = BeanUtil.copyToList(FormalTestManager.devList, PreDetection.class);
preDetections.addAll(BeanUtil.copyToList(FormalTestManager.standardDevList, PreDetection.class));
preDetections.forEach(x -> {
x.setDevType(x.getIcdType());
x.getMonitorList().forEach(y -> {
String pt = y.getPt();
int i = pt.indexOf(":");
y.setPt(BigDecimal.valueOf(Double.parseDouble(pt.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(pt.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP) + "");
String ct = y.getCt();
i = ct.indexOf(":");
y.setCt(BigDecimal.valueOf(Double.parseDouble(ct.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(ct.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP) + "");
});
});
map.put("deviceList", preDetections);
String jsonString = JSON.toJSONString(map);
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
socketMsg.setData(jsonString);
String json = JSON.toJSONString(socketMsg);
SocketManager.sendMsg(s, json);
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setUserPageId(param.getUserId());
NettyClient.socketClient(ip, port, preDetectionParam, json, new NettyContrastClientHandler(preDetectionParam, socketContrastResponseService));
}
/**
* 校验被检设备中是否存在IP重复的
*/
private void checkDevIp(List<String> devIds) {
List<PqDev> pqDevList = iPqDevService.listByIds(devIds);
List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList());
if(ipList.size()!=param.getDevIds().size()){
if (ipList.size() != devIds.size()) {
throw new BusinessException(DetectionResponseEnum.PLAN_DEV_IP_HAS);
}
}

View File

@@ -0,0 +1,219 @@
package com.njcn.gather.detection.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.gather.detection.pojo.po.DevData;
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author caozehui
* @data 2025-07-28
*/
public class DetectionUtil {
/**
* 相角矫正到统一个区间
*
* @param phase
* @return
*/
public static Double adjustPhase(Double phase) {
if (phase < -180) {
return phase + 360;
}
if (phase > 180) {
return phase - 360;
}
return phase;
}
/**
* 判断数据是否对齐
*
* @param devData 被检设备数据
* @param standardDevData 标准设备数据
* @return
*/
public static boolean isAlignData(DevData devData, DevData standardDevData) {
if (ObjectUtil.isNotNull(devData) && ObjectUtil.isNotNull(standardDevData)) {
long devMillis = getMillis(devData.getTime());
long standardMillis = getMillis(standardDevData.getTime());
if (BigDecimal.valueOf(devMillis).divide(BigDecimal.valueOf(10), 0, BigDecimal.ROUND_HALF_UP).compareTo(BigDecimal.valueOf(standardMillis).divide(BigDecimal.valueOf(10), 0, BigDecimal.ROUND_HALF_UP)) == 0) {
return true;
} else if (Math.abs(devMillis - standardMillis) < 100) {
return true;
}
}
return false;
}
/**
* 将字符串日期时间转换为指定格式的LocalDateTime
*
* @param dateTimeStr
* @param formatter
* @return
*/
public static LocalDateTime timeFormat(String dateTimeStr, DateTimeFormatter formatter) {
try {
ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateTimeStr, formatter.withZone(ZoneId.of("UTC")));
LocalDateTime localDateTime = zonedDateTime.toLocalDateTime();
return localDateTime;
} catch (DateTimeParseException e) {
System.err.println("日期时间字符串格式错误: " + e.getMessage());
return null;
}
}
/**
* 获取字符串日期时间对应的毫秒数
*
* @param dateTimeStr
* @return
*/
public static long getMillis(String dateTimeStr) {
LocalDateTime localDateTime = timeFormat(dateTimeStr, DateTimeFormatter.ISO_DATE_TIME);
return getMillis(localDateTime);
}
/**
* 获取LocalDateTime的所对应的毫秒数
*
* @param localDateTime
* @return
*/
public static long getMillis(LocalDateTime localDateTime) {
return localDateTime.atZone(ZoneId.of("UTC")).toInstant().toEpochMilli();
}
/**
* 判断value是否为0
* @param value
* @return
*/
public static boolean isZero(Double value) {
BigDecimal bd = BigDecimal.valueOf(value);
if(bd.subtract(BigDecimal.ZERO).abs().compareTo(BigDecimal.valueOf(0.001)) < 0){
return true;
}
return false;
}
/**
* 获取CP95值
*
* @param t
* @return
*/
public static List<Double> getCP95Doubles(List<Double> t) {
if (CollUtil.isNotEmpty(t)) {
if (t.size() < 21) {
if (t.size() == 1) {
return t;
}
if (t.size() > 1) {
return t.subList(1, 2);
}
} else {
int v = (int) (t.size() * 0.5);
return t.subList(v, v + 1);
}
}
return t;
}
/**
* 获取CP95值所在索引
*
* @param t
* @return
*/
public static int getCP95Idx(List<Double> t) {
if (CollUtil.isNotEmpty(t)) {
if (t.size() < 21) {
if (t.size() == 1) {
return 0;
}
if (t.size() > 1) {
return 1;
}
} else {
int v = (int) (t.size() * 0.5);
return v;
}
}
return -1;
}
/**
* 获取部分值
*
* @param t
* @return
*/
public static List<Double> getSectionValueDoubles(List<Double> t) {
if (CollUtil.isNotEmpty(t)) {
if (t.size() > 2) {
Double max = Collections.max(t);
Double min = Collections.min(t);
t.remove(max);
t.remove(min);
}
}
return t;
}
/**
* 获取平均值
*
* @param t
* @return
*/
public static List<Double> getAvgDoubles(List<Double> t) {
if (CollUtil.isNotEmpty(t)) {
t = Arrays.asList(t.stream().mapToDouble(Double::doubleValue).average().orElse(0.0));
}
return t;
}
/**
* 对list进行从大到小排序并返回排序后的索引序列
*
* @param list
* @return
*/
public static List<Integer> sort(List<Double> list) {
List<Integer> indexList = Stream.iterate(0, i -> i + 1).limit(list.size()).collect(Collectors.toList());
for (int i = 0; i < list.size(); i++) {
int maxIdx = i;
for (int j = i + 1; j < list.size(); j++) {
if (list.get(j) > list.get(maxIdx)) {
maxIdx = j;
}
}
if (maxIdx != i) {
double temp = list.get(i);
list.set(i, list.get(maxIdx));
list.set(maxIdx, temp);
int tempIdx = indexList.get(i);
indexList.set(i, indexList.get(maxIdx));
indexList.set(maxIdx, tempIdx);
}
}
return indexList;
}
}

View File

@@ -0,0 +1,83 @@
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());
}
}
/**
* 比对式-检测是否存在已有的Socket通道有则强行关闭
*
* @param userId
*/
public static void checkContrastCommunicateChannel(String userId) {
Channel channel = SocketManager.getChannelByUserId(userId);
if (Objects.nonNull(channel) && channel.isActive()) {
System.out.println("存在已有的Socket通道强行关闭。。。。。。。。");
CnSocketUtil.contrastSendquit(userId);
}
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
SocketManager.removeUser(userId);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
}

View File

@@ -14,8 +14,17 @@ import com.njcn.gather.detection.pojo.vo.WebSocketVO;
*/
public class CnSocketUtil {
private final static String devTag = "_Dev";
private final static String sourceTag = "_Source";
public final static String DEV_TAG = "_Dev";
public final static String SOURCE_TAG = "_Source";
public final static String START_TAG = "_Start";
public final static String END_TAG = "_End";
public final static String STEP_TAG = "&&";
public final static String SPLIT_TAG = "_";
/**
* 退出检测
@@ -24,7 +33,8 @@ public class CnSocketUtil {
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
SocketManager.sendMsg(param.getUserPageId() + devTag, JSON.toJSONString(socketMsg));
SocketManager.sendMsg(param.getUserPageId() + DEV_TAG, JSON.toJSONString(socketMsg));
WebServiceManager.removePreDetectionParam();
}
/**
@@ -37,30 +47,44 @@ public class CnSocketUtil {
JSONObject jsonObject = new JSONObject();
jsonObject.put("sourceId", param.getSourceId());
socketMsg.setData(jsonObject.toJSONString());
SocketManager.sendMsg(param.getUserPageId() + sourceTag, JSON.toJSONString(socketMsg));
SocketManager.sendMsg(param.getUserPageId() + SOURCE_TAG, JSON.toJSONString(socketMsg));
WebServiceManager.removePreDetectionParam();
}
/**
* 推送webSocket数据
*/
public static void sendToWebSocket(String userId, String requestId, String operatorType, Object data, String desc){
public static void sendToWebSocket(String userId, String requestId, String operatorType, Object data, String desc) {
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
webSocketVO.setRequestId(requestId);
webSocketVO.setOperateCode(operatorType);
webSocketVO.setData(data);
webSocketVO.setDesc(desc);
WebServiceManager.sendMessage(userId,webSocketVO);
WebServiceManager.sendMessage(userId, webSocketVO);
}
/**
* 推送未知异常的webSocket数据
*/
public static void sendUnSocket(String userId){
public static void sendUnSocket(String userId) {
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue());
webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
webSocketVO.setOperateCode(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
WebServiceManager.sendMessage(userId,webSocketVO);
WebServiceManager.sendMessage(userId, webSocketVO);
}
/**
* 比对式-退出检测
*/
public static void contrastSendquit(String userId) {
System.out.println("比对式-发送关闭备通讯模块指令。。。。。。。。");
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
SocketManager.sendMsg(userId + DEV_TAG, JSON.toJSONString(socketMsg));
WebServiceManager.removePreDetectionParam();
}
}

View File

@@ -1,6 +1,11 @@
package com.njcn.gather.detection.util.socket;
import com.google.common.collect.HashBiMap;
import com.njcn.gather.detection.pojo.po.DevData;
import com.njcn.gather.device.pojo.po.PqStandardDev;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import java.util.ArrayList;
import java.util.HashMap;
@@ -11,57 +16,98 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* @Author: cdf
* @CreateTime: 2025-01-08
* @Description: 正式检测对象管理
* @Description: 正式(预)检测对象管理
*/
public class FormalTestManager {
/**
* key:设备ip,value:当前设备下面的通道
* key:设备ip,value:当前设备下面的通道号
*/
public static Map<String,List<String>> devMapMonitorNum = new ConcurrentHashMap<>();
public static Map<String, List<String>> devMapMonitorNum = new ConcurrentHashMap<>();
/**
* 所有参与检测的装置
* 所有参与检测的被检设备
*/
public static List<PreDetection> devList = new ArrayList<>();
/**
* 所有参与检测的标准设备
*/
public static List<PreDetection> standardDevList = new ArrayList<>();
/**
* 所有参与检测的监测点
*/
public static List<String> monitorIdListComm = new ArrayList<>();
/**
* 所有参与检测的监测点。key:监测点idip_通道号,value:检测点实体
*/
public static Map<String, PreDetection.MonitorListDTO> monitorMap = new HashMap<>();
/**
* 用于存储所有测点的实时数据
*/
public static List<DevData> realDataXiList = new ArrayList<>();
/**
* key:设备ip,value:装置名称
*/
public static Map<String, String> devNameMapComm = new HashMap<>();
/**
* key:设备ip,value:装置id
*/
public static Map<String, String> devIdMapComm = new HashMap<>();
/**
* 停止触发标识
*/
public static Boolean stopFlag = false;
/**
* 已经暂停后的标识
*/
public static Boolean hasStopFlag = false;
/**
* 暂停后的超时计时时间
*/
public static Integer stopTime = 0;
/**
* 强行赋值关系
*/
public static Map<String, String> harmonicRelationMap = new HashMap<>();
/**
* 当前正在检测的计划
*/
public static AdPlan currentTestPlan;
/**
* 比对式检测-检测项。
*/
public static List<String> testItemCodeList = new ArrayList<>();
/**
* 数据处理原则
*/
public static DictDataEnum dataRule;
/**
* 所有参与比对式检测的被检设备、标准设备配对关系。key:标准设备id_通道号,value:被检设备id_通道号
*/
public static Map<String, String> pairsMap = HashBiMap.create();
/**
* 被检设备的数据。key:设备ip_通道号,value:DevData数据集合
*/
public static Map<String, List<DevData>> devDataMap = new HashMap<>();
/**
* 标准设备的数据。key:设备ip_通道号,value:DevData数据集合
*/
public static Map<String, List<DevData>> standardDevDataMap = new HashMap<>();
}

View File

@@ -3,10 +3,7 @@ package com.njcn.gather.detection.util.socket;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
import com.njcn.gather.detection.pojo.vo.SocketMsg;
import java.util.Map;
@@ -19,9 +16,8 @@ import java.util.Map;
public class MsgUtil {
public static SocketDataMsg socketDataMsg(String textMsg){
return JSON.parseObject(textMsg,SocketDataMsg.class);
public static SocketDataMsg socketDataMsg(String textMsg) {
return JSON.parseObject(textMsg, SocketDataMsg.class);
}
/**
@@ -46,13 +42,12 @@ public class MsgUtil {
/**
*
* @param socketDataMsg
* @param devMap
* @param type 0.装置 1.监测点
* @param type 0.装置 1.监测点
* @return
*/
public static String msgToWebData(SocketDataMsg socketDataMsg, Map<String,String> devMap,Integer type){
public static String msgToWebData(SocketDataMsg socketDataMsg, Map<String, String> devMap, Integer type) {
String data = socketDataMsg.getData();
if (StrUtil.isNotBlank(data)) {
String[] parts = data.split("_");
@@ -60,17 +55,14 @@ public class MsgUtil {
String key = parts[0];
String newValue = devMap.get(key);
if (newValue != null) {
if(type == 0) {
if (type == 0) {
socketDataMsg.setData(newValue);
}else {
socketDataMsg.setData(newValue+"_"+parts[1]+"");
} else {
socketDataMsg.setData(newValue + "_" + parts[1] + "");
}
}
}
}
return JSON.toJSONString(socketDataMsg);
}
}

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.detection.util.socket;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
import com.njcn.gather.script.pojo.po.SourceIssue;
import io.netty.channel.Channel;
import io.netty.channel.nio.NioEventLoopGroup;
@@ -19,7 +19,14 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
public class SocketManager {
/**
* key为userIdxxx_Source、xxx_Devvalue为channel
*/
private static final Map<String, Channel> socketSessions = new ConcurrentHashMap<>();
/**
* key为userIdxxx_Source、xxx_Devvalue为group
*/
private static final Map<String, NioEventLoopGroup> socketGroup = new ConcurrentHashMap<>();
public static void addUser(String userId, Channel channel) {
@@ -88,6 +95,10 @@ public class SocketManager {
*/
public static volatile Map<Integer,Long> clockMap = new ConcurrentHashMap<>();
/**
* 用于存储比对式测试时间。
*/
public static volatile Map<DataSourceEnum, Long> contrastClockMap = new ConcurrentHashMap<>();

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

@@ -1,6 +1,7 @@
package com.njcn.gather.detection.util.socket;
import com.alibaba.fastjson.JSON;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
@@ -24,6 +25,8 @@ public class WebServiceManager {
//key:页面 value:channel
private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>();
// 检测参数。key固定为preDetectionParam, value:检测参数
private static final Map<String, PreDetectionParam> preDetectionParamMap = new ConcurrentHashMap<>();
public static void addUser(String userId, Channel channel) {
userSessions.put(userId, channel);
@@ -35,7 +38,7 @@ public class WebServiceManager {
Iterator<Map.Entry<String, Channel>> iterator = userSessions.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Channel> entry = iterator.next();
if (entry.getValue().id().equals(channelId)) {
if (entry.getValue().id().toString().equals(channelId)) {
iterator.remove();
}
}
@@ -52,6 +55,9 @@ public class WebServiceManager {
channel.writeAndFlush(wd);
}else {
log.error("{}-websocket推送消息失败;当前用户-{}-客户端已经断开连接", LocalDateTime.now(),userId);
// PreDetectionParam param = preDetectionParamMap.get("preDetectionParam");
// CnSocketUtil.quitSend(param);
// CnSocketUtil.quitSendSource(param);
}
}
@@ -66,5 +72,15 @@ public class WebServiceManager {
}
}
public static void addPreDetectionParam(PreDetectionParam preDetectionParam) {
preDetectionParamMap.put("preDetectionParam", preDetectionParam);
}
public static PreDetectionParam getPreDetectionParam() {
return preDetectionParamMap.get("preDetectionParam");
}
public static void removePreDetectionParam() {
preDetectionParamMap.clear();
}
}

View File

@@ -2,6 +2,7 @@ package com.njcn.gather.detection.util.socket;
import com.njcn.gather.detection.pojo.dto.DevXiNumData;
import com.njcn.gather.detection.pojo.vo.CoefficientVO;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.script.pojo.po.SourceIssue;
import java.util.ArrayList;
@@ -27,7 +28,7 @@ public class XiNumberManager {
public static List<String> devXiList = new ArrayList<>();
/**
* 存储所有测点的大电压系数
* 最开始存储装置通道原始系数后续存储大电压计算出来的系数。key为装置ip
*/
public static Map<String, DevXiNumData> devXiNumDataMap = new ConcurrentHashMap<>();
@@ -42,10 +43,19 @@ public class XiNumberManager {
public static Integer stepNumber = 0;
// 存放大电压、小电压、大电流、小电流的数值
public static List<CoefficientVO.DevParameter> devParameterList = new ArrayList<>();
/**
* 因为只支持单台装置获取系数,用于记录未获取到系数的装置,获取到一个删除一个
*/
public static List<PreDetection> xiDevList = new ArrayList<>();
}

View File

@@ -0,0 +1,111 @@
package com.njcn.gather.detection.util.socket.cilent;
import com.alibaba.fastjson.JSON;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.MsgUtil;
import com.njcn.gather.detection.util.socket.SocketManager;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* @Author: cdf
* @CreateTime: 2025-02-11
* @Description: 心跳处理类
*/
public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
private final ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
private final PreDetectionParam param;
private final String handlerType;
// 允许连续未收到心跳响应的最大次数
private static final int MAX_HEARTBEAT_MISSES = 3;
// 连续未收到心跳响应的次数
private int consecutiveHeartbeatMisses = 0;
public HeartbeatHandler(PreDetectionParam param, String type) {
this.param = param;
this.handlerType = type;
}
@Override
public void channelActive(ChannelHandlerContext ctx) {
// 启动心跳定时任务
scheduleHeartbeat(ctx);
ctx.fireChannelActive();
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
heartbeatExecutor.shutdown();
super.channelInactive(ctx);
}
// 每10秒发送一次心跳
private void scheduleHeartbeat(ChannelHandlerContext ctx) {
heartbeatExecutor.scheduleAtFixedRate(() -> {
if (ctx.channel().isActive()) {
// 发送心跳包
SocketMsg<String> msg = new SocketMsg<>();
msg.setRequestId("yxt");
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
msg.setData("");
ctx.channel().writeAndFlush(JSON.toJSONString(msg) + "\n");
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥send" + LocalDateTime.now());
consecutiveHeartbeatMisses++;
if (consecutiveHeartbeatMisses >= MAX_HEARTBEAT_MISSES) {
// 连续三次未收到心跳响应,断开连接
System.out.println(handlerType + "连续三次未收到心跳响应,断开连接");
if (CnSocketUtil.DEV_TAG.equals(handlerType)) {
//CnSocketUtil.sendToWebSocket(param.getUserPageId(),);
CnSocketUtil.quitSend(param);
} else {
CnSocketUtil.quitSendSource(param);
}
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.err.println("线程中断异常: " + e.getMessage());
}
String key = CnSocketUtil.DEV_TAG.equals(handlerType) ? param.getUserPageId() + CnSocketUtil.DEV_TAG : param.getUserPageId() + CnSocketUtil.SOURCE_TAG;
SocketManager.removeUser(key);
consecutiveHeartbeatMisses = 0; // 重置连续心跳丢失次数
}
}
}, 3, 10, TimeUnit.SECONDS);
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
// 过滤心跳包,避免进入业务逻辑
if (isHeartbeatPacket(msg)) {
System.out.println(handlerType + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥response" + LocalDateTime.now());
consecutiveHeartbeatMisses = 0;
return;
}
// 处理业务数据
ctx.fireChannelRead(msg);
}
private boolean isHeartbeatPacket(String msg) {
// 判断是否为心跳包
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
return !Objects.isNull(socketDataMsg.getOperateCode()) && socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.HEARTBEAT.getValue());
}
}

View File

@@ -46,18 +46,24 @@ public class NettyClient {
//空闲状态的handler
// 添加LineBasedFrameDecoder来按行分割数据
.addLast(new LineBasedFrameDecoder(10240))
.addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
// .addLast(new IdleStateHandler(0, 10, 0, TimeUnit.SECONDS))
.addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new HeartbeatHandler(param, CnSocketUtil.SOURCE_TAG))
.addLast(handler);
} else {
ch.pipeline()
//空闲状态的handler
// 添加LineBasedFrameDecoder来按行分割数据
.addLast(new LineBasedFrameDecoder(10240))
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
.addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new HeartbeatHandler(param, CnSocketUtil.DEV_TAG))
//空闲状态的handler
//readerIdleTimeSeconds在指定的秒数内如果没有读取到任何数据则触发IdleState.READER_IDLE事件。
//writerIdleTimeSeconds在指定的秒数内如果没有写入任何数据则触发IdleState.WRITER_IDLE事件。
//allIdleTimeSeconds在指定的秒数内如果没有发生任何读取或写入操作则触发IdleState.ALL_IDLE事件。
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
.addLast(handler);
}
@@ -67,22 +73,28 @@ public class NettyClient {
channelFuture.addListener((ChannelFutureListener) ch -> {
if (!ch.isSuccess()) {
System.out.println("链接服务端失败...");
// 连接失败时关闭 group
group.shutdownGracefully();
} else {
System.out.println("链接服务端成功...");
System.out.println("客户端向服务端发送消息:"+msg);
channelFuture.channel().writeAndFlush(msg+"\n");
if (handler instanceof NettySourceClientHandler) {
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + CnSocketUtil.SOURCE_TAG);
if (ObjectUtil.isNotNull(groupByUserId)) {
groupByUserId.shutdownGracefully().sync();
}
SocketManager.addGroup(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, group);
} else {
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
if (ObjectUtil.isNotNull(groupByUserId)) {
groupByUserId.shutdownGracefully().sync();
}
SocketManager.addGroup(param.getUserPageId() + CnSocketUtil.DEV_TAG, group);
}
System.out.println("客户端向服务端发送消息:" + port + msg);
channelFuture.channel().writeAndFlush(msg + "\n");
}
});
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + "_Dev");
if(ObjectUtil.isNotNull(groupByUserId)){
groupByUserId.shutdownGracefully();
}else{
if (handler instanceof NettySourceClientHandler) {
SocketManager.addGroup(param.getUserPageId()+"_Source",group);
}else{
SocketManager.addGroup(param.getUserPageId()+"_Dev",group);
}
}
} catch (Exception e) {
System.out.println("连接socket服务端发送异常............" + e.getMessage());
group.shutdownGracefully();
@@ -94,9 +106,12 @@ public class NettyClient {
socketDataMsg.setRequestId("connect");
if (handler instanceof NettySourceClientHandler) {
socketDataMsg.setOperateCode("Source");
}else{
} else if (handler instanceof NettyDevClientHandler) {
CnSocketUtil.quitSendSource(param);
socketDataMsg.setOperateCode("Dev");
} else {
socketDataMsg.setOperateCode("Dev");
CnSocketUtil.quitSend(param);
}
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
} finally {

View File

@@ -0,0 +1,181 @@
package com.njcn.gather.detection.util.socket.cilent;
import com.njcn.gather.detection.handler.SocketContrastResponseService;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
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 com.njcn.gather.plan.pojo.enums.DataSourceEnum;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.TimeoutException;
import lombok.RequiredArgsConstructor;
import java.io.IOException;
import java.net.ConnectException;
import java.net.ProtocolException;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* @author caozehui
* @data 2025-07-25
*/
@RequiredArgsConstructor
public class NettyContrastClientHandler extends SimpleChannelInboundHandler<String> {
private final PreDetectionParam param;
private final SocketContrastResponseService socketContrastResponseService;
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
System.out.println("客户端通道已建立" + ctx.channel().id());
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
if (Objects.nonNull(channel)) {
try {
channel.close().sync();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
SocketManager.addUser(param.getUserPageId() + CnSocketUtil.DEV_TAG, ctx.channel());
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws InterruptedException {
System.out.println("contrastClientHandler接收server端数据>>>>>>" + msg);
try {
socketContrastResponseService.deal(param, msg);
} catch (Exception e) {
e.printStackTrace();
CnSocketUtil.quitSend(param);
}
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
System.out.println("与通信模块端断线");
ctx.close();
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.DEV_TAG);
}
/**
* 用户事件的回调方法(自定义事件用于心跳机制)
*
* @param ctx
* @param evt
*/
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof IdleStateEvent) { //IdleState.在一段时间内没有收到任何消息时,会触发该事件
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
System.out.println(LocalDateTime.now() + "contrastClientHandler触发读超时函数**************************************");
SocketManager.contrastClockMap.put(DataSourceEnum.REAL_DATA, SocketManager.contrastClockMap.get(DataSourceEnum.REAL_DATA) + 60L);
//实时数据
if (SocketManager.contrastClockMap.get(DataSourceEnum.REAL_DATA) >= 60) {
CnSocketUtil.quitSend(param);
System.out.println("超时处理-----》" + "实时数据已超时----------------关闭");
timeoutSend();
}
// if (!FormalTestManager.hasStopFlag) {
// if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
// SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
// if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
// SocketManager.clockMap.put(sourceIssue.getIndex(), SocketManager.clockMap.get(sourceIssue.getIndex()) + 60L);
// } else {
// SocketManager.clockMap.put(sourceIssue.getIndex(), 60L);
// }
//
// if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
// //闪变,正常抛一轮最大等待20分钟超时
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 1300) {
// fly = true;
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
// CnSocketUtil.quitSend(param);
// timeoutSend(sourceIssue);
// }
// } else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
// //统计数据项,正常抛一轮数据,超时
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 180) {
// fly = true;
// CnSocketUtil.quitSend(param);
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
// timeoutSend(sourceIssue);
// }
// } else {
// //实时数据
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 60) {
// fly = true;
// CnSocketUtil.quitSend(param);
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
// timeoutSend(sourceIssue);
// }
// }
// } else {
// fly = true;
// //为空则认为是常规步骤,设定一分钟超时
// CnSocketUtil.quitSend(param);
// CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg(), null);
// }
// if (fly) {
// socketContrastResponseService.backCheckState(param);
// }
// } else {
// //如果是暂停操作后
// FormalTestManager.stopTime += 60;
// System.out.println("当前进入暂停操作超时函数-----------------" + FormalTestManager.stopTime);
// if (FormalTestManager.stopTime > 600) {
// CnSocketUtil.quitSend(param);
// CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.FORMAL_REAL.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(), null);
// }
// }
}
}
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
System.out.println("有通道准备接入" + ctx.channel());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
System.out.println("捕获到通信模块服务异常。。。。。。。");
// 处理异常,例如记录日志、关闭连接等
cause.printStackTrace();
// 根据异常类型进行不同的处理
if (cause instanceof ConnectException) {
System.out.println("连接socket服务端异常");
} else if (cause instanceof IOException) {
System.out.println("IOException caught: There was an I/O error.");
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
} else if (cause instanceof TimeoutException) {
System.out.println("TimeoutException caught: Operation timed out.");
} else if (cause instanceof ProtocolException) {
System.out.println("ProtocolException caught: Invalid protocol message.");
} else {
// 处理其他类型的异常
System.out.println("Unknown exception caught: " + cause.getMessage());
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
}
CnSocketUtil.quitSend(param);
// socketContrastResponseService.backCheckState(param);
ctx.close();
}
/**
* 接收数据超时处理
*/
private void timeoutSend() {
}
}

View File

@@ -7,7 +7,10 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
import com.njcn.gather.detection.util.socket.*;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.FormalTestManager;
import com.njcn.gather.detection.util.socket.SocketManager;
import com.njcn.gather.detection.util.socket.WebServiceManager;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.script.pojo.po.SourceIssue;
import com.njcn.gather.system.pojo.enums.DicDataEnum;
@@ -22,6 +25,7 @@ import lombok.RequiredArgsConstructor;
import java.io.IOException;
import java.net.ConnectException;
import java.net.ProtocolException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -36,8 +40,6 @@ import java.util.Objects;
@RequiredArgsConstructor
public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
private final String dev = "_Dev";
private final PreDetectionParam param;
private final SocketDevResponseService socketResponseService;
@@ -51,7 +53,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
System.out.println("客户端通道已建立" + ctx.channel().id());
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
if (Objects.nonNull(channel)) {
try {
channel.close().sync();
@@ -59,7 +61,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
e.printStackTrace();
}
}
SocketManager.addUser(param.getUserPageId() + dev, ctx.channel());
SocketManager.addUser(param.getUserPageId() + CnSocketUtil.DEV_TAG, ctx.channel());
}
/**
@@ -74,8 +76,6 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
e.printStackTrace();
CnSocketUtil.quitSend(param);
}
}
/**
@@ -87,7 +87,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
System.out.println("设备通讯客户端断线");
ctx.close();
SocketManager.removeUser(param.getUserPageId() + dev);
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.DEV_TAG);
CnSocketUtil.quitSendSource(param);
}
@@ -100,9 +100,10 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
Boolean fly = false;
if (evt instanceof IdleStateEvent) {
if (evt instanceof IdleStateEvent) { //IdleState.在一段时间内没有收到任何消息时,会触发该事件
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
if(!FormalTestManager.hasStopFlag) {
System.out.println(LocalDateTime.now() + "devHandler触发读超时函数**************************************");
if (!FormalTestManager.hasStopFlag) {
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
@@ -114,7 +115,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
//闪变,正常抛一轮最大等待20分钟超时
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 1300) {
fly=true;
fly = true;
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
CnSocketUtil.quitSend(param);
timeoutSend(sourceIssue);
@@ -122,37 +123,36 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
} else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
//统计数据项,正常抛一轮数据,超时
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 180) {
fly=true;
fly = true;
CnSocketUtil.quitSend(param);
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
timeoutSend(sourceIssue);
}
} else {
//实时数据
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 60) {
fly=true;
fly = true;
CnSocketUtil.quitSend(param);
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
timeoutSend(sourceIssue);
}
}
} else {
fly=true;
fly = true;
//为空则认为是常规步骤,设定一分钟超时
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);
}
System.out.println("已经等了一分钟了。。。。。。。。。。。。");
}else {
} else {
//如果是暂停操作后
FormalTestManager.stopTime+=60;
System.out.println("当前进入暂停操作超时函数-----------------"+FormalTestManager.stopTime);
if(FormalTestManager.stopTime > 600){
FormalTestManager.stopTime += 60;
System.out.println("当前进入暂停操作超时函数-----------------" + FormalTestManager.stopTime);
if (FormalTestManager.stopTime > 600) {
CnSocketUtil.quitSend(param);
CnSocketUtil.sendToWebSocket(param.getUserPageId(),SourceOperateCodeEnum.FORMAL_REAL.getValue(),SourceOperateCodeEnum.STOP_TIMEOUT.getValue(),SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(),null);
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.FORMAL_REAL.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(), null);
}
}
}
@@ -162,8 +162,6 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
System.out.println("有通道准备接入" + ctx.channel());
@@ -183,7 +181,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
} else if (cause instanceof IOException) {
// 处理I/O异常例如读写错误
System.out.println("IOException caught: There was an I/O error.");
CnSocketUtil.sendToWebSocket(param.getUserPageId(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getMsg(),null );
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
// 例如可以记录更详细的I/O错误信息
} else if (cause instanceof TimeoutException) {
@@ -197,18 +195,37 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
} else {
// 处理其他类型的异常
System.out.println("Unknown exception caught: " + cause.getMessage());
CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getValue(), SourceOperateCodeEnum.DEVICE_ERROR.getMsg(), null);
// 可以记录未知异常信息
}
CnSocketUtil.quitSend(param);
CnSocketUtil.quitSendSource(param);
socketResponseService.backCheckState(param);
ctx.close();
}
/**
*
* 发送业务消息时候开启计时器,
* @param requestId
*/
private void timeoutSend(SourceIssue sourceIssue){
/* private void scheduleTimeoutTask(String requestId) {
ScheduledFuture<?> future = scheduler.schedule(() -> {
if (requestTimeoutTasks.containsKey(requestId)) {
// 处理超时逻辑
System.out.println("Business request with ID " + requestId + " timed out.");
requestTimeoutTasks.remove(requestId);
ctx.close();
}
}, BUSINESS_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS);
requestTimeoutTasks.put(requestId, future);
}*/
/**
* 超时后的处理
*/
private void timeoutSend(SourceIssue sourceIssue) {
List<DevLineTestResult> devListRes = new ArrayList<>();
FormalTestManager.devList.forEach(dev -> {
DevLineTestResult devLineTestResult = new DevLineTestResult();
@@ -221,7 +238,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
devListRes.add(devLineTestResult);
});
WebSocketVO<List<DevLineTestResult>> socketVO = new WebSocketVO<>();
socketVO.setRequestId(sourceIssue.getType()+"_End");
socketVO.setRequestId(sourceIssue.getType() + CnSocketUtil.END_TAG);
socketVO.setOperateCode(sourceIssue.getType());
socketVO.setData(devListRes);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));

View File

@@ -1,16 +1,10 @@
package com.njcn.gather.detection.util.socket.cilent;
import com.alibaba.fastjson.JSON;
import com.njcn.gather.detection.handler.SocketSourceResponseService;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
import com.njcn.gather.detection.pojo.vo.SocketMsg;
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.MsgUtil;
import com.njcn.gather.detection.util.socket.SocketManager;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.timeout.IdleState;
@@ -21,7 +15,6 @@ import lombok.RequiredArgsConstructor;
import java.io.IOException;
import java.net.ConnectException;
import java.net.ProtocolException;
import java.util.Objects;
/**
@@ -71,10 +64,10 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
* @param ctx
*/
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception{
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
System.out.println("源通讯客户端断线");
ctx.close();
SocketManager.removeUser(webUser.getUserPageId()+sourceTag);
SocketManager.removeUser(webUser.getUserPageId() + sourceTag);
// System.out.println("断线了......" + ctx.channel());
// ctx.channel().eventLoop().schedule(() -> {
// System.out.println("断线重连......");
@@ -95,11 +88,11 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
if (evt instanceof IdleStateEvent) {
if (((IdleStateEvent) evt).state() == IdleState.WRITER_IDLE) {
//发送ping 保持心跳链接
SocketMsg msg = new SocketMsg();
/* SocketMsg<String> msg = new SocketMsg<>();
msg.setRequestId("yxt");
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
msg.setData("");
ctx.writeAndFlush(JSON.toJSONString(msg)+"\n");
ctx.writeAndFlush(JSON.toJSONString(msg)+"\n");*/
}
} else {
//防止堆栈溢出
@@ -125,7 +118,8 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
} else if (cause instanceof IOException) {
// 处理I/O异常例如读写错误
CnSocketUtil.sendToWebSocket(webUser.getUserPageId(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getValue(),SourceOperateCodeEnum.SERVER_ERROR.getMsg(),null );
CnSocketUtil.sendToWebSocket(webUser.getUserPageId(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getValue(), SourceOperateCodeEnum.SERVER_ERROR.getMsg(), null);
// 例如可以记录更详细的I/O错误信息
} else if (cause instanceof TimeoutException) {
// 处理超时异常

View File

@@ -0,0 +1,149 @@
package com.njcn.gather.detection.util.socket.service;
import com.alibaba.fastjson.JSONObject;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
import com.njcn.gather.detection.util.socket.MsgUtil;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import java.util.Objects;
/**
* @Description: 客户端业务处理
* @Author: wr
* @Date: 2024/12/10 14:18
*/
public class DevNettyServerHandler extends SimpleChannelInboundHandler<String> {
private final String DEV = "_Dev";
private final String source = "_Source";
private final String stepTag = "&&";
private final String stepBegin = "_Start";
private final String stepEnd = "_End";
public static final DevNettyServerHandler INSTANCE = new DevNettyServerHandler();
/**
* @Description: 当通道进行连接时推送消息
* @Author: wr
* @Date: 2024/12/10 14:19
*/
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
System.out.println("服务端监听到" + ctx.channel().id() + "连接");
super.channelActive(ctx);
}
/**
* 处理消息信息
*/
@Override
public void channelRead0(ChannelHandlerContext ctx, String msg) {
System.out.println(ctx.channel().id() + "NettyServer服务端接收到客户端消息" + msg);
Channel channel = ctx.channel();
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
String[] tem = socketDataMsg.getRequestId().split(stepTag);
SourceOperateCodeEnum sourceOperateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
//设备通讯校验
case YJC_SBTXJY:
String aa = "{\"requestId\":\"yjc_sbtxjy\",\"operateCode\":\"INIT_GATHER$01\",\"data\":null,\"code\":10201}";
String bb = "{\"requestId\":\"yjc_sbtxjy\",\"operateCode\":\"INIT_GATHER$01\",\"data\":null,\"code\":10201}";
String cc = "{\"requestId\":\"yjc_sbtxjy\",\"operateCode\":\"INIT_GATHER$01\",\"data\":\"192.168.1.237_1\",\"code\":10200}";
channel.writeAndFlush(aa+"\n");
channel.writeAndFlush(bb+"\n");
channel.writeAndFlush(cc+"\n");
break;
//协议校验
case YJC_XYJY:
String dd="{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$02\",\"data\":null,\"code\":10201}";
String ee = "{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$02\",\"data\":\"192.168.1.237_1\",\"code\":10200}";
channel.writeAndFlush(dd+"\n");
channel.writeAndFlush(ee+"\n");
String ff = "{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$03\",\"data\":null,\"code\":10201}";
String gg ="{\"requestId\":\"yjc_xyjy\",\"operateCode\":\"INIT_GATHER$03\",\"data\":\"192.168.1.237_1\",\"code\":10200}";
channel.writeAndFlush(ff+"\n");
channel.writeAndFlush(gg+"\n");
break;
//相序校验
case YJC_XUJY:
String hh = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"DATA_REQUEST$02\",\"data\":null,\"code\":10201}";
String ii = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"DATA_REQUEST$02\",\"data\":\"{\\\"Time\\\":\\\"2025-02-14T15:09:06.004\\\",\\\"ID\\\":\\\"192.168.1.237_1\\\",\\\"result\\\":false,\\\"SqlData\\\":[{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"VRMS\\\",\\\"list\\\":{\\\"A\\\":\\\"59.969920\\\",\\\"B\\\":\\\"49.963360\\\",\\\"C\\\":\\\"39.971470\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"VA\\\",\\\"list\\\":{\\\"A\\\":\\\"0.000000\\\",\\\"B\\\":\\\"-119.864000\\\",\\\"C\\\":\\\"120.052000\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"IRMS\\\",\\\"list\\\":{\\\"A\\\":\\\"1.000979\\\",\\\"B\\\":\\\"1.998939\\\",\\\"C\\\":\\\"3.000807\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"real\\\",\\\"desc\\\":\\\"IA\\\",\\\"list\\\":{\\\"A\\\":\\\"-0.038000\\\",\\\"B\\\":\\\"-120.052000\\\",\\\"C\\\":\\\"119.941000\\\",\\\"T\\\":null}}],\\\"SqlDataHarm\\\":[]}\",\"code\":10200}\n";
channel.writeAndFlush(hh+"\n");
channel.writeAndFlush(ii+"\n");
break;
//正式检测
case FORMAL_REAL:
break;
//系数校验
case Coefficient_Check:
String a = "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"DATA_CHNFACTOR$01\",\"data\":null,\"code\":10201}";
String b = "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"DATA_CHNFACTOR$01\",\"data\":\"[{\\\"uMonitorPoint\\\":0,\\\"f\\\":{\\\"Ua_gain\\\":9999,\\\"Ub_gain\\\":10008,\\\"Uc_gain\\\":10000,\\\"U0_gain\\\":10000,\\\"Ia_gain\\\":9997,\\\"Ib_gain\\\":9997,\\\"Ic_gain\\\":10001,\\\"I0_gain\\\":10000,\\\"Uab_gain\\\":9999,\\\"Ubc_gain\\\":10008,\\\"Uca_gain\\\":10000}}]\",\"code\":10200}";
channel.writeAndFlush(a+"\n");
channel.writeAndFlush(b+"\n");
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
case DATA_CHNFACTOR$01:
break;
}
break;
//退出关闭
case QUITE:
// quitDeal(socketDataMsg, param, msg);
break;
case YXT:
break;
}
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
System.out.println("有新连接加入了++++......" + ctx.channel());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// Client disconnected, close the server-side channel too
System.out.println("NettyServer服务端监听到" + ctx.channel().id() + "关闭连接");
ctx.close(); // This will trigger the close event on the server side
super.channelInactive(ctx);
}
/**
* 用户事件的回调方法(自定义事件用于心跳机制)
*/
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
//空闲状态的事件
// if (evt instanceof IdleStateEvent) {
// IdleStateEvent event = (IdleStateEvent) evt;
// System.out.println(event.state() + ">>>" + ctx.channel().id());
// //已经10秒钟没有读时间了
// if (event.state().equals(IdleState.READER_IDLE)){
// // 心跳包丢失10秒没有收到客户端心跳 (断开连接)
// ctx.channel().close().sync();
// System.out.println("已与 "+ctx.channel().remoteAddress()+" 断开连接");
// }
// }
}
}

View File

@@ -6,6 +6,11 @@ import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.util.CharsetUtil;
/**
@@ -25,11 +30,17 @@ public class NettyServer {
public static void main(String[] args) {
NettyServer nettyServer = new NettyServer();
nettyServer.run();
nettyServer.runSource();
}
private void run() {
public static void sourceMain(String[] args) {
NettyServer nettyServer = new NettyServer();
nettyServer.runDev();
}
private void runSource() {
NioEventLoopGroup boss = new NioEventLoopGroup(1);
NioEventLoopGroup work = new NioEventLoopGroup();
try {
@@ -39,19 +50,30 @@ public class NettyServer {
.handler(new ChannelInitializer<ServerSocketChannel>() {
@Override
protected void initChannel(ServerSocketChannel ch) {
System.out.println("服务正在启动中......");
System.out.println("源通讯服务正在启动中......");
}
})
//业务处理
.childHandler(NettyServerChannelInitializer.INSTANCE);
.childHandler(new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel ch) {
ch.pipeline()
//空闲状态的handler
// 添加LineBasedFrameDecoder来按行分割数据
.addLast(new LineBasedFrameDecoder(10240))
.addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new DevNettyServerHandler());
}
});
ChannelFuture future = bootstrap.bind(port).sync();
future.addListener(f -> {
if (future.isSuccess()) {
System.out.println("服务启动成功");
System.out.println("源通讯服务启动成功");
} else {
System.out.println("服务启动失败");
System.out.println("源通讯服务启动失败");
}
});
future.channel().closeFuture().sync();
@@ -63,4 +85,52 @@ public class NettyServer {
work.shutdownGracefully();
}
}
private void runDev() {
NioEventLoopGroup boss = new NioEventLoopGroup(1);
NioEventLoopGroup work = new NioEventLoopGroup();
try {
ServerBootstrap bootstrap = new ServerBootstrap().group(boss, work);
bootstrap.channel(NioServerSocketChannel.class)
//这个处理器可以不写
.handler(new ChannelInitializer<ServerSocketChannel>() {
@Override
protected void initChannel(ServerSocketChannel ch) {
System.out.println("设备通讯服务正在启动中......");
}
})
//业务处理
.childHandler(new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel ch) {
ch.pipeline()
//空闲状态的handler
// 添加LineBasedFrameDecoder来按行分割数据
.addLast(new LineBasedFrameDecoder(10240))
.addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new SourceNettyServerHandler());
}
});
ChannelFuture future = bootstrap.bind(port).sync();
future.addListener(f -> {
if (future.isSuccess()) {
System.out.println("设备通讯服务启动成功");
} else {
System.out.println("设备通讯服务启动失败");
}
});
future.channel().closeFuture().sync();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
boss.shutdownGracefully();
work.shutdownGracefully();
}
}
}

View File

@@ -23,7 +23,7 @@ public class NettyServerChannelInitializer extends ChannelInitializer<NioSocketC
// .addLast(new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS))
.addLast(new StringDecoder(CharsetUtil.UTF_8))
.addLast(new StringEncoder(CharsetUtil.UTF_8))
.addLast(new NettyServerHandler());
.addLast(new DevNettyServerHandler());
}

View File

@@ -1,130 +0,0 @@
package com.njcn.gather.detection.util.socket.service;
import com.alibaba.fastjson.JSONObject;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
/**
* @Description: 客户端业务处理
* @Author: wr
* @Date: 2024/12/10 14:18
*/
public class NettyServerHandler extends SimpleChannelInboundHandler<String> {
public static final NettyServerHandler INSTANCE = new NettyServerHandler();
/**
* @Description: 当通道进行连接时推送消息
* @Author: wr
* @Date: 2024/12/10 14:19
*/
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
System.out.println("服务端监听到"+ctx.channel().id()+"连接");
super.channelActive(ctx);
}
/**
* 处理消息信息
*/
@Override
public void channelRead0(ChannelHandlerContext ctx, String msg) {
System.out.println(ctx.channel().id()+"NettyServer服务端接收到客户端消息"+msg);
Channel channel = ctx.channel();
/*
if(msg.endsWith("结束")) {
channel.writeAndFlush("socket指令结果"+msg);
for (int i = 0; i < 5; i++) {
channel.writeAndFlush("socket指令结果"+msg);
}
}else{
channel.writeAndFlush("socket指令结果成功指令");
}*/
if(!msg.contains("HeartBeat")){
if(msg.contains("start")){
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("requestId","yjc_ytxjy");
jsonObject1.put("operateCode","INIT_GATHER");
jsonObject1.put("code","10201");
channel.writeAndFlush(jsonObject1.toJSONString()+'\n');
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("requestId","yjc_ytxjy");
jsonObject.put("operateCode","INIT_GATHER");
jsonObject.put("code","10200");
channel.writeAndFlush(jsonObject.toJSONString()+'\n');
}else if(msg.contains("YJC_xujy")){
JSONObject jsonObject = new JSONObject();
jsonObject.put("requestId","YJC_xujy");
jsonObject.put("operateCode","OPER_GATHER");
jsonObject.put("code","10201");
channel.writeAndFlush(jsonObject.toJSONString()+'\n');
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("requestId","YJC_xujy");
jsonObject1.put("operateCode","OPER_GATHER");
jsonObject1.put("code","10200");
channel.writeAndFlush(jsonObject1.toJSONString()+'\n');
}
}
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
System.out.println("有新连接加入了++++......" + ctx.channel());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// Client disconnected, close the server-side channel too
System.out.println("NettyServer服务端监听到"+ctx.channel().id()+"关闭连接");
ctx.close(); // This will trigger the close event on the server side
super.channelInactive(ctx);
}
/**
* 用户事件的回调方法(自定义事件用于心跳机制)
*/
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
//空闲状态的事件
// if (evt instanceof IdleStateEvent) {
// IdleStateEvent event = (IdleStateEvent) evt;
// System.out.println(event.state() + ">>>" + ctx.channel().id());
// //已经10秒钟没有读时间了
// if (event.state().equals(IdleState.READER_IDLE)){
// // 心跳包丢失10秒没有收到客户端心跳 (断开连接)
// ctx.channel().close().sync();
// System.out.println("已与 "+ctx.channel().remoteAddress()+" 断开连接");
// }
// }
}
}

View File

@@ -0,0 +1,133 @@
package com.njcn.gather.detection.util.socket.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
import com.njcn.gather.detection.util.socket.MsgUtil;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
/**
* @Description: 客户端业务处理
* @Author: wr
* @Date: 2024/12/10 14:18
*/
public class SourceNettyServerHandler extends SimpleChannelInboundHandler<String> {
private final String DEV = "_Dev";
private final String source = "_Source";
private final String stepTag = "&&";
private final String stepBegin = "_Start";
private final String stepEnd = "_End";
public static final SourceNettyServerHandler INSTANCE = new SourceNettyServerHandler();
/**
* @Description: 当通道进行连接时推送消息
* @Author: wr
* @Date: 2024/12/10 14:19
*/
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
System.out.println("服务端监听到" + ctx.channel().id() + "连接");
super.channelActive(ctx);
}
/**
* 处理消息信息
*/
@Override
public void channelRead0(ChannelHandlerContext ctx, String msg) {
System.out.println(ctx.channel().id() + "NettyServer服务端接收到客户端消息" + msg);
Channel channel = ctx.channel();
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
String[] tem = socketDataMsg.getRequestId().split(stepTag);
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
JSONObject jsonObject1 = new JSONObject();
if (ObjectUtil.isNotNull(enumByCode)) {
switch (enumByCode) {
//源初始化
case YJC_YTXJY:
String aa = "{\"requestId\":\"yjc_ytxjy\",\"operateCode\":\"INIT_GATHER\",\"data\":null,\"code\":10201}";
String bb = "{\"requestId\":\"yjc_ytxjy\",\"operateCode\":\"INIT_GATHER\",\"data\":null,\"code\":10200}";
channel.writeAndFlush(aa+"/n");
channel.writeAndFlush(bb+"/n");
break;
//相序检测
case YJC_XUJY:
String hh = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10201}";
String ii = "{\"requestId\":\"YJC_xujy\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10200}";
channel.writeAndFlush(hh+"\n");
channel.writeAndFlush(ii+"\n");
break;
//正式检测
case FORMAL_REAL:
break;
//系数校验
case Coefficient_Check:
String a = "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10201}";
String b= "{\"requestId\":\"Coefficient_Check\",\"operateCode\":\"OPER_GATHER\",\"data\":null,\"code\":10200}";
break;
case QUITE_SOURCE:
break;
case YXT:
jsonObject1.put("requestId", "yjc_ytxjy");
jsonObject1.put("operateCode", "INIT_GATHER");
jsonObject1.put("code", "10201");
channel.writeAndFlush(jsonObject1.toJSONString() + '\n');
break;
}
} else {
System.out.println("未知异常" + enumByCode);
}
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
System.out.println("有新连接加入了++++......" + ctx.channel());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// Client disconnected, close the server-side channel too
System.out.println("NettyServer服务端监听到" + ctx.channel().id() + "关闭连接");
ctx.close(); // This will trigger the close event on the server side
super.channelInactive(ctx);
}
/**
* 用户事件的回调方法(自定义事件用于心跳机制)
*/
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
//空闲状态的事件
// if (evt instanceof IdleStateEvent) {
// IdleStateEvent event = (IdleStateEvent) evt;
// System.out.println(event.state() + ">>>" + ctx.channel().id());
// //已经10秒钟没有读时间了
// if (event.state().equals(IdleState.READER_IDLE)){
// // 心跳包丢失10秒没有收到客户端心跳 (断开连接)
// ctx.channel().close().sync();
// System.out.println("已与 "+ctx.channel().remoteAddress()+" 断开连接");
// }
// }
}
}

View File

@@ -1,19 +1,15 @@
package com.njcn.gather.detection.util.socket.web;
import cn.hutool.core.util.ObjectUtil;
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 com.njcn.gather.detection.util.socket.WebServiceManager;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
@@ -57,11 +53,13 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
} else if (msg instanceof TextWebSocketFrame) {
//正常的TEXT消息类型
TextWebSocketFrame frame = (TextWebSocketFrame) msg;
log.info("webSocket服务器收到客户端心跳信息{}", frame.text());
/*if ("alive".equals(frame.text())) {
//log.info("webSocket服务器收到客户端心跳信息{}", frame.text());
if ("alive".equals(frame.text())) {
//System.out.println("webSocket心跳收到时间………………………………………………………………"+LocalDateTime.now());
times = 0;
TextWebSocketFrame wd = new TextWebSocketFrame("over");
ctx.writeAndFlush(wd);
}*/
ctx.channel().writeAndFlush(wd);
}
}
super.channelRead(ctx, msg);
@@ -69,6 +67,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
/**
* 根据用户地址获取用户名 ws://127.0.0.1:7777/hello?name=aa
*
* @param url
* @return
*/
@@ -108,7 +107,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx){
public void handlerRemoved(ChannelHandlerContext ctx) {
// 假设用户 ID 是从某个地方获取的,这里简单示例为 "userId"
System.out.println("weoSocket客户端退出: " + ctx.channel().id());
WebServiceManager.removeChannel(ctx.channel().id().toString());
@@ -120,9 +119,15 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
System.out.println("weoSocket断线" + ctx.channel().id());
ctx.close();
PreDetectionParam param = new PreDetectionParam();
param.setUserPageId("cdf");
CnSocketUtil.quitSend(param);
PreDetectionParam preDetectionParam = WebServiceManager.getPreDetectionParam();
if (ObjectUtil.isNotNull(preDetectionParam)) {
CnSocketUtil.quitSendSource(preDetectionParam); // 能否在这里关闭源socket连接
CnSocketUtil.quitSend(preDetectionParam);
} else {
preDetectionParam = new PreDetectionParam();
preDetectionParam.setUserPageId("cdf");
CnSocketUtil.quitSend(preDetectionParam);
}
}
@@ -133,11 +138,12 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
switch (event.state()) {
case READER_IDLE:
eventDesc = "读空闲";
System.out.println(ctx.channel().remoteAddress() + "发生超时事件--" + eventDesc);
System.out.println("c端心跳检测发生超时事件--" + eventDesc);
times++;
if (times > 3) {
System.out.println("空闲次数超过三次 关闭连接");
System.out.println("c端心跳检测空闲次数超过三次 关闭连接");
ctx.channel().close();
WebServiceManager.removeChannel(ctx.channel().id().toString());
}
break;
case WRITER_IDLE:
@@ -153,12 +159,6 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
}
/**
* 推送数据至前台
*/
public void sendMsgToUser(String userId, String msg) {
WebServiceManager.sendMsg(userId, msg);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {

View File

@@ -1,12 +1,7 @@
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.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
@@ -15,37 +10,27 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.device.pojo.enums.PatternEnum;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.param.PqDevParam;
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.PreDetection;
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.plan.pojo.po.AdPlan;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.FileUtil;
import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -62,24 +47,8 @@ import java.util.Map;
public class PqDevController extends BaseController {
private final IPqDevService pqDevService;
private final IDictDataService dictDataService;
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
@PostMapping("/list")
@ApiOperation("分页查询被检设备")
@@ -106,14 +75,14 @@ public class PqDevController extends BaseController {
@PostMapping("/add")
@ApiOperation("新增被检设备")
@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");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, pqDevParam);
boolean result = pqDevService.addPqDev(pqDevParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@@ -121,14 +90,14 @@ public class PqDevController extends BaseController {
@PostMapping("/update")
@ApiOperation("修改被检设备")
@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");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
boolean result = pqDevService.updatePqDev(updateParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@@ -136,142 +105,57 @@ public class PqDevController extends BaseController {
@PostMapping("/delete")
@ApiOperation("删除被检设备")
@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");
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, param.getIds()));
boolean result = pqDevService.deletePqDev(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/export")
@ApiOperation("导出被检设备数据")
@ApiOperation("批量导出被检设备")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public void export(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("export");
public void exportDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("exportDev");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
DictData dictData = dictDataService.getDictDataById(queryParam.getPattern());
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);
}
}
pqDevService.exportDev(queryParam);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载被检设备导入文件模板")
public void downloadTemplate() {
pqDevService.downloadTemplate();
public void downloadTemplate(@RequestBody PqDevParam pqDevParam) {
pqDevService.downloadTemplate(pqDevParam.getPattern());
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping(value = "/importContrast")
@ApiOperation("批量导入被检设备数据")
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
public HttpResult<Object> importContrastData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importContrastData");
@PostMapping(value = "/import")
@ApiOperation("批量导入被检设备")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
})
public HttpResult<Boolean> importDev(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, @RequestParam("planId") String planId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importDev");
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("批量导入设备数据")
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file, String patternId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importCNDev");
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
}
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("null".equals(planId)){
planId = null;
}
if (ObjectUtil.isNotEmpty(cnDevExcelList)) {
pqDevService.importCNDev(cnDevExcelList, patternId);
Boolean result = pqDevService.importDev(file, patternId, planId, response);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@@ -285,54 +169,12 @@ public class PqDevController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/listByPlanId")
@ApiOperation("查询出所有已绑定的设备")
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
String methodDescribe = getMethodDescribe("listByPlanId");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
List<PqDev> pqDevList = pqDevService.listByPlanId(param);
List<PqDevVO> result = BeanUtil.copyToList(pqDevList, PqDevVO.class);
result.forEach(pqDevVO -> {
DevType devType = devTypeService.getById(pqDevVO.getDevType());
if (ObjectUtil.isNotNull(devType)) {
pqDevVO.setDevChns(devType.getDevChns());
pqDevVO.setDevVolt(devType.getDevVolt());
pqDevVO.setDevCurr(devType.getDevCurr());
}
});
@OperateInfo
@GetMapping("/getSelectOptions")
@ApiOperation("根据历史记录信息来获取下拉框内容")
public HttpResult<Map<String, List<String>>> getSelectOptions(@RequestParam("pattern") String pattern) {
String methodDescribe = getMethodDescribe("getSelectOptions");
Map<String, List<String>> result = pqDevService.listSelectOptions(pattern);
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

@@ -0,0 +1,164 @@
package com.njcn.gather.device.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
import com.njcn.gather.device.pojo.po.PqStandardDev;
import com.njcn.gather.device.service.IPqStandardDevService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.FileUtil;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author caozehui
* @date 2025-07-02
*/
@Slf4j
@Api(tags = "标准设备管理")
@RestController
@RequestMapping("/pqStandardDev")
@RequiredArgsConstructor
public class PqStandardDevController extends BaseController {
private final IPqStandardDevService pqStandardDevService;
@OperateInfo
@PostMapping("/list")
@ApiOperation("分页查询标准设备")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<Page<PqStandardDev>> list(@RequestBody PqStandardDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
Page<PqStandardDev> result = pqStandardDevService.listPqStandardDevs(queryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo
@GetMapping("/getById")
@ApiOperation("根据id查询标准设备")
@ApiImplicitParam(name = "id", value = "标准设备id", required = true)
public HttpResult<PqStandardDev> getById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getById");
LogUtil.njcnDebug(log, "{}查询ID为{}", methodDescribe, id);
PqStandardDev result = pqStandardDevService.getPqStandardDevById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增标准设备")
@ApiImplicitParam(name = "param", value = "标准设备", required = true)
public HttpResult<Boolean> add(@RequestBody @Validated PqStandardDevParam param) {
String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = pqStandardDevService.addPqStandardDev(param);
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(@RequestBody @Validated PqStandardDevParam.UpdateParam param) {
String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
boolean result = pqStandardDevService.updatePqStandardDev(param);
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 = "ids", value = "标准设备id", required = true)
public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = pqStandardDevService.deletePqStandardDevs(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/export")
@ApiOperation("批量导出标准设备")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public void export(@RequestBody PqStandardDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("export");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
pqStandardDevService.export(queryParam);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载标准设备导入文件模板")
public void downloadTemplate() {
pqStandardDevService.downloadTemplate();
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping("/import")
@ApiOperation("导入标准设备")
@ApiImplicitParam(name = "file", value = "导入文件", required = true)
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importData");
LogUtil.njcnDebug(log, "{},导入文件为:{}", methodDescribe, file.getOriginalFilename());
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
}
pqStandardDevService.importData(file, response);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo
@GetMapping("/getAll")
@ApiOperation("获取所有标准设备")
public HttpResult<List<PqStandardDev>> getAll() {
String methodDescribe = getMethodDescribe("getAll");
LogUtil.njcnDebug(log, "{},查询所有数据", methodDescribe);
List<PqStandardDev> result = pqStandardDevService.lambdaQuery().eq(PqStandardDev::getState, DataStateEnum.ENABLE.getCode()).list();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/listByPlanId")
@ApiOperation("查询出指定计划已关联的标准设备")
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
public HttpResult<List<PqStandardDev>> listByPlanId(@RequestParam("planId") String planId) {
String methodDescribe = getMethodDescribe("listByPlanId");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
List<PqStandardDev> pqDevVOList = pqStandardDevService.listByPlanId(planId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOList, methodDescribe);
}
}

View File

@@ -1,7 +1,9 @@
package com.njcn.gather.device.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.device.pojo.param.PqDevParam;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.pojo.vo.PreDetection;
import org.apache.ibatis.annotations.Param;
@@ -26,8 +28,33 @@ public interface PqDevMapper extends MPJBaseMapper<PqDev> {
void updateReportState(@Param("id")String id);
/**
* 修改检测计划的检测结果
*
* @param planId
* @param 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);
/**
* 根据计划id获取脚本id
*
* @param planId
*/
String getScriptIdByPlanId(@Param("planId")String planId);
List<PqDevVO> selectByQueryParam(PqDevParam.QueryParam param);
PqDevVO selectByDevId(@Param("devId") String devId);
List<PqDevVO> listByDevIds(@Param("devIds") List<String> devIds);
}

View File

@@ -0,0 +1,13 @@
package com.njcn.gather.device.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.device.pojo.po.PqDevSub;
/**
* @author caozehui
* @date 2025-07-02
*/
public interface PqDevSubMapper extends MPJBaseMapper<PqDevSub> {
}

View File

@@ -0,0 +1,18 @@
package com.njcn.gather.device.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.device.pojo.po.PqStandardDev;
import com.njcn.gather.device.pojo.vo.PreDetection;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author makejava
* @date 2025-05-09
*/
public interface PqStandardDevMapper extends MPJBaseMapper<PqStandardDev> {
List<PreDetection> listStandardDevPreDetection(@Param("devIds") List<String> ids);
}

View File

@@ -4,17 +4,17 @@
<!-- 通用查询映射结果 -->
<resultMap id="DevResultMap" type="com.njcn.gather.device.pojo.vo.PreDetection">
<id column="Id" property="devId" />
<id column="Name" property="devName" />
<id column="IP" property="devIP" />
<result column="Port" property="port" />
<result column="Dev_Type" property="devType" />
<result column="Series" property="devCode" />
<result column="Dev_Key" property="devKey" />
<result column="icdType" property="icdType" />
<result column="Dev_Chns" property="devChns" />
<result column="Dev_Volt" property="devVolt" />
<result column="Dev_Curr" property="devCurr" />
<id column="Id" property="devId"/>
<id column="Name" property="devName"/>
<id column="IP" property="devIP"/>
<result column="Port" property="port"/>
<result column="Dev_Type" property="devType"/>
<result column="Series" property="devCode"/>
<result column="Dev_Key" property="devKey"/>
<result column="icdType" property="icdType"/>
<result column="Dev_Chns" property="devChns"/>
<result column="Dev_Volt" property="devVolt"/>
<result column="Dev_Curr" property="devCurr"/>
<collection
property="monitorList"
@@ -50,22 +50,84 @@
</where>
</select>
<update id="finishPlan" >
update ad_plan set Test_State = 2 where id = #{planId}
<update id="finishPlan">
update ad_plan
set Test_State = 2
where id = #{planId}
</update>
<update id="updateReportState" >
update pq_dev set Report_State = 1 where id = #{id}
<update id="updateReportState">
update pq_dev
set Report_State = 1
where id = #{id}
</update>
<update id="updatePlanCheckResult">
update ad_plan set Result = #{checkResult} where id = #{planId}
update ad_plan
set Result = #{checkResult}
where id = #{planId}
</update>
<update id="updatePlanTestState">
update ad_plan set Test_State = #{testState} where id = #{planId}
update ad_plan
set Test_State = #{testState}
where id = #{planId}
</update>
<select id="getScriptIdByPlanId" resultType="java.lang.String">
SELECT Script_Id
FROM ad_plan
WHERE id = #{planId}
</select>
<select id="selectByQueryParam" resultType="com.njcn.gather.device.pojo.vo.PqDevVO">
SELECT dev.*,dev_sub.* FROM pq_dev dev
left JOIN pq_dev_sub dev_sub ON dev.Id = dev_sub.Dev_Id
<where>
dev.state = 1
<if test="planIdList!= null and planIdList.size!=0">
AND dev.Plan_Id in
<foreach collection="planIdList" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="name!= null and name!= ''">
AND dev.Name LIKE CONCAT('%',#{name},'%')
</if>
<if test="checkStateList!= null and checkStateList.size()!= 0 ">
AND dev_sub.Check_State in
<foreach collection="checkStateList" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="checkResult!= null">
AND dev_sub.Check_Result = #{checkResult}
</if>
<if test="reportState!= null">
AND dev_sub.Report_State = #{reportState}
</if>
</where>
ORDER BY dev.Create_Time DESC,dev.Name
</select>
<select id="selectByDevId" resultType="com.njcn.gather.device.pojo.vo.PqDevVO">
SELECT dev.*, dev_sub.*
FROM pq_dev dev
left JOIN pq_dev_sub dev_sub ON dev.Id = dev_sub.Dev_Id
WHERE dev.Id = #{devId}
</select>
<select id="listByDevIds" resultType="com.njcn.gather.device.pojo.vo.PqDevVO">
SELECT dev.*, dev_sub.*
FROM pq_dev dev
left JOIN pq_dev_sub dev_sub ON dev.Id = dev_sub.Dev_Id
WHERE dev.state = 1
<if test="devIds!= null and devIds.size() != 0">
AND dev.Id in
<foreach collection="devIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>

View File

@@ -1,7 +1,6 @@
<?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.storage.mapper.AdNonHarmonicMapper">
<mapper namespace="com.njcn.gather.device.mapper.PqDevSubMapper">
</mapper>

View File

@@ -0,0 +1,48 @@
<?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.device.mapper.PqStandardDevMapper">
<!-- 通用查询映射结果 -->
<resultMap id="standardDevResultMap" type="com.njcn.gather.device.pojo.vo.PreDetection">
<id column="Id" property="devId"/>
<id column="Name" property="devName"/>
<id column="IP" property="devIP"/>
<result column="Port" property="port"/>
<result column="Dev_Type" property="devType"/>
<result column="Series" property="devCode"/>
<result column="Dev_Key" property="devKey"/>
<result column="icdType" property="icdType"/>
<result column="Dev_Chns" property="devChns"/>
<result column="Dev_Volt" property="devVolt"/>
<result column="Dev_Curr" property="devCurr"/>
<!-- <collection-->
<!-- property="monitorList"-->
<!-- column="{ devId = Id}"-->
<!-- select="com.njcn.gather.monitor.mapper.PqMonitorMapper.selectMonitorInfo"-->
<!-- >-->
<!-- </collection>-->
</resultMap>
<select id="listStandardDevPreDetection" resultMap="standardDevResultMap">
select
standard_dev.Id,
standard_dev.Name,
standard_dev.IP,
standard_dev.Port,
standard_dev.Dev_Type,
standard_dev.Series,
standard_dev.Dev_Key,
dev_type.icdType,
dev_type.Dev_Chns,
dev_type.Dev_Volt,
dev_type.Dev_Curr
from pq_standard_dev standard_dev
inner join pq_dev_type dev_type on standard_dev.Dev_Type = dev_type.id
where standard_dev.Id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

View File

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

View File

@@ -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,16 +2,18 @@ package com.njcn.gather.device.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
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.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.time.LocalDate;
import java.util.List;
/**
@@ -22,61 +24,55 @@ import java.util.List;
public class PqDevParam {
@ApiModelProperty(value = "名称", required = true)
//@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
//@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
private String pattern;
@ApiModelProperty(value = "设备类型,字典表", required = true)
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_TYPE_FORMAT_ERROR)
@ApiModelProperty(value = "设备类型", required = true)
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_TYPE_FORMAT_ERROR)
private String devType;
@ApiModelProperty(value = "设备厂家,字典表", required = true)
//@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR)
private String manufacturer;
@ApiModelProperty(value = "出厂日期", required = true)
//@NotBlank(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
//@DateTimeStrValid(format = "yyyy-MM-dd", message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate;
@ApiModelProperty(value = "设备序列", required = true)
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
@ApiModelProperty(value = "装置编", required = true)
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_CREATE_ID_REGEX, message = DetectionValidMessage.DEV_CREATE_ID_FORMAT_ERROR)
private String createId;
@ApiModelProperty(value = "固件版本", required = true)
//@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion;
@ApiModelProperty(value = "软件版本", required = true)
//@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion;
@ApiModelProperty(value = "通讯协议", required = true)
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PROTOCOL_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PROTOCOL_FORMAT_ERROR)
private String protocol;
@ApiModelProperty(value = "IP地址", required = true)
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
private String ip;
@ApiModelProperty(value = "端口号", required = true)
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
private Integer port;
@ApiModelProperty(value = "装置是否为加密版本", required = true)
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
@Min(value = 0, message = DevValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
@Max(value = 1, message = DevValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
@Min(value = 0, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
@Max(value = 1, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
private Integer encryptionFlag;
@ApiModelProperty("装置识别码3ds加密")
@@ -89,7 +85,7 @@ public class PqDevParam {
private String sampleId;
@ApiModelProperty(value = "送样日期")
@DateTimeStrValid(message = DevValidMessage.ARRIVE_DATE_FORMAT_ERROR)
@DateTimeStrValid(message = DetectionValidMessage.ARRIVE_DATE_FORMAT_ERROR)
private String arrivedDate;
@ApiModelProperty("所属地市名称")
@@ -104,18 +100,16 @@ public class PqDevParam {
@ApiModelProperty("报告路径")
private String reportPath;
@ApiModelProperty("设备关键信息二维码")
private String qrCode;
// @ApiModelProperty("设备关键信息二维码")
// private String qrCode;
@ApiModelProperty(value = "检测次数,默认为0", required = true)
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
@Min(value = 0, message = DevValidMessage.RECHECK_NUM_FORMAT_ERROR)
private Integer reCheckNum;
// @ApiModelProperty(value = "检测次数,默认为0", required = true)
// @NotNull(message = DetectionValidMessage.RECHECK_NUM_NOT_NULL)
// @Min(value = 0, message = DetectionValidMessage.RECHECK_NUM_FORMAT_ERROR)
// private Integer reCheckNum;
@ApiModelProperty("是否支持系数校准")
@Min(value = 0, message = DevValidMessage.FACTOR_FLAG_FORMAT_ERROR)
@Max(value = 1, message = DevValidMessage.FACTOR_FLAG_FORMAT_ERROR)
private String factorFlag;
private Integer factorFlag;
@ApiModelProperty("监测点台账列表")
@Valid
@@ -123,13 +117,26 @@ public class PqDevParam {
@ApiModelProperty("icdId")
private String icdId;
//
// @ApiModelProperty("power")
// private String power;
@ApiModelProperty("预投计划")
private String preinvestmentPlan;
@ApiModelProperty("委托方")
private String delegate;
@ApiModelProperty("被检通道")
private String inspectChannel;
@ApiModelProperty("投运日期")
@DateTimeStrValid(message = DetectionValidMessage.OPERATION_DATE_FORMAT_ERROR)
private String operationDate;
@ApiModelProperty("定验日期")
@DateTimeStrValid(message = DetectionValidMessage.INSPECT_DATE_FORMAT_ERROR)
private String inspectDate;
@ApiModelProperty("是否为导入设备")
private Integer importFlag;
/**
* 更新操作实体
*/
@@ -138,29 +145,9 @@ public class PqDevParam {
public static class UpdateParam extends PqDevParam {
@ApiModelProperty(value = "id", required = true)
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
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 +157,6 @@ public class PqDevParam {
@EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam {
@ApiModelProperty("名称")
// @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)")
@@ -180,46 +166,62 @@ public class PqDevParam {
private String manufacturer;
@ApiModelProperty("检测计划ID")
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
private String planId;
private List<String> planIdList;
@ApiModelProperty("检测状态列表")
private List<
@Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
@Max(value = 3, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR) Integer> checkStateList;
@Min(value = 0, message = DetectionValidMessage.CHECK_STATE_FORMAT_ERROR)
@Max(value = 3, message = DetectionValidMessage.CHECK_STATE_FORMAT_ERROR) Integer> checkStateList;
@ApiModelProperty("检测结果")
@Min(value = 0, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
@Max(value = 2, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
@Min(value = 0, message = DetectionValidMessage.CHECK_RESULT_FORMAT_ERROR)
@Max(value = 2, message = DetectionValidMessage.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)
@Min(value = 0, message = DetectionValidMessage.REPORT_STATE_FORMAT_ERROR)
@Max(value = 2, message = DetectionValidMessage.REPORT_STATE_FORMAT_ERROR)
private Integer reportState;
@ApiModelProperty("所属地市名称")
private String cityName;
@ApiModelProperty("所属供电公司名称")
private String gdName;
@ApiModelProperty("所属电站名称")
private String subName;
@ApiModelProperty("地市")
private String region;
@ApiModelProperty("是否分配")
private Integer assign;
}
@Data
public static class DeleteParam {
@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)
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PATTERN_FORMAT_ERROR)
private String pattern;
}
@Data
public static class BindPlanParam {
@ApiModelProperty("检测计划ID")
@NotNull(message = DevValidMessage.PLAN_ID_NOT_NULL)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.PLAN_ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PLAN_ID_FORMAT_ERROR)
private String planId;
@ApiModelProperty("被检设备ID列表")
@NotNull(message = DevValidMessage.PQ_DEV_IDS_NOT_NULL)
private List<String> pqDevIds;
@NotNull(message = DetectionValidMessage.PQ_DEV_IDS_NOT_NULL)
private List<String> devIds;
@ApiModelProperty("0-解绑、1-绑定")
private Integer bindFlag;
}
}

View File

@@ -0,0 +1,92 @@
package com.njcn.gather.device.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.*;
import java.util.List;
/**
* @author caozehui
* @data 2025-05-09
*/
@Data
public class PqStandardDevParam {
@ApiModelProperty(value = "名称", required = true)
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
private String name;
@ApiModelProperty(value = "设备类型", required = true)
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_TYPE_FORMAT_ERROR)
private String devType;
@ApiModelProperty(value = "设备厂家", required = true)
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.MANUFACTURER_FORMAT_ERROR)
private String manufacturer;
@ApiModelProperty(value = "通信协议", required = true)
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.PROTOCOL_FORMAT_ERROR)
private String protocol;
@ApiModelProperty(value = "ip地址", required = true)
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
private String ip;
@ApiModelProperty(value = "端口", required = true)
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
private Integer port;
@ApiModelProperty(value = "装置是否为加密版本", required = true)
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
@Min(value = 0, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
@Max(value = 1, message = DetectionValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
private Integer encryptionFlag;
@ApiModelProperty("识别码3ds加密")
private String series;
@ApiModelProperty("秘钥3ds加密")
private String devKey;
@ApiModelProperty(value = "可检通道", required = true)
private String inspectChannel;
/**
* 分页查询实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class QueryParam extends BaseParam {
@ApiModelProperty(value = "名称", required = true)
private String name;
@ApiModelProperty(value = "设备厂家", required = true)
private String manufacturer;
@ApiModelProperty(value = "设备类型", required = true)
private String devType;
}
/**
* 更新操作实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class UpdateParam extends PqStandardDevParam {
@ApiModelProperty(value = "标准设备id", required = true)
@NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id;
}
}

View File

@@ -1,7 +1,6 @@
package com.njcn.gather.device.pojo.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -15,7 +14,6 @@ import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* @author caozehui
@@ -115,7 +113,6 @@ public class PqDev extends BaseEntity implements Serializable {
/**
* 送样日期
*/
@TableField(updateStrategy = FieldStrategy.IGNORED)
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@@ -136,67 +133,58 @@ public class PqDev extends BaseEntity implements Serializable {
*/
private String subName;
/**
* 检测状态
*/
private Integer checkState;
/**
* 检测结果
*/
private Integer checkResult;
/**
* 报告状态
*/
private Integer reportState;
/**
* 报告路径
*/
private String reportPath;
/**
* 设备关键信息二维码
*/
private String qrCode;
/**
* 检测次数,默认为0
*/
@TableField(value = "ReCheck_Num")
private Integer reCheckNum;
/**
* 状态0-删除 1-正常
*/
private Integer state;
/**
* 检测计划id
*/
private String planId;
/**
* 守时检测结果0:不合格, 1:合格)
*/
private Integer timeCheckResult;
/**
* 是否支持系数校准0:不支持,1:支持)
*/
private Integer factorFlag;
/**
* 系数校准结果0:不合格1:合格)
* 预投计划
*/
private Integer factorCheckResult;
@TableField("Check_Time")
private LocalDateTime checkTime;
@TableField("Preinvestment_Plan")
private String preinvestmentPlan;
/**
* 委托方
*/
private String delegate;
/**
* 可检通道
*/
private String inspectChannel;
/**
* 定检日期
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate inspectDate;
/**
* 谐波系统设备id
*/
private String harmSysId;
/**
* 是否为导入设备(比对式使用) 0-否 1-是
*/
private Integer importFlag;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -0,0 +1,105 @@
package com.njcn.gather.device.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author caozehui
* @date 2025-07-04
*/
@Data
@TableName("pq_dev_sub")
public class PqDevSub {
private static final long serialVersionUID = -93146063424890267L;
/**
* 关联pq_dev表的id字段
*/
private String devId;
/**
* 检测状态 0-未检、1检测中、2检测完成、3归档
*/
private Integer checkState;
/**
* 检测结果 0不符合、1符合、2未检
*/
private Integer checkResult;
/**
* 报告生成状态 0未生成、1已生成、2未检
*/
private Integer reportState;
/**
* 检测次数
*/
@TableField(value = "ReCheck_Num")
private Integer recheckNum;
/**
* 守时检测结果 0:不合格, 1:合格2/表示没有做守时检测
*/
private Integer timeCheckResult;
/**
* 系数校准结果 0:不合格1:合格2/表示没有做系数校准
*/
private Integer factorCheckResult;
/**
* 实时数据结果 0:不合格1:合格2未检
*/
private Integer realtimeResult;
/**
* 统计数据结果 0:不合格1:合格2未检
*/
private Integer statisticsResult;
/**
* 录波数据结果 0:不合格1:合格2未检
*/
private Integer recordedResult;
/**
* 检测人
*/
private String checkBy;
/**
* 检测时间
*/
@TableField("Check_Time")
private LocalDateTime checkTime;
/**
* 预检测耗时
*/
private Integer preDetectTime;
/**
* 系数校准耗时
*/
private Integer coefficientTime;
/**
* 正式检测耗时
*/
private Integer formalCheckTime;
/**
* 温度
*/
private Float temperature;
/**
* 相对湿度
*/
private Float humidity;
}

View File

@@ -0,0 +1,76 @@
package com.njcn.gather.device.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;
/**
* @author makejava
* @date 2025-05-09
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pq_standard_dev")
public class PqStandardDev extends BaseEntity implements Serializable {
private static final long serialVersionUID = 932459726326242984L;
/**
* 标准设备id
*/
private String id;
/**
* 标准设备-名称
*/
private String name;
/**
* 标准设备-设备类型
*/
private String devType;
/**
* 标准设备-设备厂家
*/
private String manufacturer;
/**
* 可检通道(可多选,中间使用英文逗号隔开)
*/
private String inspectChannel;
/**
* 通信协议
*/
private String protocol;
/**
* IP地址
*/
private String ip;
/**
* 端口号
*/
private Integer port;
/**
* 是否加密0否、1是
*/
private Integer encryptionFlag;
/**
* 识别码
*/
private String series;
/**
* 密钥
*/
private String devKey;
private Integer state;
}

View File

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

View File

@@ -0,0 +1,100 @@
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.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;
import java.util.List;
/**
* @author caozehui
* @data 2025-05-07
*/
@Data
public class ContrastDevExcel implements Serializable {
private String id;
@Excel(name = "所属地市*", width = 30, needMerge = true, orderNum = "1")
private String cityName;
@Excel(name = "所属供电公司*", width = 30, needMerge = true, orderNum = "2")
private String gdName;
@Excel(name = "所属电站*", width = 30, needMerge = true, orderNum = "3")
private String subName;
@Excel(name = "设备名称*", width = 20, needMerge = true, orderNum = "4")
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
private String name;
@Excel(name = "设备序列号*", width = 20, needMerge = true, orderNum = "5")
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
private String createId;
@Excel(name = "设备类型*", width = 20, needMerge = true, orderNum = "6")
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@Excel(name = "设备厂家*", width = 20, needMerge = true, orderNum = "7")
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
// @Excel(name = "被检通道", width = 20, needMerge = true, orderNum = "8")
// private String inspectChannel;
@Excel(name = "固件版本", width = 15, needMerge = true, orderNum = "8")
private String hardwareVersion;
@Excel(name = "软件版本", width = 15, needMerge = true, orderNum = "9")
private String softwareVersion;
@Excel(name = "通讯协议*", width = 15, needMerge = true, orderNum = "10")
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@Excel(name = "是否加密*", width = 20, needMerge = true, replace = {"否_0", "是_1"}, orderNum = "11")
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryptionFlag;
@Excel(name = "识别码(当加密时必填)", width = 30, needMerge = true, orderNum = "12")
private String series;
@Excel(name = "秘钥(当加密时必填)", width = 30, needMerge = true, orderNum = "13")
private String devKey;
@Excel(name = "IP地址*", width = 20, needMerge = true, orderNum = "14")
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
private String ip;
@Excel(name = "端口号*", width = 15, needMerge = true, orderNum = "15")
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
private Integer port;
@Excel(name = "投运日期yyyy-MM-dd*", width = 30, needMerge = true, orderNum = "16", format = "yyyy-MM-dd")
@NotNull(message = DetectionValidMessage.CREATE_DATE_NOT_NULL)
private LocalDate createDate;
@Excel(name = "定检日期yyyy-MM-dd*", width = 30, needMerge = true, orderNum = "17", format = "yyyy-MM-dd")
@NotNull(message = DetectionValidMessage.INSPECT_DATE_NOT_NULL)
private LocalDate inspectDate;
@Excel(name = "谐波系统设备id*", width = 30, needMerge = true, orderNum = "18")
@NotBlank(message = DetectionValidMessage.HARM_SYS_ID_NOT_BLANK)
private String harmSysId;
@ExcelCollection(name = "监测点信息", orderNum = "19")
private List<PqMonitorExcel> pqMonitorExcelList;
}

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

@@ -1,15 +1,9 @@
package com.njcn.gather.device.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.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.monitor.pojo.po.PqMonitor;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
@@ -27,4 +21,94 @@ public class PqDevVO extends PqDev {
private Double devCurr;
private List<PqMonitor> monitorList;
/**
* 检测状态 0-未检、1检测中、2检测完成、3归档
*/
private Integer checkState;
/**
* 检测结果 0不符合、1符合、2未检
*/
private Integer checkResult;
/**
* 报告生成状态 0未生成、1已生成、2未检
*/
private Integer reportState;
/**
* 检测次数
*/
private Integer recheckNum;
/**
* 守时检测结果 0:不合格, 1:合格2/表示没有做守时检测
*/
private Integer timeCheckResult;
/**
* 系数校准结果 0:不合格1:合格2/表示没有做系数校准
*/
private Integer factorCheckResult;
/**
* 实时数据结果 0:不合格1:合格2未检
*/
private Integer realtimeResult;
/**
* 统计数据结果 0:不合格1:合格2未检
*/
private Integer statisticsResult;
/**
* 录波数据结果 0:不合格1:合格2未检
*/
private Integer recordedResult;
/**
* 检测人
*/
private String checkBy;
/**
* 检测时间
*/
private LocalDateTime checkTime;
/**
* 预检测耗时
*/
private Integer preDetectTime;
/**
* 系数校准耗时
*/
private Integer coefficientTime;
/**
* 正式检测耗时
*/
private Integer formalCheckTime;
/**
* 温度
*/
private Float temperature;
/**
* 相对湿度
*/
private Float humidity;
/**
* 绑定的计划名称
*/
private String boundPlanName;
/**
* 是否已经分配。0-未分配、1-已分配、2-所有
*/
private Integer assign;
}

View File

@@ -0,0 +1,59 @@
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;
/**
* @author caozehui
* @data 2025-07-01
*/
@Data
public class PqStandardDevExcel {
@Excel(name = "名称*", width = 20, orderNum = "1")
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
private String name;
@Excel(name = "设备类型*", width = 25, orderNum = "2")
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@Excel(name = "设备厂家*", width = 25, orderNum = "3")
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
@Excel(name = "可检通道*", width = 25, orderNum = "4")
@NotBlank(message = DetectionValidMessage.INSPECT_CHANNEL_NOT_BLANK)
private String inspectChannel;
@Excel(name = "通信协议*", width = 25, orderNum = "5")
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@Excel(name = "IP地址*", width = 25, orderNum = "6")
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
private String ip;
@Excel(name = "端口号*", width = 15, orderNum = "7")
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
private Integer port;
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "8")
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryptionFlag;
@Excel(name = "识别码(当加密时必填)", width = 30, orderNum = "9")
private String series;
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "10")
private String devKey;
}

View File

@@ -18,7 +18,7 @@ import java.util.List;
public class PreDetection {
/**
* 装置ip
* 装置id
*/
@JSONField(serialize = false)
private String devId;
@@ -95,16 +95,28 @@ public class PreDetection {
private Integer line;
/**
* 监测点线路号
* pt
*/
@JSONField(name = "pt")
private Integer pt;
private String pt;
/**
* 监测点线路号
* ct
*/
@JSONField(name = "pt")
private Integer ct;
@JSONField(name = "ct") //todo 是否改为ct
private String ct;
/**
* 统计间隔
*/
@JSONField(name = "statInterval")
private Integer statInterval;
/**
* 接线方式
*/
@JSONField(name = "connection")
private String connection;
}
public String getDevKey() {

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,15 @@ package com.njcn.gather.device.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.param.PqDevParam;
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.PreDetection;
import com.njcn.gather.device.pojo.vo.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@@ -61,41 +61,6 @@ public interface IPqDevService extends IService<PqDev> {
*/
boolean updatePqDevTimeCheckResult(List<String> ids, TimeCheckResultEnum result);
/**
* 获取模拟式||数字式设备导出时所需的数据
*
* @param queryParam 查询参数
* @return
*/
List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam);
/**
* 获取比对式设备导出时所需的数据
*
* @param queryParam 查询参数
* @return 比对式设备导出时所需的数据
*/
List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam);
/**
* 下载模板文件
*/
void downloadTemplate();
/**
* 批量导入被检设备信息
*
* @param sgEventExcels 批量导入的数据
*/
void importContrastData(List<PqDevExcel.ContrastImportData> sgEventExcels);
/**
* 批量导入被检设备信息
*
* @param sgEventExcels 批量导入的数据
*/
void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels);
/**
* 获取所有未绑定的设备
*
@@ -110,7 +75,7 @@ public interface IPqDevService extends IService<PqDev> {
* @param param 计划id
* @return 绑定的设备列表
*/
List<PqDev> listByPlanId(PqDevParam.QueryParam param);
List<PqDevVO> listByPlanId(PqDevParam.QueryParam param);
/**
* 绑定计划
@@ -121,14 +86,6 @@ public interface IPqDevService extends IService<PqDev> {
*/
Integer bind(String planId, List<String> devIds);
/**
* 获取饼图数据
*
* @param planId 检测计划id
* @return 饼图数据
*/
//List<List<Map<String, Object>>> getPieData(String planId);
/**
* 根据id获取被检设备信息
*
@@ -137,25 +94,6 @@ public interface IPqDevService extends IService<PqDev> {
*/
PqDevVO getPqDevById(String id);
/**
* 获取所有非未检测状态的设备
*
* @return 所有非未检测状态的设备列表
*/
List<PqDev> listUnchecked();
/**
* 可视化各种id回显字典值解码等操作
*
* @param sourceList
*/
void visualize(List<PqDev> sourceList);
/**
* 逆向可视化
*/
void reverseVisualize(List<PqDev> sourceList);
/**
* 获取装置信息和装置下监测点信息
*
@@ -166,14 +104,6 @@ public interface IPqDevService extends IService<PqDev> {
*/
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
/**
* 设备归档操作
*
* @param id 设备id
* @return 归档成功返回true否则返回false
*/
boolean documented(List<String> id);
/**
* 正式监测完成,修改中断状态
@@ -181,31 +111,172 @@ public interface IPqDevService extends IService<PqDev> {
* @param ids
* @param valueType
* @param code
* @param userId
* @param temperature
* @param humidity
* @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);
int countUnReportDev(String planId);
long countUnReportDev(String planId);
/**
* 导出灿能二楼设备数据
* 根据计划id列表获取设备列表
*
* @param planIds
* @return
*/
List<PqDev> listByPlanIds(List<String> planIds);
/**
* 导出设备数据
*
* @param queryParam
*/
void exportCNDev(PqDevParam.QueryParam queryParam);
void exportDev(PqDevParam.QueryParam queryParam);
/**
* 下载灿能二楼设备模板文件
* 下载模板文件
*
* @param patternId 模式Id
*/
void downloadCNDevTemplate();
void downloadTemplate(String patternId);
/**
* 导入设备数据
*
* @param file 上传的文件
* @param patternId 模式Id
* @param planId 计划Id
* @param response 响应
*/
boolean importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
/**
* 导入灿能二楼设备数据
*
* @param cnDevExcelList 灿能二楼设备数据列表
* @param patternId 模式Id
* @param file 上传的文件
* @param patternId 模式Id
* @param planId 计划Id
* @param response 响应
*/
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId);
boolean importCNDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
/**
* 导入灿能二楼设备数据
*
* @param cnDevExcelList
* @param patternId
* @param planId
*/
boolean importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
/**
* 可视化-灿能二楼设备
*
* @param pqDevs
*/
void visualizeCNDev(List<PqDevVO> pqDevs);
/**
* 逆向可视化-灿能二楼设备
*
* @param pqDevs 设备列表
* @param patternId 模式Id
*/
void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId);
/**
* 导入省级平台设备数据
*
* @param file 上传的文件
* @param patternId 模式Id
* @param planId 计划Id
* @param response 响应
*/
boolean importProvinceDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
/**
* 导入省级平台设备数据
*
* @param proviceDevExcelList
* @param patternId
* @param planId
*/
boolean importProvinceDev(List<ProvinceDevExcel> proviceDevExcelList, String patternId, String planId);
/**
* 可视化-省级平台设备
*
* @param pqDevs
*/
void visualizeProvinceDev(List<PqDevVO> pqDevs);
/**
* 逆向可视化-省级平台设备
*
* @param pqDevs 设备列表
* @param patternId 模式Id
*/
void reverseVisualizeProvinceDev(List<PqDev> pqDevs, String patternId);
/**
* 获取省级平台设备导出、导出文件模板的下拉列表
*
* @param startCol 开始列
* @return
*/
List<PullDown> getProvinceDevPullDownList(int startCol);
/**
* 获取灿能二楼设备导出、导出文件模板的下拉列表
*
* @param startCol 开始列
* @return
*/
List<PullDown> getCNDevPullDownList(int startCol);
/**
* 导入比对式设备数据
*
* @param file 上传的文件
* @param patternId 模式Id
* @param planId 计划Id
* @param response 响应
*/
boolean importContrastDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
/**
* 导入比对式设备数据
*
* @param contrastDevExcelList
* @param patternId
*/
boolean importContrastDev(List<ContrastDevExcel> contrastDevExcelList, String patternId, String planId);
/**
* 获取比对式设备导出、导出文件模板的下拉列表
*
* @param startCol
* @return
*/
List<PullDown> getContrastDevPullDownList(int startCol);
/**
* 根据历史记录来获取下拉框内容
*
* @param pattern
* @return
*/
Map<String, List<String>> listSelectOptions(String pattern);
/**
* 获取比对式设备导出数据
*
* @param pqDevVOList 设备id列表
* @return
*/
List<ContrastDevExcel> getExportContrastDevData(List<PqDevVO> pqDevVOList);
}

View File

@@ -0,0 +1,12 @@
package com.njcn.gather.device.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.device.pojo.po.PqDevSub;
/**
* @author caozehui
* @date 2025-07-04
*/
public interface IPqDevSubService extends IService<PqDevSub> {
}

View File

@@ -0,0 +1,94 @@
package com.njcn.gather.device.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
import com.njcn.gather.device.pojo.po.PqStandardDev;
import com.njcn.gather.device.pojo.vo.PreDetection;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author caozehui
* @date 2025-07-02
*/
public interface IPqStandardDevService extends IService<PqStandardDev> {
/**
* 分页查询标准设备列表
*
* @param queryParam 分页查询参数
* @return
*/
Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam);
/**
* 根据id查询标准设备
*
* @param id 设备id
* @return 设备对象
*/
PqStandardDev getPqStandardDevById(String id);
/**
* 新增标准设备
*
* @param param 新增参数
* @return 新增成功返回true失败返回false
*/
boolean addPqStandardDev(PqStandardDevParam param);
/**
* 修改标准设备
*
* @param param 修改参数
* @return 修改成功返回true失败返回false
*/
boolean updatePqStandardDev(PqStandardDevParam.UpdateParam param);
/**
* 批量删除标准设备
*
* @param ids
* @return
*/
boolean deletePqStandardDevs(List<String> ids);
/**
* 导出标准设备
*
* @param queryParam
*/
void export(PqStandardDevParam.QueryParam queryParam);
/**
* 下装标准设备导入模板
*/
void downloadTemplate();
/**
* 导入标准设备数据
*
* @param file
* @return
*/
void importData(MultipartFile file, HttpServletResponse response);
/**
* 查询出指定计划以关联的标准设备列表
*
* @param planId
* @return
*/
List<PqStandardDev> listByPlanId(String planId);
/**
* 查询出标准设备所需的检测信息
*
* @param ids
* @return
*/
List<PreDetection> listStandardDevPreDetection(List<String> ids);
}

View File

@@ -0,0 +1,20 @@
package com.njcn.gather.device.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.device.pojo.po.PqDevSub;
import com.njcn.gather.device.mapper.PqDevSubMapper;
import com.njcn.gather.device.service.IPqDevSubService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author caozehui
* @date 2025-07-04
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class PqDevSubServiceImpl extends ServiceImpl<PqDevSubMapper, PqDevSub> implements IPqDevSubService {
}

View File

@@ -0,0 +1,303 @@
package com.njcn.gather.device.service.impl;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
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.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.poi.PullDown;
import com.njcn.common.utils.EncryptionUtil;
import com.njcn.gather.device.mapper.PqStandardDevMapper;
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
import com.njcn.gather.device.pojo.po.PqStandardDev;
import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqStandardDevService;
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictType;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.dictionary.service.IDictTypeService;
import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.PoiUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author 曹泽辉
* @date 2025-07-02
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, PqStandardDev> implements IPqStandardDevService {
private final IDevTypeService devTypeService;
private final IDictDataService dictDataService;
private final IDictTypeService dictTypeService;
private final AdPlanStandardDevMapper adPlanStandardDevMapper;
@Override
public Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) {
QueryWrapper<PqStandardDev> wrapper = new QueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName())
.eq(StrUtil.isNotBlank(queryParam.getManufacturer()), "manufacturer", queryParam.getManufacturer())
.eq(StrUtil.isNotBlank(queryParam.getDevType()), "dev_type", queryParam.getDevType())
.eq("state", DataStateEnum.ENABLE.getCode());
return this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper);
}
@Override
public PqStandardDev getPqStandardDevById(String id) {
PqStandardDev standardDev = this.getById(id);
if (standardDev.getEncryptionFlag() == 1) {
standardDev.setSeries(EncryptionUtil.decoderString(1, standardDev.getSeries()));
standardDev.setDevKey(EncryptionUtil.decoderString(1, standardDev.getDevKey()));
}
return standardDev;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addPqStandardDev(PqStandardDevParam param) {
this.checkRepeat(param, false);
PqStandardDev pqStandardDev = BeanUtil.copyProperties(param, PqStandardDev.class);
pqStandardDev.setState(DataStateEnum.ENABLE.getCode());
this.checkEncryption(pqStandardDev);
return this.save(pqStandardDev);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePqStandardDev(PqStandardDevParam.UpdateParam param) {
this.checkRepeat(param, true);
PqStandardDev pqStandardDev = BeanUtil.copyProperties(param, PqStandardDev.class);
this.checkEncryption(pqStandardDev);
return this.updateById(pqStandardDev);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deletePqStandardDevs(List<String> ids) {
LambdaUpdateWrapper<PqStandardDev> wrapper = new LambdaUpdateWrapper();
wrapper.set(PqStandardDev::getState, DataStateEnum.DELETED.getCode())
.in(PqStandardDev::getId, ids);
return this.update(wrapper);
}
@Override
public void export(PqStandardDevParam.QueryParam queryParam) {
QueryWrapper<PqStandardDev> wrapper = new QueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName())
.eq(StrUtil.isNotBlank(queryParam.getManufacturer()), "manufacturer", queryParam.getManufacturer())
.eq(StrUtil.isNotBlank(queryParam.getDevType()), "dev_type", queryParam.getDevType())
.eq("state", DataStateEnum.ENABLE.getCode());
List<PqStandardDev> pqStandardDevs = this.list(wrapper);
this.visualizeStandardDev(pqStandardDevs);
List<PqStandardDevExcel> pqStandardDevExcels = BeanUtil.copyToList(pqStandardDevs, PqStandardDevExcel.class);
ExcelUtil.exportExcelPullDown(new ExportParams(), "标准设备导出数据.xlsx", 1, this.getStandardDevPullDownList(), PqStandardDevExcel.class, pqStandardDevExcels);
}
@Override
public void downloadTemplate() {
ExcelUtil.exportExcelPullDown(new ExportParams(), "标准设备导入模板.xlsx", 1, this.getStandardDevPullDownList(), PqStandardDevExcel.class, Collections.emptyList());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importData(MultipartFile file, HttpServletResponse response) {
ImportParams params = new ImportParams();
params.setStartSheetIndex(0);
params.setSheetNum(1);
params.setNeedVerify(true);
params.setHeadRows(1);
List<PqStandardDevExcel> contrastDevExcelList = null;
try {
ExcelImportResult<PqStandardDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqStandardDevExcel.class, params);
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
Workbook failWorkbook = excelImportResult.getFailWorkbook();
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
} else {
contrastDevExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
}
this.importData(contrastDevExcelList);
}
@Override
public List<PqStandardDev> listByPlanId(String planId) {
return adPlanStandardDevMapper.listByPlanId(Collections.singletonList(planId));
}
@Override
public List<PreDetection> listStandardDevPreDetection(List<String> ids) {
if (CollectionUtil.isNotEmpty(ids)) {
return this.baseMapper.listStandardDevPreDetection(ids);
}
return Collections.emptyList();
}
/**
* 导入数据
*
* @param contrastDevExcelList
* @return
*/
private void importData(List<PqStandardDevExcel> contrastDevExcelList) {
if (CollectionUtil.isNotEmpty(contrastDevExcelList)) {
List<PqStandardDev> contrastDevs = BeanUtil.copyToList(contrastDevExcelList, PqStandardDev.class);
this.reverseVisualizeStandardDev(contrastDevs);
this.saveBatch(contrastDevs);
}
}
/**
* 获取标准设备导出文件下拉列表
*
* @return
*/
private List<PullDown> getStandardDevPullDownList() {
List<PullDown> pullDownList = new ArrayList<>();
PullDown pullDown = new PullDown();
// 设备类型
pullDown.setFirstCol(1);
pullDown.setLastCol(1);
pullDown.setStrings(devTypeService.listAll().stream().map(devType -> devType.getName()).collect(Collectors.toList()));
pullDownList.add(pullDown);
List<DictData> dictDataList = null;
// 设备厂家
DictType dictType = dictTypeService.getByCode("Dev_Manufacturers");
if (ObjectUtil.isNotNull(dictType)) {
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown();
pullDown.setFirstCol(2);
pullDown.setLastCol(2);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDownList.add(pullDown);
}
// 通讯协议
dictType = dictTypeService.getByCode("Protocol");
if (ObjectUtil.isNotNull(dictType)) {
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown();
pullDown.setFirstCol(4);
pullDown.setLastCol(4);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDownList.add(pullDown);
}
// 是否加密
pullDown = new PullDown();
pullDown.setFirstCol(7);
pullDown.setLastCol(7);
pullDown.setStrings(Arrays.asList("", ""));
pullDownList.add(pullDown);
return pullDownList;
}
/**
* 可视化标准设备
*
* @param pqStandardDevs
*/
private void visualizeStandardDev(List<PqStandardDev> pqStandardDevs) {
pqStandardDevs.forEach(pqStandardDev -> {
pqStandardDev.setDevType(devTypeService.getById(pqStandardDev.getDevType()).getName());
pqStandardDev.setManufacturer(dictDataService.getDictDataById(pqStandardDev.getManufacturer()).getName());
pqStandardDev.setProtocol(dictDataService.getDictDataById(pqStandardDev.getProtocol()).getName());
if (pqStandardDev.getEncryptionFlag() == 1) {
pqStandardDev.setSeries(EncryptionUtil.decoderString(1, pqStandardDev.getSeries()));
pqStandardDev.setDevKey(EncryptionUtil.decoderString(1, pqStandardDev.getDevKey()));
}
});
}
/**
* 逆向可视化标准设备
*
* @param pqStandardDevs
*/
private void reverseVisualizeStandardDev(List<PqStandardDev> pqStandardDevs) {
pqStandardDevs.forEach(pqStandardDev -> {
PqStandardDevParam pqStandardDevParam = BeanUtil.copyProperties(pqStandardDev, PqStandardDevParam.class);
this.checkRepeat(pqStandardDevParam, false);
this.checkEncryption(pqStandardDev);
pqStandardDev.setDevType(devTypeService.getByName(pqStandardDev.getDevType()).getId());
pqStandardDev.setManufacturer(dictDataService.getDictDataByName(pqStandardDev.getManufacturer()).getId());
pqStandardDev.setProtocol(dictDataService.getDictDataByName(pqStandardDev.getProtocol()).getId());
pqStandardDev.setState(DataStateEnum.ENABLE.getCode());
});
}
/**
* 检查是否重复
*
* @param pqStandardDevParam
* @param isExcludeSelf
*/
private void checkRepeat(PqStandardDevParam pqStandardDevParam, boolean isExcludeSelf) {
QueryWrapper<PqStandardDev> wrapper = new QueryWrapper<>();
wrapper.eq("pq_standard_dev.Name", pqStandardDevParam.getName())
.eq("pq_standard_dev.State", DataStateEnum.ENABLE.getCode());
if (isExcludeSelf) {
if (pqStandardDevParam instanceof PqStandardDevParam.UpdateParam) {
wrapper.ne("pq_standard_dev.Id", ((PqStandardDevParam.UpdateParam) pqStandardDevParam).getId());
}
}
int count = this.count(wrapper);
if (count > 0) {
throw new BusinessException(DetectionResponseEnum.PQ_STANDARD_DEV_REPEAT);
}
}
/**
* 检查加密情况
*
* @param pqStandardDev
*/
private void checkEncryption(PqStandardDev pqStandardDev) {
if (pqStandardDev.getEncryptionFlag() == 1) {
if (StrUtil.isNotBlank(pqStandardDev.getSeries()) && StrUtil.isNotBlank(pqStandardDev.getDevKey())) {
pqStandardDev.setSeries(EncryptionUtil.encodeString(1, pqStandardDev.getSeries()));
pqStandardDev.setDevKey(EncryptionUtil.encodeString(1, pqStandardDev.getDevKey()));
} else {
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
}
}

View File

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

View File

@@ -2,12 +2,20 @@ package com.njcn.gather.err.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.err.pojo.po.PqErrSys;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author caozehui
* @date 2024-11-27
*/
public interface PqErrSysMapper extends MPJBaseMapper<PqErrSys> {
/**
* 根据ids获取绑定的计划数量
* @param ids
* @return
*/
Integer getCountBoundByIds(@Param("ids") List<String> ids);
}

View File

@@ -3,5 +3,16 @@
<mapper namespace="com.njcn.gather.err.mapper.PqErrSysMapper">
<select id="getCountBoundByIds" resultType="java.lang.Integer">
SELECT COUNT(*) FROM ad_plan
<if test="ids!= null and ids.size() > 0">
<where>
AND Error_Sys_Id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</if>
</select>
</mapper>

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.err.pojo.param;
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 lombok.Data;
@@ -17,13 +17,13 @@ import javax.validation.constraints.Pattern;
public class PqErrSysDtlsParam {
@ApiModelProperty(value = "误差项类型", required = true)
@NotBlank(message = DevValidMessage.ERR_SYS_DTLS_ERROR_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERR_SYS_DTLS_ERROR_TYPE_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ERR_SYS_DTLS_ERROR_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ERR_SYS_DTLS_ERROR_TYPE_FORMAT_ERROR)
private String errorType;
@ApiModelProperty(value = "脚本项类型", required = true)
@NotBlank(message = DevValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR)
private String scriptType;
@ApiModelProperty(value = "误差判断起始值", required = true)
@@ -38,24 +38,25 @@ public class PqErrSysDtlsParam {
@ApiModelProperty(value = "是否包含结束值", required = true)
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)
private Integer conditionType;
@ApiModelProperty(value = "最大值误差", required = true)
@NotNull(message = DevValidMessage.MAX_ERROR_VALUE_NOT_NULL)
@NotNull(message = DetectionValidMessage.MAX_ERROR_VALUE_NOT_NULL)
private Double maxErrorValue;
@ApiModelProperty(value = "误差值类型", required = true)
@NotNull(message = DevValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
@NotNull(message = DetectionValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
private Integer errorValueType;
@ApiModelProperty("排序")
@NotNull(message = DevValidMessage.SORT_NOT_NULL)
@NotNull(message = DetectionValidMessage.SORT_NOT_NULL)
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;
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.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
@@ -20,39 +20,38 @@ import java.util.List;
public class PqErrSysParam {
@ApiModelProperty(value = "参照标准名称", required = true)
@NotBlank(message = DevValidMessage.STANDARD_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.STANDARD_NAME_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.STANDARD_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME_REGEX, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
private String standardName;
@ApiModelProperty(value = "标准实施年份", required = true)
@NotBlank(message = DevValidMessage.STANDARD_TIME_NOT_BLANK)
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.STANDARD_TIME_NOT_BLANK)
@DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
private String standardTime;
@ApiModelProperty(value = "设备等级", required = true)
@NotBlank(message = DevValidMessage.DEV_LEVEL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_LEVEL_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.DEV_LEVEL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_LEVEL_FORMAT_ERROR)
private String devLevel;
@ApiModelProperty("状态")
@NotNull(message = DevValidMessage.ENABLE_NOT_NULL)
@Min(value = 0, message = DevValidMessage.ENABLE_FORMAT_ERROR)
@Max(value = 1, message = DevValidMessage.ENABLE_FORMAT_ERROR)
@NotNull(message = DetectionValidMessage.ENABLE_NOT_NULL)
@Min(value = 0, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
@Max(value = 1, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
private Integer enable;
@ApiModelProperty(value = "误差详情列表", required = true)
@Valid
private List<PqErrSysDtlsParam> pqErrSysDtlsList;
@Data
@EqualsAndHashCode(callSuper = false)
public static class QueryParam extends BaseParam {
@ApiModelProperty("标准实施年份")
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
@DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
private String standardTime;
@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;
}
@@ -60,14 +59,14 @@ public class PqErrSysParam {
@EqualsAndHashCode(callSuper = false)
public static class UpdateParam extends PqErrSysParam {
@ApiModelProperty("id")
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id;
}
@Data
@EqualsAndHashCode(callSuper = false)
public static class DetectionParam{
public static class DetectionParam {
@ApiModelProperty("所属误差体系ID")
private String errorSysId;
@@ -76,6 +75,14 @@ public class PqErrSysParam {
@ApiModelProperty("所属检测脚本")
private String scriptId;
@ApiModelProperty("电压")
private Double un;
@ApiModelProperty("电流")
private Double in;
}
}

View File

@@ -60,10 +60,6 @@ public class PqErrSysDtls implements Serializable {
*/
private Integer endFlag;
/**
* 单位
*/
// private String unit;
/**
* 判断条件值类型(包括值类型,绝对值、相对值)
@@ -77,7 +73,7 @@ public class PqErrSysDtls implements Serializable {
private Double maxErrorValue;
/**
* 误差值类型
* 误差值类型(绝对值:0:标称值 1:标准值 2:值比较 相对值:0标称值 1:标准值)
*/
private Integer errorValueType;
@@ -86,5 +82,14 @@ public class PqErrSysDtls implements Serializable {
*/
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;
/**
* 默认参与比较值4.不参与值 5.不参与误差比较)
*/
private Integer isQualified;
/**
* 误差体系
*/

View File

@@ -57,4 +57,10 @@ public interface IPqErrSysDtlsService extends IService<PqErrSysDtls> {
* @return
*/
List<ErrDtlsCheckDataVO> listByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param);
/**
* 根据误差体系id和脚本类型查询脚本类型
* @return
*/
List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndScriptType(String errSysId, String scriptType);
}

View File

@@ -78,5 +78,13 @@ public interface IPqErrSysService extends IService<PqErrSys> {
* @param id 误差体系id
* @return 成功返回true失败返回false
*/
//boolean copyPqErrSys(String id);
boolean copyPqErrSys(String id);
/**
* 根据id获取测试项列表
*
* @param id 误差体系id
* @return
*/
List<Map<String, String>> getTestItems(String id);
}

View File

@@ -4,12 +4,14 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.err.mapper.PqErrSysDtlsMapper;
import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
import com.njcn.gather.err.pojo.param.PqErrSysParam;
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
import com.njcn.gather.err.service.IPqErrSysDtlsService;
import com.njcn.gather.script.mapper.PqScriptMapper;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.script.service.IPqScriptCheckDataService;
@@ -20,6 +22,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -33,7 +36,7 @@ import java.util.stream.Collectors;
public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqErrSysDtls> implements IPqErrSysDtlsService {
private final IPqScriptCheckDataService pqScriptCheckDataService;
private final PqScriptMapper pqScriptMapper;
@Override
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
@@ -41,7 +44,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
}
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional
public boolean addPqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) {
List<PqErrSysDtls> data = new ArrayList<>();
for (PqErrSysDtlsParam param : list) {
@@ -54,7 +57,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
}
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional
public boolean updatePqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) {
//先按照pqErrSysId全部删除
this.deletePqErrSysDtlsByPqErrSysId(Collections.singletonList(pqErrSysId));
@@ -64,7 +67,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
}
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional
public boolean deletePqErrSysDtlsByPqErrSysId(List<String> pqErrSysIds) {
QueryWrapper<PqErrSysDtls> queryWrapper = new QueryWrapper<>();
queryWrapper.in("pq_err_sys_dtls.Error_Sys_Id", pqErrSysIds);
@@ -91,37 +94,75 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
@Override
public List<ErrDtlsCheckDataVO> listByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param) {
List<ErrDtlsCheckDataVO> info=new ArrayList<>();
List<ErrDtlsCheckDataVO> info = new ArrayList<>();
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
checkDataParam.setScriptId(param.getScriptId());
checkDataParam.setIndex(param.getIndex());
//获取检测脚本中所有装置下发的测试项
List<PqScriptCheckData> list = pqScriptCheckDataService.listCheckDataCode(checkDataParam);
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId());
List<String> valueType = list.stream().filter(x->x.getErrorFlag()!=0).map(PqScriptCheckData::getValueType).collect(Collectors.toList());
Map<String, List<PqErrSysDtls>> errMap =new HashMap<>(3);
if(CollUtil.isNotEmpty(valueType)){
Map<String, Integer> valueType = list.stream().collect(Collectors.toMap(PqScriptCheckData::getValueType, PqScriptCheckData::getErrorFlag,
(key1, key2) -> key1));
//获取误差体系
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)
.selectAll(PqErrSysDtls.class)
.selectAs(DictTree::getCode, PqErrSysDtls::getScriptCode)
.leftJoin(DictTree.class, DictTree::getId, PqErrSysDtls::getScriptType)
.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;
for (PqScriptCheckData script : list) {
dataVO=new ErrDtlsCheckDataVO();
dataVO = new ErrDtlsCheckDataVO();
dataVO.setCheckDataId(script.getScriptId());
dataVO.setValueTypeCode(script.getValueTypeCode());
dataVO.setValueType(script.getValueType());
dataVO.setValue(script.getValue());
dataVO.setPhase(script.getPhase());
if(errMap.containsKey(script.getValueType())){
dataVO.setErrSysDtls(errMap.get(script.getValueType()));
if (isValueType) {
if (DetectionCodeEnum.VRMS.getCode().equals(script.getValueTypeCode())) {
BigDecimal volValue = new BigDecimal(script.getValue());
BigDecimal result = volValue.multiply(new BigDecimal(param.getUn().toString()))
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
dataVO.setValue(result.doubleValue());
}
if (DetectionCodeEnum.IRMS.getCode().equals(script.getValueTypeCode())) {
BigDecimal volValue = new BigDecimal(script.getValue());
BigDecimal result = volValue.multiply(new BigDecimal(param.getIn().toString()))
.divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
dataVO.setValue(result.doubleValue());
}
}
if (valueType.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()));
}
} else { //不参与误差比较
dataVO.setIsQualified(5);
}
}
info.add(dataVO);
}
return info;
}
@Override
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndScriptType(String errSysId, String scriptType) {
MPJLambdaWrapper<PqErrSysDtls> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(PqErrSysDtls.class)
.leftJoin(DictTree.class, DictTree::getId, PqErrSysDtls::getScriptType)
.eq(PqErrSysDtls::getErrorSysId, errSysId)
.eq(DictTree::getId, scriptType);
return this.list(wrapper);
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.err.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -8,13 +9,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.err.mapper.PqErrSysMapper;
import com.njcn.gather.err.pojo.param.PqErrSysDtlsParam;
import com.njcn.gather.err.pojo.param.PqErrSysParam;
import com.njcn.gather.err.pojo.po.PqErrSys;
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.err.pojo.vo.PqErrSysDtlsVO;
import com.njcn.gather.err.service.IPqErrSysDtlsService;
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.DictTree;
import com.njcn.gather.system.dictionary.service.IDictDataService;
@@ -22,7 +24,6 @@ import com.njcn.gather.system.dictionary.service.IDictTreeService;
import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -64,8 +65,10 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
}
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional
public boolean addPqErrSys(PqErrSysParam param) {
param.setStandardName(param.getStandardName().trim());
this.checkRepeat(param, false);
PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys);
String id = UUID.randomUUID().toString().replaceAll("-", "");
@@ -78,9 +81,12 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
return result1 && result2;
}
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
param.setStandardName(param.getStandardName().trim());
this.checkRepeat(param, true);
PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys);
pqErrSys.setName(generateErrSysName(param));
@@ -91,8 +97,12 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
}
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional
public boolean deletePqErrSys(List<String> ids) {
Integer count = this.baseMapper.getCountBoundByIds(ids);
if (count > 0) {
throw new BusinessException(DetectionResponseEnum.ERR_SYS_BOUND_NOT_DELETE);
}
pqErrSysDtlsService.deletePqErrSysDtlsByPqErrSysId(ids);
this.lambdaUpdate().in(PqErrSys::getId, ids).set(PqErrSys::getState, DataStateEnum.DELETED.getCode()).update();
return true;
@@ -116,9 +126,10 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
}
@Override
@Transactional(rollbackFor = {Exception.class})
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 -> {
Map<String, Object> map = new HashMap<>();
map.put("id", pqErrSys.getId());
@@ -182,29 +193,46 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
if (ObjectUtil.isNotNull(devLevelDictData)) {
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
// public boolean copyPqErrSys(String id) {
// PqErrSys pqErrSys = this.getPqErrSysById(id);
// pqErrSys.setId(UUID.randomUUID().toString().replaceAll("-", ""));
// pqErrSys.setName(pqErrSys.getName() + "_副本");
// pqErrSys.setStandardTime(LocalDate.of(pqErrSys.getStandardTime().getYear(), 1, 1));
// pqErrSys.getPqErrSysDtlsList().forEach(pqErrSysDtls -> pqErrSysDtls.setId(UUID.randomUUID().toString().replaceAll("-", "")));
// return this.save(pqErrSys);
// }
@Override
public boolean copyPqErrSys(String id) {
PqErrSys pqErrSys = this.getPqErrSysById(id);
pqErrSys.setId(UUID.randomUUID().toString().replaceAll("-", ""));
pqErrSys.setName(pqErrSys.getName() + "_copy");
pqErrSys.setStandardName(pqErrSys.getStandardName() + "_copy");
pqErrSys.setStandardTime(LocalDate.of(pqErrSys.getStandardTime().getYear(), 1, 1));
List<PqErrSysDtlsParam> pqErrSysDtlsParams = BeanUtil.copyToList(pqErrSys.getPqErrSysDtlsList(), PqErrSysDtlsParam.class);
pqErrSysDtlsService.addPqErrSysDtls(pqErrSys.getId(), pqErrSysDtlsParams);
return this.save(pqErrSys);
}
@Override
public List<Map<String, String>> getTestItems(String id) {
return null;
}
/**
* 生成误差体系名称(标准号+年份+设备等级)
* 检查重复
*
* @return 检测源名称
* @param param 检测参数
* @param isExcludeSelf 是否排除自己
*/
private String generatePqSourceName(PqErrSysParam param) {
DictData devLevel = dictDataService.getDictDataById(param.getDevLevel());
if (ObjectUtils.allNotNull(param.getStandardName(), param.getStandardTime(), devLevel)) {
return param.getStandardName() + "-" + param.getStandardTime() + "-" + devLevel.getName();
private void checkRepeat(PqErrSysParam param, boolean isExcludeSelf) {
QueryWrapper<PqErrSys> wrapper = new QueryWrapper<>();
wrapper.eq("Standard_Name", param.getStandardName())
.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.po.PqIcdPath;
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.utils.HttpResultUtil;
import io.swagger.annotations.Api;
@@ -27,16 +25,15 @@ import java.util.List;
/**
*
* @author caozehui
* @date 2025-02-10
*/
@Slf4j
@Api(tags="icd管理")
@Api(tags = "icd管理")
@RestController
@RequestMapping("/icd")
@RequiredArgsConstructor
public class PqIcdPathController extends BaseController{
public class PqIcdPathController extends BaseController {
private final IPqIcdPathService pqIcdPathService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@@ -63,15 +60,15 @@ public class PqIcdPathController extends BaseController{
@PostMapping("/add")
@ApiOperation("新增icd")
@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");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = pqIcdPathService.addIcd(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} 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")
@ApiOperation("修改icd")
@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");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
boolean result = pqIcdPathService.updateIcd(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} 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")
@ApiOperation("删除icd")
@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");
LogUtil.njcnDebug(log, "{},删除数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = pqIcdPathService.deleteIcd(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} 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.njcn.gather.icd.pojo.po.PqIcdPath;
import org.apache.ibatis.annotations.Param;
/**
* @author caozehui
@@ -9,5 +10,12 @@ import com.njcn.gather.icd.pojo.po.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">
<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>

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;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.icd.pojo.constant.PqIcdPathValidMessage;
import com.njcn.gather.type.pojo.constant.DevTypeValidMessage;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -18,11 +17,13 @@ import javax.validation.constraints.Pattern;
@Data
public class PqIcdPathParam {
@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;
@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;
/**
@@ -43,8 +44,8 @@ public class PqIcdPathParam {
@EqualsAndHashCode(callSuper = true)
public static class UpdateParam extends PqIcdPathParam {
@ApiModelProperty(value = "id", required = true)
@NotBlank(message = PqIcdPathValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = PqIcdPathValidMessage.ID_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id;
}
}

View File

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

View File

@@ -7,16 +7,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.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.po.PqIcdPath;
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -45,7 +45,9 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
}
@Override
@Transactional
public boolean addIcd(PqIcdPathParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, false);
PqIcdPath pqIcdPath = new PqIcdPath();
BeanUtils.copyProperties(param, pqIcdPath);
@@ -54,7 +56,9 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
}
@Override
@Transactional
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
param.setName(param.getName().trim());
this.checkRepeat(param, true);
PqIcdPath pqIcdPath = new PqIcdPath();
BeanUtils.copyProperties(param, pqIcdPath);
@@ -62,10 +66,16 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
}
@Override
@Transactional
public boolean deleteIcd(List<String> ids) {
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) {
LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PqIcdPath::getName, param.getName())
@@ -77,7 +87,7 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
}
int count = this.count(wrapper);
if (count > 0) {
throw new BusinessException(IcdPathResponseEnum.ICD_PATH_NAME_REPEAT);
throw new BusinessException(DetectionResponseEnum.ICD_PATH_NAME_REPEAT);
}
}
}

View File

@@ -1,13 +1,26 @@
package com.njcn.gather.monitor.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.common.utils.LogUtil;
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
import com.njcn.gather.monitor.pojo.po.PqMonitor;
import com.njcn.gather.monitor.service.IPqMonitorService;
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;
import java.util.List;
/**
* @author caozehui
@@ -21,5 +34,15 @@ import org.springframework.web.bind.annotation.RestController;
public class PqMonitorController extends BaseController {
private final IPqMonitorService pqMonitorService;
@OperateInfo
@PostMapping("/list")
@ApiOperation("查询监测点")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<List<PqMonitor>> list(@RequestBody PqMonitorParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
List<PqMonitor> result = pqMonitorService.listPqMonitorByDevId(queryParam.getDevId());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -4,15 +4,16 @@
<select id="selectMonitorInfo"
resultType="com.njcn.gather.device.pojo.vo.PreDetection$MonitorListDTO">
SELECT
Id as lineId,
Num as line,
pt as pt,
ct as ct
FROM
pq_monitor
WHERE
dev_id = #{devId}
SELECT CONCAT(pq_dev.IP, '_', Num) as lineId,
Num as line,
pt as pt,
ct as ct,
Stat_Interval,
sys_dict_data.Code as `Connection`
FROM pq_monitor
inner join sys_dict_data on pq_monitor.Connection = sys_dict_data.id
inner join pq_dev on pq_monitor.Dev_Id = pq_dev.Id
WHERE Dev_Id = #{devId}
</select>
</mapper>

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.monitor.pojo.param;
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 lombok.Data;
import lombok.EqualsAndHashCode;
@@ -17,28 +17,63 @@ import javax.validation.constraints.Pattern;
@Data
public class PqMonitorParam {
@ApiModelProperty(value = "谐波系统监测点ID")
private String code;
@ApiModelProperty(value = "所属设备id")
@NotBlank(message = DetectionValidMessage.DEVICE_ID_NOT_BLANK)
private String devId;
@ApiModelProperty(value = "所属母线")
@NotBlank(message = DevValidMessage.BELONG_LINE_NOT_BLANK)
@NotBlank(message = DetectionValidMessage.BELONG_LINE_NOT_BLANK)
private String busbar;
@ApiModelProperty(value = "监测点名称")
@NotBlank(message = DetectionValidMessage.MONITOR_NAME_NOT_BLANK)
private String name;
@ApiModelProperty(value = "监测点序号")
@NotNull(message = DevValidMessage.MONITOR_NUM_NOT_NULL)
@ApiModelProperty(value = "线路号(监测点序号)")
@NotNull(message = DetectionValidMessage.MONITOR_NUM_NOT_NULL)
private Integer num;
@ApiModelProperty(value = "PT变比")
@NotNull(message = DevValidMessage.PT_NOT_NULL)
private Float pt;
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
private String pt;
@ApiModelProperty(value = "CT变比")
@NotNull(message = DevValidMessage.CT_NOT_NULL)
private Float ct;
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
private String ct;
@ApiModelProperty(value = "接线方式")
@NotBlank(message = DevValidMessage.WIRING_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.WIRING_TYPE_FORMAT_ERROR)
private String ptType;
@NotBlank(message = DetectionValidMessage.CONNECTION_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.CONNECTION_FORMAT_ERROR)
private String connection;
@ApiModelProperty(value = "统计间隔")
@NotNull(message = DetectionValidMessage.STAT_INTERVAL_NOT_NULL)
private Integer statInterval;
@ApiModelProperty(value = "谐波系统监测点id")
@NotBlank(message = DetectionValidMessage.MONITOR_ID_NOT_BLANK)
private String harmSysId;
/**
* 分页查询实体
*/
@Data
public static class QueryParam {
@ApiModelProperty(value = "所属设备id")
@NotBlank(message = DetectionValidMessage.DEVICE_ID_NOT_BLANK)
private String devId;
}
/**
* 修改实体
*/
// @Data
// @EqualsAndHashCode(callSuper = true)
// public static class UpdateParam extends PqMonitorParam {
// @ApiModelProperty(value = "监测点id", required = true)
// @NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
// private String id;
// }
}

View File

@@ -1,9 +1,7 @@
package com.njcn.gather.monitor.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;
@@ -20,40 +18,49 @@ public class PqMonitor implements Serializable {
*/
private String id;
/**
* 默认与谐波系统监测点ID相同
*/
private String code;
/**
* 所属设备ID
*/
private String devId;
/**
* 所属母线
* 监测点名称
*/
private String name;
/**
* 监测点序号
* 所属母线
*/
private String busbar;
/**
* 线路号(监测点序号)
*/
private Integer num;
/**
* PT变比
*/
private Float pt;
private String pt;
/**
* CT变比
*/
private Float ct;
private String ct;
/**
* 统计间隔
*/
private Integer statInterval;
/**
* 接线方式,字典表
*/
private String ptType;
private String connection;
/**
* 谐波系统监测点id
*/
private String harmSysId;
}

View File

@@ -1,14 +1,11 @@
package com.njcn.gather.monitor.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
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.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @author caozehui
@@ -17,36 +14,35 @@ import javax.validation.constraints.Pattern;
@Data
public class PqMonitorExcel {
@Excel(name = "监测点序号", width = 20, orderNum = "1")
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MONITOR_NUM_FORMAT_ERROR)
private Integer num;
@Excel(name = "谐波系统监测点ID*", width = 20, orderNum = "1")
@NotBlank(message = DetectionValidMessage.MONITOR_ID_NOT_BLANK)
private String harmSysId;
@Excel(name = "所属母线", width = 20, orderNum = "2")
@NotBlank(message = DevValidMessage.BELONG_LINE_NOT_BLANK)
@Excel(name = "所属母线*", width = 20, orderNum = "2")
@NotBlank(message = DetectionValidMessage.BELONG_LINE_NOT_BLANK)
private String busbar;
@Excel(name = "监测点名称*", width = 20, orderNum = "3")
@NotBlank(message = DetectionValidMessage.MONITOR_NAME_NOT_BLANK)
private String name;
@Excel(name = "PT变比", width = 20, orderNum = "3")
@NotNull(message = DevValidMessage.PT_NOT_NULL)
private Float pt;
@Excel(name = "线路号(监测点序号)*", width = 20, orderNum = "4")
@NotNull(message = DetectionValidMessage.MONITOR_NUM_NOT_NULL)
private Integer num;
@Excel(name = "CT变比", width = 20, orderNum = "4")
@NotNull(message = DevValidMessage.CT_NOT_NULL)
private Float ct;
@Excel(name = "PT变比(pt1:pt2)*", width = 20, orderNum = "5")
@NotBlank(message = DetectionValidMessage.PT_NOT_BLANK)
private String pt;
@Excel(name = "接线方式", width = 20, orderNum = "5")
@NotBlank(message = DevValidMessage.WIRING_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.WIRING_TYPE_FORMAT_ERROR)
private String ptType;
@Excel(name = "CT变比(ct1:ct2)*", width = 20, orderNum = "6")
@NotBlank(message = DetectionValidMessage.CT_NOT_BLANK)
private String ct;
@Data
@EqualsAndHashCode(callSuper = true)
public static class ImportData extends PqMonitorExcel {
@Excel(name = "接线方式*", width = 20, orderNum = "7")
@NotBlank(message = DetectionValidMessage.CONNECTION_NOT_BLANK)
private String connection;
}
@Data
@EqualsAndHashCode(callSuper = true)
public static class ExportData extends PqMonitorExcel {
}
@Excel(name = "统计间隔*", width = 10, orderNum = "8")
@NotNull(message = DetectionValidMessage.STAT_INTERVAL_NOT_NULL)
private Integer statInterval;
}

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.monitor.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
import com.njcn.gather.monitor.pojo.po.PqMonitor;
@@ -13,6 +13,8 @@ import java.util.List;
*/
public interface IPqMonitorService extends IService<PqMonitor> {
/**
* 根据设备id获取所有监测点信息
*
@@ -22,28 +24,42 @@ public interface IPqMonitorService extends IService<PqMonitor> {
List<PqMonitor> listPqMonitorByDevId(String devId);
/**
* 批量新增监测点信息
* 根据设备id批量新增监测点信息
*
* @param devId 被检设备id
* @param pqMonitorParamList 监测点信息列表
* @return 新增成功返回true否则返回false
* @param devId
* @param monitorList
* @return
*/
boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList);
boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> monitorList);
/**
* 批量删除监测点信息
* 根据设备id批量修改监测点信息
*
* @param devId 被检设备id
* @return 删除成功返回true否则返回false
* @param devId
* @param paramList
* @return
*/
boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList);
/**
* 根据设备id删除监测点信息
*
* @param devId
* @return
*/
boolean deletePqMonitorByDevId(String devId);
/**
* 修改监测点信息
* 可视化监测点
*
* @param devId 被检设备id
* @param paramList 监测点信息
* @return 修改成功返回true否则返回false
* @param monitorList
*/
boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList);
void visualizeMonitor(List<PqMonitor> monitorList);
/**
* 逆向可视化监测点
*
* @param monitorList
*/
void reverseVisualizeMonitor(List<PqMonitor> monitorList);
}

View File

@@ -1,13 +1,16 @@
package com.njcn.gather.monitor.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.monitor.mapper.PqMonitorMapper;
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
import com.njcn.gather.monitor.pojo.po.PqMonitor;
import com.njcn.gather.monitor.service.IPqMonitorService;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -33,23 +36,14 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
}
@Override
@Transactional(rollbackFor = {Exception.class})
public boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList) {
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(pqMonitorParamList, PqMonitor.class);
public boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> monitorList) {
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(monitorList, PqMonitor.class);
pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId));
return this.saveBatch(pqMonitorList);
}
@Override
@Transactional(rollbackFor = {Exception.class})
public boolean deletePqMonitorByDevId(String devId) {
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
wrapper.eq("pq_monitor.Dev_Id", devId);
return this.remove(wrapper);
}
@Override
@Transactional(rollbackFor = {Exception.class})
@Transactional
public boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList) {
// 先删除原有数据
this.deletePqMonitorByDevId(devId);
@@ -59,4 +53,35 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
return this.saveBatch(pqMonitorList);
}
@Override
@Transactional
public boolean deletePqMonitorByDevId(String devId) {
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
wrapper.eq("pq_monitor.Dev_Id", devId);
return this.remove(wrapper);
}
@Override
public void visualizeMonitor(List<PqMonitor> monitorList) {
monitorList.forEach(monitor -> {
DictData dictData = dictDataService.getDictDataById(monitor.getConnection());
if (ObjectUtil.isNotNull(dictData)) {
monitor.setConnection(dictData.getName());
} else {
throw new BusinessException(DetectionResponseEnum.CONNECTION_NOT_EXIST);
}
});
}
@Override
public void reverseVisualizeMonitor(List<PqMonitor> monitorList) {
monitorList.forEach(monitor -> {
DictData dictData = dictDataService.getDictDataByName(monitor.getConnection());
if (ObjectUtil.isNotNull(dictData)) {
monitor.setConnection(dictData.getId());
} else {
throw new BusinessException(DetectionResponseEnum.CONNECTION_NOT_EXIST);
}
});
}
}

View File

@@ -1,28 +1,30 @@
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.param.PqDevParam;
import com.njcn.gather.device.pojo.po.PqStandardDev;
import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.plan.pojo.param.AdPlanParam;
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.FileUtil;
import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -36,7 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author caozehui
@@ -50,65 +52,67 @@ import java.util.Map;
public class AdPlanController extends BaseController {
private final IAdPlanService adPlanService;
private final IPqDevService pqDevService;
private final IDevTypeService devTypeService;
@OperateInfo
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/list")
@ApiOperation("分页查询检测计划")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<Page<AdPlanVO>> list(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
public HttpResult<List<AdPlanVO>> list(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
Page<AdPlanVO> result = adPlanService.listAdPlan(queryParam);
List<AdPlanVO> result = adPlanService.listAdPlan(queryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(operateType = OperateType.ADD)
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增检测计划")
@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");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
boolean result = adPlanService.addAdPlan(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(operateType = OperateType.UPDATE)
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("修改检测计划")
@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");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
boolean result = adPlanService.updateAdPlan(updateParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(operateType = OperateType.DELETE)
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
@PostMapping("/delete")
@ApiOperation("删除检测计划")
@ApiImplicitParam(name = "ids", value = "检测计划id", required = true)
public HttpResult<Object> delete(@RequestBody List<String> ids) {
@ApiImplicitParam(name = "ids", value = "计划id列表", required = true)
public HttpResult<Boolean> delete(@RequestBody List<String> ids, @RequestParam("pattern") String pattern) {
String methodDescribe = getMethodDescribe("delete");
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = adPlanService.deleteAdPlan(ids);
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids), pattern);
boolean result = adPlanService.deleteAdPlan(ids, pattern);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/listByPattern")
@ApiOperation("按照模式查询检测计划")
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
@@ -119,79 +123,237 @@ public class AdPlanController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载监测计划导入文件模板")
public void downloadTemplate() {
adPlanService.downloadTemplate();
}
@OperateInfo(operateType = OperateType.DOWNLOAD)
@PostMapping("/export")
@ApiOperation("导出检测计划")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public void export(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("export");
public void exportPlan(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("exportPlan");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
List<AdPlanExcel.ExportData> data = adPlanService.getExportData(queryParam);
ExcelUtil.exportExcel("检测计划导出数据.xlsx", AdPlanExcel.ExportData.class, data);
adPlanService.exportPlan(queryParam);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载检测计划导出模板")
public void downloadTemplate(@RequestBody AdPlanParam param) {
adPlanService.downloadTemplate(param.getPattern());
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping(value = "/import")
@ApiOperation("批量导入检测计划数据")
@ApiOperation("导入检测计划数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
})
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importData");
LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为{}", methodDescribe, file.getOriginalFilename(), patternId);
public HttpResult<Boolean> importPlan(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importCNPlan");
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
ImportParams params = new ImportParams();
params.setHeadRows(2);
params.setNeedVerify(true);
params.setStartSheetIndex(0);
params.setSheetNum(1);
try {
ExcelImportResult<AdPlanExcel.ImportData> adPlanExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.ImportData.class, params);
if (adPlanExcelResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
PoiUtil.exportFileByWorkbook(adPlanExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
} else {
List<AdPlanExcel.ImportData> adPlanExcelList = adPlanExcelResult.getList();
if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
adPlanService.importData(patternId, adPlanExcelList);
}
}
} catch (Exception e) {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL, e.getMessage());
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
}
boolean result = adPlanService.importPlan(file, patternId, response);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
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
@GetMapping("/getBigTestItem")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getBigTestItem")
@ApiOperation("获取检测大项数据")
@ApiImplicitParam(name = "id", value = "检测计划id", required = true)
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestParam("planId") String planId) {
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestBody AdPlanParam.CheckParam checkParam) {
String methodDescribe = getMethodDescribe("getBigTestItem");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
List<Map<String, String>> result = adPlanService.getBigTestItem(planId);
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, checkParam);
List<Map<String, String>> result = adPlanService.getBigTestItem(checkParam.getReCheckType(), checkParam.getPlanId(), checkParam.getDevIds());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/analyse")
@ApiOperation("检测数据分析")
@ApiImplicitParam(name = "planId", value = "检测计划id", required = true)
public void analyse(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("analyse");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
adPlanService.analyse(ids);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/listByPlanId")
@ApiOperation("查询出所有已绑定的设备")
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
String methodDescribe = getMethodDescribe("listByPlanId");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
AdPlan plan = adPlanService.getById(param.getPlanIdList().get(0));
if (CommonEnum.FATHER_ID.getValue().equals(plan.getFatherPlanId())) {
List<AdPlan> planList = adPlanService.lambdaQuery().eq(AdPlan::getFatherPlanId, param.getPlanIdList().get(0)).list();
List<String> planIdList = planList.stream().map(AdPlan::getId).collect(Collectors.toList());
param.getPlanIdList().addAll(planIdList);
}
List<PqDevVO> pqDevVOList = pqDevService.listByPlanId(param);
List<AdPlan> planList = adPlanService.listByIds(param.getPlanIdList());
pqDevVOList.forEach(pqDevVO -> {
DevType devType = devTypeService.getById(pqDevVO.getDevType());
if (ObjectUtil.isNotNull(devType)) {
pqDevVO.setDevType(devType.getName());
pqDevVO.setDevVolt(devType.getDevVolt());
pqDevVO.setDevCurr(devType.getDevCurr());
pqDevVO.setDevChns(devType.getDevChns());
}
if (StrUtil.isNotBlank(pqDevVO.getPlanId())) {
AdPlan plan1 = planList.stream().filter(p -> p.getId().equals(pqDevVO.getPlanId())).findFirst().get();
if (ObjectUtil.isNotNull(plan1) && plan.getId().equals(plan1.getFatherPlanId())) {
pqDevVO.setBoundPlanName(plan1.getName());
pqDevVO.setAssign(DataStateEnum.ENABLE.getCode());
} else {
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
}
} else {
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
}
});
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOList, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/listDevByPlanId")
@ApiOperation("根据计划id分页查询被检设备")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<Page<PqDevVO>> listDevByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
String methodDescribe = getMethodDescribe("listDevByPlanId");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
AdPlan plan = adPlanService.getById(param.getPlanIdList().get(0));
if (CommonEnum.FATHER_ID.getValue().equals(plan.getFatherPlanId())) {
List<AdPlan> planList = adPlanService.lambdaQuery().eq(AdPlan::getFatherPlanId, param.getPlanIdList().get(0)).list();
List<String> planIdList = planList.stream().map(AdPlan::getId).collect(Collectors.toList());
param.getPlanIdList().addAll(planIdList);
}
Page<PqDevVO> pqDevVOPage = pqDevService.listPqDevs(param);
List<AdPlan> planList = adPlanService.listByIds(param.getPlanIdList());
for (PqDevVO pqDevVO : pqDevVOPage.getRecords()) {
if (StrUtil.isNotBlank(pqDevVO.getPlanId())) {
AdPlan plan1 = planList.stream().filter(p -> p.getId().equals(pqDevVO.getPlanId())).findFirst().get();
if (ObjectUtil.isNotNull(plan1) && plan.getId().equals(plan1.getFatherPlanId())) {
pqDevVO.setBoundPlanName(plan1.getName());
pqDevVO.setAssign(DataStateEnum.ENABLE.getCode());
} else {
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
}
} else {
pqDevVO.setAssign(DataStateEnum.DELETED.getCode());
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOPage, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@GetMapping("/updateSubPlanName")
@ApiOperation("修改子计划名称")
@ApiImplicitParams({
@ApiImplicitParam(name = "planId", value = "计划id", required = true),
@ApiImplicitParam(name = "name", value = "计划名称", required = true)
})
public HttpResult<Boolean> updateSubPlanName(@RequestParam("planId") String planId, @RequestParam("name") String name) {
String methodDescribe = getMethodDescribe("updateSubPlanName");
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, planId, name);
boolean result = adPlanService.updateSubPlanName(planId, name);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getUnBoundStandardDev")
@ApiOperation("根据父计划ID获取未被子计划绑定的标准设备")
@ApiImplicitParam(name = "fatherPlanId", value = "父计划ID", required = true)
public HttpResult<List<PqStandardDev>> getUnBoundStandardDev(@RequestParam("fatherPlanId") String fatherPlanId) {
String methodDescribe = getMethodDescribe("getUnBoundStandardDev");
LogUtil.njcnDebug(log, "{}父计划ID为{}", methodDescribe, fatherPlanId);
List<PqStandardDev> result = adPlanService.getUnBoundStandardDev(fatherPlanId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getBoundStandardDev")
@ApiOperation("根据计划ID获取已绑定的标准设备")
@ApiImplicitParam(name = "planId", value = "计划ID", required = true)
public HttpResult<List<PqStandardDev>> getBoundStandardDev(@RequestParam("planId") String planId) {
String methodDescribe = getMethodDescribe("getUnBoundStandardDev");
LogUtil.njcnDebug(log, "{}计划ID为{}", methodDescribe, planId);
List<PqStandardDev> result = adPlanService.getBoundStandardDev(planId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateBindStandardDev")
@ApiOperation("子计划绑定/解绑标准设备")
@ApiImplicitParam(name = "param", value = "绑定/解绑参数", required = true)
public HttpResult<Boolean> updateBindStandardDev(@RequestBody @Validated PqDevParam.BindPlanParam param) {
String methodDescribe = getMethodDescribe("updateBindStandardDev");
LogUtil.njcnDebug(log, "{},绑定/解绑参数为:{}", methodDescribe, param);
boolean result = adPlanService.updateBindStandardDev(param.getPlanId(), param.getDevIds());
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateBindDev")
@ApiOperation("子计划绑定/解绑被检设备")
@ApiImplicitParam(name = "param", value = "绑定/解绑参数", required = true)
public HttpResult<Boolean> updateBindDev(@RequestBody @Validated PqDevParam.BindPlanParam param) {
String methodDescribe = getMethodDescribe("updateBindDev");
LogUtil.njcnDebug(log, "{},绑定/解绑参数为:{}", methodDescribe, param);
boolean result = adPlanService.updateBindDev(param);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
}
}
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DELETE)
// @PostMapping("/deleteSubPlan")
// @ApiOperation("删除子计划")
// @ApiImplicitParam(name = "ids", value = "子计划id列表", required = true)
// public HttpResult<Boolean> deleteSubPlan(@RequestBody List<String> ids) {
// String methodDescribe = getMethodDescribe("deleteSubPlan");
// LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids));
// boolean result = adPlanService.deleteAdPlan(ids);
// if (result) {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
// } else {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
// }
// }
@OperateInfo(operateType = OperateType.DOWNLOAD)
@PostMapping("/exportSubPlan")
@ApiOperation("导出子计划")
@ApiImplicitParam(name = "planId", value = "子计划id", required = true)
public void exportSubPlan(@RequestParam("planId") String planId, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("exportSubPlan");
LogUtil.njcnDebug(log, "{}导出ID数据为{}", methodDescribe, planId);
adPlanService.exportSubPlan(planId, response);
}
}

View File

@@ -2,6 +2,10 @@ package com.njcn.gather.plan.mapper;
import com.github.yulichang.base.MPJBaseMapper;
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
@@ -9,5 +13,29 @@ import com.njcn.gather.plan.pojo.po.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

@@ -0,0 +1,24 @@
package com.njcn.gather.plan.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.device.pojo.po.PqStandardDev;
import com.njcn.gather.plan.pojo.po.AdPlanStandardDev;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author caozehui
* @date 2025-07-16
*/
public interface AdPlanStandardDevMapper extends MPJBaseMapper<AdPlanStandardDev> {
/**
* 根据计划id查询标准设备列表
*
* @param planIdList
* @return
*/
List<PqStandardDev> listByPlanId(@Param("planIdList") List<String> planIdList);
}

View File

@@ -3,5 +3,24 @@
<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>

View File

@@ -0,0 +1,17 @@
<?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.plan.mapper.AdPlanStandardDevMapper">
<select id="listByPlanId" resultType="com.njcn.gather.device.pojo.po.PqStandardDev">
select standard_dev.*
from ad_plan_standard_dev plan_std_dev left join pq_standard_dev standard_dev on plan_std_dev.Standard_Dev_Id = standard_dev.Id
<if test="planIdList!= null and planIdList.size() != 0">
where plan_std_dev.Plan_Id in
<foreach collection="planIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>

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