Compare commits
16 Commits
Author | SHA1 | Date |
---|---|---|
mh | 88c2ea4075 | 2 days ago |
mh | 040437a702 | 3 weeks ago |
mh | 2977912e0d | 4 weeks ago |
mh | 9a06a5a124 | 2 months ago |
mh | 81a8678db6 | 2 months ago |
mh | 7b52dd62f1 | 2 months ago |
mh | f48279969a | 2 months ago |
mh | 64f460bb23 | 2 months ago |
mh | bfb802a739 | 2 months ago |
mh | 389faa7110 | 2 months ago |
mh | 3a95013969 | 2 months ago |
mh | 95987cdc6d | 3 months ago |
mh | 1a3cf1569e | 4 months ago |
mh | c27e778d60 | 4 months ago |
mh | 3b87a5b40d | 4 months ago |
mh | 1fc44b3555 | 4 months ago |
223 changed files with 8406 additions and 6354 deletions
@ -0,0 +1,249 @@ |
|||||||
|
-- 2024-07-31 (未执行) |
||||||
|
alter table project_info add longitude numeric(10,2) null; |
||||||
|
exec sp_addextendedproperty N'MS_Description', N'经度', N'schema', N'dbo', N'table', N'project_info', N'column', N'longitude'; |
||||||
|
|
||||||
|
alter table project_info add latitude numeric(10,2) null; |
||||||
|
exec sp_addextendedproperty N'MS_Description', N'纬度', N'schema', N'dbo', N'table', N'project_info', N'column', N'latitude'; |
||||||
|
|
||||||
|
alter table project_info add create_time datetime null; |
||||||
|
exec sp_addextendedproperty N'MS_Description', N'创建时间', N'schema', N'dbo', N'table', N'project_info', N'column', N'create_time'; |
||||||
|
|
||||||
|
alter table project_info add pic_content text null; |
||||||
|
exec sp_addextendedproperty N'MS_Description', N'图片内容', N'schema', N'dbo', N'table', N'project_info', N'column', N'pic_content'; |
||||||
|
|
||||||
|
-- 2024-08-13 创建字典表数据 |
||||||
|
CREATE TABLE sys_dict ( |
||||||
|
id bigint NOT NULL, |
||||||
|
value nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL, |
||||||
|
label nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL, |
||||||
|
[type] nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL, |
||||||
|
description nvarchar(100) COLLATE Chinese_PRC_CI_AS NOT NULL, |
||||||
|
sort decimal(10,0) NOT NULL, |
||||||
|
create_by nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
create_time datetime2 NULL, |
||||||
|
last_update_by nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
last_update_time datetime2 NULL, |
||||||
|
remarks nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
del_flag tinyint NULL, |
||||||
|
status bit null, |
||||||
|
parent_id bigint null |
||||||
|
CONSTRAINT PK__sys_dict__3213E83F527BBC48 PRIMARY KEY (id) |
||||||
|
); |
||||||
|
|
||||||
|
-- Extended properties |
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字典表', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'value'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标签名', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'label'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类型', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'type'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'描述', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'description'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序(升序)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'sort'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'create_by'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'create_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新人', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'last_update_by'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'last_update_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注信息', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'remarks'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否删除 -1:已删除 0:正常', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'del_flag'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态(0正常 1停用)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'status'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'父id:0最高级', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'sys_dict', @level2type=N'Column', @level2name=N'parent_id'; |
||||||
|
|
||||||
|
-- 2024-08-22 |
||||||
|
-- 资产设备管理 |
||||||
|
create table devices_manage |
||||||
|
( |
||||||
|
id bigint identity primary key not null, -- id |
||||||
|
device_name nvarchar(100) null, -- 设备名称 |
||||||
|
device_brand nvarchar(100) null, -- 设备品牌 |
||||||
|
em_brand nvarchar(100) null, -- 机电品牌 |
||||||
|
rated_input_power numeric(24, 2) null, -- 额定输入功率 |
||||||
|
rated_refrigeration_capacity numeric(24, 2) null, -- 额定制冷量 |
||||||
|
rated_cop numeric(24, 2) null, -- 额定COP |
||||||
|
rated_flow numeric(24, 2) null, -- 额定流量 |
||||||
|
production_time datetime null, -- 生产日期 |
||||||
|
create_time datetime null, -- 创建时间 |
||||||
|
update_time datetime null, -- 更新时间 |
||||||
|
create_by nvarchar(50) null, -- 创建人 |
||||||
|
is_frequency bit null, -- 是否变频 |
||||||
|
device_type bigint null, -- 设备类型id(字典配置) |
||||||
|
system_id bigint null, -- 项目类型id |
||||||
|
project_id bigint null, -- 项目类型id |
||||||
|
remark nvarchar(255) null, -- 系统id |
||||||
|
grade int null -- 保留 |
||||||
|
) |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'资产设备管理', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备名称', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_name'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备品牌', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_brand'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'机电品牌', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'em_brand'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定输入功率', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_input_power'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定制冷量', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_refrigeration_capacity'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定COP', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_cop'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'额定流量', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'rated_flow'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生产日期', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'production_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'create_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'update_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'create_by'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否变频', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'is_frequency'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备类型id(字典配置)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_type'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目类型id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'system_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'project_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'remark'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据标识', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'grade'; |
||||||
|
|
||||||
|
-- 仪表管理 |
||||||
|
create table meter_manage ( |
||||||
|
id bigint identity primary key not null, -- 编号 |
||||||
|
mt_type bigint null, -- 仪表类型(从字典值获取) |
||||||
|
mt_name nvarchar(100) null, -- 仪表名称 |
||||||
|
other_name nvarchar(100) null, -- 仪表别名 |
||||||
|
mt_brand nvarchar(100) null, -- 仪表品牌 |
||||||
|
mt_num nvarchar(20) null, -- 仪表表面号 |
||||||
|
mt_code nvarchar(20) null, -- 仪表采集码 |
||||||
|
register_addr nvarchar(20), -- 寄存器地址 |
||||||
|
func_code nvarchar(20) null, -- 功能码 |
||||||
|
identify_code nvarchar(20) null, -- 仪表识别码 |
||||||
|
mt_caliber_pulse nvarchar(20) null, -- 仪表口径或者脉冲常数 |
||||||
|
mt_range numeric(24,3) null, -- 仪表范围 |
||||||
|
mt_ratio int null, -- 仪表倍率 |
||||||
|
mt_init_value numeric(24,3) null, -- 初始值 |
||||||
|
digits int null, -- 小数位数 |
||||||
|
data_type int null, -- 数据类型16位、32位、64位 |
||||||
|
cur_value numeric(24,3) null, -- 当前值 |
||||||
|
cur_time datetime null, -- 当前值时间 |
||||||
|
mt_is_sum bit null, -- 是否总表 |
||||||
|
create_time datetime null, -- 创建时间 |
||||||
|
update_time datetime null, -- 更新时间 |
||||||
|
unit nvarchar(20) null, -- 单位 |
||||||
|
sort bigint null, -- 排序 |
||||||
|
data_com nvarchar(100) null, -- 通信端口 |
||||||
|
device_id bigint null, -- 对应device_manage的id |
||||||
|
gateway_id bigint null, -- 对应网关管理表gateway_manage的id |
||||||
|
param_id bigint null, -- 对应参数id |
||||||
|
protocol_type bigint null, -- 协议类型(字典表) |
||||||
|
communication_type int NULL, -- 通讯方式(字典表) |
||||||
|
remark nvarchar(255) null, -- 备注 |
||||||
|
system_id bigint null, -- 系统类型id |
||||||
|
project_id bigint null, -- 项目类型id |
||||||
|
grade int null -- 保留 |
||||||
|
) |
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表管理', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表类型(从字典值获取)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_type_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表名称', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_name'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表别名', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'other_name'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表品牌', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_brand'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表表面号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_num'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表采集码', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_code'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'寄存器地址', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'register_addr'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'功能码', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'func_code'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表识别码', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'identify_code'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表口径或者脉冲常数', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_caliber_pulse'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表范围', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_range'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表倍率', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_ratio'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'初始值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'mt_init_value'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'小数位数', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'meter_manage', @level2type=N'Column', @level2name=N'digits'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据类型16位、32位、64位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'data_type'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'cur_value'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前值时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'cur_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否总表', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'mt_is_sum'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'create_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'update_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'单位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'unit'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'sort'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应device_manage的id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'device_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应网关管理表gateway_manage的id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'gateway_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'对应参数id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'param_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'协议类型(字典表)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'protocol_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通讯方式', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'communication_type'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'remark'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目类型ID', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'project_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统类型ID', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'system_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'保留', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'devices_manage', @level2type=N'Column', @level2name=N'grade'; |
||||||
|
|
||||||
|
|
||||||
|
-- 网关管理表 |
||||||
|
CREATE TABLE gateway_manage ( |
||||||
|
id bigint identity(1,1) NOT NULL, |
||||||
|
gw_name varchar(100) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
gw_ip varchar(20) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
gw_addr varchar(100) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
port int NULL, |
||||||
|
collection_loop int NULL, |
||||||
|
create_time datetime NULL, |
||||||
|
update_time datetime NULL, |
||||||
|
connect_time datetime NULL, |
||||||
|
internet_card varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
operator_type int NULL, |
||||||
|
remark varchar(100) COLLATE Chinese_PRC_CI_AS NULL, |
||||||
|
communication_type int NULL, |
||||||
|
grade int NULL, |
||||||
|
system_id bigint null, -- 系统类型id |
||||||
|
project_id bigint null, -- 项目类型id |
||||||
|
CONSTRAINT pk_gateway_manage PRIMARY KEY (id) |
||||||
|
); |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关管理', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关名称', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'gw_name'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关IP地址', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'gw_ip'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关对应的编号地址', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'gw_addr'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网关端口', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'port'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'采集周期', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'collection_loop'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'create_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'更新时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'update_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'连接时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'connect_time'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'卡号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'internet_card'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'运营商类型 0:中国移动 1:中国联通 2:中国电信', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'operator_type'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'remark'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'通信类型(字典表)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'communication_type_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'预留字段', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'grade'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统类型id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'system_id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'项目类型id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'gateway_manage', @level2type=N'Column', @level2name=N'project_id'; |
||||||
|
|
||||||
|
-- 设备采集参数表 |
||||||
|
create table device_params( |
||||||
|
id bigint primary key identity(1,1) not null, -- 编号 |
||||||
|
mt_type int not null, -- 仪表类型(从字典表中拿) |
||||||
|
baud_rate int not null, -- 波特率 |
||||||
|
data_bit int not null, -- 数据位 |
||||||
|
stop_bit int not null, -- 停止位 |
||||||
|
parity nvarchar(10) not null, -- 校验位 |
||||||
|
remark varchar(100) null -- 备注 |
||||||
|
) |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'设备采集参数表', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'id'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仪表类型(从字典中获取)', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'mt_type'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'波特率', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'baud_rate'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'data_bit'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'停止位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'stop_bit'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'校验位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'parity'; |
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'device_params', @level2type=N'Column', @level2name=N'remark'; |
||||||
|
|
||||||
|
-- 2024-08-22 |
||||||
|
|
||||||
|
-- 2028-09-02 |
||||||
|
ALTER TABLE devices_manage ADD factory_barcode varchar(100) NULL; |
||||||
|
EXEC sys.sp_addextendedproperty 'MS_Description', N'出厂条码', 'schema', N'dbo', 'table', N'devices_manage', 'column', N'factory_barcode'; |
||||||
|
ALTER TABLE devices_manage ADD imu_code varchar(100) NULL; |
||||||
|
EXEC sys.sp_addextendedproperty 'MS_Description', N'IMU编码', 'schema', N'dbo', 'table', N'devices_manage', 'column', N'imu_code'; |
||||||
|
|
||||||
|
ALTER TABLE meter_manage ADD register_size int DEFAULT 1 NULL; |
||||||
|
EXEC sys.sp_addextendedproperty 'MS_Description', N'寄存器大小', 'schema', N'dbo', 'table', N'meter_manage', 'column', N'register_size'; |
||||||
|
|
||||||
|
ALTER TABLE meter_manage ADD is_use bit DEFAULT 1 NULL; |
||||||
|
EXEC sys.sp_addextendedproperty 'MS_Description', N'当前采集点位是否启用', 'schema', N'dbo', 'table', N'meter_manage', 'column', N'is_use'; |
||||||
|
|
||||||
|
-- 2024-09-23 冗余设备管理采集参数表数据 |
||||||
|
ALTER TABLE mh_jnd.dbo.device_code_param ADD mm_id bigint NULL; |
||||||
|
EXEC mh_jnd.sys.sp_addextendedproperty 'MS_Description', N'采集设备参数表ID值', 'schema', N'dbo', 'table', N'device_code_param', 'column', N'mm_id'; |
||||||
|
ALTER TABLE mh_jnd.dbo.device_code_param ADD data_type int NULL; |
||||||
|
EXEC mh_jnd.sys.sp_addextendedproperty 'MS_Description', N'数据类型', 'schema', N'dbo', 'table', N'device_code_param', 'column', N'data_type'; |
||||||
|
ALTER TABLE mh_jnd.dbo.device_code_param ADD protocol_type int NULL; |
||||||
|
EXEC mh_jnd.sys.sp_addextendedproperty 'MS_Description', N'协议类型(数据字典表)', 'schema', N'dbo', 'table', N'device_code_param', 'column', N'protocol_type'; |
||||||
|
|
||||||
|
-- 2024-09-24 data_result表添加字段 |
||||||
|
ALTER TABLE data_result ADD register_addr varchar(50) NULL; |
||||||
|
EXEC sys.sp_addextendedproperty 'MS_Description', N'寄存器地址', 'schema', N'dbo', 'table', N'data_result', 'column', N'register_addr'; |
||||||
|
ALTER TABLE data_result ADD register_name varchar(50) NULL; |
||||||
|
EXEC sys.sp_addextendedproperty 'MS_Description', N'寄存器名称', 'schema', N'dbo', 'table', N'data_result', 'column', N'register_name'; |
@ -0,0 +1,48 @@ |
|||||||
|
package com.mh.user.annotation; |
||||||
|
|
||||||
|
import java.lang.annotation.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 数据字典注解 |
||||||
|
* @date 2024-11-08 11:40:46 |
||||||
|
*/ |
||||||
|
@Target(ElementType.FIELD) |
||||||
|
@Inherited |
||||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||||
|
@Documented |
||||||
|
public @interface FieldParam { |
||||||
|
|
||||||
|
/** |
||||||
|
* 字典值 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
String value() default ""; |
||||||
|
|
||||||
|
/** |
||||||
|
* 字典类型 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
String type() default ""; |
||||||
|
|
||||||
|
/** |
||||||
|
* 字典标签 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
String label() default ""; |
||||||
|
|
||||||
|
/** |
||||||
|
* 要翻译的字段,目标字段翻译的字段+Str |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
String targetField() default ""; |
||||||
|
|
||||||
|
/** |
||||||
|
* 要翻译的字段值类型 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
Class targetFieldValueClazz() default String.class; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.mh.user.annotation; |
||||||
|
|
||||||
|
import java.lang.annotation.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 需要翻译的字典值 |
||||||
|
* @date 2024-11-08 14:29:39 |
||||||
|
*/ |
||||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||||
|
@Target(ElementType.METHOD) |
||||||
|
@Documented |
||||||
|
public @interface TranslationDict { |
||||||
|
FieldParam[] value(); |
||||||
|
} |
@ -0,0 +1,136 @@ |
|||||||
|
package com.mh.user.aspect; |
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||||
|
import com.mh.user.annotation.FieldParam; |
||||||
|
import com.mh.user.annotation.TranslationDict; |
||||||
|
import com.mh.user.model.SysDict; |
||||||
|
import com.mh.user.service.SysDictService; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.aspectj.lang.ProceedingJoinPoint; |
||||||
|
import org.aspectj.lang.annotation.Around; |
||||||
|
import org.aspectj.lang.annotation.Aspect; |
||||||
|
import org.aspectj.lang.reflect.MethodSignature; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.lang.reflect.Method; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Optional; |
||||||
|
import java.util.regex.Matcher; |
||||||
|
import java.util.regex.Pattern; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 数据字典转换 |
||||||
|
* @date 2024-11-08 14:08:20 |
||||||
|
*/ |
||||||
|
@Aspect |
||||||
|
@Component |
||||||
|
@Slf4j |
||||||
|
public class DictDataTranslateAsp { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private SysDictService sysDictService; |
||||||
|
|
||||||
|
@Around("@annotation(com.mh.user.annotation.TranslationDict)") |
||||||
|
public Object aroundMethodTranslate(ProceedingJoinPoint joinPoint) throws Throwable { |
||||||
|
// 接收到请求时间
|
||||||
|
Long startTime = System.currentTimeMillis(); |
||||||
|
// 注意,如果调用joinPoint.proceed()方法,则修改的参数值不会生效,必须调用joinPoint.proceed(args)
|
||||||
|
Object result = joinPoint.proceed(); |
||||||
|
|
||||||
|
// 获取返回值类型
|
||||||
|
Class<?> returnType = ((MethodSignature) joinPoint.getSignature()).getReturnType(); |
||||||
|
|
||||||
|
// 取出要翻译的字典值
|
||||||
|
String returnJsonResult = JSONObject.toJSONString(result); |
||||||
|
|
||||||
|
// 开始解析
|
||||||
|
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); |
||||||
|
|
||||||
|
// 获取注解上参数
|
||||||
|
TranslationDict annotation = method.getAnnotation(TranslationDict.class); |
||||||
|
FieldParam[] fieldParams = annotation.value(); |
||||||
|
|
||||||
|
// 遍历
|
||||||
|
for (FieldParam fieldParam : fieldParams) { |
||||||
|
log.info("字典类型:{},取值字段:{}", fieldParam.type(), fieldParam.targetField()); |
||||||
|
Pattern dictPattern = getPattern(fieldParam); |
||||||
|
Matcher matcher = dictPattern.matcher(returnJsonResult); |
||||||
|
StringBuffer sb = new StringBuffer(); |
||||||
|
// 转义字段
|
||||||
|
this.translateDict(fieldParam, dictPattern, matcher, sb); |
||||||
|
matcher.appendTail(sb); |
||||||
|
returnJsonResult = sb.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
result = JSONObject.parseObject(returnJsonResult, returnType); |
||||||
|
// 如果这里不返回result,则目标对象实际返回值会被置为null
|
||||||
|
// 处理完成时间
|
||||||
|
Long endTime = System.currentTimeMillis(); |
||||||
|
log.info("数据字典转换耗时:{}ms", endTime - startTime); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 字典值转义为中文 |
||||||
|
* |
||||||
|
* @param fieldParam |
||||||
|
* @param fieldPattern |
||||||
|
* @param fieldMatcher |
||||||
|
* @param sb |
||||||
|
*/ |
||||||
|
private void translateDict(FieldParam fieldParam, Pattern fieldPattern, Matcher fieldMatcher, StringBuffer sb) { |
||||||
|
//从缓存中一次性取值
|
||||||
|
List<SysDict> dictNames = sysDictService.findByType(fieldParam.type()); |
||||||
|
while (fieldMatcher.find()) { |
||||||
|
//取出要翻译字段对应的值
|
||||||
|
Matcher dictValueMatcher = fieldPattern.matcher(fieldMatcher.group()); |
||||||
|
dictValueMatcher.find(); |
||||||
|
String group = dictValueMatcher.group(); |
||||||
|
//""sex":1", ""sex":"1"",""sex":null"
|
||||||
|
//属性无值
|
||||||
|
if (group.split(":").length <= 1) continue; |
||||||
|
String dictName = ""; |
||||||
|
//获取字典值
|
||||||
|
String dictValue = group.split(":")[1].replace("\"", ""); |
||||||
|
//属性值非为空 为空赋值空串
|
||||||
|
if (StringUtils.isNotBlank(dictValue) && !dictValue.equalsIgnoreCase("null")) { |
||||||
|
//多值
|
||||||
|
if (dictValue.split(",").length > 1) { |
||||||
|
for (String s : dictValue.split(",")) { |
||||||
|
//fieldParam.dictType() + "_" + s 根据自己字典表设置的规则去查询
|
||||||
|
String type = s; |
||||||
|
Optional<SysDict> first = dictNames.stream().filter(d -> d.getValue().equals(type)).findFirst(); |
||||||
|
if (!first.isPresent()) continue; |
||||||
|
dictName += first.get().getLabel() + "/"; |
||||||
|
} |
||||||
|
} else { |
||||||
|
String type = dictValue; |
||||||
|
Optional<SysDict> first = dictNames.stream().filter(d -> d.getValue().equals(type)).findFirst(); |
||||||
|
if (!first.isPresent()) continue; |
||||||
|
dictName = first.get().getLabel(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
String s = "\"" + fieldParam.targetField() + "Str" + "\":\"" + dictName + "\"," + fieldMatcher.group(); |
||||||
|
log.info("拼接后字符串:{}", s); |
||||||
|
fieldMatcher.appendReplacement(sb, s); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private Pattern getPattern(FieldParam fieldParam) { |
||||||
|
Pattern fieldPattern;//属性整型 字符型
|
||||||
|
if (fieldParam.targetFieldValueClazz().equals(Integer.class)) { |
||||||
|
fieldPattern = Pattern.compile("\"" + fieldParam.targetField() + "\":(\\d+)?"); |
||||||
|
} else { |
||||||
|
fieldPattern = Pattern.compile("\"" + fieldParam.targetField() + "\":\"([0-9a-zA-Z_,]+)?\""); |
||||||
|
} |
||||||
|
return fieldPattern; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.mh.user.config; |
||||||
|
|
||||||
|
import com.github.benmanes.caffeine.cache.*; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @title : |
||||||
|
* @description 使用caffeine缓存技术 |
||||||
|
* @updateTime 2020-12-15 |
||||||
|
* @throws : |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@Configuration |
||||||
|
public class CaffeineCacheConfig { |
||||||
|
|
||||||
|
// 软引用: 如果一个对象只具有软引用,则内存空间足够,垃圾回收器就不会回收它;如果内存空间不足了,就会回收这些对象的内存。
|
||||||
|
// 弱引用: 弱引用的对象拥有更短暂的生命周期。在垃圾回收器线程扫描它所管辖的内存区域的过程中,一旦发现了只具有弱引用的对象,
|
||||||
|
// 不管当前内存空间足够与否,都会回收它的内存
|
||||||
|
@Bean(name = "caffeineCache") |
||||||
|
public Cache<String, Object> caffeineCache() { |
||||||
|
return Caffeine.newBuilder() |
||||||
|
// 软引用
|
||||||
|
.softValues() |
||||||
|
// 弱引用
|
||||||
|
// .weakValues()
|
||||||
|
// 设置最后一次写入或访问后经过固定时间过期
|
||||||
|
.expireAfterWrite(8*60*60, TimeUnit.SECONDS) |
||||||
|
// 初始的缓存空间大小
|
||||||
|
.initialCapacity(100) |
||||||
|
// 缓存的最大条数
|
||||||
|
.maximumSize(1000) |
||||||
|
.build(); |
||||||
|
} |
||||||
|
|
||||||
|
//定义缓存,可直接使用
|
||||||
|
@Bean |
||||||
|
public LoadingCache expiryCache(){ |
||||||
|
LoadingCache<String, Object> loadingCache = Caffeine.newBuilder() |
||||||
|
.initialCapacity(100) |
||||||
|
.maximumSize(1000) |
||||||
|
//缓存写入/删除监控
|
||||||
|
.writer(new CacheWriter<Object, Object>() { |
||||||
|
@Override |
||||||
|
public void write(Object key, Object value) { //此方法是同步阻塞的
|
||||||
|
log.info("--缓存写入--:key={}, value={}", key, value); |
||||||
|
} |
||||||
|
@Override |
||||||
|
public void delete(Object key, Object value, RemovalCause cause) { |
||||||
|
log.info("--缓存删除--:key={}", key); } |
||||||
|
}) |
||||||
|
.expireAfterAccess(6, TimeUnit.HOURS) //过期时间
|
||||||
|
.build((String key)->"刷新的数据"); //cacheload实现类,刷新时候调用
|
||||||
|
// loadingCache.put("name","侯征");
|
||||||
|
return loadingCache; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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;
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
@ -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;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
} |
//}
|
||||||
|
@ -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;
|
||||||
} |
//}
|
@ -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(); |
// }
|
||||||
} |
//}
|
||||||
} |
|
||||||
|
@ -0,0 +1,12 @@ |
|||||||
|
package com.mh.user.constants; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 主机枚举类 |
||||||
|
* @date 2024-08-28 17:21:39 |
||||||
|
*/ |
||||||
|
public enum ChillerParamsEnum { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
package com.mh.user.constants; |
||||||
|
|
||||||
|
import com.mh.user.factory.CJ188Protocol; |
||||||
|
import com.mh.user.factory.EleProtocol; |
||||||
|
import com.mh.user.factory.ModbusProtocol; |
||||||
|
import com.mh.user.factory.Protocol; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 协议枚举类 |
||||||
|
* @date 2024-09-12 10:31:53 |
||||||
|
*/ |
||||||
|
public enum ProtocolEnum { |
||||||
|
|
||||||
|
CJ188_PROTOCOL("0", CJ188Protocol.getInstance()), |
||||||
|
|
||||||
|
MODBUS_PROTOCOL("1", ModbusProtocol.getInstance()), |
||||||
|
|
||||||
|
ELE_97_PROTOCOL("2", EleProtocol.getInstance()), |
||||||
|
|
||||||
|
ELE_07_PROTOCOL("3", EleProtocol.getInstance()), |
||||||
|
|
||||||
|
; |
||||||
|
|
||||||
|
private String protocolType; |
||||||
|
|
||||||
|
private Protocol protocol; |
||||||
|
|
||||||
|
private ProtocolEnum(String protocolType, Protocol protocol) { |
||||||
|
this.protocolType = protocolType; |
||||||
|
this.protocol = protocol; |
||||||
|
} |
||||||
|
|
||||||
|
public String getProtocolType() { |
||||||
|
return protocolType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProtocolType(String protocolType) { |
||||||
|
this.protocolType = protocolType; |
||||||
|
} |
||||||
|
|
||||||
|
public Protocol getProtocol() { |
||||||
|
return protocol; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProtocol(Protocol protocol) { |
||||||
|
this.protocol = protocol; |
||||||
|
} |
||||||
|
|
||||||
|
public static Protocol getProtocol(String protocolType) { |
||||||
|
for (ProtocolEnum protocolEnum : ProtocolEnum.values()) { |
||||||
|
if (protocolEnum.getProtocolType().equals(protocolType)) { |
||||||
|
return protocolEnum.getProtocol(); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
package com.mh.user.constants; |
||||||
|
|
||||||
|
import com.mh.user.strategy.CJ188ProtocolStrategy; |
||||||
|
import com.mh.user.strategy.EleProtocolStrategy; |
||||||
|
import com.mh.user.strategy.ModbusProtocolStrategy; |
||||||
|
import com.mh.user.strategy.ProtocolStrategy; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 协议枚举类 |
||||||
|
* @date 2024-09-12 10:31:53 |
||||||
|
*/ |
||||||
|
public enum ProtocolStrategyEnum { |
||||||
|
|
||||||
|
CJ188_PROTOCOL("0", CJ188ProtocolStrategy.getInstance()), |
||||||
|
|
||||||
|
MODBUS_PROTOCOL("1", ModbusProtocolStrategy.getInstance()), |
||||||
|
|
||||||
|
ELE_97_PROTOCOL("2", EleProtocolStrategy.getInstance()), |
||||||
|
|
||||||
|
ELE_07_PROTOCOL("3", EleProtocolStrategy.getInstance()), |
||||||
|
|
||||||
|
; |
||||||
|
|
||||||
|
private String protocolType; |
||||||
|
|
||||||
|
private ProtocolStrategy protocolStrategy; |
||||||
|
|
||||||
|
ProtocolStrategyEnum(String protocolType, ProtocolStrategy protocolStrategy) { |
||||||
|
this.protocolType = protocolType; |
||||||
|
this.protocolStrategy = protocolStrategy; |
||||||
|
} |
||||||
|
|
||||||
|
public String getProtocolType() { |
||||||
|
return protocolType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProtocolType(String protocolType) { |
||||||
|
this.protocolType = protocolType; |
||||||
|
} |
||||||
|
|
||||||
|
public ProtocolStrategy getProtocolStrategy() { |
||||||
|
return protocolStrategy; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProtocolStrategy(ProtocolStrategy protocolStrategy) { |
||||||
|
this.protocolStrategy = protocolStrategy; |
||||||
|
} |
||||||
|
|
||||||
|
public static ProtocolStrategy getProtocolStrategy(String protocolType) { |
||||||
|
for (ProtocolStrategyEnum protocolStrategyEnum : ProtocolStrategyEnum.values()) { |
||||||
|
if (protocolStrategyEnum.getProtocolType().equals(protocolType)) { |
||||||
|
return protocolStrategyEnum.getProtocolStrategy(); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -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()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,63 @@ |
|||||||
|
package com.mh.user.controller; |
||||||
|
|
||||||
|
import com.mh.common.http.HttpResult; |
||||||
|
import com.mh.common.page.PageRequest; |
||||||
|
import com.mh.common.page.PageResult; |
||||||
|
import com.mh.user.annotation.FieldParam; |
||||||
|
import com.mh.user.annotation.SysLogger; |
||||||
|
import com.mh.user.annotation.TranslationDict; |
||||||
|
import com.mh.user.entity.DevicesManageEntity; |
||||||
|
import com.mh.user.service.DevicesManageService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 仪表管理控制层 |
||||||
|
* @date 2024-08-23 08:53:03 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/devicesManage") |
||||||
|
public class DevicesManageController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private DevicesManageService devicesManageService; |
||||||
|
|
||||||
|
@SysLogger(value = "资产管理信息", optDesc = "查询资产管理信息") |
||||||
|
@PostMapping("/findByPage") |
||||||
|
@TranslationDict({@FieldParam(type = "device_type", targetField = "deviceType", targetFieldValueClazz = Integer.class)}) |
||||||
|
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) { |
||||||
|
return devicesManageService.queryByPage(pageRequest); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value = "资产管理信息", optDesc = "编辑资产管理信息") |
||||||
|
@PostMapping("/update") |
||||||
|
public HttpResult updateProInfo(DevicesManageEntity entity) { |
||||||
|
devicesManageService.update(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value = "资产管理信息", optDesc = "根据项目id查询对应信息") |
||||||
|
@GetMapping("/findById") |
||||||
|
public HttpResult findById(@RequestParam("id") Long id) { |
||||||
|
DevicesManageEntity entity = devicesManageService.findById(id); |
||||||
|
return HttpResult.ok(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value = "资产管理信息", optDesc = "添加资产管理信息") |
||||||
|
@PostMapping("/save") |
||||||
|
public HttpResult saveDevice(DevicesManageEntity entity) { |
||||||
|
devicesManageService.save(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value = "资产管理信息", optDesc = "删除资产管理信息") |
||||||
|
@GetMapping("/deleteById") |
||||||
|
public HttpResult deleteProInfo(@RequestParam String id) { |
||||||
|
devicesManageService.delete(id); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
package com.mh.user.controller; |
||||||
|
|
||||||
|
import com.mh.common.http.HttpResult; |
||||||
|
import com.mh.common.page.PageRequest; |
||||||
|
import com.mh.common.page.PageResult; |
||||||
|
import com.mh.user.annotation.SysLogger; |
||||||
|
import com.mh.user.entity.DeviceParamsEntity; |
||||||
|
import com.mh.user.service.DeviceParamsService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 设备参数管理控制层 |
||||||
|
* @date 2024-08-23 08:53:03 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/deviceParams") |
||||||
|
public class DevicesParamsController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private DeviceParamsService deviceParamsService; |
||||||
|
|
||||||
|
@SysLogger(value="设备参数管理",optDesc = "查询设备参数管理") |
||||||
|
@PostMapping("/findByPage") |
||||||
|
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) { |
||||||
|
return deviceParamsService.queryByPage(pageRequest); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="设备参数管理",optDesc = "编辑设备参数管理") |
||||||
|
@PostMapping("/update") |
||||||
|
public HttpResult updateProInfo(DeviceParamsEntity entity) { |
||||||
|
deviceParamsService.update(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="设备参数管理",optDesc = "根据项目id查询对应信息") |
||||||
|
@GetMapping("/findById") |
||||||
|
public HttpResult findById(@RequestParam("id") Long id) { |
||||||
|
DeviceParamsEntity entity = deviceParamsService.findById(id); |
||||||
|
return HttpResult.ok(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="设备参数管理",optDesc = "添加设备参数管理") |
||||||
|
@PostMapping("/save") |
||||||
|
public HttpResult saveGw(DeviceParamsEntity entity) { |
||||||
|
deviceParamsService.save(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="设备参数管理",optDesc = "删除设备参数管理") |
||||||
|
@GetMapping("/deleteById") |
||||||
|
public HttpResult deleteProInfo(@RequestParam String id) { |
||||||
|
deviceParamsService.delete(id); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
package com.mh.user.controller; |
||||||
|
|
||||||
|
import com.mh.common.http.HttpResult; |
||||||
|
import com.mh.common.page.PageRequest; |
||||||
|
import com.mh.common.page.PageResult; |
||||||
|
import com.mh.user.annotation.SysLogger; |
||||||
|
import com.mh.user.entity.GatewayManageEntity; |
||||||
|
import com.mh.user.service.GatewayManageService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 网关管理接口控制类 |
||||||
|
* @date 2024-08-22 17:19:21 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/gw") |
||||||
|
public class GatewayManageController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private GatewayManageService gatewayManageService; |
||||||
|
|
||||||
|
@SysLogger(value="网关管理信息",optDesc = "查询网关管理信息") |
||||||
|
@PostMapping("/findByPage") |
||||||
|
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) { |
||||||
|
return gatewayManageService.queryByPage(pageRequest); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="网关管理信息",optDesc = "编辑网关管理信息") |
||||||
|
@PostMapping("/update") |
||||||
|
public HttpResult updateProInfo(GatewayManageEntity gatewayManageEntity) { |
||||||
|
gatewayManageService.update(gatewayManageEntity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="网关管理信息",optDesc = "根据项目id查询对应信息") |
||||||
|
@GetMapping("/findById") |
||||||
|
public HttpResult findById(@RequestParam("id") Long id) { |
||||||
|
GatewayManageEntity gatewayManageEntity = gatewayManageService.findById(id); |
||||||
|
return HttpResult.ok(gatewayManageEntity); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="网关管理信息",optDesc = "添加网关管理信息") |
||||||
|
@PostMapping("/save") |
||||||
|
public HttpResult saveGw(GatewayManageEntity gatewayManageEntity) { |
||||||
|
gatewayManageService.save(gatewayManageEntity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="网关管理信息",optDesc = "删除网关管理信息") |
||||||
|
@GetMapping("/deleteById") |
||||||
|
public HttpResult deleteProInfo(@RequestParam String id) { |
||||||
|
gatewayManageService.delete(id); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,67 @@ |
|||||||
|
package com.mh.user.controller; |
||||||
|
|
||||||
|
import com.mh.common.http.HttpResult; |
||||||
|
import com.mh.common.page.PageRequest; |
||||||
|
import com.mh.common.page.PageResult; |
||||||
|
import com.mh.user.annotation.FieldParam; |
||||||
|
import com.mh.user.annotation.SysLogger; |
||||||
|
import com.mh.user.annotation.TranslationDict; |
||||||
|
import com.mh.user.entity.MeterManageEntity; |
||||||
|
import com.mh.user.service.MeterManageService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 仪表管理控制层 |
||||||
|
* @date 2024-08-23 08:53:03 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/mtManage") |
||||||
|
public class MeterManageController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private MeterManageService meterManageService; |
||||||
|
|
||||||
|
@TranslationDict({@FieldParam(type = "device_type", targetField = "deviceType", targetFieldValueClazz = Integer.class), |
||||||
|
@FieldParam(type = "communication_type", targetField = "communicationType", targetFieldValueClazz = Integer.class), |
||||||
|
@FieldParam(type = "data_type", targetField = "dataType", targetFieldValueClazz = Integer.class), |
||||||
|
@FieldParam(type = "protocol_type", targetField = "protocolType", targetFieldValueClazz = Integer.class), |
||||||
|
}) |
||||||
|
@SysLogger(value="仪表管理信息",optDesc = "查询仪表管理信息") |
||||||
|
@PostMapping("/findByPage") |
||||||
|
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) { |
||||||
|
return meterManageService.queryByPage(pageRequest); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="仪表管理信息",optDesc = "编辑仪表管理信息") |
||||||
|
@PostMapping("/update") |
||||||
|
public HttpResult updateProInfo(MeterManageEntity entity) { |
||||||
|
meterManageService.update(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="仪表管理信息",optDesc = "根据项目id查询对应信息") |
||||||
|
@GetMapping("/findById") |
||||||
|
public HttpResult findById(@RequestParam("id") Long id) { |
||||||
|
MeterManageEntity entity = meterManageService.findById(id); |
||||||
|
return HttpResult.ok(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="仪表管理信息",optDesc = "添加仪表管理信息") |
||||||
|
@PostMapping("/save") |
||||||
|
public HttpResult saveGw(MeterManageEntity entity) { |
||||||
|
meterManageService.save(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="仪表管理信息",optDesc = "删除仪表管理信息") |
||||||
|
@GetMapping("/deleteById") |
||||||
|
public HttpResult deleteProInfo(@RequestParam String id) { |
||||||
|
meterManageService.delete(id); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
package com.mh.user.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject; |
||||||
|
import com.mh.common.http.HttpResult; |
||||||
|
import com.mh.user.dto.ScreenRequestParamDTO; |
||||||
|
import com.mh.user.service.ScreenService; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 大屏接口类 |
||||||
|
* @date 2024-09-24 11:40:15 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/screen") |
||||||
|
public class ScreenController { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ScreenService screenService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 能耗数据 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/energyData") |
||||||
|
public HttpResult energyData(@RequestBody ScreenRequestParamDTO screenRequestParamDTO) { |
||||||
|
return HttpResult.ok(screenService.energyData(screenRequestParamDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 节能量概况 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/savingEnergyData") |
||||||
|
public HttpResult savingEnergy(@RequestBody ScreenRequestParamDTO screenRequestParamDTO) { |
||||||
|
return HttpResult.ok(screenService.savingEnergy(screenRequestParamDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 节能量同比 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/savingYoyEnergyData") |
||||||
|
public HttpResult savingYoyEnergyData(@RequestBody ScreenRequestParamDTO screenRequestParamDTO) { |
||||||
|
return HttpResult.ok(screenService.savingYoyEnergyData(screenRequestParamDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 故障详情 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/faultList") |
||||||
|
public HttpResult faultList() { |
||||||
|
return HttpResult.ok(screenService.faultList()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 项目坐标数据 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/projectData") |
||||||
|
public HttpResult projectData() { |
||||||
|
return HttpResult.ok(screenService.projectData()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
package com.mh.user.controller; |
||||||
|
|
||||||
|
import com.mh.common.http.HttpResult; |
||||||
|
import com.mh.common.page.PageRequest; |
||||||
|
import com.mh.common.page.PageResult; |
||||||
|
import com.mh.user.annotation.SysLogger; |
||||||
|
import com.mh.user.model.SysDict; |
||||||
|
import com.mh.user.service.SysDictService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 系统字典管理 |
||||||
|
* @date 2024-08-23 10:59:09 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/dict") |
||||||
|
public class SysDictController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private SysDictService sysDictService; |
||||||
|
|
||||||
|
@SysLogger(value="系统字典管理",optDesc = "查询系统字典管理") |
||||||
|
@PostMapping("/findByPage") |
||||||
|
public PageResult queryGatewayManage(@RequestBody PageRequest pageRequest) { |
||||||
|
return sysDictService.findPage(pageRequest); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="系统字典管理",optDesc = "编辑系统字典管理") |
||||||
|
@PostMapping("/update") |
||||||
|
public HttpResult update(SysDict entity) { |
||||||
|
sysDictService.updateByPrimaryKey(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="系统字典管理",optDesc = "根据项目id查询对应信息") |
||||||
|
@GetMapping("/findById") |
||||||
|
public HttpResult findById(@RequestParam("id") Long id) { |
||||||
|
SysDict entity = sysDictService.findById(id); |
||||||
|
return HttpResult.ok(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="系统字典管理",optDesc = "添加系统字典管理") |
||||||
|
@PostMapping("/save") |
||||||
|
public HttpResult save(SysDict entity) { |
||||||
|
sysDictService.save(entity); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="系统字典管理",optDesc = "删除系统字典管理") |
||||||
|
@GetMapping("/deleteById") |
||||||
|
public HttpResult delete(@RequestParam Long id) { |
||||||
|
sysDictService.deleteByPrimaryKey(id); |
||||||
|
return HttpResult.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
@SysLogger(value="系统字典管理",optDesc = "根据设备类型查询系统字典管理") |
||||||
|
@GetMapping("/findByType") |
||||||
|
public HttpResult findByType(@RequestParam String type) { |
||||||
|
return HttpResult.ok(sysDictService.findByType(type)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
package com.mh.user.dto; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 大屏请求参数 |
||||||
|
* @date 2024-09-24 14:12:01 |
||||||
|
*/ |
||||||
|
public class ScreenRequestParamDTO { |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询类型:now:当前数据, day:日数据, week:周数据, month:月数据, year:年数据 |
||||||
|
*/ |
||||||
|
private String timeType; |
||||||
|
|
||||||
|
private String startTime; |
||||||
|
|
||||||
|
private String endTime; |
||||||
|
|
||||||
|
private String projectId; |
||||||
|
|
||||||
|
public String getProjectId() { |
||||||
|
return projectId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProjectId(String projectId) { |
||||||
|
this.projectId = projectId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTimeType() { |
||||||
|
return timeType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTimeType(String timeType) { |
||||||
|
this.timeType = timeType; |
||||||
|
} |
||||||
|
|
||||||
|
public String getStartTime() { |
||||||
|
return startTime; |
||||||
|
} |
||||||
|
|
||||||
|
public void setStartTime(String startTime) { |
||||||
|
this.startTime = startTime; |
||||||
|
} |
||||||
|
|
||||||
|
public String getEndTime() { |
||||||
|
return endTime; |
||||||
|
} |
||||||
|
|
||||||
|
public void setEndTime(String endTime) { |
||||||
|
this.endTime = endTime; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "ScreenRequestParamDTO{" + |
||||||
|
"timeType='" + timeType + '\'' + |
||||||
|
", startTime='" + startTime + '\'' + |
||||||
|
", endTime='" + endTime + '\'' + |
||||||
|
", projectId='" + projectId + '\'' + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
@ -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);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
} |
//}
|
||||||
|
@ -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;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
} |
//}
|
||||||
|
@ -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);
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
@ -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; |
||||||
|
|
||||||
|
} |
@ -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; |
|
||||||
} |
} |
||||||
|
@ -0,0 +1,7 @@ |
|||||||
|
package com.mh.user.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
|
||||||
|
@TableName("data_result_ch") |
||||||
|
public class DataResultChillerEntity extends BaseResultEntity { |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
} |
@ -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; |
||||||
|
|
||||||
} |
} |
||||||
|
@ -1,22 +1,34 @@ |
|||||||
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; |
||||||
|
private String registerName; |
||||||
|
private String registerAddr; |
||||||
} |
} |
||||||
|
@ -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 { |
||||||
|
} |
@ -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 { |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
package com.mh.user.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
|
||||||
|
@TableName("data_result_now") |
||||||
|
public class DataResultNowEntity extends BaseResultEntity { |
||||||
|
} |
@ -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 { |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
} |
@ -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 + '\'' + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,148 @@ |
|||||||
|
package com.mh.user.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 资产设备管理 |
||||||
|
* @date 2024-08-22 16:11:30 |
||||||
|
*/ |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
@TableName("devices_manage") |
||||||
|
public class DevicesManageEntity implements Serializable { |
||||||
|
|
||||||
|
/** |
||||||
|
* 编号 |
||||||
|
*/ |
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备名称 |
||||||
|
*/ |
||||||
|
private String deviceName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备品牌 |
||||||
|
*/ |
||||||
|
private String deviceBrand; |
||||||
|
|
||||||
|
/** |
||||||
|
* 机电品牌 |
||||||
|
*/ |
||||||
|
private String emBrand; |
||||||
|
|
||||||
|
/** |
||||||
|
* 额定输入功率 |
||||||
|
*/ |
||||||
|
private BigDecimal ratedInputPower; |
||||||
|
|
||||||
|
/** |
||||||
|
* 额定制冷量 |
||||||
|
*/ |
||||||
|
private BigDecimal ratedRefrigerationCapacity; |
||||||
|
|
||||||
|
/** |
||||||
|
* 额定COP |
||||||
|
*/ |
||||||
|
private BigDecimal ratedCop; |
||||||
|
|
||||||
|
/** |
||||||
|
* 额定流量 |
||||||
|
*/ |
||||||
|
private BigDecimal ratedFlow; |
||||||
|
|
||||||
|
/** |
||||||
|
* 生产日期 |
||||||
|
*/ |
||||||
|
private String productionTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间 |
||||||
|
*/ |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建人 |
||||||
|
*/ |
||||||
|
private String createBy; |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否变频 |
||||||
|
*/ |
||||||
|
private byte isFrequency; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备类型 |
||||||
|
*/ |
||||||
|
private long deviceType; |
||||||
|
|
||||||
|
/** |
||||||
|
* 备注 |
||||||
|
*/ |
||||||
|
private String remark; |
||||||
|
|
||||||
|
/** |
||||||
|
* 等级 |
||||||
|
*/ |
||||||
|
private Integer grade = 0; |
||||||
|
|
||||||
|
/** |
||||||
|
* 系统类型id |
||||||
|
*/ |
||||||
|
private Long systemId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 项目id |
||||||
|
*/ |
||||||
|
private Long projectId; |
||||||
|
|
||||||
|
private String factoryBarcode; |
||||||
|
|
||||||
|
private String imuCode; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "DevicesManageEntity{" + |
||||||
|
"id=" + id + |
||||||
|
", deviceName='" + deviceName + '\'' + |
||||||
|
", deviceBrand='" + deviceBrand + '\'' + |
||||||
|
", emBrand='" + emBrand + '\'' + |
||||||
|
", ratedInputPower=" + ratedInputPower + |
||||||
|
", ratedRefrigerationCapacity=" + ratedRefrigerationCapacity + |
||||||
|
", ratedCop=" + ratedCop + |
||||||
|
", ratedFlow=" + ratedFlow + |
||||||
|
", productionTime='" + productionTime + '\'' + |
||||||
|
", createTime=" + createTime + |
||||||
|
", updateTime=" + updateTime + |
||||||
|
", createBy='" + createBy + '\'' + |
||||||
|
", isFrequency=" + isFrequency + |
||||||
|
", deviceType=" + deviceType + |
||||||
|
", remark='" + remark + '\'' + |
||||||
|
", grade=" + grade + |
||||||
|
", systemId=" + systemId + |
||||||
|
", projectId=" + projectId + |
||||||
|
", factoryBarcode='" + factoryBarcode + '\'' + |
||||||
|
", imuCode='" + imuCode + '\'' + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,235 @@ |
|||||||
|
package com.mh.user.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 仪表管理 |
||||||
|
* @date 2024-08-22 16:35:19 |
||||||
|
*/ |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
@TableName("meter_manage") |
||||||
|
public class MeterManageEntity implements Serializable { |
||||||
|
|
||||||
|
/** |
||||||
|
* 编号 |
||||||
|
*/ |
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仪表类型 |
||||||
|
*/ |
||||||
|
private Long mtType; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仪表名称 |
||||||
|
*/ |
||||||
|
private String mtName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 其他名称 |
||||||
|
*/ |
||||||
|
private String otherName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仪表品牌 |
||||||
|
*/ |
||||||
|
private String mtBrand; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仪表编号 |
||||||
|
*/ |
||||||
|
private String mtNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仪表地址 |
||||||
|
*/ |
||||||
|
private String mtCode; |
||||||
|
|
||||||
|
/** |
||||||
|
* 寄存器地址 |
||||||
|
*/ |
||||||
|
private String registerAddr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 功能码 |
||||||
|
*/ |
||||||
|
private String funcCode; |
||||||
|
|
||||||
|
/** |
||||||
|
* 数据标识码 |
||||||
|
*/ |
||||||
|
private String identifyCode; |
||||||
|
|
||||||
|
/** |
||||||
|
* 口径以及脉冲常数 |
||||||
|
*/ |
||||||
|
private String mtCaliberPulse; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仪表范围 |
||||||
|
*/ |
||||||
|
private BigDecimal mtRange; |
||||||
|
|
||||||
|
/** |
||||||
|
* 仪表比例 |
||||||
|
*/ |
||||||
|
private int mtRatio; |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始值 |
||||||
|
*/ |
||||||
|
private BigDecimal mtInitValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 保留位数 |
||||||
|
*/ |
||||||
|
private int digits; |
||||||
|
|
||||||
|
/** |
||||||
|
* 数据类型 |
||||||
|
*/ |
||||||
|
private int dataType; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前值 |
||||||
|
*/ |
||||||
|
private BigDecimal curValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前时间 |
||||||
|
*/ |
||||||
|
private Date curTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否是总表 |
||||||
|
*/ |
||||||
|
private byte mtIsSum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间 |
||||||
|
*/ |
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单位 |
||||||
|
*/ |
||||||
|
private String unit; |
||||||
|
|
||||||
|
/** |
||||||
|
* 排序 |
||||||
|
*/ |
||||||
|
private Long sort; |
||||||
|
|
||||||
|
/** |
||||||
|
* 通讯串口 |
||||||
|
*/ |
||||||
|
private String dataCom; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备id |
||||||
|
*/ |
||||||
|
private Long deviceId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 网关id |
||||||
|
*/ |
||||||
|
private Long gatewayId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数id |
||||||
|
*/ |
||||||
|
private Long paramId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 协议类型 |
||||||
|
*/ |
||||||
|
private int protocolType; |
||||||
|
|
||||||
|
/** |
||||||
|
* 备注 |
||||||
|
*/ |
||||||
|
private String remark; |
||||||
|
|
||||||
|
/** |
||||||
|
* 保留位 |
||||||
|
*/ |
||||||
|
private Integer grade = 0; |
||||||
|
|
||||||
|
/** |
||||||
|
* 系统类型id |
||||||
|
*/ |
||||||
|
private Long systemId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 项目id |
||||||
|
*/ |
||||||
|
private Long projectId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 通讯类型 |
||||||
|
*/ |
||||||
|
private Long communicationType; |
||||||
|
|
||||||
|
/** |
||||||
|
* 读取寄存器大小 |
||||||
|
*/ |
||||||
|
private int registerSize; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "MeterManageEntity{" + |
||||||
|
"id=" + id + |
||||||
|
", mtType=" + mtType + |
||||||
|
", mtName='" + mtName + '\'' + |
||||||
|
", otherName='" + otherName + '\'' + |
||||||
|
", mtBrand='" + mtBrand + '\'' + |
||||||
|
", mtNum='" + mtNum + '\'' + |
||||||
|
", mtCode='" + mtCode + '\'' + |
||||||
|
", registerAddr='" + registerAddr + '\'' + |
||||||
|
", funcCode='" + funcCode + '\'' + |
||||||
|
", identifyCode='" + identifyCode + '\'' + |
||||||
|
", mtCaliberPulse='" + mtCaliberPulse + '\'' + |
||||||
|
", mtRange=" + mtRange + |
||||||
|
", mtRatio=" + mtRatio + |
||||||
|
", mtInitValue=" + mtInitValue + |
||||||
|
", digits=" + digits + |
||||||
|
", dataType=" + dataType + |
||||||
|
", curValue=" + curValue + |
||||||
|
", curTime=" + curTime + |
||||||
|
", mtIsSum=" + mtIsSum + |
||||||
|
", createTime=" + createTime + |
||||||
|
", updateTime=" + updateTime + |
||||||
|
", unit='" + unit + '\'' + |
||||||
|
", sort=" + sort + |
||||||
|
", dataCom='" + dataCom + '\'' + |
||||||
|
", deviceId=" + deviceId + |
||||||
|
", gatewayId=" + gatewayId + |
||||||
|
", paramId=" + paramId + |
||||||
|
", protocolType=" + protocolType + |
||||||
|
", remark='" + remark + '\'' + |
||||||
|
", grade=" + grade + |
||||||
|
", systemId=" + systemId + |
||||||
|
", projectId=" + projectId + |
||||||
|
", communicationType=" + communicationType + |
||||||
|
", registerSize=" + registerSize + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
@ -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; //地址
|
||||||
private int pScale; |
|
||||||
private String pic; //图片
|
@TableField("p_scale") |
||||||
|
private String pScale; |
||||||
|
|
||||||
|
@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 String getpScale() { |
||||||
|
return pScale; |
||||||
|
} |
||||||
|
|
||||||
|
public void setpScale(String pScale) { |
||||||
|
this.pScale = pScale; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPic() { |
||||||
|
return pic; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPic(String pic) { |
||||||
|
this.pic = pic; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPicContent() { |
||||||
|
return picContent; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPicContent(String picContent) { |
||||||
|
this.picContent = picContent; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTel() { |
||||||
|
return tel; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTel(String tel) { |
||||||
|
this.tel = tel; |
||||||
|
} |
||||||
|
|
||||||
|
public String getSystemId() { |
||||||
|
return systemId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSystemId(String systemId) { |
||||||
|
this.systemId = systemId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getRemarks() { |
||||||
|
return remarks; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRemarks(String remarks) { |
||||||
|
this.remarks = remarks; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getLongitude() { |
||||||
|
return longitude; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLongitude(BigDecimal longitude) { |
||||||
|
this.longitude = longitude; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getLatitude() { |
||||||
|
return latitude; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLatitude(BigDecimal latitude) { |
||||||
|
this.latitude = latitude; |
||||||
|
} |
||||||
|
|
||||||
|
public Date getCreateTime() { |
||||||
|
return createTime; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) { |
||||||
|
this.createTime = createTime; |
||||||
|
} |
||||||
|
|
||||||
|
public MultipartFile getFile() { |
||||||
|
return file; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFile(MultipartFile file) { |
||||||
|
this.file = file; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "ProjectInfoEntity{" + |
||||||
|
"id=" + id + |
||||||
|
", projectName='" + projectName + '\'' + |
||||||
|
", pAddress='" + pAddress + '\'' + |
||||||
|
", pScale=" + pScale + |
||||||
|
", pic='" + pic + '\'' + |
||||||
|
", picContent='" + picContent + '\'' + |
||||||
|
", tel='" + tel + '\'' + |
||||||
|
", systemId='" + systemId + '\'' + |
||||||
|
", remarks='" + remarks + '\'' + |
||||||
|
", longitude=" + longitude + |
||||||
|
", latitude=" + latitude + |
||||||
|
", createTime=" + createTime + |
||||||
|
", file=" + file + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
|
@ -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 + '\'' + |
||||||
|
'}'; |
||||||
|
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,49 @@ |
|||||||
|
package com.mh.user.factory; |
||||||
|
|
||||||
|
import com.mh.user.entity.DeviceCodeParamEntity; |
||||||
|
import com.mh.user.entity.MeterManageEntity; |
||||||
|
import com.mh.user.strategy.ProtocolStrategy; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 水表标准协议 |
||||||
|
* @date 2024-09-12 14:04:01 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class CJ188Protocol implements Protocol { |
||||||
|
|
||||||
|
private ProtocolStrategy cj188ProtocolStrategy; |
||||||
|
|
||||||
|
private static class SingletonHolder{ |
||||||
|
private static final CJ188Protocol INSTANCE = new CJ188Protocol(); |
||||||
|
} |
||||||
|
|
||||||
|
private CJ188Protocol(){ |
||||||
|
// 防止外部直接实例化
|
||||||
|
} |
||||||
|
|
||||||
|
public static CJ188Protocol getInstance(){ |
||||||
|
return SingletonHolder.INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setStrategy(ProtocolStrategy protocolStrategy) { |
||||||
|
this.cj188ProtocolStrategy = protocolStrategy; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String createOrder(MeterManageEntity meterManageEntity) { |
||||||
|
log.info("水表标准协议:工厂创建报文"); |
||||||
|
return cj188ProtocolStrategy.createOrder(meterManageEntity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData) { |
||||||
|
log.info("水表标准协议:工厂解析报文"); |
||||||
|
return cj188ProtocolStrategy.analysisReceiveData(deviceCodeParamEntity, receiveData); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
package com.mh.user.factory; |
||||||
|
|
||||||
|
import com.mh.user.entity.DeviceCodeParamEntity; |
||||||
|
import com.mh.user.entity.MeterManageEntity; |
||||||
|
import com.mh.user.strategy.ProtocolStrategy; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 水表标准协议 |
||||||
|
* @date 2024-09-12 14:04:01 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class EleProtocol implements Protocol { |
||||||
|
|
||||||
|
private ProtocolStrategy eleProtocolStrategy; |
||||||
|
|
||||||
|
private static class SingletonHolder{ |
||||||
|
private static final EleProtocol INSTANCE = new EleProtocol(); |
||||||
|
} |
||||||
|
|
||||||
|
private EleProtocol(){ |
||||||
|
// 防止外部直接实例化
|
||||||
|
} |
||||||
|
|
||||||
|
public static EleProtocol getInstance(){ |
||||||
|
return SingletonHolder.INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setStrategy(ProtocolStrategy protocolStrategy) { |
||||||
|
this.eleProtocolStrategy = protocolStrategy; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String createOrder(MeterManageEntity meterManageEntity) { |
||||||
|
log.info("电表97/07规约协议:工厂创建报文"); |
||||||
|
return eleProtocolStrategy.createOrder(meterManageEntity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData) { |
||||||
|
log.info("电表97/07规约协议:工厂解析报文"); |
||||||
|
return eleProtocolStrategy.analysisReceiveData(deviceCodeParamEntity, receiveData); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
package com.mh.user.factory; |
||||||
|
|
||||||
|
import com.mh.user.entity.DeviceCodeParamEntity; |
||||||
|
import com.mh.user.entity.MeterManageEntity; |
||||||
|
import com.mh.user.strategy.ProtocolStrategy; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description modbus协议 |
||||||
|
* @date 2024-09-12 16:38:44 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class ModbusProtocol implements Protocol { |
||||||
|
|
||||||
|
private ProtocolStrategy modbusProtocolStrategy; |
||||||
|
|
||||||
|
private static class SingletonHolder{ |
||||||
|
private static final ModbusProtocol INSTANCE = new ModbusProtocol(); |
||||||
|
} |
||||||
|
|
||||||
|
private ModbusProtocol(){ |
||||||
|
// 防止外部直接实例化
|
||||||
|
} |
||||||
|
|
||||||
|
public static ModbusProtocol getInstance(){ |
||||||
|
return ModbusProtocol.SingletonHolder.INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setStrategy(ProtocolStrategy protocolStrategy) { |
||||||
|
this.modbusProtocolStrategy = protocolStrategy; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String createOrder(MeterManageEntity meterManageEntity) { |
||||||
|
log.info("modbus标准协议:工厂创建报文"); |
||||||
|
return modbusProtocolStrategy.createOrder(meterManageEntity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData) { |
||||||
|
log.info("modbus标准协议:工厂解析报文"); |
||||||
|
return modbusProtocolStrategy.analysisReceiveData(deviceCodeParamEntity, receiveData); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package com.mh.user.factory; |
||||||
|
|
||||||
|
import com.mh.user.entity.DeviceCodeParamEntity; |
||||||
|
import com.mh.user.entity.MeterManageEntity; |
||||||
|
import com.mh.user.strategy.ProtocolStrategy; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 根据协议实现对设备的生产和解析 |
||||||
|
* @date 2024-09-12 11:17:20 |
||||||
|
*/ |
||||||
|
public interface Protocol { |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置协议策略 |
||||||
|
* @param protocolStrategy |
||||||
|
*/ |
||||||
|
void setStrategy(ProtocolStrategy protocolStrategy); |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建指令 |
||||||
|
* @param meterManageEntity |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
String createOrder(MeterManageEntity meterManageEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 解析指令 |
||||||
|
* @param deviceCodeParamEntity |
||||||
|
* @param receiveData |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
String analysisReceiveData(DeviceCodeParamEntity deviceCodeParamEntity, String receiveData); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.mh.user.factory; |
||||||
|
|
||||||
|
import com.mh.user.constants.ProtocolEnum; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 协议工厂 |
||||||
|
* @date 2024-09-12 10:29:51 |
||||||
|
*/ |
||||||
|
public class ProtocolFactory { |
||||||
|
|
||||||
|
public static Protocol matchProtocol(String protocolType) { |
||||||
|
return ProtocolEnum.getProtocol(protocolType); |
||||||
|
} |
||||||
|
} |
@ -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();
|
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -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()); |
|
||||||
} |
|
||||||
} |
|
@ -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()); |
|
||||||
} |
|
||||||
} |
|
@ -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;//返回对象
|
|
||||||
} |
|
||||||
} |
|
@ -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()); |
|
||||||
} |
|
||||||
} |
|
@ -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()+"---------------------定时任务测试----------------------"); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -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); |
||||||
|
|
||||||
|
} |
@ -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); |
||||||
|
|
||||||
|
} |
@ -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); |
||||||
|
|
||||||
|
} |
@ -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); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.mh.user.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.mh.user.entity.DataResultChEntity; |
||||||
|
import com.mh.user.entity.DataResultFifteenMiEntity; |
||||||
|
import com.mh.user.entity.DataResultFiveMiEntity; |
||||||
|
import com.mh.user.mapper.provider.DataResultProvider; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
import org.apache.ibatis.annotations.ResultMap; |
||||||
|
import org.apache.ibatis.annotations.SelectProvider; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 每分钟保存数据 |
||||||
|
* @date 2024-07-10 17:34:30 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface DataResultFifteenMiMapper extends BaseMapper<DataResultFifteenMiEntity> { |
||||||
|
|
||||||
|
@SelectProvider(type = DataResultProvider.class,method = "queryDataResultFifteenMi") |
||||||
|
List<DataResultChEntity> queryDataResultFifteenMi(@Param("projectId") String projectId, |
||||||
|
@Param("startDate") String startDate, |
||||||
|
@Param("curDate") String curDate, |
||||||
|
@Param("page") int page, |
||||||
|
@Param("limit") int limit); |
||||||
|
|
||||||
|
//@Select("select count(*) from data_result_fifteen_mi where projectId=#{projectId} and curDate>=#{startDate} and curDate<=#{curDate} ")
|
||||||
|
@SelectProvider(type = DataResultProvider.class,method = "dataResultFifteenMiCount") |
||||||
|
int dataResultFifteenMiCount(@Param("projectId") String projectId,@Param("startDate") String startDate,@Param("curDate") String curDate); |
||||||
|
|
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue