Compare commits
No commits in common. 'dev' and 'prod_202403' have entirely different histories.
dev
...
prod_20240
223 changed files with 1462 additions and 17301 deletions
@ -1,210 +0,0 @@ |
|||||||
-- 2024-05-07 维修表缺少字段 |
|
||||||
ALTER TABLE maintain_info |
|
||||||
ADD cost numeric(2, 0) NULL; |
|
||||||
EXEC sys.sp_addextendedproperty 'MS_Description', N'材料费用', 'schema', N'dbo', 'table', N'maintain_info', 'column', N'cost'; |
|
||||||
ALTER TABLE maintain_info |
|
||||||
ADD contents varchar(100) NULL; |
|
||||||
EXEC sys.sp_addextendedproperty 'MS_Description', N'维保内容', 'schema', N'dbo', 'table', N'maintain_info', 'column', N'contents'; |
|
||||||
ALTER TABLE maintain_info |
|
||||||
ADD evaluate varchar(10) NULL; |
|
||||||
EXEC sys.sp_addextendedproperty 'MS_Description', N'评价内容', 'schema', N'dbo', 'table', N'maintain_info', 'column', N'evaluate'; |
|
||||||
|
|
||||||
-- 训练集合: |
|
||||||
begin tran |
|
||||||
insert into history_data_pre(cur_date,building_id,water_value,elect_value,water_level,env_min_temp,env_max_temp) |
|
||||||
select eds.cur_date, |
|
||||||
eds.building_id, |
|
||||||
isnull(eds.water_value, |
|
||||||
0) as water_value, |
|
||||||
isnull(eds.elect_value, |
|
||||||
0) as elect_value, |
|
||||||
isnull(convert(numeric (24, 2), t1.water_level), |
|
||||||
0) as water_level, |
|
||||||
th.tempmin, |
|
||||||
th.tempmax |
|
||||||
from energy_day_sum eds |
|
||||||
left join (select convert(date, |
|
||||||
cur_date) as cur_date, |
|
||||||
building_id, |
|
||||||
avg(isnull(convert(numeric (24, 2), water_level), 0)) as water_level |
|
||||||
from history_data |
|
||||||
group by convert(date, |
|
||||||
cur_date), |
|
||||||
building_id) t1 on |
|
||||||
eds.cur_date = t1.cur_date and eds.building_id = t1.building_id |
|
||||||
left join temp_history th |
|
||||||
on eds.cur_date = th.cur_date |
|
||||||
where eds.building_id != '所有' |
|
||||||
order by |
|
||||||
eds.building_id, |
|
||||||
eds.cur_date |
|
||||||
rollback |
|
||||||
|
|
||||||
-- 2024-05-09 创建历史预测表 |
|
||||||
-- 历史水电用量以及预测值 |
|
||||||
CREATE TABLE history_data_pre |
|
||||||
( |
|
||||||
cur_date date NULL, |
|
||||||
building_id varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
env_min_temp numeric(24, 2) NULL, |
|
||||||
env_max_temp numeric(24, 2) NULL, |
|
||||||
water_value numeric(24, 2) NULL, |
|
||||||
elect_value numeric(24, 2) NULL, |
|
||||||
water_level numeric(24, 2) NULL, |
|
||||||
id bigint IDENTITY(1,1) NOT NULL, |
|
||||||
water_value_pre numeric(24, 2) NULL, |
|
||||||
elect_value_pre numeric(24, 2) NULL, |
|
||||||
water_level_pre numeric(24, 2) NULL, |
|
||||||
remark varchar(200) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
CONSTRAINT PK_history_data_pre PRIMARY KEY (id) |
|
||||||
); |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'历史水电用量以及预测值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'日期', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'cur_date'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'楼栋编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'building_id'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'环境最低温度', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'env_min_temp'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'环境最高温度', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'env_max_temp'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'实际用水量', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'water_value'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'实际用电量', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'elect_value'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'平均水位', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'water_level'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'id'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'用水量预测值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'water_value_pre'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'用电量预测值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'elect_value_pre'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'平均水位预测值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'water_level_pre'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'history_data_pre', @level2type=N'Column', @level2name=N'remark'; |
|
||||||
|
|
||||||
create index history_data_pre_building_id on history_data_pre (building_id); |
|
||||||
create index history_data_pre_cur_date on history_data_pre (cur_date); |
|
||||||
|
|
||||||
-- 2024-05-09 系统参数表增加天气区域 |
|
||||||
ALTER TABLE SysParam |
|
||||||
ADD proArea varchar(100) NULL; |
|
||||||
EXEC sp_addextendedproperty 'MS_Description', N'天气区域', 'schema', N'dbo', 'table', N'SysParam', 'column', N'proArea'; |
|
||||||
|
|
||||||
-- 2024-05-15 热泵使用时间表(月表) |
|
||||||
CREATE TABLE analysis_runtime_month ( |
|
||||||
id bigint IDENTITY(1,1) NOT NULL, |
|
||||||
cur_date varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
item_type varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day01 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day02 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day03 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day04 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day05 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day06 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day07 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day08 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day09 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day10 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day11 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day12 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day13 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day14 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day15 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day16 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day17 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day18 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day19 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day20 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day21 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day22 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day23 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day24 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day25 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day26 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day27 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day28 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day29 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day30 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
day31 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
total_value varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
building_id varchar(50) COLLATE Chinese_PRC_CI_AS NULL |
|
||||||
); |
|
||||||
-- 使用时间年表 |
|
||||||
CREATE TABLE analysis_runtime_year ( |
|
||||||
id bigint IDENTITY(1,1) NOT NULL, |
|
||||||
cur_date varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
item_type varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month01 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month02 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month03 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month04 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month05 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month06 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month07 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month08 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month09 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month10 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month11 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
month12 varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
total_value varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
building_id varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
building_name varchar(50) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
CONSTRAINT analysis_runtime_year_id PRIMARY KEY (id) |
|
||||||
); |
|
||||||
|
|
||||||
-- Extended properties |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'序号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'id'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'日期', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'cur_date'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'类型', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'item_type'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'1月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month01'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'2月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month02'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'3月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month03'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'4月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month04'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'5月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month05'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'6月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month06'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'7月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month07'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'8月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month08'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'9月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month09'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'10月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month10'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'11月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month11'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'12月用量或比值', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'month12'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'合计用量', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'total_value'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'楼栋编号', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'building_id'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'楼栋名称', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'analysis_runtime_year', @level2type=N'Column', @level2name=N'building_name'; |
|
||||||
|
|
||||||
|
|
||||||
-- 2024-06-24 添加楼栋人数 |
|
||||||
alter table history_data_pre add people_num numeric(24,2) not null default 0; |
|
||||||
exec sp_addextendedproperty N'MS_Description', N'每栋楼人数', N'schema', N'dbo',N'table', N'history_data_pre', N'column', N'people_num'; |
|
||||||
|
|
||||||
-- 2024-06-26 添加知识库 |
|
||||||
CREATE TABLE knowledge_data |
|
||||||
( |
|
||||||
id bigint IDENTITY(1,1) NOT NULL, |
|
||||||
title varchar(100) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
description varchar(200) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
content varchar(2000) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
create_time datetime NULL, |
|
||||||
status int NULL, |
|
||||||
remark varchar(200) COLLATE Chinese_PRC_CI_AS NULL, |
|
||||||
CONSTRAINT pk_knowledge_data PRIMARY KEY (id) |
|
||||||
); |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'知识库数据', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'id', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'id'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'标题', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'title'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'描述', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'description'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'内容', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'content'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'create_time'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'状态', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'status'; |
|
||||||
EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'remark'; |
|
||||||
|
|
||||||
create index knowledge_data_create_time on history_data_pre (create_time); |
|
||||||
|
|
||||||
-- 2024-07-01 水位变换添加 |
|
||||||
ALTER TABLE chws_gsh.dbo.waterLevel ADD level14 varchar(50) NULL; |
|
||||||
EXEC chws_gsh.sys.sp_addextendedproperty 'MS_Description', N'14点水位', 'schema', N'dbo', 'table', N'waterLevel', 'column', N'level14'; |
|
||||||
|
|
||||||
ALTER TABLE chws_gsh.dbo.building ADD low_tank_height numeric(24,2) NULL; |
|
||||||
EXEC chws_gsh.sys.sp_addextendedproperty 'MS_Description', N'低区域水箱高度', 'schema', N'dbo', 'table', N'building', 'column', N'low_tank_height'; |
|
||||||
|
|
||||||
-- 2024-10-11 添加供水,补水,回水状态 |
|
||||||
ALTER TABLE now_data ADD up_water_state varchar(50) NULL; |
|
||||||
EXEC sp_addextendedproperty 'MS_Description', N'供水状态', 'schema', N'dbo', 'table', N'now_data', 'column', N'up_water_state'; |
|
||||||
ALTER TABLE now_data ADD use_water_state varchar(50) NULL; |
|
||||||
EXEC sp_addextendedproperty 'MS_Description', N'补水状态', 'schema', N'dbo', 'table', N'now_data', 'column', N'use_water_state'; |
|
||||||
ALTER TABLE now_data ADD back_water_state varchar(50) NULL; |
|
||||||
EXEC sp_addextendedproperty 'MS_Description', N'回水状态', 'schema', N'dbo', 'table', N'now_data', 'column', N'back_water_state'; |
|
||||||
|
|
||||||
-- 2024-11-19 添加是否是单箱 |
|
||||||
ALTER TABLE building ADD is_single_box bit NULL; |
|
||||||
EXEC sp_addextendedproperty 'MS_Description', N'是否是单箱温度', 'schema', N'dbo', 'table', N'device_install', 'column', N'is_single_box'; |
|
||||||
@ -1,135 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
||||||
<parent> |
|
||||||
<groupId>com.mh</groupId> |
|
||||||
<artifactId>chws</artifactId> |
|
||||||
<version>1.0-SNAPSHOT</version> |
|
||||||
</parent> |
|
||||||
<modelVersion>4.0.0</modelVersion> |
|
||||||
|
|
||||||
<groupId>com.mh</groupId> |
|
||||||
<artifactId>algorithm</artifactId> |
|
||||||
<version>1.0.0</version> |
|
||||||
<packaging>jar</packaging> |
|
||||||
|
|
||||||
<properties> |
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|
||||||
<encoding>UTF-8</encoding> |
|
||||||
<java.version>1.8</java.version> |
|
||||||
<maven.compiler.source>1.8</maven.compiler.source> |
|
||||||
<maven.compiler.target>1.8</maven.compiler.target> |
|
||||||
</properties> |
|
||||||
<dependencies> |
|
||||||
<!-- https://mvnrepository.com/artifact/net.sourceforge.javacsv/javacsv --> |
|
||||||
<dependency> |
|
||||||
<groupId>net.sourceforge.javacsv</groupId> |
|
||||||
<artifactId>javacsv</artifactId> |
|
||||||
<version>2.0</version> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>gov.nist.math</groupId> |
|
||||||
<artifactId>jama</artifactId> |
|
||||||
<version>1.0.3</version> |
|
||||||
</dependency> |
|
||||||
<dependency> |
|
||||||
<groupId>junit</groupId> |
|
||||||
<artifactId>junit</artifactId> |
|
||||||
<version>RELEASE</version> |
|
||||||
<scope>test</scope> |
|
||||||
</dependency> |
|
||||||
</dependencies> |
|
||||||
|
|
||||||
<build> |
|
||||||
<plugins> |
|
||||||
<plugin> |
|
||||||
<groupId>org.apache.maven.plugins</groupId> |
|
||||||
<artifactId>maven-compiler-plugin</artifactId> |
|
||||||
<version>3.9.3</version> |
|
||||||
<configuration> |
|
||||||
<source>1.8</source> |
|
||||||
<target>1.8</target> |
|
||||||
</configuration> |
|
||||||
</plugin> |
|
||||||
</plugins> |
|
||||||
</build> |
|
||||||
|
|
||||||
<profiles> |
|
||||||
<profile> |
|
||||||
<id>default</id> |
|
||||||
<activation> |
|
||||||
<activeByDefault>true</activeByDefault> |
|
||||||
</activation> |
|
||||||
<build> |
|
||||||
<plugins> |
|
||||||
<!-- java版本 --> |
|
||||||
<plugin> |
|
||||||
<groupId>org.apache.maven.plugins</groupId> |
|
||||||
<artifactId>maven-compiler-plugin</artifactId> |
|
||||||
<version>3.8.0</version> |
|
||||||
<configuration> |
|
||||||
<source>1.8</source> |
|
||||||
<target>1.8</target> |
|
||||||
<encoding>UTF-8</encoding> |
|
||||||
</configuration> |
|
||||||
</plugin> |
|
||||||
<!-- 这是javadoc打包插件 --> |
|
||||||
<plugin> |
|
||||||
<groupId>org.apache.maven.plugins</groupId> |
|
||||||
<artifactId>maven-javadoc-plugin</artifactId> |
|
||||||
<version>2.9.1</version> |
|
||||||
<executions> |
|
||||||
<execution> |
|
||||||
<id>attach-javadocs</id> |
|
||||||
<goals> |
|
||||||
<goal>jar</goal> |
|
||||||
</goals> |
|
||||||
<!-- 该处屏蔽jdk1.8后javadoc的严格校验 --> |
|
||||||
<configuration> |
|
||||||
<additionalparam>-Xdoclint:none</additionalparam> |
|
||||||
</configuration> |
|
||||||
</execution> |
|
||||||
</executions> |
|
||||||
</plugin> |
|
||||||
<!-- 打包源码插件 --> |
|
||||||
<plugin> |
|
||||||
<groupId>org.apache.maven.plugins</groupId> |
|
||||||
<artifactId>maven-source-plugin</artifactId> |
|
||||||
<version>2.3</version> |
|
||||||
<executions> |
|
||||||
<execution> |
|
||||||
<id>attach-sources</id> |
|
||||||
<goals> |
|
||||||
<goal>jar</goal> |
|
||||||
</goals> |
|
||||||
</execution> |
|
||||||
</executions> |
|
||||||
</plugin> |
|
||||||
<!--签名插件--> |
|
||||||
<!-- <plugin>--> |
|
||||||
<!-- <groupId>org.apache.maven.plugins</groupId>--> |
|
||||||
<!-- <artifactId>maven-gpg-plugin</artifactId>--> |
|
||||||
<!-- <version>1.4</version>--> |
|
||||||
<!-- <executions>--> |
|
||||||
<!-- <execution>--> |
|
||||||
<!-- <id>sign-artifacts</id>--> |
|
||||||
<!-- <phase>verify</phase>--> |
|
||||||
<!-- <goals>--> |
|
||||||
<!-- <goal>sign</goal>--> |
|
||||||
<!-- </goals>--> |
|
||||||
<!-- </execution>--> |
|
||||||
<!-- </executions>--> |
|
||||||
<!-- </plugin>--> |
|
||||||
<plugin> |
|
||||||
<artifactId>maven-jar-plugin</artifactId> |
|
||||||
<version>2.3.1</version> |
|
||||||
<configuration> |
|
||||||
<classesDirectory>target/classes</classesDirectory> |
|
||||||
</configuration> |
|
||||||
</plugin> |
|
||||||
</plugins> |
|
||||||
</build> |
|
||||||
</profile> |
|
||||||
</profiles> |
|
||||||
</project> |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
package com.mh.algorithm.bpnn; |
|
||||||
|
|
||||||
public interface ActivationFunction { |
|
||||||
//计算值
|
|
||||||
double computeValue(double val); |
|
||||||
//计算导数
|
|
||||||
double computeDerivative(double val); |
|
||||||
} |
|
||||||
@ -1,111 +0,0 @@ |
|||||||
package com.mh.algorithm.bpnn; |
|
||||||
|
|
||||||
import com.mh.algorithm.matrix.Matrix; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
|
|
||||||
public class BPModel implements Serializable { |
|
||||||
//BP神经网络权值与阈值
|
|
||||||
private Matrix weightIJ; |
|
||||||
private Matrix b1; |
|
||||||
private Matrix weightJP; |
|
||||||
private Matrix b2; |
|
||||||
/*用于反归一化*/ |
|
||||||
private Matrix inputMax; |
|
||||||
private Matrix inputMin; |
|
||||||
private Matrix outputMax; |
|
||||||
private Matrix outputMin; |
|
||||||
/*BP神经网络训练参数*/ |
|
||||||
private BPParameter bpParameter; |
|
||||||
/*BP神经网络训练情况*/ |
|
||||||
private double error; |
|
||||||
private int times; |
|
||||||
|
|
||||||
public Matrix getWeightIJ() { |
|
||||||
return weightIJ; |
|
||||||
} |
|
||||||
|
|
||||||
public void setWeightIJ(Matrix weightIJ) { |
|
||||||
this.weightIJ = weightIJ; |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix getB1() { |
|
||||||
return b1; |
|
||||||
} |
|
||||||
|
|
||||||
public void setB1(Matrix b1) { |
|
||||||
this.b1 = b1; |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix getWeightJP() { |
|
||||||
return weightJP; |
|
||||||
} |
|
||||||
|
|
||||||
public void setWeightJP(Matrix weightJP) { |
|
||||||
this.weightJP = weightJP; |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix getB2() { |
|
||||||
return b2; |
|
||||||
} |
|
||||||
|
|
||||||
public void setB2(Matrix b2) { |
|
||||||
this.b2 = b2; |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix getInputMax() { |
|
||||||
return inputMax; |
|
||||||
} |
|
||||||
|
|
||||||
public void setInputMax(Matrix inputMax) { |
|
||||||
this.inputMax = inputMax; |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix getInputMin() { |
|
||||||
return inputMin; |
|
||||||
} |
|
||||||
|
|
||||||
public void setInputMin(Matrix inputMin) { |
|
||||||
this.inputMin = inputMin; |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix getOutputMax() { |
|
||||||
return outputMax; |
|
||||||
} |
|
||||||
|
|
||||||
public void setOutputMax(Matrix outputMax) { |
|
||||||
this.outputMax = outputMax; |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix getOutputMin() { |
|
||||||
return outputMin; |
|
||||||
} |
|
||||||
|
|
||||||
public void setOutputMin(Matrix outputMin) { |
|
||||||
this.outputMin = outputMin; |
|
||||||
} |
|
||||||
|
|
||||||
public BPParameter getBpParameter() { |
|
||||||
return bpParameter; |
|
||||||
} |
|
||||||
|
|
||||||
public void setBpParameter(BPParameter bpParameter) { |
|
||||||
this.bpParameter = bpParameter; |
|
||||||
} |
|
||||||
|
|
||||||
public double getError() { |
|
||||||
return error; |
|
||||||
} |
|
||||||
|
|
||||||
public void setError(double error) { |
|
||||||
this.error = error; |
|
||||||
} |
|
||||||
|
|
||||||
public int getTimes() { |
|
||||||
return times; |
|
||||||
} |
|
||||||
|
|
||||||
public void setTimes(int times) { |
|
||||||
this.times = times; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,262 +0,0 @@ |
|||||||
package com.mh.algorithm.bpnn; |
|
||||||
|
|
||||||
import com.mh.algorithm.matrix.Matrix; |
|
||||||
import com.mh.algorithm.utils.MatrixUtil; |
|
||||||
|
|
||||||
import java.util.*; |
|
||||||
|
|
||||||
public class BPNeuralNetworkFactory { |
|
||||||
/** |
|
||||||
* 训练BP神经网络模型 |
|
||||||
* @param bpParameter |
|
||||||
* @param inputAndOutput |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public BPModel trainBP(BPParameter bpParameter, Matrix inputAndOutput) throws Exception { |
|
||||||
|
|
||||||
ActivationFunction activationFunction = bpParameter.getActivationFunction(); |
|
||||||
int inputCount = bpParameter.getInputLayerNeuronCount(); |
|
||||||
int hiddenCount = bpParameter.getHiddenLayerNeuronCount(); |
|
||||||
int outputCount = bpParameter.getOutputLayerNeuronCount(); |
|
||||||
double normalizationMin = bpParameter.getNormalizationMin(); |
|
||||||
double normalizationMax = bpParameter.getNormalizationMax(); |
|
||||||
double step = bpParameter.getStep(); |
|
||||||
double momentumFactor = bpParameter.getMomentumFactor(); |
|
||||||
double precision = bpParameter.getPrecision(); |
|
||||||
int maxTimes = bpParameter.getMaxTimes(); |
|
||||||
|
|
||||||
if(inputAndOutput.getMatrixColCount() != inputCount + outputCount){ |
|
||||||
throw new Exception("神经元个数不符,请修改"); |
|
||||||
} |
|
||||||
// 初始化权值
|
|
||||||
Matrix weightIJ = initWeight(inputCount, hiddenCount); |
|
||||||
Matrix weightJP = initWeight(hiddenCount, outputCount); |
|
||||||
|
|
||||||
// 初始化阈值
|
|
||||||
Matrix b1 = initThreshold(hiddenCount); |
|
||||||
Matrix b2 = initThreshold(outputCount); |
|
||||||
|
|
||||||
// 动量项
|
|
||||||
Matrix deltaWeightIJ0 = new Matrix(inputCount, hiddenCount); |
|
||||||
Matrix deltaWeightJP0 = new Matrix(hiddenCount, outputCount); |
|
||||||
Matrix deltaB10 = new Matrix(1, hiddenCount); |
|
||||||
Matrix deltaB20 = new Matrix(1, outputCount); |
|
||||||
|
|
||||||
// 截取输入矩阵和输出矩阵
|
|
||||||
Matrix input = inputAndOutput.subMatrix(0,inputAndOutput.getMatrixRowCount(),0,inputCount); |
|
||||||
Matrix output = inputAndOutput.subMatrix(0,inputAndOutput.getMatrixRowCount(),inputCount,outputCount); |
|
||||||
|
|
||||||
// 归一化
|
|
||||||
Map<String,Object> inputAfterNormalize = MatrixUtil.normalize(input, normalizationMin, normalizationMax); |
|
||||||
input = (Matrix) inputAfterNormalize.get("res"); |
|
||||||
|
|
||||||
Map<String,Object> outputAfterNormalize = MatrixUtil.normalize(output, normalizationMin, normalizationMax); |
|
||||||
output = (Matrix) outputAfterNormalize.get("res"); |
|
||||||
|
|
||||||
int times = 1; |
|
||||||
double E = 0;//误差
|
|
||||||
while (times < maxTimes) { |
|
||||||
/*-----------------正向传播---------------------*/ |
|
||||||
// 隐含层输入
|
|
||||||
Matrix jIn = input.multiple(weightIJ); |
|
||||||
// 扩充阈值
|
|
||||||
Matrix b1Copy = b1.extend(2,jIn.getMatrixRowCount()); |
|
||||||
// 加上阈值
|
|
||||||
jIn = jIn.plus(b1Copy); |
|
||||||
// 隐含层输出
|
|
||||||
Matrix jOut = computeValue(jIn,activationFunction); |
|
||||||
// 输出层输入
|
|
||||||
Matrix pIn = jOut.multiple(weightJP); |
|
||||||
// 扩充阈值
|
|
||||||
Matrix b2Copy = b2.extend(2, pIn.getMatrixRowCount()); |
|
||||||
// 加上阈值
|
|
||||||
pIn = pIn.plus(b2Copy); |
|
||||||
// 输出层输出
|
|
||||||
Matrix pOut = computeValue(pIn,activationFunction); |
|
||||||
// 计算误差
|
|
||||||
Matrix e = output.subtract(pOut); |
|
||||||
E = computeE(e);//误差
|
|
||||||
// 判断是否符合精度
|
|
||||||
if (Math.abs(E) <= precision) { |
|
||||||
System.out.println("满足精度"); |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
/*-----------------反向传播---------------------*/ |
|
||||||
// J与P之间权值修正量
|
|
||||||
Matrix deltaWeightJP = e.multiple(step); |
|
||||||
deltaWeightJP = deltaWeightJP.pointMultiple(computeDerivative(pIn,activationFunction)); |
|
||||||
deltaWeightJP = deltaWeightJP.transpose().multiple(jOut); |
|
||||||
deltaWeightJP = deltaWeightJP.transpose(); |
|
||||||
// P层神经元阈值修正量
|
|
||||||
Matrix deltaThresholdP = e.multiple(step); |
|
||||||
deltaThresholdP = deltaThresholdP.transpose().multiple(computeDerivative(pIn, activationFunction)); |
|
||||||
|
|
||||||
// I与J之间的权值修正量
|
|
||||||
Matrix deltaO = e.pointMultiple(computeDerivative(pIn,activationFunction)); |
|
||||||
Matrix tmp = weightJP.multiple(deltaO.transpose()).transpose(); |
|
||||||
Matrix deltaWeightIJ = tmp.pointMultiple(computeDerivative(jIn, activationFunction)); |
|
||||||
deltaWeightIJ = input.transpose().multiple(deltaWeightIJ); |
|
||||||
deltaWeightIJ = deltaWeightIJ.multiple(step); |
|
||||||
|
|
||||||
// J层神经元阈值修正量
|
|
||||||
Matrix deltaThresholdJ = tmp.transpose().multiple(computeDerivative(jIn, activationFunction)); |
|
||||||
deltaThresholdJ = deltaThresholdJ.multiple(-step); |
|
||||||
|
|
||||||
if (times == 1) { |
|
||||||
// 更新权值与阈值
|
|
||||||
weightIJ = weightIJ.plus(deltaWeightIJ); |
|
||||||
weightJP = weightJP.plus(deltaWeightJP); |
|
||||||
b1 = b1.plus(deltaThresholdJ); |
|
||||||
b2 = b2.plus(deltaThresholdP); |
|
||||||
}else{ |
|
||||||
// 加动量项
|
|
||||||
weightIJ = weightIJ.plus(deltaWeightIJ).plus(deltaWeightIJ0.multiple(momentumFactor)); |
|
||||||
weightJP = weightJP.plus(deltaWeightJP).plus(deltaWeightJP0.multiple(momentumFactor)); |
|
||||||
b1 = b1.plus(deltaThresholdJ).plus(deltaB10.multiple(momentumFactor)); |
|
||||||
b2 = b2.plus(deltaThresholdP).plus(deltaB20.multiple(momentumFactor)); |
|
||||||
} |
|
||||||
|
|
||||||
deltaWeightIJ0 = deltaWeightIJ; |
|
||||||
deltaWeightJP0 = deltaWeightJP; |
|
||||||
deltaB10 = deltaThresholdJ; |
|
||||||
deltaB20 = deltaThresholdP; |
|
||||||
|
|
||||||
times++; |
|
||||||
} |
|
||||||
|
|
||||||
// BP神经网络的输出
|
|
||||||
BPModel result = new BPModel(); |
|
||||||
result.setInputMax((Matrix) inputAfterNormalize.get("max")); |
|
||||||
result.setInputMin((Matrix) inputAfterNormalize.get("min")); |
|
||||||
result.setOutputMax((Matrix) outputAfterNormalize.get("max")); |
|
||||||
result.setOutputMin((Matrix) outputAfterNormalize.get("min")); |
|
||||||
result.setWeightIJ(weightIJ); |
|
||||||
result.setWeightJP(weightJP); |
|
||||||
result.setB1(b1); |
|
||||||
result.setB2(b2); |
|
||||||
result.setError(E); |
|
||||||
result.setTimes(times); |
|
||||||
result.setBpParameter(bpParameter); |
|
||||||
System.out.println("循环次数:" + times + ",误差:" + E); |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 计算BP神经网络的值 |
|
||||||
* @param bpModel |
|
||||||
* @param input |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix computeBP(BPModel bpModel,Matrix input) throws Exception { |
|
||||||
if (input.getMatrixColCount() != bpModel.getBpParameter().getInputLayerNeuronCount()) { |
|
||||||
throw new Exception("输入矩阵纬度有误"); |
|
||||||
} |
|
||||||
ActivationFunction activationFunction = bpModel.getBpParameter().getActivationFunction(); |
|
||||||
Matrix weightIJ = bpModel.getWeightIJ(); |
|
||||||
Matrix weightJP = bpModel.getWeightJP(); |
|
||||||
Matrix b1 = bpModel.getB1(); |
|
||||||
Matrix b2 = bpModel.getB2(); |
|
||||||
double[][] normalizedInput = new double[input.getMatrixRowCount()][input.getMatrixColCount()]; |
|
||||||
for (int i = 0; i < input.getMatrixRowCount(); i++) { |
|
||||||
for (int j = 0; j < input.getMatrixColCount(); j++) { |
|
||||||
if ((input.getValOfIdx(i,j) - bpModel.getInputMin().getValOfIdx(0,j)) == 0 |
|
||||||
|| (bpModel.getInputMax().getValOfIdx(0,j) - bpModel.getInputMin().getValOfIdx(0,j)) == 0) { |
|
||||||
normalizedInput[i][j] = bpModel.getBpParameter().getNormalizationMin(); |
|
||||||
continue; |
|
||||||
} |
|
||||||
normalizedInput[i][j] = bpModel.getBpParameter().getNormalizationMin() |
|
||||||
+ (input.getValOfIdx(i,j) - bpModel.getInputMin().getValOfIdx(0,j)) |
|
||||||
/ (bpModel.getInputMax().getValOfIdx(0,j) - bpModel.getInputMin().getValOfIdx(0,j)) |
|
||||||
* (bpModel.getBpParameter().getNormalizationMax() - bpModel.getBpParameter().getNormalizationMin()); |
|
||||||
} |
|
||||||
} |
|
||||||
Matrix normalizedInputMatrix = new Matrix(normalizedInput); |
|
||||||
Matrix jIn = normalizedInputMatrix.multiple(weightIJ); |
|
||||||
// 扩充阈值
|
|
||||||
Matrix b1Copy = b1.extend(2,jIn.getMatrixRowCount()); |
|
||||||
// 加上阈值
|
|
||||||
jIn = jIn.plus(b1Copy); |
|
||||||
// 隐含层输出
|
|
||||||
Matrix jOut = computeValue(jIn,activationFunction); |
|
||||||
// 输出层输入
|
|
||||||
Matrix pIn = jOut.multiple(weightJP); |
|
||||||
// 扩充阈值
|
|
||||||
Matrix b2Copy = b2.extend(2,pIn.getMatrixRowCount()); |
|
||||||
// 加上阈值
|
|
||||||
pIn = pIn.plus(b2Copy); |
|
||||||
// 输出层输出
|
|
||||||
Matrix pOut = computeValue(pIn,activationFunction); |
|
||||||
// 反归一化
|
|
||||||
return MatrixUtil.inverseNormalize(pOut, bpModel.getBpParameter().getNormalizationMax(), bpModel.getBpParameter().getNormalizationMin(), bpModel.getOutputMax(), bpModel.getOutputMin()); |
|
||||||
} |
|
||||||
|
|
||||||
// 初始化权值
|
|
||||||
private Matrix initWeight(int x,int y){ |
|
||||||
Random random=new Random(); |
|
||||||
double[][] weight = new double[x][y]; |
|
||||||
for (int i = 0; i < x; i++) { |
|
||||||
for (int j = 0; j < y; j++) { |
|
||||||
weight[i][j] = 2*random.nextDouble()-1; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(weight); |
|
||||||
} |
|
||||||
// 初始化阈值
|
|
||||||
private Matrix initThreshold(int x){ |
|
||||||
Random random = new Random(); |
|
||||||
double[][] result = new double[1][x]; |
|
||||||
for (int i = 0; i < x; i++) { |
|
||||||
result[0][i] = 2*random.nextDouble()-1; |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 计算激活函数的值 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
private Matrix computeValue(Matrix a, ActivationFunction activationFunction) throws Exception { |
|
||||||
if (a.getMatrix() == null) { |
|
||||||
throw new Exception("参数值为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[a.getMatrixRowCount()][a.getMatrixColCount()]; |
|
||||||
for (int i = 0; i < a.getMatrixRowCount(); i++) { |
|
||||||
for (int j = 0; j < a.getMatrixColCount(); j++) { |
|
||||||
result[i][j] = activationFunction.computeValue(a.getValOfIdx(i,j)); |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 激活函数导数的值 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
private Matrix computeDerivative(Matrix a , ActivationFunction activationFunction) throws Exception { |
|
||||||
if (a.getMatrix() == null) { |
|
||||||
throw new Exception("参数值为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[a.getMatrixRowCount()][a.getMatrixColCount()]; |
|
||||||
for (int i = 0; i < a.getMatrixRowCount(); i++) { |
|
||||||
for (int j = 0; j < a.getMatrixColCount(); j++) { |
|
||||||
result[i][j] = activationFunction.computeDerivative(a.getValOfIdx(i,j)); |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 计算误差 |
|
||||||
* @param e |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
private double computeE(Matrix e){ |
|
||||||
e = e.square(); |
|
||||||
return 0.5*e.sumAll(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,106 +0,0 @@ |
|||||||
package com.mh.algorithm.bpnn; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
|
|
||||||
public class BPParameter implements Serializable { |
|
||||||
|
|
||||||
//输入层神经元个数
|
|
||||||
private int inputLayerNeuronCount = 3; |
|
||||||
//隐含层神经元个数
|
|
||||||
private int hiddenLayerNeuronCount = 3; |
|
||||||
//输出层神经元个数
|
|
||||||
private int outputLayerNeuronCount = 1; |
|
||||||
//归一化区间
|
|
||||||
private double normalizationMin = 0.2; |
|
||||||
private double normalizationMax = 0.8; |
|
||||||
//学习步长
|
|
||||||
private double step = 0.05; |
|
||||||
//动量因子
|
|
||||||
private double momentumFactor = 0.2; |
|
||||||
//激活函数
|
|
||||||
private ActivationFunction activationFunction = new Sigmoid(); |
|
||||||
//精度
|
|
||||||
private double precision = 0.000001; |
|
||||||
//最大循环次数
|
|
||||||
private int maxTimes = 1000000; |
|
||||||
|
|
||||||
public double getMomentumFactor() { |
|
||||||
return momentumFactor; |
|
||||||
} |
|
||||||
|
|
||||||
public void setMomentumFactor(double momentumFactor) { |
|
||||||
this.momentumFactor = momentumFactor; |
|
||||||
} |
|
||||||
|
|
||||||
public double getStep() { |
|
||||||
return step; |
|
||||||
} |
|
||||||
|
|
||||||
public void setStep(double step) { |
|
||||||
this.step = step; |
|
||||||
} |
|
||||||
|
|
||||||
public double getNormalizationMin() { |
|
||||||
return normalizationMin; |
|
||||||
} |
|
||||||
|
|
||||||
public void setNormalizationMin(double normalizationMin) { |
|
||||||
this.normalizationMin = normalizationMin; |
|
||||||
} |
|
||||||
|
|
||||||
public double getNormalizationMax() { |
|
||||||
return normalizationMax; |
|
||||||
} |
|
||||||
|
|
||||||
public void setNormalizationMax(double normalizationMax) { |
|
||||||
this.normalizationMax = normalizationMax; |
|
||||||
} |
|
||||||
|
|
||||||
public int getInputLayerNeuronCount() { |
|
||||||
return inputLayerNeuronCount; |
|
||||||
} |
|
||||||
|
|
||||||
public void setInputLayerNeuronCount(int inputLayerNeuronCount) { |
|
||||||
this.inputLayerNeuronCount = inputLayerNeuronCount; |
|
||||||
} |
|
||||||
|
|
||||||
public int getHiddenLayerNeuronCount() { |
|
||||||
return hiddenLayerNeuronCount; |
|
||||||
} |
|
||||||
|
|
||||||
public void setHiddenLayerNeuronCount(int hiddenLayerNeuronCount) { |
|
||||||
this.hiddenLayerNeuronCount = hiddenLayerNeuronCount; |
|
||||||
} |
|
||||||
|
|
||||||
public int getOutputLayerNeuronCount() { |
|
||||||
return outputLayerNeuronCount; |
|
||||||
} |
|
||||||
|
|
||||||
public void setOutputLayerNeuronCount(int outputLayerNeuronCount) { |
|
||||||
this.outputLayerNeuronCount = outputLayerNeuronCount; |
|
||||||
} |
|
||||||
|
|
||||||
public ActivationFunction getActivationFunction() { |
|
||||||
return activationFunction; |
|
||||||
} |
|
||||||
|
|
||||||
public void setActivationFunction(ActivationFunction activationFunction) { |
|
||||||
this.activationFunction = activationFunction; |
|
||||||
} |
|
||||||
|
|
||||||
public double getPrecision() { |
|
||||||
return precision; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPrecision(double precision) { |
|
||||||
this.precision = precision; |
|
||||||
} |
|
||||||
|
|
||||||
public int getMaxTimes() { |
|
||||||
return maxTimes; |
|
||||||
} |
|
||||||
|
|
||||||
public void setMaxTimes(int maxTimes) { |
|
||||||
this.maxTimes = maxTimes; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,15 +0,0 @@ |
|||||||
package com.mh.algorithm.bpnn; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
|
|
||||||
public class Sigmoid implements ActivationFunction, Serializable { |
|
||||||
@Override |
|
||||||
public double computeValue(double val) { |
|
||||||
return 1 / (1 + Math.exp(-val)); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public double computeDerivative(double val) { |
|
||||||
return computeValue(val) * (1 - computeValue(val)); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,24 +0,0 @@ |
|||||||
package com.mh.algorithm.constants; |
|
||||||
|
|
||||||
/** |
|
||||||
* 排序枚举类 |
|
||||||
*/ |
|
||||||
public enum OrderEnum { |
|
||||||
|
|
||||||
ASC(1,"升序"), |
|
||||||
|
|
||||||
DESC(2,"降序"); |
|
||||||
|
|
||||||
OrderEnum(int flag, String name) { |
|
||||||
|
|
||||||
this.flag = flag; |
|
||||||
|
|
||||||
this.name = name; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
private int flag; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,88 +0,0 @@ |
|||||||
package com.mh.algorithm.knn; |
|
||||||
|
|
||||||
import com.mh.algorithm.constants.OrderEnum; |
|
||||||
import com.mh.algorithm.matrix.Matrix; |
|
||||||
import com.mh.algorithm.utils.MatrixUtil; |
|
||||||
|
|
||||||
import java.util.*; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* @program: top-algorithm-set |
|
||||||
* @description: KNN k-临近算法进行分类 |
|
||||||
* @author: Mr.Zhao |
|
||||||
* @create: 2020-10-13 22:03 |
|
||||||
**/ |
|
||||||
public class KNN { |
|
||||||
public static Matrix classify(Matrix input, Matrix dataSet, Matrix labels, int k) throws Exception { |
|
||||||
if (dataSet.getMatrixRowCount() != labels.getMatrixRowCount()) { |
|
||||||
throw new IllegalArgumentException("矩阵训练集与标签维度不一致"); |
|
||||||
} |
|
||||||
if (input.getMatrixColCount() != dataSet.getMatrixColCount()) { |
|
||||||
throw new IllegalArgumentException("待分类矩阵列数与训练集列数不一致"); |
|
||||||
} |
|
||||||
if (dataSet.getMatrixRowCount() < k) { |
|
||||||
throw new IllegalArgumentException("训练集样本数小于k"); |
|
||||||
} |
|
||||||
// 归一化
|
|
||||||
int trainCount = dataSet.getMatrixRowCount(); |
|
||||||
int testCount = input.getMatrixRowCount(); |
|
||||||
Matrix trainAndTest = dataSet.splice(2, input); |
|
||||||
Map<String, Object> normalize = MatrixUtil.normalize(trainAndTest, 0, 1); |
|
||||||
trainAndTest = (Matrix) normalize.get("res"); |
|
||||||
dataSet = trainAndTest.subMatrix(0, trainCount, 0, trainAndTest.getMatrixColCount()); |
|
||||||
input = trainAndTest.subMatrix(0, testCount, 0, trainAndTest.getMatrixColCount()); |
|
||||||
|
|
||||||
// 获取标签信息
|
|
||||||
List<Double> labelList = new ArrayList<>(); |
|
||||||
for (int i = 0; i < labels.getMatrixRowCount(); i++) { |
|
||||||
if (!labelList.contains(labels.getValOfIdx(i, 0))) { |
|
||||||
labelList.add(labels.getValOfIdx(i, 0)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Matrix result = new Matrix(new double[input.getMatrixRowCount()][1]); |
|
||||||
for (int i = 0; i < input.getMatrixRowCount(); i++) { |
|
||||||
// 计算向量间的欧式距离
|
|
||||||
// 将labels矩阵扩展
|
|
||||||
Matrix labelMatrixCopied = input.getRowOfIdx(i).extend(2, dataSet.getMatrixRowCount()); |
|
||||||
// 前面是计算欧氏距离,splice(1,labels)是将距离矩阵与labels矩阵合并
|
|
||||||
Matrix distanceMatrix = dataSet.subtract(labelMatrixCopied).square().sumRow().pow(0.5).splice(1, labels); |
|
||||||
// 将计算出的距离矩阵按照距离升序排序
|
|
||||||
distanceMatrix.sort(0, OrderEnum.ASC); |
|
||||||
// 遍历最近的k个变量
|
|
||||||
Map<Double, Integer> map = new HashMap<>(); |
|
||||||
for (int j = 0; j < k; j++) { |
|
||||||
// 遍历标签种类数
|
|
||||||
for (Double label : labelList) { |
|
||||||
if (distanceMatrix.getValOfIdx(j, 1) == label) { |
|
||||||
map.put(label, map.getOrDefault(label, 0) + 1); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
result.setValue(i, 0, getKeyOfMaxValue(map)); |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 取map中值最大的key |
|
||||||
* |
|
||||||
* @param map |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
private static Double getKeyOfMaxValue(Map<Double, Integer> map) { |
|
||||||
if (map == null) |
|
||||||
return null; |
|
||||||
Double keyOfMaxValue = 0.0; |
|
||||||
Integer maxValue = 0; |
|
||||||
for (Double key : map.keySet()) { |
|
||||||
if (map.get(key) > maxValue) { |
|
||||||
keyOfMaxValue = key; |
|
||||||
maxValue = map.get(key); |
|
||||||
} |
|
||||||
} |
|
||||||
return keyOfMaxValue; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,646 +0,0 @@ |
|||||||
package com.mh.algorithm.matrix; |
|
||||||
|
|
||||||
import com.mh.algorithm.constants.OrderEnum; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
|
|
||||||
public class Matrix implements Serializable { |
|
||||||
private double[][] matrix; |
|
||||||
//矩阵列数
|
|
||||||
private int matrixColCount; |
|
||||||
//矩阵行数
|
|
||||||
private int matrixRowCount; |
|
||||||
|
|
||||||
/** |
|
||||||
* 构造一个空矩阵 |
|
||||||
*/ |
|
||||||
public Matrix() { |
|
||||||
this.matrix = null; |
|
||||||
this.matrixColCount = 0; |
|
||||||
this.matrixRowCount = 0; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 构造一个matrix矩阵 |
|
||||||
* @param matrix |
|
||||||
*/ |
|
||||||
public Matrix(double[][] matrix) { |
|
||||||
this.matrix = matrix; |
|
||||||
this.matrixRowCount = matrix.length; |
|
||||||
this.matrixColCount = matrix[0].length; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 构造一个rowCount行colCount列值为0的矩阵 |
|
||||||
* @param rowCount |
|
||||||
* @param colCount |
|
||||||
*/ |
|
||||||
public Matrix(int rowCount,int colCount) { |
|
||||||
double[][] matrix = new double[rowCount][colCount]; |
|
||||||
for (int i = 0; i < rowCount; i++) { |
|
||||||
for (int j = 0; j < colCount; j++) { |
|
||||||
matrix[i][j] = 0; |
|
||||||
} |
|
||||||
} |
|
||||||
this.matrix = matrix; |
|
||||||
this.matrixRowCount = rowCount; |
|
||||||
this.matrixColCount = colCount; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 构造一个rowCount行colCount列值为val的矩阵 |
|
||||||
* @param val |
|
||||||
* @param rowCount |
|
||||||
* @param colCount |
|
||||||
*/ |
|
||||||
public Matrix(double val,int rowCount,int colCount) { |
|
||||||
double[][] matrix = new double[rowCount][colCount]; |
|
||||||
for (int i = 0; i < rowCount; i++) { |
|
||||||
for (int j = 0; j < colCount; j++) { |
|
||||||
matrix[i][j] = val; |
|
||||||
} |
|
||||||
} |
|
||||||
this.matrix = matrix; |
|
||||||
this.matrixRowCount = rowCount; |
|
||||||
this.matrixColCount = colCount; |
|
||||||
} |
|
||||||
|
|
||||||
public double[][] getMatrix() { |
|
||||||
return matrix; |
|
||||||
} |
|
||||||
|
|
||||||
public void setMatrix(double[][] matrix) { |
|
||||||
this.matrix = matrix; |
|
||||||
this.matrixRowCount = matrix.length; |
|
||||||
this.matrixColCount = matrix[0].length; |
|
||||||
} |
|
||||||
|
|
||||||
public int getMatrixColCount() { |
|
||||||
return matrixColCount; |
|
||||||
} |
|
||||||
|
|
||||||
public int getMatrixRowCount() { |
|
||||||
return matrixRowCount; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取矩阵指定位置的值 |
|
||||||
* |
|
||||||
* @param x |
|
||||||
* @param y |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public double getValOfIdx(int x, int y) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (x > matrixRowCount - 1) { |
|
||||||
throw new IllegalArgumentException("索引x越界"); |
|
||||||
} |
|
||||||
if (y > matrixColCount - 1) { |
|
||||||
throw new IllegalArgumentException("索引y越界"); |
|
||||||
} |
|
||||||
return matrix[x][y]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取矩阵指定行 |
|
||||||
* |
|
||||||
* @param x |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix getRowOfIdx(int x) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (x > matrixRowCount - 1) { |
|
||||||
throw new IllegalArgumentException("索引x越界"); |
|
||||||
} |
|
||||||
double[][] result = new double[1][matrixColCount]; |
|
||||||
result[0] = matrix[x]; |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取矩阵指定列 |
|
||||||
* |
|
||||||
* @param y |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix getColOfIdx(int y) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (y > matrixColCount - 1) { |
|
||||||
throw new IllegalArgumentException("索引y越界"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][1]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
result[i][0] = matrix[i][y]; |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 设置矩阵中x,y位置元素的值 |
|
||||||
* @param x |
|
||||||
* @param y |
|
||||||
* @param val |
|
||||||
*/ |
|
||||||
public void setValue(int x, int y, double val) { |
|
||||||
if (x > this.matrixRowCount - 1) { |
|
||||||
throw new IllegalArgumentException("行索引越界"); |
|
||||||
} |
|
||||||
if (y > this.matrixColCount - 1) { |
|
||||||
throw new IllegalArgumentException("列索引越界"); |
|
||||||
} |
|
||||||
this.matrix[x][y] = val; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵乘矩阵 |
|
||||||
* |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix multiple(Matrix a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (a.getMatrix() == null || a.getMatrixRowCount() == 0 || a.getMatrixColCount() == 0) { |
|
||||||
throw new IllegalArgumentException("参数矩阵为空"); |
|
||||||
} |
|
||||||
if (matrixColCount != a.getMatrixRowCount()) { |
|
||||||
throw new IllegalArgumentException("矩阵纬度不同,不可计算"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][a.getMatrixColCount()]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < a.getMatrixColCount(); j++) { |
|
||||||
for (int k = 0; k < matrixColCount; k++) { |
|
||||||
result[i][j] = result[i][j] + matrix[i][k] * a.getMatrix()[k][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵乘一个数字 |
|
||||||
* |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix multiple(double a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] * a; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵点乘 |
|
||||||
* |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix pointMultiple(Matrix a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (a.getMatrix() == null || a.getMatrixRowCount() == 0 || a.getMatrixColCount() == 0) { |
|
||||||
throw new IllegalArgumentException("参数矩阵为空"); |
|
||||||
} |
|
||||||
if (matrixRowCount != a.getMatrixRowCount() && matrixColCount != a.getMatrixColCount()) { |
|
||||||
throw new IllegalArgumentException("矩阵纬度不同,不可计算"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] * a.getMatrix()[i][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵除一个数字 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix divide(double a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] / a; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵加法 |
|
||||||
* |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix plus(Matrix a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (a.getMatrix() == null || a.getMatrixRowCount() == 0 || a.getMatrixColCount() == 0) { |
|
||||||
throw new IllegalArgumentException("参数矩阵为空"); |
|
||||||
} |
|
||||||
if (matrixRowCount != a.getMatrixRowCount() && matrixColCount != a.getMatrixColCount()) { |
|
||||||
throw new IllegalArgumentException("矩阵纬度不同,不可计算"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] + a.getMatrix()[i][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵加一个数字 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix plus(double a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] + a; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵减法 |
|
||||||
* |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix subtract(Matrix a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (a.getMatrix() == null || a.getMatrixRowCount() == 0 || a.getMatrixColCount() == 0) { |
|
||||||
throw new IllegalArgumentException("参数矩阵为空"); |
|
||||||
} |
|
||||||
if (matrixRowCount != a.getMatrixRowCount() && matrixColCount != a.getMatrixColCount()) { |
|
||||||
throw new IllegalArgumentException("矩阵纬度不同,不可计算"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] - a.getMatrix()[i][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵减一个数字 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix subtract(double a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] - a; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵行求和 |
|
||||||
* |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix sumRow() throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][1]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][0] += matrix[i][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵列求和 |
|
||||||
* |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix sumCol() throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[1][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[0][j] += matrix[i][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵所有元素求和 |
|
||||||
* |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public double sumAll() throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double result = 0; |
|
||||||
for (double[] doubles : matrix) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result += doubles[j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵所有元素求平方 |
|
||||||
* |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix square() throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = matrix[i][j] * matrix[i][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵所有元素求N次方 |
|
||||||
* |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix pow(double n) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[i][j] = Math.pow(matrix[i][j],n); |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵转置 |
|
||||||
* |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public Matrix transpose() throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixColCount][matrixRowCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
result[j][i] = matrix[i][j]; |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 截取矩阵 |
|
||||||
* @param startRowIndex 开始行索引 |
|
||||||
* @param rowCount 截取行数 |
|
||||||
* @param startColIndex 开始列索引 |
|
||||||
* @param colCount 截取列数 |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix subMatrix(int startRowIndex,int rowCount,int startColIndex,int colCount) throws IllegalArgumentException { |
|
||||||
if (startRowIndex + rowCount > matrixRowCount) { |
|
||||||
throw new IllegalArgumentException("行索引越界"); |
|
||||||
} |
|
||||||
if (startColIndex + colCount> matrixColCount) { |
|
||||||
throw new IllegalArgumentException("列索引越界"); |
|
||||||
} |
|
||||||
double[][] result = new double[rowCount][colCount]; |
|
||||||
for (int i = startRowIndex; i < startRowIndex + rowCount; i++) { |
|
||||||
if (startColIndex + colCount - startColIndex >= 0) |
|
||||||
System.arraycopy(matrix[i], startColIndex, result[i - startRowIndex], 0, colCount); |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵合并 |
|
||||||
* @param direction 合并方向,1为横向,2为竖向 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix splice(int direction, Matrix a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if (a.getMatrix() == null || a.getMatrixRowCount() == 0 || a.getMatrixColCount() == 0) { |
|
||||||
throw new IllegalArgumentException("参数矩阵为空"); |
|
||||||
} |
|
||||||
if(direction == 1){ |
|
||||||
//横向拼接
|
|
||||||
if (matrixRowCount != a.getMatrixRowCount()) { |
|
||||||
throw new IllegalArgumentException("矩阵行数不一致,无法拼接"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount + a.getMatrixColCount()]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
System.arraycopy(matrix[i],0,result[i],0,matrixColCount); |
|
||||||
System.arraycopy(a.getMatrix()[i],0,result[i],matrixColCount,a.getMatrixColCount()); |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
}else if(direction == 2){ |
|
||||||
//纵向拼接
|
|
||||||
if (matrixColCount != a.getMatrixColCount()) { |
|
||||||
throw new IllegalArgumentException("矩阵列数不一致,无法拼接"); |
|
||||||
} |
|
||||||
double[][] result = new double[matrixRowCount + a.getMatrixRowCount()][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
result[i] = matrix[i]; |
|
||||||
} |
|
||||||
for (int i = 0; i < a.getMatrixRowCount(); i++) { |
|
||||||
result[matrixRowCount + i] = a.getMatrix()[i]; |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
}else{ |
|
||||||
throw new IllegalArgumentException("方向参数有误"); |
|
||||||
} |
|
||||||
} |
|
||||||
/** |
|
||||||
* 扩展矩阵 |
|
||||||
* @param direction 扩展方向,1为横向,2为竖向 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix extend(int direction , int a) throws IllegalArgumentException { |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if(direction == 1){ |
|
||||||
//横向复制
|
|
||||||
double[][] result = new double[matrixRowCount][matrixColCount*a]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < a; j++) { |
|
||||||
System.arraycopy(matrix[i],0,result[i],j*matrixColCount,matrixColCount); |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
}else if(direction == 2){ |
|
||||||
//纵向复制
|
|
||||||
double[][] result = new double[matrixRowCount*a][matrixColCount]; |
|
||||||
for (int i = 0; i < matrixRowCount*a; i++) { |
|
||||||
result[i] = matrix[i%matrixRowCount]; |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
}else{ |
|
||||||
throw new IllegalArgumentException("方向参数有误"); |
|
||||||
} |
|
||||||
} |
|
||||||
/** |
|
||||||
* 获取每列的平均值 |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public Matrix getColAvg() throws IllegalArgumentException { |
|
||||||
Matrix tmp = this.sumCol(); |
|
||||||
return tmp.divide(matrixRowCount); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵行排序 |
|
||||||
* @param index 根据第几列的数进行行排序 |
|
||||||
* @param order 排序顺序,升序或降序 |
|
||||||
* @return |
|
||||||
* @throws IllegalArgumentException |
|
||||||
*/ |
|
||||||
public void sort(int index, OrderEnum order) throws IllegalArgumentException{ |
|
||||||
if (matrix == null || matrixRowCount == 0 || matrixColCount == 0) { |
|
||||||
throw new IllegalArgumentException("矩阵为空"); |
|
||||||
} |
|
||||||
if(index >= matrixColCount){ |
|
||||||
throw new IllegalArgumentException("排序索引index越界"); |
|
||||||
} |
|
||||||
sort(index,order,0,this.matrixRowCount - 1); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 判断是否是方阵 |
|
||||||
* 行列数相等,并且不等于0 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public boolean isSquareMatrix(){ |
|
||||||
return matrixColCount == matrixRowCount && matrixColCount != 0; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
StringBuilder stringBuilder = new StringBuilder(); |
|
||||||
stringBuilder.append("\r\n"); |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
stringBuilder.append("# "); |
|
||||||
for (int j = 0; j < matrixColCount; j++) { |
|
||||||
stringBuilder.append(matrix[i][j]).append("\t "); |
|
||||||
} |
|
||||||
stringBuilder.append("#\r\n"); |
|
||||||
} |
|
||||||
stringBuilder.append("\r\n"); |
|
||||||
return stringBuilder.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
private void sort(int index,OrderEnum order,int start,int end){ |
|
||||||
if(start >= end){ |
|
||||||
return; |
|
||||||
} |
|
||||||
int tmp = partition(index,order,start,end); |
|
||||||
sort(index,order, start, tmp - 1); |
|
||||||
sort(index,order, tmp + 1, end); |
|
||||||
} |
|
||||||
|
|
||||||
private int partition(int index,OrderEnum order,int start,int end){ |
|
||||||
int l = start + 1,r = end; |
|
||||||
double v = matrix[start][index]; |
|
||||||
switch (order){ |
|
||||||
case ASC: |
|
||||||
while(true){ |
|
||||||
while(matrix[r][index] >= v && r > start){ |
|
||||||
r--; |
|
||||||
} |
|
||||||
while(matrix[l][index] <= v && l < end){ |
|
||||||
l++; |
|
||||||
} |
|
||||||
if(l >= r){ |
|
||||||
break; |
|
||||||
} |
|
||||||
double[] tmp = matrix[r]; |
|
||||||
matrix[r] = matrix[l]; |
|
||||||
matrix[l] = tmp; |
|
||||||
} |
|
||||||
break; |
|
||||||
case DESC: |
|
||||||
while(true){ |
|
||||||
while(matrix[r][index] <= v && r > start){ |
|
||||||
r--; |
|
||||||
} |
|
||||||
while(matrix[l][index] >= v && l < end){ |
|
||||||
l++; |
|
||||||
} |
|
||||||
if(l >= r){ |
|
||||||
break; |
|
||||||
} |
|
||||||
double[] tmp = matrix[r]; |
|
||||||
matrix[r] = matrix[l]; |
|
||||||
matrix[l] = tmp; |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
double[] tmp = matrix[r]; |
|
||||||
matrix[r] = matrix[start]; |
|
||||||
matrix[start] = tmp; |
|
||||||
return r; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,53 +0,0 @@ |
|||||||
package com.mh.algorithm.utils; |
|
||||||
|
|
||||||
import com.mh.algorithm.matrix.Matrix; |
|
||||||
|
|
||||||
import java.util.ArrayList; |
|
||||||
|
|
||||||
public class CsvInfo { |
|
||||||
private String[] header; |
|
||||||
private int csvRowCount; |
|
||||||
private int csvColCount; |
|
||||||
private ArrayList<String[]> csvFileList; |
|
||||||
|
|
||||||
public String[] getHeader() { |
|
||||||
return header; |
|
||||||
} |
|
||||||
|
|
||||||
public void setHeader(String[] header) { |
|
||||||
this.header = header; |
|
||||||
} |
|
||||||
|
|
||||||
public int getCsvRowCount() { |
|
||||||
return csvRowCount; |
|
||||||
} |
|
||||||
|
|
||||||
public int getCsvColCount() { |
|
||||||
return csvColCount; |
|
||||||
} |
|
||||||
|
|
||||||
public ArrayList<String[]> getCsvFileList() { |
|
||||||
return csvFileList; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCsvFileList(ArrayList<String[]> csvFileList) { |
|
||||||
this.csvFileList = csvFileList; |
|
||||||
this.csvColCount = csvFileList.get(0) != null?csvFileList.get(0).length:0; |
|
||||||
this.csvRowCount = csvFileList.size(); |
|
||||||
} |
|
||||||
|
|
||||||
public Matrix toMatrix() throws Exception { |
|
||||||
double[][] arr = new double[csvFileList.size()][csvFileList.get(0).length]; |
|
||||||
for (int i = 0; i < csvFileList.size(); i++) { |
|
||||||
for (int j = 0; j < csvFileList.get(0).length; j++) { |
|
||||||
try { |
|
||||||
arr[i][j] = Double.parseDouble(csvFileList.get(i)[j]); |
|
||||||
}catch (NumberFormatException e){ |
|
||||||
throw new Exception("Csv中含有非数字字符,无法转换成Matrix对象"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(arr); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,66 +0,0 @@ |
|||||||
package com.mh.algorithm.utils; |
|
||||||
|
|
||||||
import com.csvreader.CsvReader; |
|
||||||
import com.csvreader.CsvWriter; |
|
||||||
import com.mh.algorithm.matrix.Matrix; |
|
||||||
|
|
||||||
import java.io.IOException; |
|
||||||
import java.nio.charset.StandardCharsets; |
|
||||||
import java.util.ArrayList; |
|
||||||
|
|
||||||
public class CsvUtil { |
|
||||||
/** |
|
||||||
* 获取CSV中的信息 |
|
||||||
* @param hasHeader 是否含有表头 |
|
||||||
* @param path CSV文件的路径 |
|
||||||
* @return |
|
||||||
* @throws IOException |
|
||||||
*/ |
|
||||||
public static CsvInfo getCsvInfo(boolean hasHeader , String path) throws IOException { |
|
||||||
//创建csv对象,存储csv中的信息
|
|
||||||
CsvInfo csvInfo = new CsvInfo(); |
|
||||||
//获取CsvReader流
|
|
||||||
CsvReader csvReader = new CsvReader(path, ',', StandardCharsets.UTF_8); |
|
||||||
if(hasHeader){ |
|
||||||
csvReader.readHeaders(); |
|
||||||
} |
|
||||||
//获取Csv中的所有记录
|
|
||||||
ArrayList<String[]> csvFileList = new ArrayList<String[]>(); |
|
||||||
while (csvReader.readRecord()) { |
|
||||||
csvFileList.add(csvReader.getValues()); |
|
||||||
} |
|
||||||
//赋值
|
|
||||||
csvInfo.setHeader(csvReader.getHeaders()); |
|
||||||
csvInfo.setCsvFileList(csvFileList); |
|
||||||
//关闭流
|
|
||||||
csvReader.close(); |
|
||||||
return csvInfo; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 将矩阵写入到csv文件中 |
|
||||||
* @param header 表头 |
|
||||||
* @param data 以矩阵形式存放的数据 |
|
||||||
* @param path 写入的文件地址 |
|
||||||
* @throws Exception |
|
||||||
*/ |
|
||||||
public static void createCsvFile(String[] header,Matrix data,String path) throws Exception { |
|
||||||
|
|
||||||
if (header!=null && header.length != data.getMatrixColCount()) { |
|
||||||
throw new Exception("表头列数与数据列数不符"); |
|
||||||
} |
|
||||||
CsvWriter csvWriter = new CsvWriter(path, ',', StandardCharsets.UTF_8); |
|
||||||
|
|
||||||
if (header != null) { |
|
||||||
csvWriter.writeRecord(header); |
|
||||||
} |
|
||||||
for (int i = 0; i < data.getMatrixRowCount(); i++) { |
|
||||||
String[] record = new String[data.getMatrixColCount()]; |
|
||||||
for (int j = 0; j < data.getMatrixColCount(); j++) { |
|
||||||
record[j] = data.getValOfIdx(i, j)+""; |
|
||||||
} |
|
||||||
csvWriter.writeRecord(record); |
|
||||||
} |
|
||||||
csvWriter.close(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,20 +0,0 @@ |
|||||||
package com.mh.algorithm.utils; |
|
||||||
|
|
||||||
/** |
|
||||||
* @program: top-algorithm-set |
|
||||||
* @description: DoubleTool |
|
||||||
* @author: Mr.Zhao |
|
||||||
* @create: 2020-11-12 21:54 |
|
||||||
**/ |
|
||||||
public class DoubleUtil { |
|
||||||
|
|
||||||
private static final Double MAX_ERROR = 0.0001; |
|
||||||
|
|
||||||
public static boolean equals(Double a, Double b) { |
|
||||||
return Math.abs(a - b)< MAX_ERROR; |
|
||||||
} |
|
||||||
|
|
||||||
public static boolean equals(Double a, Double b,Double maxError) { |
|
||||||
return Math.abs(a - b)< maxError; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,297 +0,0 @@ |
|||||||
package com.mh.algorithm.utils; |
|
||||||
|
|
||||||
import Jama.EigenvalueDecomposition; |
|
||||||
import com.mh.algorithm.matrix.Matrix; |
|
||||||
|
|
||||||
import java.util.*; |
|
||||||
|
|
||||||
public class MatrixUtil { |
|
||||||
/** |
|
||||||
* 创建一个单位矩阵 |
|
||||||
* @param matrixRowCount 单位矩阵的纬度 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public static Matrix eye(int matrixRowCount){ |
|
||||||
double[][] result = new double[matrixRowCount][matrixRowCount]; |
|
||||||
for (int i = 0; i < matrixRowCount; i++) { |
|
||||||
for (int j = 0; j < matrixRowCount; j++) { |
|
||||||
if(i == j){ |
|
||||||
result[i][j] = 1; |
|
||||||
}else{ |
|
||||||
result[i][j] = 0; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 求矩阵的逆 |
|
||||||
* 原理:AE=EA^-1 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws Exception |
|
||||||
*/ |
|
||||||
public static Matrix inv(Matrix a) throws Exception { |
|
||||||
if (!invable(a)) { |
|
||||||
throw new Exception("矩阵不可逆"); |
|
||||||
} |
|
||||||
// [a|E]
|
|
||||||
Matrix b = a.splice(1, eye(a.getMatrixRowCount())); |
|
||||||
double[][] data = b.getMatrix(); |
|
||||||
int rowCount = b.getMatrixRowCount(); |
|
||||||
int colCount = b.getMatrixColCount(); |
|
||||||
//此处应用a的列数,为简化,直接用b的行数
|
|
||||||
for (int j = 0; j < rowCount; j++) { |
|
||||||
//若遇到0则交换两行
|
|
||||||
int notZeroRow = -2; |
|
||||||
if(data[j][j] == 0){ |
|
||||||
notZeroRow = -1; |
|
||||||
for (int l = j; l < rowCount; l++) { |
|
||||||
if (data[l][j] != 0) { |
|
||||||
notZeroRow = l; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if (notZeroRow == -1) { |
|
||||||
throw new Exception("矩阵不可逆"); |
|
||||||
}else if(notZeroRow != -2){ |
|
||||||
//交换j与notZeroRow两行
|
|
||||||
double[] tmp = data[j]; |
|
||||||
data[j] = data[notZeroRow]; |
|
||||||
data[notZeroRow] = tmp; |
|
||||||
} |
|
||||||
//将第data[j][j]化为1
|
|
||||||
if (data[j][j] != 1) { |
|
||||||
double multiple = data[j][j]; |
|
||||||
for (int colIdx = j; colIdx < colCount; colIdx++) { |
|
||||||
data[j][colIdx] /= multiple; |
|
||||||
} |
|
||||||
} |
|
||||||
//行与行相减
|
|
||||||
for (int i = 0; i < rowCount; i++) { |
|
||||||
if (i != j) { |
|
||||||
double multiple = data[i][j] / data[j][j]; |
|
||||||
//遍历行中的列
|
|
||||||
for (int k = j; k < colCount; k++) { |
|
||||||
data[i][k] = data[i][k] - multiple * data[j][k]; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
Matrix result = new Matrix(data); |
|
||||||
return result.subMatrix(0, rowCount, rowCount, rowCount); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 求矩阵的伴随矩阵 |
|
||||||
* 原理:A*=|A|A^-1 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws Exception |
|
||||||
*/ |
|
||||||
public static Matrix adj(Matrix a) throws Exception { |
|
||||||
return inv(a).multiple(det(a)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 矩阵转成上三角矩阵 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws Exception |
|
||||||
*/ |
|
||||||
public static Matrix getTopTriangle(Matrix a) throws Exception { |
|
||||||
if (!a.isSquareMatrix()) { |
|
||||||
throw new Exception("不是方阵无法进行计算"); |
|
||||||
} |
|
||||||
int matrixHeight = a.getMatrixRowCount(); |
|
||||||
double[][] result = a.getMatrix(); |
|
||||||
//遍历列
|
|
||||||
for (int j = 0; j < matrixHeight; j++) { |
|
||||||
//遍历行
|
|
||||||
for (int i = j+1; i < matrixHeight; i++) { |
|
||||||
//若遇到0则交换两行
|
|
||||||
int notZeroRow = -2; |
|
||||||
if(result[j][j] == 0){ |
|
||||||
notZeroRow = -1; |
|
||||||
for (int l = i; l < matrixHeight; l++) { |
|
||||||
if (result[l][j] != 0) { |
|
||||||
notZeroRow = l; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if (notZeroRow == -1) { |
|
||||||
throw new Exception("矩阵不可逆"); |
|
||||||
}else if(notZeroRow != -2){ |
|
||||||
//交换j与notZeroRow两行
|
|
||||||
double[] tmp = result[j]; |
|
||||||
result[j] = result[notZeroRow]; |
|
||||||
result[notZeroRow] = tmp; |
|
||||||
} |
|
||||||
|
|
||||||
double multiple = result[i][j]/result[j][j]; |
|
||||||
//遍历行中的列
|
|
||||||
for (int k = j; k < matrixHeight; k++) { |
|
||||||
result[i][k] = result[i][k] - multiple * result[j][k]; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(result); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 计算矩阵的行列式 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws Exception |
|
||||||
*/ |
|
||||||
public static double det(Matrix a) throws Exception { |
|
||||||
//将矩阵转成上三角矩阵
|
|
||||||
Matrix b = MatrixUtil.getTopTriangle(a); |
|
||||||
double result = 1; |
|
||||||
//计算矩阵行列式
|
|
||||||
for (int i = 0; i < b.getMatrixRowCount(); i++) { |
|
||||||
result *= b.getValOfIdx(i, i); |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
/** |
|
||||||
* 获取协方差矩阵 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
* @throws Exception |
|
||||||
*/ |
|
||||||
public static Matrix cov(Matrix a) throws Exception { |
|
||||||
if (a.getMatrix() == null) { |
|
||||||
throw new Exception("矩阵为空"); |
|
||||||
} |
|
||||||
Matrix avg = a.getColAvg().extend(2, a.getMatrixRowCount()); |
|
||||||
Matrix tmp = a.subtract(avg); |
|
||||||
return tmp.transpose().multiple(tmp).multiple(1/((double) a.getMatrixRowCount() -1)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 判断矩阵是否可逆 |
|
||||||
* 如果可转为上三角矩阵则可逆 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public static boolean invable(Matrix a) { |
|
||||||
try { |
|
||||||
getTopTriangle(a); |
|
||||||
return true; |
|
||||||
} catch (Exception e) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取矩阵的特征值矩阵,调用Jama中的getV方法 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public static Matrix getV(Matrix a) { |
|
||||||
EigenvalueDecomposition eig = new EigenvalueDecomposition(new Jama.Matrix(a.getMatrix())); |
|
||||||
return new Matrix(eig.getV().getArray()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 取特征值实部 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public double[] getRealEigenvalues(Matrix a){ |
|
||||||
EigenvalueDecomposition eig = new EigenvalueDecomposition(new Jama.Matrix(a.getMatrix())); |
|
||||||
return eig.getRealEigenvalues(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 取特征值虚部 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public double[] getImagEigenvalues(Matrix a){ |
|
||||||
EigenvalueDecomposition eig = new EigenvalueDecomposition(new Jama.Matrix(a.getMatrix())); |
|
||||||
return eig.getImagEigenvalues(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 取块对角特征值矩阵 |
|
||||||
* @param a |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public static Matrix getD(Matrix a) { |
|
||||||
EigenvalueDecomposition eig = new EigenvalueDecomposition(new Jama.Matrix(a.getMatrix())); |
|
||||||
return new Matrix(eig.getD().getArray()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 数据归一化 |
|
||||||
* @param a 要归一化的数据 |
|
||||||
* @param normalizationMin 要归一化的区间下限 |
|
||||||
* @param normalizationMax 要归一化的区间上限 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public static Map<String, Object> normalize(Matrix a, double normalizationMin, double normalizationMax) throws Exception { |
|
||||||
HashMap<String, Object> result = new HashMap<>(); |
|
||||||
double[][] maxArr = new double[1][a.getMatrixColCount()]; |
|
||||||
double[][] minArr = new double[1][a.getMatrixColCount()]; |
|
||||||
double[][] res = new double[a.getMatrixRowCount()][a.getMatrixColCount()]; |
|
||||||
for (int i = 0; i < a.getMatrixColCount(); i++) { |
|
||||||
List tmp = new ArrayList(); |
|
||||||
for (int j = 0; j < a.getMatrixRowCount(); j++) { |
|
||||||
tmp.add(a.getValOfIdx(j,i)); |
|
||||||
} |
|
||||||
double max = (double) Collections.max(tmp); |
|
||||||
double min = (double) Collections.min(tmp); |
|
||||||
//数据归一化(注:若max与min均为0则不需要归一化)
|
|
||||||
if (max != 0 || min != 0) { |
|
||||||
for (int j = 0; j < a.getMatrixRowCount(); j++) { |
|
||||||
try { |
|
||||||
if ((a.getValOfIdx(j,i) - min) == 0 || (max - min) == 0) { |
|
||||||
res[j][i] = normalizationMin; |
|
||||||
continue; |
|
||||||
} |
|
||||||
res[j][i] = normalizationMin + (a.getValOfIdx(j,i) - min) / (max - min) * (normalizationMax - normalizationMin); |
|
||||||
} catch (IllegalArgumentException e) { |
|
||||||
res[j][i] = 0; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
maxArr[0][i] = max; |
|
||||||
minArr[0][i] = min; |
|
||||||
} |
|
||||||
result.put("max", new Matrix(maxArr)); |
|
||||||
result.put("min", new Matrix(minArr)); |
|
||||||
result.put("res", new Matrix(res)); |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 反归一化 |
|
||||||
* @param a 要反归一化的数据 |
|
||||||
* @param normalizationMin 要反归一化的区间下限 |
|
||||||
* @param normalizationMax 要反归一化的区间上限 |
|
||||||
* @param dataMax 数据最大值 |
|
||||||
* @param dataMin 数据最小值 |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
public static Matrix inverseNormalize(Matrix a, double normalizationMax, double normalizationMin , Matrix dataMax,Matrix dataMin){ |
|
||||||
double[][] res = new double[a.getMatrixRowCount()][a.getMatrixColCount()]; |
|
||||||
for (int i = 0; i < a.getMatrixColCount(); i++) { |
|
||||||
//数据反归一化
|
|
||||||
if (dataMin.getValOfIdx(0,i) != 0 || dataMax.getValOfIdx(0,i) != 0) { |
|
||||||
for (int j = 0; j < a.getMatrixRowCount(); j++) { |
|
||||||
if ((a.getValOfIdx(j,i) - normalizationMin) == 0 || (normalizationMax - normalizationMin) == 0) { |
|
||||||
res[j][i] = dataMin.getValOfIdx(0,i); |
|
||||||
continue; |
|
||||||
} |
|
||||||
res[j][i] = dataMin.getValOfIdx(0,i) + (dataMax.getValOfIdx(0,i) - dataMin.getValOfIdx(0,i)) * (a.getValOfIdx(j,i) - normalizationMin) / (normalizationMax - normalizationMin); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return new Matrix(res); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,32 +0,0 @@ |
|||||||
package com.mh.algorithm.utils; |
|
||||||
|
|
||||||
import java.io.*; |
|
||||||
|
|
||||||
public class SerializationUtil { |
|
||||||
/** |
|
||||||
* 对象序列化到本地 |
|
||||||
* @param object |
|
||||||
* @throws IOException |
|
||||||
*/ |
|
||||||
public static void serialize(Object object, String path) throws IOException { |
|
||||||
File file = new File(path); |
|
||||||
System.out.println(file.getAbsolutePath()); |
|
||||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file)); |
|
||||||
out.writeObject(object); |
|
||||||
out.close(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 对象反序列化 |
|
||||||
* @return |
|
||||||
* @throws IOException |
|
||||||
* @throws ClassNotFoundException |
|
||||||
*/ |
|
||||||
public static Object deSerialization(String path) throws IOException, ClassNotFoundException { |
|
||||||
File file = new File(path); |
|
||||||
ObjectInputStream oin = new ObjectInputStream(new FileInputStream(file)); |
|
||||||
Object object = oin.readObject(); |
|
||||||
oin.close(); |
|
||||||
return object; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,71 +0,0 @@ |
|||||||
package com.mh.algorithm.bpnn; |
|
||||||
|
|
||||||
import com.mh.algorithm.matrix.Matrix; |
|
||||||
import com.mh.algorithm.utils.CsvInfo; |
|
||||||
import com.mh.algorithm.utils.CsvUtil; |
|
||||||
import com.mh.algorithm.utils.SerializationUtil; |
|
||||||
import org.junit.Test; |
|
||||||
|
|
||||||
import java.util.Date; |
|
||||||
|
|
||||||
public class bpnnTest { |
|
||||||
@Test |
|
||||||
public void test() throws Exception { |
|
||||||
// 创建训练集矩阵
|
|
||||||
CsvInfo csvInfo = CsvUtil.getCsvInfo(true, "D:\\ljf\\my_pro\\top-algorithm-set-dev\\src\\trainDataElec.csv"); |
|
||||||
Matrix trainSet = csvInfo.toMatrix(); |
|
||||||
// 创建BPNN工厂对象
|
|
||||||
BPNeuralNetworkFactory factory = new BPNeuralNetworkFactory(); |
|
||||||
// 创建BP参数对象
|
|
||||||
BPParameter bpParameter = new BPParameter(); |
|
||||||
bpParameter.setInputLayerNeuronCount(2); |
|
||||||
bpParameter.setHiddenLayerNeuronCount(2); |
|
||||||
bpParameter.setOutputLayerNeuronCount(2); |
|
||||||
bpParameter.setPrecision(0.01); |
|
||||||
bpParameter.setMaxTimes(10000); |
|
||||||
|
|
||||||
// 训练BP神经网络
|
|
||||||
System.out.println(new Date()); |
|
||||||
BPModel bpModel = factory.trainBP(bpParameter, trainSet); |
|
||||||
System.out.println(new Date()); |
|
||||||
|
|
||||||
// 将BPModel序列化到本地
|
|
||||||
SerializationUtil.serialize(bpModel, "elec"); |
|
||||||
|
|
||||||
CsvInfo csvInfo2 = CsvUtil.getCsvInfo(true, "D:\\ljf\\my_pro\\top-algorithm-set-dev\\src\\testDataElec.csv"); |
|
||||||
Matrix testSet = csvInfo2.toMatrix(); |
|
||||||
|
|
||||||
Matrix testData1 = testSet.subMatrix(0, testSet.getMatrixRowCount(), 0, testSet.getMatrixColCount() - 2); |
|
||||||
Matrix testLabel = testSet.subMatrix(0, testSet.getMatrixRowCount(), testSet.getMatrixColCount() - 2, 1); |
|
||||||
// 将BPModel反序列化
|
|
||||||
BPModel bpModel1 = (BPModel) SerializationUtil.deSerialization("elec"); |
|
||||||
Matrix result = factory.computeBP(bpModel1, testData1); |
|
||||||
|
|
||||||
int total = result.getMatrixRowCount(); |
|
||||||
int correct = 0; |
|
||||||
for (int i = 0; i < result.getMatrixRowCount(); i++) { |
|
||||||
if(Math.round(result.getValOfIdx(i,0)) == testLabel.getValOfIdx(i,0)){ |
|
||||||
correct++; |
|
||||||
} |
|
||||||
} |
|
||||||
double correctRate = Double.valueOf(correct) / Double.valueOf(total); |
|
||||||
System.out.println(correctRate); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 使用示例 |
|
||||||
* @throws Exception |
|
||||||
*/ |
|
||||||
@Test |
|
||||||
public void bpnnUsing() throws Exception{ |
|
||||||
CsvInfo csvInfo = CsvUtil.getCsvInfo(false, "D:\\ljf\\my_pro\\top-algorithm-set-dev\\src\\dataElec.csv"); |
|
||||||
Matrix data = csvInfo.toMatrix(); |
|
||||||
// 将BPModel反序列化
|
|
||||||
BPModel bpModel1 = (BPModel) SerializationUtil.deSerialization("elec"); |
|
||||||
// 创建工厂
|
|
||||||
BPNeuralNetworkFactory factory = new BPNeuralNetworkFactory(); |
|
||||||
Matrix result = factory.computeBP(bpModel1, data); |
|
||||||
CsvUtil.createCsvFile(null,result,"D:\\ljf\\my_pro\\top-algorithm-set-dev\\src\\computeResult.csv"); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,46 +0,0 @@ |
|||||||
//package com.mh.algorithm.knn;
|
|
||||||
//
|
|
||||||
//import com.mh.algorithm.matrix.Matrix;
|
|
||||||
//import com.mh.algorithm.utils.CsvInfo;
|
|
||||||
//import com.mh.algorithm.utils.CsvUtil;
|
|
||||||
//import com.mh.algorithm.utils.DoubleUtil;
|
|
||||||
//import org.junit.Test;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @program: top-algorithm-set
|
|
||||||
// * @description:
|
|
||||||
// * @author: Mr.Zhao
|
|
||||||
// * @create: 2020-10-26 22:04
|
|
||||||
// **/
|
|
||||||
//public class knnTest {
|
|
||||||
// @Test
|
|
||||||
// public void test() throws Exception {
|
|
||||||
// // 训练集
|
|
||||||
// CsvInfo csvInfo = CsvUtil.getCsvInfo(false, "E:\\jarTest\\trainData.csv");
|
|
||||||
// Matrix trainSet = csvInfo.toMatrix();
|
|
||||||
// Matrix trainSetLabels = trainSet.getColOfIdx(trainSet.getMatrixColCount() - 1);
|
|
||||||
// Matrix trainSetData = trainSet.subMatrix(0, trainSet.getMatrixRowCount(), 0, trainSet.getMatrixColCount() - 1);
|
|
||||||
//
|
|
||||||
// CsvInfo csvInfo1 = CsvUtil.getCsvInfo(false, "E:\\jarTest\\testData.csv");
|
|
||||||
// Matrix testSet = csvInfo1.toMatrix();
|
|
||||||
// Matrix testSetData = trainSet.subMatrix(0, testSet.getMatrixRowCount(), 0, testSet.getMatrixColCount() - 1);
|
|
||||||
// Matrix testSetLabels = trainSet.getColOfIdx(testSet.getMatrixColCount() - 1);
|
|
||||||
//
|
|
||||||
// // 分类
|
|
||||||
// long startTime = System.currentTimeMillis();
|
|
||||||
// Matrix result = KNN.classify(testSetData, trainSetData, trainSetLabels, 5);
|
|
||||||
// long endTime = System.currentTimeMillis();
|
|
||||||
// System.out.println("run time:" + (endTime - startTime));
|
|
||||||
// // 正确率
|
|
||||||
// Matrix error = result.subtract(testSetLabels);
|
|
||||||
// int total = error.getMatrixRowCount();
|
|
||||||
// int correct = 0;
|
|
||||||
// for (int i = 0; i < error.getMatrixRowCount(); i++) {
|
|
||||||
// if (DoubleUtil.equals(error.getValOfIdx(i, 0), 0.0)) {
|
|
||||||
// correct++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// double correctRate = Double.valueOf(correct) / Double.valueOf(total);
|
|
||||||
// System.out.println("correctRate:"+ correctRate);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@ -1,13 +1,13 @@ |
|||||||
//package com.mh.common.annotation;
|
package com.mh.common.annotation; |
||||||
//
|
|
||||||
//import java.lang.annotation.*;
|
import java.lang.annotation.*; |
||||||
//
|
|
||||||
///**
|
/** |
||||||
// * Created by fangzhipeng on 2017/7/12.
|
* Created by fangzhipeng on 2017/7/12. |
||||||
// */
|
*/ |
||||||
//@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD) |
||||||
//@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME) |
||||||
//@Documented
|
@Documented |
||||||
//public @interface SysLogger {
|
public @interface SysLogger { |
||||||
// String value() default "";
|
String value() default ""; |
||||||
//}
|
} |
||||||
|
|||||||
@ -1,42 +1,42 @@ |
|||||||
//package com.mh.common.utils;
|
package com.mh.common.utils; |
||||||
//
|
|
||||||
//import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse; |
||||||
//import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream; |
||||||
//import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream; |
||||||
//import java.io.File;
|
import java.io.File; |
||||||
//import java.io.FileInputStream;
|
import java.io.FileInputStream; |
||||||
//import java.io.InputStream;
|
import java.io.InputStream; |
||||||
//
|
|
||||||
///**
|
/** |
||||||
// * 文件相关操作
|
* 文件相关操作 |
||||||
// * @author Louis
|
* @author Louis |
||||||
// * @date Jan 14, 2019
|
* @date Jan 14, 2019 |
||||||
// */
|
*/ |
||||||
//public class FileUtils {
|
public class FileUtils { |
||||||
//
|
|
||||||
// /**
|
/** |
||||||
// * 下载文件
|
* 下载文件 |
||||||
// * @param response
|
* @param response |
||||||
// * @param file
|
* @param file |
||||||
// * @param newFileName
|
* @param newFileName |
||||||
// */
|
*/ |
||||||
// public static void downloadFile(HttpServletResponse response, File file, String newFileName) {
|
public static void downloadFile(HttpServletResponse response, File file, String newFileName) { |
||||||
// try {
|
try { |
||||||
// response.setHeader("Content-Disposition", "attachment; filename=" + new String(newFileName.getBytes("ISO-8859-1"), "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment; filename=" + new String(newFileName.getBytes("ISO-8859-1"), "UTF-8")); |
||||||
// BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
|
BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream()); |
||||||
// InputStream is = new FileInputStream(file.getAbsolutePath());
|
InputStream is = new FileInputStream(file.getAbsolutePath()); |
||||||
// BufferedInputStream bis = new BufferedInputStream(is);
|
BufferedInputStream bis = new BufferedInputStream(is); |
||||||
// int length = 0;
|
int length = 0; |
||||||
// byte[] temp = new byte[1 * 1024 * 10];
|
byte[] temp = new byte[1 * 1024 * 10]; |
||||||
// while ((length = bis.read(temp)) != -1) {
|
while ((length = bis.read(temp)) != -1) { |
||||||
// bos.write(temp, 0, length);
|
bos.write(temp, 0, length); |
||||||
// }
|
} |
||||||
// bos.flush();
|
bos.flush(); |
||||||
// bis.close();
|
bis.close(); |
||||||
// bos.close();
|
bos.close(); |
||||||
// is.close();
|
is.close(); |
||||||
// } catch (Exception e) {
|
} catch (Exception e) { |
||||||
// e.printStackTrace();
|
e.printStackTrace(); |
||||||
// }
|
} |
||||||
// }
|
} |
||||||
//}
|
} |
||||||
|
|||||||
@ -1,122 +0,0 @@ |
|||||||
package com.mh.user.config; |
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|
||||||
import org.springframework.stereotype.Component; |
|
||||||
|
|
||||||
/** |
|
||||||
* 读取项目相关配置 |
|
||||||
* |
|
||||||
* @author mh |
|
||||||
*/ |
|
||||||
@Component |
|
||||||
@ConfigurationProperties(prefix = "mh") |
|
||||||
public class MHConfig |
|
||||||
{ |
|
||||||
/** 项目名称 */ |
|
||||||
private String name; |
|
||||||
|
|
||||||
/** 版本 */ |
|
||||||
private String version; |
|
||||||
|
|
||||||
/** 版权年份 */ |
|
||||||
private String copyrightYear; |
|
||||||
|
|
||||||
/** 上传路径 */ |
|
||||||
private static String profile; |
|
||||||
|
|
||||||
/** 获取地址开关 */ |
|
||||||
private static boolean addressEnabled; |
|
||||||
|
|
||||||
/** 验证码类型 */ |
|
||||||
private static String captchaType; |
|
||||||
|
|
||||||
public String getName() |
|
||||||
{ |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
public void setName(String name) |
|
||||||
{ |
|
||||||
this.name = name; |
|
||||||
} |
|
||||||
|
|
||||||
public String getVersion() |
|
||||||
{ |
|
||||||
return version; |
|
||||||
} |
|
||||||
|
|
||||||
public void setVersion(String version) |
|
||||||
{ |
|
||||||
this.version = version; |
|
||||||
} |
|
||||||
|
|
||||||
public String getCopyrightYear() |
|
||||||
{ |
|
||||||
return copyrightYear; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCopyrightYear(String copyrightYear) |
|
||||||
{ |
|
||||||
this.copyrightYear = copyrightYear; |
|
||||||
} |
|
||||||
|
|
||||||
public static String getProfile() |
|
||||||
{ |
|
||||||
return profile; |
|
||||||
} |
|
||||||
|
|
||||||
public void setProfile(String profile) |
|
||||||
{ |
|
||||||
MHConfig.profile = profile; |
|
||||||
} |
|
||||||
|
|
||||||
public static boolean isAddressEnabled() |
|
||||||
{ |
|
||||||
return addressEnabled; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAddressEnabled(boolean addressEnabled) |
|
||||||
{ |
|
||||||
MHConfig.addressEnabled = addressEnabled; |
|
||||||
} |
|
||||||
|
|
||||||
public static String getCaptchaType() { |
|
||||||
return captchaType; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCaptchaType(String captchaType) { |
|
||||||
MHConfig.captchaType = captchaType; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取导入上传路径 |
|
||||||
*/ |
|
||||||
public static String getImportPath() |
|
||||||
{ |
|
||||||
return getProfile() + "/import"; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取头像上传路径 |
|
||||||
*/ |
|
||||||
public static String getAvatarPath() |
|
||||||
{ |
|
||||||
return getProfile() + "/avatar"; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取下载路径 |
|
||||||
*/ |
|
||||||
public static String getDownloadPath() |
|
||||||
{ |
|
||||||
return getProfile() + "/download/"; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取上传路径 |
|
||||||
*/ |
|
||||||
public static String getUploadPath() |
|
||||||
{ |
|
||||||
return getProfile() + "/upload"; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,22 +1,14 @@ |
|||||||
package com.mh.user.config; |
package com.mh.user.config; |
||||||
|
|
||||||
import org.springframework.context.annotation.Bean; |
|
||||||
import org.springframework.context.annotation.Configuration; |
import org.springframework.context.annotation.Configuration; |
||||||
import org.springframework.web.client.RestTemplate; |
|
||||||
|
|
||||||
/** |
/** |
||||||
* @author LJF |
* @author ljf |
||||||
* @title : |
* @title : |
||||||
* @description 请求数据 |
* @description : redis配置 |
||||||
* @updateTime 2020-08-20 |
* @updateTime 2020-08-20 |
||||||
* @throws : |
* @throws : |
||||||
*/ |
*/ |
||||||
@Configuration |
@Configuration |
||||||
public class RestTemplateConfig { |
public class RestTemplateConfig { |
||||||
|
|
||||||
@Bean |
|
||||||
public RestTemplate restTemplate() { |
|
||||||
return new RestTemplate(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
} |
||||||
|
|||||||
@ -1,59 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project springboot-mqtt-demo |
|
||||||
* @description 声明所有通道 |
|
||||||
* @date 2024-10-29 16:04:19 |
|
||||||
*/ |
|
||||||
public class ChannelName { |
|
||||||
|
|
||||||
/** |
|
||||||
* 默认通道名称(防止出错) |
|
||||||
*/ |
|
||||||
public static final String DEFAULT_BOUND = "default_bound"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 主动上报入站 |
|
||||||
*/ |
|
||||||
public static final String INBOUND = "inbound"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 出站 |
|
||||||
*/ |
|
||||||
public static final String OUTBOUND = "outbound"; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 入站主动上报 |
|
||||||
*/ |
|
||||||
public static final String EVENTS_UPLOAD_INBOUND = "events_upload_inbound"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 入站主动采集 |
|
||||||
*/ |
|
||||||
public static final String EVENTS_COLLECTION_INBOUND = "events_collection_inbound"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 入站主动控制 |
|
||||||
*/ |
|
||||||
public static final String EVENTS_CONTROL_INBOUND = "events_control_inbound"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 默认进站处理 |
|
||||||
*/ |
|
||||||
public static final String EVENTS_DEFAULT_INBOUND = "events_default_inbound"; |
|
||||||
|
|
||||||
public static final String REPLY_EVENTS_OUTBOUND = "reply_events_outbound"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 新珠江收到的信息 |
|
||||||
*/ |
|
||||||
public static final String EVENTS_RECEIVE_INBOUND = "events_receive_inbound"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 接收服务端的数据报文 |
|
||||||
*/ |
|
||||||
public static final String EVENTS_SEND_INBOUND = "events_send_inbound"; |
|
||||||
} |
|
||||||
@ -1,36 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|
||||||
import lombok.AllArgsConstructor; |
|
||||||
import lombok.Builder; |
|
||||||
import lombok.Data; |
|
||||||
import lombok.NoArgsConstructor; |
|
||||||
|
|
||||||
/** |
|
||||||
* Unified Topic response format |
|
||||||
* |
|
||||||
* @author sean.zhou |
|
||||||
* @version 0.1 |
|
||||||
* @date 2021/11/15 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
@AllArgsConstructor |
|
||||||
@NoArgsConstructor |
|
||||||
@Builder |
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true) |
|
||||||
public class CommonTopicResponse<T> { |
|
||||||
|
|
||||||
/** |
|
||||||
* The command is sent and the response is matched by the tid and bid fields in the message, |
|
||||||
* and the reply should keep the tid and bid the same. |
|
||||||
*/ |
|
||||||
private String tid; |
|
||||||
|
|
||||||
private String bid; |
|
||||||
|
|
||||||
private String method; |
|
||||||
|
|
||||||
private T data; |
|
||||||
|
|
||||||
private Long timestamp; |
|
||||||
} |
|
||||||
@ -1,63 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
import com.mh.user.factory.*; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 设备枚举类 |
|
||||||
* @date 2024-03-19 10:06:29 |
|
||||||
*/ |
|
||||||
public enum DeviceEnum { |
|
||||||
|
|
||||||
WtMeterEnum("水表", WtMeter.getInstance()), |
|
||||||
EleMeterEnum("电表", EleMeter.getInstance()), |
|
||||||
PressureTransEnum("压变", PressureTrans.getInstance()), |
|
||||||
HeatPumpEnum("热泵", HeatPump.getInstance()), |
|
||||||
TempControlEnum("温控", TempControl.getInstance()), |
|
||||||
BackTempControlEnum("回水温控", BackTempControl.getInstance()), |
|
||||||
TimeControlEnum("时控", TimeControl.getInstance()), |
|
||||||
ALiTaControlEnum("阿丽塔时控", TimeControl.getInstance()), |
|
||||||
MHControlEnum("蒙浩时控", TimeControl.getInstance()), |
|
||||||
WaterLevelSwitchEnum("水位开关", WaterLevelSwitch.getInstance()), |
|
||||||
StatusCheckEnum("状态检测", StatusCheck.getInstance()), |
|
||||||
TempTransEnum("温度变送器", TempTrans.getInstance()), |
|
||||||
HeatPumpStatusEnum("热泵状态", HeatPumpStatus.getInstance()), |
|
||||||
MultiControlEnum("多路控制", MultiControl.getInstance()); |
|
||||||
|
|
||||||
private String deviceType; |
|
||||||
|
|
||||||
private Device device; |
|
||||||
|
|
||||||
private |
|
||||||
DeviceEnum(String deviceType, Device device) { |
|
||||||
this.deviceType = deviceType; |
|
||||||
this.device = device; |
|
||||||
} |
|
||||||
|
|
||||||
public String getDeviceType() { |
|
||||||
return deviceType; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDeviceType(String deviceType) { |
|
||||||
this.deviceType = deviceType; |
|
||||||
} |
|
||||||
|
|
||||||
public Device getDevice() { |
|
||||||
return device; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDevice(Device device) { |
|
||||||
this.device = device; |
|
||||||
} |
|
||||||
|
|
||||||
public static Device getDevice(String deviceType) { |
|
||||||
for (DeviceEnum deviceEnum : DeviceEnum.values()) { |
|
||||||
if (deviceEnum.getDeviceType().equals(deviceType)) { |
|
||||||
return deviceEnum.getDevice(); |
|
||||||
} |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,62 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
import com.mh.user.strategy.*; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 设备枚举类 |
|
||||||
* @date 2024-03-19 10:06:29 |
|
||||||
*/ |
|
||||||
public enum DeviceStrategyEnum { |
|
||||||
|
|
||||||
WtMeterEnum("水表", WtMeterStrategy.getInstance()), |
|
||||||
EleMeterEnum("电表", EleMeterStrategy.getInstance()), |
|
||||||
PressureTransEnum("压变", PressureTransStrategy.getInstance()), |
|
||||||
HeatPumpEnum("热泵", HeatPumpStrategy.getInstance()), |
|
||||||
TempControlEnum("温控", TempControlStrategy.getInstance()), |
|
||||||
BackTempControlEnum("回水温控", BackTempControlStrategy.getInstance()), |
|
||||||
TimeControlEnum("时控", TimeControlStrategy.getInstance()), |
|
||||||
ALitaTimeControlEnum("阿丽塔时控", TimeControlStrategy.getInstance()), |
|
||||||
MHTimeControlEnum("蒙浩时控", TimeControlStrategy.getInstance()), |
|
||||||
WaterLevelSwitchEnum("水位开关", WaterLevelSwitchStrategy.getInstance()), |
|
||||||
StatusCheckEnum("状态检测", StatusCheckStrategy.getInstance()), |
|
||||||
TempTransEnum("温度变送器", TempTransStrategy.getInstance()), |
|
||||||
HeatPumpStatusEnum("热泵状态", HeatPumpStatusStrategy.getInstance()), |
|
||||||
MultiControlEnum("多路控制", MultiControlStrategy.getInstance()); |
|
||||||
|
|
||||||
private String deviceType; |
|
||||||
|
|
||||||
private DeviceStrategy deviceStrategy; |
|
||||||
|
|
||||||
private DeviceStrategyEnum(String deviceType, DeviceStrategy deviceStrategy) { |
|
||||||
this.deviceType = deviceType; |
|
||||||
this.deviceStrategy = deviceStrategy; |
|
||||||
} |
|
||||||
|
|
||||||
public String getDeviceType() { |
|
||||||
return deviceType; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDeviceType(String deviceType) { |
|
||||||
this.deviceType = deviceType; |
|
||||||
} |
|
||||||
|
|
||||||
public DeviceStrategy getDeviceStrategy() { |
|
||||||
return deviceStrategy; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDeviceStrategy(DeviceStrategy deviceStrategy) { |
|
||||||
this.deviceStrategy = deviceStrategy; |
|
||||||
} |
|
||||||
|
|
||||||
public static DeviceStrategy getDeviceStrategy(String deviceType) { |
|
||||||
for (DeviceStrategyEnum deviceEnum : DeviceStrategyEnum.values()) { |
|
||||||
if (deviceEnum.getDeviceType().equals(deviceType)) { |
|
||||||
return deviceEnum.getDeviceStrategy(); |
|
||||||
} |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,111 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project TAD_Server |
|
||||||
* @description 4G设备常量值 |
|
||||||
* @date 2023/7/3 18:14:12 |
|
||||||
*/ |
|
||||||
public enum FourthGEnum { |
|
||||||
|
|
||||||
LOGIN_HEART_RESPONSE("0D", "登录和心跳确认控制码"), |
|
||||||
|
|
||||||
LOGIN_HEART_REQUEST("8D", "登录和心跳请求控制码"), |
|
||||||
|
|
||||||
LOGIN_HEART_EXCEPTION("CD", "登录和心跳异常应答控制码"), |
|
||||||
|
|
||||||
LOGIN_TYPE("02", "登录类型"), |
|
||||||
|
|
||||||
HEART_TYPE("01", "心跳类型"), |
|
||||||
|
|
||||||
CLOSE_CONTROL_TYPE("1C", "合闸指令"), |
|
||||||
|
|
||||||
OPEN_CONTROL_TYPE("1A", "跳闸指令"), |
|
||||||
|
|
||||||
DATA_ACTIVE_UPLOAD("8E", "数据主动上报控制码"), |
|
||||||
|
|
||||||
PULL_AND_CLOSE_DEVICE_REQUEST("1C", "跳合闸请求控制码"), |
|
||||||
|
|
||||||
PULL_AND_CLOSE_DEVICE_RESPONSE("9C", "跳合闸应答控制码"), |
|
||||||
|
|
||||||
PULL_AND_CLOSE_DEVICE_EXCEPTION("DC", "跳合闸应答异常控制码"), |
|
||||||
|
|
||||||
CLEAR_DEVICE_REQUEST("1A", "电表清零请求控制码"), |
|
||||||
|
|
||||||
CLEAR_DEVICE_RESPONSE("9A", "电表清零应答控制码"), |
|
||||||
|
|
||||||
CLEAR_DEVICE_EXCEPTION("DA", "电表清零应答异常控制码"), |
|
||||||
|
|
||||||
READ_DEVICE_REQUEST("11", "读电表请求控制码"), |
|
||||||
|
|
||||||
READ_DEVICE_RESPONSE("91", "读电表应答控制码"), |
|
||||||
|
|
||||||
READ_DEVICE_EXCEPTION("D1", "读电表应答异常控制码"), |
|
||||||
|
|
||||||
WRITE_DEVICE_REQUEST("14", "写电表请求控制码"), |
|
||||||
|
|
||||||
WRITE_DEVICE_RESPONSE("94", "读电表应答控制码"), |
|
||||||
WRITE_DEVICE_IP("94", "写电表IP应答控制码"), |
|
||||||
|
|
||||||
WRITE_DEVICE_EXCEPTION("D4", "读电表应答异常控制码"), |
|
||||||
|
|
||||||
CHARGE_DEVICE_REQUEST("0F", "充值指令"), |
|
||||||
|
|
||||||
CHARGE_DEVICE_RESPONSE("8F", "充值正确应答控制码"), |
|
||||||
|
|
||||||
CHARGE_DEVICE_EXCEPTION("CF", "充值异常应答控制码"), |
|
||||||
|
|
||||||
READ_TOTAL_CHARGE_IDENTIFY_CODE("00000000", "当前组合有功总电能"), |
|
||||||
|
|
||||||
READ_STATUS_IDENTIFY_CODE("03050004", "读电表运行状态"), |
|
||||||
READ_UPLOAD_CODE("02008104", "读取上报报文"), |
|
||||||
|
|
||||||
TY_UPLOAD_CODE("55C2", "腾越水表上报标识"), |
|
||||||
|
|
||||||
WRITE_CHARGE_TIME_IDENTIFY_CODE("07008104", "写入充值次数"), |
|
||||||
|
|
||||||
WRITE_LIMIT_POWER("10008104","写入限容功率"), |
|
||||||
READ_LIMIT_POWER("10008104","读取限容功率"), |
|
||||||
READ_SOFT_VERSION("01008004","读软件版本"), |
|
||||||
READ_HARD_VERSION("02008004","读硬件版本"), |
|
||||||
READ_ICCID("05008104","读取ICCID"), |
|
||||||
READ_IMEI("04008104","读取IMEI"), |
|
||||||
WRITE_IP("0B008104","设置IP端口号"), |
|
||||||
READ_IP("0B008104","读取IP端口号"), |
|
||||||
UPGRADES("13008104","触发升级,写1触发升级") |
|
||||||
; |
|
||||||
|
|
||||||
private String code; |
|
||||||
|
|
||||||
private String desc; |
|
||||||
|
|
||||||
FourthGEnum(String code, String desc) { |
|
||||||
this.code = code; |
|
||||||
this.desc = desc; |
|
||||||
} |
|
||||||
|
|
||||||
public String getCode() { |
|
||||||
return code; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCode(String code) { |
|
||||||
this.code = code; |
|
||||||
} |
|
||||||
|
|
||||||
public String getDesc() { |
|
||||||
return desc; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDesc(String desc) { |
|
||||||
this.desc = desc; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "FourthGEnum{" + |
|
||||||
"code='" + code + '\'' + |
|
||||||
", desc='" + desc + '\'' + |
|
||||||
'}'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,108 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project springboot-mqtt-demo |
|
||||||
* @description mqtt连接的参数 |
|
||||||
* @date 2024-10-29 14:46:24 |
|
||||||
*/ |
|
||||||
public class MqttClientOptions { |
|
||||||
|
|
||||||
private MqttProtocolEnum protocol; |
|
||||||
|
|
||||||
private String host; |
|
||||||
|
|
||||||
private Integer port; |
|
||||||
|
|
||||||
private String username; |
|
||||||
|
|
||||||
private String password; |
|
||||||
|
|
||||||
private String clientId; |
|
||||||
|
|
||||||
private String path; |
|
||||||
|
|
||||||
/** |
|
||||||
* 客户端连接的时候,订阅的主题 |
|
||||||
*/ |
|
||||||
private String inboundTopic; |
|
||||||
|
|
||||||
public MqttProtocolEnum getProtocol() { |
|
||||||
return protocol; |
|
||||||
} |
|
||||||
|
|
||||||
public void setProtocol(MqttProtocolEnum protocol) { |
|
||||||
this.protocol = protocol; |
|
||||||
} |
|
||||||
|
|
||||||
public String getHost() { |
|
||||||
return host; |
|
||||||
} |
|
||||||
|
|
||||||
public void setHost(String host) { |
|
||||||
this.host = host; |
|
||||||
} |
|
||||||
|
|
||||||
public Integer getPort() { |
|
||||||
return port; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPort(Integer port) { |
|
||||||
this.port = port; |
|
||||||
} |
|
||||||
|
|
||||||
public String getUsername() { |
|
||||||
return username; |
|
||||||
} |
|
||||||
|
|
||||||
public void setUsername(String username) { |
|
||||||
this.username = username; |
|
||||||
} |
|
||||||
|
|
||||||
public String getPassword() { |
|
||||||
return password; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPassword(String password) { |
|
||||||
this.password = password; |
|
||||||
} |
|
||||||
|
|
||||||
public String getClientId() { |
|
||||||
return clientId; |
|
||||||
} |
|
||||||
|
|
||||||
public void setClientId(String clientId) { |
|
||||||
this.clientId = clientId; |
|
||||||
} |
|
||||||
|
|
||||||
public String getPath() { |
|
||||||
return path; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPath(String path) { |
|
||||||
this.path = path; |
|
||||||
} |
|
||||||
|
|
||||||
public String getInboundTopic() { |
|
||||||
return inboundTopic; |
|
||||||
} |
|
||||||
|
|
||||||
public void setInboundTopic(String inboundTopic) { |
|
||||||
this.inboundTopic = inboundTopic; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "MqttClientOptions{" + |
|
||||||
"protocol=" + protocol + |
|
||||||
", host='" + host + '\'' + |
|
||||||
", port=" + port + |
|
||||||
", username='" + username + '\'' + |
|
||||||
", password='" + password + '\'' + |
|
||||||
", clientId='" + clientId + '\'' + |
|
||||||
", path='" + path + '\'' + |
|
||||||
", inboundTopic='" + inboundTopic + '\'' + |
|
||||||
'}'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,33 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project springboot-mqtt-demo |
|
||||||
* @description 采用哪种协议进行数据交互 |
|
||||||
* @date 2024-10-29 15:21:07 |
|
||||||
*/ |
|
||||||
public enum MqttProtocolEnum { |
|
||||||
|
|
||||||
MQTT("tcp"), |
|
||||||
|
|
||||||
MQTTS("tcp"), |
|
||||||
|
|
||||||
WS("ws"), |
|
||||||
|
|
||||||
WSS("wss"); |
|
||||||
|
|
||||||
final String protocol; |
|
||||||
|
|
||||||
MqttProtocolEnum(String protocol) { |
|
||||||
this.protocol = protocol; |
|
||||||
} |
|
||||||
|
|
||||||
public String getProtocolAddr() { |
|
||||||
return protocol + "://"; |
|
||||||
} |
|
||||||
|
|
||||||
public String getProtocol() { |
|
||||||
return protocol; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,16 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project springboot-mqtt-demo |
|
||||||
* @description mqtt选择模式 |
|
||||||
* @date 2024-10-29 15:19:21 |
|
||||||
*/ |
|
||||||
public enum MqttUseEnum { |
|
||||||
|
|
||||||
BASIC, |
|
||||||
|
|
||||||
DRC |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,20 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author sean.zhou |
|
||||||
* @version 0.1 |
|
||||||
* @date 2021/11/22 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true) |
|
||||||
public class ServiceReply<T> { |
|
||||||
|
|
||||||
private Integer result; |
|
||||||
|
|
||||||
private T info; |
|
||||||
|
|
||||||
private T output; |
|
||||||
} |
|
||||||
@ -1,31 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
/** |
|
||||||
* All the topics that need to be used in the project. |
|
||||||
* |
|
||||||
* @author ljf |
|
||||||
* @version 0.1 |
|
||||||
* @date 2025-01-22 |
|
||||||
*/ |
|
||||||
public class TopicConst { |
|
||||||
|
|
||||||
public static final String MH_UPLOAD = "mh_upload/"; |
|
||||||
|
|
||||||
public static final String EVENTS_UPLOAD = "events_upload/"; |
|
||||||
|
|
||||||
public static final String MH_COLLECTION = "mh_collection/"; |
|
||||||
|
|
||||||
public static final String EVENTS_COLLECTION = "events_collection/"; |
|
||||||
|
|
||||||
public static final String MH_CONTROL = "mh_control/"; |
|
||||||
|
|
||||||
public static final String EVENTS_CONTROL = "events_control/"; |
|
||||||
|
|
||||||
public static final String REGEX_SN = "[A-Za-z0-9]+"; |
|
||||||
|
|
||||||
public static final String THING_MODEL_PRE = "thing/"; |
|
||||||
|
|
||||||
public static final String PRODUCT = "product/"; |
|
||||||
|
|
||||||
public static final String SERVICES_SUF = "/services"; |
|
||||||
} |
|
||||||
@ -1,60 +0,0 @@ |
|||||||
package com.mh.user.constants; |
|
||||||
|
|
||||||
import java.util.Arrays; |
|
||||||
import java.util.regex.Pattern; |
|
||||||
|
|
||||||
import static com.mh.user.constants.TopicConst.*; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author ljf |
|
||||||
* @version 1.0 |
|
||||||
* @description: TODO |
|
||||||
* @date 2024/11/06 14:28 |
|
||||||
*/ |
|
||||||
public enum TopicEnum { |
|
||||||
|
|
||||||
/** |
|
||||||
* 客户端主动上报数据 |
|
||||||
*/ |
|
||||||
CLIENT_UPLOAD_DATA(Pattern.compile("^" + MH_UPLOAD + EVENTS_UPLOAD + REGEX_SN + "$"), ChannelName.EVENTS_UPLOAD_INBOUND), |
|
||||||
|
|
||||||
/** |
|
||||||
* 服务端采集数据 |
|
||||||
*/ |
|
||||||
SERVER_COLLECTION_DATA(Pattern.compile("^" + MH_COLLECTION + EVENTS_COLLECTION + REGEX_SN + "$"), ChannelName.EVENTS_COLLECTION_INBOUND), |
|
||||||
|
|
||||||
/** |
|
||||||
* 服务端控制指令 |
|
||||||
*/ |
|
||||||
SERVER_CONTROL_DATA(Pattern.compile("^" + MH_CONTROL + EVENTS_CONTROL + REGEX_SN + "$"), ChannelName.EVENTS_CONTROL_INBOUND), |
|
||||||
|
|
||||||
/** |
|
||||||
* 订阅服务端发送的主题命令 |
|
||||||
*/ |
|
||||||
SERVER_SEND_DATA(Pattern.compile("^A/cmd/ctl/send" + "$"), ChannelName.EVENTS_SEND_INBOUND), |
|
||||||
|
|
||||||
UNKNOWN(Pattern.compile("^.*$"), ChannelName.DEFAULT_BOUND); |
|
||||||
|
|
||||||
final Pattern pattern; |
|
||||||
|
|
||||||
final String beanName; |
|
||||||
|
|
||||||
TopicEnum(Pattern pattern, String beanName) { |
|
||||||
this.pattern = pattern; |
|
||||||
this.beanName = beanName; |
|
||||||
} |
|
||||||
|
|
||||||
public Pattern getPattern() { |
|
||||||
return pattern; |
|
||||||
} |
|
||||||
|
|
||||||
public String getBeanName() { |
|
||||||
return beanName; |
|
||||||
} |
|
||||||
|
|
||||||
public static TopicEnum find(String proName, String topic) { |
|
||||||
// 去掉第一个"/"以及之前数据
|
|
||||||
String finalTopic = topic.replaceFirst("^"+proName, "");; |
|
||||||
return Arrays.stream(TopicEnum.values()).filter(topicEnum -> topicEnum.pattern.matcher(finalTopic).matches()).findAny().orElse(UNKNOWN); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,71 +0,0 @@ |
|||||||
package com.mh.user.controller; |
|
||||||
|
|
||||||
import com.mh.common.http.HttpResult; |
|
||||||
import com.mh.common.utils.StringUtils; |
|
||||||
import com.mh.user.annotation.SysLogger; |
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.model.DeviceModel; |
|
||||||
import com.mh.user.service.*; |
|
||||||
import org.apache.poi.hssf.usermodel.HSSFCell; |
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet; |
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
||||||
import org.apache.poi.ss.usermodel.CellType; |
|
||||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||||
import org.springframework.web.bind.annotation.*; |
|
||||||
import org.springframework.web.multipart.MultipartFile; |
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest; |
|
||||||
import java.io.IOException; |
|
||||||
import java.io.InputStream; |
|
||||||
import java.text.SimpleDateFormat; |
|
||||||
import java.util.*; |
|
||||||
|
|
||||||
/** |
|
||||||
* 基表参数信息管理 |
|
||||||
*/ |
|
||||||
@RestController |
|
||||||
@RequestMapping("cpm") |
|
||||||
public class CollectionParamsManageController { |
|
||||||
|
|
||||||
@Autowired |
|
||||||
private CollectionParamsManageService collectionParamsManageService; |
|
||||||
|
|
||||||
//保存
|
|
||||||
@SysLogger(title="基表采集信息",optDesc = "保存基表采集参数信息") |
|
||||||
@PostMapping(value="/save") |
|
||||||
public HttpResult saveDevice(@RequestBody CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return HttpResult.ok(collectionParamsManageService.insertCPM(collectionParamsManageEntity)); |
|
||||||
} |
|
||||||
|
|
||||||
//修改
|
|
||||||
@SysLogger(title="基表采集参数信息",optDesc = "修改基表采集参数信息") |
|
||||||
@PostMapping(value="/update") |
|
||||||
public HttpResult updateDevice(@RequestBody CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return HttpResult.ok(collectionParamsManageService.updateCPM(collectionParamsManageEntity)); |
|
||||||
} |
|
||||||
|
|
||||||
// 删除多
|
|
||||||
@PostMapping(value="/deletes") |
|
||||||
public HttpResult deleteDevices(@RequestBody String[] ids) { |
|
||||||
return HttpResult.ok(collectionParamsManageService.deleteByIds(ids)); |
|
||||||
} |
|
||||||
|
|
||||||
// 按条件查询
|
|
||||||
@SysLogger(title="基表采集信息",optDesc = "按条件查询基表采集参数信息") |
|
||||||
@PostMapping(value="/query") |
|
||||||
public HttpResult queryDevice( @RequestParam(value = "deviceInstallId", required = false)String deviceInstallId, |
|
||||||
@RequestParam(value = "buildingId", required = false)String buildingId, |
|
||||||
@RequestParam(value = "otherName", required = false)String otherName, |
|
||||||
@RequestParam(value = "page", required=true)Integer page, |
|
||||||
@RequestParam(value = "limit", required=true)Integer limit) { |
|
||||||
try{ |
|
||||||
int count=collectionParamsManageService.selectCPMListCount(buildingId, deviceInstallId,otherName, page, limit); |
|
||||||
List<CollectionParamsManageEntity> records=collectionParamsManageService.selectCPMList(buildingId, deviceInstallId,otherName, page, limit); |
|
||||||
return HttpResult.ok(count,records); |
|
||||||
}catch (Exception e){ |
|
||||||
return HttpResult.error(e.getMessage()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,36 +0,0 @@ |
|||||||
package com.mh.user.controller; |
|
||||||
|
|
||||||
import com.mh.common.http.HttpResult; |
|
||||||
import com.mh.user.dto.EnergyPreDTO; |
|
||||||
import com.mh.user.service.HistoryDataPreService; |
|
||||||
import org.springframework.web.bind.annotation.PostMapping; |
|
||||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||||
import org.springframework.web.bind.annotation.RestController; |
|
||||||
|
|
||||||
import javax.annotation.Resource; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 用能预测controller |
|
||||||
* @date 2024-05-09 17:24:48 |
|
||||||
*/ |
|
||||||
@RestController |
|
||||||
@RequestMapping("/energyPre") |
|
||||||
public class EnergyPreController { |
|
||||||
|
|
||||||
@Resource |
|
||||||
private HistoryDataPreService historyDataPreService; |
|
||||||
|
|
||||||
@PostMapping("/topData") |
|
||||||
public HttpResult getTopData(String buildingId, String type) { |
|
||||||
return HttpResult.ok(historyDataPreService.getTopData(buildingId, type)); |
|
||||||
} |
|
||||||
|
|
||||||
@PostMapping("/echartData") |
|
||||||
public HttpResult getEnergyPre(String buildingId, String beginDate, String endDate, String type) { |
|
||||||
return HttpResult.ok(historyDataPreService.getEnergyPre(buildingId, beginDate, endDate, type)); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,52 +0,0 @@ |
|||||||
package com.mh.user.controller; |
|
||||||
|
|
||||||
import com.mh.common.http.HttpResult; |
|
||||||
import com.mh.user.dto.HotWaterControlDTO; |
|
||||||
import com.mh.user.dto.HotWaterNowDataDTO; |
|
||||||
import com.mh.user.service.CollectionParamsManageService; |
|
||||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||||
import org.springframework.web.bind.annotation.GetMapping; |
|
||||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||||
import org.springframework.web.bind.annotation.RequestParam; |
|
||||||
import org.springframework.web.bind.annotation.RestController; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 热水监控 |
|
||||||
* @date 2025-12-16 16:02:20 |
|
||||||
*/ |
|
||||||
@RestController |
|
||||||
@RequestMapping("/device/hotWater") |
|
||||||
public class HotWaterMonitorController { |
|
||||||
|
|
||||||
@Autowired |
|
||||||
private CollectionParamsManageService collectionParamsManageService; |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取生活热水监控热泵信息 |
|
||||||
* @param buildingId |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
@GetMapping("/monitorList") |
|
||||||
public HttpResult monitorList(@RequestParam("buildingId") String buildingId) { |
|
||||||
List<HotWaterNowDataDTO> list = collectionParamsManageService.monitorList(buildingId); |
|
||||||
return HttpResult. ok(list); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取生活热水监控操作信息内容 |
|
||||||
* @param buildingId |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
@GetMapping("/operateList") |
|
||||||
public HttpResult operateList(@RequestParam("buildingId") String buildingId) { |
|
||||||
List<HotWaterControlDTO> list = collectionParamsManageService.operateList(buildingId); |
|
||||||
return HttpResult.ok(list); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
@ -1,63 +0,0 @@ |
|||||||
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.entity.KnowledgeDataEntity; |
|
||||||
import com.mh.user.service.KnowledgeDataService; |
|
||||||
import io.jsonwebtoken.lang.Assert; |
|
||||||
import org.springframework.validation.annotation.Validated; |
|
||||||
import org.springframework.web.bind.annotation.*; |
|
||||||
|
|
||||||
import javax.annotation.Resource; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 知识库管理 |
|
||||||
* @date 2024-06-26 14:39:24 |
|
||||||
*/ |
|
||||||
@RestController |
|
||||||
@RequestMapping("/knowledge") |
|
||||||
public class KnowledgeDataController { |
|
||||||
|
|
||||||
@Resource |
|
||||||
private KnowledgeDataService knowledgeDataService; |
|
||||||
|
|
||||||
@GetMapping("/query") |
|
||||||
public HttpResult queryKnowledgeData(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize) { |
|
||||||
PageRequest pageRequest = new PageRequest(); |
|
||||||
pageRequest.setPageNum(pageNum); |
|
||||||
pageRequest.setPageSize(pageSize); |
|
||||||
return HttpResult.ok(knowledgeDataService.queryKnowledgeData(pageRequest)); |
|
||||||
} |
|
||||||
|
|
||||||
@GetMapping("/{id}") |
|
||||||
public HttpResult detail(@PathVariable(name = "id") Long id) { |
|
||||||
KnowledgeDataEntity knowledgeData = knowledgeDataService.getById(id); |
|
||||||
Assert.notNull(knowledgeData, "该文章已被删除"); |
|
||||||
return HttpResult.ok(knowledgeData); |
|
||||||
} |
|
||||||
|
|
||||||
@PostMapping("/update") |
|
||||||
public HttpResult updateData(@Validated @RequestBody KnowledgeDataEntity knowledgeData) { |
|
||||||
try { |
|
||||||
knowledgeDataService.updateData(knowledgeData); |
|
||||||
} catch (Exception e) { |
|
||||||
throw new RuntimeException(e); |
|
||||||
} |
|
||||||
return HttpResult.ok(); |
|
||||||
} |
|
||||||
|
|
||||||
@PostMapping("/insert") |
|
||||||
public HttpResult insertKnowledgeData(@Validated @RequestBody KnowledgeDataEntity knowledgeData) { |
|
||||||
try { |
|
||||||
knowledgeDataService.insertKnowledgeData(knowledgeData); |
|
||||||
} catch (Exception e) { |
|
||||||
throw new RuntimeException(e); |
|
||||||
} |
|
||||||
return HttpResult.ok(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,27 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 用能预测前端类 |
|
||||||
* @date 2024-05-09 17:31:27 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class EnergyPreDTO { |
|
||||||
|
|
||||||
/** |
|
||||||
* 顶部数据 |
|
||||||
*/ |
|
||||||
private EnergyPreTopDataDTO topData; |
|
||||||
|
|
||||||
/** |
|
||||||
* 折线图数据 |
|
||||||
*/ |
|
||||||
private EnergyPreEchartDataDTO echartData; |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,37 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 用能预测前端类 |
|
||||||
* @date 2024-05-09 17:31:27 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class EnergyPreEchartDataDTO { |
|
||||||
|
|
||||||
/** |
|
||||||
* 时间 |
|
||||||
*/ |
|
||||||
private String curDate; |
|
||||||
|
|
||||||
/** |
|
||||||
* 实际值 |
|
||||||
*/ |
|
||||||
private String curData; |
|
||||||
|
|
||||||
/** |
|
||||||
* 预测值 |
|
||||||
*/ |
|
||||||
private String preData; |
|
||||||
|
|
||||||
/** |
|
||||||
* 误差值 |
|
||||||
*/ |
|
||||||
private String errorData; |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,37 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 用能预测前端类 |
|
||||||
* @date 2024-05-09 17:31:27 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class EnergyPreTopDataDTO { |
|
||||||
|
|
||||||
/** |
|
||||||
* 昨日实际值 |
|
||||||
*/ |
|
||||||
private String yesData; |
|
||||||
|
|
||||||
/** |
|
||||||
* 昨日预测值 |
|
||||||
*/ |
|
||||||
private String preYesData; |
|
||||||
|
|
||||||
/** |
|
||||||
* 今日预测值 |
|
||||||
*/ |
|
||||||
private String curYesData; |
|
||||||
|
|
||||||
/** |
|
||||||
* 误差值 |
|
||||||
*/ |
|
||||||
private String errorData; |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,144 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 回水泵热泵控制界面VO |
|
||||||
* @date 2025-03-14 09:00:37 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterBackPumpControlVO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
// 定时_时开1
|
|
||||||
private int oneHourTimeOpenSetOne; |
|
||||||
private String oneHourTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 定时_分开1
|
|
||||||
private int oneMinTimeOpenSetOne; |
|
||||||
private String oneMinTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 定时_时关1
|
|
||||||
private int oneHourTimeCloseSetOne; |
|
||||||
private String oneHourTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 定时_分关1
|
|
||||||
private int oneMinTimeCloseSetOne; |
|
||||||
private String oneMinTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 定时_时开2
|
|
||||||
private int oneHourTimeOpenSetTwo; |
|
||||||
private String oneHourTimeOpenSetTwoId; |
|
||||||
|
|
||||||
// 定时_分开2
|
|
||||||
private int oneMinTimeOpenSetTwo; |
|
||||||
private String oneMinTimeOpenSetTwoId; |
|
||||||
|
|
||||||
// 定时_时关2
|
|
||||||
private int oneHourTimeCloseSetTwo; |
|
||||||
private String oneHourTimeCloseSetTwoId; |
|
||||||
|
|
||||||
// 定时_分关2
|
|
||||||
private int oneMinTimeCloseSetTwo; |
|
||||||
private String oneMinTimeCloseSetTwoId; |
|
||||||
|
|
||||||
// 定时_时开3
|
|
||||||
private int oneHourTimeOpenSetThree; |
|
||||||
private String oneHourTimeOpenSetThreeId; |
|
||||||
|
|
||||||
// 定时_分开3
|
|
||||||
private int oneMinTimeOpenSetThree; |
|
||||||
private String oneMinTimeOpenSetThreeId; |
|
||||||
|
|
||||||
// 定时_时关3
|
|
||||||
private int oneHourTimeCloseSetThree; |
|
||||||
private String oneHourTimeCloseSetThreeId; |
|
||||||
|
|
||||||
// 定时_分关3
|
|
||||||
private int oneMinTimeCloseSetThree; |
|
||||||
private String oneMinTimeCloseSetThreeId; |
|
||||||
|
|
||||||
// 开延时
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private int openDelayTime; |
|
||||||
private String openDelayTimeId; |
|
||||||
|
|
||||||
// 温度设置
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal tempSet; |
|
||||||
private String tempSetId; |
|
||||||
|
|
||||||
// 累计运行时间
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal runTime; |
|
||||||
private String runTimeId; |
|
||||||
|
|
||||||
// 运行状态
|
|
||||||
private int runState; |
|
||||||
private String runStateId; |
|
||||||
|
|
||||||
// 启停控制
|
|
||||||
private int startStopControl; |
|
||||||
private String startStopControlId; |
|
||||||
|
|
||||||
// 故障
|
|
||||||
private int fault; |
|
||||||
private String faultId; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterBackPumpControlVO.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.add("oneHourTimeOpenSetOne=" + oneHourTimeOpenSetOne) |
|
||||||
.add("oneHourTimeOpenSetOneId='" + oneHourTimeOpenSetOneId + "'") |
|
||||||
.add("oneMinTimeOpenSetOne=" + oneMinTimeOpenSetOne) |
|
||||||
.add("oneMinTimeOpenSetOneId='" + oneMinTimeOpenSetOneId + "'") |
|
||||||
.add("oneHourTimeCloseSetOne=" + oneHourTimeCloseSetOne) |
|
||||||
.add("oneHourTimeCloseSetOneId='" + oneHourTimeCloseSetOneId + "'") |
|
||||||
.add("oneMinTimeCloseSetOne=" + oneMinTimeCloseSetOne) |
|
||||||
.add("oneMinTimeCloseSetOneId='" + oneMinTimeCloseSetOneId + "'") |
|
||||||
.add("oneHourTimeOpenSetTwo=" + oneHourTimeOpenSetTwo) |
|
||||||
.add("oneHourTimeOpenSetTwoId='" + oneHourTimeOpenSetTwoId + "'") |
|
||||||
.add("oneMinTimeOpenSetTwo=" + oneMinTimeOpenSetTwo) |
|
||||||
.add("oneMinTimeOpenSetTwoId='" + oneMinTimeOpenSetTwoId + "'") |
|
||||||
.add("oneHourTimeCloseSetTwo=" + oneHourTimeCloseSetTwo) |
|
||||||
.add("oneHourTimeCloseSetTwoId='" + oneHourTimeCloseSetTwoId + "'") |
|
||||||
.add("oneMinTimeCloseSetTwo=" + oneMinTimeCloseSetTwo) |
|
||||||
.add("oneMinTimeCloseSetTwoId='" + oneMinTimeCloseSetTwoId + "'") |
|
||||||
.add("oneHourTimeOpenSetThree=" + oneHourTimeOpenSetThree) |
|
||||||
.add("oneHourTimeOpenSetThreeId='" + oneHourTimeOpenSetThreeId + "'") |
|
||||||
.add("oneMinTimeOpenSetThree=" + oneMinTimeOpenSetThree) |
|
||||||
.add("oneMinTimeOpenSetThreeId='" + oneMinTimeOpenSetThreeId + "'") |
|
||||||
.add("oneHourTimeCloseSetThree=" + oneHourTimeCloseSetThree) |
|
||||||
.add("oneHourTimeCloseSetThreeId='" + oneHourTimeCloseSetThreeId + "'") |
|
||||||
.add("openDelayTime=" + openDelayTime) |
|
||||||
.add("openDelayTimeId='" + openDelayTimeId + "'") |
|
||||||
.add("tempSet=" + tempSet) |
|
||||||
.add("tempSetId='" + tempSetId + "'") |
|
||||||
.add("runTime=" + runTime) |
|
||||||
.add("runTimeId='" + runTimeId + "'") |
|
||||||
.add("runState=" + runState) |
|
||||||
.add("runStateId='" + runStateId + "'") |
|
||||||
.add("startStopControl=" + startStopControl) |
|
||||||
.add("startStopControlId='" + startStopControlId + "'") |
|
||||||
.add("fault=" + fault) |
|
||||||
.add("faultId='" + faultId + "'") |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,104 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 热泵控制界面VO |
|
||||||
* @date 2025-03-14 09:00:37 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterCircuitPumpControlVO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
// 定时_时开1
|
|
||||||
private int oneHourTimeOpenSetOne; |
|
||||||
private String oneHourTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 定时_分开1
|
|
||||||
private int oneMinTimeOpenSetOne; |
|
||||||
private String oneMinTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 定时_时关1
|
|
||||||
private int oneHourTimeCloseSetOne; |
|
||||||
private String oneHourTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 定时_分关1
|
|
||||||
private int oneMinTimeCloseSetOne; |
|
||||||
private String oneMinTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 开延时
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private int openDelayTime; |
|
||||||
private String openDelayTimeId; |
|
||||||
|
|
||||||
// 温差
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal tempDiff; |
|
||||||
private String tempDiffId; |
|
||||||
|
|
||||||
// 温差设置
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal tempDiffSet; |
|
||||||
private String tempDiffSetId; |
|
||||||
|
|
||||||
// 累计运行时间
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal runTime; |
|
||||||
private String runTimeId; |
|
||||||
|
|
||||||
// 运行状态
|
|
||||||
private int runState; |
|
||||||
private String runStateId; |
|
||||||
|
|
||||||
// 启停控制
|
|
||||||
private int startStopControl; |
|
||||||
private String startStopControlId; |
|
||||||
|
|
||||||
// 故障
|
|
||||||
private int fault; |
|
||||||
private String faultId; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterCircuitPumpControlVO.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.add("oneHourTimeOpenSetOne=" + oneHourTimeOpenSetOne) |
|
||||||
.add("oneHourTimeOpenSetOneId='" + oneHourTimeOpenSetOneId + "'") |
|
||||||
.add("oneMinTimeOpenSetOne=" + oneMinTimeOpenSetOne) |
|
||||||
.add("oneMinTimeOpenSetOneId='" + oneMinTimeOpenSetOneId + "'") |
|
||||||
.add("oneHourTimeCloseSetOne=" + oneHourTimeCloseSetOne) |
|
||||||
.add("oneHourTimeCloseSetOneId='" + oneHourTimeCloseSetOneId + "'") |
|
||||||
.add("oneMinTimeCloseSetOne=" + oneMinTimeCloseSetOne) |
|
||||||
.add("oneMinTimeCloseSetOneId='" + oneMinTimeCloseSetOneId + "'") |
|
||||||
.add("tempDiff=" + tempDiff) |
|
||||||
.add("tempDiffId='" + tempDiffId + "'") |
|
||||||
.add("tempDiffSet=" + tempDiffSet) |
|
||||||
.add("tempDiffSetId='" + tempDiffSetId + "'") |
|
||||||
.add("runTime=" + runTime) |
|
||||||
.add("runTimeId='" + runTimeId + "'") |
|
||||||
.add("runState=" + runState) |
|
||||||
.add("runStateId='" + runStateId + "'") |
|
||||||
.add("startStopControl=" + startStopControl) |
|
||||||
.add("startStopControlId='" + startStopControlId + "'") |
|
||||||
.add("fault=" + fault) |
|
||||||
.add("faultId='" + faultId + "'") |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,38 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
import org.apache.poi.ss.formula.functions.T; |
|
||||||
|
|
||||||
import java.util.List; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 生活热水监控dto |
|
||||||
* @date 2025-03-14 09:13:19 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterControlDTO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
private List<?> children; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterControlDTO.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.add("children=" + children) |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,77 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 生活热水监控需要的列表信息 |
|
||||||
* @date 2025-03-14 09:07:46 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterControlListVO { |
|
||||||
|
|
||||||
private String cpmId; |
|
||||||
|
|
||||||
private String buildingId; |
|
||||||
|
|
||||||
private String buildingName; |
|
||||||
|
|
||||||
private String deviceType; |
|
||||||
|
|
||||||
private String deviceId; |
|
||||||
|
|
||||||
private String deviceName; |
|
||||||
|
|
||||||
private BigDecimal curValue; |
|
||||||
|
|
||||||
private Date curTime; |
|
||||||
|
|
||||||
private String paramTypeId; |
|
||||||
|
|
||||||
private String otherName; |
|
||||||
|
|
||||||
private int dtOrderNum; |
|
||||||
|
|
||||||
private int dlOrderNum; |
|
||||||
|
|
||||||
private int ctOrderNum; |
|
||||||
|
|
||||||
public BigDecimal getCurValue() { |
|
||||||
return curValue; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCurValue(BigDecimal curValue) { |
|
||||||
if (curValue!= null) { |
|
||||||
// 保留两位小数
|
|
||||||
curValue = curValue.setScale(2, BigDecimal.ROUND_HALF_UP); |
|
||||||
} |
|
||||||
this.curValue = curValue; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterControlListVO.class.getSimpleName() + "[", "]") |
|
||||||
.add("cpmId='" + cpmId + "'") |
|
||||||
.add("buildingId='" + buildingId + "'") |
|
||||||
.add("buildingName='" + buildingName + "'") |
|
||||||
.add("deviceType='" + deviceType + "'") |
|
||||||
.add("deviceId='" + deviceId + "'") |
|
||||||
.add("deviceName='" + deviceName + "'") |
|
||||||
.add("curValue=" + curValue) |
|
||||||
.add("curTime=" + curTime) |
|
||||||
.add("paramTypeId='" + paramTypeId + "'") |
|
||||||
.add("otherName='" + otherName + "'") |
|
||||||
.add("dtOrderNum=" + dtOrderNum) |
|
||||||
.add("dlOrderNum=" + dlOrderNum) |
|
||||||
.add("ctOrderNum=" + ctOrderNum) |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,186 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 生活热水系统控制界面VO |
|
||||||
* @date 2025-03-14 09:00:37 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterControlVO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
// 运行状态 1d
|
|
||||||
private int runningStatus; |
|
||||||
private String runningStatusId; |
|
||||||
|
|
||||||
// 启停控制 2
|
|
||||||
private int switchStatus; |
|
||||||
private String switchStatusId; |
|
||||||
|
|
||||||
// 频率设置 3
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal frequencySet; |
|
||||||
private String frequencySetId; |
|
||||||
|
|
||||||
// 频率 4
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal frequency; |
|
||||||
private String frequencyId; |
|
||||||
|
|
||||||
// 故障状态 5
|
|
||||||
private int alarmStatus; |
|
||||||
private String alarmStatusId; |
|
||||||
|
|
||||||
// 手动自动切换 6
|
|
||||||
private int handAutomaticSwitch; |
|
||||||
private String handAutomaticSwitchId; |
|
||||||
|
|
||||||
// 开控制 8
|
|
||||||
private int openSwitch; |
|
||||||
private String openSwitchId; |
|
||||||
|
|
||||||
// 关控制 9
|
|
||||||
private int closeSwitch; |
|
||||||
private String closeSwitchId; |
|
||||||
|
|
||||||
// 水位设置 10
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0") |
|
||||||
private BigDecimal waterLevelSet; |
|
||||||
private String waterLevelSetId; |
|
||||||
|
|
||||||
// 水位 11
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0") |
|
||||||
private BigDecimal waterLevel; |
|
||||||
private String waterLevelId; |
|
||||||
|
|
||||||
// 温度 12
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal temp; |
|
||||||
private String tempId; |
|
||||||
|
|
||||||
// 压力 13
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal pressure; |
|
||||||
private String pressureId; |
|
||||||
|
|
||||||
// 温度设置 14
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal tempSet; |
|
||||||
private String tempSetId; |
|
||||||
|
|
||||||
// 压力设置 15
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal pressureSet; |
|
||||||
private String pressureSetId; |
|
||||||
|
|
||||||
// 延时时间设置 34
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal delayTimeSet; |
|
||||||
private String delayTimeSetId; |
|
||||||
|
|
||||||
// 差值设置 35
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal diffValueSet; |
|
||||||
private String diffValueSetId; |
|
||||||
|
|
||||||
// 计数器设置 36
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal counterSet; |
|
||||||
private String counterSetId; |
|
||||||
|
|
||||||
// 切换时间设置 37
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal switchTimeSet; |
|
||||||
private String switchTimeSetId; |
|
||||||
|
|
||||||
// 故障复位状态 38
|
|
||||||
private int faultResetStatus; |
|
||||||
private String faultResetStatusId; |
|
||||||
|
|
||||||
// 急停状态 39
|
|
||||||
private int emergencyStopStatus; |
|
||||||
private String emergencyStopStatusId; |
|
||||||
|
|
||||||
// 最低设置值 44
|
|
||||||
private int minSet; |
|
||||||
private String minSetId; |
|
||||||
|
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
private Date curTime; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
public void setCounterSet(BigDecimal counterSet) { |
|
||||||
if (counterSet != null) { |
|
||||||
counterSet = counterSet.setScale(0, BigDecimal.ROUND_HALF_UP); |
|
||||||
} |
|
||||||
this.counterSet = counterSet; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterControlVO.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("runningStatus=" + runningStatus) |
|
||||||
.add("runningStatusId='" + runningStatusId + "'") |
|
||||||
.add("switchStatus=" + switchStatus) |
|
||||||
.add("switchStatusId='" + switchStatusId + "'") |
|
||||||
.add("frequencySet=" + frequencySet) |
|
||||||
.add("frequencySetId='" + frequencySetId + "'") |
|
||||||
.add("frequency=" + frequency) |
|
||||||
.add("frequencyId='" + frequencyId + "'") |
|
||||||
.add("alarmStatus=" + alarmStatus) |
|
||||||
.add("alarmStatusId='" + alarmStatusId + "'") |
|
||||||
.add("handAutomaticSwitch=" + handAutomaticSwitch) |
|
||||||
.add("handAutomaticSwitchId='" + handAutomaticSwitchId + "'") |
|
||||||
.add("openSwitch=" + openSwitch) |
|
||||||
.add("openSwitchId='" + openSwitchId + "'") |
|
||||||
.add("closeSwitch=" + closeSwitch) |
|
||||||
.add("closeSwitchId='" + closeSwitchId + "'") |
|
||||||
.add("waterLevelSet=" + waterLevelSet) |
|
||||||
.add("waterLevelSetId='" + waterLevelSetId + "'") |
|
||||||
.add("waterLevel=" + waterLevel) |
|
||||||
.add("waterLevelId='" + waterLevelId + "'") |
|
||||||
.add("temp=" + temp) |
|
||||||
.add("tempId='" + tempId + "'") |
|
||||||
.add("pressure=" + pressure) |
|
||||||
.add("pressureId='" + pressureId + "'") |
|
||||||
.add("tempSet=" + tempSet) |
|
||||||
.add("tempSetId='" + tempSetId + "'") |
|
||||||
.add("pressureSet=" + pressureSet) |
|
||||||
.add("pressureSetId='" + pressureSetId + "'") |
|
||||||
.add("delayTimeSet=" + delayTimeSet) |
|
||||||
.add("delayTimeSetId='" + delayTimeSetId + "'") |
|
||||||
.add("diffValueSet=" + diffValueSet) |
|
||||||
.add("diffValueSetId='" + diffValueSetId + "'") |
|
||||||
.add("counterSet=" + counterSet) |
|
||||||
.add("counterSetId='" + counterSetId + "'") |
|
||||||
.add("switchTimeSet=" + switchTimeSet) |
|
||||||
.add("switchTimeSetId='" + switchTimeSetId + "'") |
|
||||||
.add("faultResetStatus=" + faultResetStatus) |
|
||||||
.add("faultResetStatusId='" + faultResetStatusId + "'") |
|
||||||
.add("emergencyStopStatus=" + emergencyStopStatus) |
|
||||||
.add("emergencyStopStatusId='" + emergencyStopStatusId + "'") |
|
||||||
.add("minSet=" + minSet) |
|
||||||
.add("minSetId='" + minSetId + "'") |
|
||||||
.add("curTime=" + curTime) |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,71 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 设备校准控制界面VO |
|
||||||
* @date 2025-03-14 09:00:37 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterDeviceCalibrationControlVO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
// 校准值
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal calibrationValue; |
|
||||||
private String calibrationValueId; |
|
||||||
|
|
||||||
// 工程量最低值
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal engineeringMinValue; |
|
||||||
private String engineeringMinValueId; |
|
||||||
|
|
||||||
// 工程量最高值
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal engineeringMaxValue; |
|
||||||
private String engineeringMaxValueId; |
|
||||||
|
|
||||||
// 数字量最低值
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal digitalMinValue; |
|
||||||
private String digitalMinValueId; |
|
||||||
|
|
||||||
// 数字量最高值
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal digitalMaxValue; |
|
||||||
private String digitalMaxValueId; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterDeviceCalibrationControlVO.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.add("calibrationValue=" + calibrationValue) |
|
||||||
.add("calibrationValueId='" + calibrationValueId + "'") |
|
||||||
.add("engineeringMinValue=" + engineeringMinValue) |
|
||||||
.add("engineeringMinValueId='" + engineeringMinValueId + "'") |
|
||||||
.add("engineeringMaxValue=" + engineeringMaxValue) |
|
||||||
.add("engineeringMaxValueId='" + engineeringMaxValueId + "'") |
|
||||||
.add("digitalMinValue=" + digitalMinValue) |
|
||||||
.add("digitalMinValueId='" + digitalMinValueId + "'") |
|
||||||
.add("digitalMaxValue=" + digitalMaxValue) |
|
||||||
.add("digitalMaxValueId='" + digitalMaxValueId + "'") |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,43 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 生活热水系统控制界面VO |
|
||||||
* @date 2025-03-14 09:00:37 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterDeviceControlVO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
// 累计读数
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING) |
|
||||||
private BigDecimal totalReading; |
|
||||||
private String totalReadingId; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterDeviceControlVO.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.add("totalReading=" + totalReading) |
|
||||||
.add("totalReadingId='" + totalReadingId + "'") |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,241 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 热泵控制界面VO |
|
||||||
* @date 2025-03-14 09:00:37 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterHotPumpControlVO { // 去掉pump后的类名
|
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
// 热泵12定时_时开1
|
|
||||||
private int oneHourTimeOpenSetOne; |
|
||||||
private String oneHourTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 热泵12定时_分开1 (新增分钟设置)
|
|
||||||
private int oneMinTimeOpenSetOne; |
|
||||||
private String oneMinTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 热泵12定时_时关1
|
|
||||||
private int oneHourTimeCloseSetOne; |
|
||||||
private String oneHourTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 热泵12定时_分关1 (新增分钟设置)
|
|
||||||
private int oneMinTimeCloseSetOne; |
|
||||||
private String oneMinTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 热泵12定时_时开2
|
|
||||||
private int oneHourTimeOpenSetTwo; |
|
||||||
private String oneHourTimeOpenSetTwoId; |
|
||||||
|
|
||||||
// 热泵12定时_分开2 (新增分钟设置)
|
|
||||||
private int oneMinTimeOpenSetTwo; |
|
||||||
private String oneMinTimeOpenSetTwoId; |
|
||||||
|
|
||||||
// 热泵12定时_时关2
|
|
||||||
private int oneHourTimeCloseSetTwo; |
|
||||||
private String oneHourTimeCloseSetTwoId; |
|
||||||
|
|
||||||
// 热泵12定时_分关2 (新增分钟设置)
|
|
||||||
private int oneMinTimeCloseSetTwo; |
|
||||||
private String oneMinTimeCloseSetTwoId; |
|
||||||
|
|
||||||
// 热泵12定时_时开3
|
|
||||||
private int oneHourTimeOpenSetThree; |
|
||||||
private String oneHourTimeOpenSetThreeId; |
|
||||||
|
|
||||||
// 热泵12定时_分开3 (新增分钟设置)
|
|
||||||
private int oneMinTimeOpenSetThree; |
|
||||||
private String oneMinTimeOpenSetThreeId; |
|
||||||
|
|
||||||
// 热泵12定时_时关3
|
|
||||||
private int oneHourTimeCloseSetThree; |
|
||||||
private String oneHourTimeCloseSetThreeId; |
|
||||||
|
|
||||||
// 热泵12定时_分关3 (新增分钟设置)
|
|
||||||
private int oneMinTimeCloseSetThree; |
|
||||||
private String oneMinTimeCloseSetThreeId; |
|
||||||
|
|
||||||
// 热泵12定时_时开1
|
|
||||||
private int twoHourTimeOpenSetOne; |
|
||||||
private String twoHourTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 热泵34定时_分开1 (新增分钟设置)
|
|
||||||
private int twoMinTimeOpenSetOne; |
|
||||||
private String twoMinTimeOpenSetOneId; |
|
||||||
|
|
||||||
// 热泵34定时_时关1
|
|
||||||
private int twoHourTimeCloseSetOne; |
|
||||||
private String twoHourTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 热泵34定时_分关1 (新增分钟设置)
|
|
||||||
private int twoMinTimeCloseSetOne; |
|
||||||
private String twoMinTimeCloseSetOneId; |
|
||||||
|
|
||||||
// 热泵34定时_时开2
|
|
||||||
private int twoHourTimeOpenSetTwo; |
|
||||||
private String twoHourTimeOpenSetTwoId; |
|
||||||
|
|
||||||
// 热泵34定时_分开2 (新增分钟设置)
|
|
||||||
private int twoMinTimeOpenSetTwo; |
|
||||||
private String twoMinTimeOpenSetTwoId; |
|
||||||
|
|
||||||
// 热泵34定时_时关2
|
|
||||||
private int twoHourTimeCloseSetTwo; |
|
||||||
private String twoHourTimeCloseSetTwoId; |
|
||||||
|
|
||||||
// 热泵34定时_分关2 (新增分钟设置)
|
|
||||||
private int twoMinTimeCloseSetTwo; |
|
||||||
private String twoMinTimeCloseSetTwoId; |
|
||||||
|
|
||||||
// 热泵34定时_时开3
|
|
||||||
private int twoHourTimeOpenSetThree; |
|
||||||
private String twoHourTimeOpenSetThreeId; |
|
||||||
|
|
||||||
// 热泵34定时_分开3 (新增分钟设置)
|
|
||||||
private int twoMinTimeOpenSetThree; |
|
||||||
private String twoMinTimeOpenSetThreeId; |
|
||||||
|
|
||||||
// 热泵34定时_时关3
|
|
||||||
private int twoHourTimeCloseSetThree; |
|
||||||
private String twoHourTimeCloseSetThreeId; |
|
||||||
|
|
||||||
// 热泵34定时_分关3 (新增分钟设置)
|
|
||||||
private int twoMinTimeCloseSetThree; |
|
||||||
private String twoMinTimeCloseSetThreeId; |
|
||||||
|
|
||||||
// 热泵_开机 -> 去掉pump前缀
|
|
||||||
private String start; |
|
||||||
private String startId; |
|
||||||
|
|
||||||
// 热泵_关机 -> 去掉pump前缀
|
|
||||||
private String stop; |
|
||||||
private String stopId; |
|
||||||
|
|
||||||
// 热泵_运行状态 -> 去掉pump前缀
|
|
||||||
private int runState; |
|
||||||
private String runStateId; |
|
||||||
|
|
||||||
// 热泵_启停控制 -> 去掉pump前缀
|
|
||||||
private int startStopControl; |
|
||||||
private String startStopControlId; |
|
||||||
|
|
||||||
// 热泵_设定温度 -> 去掉pump前缀
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal setTemp; |
|
||||||
private String setTempId; |
|
||||||
|
|
||||||
// 热泵_水箱温度 -> 去掉pump前缀
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal tankTemp; |
|
||||||
private String tankTempId; |
|
||||||
|
|
||||||
// 热泵累计运行时间 -> 去掉pump前缀
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal runTime; |
|
||||||
private String runTimeId; |
|
||||||
|
|
||||||
// 热泵_出水温度 -> 去掉pump前缀
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal outWaterTemp; |
|
||||||
private String outWaterTempId; |
|
||||||
|
|
||||||
// 热泵_进水温度 -> 去掉pump前缀
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal inWaterTemp; |
|
||||||
private String inWaterTempId; |
|
||||||
|
|
||||||
// 热泵_故障 -> 去掉pump前缀
|
|
||||||
private int fault; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterHotPumpControlVO.class.getSimpleName() + "[", "]") // 更新类名引用
|
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("oneHourTimeOpenSetOne=" + oneHourTimeOpenSetOne) |
|
||||||
.add("oneHourTimeOpenSetOneId='" + oneHourTimeOpenSetOneId + "'") |
|
||||||
.add("oneMinTimeOpenSetOne=" + oneMinTimeOpenSetOne) // 新增分钟字段
|
|
||||||
.add("oneMinTimeOpenSetOneId='" + oneMinTimeOpenSetOneId + "'") // 新增分钟字段
|
|
||||||
.add("oneHourTimeCloseSetOne=" + oneHourTimeCloseSetOne) |
|
||||||
.add("oneHourTimeCloseSetOneId='" + oneHourTimeCloseSetOneId + "'") |
|
||||||
.add("oneMinTimeCloseSetOne=" + oneMinTimeCloseSetOne) // 新增分钟字段
|
|
||||||
.add("oneMinTimeCloseSetOneId='" + oneMinTimeCloseSetOneId + "'") // 新增分钟字段
|
|
||||||
.add("oneHourTimeOpenSetTwo=" + oneHourTimeOpenSetTwo) |
|
||||||
.add("oneHourTimeOpenSetTwoId='" + oneHourTimeOpenSetTwoId + "'") |
|
||||||
.add("oneMinTimeOpenSetTwo=" + oneMinTimeOpenSetTwo) // 新增分钟字段
|
|
||||||
.add("oneMinTimeOpenSetTwoId='" + oneMinTimeOpenSetTwoId + "'") // 新增分钟字段
|
|
||||||
.add("oneHourTimeCloseSetTwo=" + oneHourTimeCloseSetTwo) |
|
||||||
.add("oneHourTimeCloseSetTwoId='" + oneHourTimeCloseSetTwoId + "'") |
|
||||||
.add("oneMinTimeCloseSetTwo=" + oneMinTimeCloseSetTwo) // 新增分钟字段
|
|
||||||
.add("oneMinTimeCloseSetTwoId='" + oneMinTimeCloseSetTwoId + "'") // 新增分钟字段
|
|
||||||
.add("oneHourTimeOpenSetThree=" + oneHourTimeOpenSetThree) |
|
||||||
.add("oneHourTimeOpenSetThreeId='" + oneHourTimeOpenSetThreeId + "'") |
|
||||||
.add("oneMinTimeOpenSetThree=" + oneMinTimeOpenSetThree) // 新增分钟字段
|
|
||||||
.add("oneMinTimeOpenSetThreeId='" + oneMinTimeOpenSetThreeId + "'") // 新增分钟字段
|
|
||||||
.add("oneHourTimeCloseSetThree=" + oneHourTimeCloseSetThree) |
|
||||||
.add("oneHourTimeCloseSetThreeId='" + oneHourTimeCloseSetThreeId + "'") |
|
||||||
.add("oneMinTimeCloseSetThree=" + oneMinTimeCloseSetThree) // 新增分钟字段
|
|
||||||
.add("oneMinTimeCloseSetThreeId='" + oneMinTimeCloseSetThreeId + "'") // 新增分钟字段
|
|
||||||
.add("twoHourTimeOpenSetOne=" + twoHourTimeOpenSetOne) |
|
||||||
.add("twoHourTimeOpenSetOneId='" + twoHourTimeOpenSetOneId + "'") |
|
||||||
.add("twoMinTimeOpenSetOne=" + twoMinTimeOpenSetOne) // 新增分钟字段
|
|
||||||
.add("twoMinTimeOpenSetOneId='" + twoMinTimeOpenSetOneId + "'") // 新增分钟字段
|
|
||||||
.add("twoHourTimeCloseSetOne=" + twoHourTimeCloseSetOne) |
|
||||||
.add("twoHourTimeCloseSetOneId='" + twoHourTimeCloseSetOneId + "'") |
|
||||||
.add("twoMinTimeCloseSetOne=" + twoMinTimeCloseSetOne) // 新增分钟字段
|
|
||||||
.add("twoMinTimeCloseSetOneId='" + twoMinTimeCloseSetOneId + "'") // 新增分钟字段
|
|
||||||
.add("twoHourTimeOpenSetTwo=" + twoHourTimeOpenSetTwo) |
|
||||||
.add("twoHourTimeOpenSetTwoId='" + twoHourTimeOpenSetTwoId + "'") |
|
||||||
.add("twoMinTimeOpenSetTwo=" + twoMinTimeOpenSetTwo) // 新增分钟字段
|
|
||||||
.add("twoMinTimeOpenSetTwoId='" + twoMinTimeOpenSetTwoId + "'") // 新增分钟字段
|
|
||||||
.add("twoHourTimeCloseSetTwo=" + twoHourTimeCloseSetTwo) |
|
||||||
.add("twoHourTimeCloseSetTwoId='" + twoHourTimeCloseSetTwoId + "'") |
|
||||||
.add("twoMinTimeCloseSetTwo=" + twoMinTimeCloseSetTwo) // 新增分钟字段
|
|
||||||
.add("twoMinTimeCloseSetTwoId='" + twoMinTimeCloseSetTwoId + "'") // 新增分钟字段
|
|
||||||
.add("twoHourTimeOpenSetThree=" + twoHourTimeOpenSetThree) |
|
||||||
.add("twoHourTimeOpenSetThreeId='" + twoHourTimeOpenSetThreeId + "'") |
|
||||||
.add("twoMinTimeOpenSetThree=" + twoMinTimeOpenSetThree) // 新增分钟字段
|
|
||||||
.add("twoMinTimeOpenSetThreeId='" + twoMinTimeOpenSetThreeId + "'") // 新增分钟字段
|
|
||||||
.add("twoHourTimeCloseSetThree=" + twoHourTimeCloseSetThree) |
|
||||||
.add("twoHourTimeCloseSetThreeId='" + twoHourTimeCloseSetThreeId + "'") |
|
||||||
.add("twoMinTimeCloseSetThree=" + twoMinTimeCloseSetThree) // 新增分钟字段
|
|
||||||
.add("twoMinTimeCloseSetThreeId='" + twoMinTimeCloseSetThreeId + "'") // 新增分钟字段
|
|
||||||
.add("start='" + start + "'") |
|
||||||
.add("startId='" + startId + "'") |
|
||||||
.add("stop='" + stop + "'") |
|
||||||
.add("stopId='" + stopId + "'") |
|
||||||
.add("runState='" + runState + "'") |
|
||||||
.add("runStateId='" + runStateId + "'") |
|
||||||
.add("startStopControl='" + startStopControl + "'") |
|
||||||
.add("startStopControlId='" + startStopControlId + "'") |
|
||||||
.add("setTemp=" + setTemp) |
|
||||||
.add("setTempId='" + setTempId + "'") |
|
||||||
.add("tankTemp=" + tankTemp) |
|
||||||
.add("tankTempId='" + tankTempId + "'") |
|
||||||
.add("runTime=" + runTime) |
|
||||||
.add("runTimeId='" + runTimeId + "'") |
|
||||||
.add("outWaterTemp=" + outWaterTemp) |
|
||||||
.add("outWaterTempId='" + outWaterTempId + "'") |
|
||||||
.add("inWaterTemp=" + inWaterTemp) |
|
||||||
.add("inWaterTempId='" + inWaterTempId + "'") |
|
||||||
.add("fault=" + fault) |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,55 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 热水实时监控列表数据 |
|
||||||
* @date 2025-03-10 15:43:36 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
public class HotWaterNowDataDTO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
private String curDate; //日期
|
|
||||||
private String buildingId; //楼栋编号
|
|
||||||
private String buildingName; //楼栋名称
|
|
||||||
private String pumpId; //热泵编号
|
|
||||||
private String pumpName; //热泵名称
|
|
||||||
private String tempSet; //水温设定
|
|
||||||
private String waterTemp; //水箱水温
|
|
||||||
private String runState; //运行状态
|
|
||||||
private String isFault; //是否故障
|
|
||||||
private String levelSet1; //水位设置
|
|
||||||
private String levelSet2; //水位设置
|
|
||||||
private String waterLevel1; //实际水位
|
|
||||||
private String waterLevel2; //实际水位
|
|
||||||
private String tankId; //水箱编号
|
|
||||||
private String tankName; //水箱名称
|
|
||||||
private String envTemp; //环境温度
|
|
||||||
|
|
||||||
private String upWaterState1; // 供水1泵状态
|
|
||||||
|
|
||||||
private String freq1; // 供水频率1
|
|
||||||
|
|
||||||
private String upWaterState2; // 供水2泵状态
|
|
||||||
|
|
||||||
private String freq2; // 供水频率2
|
|
||||||
|
|
||||||
private String upWaterState3; // 供水3泵状态
|
|
||||||
|
|
||||||
private String freq3; // 供水频率3
|
|
||||||
|
|
||||||
private String upWaterState4; // 供水4泵状态
|
|
||||||
|
|
||||||
private String freq4; // 供水频率4
|
|
||||||
|
|
||||||
private String useWaterState; // 补水状态
|
|
||||||
|
|
||||||
private String backWaterState; // 回水状态
|
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,145 +0,0 @@ |
|||||||
package com.mh.user.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description 生活热水系统控制界面VO |
|
||||||
* @date 2025-03-14 09:00:37 |
|
||||||
*/ |
|
||||||
@Setter |
|
||||||
@Getter |
|
||||||
public class HotWaterSystemControlVO { |
|
||||||
|
|
||||||
private String id; |
|
||||||
|
|
||||||
private String name; |
|
||||||
|
|
||||||
// 启用时间写入 1
|
|
||||||
private int timeSet; |
|
||||||
private String timeSetId; |
|
||||||
|
|
||||||
// 水箱温度 2
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal tankTemp; |
|
||||||
private String tankTempId; |
|
||||||
|
|
||||||
// 太阳能温度 3
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal solarTemp; |
|
||||||
private String solarTempId; |
|
||||||
|
|
||||||
// 回水温度 4
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal inTemp; |
|
||||||
private String inTempId; |
|
||||||
|
|
||||||
// 压力 4
|
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
|
||||||
private BigDecimal pressure; |
|
||||||
private String pressureId; |
|
||||||
|
|
||||||
// PLC 时间
|
|
||||||
private String plcTime; |
|
||||||
// 秒_读 6
|
|
||||||
private int sTimeRead; |
|
||||||
private String sTimeReadId; |
|
||||||
|
|
||||||
// 分_读 8
|
|
||||||
private int minTimeRead; |
|
||||||
private String minTimeReadId; |
|
||||||
|
|
||||||
// 时_读 9
|
|
||||||
private int hourTimeRead; |
|
||||||
private String hourTimeReadId; |
|
||||||
|
|
||||||
// 日_读 9
|
|
||||||
private int dayTimeRead; |
|
||||||
private String dayTimeReadId; |
|
||||||
|
|
||||||
// 月_读 10
|
|
||||||
private int monthTimeRead; |
|
||||||
private String monthTimeReadId; |
|
||||||
|
|
||||||
// 年_读 11
|
|
||||||
private int yearTimeRead; |
|
||||||
private String yearTimeReadId; |
|
||||||
|
|
||||||
// 秒_写 6
|
|
||||||
private int sTimeSet; |
|
||||||
private String sTimeSetId; |
|
||||||
|
|
||||||
// 分_写 8
|
|
||||||
private int minTimeSet; |
|
||||||
private String minTimeSetId; |
|
||||||
|
|
||||||
// 时_写 9
|
|
||||||
private int hourTimeSet; |
|
||||||
private String hourTimeSetId; |
|
||||||
|
|
||||||
// 日_写 9
|
|
||||||
private int dayTimeSet; |
|
||||||
private String dayTimeSetId; |
|
||||||
|
|
||||||
// 月_写 10
|
|
||||||
private int monthTimeSet; |
|
||||||
private String monthTimeSetId; |
|
||||||
|
|
||||||
// 年_写 11
|
|
||||||
private int yearTimeSet; |
|
||||||
private String yearTimeSetId; |
|
||||||
|
|
||||||
private int orderNum; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", HotWaterSystemControlVO.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("timeSet=" + timeSet) |
|
||||||
.add("timeSetId='" + timeSetId + "'") |
|
||||||
.add("tankTemp=" + tankTemp) |
|
||||||
.add("tankTempId='" + tankTempId + "'") |
|
||||||
.add("solarTemp=" + solarTemp) |
|
||||||
.add("solarTempId='" + solarTempId + "'") |
|
||||||
.add("inTemp=" + inTemp) |
|
||||||
.add("inTempId='" + inTempId + "'") |
|
||||||
.add("pressure=" + pressure) |
|
||||||
.add("pressureId='" + pressureId + "'") |
|
||||||
.add("plcTime='" + plcTime + "'") |
|
||||||
.add("sTimeRead=" + sTimeRead) |
|
||||||
.add("sTimeReadId='" + sTimeReadId + "'") |
|
||||||
.add("minTimeRead=" + minTimeRead) |
|
||||||
.add("minTimeReadId='" + minTimeReadId + "'") |
|
||||||
.add("hourTimeRead=" + hourTimeRead) |
|
||||||
.add("hourTimeReadId='" + hourTimeReadId + "'") |
|
||||||
.add("dayTimeRead=" + dayTimeRead) |
|
||||||
.add("dayTimeReadId='" + dayTimeReadId + "'") |
|
||||||
.add("monthTimeRead=" + monthTimeRead) |
|
||||||
.add("monthTimeReadId='" + monthTimeReadId + "'") |
|
||||||
.add("yearTimeRead=" + yearTimeRead) |
|
||||||
.add("yearTimeReadId='" + yearTimeReadId + "'") |
|
||||||
.add("sTimeSet=" + sTimeSet) |
|
||||||
.add("sTimeSetId='" + sTimeSetId + "'") |
|
||||||
.add("minTimeSet=" + minTimeSet) |
|
||||||
.add("minTimeSetId='" + minTimeSetId + "'") |
|
||||||
.add("hourTimeSet=" + hourTimeSet) |
|
||||||
.add("hourTimeSetId='" + hourTimeSetId + "'") |
|
||||||
.add("dayTimeSet=" + dayTimeSet) |
|
||||||
.add("dayTimeSetId='" + dayTimeSetId + "'") |
|
||||||
.add("monthTimeSet=" + monthTimeSet) |
|
||||||
.add("monthTimeSetId='" + monthTimeSetId + "'") |
|
||||||
.add("yearTimeSet=" + yearTimeSet) |
|
||||||
.add("yearTimeSetId='" + yearTimeSetId + "'") |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,108 +0,0 @@ |
|||||||
package com.mh.user.entity; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
import org.springframework.format.annotation.DateTimeFormat; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.time.LocalDateTime; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 采集参数实体类 |
|
||||||
* @date 2025-12-10 10:53:33 |
|
||||||
*/ |
|
||||||
@Getter |
|
||||||
@Setter |
|
||||||
public class CollectionParamsManageEntity implements Serializable { |
|
||||||
|
|
||||||
static final long serialVersionUID = 42L; |
|
||||||
|
|
||||||
private Long id; |
|
||||||
|
|
||||||
/** 当前时间 */ |
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
private Date createTime; |
|
||||||
|
|
||||||
/** 当前时间 */ |
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
private Date updateTime; |
|
||||||
private Long buildingId; |
|
||||||
/** 设备id */ |
|
||||||
private Long deviceInstallId; |
|
||||||
/** 寄存器地址 */ |
|
||||||
private String registerAddr; |
|
||||||
/** 功能码 */ |
|
||||||
private String funcCode; |
|
||||||
/** 倍率 */ |
|
||||||
private Integer mtRatio; |
|
||||||
/** 初始值 */ |
|
||||||
private BigDecimal mtInitValue; |
|
||||||
/** 小数点 */ |
|
||||||
private Integer digits; |
|
||||||
/** 数据类型 */ |
|
||||||
private Integer dataType; |
|
||||||
/** 当前值 */ |
|
||||||
private BigDecimal curValue; |
|
||||||
/** 当前时间 */ |
|
||||||
/** 当前时间 */ |
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
private Date curTime; |
|
||||||
/** 是否是总表 (0: 是, 1: 否) */ |
|
||||||
private Integer mtIsSum; |
|
||||||
/** 单位 */ |
|
||||||
private String unit; |
|
||||||
/** 排序 */ |
|
||||||
private Long orderNum; |
|
||||||
/** 备注 */ |
|
||||||
private String remark; |
|
||||||
/** 读取的寄存器大小 */ |
|
||||||
private Integer registerSize; |
|
||||||
/** 是否使用 */ |
|
||||||
private Integer isUse; |
|
||||||
/** 别名:mqtt上传名,唯一值 */ |
|
||||||
private String otherName; |
|
||||||
/** 40,累计值,140瞬时值 */ |
|
||||||
private Integer grade; |
|
||||||
/** 参数id */ |
|
||||||
private Integer paramTypeId; |
|
||||||
/** 遥测、遥信数据类型 */ |
|
||||||
private Integer collectionType; |
|
||||||
/** 上报质量 */ |
|
||||||
private String quality; |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", CollectionParamsManageEntity.class.getSimpleName() + "[", "]") |
|
||||||
.add("deviceInstallId=" + deviceInstallId) |
|
||||||
.add("registerAddr='" + registerAddr + "'") |
|
||||||
.add("funcCode='" + funcCode + "'") |
|
||||||
.add("mtRatio=" + mtRatio) |
|
||||||
.add("mtInitValue=" + mtInitValue) |
|
||||||
.add("digits=" + digits) |
|
||||||
.add("dataType=" + dataType) |
|
||||||
.add("curValue=" + curValue) |
|
||||||
.add("curTime=" + curTime) |
|
||||||
.add("mtIsSum=" + mtIsSum) |
|
||||||
.add("unit='" + unit + "'") |
|
||||||
.add("orderNum=" + orderNum) |
|
||||||
.add("remark='" + remark + "'") |
|
||||||
.add("registerSize=" + registerSize) |
|
||||||
.add("isUse=" + isUse) |
|
||||||
.add("otherName='" + otherName + "'") |
|
||||||
.add("grade=" + grade) |
|
||||||
.add("paramTypeId=" + paramTypeId) |
|
||||||
.add("collectionType=" + collectionType) |
|
||||||
.add("quality='" + quality + "'") |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,168 +0,0 @@ |
|||||||
package com.mh.user.entity; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
|
|
||||||
import java.math.BigDecimal; |
|
||||||
import java.util.Date; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 历史预测数据表 |
|
||||||
* @date 2024-05-09 09:55:09 |
|
||||||
*/ |
|
||||||
public class HistoryDataPre { |
|
||||||
|
|
||||||
private Long id; |
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|
||||||
private Date curDate; |
|
||||||
|
|
||||||
private String buildingId; |
|
||||||
|
|
||||||
private BigDecimal envMinTemp; |
|
||||||
|
|
||||||
private BigDecimal envMaxTemp; |
|
||||||
|
|
||||||
private BigDecimal waterValue; |
|
||||||
|
|
||||||
private BigDecimal electValue; |
|
||||||
|
|
||||||
private BigDecimal waterLevel; |
|
||||||
|
|
||||||
/** |
|
||||||
* 每栋楼人数 |
|
||||||
*/ |
|
||||||
private BigDecimal peopleNum; |
|
||||||
|
|
||||||
private BigDecimal waterValuePre; |
|
||||||
|
|
||||||
private BigDecimal electValuePre; |
|
||||||
|
|
||||||
private BigDecimal waterLevelPre; |
|
||||||
|
|
||||||
private String remark; |
|
||||||
|
|
||||||
public BigDecimal getPeopleNum() { |
|
||||||
return peopleNum; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPeopleNum(BigDecimal peopleNum) { |
|
||||||
this.peopleNum = peopleNum; |
|
||||||
} |
|
||||||
|
|
||||||
public Long getId() { |
|
||||||
return id; |
|
||||||
} |
|
||||||
|
|
||||||
public void setId(Long id) { |
|
||||||
this.id = id; |
|
||||||
} |
|
||||||
|
|
||||||
public Date getCurDate() { |
|
||||||
return curDate; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCurDate(Date curDate) { |
|
||||||
this.curDate = curDate; |
|
||||||
} |
|
||||||
|
|
||||||
public String getBuildingId() { |
|
||||||
return buildingId; |
|
||||||
} |
|
||||||
|
|
||||||
public void setBuildingId(String buildingId) { |
|
||||||
this.buildingId = buildingId; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getEnvMinTemp() { |
|
||||||
return envMinTemp; |
|
||||||
} |
|
||||||
|
|
||||||
public void setEnvMinTemp(BigDecimal envMinTemp) { |
|
||||||
this.envMinTemp = envMinTemp; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getEnvMaxTemp() { |
|
||||||
return envMaxTemp; |
|
||||||
} |
|
||||||
|
|
||||||
public void setEnvMaxTemp(BigDecimal envMaxTemp) { |
|
||||||
this.envMaxTemp = envMaxTemp; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getWaterValue() { |
|
||||||
return waterValue; |
|
||||||
} |
|
||||||
|
|
||||||
public void setWaterValue(BigDecimal waterValue) { |
|
||||||
this.waterValue = waterValue; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getElectValue() { |
|
||||||
return electValue; |
|
||||||
} |
|
||||||
|
|
||||||
public void setElectValue(BigDecimal electValue) { |
|
||||||
this.electValue = electValue; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getWaterLevel() { |
|
||||||
return waterLevel; |
|
||||||
} |
|
||||||
|
|
||||||
public void setWaterLevel(BigDecimal waterLevel) { |
|
||||||
this.waterLevel = waterLevel; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getWaterValuePre() { |
|
||||||
return waterValuePre; |
|
||||||
} |
|
||||||
|
|
||||||
public void setWaterValuePre(BigDecimal waterValuePre) { |
|
||||||
this.waterValuePre = waterValuePre; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getElectValuePre() { |
|
||||||
return electValuePre; |
|
||||||
} |
|
||||||
|
|
||||||
public void setElectValuePre(BigDecimal electValuePre) { |
|
||||||
this.electValuePre = electValuePre; |
|
||||||
} |
|
||||||
|
|
||||||
public BigDecimal getWaterLevelPre() { |
|
||||||
return waterLevelPre; |
|
||||||
} |
|
||||||
|
|
||||||
public void setWaterLevelPre(BigDecimal waterLevelPre) { |
|
||||||
this.waterLevelPre = waterLevelPre; |
|
||||||
} |
|
||||||
|
|
||||||
public String getRemark() { |
|
||||||
return remark; |
|
||||||
} |
|
||||||
|
|
||||||
public void setRemark(String remark) { |
|
||||||
this.remark = remark; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "HistoryDataPre{" + |
|
||||||
"id=" + id + |
|
||||||
", curDate=" + curDate + |
|
||||||
", buildingId='" + buildingId + '\'' + |
|
||||||
", envMinTemp=" + envMinTemp + |
|
||||||
", envMaxTemp=" + envMaxTemp + |
|
||||||
", waterValue=" + waterValue + |
|
||||||
", electValue=" + electValue + |
|
||||||
", waterLevel=" + waterLevel + |
|
||||||
", waterValuePre=" + waterValuePre + |
|
||||||
", electValuePre=" + electValuePre + |
|
||||||
", waterLevelPre=" + waterLevelPre + |
|
||||||
", remark='" + remark + '\'' + |
|
||||||
'}'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,38 +0,0 @@ |
|||||||
package com.mh.user.entity; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank; |
|
||||||
import java.io.Serializable; |
|
||||||
import java.util.Date; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 知识库管理 |
|
||||||
* @date 2024-06-26 14:18:28 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
public class KnowledgeDataEntity implements Serializable { |
|
||||||
|
|
||||||
private Long id; |
|
||||||
|
|
||||||
@NotBlank(message = "标题不能为空") |
|
||||||
private String title; |
|
||||||
|
|
||||||
@NotBlank(message = "摘要不能为空") |
|
||||||
private String description; |
|
||||||
|
|
||||||
@NotBlank(message = "内容不能为空") |
|
||||||
private String content; |
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|
||||||
private Date createTime; |
|
||||||
|
|
||||||
private Integer status; |
|
||||||
|
|
||||||
private String remark; |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,48 +0,0 @@ |
|||||||
package com.mh.user.entity; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat; |
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude; |
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
import java.util.Date; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project EEMCS |
|
||||||
* @description mqtt订阅管理 |
|
||||||
* @date 2025-02-14 13:47:07 |
|
||||||
*/ |
|
||||||
@Data |
|
||||||
public class MqttSubscriptionEntity { |
|
||||||
|
|
||||||
private Long id; |
|
||||||
|
|
||||||
private String topic; |
|
||||||
|
|
||||||
private Short qos; |
|
||||||
|
|
||||||
private String clientId; |
|
||||||
|
|
||||||
private String status; |
|
||||||
|
|
||||||
/** 创建者 */ |
|
||||||
private String createBy; |
|
||||||
|
|
||||||
/** 创建时间 */ |
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
private Date createTime; |
|
||||||
|
|
||||||
/** 更新者 */ |
|
||||||
private String updateBy; |
|
||||||
|
|
||||||
/** 更新时间 */ |
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|
||||||
private Date updateTime; |
|
||||||
|
|
||||||
/** 备注 */ |
|
||||||
private String remark; |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,50 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 回水温度控制器 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class BackTempControl implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final BackTempControl INSTANCE = new BackTempControl(); |
|
||||||
} |
|
||||||
|
|
||||||
private BackTempControl() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static BackTempControl getInstance() { |
|
||||||
return BackTempControl.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,38 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 设备接口 |
|
||||||
* @date 2024-03-15 16:48:26 |
|
||||||
*/ |
|
||||||
public interface Device { |
|
||||||
|
|
||||||
void setStrategy(DeviceStrategy strategy); |
|
||||||
|
|
||||||
String createOrders(DeviceCodeParamEntity deviceCodeParamEntity); |
|
||||||
|
|
||||||
String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity); |
|
||||||
|
|
||||||
/** |
|
||||||
* 解析MQTT报文 |
|
||||||
* @param dateStr |
|
||||||
* @param registerAddr |
|
||||||
* @param dataStr 已经是解析好的数据 |
|
||||||
* @param operateType 操作类型,读取/设置 |
|
||||||
* @param deviceInstallEntity |
|
||||||
* @return |
|
||||||
*/ |
|
||||||
String analysisMQTTReceiveData(String dateStr, |
|
||||||
String registerAddr, |
|
||||||
String dataStr, |
|
||||||
String operateType, |
|
||||||
DeviceInstallEntity deviceInstallEntity, |
|
||||||
CollectionParamsManageEntity collectionParamsManageEntity); |
|
||||||
} |
|
||||||
@ -1,20 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.constants.DeviceEnum; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 设备工厂类 |
|
||||||
* @date 2024-03-15 17:09:49 |
|
||||||
*/ |
|
||||||
@Slf4j |
|
||||||
public class DeviceFactory { |
|
||||||
|
|
||||||
public static Device createDevice(String deviceType) { |
|
||||||
return DeviceEnum.getDevice(deviceType); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,53 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 电表设备 |
|
||||||
* @date 2024-03-15 16:52:39 |
|
||||||
*/ |
|
||||||
@Slf4j |
|
||||||
public class EleMeter implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy eleMeterStrategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final EleMeter INSTANCE = new EleMeter(); |
|
||||||
} |
|
||||||
|
|
||||||
private EleMeter() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static EleMeter getInstance() { |
|
||||||
return EleMeter.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.eleMeterStrategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
log.info("电表设备创建报文"); |
|
||||||
return eleMeterStrategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return eleMeterStrategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return eleMeterStrategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,50 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 热泵 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class HeatPump implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final HeatPump INSTANCE = new HeatPump(); |
|
||||||
} |
|
||||||
|
|
||||||
private HeatPump() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static HeatPump getInstance() { |
|
||||||
return HeatPump.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,50 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 热泵状态 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class HeatPumpStatus implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final HeatPumpStatus INSTANCE = new HeatPumpStatus(); |
|
||||||
} |
|
||||||
|
|
||||||
private HeatPumpStatus() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static HeatPumpStatus getInstance() { |
|
||||||
return HeatPumpStatus.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,51 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 多路控制控制 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class MultiControl implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final MultiControl INSTANCE = new MultiControl(); |
|
||||||
} |
|
||||||
|
|
||||||
private MultiControl() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static MultiControl getInstance() { |
|
||||||
return MultiControl.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,51 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 压力变送器 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class PressureTrans implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final PressureTrans INSTANCE = new PressureTrans(); |
|
||||||
} |
|
||||||
|
|
||||||
private PressureTrans() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static PressureTrans getInstance() { |
|
||||||
return PressureTrans.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,55 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 状态检测 |
|
||||||
* @date 2024-03-15 17:07:54 |
|
||||||
*/ |
|
||||||
@Slf4j |
|
||||||
public class StatusCheck implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy wtMeterStrategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final StatusCheck INSTANCE = new StatusCheck(); |
|
||||||
} |
|
||||||
|
|
||||||
private StatusCheck() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static StatusCheck getInstance() { |
|
||||||
return SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.wtMeterStrategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
log.info("水表设备创建报文"); |
|
||||||
return wtMeterStrategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return wtMeterStrategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return wtMeterStrategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,51 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 温度控制器 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class TempControl implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final TempControl INSTANCE = new TempControl(); |
|
||||||
} |
|
||||||
|
|
||||||
private TempControl() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static TempControl getInstance() { |
|
||||||
return TempControl.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,51 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 压力变送器 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class TempTrans implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final TempTrans INSTANCE = new TempTrans(); |
|
||||||
} |
|
||||||
|
|
||||||
private TempTrans() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static TempTrans getInstance() { |
|
||||||
return TempTrans.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,51 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 时间控制器 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class TimeControl implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final TimeControl INSTANCE = new TimeControl(); |
|
||||||
} |
|
||||||
|
|
||||||
private TimeControl() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static TimeControl getInstance() { |
|
||||||
return TimeControl.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity , collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,51 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 水位开关控制 |
|
||||||
* @date 2024-03-18 16:53:35 |
|
||||||
*/ |
|
||||||
public class WaterLevelSwitch implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy strategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final WaterLevelSwitch INSTANCE = new WaterLevelSwitch(); |
|
||||||
} |
|
||||||
|
|
||||||
private WaterLevelSwitch() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static WaterLevelSwitch getInstance() { |
|
||||||
return WaterLevelSwitch.SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.strategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,55 +0,0 @@ |
|||||||
package com.mh.user.factory; |
|
||||||
|
|
||||||
import com.mh.user.entity.CollectionParamsManageEntity; |
|
||||||
import com.mh.user.entity.DeviceCodeParamEntity; |
|
||||||
import com.mh.user.entity.DeviceInstallEntity; |
|
||||||
import com.mh.user.strategy.DeviceStrategy; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project CHWS |
|
||||||
* @description 水表设备 |
|
||||||
* @date 2024-03-15 17:07:54 |
|
||||||
*/ |
|
||||||
@Slf4j |
|
||||||
public class WtMeter implements Device { |
|
||||||
|
|
||||||
private DeviceStrategy wtMeterStrategy; |
|
||||||
|
|
||||||
private static class SingletonHolder { |
|
||||||
private static final WtMeter INSTANCE = new WtMeter(); |
|
||||||
} |
|
||||||
|
|
||||||
private WtMeter() { |
|
||||||
// 防止外部直接实例化
|
|
||||||
} |
|
||||||
|
|
||||||
public static WtMeter getInstance() { |
|
||||||
return SingletonHolder.INSTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public void setStrategy(DeviceStrategy strategy) { |
|
||||||
this.wtMeterStrategy = strategy; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
log.info("水表设备创建报文"); |
|
||||||
return wtMeterStrategy.createOrders(deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
|
||||||
return wtMeterStrategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
|
||||||
return wtMeterStrategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,64 +0,0 @@ |
|||||||
package com.mh.user.job; |
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON; |
|
||||||
import com.alibaba.fastjson2.JSONObject; |
|
||||||
import com.github.benmanes.caffeine.cache.Cache; |
|
||||||
import com.mh.common.utils.StringUtils; |
|
||||||
import com.mh.user.entity.SysParamEntity; |
|
||||||
import com.mh.user.service.SysParamService; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.springframework.beans.factory.annotation.Qualifier; |
|
||||||
import org.springframework.beans.factory.annotation.Value; |
|
||||||
import org.springframework.scheduling.annotation.Scheduled; |
|
||||||
import org.springframework.stereotype.Component; |
|
||||||
import org.springframework.web.client.RestTemplate; |
|
||||||
|
|
||||||
import javax.annotation.Resource; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author LJF |
|
||||||
* @version 1.0 |
|
||||||
* @project NewZhujiang_Server |
|
||||||
* @description 定期获取时间 |
|
||||||
* @date 2023-12-05 14:12:56 |
|
||||||
*/ |
|
||||||
@Component |
|
||||||
@Slf4j |
|
||||||
public class GetWeatherInfoJob { |
|
||||||
|
|
||||||
@Resource |
|
||||||
private SysParamService sysParamService; |
|
||||||
|
|
||||||
@Resource |
|
||||||
private RestTemplate restTemplate; |
|
||||||
|
|
||||||
@Resource |
|
||||||
@Qualifier("caffeineCache") |
|
||||||
private Cache caffeineCache; |
|
||||||
|
|
||||||
@Value("${amap.key}") |
|
||||||
String amapKey; |
|
||||||
|
|
||||||
/** |
|
||||||
* 定时获取每天天气 |
|
||||||
*/ |
|
||||||
@Scheduled(cron = "0 0 0 1/1 * ?") |
|
||||||
public void getWeatherInfo() { |
|
||||||
// 从系统参数中获取对应的项目区域
|
|
||||||
SysParamEntity sysParam = sysParamService.selectSysParam(); |
|
||||||
if (null != sysParam) { |
|
||||||
String url = "https://restapi.amap.com/v3/weather/weatherInfo?extensions=all&key="+amapKey+"&city="+sysParam.getProArea(); |
|
||||||
String returnResult = restTemplate.getForObject(url, String.class); |
|
||||||
if (!StringUtils.isBlank(returnResult)) { |
|
||||||
JSONObject jsonObject = JSON.parseObject(returnResult); |
|
||||||
if ("1".equals(jsonObject.get("status"))) { |
|
||||||
Object wetTemp = caffeineCache.getIfPresent(sysParam.getProArea()); |
|
||||||
if (wetTemp != null) { |
|
||||||
caffeineCache.invalidate(sysParam.getProArea()); |
|
||||||
} |
|
||||||
caffeineCache.put(sysParam.getProArea(), jsonObject.toString()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,159 +1,159 @@ |
|||||||
//package com.mh.user.job;
|
package com.mh.user.job; |
||||||
|
|
||||||
|
import com.mh.user.constants.SocketMessage; |
||||||
|
import com.mh.user.entity.GatewayManageEntity; |
||||||
|
import com.mh.user.serialport.SerialPortThread; |
||||||
|
import com.mh.user.service.DeviceCodeParamService; |
||||||
|
import com.mh.user.service.impl.DeviceDisplayServiceImpl; |
||||||
|
import com.mh.user.utils.GetReadOrder485; |
||||||
|
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; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @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 JobCloudAndMeter implements Job { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private SocketMessage socketMessage; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
DeviceDisplayServiceImpl.GatewayManageService gatewayManageService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
DeviceCodeParamService deviceCodeParamService; |
||||||
|
|
||||||
|
private static int taskTimes = 1; |
||||||
|
List<GatewayManageEntity> gatewayDtoList=new ArrayList<>(); |
||||||
|
GetReadOrder485 getReadOrder485=new GetReadOrder485(); |
||||||
|
|
||||||
|
@SneakyThrows |
||||||
|
@Override |
||||||
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { |
||||||
|
log.info("定时采集开始>>>>>>"); |
||||||
|
if(taskTimes==2){//2
|
||||||
|
int r=deviceCodeParamService.queryCount2(); //查询记录数
|
||||||
|
if (r==0){ |
||||||
|
getReadOrder485.createOrderParam2(); //生成采集参数
|
||||||
|
} |
||||||
|
|
||||||
|
SerialPortThread myThread = new SerialPortThread(); |
||||||
|
Thread thread = new Thread(myThread); |
||||||
|
myThread.setName("2","1"); |
||||||
|
thread.start(); |
||||||
|
System.out.println("当前活动线程数:"+Thread.activeCount()); |
||||||
|
Thread.currentThread().sleep(3000);//毫秒
|
||||||
|
|
||||||
|
// SerialPortThread myThread2 = new SerialPortThread();
|
||||||
|
// Thread thread2 = new Thread(myThread2);
|
||||||
|
// myThread2.setName("2","2");
|
||||||
|
// thread2.start();
|
||||||
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
//
|
//
|
||||||
//import com.mh.user.constants.SocketMessage;
|
// SerialPortThread myThread3 = new SerialPortThread();
|
||||||
//import com.mh.user.entity.GatewayManageEntity;
|
// Thread thread3 = new Thread(myThread3);
|
||||||
//import com.mh.user.serialport.SerialPortThread;
|
// myThread3.setName("2","3");
|
||||||
//import com.mh.user.service.DeviceCodeParamService;
|
// thread3.start();
|
||||||
//import com.mh.user.service.GatewayManageService;
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
//import com.mh.user.utils.GetReadOrder485;
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
//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;
|
|
||||||
//import java.util.ArrayList;
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
//
|
||||||
///**
|
// SerialPortThread myThread4= new SerialPortThread();
|
||||||
// * @author ljf
|
// Thread thread4 = new Thread(myThread4);
|
||||||
// * @title :
|
// myThread4.setName("2","4");
|
||||||
// * @description : 定时采集冷量计任务
|
// thread4.start();
|
||||||
// * @updateTime 2020-05-18
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
// * @throws :
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
// */
|
System.out.println("采集水、电、运行状态!"+taskTimes); |
||||||
///**
|
taskTimes++; |
||||||
// * :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行.
|
}else if(taskTimes==3){//5
|
||||||
// * :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效
|
int r=deviceCodeParamService.queryCount3();//查询记录数
|
||||||
// * :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行,
|
if (r==0){ |
||||||
// * 否则会在3秒时再启用新的线程执行
|
getReadOrder485.createOrderParam3(); //生成采集参数
|
||||||
// */
|
} |
||||||
//@DisallowConcurrentExecution
|
|
||||||
//@Slf4j
|
SerialPortThread myThread = new SerialPortThread(); |
||||||
//public class JobCloudAndMeter implements Job {
|
Thread thread = new Thread(myThread); |
||||||
|
myThread.setName("3","1"); |
||||||
|
thread.start(); |
||||||
|
System.out.println("当前活动线程数:"+Thread.activeCount()); |
||||||
|
Thread.currentThread().sleep(3000);//毫秒
|
||||||
|
|
||||||
|
// SerialPortThread myThread2 = new SerialPortThread();
|
||||||
|
// Thread thread2 = new Thread(myThread2);
|
||||||
|
// myThread2.setName("3","2");
|
||||||
|
// thread2.start();
|
||||||
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
//
|
//
|
||||||
// @Autowired
|
// SerialPortThread myThread3 = new SerialPortThread();
|
||||||
// private SocketMessage socketMessage;
|
// Thread thread3 = new Thread(myThread3);
|
||||||
|
// myThread3.setName("3","3");
|
||||||
|
// thread3.start();
|
||||||
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
//
|
//
|
||||||
// @Autowired
|
// SerialPortThread myThread4= new SerialPortThread();
|
||||||
// GatewayManageService gatewayManageService;
|
// Thread thread4 = new Thread(myThread4);
|
||||||
|
// myThread4.setName("3","4");
|
||||||
|
// thread4.start();
|
||||||
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
|
System.out.println("采集设定温度、设定水位、故障状态!"+taskTimes); |
||||||
|
taskTimes=1; |
||||||
|
}else if(taskTimes==1){ |
||||||
|
int r=deviceCodeParamService.queryCount(); //查询记录数
|
||||||
|
if (r==0){ |
||||||
|
getReadOrder485.createOrderParam(); //生成采集参数
|
||||||
|
} |
||||||
|
SerialPortThread myThread = new SerialPortThread(); |
||||||
|
Thread thread = new Thread(myThread); |
||||||
|
myThread.setName("1","1"); |
||||||
|
thread.start(); |
||||||
|
System.out.println("当前活动线程数:"+Thread.activeCount()); |
||||||
|
Thread.currentThread().sleep(3000);//毫秒
|
||||||
|
|
||||||
|
// SerialPortThread myThread2 = new SerialPortThread();
|
||||||
|
// Thread thread2 = new Thread(myThread2);
|
||||||
|
// myThread2.setName("1","2");
|
||||||
|
// thread2.start();
|
||||||
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
//
|
//
|
||||||
// @Autowired
|
// SerialPortThread myThread3 = new SerialPortThread();
|
||||||
// DeviceCodeParamService deviceCodeParamService;
|
// Thread thread3 = new Thread(myThread3);
|
||||||
|
// myThread3.setName("1","3");
|
||||||
|
// thread3.start();
|
||||||
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
//
|
//
|
||||||
// private static int taskTimes = 1;
|
// SerialPortThread myThread4= new SerialPortThread();
|
||||||
// List<GatewayManageEntity> gatewayDtoList=new ArrayList<>();
|
// Thread thread4 = new Thread(myThread4);
|
||||||
// GetReadOrder485 getReadOrder485=new GetReadOrder485();
|
// myThread4.setName("1","4");
|
||||||
//
|
// thread4.start();
|
||||||
// @SneakyThrows
|
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
||||||
// @Override
|
// Thread.currentThread().sleep(3000);//毫秒
|
||||||
// public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
System.out.println("采集水位、水温!"+taskTimes); |
||||||
// log.info("定时采集开始>>>>>>");
|
taskTimes++; |
||||||
// if(taskTimes==2){//2
|
} |
||||||
// int r=deviceCodeParamService.queryCount2(); //查询记录数
|
} |
||||||
// if (r==0){
|
} |
||||||
// getReadOrder485.createOrderParam2(); //生成采集参数
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// SerialPortThread myThread = new SerialPortThread();
|
|
||||||
// Thread thread = new Thread(myThread);
|
|
||||||
// myThread.setName("2","1");
|
|
||||||
// thread.start();
|
|
||||||
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
//
|
|
||||||
//// SerialPortThread myThread2 = new SerialPortThread();
|
|
||||||
//// Thread thread2 = new Thread(myThread2);
|
|
||||||
//// myThread2.setName("2","2");
|
|
||||||
//// thread2.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
////
|
|
||||||
//// SerialPortThread myThread3 = new SerialPortThread();
|
|
||||||
//// Thread thread3 = new Thread(myThread3);
|
|
||||||
//// myThread3.setName("2","3");
|
|
||||||
//// thread3.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
////
|
|
||||||
//// SerialPortThread myThread4= new SerialPortThread();
|
|
||||||
//// Thread thread4 = new Thread(myThread4);
|
|
||||||
//// myThread4.setName("2","4");
|
|
||||||
//// thread4.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
// System.out.println("采集水、电、运行状态!"+taskTimes);
|
|
||||||
// taskTimes++;
|
|
||||||
// }else if(taskTimes==3){//5
|
|
||||||
// int r=deviceCodeParamService.queryCount3();//查询记录数
|
|
||||||
// if (r==0){
|
|
||||||
// getReadOrder485.createOrderParam3(); //生成采集参数
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// SerialPortThread myThread = new SerialPortThread();
|
|
||||||
// Thread thread = new Thread(myThread);
|
|
||||||
// myThread.setName("3","1");
|
|
||||||
// thread.start();
|
|
||||||
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
//
|
|
||||||
//// SerialPortThread myThread2 = new SerialPortThread();
|
|
||||||
//// Thread thread2 = new Thread(myThread2);
|
|
||||||
//// myThread2.setName("3","2");
|
|
||||||
//// thread2.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
////
|
|
||||||
//// SerialPortThread myThread3 = new SerialPortThread();
|
|
||||||
//// Thread thread3 = new Thread(myThread3);
|
|
||||||
//// myThread3.setName("3","3");
|
|
||||||
//// thread3.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
////
|
|
||||||
//// SerialPortThread myThread4= new SerialPortThread();
|
|
||||||
//// Thread thread4 = new Thread(myThread4);
|
|
||||||
//// myThread4.setName("3","4");
|
|
||||||
//// thread4.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
// System.out.println("采集设定温度、设定水位、故障状态!"+taskTimes);
|
|
||||||
// taskTimes=1;
|
|
||||||
// }else if(taskTimes==1){
|
|
||||||
// int r=deviceCodeParamService.queryCount(); //查询记录数
|
|
||||||
// if (r==0){
|
|
||||||
// getReadOrder485.createOrderParam(); //生成采集参数
|
|
||||||
// }
|
|
||||||
// SerialPortThread myThread = new SerialPortThread();
|
|
||||||
// Thread thread = new Thread(myThread);
|
|
||||||
// myThread.setName("1","1");
|
|
||||||
// thread.start();
|
|
||||||
// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
//
|
|
||||||
//// SerialPortThread myThread2 = new SerialPortThread();
|
|
||||||
//// Thread thread2 = new Thread(myThread2);
|
|
||||||
//// myThread2.setName("1","2");
|
|
||||||
//// thread2.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
////
|
|
||||||
//// SerialPortThread myThread3 = new SerialPortThread();
|
|
||||||
//// Thread thread3 = new Thread(myThread3);
|
|
||||||
//// myThread3.setName("1","3");
|
|
||||||
//// thread3.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
////
|
|
||||||
//// SerialPortThread myThread4= new SerialPortThread();
|
|
||||||
//// Thread thread4 = new Thread(myThread4);
|
|
||||||
//// myThread4.setName("1","4");
|
|
||||||
//// thread4.start();
|
|
||||||
//// System.out.println("当前活动线程数:"+Thread.activeCount());
|
|
||||||
//// Thread.currentThread().sleep(3000);//毫秒
|
|
||||||
// System.out.println("采集水位、水温!"+taskTimes);
|
|
||||||
// taskTimes++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue