Compare commits

..

16 Commits
master ... dev

  1. 249
      2024新增脚本.sql
  2. 39
      common/pom.xml
  3. 6
      common/src/main/java/com/mh/common/page/MybatisPageHelper.java
  4. 12
      common/src/main/java/com/mh/common/page/PageRequest.java
  5. 25
      common/src/main/java/com/mh/common/utils/FileUtils.java
  6. 17
      common/src/main/java/com/mh/common/utils/StringUtils.java
  7. 26
      pom.xml
  8. 94
      user-service/pom.xml
  9. 8
      user-service/src/main/java/com/mh/user/UserServiceApplication.java
  10. 48
      user-service/src/main/java/com/mh/user/annotation/FieldParam.java
  11. 17
      user-service/src/main/java/com/mh/user/annotation/TranslationDict.java
  12. 136
      user-service/src/main/java/com/mh/user/aspect/DictDataTranslateAsp.java
  13. 4
      user-service/src/main/java/com/mh/user/aspect/SysLogAspect.java
  14. 14
      user-service/src/main/java/com/mh/user/component/ReceiveHandler.java
  15. 62
      user-service/src/main/java/com/mh/user/config/CaffeineCacheConfig.java
  16. 234
      user-service/src/main/java/com/mh/user/config/DruidConfig.java
  17. 344
      user-service/src/main/java/com/mh/user/config/DruidDataSourceProperties.java
  18. 34
      user-service/src/main/java/com/mh/user/config/DruidStatViewServlet.java
  19. 8
      user-service/src/main/java/com/mh/user/config/PrimessionInterceptor.java
  20. 107
      user-service/src/main/java/com/mh/user/config/QuartzConfig.java
  21. 11
      user-service/src/main/java/com/mh/user/config/RabbitmqConfig.java
  22. 12
      user-service/src/main/java/com/mh/user/constants/ChillerParamsEnum.java
  23. 14
      user-service/src/main/java/com/mh/user/constants/Constant.java
  24. 60
      user-service/src/main/java/com/mh/user/constants/ProtocolEnum.java
  25. 60
      user-service/src/main/java/com/mh/user/constants/ProtocolStrategyEnum.java
  26. 2
      user-service/src/main/java/com/mh/user/controller/ChartController.java
  27. 129
      user-service/src/main/java/com/mh/user/controller/ChillersController.java
  28. 58
      user-service/src/main/java/com/mh/user/controller/DataResultController.java
  29. 22
      user-service/src/main/java/com/mh/user/controller/DeviceInfoController.java
  30. 299
      user-service/src/main/java/com/mh/user/controller/DeviceManageController.java
  31. 63
      user-service/src/main/java/com/mh/user/controller/DevicesManageController.java
  32. 60
      user-service/src/main/java/com/mh/user/controller/DevicesParamsController.java
  33. 4
      user-service/src/main/java/com/mh/user/controller/EnergyDataController.java
  34. 61
      user-service/src/main/java/com/mh/user/controller/GatewayManageController.java
  35. 6
      user-service/src/main/java/com/mh/user/controller/MeterInfoController.java
  36. 67
      user-service/src/main/java/com/mh/user/controller/MeterManageController.java
  37. 46
      user-service/src/main/java/com/mh/user/controller/ProjectInfoController.java
  38. 70
      user-service/src/main/java/com/mh/user/controller/ScreenController.java
  39. 4
      user-service/src/main/java/com/mh/user/controller/SerialPortController.java
  40. 6
      user-service/src/main/java/com/mh/user/controller/StrategyInfoController.java
  41. 66
      user-service/src/main/java/com/mh/user/controller/SysDictController.java
  42. 6
      user-service/src/main/java/com/mh/user/controller/SysLoginController.java
  43. 8
      user-service/src/main/java/com/mh/user/controller/SysMenuController.java
  44. 4
      user-service/src/main/java/com/mh/user/controller/SysUserController.java
  45. 11
      user-service/src/main/java/com/mh/user/controller/TestController.java
  46. 64
      user-service/src/main/java/com/mh/user/dto/ScreenRequestParamDTO.java
  47. 154
      user-service/src/main/java/com/mh/user/dynamic/config/DataSourceConfig.java
  48. 56
      user-service/src/main/java/com/mh/user/dynamic/config/MyBatisMapperScannerConfig.java
  49. 142
      user-service/src/main/java/com/mh/user/dynamic/datasource/DataSourceObject.java
  50. 3
      user-service/src/main/java/com/mh/user/entity/BaseEntity.java
  51. 34
      user-service/src/main/java/com/mh/user/entity/BaseResultEntity.java
  52. 23
      user-service/src/main/java/com/mh/user/entity/DataResultChEntity.java
  53. 7
      user-service/src/main/java/com/mh/user/entity/DataResultChillerEntity.java
  54. 32
      user-service/src/main/java/com/mh/user/entity/DataResultClBakEntity.java
  55. 21
      user-service/src/main/java/com/mh/user/entity/DataResultClEntity.java
  56. 22
      user-service/src/main/java/com/mh/user/entity/DataResultEntity.java
  57. 7
      user-service/src/main/java/com/mh/user/entity/DataResultFifteenMiEntity.java
  58. 7
      user-service/src/main/java/com/mh/user/entity/DataResultFiveMiEntity.java
  59. 7
      user-service/src/main/java/com/mh/user/entity/DataResultNowEntity.java
  60. 7
      user-service/src/main/java/com/mh/user/entity/DataResultOneMiEntity.java
  61. 130
      user-service/src/main/java/com/mh/user/entity/DeviceCodeEntity.java
  62. 193
      user-service/src/main/java/com/mh/user/entity/DeviceCodeParamEntity.java
  63. 6
      user-service/src/main/java/com/mh/user/entity/DeviceInfoEntity.java
  64. 15
      user-service/src/main/java/com/mh/user/entity/DeviceInstallEntity.java
  65. 11
      user-service/src/main/java/com/mh/user/entity/DeviceManageEntity.java
  66. 69
      user-service/src/main/java/com/mh/user/entity/DeviceParamsEntity.java
  67. 148
      user-service/src/main/java/com/mh/user/entity/DevicesManageEntity.java
  68. 99
      user-service/src/main/java/com/mh/user/entity/EnergyDataEntity.java
  69. 2
      user-service/src/main/java/com/mh/user/entity/EnergyEntity.java
  70. 2
      user-service/src/main/java/com/mh/user/entity/EnergySumEntity.java
  71. 31
      user-service/src/main/java/com/mh/user/entity/GatewayManageEntity.java
  72. 11
      user-service/src/main/java/com/mh/user/entity/MeterInfoEntity.java
  73. 235
      user-service/src/main/java/com/mh/user/entity/MeterManageEntity.java
  74. 192
      user-service/src/main/java/com/mh/user/entity/ProjectInfoEntity.java
  75. 2
      user-service/src/main/java/com/mh/user/entity/RegisterAddrEntity.java
  76. 71
      user-service/src/main/java/com/mh/user/entity/StrategyInfoEntity.java
  77. 2
      user-service/src/main/java/com/mh/user/entity/chart/ChartEntity.java
  78. 2
      user-service/src/main/java/com/mh/user/entity/chart/Feature.java
  79. 2
      user-service/src/main/java/com/mh/user/entity/chart/Legend.java
  80. 2
      user-service/src/main/java/com/mh/user/entity/chart/Series.java
  81. 2
      user-service/src/main/java/com/mh/user/entity/chart/Title.java
  82. 2
      user-service/src/main/java/com/mh/user/entity/chart/YAxis.java
  83. 49
      user-service/src/main/java/com/mh/user/factory/CJ188Protocol.java
  84. 49
      user-service/src/main/java/com/mh/user/factory/EleProtocol.java
  85. 48
      user-service/src/main/java/com/mh/user/factory/ModbusProtocol.java
  86. 37
      user-service/src/main/java/com/mh/user/factory/Protocol.java
  87. 17
      user-service/src/main/java/com/mh/user/factory/ProtocolFactory.java
  88. 373
      user-service/src/main/java/com/mh/user/job/CollectionLoopRunner.java
  89. 15
      user-service/src/main/java/com/mh/user/job/DealDataJob.java
  90. 39
      user-service/src/main/java/com/mh/user/job/JobChillers.java
  91. 41
      user-service/src/main/java/com/mh/user/job/JobCloud.java
  92. 39
      user-service/src/main/java/com/mh/user/job/JobDDC.java
  93. 45
      user-service/src/main/java/com/mh/user/job/JobFactory.java
  94. 39
      user-service/src/main/java/com/mh/user/job/JobMeter.java
  95. 32
      user-service/src/main/java/com/mh/user/job/JobTest.java
  96. 73
      user-service/src/main/java/com/mh/user/mapper/DataResultChMapper.java
  97. 105
      user-service/src/main/java/com/mh/user/mapper/DataResultChillerMapper.java
  98. 35
      user-service/src/main/java/com/mh/user/mapper/DataResultClBakMapper.java
  99. 42
      user-service/src/main/java/com/mh/user/mapper/DataResultClMapper.java
  100. 36
      user-service/src/main/java/com/mh/user/mapper/DataResultFifteenMiMapper.java
  101. Some files were not shown because too many files have changed in this diff Show More

249
2024新增脚本.sql

@ -0,0 +1,249 @@
-- 2024-07-31 (未执行)
alter table project_info add longitude numeric(10,2) null;
exec sp_addextendedproperty N'MS_Description', N'经度', N'schema', N'dbo', N'table', N'project_info', N'column', N'longitude';
alter table project_info add latitude numeric(10,2) null;
exec sp_addextendedproperty N'MS_Description', N'纬度', N'schema', N'dbo', N'table', N'project_info', N'column', N'latitude';
alter table project_info add create_time datetime null;
exec sp_addextendedproperty N'MS_Description', N'创建时间', N'schema', N'dbo', N'table', N'project_info', N'column', N'create_time';
alter table project_info add pic_content text null;
exec sp_addextendedproperty N'MS_Description', N'图片内容', N'schema', N'dbo', N'table', N'project_info', N'column', N'pic_content';
-- 2024-08-13 创建字典表数据
CREATE TABLE sys_dict (
id bigint NOT NULL,
value nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL,
label nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL,
[type] nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL,
description nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL,
sort decimal(10,0) NOT NULL,
create_by nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL,
create_time datetime2 NULL,
last_update_by nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL,
last_update_time datetime2 NULL,
remarks nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
del_flag tinyint NULL,
status bit null,
parent_id bigint null
CONSTRAINT PK__sys_dict__3213E83F527BBC48 PRIMARY KEY (id)
);
-- Extended properties
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字典表', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'value';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标签名', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'label';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类型', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'type';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'描述', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'description';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序(升序)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'sort';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'create_by';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'create_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新人', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'last_update_by';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'last_update_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注信息', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'remarks';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否删除 -1:已删除 0:正常', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'del_flag';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态(0正常 1停用)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'status';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'父id:0最高级', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'parent_id';
-- 2024-08-22
-- 资产设备管理
create table devices_manage
(
id bigint identity primary key not null, -- id
device_name nvarchar(100) null, -- 设备名称
device_brand nvarchar(100) null, -- 设备品牌
em_brand nvarchar(100) null, -- 机电品牌
rated_input_power numeric(24, 2) null, -- 额定输入功率
rated_refrigeration_capacity numeric(24, 2) null, -- 额定制冷量
rated_cop numeric(24, 2) null, -- 额定COP
rated_flow numeric(24, 2) null, -- 额定流量
production_time datetime null, -- 生产日期
create_time datetime null, -- 创建时间
update_time datetime null, -- 更新时间
create_by nvarchar(50) null, -- 创建人
is_frequency bit null, -- 是否变频
device_type bigint null, -- 设备类型id(字典配置)
system_id bigint null, -- 项目类型id
project_id bigint null, -- 项目类型id
remark nvarchar(255) null, -- 系统id
grade int null -- 保留
)
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'资产设备管理', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备名称', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_name';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备品牌', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_brand';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'机电品牌', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'em_brand';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定输入功率', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_input_power';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定制冷量', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_refrigeration_capacity';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定COP', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_cop';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定流量', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_flow';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产日期', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'production_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'create_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'update_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'create_by';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否变频', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'is_frequency';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备类型id(字典配置)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_type';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目类型id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'system_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'project_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'remark';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据标识', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'grade';
-- 仪表管理
create table meter_manage (
id bigint identity primary key not null, -- 编号
mt_type bigint null, -- 仪表类型(从字典值获取)
mt_name nvarchar(100) null, -- 仪表名称
other_name nvarchar(100) null, -- 仪表别名
mt_brand nvarchar(100) null, -- 仪表品牌
mt_num nvarchar(20) null, -- 仪表表面号
mt_code nvarchar(20) null, -- 仪表采集码
register_addr nvarchar(20), -- 寄存器地址
func_code nvarchar(20) null, -- 功能码
identify_code nvarchar(20) null, -- 仪表识别码
mt_caliber_pulse nvarchar(20) null, -- 仪表口径或者脉冲常数
mt_range numeric(24,3) null, -- 仪表范围
mt_ratio int null, -- 仪表倍率
mt_init_value numeric(24,3) null, -- 初始值
digits int null, -- 小数位数
data_type int null, -- 数据类型16位、32位、64位
cur_value numeric(24,3) null, -- 当前值
cur_time datetime null, -- 当前值时间
mt_is_sum bit null, -- 是否总表
create_time datetime null, -- 创建时间
update_time datetime null, -- 更新时间
unit nvarchar(20) null, -- 单位
sort bigint null, -- 排序
data_com nvarchar(100) null, -- 通信端口
device_id bigint null, -- 对应device_manage的id
gateway_id bigint null, -- 对应网关管理表gateway_manage的id
param_id bigint null, -- 对应参数id
protocol_type bigint null, -- 协议类型(字典表)
communication_type int NULL, -- 通讯方式(字典表)
remark nvarchar(255) null, -- 备注
system_id bigint null, -- 系统类型id
project_id bigint null, -- 项目类型id
grade int null -- 保留
)
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表管理', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表类型(从字典值获取)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_type_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表名称', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_name';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表别名', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'other_name';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表品牌', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_brand';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表表面号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_num';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表采集码', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_code';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'寄存器地址', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'register_addr';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'功能码', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'func_code';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表识别码', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'identify_code';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表口径或者脉冲常数', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_caliber_pulse';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表范围', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_range';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表倍率', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_ratio';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'初始值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_init_value';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'小数位数', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'digits';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据类型16位、32位、64位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'data_type';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'cur_value';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前值时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'cur_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否总表', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'mt_is_sum';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'create_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'update_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'unit';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'sort';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应device_manage的id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应网关管理表gateway_manage的id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'gateway_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应参数id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'param_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'协议类型(字典表)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'protocol_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通讯方式', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'communication_type';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'remark';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目类型ID', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'project_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统类型ID', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'system_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'保留', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'grade';
-- 网关管理表
CREATE TABLE gateway_manage (
id bigint identity(1,1) NOT NULL,
gw_name varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
gw_ip varchar(20) COLLATE Chinese_PRC_CI_AS NULL,
gw_addr varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
port int NULL,
collection_loop int NULL,
create_time datetime NULL,
update_time datetime NULL,
connect_time datetime NULL,
internet_card varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
operator_type int NULL,
remark varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
communication_type int NULL,
grade int NULL,
system_id bigint null, -- 系统类型id
project_id bigint null, -- 项目类型id
CONSTRAINT pk_gateway_manage PRIMARY KEY (id)
);
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关管理', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关名称', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'gw_name';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关IP地址', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'gw_ip';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关对应的编号地址', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'gw_addr';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关端口', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'port';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集周期', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'collection_loop';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'create_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'update_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'连接时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'connect_time';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'卡号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'internet_card';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运营商类型 0:中国移动 1:中国联通 2:中国电信', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'operator_type';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'remark';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通信类型(字典表)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'communication_type_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'预留字段', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'grade';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统类型id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'system_id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目类型id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'project_id';
-- 设备采集参数表
create table device_params(
id bigint primary key identity(1,1) not null, -- 编号
mt_type int not null, -- 仪表类型(从字典表中拿)
baud_rate int not null, -- 波特率
data_bit int not null, -- 数据位
stop_bit int not null, -- 停止位
parity nvarchar(10) not null, -- 校验位
remark varchar(100) null -- 备注
)
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备采集参数表', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'id';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表类型(从字典中获取)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'mt_type';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'波特率', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'baud_rate';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'data_bit';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'停止位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'stop_bit';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'校验位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'parity';
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'remark';
-- 2024-08-22
-- 2028-09-02
ALTER TABLE devices_manage ADD factory_barcode varchar(100) NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'出厂条码', 'schema', N'dbo', 'table', N'devices_manage', 'column', N'factory_barcode';
ALTER TABLE devices_manage ADD imu_code varchar(100) NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'IMU编码', 'schema', N'dbo', 'table', N'devices_manage', 'column', N'imu_code';
ALTER TABLE meter_manage ADD register_size int DEFAULT 1 NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'寄存器大小', 'schema', N'dbo', 'table', N'meter_manage', 'column', N'register_size';
ALTER TABLE meter_manage ADD is_use bit DEFAULT 1 NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'当前采集点位是否启用', 'schema', N'dbo', 'table', N'meter_manage', 'column', N'is_use';
-- 2024-09-23 冗余设备管理采集参数表数据
ALTER TABLE mh_jnd.dbo.device_code_param ADD mm_id bigint NULL;
EXEC mh_jnd.sys.sp_addextendedproperty 'MS_Description', N'采集设备参数表ID值', 'schema', N'dbo', 'table', N'device_code_param', 'column', N'mm_id';
ALTER TABLE mh_jnd.dbo.device_code_param ADD data_type int NULL;
EXEC mh_jnd.sys.sp_addextendedproperty 'MS_Description', N'数据类型', 'schema', N'dbo', 'table', N'device_code_param', 'column', N'data_type';
ALTER TABLE mh_jnd.dbo.device_code_param ADD protocol_type int NULL;
EXEC mh_jnd.sys.sp_addextendedproperty 'MS_Description', N'协议类型(数据字典表)', 'schema', N'dbo', 'table', N'device_code_param', 'column', N'protocol_type';
-- 2024-09-24 data_result表添加字段
ALTER TABLE data_result ADD register_addr varchar(50) NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'寄存器地址', 'schema', N'dbo', 'table', N'data_result', 'column', N'register_addr';
ALTER TABLE data_result ADD register_name varchar(50) NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'寄存器名称', 'schema', N'dbo', 'table', N'data_result', 'column', N'register_name';

39
common/pom.xml

@ -23,17 +23,48 @@
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.31</version>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.51</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
<version>2.1.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.pagehelper</groupId>-->
<!-- <artifactId>pagehelper</artifactId>-->
<!-- <version>6.1.0</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>com.github.jsqlparser</groupId>-->
<!-- <artifactId>jsqlparser</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.github.pagehelper</groupId>-->
<!-- <artifactId>sqlparser4.5</artifactId>-->
<!-- <version>6.1.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.github.pagehelper</groupId>-->
<!-- <artifactId>sqlparser-timeout</artifactId>-->
<!-- <version>6.1.0</version>-->
<!-- </dependency>-->
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>

6
common/src/main/java/com/mh/common/page/MybatisPageHelper.java

