Browse Source

Merge pull request 'master' (#38) from master into V3

Reviewed-on: http://git.lrdaiot.cn:9000/thing/thing_api/pulls/38
qingyuan_dev_new
李帅 1 year ago
parent
commit
28fe6e68e7
  1. 87
      help/sql/dml_1.0.0.sql
  2. 210
      modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java
  3. 33
      modules/thing/src/main/java/com/thing/thing/cache/service/ThingCache.java
  4. 2
      modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java

87
help/sql/dml_1.0.0.sql

@ -1,7 +1,4 @@
-- ----------------------------
-- Records of carbon_pub_eng_eff
-- ----------------------------
INSERT INTO "public"."carbon_pub_eng_eff" VALUES (166277698467926016, '商用设备', '多联式空调(热泵)机组', '制热季节性能系数', '(W·h)/(W·h)', '低温多联机', '名义制热量≤18000W', '', '3.40', '3.20', '3.00', 'GB 21454-2021', 458989019666055168, 458989019666055168, 458989019666055168, 1067246875800000001, 1720055352605, 1067246875800000001, 1721958811010, 'http://minio.lrdiot.com/thingmanager/20240726/88e1b351c15f.png', NULL);
INSERT INTO "public"."carbon_pub_eng_eff" VALUES (166277104508342272, '商用设备', '多联式空调(热泵)机组', '全年能源消耗效率', '(W·h)/(W·h)', '风冷式热泵', '名义制冷量>68000W', '', '4.60', '3.80', '3.20', 'GB 21454-2021', 458989019666055168, 458989019666055168, 458989019666055168, 1067246875800000001, 1720055210994, 1067246875800000001, 1721958818256, 'http://minio.lrdiot.com/thingmanager/20240726/91407aa6cd4b.png', NULL);
INSERT INTO "public"."carbon_pub_eng_eff" VALUES (166273446450302976, '商用设备', '多联式空调(热泵)机组', '全年能源消耗效率', '(W·h)/(W·h)', '风冷式热泵', '28000W<名义制冷量≤50000W', '', '5.20', '4.20', '3.40', 'GB 21454-2021', 458989019666055168, 458989019666055168, 458989019666055168, 1067246875800000001, 1720054338845, 1067246875800000001, 1721958832391, 'http://minio.lrdiot.com/thingmanager/20240726/26408f828873.png', NULL);
@ -19,10 +16,6 @@ INSERT INTO "public"."carbon_pub_eng_eff" VALUES (166287855004422144, '工业设
INSERT INTO "public"."carbon_pub_eng_eff" VALUES (166279630297239552, '商用设备', '多联式空调(热泵)机组', '制热季节性能系数', '(W·h)/(W·h)', '低温多联机', '名义制热量>18000W', '', '3.20', '3.00', '2.80', 'GB 21454-2021', 458989019666055168, 458989019666055168, 458989019666055168, 1067246875800000001, 1720055813189, 1067246875800000001, 1721958790240, 'http://minio.lrdiot.com/thingmanager/20240726/49b27778b21f.png', NULL);
INSERT INTO "public"."carbon_pub_eng_eff" VALUES (161275042062143488, '商用设备', '多联式空调(热泵)机组', '全年能源消耗效率', '(W·h)/(W·h)', '风冷式热泵', '名义制冷量≤14000W', '', '5.60', '4.40', '3.60', 'GB 21454-2021', 458989019666055168, 458989019666055168, 458989019666055168, 1067246875800000001, 1718862626373, 1067246875800000001, 1721958799093, 'http://minio.lrdiot.com/thingmanager/20240726/627999db6049.png', NULL);
-- ----------------------------
-- Records of carbon_energy_dict_relation
-- ----------------------------
INSERT INTO "public"."carbon_energy_dict_relation" VALUES (483315936342835200, 159136210321707008, 'A29hh', '时用电', 'hh', NULL, 1001, 1001, 1001, 1067246875800000001, 1724661898800, NULL, 1724661898800, '');
INSERT INTO "public"."carbon_energy_dict_relation" VALUES (483315936342835201, 159136210321707008, 'A29dd', '日用电', 'dd', NULL, 1001, 1001, 1001, 1067246875800000001, 1724661898800, NULL, 1724661898800, '');
INSERT INTO "public"."carbon_energy_dict_relation" VALUES (483315936342835202, 159136210321707008, 'A29mm', '月用电', 'mm', NULL, 1001, 1001, 1001, 1067246875800000001, 1724661898800, NULL, 1724661898800, '');
@ -121,9 +114,6 @@ INSERT INTO "public"."carbon_energy_dict_relation" VALUES (484030825931735044, 1
INSERT INTO "public"."carbon_energy_dict_relation" VALUES (484030825931735045, 186311940837081088, 'U2am', '', 'am', NULL, 1001, 1001, 1001, 1067246875800000001, 1724832341760, NULL, 1724832341760, '柴油');
-- ----------------------------
-- Records of carbon_energy_price
-- ----------------------------
INSERT INTO "public"."carbon_energy_price" VALUES (185844283968978944, 'A29', '电量', 159136210321707008, '电量', 0.10, 1, '2024-09-01', '2025-09-01', 'kWh', 1001, 1001, 1001, 1067246875800000001, 1724720390118, 1067246875800000001, 1724720390118);
INSERT INTO "public"."carbon_energy_price" VALUES (185920710605144064, 'A29_peak', '峰用电', 159136210321707008, '峰用电', 0.50, 2, '2024-09-01', '2025-09-01', 'kWh', 1001, 1001, 1001, 1067246875800000001, 1724738611648, 1067246875800000001, 1724738611648);
INSERT INTO "public"."carbon_energy_price" VALUES (185921764071702528, 'A29_rush', '尖用电', 159136210321707008, '尖用电', 0.30, 4, '2024-09-01', '2025-09-01', 'kWh', 1001, 1001, 1001, 1067246875800000001, 1724738862814, 1067246875800000001, 1724738862814);
@ -131,10 +121,6 @@ INSERT INTO "public"."carbon_energy_price" VALUES (185921493941747712, 'A29_vall
INSERT INTO "public"."carbon_energy_price" VALUES (185922011321729024, 'A29_normal', '平用电', 159136210321707008, '平用电', 0.60, 6, '2024-09-01', '2025-09-01', 'kWh', 1001, 1001, 1001, 1067246875800000001, 1724738921763, 1067246875800000001, 1724738921763);
INSERT INTO "public"."carbon_energy_price" VALUES (186604761926205440, 'B2', '水价格', 186310184338063360, '水价格', 1.00, 5, '2024-09-01', '2025-09-01', 't', 1001, 1001, 1001, 1067246875800000001, 1724901702192, 1067246875800000001, 1724901702192);
-- ----------------------------
-- Records of carbon_peak_config
-- ----------------------------
INSERT INTO "public"."carbon_peak_config" VALUES (185924170549428224, '2024', '1,12', 1020, 1080, 'A29am', 'A29_peakam', NULL, 1001, 1001, 1001, 1067246875800000001, 1724739436563, 1067246875800000001, 1724739436563, '17:00', '18:00', 159136210321707008);
INSERT INTO "public"."carbon_peak_config" VALUES (185924327559004160, '2024', '1,12', 480, 540, 'A29am', 'A29_peakam', NULL, 1001, 1001, 1001, 1067246875800000001, 1724739473997, 1067246875800000001, 1724739473997, '08:00', '09:00', 159136210321707008);
INSERT INTO "public"."carbon_peak_config" VALUES (185924517149933568, '2024', '2,3,4,5,6,9,10,11', 1020, 1320, 'A29am', 'A29_peakam', NULL, 1001, 1001, 1001, 1067246875800000001, 1724739519199, 1067246875800000001, 1724739519199, '17:00', '22:00', 159136210321707008);
@ -184,9 +170,6 @@ INSERT INTO "public"."carbon_peak_config" VALUES (190679553627160589, '2024', '1
INSERT INTO "public"."carbon_peak_config" VALUES (190679553627160590, '2024', '1,12', 540, 660, 'A29am', 'A29_rusham', NULL, 488389224244969472, 1001, 1001, NULL, 1725873208238, NULL, 1725873208238, '09:00', '11:00', 159136210321707008);
INSERT INTO "public"."carbon_peak_config" VALUES (190679553627160591, '2024', '1,12', 1200, 1320, 'A29am', 'A29_peakam', NULL, 488389224244969472, 1001, 1001, NULL, 1725873208238, NULL, 1725873208238, '20:00', '22:00', 159136210321707008);
-- ----------------------------
-- Records of carbon_pub_material_factor
-- ----------------------------
INSERT INTO "public"."carbon_pub_material_factor" VALUES ('1747910190130397184', 'CN-SGCC', 'State Grid Corporation of China', '国家电网公司', 'Coal fired gas power', '燃煤燃气电', 'kWh', 2.909837395811256, 1, 'CLCD', 0, '2022', '2023', 'currency', '通用');
INSERT INTO "public"."carbon_pub_material_factor" VALUES ('1747910362705035264', 'CN-CSG', 'China Southern Power Grid', '中国南方电网', 'Coal fired gas power', '燃煤燃气电', 'kWh', 2.908645123588052, 1, 'CLCD', 0, '2022', '2023', 'currency', '通用');
INSERT INTO "public"."carbon_pub_material_factor" VALUES ('1747911475248365568', 'CN-CSG', 'China Southern Power Grid', '中国南方电网', 'Gas electricity', '燃气电', 'kWh', 2.87856339933552, 1, 'CLCD', 0, '2022', '2022', 'currency', '通用');
@ -44204,11 +44187,6 @@ INSERT INTO "public"."carbon_pub_material_factor" VALUES ('1660693928472608768',
INSERT INTO "public"."carbon_pub_material_factor" VALUES ('1660688994196914176', 'GLO', 'Global', '全球的', 'market for infrastructure, for regional distribution of oil product', '基础设施市场,用于石油产品的区域分销', 'unit', 6903926.480803698, 1, 'Ecoinvent', 1, '2011', '2022', NULL, NULL);
INSERT INTO "public"."carbon_pub_material_factor" VALUES ('bb80e8d1-7dd8-5491-9cb4-a4c0396f899d_54d3412f-bf58-44be-8a75-f4b35480f24e', 'RER', 'Europe', '欧洲', 'infrastructure, for regional distribution of oil product', '基础设施,用于石油产品的区域分销', 'unit', 6088673.286685, 1, 'Ecoinvent 3.9.1', 1, '1991', '2022', 'Infrastructure & Machinery; Fuels', '基础设施和机械;燃料');
-- ----------------------------
-- Records of iot_carbon_ratio
-- ----------------------------
INSERT INTO "public"."iot_carbon_ratio" VALUES (160871336871202816, 160867998926639104, 'kgCO₂e/(t·km)', 0.04900000, '中国产品全生命周期温室气体排放系数集(2022)', NULL, '1', 1001, 1001, 1001, 1067246875800000001, 1718766375555, 1067246875800000001, 1718766375555, '2024-06-01', '2025-06-30', '中国');
INSERT INTO "public"."iot_carbon_ratio" VALUES (160872118509113344, 160868409532223488, 'kgCO₂e/(t·km)', 0.04200000, '中国产品全生命周期温室气体排放系数集(2022)', NULL, '1', 1001, 1001, 1001, 1067246875800000001, 1718766561912, 1067246875800000001, 1718766561912, '2024-06-01', '2025-06-30', '中国');
INSERT INTO "public"."iot_carbon_ratio" VALUES (160872400982904832, 160868534795112448, 'kgCO₂e/(t·km)', 0.04200000, '中国产品全生命周期温室气体排放系数集(2022)', NULL, '1', 1001, 1001, 1001, 1067246875800000001, 1718766629258, 1067246875800000001, 1718766629258, '2024-06-01', '2025-06-30', '中国');
@ -44220,9 +44198,6 @@ INSERT INTO "public"."iot_carbon_ratio" VALUES (159416392433594368, 159415383921
INSERT INTO "public"."iot_carbon_ratio" VALUES (159416392433594361, 159136210321707008, 'kgCO₂e/kWh', 0.57030000, '《企业温室气体排放核算与报告指南 发电设施》(2022年修订版)', '1', '1', 1001, 1001, 1001, 1067246875800000001, 1718419489768, 1067246875800000001, 1718419489768, '2023-04-20', '2024-04-11', '中国');
INSERT INTO "public"."iot_carbon_ratio" VALUES (160874724086255616, 159136210321707008, 'kgCO₂e/kWh', 0.55680000, '生态环境部、国家统计局关于发布2021年电力二氧化碳排放因子的公告', NULL, '1', 1001, 1001, 1001, 1067246875800000001, 1718767183130, 1067246875800000001, 1718767183130, '2024-04-12', '2025-05-01', '中国');
-- ----------------------------
-- Records of iot_thing_dict
-- ----------------------------
INSERT INTO "public"."iot_thing_dict" VALUES (160141466738364417, 'CO2_A29yy', '年用电碳排', 'kgCO₂', NULL, NULL, 'instant', NULL, NULL, NULL, 0, 4, NULL, '', NULL, NULL, NULL, 1001, 1001, 1001, 1067246875800000001, 1718592360955, 1067246875800000001, 1718592360955);
INSERT INTO "public"."iot_thing_dict" VALUES (160141466738364418, 'CO2_A29mm', '月用电碳排', 'kgCO₂', NULL, NULL, 'instant', NULL, NULL, NULL, 0, 5, NULL, '', NULL, NULL, NULL, 1001, 1001, 1001, 1067246875800000001, 1718592360955, 1067246875800000001, 1718592360955);
INSERT INTO "public"."iot_thing_dict" VALUES (160141466738364419, 'CO2_A29dd', '日用电碳排', 'kgCO₂', NULL, NULL, 'instant', NULL, NULL, NULL, 0, 6, NULL, '', NULL, NULL, NULL, 1001, 1001, 1001, 1067246875800000001, 1718592360955, 1067246875800000001, 1718592360955);
@ -44504,11 +44479,6 @@ INSERT INTO "public"."iot_thing_dict" VALUES (185920552140144640, 'A29_valley',
INSERT INTO "public"."iot_thing_dict" VALUES (160941049441685507, 'A29_normalam', '平刻用电', 'kWh', 900, NULL, 'region', NULL, NULL, NULL, 0, 61, NULL, '尖峰谷平计算属性组', NULL, NULL, NULL, 1001, 1001, 1001, 1067246875800000001, 1718782996327, 1067246875800000001, 1718782996327);
INSERT INTO "public"."iot_thing_dict" VALUES (186604471944609792, 'B2', '水价格', 't', 900, '', 'default', '', '', NULL, 1, 275, '', '用量价格组', NULL, NULL, '', 1001, 1001, 1001, 1067246875800000001, 1724901633056, 1067246875800000001, 1724901633056);
-- ----------------------------
-- Records of sys_dept
-- ----------------------------
INSERT INTO "public"."sys_dept" VALUES (1067246875800000062, 1067246875800000063, '1001,1067246875800000063', '技术部', 2, 1001, 1067246875800000001, 1651296954268, 1067246875800000001, 1651296954268);
INSERT INTO "public"."sys_dept" VALUES (1067246875800000063, 1001, '1001', '长沙分公司', 1, 1001, 1067246875800000001, 1651296954271, 1067246875800000001, 1651296954271);
INSERT INTO "public"."sys_dept" VALUES (1067246875800000064, 1001, '1001', '上海分公司', 0, 1001, 1067246875800000001, 1651296954274, 1067246875800000001, 1651296954274);
@ -44517,10 +44487,6 @@ INSERT INTO "public"."sys_dept" VALUES (1001, 0, '0', '物管理', 0, 1001, 1067
INSERT INTO "public"."sys_dept" VALUES (1067246875800000067, 1067246875800000064, '1001,1067246875800000064', '销售部', 0, 1001, 1067246875800000001, 1651296954291, 1067246875800000001, 1651296954291);
INSERT INTO "public"."sys_dept" VALUES (1067246875800000068, 1067246875800000063, '1001,1067246875800000063', '产品部', 1, 1001, 1067246875800000001, 1651296954297, 1067246875800000001, 1651296954297);
-- ----------------------------
-- Records of sys_dict_data
-- ----------------------------
INSERT INTO "public"."sys_dict_data" VALUES (1225814069634195457, 1225813644059140097, '公告', '0', '', 0, 1067246875800000001, 1651296953481, 1067246875800000001, 1651296953481);
INSERT INTO "public"."sys_dict_data" VALUES (1225814107559092225, 1225813644059140097, '会议', '1', '', 1, 1067246875800000001, 1651296953485, 1067246875800000001, 1651296953485);
INSERT INTO "public"."sys_dict_data" VALUES (1225814271879340034, 1225813644059140097, '其他', '2', '', 2, 1067246875800000001, 1651296953489, 1067246875800000001, 1651296953489);
@ -44851,11 +44817,6 @@ INSERT INTO "public"."sys_dict_data" VALUES (153332465809788928, 153332059037798
INSERT INTO "public"."sys_dict_data" VALUES (153332546797604864, 153332059037798400, '设备耗材', '4', '', 3, 1067246875800000001, 1716968987937, 1067246875800000001, 1716969027028);
INSERT INTO "public"."sys_dict_data" VALUES (153332692381896704, 153332059037798400, '包材', '5', '', 4, 1067246875800000001, 1716969022647, 1067246875800000001, 1716969029827);
-- ----------------------------
-- Records of sys_dict_type
-- ----------------------------
INSERT INTO "public"."sys_dict_type" VALUES (1225813644059140097, 'notice_type', '站内通知-类型', '', 1, 1067246875800000001, 1651296953478, 1067246875800000001, 1651296953478);
INSERT INTO "public"."sys_dict_type" VALUES (1542780233327476738, 'protocol_provider', '协议类型', '', 2, 1067246875800000001, 1656691245752, 1067246875800000001, 1656691245752);
INSERT INTO "public"."sys_dict_type" VALUES (1628323542649016322, 'data_source_type', '数据源类型', '', 3, 1067246875800000001, 1677086360013, 1067246875800000001, 1677086360013);
@ -44898,11 +44859,6 @@ INSERT INTO "public"."sys_dict_type" VALUES (1653245486361239528, 'aggregation_t
INSERT INTO "public"."sys_dict_type" VALUES (1653245486361239527, 'search_time_range_type', '搜索时间类型', NULL, 40, 1067246875800000001, 1682612271000, 1067246875800000001, 1724740236476);
INSERT INTO "public"."sys_dict_type" VALUES (1319844151704948737, 'attribute_unit', '属性单位', '', 41, 1067246875800000001, 1603539141942, 1067246875800000001, 1724740243374);
-- ----------------------------
-- Records of sys_industry_type
-- ----------------------------
INSERT INTO "public"."sys_industry_type" VALUES (1340987262782935042, 'A', '0', '农、林、牧、渔业', '农、林、牧、渔业', 'f', 10001, 1340986980183314433, 0);
INSERT INTO "public"."sys_industry_type" VALUES (1340987262782935043, 'A01', 'A', '农业', '农业', 'f', 10001, 1340986980183314433, 0);
INSERT INTO "public"."sys_industry_type" VALUES (1340987262782935044, 'A011', 'A01', '谷物种植', '谷物种植', 'f', 10001, 1340986980183314433, 0);
@ -46545,10 +46501,6 @@ INSERT INTO "public"."sys_industry_type" VALUES (1340987262812295350, 'D44', 'D'
INSERT INTO "public"."sys_industry_type" VALUES (1340987262812295262, 'C39', 'C', '电子业', '计算机、通信和其他电子设备制造业', 'f', 10001, 1340986980183314433, 0);
INSERT INTO "public"."sys_industry_type" VALUES (1340987262799712280, 'C26', 'C', '化工业', '化学原料和化学制品制造业', 'f', 10001, 1340986980183314433, 0);
-- ----------------------------
-- Records of sys_language
-- ----------------------------
INSERT INTO "public"."sys_language" VALUES ('sys_menu', 184490656792707072, 'name', '国网侧首页总览', 'zh-CN');
INSERT INTO "public"."sys_language" VALUES ('sys_menu', 184490852431822848, 'name', '功能导航', 'zh-CN');
INSERT INTO "public"."sys_language" VALUES ('sys_menu', 184491081449209856, 'name', '企业侧看板', 'zh-CN');
@ -46765,10 +46717,6 @@ INSERT INTO "public"."sys_language" VALUES ('sys_menu', 184504796353527808, 'nam
INSERT INTO "public"."sys_language" VALUES ('sys_menu', 184525561253724160, 'name', '角色管理', 'zh-CN');
INSERT INTO "public"."sys_language" VALUES ('sys_menu', 184525112962318336, 'name', '岗位管理', 'zh-CN');
-- ----------------------------
-- Records of sys_menu
-- ----------------------------
INSERT INTO "public"."sys_menu" VALUES (184490656792707072, 0, 'overview/cgcc', '', 0, 0, '', 10, 1067246875800000001, 1724397660250, 1067246875800000001, 1724397660250, 1, '', '2', '');
INSERT INTO "public"."sys_menu" VALUES (184490852431822848, 0, 'overview', '', 0, 0, '', 20, 1067246875800000001, 1724397706894, 1067246875800000001, 1724397706894, 1, '', '2', '');
INSERT INTO "public"."sys_menu" VALUES (184491081449209856, 0, 'carbon/sys?fullscreen=0', '', 0, 0, '', 30, 1067246875800000001, 1724397761497, 1067246875800000001, 1724397761497, 1, '', '2', '');
@ -46981,11 +46929,6 @@ INSERT INTO "public"."sys_menu" VALUES (184501463697981440, 184501362657198080,
INSERT INTO "public"."sys_menu" VALUES (184501555381272576, 184501362657198080, 'calc-result/results?type=res', '', 0, 0, '', 1, 1067246875800000001, 1724400258676, 1067246875800000001, 1724741744293, 1, '', '2', 'http://minio.lrdiot.com/thingmanager/20240827/f76f29a4a3be.png');
INSERT INTO "public"."sys_menu" VALUES (184511127894491136, 0, 'carbon/efficiency', '', 0, 0, '', 190, 1067246875800000001, 1724402540941, 1067246875800000001, 1724741926155, 1, '查看设备标准能效参考值与企业共享的能效实测值', '2', 'http://minio.lrdiot.com/thingmanager/20240827/91554644feaf.png');
-- ----------------------------
-- Records of sys_params
-- ----------------------------
INSERT INTO "public"."sys_params" VALUES (1500711309585027074, 'WECHAT_BIND_PARAMS', '{"weChatAppId":"wxed829a289e1b8ce6","weChatSecret":"ad001be8995572b0677696818ba475f7","weChatAuthorizationGrantType":"authorization_code"}', 1, '微信绑定参数', 1067246875800000001, 1651296954608, 1067246875800000001, 1651296954608);
INSERT INTO "public"."sys_params" VALUES (1479007239724392450, 'CONFIG_TYPE', '[{"code":"0","value":"短信"},{"code":"1","value":"邮箱"},{"code":"2","value":"微信公众号"},{"code":"3","value":"钉钉"},{"code":"4","value":"企业微信"}]', 1, '字典', 1067246875800000001, 1641486579233, 1067246875800000001, 1641486579233);
INSERT INTO "public"."sys_params" VALUES (1479007595594309634, 'CACHE_TYPE', '[{"code":"0","value":"微信用户token"},{"code":"1","value":"模板内容"}]', 1, '字典', 1067246875800000001, 1641486664080, 1067246875800000001, 1641486664080);
@ -47018,9 +46961,6 @@ INSERT INTO "public"."sys_params" VALUES (1374647606281506818, 'TB_CALCULATION',
INSERT INTO "public"."sys_params" VALUES (1067246875800000072, 'DEV_TOOLS_PARAM_KEY', '{"packageName":"com.thing.","version":"3.0","author":"xc","email":"","backendPath":"D:\\thingiot","frontendPath":"D:\\thingiot"}', 0, '代码生成器配置信息', 1067246875800000001, 1669888850252, 1067246875800000001, 1669888850252);
INSERT INTO "public"."sys_params" VALUES (1067246875800000073, 'CLOUD_STORAGE_CONFIG_KEY', '{"type":6,"qiniuDomain":"http://test.oss.renren.io","qiniuPrefix":"upload","qiniuAccessKey":"NrgMfABZxWLo5B-YYSjoE8-AZ1EISdi1Z3ubLOeZ","qiniuSecretKey":"uIwJHevMRWU0VLxFvgy0tAcOdGqasdtVlJkdy6vV","qiniuBucketName":"renren-oss","aliyunDomain":"","aliyunPrefix":"","aliyunEndPoint":"","aliyunAccessKeyId":"","aliyunAccessKeySecret":"","aliyunBucketName":"","qcloudSecretId":"admin","qcloudSecretKey":"Sddt8888!","qcloudBucketName":"","localDomain":"http://localhost","localPath":"D:/thingiot","minioEndPoint":"http://minio.lrdiot.com","minioAccessKey":"thing","minioSecretKey":"sddt8888","minioBucketName":"thingmanager"}', 1, '云存储配置信息', 1067246875800000001, 1651296954372, 1067246875800000001, 1651296954372);
-- ----------------------------
-- Records of sys_region
-- ----------------------------
INSERT INTO "public"."sys_region" VALUES (110000, 0, '北京市', 1, 0, 110000, 1067246875800000001, 1653114357144, 1067246875800000001, 1653114357144);
INSERT INTO "public"."sys_region" VALUES (110100, 110000, '北京市', 2, 0, 110100, 1067246875800000001, 1653114357147, 1067246875800000001, 1653114357147);
INSERT INTO "public"."sys_region" VALUES (110101, 110100, '东城区', 3, 1, 110101, 1067246875800000001, 1653114357152, 1067246875800000001, 1653114357152);
@ -50840,10 +50780,6 @@ INSERT INTO "public"."sys_region" VALUES (320581111, 320581, '尚湖镇', 4, 1,
INSERT INTO "public"."sys_region" VALUES (320581401, 320581, '常熟经济技术开发区', 4, 1, 14, 1067246875800000001, 1706492682306, 1067246875800000001, 1706492682306);
INSERT INTO "public"."sys_region" VALUES (320581402, 320581, '常熟高新技术产业开发区', 4, 1, 15, 1067246875800000001, 1706492716614, 1067246875800000001, 1706492716614);
-- ----------------------------
-- Records of sys_region_weather
-- ----------------------------
INSERT INTO "public"."sys_region_weather" VALUES (520281, 101260804, '盘县', 1523609783911165956);
INSERT INTO "public"."sys_region_weather" VALUES (511500, 101271103, '宜宾县', 1523609762570547203);
INSERT INTO "public"."sys_region_weather" VALUES (341003, 101221008, '黄山风景区', 1523609732639993865);
@ -53415,15 +53351,9 @@ INSERT INTO "public"."sys_region_weather" VALUES (310104, 101021200, '徐家汇'
INSERT INTO "public"."sys_region_weather" VALUES (310115, 101020600, '南汇', 1523833052387966985);
INSERT INTO "public"."sys_region_weather" VALUES (460322, 101310220, '南沙岛', 1523831763121762313);
-- ----------------------------
-- Records of sys_role
-- ----------------------------
INSERT INTO "public"."sys_role" VALUES (1509429649562079234, '默认企业角色', '初始角色,请勿删除', 1001, 1001, 1067246875800000001, 1641965789769, 1067246875800000001, 1725324827419, 't', 1001, '0');
INSERT INTO "public"."sys_role" VALUES (1125415693534105602, '默认租户角色', '初始角色,请勿删除', 1001, 1001, 1067246875800000001, 1641965789769, 1067246875800000001, 1725868169796, 't', 1001, '0');
-- ----------------------------
-- Records of sys_role_menu
-- ----------------------------
INSERT INTO "public"."sys_role_menu" VALUES (188379478009970688, 1509429649562079234, 184491305047556096, 1067246875800000001, 1725324827479);
INSERT INTO "public"."sys_role_menu" VALUES (188379478018359296, 1509429649562079234, 184491425327611904, 1067246875800000001, 1725324827481);
INSERT INTO "public"."sys_role_menu" VALUES (188379478022553600, 1509429649562079234, 184491527790264320, 1067246875800000001, 1725324827482);
@ -53798,30 +53728,13 @@ INSERT INTO "public"."sys_role_menu" VALUES (190658421207465984, 112541569353410
INSERT INTO "public"."sys_role_menu" VALUES (190658421207465985, 1125415693534105602, 185565628424388608, 1067246875800000001, 1725868169878);
INSERT INTO "public"."sys_role_menu" VALUES (190658421207465986, 1125415693534105602, 185565721596657664, 1067246875800000001, 1725868169878);
-- ----------------------------
-- Records of sys_role_user
-- ----------------------------
INSERT INTO "public"."sys_role_user" VALUES (190671848034402304, 1509429649562079234, 190652150555213824, 1067246875800000001, 1725871371083);
INSERT INTO "public"."sys_role_user" VALUES (190672241896325120, 190672241510449152, 190672241883742208, 1067246875800000001, 1725871464987);
INSERT INTO "public"."sys_role_user" VALUES (190672241896325121, 1125415693534105602, 190672241883742208, 1067246875800000001, 1725871464987);
-- ----------------------------
-- Records of sys_tenant
-- ----------------------------
INSERT INTO "public"."sys_tenant" VALUES (1067246875800001000, 1001, '默认租户', 1, NULL, 1067246875800000001, 'admin', 0, 1, NULL, 1651297050415, 1067246875800000001, 1651297050415, 1, 'energy_board', NULL, NULL, NULL);
-- ----------------------------
-- Records of sys_tenant_detail
-- ----------------------------
INSERT INTO "public"."sys_tenant_detail" VALUES (1001, '默认租户', '', 'A01', 'A', '110101', '', 'moni', NULL, NULL, NULL, '120.686982,31.4235', NULL, NULL, NULL, NULL, NULL, 1067246875800000001, 1718604894238, NULL);
-
-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO "public"."sys_user" VALUES (1067246875800000001, 'admin', '$2a$10$ZNm8E/iO5YUEx0DrvhfnKeSnHHCVAyZ1iS/7UfyXjKGPN.KVqAD5W', '管理员', NULL, 0, 'root@thing.iot', '13612345678', 1001, 1, 1, 1, 1001, 1067246875800000001, 1651296953091, 1067246875800000001, 1709111015890, NULL, 1, 'chart/monitoring', NULL);

210
modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java

@ -8,7 +8,6 @@ import com.thing.common.core.enumeration.GateWayStatus;
import com.thing.common.core.enumeration.QueueOriginType;
import com.thing.common.core.enumeration.TemplateMark;
import com.thing.common.core.enumeration.ThingStatus;
import com.thing.common.core.event.AuthParam;
import com.thing.common.core.event.QueueDeviceEvent;
import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.core.utils.DateTimeUtils;
@ -19,10 +18,12 @@ import com.thing.thing.cache.service.ThingCache;
import com.thing.thing.context.service.ThingManageContextService;
import com.thing.thing.entity.dto.IotThingViewDTO;
import com.thing.thing.entity.entity.IotThingEntity;
import com.thing.thing.entity.service.IotThingEntityService;
import com.thing.thing.model.dto.IotThingModelDTO;
import com.thing.thing.model.entity.IotThingModelEntity;
import com.thing.thing.model.service.IotThingModelService;
import com.thing.transport.api.adaptor.JsonConverter;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@ -31,6 +32,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@ -42,6 +44,8 @@ public class QueueDeviceEventListener {
private final IotThingModelService thingModelService;
private final IotThingEntityService entityService;
private final ThingCache thingCache;
@EventListener(QueueDeviceEvent.class)
@ -55,60 +59,99 @@ public class QueueDeviceEventListener {
if (CollectionUtil.isEmpty(validMsgList)) {
return;
}
//新增和更新物模型信息
Map<String, String> codeOriginMap = validMsgList.parallelStream()
.collect(Collectors.toMap(QueueMsgDTO::getThingCode,
item -> (QueueOriginType.AUTO_DATA_SYNC.name().equals(item.getOrigin())
|| QueueOriginType.MANUAL_DATA_SYNC.name().equals(item.getOrigin()))
? QueueOriginType.TB.name() : item.getOrigin(), (e1, e2) -> e1));
//先根据物模型编码去重
Map<String, Map<Long, List<QueueMsgDTO>>> codeMapList = validMsgList.stream()
.collect(Collectors.groupingBy(QueueMsgDTO::getThingCode, Collectors.groupingBy(QueueMsgDTO::getTenantCode)));
//物模型插入
List<IotThingModelEntity> insertModelList = new ArrayList<>();
//物模型更新
List<IotThingModelEntity> updateModelList = new ArrayList<>();
//筛选物模型的插入和更新
checkAndSaveThingModels(codeOriginMap, insertModelList,updateModelList);
//物实体的插入
List<IotThingEntity> insertEntityList = new ArrayList<>();
//组装物实体和物模型
for (Map.Entry<String, Map<Long, List<QueueMsgDTO>>> entry : codeMapList.entrySet()) {
String thingCode = entry.getKey();
//分用户admin用户不用创建物实体其他用户需要创建物实体
Map<Long, List<QueueMsgDTO>> valueEntry = entry.getValue();
for (Map.Entry<Long, List<QueueMsgDTO>> thingEntry : valueEntry.entrySet()) {
Long tenantCode = thingEntry.getKey();
QueueMsgDTO queueMsgDTO = thingEntry.getValue().get(0);
//物模型缓存查询
ObjectNode jsonObject = thingCache.findAccurateObjectNode(CacheNameEnum.THING_MODEL, thingCode);
//缓存存在更新否则插入
if (null != jsonObject && !jsonObject.isEmpty()) {
IotThingModelEntity modelEntity = JacksonUtil.convertValue(jsonObject, IotThingModelEntity.class);
updateModelList.add(modelEntity);
} else {
String origin = QueueOriginType.AUTO_DATA_SYNC.name().equals(queueMsgDTO.getOrigin())
|| QueueOriginType.MANUAL_DATA_SYNC.name().equals(queueMsgDTO.getOrigin())
? QueueOriginType.TB.name() : queueMsgDTO.getOrigin();
IotThingModelEntity modelEntity = new IotThingModelEntity()
.setCode(thingCode)
.setToken(TokenGenerator.generateValue())
.setGateway(GateWayStatus.NO_GATE_WAY.getValue())
.setStatus(ThingStatus.NOT_CONNECTED.getCode())
.setAuthNum(0L)
.setStatusTs(DateTimeUtils.getCurrentTime())
.setOrigin(origin);
// modelEntity.setId(IdUtil.getSnowflake().nextId())
// .setCreateDate(DateTimeUtils.getCurrentTime())
// .setCreateDate(DateTimeUtils.getCurrentTime())
;
insertModelList.add(modelEntity);
}
//物实体的构建
// if (!Objects.equals(queueMsgDTO.getTenantCode(), 1001L)) {
// ObjectNode entityNode = thingCache.findObjectNode(CacheNameEnum.THING_ENTITY, tenantCode + ":" + thingCode);
// if (null == entityNode || entityNode.isEmpty()) {
// IotThingEntity newThingEntity = createThingEntity(thingCode, queueMsgDTO.getTenantCode(), queueMsgDTO.getCompanyId(), queueMsgDTO.getDeptId());
// insertEntityList.add(newThingEntity);
// }
// }
ObjectNode entityNode = thingCache.findObjectNode(CacheNameEnum.THING_ENTITY, tenantCode + ":" + thingCode);
if (null == entityNode || entityNode.isEmpty()) {
IotThingEntity newThingEntity = createThingEntity(thingCode, queueMsgDTO.getTenantCode(), queueMsgDTO.getCompanyId(), queueMsgDTO.getDeptId());
insertEntityList.add(newThingEntity);
}
}
}
//插入新的物模型
if (CollectionUtils.isNotEmpty(insertModelList)) {
// 物实体
Map<AuthParam, Set<String>> tenantThingCodeMap =
validMsgList.stream()
.filter(item -> Objects.nonNull(item.getTenantCode())
|| Objects.nonNull(item.getCompanyId())
|| Objects.nonNull(item.getDeptId()))
.collect(Collectors.groupingBy(
item ->new AuthParam(item.getTenantCode(),item.getCompanyId(),item.getDeptId()),
Collectors.mapping(QueueMsgDTO::getThingCode,Collectors.toSet())));
List<IotThingEntity> insertEntityList = new ArrayList<>();
saveTenantThingList(tenantThingCodeMap, insertEntityList);
insertModelList.forEach(item -> {
long count = insertEntityList.stream().filter(e -> StringUtils.equals(e.getCode(), item.getCode())).count();
List<ObjectNode> keyMap = thingCache.findKeyMap(CacheNameEnum.THING_ENTITY, item.getCode());
item.setAuthNum(count+CollectionUtils.size(keyMap));
});
thingModelService.saveBatch(insertModelList);
// thingModelService.saveBatch(insertModelList);
}
//更新老的物模型
if (CollectionUtils.isNotEmpty(updateModelList)) {
// thingModelService.updateBatch(updateModelList);
insertModelList.addAll(updateModelList);
}
//更新物实体的模型uniqueModelList有值物实体不一定有值
List<IotThingEntity> distinctStudentFile = new ArrayList<>();
if (CollectionUtils.isNotEmpty(insertModelList)) {
//插入物实体
//物实体的插入和缓存更新
if (CollectionUtils.isNotEmpty(insertEntityList)) {
List<IotThingEntity> distinctStudentFile = insertEntityList.stream()
distinctStudentFile.addAll(insertEntityList.stream()
.collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getCode() + ";" + o.getTenantCode()))), ArrayList::new));
thingManageContextService.saveEntity(distinctStudentFile);
updateEntityCache(distinctStudentFile);
Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(o -> o.getCode() + ";" + o.getTenantCode()))), ArrayList::new)));
}
}
if(CollectionUtils.isNotEmpty(updateModelList)){
updateModelList.forEach(item -> {
long count = updateModelList.stream().filter(e -> StringUtils.equals(e.getCode(), item.getCode())).count();
//更新物模型和物实体的缓存
insertModelList.forEach(item -> {
long count = distinctStudentFile.stream().filter(e -> StringUtils.equals(e.getCode(), item.getCode())).count();
List<ObjectNode> keyMap = thingCache.findKeyMap(CacheNameEnum.THING_ENTITY, item.getCode());
item.setAuthNum(count + CollectionUtils.size(keyMap));
});
thingModelService.updateBatch(updateModelList);
insertModelList.addAll(updateModelList);
}
//更新物模板缓存
if(CollectionUtils.isNotEmpty(insertModelList)){
thingModelService.saveOrUpdateBatch(insertModelList);
updateModleCache(insertModelList);
}
if(CollectionUtils.isNotEmpty(distinctStudentFile)){
entityService.saveOrUpdateBatch(distinctStudentFile);
updateEntityCache(distinctStudentFile);
}
} catch (Exception e) {
log.error("设备保存失败: {}", e.getMessage(), e);
}
@ -117,7 +160,14 @@ public class QueueDeviceEventListener {
private void updateModleCache(List<IotThingModelEntity> insertModelList) {
List<IotThingModelDTO> iotThingModelDTOS = ConvertUtils.sourceToTarget(insertModelList, IotThingModelDTO.class);
List<ObjectNode> modelList = JsonConverter.convertToJsonObjectListObjectNode(iotThingModelDTOS);
List<ObjectNode> topicMap = thingCache.getTopicMap(CacheNameEnum.THING_MODEL);
if(CollectionUtils.isNotEmpty(topicMap)){
Map<String, ObjectNode> modelMap = modelList.stream().collect(Collectors.toMap(
model -> model.get(CacheNameEnum.ModelField.THING_MODEL_CODE.getField()).asText()
+ ":" + model.get(CacheNameEnum.ModelField.THING_MODEL_ID.getField()).asText()
, Function.identity()));
thingCache.putMap(CacheNameEnum.THING_MODEL, modelMap);
}else{
for (ObjectNode item : modelList) {
//更新物模型的缓存
thingCache.updateKeyMap(CacheNameEnum.THING_MODEL
@ -125,24 +175,26 @@ public class QueueDeviceEventListener {
+ ":" + item.get(CacheNameEnum.ModelField.THING_MODEL_ID.getField()).asText(), item);
}
}
}
private void updateEntityCache(List<IotThingEntity> distinctStudentFile) {
//更新物实体缓存
List<IotThingViewDTO> entityList = distinctStudentFile.stream().map(e -> {
ObjectNode keyMap = thingCache.getKeyMap(CacheNameEnum.THING_ENTITY, e.getCode());
// ObjectNode keyMap = thingCache.getKeyMap(CacheNameEnum.THING_ENTITY, e.getCode());
ObjectNode modelMap = thingCache.findAccurateObjectNode(CacheNameEnum.THING_MODEL, e.getCode());
return new IotThingViewDTO()
.setLat(e.getLat())
.setLon(e.getLon())
.setTags(e.getTags())
.setDeptIds(e.getDeptIds())
.setOrigin(keyMap.get(CacheNameEnum.ModelField.THING_MODEL_ORIGIN.getField()).asText())
.setOrigin(modelMap.get(CacheNameEnum.ModelField.THING_MODEL_ORIGIN.getField()).asText())
.setTemplateMark(TemplateMark.NO.getValue())
.setRealType("1")
.setImg(e.getImg())
.setRemark(e.getRemark())
.setEnableStatus(e.getEnableStatus())
.setStatusTs(keyMap.get(CacheNameEnum.ModelField.THING_MODEL_STATUS_TS.getField()).asLong())
.setStatus(keyMap.get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText())
.setStatusTs(modelMap.get(CacheNameEnum.ModelField.THING_MODEL_STATUS_TS.getField()).asLong())
.setStatus(modelMap.get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText())
.setTenantCode(e.getTenantCode())
.setCompanyId(e.getTenantCode())
.setDeptId(e.getTenantCode())
@ -150,7 +202,7 @@ public class QueueDeviceEventListener {
.setEntityName(e.getName())
.setEntityCode(e.getCode())
.setEntityId(e.getId())
.setModelId(keyMap.get(CacheNameEnum.ModelField.THING_MODEL_ID.getField()).asLong())
.setModelId(modelMap.get(CacheNameEnum.ModelField.THING_MODEL_ID.getField()).asLong())
.setCreateDate(e.getCreateDate());
}).toList();
List<ObjectNode> entityJsonList = JsonConverter.convertToJsonObjectListObjectNode(entityList);
@ -162,76 +214,18 @@ public class QueueDeviceEventListener {
}
}
/**
* 物管理表是否存在不存在新增设备
*
* @param codeOriginMap 物编码
*/
private void checkAndSaveThingModels(Map<String, String> codeOriginMap, List<IotThingModelEntity> insertList,List<IotThingModelEntity> updateList) {
// 使用迭代器遍历并删除不符合条件的元素
Iterator<Map.Entry<String, String>> iterator = codeOriginMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
String code = entry.getKey();
ObjectNode jsonObject = thingCache.findObjectNode(CacheNameEnum.THING_MODEL, code);
if (null != jsonObject && !jsonObject.isEmpty()) {
IotThingModelEntity modelEntity = JacksonUtil.convertValue(jsonObject, IotThingModelEntity.class);
updateList.add(modelEntity);
iterator.remove();
}
}
codeOriginMap.forEach((thingCode, origin) -> {
IotThingModelEntity modelEntity = new IotThingModelEntity()
.setCode(thingCode)
.setToken(TokenGenerator.generateValue())
.setGateway(GateWayStatus.NO_GATE_WAY.getValue())
.setStatus(ThingStatus.NOT_CONNECTED.getCode())
.setAuthNum(0L)
.setStatusTs(DateTimeUtils.getCurrentTime())
.setOrigin(origin);
modelEntity.setId(IdUtil.getSnowflake().nextId())
.setCreateDate(DateTimeUtils.getCurrentTime())
.setCreateDate(DateTimeUtils.getCurrentTime())
;
insertList.add(modelEntity);
});
}
/**
* 保存物实体
*
* @param tenantThingCodeMap 物实体
*/
private void saveTenantThingList(Map<AuthParam, Set<String>> tenantThingCodeMap, List<IotThingEntity> insertList) {
tenantThingCodeMap.forEach(
(authParam, thingCodes) -> {
if (CollectionUtil.isEmpty(thingCodes)) {
return;
}
thingCodes.removeIf(code -> {
ObjectNode keyMap = thingCache.findObjectNode(CacheNameEnum.THING_ENTITY, authParam.getTenantCode() + ":" + code);
return null != keyMap && !keyMap.isEmpty();
});
if (CollectionUtil.isNotEmpty(thingCodes)) {
for (String newThingCode : thingCodes) {
insertList.add(createThingEntity(newThingCode, authParam));
}
}
});
}
private IotThingEntity createThingEntity(String thingCode, AuthParam authParam) {
private IotThingEntity createThingEntity(String thingCode, Long tenantCode, Long companyId, Long deptId) {
IotThingEntity entity = new IotThingEntity();
entity.setId(IdUtil.getSnowflake().nextId());
// entity.setId(IdUtil.getSnowflake().nextId());
entity.setCode(thingCode);
entity.setName(thingCode);
entity.setEnableStatus("1");
entity.setRealType("1");
entity.setTemplateMark("0");
entity.setType("默认物类型");
entity.setTenantCode(authParam.getTenantCode());
entity.setCompanyId(authParam.getCompanyId());
entity.setDeptIds(authParam.getDeptId().toString());
entity.setTenantCode(tenantCode);
entity.setCompanyId(companyId);
entity.setDeptIds(deptId.toString());
return entity;
}

33
modules/thing/src/main/java/com/thing/thing/cache/service/ThingCache.java

@ -6,10 +6,7 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@ -90,6 +87,12 @@ public final class ThingCache {
return valMap.entrySet().stream().filter(entry -> entry.getKey().contains(key)).map(Map.Entry::getValue).collect(Collectors.toList());
}
/**
* 模糊匹配
* @param topic
* @param key
* @return
*/
public ObjectNode findObjectNode(String topic, String key) {
ConcurrentHashMap<String, ObjectNode> valMap = thingMap.get(topic);
if(MapUtils.isEmpty(valMap)){
@ -99,6 +102,27 @@ public final class ThingCache {
return first.orElse(null);
}
/**
* 精确匹配
* @param topic
* @param key
* @return
*/
public ObjectNode findAccurateObjectNode(String topic, String key) {
ConcurrentHashMap<String, ObjectNode> valMap = thingMap.get(topic);
if(MapUtils.isEmpty(valMap)){
return null;
}
Optional<ObjectNode> first = valMap.entrySet().stream().filter(entry ->
Arrays.asList(entry.getKey().split(":")).contains(key)
).map(Map.Entry::getValue).findFirst();
return first.orElse(null);
}
public void deleteKeyMap(String topic, String key) {
ConcurrentHashMap<String, ObjectNode> valMap = thingMap.get(topic);
if(MapUtils.isEmpty(valMap)){
@ -132,6 +156,7 @@ public final class ThingCache {
}
//直接利用key覆盖
valMap.put(key,value);
thingMap.put(topic,valMap);
}
public List<ObjectNode> findAllKeyMap(String topic, Collection<String> key) {

2
modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java

@ -251,7 +251,7 @@ public class IotThingDictServiceImpl extends BaseServiceImpl<IotThingDictMapper,
throw new SysException("字典编码和字典类型不能为空,请检查下excel数据");
}
Map<String, Long> codeCountMap = sheetData.stream()
.collect(Collectors.groupingBy(IotThingDictExcel::getCode, Collectors.counting())); // 使用 groupingBy 收集器按照 code 进行分组并计数
.collect(Collectors.groupingBy(s-> s.getCode()+":"+s.getGroupName(), Collectors.counting())); // 使用 groupingBy 收集器按照 code 进行分组并计数
String duplicates = codeCountMap.entrySet().stream()
.filter(entry -> entry.getValue() > 1) // 过滤出计数大于 1 entry
.map(Map.Entry::getKey) // 获取过滤后的 entry key即重复的 code

Loading…
Cancel
Save