Compare commits

..

6 Commits

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

217
2024新增脚本.sql

@ -0,0 +1,217 @@
-- 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
remark nvarchar(255) null, -- 备注
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'备注', @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
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'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
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';
-- 设备采集参数表
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

30
common/pom.xml

@ -23,17 +23,35 @@
</properties> </properties>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson2</artifactId>
<version>1.2.31</version> <version>2.0.51</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>
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId> <artifactId>sqlparser4.5</artifactId>
<version>1.2.13</version> <version>6.1.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>sqlparser-timeout</artifactId>
<version>6.1.0</version>
</dependency>
<!-- web --> <!-- web -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

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

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

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

@ -1,11 +1,10 @@
package com.mh.common.utils; package com.mh.common.utils;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream; import java.io.*;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
/** /**
* 文件相关操作 * 文件相关操作
@ -39,4 +38,20 @@ public class FileUtils {
e.printStackTrace(); 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; package com.mh.common.utils;
import com.mh.common.page.ColumnFilter;
import com.mh.common.page.PageRequest;
/** /**
* 字符串工具类 * 字符串工具类
* @author Louis * @author Louis
@ -16,4 +19,18 @@ public class StringUtils {
return value == null || "".equals(value) || "null".equals(value) || "undefined".equals(value); 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;
}
} }

6
pom.xml

@ -59,6 +59,12 @@
<artifactId>purejavacomm</artifactId> <artifactId>purejavacomm</artifactId>
<version>1.0.1.RELEASE</version> <version>1.0.1.RELEASE</version>
</dependency> </dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.15.3</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>

100
user-service/pom.xml

@ -23,32 +23,39 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> <exclusions>
<dependency> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-starter-tomcat</artifactId>
<scope>import</scope> </exclusion>
<!-- 当时本地启动需要注释掉--> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId> <artifactId>spring-boot-starter-undertow</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-cloud-starter-config</artifactId> <artifactId>spring-boot-starter-quartz</artifactId>
<version>2.2.2.RELEASE</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-config</artifactId>-->
<!-- <version>2.2.2.RELEASE</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.github.ben-manes.caffeine</groupId> <groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId> <artifactId>caffeine</artifactId>
<version>2.8.8</version> <version>2.8.8</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson2</artifactId>
<version>1.2.41</version> <version>2.0.51</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>--> <!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-config-client</artifactId>--> <!-- <artifactId>spring-cloud-config-client</artifactId>-->
@ -74,32 +81,56 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- mybatis配置--> <!-- mybatis配置-->
<!-- <dependency>-->
<!-- <groupId>org.mybatis.spring.boot</groupId>-->
<!-- <artifactId>mybatis-spring-boot-starter</artifactId>-->
<!-- <version>3.0.2</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>2.1.2</version> <version>3.5.7</version>
<exclusions>
<exclusion>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- mysql数据库链接--> <!-- mysql数据库链接-->
<dependency> <!-- <dependency>-->
<groupId>mysql</groupId> <!-- <groupId>mysql</groupId>-->
<artifactId>mysql-connector-java</artifactId> <!-- <artifactId>mysql-connector-java</artifactId>-->
</dependency> <!-- </dependency>-->
<!-- druid配置--> <!-- druid配置-->
<dependency> <!-- <dependency>-->
<groupId>com.alibaba</groupId> <!-- <groupId>com.alibaba</groupId>-->
<artifactId>druid-spring-boot-starter</artifactId> <!-- <artifactId>druid-spring-boot-starter</artifactId>-->
<version>1.1.18</version> <!-- <version>1.1.18</version>-->
</dependency> <!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-core</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.microsoft.sqlserver</groupId> <groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId> <artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- 引入log4j依赖 --> <!-- 引入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> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-api</artifactId>
<version>1.2.17</version> <version>2.23.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
@ -141,21 +172,16 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>tk.mybatis</groupId> <!-- <groupId>tk.mybatis</groupId>-->
<artifactId>mapper</artifactId> <!-- <artifactId>mapper</artifactId>-->
<version>3.3.9</version> <!-- <version>3.3.9</version>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId> <artifactId>commons-pool2</artifactId>
</dependency> </dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId> <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; 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.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; 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 org.springframework.scheduling.annotation.EnableScheduling;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
@Slf4j
@SpringBootApplication(scanBasePackages = "com.mh.user") @SpringBootApplication(scanBasePackages = "com.mh.user")
@EnableScheduling @EnableScheduling
@MapperScan("com.mh.user.mapper")
public class UserServiceApplication extends SpringBootServletInitializer { public class UserServiceApplication extends SpringBootServletInitializer {
private static final Logger log = Logger.getLogger(UserServiceApplication.class);
@Override @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(UserServiceApplication.class); return builder.sources(UserServiceApplication.class);

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 javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson2.JSONObject;
import com.mh.user.annotation.SysLogger; import com.mh.user.annotation.SysLogger;
import com.mh.user.model.SysLog; import com.mh.user.model.SysLog;
import com.mh.user.service.SysLogService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date; 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; package com.mh.user.component;
import com.alibaba.druid.sql.visitor.functions.Isnull; import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.mh.user.config.RabbitmqConfig; import com.mh.user.config.RabbitmqConfig;
import com.mh.user.model.QueueParam; import com.mh.user.model.QueueParam;
import com.mh.user.utils.AnalysisReceiveOrder485; import com.mh.user.utils.AnalysisReceiveOrder485;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.rabbitmq.client.impl.AMQImpl;
import lombok.extern.slf4j.Slf4j; 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.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.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,10 +15,10 @@ import java.io.IOException;
/** /**
* 队列消费接收消息 * 队列消费接收消息
*/ */
@Slf4j
@Component @Component
public class ReceiveHandler { public class ReceiveHandler {
private static final Logger log = Logger.getLogger(ReceiveHandler.class);
//监听队列 //监听队列
// @RabbitListener(bindings = @QueueBinding( // @RabbitListener(bindings = @QueueBinding(
// value = @Queue(value = "queue_zjjd", durable = "true"), // value = @Queue(value = "queue_zjjd", durable = "true"),
@ -48,7 +40,7 @@ public class ReceiveHandler {
queueParam.setRecData(JSONObj.getString("recData")); queueParam.setRecData(JSONObj.getString("recData"));
queueParam.setDeviceType(JSONObj.getString("deviceType")); queueParam.setDeviceType(JSONObj.getString("deviceType"));
queueParam.setRegisterAddr(JSONObj.getString("registerAddr")); queueParam.setRegisterAddr(JSONObj.getString("registerAddr"));
queueParam.setProjectID(JSONObj.getString("projectID")); queueParam.setProjectId(JSONObj.getString("projectId"));
queueParam.setCopyTime(JSONObj.getString("copyTime")); queueParam.setCopyTime(JSONObj.getString("copyTime"));
String deviceType=JSONObj.getString("deviceType"); String deviceType=JSONObj.getString("deviceType");
show=deviceType+",数据:"+JSONObj.getString("recData"); show=deviceType+",数据:"+JSONObj.getString("recData");

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

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

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

@ -1,172 +1,172 @@
package com.mh.user.config; //package com.mh.user.config;
//
import org.springframework.boot.context.properties.ConfigurationProperties; //import org.springframework.boot.context.properties.ConfigurationProperties;
//
/** ///**
* @author ljf // * @author ljf
* @title // * @title :
* @description // * @description :
* @updateTime 2020-03-13 // * @updateTime 2020-03-13
* @throws // * @throws :
*/ // */
@ConfigurationProperties(prefix = "spring.datasource.druid") //@ConfigurationProperties(prefix = "spring.datasource.druid")
public class DruidDataSourceProperties { //public class DruidDataSourceProperties {
//
// jdbc // // jdbc
private String driverClassName; // private String driverClassName;
private String url; // private String url;
private String username; // private String username;
private String password; // private String password;
// jdbc connection pool // // jdbc connection pool
private int initialSize; // private int initialSize;
private int minIdle; // private int minIdle;
private int maxActive = 100; // private int maxActive = 100;
private long maxWait; // private long maxWait;
private long timeBetweenEvictionRunsMillis; // private long timeBetweenEvictionRunsMillis;
private long minEvictableIdleTimeMillis; // private long minEvictableIdleTimeMillis;
private String validationQuery; // private String validationQuery;
private boolean testWhileIdle; // private boolean testWhileIdle;
private boolean testOnBorrow; // private boolean testOnBorrow;
private boolean testOnReturn; // private boolean testOnReturn;
private boolean poolPreparedStatements; // private boolean poolPreparedStatements;
private int maxPoolPreparedStatementPerConnectionSize; // private int maxPoolPreparedStatementPerConnectionSize;
// filter // // filter
private String filters; // private String filters;
//
public int getInitialSize() { // public int getInitialSize() {
return initialSize; // return initialSize;
} // }
//
public void setInitialSize(int initialSize) { // public void setInitialSize(int initialSize) {
this.initialSize = initialSize; // this.initialSize = initialSize;
} // }
//
public int getMinIdle() { // public int getMinIdle() {
return minIdle; // return minIdle;
} // }
//
public void setMinIdle(int minIdle) { // public void setMinIdle(int minIdle) {
this.minIdle = minIdle; // this.minIdle = minIdle;
} // }
//
public int getMaxActive() { // public int getMaxActive() {
return maxActive; // return maxActive;
} // }
//
public void setMaxActive(int maxActive) { // public void setMaxActive(int maxActive) {
this.maxActive = maxActive; // this.maxActive = maxActive;
} // }
//
public long getMaxWait() { // public long getMaxWait() {
return maxWait; // return maxWait;
} // }
//
public void setMaxWait(long maxWait) { // public void setMaxWait(long maxWait) {
this.maxWait = maxWait; // this.maxWait = maxWait;
} // }
//
public long getTimeBetweenEvictionRunsMillis() { // public long getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis; // return timeBetweenEvictionRunsMillis;
} // }
//
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { // public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; // this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
} // }
//
public long getMinEvictableIdleTimeMillis() { // public long getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis; // return minEvictableIdleTimeMillis;
} // }
//
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { // public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; // this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
} // }
//
public String getValidationQuery() { // public String getValidationQuery() {
return validationQuery; // return validationQuery;
} // }
//
public void setValidationQuery(String validationQuery) { // public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery; // this.validationQuery = validationQuery;
} // }
//
public boolean isTestWhileIdle() { // public boolean isTestWhileIdle() {
return testWhileIdle; // return testWhileIdle;
} // }
//
public void setTestWhileIdle(boolean testWhileIdle) { // public void setTestWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle; // this.testWhileIdle = testWhileIdle;
} // }
//
public boolean isTestOnBorrow() { // public boolean isTestOnBorrow() {
return testOnBorrow; // return testOnBorrow;
} // }
//
public void setTestOnBorrow(boolean testOnBorrow) { // public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow; // this.testOnBorrow = testOnBorrow;
} // }
//
public boolean isTestOnReturn() { // public boolean isTestOnReturn() {
return testOnReturn; // return testOnReturn;
} // }
//
public void setTestOnReturn(boolean testOnReturn) { // public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn; // this.testOnReturn = testOnReturn;
} // }
//
public boolean isPoolPreparedStatements() { // public boolean isPoolPreparedStatements() {
return poolPreparedStatements; // return poolPreparedStatements;
} // }
//
public void setPoolPreparedStatements(boolean poolPreparedStatements) { // public void setPoolPreparedStatements(boolean poolPreparedStatements) {
this.poolPreparedStatements = poolPreparedStatements; // this.poolPreparedStatements = poolPreparedStatements;
} // }
//
public int getMaxPoolPreparedStatementPerConnectionSize() { // public int getMaxPoolPreparedStatementPerConnectionSize() {
return maxPoolPreparedStatementPerConnectionSize; // return maxPoolPreparedStatementPerConnectionSize;
} // }
//
public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) { // public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize; // this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
} // }
//
public String getFilters() { // public String getFilters() {
return filters; // return filters;
} // }
//
public void setFilters(String filters) { // public void setFilters(String filters) {
this.filters = filters; // this.filters = filters;
} // }
//
public String getDriverClassName() { // public String getDriverClassName() {
return driverClassName; // return driverClassName;
} // }
//
public void setDriverClassName(String driverClassName) { // public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName; // this.driverClassName = driverClassName;
} // }
//
public String getUrl() { // public String getUrl() {
return url; // return url;
} // }
//
public void setUrl(String url) { // public void setUrl(String url) {
this.url = url; // this.url = url;
} // }
//
public String getUsername() { // public String getUsername() {
return username; // return username;
} // }
//
public void setUsername(String username) { // public void setUsername(String username) {
this.username = username; // this.username = username;
} // }
//
public String getPassword() { // public String getPassword() {
return password; // return password;
} // }
//
public void setPassword(String password) { // public void setPassword(String password) {
this.password = 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; //package com.mh.user.config;
//
import com.alibaba.druid.support.http.StatViewServlet; //import com.alibaba.druid.support.http.StatViewServlet;
//
/** ///**
* druid监控视图配置 // * druid监控视图配置
*/ // */
//@WebServlet(urlPatterns = "/druid/*", initParams={ ////@WebServlet(urlPatterns = "/druid/*", initParams={
// @WebInitParam(name="allow",value="192.168.6.195"), // IP白名单 (没有配置或者为空,则允许所有访问) //// @WebInitParam(name="allow",value="192.168.6.195"), // IP白名单 (没有配置或者为空,则允许所有访问)
// @WebInitParam(name="deny",value="192.168.6.73"), // IP黑名单 (存在共同时,deny优先于allow) //// @WebInitParam(name="deny",value="192.168.6.73"), // IP黑名单 (存在共同时,deny优先于allow)
// @WebInitParam(name="loginUsername",value="admin"), // 用户名 //// @WebInitParam(name="loginUsername",value="admin"), // 用户名
// @WebInitParam(name="loginPassword",value="admin"), // 密码 //// @WebInitParam(name="loginPassword",value="admin"), // 密码
// @WebInitParam(name="resetEnable",value="true") // 禁用HTML页面上的“Reset All”功能 //// @WebInitParam(name="resetEnable",value="true") // 禁用HTML页面上的“Reset All”功能
//}) ////})
public class DruidStatViewServlet extends StatViewServlet { //public class DruidStatViewServlet extends StatViewServlet {
private static final long serialVersionUID = 7359758657306626394L; // 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; package com.mh.user.config;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.mh.user.dynamic.datasource.DataSourceContextHolder; 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.service.SysUserService;
import com.mh.user.utils.JwtTokenUtils;
import com.mh.user.utils.AESUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor; 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; //package com.mh.user.config;
//
import com.mh.user.job.JobFactory; //import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.Slf4j; //import org.quartz.Scheduler;
import org.quartz.Scheduler; //import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Configuration; //import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //
///**
/** // * @author ljf
* @author ljf // * @title : Quartz配置
* @title Quartz配置 // * @description :
* @description // * @updateTime 2020-04-03
* @updateTime 2020-04-03 // * @throws :
* @throws // */
*/ //@Slf4j
@Slf4j //@Configuration
@Configuration //public class QuartzConfig {
public class QuartzConfig { //
// private JobFactory jobFactory;
private JobFactory jobFactory; //
// /**
/** // * @author jinhaoxun
* @author jinhaoxun // * @description 构造器
* @description 构造器 // * @param jobFactory
* @param jobFactory // */
*/ // public QuartzConfig(JobFactory jobFactory){
public QuartzConfig(JobFactory jobFactory){ // this.jobFactory = jobFactory;
this.jobFactory = jobFactory; // }
} //
// /**
/** // * @author jinhaoxun
* @author jinhaoxun // * @description 配置SchedulerFactoryBean,将一个方法产生为Bean并交给Spring容器管理
* @description 配置SchedulerFactoryBean将一个方法产生为Bean并交给Spring容器管理 // * @return SchedulerFactoryBean
* @return SchedulerFactoryBean // */
*/ // @Bean
@Bean // public SchedulerFactoryBean schedulerFactoryBean() {
public SchedulerFactoryBean schedulerFactoryBean() { //// log.info("开始注入定时任务调度器工厂...");
// log.info("开始注入定时任务调度器工厂..."); // System.out.println("开始注入定时任务调度器工厂...");
System.out.println("开始注入定时任务调度器工厂..."); // SchedulerFactoryBean factory = new SchedulerFactoryBean();// Spring提供SchedulerFactoryBean为Scheduler提供配置信息,并被Spring容器管理其生命周期
SchedulerFactoryBean factory = new SchedulerFactoryBean();// Spring提供SchedulerFactoryBean为Scheduler提供配置信息,并被Spring容器管理其生命周期 // factory.setJobFactory(jobFactory);// 设置自定义Job Factory,用于Spring管理Job bean
factory.setJobFactory(jobFactory);// 设置自定义Job Factory,用于Spring管理Job bean // factory.setOverwriteExistingJobs(true);// 覆盖存在的定时任务
factory.setOverwriteExistingJobs(true);// 覆盖存在的定时任务 // factory.setStartupDelay(30); //延时30秒启动定时任务,避免系统未完全启动却开始执行定时任务的情况
factory.setStartupDelay(30); //延时30秒启动定时任务,避免系统未完全启动却开始执行定时任务的情况 //// log.info("注入定时任务调度器工厂成功!");
// log.info("注入定时任务调度器工厂成功!"); // System.out.println("注入定时任务调度器工厂成功!");
System.out.println("注入定时任务调度器工厂成功!"); // return factory;
return factory; // }
} //
// @Bean(name = "scheduler")
@Bean(name = "scheduler") // public Scheduler scheduler() {
public Scheduler scheduler() { // return schedulerFactoryBean().getScheduler();
return schedulerFactoryBean().getScheduler(); // }
} //}
}

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

@ -1,30 +1,21 @@
package com.mh.user.config; package com.mh.user.config;
import com.mh.user.component.ReceiveHandler;
import com.mh.user.constants.Constant;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.Logger;
import org.springframework.amqp.core.*; import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; 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.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;
/** /**
*队列绑定队列绑定交换机绑定路由KEY *队列绑定队列绑定交换机绑定路由KEY
*/ */
@Slf4j
@Configuration @Configuration
public class RabbitmqConfig { 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_zjjd"; //采集队列,珠江酒店
// public static final String QUEUE_NAME = "queue_gdkj"; //采集队列,广大科技 // public static final String QUEUE_NAME = "queue_gdkj"; //采集队列,广大科技

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

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

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

@ -1,6 +1,6 @@
package com.mh.user.controller; package com.mh.user.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.mh.common.http.HttpResult; import com.mh.common.http.HttpResult;
import com.mh.user.dto.DisplayBoxDataDTO; import com.mh.user.dto.DisplayBoxDataDTO;
import com.mh.user.dto.TableInfoDTO; import com.mh.user.dto.TableInfoDTO;

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

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

60
user-service/src/main/java/com/mh/user/controller/DevicesManageController.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.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")
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") Integer id) {
DevicesManageEntity entity = devicesManageService.findById(id);
return HttpResult.ok(entity);
}
@SysLogger(value="资产管理信息",optDesc = "添加资产管理信息")
@PostMapping("/save")
public HttpResult saveGw(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") Integer 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") @PostMapping("/query")
public HttpResult queryEnergyData(@RequestBody EnergyModel energyModel){ public HttpResult queryEnergyData(@RequestBody EnergyModel energyModel){
try{ try{
String projectID=energyModel.getProjectID(); String projectId=energyModel.getProjectId();
if(projectID!=null && projectID.length()>0){ if(projectId!=null && projectId.length()>0){
List<EnergyDataEntity> list=energyDataService.queryEnergyData(energyModel); List<EnergyDataEntity> list=energyDataService.queryEnergyData(energyModel);
int count=energyDataService.getEnergyDataCount(energyModel); int count=energyDataService.getEnergyDataCount(energyModel);
return HttpResult.ok(count,list); 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") Integer 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 = "查询基表信息") @SysLogger(value="基表信息",optDesc = "查询基表信息")
@PostMapping("/query") @PostMapping("/query")
public HttpResult queryMeterInfo(@RequestParam(value = "systemID",required = false) String systemID, public HttpResult queryMeterInfo(@RequestParam(value = "systemId",required = false) String systemID,
@RequestParam(value = "projectID",required = false) String projectID){ @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); return HttpResult.ok(list);
} }
} }

60
user-service/src/main/java/com/mh/user/controller/MeterManageController.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.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;
@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") Integer 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; package com.mh.user.controller;
import com.mh.common.http.HttpResult; 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.annotation.SysLogger;
import com.mh.user.entity.ProjectInfoEntity; import com.mh.user.entity.ProjectInfoEntity;
import com.mh.user.service.ProjectInfoService; import com.mh.user.service.ProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -20,10 +19,45 @@ public class ProjectInfoController {
ProjectInfoService projectInfoService; ProjectInfoService projectInfoService;
@SysLogger(value="项目信息",optDesc = "查询项目信息") @SysLogger(value="项目信息",optDesc = "查询项目信息")
@PostMapping("/queryPro") @PostMapping("/queryProBySystemId")
public HttpResult queryProject(@RequestParam(value = "systemID")String systemID) { public HttpResult queryProBySystemId(@RequestParam(value = "systemId")String systemID) {
List<ProjectInfoEntity> list=projectInfoService.queryProjectInfo(systemID); List<ProjectInfoEntity> list=projectInfoService.queryProjectInfo(systemID);
return HttpResult.ok(list); 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") Integer 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();
}
} }

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

@ -46,13 +46,13 @@ public class SerialPortController {
deviceCodeParam.setBaudRate(deviceInstallEntity.getBaudRate()); deviceCodeParam.setBaudRate(deviceInstallEntity.getBaudRate());
deviceCodeParam.setParity(deviceInstallEntity.getParity()); deviceCodeParam.setParity(deviceInstallEntity.getParity());
deviceCodeParam.setDataValue(serialPortModel.getDataValue());//传入相关参数值 deviceCodeParam.setDataValue(serialPortModel.getDataValue());//传入相关参数值
deviceCodeParam.setProjectID(buildingId); deviceCodeParam.setProjectId(buildingId);
String brand=deviceInstallEntity.getBrand();//品牌 String brand=deviceInstallEntity.getBrand();//品牌
deviceCodeParam.setBrand(brand); deviceCodeParam.setBrand(brand);
ControlSetEntity controlData=new ControlSetEntity(); ControlSetEntity controlData=new ControlSetEntity();
//设置设备实体对象 //设置设备实体对象
controlData.setBuildingId(deviceInstallEntity.getProjectID()); controlData.setBuildingId(deviceInstallEntity.getProjectId());
if (deviceType==null || deviceType.equals("") || deviceType.equals("热泵")){ if (deviceType==null || deviceType.equals("") || deviceType.equals("热泵")){
if (param==null || param.equals("") || param.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="节能策略查询") @SysLogger(value="节能策略查询")
@RequestMapping("query") @RequestMapping("query")
public HttpResult queryStrategyInfo(@RequestParam(value = "systemID",required = false) String systemID, public HttpResult queryStrategyInfo(@RequestParam(value = "systemId",required = false) String systemID,
@RequestParam(value = "projectID",required = false) String projectID){ @RequestParam(value = "projectId",required = false) String projectId){
List<StrategyInfoEntity> list=strategyInfoService.queryStrategyInfo(systemID,projectID); List<StrategyInfoEntity> list=strategyInfoService.queryStrategyInfo(systemID,projectId);
return HttpResult.ok(list); return HttpResult.ok(list);
} }
} }

60
user-service/src/main/java/com/mh/user/controller/SysDictController.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.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();
}
}

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.http.HttpResult;
import com.mh.common.utils.IOUtils; import com.mh.common.utils.IOUtils;
import com.mh.user.annotation.SysLogger; 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.model.SysUser;
import com.mh.user.security.JwtAuthenticatioToken; import com.mh.user.security.JwtAuthenticatioToken;
import com.mh.user.service.SysRoleService; import com.mh.user.service.SysRoleService;
import com.mh.user.service.SysUserService; import com.mh.user.service.SysUserService;
import com.mh.user.utils.AESUtil;
import com.mh.user.utils.PasswordUtils; import com.mh.user.utils.PasswordUtils;
import com.mh.user.utils.SecurityUtils; import com.mh.user.utils.SecurityUtils;
import com.mh.user.vo.LoginBean; import com.mh.user.vo.LoginBean;
@ -93,6 +88,7 @@ public class SysLoginController {
} }
// 系统登录认证 // 系统登录认证
JwtAuthenticatioToken token = SecurityUtils.login(request, username, password, authenticationManager); JwtAuthenticatioToken token = SecurityUtils.login(request, username, password, authenticationManager);
sysUserService.updateLoginTime(user.getId());
return HttpResult.ok(token); 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:获取所有菜单,不包含按钮 //查询菜单树,用户ID和用户名为空则查询全部,获取菜单类型,0:获取所有菜单,包含按钮,1:获取所有菜单,不包含按钮
@GetMapping(value="/findNavTree") @GetMapping(value="/findNavTree")
public HttpResult findNavTree(@RequestParam String systemID,@RequestParam String userName) { public HttpResult findNavTree(@RequestParam String systemId,@RequestParam String userName) {
return HttpResult.ok(sysMenuService.findTree(systemID,userName, 0)); return HttpResult.ok(sysMenuService.findTree(systemId,userName, 0));
} }
@GetMapping(value="/findMenuTree") @GetMapping(value="/findMenuTree")
public HttpResult findMenuTree(@RequestParam String systemID) { public HttpResult findMenuTree(@RequestParam String systemId) {
return HttpResult.ok(sysMenuService.findTree(systemID,"", 0)); 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") @GetMapping(value="/findPermissions")
public HttpResult findPermissions(@RequestParam String systemID,@RequestParam String name) { public HttpResult findPermissions(@RequestParam String systemId,@RequestParam String name) {
return HttpResult.ok(sysUserService.findPermissions(systemID,name)); return HttpResult.ok(sysUserService.findPermissions(systemId,name));
} }
@GetMapping(value="/findUserRoles") @GetMapping(value="/findUserRoles")

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

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

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

@ -1,77 +1,77 @@
package com.mh.user.dynamic.config; //package com.mh.user.dynamic.config;
//
import com.alibaba.druid.pool.DruidDataSource; //import com.alibaba.druid.pool.DruidDataSource;
import com.mh.user.dynamic.datasource.DynamicDataSource; //import com.mh.user.dynamic.datasource.DynamicDataSource;
import org.apache.ibatis.session.SqlSessionFactory; //import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean; //import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate; //import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan; //import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier; //import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; //import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; //import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//
import javax.sql.DataSource; //import javax.sql.DataSource;
import java.util.HashMap; //import java.util.HashMap;
import java.util.Map; //import java.util.Map;
//
/** ///**
* @author chison // * @author chison
* @date 2020-04-02 09:39 // * @date 2020-04-02 09:39
* @Description // * @Description
*/ // */
@Configuration //@Configuration
@MapperScan("com.mh.*.mapper") // 扫描DAO //@MapperScan("com.mh.*.mapper") // 扫描DAO
public class DataSourceConfig { //public class DataSourceConfig {
//
@Value("${spring.datasource.druid.url}") // @Value("${spring.datasource.druid.url}")
private String defaultDBUrl; // private String defaultDBUrl;
@Value("${spring.datasource.druid.username}") // @Value("${spring.datasource.druid.username}")
private String defaultDBUser; // private String defaultDBUser;
@Value("${spring.datasource.druid.password}") // @Value("${spring.datasource.druid.password}")
private String defaultDBPassword; // private String defaultDBPassword;
@Value("${spring.datasource.druid.driver-class-name}") // @Value("${spring.datasource.druid.driver-class-name}")
private String defaultDBDreiverName; // private String defaultDBDreiverName;
//
//
@Bean // @Bean
public DynamicDataSource dynamicDataSource() { // public DynamicDataSource dynamicDataSource() {
DynamicDataSource dynamicDataSource = DynamicDataSource.getInstance(); // DynamicDataSource dynamicDataSource = DynamicDataSource.getInstance();
//
DruidDataSource defaultDataSource = new DruidDataSource(); // DruidDataSource defaultDataSource = new DruidDataSource();
defaultDataSource.setUrl(defaultDBUrl); // defaultDataSource.setUrl(defaultDBUrl);
defaultDataSource.setUsername(defaultDBUser); // defaultDataSource.setUsername(defaultDBUser);
defaultDataSource.setPassword(defaultDBPassword); // defaultDataSource.setPassword(defaultDBPassword);
defaultDataSource.setDriverClassName(defaultDBDreiverName); // defaultDataSource.setDriverClassName(defaultDBDreiverName);
//
Map<Object,Object> map = new HashMap<>(); // Map<Object,Object> map = new HashMap<>();
map.put("default", defaultDataSource); // map.put("default", defaultDataSource);
dynamicDataSource.setTargetDataSources(map); // dynamicDataSource.setTargetDataSources(map);
dynamicDataSource.setDefaultTargetDataSource(defaultDataSource); // dynamicDataSource.setDefaultTargetDataSource(defaultDataSource);
//
return dynamicDataSource; // return dynamicDataSource;
} // }
//
@Bean // @Bean
public SqlSessionFactory sqlSessionFactory( // public SqlSessionFactory sqlSessionFactory(
@Qualifier("dynamicDataSource") DataSource dynamicDataSource) // @Qualifier("dynamicDataSource") DataSource dynamicDataSource)
throws Exception { // throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); // SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dynamicDataSource); // bean.setDataSource(dynamicDataSource);
bean.setTypeAliasesPackage("com.mh.*.model"); // 扫描Model // bean.setTypeAliasesPackage("com.mh.*.model"); // 扫描Model
//
bean.setMapperLocations(new PathMatchingResourcePatternResolver() // bean.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources("classpath*:**/sqlmapper/*.xml")); // .getResources("classpath*:**/sqlmapper/*.xml"));
return bean.getObject(); // return bean.getObject();
//
} // }
//
@Bean(name = "sqlSessionTemplate") // @Bean(name = "sqlSessionTemplate")
public SqlSessionTemplate sqlSessionTemplate( // public SqlSessionTemplate sqlSessionTemplate(
@Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory) // @Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory)
throws Exception { // throws Exception {
return new SqlSessionTemplate(sqlSessionFactory); // 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; //package com.mh.user.dynamic.config;
//
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; //import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Bean;
import tk.mybatis.spring.mapper.MapperScannerConfigurer; //import tk.mybatis.spring.mapper.MapperScannerConfigurer;
//
import java.util.Properties; //import java.util.Properties;
//
/** ///**
* @author chison // * @author chison
* @date 2020-04-02 09:40 // * @date 2020-04-02 09:40
* @Description // * @Description
*/ // */
@EnableAutoConfiguration //@EnableAutoConfiguration
public class MyBatisMapperScannerConfig { //public class MyBatisMapperScannerConfig {
@Bean // @Bean
public MapperScannerConfigurer mapperScannerConfigurer() { // public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); // MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory"); // mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
mapperScannerConfigurer.setBasePackage("com.mh.user.mapper"); // mapperScannerConfigurer.setBasePackage("com.mh.user.mapper");
Properties properties = new Properties(); // Properties properties = new Properties();
properties.setProperty("notEmpty", "false"); // properties.setProperty("notEmpty", "false");
properties.setProperty("IDENTITY", "MYSQL"); // properties.setProperty("IDENTITY", "MYSQL");
mapperScannerConfigurer.setProperties(properties); // mapperScannerConfigurer.setProperties(properties);
return mapperScannerConfigurer; // 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; //package com.mh.user.dynamic.datasource;
//
import com.alibaba.druid.pool.DruidDataSource; //import com.alibaba.druid.pool.DruidDataSource;
import com.mh.user.entity.DBEntity; //import com.mh.user.entity.DBEntity;
//
import java.util.HashMap; //import java.util.HashMap;
import java.util.Map; //import java.util.Map;
//
/** ///**
* @author chison // * @author chison
* @date 2020-04-02 09:40 // * @date 2020-04-02 09:40
* @Description // * @Description
*/ // */
public class DataSourceObject { //public class DataSourceObject {
//
private Long MaxWait=6000L; // private Long MaxWait=6000L;
private Integer maxActive=10; // private Integer maxActive=10;
private Long timeBetweenEvictionRunsMillis=6000L; // private Long timeBetweenEvictionRunsMillis=6000L;
//
/** // /**
* 切换sqlserver数据库并动态赋值 // * 切换sqlserver数据库,并动态赋值
* @param dbInfo // * @param dbInfo
* @param SourceName // * @param SourceName
*/ // */
public void SwitchMySQLDataSource(DBEntity dbInfo, String SourceName) { // public void SwitchMySQLDataSource(DBEntity dbInfo, String SourceName) {
System.out.println("mysql进入数据源切换"); // System.out.println("mysql进入数据源切换");
System.out.println("MaxWait:"+MaxWait); // System.out.println("MaxWait:"+MaxWait);
DruidDataSource dynamicDataSource = new DruidDataSource(); // DruidDataSource dynamicDataSource = new DruidDataSource();
dynamicDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); // 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.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.setUsername(dbInfo.getDB_UserName());
dynamicDataSource.setPassword(dbInfo.getDB_Pwd()); // dynamicDataSource.setPassword(dbInfo.getDB_Pwd());
dynamicDataSource.setMaxWait(MaxWait); // dynamicDataSource.setMaxWait(MaxWait);
dynamicDataSource.setMaxActive(maxActive); // dynamicDataSource.setMaxActive(maxActive);
dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//
DynamicDataSource dataSource = DynamicDataSource.getInstance(); // DynamicDataSource dataSource = DynamicDataSource.getInstance();
Map<Object, Object> map=new HashMap<Object, Object>(); // Map<Object, Object> map=new HashMap<Object, Object>();
map.put(SourceName, dynamicDataSource); // map.put(SourceName, dynamicDataSource);
dataSource.setTargetDataSources(map); // dataSource.setTargetDataSources(map);
System.out.println(dynamicDataSource.getUrl()); // System.out.println(dynamicDataSource.getUrl());
System.out.println(SourceName); // System.out.println(SourceName);
} // }
/** // /**
* 第二个sqlserver数据库 // * 第二个sqlserver数据库
* @param dbInfo // * @param dbInfo
* @param SourceName // * @param SourceName
*/ // */
public void SwitchSQLServerDataSource(DBEntity dbInfo,String SourceName) { // public void SwitchSQLServerDataSource(DBEntity dbInfo,String SourceName) {
System.out.println("进入数据源切换"); // System.out.println("进入数据源切换");
System.out.println("MaxWait:"+MaxWait); // System.out.println("MaxWait:"+MaxWait);
DruidDataSource dynamicDataSource = new DruidDataSource(); // DruidDataSource dynamicDataSource = new DruidDataSource();
dynamicDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // dynamicDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
dynamicDataSource.setUrl("jdbc:sqlserver://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+";Databasename="+dbInfo.getDB_Names()); // dynamicDataSource.setUrl("jdbc:sqlserver://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+";Databasename="+dbInfo.getDB_Names());
dynamicDataSource.setUsername(dbInfo.getDB_UserName()); // dynamicDataSource.setUsername(dbInfo.getDB_UserName());
dynamicDataSource.setPassword(dbInfo.getDB_Pwd()); // dynamicDataSource.setPassword(dbInfo.getDB_Pwd());
System.out.println(dbInfo.getDB_UserName()); // System.out.println(dbInfo.getDB_UserName());
System.out.println(dbInfo.getDB_Pwd()); // System.out.println(dbInfo.getDB_Pwd());
dynamicDataSource.setMaxWait(MaxWait); // dynamicDataSource.setMaxWait(MaxWait);
dynamicDataSource.setMaxActive(maxActive); // dynamicDataSource.setMaxActive(maxActive);
dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//
DynamicDataSource dataSource = DynamicDataSource.getInstance(); // DynamicDataSource dataSource = DynamicDataSource.getInstance();
Map<Object, Object> map=new HashMap<Object, Object>(); // Map<Object, Object> map=new HashMap<Object, Object>();
map.put(SourceName, dynamicDataSource); // map.put(SourceName, dynamicDataSource);
dataSource.setTargetDataSources(map); // dataSource.setTargetDataSources(map);
//
System.out.println(dynamicDataSource.getUrl()); // System.out.println(dynamicDataSource.getUrl());
System.out.println(SourceName); // 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; package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -21,6 +23,7 @@ public class BaseEntity implements Serializable {
static final long serialVersionUID = 42L; static final long serialVersionUID = 42L;
@TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @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; package com.mh.user.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date; @TableName("data_result_ch")
public class DataResultChEntity extends BaseResultEntity {
@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;
} }

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; 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 lombok.Data;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@Data @Data
@TableName("data_result_cl")
public class DataResultClEntity { public class DataResultClEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
private String deviceAddr; private String deviceAddr;
private String deviceType; private String deviceType;
private double lastValue;
private Date lastDate;
private double curValue;
private Date curDate; private Date curDate;
private double ratio; private BigDecimal curValue;
private double calcValue; private BigDecimal lastValue;
private Date lastDate;
private BigDecimal ratio;
private BigDecimal calcValue;
private int grade; private int grade;
private String havedUpdate;
private String registerAddr; private String registerAddr;
private String registerName; private String registerName;
private String projectName; private String projectName;
private String projectID; private String projectId;
} }

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

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

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;
}

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

@ -1,7 +1,16 @@
package com.mh.user.entity; package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Date; import java.util.Date;
@Setter
@Getter
@ToString
@TableName("device_code_param")
public class DeviceCodeParamEntity { public class DeviceCodeParamEntity {
private Long id; private Long id;
@ -20,141 +29,6 @@ public class DeviceCodeParamEntity {
private int grade; //级别 private int grade; //级别
private String dataValue; //传入值 private String dataValue; //传入值
private Date createTime; private Date createTime;
private String projectID; 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;
}
} }

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

@ -12,9 +12,9 @@ public class DeviceInfoEntity {
private String power; //功率 private String power; //功率
private String madeTime; //制造时间 private String madeTime; //制造时间
private String flow; //流量 private String flow; //流量
private String isFC; //是否变频 private String isFc; //是否变频
private String motorBrand; //机电品牌 private String motorBrand; //机电品牌
private String projectID; //项目ID private String projectId; //项目ID
private String systemID; //系统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; package com.mh.user.entity;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@Data @Data
@ -14,9 +16,9 @@ public class DeviceInstallEntity {
private String dataPort; private String dataPort;
private int baudRate; private int baudRate;
private String parity; private String parity;
private double ratio; private BigDecimal ratio;
private double initValue; private BigDecimal initValue;
private double lastValue; private BigDecimal lastValue;
private Date lastDate; private Date lastDate;
private String standard; private String standard;
private String isTotal; private String isTotal;
@ -25,7 +27,10 @@ public class DeviceInstallEntity {
private String brand; private String brand;
private String installPosition; private String installPosition;
private Date installDate; private Date installDate;
private String projectID; private String projectId;
private String remarks; private String remarks;
private String registerAddr;
private String registerName;
private String funCode;
private int digit;
} }

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 + '\'' +
'}';
}
}

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

@ -0,0 +1,142 @@
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 int grade;
/**
* 系统类型id
*/
private Long systemId;
/**
* 项目id
*/
private Long projectId;
@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 +
'}';
}
}

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

@ -2,7 +2,6 @@ package com.mh.user.entity;
import lombok.Data; import lombok.Data;
@Data
public class EnergyDataEntity { public class EnergyDataEntity {
private long id; private long id;
@ -13,6 +12,102 @@ public class EnergyDataEntity {
private Double elect; private Double elect;
private Double cl; private Double cl;
private Double cop; private Double cop;
private String projectID; private String projectId;
private String projectName; 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 int checkInCount; //楼栋人数
private double perElect; //平均用电 private double perElect; //平均用电
private double perWater; //平均用水 private double perWater; //平均用水
private String projectID; //项目编号 private String projectId; //项目编号
private String projectName; //项目名称 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 Long id; //序号
private String curDate; //日期 private String curDate; //日期
private String buildingId; //楼栋编号 private String buildingId; //楼栋编号
private String projectID; //项目编号 private String projectId; //项目编号
private String useHotWater; //用水 private String useHotWater; //用水
private String electValue; //用电 private String electValue; //用电
private String electWater; //单耗 private String electWater; //单耗

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

@ -1,8 +1,10 @@
package com.mh.user.entity; package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
@ -14,20 +16,25 @@ import java.util.Date;
* @updateTime 2020-05-21 * @updateTime 2020-05-21
* @throws * @throws
*/ */
@Data @Setter
@Getter
@ToString
@TableName("gateway_manage")
public class GatewayManageEntity extends BaseEntity { public class GatewayManageEntity extends BaseEntity {
private String gatewayName; // 网关名称 private String gwName; // 网关名称
private String gatewayIP; // 网关IP地址 private String gwIp; // 网关IP地址
private String gatewayAddress; // 网关安装地址 private String gwAddr; // 网关安装地址
private String dataCom; // 串口号 private int port; // 端口号
private String createDate; // 安装时间 private int collectionLoop; // 采集周期
private String connectDate; // 最新上线连接时间 private Date connectTime; // 最新上线连接时间
private int grade; // 标志位(连接状态) 0:正常;1:不在线;2:异常
private String internetCard; // 物联网卡号 private String internetCard; // 物联网卡号
private int operator; //0:中国移动 1:中国联通 2:中国电信 private int operatorType; // 0:中国移动 1:中国联通 2:中国电信
private int gatewayPort; // 端口号 private int communicationType; // 通讯类型
private String type; // 操作类型 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; 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 lombok.Data;
@TableName("meter_info")
@Data @Data
public class MeterInfoEntity { public class MeterInfoEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
private String meterName; //表名称 private String meterName; //表名称
private String meterType; //表类型 private String meterType; //表类型
@ -16,6 +22,7 @@ public class MeterInfoEntity {
private String caliber; //口径 private String caliber; //口径
private String range; //测量范围 private String range; //测量范围
private String structural; //结构形式 private String structural; //结构形式
private String projectID; //项目ID private String projectId; //项目ID
private String systemID; //系统ID private String systemId; //系统ID
} }

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

@ -0,0 +1,228 @@
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 Long protocolType;
/**
* 备注
*/
private String remark;
/**
* 保留位
*/
private int grade;
/**
* 系统类型id
*/
private Long systemId;
/**
* 项目id
*/
private Long projectId;
/**
* 通讯类型
*/
private Long communicationType;
@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 +
'}';
}
}

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

@ -1,18 +1,192 @@
package com.mh.user.entity; 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 { public class ProjectInfoEntity {
private String id; @TableId(value = "id", type = IdType.AUTO)
private Long id;
@TableField("project_name")
private String projectName; //项目名称 private String projectName; //项目名称
@TableField("p_address")
private String pAddress; //地址 private String pAddress; //地址
@TableField("p_scale")
private int pScale; private int pScale;
private String pic; //图片
@TableField("pic")
private String pic; //图片地址
@TableField("pic_content")
private String picContent; // 图片内容
@TableField("tel")
private String tel; //电话 private String tel; //电话
private String systemID; //系统编号
@TableField("system_id")
private String systemId; //系统编号
@TableField("remarks")
private String 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 int getpScale() {
return pScale;
}
public void setpScale(int 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; package com.mh.user.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@TableName("register_addr")
@Data @Data
public class RegisterAddrEntity { public class RegisterAddrEntity {

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

@ -1,14 +1,77 @@
package com.mh.user.entity; 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 { public class StrategyInfoEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
private String dataAnalysis; private String dataAnalysis;
private String operationOpt; private String operationOpt;
private String controlOpt; private String controlOpt;
private String projectID; private String projectId;
private String systemID; 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; package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType; import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; 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; package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType; import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; 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; package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType; import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; 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; package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType; import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; 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; package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType; import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; 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; package com.mh.user.entity.chart;
import com.alibaba.fastjson.annotation.JSONType; import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

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

@ -1,26 +1,16 @@
package com.mh.user.job; package com.mh.user.job;
import com.mh.user.entity.AddCronJobReq;
import com.mh.user.entity.ProjectInfoEntity; import com.mh.user.entity.ProjectInfoEntity;
import com.mh.user.manage.QuartzManager;
import com.mh.user.netty.EchoServer; 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.ProjectInfoService;
import com.mh.user.utils.GetReadOrder485; import com.mh.user.utils.GetReadOrder485;
import gnu.io.SerialPort; import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author ljf * @author ljf
@ -29,11 +19,10 @@ import java.util.Map;
* @updateTime 2020-05-15 * @updateTime 2020-05-15
* @throws * @throws
*/ */
@Slf4j
@Component @Component
public class CollectionLoopRunner implements ApplicationRunner { 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 @Autowired
@ -45,7 +34,7 @@ public class CollectionLoopRunner implements ApplicationRunner {
List<ProjectInfoEntity> projectInfoEntities = projectInfoService.queryProjectInfo("1"); List<ProjectInfoEntity> projectInfoEntities = projectInfoService.queryProjectInfo("1");
if (null != projectInfoEntities && !projectInfoEntities.isEmpty()) { if (null != projectInfoEntities && !projectInfoEntities.isEmpty()) {
for (ProjectInfoEntity projectInfoEntity : projectInfoEntities) { for (ProjectInfoEntity projectInfoEntity : projectInfoEntities) {
getReadOrder485.createOrderParam(projectInfoEntity.getId()); //生成采集参数,1新珠江(6000),2广合科技(6001),3广大科技(6002),6珠江国际,7保利山庄,8东莞迎宾馆 getReadOrder485.createOrderParam(String.valueOf(projectInfoEntity.getId())); //生成采集参数,1新珠江(6000),2广合科技(6001),3广大科技(6002),6珠江国际,7保利山庄,8东莞迎宾馆
} }
} }
try{ try{
@ -55,215 +44,4 @@ public class CollectionLoopRunner implements ApplicationRunner {
} }
} }
// 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)) {
//// //数据解析方法 此处编写你的解析方法,根据获取到的数据编写适合自己的方法
//// }
// }
// });
// }
// }
} }

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

33
user-service/src/main/java/com/mh/user/mapper/DataResultFiveMiMapper.java

@ -0,0 +1,33 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultChEntity;
import com.mh.user.entity.DataResultFiveMiEntity;
import com.mh.user.entity.DataResultOneMiEntity;
import com.mh.user.mapper.provider.DataResultProvider;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 每分钟保存数据
* @date 2024-07-10 17:34:30
*/
@Mapper
public interface DataResultFiveMiMapper extends BaseMapper<DataResultFiveMiEntity> {
@SelectProvider(type = DataResultProvider.class,method = "queryDataResultFiveMi")
List<DataResultChEntity> queryDataResultFiveMi(@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_five_mi where projectId=#{projectId} and curDate>=#{startDate} and curDate<=#{curDate} ")
@SelectProvider(type = DataResultProvider.class,method = "dataResultFiveMiCount")
int dataResultFiveMiCount(@Param("projectId") String projectId,@Param("startDate") String startDate,@Param("curDate") String curDate);
}

235
user-service/src/main/java/com/mh/user/mapper/DataResultMapper.java

@ -1,5 +1,6 @@
package com.mh.user.mapper; package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultClEntity; import com.mh.user.entity.DataResultClEntity;
import com.mh.user.entity.DataResultEntity; import com.mh.user.entity.DataResultEntity;
import com.mh.user.entity.DataResultChEntity; import com.mh.user.entity.DataResultChEntity;
@ -10,34 +11,34 @@ import org.apache.ibatis.annotations.*;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface DataResultMapper { public interface DataResultMapper extends BaseMapper<DataResultEntity> {
//保存水电表等数据 //保存水电表等数据
@Insert("insert into data_result(device_addr,deviceType,project_id,lastValue,lastDate,cur_value,cur_date,ratio,calc_value,grade) values (" + @Insert("insert into data_result(device_addr,device_type,project_id,last_value,last_date,cur_value,cur_date,ratio,calc_value,grade) values (" +
" #{deviceAddr},#{deviceType},#{projectID},#{lastValue},#{lastDate},#{curValue},#{curDate},#{ratio},#{calcValue},#{grade})") " #{deviceAddr},#{deviceType},#{projectId},#{lastValue},#{lastDate},#{curValue},#{curDate},#{ratio},#{calcValue},#{grade})")
void saveDataResult(DataResultEntity dataResultEntity); void saveDataResult(DataResultEntity dataResultEntity);
@Update("<script>" + @Update("<script>" +
" update data_result set " + " update data_result set " +
" <if test='deviceAddr!=null'> device_addr = #{deviceAddr} </if>" + " <if test='deviceAddr!=null'> device_addr = #{deviceAddr} </if>" +
" <if test='deviceType!=null'> , deviceType = #{deviceType} </if>" + " <if test='deviceType!=null'> , device_type = #{deviceType} </if>" +
" <if test='projectID!=null'> , project_id = #{projectID} </if>" + " <if test='projectId!=null'> , project_id = #{projectId} </if>" +
" <if test='lastValue!=null'> , lastValue = #{lastValue} </if>" + " <if test='lastValue!=null'> , last_value = #{lastValue} </if>" +
" <if test='lastDate!=null'> , lastDate = #{lastDate} </if>" + " <if test='lastDate!=null'> , last_date = #{lastDate} </if>" +
" <if test='curValue!=null'> , cur_value = #{curValue} </if>" + " <if test='curValue!=null'> , cur_value = #{curValue} </if>" +
" <if test='ratio!=null'> , ratio = #{ratio} </if>" + " <if test='ratio!=null'> , ratio = #{ratio} </if>" +
" <if test='calcValue!=null'> , calc_value = #{calcValue} </if>" + " <if test='calcValue!=null'> , calc_value = #{calcValue} </if>" +
" <if test='grade!=null'> , grade = #{grade} </if>" + " <if test='grade!=null'> , grade = #{grade} </if>" +
" where cur_date=#{curDate} and device_addr=#{deviceAddr} and deviceType=#{deviceType}" + " where cur_date=#{curDate} and device_addr=#{deviceAddr} and device_type=#{deviceType}" +
"</script>") "</script>")
void updateDataResult(DataResultEntity dataResultEntity); void updateDataResult(DataResultEntity dataResultEntity);
@Results(id="rs", value = { @Results(id="rs", value = {
@Result(property="deviceAddr",column="device_addr"), @Result(property="deviceAddr",column="device_addr"),
@Result(property="deviceType",column="deviceType"), @Result(property="deviceType",column="device_type"),
@Result(property="projectID",column="project_id"), @Result(property="projectId",column="project_id"),
@Result(property="lastValue",column="lastValue"), @Result(property="lastValue",column="last_value"),
@Result(property ="lastDate",column ="lastDate"), @Result(property ="lastDate",column ="last_date"),
@Result(property ="curValue",column ="cur_value"), @Result(property ="curValue",column ="cur_value"),
@Result(property="curDate",column="cur_date"), @Result(property="curDate",column="cur_date"),
@Result(property="ratio",column="ratio"), @Result(property="ratio",column="ratio"),
@ -45,7 +46,7 @@ public interface DataResultMapper {
@Result(property="grade",column="grade") @Result(property="grade",column="grade")
}) })
@SelectProvider(type = DataResultProvider.class,method = "queryDataResult") @SelectProvider(type = DataResultProvider.class,method = "queryDataResult")
List<DataResultEntity> queryDataResult(@Param("projectID") String projectID, List<DataResultEntity> queryDataResult(@Param("projectId") String projectId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@Param("deviceType") String deviceType, @Param("deviceType") String deviceType,
@ -54,7 +55,7 @@ public interface DataResultMapper {
@SelectProvider(type = DataResultProvider.class,method = "getDataResultCount") @SelectProvider(type = DataResultProvider.class,method = "getDataResultCount")
int getDataResultCount(@Param("projectID") String projectID, int getDataResultCount(@Param("projectId") String projectId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@Param("deviceType") String deviceType, @Param("deviceType") String deviceType,
@ -75,210 +76,4 @@ public interface DataResultMapper {
@Param("deviceAddr") String deviceAddr, @Param("deviceAddr") String deviceAddr,
@Param("deviceType") String deviceType); @Param("deviceType") String deviceType);
//----------------------------------------------------------------------------------------------
//保存冷量计数据
@Insert("insert into data_result_cl(device_addr,deviceType,project_id,lastValue,lastDate,cur_value,cur_date,ratio,calc_value,grade,registerAddr,registerName) 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'> , deviceType = #{deviceType} </if>" +
" <if test='projectID!=null'> , project_id = #{projectID} </if>" +
" <if test='lastValue!=null'> , lastValue = #{lastValue} </if>" +
" <if test='lastDate!=null'> , lastDate = #{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'> , registerAddr = #{registerAddr} </if>" +
" <if test='registerName!=null'> , registerName = #{registerName} </if>" +
" where cur_date=#{curDate} and device_addr=#{deviceAddr} and deviceType=#{deviceType}" +
"</script>")
void updateDataResultCl(DataResultClEntity dataResultClEntity);
@Insert("insert into data_result_cl_bak(device_addr,deviceType,project_id,lastValue,lastDate,cur_value,cur_date,ratio,calc_value,grade,registerAddr,registerName) values (" +
" #{deviceAddr},#{deviceType},#{projectID},#{lastValue},#{lastDate},#{curValue},#{curDate},#{ratio},#{calcValue},#{grade},#{registerAddr},#{registerName})")
void saveDataResultCl_bak(DataResultClEntity dataResultClEntity);
//----------------------------------------------------------------------------------------------
//保存冷量计数据
@Insert("insert into data_result_ch(deviceAddr,deviceType,funCode,registerAddr,registerName,curValue,curDate,projectID,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'> deviceAddr = #{deviceAddr} </if>" +
" <if test='deviceType!=null'> , deviceType = #{deviceType} </if>" +
" <if test='funCode!=null'> , funCode = #{funCode} </if>" +
" <if test='registerAddr!=null'> , registerAddr = #{registerAddr} </if>" +
" <if test='registerName!=null'> , registerName = #{registerName} </if>" +
" <if test='curValue!=null'> , curValue = #{curValue} </if>" +
" <if test='projectID!=null'> , projectID = #{projectID} </if>" +
" <if test='grade!=null'> , grade = #{grade} </if>" +
" where curDate=#{curDate} and deviceAddr=#{deviceAddr} and deviceType=#{deviceType}" +
"</script>")
void updateDataResultCh(DataResultChEntity dataResultChEntity);
@Select("select count(*) from data_result_ch " +
" where curDate=#{curDate} " +
" and deviceAddr=#{deviceAddr} " +
" and registerAddr=#{registerAddr} " +
" and projectID=#{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);
//----------------------------------------------------------------------------------------------------
@Results(id="rsc", value = {
@Result(property="deviceAddr",column="deviceAddr"),
@Result(property="deviceType",column="deviceType"),
@Result(property="curDate",column="curDate"),
@Result(property ="curValue",column ="curValue"),
@Result(property="funCode",column="funCode"),
@Result(property="registerAddr",column="registerAddr"),
@Result(property="registerName",column="registerName"),
@Result(property="grade",column="grade"),
@Result(property="projectID",column="projectID"),
@Result(property="projectName",column="project_name")
})
@SelectProvider(type = DataResultProvider.class,method = "queryDataResultOneMi")
List<DataResultChEntity> queryDataResultOneMi(@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_one_mi where projectID=#{projectID} and curDate>=#{startDate} and curDate<=#{curDate} ")
@SelectProvider(type = DataResultProvider.class,method = "dataResultOneMiCount")
int dataResultOneMiCount(@Param("projectID") String projectID,@Param("startDate") String startDate,@Param("curDate") String curDate);
@ResultMap("rsc")
@SelectProvider(type = DataResultProvider.class,method = "queryDataResultFiveMi")
List<DataResultChEntity> queryDataResultFiveMi(@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_five_mi where projectID=#{projectID} and curDate>=#{startDate} and curDate<=#{curDate} ")
@SelectProvider(type = DataResultProvider.class,method = "dataResultFiveMiCount")
int dataResultFiveMiCount(@Param("projectID") String projectID,@Param("startDate") String startDate,@Param("curDate") String curDate);
@ResultMap("rsc")
@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);
@ResultMap("rsc")
@Select("select t1.projectID,sum(cast (t1.curValue AS decimal(18,2)))as curValue,t1.curDate,t2.project_name from data_result_ch t1 join project_info t2 on t1.projectID=t2.id " +
"where t1.projectID=#{projectID} and t1.curDate>=#{startDate} and t1.curDate<=#{curDate} group by t1.curDate,t1.projectID,t2.project_name order by t1.curDate ")
List<DataResultChEntity> queryDataResultCh(@Param("projectID") String projectID,@Param("startDate") String startDate,@Param("curDate") String curDate);
//保存冷水机数据
@Insert("insert into data_result_chiller(deviceAddr,deviceType,funCode,registerAddr,registerName,curValue,curDate,projectID,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'> deviceAddr = #{deviceAddr} </if>" +
" <if test='deviceType!=null'> , deviceType = #{deviceType} </if>" +
" <if test='funCode!=null'> , funCode = #{funCode} </if>" +
" <if test='registerAddr!=null'> , registerAddr = #{registerAddr} </if>" +
" <if test='registerName!=null'> , registerName = #{registerName} </if>" +
" <if test='curValue!=null'> , curValue = #{curValue} </if>" +
" <if test='projectID!=null'> , projectID = #{projectID} </if>" +
" <if test='grade!=null'> , grade = #{grade} </if>" +
" where curDate=#{curDate} and deviceAddr=#{deviceAddr} and registerAddr=#{registerAddr} and projectID=#{projectID} " +
"</script>")
void updateDataResultChiller(DataResultChEntity dataResultChEntity);
@Select("select count(*) from data_result_chiller where curDate=#{curDate} " +
" and deviceAddr=#{deviceAddr} " +
" and registerAddr=#{registerAddr} " +
" and projectID=#{projectID} " +
" and funCode = #{funCode} ")
int selectDataResultChillerCount(@Param("curDate") String curDate,
@Param("deviceAddr") String deviceAddr,
@Param("registerAddr") String registerAddr,
@Param("projectID") String projectID,
@Param("funCode") String funCode);
@Insert("insert into data_result_now(deviceAddr,deviceType,funCode,registerAddr,registerName,curValue,curDate,projectID,grade) values (" +
" #{deviceAddr},#{deviceType},#{funCode},#{registerAddr},#{registerName},#{curValue},#{curDate},#{projectID},#{grade})")
void saveDataResultNow(DataResultChEntity dataResultChEntity);
@Delete("delete from data_result_now where deviceAddr=#{deviceAddr} and deviceType = #{deviceType} and registerAddr=#{registerAddr} and projectID=#{projectID}")
void deleteDataResultNow(@Param("deviceAddr") String deviceAddr,
@Param("deviceType") String deviceType,
@Param("registerAddr") String registerAddr,
@Param("projectID") String projectID);
//实时参数读取
@Select("select * from data_result_now where deviceAddr=#{deviceAddr} and deviceType=#{deviceType} and projectID=#{projectID} ")
List<DataResultChEntity> selectDataResultNow(@Param("deviceAddr") String deviceAddr,
@Param("deviceType") String deviceType,
@Param("projectID") String projectID);
@Results({
@Result(property="deviceAddr",column="deviceAddr"),
@Result(property="deviceType",column="deviceType"),
@Result(property="curDate",column="curDate"),
@Result(property ="curValue",column ="curValue"),
@Result(property="funCode",column="funCode"),
@Result(property="registerAddr",column="registerAddr"),
@Result(property="registerName",column="registerName"),
@Result(property="grade",column="grade"),
@Result(property="projectID",column="projectID"),
@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(deviceAddr,deviceName,runState,setPoint,enterChw,leaveChw,enterCow,leaveCow,power,ratedPower,chillerAmps,refrigeration,ratedRef,chwFlow,ApproachCow,ApproachChw,cop,ratedCop,copyDate) values (" +
" #{deviceAddr},#{deviceName},#{projectID},#{lastValue},#{lastDate},#{curValue},#{curDate},#{ratio},#{calcValue},#{grade})")
void saveDataChiller(ChillerModel chillerModel);
@Select("select count(1) from data_result_cl_bak " +
" where cur_date = #{curDate} " +
" and device_addr = #{deviceAddr} " +
" and registerAddr = #{registerAddr} " +
" and project_id = #{projectId} ")
int selectDataResultChBakCount(@Param("curDate") String curDate,
@Param("deviceAddr") String deviceAddr,
@Param("registerAddr") String registerAddr,
@Param("projectId") String projectId);
} }

36
user-service/src/main/java/com/mh/user/mapper/DataResultNowMapper.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.DataResultNowEntity;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 当前记录
* @date 2024-07-11 13:41:04
*/
@Mapper
public interface DataResultNowMapper extends BaseMapper<DataResultNowEntity> {
@Insert("insert into data_result_now(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 saveDataResultNow(DataResultChEntity dataResultChEntity);
@Delete("delete from data_result_now where device_addr=#{deviceAddr} and device_type = #{deviceType} and register_addr=#{registerAddr} and project_id=#{projectId}")
void deleteDataResultNow(@Param("deviceAddr") String deviceAddr,
@Param("deviceType") String deviceType,
@Param("registerAddr") String registerAddr,
@Param("projectId") String projectId);
//实时参数读取
@Select("select * from data_result_now where device_addr=#{deviceAddr} and device_type=#{deviceType} and project_id=#{projectId} ")
List<DataResultChEntity> selectDataResultNow(@Param("deviceAddr") String deviceAddr,
@Param("deviceType") String deviceType,
@Param("projectId") String projectId);
}

46
user-service/src/main/java/com/mh/user/mapper/DataResultOneMiMapper.java

@ -0,0 +1,46 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DataResultChEntity;
import com.mh.user.entity.DataResultOneMiEntity;
import com.mh.user.mapper.provider.DataResultProvider;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 每分钟保存数据
* @date 2024-07-10 17:34:30
*/
@Mapper
public interface DataResultOneMiMapper extends BaseMapper<DataResultOneMiEntity> {
//----------------------------------------------------------------------------------------------------
@Results(id="rsc", value = {
@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 = "queryDataResultOneMi")
List<DataResultChEntity> queryDataResultOneMi(@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_one_mi where projectId=#{projectId} and curDate>=#{startDate} and curDate<=#{curDate} ")
@SelectProvider(type = DataResultProvider.class,method = "dataResultOneMiCount")
int dataResultOneMiCount(@Param("projectId") String projectId,@Param("startDate") String startDate,@Param("curDate") String curDate);
}

55
user-service/src/main/java/com/mh/user/mapper/DeviceCodeMapper.java

@ -0,0 +1,55 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DeviceCodeEntity;
import com.mh.user.model.ChillerModel;
import com.mh.user.model.DeviceModel;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 设备参数mapper
* @date 2024-07-11 15:37:48
*/
@Mapper
public interface DeviceCodeMapper extends BaseMapper<DeviceCodeEntity> {
//查询冷水机设备列表
@Results({
@Result(column = "device_addr",property = "deviceAddr" ),
@Result(column = "device_name", property = "deviceName")
})
@Select("select * from device_code where project_id=#{projectId} and device_type='冷水机'")
List<DeviceModel> selectDevices(@Param("projectId") String projectId);
//查询多个冷水机相关信息
@Results({
@Result(column = "device_addr",property = "deviceAddr" ),
@Result(column = "device_name", property = "deviceName"),
@Result(column = "run_State", property = "runState"),
@Result(column = "set_Point", property = "setPoint"),
@Result(column = "enter_chw", property = "enterChw"),
@Result(column = "leave_chw", property = "leaveChw"),
@Result(column = "enter_cow", property = "enterCow"),
@Result(column = "leave_cow", property = "leaveCow"),
@Result(column = "power", property = "power"),
@Result(column = "rated_power", property = "ratedPower"),
@Result(column = "chiller_amps", property = "chillerAmps"),
@Result(column = "refrigeration", property = "refrigeration"),
@Result(column = "rated_ref", property = "ratedRef"),
@Result(column = "chw_flow", property = "chwFlow"),
@Result(column = "approach_cow", property = "ApproachCow"),
@Result(column = "approach_chw", property = "ApproachChw"),
@Result(column = "cop", property = "cop"),
@Result(column = "rated_cop", property = "ratedCop"),
@Result(column = "copy_date", property = "copyDate")
})
@Select("select * from device_code where project_id=#{projectId} and device_addr=#{deviceAddr} ")
List<ChillerModel> queryChiller(@Param("projectId") String projectId, @Param("device_addr") String deviceAddr);
}

67
user-service/src/main/java/com/mh/user/mapper/DeviceCodeParamMapper.java

@ -1,5 +1,6 @@
package com.mh.user.mapper; package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DeviceCodeParamEntity; import com.mh.user.entity.DeviceCodeParamEntity;
import com.mh.user.entity.OrderMessageEntity; import com.mh.user.entity.OrderMessageEntity;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
@ -7,10 +8,10 @@ import org.apache.ibatis.annotations.*;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface DeviceCodeParamMapper { public interface DeviceCodeParamMapper extends BaseMapper<DeviceCodeParamEntity> {
//插入指令参数 //插入指令参数
@Insert("insert into device_code_param(device_addr,device_name,device_type,data_com,baudrate,brand,fun_code,register_addr,create_time)" + @Insert("insert into device_code_param(device_addr,device_name,device_type,data_com,baud_rate,brand,fun_code,register_addr,create_time)" +
"values(#{deviceAddr},#{deviceName},#{deviceType},#{dataCom},#{baudrate},#{brand},#{funCode},#{registerAddr},getDate())") "values(#{deviceAddr},#{deviceName},#{deviceType},#{dataCom},#{baudrate},#{brand},#{funCode},#{registerAddr},getDate())")
void insertDeviceCodeParam(DeviceCodeParamEntity deviceCodeParamEntity); void insertDeviceCodeParam(DeviceCodeParamEntity deviceCodeParamEntity);
@ -18,36 +19,36 @@ public interface DeviceCodeParamMapper {
@Results(id="rs", value = { @Results(id="rs", value = {
@Result(property="id",column="id"), @Result(property="id",column="id"),
@Result(property="deviceAddr",column="device_addr"), @Result(property="deviceAddr",column="device_addr"),
@Result(property="deviceType",column="deviceType"), @Result(property="deviceType",column="device_type"),
@Result(property="strData",column="strData"), @Result(property="strData",column="str_data"),
@Result(property="dataPort",column="dataPort"), @Result(property="dataPort",column="data_port"),
@Result(property="baudRate",column="baudrate"), @Result(property="baudRate",column="baud_rate"),
@Result(property ="brand",column ="brand"), @Result(property ="brand",column ="brand"),
@Result(property ="funCode",column ="fun_code"), @Result(property ="funCode",column ="fun_code"),
@Result(property ="registerAddr",column ="register_addr"), @Result(property ="registerAddr",column ="register_addr"),
@Result(property ="registerName",column ="registerName"), @Result(property ="registerName",column ="register_name"),
@Result(property ="deviceName",column ="deviceName"), @Result(property ="deviceName",column ="device_name"),
@Result(property ="createTime",column ="createTime"), @Result(property ="createTime",column ="create_time"),
@Result(property ="grade",column ="grade"), @Result(property ="grade",column ="grade"),
@Result(property ="digit",column ="digit"), @Result(property ="digit",column ="digit"),
@Result(property ="projectID",column ="project_id") @Result(property ="projectId",column ="project_id")
}) })
@Select("select id, " + @Select("select id, " +
"device_addr, " + "device_addr, " +
"deviceType, " + "device_type, " +
"strData, " + "str_data, " +
"dataPort, " + "data_port, " +
"baudrate, " + "baud_rate, " +
"brand, " + "brand, " +
"fun_code, " + "fun_code, " +
"register_addr, " + "register_addr, " +
"deviceName, " + "device_name, " +
"createTime, " + "create_time, " +
"grade, " + "grade, " +
"project_id, " + "project_id, " +
"digit, " + "digit, " +
"registerName " + "register_name " +
" from device_code_param where dataPort=#{gatewayPort} order by deviceType ") " from device_code_param where data_port=#{gatewayPort} order by device_type ")
List<DeviceCodeParamEntity> queryCodeParam(@Param("gatewayPort") String gatewayPort); List<DeviceCodeParamEntity> queryCodeParam(@Param("gatewayPort") String gatewayPort);
//查询指令参数,传入串口 //查询指令参数,传入串口
@ -57,20 +58,20 @@ public interface DeviceCodeParamMapper {
//查询所有指令参数 //查询所有指令参数
@ResultMap("rs") @ResultMap("rs")
@Select("select * from device_code_param order by data_com,deviceType") @Select("select * from device_code_param order by data_com,device_type")
List<DeviceCodeParamEntity> queryCodeParam3(); List<DeviceCodeParamEntity> queryCodeParam3();
//查询所有指令参数 //查询所有指令参数
@ResultMap("rs") @ResultMap("rs")
@Select("select * from device_code_param where project_id=#{projectID} and deviceType=#{deviceType} and device_addr=#{deviceAddr} and register_addr=#{registerAddr}") @Select("select * from device_code_param where project_id=#{projectId} and device_type=#{deviceType} and device_addr=#{deviceAddr} and register_addr=#{registerAddr}")
DeviceCodeParamEntity queryDeviceCodeParam(@Param("projectID") String projectID, DeviceCodeParamEntity queryDeviceCodeParam(@Param("projectId") String projectId,
@Param("deviceType") String deviceType, @Param("deviceType") String deviceType,
@Param("deviceAddr") String deviceAddr, @Param("deviceAddr") String deviceAddr,
@Param("registerAddr") String registerAddr); @Param("registerAddr") String registerAddr);
//查询记录数 //查询记录数
@Select("select count(*) from device_code_param where project_id=#{projectId} ") @Select("select count(*) from device_code_param where project_id=#{projectId} ")
int queryCount(@Param("projectId") String projectID); int queryCount(@Param("projectId") String projectId);
//查询记录数,所有项目 //查询记录数,所有项目
@Select("select count(*) from device_code_param ") @Select("select count(*) from device_code_param ")
@ -80,30 +81,30 @@ public interface DeviceCodeParamMapper {
@Insert("<script>" + @Insert("<script>" +
"insert into device_code_param(" + "insert into device_code_param(" +
"device_addr, " + "device_addr, " +
"deviceName, " + "device_name, " +
"deviceType, " + "device_type, " +
"dataPort, " + "data_port, " +
"baudRate, " + "baud_rate, " +
"brand, " + "brand, " +
"fun_code, " + "fun_code, " +
"register_addr," + "register_addr," +
"registerName," + "register_name," +
"createTime," + "create_time," +
"project_id," + "project_id," +
"parity," + "parity," +
"digit," + "digit," +
"grade," + "grade," +
"strData" + "str_data" +
")" + ")" +
"values " + "values " +
"<foreach collection='deviceCodeParamEntityList' item='item' separator=','>" + "<foreach collection='deviceCodeParamEntityList' item='item' separator=','>" +
"(#{item.deviceAddr},#{item.deviceName},#{item.deviceType},#{item.dataPort},#{item.baudRate},#{item.brand},#{item.funCode},#{item.registerAddr},#{item.registerName},getDate(),#{item.projectID},#{item.parity},#{item.digit},#{item.grade},#{item.strData})" + "(#{item.deviceAddr},#{item.deviceName},#{item.deviceType},#{item.dataPort},#{item.baudRate},#{item.brand},#{item.funCode},#{item.registerAddr},#{item.registerName},getDate(),#{item.projectId},#{item.parity},#{item.digit},#{item.grade},#{item.strData})" +
"</foreach>" + "</foreach>" +
"</script>") "</script>")
void insertDeviceCodeParamList(@Param("deviceCodeParamEntityList") List<DeviceCodeParamEntity> deviceCodeParamEntityList); void insertDeviceCodeParamList(@Param("deviceCodeParamEntityList") List<DeviceCodeParamEntity> deviceCodeParamEntityList);
//查询插入 //查询插入
@Insert("insert into device_code_param(device_addr,deviceName,deviceType,dataPort,baudRate,parity,brand,createTime,project_id,digit,grade) select device_addr,deviceName,deviceType,dataPort,baudRate,parity,brand,getDate(),project_id,2,grade from device_code " + @Insert("insert into device_code_param(device_addr,device_name,device_type,data_port,baud_rate,parity,brand,create_time,project_id,digit,grade) select device_addr,device_name,device_type,data_port,baud_rate,parity,brand,getDate(),project_id,2,grade from device_code " +
" where (deviceType='电表' or deviceType='水表') and project_id=#{ProjectID} ") " where (device_type='电表' or device_type='水表') and project_id=#{projectId} ")
void selectInsertDeviceCodeParam(@Param("ProjectID") String ProjectID); void selectInsertDeviceCodeParam(@Param("projectId") String projectId);
} }

82
user-service/src/main/java/com/mh/user/mapper/DeviceInfoMapper.java

@ -15,77 +15,43 @@ public interface DeviceInfoMapper {
@SelectProvider(type = DeviceInfoProvider.class,method = "queryDeviceInfo") @SelectProvider(type = DeviceInfoProvider.class,method = "queryDeviceInfo")
@Results(value = { @Results(value = {
@Result(property="id",column="id"), @Result(property="id",column="id"),
@Result(property="deviceName",column="deviceName"), @Result(property="deviceName",column="device_name"),
@Result(property="deviceType",column="deviceType"), @Result(property="deviceType",column="device_type"),
@Result(property="brand",column="brand"), @Result(property="brand",column="brand"),
@Result(property ="power",column ="power"), @Result(property ="power",column ="power"),
@Result(property ="madeTime",column ="madeTime"), @Result(property ="madeTime",column ="made_time"),
@Result(property="flow",column="flow"), @Result(property="flow",column="flow"),
@Result(property="isFC",column="isFC"), @Result(property="isFc",column="is_fc"),
@Result(property="motorBrand",column="motorBrand"), @Result(property="motorBrand",column="motor_brand"),
@Result(property="projectID",column="project_id"), @Result(property="projectId",column="project_id"),
@Result(property="systemID",column="system_id") @Result(property="systemId",column="system_id")
}) })
List<DeviceInfoEntity> queryDeviceInfo(@Param("systemID") String systemID, List<DeviceInfoEntity> queryDeviceInfo(@Param("systemID") String systemID,
@Param("projectID") String projectID, @Param("projectId") String projectId,
@Param("deviceType") String deviceType); @Param("deviceType") String deviceType);
//查询冷水机设备列表
@Results({
@Result(column = "device_addr",property = "deviceAddr" ),
@Result(column = "device_name", property = "deviceName")
})
@Select("select * from device_code where project_id=#{projectID} and device_type='冷水机'")
List<DeviceModel> selectDevices(@Param("projectID") String projectID);
//查询多个冷水机相关信息
@Results({
@Result(column = "device_addr",property = "deviceAddr" ),
@Result(column = "device_name", property = "deviceName"),
@Result(column = "runState", property = "runState"),
@Result(column = "setPoint", property = "setPoint"),
@Result(column = "enterChw", property = "enterChw"),
@Result(column = "leaveChw", property = "leaveChw"),
@Result(column = "enterCow", property = "enterCow"),
@Result(column = "leaveCow", property = "leaveCow"),
@Result(column = "power", property = "power"),
@Result(column = "ratedPower", property = "ratedPower"),
@Result(column = "chillerAmps", property = "chillerAmps"),
@Result(column = "refrigeration", property = "refrigeration"),
@Result(column = "ratedRef", property = "ratedRef"),
@Result(column = "chwFlow", property = "chwFlow"),
@Result(column = "ApproachCow", property = "ApproachCow"),
@Result(column = "ApproachChw", property = "ApproachChw"),
@Result(column = "cop", property = "cop"),
@Result(column = "ratedCop", property = "ratedCop"),
@Result(column = "copyDate", property = "copyDate")
})
@Select("select * from device_code where project_id=#{projectID} and device_addr=#{deviceAddr} ")
List<ChillerModel> queryChiller(@Param("projectID") String projectID, @Param("device_addr") String deviceAddr);
//查询单个冷水机相关信息 //查询单个冷水机相关信息
@Results({ @Results({
@Result(column = "device_addr",property = "deviceAddr" ), @Result(column = "device_addr",property = "deviceAddr" ),
@Result(column = "device_name", property = "deviceName"), @Result(column = "device_name", property = "deviceName"),
@Result(column = "runState", property = "runState"), @Result(column = "run_state", property = "runState"),
@Result(column = "setPoint", property = "setPoint"), @Result(column = "set_point", property = "setPoint"),
@Result(column = "enterChw", property = "enterChw"), @Result(column = "enter_chw", property = "enterChw"),
@Result(column = "leaveChw", property = "leaveChw"), @Result(column = "leave_chw", property = "leaveChw"),
@Result(column = "enterCow", property = "enterCow"), @Result(column = "enter_cow", property = "enterCow"),
@Result(column = "leaveCow", property = "leaveCow"), @Result(column = "leave_cow", property = "leaveCow"),
@Result(column = "power", property = "power"), @Result(column = "power", property = "power"),
@Result(column = "ratedPower", property = "ratedPower"), @Result(column = "rated_power", property = "ratedPower"),
@Result(column = "chillerAmps", property = "chillerAmps"), @Result(column = "chiller_amps", property = "chillerAmps"),
@Result(column = "refrigeration", property = "refrigeration"), @Result(column = "refrigeration", property = "refrigeration"),
@Result(column = "ratedRef", property = "ratedRef"), @Result(column = "rated_ref", property = "ratedRef"),
@Result(column = "chwFlow", property = "chwFlow"), @Result(column = "chw_flow", property = "chwFlow"),
@Result(column = "ApproachCow", property = "ApproachCow"), @Result(column = "approach_cow", property = "ApproachCow"),
@Result(column = "ApproachChw", property = "ApproachChw"), @Result(column = "approach_chw", property = "ApproachChw"),
@Result(column = "cop", property = "cop"), @Result(column = "cop", property = "cop"),
@Result(column = "ratedCop", property = "ratedCop"), @Result(column = "rated_cop", property = "ratedCop"),
@Result(column = "copyDate", property = "copyDate") @Result(column = "copy_date", property = "copyDate")
}) })
@Select("select * from chiller_data where project_id=#{projectID} and device_addr=#{deviceAddr} ") @Select("select * from chiller_data where project_id=#{projectId} and device_addr=#{deviceAddr} ")
ChillerModel selectChiller(@Param("projectID") String projectID,@Param("device_addr") String deviceAddr); ChillerModel selectChiller(@Param("projectId") String projectId,@Param("device_addr") String deviceAddr);
} }

55
user-service/src/main/java/com/mh/user/mapper/DeviceInstallMapper.java

@ -1,25 +1,26 @@
package com.mh.user.mapper; package com.mh.user.mapper;
import com.mh.user.entity.BuildingEntity; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DeviceInstallEntity; import com.mh.user.entity.DeviceInstallEntity;
import com.mh.user.entity.DeviceInstallTempEntity; import com.mh.user.entity.DeviceInstallTempEntity;
import com.mh.user.mapper.provider.DeviceInstallProvider; import com.mh.user.mapper.provider.DeviceInstallProvider;
import com.mh.user.model.DeviceModel;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType; import org.apache.ibatis.mapping.StatementType;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
public interface DeviceInstallMapper { @Mapper
public interface DeviceInstallMapper extends BaseMapper<DeviceInstallEntity> {
/** /**
* 设备安装模块 * 设备安装模块
* 保存设备信息 * 保存设备信息
* @param deviceInstallEntity * @param deviceInstallEntity
*/ */
@Insert("insert into device_code(device_addr,deviceName,deviceType,dataPort,ratio,baudRate,brand,project_id,installPosition,installDate) values (" + @Insert("insert into device_code(device_addr,device_name,device_type,data_port,ratio,baud_rate,brand,project_id,install_position,install_date) values (" +
" #{deviceAddr},#{deviceName},#{deviceType},#{dataCom},#{ratio},#{baudRate},#{brand},#{projectID},#{installPosition},getDate())") " #{deviceAddr},#{deviceName},#{deviceType},#{dataCom},#{ratio},#{baudRate},#{brand},#{projectId},#{installPosition},getDate())")
int saveDevice(DeviceInstallEntity deviceInstallEntity); int saveDevice(DeviceInstallEntity deviceInstallEntity);
/** /**
@ -29,23 +30,23 @@ public interface DeviceInstallMapper {
*/ */
@Update("<script>" + @Update("<script>" +
" update device_code set " + " update device_code set " +
" <if test='deviceName!=null'> deviceName = #{deviceName} </if>" + " <if test='deviceName!=null'> device_name = #{deviceName} </if>" +
" <if test='deviceType!=null'> , deviceType = #{deviceType} </if>" + " <if test='deviceType!=null'> , device_type = #{deviceType} </if>" +
" <if test='dataCom!=null'> , dataPort = #{dataPort} </if>" + " <if test='dataCom!=null'> , data_port = #{dataPort} </if>" +
" <if test='ratio!=null'> , ratio = #{ratio} </if>" + " <if test='ratio!=null'> , ratio = #{ratio} </if>" +
" <if test='baudRate!=null'> , baudRate = #{baudRate} </if>" + " <if test='baudRate!=null'> , baud_rate = #{baudRate} </if>" +
" <if test='brand!=null'> , brand = #{brand} </if>" + " <if test='brand!=null'> , brand = #{brand} </if>" +
" <if test='installPosition!=null'> , installPosition = #{installPosition} </if>" + " <if test='installPosition!=null'> , install_position = #{installPosition} </if>" +
" <if test='installer!=null'> , installer = #{installer} </if>" + " <if test='installer!=null'> , installer = #{installer} </if>" +
" <if test='projectID!=null'> , project_id = #{projectID} </if>" + " <if test='projectId!=null'> , project_id = #{projectId} </if>" +
" <if test='remarks!=null'> , remarks = #{remarks} </if>" + " <if test='remarks!=null'> , remarks = #{remarks} </if>" +
" where id = #{id} " + " where id = #{id} " +
"</script>") "</script>")
int updateDevice(DeviceInstallEntity deviceInstallEntity); int updateDevice(DeviceInstallEntity deviceInstallEntity);
//按id更新水电表读数和采集日期 //按id更新水电表读数和采集日期
@Update("update device_code set lastValue=#{lastValue},lastDate=#{lastDate} where id=#{id}") @Update("update device_code set last_value=#{lastValue},last_date=#{lastDate} where id=#{id}")
void updateLastValue(@Param("id") Long id,@Param("lastValue") double lastValue,@Param("lastDate") Date lastDate); void updateLastValue(@Param("id") Long id, @Param("lastValue") BigDecimal lastValue, @Param("lastDate") Date lastDate);
/** /**
* 设备管理模块 * 设备管理模块
* 查询设备资料 * 查询设备资料
@ -69,26 +70,24 @@ public interface DeviceInstallMapper {
@Result(property="installPosition",column="installPosition"), @Result(property="installPosition",column="installPosition"),
@Result(property="installDate",column="installDate"), @Result(property="installDate",column="installDate"),
@Result(property="remarks",column="remarks"), @Result(property="remarks",column="remarks"),
@Result(property ="projectID",column ="project_id"), @Result(property ="projectId",column ="project_id"),
}) })
@Select("select * from (\n" + @Select("select * from ( " +
"select *,ROW_NUMBER() over(order by id) as rn from device_code \n" + "select *,ROW_NUMBER() over(order by id) as rn from device_code " +
") t where rn between (#{page}-1)*#{limit} and #{page}*#{limit}") ") t where rn between (#{page}-1)*#{limit} and #{page}*#{limit}")
List<DeviceInstallEntity> getAllDevice(@Param("page") int page, @Param("limit") int limit); List<DeviceInstallEntity> getAllDevice(@Param("page") int page, @Param("limit") int limit);
//查询有多个采集参数的设备 //查询有多个采集参数的设备
@ResultMap("rs")
@Select("select * from device_code where Project_id=#{ProjectID} ") @Select("select * from device_code where Project_id=#{ProjectID} ")
List<DeviceInstallEntity> selectDeviceParams(@Param("ProjectID") String ProjectID); List<DeviceInstallEntity> selectDeviceParams(@Param("ProjectID") String ProjectID);
//查询有多个采集参数的设备 //查询有多个采集参数的设备
@ResultMap("rs")
@Select("select * from device_code ") @Select("select * from device_code ")
List<DeviceInstallEntity> selectDeviceParams2(); List<DeviceInstallEntity> selectDeviceParams2();
//根据类型查询设备通讯号 //根据类型查询设备通讯号
@Select("select top 1 device_addr from device_code where deviceType=#{deviceType} and project_id=#{projectID} ") @Select("select top 1 device_addr from device_code where device_type=#{deviceType} and project_id=#{projectId} ")
String selectDeviceAddr(@Param("deviceType") String deviceType,@Param("projectID") String projectID); String selectDeviceAddr(@Param("deviceType") String deviceType,@Param("projectId") String projectId);
/** /**
* 设备管理模块 * 设备管理模块
@ -100,8 +99,7 @@ public interface DeviceInstallMapper {
@SelectProvider(type = DeviceInstallProvider.class,method = "queryDevice") @SelectProvider(type = DeviceInstallProvider.class,method = "queryDevice")
@ResultMap("rs") List<DeviceInstallEntity> queryDevice(@Param("project_id") String projectId,
List<DeviceInstallEntity> queryDevice(@Param("project_id") String projectID,
@Param("deviceType") String deviceType, @Param("deviceType") String deviceType,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate")String endDate, @Param("endDate")String endDate,
@ -116,7 +114,7 @@ public interface DeviceInstallMapper {
* @return * @return
*/ */
@SelectProvider(type = DeviceInstallProvider.class,method = "getCount") @SelectProvider(type = DeviceInstallProvider.class,method = "getCount")
int getCount(@Param("project_id") String projectID, int getCount(@Param("project_id") String projectId,
@Param("deviceType") String deviceType, @Param("deviceType") String deviceType,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate")String endDate, @Param("endDate")String endDate,
@ -130,9 +128,8 @@ public interface DeviceInstallMapper {
int getIsOnlineCount(@Param("isOnline") String isOnline,@Param("deviceType") String deviceType); int getIsOnlineCount(@Param("isOnline") String isOnline,@Param("deviceType") String deviceType);
//根据通讯地址和设备类型查询对应的设备信息 //根据通讯地址和设备类型查询对应的设备信息
@ResultMap("rs") @Select("select * from device_code where device_addr=#{deviceAddr} and device_type=#{deviceType} and project_id=#{projectId}")
@Select("select * from device_code where device_addr=#{deviceAddr} and deviceType=#{deviceType} and project_id=#{projectID}") DeviceInstallEntity selectDevice(@Param("deviceAddr") String deviceAddr,@Param("deviceType") String deviceType,@Param("projectId") String projectId);
DeviceInstallEntity selectDevice(@Param("deviceAddr") String deviceAddr,@Param("deviceType") String deviceType,@Param("projectID") String projectID);
/** /**
* 设备管理模块 * 设备管理模块
@ -169,13 +166,13 @@ public interface DeviceInstallMapper {
" end " + " end " +
" ) as remarks " + " ) as remarks " +
" FROM device_install_temp " + " FROM device_install_temp " +
" ORDER BY ISNULL(remarks,'') DESC ,row_id ") " ORDER BY ISNULL(remarks,'') DESC ,row_id ")
@Options(statementType = StatementType.CALLABLE) @Options(statementType = StatementType.CALLABLE)
@Results({ @Results({
@Result(column = "device_addr",property = "deviceAddr" ), @Result(column = "device_addr",property = "deviceAddr" ),
@Result(column = "device_name", property = "deviceName"), @Result(column = "device_name", property = "deviceName"),
@Result(column = "device_type", property = "deviceType"), @Result(column = "device_type", property = "deviceType"),
@Result(column = "baudRate", property = "baudRate"), @Result(column = "baud_rate", property = "baudRate"),
@Result(column = "data_com", property = "dataCom"), @Result(column = "data_com", property = "dataCom"),
@Result(column = "ratio", property = "ratio"), @Result(column = "ratio", property = "ratio"),
@Result(column = "building_id", property = "buildingId"), @Result(column = "building_id", property = "buildingId"),
@ -206,7 +203,7 @@ public interface DeviceInstallMapper {
void updateDevice_install_temp__multiple(); void updateDevice_install_temp__multiple();
//从临时表查询插入 //从临时表查询插入
@Insert("insert into device_install(device_addr,device_name,device_type,data_com,baudRate,ratio,building_id) select device_addr,device_name,device_type,data_com,baudRate,ratio,building_id from device_install_temp") @Insert("insert into device_install(device_addr,device_name,device_type,data_com,baud_rate,ratio,building_id) select device_addr,device_name,device_type,data_com,baud_rate,ratio,building_id from device_install_temp")
void insertFromDevice_install_temp(); void insertFromDevice_install_temp();
//修改启动状态 //修改启动状态

16
user-service/src/main/java/com/mh/user/mapper/DeviceParamsMapper.java

@ -0,0 +1,16 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DeviceParamsEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 设备采集参数
* @date 2024-08-23 09:28:57
*/
@Mapper
public interface DeviceParamsMapper extends BaseMapper<DeviceParamsEntity> {
}

16
user-service/src/main/java/com/mh/user/mapper/DevicesManageMapper.java

@ -0,0 +1,16 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.DevicesManageEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 资产设备管理
* @date 2024-08-23 10:22:16
*/
@Mapper
public interface DevicesManageMapper extends BaseMapper<DevicesManageEntity> {
}

41
user-service/src/main/java/com/mh/user/mapper/EnergyDataMapper.java

@ -1,5 +1,6 @@
package com.mh.user.mapper; package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.EnergyDataEntity; import com.mh.user.entity.EnergyDataEntity;
import com.mh.user.mapper.provider.EnergyDataProvider; import com.mh.user.mapper.provider.EnergyDataProvider;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
@ -7,13 +8,13 @@ import org.apache.ibatis.annotations.*;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface EnergyDataMapper { public interface EnergyDataMapper extends BaseMapper<EnergyDataEntity> {
//按10分钟 //按10分钟
@SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataMi") @SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataMi")
@Results(id = "rs", value = { @Results(id = "rs", value = {
@Result(property = "curDate", column = "cur_date"), @Result(property = "curDate", column = "cur_date"),
@Result(property="projectID",column="project_id"), @Result(property = "projectId", column = "project_id"),
@Result(property = "projectName", column = "project_name"), @Result(property = "projectName", column = "project_name"),
@Result(property = "ambTemp", column = "amb_Temp"), @Result(property = "ambTemp", column = "amb_Temp"),
@Result(property = "humidity", column = "humidity"), @Result(property = "humidity", column = "humidity"),
@ -22,58 +23,70 @@ public interface EnergyDataMapper {
@Result(property = "cl", column = "cl"), @Result(property = "cl", column = "cl"),
@Result(property = "cop", column = "cop") @Result(property = "cop", column = "cop")
}) })
List<EnergyDataEntity> queryEnergyDataMi(@Param("projectID") String projectID, List<EnergyDataEntity> queryEnergyDataMi(@Param("projectId") String projectId,
@Param("curDate") String curDate, @Param("curDate") String curDate,
@Param("page") int page, @Param("limit") int limit); @Param("page") int page, @Param("limit") int limit);
@SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataMiCount") @SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataMiCount")
int getEnergyDataMiCount(@Param("projectID") String projectID, @Param("curDate") String curDate); int getEnergyDataMiCount(@Param("projectId") String projectId, @Param("curDate") String curDate);
//按小时 //按小时
@SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataHour") @SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataHour")
@ResultMap("rs") @Results({
List<EnergyDataEntity> queryEnergyDataHour(@Param("projectID") String projectID, @Result(property = "id", column = "id"),
@Result(property = "curDate", column = "cur_date"),
@Result(property = "ambTemp", column = "amb_temp"),
@Result(property = "humidity", column = "humidity"),
@Result(property = "water", column = "water"),
@Result(property = "elect", column = "elect"),
@Result(property = "cl", column = "cl"),
@Result(property = "cop", column = "cop"),
@Result(property = "projectId", column = "project_id"),
@Result(property = "projectName", column = "project_name")
})
List<EnergyDataEntity> queryEnergyDataHour(@Param("projectId") String projectId,
@Param("curDate") String curDate, @Param("curDate") String curDate,
@Param("page") int page, @Param("limit") int limit); @Param("page") int page,
@Param("limit") int limit);
@SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataHourCount") @SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataHourCount")
int getEnergyDataHourCount(@Param("projectID") String projectID, @Param("curDate") String curDate); int getEnergyDataHourCount(@Param("projectId") String projectId, @Param("curDate") String curDate);
//按天 //按天
@SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataDay") @SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataDay")
@ResultMap("rs") @ResultMap("rs")
List<EnergyDataEntity> queryEnergyDataDay(@Param("projectID") String projectID, List<EnergyDataEntity> queryEnergyDataDay(@Param("projectId") String projectId,
@Param("curDate") String curDate, @Param("curDate") String curDate,
@Param("queryType") int queryType, @Param("queryType") int queryType,
@Param("page") int page, @Param("page") int page,
@Param("limit") int limit); @Param("limit") int limit);
@SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataDayCount") @SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataDayCount")
int getEnergyDataDayCount(@Param("projectID") String projectID, @Param("curDate") String curDate, @Param("queryType") int queryType); int getEnergyDataDayCount(@Param("projectId") String projectId, @Param("curDate") String curDate, @Param("queryType") int queryType);
//按月 //按月
@SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataMonth") @SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataMonth")
@ResultMap("rs") @ResultMap("rs")
List<EnergyDataEntity> queryEnergyDataMonth(@Param("projectID") String projectID, List<EnergyDataEntity> queryEnergyDataMonth(@Param("projectId") String projectId,
@Param("curDate") String curDate, @Param("curDate") String curDate,
@Param("queryType") int queryTyp, @Param("queryType") int queryTyp,
@Param("page") int page, @Param("limit") int limit); @Param("page") int page, @Param("limit") int limit);
@SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataMonthCount") @SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataMonthCount")
int getEnergyDataMonthCount(@Param("projectID") String projectID, @Param("curDate") String curDate, @Param("queryType") int queryType); int getEnergyDataMonthCount(@Param("projectId") String projectId, @Param("curDate") String curDate, @Param("queryType") int queryType);
//按年 //按年
@SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataYear") @SelectProvider(type = EnergyDataProvider.class, method = "queryEnergyDataYear")
@ResultMap("rs") @ResultMap("rs")
List<EnergyDataEntity> queryEnergyDataYear(@Param("projectID") String projectID, List<EnergyDataEntity> queryEnergyDataYear(@Param("projectId") String projectId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@Param("queryType") int queryType, @Param("queryType") int queryType,
@Param("page") int page, @Param("limit") int limit); @Param("page") int page, @Param("limit") int limit);
@SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataYearCount") @SelectProvider(type = EnergyDataProvider.class, method = "getEnergyDataYearCount")
int getEnergyDataYearCount(@Param("projectID") String projectID, int getEnergyDataYearCount(@Param("projectId") String projectId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@Param("queryType") int queryType); @Param("queryType") int queryType);

19
user-service/src/main/java/com/mh/user/mapper/EnergyMapper.java

@ -5,6 +5,7 @@ import com.mh.user.mapper.provider.EnergyProvider;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import java.util.List; import java.util.List;
@Mapper
public interface EnergyMapper { public interface EnergyMapper {
/** /**
@ -91,7 +92,7 @@ public interface EnergyMapper {
/** /**
* 生产信息 * 生产信息
* 查询 * 查询
* @param projectID * @param projectId
* @param buildingId * @param buildingId
* @param startDate * @param startDate
* @param queryType * @param queryType
@ -112,10 +113,10 @@ public interface EnergyMapper {
@Result(property="checkInCount",column="check_in_count"), @Result(property="checkInCount",column="check_in_count"),
@Result(property="perElect",column="per_elect"), @Result(property="perElect",column="per_elect"),
@Result(property="perWater",column="per_water"), @Result(property="perWater",column="per_water"),
@Result(property="projectID",column="project_id"), @Result(property="projectId",column="project_id"),
@Result(property="projectName",column="project_name") @Result(property="projectName",column="project_name")
}) })
List<EnergyEntity> queryEnergyHour(@Param("projectID") String projectID, List<EnergyEntity> queryEnergyHour(@Param("projectId") String projectId,
@Param("buildingId") String buildingId, @Param("buildingId") String buildingId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("queryType") int queryType, @Param("queryType") int queryType,
@ -124,7 +125,7 @@ public interface EnergyMapper {
//按天 //按天
@SelectProvider(type = EnergyProvider.class,method = "queryEnergyDay") @SelectProvider(type = EnergyProvider.class,method = "queryEnergyDay")
@ResultMap("rs") @ResultMap("rs")
List<EnergyEntity> queryEnergyDay(@Param("projectID") String projectID, List<EnergyEntity> queryEnergyDay(@Param("projectId") String projectId,
@Param("buildingId") String buildingId, @Param("buildingId") String buildingId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@ -133,7 +134,7 @@ public interface EnergyMapper {
//按月 //按月
@SelectProvider(type = EnergyProvider.class,method = "queryEnergyMonth") @SelectProvider(type = EnergyProvider.class,method = "queryEnergyMonth")
@ResultMap("rs") @ResultMap("rs")
List<EnergyEntity> queryEnergyMonth(@Param("projectID") String projectID, List<EnergyEntity> queryEnergyMonth(@Param("projectId") String projectId,
@Param("buildingId") String buildingId, @Param("buildingId") String buildingId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@ -142,7 +143,7 @@ public interface EnergyMapper {
//按年 //按年
@SelectProvider(type = EnergyProvider.class,method = "queryEnergyYear") @SelectProvider(type = EnergyProvider.class,method = "queryEnergyYear")
@ResultMap("rs") @ResultMap("rs")
List<EnergyEntity> queryEnergyYear(@Param("projectID") String projectID, List<EnergyEntity> queryEnergyYear(@Param("projectId") String projectId,
@Param("buildingId") String buildingId, @Param("buildingId") String buildingId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@ -156,21 +157,21 @@ public interface EnergyMapper {
*/ */
//按天 //按天
@SelectProvider(type = EnergyProvider.class,method = "getEnergyDayCount") @SelectProvider(type = EnergyProvider.class,method = "getEnergyDayCount")
int getEnergyDayCount(@Param("projectID") String projectID, int getEnergyDayCount(@Param("projectId") String projectId,
@Param("buildingId") String buildingId, @Param("buildingId") String buildingId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@Param("queryType") int queryType); @Param("queryType") int queryType);
//按月 //按月
@SelectProvider(type = EnergyProvider.class,method = "getEnergyMonthCount") @SelectProvider(type = EnergyProvider.class,method = "getEnergyMonthCount")
int getEnergyMonthCount(@Param("projectID") String projectID, int getEnergyMonthCount(@Param("projectId") String projectId,
@Param("buildingId") String buildingId, @Param("buildingId") String buildingId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,
@Param("queryType") int queryType); @Param("queryType") int queryType);
//按年 //按年
@SelectProvider(type = EnergyProvider.class,method = "getEnergyYearCount") @SelectProvider(type = EnergyProvider.class,method = "getEnergyYearCount")
int getEnergyYearCount(@Param("projectID") String projectID, int getEnergyYearCount(@Param("projectId") String projectId,
@Param("buildingId") String buildingId, @Param("buildingId") String buildingId,
@Param("startDate") String startDate, @Param("startDate") String startDate,
@Param("endDate") String endDate, @Param("endDate") String endDate,

12
user-service/src/main/java/com/mh/user/mapper/MeterInfoMapper.java

@ -13,19 +13,19 @@ public interface MeterInfoMapper {
@SelectProvider(type = MeterInfoProvider.class,method = "queryMeterInfo") @SelectProvider(type = MeterInfoProvider.class,method = "queryMeterInfo")
@Results(value = { @Results(value = {
@Result(property="id",column="id"), @Result(property="id",column="id"),
@Result(property="meterName",column="meterName"), @Result(property="meterName",column="meter_name"),
@Result(property="meterType",column="meterType"), @Result(property="meterType",column="meter_type"),
@Result(property="brand",column="brand"), @Result(property="brand",column="brand"),
@Result(property="currentValue",column="currentValue"), @Result(property="currentValue",column="current_value"),
@Result(property ="model",column ="model"), @Result(property ="model",column ="model"),
@Result(property ="pulse",column ="pulse"), @Result(property ="pulse",column ="pulse"),
@Result(property="caliber",column="caliber"), @Result(property="caliber",column="caliber"),
@Result(property="range",column="range"), @Result(property="range",column="range"),
@Result(property="structural",column="structural"), @Result(property="structural",column="structural"),
@Result(property="projectID",column="project_id"), @Result(property="projectId",column="project_id"),
@Result(property="systemID",column="system_id") @Result(property="systemId",column="system_id")
}) })
List<MeterInfoEntity> queryMeterInfo(@Param("systemID") String systemID, List<MeterInfoEntity> queryMeterInfo(@Param("systemID") String systemID,
@Param("projectID") String projectID); @Param("projectId") String projectId);
} }

16
user-service/src/main/java/com/mh/user/mapper/MeterManageMapper.java

@ -0,0 +1,16 @@
package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.MeterManageEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 仪表管理对接数据库
* @date 2024-08-23 09:03:13
*/
@Mapper
public interface MeterManageMapper extends BaseMapper<MeterManageEntity> {
}

13
user-service/src/main/java/com/mh/user/mapper/ProjectInfoMapper.java

@ -1,12 +1,13 @@
package com.mh.user.mapper; package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.ProjectInfoEntity; import com.mh.user.entity.ProjectInfoEntity;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface ProjectInfoMapper { public interface ProjectInfoMapper extends BaseMapper<ProjectInfoEntity> {
//查询项目列表 //查询项目列表
@Results(value = { @Results(value = {
@ -16,11 +17,13 @@ public interface ProjectInfoMapper {
@Result(property="pScale",column="p_scale"), @Result(property="pScale",column="p_scale"),
@Result(property="pic",column="pic"), @Result(property="pic",column="pic"),
@Result(property="tel",column="tel"), @Result(property="tel",column="tel"),
@Result(property="systemID",column="system_id"), @Result(property="systemId",column="system_id"),
@Result(property="remarks",column="remarks") @Result(property="remarks",column="remarks"),
@Result(property="createTime",column="create_time"),
@Result(property="longitude",column="longitude"),
@Result(property="latitude",column="latitude")
}) })
@Select("select * from Project_Info where system_id=#{systemID}") @Select("select * from project_info where system_id=#{systemID}")
List<ProjectInfoEntity> queryProjectInfo(@Param("systemID") String systemID ); List<ProjectInfoEntity> queryProjectInfo(@Param("systemID") String systemID );
//通过id查找对应的名称 //通过id查找对应的名称

15
user-service/src/main/java/com/mh/user/mapper/RegisterAddrMapper.java

@ -1,5 +1,6 @@
package com.mh.user.mapper; package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.RegisterAddrEntity; import com.mh.user.entity.RegisterAddrEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Result;
@ -8,16 +9,16 @@ import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface RegisterAddrMapper { public interface RegisterAddrMapper extends BaseMapper<RegisterAddrEntity> {
@Results(value = { @Results(value = {
@Result(property="registerAddr",column="registerAddr"), @Result(property="registerAddr",column="register_addr"),
@Result(property="regName",column="regName"), @Result(property="regName",column="reg_name"),
@Result(property="funFlag",column="funFlag"), @Result(property="funFlag",column="fun_flag"),
@Result(property="floatFlag",column="floatFlag"), @Result(property="floatFlag",column="float_flag"),
@Result(property="grade",column="grade"), @Result(property="grade",column="grade"),
@Result(property ="otherName",column ="otherName") @Result(property ="otherName",column ="other_name")
}) })
@Select("select * from RegisterAddrs ") @Select("select * from register_addr ")
List<RegisterAddrEntity> selectRegisterAddr(); List<RegisterAddrEntity> selectRegisterAddr();
} }

26
user-service/src/main/java/com/mh/user/mapper/StrategyInfoMapper.java

@ -1,24 +1,24 @@
package com.mh.user.mapper; package com.mh.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.user.entity.StrategyInfoEntity; import com.mh.user.entity.StrategyInfoEntity;
import com.mh.user.mapper.provider.DeviceInfoProvider;
import com.mh.user.mapper.provider.StrategyInfoProvider;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface StrategyInfoMapper { public interface StrategyInfoMapper extends BaseMapper<StrategyInfoEntity> {
//查询仪表信息 //查询仪表信息
@SelectProvider(type = StrategyInfoProvider.class,method = "queryStrategyInfo") @Select("<script>" +
@Results(value = { "select * from strategy_info where 1=1 " +
@Result(property="id",column="id"), "<if test='systemID != null and systemID != \"\"'>" +
@Result(property="dataAnalysis",column="dataAnalysis"), " and system_id = #{systemID} " +
@Result(property="operationOpt",column="operation_opt"), "</if>" +
@Result(property="controlOpt",column="control_opt"), "<if test='projectId != null and projectId != \"\"'>" +
@Result(property="projectID",column="project_id"), " and project_id = #{projectId} " +
@Result(property="systemID",column="system_id") "</if>" +
}) " order by id " +
List<StrategyInfoEntity> queryStrategyInfo(@Param("systemID") String systemID,@Param("projectID") String projectID); "</script>")
List<StrategyInfoEntity> queryStrategyInfo(@Param("systemID") String systemID,@Param("projectId") String projectId);
} }

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

Loading…
Cancel
Save