@ -39,7 +39,9 @@ public class MybatisPageHelper {
// 设置分页参数
int pageNum = pageRequest.getPageNum();
int pageSize = pageRequest.getPageSize();
PageHelper.startPage(pageNum, pageSize);
if (pageNum != 0) {
PageHelper.startPage(pageNum, pageSize);
}
// 利用反射调用查询方法
Object result = ReflectionUtils.invoke(mapper, queryMethodName, args);
return getPageResult(pageRequest, new PageInfo((List) result));
@ -50,7 +52,7 @@ public class MybatisPageHelper {
* @param pageRequest
* @return
*/
private static PageResult getPageResult(PageRequest pageRequest, PageInfo<?> pageInfo) {
public static PageResult getPageResult(PageRequest pageRequest, PageInfo<?> pageInfo) {
PageResult pageResult = new PageResult();
pageResult.setPageNum(pageInfo.getPageNum());
pageResult.setPageSize(pageInfo.getPageSize());

12
common/src/main/java/com/mh/common/page/PageRequest.java

@ -20,7 +20,7 @@ public class PageRequest {
/**
* 每页数量
*/
private Map<String, ColumnFilter> columnFilters = new HashMap<String, ColumnFilter>();
private Map<String, ColumnFilter> columnFilter = new HashMap<String, ColumnFilter>();
public int getPageNum() {
return pageNum;
@ -34,13 +34,13 @@ public class PageRequest {
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Map<String, ColumnFilter> getColumnFilters() {
return columnFilters;
public Map<String, ColumnFilter> getColumnFilter() {
return columnFilter;
}
public void setColumnFilters(Map<String, ColumnFilter> columnFilters) {
this.columnFilters = columnFilters;
public void setColumnFilter(Map<String, ColumnFilter> columnFilters) {
this.columnFilter = columnFilters;
}
public ColumnFilter getColumnFilter(String name) {
return columnFilters.get(name);
return columnFilter.get(name);
}
}

25
common/src/main/java/com/mh/common/utils/FileUtils.java

@ -1,11 +1,10 @@
package com.mh.common.utils;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.*;
/**
* 文件相关操作
@ -39,4 +38,20 @@ public class FileUtils {
e.printStackTrace();
}
}
public static String convertFileToBase64(MultipartFile file) {
byte[] data = null;
// 读取文件字节数组
try {
InputStream in = file.getInputStream();
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
// 对字节数组进行编码,得到base64编码字符串
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
}
}

17
common/src/main/java/com/mh/common/utils/StringUtils.java

@ -1,5 +1,8 @@
package com.mh.common.utils;
import com.mh.common.page.ColumnFilter;
import com.mh.common.page.PageRequest;
/**
* 字符串工具类
* @author Louis
@ -16,4 +19,18 @@ public class StringUtils {
return value == null || "".equals(value) || "null".equals(value) || "undefined".equals(value);
}
/**
* 获取过滤字段的值
* @param filterName
* @return
*/
public static String getColumnFilterValue(PageRequest pageRequest, String filterName) {
String value = null;
ColumnFilter columnFilter = pageRequest.getColumnFilter(filterName);
if(columnFilter != null) {
value = columnFilter.getValue();
}
return value;
}
}

26
pom.xml

@ -34,16 +34,16 @@
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
@ -59,6 +59,12 @@
<artifactId>purejavacomm</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.15.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>

94
user-service/pom.xml

@ -23,33 +23,40 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>import</scope>
<!-- 当时本地启动需要注释掉-->
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-config</artifactId>-->
<!-- <version>2.2.2.RELEASE</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.8.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.41</version>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.51</version>
</dependency>
<!-- <dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-config-client</artifactId>-->
<!-- </dependency>-->
@ -74,32 +81,44 @@
</exclusions>
</dependency>
<!-- mybatis配置-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.mybatis.spring.boot</groupId>-->
<!-- <artifactId>mybatis-spring-boot-starter</artifactId>-->
<!-- <version>3.0.2</version>-->
<!-- </dependency>-->
<!-- mysql数据库链接-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- </dependency>-->
<!-- druid配置-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.18</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>druid-spring-boot-starter</artifactId>-->
<!-- <version>1.1.18</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-core</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<!-- 引入log4j依赖 -->
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
@ -141,21 +160,16 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>3.3.9</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>tk.mybatis</groupId>-->
<!-- <artifactId>mapper</artifactId>-->
<!-- <version>3.3.9</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>

8
user-service/src/main/java/com/mh/user/UserServiceApplication.java

@ -1,6 +1,7 @@
package com.mh.user;
import org.apache.log4j.Logger;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@ -8,13 +9,12 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.scheduling.annotation.EnableScheduling;
import javax.annotation.PreDestroy;
@Slf4j
@SpringBootApplication(scanBasePackages = "com.mh.user")
@EnableScheduling
@MapperScan("com.mh.user.mapper")
public class UserServiceApplication extends SpringBootServletInitializer {
private static final Logger log = Logger.getLogger(UserServiceApplication.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(UserServiceApplication.class);

48
user-service/src/main/java/com/mh/user/annotation/FieldParam.java

@ -0,0 +1,48 @@
package com.mh.user.annotation;
import java.lang.annotation.*;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 数据字典注解
* @date 2024-11-08 11:40:46
*/
@Target(ElementType.FIELD)
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FieldParam {
/**
* 字典值
* @return
*/
String value() default "";
/**
* 字典类型
* @return
*/
String type() default "";
/**
* 字典标签
* @return
*/
String label() default "";
/**
* 要翻译的字段目标字段翻译的字段+Str
* @return
*/
String targetField() default "";
/**
* 要翻译的字段值类型
* @return
*/
Class targetFieldValueClazz() default String.class;
}

17
user-service/src/main/java/com/mh/user/annotation/TranslationDict.java

@ -0,0 +1,17 @@
package com.mh.user.annotation;
import java.lang.annotation.*;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 需要翻译的字典值
* @date 2024-11-08 14:29:39
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface TranslationDict {
FieldParam[] value();
}

136
user-service/src/main/java/com/mh/user/aspect/DictDataTranslateAsp.java

@ -0,0 +1,136 @@
package com.mh.user.aspect;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.mh.user.annotation.FieldParam;
import com.mh.user.annotation.TranslationDict;
import com.mh.user.model.SysDict;
import com.mh.user.service.SysDictService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 数据字典转换
* @date 2024-11-08 14:08:20
*/
@Aspect
@Component
@Slf4j
public class DictDataTranslateAsp {
@Autowired
private SysDictService sysDictService;
@Around("@annotation(com.mh.user.annotation.TranslationDict)")
public Object aroundMethodTranslate(ProceedingJoinPoint joinPoint) throws Throwable {
// 接收到请求时间
Long startTime = System.currentTimeMillis();
// 注意,如果调用joinPoint.proceed()方法,则修改的参数值不会生效,必须调用joinPoint.proceed(args)
Object result = joinPoint.proceed();
// 获取返回值类型
Class<?> returnType = ((MethodSignature) joinPoint.getSignature()).getReturnType();
// 取出要翻译的字典值
String returnJsonResult = JSONObject.toJSONString(result);
// 开始解析
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
// 获取注解上参数
TranslationDict annotation = method.getAnnotation(TranslationDict.class);
FieldParam[] fieldParams = annotation.value();
// 遍历
for (FieldParam fieldParam : fieldParams) {
log.info("字典类型:{},取值字段:{}", fieldParam.type(), fieldParam.targetField());
Pattern dictPattern = getPattern(fieldParam);
Matcher matcher = dictPattern.matcher(returnJsonResult);
StringBuffer sb = new StringBuffer();
// 转义字段
this.translateDict(fieldParam, dictPattern, matcher, sb);
matcher.appendTail(sb);
returnJsonResult = sb.toString();
}
result = JSONObject.parseObject(returnJsonResult, returnType);
// 如果这里不返回result,则目标对象实际返回值会被置为null
// 处理完成时间
Long endTime = System.currentTimeMillis();
log.info("数据字典转换耗时:{}ms", endTime - startTime);
return result;
}
/**
* 字典值转义为中文
*
* @param fieldParam
* @param fieldPattern
* @param fieldMatcher
* @param sb
*/
private void translateDict(FieldParam fieldParam, Pattern fieldPattern, Matcher fieldMatcher, StringBuffer sb) {
//从缓存中一次性取值
List<SysDict> dictNames = sysDictService.findByType(fieldParam.type());
while (fieldMatcher.find()) {
//取出要翻译字段对应的值
Matcher dictValueMatcher = fieldPattern.matcher(fieldMatcher.group());
dictValueMatcher.find();
String group = dictValueMatcher.group();
//""sex":1", ""sex":"1"",""sex":null"
//属性无值
if (group.split(":").length <= 1) continue;
String dictName = "";
//获取字典值
String dictValue = group.split(":")[1].replace("\"", "");
//属性值非为空 为空赋值空串
if (StringUtils.isNotBlank(dictValue) && !dictValue.equalsIgnoreCase("null")) {
//多值
if (dictValue.split(",").length > 1) {
for (String s : dictValue.split(",")) {
//fieldParam.dictType() + "_" + s 根据自己字典表设置的规则去查询
String type = s;
Optional<SysDict> first = dictNames.stream().filter(d -> d.getValue().equals(type)).findFirst();
if (!first.isPresent()) continue;
dictName += first.get().getLabel() + "/";
}
} else {
String type = dictValue;
Optional<SysDict> first = dictNames.stream().filter(d -> d.getValue().equals(type)).findFirst();
if (!first.isPresent()) continue;
dictName = first.get().getLabel();
}
}
String s = "\"" + fieldParam.targetField() + "Str" + "\":\"" + dictName + "\"," + fieldMatcher.group();
log.info("拼接后字符串:{}", s);
fieldMatcher.appendReplacement(sb, s);
}
}
private Pattern getPattern(FieldParam fieldParam) {
Pattern fieldPattern;//属性整型 字符型
if (fieldParam.targetFieldValueClazz().equals(Integer.class)) {
fieldPattern = Pattern.compile("\"" + fieldParam.targetField() + "\":(\\d+)?");
} else {
fieldPattern = Pattern.compile("\"" + fieldParam.targetField() + "\":\"([0-9a-zA-Z_,]+)?\"");
}
return fieldPattern;
}
}

4
user-service/src/main/java/com/mh/user/aspect/SysLogAspect.java

@ -2,6 +2,7 @@ package com.mh.user.aspect;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson2.JSONObject;
import com.mh.user.annotation.SysLogger;
import com.mh.user.model.SysLog;
import com.mh.user.service.SysLogService;
@ -17,10 +18,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;

14
user-service/src/main/java/com/mh/user/component/ReceiveHandler.java

@ -1,20 +1,12 @@
package com.mh.user.component;
import com.alibaba.druid.sql.visitor.functions.Isnull;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.mh.user.config.RabbitmqConfig;
import com.mh.user.model.QueueParam;
import com.mh.user.utils.AnalysisReceiveOrder485;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.impl.AMQImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.Logger;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
@ -23,10 +15,10 @@ import java.io.IOException;
/**
* 队列消费接收消息
*/
@Slf4j
@Component
public class ReceiveHandler {
private static final Logger log = Logger.getLogger(ReceiveHandler.class);
//监听队列
// @RabbitListener(bindings = @QueueBinding(
// value = @Queue(value = "queue_zjjd", durable = "true"),
@ -48,7 +40,7 @@ public class ReceiveHandler {
queueParam.setRecData(JSONObj.getString("recData"));
queueParam.setDeviceType(JSONObj.getString("deviceType"));
queueParam.setRegisterAddr(JSONObj.getString("registerAddr"));
queueParam.setProjectID(JSONObj.getString("projectID"));
queueParam.setProjectId(JSONObj.getString("projectId"));
queueParam.setCopyTime(JSONObj.getString("copyTime"));
String deviceType=JSONObj.getString("deviceType");
show=deviceType+",数据:"+JSONObj.getString("recData");

62
user-service/src/main/java/com/mh/user/config/CaffeineCacheConfig.java

@ -0,0 +1,62 @@
package com.mh.user.config;
import com.github.benmanes.caffeine.cache.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
/**
* @author LJF
* @title
* @description 使用caffeine缓存技术
* @updateTime 2020-12-15
* @throws
*/
@Slf4j
@Configuration
public class CaffeineCacheConfig {
// 软引用: 如果一个对象只具有软引用,则内存空间足够,垃圾回收器就不会回收它;如果内存空间不足了,就会回收这些对象的内存。
// 弱引用: 弱引用的对象拥有更短暂的生命周期。在垃圾回收器线程扫描它所管辖的内存区域的过程中,一旦发现了只具有弱引用的对象,
// 不管当前内存空间足够与否,都会回收它的内存
@Bean(name = "caffeineCache")
public Cache<String, Object> caffeineCache() {
return Caffeine.newBuilder()
// 软引用
.softValues()
// 弱引用
// .weakValues()
// 设置最后一次写入或访问后经过固定时间过期
.expireAfterWrite(8*60*60, TimeUnit.SECONDS)
// 初始的缓存空间大小
.initialCapacity(100)
// 缓存的最大条数
.maximumSize(1000)
.build();
}
//定义缓存,可直接使用
@Bean
public LoadingCache expiryCache(){
LoadingCache<String, Object> loadingCache = Caffeine.newBuilder()
.initialCapacity(100)
.maximumSize(1000)
//缓存写入/删除监控
.writer(new CacheWriter<Object, Object>() {
@Override
public void write(Object key, Object value) { //此方法是同步阻塞的
log.info("--缓存写入--:key={}, value={}", key, value);
}
@Override
public void delete(Object key, Object value, RemovalCause cause) {
log.info("--缓存删除--:key={}", key); }
})
.expireAfterAccess(6, TimeUnit.HOURS) //过期时间
.build((String key)->"刷新的数据"); //cacheload实现类,刷新时候调用
// loadingCache.put("name","侯征");
return loadingCache;
}
}

234
user-service/src/main/java/com/mh/user/config/DruidConfig.java

@ -1,117 +1,117 @@
package com.mh.user.config;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.Filter;
import javax.servlet.Servlet;
import javax.sql.DataSource;
import com.alibaba.druid.wall.WallConfig;
import com.alibaba.druid.wall.WallFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
/**
* @author ljf
* @title
* @description
* @updateTime 2020-03-13
* @throws
*/
@Configuration
@EnableConfigurationProperties({DruidDataSourceProperties.class})
public class DruidConfig {
@Autowired
private DruidDataSourceProperties properties;
@Bean
@ConditionalOnMissingBean
public DataSource druidDataSource() {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(properties.getDriverClassName());
druidDataSource.setUrl(properties.getUrl());
druidDataSource.setUsername(properties.getUsername());
druidDataSource.setPassword(properties.getPassword());
druidDataSource.setInitialSize(properties.getInitialSize());
druidDataSource.setMinIdle(properties.getMinIdle());
druidDataSource.setMaxActive(properties.getMaxActive());
druidDataSource.setMaxWait(properties.getMaxWait());
druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
druidDataSource.setValidationQuery(properties.getValidationQuery());
druidDataSource.setTestWhileIdle(properties.isTestWhileIdle());
druidDataSource.setTestOnBorrow(properties.isTestOnBorrow());
druidDataSource.setTestOnReturn(properties.isTestOnReturn());
druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize());
List list=new ArrayList<>();
WallFilter wallFilter=new WallFilter();
WallConfig config = new WallConfig();
//允许一次执行多条语句
config.setMultiStatementAllow(true);
//允许非基本语句的其他语句
//config.setNoneBaseStatementAllow(true);
wallFilter.setConfig(config);
list.add(wallFilter);
druidDataSource.setProxyFilters(list);
try {
druidDataSource.setFilters(properties.getFilters());
druidDataSource.init();
} catch (SQLException e) {
e.printStackTrace();
}
return druidDataSource;
}
/**
* 注册Servlet信息 配置监控视图
*
* @return
*/
@Bean
@ConditionalOnMissingBean
public ServletRegistrationBean<Servlet> druidServlet() {
ServletRegistrationBean<Servlet> servletRegistrationBean = new ServletRegistrationBean<Servlet>(new StatViewServlet(), "/druid/*");
//白名单:
// servletRegistrationBean.addInitParameter("allow","127.0.0.1,139.196.87.48");
//IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
servletRegistrationBean.addInitParameter("deny","192.168.1.222");
//登录查看信息的账号密码, 用于登录Druid监控后台
servletRegistrationBean.addInitParameter("loginUsername", "admin");
servletRegistrationBean.addInitParameter("loginPassword", "admin");
//是否能够重置数据.
servletRegistrationBean.addInitParameter("resetEnable", "true");
return servletRegistrationBean;
}
/**
* 注册Filter信息, 监控拦截器
*
* @return
*/
@Bean
@ConditionalOnMissingBean
public FilterRegistrationBean<Filter> filterRegistrationBean() {
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<Filter>();
filterRegistrationBean.setFilter(new WebStatFilter());
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
return filterRegistrationBean;
}
}
//package com.mh.user.config;
//
//import java.sql.SQLException;
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.servlet.Filter;
//import javax.servlet.Servlet;
//import javax.sql.DataSource;
//
//import com.alibaba.druid.wall.WallConfig;
//import com.alibaba.druid.wall.WallFilter;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.boot.web.servlet.FilterRegistrationBean;
//import org.springframework.boot.web.servlet.ServletRegistrationBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.alibaba.druid.support.http.StatViewServlet;
//import com.alibaba.druid.support.http.WebStatFilter;
//
///**
// * @author ljf
// * @title :
// * @description :
// * @updateTime 2020-03-13
// * @throws :
// */
//@Configuration
//@EnableConfigurationProperties({DruidDataSourceProperties.class})
//public class DruidConfig {
// @Autowired
// private DruidDataSourceProperties properties;
//
// @Bean
// @ConditionalOnMissingBean
// public DataSource druidDataSource() {
// DruidDataSource druidDataSource = new DruidDataSource();
// druidDataSource.setDriverClassName(properties.getDriverClassName());
// druidDataSource.setUrl(properties.getUrl());
// druidDataSource.setUsername(properties.getUsername());
// druidDataSource.setPassword(properties.getPassword());
// druidDataSource.setInitialSize(properties.getInitialSize());
// druidDataSource.setMinIdle(properties.getMinIdle());
// druidDataSource.setMaxActive(properties.getMaxActive());
// druidDataSource.setMaxWait(properties.getMaxWait());
// druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
// druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
// druidDataSource.setValidationQuery(properties.getValidationQuery());
// druidDataSource.setTestWhileIdle(properties.isTestWhileIdle());
// druidDataSource.setTestOnBorrow(properties.isTestOnBorrow());
// druidDataSource.setTestOnReturn(properties.isTestOnReturn());
// druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
// druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize());
//
// List list=new ArrayList<>();
// WallFilter wallFilter=new WallFilter();
// WallConfig config = new WallConfig();
// //允许一次执行多条语句
// config.setMultiStatementAllow(true);
// //允许非基本语句的其他语句
// //config.setNoneBaseStatementAllow(true);
// wallFilter.setConfig(config);
// list.add(wallFilter);
// druidDataSource.setProxyFilters(list);
//
// try {
// druidDataSource.setFilters(properties.getFilters());
// druidDataSource.init();
// } catch (SQLException e) {
// e.printStackTrace();
// }
//
// return druidDataSource;
// }
//
// /**
// * 注册Servlet信息, 配置监控视图
// *
// * @return
// */
// @Bean
// @ConditionalOnMissingBean
// public ServletRegistrationBean<Servlet> druidServlet() {
// ServletRegistrationBean<Servlet> servletRegistrationBean = new ServletRegistrationBean<Servlet>(new StatViewServlet(), "/druid/*");
//
// //白名单:
//// servletRegistrationBean.addInitParameter("allow","127.0.0.1,139.196.87.48");
// //IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
// servletRegistrationBean.addInitParameter("deny","192.168.1.222");
// //登录查看信息的账号密码, 用于登录Druid监控后台
// servletRegistrationBean.addInitParameter("loginUsername", "admin");
// servletRegistrationBean.addInitParameter("loginPassword", "admin");
// //是否能够重置数据.
// servletRegistrationBean.addInitParameter("resetEnable", "true");
// return servletRegistrationBean;
//
// }
//
// /**
// * 注册Filter信息, 监控拦截器
// *
// * @return
// */
// @Bean
// @ConditionalOnMissingBean
// public FilterRegistrationBean<Filter> filterRegistrationBean() {
// FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<Filter>();
// filterRegistrationBean.setFilter(new WebStatFilter());
// filterRegistrationBean.addUrlPatterns("/*");
// filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
// return filterRegistrationBean;
// }
//}

344
user-service/src/main/java/com/mh/user/config/DruidDataSourceProperties.java

@ -1,172 +1,172 @@
package com.mh.user.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author ljf
* @title
* @description
* @updateTime 2020-03-13
* @throws
*/
@ConfigurationProperties(prefix = "spring.datasource.druid")
public class DruidDataSourceProperties {
// jdbc
private String driverClassName;
private String url;
private String username;
private String password;
// jdbc connection pool
private int initialSize;
private int minIdle;
private int maxActive = 100;
private long maxWait;
private long timeBetweenEvictionRunsMillis;
private long minEvictableIdleTimeMillis;
private String validationQuery;
private boolean testWhileIdle;
private boolean testOnBorrow;
private boolean testOnReturn;
private boolean poolPreparedStatements;
private int maxPoolPreparedStatementPerConnectionSize;
// filter
private String filters;
public int getInitialSize() {
return initialSize;
}
public void setInitialSize(int initialSize) {
this.initialSize = initialSize;
}
public int getMinIdle() {
return minIdle;
}
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
public int getMaxActive() {
return maxActive;
}
public void setMaxActive(int maxActive) {
this.maxActive = maxActive;
}
public long getMaxWait() {
return maxWait;
}
public void setMaxWait(long maxWait) {
this.maxWait = maxWait;
}
public long getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
}
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}
public long getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
}
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
public String getValidationQuery() {
return validationQuery;
}
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
}
public boolean isTestWhileIdle() {
return testWhileIdle;
}
public void setTestWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
}
public boolean isTestOnBorrow() {
return testOnBorrow;
}
public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
}
public boolean isTestOnReturn() {
return testOnReturn;
}
public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn;
}
public boolean isPoolPreparedStatements() {
return poolPreparedStatements;
}
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
this.poolPreparedStatements = poolPreparedStatements;
}
public int getMaxPoolPreparedStatementPerConnectionSize() {
return maxPoolPreparedStatementPerConnectionSize;
}
public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
}
public String getFilters() {
return filters;
}
public void setFilters(String filters) {
this.filters = filters;
}
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
//package com.mh.user.config;
//
//import org.springframework.boot.context.properties.ConfigurationProperties;
//
///**
// * @author ljf
// * @title :
// * @description :
// * @updateTime 2020-03-13
// * @throws :
// */
//@ConfigurationProperties(prefix = "spring.datasource.druid")
//public class DruidDataSourceProperties {
//
// // jdbc
// private String driverClassName;
// private String url;
// private String username;
// private String password;
// // jdbc connection pool
// private int initialSize;
// private int minIdle;
// private int maxActive = 100;
// private long maxWait;
// private long timeBetweenEvictionRunsMillis;
// private long minEvictableIdleTimeMillis;
// private String validationQuery;
// private boolean testWhileIdle;
// private boolean testOnBorrow;
// private boolean testOnReturn;
// private boolean poolPreparedStatements;
// private int maxPoolPreparedStatementPerConnectionSize;
// // filter
// private String filters;
//
// public int getInitialSize() {
// return initialSize;
// }
//
// public void setInitialSize(int initialSize) {
// this.initialSize = initialSize;
// }
//
// public int getMinIdle() {
// return minIdle;
// }
//
// public void setMinIdle(int minIdle) {
// this.minIdle = minIdle;
// }
//
// public int getMaxActive() {
// return maxActive;
// }
//
// public void setMaxActive(int maxActive) {
// this.maxActive = maxActive;
// }
//
// public long getMaxWait() {
// return maxWait;
// }
//
// public void setMaxWait(long maxWait) {
// this.maxWait = maxWait;
// }
//
// public long getTimeBetweenEvictionRunsMillis() {
// return timeBetweenEvictionRunsMillis;
// }
//
// public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
// this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
// }
//
// public long getMinEvictableIdleTimeMillis() {
// return minEvictableIdleTimeMillis;
// }
//
// public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
// this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
// }
//
// public String getValidationQuery() {
// return validationQuery;
// }
//
// public void setValidationQuery(String validationQuery) {
// this.validationQuery = validationQuery;
// }
//
// public boolean isTestWhileIdle() {
// return testWhileIdle;
// }
//
// public void setTestWhileIdle(boolean testWhileIdle) {
// this.testWhileIdle = testWhileIdle;
// }
//
// public boolean isTestOnBorrow() {
// return testOnBorrow;
// }
//
// public void setTestOnBorrow(boolean testOnBorrow) {
// this.testOnBorrow = testOnBorrow;
// }
//
// public boolean isTestOnReturn() {
// return testOnReturn;
// }
//
// public void setTestOnReturn(boolean testOnReturn) {
// this.testOnReturn = testOnReturn;
// }
//
// public boolean isPoolPreparedStatements() {
// return poolPreparedStatements;
// }
//
// public void setPoolPreparedStatements(boolean poolPreparedStatements) {
// this.poolPreparedStatements = poolPreparedStatements;
// }
//
// public int getMaxPoolPreparedStatementPerConnectionSize() {
// return maxPoolPreparedStatementPerConnectionSize;
// }
//
// public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
// this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
// }
//
// public String getFilters() {
// return filters;
// }
//
// public void setFilters(String filters) {
// this.filters = filters;
// }
//
// public String getDriverClassName() {
// return driverClassName;
// }
//
// public void setDriverClassName(String driverClassName) {
// this.driverClassName = driverClassName;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
//}

34
user-service/src/main/java/com/mh/user/config/DruidStatViewServlet.java

@ -1,17 +1,17 @@
package com.mh.user.config;
import com.alibaba.druid.support.http.StatViewServlet;
/**
* druid监控视图配置
*/
//@WebServlet(urlPatterns = "/druid/*", initParams={
// @WebInitParam(name="allow",value="192.168.6.195"), // IP白名单 (没有配置或者为空,则允许所有访问)
// @WebInitParam(name="deny",value="192.168.6.73"), // IP黑名单 (存在共同时,deny优先于allow)
// @WebInitParam(name="loginUsername",value="admin"), // 用户名
// @WebInitParam(name="loginPassword",value="admin"), // 密码
// @WebInitParam(name="resetEnable",value="true") // 禁用HTML页面上的“Reset All”功能
//})
public class DruidStatViewServlet extends StatViewServlet {
private static final long serialVersionUID = 7359758657306626394L;
}
//package com.mh.user.config;
//
//import com.alibaba.druid.support.http.StatViewServlet;
//
///**
// * druid监控视图配置
// */
////@WebServlet(urlPatterns = "/druid/*", initParams={
//// @WebInitParam(name="allow",value="192.168.6.195"), // IP白名单 (没有配置或者为空,则允许所有访问)
//// @WebInitParam(name="deny",value="192.168.6.73"), // IP黑名单 (存在共同时,deny优先于allow)
//// @WebInitParam(name="loginUsername",value="admin"), // 用户名
//// @WebInitParam(name="loginPassword",value="admin"), // 密码
//// @WebInitParam(name="resetEnable",value="true") // 禁用HTML页面上的“Reset All”功能
////})
//public class DruidStatViewServlet extends StatViewServlet {
// private static final long serialVersionUID = 7359758657306626394L;
//}

8
user-service/src/main/java/com/mh/user/config/PrimessionInterceptor.java

@ -1,13 +1,9 @@
package com.mh.user.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mh.user.dynamic.datasource.DataSourceContextHolder;
import com.mh.user.dynamic.datasource.DataSourceObject;
import com.mh.user.entity.DBEntity;
import com.mh.user.service.SysUserService;
import com.mh.user.utils.JwtTokenUtils;
import com.mh.user.utils.AESUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

107
user-service/src/main/java/com/mh/user/config/QuartzConfig.java

@ -1,54 +1,53 @@
package com.mh.user.config;
import com.mh.user.job.JobFactory;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Scheduler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
/**
* @author ljf
* @title Quartz配置
* @description
* @updateTime 2020-04-03
* @throws
*/
@Slf4j
@Configuration
public class QuartzConfig {
private JobFactory jobFactory;
/**
* @author jinhaoxun
* @description 构造器
* @param jobFactory
*/
public QuartzConfig(JobFactory jobFactory){
this.jobFactory = jobFactory;
}
/**
* @author jinhaoxun
* @description 配置SchedulerFactoryBean将一个方法产生为Bean并交给Spring容器管理
* @return SchedulerFactoryBean
*/
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
// log.info("开始注入定时任务调度器工厂...");
System.out.println("开始注入定时任务调度器工厂...");
SchedulerFactoryBean factory = new SchedulerFactoryBean();// Spring提供SchedulerFactoryBean为Scheduler提供配置信息,并被Spring容器管理其生命周期
factory.setJobFactory(jobFactory);// 设置自定义Job Factory,用于Spring管理Job bean
factory.setOverwriteExistingJobs(true);// 覆盖存在的定时任务
factory.setStartupDelay(30); //延时30秒启动定时任务,避免系统未完全启动却开始执行定时任务的情况
// log.info("注入定时任务调度器工厂成功!");
System.out.println("注入定时任务调度器工厂成功!");
return factory;
}
@Bean(name = "scheduler")
public Scheduler scheduler() {
return schedulerFactoryBean().getScheduler();
}
}
//package com.mh.user.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.quartz.Scheduler;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
//
///**
// * @author ljf
// * @title : Quartz配置
// * @description :
// * @updateTime 2020-04-03
// * @throws :
// */
//@Slf4j
//@Configuration
//public class QuartzConfig {
//
// private JobFactory jobFactory;
//
// /**
// * @author jinhaoxun
// * @description 构造器
// * @param jobFactory
// */
// public QuartzConfig(JobFactory jobFactory){
// this.jobFactory = jobFactory;
// }
//
// /**
// * @author jinhaoxun
// * @description 配置SchedulerFactoryBean,将一个方法产生为Bean并交给Spring容器管理
// * @return SchedulerFactoryBean
// */
// @Bean
// public SchedulerFactoryBean schedulerFactoryBean() {
//// log.info("开始注入定时任务调度器工厂...");
// System.out.println("开始注入定时任务调度器工厂...");
// SchedulerFactoryBean factory = new SchedulerFactoryBean();// Spring提供SchedulerFactoryBean为Scheduler提供配置信息,并被Spring容器管理其生命周期
// factory.setJobFactory(jobFactory);// 设置自定义Job Factory,用于Spring管理Job bean
// factory.setOverwriteExistingJobs(true);// 覆盖存在的定时任务
// factory.setStartupDelay(30); //延时30秒启动定时任务,避免系统未完全启动却开始执行定时任务的情况
//// log.info("注入定时任务调度器工厂成功!");
// System.out.println("注入定时任务调度器工厂成功!");
// return factory;
// }
//
// @Bean(name = "scheduler")
// public Scheduler scheduler() {
// return schedulerFactoryBean().getScheduler();
// }
//}

11
user-service/src/main/java/com/mh/user/config/RabbitmqConfig.java

@ -1,30 +1,21 @@
package com.mh.user.config;
import com.mh.user.component.ReceiveHandler;
import com.mh.user.constants.Constant;
import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.Logger;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;
/**
*队列绑定队列绑定交换机绑定路由KEY
*/
@Slf4j
@Configuration
public class RabbitmqConfig {
private static final Logger log = Logger.getLogger(RabbitmqConfig.class);
// public static final String QUEUE_NAME = "queue_zjjd"; //采集队列,珠江酒店
// public static final String QUEUE_NAME = "queue_gdkj"; //采集队列,广大科技

12
user-service/src/main/java/com/mh/user/constants/ChillerParamsEnum.java

@ -0,0 +1,12 @@
package com.mh.user.constants;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 主机枚举类
* @date 2024-08-28 17:21:39
*/
public enum ChillerParamsEnum {
}

14
user-service/src/main/java/com/mh/user/constants/Constant.java

@ -9,10 +9,22 @@ package com.mh.user.constants;
*/
public class Constant {
public static boolean CONTROL_WEB_FLAG = false;
public static final String FAIL = "fail";
public static final String SUCCESS = "success";
public static final Object SYS_DICT = "sys_dict";
public static boolean CONTROL_WEB_FLAG = false;
public static boolean SEND_STATUS = false; // 指令发送状态
public static boolean FLAG = false;
public static boolean WEB_FLAG = false; // 判断是否有前端指令下发
public static int projectId=1; // 项目编号
public static Long THREE_METER = 1L; // 三相电表
public static Long COOLING_METER = 2L; // 冷量计
public static Long DIG_DISPLAY_METER = 3L; // 数显电表
public static float CARBON_EMISSION_FACTOR = 0.6379f;
}

60
user-service/src/main/java/com/mh/user/constants/ProtocolEnum.java

@ -0,0 +1,60 @@
package com.mh.user.constants;
import com.mh.user.factory.CJ188Protocol;
import com.mh.user.factory.EleProtocol;
import com.mh.user.factory.ModbusProtocol;
import com.mh.user.factory.Protocol;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 协议枚举类
* @date 2024-09-12 10:31:53
*/
public enum ProtocolEnum {
CJ188_PROTOCOL("0", CJ188Protocol.getInstance()),
MODBUS_PROTOCOL("1", ModbusProtocol.getInstance()),
ELE_97_PROTOCOL("2", EleProtocol.getInstance()),
ELE_07_PROTOCOL("3", EleProtocol.getInstance()),
;
private String protocolType;
private Protocol protocol;
private ProtocolEnum(String protocolType, Protocol protocol) {
this.protocolType = protocolType;
this.protocol = protocol;
}
public String getProtocolType() {
return protocolType;
}
public void setProtocolType(String protocolType) {
this.protocolType = protocolType;
}
public Protocol getProtocol() {
return protocol;
}
public void setProtocol(Protocol protocol) {
this.protocol = protocol;
}
public static Protocol getProtocol(String protocolType) {
for (ProtocolEnum protocolEnum : ProtocolEnum.values()) {
if (protocolEnum.getProtocolType().equals(protocolType)) {
return protocolEnum.getProtocol();
}
}
return null;
}
}

60
user-service/src/main/java/com/mh/user/constants/ProtocolStrategyEnum.java

@ -0,0 +1,60 @@
package com.mh.user.constants;
import com.mh.user.strategy.CJ188ProtocolStrategy;
import com.mh.user.strategy.EleProtocolStrategy;
import com.mh.user.strategy.ModbusProtocolStrategy;
import com.mh.user.strategy.ProtocolStrategy;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 协议枚举类
* @date 2024-09-12 10:31:53
*/
public enum ProtocolStrategyEnum {
CJ188_PROTOCOL("0", CJ188ProtocolStrategy.getInstance()),
MODBUS_PROTOCOL("1", ModbusProtocolStrategy.getInstance()),
ELE_97_PROTOCOL("2", EleProtocolStrategy.getInstance()),
ELE_07_PROTOCOL("3", EleProtocolStrategy.getInstance()),
;
private String protocolType;
private ProtocolStrategy protocolStrategy;
ProtocolStrategyEnum(String protocolType, ProtocolStrategy protocolStrategy) {
this.protocolType = protocolType;
this.protocolStrategy = protocolStrategy;
}
public String getProtocolType() {
return protocolType;
}
public void setProtocolType(String protocolType) {
this.protocolType = protocolType;
}
public ProtocolStrategy getProtocolStrategy() {
return protocolStrategy;
}
public void setProtocolStrategy(ProtocolStrategy protocolStrategy) {
this.protocolStrategy = protocolStrategy;
}
public static ProtocolStrategy getProtocolStrategy(String protocolType) {
for (ProtocolStrategyEnum protocolStrategyEnum : ProtocolStrategyEnum.values()) {
if (protocolStrategyEnum.getProtocolType().equals(protocolType)) {
return protocolStrategyEnum.getProtocolStrategy();
}
}
return null;
}
}

2
user-service/src/main/java/com/mh/user/controller/ChartController.java

@ -1,6 +1,6 @@
package com.mh.user.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson2.JSONArray;
import com.mh.common.http.HttpResult;
import com.mh.user.entity.chart.ChartEntity;
import com.mh.user.entity.chart.GetChartParams;

129
user-service/src/main/java/com/mh/user/controller/ChillersController.java

@ -1,20 +1,18 @@
package com.mh.user.controller;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.mh.common.http.HttpResult;
import com.mh.user.dto.DisplayBoxDataDTO;
import com.mh.user.dto.TableInfoDTO;
import com.mh.user.entity.GaugeEntity;
import com.mh.user.entity.HostValue;
import com.mh.user.entity.TableDataEntity;
import com.mh.user.entity.TableInfoEntity;
import com.mh.user.entity.*;
import com.mh.user.service.chillers.ChillersService;
import com.mh.user.service.chillers.DeviceDisplayService;
import com.mh.user.service.chillers.GaugeService;
import com.mh.user.vo.HostListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -26,6 +24,7 @@ import java.util.List;
* @throws
*/
@RestController
@RequestMapping("/chillers")
public class ChillersController {
private final ChillersService chillersService;
@ -36,105 +35,47 @@ public class ChillersController {
this.deviceDisplayService = deviceDisplayService;
}
// 查询冷水机组各个部位的状态值
// @GetMapping("/chillers")
/**
* 查询冷水机组进出水温度值等设备数据详情
* @param deviceType
* @param type
* @return
*/
@GetMapping("/charts/getDisplayBoxData")
public HttpResult getDisplayBoxData(@RequestParam(value = "deviceType") String deviceType,
@RequestParam(value = "type") Integer type) {
List<DisplayBoxDataDTO> displayBoxDataDTOS = deviceDisplayService.deviceDisplayBoxData(deviceType, String.valueOf(type));
return HttpResult.ok("success", displayBoxDataDTOS);
}
/**
* 主机监测详情左侧表格数据
* @param deviceName
* @return
*/
@GetMapping("/charts/getHostTableOneData")
public HttpResult queryChillersOneTable(@RequestParam(value = "deviceName") String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
}
/**
* 主机监测详情顶部表格数据
* @param deviceName
* 查询主机列表详情信息
* @param proId
* @param systemId
* @return
*/
@GetMapping("/charts/getHostTopData")
public HttpResult queryChillersTopTable(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableDataEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryTopData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
@GetMapping("/queryListByProId")
public HttpResult queryChillersByProId(@RequestParam(value = "proId", required = false) String proId,
@RequestParam("systemId") String systemId) {
JSONArray resultJson = chillersService.queryChillersByProId(systemId, proId);
return HttpResult.ok(resultJson);
}
/**
* 主机监测详情右侧一表格数据
* @param deviceName
* 查询主机详情主页信息计算制冷量用电量碳排放平均COP等
* @param systemId
* @param proId
* @param deviceId
* @return
*/
@GetMapping("/charts/getHostTableTwoData")
public HttpResult queryChillersRightTable(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 2));
return HttpResult.ok("success", tableInfoDTO);
@GetMapping("/queryHomeDetail/totalData")
public HttpResult totalData(@RequestParam("systemId") String systemId,
@RequestParam(value = "proId", required = false) String proId,
@RequestParam("deviceId") String deviceId) {
JSONObject resultJson = chillersService.queryTotalData(systemId, proId, deviceId);
return HttpResult.ok(resultJson);
}
/**
* 主机监测详情右侧二表格数据
* @param deviceName
* 查询主机详情主页信息当日能耗分析
* @param systemId
* @param proId
* @param deviceId
* @return
*/
@GetMapping("/charts/getHostTableThreeData")
public HttpResult queryChillersRightTable1(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 3));
return HttpResult.ok("success", tableInfoDTO);
}
// 冷却泵、冷冻泵、冷却塔详情页顶部表格数据
@GetMapping("/charts/getPumpOrTowerTopTableData")
public HttpResult getPumpOrTowerTopData(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
}
// 冷却泵、冷冻泵、冷却塔详情页顶部数据
// @GetMapping("/charts/getPumpOrTowerTopTableData")
@GetMapping("/charts/getPumpOrTowerTopData")
public HttpResult getPumpOrTowerTopTableData(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableDataEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryTopData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
}
// 获取冷却/冷冻水进出水温度、主机/冷却塔温度
@GetMapping("/operation/getTempValue")
public HttpResult getTempValue(@RequestParam(value = "deviceType", required = true) String deviceType) {
List<HostValue> hostValueList = chillersService.queryTempValue(deviceType);
JSONObject jsonObject = new JSONObject();
jsonObject.put("values", hostValueList);
return HttpResult.ok("success",jsonObject);
}
@Autowired
private GaugeService gaugeService;
// 设备监控页表盘分析图
@GetMapping("/charts/getGaugeData")
public HttpResult getGaugeData(@RequestParam(value = "type") String type, @RequestParam(value = "deviceName") String deviceName) {
GaugeEntity gaugeEntity = gaugeService.getGaugeData(type,deviceName);
return HttpResult.ok("success",gaugeEntity);
@GetMapping("/queryHomeDetail/chartData")
public HttpResult chartData(@RequestParam("systemId") String systemId,
@RequestParam(value = "proId", required = false) String proId,
@RequestParam("deviceId") String deviceId) {
JSONObject resultJson = chillersService.queryChartData(systemId, proId, deviceId);
return HttpResult.ok(resultJson);
}
}

58
user-service/src/main/java/com/mh/user/controller/DataResultController.java

@ -25,7 +25,7 @@ public class DataResultController {
@SysLogger(value="中央空调",optDesc = "数据分析查询")
@PostMapping(value="/query")
public HttpResult queryDataResult(@RequestParam(value = "projectID", required = false) String projectID,
public HttpResult queryDataResult(@RequestParam(value = "projectId", required = false) String projectId,
@RequestParam(value= "startDate", required=false)String startDate,
@RequestParam(value= "endDate", required=false)String endDate,
@RequestParam(value= "deviceType", required=false)String deviceType,
@ -34,8 +34,8 @@ public class DataResultController {
try{
int count=dataResultService.getDataResultCount(projectID,startDate,endDate,deviceType,page,limit);
List<DataResultEntity> records=dataResultService.queryDataResult(projectID,startDate,endDate,deviceType,page,limit);
int count=dataResultService.getDataResultCount(projectId,startDate,endDate,deviceType,page,limit);
List<DataResultEntity> records=dataResultService.queryDataResult(projectId,startDate,endDate,deviceType,page,limit);
return HttpResult.ok(count,records);
}catch (Exception e){
@ -46,44 +46,44 @@ public class DataResultController {
@SysLogger(value="中央空调",optDesc = "能耗分析按小时查询")
@PostMapping(value="/hour")
public HttpResult queryDataResultMi(@RequestParam(value= "projectID", required=false)String projectID,
public HttpResult queryDataResultMi(@RequestParam(value = "projectId", required=false)String projectId,
@RequestParam(value= "dateType", required=false)String dateType,
@RequestParam(value= "curDate", required=false)String curDate,
@RequestParam(value="page", required=false) int page,
@RequestParam(value="limit", required=false) int limit) {
try{
if(projectID!=null && projectID.length()>0){
if(projectId!=null && projectId.length()>0){
String startDate="";
curDate=curDate.substring(0,16)+":00";
if (dateType.equals("1小时")){
startDate= ExchangeStringUtil.dateRoll(1,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectID,startDate,curDate,page,limit,0);
int count=dataResultService.dataResultOneMiCount(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectId,startDate,curDate,page,limit,0);
int count=dataResultService.dataResultOneMiCount(projectId,startDate,curDate);
return HttpResult.ok(count,records);
}else if (dateType.equals("2小时")){
startDate=ExchangeStringUtil.dateRoll(2,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectID,startDate,curDate,page,limit,0);
int count=dataResultService.dataResultOneMiCount(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectId,startDate,curDate,page,limit,0);
int count=dataResultService.dataResultOneMiCount(projectId,startDate,curDate);
return HttpResult.ok(count,records);
}else if (dateType.equals("8小时")){
startDate=ExchangeStringUtil.dateRoll(8,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectID,startDate,curDate,page,limit,1);
int count=dataResultService.dataResultFiveMiCount(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectId,startDate,curDate,page,limit,1);
int count=dataResultService.dataResultFiveMiCount(projectId,startDate,curDate);
return HttpResult.ok(count,records);
}else if (dateType.equals("12小时")){
startDate=ExchangeStringUtil.dateRoll(12,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectID,startDate,curDate,page,limit,1);
int count=dataResultService.dataResultFiveMiCount(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectId,startDate,curDate,page,limit,1);
int count=dataResultService.dataResultFiveMiCount(projectId,startDate,curDate);
return HttpResult.ok(count,records);
}else if (dateType.equals("24小时")){
startDate=ExchangeStringUtil.dateRoll(24,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectID,startDate,curDate,page,limit,2);
int count=dataResultService.dataResultFifteenMiCount(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectId,startDate,curDate,page,limit,2);
int count=dataResultService.dataResultFifteenMiCount(projectId,startDate,curDate);
return HttpResult.ok(count,records);
}else{ //1小时
startDate=ExchangeStringUtil.dateRoll(1,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectID,startDate,curDate,page,limit,0);
int count=dataResultService.dataResultOneMiCount(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultMi(projectId,startDate,curDate,page,limit,0);
int count=dataResultService.dataResultOneMiCount(projectId,startDate,curDate);
return HttpResult.ok(count,records);
}
}else{
@ -97,7 +97,7 @@ public class DataResultController {
@SysLogger(value="中央空调",optDesc = "能耗分析按分钟查询")
@PostMapping(value="/minute")
public HttpResult queryDataResultSec(@RequestParam(value= "projectID", required=false)String projectID,
public HttpResult queryDataResultSec(@RequestParam(value = "projectId", required=false)String projectId,
@RequestParam(value= "dateType", required=false)String dateType,
@RequestParam(value= "curDate", required=false)String curDate,
@RequestParam(value="page",required=false) int page,
@ -111,7 +111,7 @@ public class DataResultController {
curDate=curDate.substring(0,16)+":00";
if (dateType.equals("1分钟")){
startDate= ExchangeStringUtil.dateTime(1,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectId,startDate,curDate);
String deviceAddr=records.get(0).getDeviceAddr();
String projectName=records.get(0).getProjectName();
@ -139,7 +139,7 @@ public class DataResultController {
}else if (dateType.equals("2分钟")){
startDate=ExchangeStringUtil.dateTime(2,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectId,startDate,curDate);
String deviceAddr=records.get(0).getDeviceAddr();
String projectName=records.get(0).getProjectName();
//Date date=df.parse(startDate);//顺序
@ -165,7 +165,7 @@ public class DataResultController {
return HttpResult.ok(120,listMap);
}else if (dateType.equals("5分钟")){
startDate=ExchangeStringUtil.dateTime(5,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectId,startDate,curDate);
String deviceAddr=records.get(0).getDeviceAddr();
String projectName=records.get(0).getProjectName();
String s=startDate.substring(18,19);
@ -200,7 +200,7 @@ public class DataResultController {
return HttpResult.ok(60,listMap);
}else if (dateType.equals("15分钟")){
startDate=ExchangeStringUtil.dateTime(15,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectId,startDate,curDate);
String deviceAddr=records.get(0).getDeviceAddr();
String projectName=records.get(0).getProjectName();
String s=startDate.substring(18,19);
@ -235,7 +235,7 @@ public class DataResultController {
return HttpResult.ok(180,listMap);
}else if (dateType.equals("30分钟")){
startDate=ExchangeStringUtil.dateTime(30,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectId,startDate,curDate);
String deviceAddr=records.get(0).getDeviceAddr();
String projectName=records.get(0).getProjectName();
String s=startDate.substring(18,19);
@ -269,7 +269,7 @@ public class DataResultController {
return HttpResult.ok(180,listMap);
}else{ //1分钟
startDate= ExchangeStringUtil.dateTime(1,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectID,startDate,curDate);
List<DataResultChEntity> records=dataResultService.queryDataResultSec(projectId,startDate,curDate);
String deviceAddr=records.get(0).getDeviceAddr();
String projectName=records.get(0).getProjectName();
//Date date=df.parse(startDate);
@ -305,15 +305,15 @@ public class DataResultController {
@PostMapping(value="/dataNow")
public HttpResult selectDataResultNow(@RequestParam(value= "deviceAddr", required=false)String deviceAddr,
@RequestParam(value= "deviceType", required=false)String deviceType,
@RequestParam(value= "projectID", required=false)String projectID) {
@RequestParam(value = "projectId", required=false)String projectId) {
List<DataResultChEntity> dataNow=dataResultService.selectDataResultNow(deviceAddr, deviceType, projectID);
List<DataResultChEntity> dataNow=dataResultService.selectDataResultNow(deviceAddr, deviceType, projectId);
return HttpResult.ok("success",dataNow);
}
@SysLogger(value="中央空调",optDesc = "查询冷水机参数值")
@PostMapping(value="/dataChiller")
public HttpResult queryDataResultChiller(@RequestParam("projectID")String projectID,
public HttpResult queryDataResultChiller(@RequestParam("projectId")String projectId,
@RequestParam("deviceAddr")String deviceAddr,
@RequestParam("registerName")String registerName,
@RequestParam(value= "startDate", required=false)String startDate,
@ -321,8 +321,8 @@ public class DataResultController {
@RequestParam("page")int page,
@RequestParam("limit")int limit) {
int count=dataResultService.dataResultChillerCount(projectID,deviceAddr, registerName, startDate, curDate);
List<DataResultChEntity> dataChiller=dataResultService.queryDataResultChiller(projectID,deviceAddr,registerName,startDate,curDate,page,limit);
int count=dataResultService.dataResultChillerCount(projectId,deviceAddr, registerName, startDate, curDate);
List<DataResultChEntity> dataChiller=dataResultService.queryDataResultChiller(projectId,deviceAddr,registerName,startDate,curDate,page,limit);
return HttpResult.ok(count,dataChiller);
}
}

22
user-service/src/main/java/com/mh/user/controller/DeviceInfoController.java

@ -23,35 +23,35 @@ public class DeviceInfoController {
@SysLogger(value="设备信息",optDesc = "查询设备信息")
@PostMapping("/query")
public HttpResult queryMeterInfo(@RequestParam(value = "systemID") String systemID,
@RequestParam(value = "projectID") String projectID,
@RequestParam(value = "deviceType") String deviceType){
public HttpResult queryMeterInfo(@RequestParam(value = "systemId") String systemID,
@RequestParam(value = "projectId") String projectId,
@RequestParam(value = "deviceType", required = false) String deviceType){
List<DeviceInfoEntity> list=deviceInfoService.queryDeviceInfo(systemID,projectID,deviceType);
List<DeviceInfoEntity> list=deviceInfoService.queryDeviceInfo(systemID,projectId,deviceType);
return HttpResult.ok(list);
}
@SysLogger(value="设备信息",optDesc = "查询冷水机列表")
@PostMapping("/list")
public HttpResult selectDevices(@RequestParam(value = "systemID") String systemID,
@RequestParam(value = "projectID") String projectID){
List<DeviceModel> list=deviceInfoService.selectDevices(projectID);
public HttpResult selectDevices(@RequestParam(value = "systemId") String systemID,
@RequestParam(value = "projectId") String projectId){
List<DeviceModel> list=deviceInfoService.selectDevices(projectId);
return HttpResult.ok(list);
}
@SysLogger(value="设备信息",optDesc = "查询多个冷水机相关信息")
@PostMapping("/chillers")
public HttpResult queryChiller(@RequestParam(value = "projectID") String projectID,
public HttpResult queryChiller(@RequestParam(value = "projectId") String projectId,
@RequestParam(value = "deviceAddr") String deviceAddr){
List<ChillerModel> list=deviceInfoService.queryChiller(projectID,deviceAddr);
List<ChillerModel> list=deviceInfoService.queryChiller(projectId,deviceAddr);
return HttpResult.ok(list);
}
@SysLogger(value="设备信息",optDesc = "查询单个冷水机相关信息")
@PostMapping("/chiller")
public HttpResult selectChiller(@RequestParam(value = "projectID") String projectID,
public HttpResult selectChiller(@RequestParam(value = "projectId") String projectId,
@RequestParam(value = "deviceAddr") String deviceAddr){
ChillerModel chillerModel=deviceInfoService.selectChiller(projectID,deviceAddr);
ChillerModel chillerModel=deviceInfoService.selectChiller(projectId,deviceAddr);
return HttpResult.ok(chillerModel);
}
}

299
user-service/src/main/java/com/mh/user/controller/DeviceManageController.java

@ -1,299 +0,0 @@
package com.mh.user.controller;
import com.alibaba.fastjson.JSONObject;
import com.mh.common.http.HttpResult;
import com.mh.user.annotation.SysLogger;
import com.mh.user.dto.DeviceMessageDTO;
import com.mh.user.entity.*;
import com.mh.user.manage.QuartzManager;
import com.mh.user.netty.NettyChillerControlClient;
import com.mh.user.service.chillers.DeviceDisplayService;
import com.mh.user.constants.Constant;
import com.mh.user.service.chillers.DeviceManageService;
import com.mh.user.service.chillers.DeviceParamService;
import com.mh.user.service.chillers.GatewayManageService;
import com.mh.user.utils.GetReadOrder485;
import com.mh.user.utils.QuerySendThread;
import com.mh.user.constants.SocketMessage;
import com.mh.user.utils.TimeDifferenceUtil;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author ljf
* @title
* @description 设备管理接口
* @updateTime 2020-05-29
* @updateTime 2020-07-17
* @throws
*/
@RestController
public class DeviceManageController {
private final DeviceDisplayService deviceDisplayService;
private final GatewayManageService gatewayManageService;
private final DeviceManageService deviceManageService;
private final DeviceParamService deviceParamService;
public DeviceManageController(DeviceDisplayService deviceDisplayService, GatewayManageService gatewayManageService, DeviceManageService deviceManageService, DeviceParamService deviceParamService) {
this.deviceDisplayService = deviceDisplayService;
this.gatewayManageService = gatewayManageService;
this.deviceManageService = deviceManageService;
this.deviceParamService = deviceParamService;
}
@Resource
QuartzManager quartzManager;
@Autowired
private SocketMessage socketMessage;
// 查询设备信息状态
@GetMapping("/operation/getColdStation")
public HttpResult getColdStation(@RequestParam(value = "deviceType", required = true) String deviceType) {
List<DeviceMessageDTO> deviceMessageList = deviceDisplayService.queryDeviceStatus(deviceType);
Map<String, Object> formValues = new HashMap<>();
formValues.put("formValues",deviceMessageList);
return HttpResult.ok("success", formValues);
}
// 对设备进行操作处理
@PostMapping("/operation/operationDevice")
public HttpResult operationDevice(@RequestBody List<OrderEntity> changeValues) {
String result;
try {
List<OrderMessageEntity> orderMessageEntityList;
// type值 0:修改频率, 1:修改开关状态, 2: 关闭冷却泵之前,查询最近关闭的冷却塔时间,3: 群控手自动切换类型,4: 修改温度, 5: 修改压力
// // 添加网页发送指令状态 update by ljf on 2020-08-07
Constant.CONTROL_WEB_FLAG = true;
// 暂停采集
// quartzManager.pauseJob("DDC","JobDDCGroup");
// Thread.sleep(2000);
// 修改成不用暂停采集处理
GetReadOrder485 getReadOrder485 = new GetReadOrder485();
// 判断是否是去关闭冷却泵,如果是,需要检查最近冷却塔有没有关闭并且关闭时间大于8分钟
// 判断changeValues大小
int size = changeValues.size();
int type = changeValues.get(0).getType();
if (type == 3 && size == 1) {
// 生成指令
orderMessageEntityList = getReadOrder485.createOrder(changeValues);
if (orderMessageEntityList.size() != 0) {
// 开启发送指令
NettyChillerControlClient nettyChillerControlClient = new NettyChillerControlClient();
// nettyChillerControlClient.connect(8081, "192.168.1.131", orderMessageEntityList);
nettyChillerControlClient.connect(socketMessage.getPort(), socketMessage.getIP(), orderMessageEntityList);
// 开启线程监测标志
QuerySendThread querySendThread = new QuerySendThread();
querySendThread.start();
if (Constant.SEND_STATUS) {
result = "success";
} else {
result = "fail";
}
} else {
result = "fail";
}
} else if (type == 2 && size == 1) {
TimeDifferenceUtil timeDifferenceUtil = new TimeDifferenceUtil();
Boolean a = timeDifferenceUtil.timeDifference(socketMessage.getOverTime());
if (a) {
// 生成指令
orderMessageEntityList = getReadOrder485.createOrder(changeValues);
if (orderMessageEntityList.size() != 0) {
// 开启发送指令
NettyChillerControlClient nettyChillerControlClient = new NettyChillerControlClient();
// nettyChillerControlClient.connect(8081, "192.168.1.131", orderMessageEntityList);
nettyChillerControlClient.connect(socketMessage.getPort(), socketMessage.getIP(), orderMessageEntityList);
// 开启线程监测标志
QuerySendThread querySendThread = new QuerySendThread();
querySendThread.start();
if (Constant.SEND_STATUS) {
result = "success";
} else {
result = "fail";
}
} else {
result = "fail";
}
} else {
result = "冷却塔关机还没有超过8分钟";
}
} else {
// 生成指令
orderMessageEntityList = getReadOrder485.createOrder(changeValues);
if (orderMessageEntityList.size() != 0) {
// 开启发送指令
NettyChillerControlClient nettyChillerControlClient = new NettyChillerControlClient();
// nettyChillerControlClient.connect(8081, "192.168.1.131", orderMessageEntityList);
nettyChillerControlClient.connect(socketMessage.getPort(), socketMessage.getIP(), orderMessageEntityList);
// 开启线程监测标志
QuerySendThread querySendThread = new QuerySendThread();
querySendThread.start();
if (Constant.SEND_STATUS) {
result = "success";
} else {
result = "fail";
}
} else {
result = "fail";
}
}
Constant.CONTROL_WEB_FLAG = false;
// 不需要停止采集
// Constant.WEB_FLAG = false;
// // 延迟5秒处理,等待线程处理数据
Thread.sleep(500);
// // 重新开启定时采集
// quartzManager.resumeAllJob();
// quartzManager.resumeJob("DDC","JobDDCGroup");
} catch (InterruptedException | ParseException e) {
e.printStackTrace();
result = "fail";
}
// 异常情况处理
return HttpResult.ok(result);
}
/**
* 查询网关信息
* @param requestJson
* @return
*/
@PostMapping("/gateWay/getGateWayList")
public HttpResult gateWayList(@RequestBody String requestJson){
JSONObject jsonObject =JSONObject.parseObject(requestJson);
Integer operator = null;
Integer grade = null;
if(jsonObject.get("operator") != null){
if(jsonObject.get("operator").equals("中国移动")){
operator = 0;
}else if(jsonObject.get("operator").equals("中国联通")){
operator = 1;
}else if(jsonObject.get("operator").equals("中国电信")){
operator = 2;
}
}
if(jsonObject.get("grade") != null){
if(jsonObject.get("grade").equals("正常")){
grade = 0;
}else if(jsonObject.get("grade").equals("不在线")){
grade = 1;
}else if(jsonObject.get("grade").equals("异常")){
grade = 2;
}
}
List<GatewayManageEntity> gateWayList = gatewayManageService.queryByOther(grade,operator);
JSONObject tableData = new JSONObject();
tableData.put("tableData",gateWayList);
return HttpResult.ok(tableData);
// System.out.println(requestJson);
// return null;
}
/**
* 新增或更新网关信息
* @param reqestJson
* @return
*/
@PostMapping("/gateWay/addOrUpdateGateWayInfo")
public HttpResult addOrUpdateGateWayInfo(@RequestBody GatewayManageEntity reqestJson){
try {
System.out.println(reqestJson.toString());
gatewayManageService.addOrUpdateGateWayInfo(reqestJson);
return HttpResult.ok();
} catch (Exception e) {
e.printStackTrace();
return HttpResult.error(e.getMessage());
}
}
/**
* 删除网关/基表/基表参数信息
* @param requestJson
* @return
*/
@PostMapping("/device/deleteDeviceInfo")
public HttpResult deleteDeviceInfo(@RequestBody String requestJson){
JSONObject jsonObject =JSONObject.parseObject(requestJson);
System.out.println(jsonObject.get("deviceId"));
try {
deviceManageService.deleteDeviceInfo((Integer)jsonObject.get("deviceId"),jsonObject.get("deviceType").toString());
return HttpResult.ok();
} catch (Exception e) {
e.printStackTrace();
return HttpResult.error(e.getMessage());
}
}
/**
* 查询基表管理中的基表数据
* @param requestJson
* @return
*/
@PostMapping("/baseMeter/getBaseMeterList")
public HttpResult getBaseMeterList(@RequestBody String requestJson){
JSONObject jsonObject =JSONObject.parseObject(requestJson);
List<DeviceManageEntity> list = deviceManageService.getDeviceByOther(jsonObject.get("deviceNum").toString());
JSONObject tableData = new JSONObject();
tableData.put("tableData",list);
return HttpResult.ok(tableData);
}
/**
* 增加或更新基表信息数据
* @param requestJson
* @return
*/
@PostMapping("/baseMeter/addOrUpdateBaseMeter")
public HttpResult addOrUpdateBaseMeter(@RequestBody DeviceManageEntity requestJson){
try {
deviceManageService.addOrUpdateBaseMeter(requestJson);
return HttpResult.ok();
} catch (Exception e) {
e.printStackTrace();
return HttpResult.error("检查输入的设备码是否有误!");
}
}
/**
* 查询基表参数管理中的基表参数数据
* @param requestJson
* @return
*/
@PostMapping("/baseMeterParam/getBaseMeterParamList")
public HttpResult getBaseMeterParamList(@RequestBody String requestJson){
JSONObject jsonObject =JSONObject.parseObject(requestJson);
System.out.println(jsonObject.get("baseMeterType"));
String baseMeterType = (String) jsonObject.get("baseMeterType");
List<DeviceParameterEntity> list = deviceParamService.getBaseMeterParamList(baseMeterType);
JSONObject tableData = new JSONObject();
tableData.put("tableData",list);
return HttpResult.ok(tableData);
}
/**
* 添加或更新基表参数信息
* @param requestJson
* @return
*/
@PostMapping("/baseMeterParam/addOrUpdateBaseMeterParam")
public HttpResult addOrUpdateBaseMeterParam(@RequestBody DeviceParameterEntity requestJson){
try {
deviceParamService.addOrUpdateBaseMeterParam(requestJson);
return HttpResult.ok();
} catch (Exception e) {
e.printStackTrace();
return HttpResult.error(e.getMessage());
}
}
}

63
user-service/src/main/java/com/mh/user/controller/DevicesManageController.java

@ -0,0 +1,63 @@
package com.mh.user.controller;
import com.mh.common.http.HttpResult;
import com.mh.common.page.PageRequest;
import com.mh.common.page.PageResult;
import com.mh.user.annotation.FieldParam;
import com.mh.user.annotation.SysLogger;
import com.mh.user.annotation.TranslationDict;
import com.mh.user.entity.DevicesManageEntity;
import com.mh.user.service.DevicesManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 仪表管理控制层
* @date 2024-08-23 08:53:03
*/
@RestController
@RequestMapping("/devicesManage")
public class DevicesManageController {
@Autowired
private DevicesManageService devicesManageService;
@SysLogger(value = "资产管理信息", optDesc = "查询资产管理信息")
@PostMapping("/findByPage")
@TranslationDict({@FieldParam(type = "device_type", targetField = "deviceType", targetFieldValueClazz = Integer.class)})
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) {
return devicesManageService.queryByPage(pageRequest);
}
@SysLogger(value = "资产管理信息", optDesc = "编辑资产管理信息")
@PostMapping("/update")
public HttpResult updateProInfo(DevicesManageEntity entity) {
devicesManageService.update(entity);
return HttpResult.ok();
}
@SysLogger(value = "资产管理信息", optDesc = "根据项目id查询对应信息")
@GetMapping("/findById")
public HttpResult findById(@RequestParam("id") Long id) {
DevicesManageEntity entity = devicesManageService.findById(id);
return HttpResult.ok(entity);
}
@SysLogger(value = "资产管理信息", optDesc = "添加资产管理信息")
@PostMapping("/save")
public HttpResult saveDevice(DevicesManageEntity entity) {
devicesManageService.save(entity);
return HttpResult.ok();
}
@SysLogger(value = "资产管理信息", optDesc = "删除资产管理信息")
@GetMapping("/deleteById")
public HttpResult deleteProInfo(@RequestParam String id) {
devicesManageService.delete(id);
return HttpResult.ok();
}
}

60
user-service/src/main/java/com/mh/user/controller/DevicesParamsController.java

@ -0,0 +1,60 @@
package com.mh.user.controller;
import com.mh.common.http.HttpResult;
import com.mh.common.page.PageRequest;
import com.mh.common.page.PageResult;
import com.mh.user.annotation.SysLogger;
import com.mh.user.entity.DeviceParamsEntity;
import com.mh.user.service.DeviceParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 设备参数管理控制层
* @date 2024-08-23 08:53:03
*/
@RestController
@RequestMapping("/deviceParams")
public class DevicesParamsController {
@Autowired
private DeviceParamsService deviceParamsService;
@SysLogger(value="设备参数管理",optDesc = "查询设备参数管理")
@PostMapping("/findByPage")
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) {
return deviceParamsService.queryByPage(pageRequest);
}
@SysLogger(value="设备参数管理",optDesc = "编辑设备参数管理")
@PostMapping("/update")
public HttpResult updateProInfo(DeviceParamsEntity entity) {
deviceParamsService.update(entity);
return HttpResult.ok();
}
@SysLogger(value="设备参数管理",optDesc = "根据项目id查询对应信息")
@GetMapping("/findById")
public HttpResult findById(@RequestParam("id") Long id) {
DeviceParamsEntity entity = deviceParamsService.findById(id);
return HttpResult.ok(entity);
}
@SysLogger(value="设备参数管理",optDesc = "添加设备参数管理")
@PostMapping("/save")
public HttpResult saveGw(DeviceParamsEntity entity) {
deviceParamsService.save(entity);
return HttpResult.ok();
}
@SysLogger(value="设备参数管理",optDesc = "删除设备参数管理")
@GetMapping("/deleteById")
public HttpResult deleteProInfo(@RequestParam String id) {
deviceParamsService.delete(id);
return HttpResult.ok();
}
}

4
user-service/src/main/java/com/mh/user/controller/EnergyDataController.java

@ -23,8 +23,8 @@ public class EnergyDataController {
@PostMapping("/query")
public HttpResult queryEnergyData(@RequestBody EnergyModel energyModel){
try{
String projectID=energyModel.getProjectID();
if(projectID!=null && projectID.length()>0){
String projectId=energyModel.getProjectId();
if(projectId!=null && projectId.length()>0){
List<EnergyDataEntity> list=energyDataService.queryEnergyData(energyModel);
int count=energyDataService.getEnergyDataCount(energyModel);
return HttpResult.ok(count,list);

61
user-service/src/main/java/com/mh/user/controller/GatewayManageController.java

@ -0,0 +1,61 @@
package com.mh.user.controller;
import com.mh.common.http.HttpResult;
import com.mh.common.page.PageRequest;
import com.mh.common.page.PageResult;
import com.mh.user.annotation.SysLogger;
import com.mh.user.entity.GatewayManageEntity;
import com.mh.user.service.GatewayManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 网关管理接口控制类
* @date 2024-08-22 17:19:21
*/
@RestController
@RequestMapping("/gw")
public class GatewayManageController {
@Autowired
private GatewayManageService gatewayManageService;
@SysLogger(value="网关管理信息",optDesc = "查询网关管理信息")
@PostMapping("/findByPage")
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) {
return gatewayManageService.queryByPage(pageRequest);
}
@SysLogger(value="网关管理信息",optDesc = "编辑网关管理信息")
@PostMapping("/update")
public HttpResult updateProInfo(GatewayManageEntity gatewayManageEntity) {
gatewayManageService.update(gatewayManageEntity);
return HttpResult.ok();
}
@SysLogger(value="网关管理信息",optDesc = "根据项目id查询对应信息")
@GetMapping("/findById")
public HttpResult findById(@RequestParam("id") Long id) {
GatewayManageEntity gatewayManageEntity = gatewayManageService.findById(id);
return HttpResult.ok(gatewayManageEntity);
}
@SysLogger(value="网关管理信息",optDesc = "添加网关管理信息")
@PostMapping("/save")
public HttpResult saveGw(GatewayManageEntity gatewayManageEntity) {
gatewayManageService.save(gatewayManageEntity);
return HttpResult.ok();
}
@SysLogger(value="网关管理信息",optDesc = "删除网关管理信息")
@GetMapping("/deleteById")
public HttpResult deleteProInfo(@RequestParam String id) {
gatewayManageService.delete(id);
return HttpResult.ok();
}
}

6
user-service/src/main/java/com/mh/user/controller/MeterInfoController.java

@ -21,10 +21,10 @@ public class MeterInfoController {
@SysLogger(value="基表信息",optDesc = "查询基表信息")
@PostMapping("/query")
public HttpResult queryMeterInfo(@RequestParam(value = "systemID",required = false) String systemID,
@RequestParam(value = "projectID",required = false) String projectID){
public HttpResult queryMeterInfo(@RequestParam(value = "systemId",required = false) String systemID,
@RequestParam(value = "projectId",required = false) String projectId){
List<MeterInfoEntity> list=meterInfoService.queryMeterInfo(systemID,projectID);
List<MeterInfoEntity> list=meterInfoService.queryMeterInfo(systemID,projectId);
return HttpResult.ok(list);
}
}

67
user-service/src/main/java/com/mh/user/controller/MeterManageController.java

@ -0,0 +1,67 @@
package com.mh.user.controller;
import com.mh.common.http.HttpResult;
import com.mh.common.page.PageRequest;
import com.mh.common.page.PageResult;
import com.mh.user.annotation.FieldParam;
import com.mh.user.annotation.SysLogger;
import com.mh.user.annotation.TranslationDict;
import com.mh.user.entity.MeterManageEntity;
import com.mh.user.service.MeterManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 仪表管理控制层
* @date 2024-08-23 08:53:03
*/
@RestController
@RequestMapping("/mtManage")
public class MeterManageController {
@Autowired
private MeterManageService meterManageService;
@TranslationDict({@FieldParam(type = "device_type", targetField = "deviceType", targetFieldValueClazz = Integer.class),
@FieldParam(type = "communication_type", targetField = "communicationType", targetFieldValueClazz = Integer.class),
@FieldParam(type = "data_type", targetField = "dataType", targetFieldValueClazz = Integer.class),
@FieldParam(type = "protocol_type", targetField = "protocolType", targetFieldValueClazz = Integer.class),
})
@SysLogger(value="仪表管理信息",optDesc = "查询仪表管理信息")
@PostMapping("/findByPage")
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) {
return meterManageService.queryByPage(pageRequest);
}
@SysLogger(value="仪表管理信息",optDesc = "编辑仪表管理信息")
@PostMapping("/update")
public HttpResult updateProInfo(MeterManageEntity entity) {
meterManageService.update(entity);
return HttpResult.ok();
}
@SysLogger(value="仪表管理信息",optDesc = "根据项目id查询对应信息")
@GetMapping("/findById")
public HttpResult findById(@RequestParam("id") Long id) {
MeterManageEntity entity = meterManageService.findById(id);
return HttpResult.ok(entity);
}
@SysLogger(value="仪表管理信息",optDesc = "添加仪表管理信息")
@PostMapping("/save")
public HttpResult saveGw(MeterManageEntity entity) {
meterManageService.save(entity);
return HttpResult.ok();
}
@SysLogger(value="仪表管理信息",optDesc = "删除仪表管理信息")
@GetMapping("/deleteById")
public HttpResult deleteProInfo(@RequestParam String id) {
meterManageService.delete(id);
return HttpResult.ok();
}
}

46
user-service/src/main/java/com/mh/user/controller/ProjectInfoController.java

@ -1,14 +1,13 @@
package com.mh.user.controller;
import com.mh.common.http.HttpResult;
import com.mh.common.page.PageRequest;
import com.mh.common.page.PageResult;
import com.mh.user.annotation.SysLogger;
import com.mh.user.entity.ProjectInfoEntity;
import com.mh.user.service.ProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -20,10 +19,45 @@ public class ProjectInfoController {
ProjectInfoService projectInfoService;
@SysLogger(value="项目信息",optDesc = "查询项目信息")
@PostMapping("/queryPro")
public HttpResult queryProject(@RequestParam(value = "systemID")String systemID) {
@PostMapping("/queryProBySystemId")
public HttpResult queryProBySystemId(@RequestParam(value = "systemId")String systemID) {
List<ProjectInfoEntity> list=projectInfoService.queryProjectInfo(systemID);
return HttpResult.ok(list);
}
@SysLogger(value="项目信息",optDesc = "查询项目信息")
@PostMapping("/findByPage")
public PageResult queryProject(@RequestBody PageRequest pageRequest) {
return projectInfoService.queryByPage(pageRequest);
}
@SysLogger(value="项目信息",optDesc = "编辑项目信息")
@PostMapping("/update")
public HttpResult updateProInfo(ProjectInfoEntity projectInfoEntity) {
projectInfoService.update(projectInfoEntity);
return HttpResult.ok();
}
@SysLogger(value="项目信息",optDesc = "根据项目id查询对应信息")
@GetMapping("/findById")
public HttpResult findById(@RequestParam("id") Long id) {
ProjectInfoEntity projectInfoEntity = projectInfoService.findById(id);
return HttpResult.ok(projectInfoEntity);
}
@SysLogger(value="项目信息",optDesc = "添加项目信息")
@PostMapping("/save")
public HttpResult saveProInfo(ProjectInfoEntity projectInfoEntity) {
projectInfoService.save(projectInfoEntity);
return HttpResult.ok();
}
@SysLogger(value="项目信息",optDesc = "删除项目信息")
@GetMapping("/deleteById")
public HttpResult deleteProInfo(@RequestParam String id) {
projectInfoService.delete(id);
return HttpResult.ok();
}
}

70
user-service/src/main/java/com/mh/user/controller/ScreenController.java

@ -0,0 +1,70 @@
package com.mh.user.controller;
import com.alibaba.fastjson2.JSONObject;
import com.mh.common.http.HttpResult;
import com.mh.user.dto.ScreenRequestParamDTO;
import com.mh.user.service.ScreenService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 大屏接口类
* @date 2024-09-24 11:40:15
*/
@RestController
@RequestMapping("/screen")
public class ScreenController {
@Resource
private ScreenService screenService;
/**
* 能耗数据
* @return
*/
@PostMapping("/energyData")
public HttpResult energyData(@RequestBody ScreenRequestParamDTO screenRequestParamDTO) {
return HttpResult.ok(screenService.energyData(screenRequestParamDTO));
}
/**
* 节能量概况
* @return
*/
@PostMapping("/savingEnergyData")
public HttpResult savingEnergy(@RequestBody ScreenRequestParamDTO screenRequestParamDTO) {
return HttpResult.ok(screenService.savingEnergy(screenRequestParamDTO));
}
/**
* 节能量同比
* @return
*/
@PostMapping("/savingYoyEnergyData")
public HttpResult savingYoyEnergyData(@RequestBody ScreenRequestParamDTO screenRequestParamDTO) {
return HttpResult.ok(screenService.savingYoyEnergyData(screenRequestParamDTO));
}
/**
* 故障详情
* @return
*/
@PostMapping("/faultList")
public HttpResult faultList() {
return HttpResult.ok(screenService.faultList());
}
/**
* 项目坐标数据
* @return
*/
@PostMapping("/projectData")
public HttpResult projectData() {
return HttpResult.ok(screenService.projectData());
}
}

4
user-service/src/main/java/com/mh/user/controller/SerialPortController.java

@ -46,13 +46,13 @@ public class SerialPortController {
deviceCodeParam.setBaudRate(deviceInstallEntity.getBaudRate());
deviceCodeParam.setParity(deviceInstallEntity.getParity());
deviceCodeParam.setDataValue(serialPortModel.getDataValue());//传入相关参数值
deviceCodeParam.setProjectID(buildingId);
deviceCodeParam.setProjectId(buildingId);
String brand=deviceInstallEntity.getBrand();//品牌
deviceCodeParam.setBrand(brand);
ControlSetEntity controlData=new ControlSetEntity();
//设置设备实体对象
controlData.setBuildingId(deviceInstallEntity.getProjectID());
controlData.setBuildingId(deviceInstallEntity.getProjectId());
if (deviceType==null || deviceType.equals("") || deviceType.equals("热泵")){
if (param==null || param.equals("") || param.equals("温度设定")){

6
user-service/src/main/java/com/mh/user/controller/StrategyInfoController.java

@ -20,9 +20,9 @@ public class StrategyInfoController {
@SysLogger(value="节能策略查询")
@RequestMapping("query")
public HttpResult queryStrategyInfo(@RequestParam(value = "systemID",required = false) String systemID,
@RequestParam(value = "projectID",required = false) String projectID){
List<StrategyInfoEntity> list=strategyInfoService.queryStrategyInfo(systemID,projectID);
public HttpResult queryStrategyInfo(@RequestParam(value = "systemId",required = false) String systemID,
@RequestParam(value = "projectId",required = false) String projectId){
List<StrategyInfoEntity> list=strategyInfoService.queryStrategyInfo(systemID,projectId);
return HttpResult.ok(list);
}
}

66
user-service/src/main/java/com/mh/user/controller/SysDictController.java

@ -0,0 +1,66 @@
package com.mh.user.controller;
import com.mh.common.http.HttpResult;
import com.mh.common.page.PageRequest;
import com.mh.common.page.PageResult;
import com.mh.user.annotation.SysLogger;
import com.mh.user.model.SysDict;
import com.mh.user.service.SysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 系统字典管理
* @date 2024-08-23 10:59:09
*/
@RestController
@RequestMapping("/dict")
public class SysDictController {
@Autowired
private SysDictService sysDictService;
@SysLogger(value="系统字典管理",optDesc = "查询系统字典管理")
@PostMapping("/findByPage")
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) {
return sysDictService.findPage(pageRequest);
}
@SysLogger(value="系统字典管理",optDesc = "编辑系统字典管理")
@PostMapping("/update")
public HttpResult update(SysDict entity) {
sysDictService.updateByPrimaryKey(entity);
return HttpResult.ok();
}
@SysLogger(value="系统字典管理",optDesc = "根据项目id查询对应信息")
@GetMapping("/findById")
public HttpResult findById(@RequestParam("id") Long id) {
SysDict entity = sysDictService.findById(id);
return HttpResult.ok(entity);
}
@SysLogger(value="系统字典管理",optDesc = "添加系统字典管理")
@PostMapping("/save")
public HttpResult save(SysDict entity) {
sysDictService.save(entity);
return HttpResult.ok();
}
@SysLogger(value="系统字典管理",optDesc = "删除系统字典管理")
@GetMapping("/deleteById")
public HttpResult delete(@RequestParam Long id) {
sysDictService.deleteByPrimaryKey(id);
return HttpResult.ok();
}
@SysLogger(value="系统字典管理",optDesc = "根据设备类型查询系统字典管理")
@GetMapping("/findByType")
public HttpResult findByType(@RequestParam String type) {
return HttpResult.ok(sysDictService.findByType(type));
}
}

6
user-service/src/main/java/com/mh/user/controller/SysLoginController.java

@ -12,15 +12,10 @@ import javax.servlet.http.HttpServletResponse;
import com.mh.common.http.HttpResult;
import com.mh.common.utils.IOUtils;
import com.mh.user.annotation.SysLogger;
import com.mh.user.dynamic.datasource.DataSourceContextHolder;
import com.mh.user.dynamic.datasource.DataSourceObject;
import com.mh.user.entity.DBEntity;
import com.mh.user.model.SysRole;
import com.mh.user.model.SysUser;
import com.mh.user.security.JwtAuthenticatioToken;
import com.mh.user.service.SysRoleService;
import com.mh.user.service.SysUserService;
import com.mh.user.utils.AESUtil;
import com.mh.user.utils.PasswordUtils;
import com.mh.user.utils.SecurityUtils;
import com.mh.user.vo.LoginBean;
@ -93,6 +88,7 @@ public class SysLoginController {
}
// 系统登录认证
JwtAuthenticatioToken token = SecurityUtils.login(request, username, password, authenticationManager);
sysUserService.updateLoginTime(user.getId());
return HttpResult.ok(token);
}
}

8
user-service/src/main/java/com/mh/user/controller/SysMenuController.java

@ -39,12 +39,12 @@ public class SysMenuController {
//查询菜单树,用户ID和用户名为空则查询全部,获取菜单类型,0:获取所有菜单,包含按钮,1:获取所有菜单,不包含按钮
@GetMapping(value="/findNavTree")
public HttpResult findNavTree(@RequestParam String systemID,@RequestParam String userName) {
return HttpResult.ok(sysMenuService.findTree(systemID,userName, 0));
public HttpResult findNavTree(@RequestParam String systemId,@RequestParam String userName) {
return HttpResult.ok(sysMenuService.findTree(systemId,userName, 0));
}
@GetMapping(value="/findMenuTree")
public HttpResult findMenuTree(@RequestParam String systemID) {
return HttpResult.ok(sysMenuService.findTree(systemID,"", 0));
public HttpResult findMenuTree(@RequestParam String systemId) {
return HttpResult.ok(sysMenuService.findTree(systemId,"", 0));
}
}

4
user-service/src/main/java/com/mh/user/controller/SysUserController.java

@ -109,8 +109,8 @@ public class SysUserController {
@GetMapping(value="/findPermissions")
public HttpResult findPermissions(@RequestParam String systemID,@RequestParam String name) {
return HttpResult.ok(sysUserService.findPermissions(systemID,name));
public HttpResult findPermissions(@RequestParam String systemId,@RequestParam String name) {
return HttpResult.ok(sysUserService.findPermissions(systemId,name));
}
@GetMapping(value="/findUserRoles")

11
user-service/src/main/java/com/mh/user/controller/TestController.java

@ -1,27 +1,18 @@
package com.mh.user.controller;
import com.mh.user.constants.Constant;
import com.mh.user.dynamic.datasource.DataSourceContextHolder;
import com.mh.user.dynamic.datasource.DataSourceObject;
import com.mh.user.entity.DBEntity;
import com.mh.user.entity.DeviceCodeParamEntity;
import com.mh.user.manage.QuartzManager;
import com.mh.user.service.SysUserService;
import com.mh.user.utils.AESUtil;
import com.mh.user.utils.AnalysisReceiveOrder485;
import com.mh.user.utils.ExchangeStringUtil;
import com.mh.user.utils.GetReadOrder485;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
@RestController
public class TestController {
@ -78,7 +69,7 @@ public class TestController {
deviceCodeParamEntity.setRegisterAddr("34");
deviceCodeParamEntity.setRegisterName("累积量");
deviceCodeParamEntity.setGrade(1);
deviceCodeParamEntity.setProjectID("3");
deviceCodeParamEntity.setProjectId("3");
analysis.analysisCloudOrder485("5A0304AEF600D911B6",deviceCodeParamEntity);
// analysis.analysisWtMeterOrder485("FEFEFE6810398710810000008116901F00006502002C006502002C0000000000000000FF3416","","");

64
user-service/src/main/java/com/mh/user/dto/ScreenRequestParamDTO.java

@ -0,0 +1,64 @@
package com.mh.user.dto;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 大屏请求参数
* @date 2024-09-24 14:12:01
*/
public class ScreenRequestParamDTO {
/**
* 查询类型now:当前数据, day:日数据, week:周数据, month:月数据, year:年数据
*/
private String timeType;
private String startTime;
private String endTime;
private String projectId;
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getTimeType() {
return timeType;
}
public void setTimeType(String timeType) {
this.timeType = timeType;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
@Override
public String toString() {
return "ScreenRequestParamDTO{" +
"timeType='" + timeType + '\'' +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
", projectId='" + projectId + '\'' +
'}';
}
}

154
user-service/src/main/java/com/mh/user/dynamic/config/DataSourceConfig.java

@ -1,77 +1,77 @@
package com.mh.user.dynamic.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.mh.user.dynamic.datasource.DynamicDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
/**
* @author chison
* @date 2020-04-02 09:39
* @Description
*/
@Configuration
@MapperScan("com.mh.*.mapper") // 扫描DAO
public class DataSourceConfig {
@Value("${spring.datasource.druid.url}")
private String defaultDBUrl;
@Value("${spring.datasource.druid.username}")
private String defaultDBUser;
@Value("${spring.datasource.druid.password}")
private String defaultDBPassword;
@Value("${spring.datasource.druid.driver-class-name}")
private String defaultDBDreiverName;
@Bean
public DynamicDataSource dynamicDataSource() {
DynamicDataSource dynamicDataSource = DynamicDataSource.getInstance();
DruidDataSource defaultDataSource = new DruidDataSource();
defaultDataSource.setUrl(defaultDBUrl);
defaultDataSource.setUsername(defaultDBUser);
defaultDataSource.setPassword(defaultDBPassword);
defaultDataSource.setDriverClassName(defaultDBDreiverName);
Map<Object,Object> map = new HashMap<>();
map.put("default", defaultDataSource);
dynamicDataSource.setTargetDataSources(map);
dynamicDataSource.setDefaultTargetDataSource(defaultDataSource);
return dynamicDataSource;
}
@Bean
public SqlSessionFactory sqlSessionFactory(
@Qualifier("dynamicDataSource") DataSource dynamicDataSource)
throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dynamicDataSource);
bean.setTypeAliasesPackage("com.mh.*.model"); // 扫描Model
bean.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources("classpath*:**/sqlmapper/*.xml"));
return bean.getObject();
}
@Bean(name = "sqlSessionTemplate")
public SqlSessionTemplate sqlSessionTemplate(
@Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory)
throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
}
//package com.mh.user.dynamic.config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.mh.user.dynamic.datasource.DynamicDataSource;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//
//import javax.sql.DataSource;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @author chison
// * @date 2020-04-02 09:39
// * @Description
// */
//@Configuration
//@MapperScan("com.mh.*.mapper") // 扫描DAO
//public class DataSourceConfig {
//
// @Value("${spring.datasource.druid.url}")
// private String defaultDBUrl;
// @Value("${spring.datasource.druid.username}")
// private String defaultDBUser;
// @Value("${spring.datasource.druid.password}")
// private String defaultDBPassword;
// @Value("${spring.datasource.druid.driver-class-name}")
// private String defaultDBDreiverName;
//
//
// @Bean
// public DynamicDataSource dynamicDataSource() {
// DynamicDataSource dynamicDataSource = DynamicDataSource.getInstance();
//
// DruidDataSource defaultDataSource = new DruidDataSource();
// defaultDataSource.setUrl(defaultDBUrl);
// defaultDataSource.setUsername(defaultDBUser);
// defaultDataSource.setPassword(defaultDBPassword);
// defaultDataSource.setDriverClassName(defaultDBDreiverName);
//
// Map<Object,Object> map = new HashMap<>();
// map.put("default", defaultDataSource);
// dynamicDataSource.setTargetDataSources(map);
// dynamicDataSource.setDefaultTargetDataSource(defaultDataSource);
//
// return dynamicDataSource;
// }
//
// @Bean
// public SqlSessionFactory sqlSessionFactory(
// @Qualifier("dynamicDataSource") DataSource dynamicDataSource)
// throws Exception {
// SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
// bean.setDataSource(dynamicDataSource);
// bean.setTypeAliasesPackage("com.mh.*.model"); // 扫描Model
//
// bean.setMapperLocations(new PathMatchingResourcePatternResolver()
// .getResources("classpath*:**/sqlmapper/*.xml"));
// return bean.getObject();
//
// }
//
// @Bean(name = "sqlSessionTemplate")
// public SqlSessionTemplate sqlSessionTemplate(
// @Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory)
// throws Exception {
// return new SqlSessionTemplate(sqlSessionFactory);
// }
//
//}

56
user-service/src/main/java/com/mh/user/dynamic/config/MyBatisMapperScannerConfig.java

@ -1,28 +1,28 @@
package com.mh.user.dynamic.config;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import tk.mybatis.spring.mapper.MapperScannerConfigurer;
import java.util.Properties;
/**
* @author chison
* @date 2020-04-02 09:40
* @Description
*/
@EnableAutoConfiguration
public class MyBatisMapperScannerConfig {
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
mapperScannerConfigurer.setBasePackage("com.mh.user.mapper");
Properties properties = new Properties();
properties.setProperty("notEmpty", "false");
properties.setProperty("IDENTITY", "MYSQL");
mapperScannerConfigurer.setProperties(properties);
return mapperScannerConfigurer;
}
}
//package com.mh.user.dynamic.config;
//
//import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
//import org.springframework.context.annotation.Bean;
//import tk.mybatis.spring.mapper.MapperScannerConfigurer;
//
//import java.util.Properties;
//
///**
// * @author chison
// * @date 2020-04-02 09:40
// * @Description
// */
//@EnableAutoConfiguration
//public class MyBatisMapperScannerConfig {
// @Bean
// public MapperScannerConfigurer mapperScannerConfigurer() {
// MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
// mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
// mapperScannerConfigurer.setBasePackage("com.mh.user.mapper");
// Properties properties = new Properties();
// properties.setProperty("notEmpty", "false");
// properties.setProperty("IDENTITY", "MYSQL");
// mapperScannerConfigurer.setProperties(properties);
// return mapperScannerConfigurer;
// }
//
//}

142
user-service/src/main/java/com/mh/user/dynamic/datasource/DataSourceObject.java

@ -1,71 +1,71 @@
package com.mh.user.dynamic.datasource;
import com.alibaba.druid.pool.DruidDataSource;
import com.mh.user.entity.DBEntity;
import java.util.HashMap;
import java.util.Map;
/**
* @author chison
* @date 2020-04-02 09:40
* @Description
*/
public class DataSourceObject {
private Long MaxWait=6000L;
private Integer maxActive=10;
private Long timeBetweenEvictionRunsMillis=6000L;
/**
* 切换sqlserver数据库并动态赋值
* @param dbInfo
* @param SourceName
*/
public void SwitchMySQLDataSource(DBEntity dbInfo, String SourceName) {
System.out.println("mysql进入数据源切换");
System.out.println("MaxWait:"+MaxWait);
DruidDataSource dynamicDataSource = new DruidDataSource();
dynamicDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dynamicDataSource.setUrl("jdbc:mysql://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+"/"+dbInfo.getDB_Names()+"?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&autoReconnect=true");
dynamicDataSource.setUsername(dbInfo.getDB_UserName());
dynamicDataSource.setPassword(dbInfo.getDB_Pwd());
dynamicDataSource.setMaxWait(MaxWait);
dynamicDataSource.setMaxActive(maxActive);
dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
DynamicDataSource dataSource = DynamicDataSource.getInstance();
Map<Object, Object> map=new HashMap<Object, Object>();
map.put(SourceName, dynamicDataSource);
dataSource.setTargetDataSources(map);
System.out.println(dynamicDataSource.getUrl());
System.out.println(SourceName);
}
/**
* 第二个sqlserver数据库
* @param dbInfo
* @param SourceName
*/
public void SwitchSQLServerDataSource(DBEntity dbInfo,String SourceName) {
System.out.println("进入数据源切换");
System.out.println("MaxWait:"+MaxWait);
DruidDataSource dynamicDataSource = new DruidDataSource();
dynamicDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
dynamicDataSource.setUrl("jdbc:sqlserver://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+";Databasename="+dbInfo.getDB_Names());
dynamicDataSource.setUsername(dbInfo.getDB_UserName());
dynamicDataSource.setPassword(dbInfo.getDB_Pwd());
System.out.println(dbInfo.getDB_UserName());
System.out.println(dbInfo.getDB_Pwd());
dynamicDataSource.setMaxWait(MaxWait);
dynamicDataSource.setMaxActive(maxActive);
dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
DynamicDataSource dataSource = DynamicDataSource.getInstance();
Map<Object, Object> map=new HashMap<Object, Object>();
map.put(SourceName, dynamicDataSource);
dataSource.setTargetDataSources(map);
System.out.println(dynamicDataSource.getUrl());
System.out.println(SourceName);
}
}
//package com.mh.user.dynamic.datasource;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.mh.user.entity.DBEntity;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @author chison
// * @date 2020-04-02 09:40
// * @Description
// */
//public class DataSourceObject {
//
// private Long MaxWait=6000L;
// private Integer maxActive=10;
// private Long timeBetweenEvictionRunsMillis=6000L;
//
// /**
// * 切换sqlserver数据库,并动态赋值
// * @param dbInfo
// * @param SourceName
// */
// public void SwitchMySQLDataSource(DBEntity dbInfo, String SourceName) {
// System.out.println("mysql进入数据源切换");
// System.out.println("MaxWait:"+MaxWait);
// DruidDataSource dynamicDataSource = new DruidDataSource();
// dynamicDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
// dynamicDataSource.setUrl("jdbc:mysql://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+"/"+dbInfo.getDB_Names()+"?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&autoReconnect=true");
// dynamicDataSource.setUsername(dbInfo.getDB_UserName());
// dynamicDataSource.setPassword(dbInfo.getDB_Pwd());
// dynamicDataSource.setMaxWait(MaxWait);
// dynamicDataSource.setMaxActive(maxActive);
// dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//
// DynamicDataSource dataSource = DynamicDataSource.getInstance();
// Map<Object, Object> map=new HashMap<Object, Object>();
// map.put(SourceName, dynamicDataSource);
// dataSource.setTargetDataSources(map);
// System.out.println(dynamicDataSource.getUrl());
// System.out.println(SourceName);
// }
// /**
// * 第二个sqlserver数据库
// * @param dbInfo
// * @param SourceName
// */
// public void SwitchSQLServerDataSource(DBEntity dbInfo,String SourceName) {
// System.out.println("进入数据源切换");
// System.out.println("MaxWait:"+MaxWait);
// DruidDataSource dynamicDataSource = new DruidDataSource();
// dynamicDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// dynamicDataSource.setUrl("jdbc:sqlserver://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+";Databasename="+dbInfo.getDB_Names());
// dynamicDataSource.setUsername(dbInfo.getDB_UserName());
// dynamicDataSource.setPassword(dbInfo.getDB_Pwd());
// System.out.println(dbInfo.getDB_UserName());
// System.out.println(dbInfo.getDB_Pwd());
// dynamicDataSource.setMaxWait(MaxWait);
// dynamicDataSource.setMaxActive(maxActive);
// dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//
// DynamicDataSource dataSource = DynamicDataSource.getInstance();
// Map<Object, Object> map=new HashMap<Object, Object>();
// map.put(SourceName, dynamicDataSource);
// dataSource.setTargetDataSources(map);
//
// System.out.println(dynamicDataSource.getUrl());
// System.out.println(SourceName);
// }
//}

3
user-service/src/main/java/com/mh/user/entity/BaseEntity.java

@ -1,6 +1,8 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
@ -21,6 +23,7 @@ public class BaseEntity implements Serializable {
static final long serialVersionUID = 42L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")

34
user-service/src/main/java/com/mh/user/entity/BaseResultEntity.java

@ -0,0 +1,34 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 数据结果集基本类
* @date 2024-07-10 16:49:24
*/
@Data
public class BaseResultEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String deviceAddr;
private String deviceType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date curDate;
private String curValue;
private String funCode;
private String registerAddr;
private String registerName;
private int grade;
private String projectId;
private String projectName;
}

23
user-service/src/main/java/com/mh/user/entity/DataResultChEntity.java

@ -1,24 +1,7 @@
package com.mh.user.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@Data
public class DataResultChEntity {
private Long id;
private String deviceAddr;
private String deviceType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date curDate;
// private String curDate;
private String curValue;
private String funCode;
private String registerAddr;
private String registerName;
private int grade;
private String projectID;
private String projectName;
@TableName("data_result_ch")
public class DataResultChEntity extends BaseResultEntity {
}

7
user-service/src/main/java/com/mh/user/entity/DataResultChillerEntity.java

@ -0,0 +1,7 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
@TableName("data_result_ch")
public class DataResultChillerEntity extends BaseResultEntity {
}

32
user-service/src/main/java/com/mh/user/entity/DataResultClBakEntity.java

@ -0,0 +1,32 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@TableName("data_result_cl")
public class DataResultClBakEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String deviceAddr;
private String deviceType;
private Date curDate;
private BigDecimal curValue;
private BigDecimal lastValue;
private Date lastDate;
private BigDecimal ratio;
private BigDecimal calcValue;
private int grade;
private String havedUpdate;
private String registerAddr;
private String registerName;
private String projectName;
private String projectId;
}

21
user-service/src/main/java/com/mh/user/entity/DataResultClEntity.java

@ -1,23 +1,32 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@TableName("data_result_cl")
public class DataResultClEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String deviceAddr;
private String deviceType;
private double lastValue;
private Date lastDate;
private double curValue;
private Date curDate;
private double ratio;
private double calcValue;
private BigDecimal curValue;
private BigDecimal lastValue;
private Date lastDate;
private BigDecimal ratio;
private BigDecimal calcValue;
private int grade;
private String havedUpdate;
private String registerAddr;
private String registerName;
private String projectName;
private String projectID;
private String projectId;
}

22
user-service/src/main/java/com/mh/user/entity/DataResultEntity.java

@ -1,22 +1,34 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@TableName("data_result")
@Data
public class DataResultEntity {
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String deviceAddr;
private String deviceType;
private double lastValue;
private BigDecimal lastValue;
private Date lastDate;
private double curValue;
private BigDecimal curValue;
private Date curDate;
private double ratio;
private double calcValue;
private BigDecimal ratio;
private BigDecimal calcValue;
private int grade;
private String havedUpdate;
private String projectName;
private String projectID;
private String projectId;
private String registerName;
private String registerAddr;
}

7
user-service/src/main/java/com/mh/user/entity/DataResultFifteenMiEntity.java

@ -0,0 +1,7 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
@TableName("data_result_fifteen_mi")
public class DataResultFifteenMiEntity extends BaseResultEntity {
}

7
user-service/src/main/java/com/mh/user/entity/DataResultFiveMiEntity.java

@ -0,0 +1,7 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
@TableName("data_result_five_mi")
public class DataResultFiveMiEntity extends BaseResultEntity {
}

7
user-service/src/main/java/com/mh/user/entity/DataResultNowEntity.java

@ -0,0 +1,7 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
@TableName("data_result_now")
public class DataResultNowEntity extends BaseResultEntity {
}

7
user-service/src/main/java/com/mh/user/entity/DataResultOneMiEntity.java

@ -0,0 +1,7 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
@TableName("data_result_one_mi")
public class DataResultOneMiEntity extends BaseResultEntity {
}

130
user-service/src/main/java/com/mh/user/entity/DeviceCodeEntity.java

@ -0,0 +1,130 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 设备基表安装信息
* @date 2024-07-11 13:57:36
*/
@Data
@TableName("device_code")
public class DeviceCodeEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 通讯编号
*/
private String deviceAddr;
/**
* 设备类型
*/
private String deviceType;
/**
* 串口
*/
private String dataCom;
/**
* 端口
*/
private String dataPort;
/**
* 设备规格
*/
private String standard;
/**
* 安装位置
*/
private String installPosition;
/**
* 初始值
*/
private BigDecimal initValue;
/**
* 倍率
*/
private BigDecimal ratio;
/**
* 是否时总表
*/
private String isTotal;
/**
* 是否停用
*/
private String isForbid;
/**
* 停用时间
*/
private Date forbidDate;
/**
* 上次抄表读数
*/
private BigDecimal lastValue;
/**
* 上次抄表时间
*/
private Date lastDate;
/**
* 级别
*/
private int grade;
/**
* 波特率
*/
private int baudRate;
/**
* 项目ID
*/
private String projectId;
/**
* 设备名称
*/
private String deviceName;
/**
* 品牌
*/
private String brand;
/**
* 安装时间
*/
private Date installDate;
/**
* 奇偶校验
*/
private String parity;
/**
* 备注
*/
private String remarks;
}

193
user-service/src/main/java/com/mh/user/entity/DeviceCodeParamEntity.java

@ -1,8 +1,17 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Date;
public class DeviceCodeParamEntity {
@Setter
@Getter
@ToString
@TableName("device_code_param")
public class DeviceCodeParamEntity implements Cloneable {
private Long id;
private String deviceAddr;
@ -16,145 +25,47 @@ public class DeviceCodeParamEntity {
private String funCode;
private String registerAddr;
private String registerName;
private int digit; //保留小数位
private int grade; //级别
private String dataValue; //传入值
private Date createTime;
private String projectID;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDeviceAddr() {
return deviceAddr;
}
public void setDeviceAddr(String deviceAddr) {
this.deviceAddr = deviceAddr;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getStrData() {
return strData;
}
public void setStrData(String strData) {
this.strData = strData;
}
public String getDataPort() {
return dataPort;
}
public void setDataPort(String dataPort) {
this.dataPort = dataPort;
}
public int getBaudRate() {
return baudRate;
}
public void setBaudRate(int baudRate) {
this.baudRate = baudRate;
}
public String getParity() {
return parity;
}
public void setParity(String parity) {
this.parity = parity;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getFunCode() {
return funCode;
}
public void setFunCode(String funCode) {
this.funCode = funCode;
}
public String getRegisterAddr() {
return registerAddr;
}
public void setRegisterAddr(String registerAddr) {
this.registerAddr = registerAddr;
}
public String getRegisterName() {
return registerName;
}
public void setRegisterName(String registerName) {
this.registerName = registerName;
}
public int getDigit() {
return digit;
}
public void setDigit(int digit) {
this.digit = digit;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public String getDataValue() {
return dataValue;
}
public void setDataValue(String dataValue) {
this.dataValue = dataValue;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getProjectID() {
return projectID;
}
public void setProjectID(String projectID) {
this.projectID = projectID;
private int digit; //保留小数位
private int grade; //级别
private String dataValue; //传入值
private Date createTime; // 创建时间
private String projectId; // 项目id
private Long mmId; // 设备管理ID
private int dataType; // 数据类型
private int protocolType; // 协议类型(数据字典)
/**
* 重置
*/
public void reset() {
this.deviceAddr = null;
this.deviceName = null;
this.deviceType = null;
this.strData = null;
this.dataPort = null;
this.baudRate = 0;
this.parity = null;
this.brand = null;
this.funCode = null;
this.registerAddr = null;
this.registerName = null;
this.digit = 0;
this.grade = 0;
this.dataValue = null;
this.createTime = null;
this.projectId = null;
this.mmId = null;
this.dataType = 16;
this.protocolType = 0;
}
@Override
public DeviceCodeParamEntity clone() {
try {
// TODO: copy mutable state here, so the clone can't change the internals of the original
return (DeviceCodeParamEntity) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
}

6
user-service/src/main/java/com/mh/user/entity/DeviceInfoEntity.java

@ -12,9 +12,9 @@ public class DeviceInfoEntity {
private String power; //功率
private String madeTime; //制造时间
private String flow; //流量
private String isFC; //是否变频
private String isFc; //是否变频
private String motorBrand; //机电品牌
private String projectID; //项目ID
private String systemID; //系统ID
private String projectId; //项目ID
private String systemId; //系统ID
}

15
user-service/src/main/java/com/mh/user/entity/DeviceInstallEntity.java

@ -1,6 +1,8 @@
package com.mh.user.entity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@ -14,9 +16,9 @@ public class DeviceInstallEntity {
private String dataPort;
private int baudRate;
private String parity;
private double ratio;
private double initValue;
private double lastValue;
private BigDecimal ratio;
private BigDecimal initValue;
private BigDecimal lastValue;
private Date lastDate;
private String standard;
private String isTotal;
@ -25,7 +27,10 @@ public class DeviceInstallEntity {
private String brand;
private String installPosition;
private Date installDate;
private String projectID;
private String projectId;
private String remarks;
private String registerAddr;
private String registerName;
private String funCode;
private int digit;
}

11
user-service/src/main/java/com/mh/user/entity/DeviceManageEntity.java

@ -39,6 +39,17 @@ public class DeviceManageEntity extends BaseEntity {
private String createTimes;
private String updateTimes;
/**
* 出厂编码
*/
private String factoryBarcode;
/**
* imuCode
*/
private String imuCode;
@Override
public String toString() {
return "DeviceManageEntity{" +

69
user-service/src/main/java/com/mh/user/entity/DeviceParamsEntity.java

@ -0,0 +1,69 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 设备采集参数实体类
* @date 2024-08-22 17:04:12
*/
@Setter
@Getter
@TableName("device_params")
public class DeviceParamsEntity {
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 仪表类型从字典表中拿
*/
private int mtType;
/**
* 波特率
*/
private int baudRate;
/**
* 数据位
*/
private int dataBit;
/**
* 停止位
*/
private int stopBit;
/**
* 校验位
*/
private String parity;
/**
* 备注
*/
private String remark;
@Override
public String toString() {
return "DeviceParamsEntity{" +
"id=" + id +
", mtType=" + mtType +
", baudRate=" + baudRate +
", dataBit=" + dataBit +
", stopBit=" + stopBit +
", parity=" + parity +
", remark='" + remark + '\'' +
'}';
}
}

148
user-service/src/main/java/com/mh/user/entity/DevicesManageEntity.java

@ -0,0 +1,148 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 资产设备管理
* @date 2024-08-22 16:11:30
*/
@Setter
@Getter
@TableName("devices_manage")
public class DevicesManageEntity implements Serializable {
/**
* 编号
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备品牌
*/
private String deviceBrand;
/**
* 机电品牌
*/
private String emBrand;
/**
* 额定输入功率
*/
private BigDecimal ratedInputPower;
/**
* 额定制冷量
*/
private BigDecimal ratedRefrigerationCapacity;
/**
* 额定COP
*/
private BigDecimal ratedCop;
/**
* 额定流量
*/
private BigDecimal ratedFlow;
/**
* 生产日期
*/
private String productionTime;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
/**
* 创建人
*/
private String createBy;
/**
* 是否变频
*/
private byte isFrequency;
/**
* 设备类型
*/
private long deviceType;
/**
* 备注
*/
private String remark;
/**
* 等级
*/
private Integer grade = 0;
/**
* 系统类型id
*/
private Long systemId;
/**
* 项目id
*/
private Long projectId;
private String factoryBarcode;
private String imuCode;
@Override
public String toString() {
return "DevicesManageEntity{" +
"id=" + id +
", deviceName='" + deviceName + '\'' +
", deviceBrand='" + deviceBrand + '\'' +
", emBrand='" + emBrand + '\'' +
", ratedInputPower=" + ratedInputPower +
", ratedRefrigerationCapacity=" + ratedRefrigerationCapacity +
", ratedCop=" + ratedCop +
", ratedFlow=" + ratedFlow +
", productionTime='" + productionTime + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", createBy='" + createBy + '\'' +
", isFrequency=" + isFrequency +
", deviceType=" + deviceType +
", remark='" + remark + '\'' +
", grade=" + grade +
", systemId=" + systemId +
", projectId=" + projectId +
", factoryBarcode='" + factoryBarcode + '\'' +
", imuCode='" + imuCode + '\'' +
'}';
}
}

99
user-service/src/main/java/com/mh/user/entity/EnergyDataEntity.java

@ -2,7 +2,6 @@ package com.mh.user.entity;
import lombok.Data;
@Data
public class EnergyDataEntity {
private long id;
@ -13,6 +12,102 @@ public class EnergyDataEntity {
private Double elect;
private Double cl;
private Double cop;
private String projectID;
private String projectId;
private String projectName;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getCurDate() {
return curDate;
}
public void setCurDate(String curDate) {
this.curDate = curDate;
}
public String getAmbTemp() {
return ambTemp;
}
public void setAmbTemp(String ambTemp) {
this.ambTemp = ambTemp;
}
public String getHumidity() {
return humidity;
}
public void setHumidity(String humidity) {
this.humidity = humidity;
}
public Double getWater() {
return water;
}
public void setWater(Double water) {
this.water = water;
}
public Double getElect() {
return elect;
}
public void setElect(Double elect) {
this.elect = elect;
}
public Double getCl() {
return cl;
}
public void setCl(Double cl) {
this.cl = cl;
}
public Double getCop() {
return cop;
}
public void setCop(Double cop) {
this.cop = cop;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
@Override
public String toString() {
return "EnergyDataEntity{" +
"id=" + id +
", curDate='" + curDate + '\'' +
", ambTemp='" + ambTemp + '\'' +
", humidity='" + humidity + '\'' +
", water=" + water +
", elect=" + elect +
", cl=" + cl +
", cop=" + cop +
", projectId='" + projectId + '\'' +
", projectName='" + projectName + '\'' +
'}';
}
}

2
user-service/src/main/java/com/mh/user/entity/EnergyEntity.java

@ -16,7 +16,7 @@ public class EnergyEntity {
private int checkInCount; //楼栋人数
private double perElect; //平均用电
private double perWater; //平均用水
private String projectID; //项目编号
private String projectId; //项目编号
private String projectName; //项目名称
}

2
user-service/src/main/java/com/mh/user/entity/EnergySumEntity.java

@ -7,7 +7,7 @@ public class EnergySumEntity {
private Long id; //序号
private String curDate; //日期
private String buildingId; //楼栋编号
private String projectID; //项目编号
private String projectId; //项目编号
private String useHotWater; //用水
private String electValue; //用电
private String electWater; //单耗

31
user-service/src/main/java/com/mh/user/entity/GatewayManageEntity.java

@ -1,8 +1,10 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@ -14,20 +16,25 @@ import java.util.Date;
* @updateTime 2020-05-21
* @throws
*/
@Data
@Setter
@Getter
@ToString
@TableName("gateway_manage")
public class GatewayManageEntity extends BaseEntity {
private String gatewayName; // 网关名称
private String gatewayIP; // 网关IP地址
private String gatewayAddress; // 网关安装地址
private String dataCom; // 串口号
private String createDate; // 安装时间
private String connectDate; // 最新上线连接时间
private int grade; // 标志位(连接状态) 0:正常;1:不在线;2:异常
private String internetCard; // 物联网卡号
private int operator; //0:中国移动 1:中国联通 2:中国电信
private int gatewayPort; // 端口号
private String type; // 操作类型
private String gwName; // 网关名称
private String gwIp; // 网关IP地址
private String gwAddr; // 网关安装地址
private int port; // 端口号
private int collectionLoop; // 采集周期
private Date connectTime; // 最新上线连接时间
private String internetCard; // 物联网卡号
private int operatorType; // 0:中国移动 1:中国联通 2:中国电信
private int communicationType; // 通讯类型
private String remark; // 备注
private int grade; // 标志位(连接状态) 0:正常;1:不在线;2:异常
private Long systemId; // 系统类型id
private Long projectId; // 项目类型id
}

11
user-service/src/main/java/com/mh/user/entity/MeterInfoEntity.java

@ -1,10 +1,16 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@TableName("meter_info")
@Data
public class MeterInfoEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String meterName; //表名称
private String meterType; //表类型
@ -16,6 +22,7 @@ public class MeterInfoEntity {
private String caliber; //口径
private String range; //测量范围
private String structural; //结构形式
private String projectID; //项目ID
private String systemID; //系统ID
private String projectId; //项目ID
private String systemId; //系统ID
}

235
user-service/src/main/java/com/mh/user/entity/MeterManageEntity.java

@ -0,0 +1,235 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 仪表管理
* @date 2024-08-22 16:35:19
*/
@Setter
@Getter
@TableName("meter_manage")
public class MeterManageEntity implements Serializable {
/**
* 编号
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 仪表类型
*/
private Long mtType;
/**
* 仪表名称
*/
private String mtName;
/**
* 其他名称
*/
private String otherName;
/**
* 仪表品牌
*/
private String mtBrand;
/**
* 仪表编号
*/
private String mtNum;
/**
* 仪表地址
*/
private String mtCode;
/**
* 寄存器地址
*/
private String registerAddr;
/**
* 功能码
*/
private String funcCode;
/**
* 数据标识码
*/
private String identifyCode;
/**
* 口径以及脉冲常数
*/
private String mtCaliberPulse;
/**
* 仪表范围
*/
private BigDecimal mtRange;
/**
* 仪表比例
*/
private int mtRatio;
/**
* 初始值
*/
private BigDecimal mtInitValue;
/**
* 保留位数
*/
private int digits;
/**
* 数据类型
*/
private int dataType;
/**
* 当前值
*/
private BigDecimal curValue;
/**
* 当前时间
*/
private Date curTime;
/**
* 是否是总表
*/
private byte mtIsSum;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 单位
*/
private String unit;
/**
* 排序
*/
private Long sort;
/**
* 通讯串口
*/
private String dataCom;
/**
* 设备id
*/
private Long deviceId;
/**
* 网关id
*/
private Long gatewayId;
/**
* 参数id
*/
private Long paramId;
/**
* 协议类型
*/
private int protocolType;
/**
* 备注
*/
private String remark;
/**
* 保留位
*/
private Integer grade = 0;
/**
* 系统类型id
*/
private Long systemId;
/**
* 项目id
*/
private Long projectId;
/**
* 通讯类型
*/
private Long communicationType;
/**
* 读取寄存器大小
*/
private int registerSize;
@Override
public String toString() {
return "MeterManageEntity{" +
"id=" + id +
", mtType=" + mtType +
", mtName='" + mtName + '\'' +
", otherName='" + otherName + '\'' +
", mtBrand='" + mtBrand + '\'' +
", mtNum='" + mtNum + '\'' +
", mtCode='" + mtCode + '\'' +
", registerAddr='" + registerAddr + '\'' +
", funcCode='" + funcCode + '\'' +
", identifyCode='" + identifyCode + '\'' +
", mtCaliberPulse='" + mtCaliberPulse + '\'' +
", mtRange=" + mtRange +
", mtRatio=" + mtRatio +
", mtInitValue=" + mtInitValue +
", digits=" + digits +
", dataType=" + dataType +
", curValue=" + curValue +
", curTime=" + curTime +
", mtIsSum=" + mtIsSum +
", createTime=" + createTime +
", updateTime=" + updateTime +
", unit='" + unit + '\'' +
", sort=" + sort +
", dataCom='" + dataCom + '\'' +
", deviceId=" + deviceId +
", gatewayId=" + gatewayId +
", paramId=" + paramId +
", protocolType=" + protocolType +
", remark='" + remark + '\'' +
", grade=" + grade +
", systemId=" + systemId +
", projectId=" + projectId +
", communicationType=" + communicationType +
", registerSize=" + registerSize +
'}';
}
}

192
user-service/src/main/java/com/mh/user/entity/ProjectInfoEntity.java

@ -1,18 +1,192 @@
package com.mh.user.entity;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.web.multipart.MultipartFile;
@Data
import java.math.BigDecimal;
import java.util.Date;
@TableName("project_info")
public class ProjectInfoEntity {
private String id;
private String projectName; //项目名称
private String pAddress; //地址
private int pScale;
private String pic; //图片
private String tel; //电话
private String systemID; //系统编号
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField("project_name")
private String projectName; //项目名称
@TableField("p_address")
private String pAddress; //地址
@TableField("p_scale")
private String pScale;
@TableField("pic")
private String pic; //图片地址
@TableField("pic_content")
private String picContent; // 图片内容
@TableField("tel")
private String tel; //电话
@TableField("system_id")
private String systemId; //系统编号
@TableField("remarks")
private String remarks;
/**
* 经度
*/
@TableField("longitude")
private BigDecimal longitude;
/**
* 纬度
*/
@TableField("latitude")
private BigDecimal latitude;
/**
* 创建时间
*/
@TableField("create_time")
private Date createTime;
/**
* 文件流
*/
@TableField(exist = false)
@JsonIgnore
private MultipartFile file;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getpAddress() {
return pAddress;
}
public void setpAddress(String pAddress) {
this.pAddress = pAddress;
}
public String getpScale() {
return pScale;
}
public void setpScale(String pScale) {
this.pScale = pScale;
}
public String getPic() {
return pic;
}
public void setPic(String pic) {
this.pic = pic;
}
public String getPicContent() {
return picContent;
}
public void setPicContent(String picContent) {
this.picContent = picContent;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getSystemId() {
return systemId;
}
public void setSystemId(String systemId) {
this.systemId = systemId;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public BigDecimal getLongitude() {
return longitude;
}
public void setLongitude(BigDecimal longitude) {
this.longitude = longitude;
}
public BigDecimal getLatitude() {
return latitude;
}
public void setLatitude(BigDecimal latitude) {
this.latitude = latitude;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public MultipartFile getFile() {
return file;
}
public void setFile(MultipartFile file) {
this.file = file;
}
@Override
public String toString() {
return "ProjectInfoEntity{" +
"id=" + id +
", projectName='" + projectName + '\'' +
", pAddress='" + pAddress + '\'' +
", pScale=" + pScale +
", pic='" + pic + '\'' +
", picContent='" + picContent + '\'' +
", tel='" + tel + '\'' +
", systemId='" + systemId + '\'' +
", remarks='" + remarks + '\'' +
", longitude=" + longitude +
", latitude=" + latitude +
", createTime=" + createTime +
", file=" + file +
'}';
}
}

2
user-service/src/main/java/com/mh/user/entity/RegisterAddrEntity.java

@ -1,7 +1,9 @@
package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@TableName("register_addr")
@Data
public class RegisterAddrEntity {

71
user-service/src/main/java/com/mh/user/entity/StrategyInfoEntity.java

@ -1,14 +1,77 @@
package com.mh.user.entity;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@Data
@TableName("strategy_info")
public class StrategyInfoEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String dataAnalysis;
private String operationOpt;
private String controlOpt;
private String projectID;
private String systemID;
private String projectId;
private String systemId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDataAnalysis() {
return dataAnalysis;
}
public void setDataAnalysis(String dataAnalysis) {
this.dataAnalysis = dataAnalysis;
}
public String getOperationOpt() {
return operationOpt;
}
public void setOperationOpt(String operationOpt) {
this.operationOpt = operationOpt;
}
public String getControlOpt() {
return controlOpt;
}
public void setControlOpt(String controlOpt) {
this.controlOpt = controlOpt;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getSystemId() {
return systemId;
}
public void setSystemId(String systemId) {
this.systemId = systemId;
}
@Override
public String toString() {
return "StrategyInfoEntity{" +
"id=" + id +
", dataAnalysis='" + dataAnalysis + '\'' +
", operationOpt='" + operationOpt + '\'' +
", controlOpt='" + controlOpt + '\'' +
", projectId='" + projectId + '\'' +
", systemId='" + systemId + '\'' +
'}';
}
}

2
user-service/src/main/java/com/mh/user/entity/chart/ChartEntity.java

@ -1,6 +1,6 @@
package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

2
user-service/src/main/java/com/mh/user/entity/chart/Feature.java

@ -1,6 +1,6 @@
package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

2
user-service/src/main/java/com/mh/user/entity/chart/Legend.java

@ -1,6 +1,6 @@
package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

2
user-service/src/main/java/com/mh/user/entity/chart/Series.java

@ -1,6 +1,6 @@
package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

2
user-service/src/main/java/com/mh/user/entity/chart/Title.java

@ -1,6 +1,6 @@
package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

2
user-service/src/main/java/com/mh/user/entity/chart/YAxis.java

@ -1,6 +1,6 @@
package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter;
import lombok.Setter;

49
user-service/src/main/java/com/mh/user/factory/CJ188Protocol.java

@ -0,0 +1,49 @@
package com.mh.user.factory;
import com.mh.user.entity.DeviceCodeParamEntity;
import com.mh.user.entity.MeterManageEntity;
import com.mh.user.strategy.ProtocolStrategy;
import lombok.extern.slf4j.Slf4j;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 水表标准协议
* @date 2024-09-12 14:04:01
*/
@Slf4j
public class CJ188Protocol implements Protocol {
private ProtocolStrategy cj188ProtocolStrategy;
private static class SingletonHolder{
private static final CJ188Protocol INSTANCE = new CJ188Protocol();
}
private CJ188Protocol(){
// 防止外部直接实例化
}
public static CJ188Protocol getInstance(){
return SingletonHolder.INSTANCE;
}
@Override
public void setStrategy(ProtocolStrategy protocolStrategy) {
this.cj188ProtocolStrategy = protocolStrategy;
}
@Override
public String createOrder(MeterManageEntity meterManageEntity) {
log.info("水表标准协议:工厂创建报文");
return cj188ProtocolStrategy.createOrder(meterManageEntity);
}
@Override
public String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData) {
log.info("水表标准协议:工厂解析报文");
return cj188ProtocolStrategy.analysisReceiveData(deviceCodeParamEntity, receiveData);
}
}

49
user-service/src/main/java/com/mh/user/factory/EleProtocol.java

@ -0,0 +1,49 @@
package com.mh.user.factory;
import com.mh.user.entity.DeviceCodeParamEntity;
import com.mh.user.entity.MeterManageEntity;
import com.mh.user.strategy.ProtocolStrategy;
import lombok.extern.slf4j.Slf4j;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 水表标准协议
* @date 2024-09-12 14:04:01
*/
@Slf4j
public class EleProtocol implements Protocol {
private ProtocolStrategy eleProtocolStrategy;
private static class SingletonHolder{
private static final EleProtocol INSTANCE = new EleProtocol();
}
private EleProtocol(){
// 防止外部直接实例化
}
public static EleProtocol getInstance(){
return SingletonHolder.INSTANCE;
}
@Override
public void setStrategy(ProtocolStrategy protocolStrategy) {
this.eleProtocolStrategy = protocolStrategy;
}
@Override
public String createOrder(MeterManageEntity meterManageEntity) {
log.info("电表97/07规约协议:工厂创建报文");
return eleProtocolStrategy.createOrder(meterManageEntity);
}
@Override
public String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData) {
log.info("电表97/07规约协议:工厂解析报文");
return eleProtocolStrategy.analysisReceiveData(deviceCodeParamEntity, receiveData);
}
}

48
user-service/src/main/java/com/mh/user/factory/ModbusProtocol.java

@ -0,0 +1,48 @@
package com.mh.user.factory;
import com.mh.user.entity.DeviceCodeParamEntity;
import com.mh.user.entity.MeterManageEntity;
import com.mh.user.strategy.ProtocolStrategy;
import lombok.extern.slf4j.Slf4j;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description modbus协议
* @date 2024-09-12 16:38:44
*/
@Slf4j
public class ModbusProtocol implements Protocol {
private ProtocolStrategy modbusProtocolStrategy;
private static class SingletonHolder{
private static final ModbusProtocol INSTANCE = new ModbusProtocol();
}
private ModbusProtocol(){
// 防止外部直接实例化
}
public static ModbusProtocol getInstance(){
return ModbusProtocol.SingletonHolder.INSTANCE;
}
@Override
public void setStrategy(ProtocolStrategy protocolStrategy) {
this.modbusProtocolStrategy = protocolStrategy;
}
@Override
public String createOrder(MeterManageEntity meterManageEntity) {
log.info("modbus标准协议:工厂创建报文");
return modbusProtocolStrategy.createOrder(meterManageEntity);
}
@Override
public String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData) {
log.info("modbus标准协议:工厂解析报文");
return modbusProtocolStrategy.analysisReceiveData(deviceCodeParamEntity, receiveData);
}
}

37
user-service/src/main/java/com/mh/user/factory/Protocol.java

@ -0,0 +1,37 @@
package com.mh.user.factory;
import com.mh.user.entity.DeviceCodeParamEntity;
import com.mh.user.entity.MeterManageEntity;
import com.mh.user.strategy.ProtocolStrategy;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 根据协议实现对设备的生产和解析
* @date 2024-09-12 11:17:20
*/
public interface Protocol {
/**
* 设置协议策略
* @param protocolStrategy
*/
void setStrategy(ProtocolStrategy protocolStrategy);
/**
* 创建指令
* @param meterManageEntity
* @return
*/
String createOrder(MeterManageEntity meterManageEntity);
/**
* 解析指令
* @param deviceCodeParamEntity
* @param receiveData
* @return
*/
String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData);
}

17
user-service/src/main/java/com/mh/user/factory/ProtocolFactory.java

@ -0,0 +1,17 @@
package com.mh.user.factory;
import com.mh.user.constants.ProtocolEnum;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 协议工厂
* @date 2024-09-12 10:29:51
*/
public class ProtocolFactory {
public static Protocol matchProtocol(String protocolType) {
return ProtocolEnum.getProtocol(protocolType);
}
}

373
user-service/src/main/java/com/mh/user/job/CollectionLoopRunner.java

@ -1,26 +1,22 @@
package com.mh.user.job;
import com.mh.user.entity.AddCronJobReq;
import com.mh.user.entity.ProjectInfoEntity;
import com.mh.user.manage.QuartzManager;
import com.mh.common.page.PageRequest;
import com.mh.user.entity.*;
import com.mh.user.factory.Protocol;
import com.mh.user.factory.ProtocolFactory;
import com.mh.user.netty.EchoServer;
import com.mh.user.serialport.SerialPortListener;
import com.mh.user.serialport.SerialPortUtil;
import com.mh.user.service.ProjectInfoService;
import com.mh.user.service.*;
import com.mh.user.strategy.ProtocolStrategy;
import com.mh.user.strategy.ProtocolStrategyFactory;
import com.mh.user.utils.GetReadOrder485;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author ljf
@ -29,241 +25,136 @@ import java.util.Map;
* @updateTime 2020-05-15
* @throws
*/
@Slf4j
@Component
public class CollectionLoopRunner implements ApplicationRunner {
private static final Logger log = Logger.getLogger(CollectionLoopRunner.class);
public static SerialPort serialPort = null;
public static SerialPort serialPort = null;
@Autowired
ProjectInfoService projectInfoService;
@Autowired
ProjectInfoService projectInfoService;
@Autowired
private MeterManageService meterManageService;
@Override
public void run(ApplicationArguments args) throws Exception {
GetReadOrder485 getReadOrder485=new GetReadOrder485();
List<ProjectInfoEntity> projectInfoEntities = projectInfoService.queryProjectInfo("1");
if (null != projectInfoEntities && !projectInfoEntities.isEmpty()) {
for (ProjectInfoEntity projectInfoEntity : projectInfoEntities) {
getReadOrder485.createOrderParam(projectInfoEntity.getId()); //生成采集参数,1新珠江(6000),2广合科技(6001),3广大科技(6002),6珠江国际,7保利山庄,8东莞迎宾馆
}
}
try{
new EchoServer(6001).start(); // 调用服务器的start方法,网关作为客户端,6006新珠江,6001广合科技,6077广大科技 6028(6006)珠江国际,5000保利山庄,6004东莞迎宾馆
}catch (Exception e){
log.info("6001端口已占用!");
@Autowired
private DeviceCodeParamService deviceCodeParamService;
@Autowired
private GatewayManageService gatewayManageService;
@Autowired
private DeviceParamsService deviceParamsService;
@Autowired
private SysDictService sysDictService;
@Override
public void run(ApplicationArguments args) throws Exception {
List<ProjectInfoEntity> projectInfoEntities = projectInfoService.queryProjectInfo("1");
if (null != projectInfoEntities && !projectInfoEntities.isEmpty()) {
for (ProjectInfoEntity projectInfoEntity : projectInfoEntities) {
// getReadOrder485.createOrderParam(String.valueOf(projectInfoEntity.getId())); //生成采集参数,1新珠江(6000),2广合科技(6001),3广大科技(6002),6珠江国际,7保利山庄,8东莞迎宾馆
createOrderParamByStrategy(projectInfoEntity.getSystemId(), String.valueOf(projectInfoEntity.getId()));
}
}
try {
new EchoServer(6001).start(); // 调用服务器的start方法,网关作为客户端,6006新珠江,6001广合科技,6077广大科技 6028(6006)珠江国际,5000保利山庄,6004东莞迎宾馆
} catch (Exception e) {
log.info("6001端口已占用!");
}
// 生成字典缓存
createDictDataCache();
}
public void createDictDataCache() {
// 缓存字典值
sysDictService.createDictDataCache();
}
public void createOrderParamByStrategy(String systemId, String projectId) throws InterruptedException {
int r;
if (projectId != null && !projectId.isEmpty()) {
r = deviceCodeParamService.queryCount(projectId);//查询记录数
} else {
r = deviceCodeParamService.queryCount2();//查询记录数
}
if (r > 0) {
return;
}
List<DeviceCodeParamEntity> deviceCodeParamEntityList = new ArrayList<>();
List<MeterManageEntity> meterManageEntities = Collections.emptyList();
if (projectId != null && !projectId.isEmpty()) {
meterManageEntities = meterManageService.queryBySystemIdAndProjectId(systemId, projectId);
}
DeviceCodeParamEntity deviceCodeParamEntity = new DeviceCodeParamEntity();
// 根据协议进行匹配生成采集报文
for (MeterManageEntity meterManageEntity : meterManageEntities) {
// 重置采集参数
deviceCodeParamEntity.reset();
// 创建设备报文
String protocolType = String.valueOf(meterManageEntity.getProtocolType());
Protocol protocol = ProtocolFactory.matchProtocol(protocolType);
ProtocolStrategy strategy = ProtocolStrategyFactory.matchProtocolStrategy(protocolType);
if (strategy == null) {
continue;
}
protocol.setStrategy(strategy);
String sendStr = protocol.createOrder(meterManageEntity);
log.info("采集指令===> {}", sendStr);
deviceCodeParamEntity.setDeviceAddr(meterManageEntity.getMtCode());
deviceCodeParamEntity.setDeviceName(meterManageEntity.getMtName());
deviceCodeParamEntity.setDeviceType(String.valueOf(meterManageEntity.getMtType()));
deviceCodeParamEntity.setStrData(sendStr);
try {
GatewayManageEntity gatewayManageEntity = gatewayManageService.findById(meterManageEntity.getGatewayId());
if (gatewayManageEntity != null) {
deviceCodeParamEntity.setDataPort(String.valueOf(gatewayManageEntity.getPort()));
}
} catch (Exception e) {
log.error("查询网关信息失败: {}", e.getMessage());
}
try {
DeviceParamsEntity paramsEntity = deviceParamsService.findById(meterManageEntity.getParamId());
if (paramsEntity != null) {
deviceCodeParamEntity.setBaudRate(paramsEntity.getBaudRate());
deviceCodeParamEntity.setParity(paramsEntity.getParity());
}
} catch (Exception e) {
log.error("查询设备参数失败: {}", e.getMessage());
}
deviceCodeParamEntity.setBrand(meterManageEntity.getMtBrand());
deviceCodeParamEntity.setFunCode(meterManageEntity.getFuncCode());
deviceCodeParamEntity.setRegisterAddr(meterManageEntity.getRegisterAddr());
deviceCodeParamEntity.setRegisterName(meterManageEntity.getOtherName());
deviceCodeParamEntity.setDigit(meterManageEntity.getDigits());
deviceCodeParamEntity.setGrade(meterManageEntity.getGrade());
deviceCodeParamEntity.setDataValue(null); // 传入值(目前不需要)
deviceCodeParamEntity.setProjectId(projectId);
deviceCodeParamEntity.setCreateTime(new Date());
deviceCodeParamEntity.setMmId(meterManageEntity.getId());
deviceCodeParamEntity.setDataType(meterManageEntity.getDataType());
deviceCodeParamEntity.setProtocolType(meterManageEntity.getProtocolType());
deviceCodeParamEntityList.add(deviceCodeParamEntity.clone());
}
if (!deviceCodeParamEntityList.isEmpty()) {
deviceCodeParamService.insertDeviceCodeParamList(deviceCodeParamEntityList);
}
}
// public void test() throws Exception {
// System.out.println("测试定时采集开关");
// // 执行定义的定时采集程序
// Map<String, String> params = new HashMap<>();
// params.put("id", "2");
// params.put("name", "test1");
// //每 1 分钟 执行一次
// AddCronJobReq addCronJobReq = new AddCronJobReq();
// addCronJobReq.setDate("0/10 * * * * ?");
//// addCronJobReq.setDate("0/5 * * * * ?");
// addCronJobReq.setJobClass("JobTest1");
// addCronJobReq.setJobGroupName("JobTestGroup1");
// addCronJobReq.setJobName("Test1");
// addCronJobReq.setParams(params);
// addCronJobReq.setTriggerGroupName("triggerTestGroup1");
// addCronJobReq.setTriggerName("triggerTest1");
// quartzManager.addCronJob(addCronJobReq);
// }
//
// /**
// * 定时采集电表和冷量计
// *
// * @throws Exception
// */
// public void collectionMeterAndCloud() throws Exception {
// // 执行定义的定时采集程序
// Map<String, String> params = new HashMap<>();
// params.put("id", "6");
// params.put("name", "cloud_meter");
// AddCronJobReq addCronJobReq = new AddCronJobReq();
// //每 15 分钟 执行一次
// addCronJobReq.setDate("0 0/15 * * * ?");
// //每 3 分钟 执行一次
//// addCronJobReq.setDate("35 0/2 * * * ?");
// //每 2 分钟 执行一次
//// addCronJobReq.setDate("25 0/2 * * * ?");
// //每 1 分钟 执行一次
//// addCronJobReq.setDate("0/10 * * * * ?");
//// addCronJobReq.setDate("0/5 * * * * ?");
// addCronJobReq.setJobClass("JobCloudAndMeter");
// addCronJobReq.setJobGroupName("JobCloudAndMeterGroup");
// addCronJobReq.setJobName("CloudAndMeter");
// addCronJobReq.setParams(params);
// addCronJobReq.setTriggerGroupName("triggerCloudAndMeterGroup");
// addCronJobReq.setTriggerName("triggerCloudAndMeter");
// quartzManager.addCronJob(addCronJobReq);
// }
//
// /**
// * 定时采集冷量计
// *
// * @throws Exception
// */
// public void collectionCloud() throws Exception {
// // 执行定义的定时采集程序
// Map<String, String> params = new HashMap<>();
// params.put("id", "1");
// params.put("name", "cloud");
// AddCronJobReq addCronJobReq = new AddCronJobReq();
// //每 2 分钟 执行一次
// addCronJobReq.setDate("25 0/2 * * * ?");
//// addCronJobReq.setDate("0/5 * * * * ?");
// addCronJobReq.setJobClass("JobCloud");
// addCronJobReq.setJobGroupName("JobCloudGroup");
// addCronJobReq.setJobName("Cloud");
// addCronJobReq.setParams(params);
// addCronJobReq.setTriggerGroupName("triggerCloudGroup");
// addCronJobReq.setTriggerName("triggerCloud");
// quartzManager.addCronJob(addCronJobReq);
// }
// /**
// * 定时采集电表
// *
// * @throws Exception
// */
// public void collectionMeter() throws Exception {
// // 执行定义的定时采集程序
// Map<String, String> params = new HashMap<>();
// params.put("id", "2");
// params.put("name", "meter");
// AddCronJobReq addCronJobReq = new AddCronJobReq();
// //每 3 分钟 执行一次
// addCronJobReq.setDate("35 0/2 * * * ?");
//// addCronJobReq.setDate("0/20 * * * * ?");
// addCronJobReq.setJobClass("JobMeter");
// addCronJobReq.setJobGroupName("JobMeterGroup");
// addCronJobReq.setJobName("Meter");
// addCronJobReq.setParams(params);
// addCronJobReq.setTriggerGroupName("triggerMeterGroup");
// addCronJobReq.setTriggerName("triggerMeter");
// quartzManager.addCronJob(addCronJobReq);
// }
//
// /**
// * 定时采集DDC设备
// *
// * @throws Exception
// */
// public void collectionDDC() throws Exception {
// // 执行定义的定时采集程序
// Map<String, String> params = new HashMap<>();
// params.put("id", "3");
// params.put("name", "ddc");
// AddCronJobReq addCronJobReq = new AddCronJobReq();
// //每 1分钟 执行一次
//// addCronJobReq.setDate("3,33 * * * * ?");
// addCronJobReq.setDate("45 0/1 * * * ?");
// addCronJobReq.setJobClass("JobDDC");
// addCronJobReq.setJobGroupName("JobDDCGroup");
// addCronJobReq.setJobName("DDC");
// addCronJobReq.setParams(params);
// addCronJobReq.setTriggerGroupName("triggerDDCGroup");
// addCronJobReq.setTriggerName("triggerDDC");
// quartzManager.addCronJob(addCronJobReq);
// }
//
// /**
// * 定时采集冷水机组设备
// *
// * @throws Exception
// */
// public void collectionChillers() throws Exception {
// // 执行定义的定时采集程序
// Map<String, String> params = new HashMap<>();
// params.put("id", "4");
// params.put("name", "chillers");
// AddCronJobReq addCronJobReq = new AddCronJobReq();
// //每3分钟 执行一次
// addCronJobReq.setDate("55 0/2 * * * ? ");
//// addCronJobReq.setDate("0/30 * * * * ?");
// addCronJobReq.setJobClass("JobChillers");
// addCronJobReq.setJobGroupName("JobChillersGroup");
// addCronJobReq.setJobName("Chillers");
// addCronJobReq.setParams(params);
// addCronJobReq.setTriggerGroupName("triggerChillersGroup");
// addCronJobReq.setTriggerName("triggerChillers");
// quartzManager.addCronJob(addCronJobReq);
// }
//
// /**
// * 4分钟,采集第二个冷水机组数据
// */
// public void collectionChillers1() {
// // 执行定义的定时采集程序
// Map<String, String> params = new HashMap<>();
// params.put("id", "5");
// params.put("name", "chillers1");
// AddCronJobReq addCronJobReq = new AddCronJobReq();
// //每 4分钟 执行一次
// addCronJobReq.setDate("0 0/5 * * * ? ");
//// addCronJobReq.setDate("0/30 * * * * ?");
// addCronJobReq.setJobClass("JobChillers1");
// addCronJobReq.setJobGroupName("JobChillersGroup1");
// addCronJobReq.setJobName("Chillers1");
// addCronJobReq.setParams(params);
// addCronJobReq.setTriggerGroupName("triggerChillersGroup1");
// addCronJobReq.setTriggerName("triggerChillers1");
// try {
// quartzManager.addCronJob(addCronJobReq);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public void testSerialPort(){
//
// String portname = "COM7";
// //TestA();
// //查看所有串口
// SerialPortUtil serialPortUtil = SerialPortUtil.getSerialPortUtil();
// ArrayList<String> port = serialPortUtil.findPort();
// System.out.println("发现全部串口:" + port);
//
// System.out.println("打开指定portname:" + portname);
// //打开该对应portname名字的串口
// CollectionLoopRunner.serialPort = serialPortUtil.openPort(portname, 2400, SerialPort.DATABITS_8, SerialPort.PARITY_EVEN, SerialPort.PARITY_ODD);
//
// byte[] HEX = SerialPortListener.hexStr2Byte("FEFEFE6810398710810000000103901F007C16");
// serialPortUtil.sendToPort(CollectionLoopRunner.serialPort, HEX);
//
// //给对应的serialPort添加监听器
// serialPortUtil.addListener(CollectionLoopRunner.serialPort, new SerialPortListener());
//
// }
//
// public void plcAnalytic() {
// String portName = "COM1";
// //查看所有串口
// SerialPortUtil serialPortUtil = SerialPortUtil.getSerialPortUtil();
// //打开该对应portName名字的串口
// if (CollectionLoopRunner.serialPort == null) {
// CollectionLoopRunner.serialPort = serialPortUtil.openPort(portName, 19200, SerialPort.DATABITS_8, SerialPort.PARITY_NONE, SerialPort.PARITY_ODD);
// byte[] hex = SerialPortListener.hexStr2Byte("A55A230000000022".replaceAll("\\s*", ""));
// serialPortUtil.sendToPort(CollectionLoopRunner.serialPort, hex);
//
// //给对应的serialPort添加监听器-->设置串口的Listener
// SerialPortUtil.setListenerToSerialPort(CollectionLoopRunner.serialPort, serialPortEvent -> {
// if (serialPortEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
// byte[] bytes = serialPortUtil.readFromPort(CollectionLoopRunner.serialPort);
//
// String needData = SerialPortListener.printHexString(bytes);
//
// //数据校验 校验数据长度、起始5A A5、数据sum位
//// if (PlcUtil.makeChecksum(needData)) {
//// //数据解析方法 此处编写你的解析方法,根据获取到的数据编写适合自己的方法
//// }
// }
// });
// }
// }
}
}

15
user-service/src/main/java/com/mh/user/job/DealDataJob.java

@ -3,7 +3,7 @@ package com.mh.user.job;
import com.mh.user.service.chillers.DealDataService;
import com.mh.user.utils.ExchangeStringUtil;
import com.mh.user.utils.SimpleWeather;
import org.apache.log4j.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
@ -16,12 +16,11 @@ import java.util.*;
* @updateTime 2020-07-28
* @throws
*/
@Slf4j
@Component
public class DealDataJob {
private final DealDataService dealDataService;
private final SimpleWeather simpleWeather=new SimpleWeather();
private static final Logger log = Logger.getLogger(DealDataJob.class);
public DealDataJob(DealDataService dealDataService) {
this.dealDataService = dealDataService;
}
@ -80,11 +79,11 @@ public class DealDataJob {
String curDate= ExchangeStringUtil.dateTime(1,"");
List<String> list=dealDataService.queryProjectId("1");
if (!list.isEmpty()){
for(String projectID:list){
dealDataService.proDataResult(curDate,projectID); //1珠江酒店,2广合,3广大
for(String projectId:list){
dealDataService.proDataResult(curDate,projectId); //1珠江酒店,2广合,3广大
}
}
log.info("---------能效监测定时汇总,每一分钟!"+curDate);
log.info("---------能效监测定时汇总,每一分钟!{}", curDate);
} catch (Exception e) {
log.error("能效监测定时汇总异常", e);
}
@ -126,8 +125,8 @@ public class DealDataJob {
String curDate=sdf1.format(calendar.getTime());
List<String> list=dealDataService.queryProjectId("2");
if (!list.isEmpty()){
for(String projectID:list){
dealDataService.proEnergyDaySum(curDate,projectID);
for(String projectId:list){
dealDataService.proEnergyDaySum(curDate,projectId);
}
}
log.info("---------中央热水生产概况汇总,每一小时!"+curDate);

39
user-service/src/main/java/com/mh/user/job/JobChillers.java

@ -1,39 +0,0 @@
package com.mh.user.job;
import com.mh.user.constants.SocketMessage;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author ljf
* @title
* @description 定时采集冷水机组参数
* @updateTime 2020-06-24
* @throws
*/
/**
* :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行.
* :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效
* :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行,
* 否则会在3秒时再启用新的线程执行
*/
@DisallowConcurrentExecution
@Slf4j
public class JobChillers implements Job {
@Autowired
private SocketMessage socketMessage;
@SneakyThrows
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
log.info("定时采集冷水机组");
// NettyChillerClient nettyChillerClient = new NettyChillerClient();
}
}

41
user-service/src/main/java/com/mh/user/job/JobCloud.java

@ -1,41 +0,0 @@
package com.mh.user.job;
import com.mh.user.netty.NettyClient;
import com.mh.user.constants.SocketMessage;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author ljf
* @title
* @description 定时采集冷量计任务
* @updateTime 2020-05-18
* @throws
*/
/**
* :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行.
* :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效
* :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行,
* 否则会在3秒时再启用新的线程执行
*/
@DisallowConcurrentExecution
@Slf4j
public class JobCloud implements Job {
@Autowired
private SocketMessage socketMessage;
@SneakyThrows
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
// 定时采集冷量计
log.info("定时采集冷量计");
NettyClient nettyClient = new NettyClient();
nettyClient.connect(socketMessage.getPort(),socketMessage.getIP());
}
}

39
user-service/src/main/java/com/mh/user/job/JobDDC.java

@ -1,39 +0,0 @@
package com.mh.user.job;
import com.mh.user.constants.SocketMessage;
import com.mh.user.netty.NettyChillerDDCClient;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author ljf
* @title 定时采集DDC设备
* @description
* @updateTime 2020-06-09
* @throws
*/
/**
* :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行.
* :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效
* :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行,
* 否则会在3秒时再启用新的线程执行
*/
@DisallowConcurrentExecution
@Slf4j
public class JobDDC implements Job {
@Autowired
private SocketMessage socketMessage;
@SneakyThrows
@Override
public void execute(JobExecutionContext jobExecutionContext) {
log.info("定时采集DDC设备");
// NettyChillerDDCClient nettyChillerDDCClient = new NettyChillerDDCClient();
NettyChillerDDCClient.connect(socketMessage.getPort(), socketMessage.getIP());
}
}

45
user-service/src/main/java/com/mh/user/job/JobFactory.java

@ -1,45 +0,0 @@
package com.mh.user.job;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
/**
* @author ljf
* @title 创建JobFactory实例
* @description
* @updateTime 2020-04-03
* @throws
*/
@Component
public class JobFactory extends AdaptableJobFactory {
/**
* AutowireCapableBeanFactory接口是BeanFactory的子类
* 可以连接和填充那些生命周期不被Spring管理的已存在的bean实例
*/
private AutowireCapableBeanFactory factory;
/**
* @author jinhaoxun
* @description 构造器
* @param factory
*/
public JobFactory(AutowireCapableBeanFactory factory) {
this.factory = factory;
}
/**
* @author jinhaoxun
* @description 创建Job实例
* @param bundle
* @return Object
*/
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object job = super.createJobInstance(bundle);// 实例化对象
factory.autowireBean(job);// 进行注入(Spring管理该Bean)
return job;//返回对象
}
}

39
user-service/src/main/java/com/mh/user/job/JobMeter.java

@ -1,39 +0,0 @@
package com.mh.user.job;
import com.mh.user.netty.NettyMeterClient;
import com.mh.user.constants.SocketMessage;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author ljf
* @title
* @description 定时采集电表数据任务
* @updateTime 2020-05-18
* @throws
*/
/**
* :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行.
* :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效
* :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行,
* 否则会在3秒时再启用新的线程执行
*/
@DisallowConcurrentExecution
@Slf4j
public class JobMeter implements Job {
@Autowired
private SocketMessage socketMessage;
@SneakyThrows
@Override
public void execute(JobExecutionContext jobExecutionContext) {
log.info("定时采集电表数据任务开始");
NettyMeterClient nettyMeterClient = new NettyMeterClient();
nettyMeterClient.connect(socketMessage.getPort(), socketMessage.getIP());
}
}

32
user-service/src/main/java/com/mh/user/job/JobTest.java

@ -1,32 +0,0 @@
package com.mh.user.job;
import com.mh.user.constants.Constant;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
* :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行.
* :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效
* :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行,
* 否则会在3秒时再启用新的线程执行
*/
@DisallowConcurrentExecution
@Slf4j
public class JobTest implements Job {
@SneakyThrows
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
for (int i = 0; i < 30; i++) {
if (Constant.FLAG) {
break;
}
Thread.sleep(1000);
log.info("第" + i + "个," +jobExecutionContext.getJobDetail()+"---------------------定时任务测试----------------------");
}
}
}

73
user-service/src/main/java/com/mh/user/mapper/DataResultChMapper.java

@ -0,0 +1,73 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultChEntity;
import com.mh.user.entity.DataResultClEntity;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 数据冷量计
* @date 2024-07-10 15:20:55
*/
@Mapper
public interface DataResultChMapper extends BaseMapper<DataResultChEntity> {
//----------------------------------------------------------------------------------------------
//保存冷量计数据
@Insert("insert into data_result_ch(device_addr,device_type,fun_code,register_addr,register_name,cur_value,cur_date,project_id,grade) values (" +
" #{deviceAddr},#{deviceType},#{funCode},#{registerAddr},#{registerName},#{curValue},#{curDate},#{projectId},#{grade})")
void saveDataResultCh(DataResultChEntity dataResultChEntity);
@Update("<script>" +
" update data_result_ch set " +
" <if test='deviceAddr!=null'> device_addr = #{deviceAddr} </if>" +
" <if test='deviceType!=null'> , device_type = #{deviceType} </if>" +
" <if test='funCode!=null'> , fun_code = #{funCode} </if>" +
" <if test='registerAddr!=null'> , register_addr = #{registerAddr} </if>" +
" <if test='registerName!=null'> , register_name = #{registerName} </if>" +
" <if test='curValue!=null'> , cur_value = #{curValue} </if>" +
" <if test='projectId!=null'> , project_id = #{projectId} </if>" +
" <if test='grade!=null'> , grade = #{grade} </if>" +
" where cur_date=#{curDate} and device_addr=#{deviceAddr} and device_type=#{deviceType}" +
"</script>")
void updateDataResultCh(DataResultChEntity dataResultChEntity);
@Select("select count(*) from data_result_ch " +
" where cur_date=#{curDate} " +
" and device_addr=#{deviceAddr} " +
" and register_addr=#{registerAddr} " +
" and project_id=#{projectId} " +
" and grade = #{grade} ")
int selectDataResultChCount(@Param("curDate") String curDate,
@Param("deviceAddr") String deviceAddr,
@Param("registerAddr") String registerAddr,
@Param("projectId") String projectId,
@Param("grade") int grade);
@Select("select " +
" t1.project_id, " +
" sum(cast (t1.curValue AS decimal(18, 2)))as cur_value, " +
" t1.cur_date, " +
" t2.project_name " +
"from " +
" data_result_ch t1 " +
"join project_info t2 on " +
" t1.project_id = t2.id " +
"where " +
" t1.project_id = #{projectId} " +
" and t1.cur_date >= #{startDate} " +
" and t1.cur_date <= #{curDate} " +
"group by " +
" t1.cur_date, " +
" t1.project_id, " +
" t2.project_name " +
"order by " +
" t1.cur_date ")
List<DataResultChEntity> queryDataResultCh(@Param("projectId") String projectId, @Param("startDate") String startDate, @Param("curDate") String curDate);
}

105
user-service/src/main/java/com/mh/user/mapper/DataResultChillerMapper.java

@ -0,0 +1,105 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultChEntity;
import com.mh.user.entity.DataResultChillerEntity;
import com.mh.user.mapper.provider.DataResultProvider;
import com.mh.user.model.ChillerModel;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 主机参数保存
* @date 2024-07-10 15:41:15
*/
@Mapper
public interface DataResultChillerMapper extends BaseMapper<DataResultChillerEntity> {
//保存冷水机数据
@Insert("insert into data_result_chiller(device_addr,device_type,fun_code,register_addr,register_name,cur_value,cur_date,project_id,grade) values (" +
" #{deviceAddr},#{deviceType},#{funCode},#{registerAddr},#{registerName},#{curValue},#{curDate},#{projectId},#{grade})")
void saveDataResultChiller(DataResultChEntity dataResultChEntity);
@Update("<script>" +
" update data_result_chiller set " +
" <if test='deviceAddr!=null'> device_addr = #{deviceAddr} </if>" +
" <if test='deviceType!=null'> , device_type = #{deviceType} </if>" +
" <if test='funCode!=null'> , fun_code = #{funCode} </if>" +
" <if test='registerAddr!=null'> , register_addr = #{registerAddr} </if>" +
" <if test='registerName!=null'> , register_name = #{registerName} </if>" +
" <if test='curValue!=null'> , cur_value = #{curValue} </if>" +
" <if test='projectId!=null'> , project_id = #{projectId} </if>" +
" <if test='grade!=null'> , grade = #{grade} </if>" +
" where cur_date=#{curDate} and device_addr=#{deviceAddr} and register_addr=#{registerAddr} and project_id=#{projectId} " +
"</script>")
void updateDataResultChiller(DataResultChEntity dataResultChEntity);
@Select("select count(*) from data_result_chiller where cur_date=#{curDate} " +
" and device_addr=#{deviceAddr} " +
" and register_addr=#{registerAddr} " +
" and project_id=#{projectId} " +
" and fun_code = #{funCode} ")
int selectDataResultChillerCount(@Param("curDate") String curDate,
@Param("deviceAddr") String deviceAddr,
@Param("registerAddr") String registerAddr,
@Param("projectId") String projectId,
@Param("funCode") String funCode);
@Results({
@Result(property="deviceAddr",column="device_addr"),
@Result(property="deviceType",column="device_type"),
@Result(property="curDate",column="cur_date"),
@Result(property ="curValue",column ="cur_value"),
@Result(property="funCode",column="fun_code"),
@Result(property="registerAddr",column="register_addr"),
@Result(property="registerName",column="register_name"),
@Result(property="grade",column="grade"),
@Result(property="projectId",column="project_id"),
@Result(property="projectName",column="project_name")
})
@SelectProvider(type = DataResultProvider.class,method = "queryDataResultChiller")
List<DataResultChEntity> queryDataResultChiller(@Param("projectId") String projectId,
@Param("deviceAddr") String deviceAddr,
@Param("registerName") String registerName,
@Param("startDate") String startDate,
@Param("curDate") String curDate,
@Param("page") int page,
@Param("limit") int limit);
@SelectProvider(type = DataResultProvider.class,method = "dataResultChillerCount")
int dataResultChillerCount(@Param("projectId") String projectId,
@Param("deviceAddr") String deviceAddr,
@Param("registerName") String registerName,
@Param("startDate") String startDate,
@Param("curDate") String curDate);
//保存冷水机参数数据
@Insert("insert into data_chiller" +
"(device_addr," +
"device_name," +
"run_state," +
"set_soint," +
"enter_chw," +
"leave_chw," +
"enter_cow," +
"leave_cow," +
"power," +
"rated_power," +
"chiller_amps," +
"refrigeration," +
"rated_ref," +
"chw_flow," +
"approach_cow," +
"approach_chw," +
"cop," +
"rated_cop," +
"copy_date) values (" +
" #{deviceAddr},#{deviceName},#{projectId},#{lastValue},#{lastDate},#{curValue},#{curDate},#{ratio},#{calcValue},#{grade})")
void saveDataChiller(ChillerModel chillerModel);
}

35
user-service/src/main/java/com/mh/user/mapper/DataResultClBakMapper.java

@ -0,0 +1,35 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultClBakEntity;
import com.mh.user.entity.DataResultClEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 数据冷量计
* @date 2024-07-10 15:20:55
*/
@Mapper
public interface DataResultClBakMapper extends BaseMapper<DataResultClBakEntity> {
@Insert("insert into data_result_cl_bak(device_addr,device_type,project_id,last_value,last_date,cur_value,cur_date,ratio,calc_value,grade,register_addr,register_name) values (" +
" #{deviceAddr},#{deviceType},#{projectId},#{lastValue},#{lastDate},#{curValue},#{curDate},#{ratio},#{calcValue},#{grade},#{registerAddr},#{registerName})")
void saveDataResultCl_bak(DataResultClEntity dataResultClEntity);
@Select("select count(1) from data_result_cl_bak " +
" where cur_date = #{curDate} " +
" and device_addr = #{deviceAddr} " +
" and register_addr = #{registerAddr} " +
" and project_id = #{projectId} ")
int selectDataResultChBakCount(@Param("curDate") String curDate,
@Param("deviceAddr") String deviceAddr,
@Param("registerAddr") String registerAddr,
@Param("projectId") String projectId);
}

42
user-service/src/main/java/com/mh/user/mapper/DataResultClMapper.java

@ -0,0 +1,42 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultChEntity;
import com.mh.user.entity.DataResultClEntity;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 数据冷量计
* @date 2024-07-10 15:20:55
*/
@Mapper
public interface DataResultClMapper extends BaseMapper<DataResultClEntity> {
//----------------------------------------------------------------------------------------------
//保存冷量计数据
@Insert("insert into data_result_cl(device_addr,device_type,project_id,last_value,last_date,cur_value,cur_date,ratio,calc_value,grade,register_addr,register_name) values (" +
" #{deviceAddr},#{deviceType},#{projectId},#{lastValue},#{lastDate},#{curValue},#{curDate},#{ratio},#{calcValue},#{grade},#{registerAddr},#{registerName})")
void saveDataResultCl(DataResultClEntity dataResultClEntity);
@Update("<script>" +
" update data_result_cl set " +
" <if test='deviceAddr!=null'> device_addr = #{deviceAddr} </if>" +
" <if test='deviceType!=null'> , device_type = #{deviceType} </if>" +
" <if test='projectId!=null'> , project_id = #{projectId} </if>" +
" <if test='lastValue!=null'> , last_value = #{lastValue} </if>" +
" <if test='lastDate!=null'> , last_date = #{lastDate} </if>" +
" <if test='curValue!=null'> , cur_value = #{curValue} </if>" +
" <if test='ratio!=null'> , ratio = #{ratio} </if>" +
" <if test='calcValue!=null'> , calc_value = #{calcValue} </if>" +
" <if test='grade!=null'> , grade = #{grade} </if>" +
" <if test='registerAddr!=null'> , register_addr = #{registerAddr} </if>" +
" <if test='registerName!=null'> , register_name = #{registerName} </if>" +
" where cur_date=#{curDate} and device_addr=#{deviceAddr} and device_type=#{deviceType}" +
"</script>")
void updateDataResultCl(DataResultClEntity dataResultClEntity);
}

36
user-service/src/main/java/com/mh/user/mapper/DataResultFifteenMiMapper.java

@ -0,0 +1,36 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultChEntity;
import com.mh.user.entity.DataResultFifteenMiEntity;
import com.mh.user.entity.DataResultFiveMiEntity;
import com.mh.user.mapper.provider.DataResultProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.SelectProvider;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 每分钟保存数据
* @date 2024-07-10 17:34:30
*/
@Mapper
public interface DataResultFifteenMiMapper extends BaseMapper<DataResultFifteenMiEntity> {
@SelectProvider(type = DataResultProvider.class,method = "queryDataResultFifteenMi")
List<DataResultChEntity> queryDataResultFifteenMi(@Param("projectId") String projectId,
@Param("startDate") String startDate,
@Param("curDate") String curDate,
@Param("page") int page,
@Param("limit") int limit);
//@Select("select count(*) from data_result_fifteen_mi where projectId=#{projectId} and curDate>=#{startDate} and curDate<=#{curDate} ")
@SelectProvider(type = DataResultProvider.class,method = "dataResultFifteenMiCount")
int dataResultFifteenMiCount(@Param("projectId") String projectId,@Param("startDate") String startDate,@Param("curDate") String curDate);
}

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

Loading…
Cancel
Save