From 5fd51c437819f1c9d027a936db4ba2ee7cd2e053 Mon Sep 17 00:00:00 2001 From: ustcyc <yincun@163.com> Date: 星期二, 07 一月 2025 15:02:58 +0800 Subject: [PATCH] 升级架构 --- zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceRelevancyService.java | 62 zhitan-system/src/main/java/com/zhitan/model/service/impl/EnergyIndexServiceImpl.java | 13 zhitan-system/src/main/java/com/zhitan/singlelogin/service/impl/SingleLoginServiceImpl.java | 103 zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionItemVo.java | 29 zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPriceDate.java | 48 zhitan-system/src/main/java/com/zhitan/basicdata/services/impl/MeterImplementServiceImpl.java | 39 zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsMapper.java | 70 zhitan-admin/src/main/resources/application-dev.yml | 2 zhitan-framework/src/main/java/com/zhitan/framework/web/service/SysLoginService.java | 70 zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/vo/SpikesAndValleysSchemeVo.java | 25 zhitan-system/src/main/java/com/zhitan/basicdata/domain/MeterImplement.java | 13 zhitan-system/src/main/java/com/zhitan/system/service/impl/SysUserServiceImpl.java | 54 zhitan-system/src/main/java/com/zhitan/powerDistribution/services/IPowerDistributionService.java | 16 zhitan-system/src/main/resources/mapper/energyData/EnergyDataMapper.xml | 23 zhitan-common/src/main/java/com/zhitan/common/enums/ElectricityTypeEnum.java | 4 zhitan-framework/src/main/java/com/zhitan/framework/config/MyBatisInterceptor.java | 3 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTactics.java | 43 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsDataOutItem.java | 84 zhitan-system/src/main/java/com/zhitan/system/domain/SysPost.java | 20 zhitan-system/src/main/resources/mapper/dataitem/DataItemMapper.xml | 63 zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsItemServiceImpl.java | 90 zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsItemService.java | 61 zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/PeakValleyServiceImpl.java | 88 zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/IEnergyBenchmarkManageService.java | 75 zhitan-system/src/main/java/com/zhitan/carbonemission/service/impl/CarbonEmissionServiceImpl.java | 290 + zhitan-admin/src/main/java/com/zhitan/web/controller/gatewaysetting/GatewaySettingController.java | 1 zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/impl/EnergyBenchmarkManageServiceImpl.java | 111 zhitan-system/src/main/java/com/zhitan/peakvalley/service/IElectricityPriceDateService.java | 57 zhitan-system/src/main/resources/mapper/peakvalley/ElectricityDataItemMapper.xml | 21 zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/ElectricityPriceDateServiceImpl.java | 130 zhitan-system/src/main/java/com/zhitan/system/service/impl/SysRoleServiceImpl.java | 81 zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationProvider.java | 45 zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysSchemeMapper.xml | 88 zhitan-system/src/main/resources/mapper/system/SysUserMapper.xml | 9 zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceDateMapper.java | 8 zhitan-system/src/main/java/com/zhitan/carbonemission/service/ICarbonEmissionService.java | 35 zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceRelevancyController.java | 112 zhitan-system/src/main/java/com/zhitan/energydata/vo/EnergyChainYoyVO.java | 53 zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysLogininforController.java | 24 zhitan-system/src/main/java/com/zhitan/system/domain/SysOperLog.java | 8 zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysScheme.java | 94 zhitan-system/src/main/java/com/zhitan/benchmarkmanage/mapper/EnergyBenchmarkManageMapper.java | 64 zhitan-system/src/main/java/com/zhitan/gatewaysetting/domain/GatewaySetting.java | 4 zhitan-system/src/main/resources/mapper/powerDistribution/powerDistributionMapper.xml | 15 zhitan-framework/src/main/java/com/zhitan/framework/web/service/PermissionService.java | 41 zhitan-system/src/main/java/com/zhitan/system/service/ISysDictDataService.java | 20 zhitan-framework/src/main/java/com/zhitan/framework/config/SecurityConfig.java | 14 zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceMapper.java | 5 zhitan-admin/src/main/java/com/zhitan/web/controller/spikesandvalleys/SpikesAndValleysSchemeController.java | 122 zhitan-system/src/main/java/com/zhitan/basicdata/services/IMeterImplementService.java | 2 zhitan-system/src/main/java/com/zhitan/peakvalley/domain/vo/peakvalley/PeakValleyDayVO.java | 5 zhitan-system/src/main/java/com/zhitan/system/service/ISysPostService.java | 30 zhitan-system/src/main/java/com/zhitan/system/service/ISysUserService.java | 54 zhitan-system/src/main/java/com/zhitan/system/service/impl/SysPostServiceImpl.java | 44 zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsMapper.xml | 103 zhitan-system/src/main/resources/mapper/costmanagement/CostElectricityInputMapper.xml | 120 zhitan-system/src/main/resources/mapper/benchmarkmanage/EnergyBenchmarkManageMapper.xml | 108 zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/DeviationAnalysisController.java | 79 zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostElectricityInputService.java | 61 zhitan-system/src/main/resources/mapper/model/ModelNodeMapper.xml | 15 zhitan-system/src/main/java/com/zhitan/consumptionanalysis/service/impl/ConsumptionAnalysisServiceImpl.java | 22 zhitan-system/src/main/java/com/zhitan/energydata/mapper/EnergyDataStatisticMapper.java | 13 zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/impl/SpikesAndValleysSchemeServiceImpl.java | 176 + zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/carbonEmissionYQVO.java | 28 zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysPostController.java | 30 zhitan-framework/src/main/java/com/zhitan/framework/web/service/UserDetailsServiceImpl.java | 19 zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsController.java | 121 zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsItemMapper.java | 61 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceTacticsVo.java | 22 zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/CarbonEmissionRankVO.java | 26 zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceRelevancyMapper.java | 75 zhitan-system/src/main/java/com/zhitan/system/service/ISysLoginInfoService.java | 14 zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysUser.java | 32 zhitan-common/src/main/java/com/zhitan/common/utils/DateUtils.java | 24 zhitan-admin/lib/fel.jar | 0 zhitan-admin/src/main/resources/application-prod.yml | 2 zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/PeakValleyMapper.java | 11 zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceRelevancyServiceImpl.java | 105 zhitan-system/src/main/java/com/zhitan/singlelogin/service/ISingleLoginService.java | 13 zhitan-system/src/main/java/com/zhitan/system/service/impl/SysOperLogServiceImpl.java | 38 zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsItemMapper.xml | 108 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsData.java | 21 zhitan-system/pom.xml | 9 zhitan-system/src/main/java/com/zhitan/benchmarkmanage/domain/EnergyBenchmarkManage.java | 42 zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/DeviationAnalysisServiceServiceImpl.java | 572 +++ zhitan-system/src/main/java/com/zhitan/system/service/ISysOperLogService.java | 16 zhitan-system/src/main/java/com/zhitan/carbonemission/domain/dto/CarbonEmissionDTO.java | 28 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTacticsItem.java | 57 zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysItemMapper.java | 62 zhitan-system/src/main/java/com/zhitan/dataitem/mapper/DataItemMapper.java | 35 zhitan-admin/src/main/java/com/zhitan/web/controller/benchmarkmanage/EnergyBenchmarkManageController.java | 148 zhitan-admin/src/main/java/com/zhitan/web/controller/peakvalley/PeakValleyController.java | 1 zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysItem.java | 49 zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/ISpikesAndValleysSchemeService.java | 65 README.md | 74 zhitan-admin/src/main/java/com/zhitan/web/controller/energydatastatistics/EnergyDataStatisticsController.java | 178 + zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityPriceDateVo.java | 25 zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostElectricityInputController.java | 123 zhitan-system/src/main/java/com/zhitan/powerDistribution/services/impl/PowerDistributionServiceImpl.java | 66 zhitan-system/src/main/java/com/zhitan/powerDistribution/domain/PowerDistribution.java | 37 zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsTestController.java | 117 zhitan-system/src/main/java/com/zhitan/peakvalley/service/IPeakValleyService.java | 2 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceRelevancy.java | 51 zhitan-framework/src/main/java/com/zhitan/framework/mqtt/MqttMessageCallback.java | 89 zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java | 5 zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsServiceImpl.java | 201 + zhitan-system/src/main/java/com/zhitan/carbonemission/domain/CarbonEmission.java | 56 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/DeviationAnalysisDTO.java | 50 zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPrice.java | 12 zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysOperlogController.java | 24 zhitan-admin/src/main/java/com/zhitan/web/controller/carbonemission/CarbonEmissionController.java | 63 .gitignore | 64 zhitan-system/src/main/java/com/zhitan/home/service/HomePageServiceImpl.java | 6 zhitan-system/src/main/java/com/zhitan/system/service/ISysRoleService.java | 52 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceRelevancyVo.java | 24 zhitan-admin/src/main/java/com/zhitan/web/controller/powerDistribution/PowerDistributionController.java | 125 zhitan-system/src/main/resources/mapper/basicdata/MeterImplementMapper.xml | 6 zhitan-system/src/main/resources/mapper/energydatastatistics/EnergyDataStatisticMapper.xml | 70 zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationToken.java | 48 zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysDictDataController.java | 8 zhitan-system/src/main/java/com/zhitan/powerDistribution/mapper/PowerDistributionMapper.java | 12 zhitan-system/src/main/java/com/zhitan/basicdata/mapper/MeterImplementMapper.java | 2 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsInfoListOut.java | 47 zhitan-admin/src/main/java/com/zhitan/web/controller/singlelogin/SingleLoginController.java | 53 zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionVo.java | 37 zhitan-system/src/main/java/com/zhitan/system/service/impl/SysDictDataServiceImpl.java | 33 zhitan-system/src/main/java/com/zhitan/system/service/impl/SysLoginInfoServiceImpl.java | 33 zhitan-system/src/main/resources/mapper/model/EnergyIndexMapper.xml | 22 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOutItem.java | 54 zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsService.java | 71 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOut.java | 16 zhitan-system/src/main/java/com/zhitan/costmanagement/service/DeviationAnalysisService.java | 33 zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysItemMapper.xml | 98 zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysRole.java | 19 zhitan-system/src/main/java/com/zhitan/energydata/service/impl/EnergyDataStatisticServiceImpl.java | 1208 +++++++ zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysUserController.java | 34 zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostElectricityInputServiceImpl.java | 126 zhitan-system/src/main/java/com/zhitan/energydata/service/IEnergyDataStatisticService.java | 30 zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java | 11 zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostElectricityInputMapper.java | 61 zhitan-system/src/main/java/com/zhitan/model/mapper/EnergyIndexMapper.java | 2 zhitan-system/src/main/java/com/zhitan/energydata/vo/PurchaseConsumptionVo.java | 33 zhitan-system/src/main/resources/mapper/peakvalley/ElectricityPriceDateMapper.xml | 6 zhitan-system/src/main/resources/mapper/costmanagement/CostPriceRelevancyMapper.xml | 113 zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysSchemeMapper.java | 62 zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostElectricityInput.java | 65 zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysRoleController.java | 31 147 files changed, 8,581 insertions(+), 523 deletions(-) diff --git a/.gitignore b/.gitignore index a1c2a23..5f073e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,49 @@ -# Compiled class file -*.class +###################################################################### +# Build Tools -# Log file +.gradle +/build/ +!gradle/wrapper/gradle-wrapper.jar + +target/ +!.mvn/wrapper/maven-wrapper.jar + +###################################################################### +# IDE + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### JRebel ### +rebel.xml + +### NetBeans ### +nbproject/private/ +build/* +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +###################################################################### +# Others *.log +*.xml.versionsBackup +*.swp -# BlueJ files -*.ctxt +!*/build/*.java +!*/build/*.html +!*/build/*.xml -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* +uploadPath diff --git a/README.md b/README.md index 0a3c466..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,74 +0,0 @@ - -<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">浼佷笟鑳芥簮绠$悊骞冲彴</h1> -<h4 align="center">鍩轰簬SpringBoot鍜岃嫢渚濇鏋跺紑鍙�</h4> - - -#### 浠嬬粛 -閫氳繃鐗╄仈缃戞妧鏈紝閲囬泦浼佷笟姘淬�佺數銆佹皵銆佺儹绛夎兘鑰楁暟鎹紝甯紒涓氬缓绔嬭兘婧愮鐞嗕綋绯伙紝鎵惧埌璺戝啋婊存紡锛屼粠鑰屼负浼佷笟鑺傝兘鎻愪緵渚濇嵁銆� -杩涗竴姝ヤ负浼佷笟瀹炵幇纰宠窡韪�佺⒊鐩樻煡銆佺⒊浜ゆ槗銆佽皥姹囨姤鐨勫叏鐢熷懡杩囩▼銆� 涓轰腑鍥界⒊杈惧嘲-纰充腑鍜屽仛鍑鸿础鐚�� -閽堝瀹㈡埛鍦烘櫙锛氭斂搴溿�佸洯鍖恒�佷紒涓氥�佸伐鐭裤�佸叕鍏卞缓绛戠瓑銆� - -妗嗘灦锛氬熀浜嶴pringBoot鐨勮嫢渚濇鏋� 鏄撹鏄撴噦銆佺晫闈㈢畝娲佺編瑙傘�� -鍏崇郴鏁版嵁搴擄細influxdb -鏃跺簭鏁版嵁搴擄細mysql 鎴栬�� postgredb -涓棿浠讹細redis锛宮q - -#### 鏁版嵁椹卞姩鐨勮绠楁ā鍨嬪拰涓氬姟妯″瀷閰嶇疆 -鏀寔鍔ㄦ�佺偣浣嶉厤缃�佹暟鎹ā鍨嬨�佷笟鍔℃ā鍨嬬瓑銆� - -#### 涓氬姟鏋舵瀯 - -#### 鎶�鏈灦鏋勩�愭湭鏉ヨ鍒掋�� - -#### 浜偣鍔熻兘 - -#### 鍔熻兘瑙勫垝 -1. 棣栭〉鐪嬫澘 -2. 瀹炴椂鏁版嵁鐩戞祴 -2.1. 瀹炴椂鏁版嵁鏌ョ湅 -2.2. 缁勬�佸浘鍒嗘瀽锛坰vg 鍥剧粦瀹氾級 -3. 鍘嗗彶鏁版嵁鍒嗘瀽 -4. 缁煎悎鎸囨爣鍒嗘瀽 - 4.1. 缁煎悎鎸囨爣鍒嗘瀽锛堟棩锛� - 4.2. 缁煎悎鎸囨爣鍒嗘瀽锛堟湀锛� - 4.3. 缁煎悎鎸囨爣鍒嗘瀽锛堝勾锛� -5. 閲嶇偣璁惧鍒嗘瀽 - 5.1. 閲嶇偣璁惧鍒嗘瀽锛堟棩锛� - 5.2. 閲嶇偣璁惧鍒嗘瀽锛堟湀锛� - 5.3. 閲嶇偣璁惧鍒嗘瀽锛堝勾锛� -6. 宸ュ簭鑳借�楀垎鏋� - 6.1. 宸ュ簭鑳借�楀垎鏋愶紙鏃ワ級 - 6.2. 宸ュ簭鑳借�楀垎鏋愶紙鏈堬級 - 6.3. 宸ュ簭鑳借�楀垎鏋愶紙骞达級 -7. 灏栧嘲骞宠胺鍒嗘瀽 - 7.1. 灏栧嘲骞宠胺閰嶇疆 - 7.2. 灏栧嘲骞宠胺鏁版嵁 -8. 鑳借�楀姣斿垎鏋愶紙鍚勮兘婧愬搧绉嶏級 - 8.1. 鐢靛悓鐜瘮鍒嗘瀽 - 8.2. 姘村悓鐜瘮鍒嗘瀽 -9. 鏅鸿兘鎶ヨ - 9.1. 鎶ヨ鍒嗘瀽 - 9.2. 鎶ヨ閰嶇疆 -10. 鍗曡�楀垎鏋� -11. 璁″垝涓庡疄缁� -12. 鐢ㄨ兘鑰冩牳 -13. 鐢ㄨ兘瀵规爣 -14. 鏁版嵁琛ュ綍 -15. 鑺傝兘椤圭洰绠$悊 -16. 鑳芥簮骞宠 鍒嗘瀽 -17. 鑳芥簮瀵规爣鍒嗘瀽 -18. 妯″瀷閰嶇疆绠$悊锛堣绠楁ā鍨嬬瓑锛� -19. 鍩虹鏁版嵁绠$悊锛堝瓧鍏搞�佽兘婧愮被鍨嬬瓑锛� -20. 绯荤粺绠$悊锛堢敤鎴枫�佽鑹层�佹潈闄愮瓑锛� - -#### UI灞曠ず锛堝緟瀹屽杽锛� - -#### 婕旂ず璐﹀彿锛堝緟瀹屽杽锛� - -#### 鍙備笌璐$尞 - -1. Fork 鏈粨搴� -2. 鏂板缓 Feat_xxx 鍒嗘敮 -3. 鎻愪氦浠g爜 -4. 鏂板缓 Pull Request - diff --git a/zhitan-admin/lib/fel.jar b/zhitan-admin/lib/fel.jar new file mode 100644 index 0000000..6a2e707 --- /dev/null +++ b/zhitan-admin/lib/fel.jar Binary files differ diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java index af9d741..c3abae5 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java @@ -108,7 +108,6 @@ @GetMapping("/meter/list") public TableDataInfo meterList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) { -// startPage(); productOutput.setDataType("2"); Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); return getDataTable(list); @@ -180,7 +179,6 @@ @GetMapping("/energyindex/list") public TableDataInfo energyIndexList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) { - startPage(); productOutput.setDataType("3"); Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); return getDataTable(list); @@ -253,7 +251,6 @@ // @GetMapping("/energyYield/list") // public TableDataInfo energyYieldList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) // { -//// startPage(); // productOutput.setDataType("5"); // productOutput.setTimeType("MONTH"); // Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); @@ -347,7 +344,6 @@ // @GetMapping("/energyPlanYield/list") // public TableDataInfo energyPlanYieldList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) // { -//// startPage(); // productOutput.setDataType("4"); // productOutput.setTimeType("MONTH"); // Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); @@ -442,7 +438,6 @@ // @GetMapping("/energySettlement/list") // public TableDataInfo energySettlementList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) // { -//// startPage(); // productOutput.setDataType("6"); // productOutput.setTimeType("MONTH"); // Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/benchmarkmanage/EnergyBenchmarkManageController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/benchmarkmanage/EnergyBenchmarkManageController.java new file mode 100644 index 0000000..f4611e5 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/benchmarkmanage/EnergyBenchmarkManageController.java @@ -0,0 +1,148 @@ +package com.zhitan.web.controller.benchmarkmanage; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage; +import com.zhitan.benchmarkmanage.service.IEnergyBenchmarkManageService; +import com.zhitan.common.annotation.Log; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.core.domain.model.LoginUser; +import com.zhitan.common.core.page.TableDataInfo; +import com.zhitan.common.enums.BusinessType; +import com.zhitan.common.utils.ServletUtils; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.common.utils.poi.ExcelUtil; +import com.zhitan.framework.web.service.TokenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.UUID; + +/** + * 鏍囨潌鍊肩鐞咰ontroller + * + * @author ZhiTan + * @date 2024-11-12 + */ +@RestController +@RequestMapping("/benchmarkManage") +public class EnergyBenchmarkManageController extends BaseController +{ + @Resource + private IEnergyBenchmarkManageService energyBenchmarkManageService; + + @Autowired + private TokenService tokenService; + + /** + * 鏌ヨ鏍囨潌鍊肩鐞嗗垪琛� + */ + @PreAuthorize("@ss.hasPermi('system:benchmarkManage:list')") + @GetMapping("/list") + public TableDataInfo list(EnergyBenchmarkManage energyBenchmarkManage, @RequestParam Long pageNum, @RequestParam Long pageSize) + { + // startPage(); + Page<EnergyBenchmarkManage> list = energyBenchmarkManageService.selectBenchmarkManagePage(energyBenchmarkManage,pageNum,pageSize); + return getDataTable(list); + } + + + /** + * 瀵煎嚭鏍囨潌鍊肩鐞嗗垪琛� + */ + @PreAuthorize("@ss.hasPermi('system:benchmarkManage:export')") + @Log(title = "鏍囨潌鍊肩鐞�", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EnergyBenchmarkManage energyBenchmarkManage) + { + List<EnergyBenchmarkManage> list = energyBenchmarkManageService.selectEnergyBenchmarkManageList(energyBenchmarkManage); + ExcelUtil<EnergyBenchmarkManage> util = new ExcelUtil<EnergyBenchmarkManage>(EnergyBenchmarkManage.class); + util.exportExcel(response, list, "鏍囨潌鍊肩鐞嗘暟鎹�"); + } + + /** + * 鑾峰彇鏍囨潌鍊肩鐞嗚缁嗕俊鎭� + */ + @PreAuthorize("@ss.hasPermi('system:benchmarkManage:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(energyBenchmarkManageService.selectEnergyBenchmarkManageById(id)); + } + + /** + * 鏂板鏍囨潌鍊肩鐞� + */ + @PreAuthorize("@ss.hasPermi('system:benchmarkManage:add')") + @Log(title = "鏍囨潌鍊肩鐞�", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EnergyBenchmarkManage energyBenchmarkManage) + { + if (StringUtils.isBlank(energyBenchmarkManage.getCode())) { + return error("璇疯緭鍏ユ爣鏉嗙紪鍙凤紒"); + } + + //鏍¢獙鍞竴 + EnergyBenchmarkManage queryParams=new EnergyBenchmarkManage(); + queryParams.setCode(energyBenchmarkManage.getCode()); + List<EnergyBenchmarkManage> codeReptList = energyBenchmarkManageService.getList(queryParams); + if (null!=codeReptList && !codeReptList.isEmpty()) { + return error("鏍囨潌缂栧彿閲嶅锛�"); + } + queryParams=new EnergyBenchmarkManage(); + queryParams.setType(energyBenchmarkManage.getType()); + queryParams.setGrade(energyBenchmarkManage.getGrade()); + List<EnergyBenchmarkManage> dataReptList = energyBenchmarkManageService.getList(queryParams); + if (null!=dataReptList && !dataReptList.isEmpty()) { + return error("鏍囨潌淇℃伅宸茬淮鎶わ紒"); + } + energyBenchmarkManage.setId(UUID.randomUUID().toString()); + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + energyBenchmarkManage.setCreateBy(loginUser.getUsername()); + return toAjax(energyBenchmarkManageService.insertEnergyBenchmarkManage(energyBenchmarkManage)); + } + + /** + * 淇敼鏍囨潌鍊肩鐞� + */ + @PreAuthorize("@ss.hasPermi('system:benchmarkManage:edit')") + @Log(title = "鏍囨潌鍊肩鐞�", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EnergyBenchmarkManage energyBenchmarkManage) + { + if (StringUtils.isBlank(energyBenchmarkManage.getCode())) { + return error("璇疯緭鍏ユ爣鏉嗙紪鍙凤紒"); + } + EnergyBenchmarkManage queryParams=new EnergyBenchmarkManage(); + queryParams.setCode(energyBenchmarkManage.getCode()); + List<EnergyBenchmarkManage> codeReptList = energyBenchmarkManageService.getList(queryParams); + if (null!=codeReptList && !codeReptList.isEmpty()) { + return error("鏍囨潌缂栧彿閲嶅锛�"); + } + queryParams=new EnergyBenchmarkManage(); + queryParams.setType(energyBenchmarkManage.getType()); + queryParams.setGrade(energyBenchmarkManage.getGrade()); + List<EnergyBenchmarkManage> dataReptList = energyBenchmarkManageService.getList(queryParams); + if (null!=dataReptList && !dataReptList.isEmpty()) { + return error("鏍囨潌淇℃伅宸茬淮鎶わ紒"); + } + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + energyBenchmarkManage.setUpdateBy(loginUser.getUsername()); + return toAjax(energyBenchmarkManageService.updateEnergyBenchmarkManage(energyBenchmarkManage)); + } + + /** + * 鍒犻櫎鏍囨潌鍊肩鐞� + */ + @PreAuthorize("@ss.hasPermi('system:benchmarkManage:remove')") + @Log(title = "鏍囨潌鍊肩鐞�", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(energyBenchmarkManageService.deleteEnergyBenchmarkManageByIds(ids)); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/carbonemission/CarbonEmissionController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/carbonemission/CarbonEmissionController.java new file mode 100644 index 0000000..be430ba --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/carbonemission/CarbonEmissionController.java @@ -0,0 +1,63 @@ +package com.zhitan.web.controller.carbonemission; + +import com.zhitan.basicdata.domain.FacilityAnnex; +import com.zhitan.carbonemission.domain.dto.CarbonEmissionDTO; +import com.zhitan.carbonemission.domain.vo.carbonEmissionYQVO; +import com.zhitan.carbonemission.service.ICarbonEmissionService; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.core.page.TableDataInfo; +import com.zhitan.common.utils.poi.ExcelUtil; +import com.zhitan.web.controller.basicdata.FacilityAnnexController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.HttpMediaTypeException; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * 纰虫帓鏀炬牳绠桟ontroller + * + * @author lsk + * @date 2024-10-29 + */ +@RestController +@RequestMapping("/carbonEmission") +public class CarbonEmissionController extends BaseController +{ + + @Resource + private ICarbonEmissionService carbonEmissionService; + + private static final Logger log = LoggerFactory.getLogger(CarbonEmissionController.class); + + + + @GetMapping("/up") + public AjaxResult up(CarbonEmissionDTO carbonEmissionDTO) + { + final Map<String, Object> upCarbonEmission = carbonEmissionService.getUpCarbonEmission(carbonEmissionDTO); + return AjaxResult.success(upCarbonEmission); + } + + @GetMapping("/middle") + public AjaxResult middle(CarbonEmissionDTO carbonEmissionDTO) + { + final List<carbonEmissionYQVO> carbonEmissionYQVO = carbonEmissionService.getMiddleCarbonEmission(carbonEmissionDTO); + return AjaxResult.success(carbonEmissionYQVO); + } + + @PostMapping("/export") + @ResponseBody + public void export(HttpServletResponse response, CarbonEmissionDTO carbonEmissionDTO) + { + List<carbonEmissionYQVO> carbonEmissionYQVO = carbonEmissionService.getMiddleCarbonEmission(carbonEmissionDTO); + ExcelUtil<carbonEmissionYQVO> util = new ExcelUtil<carbonEmissionYQVO>(carbonEmissionYQVO.class); + util.exportExcel(response,carbonEmissionYQVO, "纰虫帓鏀鹃噺鍚岀幆姣�"); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostElectricityInputController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostElectricityInputController.java new file mode 100644 index 0000000..c990f72 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostElectricityInputController.java @@ -0,0 +1,123 @@ +package com.zhitan.web.controller.costmanagement; + +import java.math.BigDecimal; +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhitan.common.core.domain.model.LoginUser; +import com.zhitan.common.core.page.TableDataInfo; +import com.zhitan.common.utils.ServletUtils; +import com.zhitan.framework.web.service.TokenService; +import com.zhitan.spikesandvalleys.domain.vo.SpikesAndValleysSchemeVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.zhitan.common.annotation.Log; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.enums.BusinessType; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import com.zhitan.costmanagement.service.ICostElectricityInputService; +import com.zhitan.common.utils.poi.ExcelUtil; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慍ontroller + * + * @author ZhiTan + * @date 2024-11-08 + */ +@RestController +@RequestMapping("/cost/input") +public class CostElectricityInputController extends BaseController +{ + @Resource + private ICostElectricityInputService costElectricityInputService; + @Autowired + private TokenService tokenService; + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + */ + @PreAuthorize("@ss.hasPermi('system:Input:list')") + @GetMapping("/list") + public TableDataInfo list(CostElectricityInput costElectricityInput,Long pageNum, Long pageSize) + { +// startPage(); +// List<CostElectricityInput> list = costElectricityInputService.selectCostElectricityInputList(costElectricityInput); + Page<CostElectricityInput> page = costElectricityInputService.selectCostElectricityInputList(costElectricityInput, pageNum, pageSize); + return getDataTable(page); + } + + + /** + * 瀵煎嚭銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + */ +// @PreAuthorize("@ss.hasPermi('system:Input:export')") +// @Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, CostElectricityInput costElectricityInput) +// { +// List<CostElectricityInput> list = costElectricityInputService.selectCostElectricityInputList(costElectricityInput); +// ExcelUtil<CostElectricityInput> util = new ExcelUtil<CostElectricityInput>(CostElectricityInput.class); +// util.exportExcel(response, list, "銆愯濉啓鍔熻兘鍚嶇О銆戞暟鎹�"); +// } + + /** + * 鑾峰彇銆愯濉啓鍔熻兘鍚嶇О銆戣缁嗕俊鎭� + */ + @PreAuthorize("@ss.hasPermi('system:Input:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(costElectricityInputService.selectCostElectricityInputById(id)); + } + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + */ + @PreAuthorize("@ss.hasPermi('system:Input:add')") + @Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CostElectricityInput costElectricityInput) throws Exception { + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + costElectricityInput.setCreateBy(loginUser.getUsername()); + //鏍¢獙灏栧嘲骞宠胺鐢甸噺鐩稿姞鏄惁=鎬荤敤鐢� + BigDecimal total = costElectricityInput.getFlatElectricity().add(costElectricityInput.getSharpElectricity()). + add(costElectricityInput.getPeakElectricity()).add(costElectricityInput.getValleyElectricity()); + if(total.compareTo(costElectricityInput.getElectricityNum())!=0){ + return AjaxResult.error("灏栧嘲骞宠胺鐢甸噺鐩稿姞涓嶇瓑浜庢�荤敤鐢甸噺"); + } + return toAjax(costElectricityInputService.insertCostElectricityInput(costElectricityInput)); + } + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + */ + @PreAuthorize("@ss.hasPermi('system:Input:edit')") + @Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CostElectricityInput costElectricityInput) throws Exception { + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + costElectricityInput.setUpdateBy(loginUser.getUsername()); + return toAjax(costElectricityInputService.updateCostElectricityInput(costElectricityInput)); + } + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + */ + @PreAuthorize("@ss.hasPermi('system:Input:remove')") + @Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(costElectricityInputService.deleteCostElectricityInputByIds(ids)); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceRelevancyController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceRelevancyController.java new file mode 100644 index 0000000..7a1c76a --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceRelevancyController.java @@ -0,0 +1,112 @@ +package com.zhitan.web.controller.costmanagement; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhitan.common.core.page.TableDataInfo; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import com.zhitan.framework.web.service.TokenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.zhitan.common.annotation.Log; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.enums.BusinessType; +import com.zhitan.costmanagement.domain.CostPriceRelevancy; +import com.zhitan.costmanagement.service.ICostPriceRelevancyService; +import com.zhitan.common.utils.poi.ExcelUtil; + +/** + * 鍗曚环鍏宠仈Controller + * + * @author ZhiTan + * @date 2024-11-09 + */ +@RestController +@RequestMapping("/cost/relevancy") +public class CostPriceRelevancyController extends BaseController +{ + @Resource + private ICostPriceRelevancyService costPriceRelevancyService; + @Autowired + private TokenService tokenService; + + /** + * 鏌ヨ鍗曚环鍏宠仈鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:relevancy:list')") + @GetMapping("/list") + public TableDataInfo list(CostPriceRelevancy costPriceRelevancy,Long pageNum, Long pageSize) + { + startPage(); + Page<CostPriceRelevancy> page = costPriceRelevancyService.selectCostPriceRelevancyList(costPriceRelevancy, pageNum, pageSize); + return getDataTable(page); + } + + +// /** +// * 瀵煎嚭鍗曚环鍏宠仈鍒楄〃 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:relevancy:export')") +// @Log(title = "鍗曚环鍏宠仈", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, CostPriceRelevancy costPriceRelevancy) +// { +// List<CostPriceRelevancy> list = costPriceRelevancyService.selectCostPriceRelevancyList(costPriceRelevancy); +// ExcelUtil<CostPriceRelevancy> util = new ExcelUtil<CostPriceRelevancy>(CostPriceRelevancy.class); +// util.exportExcel(response, list, "鍗曚环鍏宠仈鏁版嵁"); +// } + + /** + * 鑾峰彇鍗曚环鍏宠仈璇︾粏淇℃伅 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:relevancy:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(costPriceRelevancyService.selectCostPriceRelevancyById(id)); + } + + /** + * 鏂板鍗曚环鍏宠仈 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:relevancy:add')") + @Log(title = "鍗曚环鍏宠仈", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CostPriceRelevancy costPriceRelevancy) + { + return toAjax(costPriceRelevancyService.insertCostPriceRelevancy(costPriceRelevancy)); + } + + /** + * 淇敼鍗曚环鍏宠仈 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:relevancy:edit')") + @Log(title = "鍗曚环鍏宠仈", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CostPriceRelevancy costPriceRelevancy) + { + return toAjax(costPriceRelevancyService.updateCostPriceRelevancy(costPriceRelevancy)); + } + + /** + * 鍒犻櫎鍗曚环鍏宠仈 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:relevancy:remove')") + @Log(title = "鍗曚环鍏宠仈", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(costPriceRelevancyService.deleteCostPriceRelevancyByIds(ids)); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsController.java new file mode 100644 index 0000000..e68e54c --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsController.java @@ -0,0 +1,121 @@ +package com.zhitan.web.controller.costmanagement; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhitan.common.annotation.Log; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.core.domain.model.LoginUser; +import com.zhitan.common.core.page.TableDataInfo; +import com.zhitan.common.enums.BusinessType; +import com.zhitan.common.utils.ServletUtils; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.zhitan.costmanagement.domain.vo.CostPriceTacticsVo; +import com.zhitan.costmanagement.service.ICostPriceTacticsService; +import com.zhitan.framework.web.service.TokenService; +import com.zhitan.peakvalley.service.IElectricityPriceDateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 鎴愭湰绛栫暐Controller + * + * @author ZhiTan + * @date 2024-11-08 + */ +@RestController +@RequestMapping("/cost/tactics") +public class CostPriceTacticsController extends BaseController +{ + @Resource + private ICostPriceTacticsService costPriceTacticsService; + @Autowired + private TokenService tokenService; + @Resource + private IElectricityPriceDateService electricityPriceDateService; + + /** + * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:tactics:list')") + @GetMapping("/list") + public TableDataInfo list(CostPriceTactics costPriceTactics,Long pageNum, Long pageSize) + { + Page<CostPriceTacticsVo> page = costPriceTacticsService.selectCostPriceTacticsList(costPriceTactics, pageNum, pageSize); + + return getDataTable(page); + } + /** + * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:tactics:list')") + @GetMapping("/allList") + public AjaxResult allList() + { + List<CostPriceTacticsVo> list = costPriceTacticsService.selectCostPriceTacticsListAll(); + + return AjaxResult.success(list); + } + +// /** +// * 瀵煎嚭鎴愭湰绛栫暐鍒楄〃 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:tactics:export')") +// @Log(title = "鎴愭湰绛栫暐", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, CostPriceTactics costPriceTactics) +// { +// List<CostPriceTactics> list = costPriceTacticsService.selectCostPriceTacticsList(costPriceTactics); +// ExcelUtil<CostPriceTactics> util = new ExcelUtil<CostPriceTactics>(CostPriceTactics.class); +// util.exportExcel(response, list, "鎴愭湰绛栫暐鏁版嵁"); +// } + + /** + * 鑾峰彇鎴愭湰绛栫暐璇︾粏淇℃伅 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:tactics:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(costPriceTacticsService.selectCostPriceTacticsById(id)); + } + + /** + * 鏂板鎴愭湰绛栫暐 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:tactics:add')") + @Log(title = "鎴愭湰绛栫暐", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CostPriceTacticsVo costPriceTacticsVo) throws Exception { + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + costPriceTacticsVo.setCreateBy(loginUser.getUsername()); + return toAjax(costPriceTacticsService.insertCostPriceTactics(costPriceTacticsVo)); + } + + /** + * 淇敼鎴愭湰绛栫暐 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:tactics:edit')") + @Log(title = "鎴愭湰绛栫暐", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CostPriceTacticsVo costPriceTacticsVo) + { + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + costPriceTacticsVo.setUpdateBy(loginUser.getUsername()); + return toAjax(costPriceTacticsService.updateCostPriceTactics(costPriceTacticsVo)); + } + + /** + * 鍒犻櫎鎴愭湰绛栫暐 + */ + @PreAuthorize("@ss.hasPermi('costmanagement:tactics:remove')") + @Log(title = "鎴愭湰绛栫暐", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(costPriceTacticsService.deleteCostPriceTacticsByIds(ids)); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsTestController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsTestController.java new file mode 100644 index 0000000..2e3f144 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/CostPriceTacticsTestController.java @@ -0,0 +1,117 @@ +//package com.zhitan.web.controller.costmanagement; +// +//import java.util.List; +// +//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +//import com.zhitan.common.core.domain.model.LoginUser; +//import com.zhitan.common.core.page.TableDataInfo; +//import com.zhitan.common.utils.ServletUtils; +//import com.zhitan.costmanagement.domain.vo.ElectricityPriceDateVo; +//import com.zhitan.framework.web.service.TokenService; +//import com.zhitan.peakvalley.domain.ElectricityPriceDate; +//import com.zhitan.peakvalley.service.IElectricityPriceDateService; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.security.access.prepost.PreAuthorize; +//import javax.annotation.Resource; +//import org.springframework.web.bind.annotation.GetMapping; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.PutMapping; +//import org.springframework.web.bind.annotation.DeleteMapping; +//import org.springframework.web.bind.annotation.PathVariable; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +//import com.zhitan.common.annotation.Log; +//import com.zhitan.common.core.controller.BaseController; +//import com.zhitan.common.core.domain.AjaxResult; +//import com.zhitan.common.enums.BusinessType; +//import com.zhitan.costmanagement.service.ICostPriceTacticsService; +// +///** +// * 鎴愭湰绛栫暐Controller +// * +// * @author ZhiTan +// * @date 2024-11-08 +// */ +//@RestController +//@RequestMapping("/cost/tactics") +//public class CostPriceTacticsTestController extends BaseController +//{ +// @Resource +// private ICostPriceTacticsService costPriceTacticsService; +// @Autowired +// private TokenService tokenService; +// @Resource +// private IElectricityPriceDateService electricityPriceDateService; +// +// +// /** +// * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:tactics:list')") +// @GetMapping("/list") +// public TableDataInfo list(ElectricityPriceDate electricityPriceDate, Long pageNum, Long pageSize) +// { +// Page<ElectricityPriceDateVo> page = electricityPriceDateService.selectElectricityPriceDatePageTactics(electricityPriceDate, pageNum, pageSize); +// +// return getDataTable(page); +// } +// /** +// * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:tactics:list')") +// @GetMapping("/allList") +// public AjaxResult allList() +// { +// List<ElectricityPriceDate> list = electricityPriceDateService.selectElectricityPriceDatePageTacticsAll(); +// return AjaxResult.success(list); +// } +// +// +// +// /** +// * 鑾峰彇鎴愭湰绛栫暐璇︾粏淇℃伅 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:tactics:query')") +// @GetMapping(value = "/{id}") +// public AjaxResult getInfo(@PathVariable("id") String id) +// { +// return success(electricityPriceDateService.selectCostPriceTacticsById(id)); +// } +// +// /** +// * 鏂板鎴愭湰绛栫暐 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:tactics:add')") +// @Log(title = "鎴愭湰绛栫暐", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@RequestBody ElectricityPriceDateVo electricityPriceDateVo) throws Exception { +// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); +// electricityPriceDateVo.setCreateBy(loginUser.getUsername()); +// return toAjax(electricityPriceDateService.insertCostPriceTactics(electricityPriceDateVo)); +// } +// +// /** +// * 淇敼鎴愭湰绛栫暐 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:tactics:edit')") +// @Log(title = "鎴愭湰绛栫暐", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@RequestBody ElectricityPriceDateVo electricityPriceDateVo) +// { +// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); +// electricityPriceDateVo.setUpdateBy(loginUser.getUsername()); +// return toAjax(electricityPriceDateService.updateCostPriceTactics(electricityPriceDateVo)); +// } +// +// /** +// * 鍒犻櫎鎴愭湰绛栫暐 +// */ +// @PreAuthorize("@ss.hasPermi('costmanagement:tactics:remove')") +// @Log(title = "鎴愭湰绛栫暐", businessType = BusinessType.DELETE) +// @DeleteMapping("/{ids}") +// public AjaxResult remove(@PathVariable String[] ids) +// { +// return toAjax(electricityPriceDateService.deleteCostPriceTacticsByIds(ids)); +// } +//} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/DeviationAnalysisController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/DeviationAnalysisController.java new file mode 100644 index 0000000..6e36139 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/costmanagement/DeviationAnalysisController.java @@ -0,0 +1,79 @@ +package com.zhitan.web.controller.costmanagement; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhitan.common.annotation.Log; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.core.domain.model.LoginUser; +import com.zhitan.common.core.page.TableDataInfo; +import com.zhitan.common.enums.BusinessType; +import com.zhitan.common.utils.ServletUtils; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import com.zhitan.costmanagement.domain.vo.*; +import com.zhitan.costmanagement.service.DeviationAnalysisService; +import com.zhitan.costmanagement.service.ICostElectricityInputService; +import com.zhitan.framework.web.service.TokenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慍ontroller + * + * @author ZhiTan + * @date 2024-11-08 + */ +@RestController +@RequestMapping("/cost/statistics") +public class DeviationAnalysisController extends BaseController +{ + @Resource + private ICostElectricityInputService costElectricityInputService; + @Autowired + private TokenService tokenService; + @Autowired + private DeviationAnalysisService deviationAnalysisService; + /** + * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 + */ + + @GetMapping("/statistics") + public AjaxResult statistics(DeviationAnalysisDTO dto) throws ParseException { + Map<String,Object>result = new HashMap<>(); + StatisticsDataOutItem statisticsDataItem = deviationAnalysisService.getStatisticsDataItem(dto); + ElectricityDataOutItem electricityDataItem = deviationAnalysisService.getElectricityDataItem(dto); + result.put("CostElectricityData",electricityDataItem); + result.put("CostStatisticsData",statisticsDataItem); + + return AjaxResult.success(result); + } + @GetMapping("/test") + public AjaxResult test(DeviationAnalysisDTO dto) throws ParseException { + deviationAnalysisService.getStatisticsInfoList(dto); + return AjaxResult.success(deviationAnalysisService.getStatisticsInfoList2(dto)); + } + + @GetMapping("/getStatisticsInfoList") + public AjaxResult getStatisticsInfoList(DeviationAnalysisDTO dto) throws ParseException { + + return AjaxResult.success(deviationAnalysisService.getStatisticsInfoList(dto)); + } + + @GetMapping("/getStatisticsInfoEcharts") + public AjaxResult echarts(DeviationAnalysisDTO dto) throws ParseException { + Map<String,Object>result = new HashMap<>(); + + + result = deviationAnalysisService.getEcharst(dto); + + return AjaxResult.success(result); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/energydatastatistics/EnergyDataStatisticsController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/energydatastatistics/EnergyDataStatisticsController.java new file mode 100644 index 0000000..0342f18 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/energydatastatistics/EnergyDataStatisticsController.java @@ -0,0 +1,178 @@ +package com.zhitan.web.controller.energydatastatistics; + +import com.zhitan.common.annotation.Anonymous; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.consumptionanalysis.domain.vo.RankingEnergyData; +import com.zhitan.energydata.service.IEnergyDataStatisticService; +import com.zhitan.energydata.vo.FactoryEnergyConsumptionVo; +import com.zhitan.energydata.vo.PurchaseConsumptionVo; +import com.zhitan.home.domain.vo.HomePeakValleyVO; +import com.zhitan.home.service.impl.IHomePageService; +import com.zhitan.peakvalley.domain.dto.PeakValleyDTO; +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.RestController; + +import java.util.Date; +import java.util.List; + +/** + * 鎭掗偊鑳芥簮鏁版嵁缁煎悎鍒嗘瀽 + * + * @author ZhiTan + * @date 2024-10-30 + */ +@RestController +@RequestMapping("/energydatahomepage") +@Anonymous +public class EnergyDataStatisticsController extends BaseController +{ + + @Autowired + public IHomePageService homepageService; + + @Autowired + private IEnergyDataStatisticService statisticService; + + /** + * @description: 褰撴棩鑳借�楃粺璁� + * @return + */ + @GetMapping("/energyConsumptionSummation/day") + public AjaxResult energyConsumptionSummationDay() { + try { + String timeType = "DAY"; + String modelCode = "COMPREHENSIVE_CODE"; + return AjaxResult.success(homepageService.energyConsumptionSummation(timeType,modelCode)); + } catch (Exception ex) { + logger.error("鑾峰彇鍑洪敊锛�", ex); + return AjaxResult.error("鑾峰彇鍑洪敊!"); + } + } + + /** + * 鐢靛悓鐜瘮鍒嗘瀽 + * @param timeType:month銆亂ear + * @return + */ + @GetMapping("/energyConsumptionSummation") + public AjaxResult energyConsumptionSummation(String timeType) { + try { + String modelCode = "COMPREHENSIVE_CODE"; + return AjaxResult.success(statisticService.energyConsumptionSummation(timeType,modelCode)); + } catch (Exception ex) { + logger.error("鑾峰彇鍑洪敊锛�", ex); + return AjaxResult.error("鑾峰彇鍑洪敊!"); + } + } + + /** + * @description: 鍚勫巶鍖哄綋鏈堣兘鑰楃粺璁� + * @return + */ + @GetMapping("/factoryEnergyConsumption") + public AjaxResult factoryEnergyConsumption() { + try { + String timeType = "MONTH"; + String modelCode = "COMPREHENSIVE_CODE"; + FactoryEnergyConsumptionVo vo=statisticService.factoryEnergyConsumption(timeType,modelCode); + return AjaxResult.success(vo); + } catch (Exception ex) { + logger.error("鑾峰彇鍑洪敊锛�", ex); + return AjaxResult.error("鑾峰彇鍑洪敊!"); + } + } + + /** + * 鐢ㄧ數瓒嬪娍鍒嗘瀽---鎸夊勾锛氬線鍓嶆帹12涓湀锛屾瘡涓湀缁熻 + * @return + */ + @GetMapping("/segmentAnalysis/year") + public AjaxResult segmentAnalysisMonth() { + PeakValleyDTO dto =new PeakValleyDTO(); + dto.setModelCode("COMPREHENSIVE_CODE"); + dto.setTimeType("YEAR"); + dto.setQueryTime(new Date()); + return AjaxResult.success(statisticService.segmentAnalysisMonth(dto)); + } + + + /** + * 鐢ㄧ數瓒嬪娍缁熻---鎸夋湀 + * @return + */ + @GetMapping("/segmentAnalysis/month") + public AjaxResult segmentAnalysisDay() { + PeakValleyDTO dto =new PeakValleyDTO(); + dto.setModelCode("COMPREHENSIVE_CODE"); + dto.setTimeType("MONTH"); + dto.setQueryTime(new Date()); + return AjaxResult.success(statisticService.segmentAnalysisDay(dto)); + } + + /** + * 鐢ㄧ數瓒嬪娍缁熻---鎸夋棩 + * @return + */ + @GetMapping("/segmentAnalysis/day") + public AjaxResult segmentAnalysisHour() { + PeakValleyDTO dto =new PeakValleyDTO(); + dto.setModelCode("COMPREHENSIVE_CODE"); + dto.setTimeType("DAY"); + dto.setQueryTime(new Date()); + return AjaxResult.success(statisticService.segmentAnalysisHour(dto)); + } + + /** + * @description: 璐叆鍜屾秷鑰楀姣� + * @return + */ + @GetMapping("/purchaseConsumption") + public AjaxResult purchaseConsumption() { + String timeType="MONTH"; + String modelCode = "COMPREHENSIVE_CODE"; + List<PurchaseConsumptionVo> consumptionAnalysisVO = statisticService.purchaseConsumption(modelCode,timeType); + return AjaxResult.success(consumptionAnalysisVO); + } + + /** + * @description: 绉戝鑳借�楁帓鍚� + * @return + */ + @GetMapping("/energyConsumptionRanking") + public AjaxResult energyConsumptionRanking(String timeType) { + String modelCode = "COMPREHENSIVE_CODE"; + List<RankingEnergyData> consumptionAnalysisVO = statisticService.energyConsumptionRanking(modelCode,timeType); + return AjaxResult.success(consumptionAnalysisVO); + } + + /** + * @description: 鑳芥簮鎴愭湰鍗犳瘮 + * @return + */ + @GetMapping("/costProp") + public AjaxResult costProp(String timeType) { + String modelCode = "COMPREHENSIVE_CODE"; + List<PurchaseConsumptionVo> consumptionAnalysisVO = statisticService.costProp(modelCode, timeType); + return AjaxResult.success(consumptionAnalysisVO); + + } + + /** + * @description: 灏栧嘲骞宠胺鍗犳瘮 + * @param timeType + */ + @GetMapping("/peakValley") + public AjaxResult peakValley(String timeType) { + try { + String modelcode = "COMPREHENSIVE_CODE"; + List<HomePeakValleyVO> vo = homepageService.peakValley(timeType,modelcode); + return AjaxResult.success(vo); + } catch (Exception ex) { + logger.error("鑾峰彇鍑洪敊锛�", ex); + return AjaxResult.error("鑾峰彇鍑洪敊!"); + } + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/gatewaysetting/GatewaySettingController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/gatewaysetting/GatewaySettingController.java index 7c27a6b..7aacad0 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/gatewaysetting/GatewaySettingController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/gatewaysetting/GatewaySettingController.java @@ -44,7 +44,6 @@ @GetMapping("/list") public TableDataInfo list(GatewaySetting gatewaySetting,@RequestParam Long pageNum,@RequestParam Long pageSize) { -// startPage(); Page<GatewaySetting> list = gatewaySettingService.selectGatewaySettingPage(gatewaySetting,pageNum,pageSize); return getDataTable(list); } diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java index ec027ed..00cff85 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java @@ -28,14 +28,15 @@ /** * @description: 鍏ㄥ巶鑳借�楃粺璁� * @param timeType - * @return + * @return * @author: hmj * @date: 2024/10/8 13:41 */ @GetMapping("/energyConsumptionSummation") public AjaxResult energyConsumptionSummation(String timeType) { try { - String modelcode = "Composite_Indicators"; +// String modelcode = "Composite_Indicators"; + String modelcode = "COMPREHENSIVE_CODE"; return AjaxResult.success(homepageService.energyConsumptionSummation(timeType,modelcode)); } catch (Exception ex) { logger.error("鑾峰彇鍑洪敊锛�", ex); @@ -54,7 +55,7 @@ @GetMapping("/energyConsumptionTrend") public AjaxResult energyConsumptionTrend(String timeType) { try { - String modelcode = "Composite_Indicators"; + String modelcode = "COMPREHENSIVE_CODE"; HomeEnergyConsumptionTrendVO vo = homepageService.energyConsumptionTrend(timeType,modelcode); return AjaxResult.success(vo); @@ -74,7 +75,7 @@ @GetMapping("/energyConsumptionRanking") public AjaxResult energyConsumptionRanking(String timeType) { try { - String modelcode = "Composite_Indicators"; + String modelcode = "COMPREHENSIVE_CODE"; List<RankingEnergyData> consumptionAnalysisVO = homepageService.energyConsumptionRanking(modelcode,timeType); return AjaxResult.success(consumptionAnalysisVO); } catch (Exception ex) { @@ -94,7 +95,7 @@ public AjaxResult peakValley(String timeType) { try { // String modelcode = "Composite_Indicators"; - String modelcode = "PEAK_VALLEY"; + String modelcode = "COMPREHENSIVE_CODE"; List<HomePeakValleyVO> vo = homepageService.peakValley(timeType,modelcode); return AjaxResult.success(vo); } catch (Exception ex) { diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysLogininforController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysLogininforController.java index 8550814..50c4bd1 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysLogininforController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysLogininforController.java @@ -1,15 +1,6 @@ package com.zhitan.web.controller.monitor; -import java.util.List; -import javax.servlet.http.HttpServletResponse; -import javax.annotation.Resource; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.annotation.Log; import com.zhitan.common.core.controller.BaseController; import com.zhitan.common.core.domain.AjaxResult; @@ -19,10 +10,16 @@ import com.zhitan.framework.web.service.SysPasswordService; import com.zhitan.system.domain.SysLoginInfo; import com.zhitan.system.service.ISysLoginInfoService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 绯荤粺璁块棶璁板綍 - * + * * @author zhitan */ @RestController @@ -37,10 +34,9 @@ @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')") @GetMapping("/list") - public TableDataInfo list(SysLoginInfo logininfor) + public TableDataInfo list(SysLoginInfo logininfor,Long pageNum, Long pageSize) { - startPage(); - List<SysLoginInfo> list = logininforService.selectLogininforList(logininfor); + Page<SysLoginInfo> list = logininforService.selectLogininforPage(logininfor,pageNum,pageSize); return getDataTable(list); } diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysOperlogController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysOperlogController.java index 247828e..0caaf4e 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysOperlogController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/monitor/SysOperlogController.java @@ -1,15 +1,6 @@ package com.zhitan.web.controller.monitor; -import java.util.List; -import javax.servlet.http.HttpServletResponse; -import javax.annotation.Resource; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.annotation.Log; import com.zhitan.common.core.controller.BaseController; import com.zhitan.common.core.domain.AjaxResult; @@ -18,10 +9,16 @@ import com.zhitan.common.utils.poi.ExcelUtil; import com.zhitan.system.domain.SysOperLog; import com.zhitan.system.service.ISysOperLogService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 鎿嶄綔鏃ュ織璁板綍 - * + * * @author zhitan */ @RestController @@ -33,10 +30,9 @@ @PreAuthorize("@ss.hasPermi('monitor:operlog:list')") @GetMapping("/list") - public TableDataInfo list(SysOperLog operLog) + public TableDataInfo list(SysOperLog operLog, Long pageNum, Long pageSize) { - startPage(); - List<SysOperLog> list = operLogService.selectOperLogList(operLog); + Page<SysOperLog> list = operLogService.selectOperLogPage(operLog,pageNum,pageSize); return getDataTable(list); } diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/peakvalley/PeakValleyController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/peakvalley/PeakValleyController.java index fae86f9..211ddee 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/peakvalley/PeakValleyController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/peakvalley/PeakValleyController.java @@ -60,6 +60,7 @@ @ApiOperation(value = "鑾峰彇灏栧嘲骞宠胺鍒嗘椂缁熻") public AjaxResult segmentAnalysisDay(PeakValleyDTO dto) { return AjaxResult.success(rulesService.segmentAnalysisDay(dto)); +// return AjaxResult.success(rulesService.segmentAnalysisDayCustomize(dto)); } diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/powerDistribution/PowerDistributionController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/powerDistribution/PowerDistributionController.java new file mode 100644 index 0000000..c2803c3 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/powerDistribution/PowerDistributionController.java @@ -0,0 +1,125 @@ +package com.zhitan.web.controller.powerDistribution; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhitan.basicdata.domain.MeterImplement; +import com.zhitan.basicdata.services.IMeterImplementService; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.powerDistribution.domain.PowerDistribution; +import com.zhitan.powerDistribution.services.IPowerDistributionService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@RestController +@RequestMapping("/powerDistribution") +public class PowerDistributionController extends BaseController { + + @Resource + private IPowerDistributionService powerDistributionService; + + @Resource + private IMeterImplementService meterImplementService; + + /** + * 閰嶇數瀹ゅ垪琛� + * + * @param powerDistribution + * @return + */ + @GetMapping("/list") + public AjaxResult list(PowerDistribution powerDistribution) { + List<PowerDistribution> list = powerDistributionService.selectPowerDistributionList(powerDistribution); + return AjaxResult.success(list); + } + + /** + * 閰嶇數瀹ゅ垪琛ㄥ垎椤垫煡璇� + * + * @param powerDistribution + * @param pageNo + * @param pageSize + * @return + */ + @GetMapping("/pageList") + public AjaxResult pageList(PowerDistribution powerDistribution, + @RequestParam(required = false, defaultValue = "1") int pageNo, + @RequestParam(required = false, defaultValue = "10") int pageSize) { + Page<PowerDistribution> page = new Page<>(pageNo, pageSize); + IPage<PowerDistribution> pageList = powerDistributionService.pageList(powerDistribution, page); + return AjaxResult.success(pageList); + } + + /** + * 鏌ョ湅閰嶇數瀹よ鎯� + * + * @param id + * @return + */ + @GetMapping("/getDetail") + public AjaxResult getDetail(@RequestParam("id") String id) { + PowerDistribution powerDistribution = powerDistributionService.getById(id); + return AjaxResult.success(powerDistribution); + } + + /** + * 鏂板閰嶇數瀹� + * + * @param powerDistribution + * @return + */ + @PostMapping("/add") + public AjaxResult addPowerDistribution(@RequestBody PowerDistribution powerDistribution) { + List<PowerDistribution> checkList = powerDistributionService.list(new QueryWrapper<PowerDistribution>().eq("code", powerDistribution.getCode())); + if (CollectionUtils.isNotEmpty(checkList)) { + return AjaxResult.error("閰嶇數瀹ょ紪鐮佷笉鑳介噸澶嶏紝璇烽噸鏂拌緭鍏�"); + } + return AjaxResult.success(powerDistributionService.save(powerDistribution)); + } + + /** + * 缂栬緫閰嶇數瀹� + * + * @param powerDistribution + * @return + */ + @PostMapping("/edit") + public AjaxResult edit(@RequestBody PowerDistribution powerDistribution) { + List<PowerDistribution> checkList = powerDistributionService.list(new QueryWrapper<PowerDistribution>().ne("id", powerDistribution.getId()).eq("code", powerDistribution.getCode())); + if (CollectionUtils.isNotEmpty(checkList)) { + return AjaxResult.error("閰嶇數瀹ょ紪鐮佷笉鑳介噸澶嶏紝璇烽噸鏂拌緭鍏�"); + } + return AjaxResult.success(powerDistributionService.updateById(powerDistribution)); + } + + /** + * 鍒犻櫎閰嶇數瀹� + * + * @param ids + * @return + */ + @DeleteMapping("/remove") + public AjaxResult remove(@RequestParam("ids") String[] ids) { + List<String> idList = new ArrayList<>(); + List<String> errorList = new ArrayList<>(); + for (String id : ids) { + List<MeterImplement> meterList = meterImplementService.listMeterImplByInstallLocation(id); + if (CollectionUtils.isEmpty(meterList)) { + idList.add(id); + } else { + errorList.add(id); + } + } + if (CollectionUtils.isNotEmpty(errorList)) { + return AjaxResult.error("姝ら厤鐢靛宸插湪璁¢噺鍣ㄥ叿涓厤缃紝涓嶈兘鍒犻櫎"); + } else { + return AjaxResult.success(powerDistributionService.deleteByIds(idList)); + } + } + +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/singlelogin/SingleLoginController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/singlelogin/SingleLoginController.java new file mode 100644 index 0000000..b71d03b --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/singlelogin/SingleLoginController.java @@ -0,0 +1,53 @@ +package com.zhitan.web.controller.singlelogin; + +import com.zhitan.common.annotation.Anonymous; +import com.zhitan.common.constant.Constants; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.core.domain.entity.SysUser; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.framework.web.service.SysLoginService; +import com.zhitan.singlelogin.service.ISingleLoginService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 鍗曠偣鐧诲綍鎺ュ彛瀵规帴 + * + * @author zhitan + */ +@RestController +public class SingleLoginController +{ + @Resource + private ISingleLoginService singleLoginService; + + @Resource + private SysLoginService loginService; + /** + * 鐧诲綍鏂规硶 + * + * @param token 鐧诲綍淇℃伅 + * @return 缁撴灉 + */ + @Anonymous + @GetMapping("/singleLogin") + public AjaxResult singleLogin(@RequestParam String token) + { + AjaxResult ajax = AjaxResult.success(); + if(StringUtils.isEmpty(token)){ + return AjaxResult.error("token涓嶈兘涓虹┖"); + } + SysUser user = singleLoginService.singleLogin(token); + if(null == user){ + return AjaxResult.error("鐧诲綍澶辫触"); + } + // 鐢熸垚浠ょ墝 + String newtoken = loginService.loginNoCode(user.getUserName()); + ajax.put(Constants.TOKEN, newtoken); + return ajax; + } + +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/spikesandvalleys/SpikesAndValleysSchemeController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/spikesandvalleys/SpikesAndValleysSchemeController.java new file mode 100644 index 0000000..30e4995 --- /dev/null +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/spikesandvalleys/SpikesAndValleysSchemeController.java @@ -0,0 +1,122 @@ +package com.zhitan.web.controller.spikesandvalleys; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhitan.alarm.domain.LimitType; +import com.zhitan.common.core.domain.model.LoginUser; +import com.zhitan.common.core.page.TableDataInfo; +import com.zhitan.common.utils.ServletUtils; +import com.zhitan.framework.web.service.TokenService; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysScheme; +import com.zhitan.spikesandvalleys.domain.vo.SpikesAndValleysSchemeVo; +import com.zhitan.spikesandvalleys.service.ISpikesAndValleysSchemeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.zhitan.common.annotation.Log; +import com.zhitan.common.core.controller.BaseController; +import com.zhitan.common.core.domain.AjaxResult; +import com.zhitan.common.enums.BusinessType; + +import com.zhitan.common.utils.poi.ExcelUtil; + +/** + * 灏栧嘲骞宠胺鏃堕棿娈垫槑缁咰ontroller + * + * @author ZhiTan + * @date 2024-10-29 + */ +@RestController +@RequestMapping("/system/scheme") +public class SpikesAndValleysSchemeController extends BaseController +{ + @Resource + private ISpikesAndValleysSchemeService spikesAndValleysSchemeService; + + @Autowired + private TokenService tokenService; + /** + * 鏌ヨ灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗗垪琛� + */ + @PreAuthorize("@ss.hasPermi('system:scheme:list')") + @GetMapping("/list") + public TableDataInfo list(SpikesAndValleysScheme spikesAndValleysScheme, Long pageNum, Long pageSize) + { +// startPage(); + + Page<SpikesAndValleysSchemeVo> page = spikesAndValleysSchemeService.selectSpikesAndValleysSchemeList(spikesAndValleysScheme, pageNum, pageSize); + + return getDataTable(page); + } + + +// /** +// * 瀵煎嚭灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗗垪琛� +// */ +// @PreAuthorize("@ss.hasPermi('system:scheme:export')") +// @Log(title = "灏栧嘲骞宠胺鏃堕棿娈垫槑缁�", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, SpikesAndValleysScheme spikesAndValleysScheme) +// { +// List<SpikesAndValleysScheme> list = spikesAndValleysSchemeService.selectSpikesAndValleysSchemeList(spikesAndValleysScheme); +// ExcelUtil<SpikesAndValleysScheme> util = new ExcelUtil<SpikesAndValleysScheme>(SpikesAndValleysScheme.class); +// util.exportExcel(response, list, "灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗘暟鎹�"); +// } + + /** + * 鑾峰彇灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗚缁嗕俊鎭� + */ + @PreAuthorize("@ss.hasPermi('system:scheme:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(spikesAndValleysSchemeService.selectSpikesAndValleysSchemeById(id)); + } + + /** + * 鏂板灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + */ + @PreAuthorize("@ss.hasPermi('system:scheme:add')") + @Log(title = "灏栧嘲骞宠胺鏃堕棿娈垫槑缁�", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SpikesAndValleysSchemeVo spikesAndValleysScheme) + { + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + spikesAndValleysScheme.setCreateBy(loginUser.getUsername()); + return toAjax(spikesAndValleysSchemeService.insertSpikesAndValleysScheme(spikesAndValleysScheme)); + } + + /** + * 淇敼灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + */ + @PreAuthorize("@ss.hasPermi('system:scheme:edit')") + @Log(title = "灏栧嘲骞宠胺鏃堕棿娈垫槑缁�", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SpikesAndValleysSchemeVo spikesAndValleysScheme) + { + LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); + spikesAndValleysScheme.setUpdateBy(loginUser.getUsername()); + return toAjax(spikesAndValleysSchemeService.updateSpikesAndValleysScheme(spikesAndValleysScheme)); + } + + /** + * 鍒犻櫎灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + */ + @PreAuthorize("@ss.hasPermi('system:scheme:remove')") + @Log(title = "灏栧嘲骞宠胺鏃堕棿娈垫槑缁�", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(spikesAndValleysSchemeService.deleteSpikesAndValleysSchemeByIds(ids)); + } +} diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysDictDataController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysDictDataController.java index 1aec1e7..63f6ebe 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysDictDataController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysDictDataController.java @@ -1,5 +1,6 @@ package com.zhitan.web.controller.system; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.annotation.Log; import com.zhitan.common.core.controller.BaseController; import com.zhitan.common.core.domain.AjaxResult; @@ -21,7 +22,7 @@ /** * 鏁版嵁瀛楀吀淇℃伅 - * + * * @author zhitan */ @RestController @@ -36,10 +37,9 @@ @PreAuthorize("@ss.hasPermi('system:dict:list')") @GetMapping("/list") - public TableDataInfo list(SysDictData dictData) + public TableDataInfo list(SysDictData dictData,Long pageNum, Long pageSize) { - startPage(); - List<SysDictData> list = dictDataService.selectDictDataList(dictData); + Page<SysDictData> list = dictDataService.selectDictDataPage(dictData,pageNum,pageSize); return getDataTable(list); } diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysPostController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysPostController.java index 9db471e..f3f3880 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysPostController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysPostController.java @@ -1,18 +1,6 @@ package com.zhitan.web.controller.system; -import java.util.List; -import javax.servlet.http.HttpServletResponse; -import javax.annotation.Resource; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.annotation.Log; import com.zhitan.common.core.controller.BaseController; import com.zhitan.common.core.domain.AjaxResult; @@ -21,10 +9,17 @@ import com.zhitan.common.utils.poi.ExcelUtil; import com.zhitan.system.domain.SysPost; import com.zhitan.system.service.ISysPostService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 宀椾綅淇℃伅鎿嶄綔澶勭悊 - * + * * @author zhitan */ @RestController @@ -39,13 +34,12 @@ */ @PreAuthorize("@ss.hasPermi('system:post:list')") @GetMapping("/list") - public TableDataInfo list(SysPost post) + public TableDataInfo list(SysPost post,Long pageNum,Long pageSize) { - startPage(); - List<SysPost> list = postService.selectPostList(post); + Page<SysPost> list = postService.selectPostPage(post,pageNum,pageSize); return getDataTable(list); } - + @Log(title = "宀椾綅绠$悊", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:post:export')") @PostMapping("/export") diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysRoleController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysRoleController.java index 64653ce..93429cf 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysRoleController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysRoleController.java @@ -1,18 +1,6 @@ package com.zhitan.web.controller.system; -import java.util.List; -import javax.servlet.http.HttpServletResponse; -import javax.annotation.Resource; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.annotation.Log; import com.zhitan.common.core.controller.BaseController; import com.zhitan.common.core.domain.AjaxResult; @@ -30,10 +18,17 @@ import com.zhitan.system.service.ISysDeptService; import com.zhitan.system.service.ISysRoleService; import com.zhitan.system.service.ISysUserService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 瑙掕壊淇℃伅 - * + * * @author zhitan */ @RestController @@ -57,10 +52,9 @@ @PreAuthorize("@ss.hasPermi('system:role:list')") @GetMapping("/list") - public TableDataInfo list(SysRole role) + public TableDataInfo list(SysRole role, Long pageNum, Long pageSize) { - startPage(); - List<SysRole> list = roleService.selectRoleList(role); + Page<SysRole> list = roleService.selectRolePage(role, pageNum, pageSize); return getDataTable(list); } @@ -125,7 +119,7 @@ return error("淇敼瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹叉潈闄愬凡瀛樺湪"); } role.setUpdateBy(getUsername()); - + if (roleService.updateRole(role) > 0) { // 鏇存柊缂撳瓨鐢ㄦ埛鏉冮檺 @@ -208,7 +202,6 @@ @GetMapping("/authUser/unallocatedList") public TableDataInfo unallocatedList(SysUser user) { - startPage(); List<SysUser> list = userService.selectUnallocatedList(user); return getDataTable(list); } diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysUserController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysUserController.java index 98c4bc4..f4d31c6 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysUserController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/system/SysUserController.java @@ -1,21 +1,6 @@ package com.zhitan.web.controller.system; -import java.util.List; -import java.util.stream.Collectors; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang3.ArrayUtils; -import javax.annotation.Resource; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.annotation.Log; import com.zhitan.common.core.controller.BaseController; import com.zhitan.common.core.domain.AjaxResult; @@ -31,10 +16,20 @@ import com.zhitan.system.service.ISysPostService; import com.zhitan.system.service.ISysRoleService; import com.zhitan.system.service.ISysUserService; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.stream.Collectors; /** * 鐢ㄦ埛淇℃伅 - * + * * @author zhitan */ @RestController @@ -58,10 +53,9 @@ */ @PreAuthorize("@ss.hasPermi('system:user:list')") @GetMapping("/list") - public TableDataInfo list(SysUser user) + public TableDataInfo list(SysUser user, Long pageNum, Long pageSize) { - startPage(); - List<SysUser> list = userService.selectUserList(user); + Page<SysUser> list = userService.selectUserPage(user,pageNum,pageSize); return getDataTable(list); } diff --git a/zhitan-admin/src/main/resources/application-dev.yml b/zhitan-admin/src/main/resources/application-dev.yml index c2f6b04..fbf552a 100644 --- a/zhitan-admin/src/main/resources/application-dev.yml +++ b/zhitan-admin/src/main/resources/application-dev.yml @@ -35,7 +35,7 @@ # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�澶х敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 maxEvictableIdleTimeMillis: 900000 # 閰嶇疆妫�娴嬭繛鎺ユ槸鍚︽湁鏁� - validationQuery: SELECT 1 + validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false diff --git a/zhitan-admin/src/main/resources/application-prod.yml b/zhitan-admin/src/main/resources/application-prod.yml index 76415bc..2f5a7cb 100644 --- a/zhitan-admin/src/main/resources/application-prod.yml +++ b/zhitan-admin/src/main/resources/application-prod.yml @@ -6,7 +6,7 @@ druid: # 涓诲簱鏁版嵁婧� master: - url: jdbc:postgresql://127.0.0.1:5432/energy + url: jdbc:postgresql://127.0.0.1:5432/energy_ml username: root password: 123456 # 浠庡簱鏁版嵁婧� diff --git a/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysRole.java b/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysRole.java index 9ab4e78..50fc0e4 100644 --- a/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysRole.java +++ b/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysRole.java @@ -1,20 +1,21 @@ package com.zhitan.common.core.domain.entity; -import java.util.Set; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.zhitan.common.annotation.Excel; +import com.zhitan.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.zhitan.common.core.domain.BaseEntity; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.Set; /** * 瑙掕壊琛� sys_role - * + * * @author zhitan */ @TableName("sys_role") @@ -57,15 +58,19 @@ private String delFlag; /** 鐢ㄦ埛鏄惁瀛樺湪姝よ鑹叉爣璇� 榛樿涓嶅瓨鍦� */ + @TableField(exist = false) private boolean flag = false; /** 鑿滃崟缁� */ + @TableField(exist = false) private Long[] menuIds; /** 閮ㄩ棬缁勶紙鏁版嵁鏉冮檺锛� */ + @TableField(exist = false) private Long[] deptIds; /** 瑙掕壊鑿滃崟鏉冮檺 */ + @TableField(exist = false) private Set<String> permissions; public SysRole() diff --git a/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysUser.java b/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysUser.java index 2cb8c09..227c117 100644 --- a/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysUser.java +++ b/zhitan-common/src/main/java/com/zhitan/common/core/domain/entity/SysUser.java @@ -1,21 +1,24 @@ package com.zhitan.common.core.domain.entity; -import java.util.Date; -import java.util.List; -import javax.validation.constraints.*; - +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.zhitan.common.annotation.Excel; import com.zhitan.common.annotation.Excels; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; import com.zhitan.common.core.domain.BaseEntity; import com.zhitan.common.xss.Xss; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Date; +import java.util.List; /** * 鐢ㄦ埛瀵硅薄 sys_user - * + * * @author zhitan */ @TableName("sys_user") @@ -78,19 +81,26 @@ @Excel(name = "閮ㄩ棬鍚嶇О", targetAttr = "deptName", type = Excel.Type.EXPORT), @Excel(name = "閮ㄩ棬璐熻矗浜�", targetAttr = "leader", type = Excel.Type.EXPORT) }) + @TableField(exist = false) private SysDept dept; /** 瑙掕壊瀵硅薄 */ + @TableField(exist = false) private List<SysRole> roles; /** 瑙掕壊缁� */ + @TableField(exist = false) private Long[] roleIds; /** 宀椾綅缁� */ + @TableField(exist = false) private Long[] postIds; /** 瑙掕壊ID */ + @TableField(exist = false) private Long roleId; + + private String singleUser; public SysUser() { @@ -300,6 +310,14 @@ this.roleId = roleId; } + public String getSingleUser() { + return singleUser; + } + + public void setSingleUser(String singleUser) { + this.singleUser = singleUser; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/zhitan-common/src/main/java/com/zhitan/common/enums/ElectricityTypeEnum.java b/zhitan-common/src/main/java/com/zhitan/common/enums/ElectricityTypeEnum.java index 46a1d63..433d789 100644 --- a/zhitan-common/src/main/java/com/zhitan/common/enums/ElectricityTypeEnum.java +++ b/zhitan-common/src/main/java/com/zhitan/common/enums/ElectricityTypeEnum.java @@ -9,7 +9,9 @@ SHARP("灏�"), PEAK("宄�"), FLAT("骞�"), - VALLEY("璋�"); + VALLEY("璋�"), + DEEP("娣辫胺"); + private final String desc; diff --git a/zhitan-common/src/main/java/com/zhitan/common/utils/DateUtils.java b/zhitan-common/src/main/java/com/zhitan/common/utils/DateUtils.java index fa784c5..07b5d57 100644 --- a/zhitan-common/src/main/java/com/zhitan/common/utils/DateUtils.java +++ b/zhitan-common/src/main/java/com/zhitan/common/utils/DateUtils.java @@ -193,4 +193,28 @@ ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault()); return Date.from(zdt.toInstant()); } + + /** + * 鑾峰彇鎸囧畾鏃ユ湡棰濇湀浠界殑澶╂暟锛屽苟杞崲鎴愭暟缁� + * @param date 鏃ユ湡 + * @return 鏃ユ湡鏁扮粍 + */ + public static String[] getDays(Date date) { + if (date == null) { + throw new IllegalArgumentException("鏃ユ湡鍙傛暟涓嶈兘涓虹┖"); + } + + // 灏� Date 杞崲涓� LocalDate + LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + int daysInMonth = localDate.lengthOfMonth(); + String[] strings = new String[daysInMonth]; + + for (int i = 1; i <= daysInMonth; i++) { + // 浣跨敤String.format绠�鍖栭浂濉厖 + strings[i - 1] = String.format("%02d", i); + } + + return strings; + } + } diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/config/MyBatisInterceptor.java b/zhitan-framework/src/main/java/com/zhitan/framework/config/MyBatisInterceptor.java index 35b4538..8a95059 100644 --- a/zhitan-framework/src/main/java/com/zhitan/framework/config/MyBatisInterceptor.java +++ b/zhitan-framework/src/main/java/com/zhitan/framework/config/MyBatisInterceptor.java @@ -1,6 +1,6 @@ package com.zhitan.framework.config; -import com.sun.istack.internal.NotNull; + import com.zhitan.common.core.domain.model.LoginUser; import com.zhitan.common.utils.ReflectionUtils; import com.zhitan.common.utils.SecurityUtils; @@ -13,6 +13,7 @@ import org.apache.ibatis.plugin.*; import org.springframework.stereotype.Component; +import javax.validation.constraints.NotNull; import java.lang.reflect.Field; import java.util.Arrays; import java.util.Date; diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/config/SecurityConfig.java b/zhitan-framework/src/main/java/com/zhitan/framework/config/SecurityConfig.java index 91909f6..e0125a6 100644 --- a/zhitan-framework/src/main/java/com/zhitan/framework/config/SecurityConfig.java +++ b/zhitan-framework/src/main/java/com/zhitan/framework/config/SecurityConfig.java @@ -4,9 +4,7 @@ import com.zhitan.framework.security.filter.JwtAuthenticationTokenFilter; import com.zhitan.framework.security.handle.AuthenticationEntryPointImpl; import com.zhitan.framework.security.handle.LogoutSuccessHandlerImpl; - -import javax.annotation.Resource; - +import com.zhitan.framework.security.single.SingleAuthenticationProvider; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AuthenticationManager; @@ -22,8 +20,7 @@ import org.springframework.security.web.authentication.logout.LogoutFilter; import org.springframework.web.filter.CorsFilter; -import java.util.ArrayList; -import java.util.List; +import javax.annotation.Resource; /** * spring security閰嶇疆 @@ -55,6 +52,12 @@ */ @Resource private JwtAuthenticationTokenFilter authenticationTokenFilter; + + /** + * token璁よ瘉杩囨护鍣� + */ + @Resource + private SingleAuthenticationProvider singleAuthenticationProvider; /** * 璺ㄥ煙杩囨护鍣� @@ -143,5 +146,6 @@ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder()); + auth.authenticationProvider(singleAuthenticationProvider); } } diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/mqtt/MqttMessageCallback.java b/zhitan-framework/src/main/java/com/zhitan/framework/mqtt/MqttMessageCallback.java index 7f64714..e3c5e61 100644 --- a/zhitan-framework/src/main/java/com/zhitan/framework/mqtt/MqttMessageCallback.java +++ b/zhitan-framework/src/main/java/com/zhitan/framework/mqtt/MqttMessageCallback.java @@ -1,6 +1,11 @@ package com.zhitan.framework.mqtt; +import cn.hutool.core.date.DateTime; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.zhitan.framework.mqtt.domain.EletricData; import com.zhitan.realtimedata.data.influxdb.InfluxDBRepository; +import com.zhitan.realtimedata.domain.TagValue; import lombok.extern.slf4j.Slf4j; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttCallback; @@ -8,9 +13,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + @Component @Slf4j public class MqttMessageCallback implements MqttCallback { + + private ExecutorService executorService = Executors.newFixedThreadPool(10); // 鍒涘缓涓�涓嚎绋嬫睜 @Autowired private InfluxDBRepository repository; @@ -24,24 +36,67 @@ } @Override public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception { - log.info("鎺ユ敹鍒版秷鎭叿浣撲俊鎭�---->{}",new String(mqttMessage.getPayload())); -// final String msg = new String(mqttMessage.getPayload()); -// JSONObject jsonObject = JSON.parseObject(msg); -// final String values = jsonObject.getString("values"); -// final List<EletricData> eletricData = JSON.parseArray(values, EletricData.class); -// List<TagValue> tagValueList = new ArrayList<>(); -// //缁撳悎涓氬姟 缂栧啓鍏蜂綋淇℃伅鍗冲彲 -// eletricData.forEach(ele->{ -// final String key = ele.getKey(); -// TagValue tagValue = new TagValue(); -// tagValue.setDataTime(new DateTime(ele.getTime())); -// tagValue.setValue(ele.getVaule()); -// tagValue.setTagCode(key.substring(key.lastIndexOf(".") + 1)); -// tagValueList.add(tagValue); -// }); -// repository.store(tagValueList); + + executorService.submit(new Runnable() { + @Override + public void run() { + final String msg = new String(mqttMessage.getPayload()); + JSONObject jsonObject = JSON.parseObject(msg); + final String values = jsonObject.getString("values"); + final List<EletricData> eletricData = JSON.parseArray(values, EletricData.class); + List<TagValue> tagValueList = new ArrayList<>(); + + //EMS.HB.High.9_42302035834_Voltagec + //9 鏄厤鐢电锛�42302035834鏄數琛ㄥ彿 + //缁撳悎涓氬姟 缂栧啓鍏蜂綋淇℃伅鍗冲彲 + eletricData.forEach(ele->{ + final String key = ele.getKey(); + TagValue tagValue = new TagValue(); + tagValue.setDataTime(new DateTime(ele.getTime())); + tagValue.setValue(ele.getVaule()); + final String eNoIndex = key.substring(key.indexOf("_") + 1); + String tagValueString = formateTag(eNoIndex); + tagValue.setTagCode(tagValueString); + tagValueList.add(tagValue); + }); + repository.store(tagValueList); + } + }); + +// } + + //灏嗙數琛ㄥ彿鍜屾寚鏍� 42302035834_Voltagec 杞崲鎴愭垜浠郴缁熺殑 + private String formateTag(String tag) { + final String[] tags = tag.split("_"); + String index = tags[1]; + String tagValue = tags[0] + "_"; + switch (index){ + case "PowFactorT": //鍔熺巼鍥犳暟 + tagValue += "PowFactorT"; + break; + case "Imp": //姝e悜鐢佃兘 + tagValue += "ActiveZT"; + break; +// case "spare": // +// tagValue += ""; +// break; +// case "CurrentD": // +// tagValue += "CurrentD"; +// break; +// case "EXP": //鍙嶅悜鐢佃兘 +// tagValue += ""; +// break; +// case "Total": //鐢佃兘鎬诲拰 +// tagValue += ""; +// break; + default: + tagValue = tag; + } + return tagValue; + } + @Override public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { } -} +} \ No newline at end of file diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationProvider.java b/zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationProvider.java new file mode 100644 index 0000000..d7af4a8 --- /dev/null +++ b/zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationProvider.java @@ -0,0 +1,45 @@ +package com.zhitan.framework.security.single; + +import com.zhitan.framework.web.service.UserDetailsServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Component; + +import java.util.Collections; + +@Component +public class SingleAuthenticationProvider implements AuthenticationProvider { + @Autowired + private UserDetailsServiceImpl userDetailsService; + + /** + * 璁よ瘉閫昏緫 + */ + @Override + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + SingleAuthenticationToken SingleAuthenticationToken = (SingleAuthenticationToken) authentication; + + String username = (String) SingleAuthenticationToken.getPrincipal(); + UserDetails user = userDetailsService.loadUserByUsername(username); + SingleAuthenticationToken result = new SingleAuthenticationToken(user, Collections.emptyList()); + /* + Details 涓寘鍚簡 ip鍦板潃銆� sessionId 绛夌瓑灞炴�� 涔熷彲浠ュ瓨鍌ㄤ竴浜涜嚜宸辨兂瑕佹斁杩涘幓鐨勫唴瀹� + */ + result.setDetails(SingleAuthenticationToken.getDetails()); + return result; + } + + /** + *UserIdAuthenticationToken浜ょ粰UserIdAuthenticationProvider澶勭悊 + * @param aClass + * @return + */ + @Override + public boolean supports(Class<?> aClass) { + return SingleAuthenticationToken.class.isAssignableFrom(aClass); + + } +} diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationToken.java b/zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationToken.java new file mode 100644 index 0000000..fd3af0a --- /dev/null +++ b/zhitan-framework/src/main/java/com/zhitan/framework/security/single/SingleAuthenticationToken.java @@ -0,0 +1,48 @@ +package com.zhitan.framework.security.single; + +import org.springframework.security.authentication.AbstractAuthenticationToken; +import org.springframework.security.core.GrantedAuthority; + +import java.util.Collection; + +public class SingleAuthenticationToken extends AbstractAuthenticationToken { + + private final Object principal; + + public SingleAuthenticationToken(Object principal) { + super(null); + this.principal = principal; + this.setAuthenticated(false); + } + + public SingleAuthenticationToken(Object principal, Collection<? extends GrantedAuthority> authorities) { + super(authorities); + this.principal = principal; + super.setAuthenticated(true); + } + + @Override + public Object getCredentials() { + return null; + } + + @Override + public Object getPrincipal() { + return this.principal; + } + + @Override + public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { + if (isAuthenticated) { + throw new IllegalArgumentException( + "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); + } + + super.setAuthenticated(false); + } + + @Override + public void eraseCredentials() { + super.eraseCredentials(); + } +} diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/web/service/PermissionService.java b/zhitan-framework/src/main/java/com/zhitan/framework/web/service/PermissionService.java index 520d562..68171fc 100644 --- a/zhitan-framework/src/main/java/com/zhitan/framework/web/service/PermissionService.java +++ b/zhitan-framework/src/main/java/com/zhitan/framework/web/service/PermissionService.java @@ -1,19 +1,19 @@ package com.zhitan.framework.web.service; +import java.util.Set; + +import com.zhitan.framework.security.context.PermissionContextHolder; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import com.zhitan.common.constant.Constants; import com.zhitan.common.core.domain.entity.SysRole; import com.zhitan.common.core.domain.model.LoginUser; import com.zhitan.common.utils.SecurityUtils; import com.zhitan.common.utils.StringUtils; -import com.zhitan.framework.security.context.PermissionContextHolder; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.Set; /** * 棣栧垱 鑷畾涔夋潈闄愬疄鐜帮紝ss鍙栬嚜SpringSecurity棣栧瓧姣� - * + * * @author zhitan */ @Service("ss") @@ -21,24 +21,23 @@ { /** * 楠岃瘉鐢ㄦ埛鏄惁鍏峰鏌愭潈闄� - * + * * @param permission 鏉冮檺瀛楃涓� * @return 鐢ㄦ埛鏄惁鍏峰鏌愭潈闄� */ public boolean hasPermi(String permission) { - return true; -// if (StringUtils.isEmpty(permission)) -// { -// return false; -// } -// LoginUser loginUser = SecurityUtils.getLoginUser(); -// if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) -// { -// return false; -// } -// PermissionContextHolder.setContext(permission); -// return hasPermissions(loginUser.getPermissions(), permission); + if (StringUtils.isEmpty(permission)) + { + return false; + } + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) + { + return false; + } + PermissionContextHolder.setContext(permission); + return hasPermissions(loginUser.getPermissions(), permission); } /** @@ -83,7 +82,7 @@ /** * 鍒ゆ柇鐢ㄦ埛鏄惁鎷ユ湁鏌愪釜瑙掕壊 - * + * * @param role 瑙掕壊瀛楃涓� * @return 鐢ㄦ埛鏄惁鍏峰鏌愯鑹� */ @@ -149,7 +148,7 @@ /** * 鍒ゆ柇鏄惁鍖呭惈鏉冮檺 - * + * * @param permissions 鏉冮檺鍒楄〃 * @param permission 鏉冮檺瀛楃涓� * @return 鐢ㄦ埛鏄惁鍏峰鏌愭潈闄� diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/web/service/SysLoginService.java b/zhitan-framework/src/main/java/com/zhitan/framework/web/service/SysLoginService.java index d881545..be2716a 100644 --- a/zhitan-framework/src/main/java/com/zhitan/framework/web/service/SysLoginService.java +++ b/zhitan-framework/src/main/java/com/zhitan/framework/web/service/SysLoginService.java @@ -1,15 +1,5 @@ package com.zhitan.framework.web.service; -import javax.annotation.Resource; - -import com.zhitan.framework.manager.AsyncManager; -import com.zhitan.framework.manager.factory.AsyncFactory; -import com.zhitan.framework.security.context.AuthenticationContextHolder; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.stereotype.Component; import com.zhitan.common.constant.CacheConstants; import com.zhitan.common.constant.Constants; import com.zhitan.common.constant.UserConstants; @@ -17,21 +7,28 @@ import com.zhitan.common.core.domain.model.LoginUser; import com.zhitan.common.core.redis.RedisCache; import com.zhitan.common.exception.ServiceException; -import com.zhitan.common.exception.user.BlackListException; -import com.zhitan.common.exception.user.CaptchaException; -import com.zhitan.common.exception.user.CaptchaExpireException; -import com.zhitan.common.exception.user.UserNotExistsException; -import com.zhitan.common.exception.user.UserPasswordNotMatchException; +import com.zhitan.common.exception.user.*; import com.zhitan.common.utils.DateUtils; import com.zhitan.common.utils.MessageUtils; import com.zhitan.common.utils.StringUtils; import com.zhitan.common.utils.ip.IpUtils; +import com.zhitan.framework.manager.AsyncManager; +import com.zhitan.framework.manager.factory.AsyncFactory; +import com.zhitan.framework.security.context.AuthenticationContextHolder; +import com.zhitan.framework.security.single.SingleAuthenticationToken; import com.zhitan.system.service.ISysConfigService; import com.zhitan.system.service.ISysUserService; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; /** * 鐧诲綍鏍¢獙鏂规硶 - * + * * @author zhitan */ @Component @@ -45,7 +42,7 @@ @Resource private RedisCache redisCache; - + @Resource private ISysUserService userService; @@ -54,7 +51,7 @@ /** * 鐧诲綍楠岃瘉 - * + * * @param username 鐢ㄦ埛鍚� * @param password 瀵嗙爜 * @param code 楠岃瘉鐮� @@ -102,7 +99,7 @@ /** * 鏍¢獙楠岃瘉鐮� - * + * * @param username 鐢ㄦ埛鍚� * @param code 楠岃瘉鐮� * @param uuid 鍞竴鏍囪瘑 @@ -178,4 +175,39 @@ sysUser.setLoginDate(DateUtils.getNowDate()); userService.updateUserProfile(sysUser); } + + + /** + * 鐧诲綍楠岃瘉 + * @param username + * @return 缁撴灉 + */ + public String loginNoCode(String username) + { + // 鐢ㄦ埛楠岃瘉 + Authentication authentication = null; + try + { + authentication = authenticationManager + .authenticate(new SingleAuthenticationToken(username)); + } + catch (Exception e) + { + if (e instanceof BadCredentialsException) + { + AsyncManager.me().execute(AsyncFactory.recordLoginInfo(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); + throw new UserPasswordNotMatchException(); + } + else + { + AsyncManager.me().execute(AsyncFactory.recordLoginInfo(username, Constants.LOGIN_FAIL, e.getMessage())); + throw new ServiceException(e.getMessage()); + } + } + AsyncManager.me().execute(AsyncFactory.recordLoginInfo(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); + LoginUser loginUser = (LoginUser) authentication.getPrincipal(); + recordLoginInfo(loginUser.getUserId()); + // 鐢熸垚token + return tokenService.createToken(loginUser); + } } diff --git a/zhitan-framework/src/main/java/com/zhitan/framework/web/service/UserDetailsServiceImpl.java b/zhitan-framework/src/main/java/com/zhitan/framework/web/service/UserDetailsServiceImpl.java index 95cb696..15575ac 100644 --- a/zhitan-framework/src/main/java/com/zhitan/framework/web/service/UserDetailsServiceImpl.java +++ b/zhitan-framework/src/main/java/com/zhitan/framework/web/service/UserDetailsServiceImpl.java @@ -1,12 +1,5 @@ package com.zhitan.framework.web.service; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import javax.annotation.Resource; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.stereotype.Service; import com.zhitan.common.core.domain.entity.SysUser; import com.zhitan.common.core.domain.model.LoginUser; import com.zhitan.common.enums.UserStatus; @@ -14,6 +7,14 @@ import com.zhitan.common.utils.MessageUtils; import com.zhitan.common.utils.StringUtils; import com.zhitan.system.service.ISysUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; /** * 鐢ㄦ埛楠岃瘉澶勭悊 @@ -27,7 +28,7 @@ @Resource private ISysUserService userService; - + @Resource private SysPasswordService passwordService; @@ -54,7 +55,7 @@ throw new ServiceException(MessageUtils.message("user.blocked")); } - passwordService.validate(user); +// passwordService.validate(user); return createLoginUser(user); } diff --git a/zhitan-system/pom.xml b/zhitan-system/pom.xml index 7886149..8e81924 100644 --- a/zhitan-system/pom.xml +++ b/zhitan-system/pom.xml @@ -22,7 +22,12 @@ <groupId>com.zhitan</groupId> <artifactId>zhitan-common</artifactId> </dependency> - + <!-- hutool宸ュ叿绫� --> + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-all</artifactId> + <version>5.2.4</version> + </dependency> </dependencies> -</project> \ No newline at end of file +</project> diff --git a/zhitan-system/src/main/java/com/zhitan/basicdata/domain/MeterImplement.java b/zhitan-system/src/main/java/com/zhitan/basicdata/domain/MeterImplement.java index 822d1d0..1701dc2 100644 --- a/zhitan-system/src/main/java/com/zhitan/basicdata/domain/MeterImplement.java +++ b/zhitan-system/src/main/java/com/zhitan/basicdata/domain/MeterImplement.java @@ -116,6 +116,19 @@ @Excel(name = "鍏佽鏈�澶у姛鐜�") private String maxAllowablePower; + + + @TableField(exist = false) + private String installLocationName; + + public String getInstallLocationName() { + return installLocationName; + } + + public void setInstallLocationName(String installLocationName) { + this.installLocationName = installLocationName; + } + public String getGatewayId() { return gatewayId; } diff --git a/zhitan-system/src/main/java/com/zhitan/basicdata/mapper/MeterImplementMapper.java b/zhitan-system/src/main/java/com/zhitan/basicdata/mapper/MeterImplementMapper.java index 5f98943..b744816 100644 --- a/zhitan-system/src/main/java/com/zhitan/basicdata/mapper/MeterImplementMapper.java +++ b/zhitan-system/src/main/java/com/zhitan/basicdata/mapper/MeterImplementMapper.java @@ -86,4 +86,6 @@ List<MeterImplement> listMeterImplementByIds(@Param("meterIdList") List<String> meterIdList); MeterImplement selectByNodeIdIndexId(@Param("nodeId") String nodeId, @Param("indexId") String indexId); + + List<MeterImplement> listMeterImplByInstallLocation(@Param("installactionLocation") String installactionLocation); } diff --git a/zhitan-system/src/main/java/com/zhitan/basicdata/services/IMeterImplementService.java b/zhitan-system/src/main/java/com/zhitan/basicdata/services/IMeterImplementService.java index e39a40c..f5411b3 100644 --- a/zhitan-system/src/main/java/com/zhitan/basicdata/services/IMeterImplementService.java +++ b/zhitan-system/src/main/java/com/zhitan/basicdata/services/IMeterImplementService.java @@ -95,4 +95,6 @@ List<MeterImplement> listMeterImplementByIds(List<String> meterIdList); Page<MeterImplement> selectMeterImplementPage(MeterImplement meterImplement, Long pageNum, Long pageSize); + + List<MeterImplement> listMeterImplByInstallLocation(String id); } diff --git a/zhitan-system/src/main/java/com/zhitan/basicdata/services/impl/MeterImplementServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/basicdata/services/impl/MeterImplementServiceImpl.java index 139e2a1..b0ca237 100644 --- a/zhitan-system/src/main/java/com/zhitan/basicdata/services/impl/MeterImplementServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/basicdata/services/impl/MeterImplementServiceImpl.java @@ -19,6 +19,8 @@ import com.zhitan.model.domain.EnergyIndex; import com.zhitan.model.mapper.DaqTemplateMapper; import com.zhitan.model.mapper.EnergyIndexMapper; +import com.zhitan.powerDistribution.domain.PowerDistribution; +import com.zhitan.powerDistribution.mapper.PowerDistributionMapper; import com.zhitan.system.mapper.SysDictDataMapper; import com.zhitan.system.service.impl.SysUserServiceImpl; import org.slf4j.Logger; @@ -27,6 +29,7 @@ import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; /** * 璁¢噺鍣ㄥ叿妗f缁存姢Service涓氬姟灞傚鐞� @@ -48,6 +51,9 @@ @Autowired private SysDictDataMapper dictDataMapper; + + @Autowired + private PowerDistributionMapper distributionMapper; private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); @Autowired @@ -343,12 +349,43 @@ @Override public Page<MeterImplement> selectMeterImplementPage(MeterImplement meterImplement, Long pageNum, Long pageSize) { + Page<MeterImplement> meterImplementPage =new Page<>(); LambdaQueryWrapper<MeterImplement> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.like(StringUtils.isNotEmpty(meterImplement.getCode()),MeterImplement::getCode,meterImplement.getCode()); queryWrapper.like(StringUtils.isNotEmpty(meterImplement.getMeterName()),MeterImplement::getMeterName,meterImplement.getMeterName()); queryWrapper.eq(StringUtils.isNotEmpty(meterImplement.getMeterType()),MeterImplement::getMeterType,meterImplement.getMeterType()); queryWrapper.orderByDesc(MeterImplement::getCreateTime); - final Page<MeterImplement> meterImplementPage = meterImplementMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper); + +// 閰嶇數瀹よ〃锛歅owerDistribution + if (StringUtils.isNotBlank(meterImplement.getInstallactionLocation())){ + LambdaQueryWrapper<PowerDistribution> installLocationWrapper = new LambdaQueryWrapper<>(); + installLocationWrapper.like(StringUtils.isNotEmpty(meterImplement.getInstallactionLocation()),PowerDistribution::getName,meterImplement.getInstallactionLocation()); + List<PowerDistribution> installList=distributionMapper.selectList(installLocationWrapper); + + if (!installList.isEmpty()){ + queryWrapper.in(MeterImplement::getInstallactionLocation,installList.stream().map(PowerDistribution::getId).collect(Collectors.toList())); + }else{ + return meterImplementPage; + } + } + + meterImplementPage=meterImplementMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper); + + if (meterImplementPage.getTotal() > 0){ + meterImplementPage.getRecords().forEach(v->{ + PowerDistribution distribution=distributionMapper.selectById(v.getInstallactionLocation()); + if (null!=distribution && StringUtils.isNotEmpty(distribution.getName())) { + v.setInstallLocationName(distribution.getName()); + } + + }); + } + return meterImplementPage; } + + @Override + public List<MeterImplement> listMeterImplByInstallLocation(String installLocation) { + return meterImplementMapper.listMeterImplByInstallLocation(installLocation); + } } diff --git a/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/domain/EnergyBenchmarkManage.java b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/domain/EnergyBenchmarkManage.java new file mode 100644 index 0000000..2b6aaed --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/domain/EnergyBenchmarkManage.java @@ -0,0 +1,42 @@ +package com.zhitan.benchmarkmanage.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.annotation.Excel; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * 鏍囨潌鍊肩鐞嗗璞� energy_benchmark_manage + * + * @author ZhiTan + * @date 2024-11-12 + */ +@TableName("energy_benchmark_manage") +@Data +public class EnergyBenchmarkManage extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** uuid涓婚敭 */ + private String id; + + /** 鏍囨潌缂栫爜 */ + @Excel(name = "鏍囨潌缂栫爜") + private String code; + + /** 鏍囨潌绫诲瀷 */ + @Excel(name = "鏍囨潌绫诲瀷") + private String type; + + /** 鏍囨潌绛夌骇 */ + @Excel(name = "鏍囨潌绛夌骇") + private String grade; + + /** 鏍囨潌鍊� */ + @Excel(name = "鏍囨潌鍊�") + private String value; + + /** 鍥芥爣缂栧彿 */ + @Excel(name = "鍥芥爣缂栧彿") + private String nationalNum; + +} diff --git a/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/mapper/EnergyBenchmarkManageMapper.java b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/mapper/EnergyBenchmarkManageMapper.java new file mode 100644 index 0000000..e0b61cc --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/mapper/EnergyBenchmarkManageMapper.java @@ -0,0 +1,64 @@ +package com.zhitan.benchmarkmanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage; + +import java.util.List; + +/** + * 鏍囨潌鍊肩鐞哅apper鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-12 + */ +public interface EnergyBenchmarkManageMapper extends BaseMapper<EnergyBenchmarkManage> { + /** + * 鏌ヨ鏍囨潌鍊肩鐞� + * + * @param id 鏍囨潌鍊肩鐞嗕富閿� + * @return 鏍囨潌鍊肩鐞� + */ + public EnergyBenchmarkManage selectEnergyBenchmarkManageById(String id); + + /** + * 鏌ヨ鏍囨潌鍊肩鐞嗗垪琛� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 鏍囨潌鍊肩鐞嗛泦鍚� + */ + public List<EnergyBenchmarkManage> selectEnergyBenchmarkManageList(EnergyBenchmarkManage energyBenchmarkManage); + + /** + * 鏂板鏍囨潌鍊肩鐞� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 缁撴灉 + */ + public int insertEnergyBenchmarkManage(EnergyBenchmarkManage energyBenchmarkManage); + + /** + * 淇敼鏍囨潌鍊肩鐞� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 缁撴灉 + */ + public int updateEnergyBenchmarkManage(EnergyBenchmarkManage energyBenchmarkManage); + + /** + * 鍒犻櫎鏍囨潌鍊肩鐞� + * + * @param id 鏍囨潌鍊肩鐞嗕富閿� + * @return 缁撴灉 + */ + public int deleteEnergyBenchmarkManageById(String id); + + /** + * 鎵归噺鍒犻櫎鏍囨潌鍊肩鐞� + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteEnergyBenchmarkManageByIds(String[] ids); + + List<EnergyBenchmarkManage> getList(EnergyBenchmarkManage queryParams); +} diff --git a/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/IEnergyBenchmarkManageService.java b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/IEnergyBenchmarkManageService.java new file mode 100644 index 0000000..2c07a8a --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/IEnergyBenchmarkManageService.java @@ -0,0 +1,75 @@ +package com.zhitan.benchmarkmanage.service; + + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage; + +import java.util.List; + +/** + * 鏍囨潌鍊肩鐞哠ervice鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-12 + */ +public interface IEnergyBenchmarkManageService extends IService<EnergyBenchmarkManage> { + /** + * 鏌ヨ鏍囨潌鍊肩鐞� + * + * @param id 鏍囨潌鍊肩鐞嗕富閿� + * @return 鏍囨潌鍊肩鐞� + */ + public EnergyBenchmarkManage selectEnergyBenchmarkManageById(String id); + + /** + * 鏌ヨ鏍囨潌鍊肩鐞嗗垪琛� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 鏍囨潌鍊肩鐞嗛泦鍚� + */ + public List<EnergyBenchmarkManage> selectEnergyBenchmarkManageList(EnergyBenchmarkManage energyBenchmarkManage); + + /** + * 鏂板鏍囨潌鍊肩鐞� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 缁撴灉 + */ + public int insertEnergyBenchmarkManage(EnergyBenchmarkManage energyBenchmarkManage); + + /** + * 淇敼鏍囨潌鍊肩鐞� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 缁撴灉 + */ + public int updateEnergyBenchmarkManage(EnergyBenchmarkManage energyBenchmarkManage); + + /** + * 鎵归噺鍒犻櫎鏍囨潌鍊肩鐞� + * + * @param ids 闇�瑕佸垹闄ょ殑鏍囨潌鍊肩鐞嗕富閿泦鍚� + * @return 缁撴灉 + */ + public int deleteEnergyBenchmarkManageByIds(String[] ids); + + /** + * 鍒犻櫎鏍囨潌鍊肩鐞嗕俊鎭� + * + * @param id 鏍囨潌鍊肩鐞嗕富閿� + * @return 缁撴灉 + */ + public int deleteEnergyBenchmarkManageById(String id); + + /** + * 鍒嗛〉鏌ヨ鏁版嵁 + * @param energyBenchmarkManage + * @param pageNum + * @param pageSize + * @return + */ + Page<EnergyBenchmarkManage> selectBenchmarkManagePage(EnergyBenchmarkManage energyBenchmarkManage, Long pageNum, Long pageSize); + + List<EnergyBenchmarkManage> getList(EnergyBenchmarkManage queryParams); +} diff --git a/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/impl/EnergyBenchmarkManageServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/impl/EnergyBenchmarkManageServiceImpl.java new file mode 100644 index 0000000..0dc219c --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/benchmarkmanage/service/impl/EnergyBenchmarkManageServiceImpl.java @@ -0,0 +1,111 @@ +package com.zhitan.benchmarkmanage.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage; +import com.zhitan.benchmarkmanage.mapper.EnergyBenchmarkManageMapper; +import com.zhitan.benchmarkmanage.service.IEnergyBenchmarkManageService; +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Collections; +import java.util.List; + +/** + * 鏍囨潌鍊肩鐞哠ervice涓氬姟灞傚鐞� + * + * @author ZhiTan + * @date 2024-11-12 + */ +@Service +public class EnergyBenchmarkManageServiceImpl extends ServiceImpl<EnergyBenchmarkManageMapper, EnergyBenchmarkManage> implements IEnergyBenchmarkManageService { + @Autowired + private EnergyBenchmarkManageMapper energyBenchmarkManageMapper; + + /** + * 鏌ヨ鏍囨潌鍊肩鐞� + * + * @param id 鏍囨潌鍊肩鐞嗕富閿� + * @return 鏍囨潌鍊肩鐞� + */ + @Override + public EnergyBenchmarkManage selectEnergyBenchmarkManageById(String id) { + return energyBenchmarkManageMapper.selectEnergyBenchmarkManageById(id); + } + + /** + * 鏌ヨ鏍囨潌鍊肩鐞嗗垪琛� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 鏍囨潌鍊肩鐞� + */ + @Override + public List<EnergyBenchmarkManage> selectEnergyBenchmarkManageList(EnergyBenchmarkManage energyBenchmarkManage) { + return energyBenchmarkManageMapper.selectEnergyBenchmarkManageList(energyBenchmarkManage); + } + + /** + * 鏂板鏍囨潌鍊肩鐞� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 缁撴灉 + */ + @Override + public int insertEnergyBenchmarkManage(EnergyBenchmarkManage energyBenchmarkManage) { + energyBenchmarkManage.setCreateTime(DateUtils.getNowDate()); + return energyBenchmarkManageMapper.insertEnergyBenchmarkManage(energyBenchmarkManage); + } + + /** + * 淇敼鏍囨潌鍊肩鐞� + * + * @param energyBenchmarkManage 鏍囨潌鍊肩鐞� + * @return 缁撴灉 + */ + @Override + public int updateEnergyBenchmarkManage(EnergyBenchmarkManage energyBenchmarkManage) { + energyBenchmarkManage.setUpdateTime(DateUtils.getNowDate()); + return energyBenchmarkManageMapper.updateEnergyBenchmarkManage(energyBenchmarkManage); + } + + /** + * 鎵归噺鍒犻櫎鏍囨潌鍊肩鐞� + * + * @param ids 闇�瑕佸垹闄ょ殑鏍囨潌鍊肩鐞嗕富閿� + * @return 缁撴灉 + */ + @Override + public int deleteEnergyBenchmarkManageByIds(String[] ids) { + return energyBenchmarkManageMapper.deleteEnergyBenchmarkManageByIds(ids); + } + + /** + * 鍒犻櫎鏍囨潌鍊肩鐞嗕俊鎭� + * + * @param id 鏍囨潌鍊肩鐞嗕富閿� + * @return 缁撴灉 + */ + @Override + public int deleteEnergyBenchmarkManageById(String id) { + return energyBenchmarkManageMapper.deleteEnergyBenchmarkManageById(id); + } + + @Override + public Page<EnergyBenchmarkManage> selectBenchmarkManagePage(EnergyBenchmarkManage energyBenchmarkManage, Long pageNum, Long pageSize) { + LambdaQueryWrapper<EnergyBenchmarkManage> queryWrapper=new LambdaQueryWrapper<EnergyBenchmarkManage>(); + queryWrapper.like(StringUtils.isNotEmpty(energyBenchmarkManage.getCode()),EnergyBenchmarkManage::getCode,energyBenchmarkManage.getCode()); + queryWrapper.eq(StringUtils.isNotEmpty(energyBenchmarkManage.getType()),EnergyBenchmarkManage::getType,energyBenchmarkManage.getType()); + queryWrapper.eq(StringUtils.isNotEmpty(energyBenchmarkManage.getGrade()),EnergyBenchmarkManage::getGrade,energyBenchmarkManage.getGrade()); + queryWrapper.orderByDesc(EnergyBenchmarkManage::getCreateTime); + + return energyBenchmarkManageMapper.selectPage(new Page<EnergyBenchmarkManage>(pageNum, pageSize), queryWrapper); + } + + @Override + public List<EnergyBenchmarkManage> getList(EnergyBenchmarkManage queryParams) { + return energyBenchmarkManageMapper.getList(queryParams); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/CarbonEmission.java b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/CarbonEmission.java new file mode 100644 index 0000000..e1caa22 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/CarbonEmission.java @@ -0,0 +1,56 @@ +package com.zhitan.carbonemission.domain; + +import com.zhitan.common.enums.Quality; +import com.zhitan.common.enums.TimeType; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 鍛ㄦ湡鏁版嵁椤�. + */ +@Data +@ApiModel(value = "dataItem瀵硅薄-璁$畻纰虫帓鏀剧敤") +public class CarbonEmission implements Serializable { + private static final long serialVersionUID = -2777479013884125925L; + + @ApiModelProperty(value = "鎸囨爣id") + private String indexId; + @ApiModelProperty(value = "鎸囨爣搴搃d") + private String indexStorageId; + @ApiModelProperty(value = "鎸囨爣code") + private String indexCode; + @ApiModelProperty(value = "鎸囨爣鍚嶇О") + private String indexName; + @ApiModelProperty(value = "寮�濮嬫椂闂�") + private Date beginTime; + @ApiModelProperty(value = "缁撴潫鏃堕棿") + private Date endTime; + @ApiModelProperty(value = "鏃ユ湡") + private Date dataTime; + @ApiModelProperty(value = "鏃ユ湡瀛楃涓�") + private String dataTimeStr; + @ApiModelProperty(value = "鏃堕棿绫诲瀷缂栫爜") + private String timeCode; + @ApiModelProperty(value = "鏃堕棿绫诲瀷") + private TimeType timeType; + @ApiModelProperty(value = "鍊�") + private Double value; + @ApiModelProperty(value = "璐ㄩ噺") + private Quality quality; + @ApiModelProperty(value = "") + private String unitId; + @ApiModelProperty(value = "鍒涘缓鏃堕棿") + private Date createTime; + @ApiModelProperty(value = "鏇存柊鏃堕棿") + private Date updateTime; + @ApiModelProperty(value = "澶囨敞") + private String remark; + @ApiModelProperty(value = "鑳芥簮绫诲瀷") + private String energyId; + @ApiModelProperty(value = "鑺傜偣鍚嶇О") + private String nodeName; +} diff --git a/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/dto/CarbonEmissionDTO.java b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/dto/CarbonEmissionDTO.java new file mode 100644 index 0000000..ef441b4 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/dto/CarbonEmissionDTO.java @@ -0,0 +1,28 @@ +package com.zhitan.carbonemission.domain.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhitan.common.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.util.Date; + +/** + * 纰虫帓鏀炬牳绠� + * + * @author lsk + * @date 2024-10-29 17:55 + */ +@Getter +@Setter +public class CarbonEmissionDTO { + @ApiModelProperty(value = "鑺傜偣id") + private String nodeId; + @ApiModelProperty(value = "鏃堕棿绫诲瀷锛氬勾銆佹湀銆佹棩") + private String timeType; + @ApiModelProperty(value = "鏌ヨ鏃堕棿") + private Date dataTime; + @ApiModelProperty(value = "鎺掓斁绫诲瀷") + private String emissionType; +} diff --git a/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/CarbonEmissionRankVO.java b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/CarbonEmissionRankVO.java new file mode 100644 index 0000000..b37abdf --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/CarbonEmissionRankVO.java @@ -0,0 +1,26 @@ +package com.zhitan.carbonemission.domain.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class CarbonEmissionRankVO { + + + @ApiModelProperty(value = "鑺傜偣鍚嶇О") + private String nodeName; + @ApiModelProperty(value = "鍏ㄩ儴纰虫帓鏀鹃噺") + private Double allValue; + @ApiModelProperty(value = "姘存秷鑰楅噺") + private Double water; + @ApiModelProperty(value = "鐢垫秷鑰楅噺") + private Double steam; + @ApiModelProperty(value = "鐢ㄧ數閲�") + private Double electric; + @ApiModelProperty(value = "鍚屾瘮") + private String yoyEnery; + @ApiModelProperty(value = "绫诲瀷鍚嶇О") + private String allEneryType; + @ApiModelProperty(value = "鎬荤敤閲�") + private Double totalEnery; +} diff --git a/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/carbonEmissionYQVO.java b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/carbonEmissionYQVO.java new file mode 100644 index 0000000..721f5ba --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/carbonemission/domain/vo/carbonEmissionYQVO.java @@ -0,0 +1,28 @@ +package com.zhitan.carbonemission.domain.vo; + +import com.zhitan.common.annotation.Excel; +import lombok.Data; + +@Data +public class carbonEmissionYQVO { + + @Excel(name = "鏃ユ湡") + private String xAxis; + @Excel(name = "纰虫帓鏀鹃噺") + private String yAxis; + @Excel(name = "鍚屾瘮") + private String YOY; + @Excel(name = "鐜瘮") + private String QOQ; + + + public carbonEmissionYQVO() { + } + + public carbonEmissionYQVO(String xAxis, String yAxis, String YOY, String QOQ) { + this.xAxis = xAxis; + this.yAxis = yAxis; + this.YOY = YOY; + this.QOQ = QOQ; + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/carbonemission/service/ICarbonEmissionService.java b/zhitan-system/src/main/java/com/zhitan/carbonemission/service/ICarbonEmissionService.java new file mode 100644 index 0000000..c58758c --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/carbonemission/service/ICarbonEmissionService.java @@ -0,0 +1,35 @@ +package com.zhitan.carbonemission.service; + +import com.zhitan.carbonemission.domain.dto.CarbonEmissionDTO; +import com.zhitan.carbonemission.domain.vo.carbonEmissionYQVO; + +import java.util.List; +import java.util.Map; + +/** + * 纰虫帓鏀炬牳绠� + * + * @author lsk + * @date 2024-10-29 + */ +public interface ICarbonEmissionService { + + /** + * 璁$畻纰虫帓鏀鹃噺 - 椤堕儴涓庡簳閮� + * + * @param carbonEmissionDTO 杈撳叆鍙傛暟 + * @return 纰虫帓鏀鹃噺 + */ + Map<String,Object> getUpCarbonEmission(CarbonEmissionDTO carbonEmissionDTO); + + + /** + * 璁$畻纰虫帓鏀鹃噺 - 涓棿灞� + * + * @param carbonEmissionDTO 杈撳叆鍙傛暟 + * @return 纰虫帓鏀鹃噺 + */ + List<carbonEmissionYQVO> getMiddleCarbonEmission(CarbonEmissionDTO carbonEmissionDTO); + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/carbonemission/service/impl/CarbonEmissionServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/carbonemission/service/impl/CarbonEmissionServiceImpl.java new file mode 100644 index 0000000..c9bb77d --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/carbonemission/service/impl/CarbonEmissionServiceImpl.java @@ -0,0 +1,290 @@ +package com.zhitan.carbonemission.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.zhitan.basicdata.domain.SysEnergy; +import com.zhitan.basicdata.mapper.SysEnergyMapper; +import com.zhitan.carbonemission.domain.CarbonEmission; +import com.zhitan.carbonemission.domain.dto.CarbonEmissionDTO; +import com.zhitan.carbonemission.domain.vo.CarbonEmissionRankVO; +import com.zhitan.carbonemission.domain.vo.carbonEmissionYQVO; +import com.zhitan.carbonemission.service.ICarbonEmissionService; +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.dataitem.mapper.DataItemMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.text.DecimalFormat; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + + +/** + * 銆愮⒊鎺掓斁鏍哥畻銆慡ervice涓氬姟灞傚鐞� + * + * @author lsk + * @date 2024-10-29 + */ +@Service +public class CarbonEmissionServiceImpl implements ICarbonEmissionService { + + @Resource + private DataItemMapper dataItemMapper; + + @Resource + private SysEnergyMapper sysEnergyMapper; + + private final static String[] YEAR = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}; + private final static String[] DAY = {"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"}; + + //鑾峰彇椤甸潰涓婇儴鍒嗙殑纰虫帓鏀� + @Override + public Map<String, Object> getUpCarbonEmission(CarbonEmissionDTO carbonEmissionDTO) { + Map<String, Object> stringObjectMap = new HashMap<>(); + validate(carbonEmissionDTO, "N"); + + // 鑾峰彇鏌ヨ鏃堕棿鐨勫紑濮嬪拰缁撴潫鏃堕棿 + Date queryTime = carbonEmissionDTO.getDataTime(); + Date beginTime; + Date endTime; + switch (carbonEmissionDTO.getTimeType()) { + case "DAY": + beginTime = DateUtil.beginOfDay(queryTime); + endTime = DateUtil.endOfDay(queryTime); + break; + case "MONTH": + beginTime = DateUtil.beginOfMonth(queryTime); + endTime = DateUtil.endOfMonth(queryTime); + break; + case "YEAR": + beginTime = DateUtil.beginOfYear(queryTime); + endTime = DateUtil.endOfYear(queryTime); + break; + default: + throw new RuntimeException("鏃堕棿绫诲瀷閿欒"); + } + Date lastTime = DateUtil.offsetMonth(beginTime, -12); + Date lastEndTime = DateUtil.offsetMonth(endTime, -12); + // 鑾峰彇褰撳墠骞翠唤鍜屼笂涓�骞翠唤鐨勭⒊鎺掓斁鏁版嵁 + List<CarbonEmission> upCarbonEmission = dataItemMapper.getUpCarbonEmission(beginTime, endTime, carbonEmissionDTO.getTimeType(), carbonEmissionDTO.getNodeId()); + + List<CarbonEmission> upLastCarbonEmission = dataItemMapper.getUpCarbonEmission(lastTime, lastEndTime, carbonEmissionDTO.getTimeType(), carbonEmissionDTO.getNodeId()); + List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(null); + if (ObjectUtil.isEmpty(sysEnergies)) { + throw new RuntimeException("鑾峰彇纰虫帓鏀捐浆鎹㈢巼鏃跺嚭閿�: 绯荤粺鑳芥簮鏁版嵁涓虹┖"); + } + + // 鏋勫缓鑳芥簮鏄犲皠鍜岀⒊鎺掓斁鏁版嵁鏄犲皠 + Map<String, SysEnergy> energyMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, Function.identity())); + final List<String> energyType = sysEnergies.stream().map(SysEnergy::getEnersno).collect(Collectors.toList()); + + double allValue = 0.0; + double allLastValue = 0.0; + + List<CarbonEmissionRankVO> upData = new ArrayList<>(); + + // 璁$畻姣忕鑳芥簮鐨勫綋鍓嶅�煎拰鍘诲勾鐨勫�� + for (String s : energyType) { + final double value = getValues(energyMap, upCarbonEmission,energyType); + final double lastYearValueNum = getValues(energyMap, upLastCarbonEmission,energyType); + allValue += value; + allLastValue += lastYearValueNum; + final CarbonEmissionRankVO carbonEmissionRankVO = new CarbonEmissionRankVO(); + carbonEmissionRankVO.setAllEneryType(energyMap.get(s).getEnername()); + carbonEmissionRankVO.setYoyEnery(String.format("%.2f", calculateYOY(value, lastYearValueNum))); + carbonEmissionRankVO.setTotalEnery(value); + upData.add(carbonEmissionRankVO); + } + CarbonEmissionRankVO carbonEmissionRankVOAll = new CarbonEmissionRankVO(); + carbonEmissionRankVOAll.setAllEneryType("鎬荤⒊鎺掓斁閲�"); + carbonEmissionRankVOAll.setYoyEnery(String.format("%.2f", calculateYOY(allValue, allLastValue))); + carbonEmissionRankVOAll.setTotalEnery(allValue); + upData.add(carbonEmissionRankVOAll); + + // 璁$畻涓嬫柟鐨勭⒊鎺掓斁骞舵帓搴� + List<CarbonEmissionRankVO> carbonEmissionRankVOS = calculateDownCarbonEmission(beginTime, endTime, carbonEmissionDTO, energyMap,sysEnergies); + carbonEmissionRankVOS.sort(Comparator.comparing(CarbonEmissionRankVO::getAllValue).reversed()); + stringObjectMap.put("down", carbonEmissionRankVOS); + stringObjectMap.put("upData", upData); + + return stringObjectMap; + } + + // 璁$畻鍚屾瘮澧為暱鐜� + private double calculateYOY(double current, double last) { + if(last !=0.0) { + return (current - last) / last * 100; + } + return 0; +// return (current - last) / (last == 0.0 ? 1 : last) * 100; + } + + // 璁$畻涓嬫柟鐨勭⒊鎺掓斁 + private List<CarbonEmissionRankVO> calculateDownCarbonEmission(Date beginTime, Date endTime, CarbonEmissionDTO carbonEmissionDTO, Map<String, SysEnergy> energyMap,List<SysEnergy> sysEnergies) { + List<CarbonEmission> downCarbonEmission = dataItemMapper.getDownCarbonEmission(beginTime, endTime, carbonEmissionDTO.getTimeType(), carbonEmissionDTO.getNodeId()); + List<CarbonEmissionRankVO> carbonEmissionRankVOS = new ArrayList<>(); + + final List<String> energyType = sysEnergies.stream().map(SysEnergy::getEnersno).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(downCarbonEmission)) { + DecimalFormat df = new DecimalFormat("#.00"); + Map<String, List<CarbonEmission>> nodeNameMap = downCarbonEmission.stream().collect(Collectors.groupingBy(CarbonEmission::getNodeName)); + + nodeNameMap.forEach((k, v) -> { + CarbonEmissionRankVO rankVO = new CarbonEmissionRankVO(); + rankVO.setNodeName(k); + double totalValues = 0.0; + + // 璁$畻姣忕鑳芥簮鐨勫�� + for (String s : energyType) { + SysEnergy sysEnergy = energyMap.get(s); + if (sysEnergy == null || ObjectUtil.isEmpty(sysEnergy.getCoefficient())) { + throw new RuntimeException("鑾峰彇纰虫帓鏀捐浆鎹㈢巼鏃跺嚭閿�: 绯荤粺鑳芥簮鏁版嵁涓笉瀛樺湪" + s + "鑳芥簮绫诲瀷"); + } + double value = v.stream().filter(ec -> ec.getEnergyId().equals(s)) + .mapToDouble(CarbonEmission::getValue) + .sum(); + double calculatedValue = Double.parseDouble(df.format(sysEnergy.getCoefficient().doubleValue() * value)); + + switch (s) { + case "water": + rankVO.setWater(calculatedValue); + break; + case "steam": + rankVO.setSteam(calculatedValue); + break; + case "electric": + rankVO.setElectric(calculatedValue); + break; + } + totalValues += calculatedValue; + } + rankVO.setAllValue(totalValues); + carbonEmissionRankVOS.add(rankVO); + }); + } + + return carbonEmissionRankVOS; + } + + + @Override + public List<carbonEmissionYQVO> getMiddleCarbonEmission(CarbonEmissionDTO carbonEmissionDTO) { + validate(carbonEmissionDTO, "Y"); + // 璇ユ柟娉曠敤浜庤绠楃⒊鎺掓斁鎬诲�煎苟杩斿洖缁撴灉 + Map<String, Object> stringObjectMap = new HashMap<>(); + Date beginTime; + Date endTime; + final String timeType = carbonEmissionDTO.getTimeType(); + final Date dataTime = carbonEmissionDTO.getDataTime(); + String timeTypeStr; + String[] XAxis; + switch (timeType) { + case "DAY": + timeTypeStr = "HOUR"; + XAxis = DAY; + beginTime = DateUtil.beginOfDay(dataTime); + endTime = DateUtil.endOfDay(dataTime); + break; + case "MONTH": + timeTypeStr = "DAY"; + XAxis = DateUtils.getDays(dataTime); + beginTime = DateUtil.beginOfMonth(dataTime); + endTime = DateUtil.endOfMonth(dataTime); + break; + case "YEAR": + timeTypeStr = "MONTH"; + XAxis = YEAR; + beginTime = DateUtil.beginOfYear(dataTime); + endTime = DateUtil.endOfYear(dataTime); + break; + default: + throw new RuntimeException("鏃堕棿绫诲瀷閿欒"); + } + Date lastTime = DateUtil.offsetMonth(beginTime, -12); + Date lastEndTime = DateUtil.offsetMonth(endTime, -12); + + List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(null); + if (ObjectUtil.isEmpty(sysEnergies)) { + throw new RuntimeException("鑾峰彇纰虫帓鏀捐浆鎹㈢巼鏃跺嚭閿�: 绯荤粺鑳芥簮鏁版嵁涓虹┖"); + } + + // 鏋勫缓鑳芥簮鏄犲皠鍜岀⒊鎺掓斁鏁版嵁鏄犲皠 + Map<String, SysEnergy> energyMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, Function.identity())); + final List<String> energyType = sysEnergies.stream().map(SysEnergy::getEnersno).collect(Collectors.toList()); + final List<CarbonEmission> middleCarbonEmission = dataItemMapper.getMiddleCarbonEmission(beginTime, endTime, timeTypeStr, carbonEmissionDTO.getNodeId(), carbonEmissionDTO.getEmissionType()); + final List<CarbonEmission> lastMiddleCarbonEmission = dataItemMapper.getMiddleCarbonEmission(lastTime, lastEndTime, timeTypeStr, carbonEmissionDTO.getNodeId(), carbonEmissionDTO.getEmissionType()); + final Map<String, List<CarbonEmission>> collect = middleCarbonEmission.stream().collect(Collectors.groupingBy(CarbonEmission::getDataTimeStr)); + final Map<String, List<CarbonEmission>> lastCollect = lastMiddleCarbonEmission.stream().collect(Collectors.groupingBy(CarbonEmission::getDataTimeStr)); + List<carbonEmissionYQVO> carbonEmissionYQVOS = new ArrayList<>(); + for (int i = 0; i < XAxis.length; i++) { + // 褰撳墠鏃堕棿娈电殑纰虫帓鏀炬暟鎹� + final List<CarbonEmission> carbonEmissions = collect.get(XAxis[i]); + // 涓婁竴鏃堕棿娈电殑纰虫帓鏀炬暟鎹� + final List<CarbonEmission> lastCarbonEmissions = lastCollect.get(XAxis[i]); + // 鎬诲�� + double totalValue = getValues(energyMap, carbonEmissions,energyType); + // 涓婁竴鏃堕棿娈电殑鎬诲�� + double totalLastValue = getValues(energyMap, lastCarbonEmissions,energyType); + // 鍓嶄竴娆$殑鎬诲�� + double totalFrontValue = (i == 0) ? 0.0 : getValues(energyMap, collect.get(XAxis[i - 1]),energyType); + final carbonEmissionYQVO carbonEmissionYQVO = new carbonEmissionYQVO(XAxis[i] , String.format("%.2f", totalValue) ,String.format("%.2f", calculateYOY(totalValue, totalLastValue)) , String.format("%.2f", calculateYOY(totalValue, totalFrontValue))); + carbonEmissionYQVOS.add(carbonEmissionYQVO); + } + return carbonEmissionYQVOS; + } + + // 楠岃瘉 CarbonEmissionDTO 瀵硅薄鐨勫悇椤瑰睘鎬ф槸鍚︽湁鏁� + public static void validate(CarbonEmissionDTO carbonEmissionDTO, String type) { + if (ObjectUtil.isNull(carbonEmissionDTO.getDataTime())) { + throw new RuntimeException("璇烽�夋嫨鏃堕棿"); + } + if (StringUtils.isEmpty(carbonEmissionDTO.getTimeType())) { + throw new RuntimeException("璇烽�夋嫨鏃堕棿绫诲瀷"); + } + if (ObjectUtil.isEmpty(carbonEmissionDTO.getNodeId())) { + throw new RuntimeException("璇烽�夋嫨鑺傜偣"); + } + if ("Y".equals(type) && ObjectUtil.isEmpty(carbonEmissionDTO.getEmissionType())) { + throw new RuntimeException("璇烽�夋嫨鎺掓斁绫诲瀷"); + } + } + + + public static double getValues(Map<String, SysEnergy> energyMap, List<CarbonEmission> carbonEmissions,List<String> energyType) { + if (CollectionUtils.isEmpty(carbonEmissions)) { + return 0.0; + } + + // 鍒濆鍖栨�诲�� + double allValue = 0.0; + + // 鎸夎兘婧怚D鍒嗙粍 + final Map<String, List<CarbonEmission>> energyValueMap = carbonEmissions.stream() + .collect(Collectors.groupingBy(CarbonEmission::getEnergyId)); +// final List<String> energyType = sysEnergies.stream().map(SysEnergy::getEnersno).collect(Collectors.toList()); +// 璁$畻姣忕鑳芥簮鐨勫綋鍓嶅�� + for (String s : energyType) { + SysEnergy sysEnergy = energyMap.get(s); + + // 纭繚鑳芥簮瀛樺湪涓旂郴鏁颁笉涓虹┖ + if (sysEnergy == null || sysEnergy.getCoefficient() == null) { + throw new RuntimeException("鑾峰彇纰虫帓鏀捐浆鎹㈢巼鏃跺嚭閿�: 绯荤粺鑳芥簮鏁版嵁涓笉瀛樺湪鎴栫郴鏁颁负绌�" + s + "鑳芥簮绫诲瀷"); + } + + // 鑾峰彇瀵瑰簲鑳芥簮鐨勫�� + double value = energyValueMap.getOrDefault(s, Collections.emptyList()).stream() + .mapToDouble(CarbonEmission::getValue) + .sum(); + + // 鐩存帴璁$畻鎬诲�硷紝閬垮厤鍐椾綑鐨勮浆鎹� + allValue += sysEnergy.getCoefficient().doubleValue() * value; + } + + // 鏍煎紡鍖栨渶缁堢粨鏋� + return Double.parseDouble(new DecimalFormat("#.00").format(allValue)); + } + +} diff --git a/zhitan-system/src/main/java/com/zhitan/consumptionanalysis/service/impl/ConsumptionAnalysisServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/consumptionanalysis/service/impl/ConsumptionAnalysisServiceImpl.java index ef04d02..4f48bc5 100644 --- a/zhitan-system/src/main/java/com/zhitan/consumptionanalysis/service/impl/ConsumptionAnalysisServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/consumptionanalysis/service/impl/ConsumptionAnalysisServiceImpl.java @@ -402,7 +402,7 @@ final LambdaQueryWrapper<SysEnergy> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(CollectionUtils.isNotEmpty(eneryIdList),SysEnergy::getEnersno,eneryIdList); final List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(queryWrapper); - final Map<String, Object> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); + final Map<String, BigDecimal> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); final Map<String, String> energyNameMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno,SysEnergy::getEnername)); final Map<String, String> indexIdEnergyIdMap = new HashMap<>(); nodeIndexInforList.forEach(n->{ @@ -528,7 +528,7 @@ final String indexId = dataItem.getIndexId(); final String energyId = indexIdEnergyIdMap.get(indexId); - final BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + final BigDecimal coefficient = energyCoefficientMap.get(energyId); if(coefficient == null){ throw new RuntimeException("鑳芥簮绫诲瀷" + energyId + "娌℃湁閰嶇疆鎶樻爣绯绘暟锛屾棤娉曡绠�"); } @@ -549,7 +549,7 @@ final String indexId = dataItem.getIndexId(); final String energyId = indexIdEnergyIdMap.get(indexId); - final BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + final BigDecimal coefficient = energyCoefficientMap.get(energyId); if(coefficient == null){ throw new RuntimeException("鑳芥簮绫诲瀷" + energyId + "娌℃湁閰嶇疆鎶樻爣绯绘暟锛屾棤娉曡绠�"); } @@ -613,7 +613,7 @@ indexDataItemMap.forEach((indexId,value)->{ final String energyId = indexIdEnergyIdMap.get(indexId); - final BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + final BigDecimal coefficient = energyCoefficientMap.get(energyId); if(coefficient == null){ throw new RuntimeException("鑳芥簮绫诲瀷" + energyId + "娌℃湁閰嶇疆鎶樻爣绯绘暟锛屾棤娉曡绠�"); } @@ -722,7 +722,7 @@ final LambdaQueryWrapper<SysEnergy> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(CollectionUtils.isNotEmpty(eneryIdList),SysEnergy::getEnersno,eneryIdList); final List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(queryWrapper); - final Map<String, Object> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); + final Map<String, BigDecimal> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); final Map<String, String> indexIdEnergyIdMap = new HashMap<>(); nodeIndexInforList.forEach(n->{ final String indexId = n.getIndexId(); @@ -775,7 +775,7 @@ final String indexId = dataItem.getIndexId(); final String energyId = indexIdEnergyIdMap.get(indexId); - final BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + final BigDecimal coefficient = energyCoefficientMap.get(energyId); if(coefficient == null){ throw new RuntimeException("鑳芥簮绫诲瀷" + energyId + "娌℃湁閰嶇疆鎶樻爣绯绘暟锛屾棤娉曡绠�"); } @@ -811,7 +811,7 @@ indexDataItemMap.forEach((indexId,value)->{ final String energyId = indexIdEnergyIdMap.get(indexId); - final BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + final BigDecimal coefficient = energyCoefficientMap.get(energyId); if(coefficient == null){ throw new RuntimeException("鑳芥簮绫诲瀷" + energyId + "娌℃湁閰嶇疆鎶樻爣绯绘暟锛屾棤娉曡绠�"); } @@ -854,7 +854,7 @@ queryWrapper.in(CollectionUtils.isNotEmpty(eneryIdList),SysEnergy::getEnersno,eneryIdList); final List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(queryWrapper); //鑳芥簮缂栧彿鍜岃兘婧愭姌鏍囩郴鏁� - final Map<String, Object> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); + final Map<String, BigDecimal> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); //index鍜岃兘婧� final Map<String, String> indexIdEnergyIdMap = new HashMap<>(); nodeIndexInforList.forEach(n->{ @@ -899,7 +899,7 @@ indexIdList.forEach(indexId->{ final List<DataItem> dataItems = dataItemMap.get(indexId); final String energyId = indexIdEnergyIdMap.get(indexId); - final BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + final BigDecimal coefficient = energyCoefficientMap.get(energyId); if(CollectionUtils.isNotEmpty(dataItems) ){ BigDecimal sum = BigDecimal.valueOf(dataItems.stream() @@ -999,7 +999,7 @@ final LambdaQueryWrapper<SysEnergy> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(CollectionUtils.isNotEmpty(eneryIdList),SysEnergy::getEnersno,eneryIdList); final List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(queryWrapper); - final Map<String, Object> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); + final Map<String, BigDecimal> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); final Map<String, String> indexIdEnergyIdMap = new HashMap<>(); nodeIndexInforList.forEach(n->{ final String indexId = n.getIndexId(); @@ -1063,7 +1063,7 @@ final String indexId = dataItem.getIndexId(); final String energyId = indexIdEnergyIdMap.get(indexId); - final BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + final BigDecimal coefficient = energyCoefficientMap.get(energyId); if(coefficient == null){ throw new RuntimeException("鑳芥簮绫诲瀷" + energyId + "娌℃湁閰嶇疆鎶樻爣绯绘暟锛屾棤娉曡绠�"); } diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostElectricityInput.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostElectricityInput.java new file mode 100644 index 0000000..0d28d1a --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostElectricityInput.java @@ -0,0 +1,65 @@ +package com.zhitan.costmanagement.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhitan.common.annotation.Excel; + +import java.math.BigDecimal; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆戝璞� cost_electricity_Input + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Data +@TableName("cost_electricity_Input") +public class CostElectricityInput extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private String id; + + /** 鏃堕棿绫诲瀷瀛楀吀鍊紅imeType */ + @Excel(name = "鏃堕棿绫诲瀷瀛楀吀鍊紅imeType") + private String type; + + /** 鐢甸噺 */ + @Excel(name = "鐢甸噺") + private BigDecimal electricityNum; + + /** 鏌ヨ鏃堕棿 */ + @Excel(name = "鏌ヨ鏃堕棿") + private String time; + + /** 鐢佃垂 */ + @Excel(name = "鐢佃垂") + private BigDecimal electricityFee; + + /** 鍔熺巼鍥犳暟 */ + @Excel(name = "鍔熺巼鍥犳暟") + private BigDecimal powerFactor; + + /** 灏栨椂娈电敤鐢甸噺 */ + @Excel(name = "灏栨椂娈电敤鐢甸噺") + private BigDecimal sharpElectricity; + + /** 宄版椂娈电敤鐢甸噺 */ + @Excel(name = "宄版椂娈电敤鐢甸噺") + private BigDecimal peakElectricity; + + /** 骞虫椂娈电敤鐢甸噺 */ + @Excel(name = "骞虫椂娈电敤鐢甸噺") + private BigDecimal flatElectricity; + + /** 璋锋椂娈电敤鐢甸噺 */ + @Excel(name = "璋锋椂娈电敤鐢甸噺") + private BigDecimal valleyElectricity; + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceRelevancy.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceRelevancy.java new file mode 100644 index 0000000..73d4252 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceRelevancy.java @@ -0,0 +1,51 @@ +package com.zhitan.costmanagement.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhitan.common.annotation.Excel; + +/** + * 鍗曚环鍏宠仈瀵硅薄 cost_price_relevancy + * + * @author ZhiTan + * @date 2024-11-09 + */ +@TableName("cost_price_relevancy") +@Data +public class CostPriceRelevancy extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private String id; + + /** 鐢ㄨ兘鍗曚綅 */ + @Excel(name = "鐢ㄨ兘鍗曚綅") + private String nodeId; + + /** 鍗曚环绛栫暐id */ + @Excel(name = "鍗曚环绛栫暐id") + private String tacticsId; + + /** 鑳芥簮鍝佺 */ + @Excel(name = "鑳芥簮鍝佺") + private Integer energyType; + + /** 鏈夋晥鏈熷紑濮嬫棩鏈� */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "鏈夋晥鏈熷紑濮嬫棩鏈�", width = 30, dateFormat = "yyyy-MM-dd") + private Date effectiveBeginTime; + + /** 鏈夋晥鏈熺粨鏉熸棩鏈� */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "鏈夋晥鏈熺粨鏉熸棩鏈�", width = 30, dateFormat = "yyyy-MM-dd") + private Date effectiveEndTime; + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTactics.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTactics.java new file mode 100644 index 0000000..2adec75 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTactics.java @@ -0,0 +1,43 @@ +package com.zhitan.costmanagement.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhitan.common.annotation.Excel; + +/** + * 鎴愭湰绛栫暐瀵硅薄 cost_price_tactics + * + * @author ZhiTan + * @date 2024-11-08 + */ +@TableName("cost_price_tactics") +@Data +public class CostPriceTactics extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private String id; + + /** 鏄惁闃舵浠锋牸0鍚�1鏄� */ + @Excel(name = "鏄惁闃舵浠锋牸0鍚�1鏄�") + private String type; + + /** 绛栫暐缂栫爜 */ + @Excel(name = "绛栫暐缂栫爜") + private String tacticsNumber; + + /** 绛栫暐鍚嶇О */ + @Excel(name = "绛栫暐鍚嶇О") + private String tacticsName; + + /** 鑳芥簮鍝佺 */ + @Excel(name = "鑳芥簮鍝佺") + private Integer energyType; + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTacticsItem.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTacticsItem.java new file mode 100644 index 0000000..baa5445 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/CostPriceTacticsItem.java @@ -0,0 +1,57 @@ +package com.zhitan.costmanagement.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhitan.common.annotation.Excel; + +import java.math.BigDecimal; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆戝璞� cost_price_tactics_item + * + * @author ZhiTan + * @date 2024-11-08 + */ +@TableName("cost_price_tactics_item") +@Data +public class CostPriceTacticsItem extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private String id; + + /** 鑼冨洿绫诲瀷瀛楀吀鍊糲ost_range_type */ + @Excel(name = "鑼冨洿绫诲瀷瀛楀吀鍊糲ost_range_type") + private String rangeType; + + /** 绛栫暐鍚嶇О */ + @Excel(name = "绛栫暐鍚嶇О") + private String tacticsNumber; + + /** 鍏宠仈绛栫暐id */ + @Excel(name = "鍏宠仈绛栫暐id") + private String tacticsId; + + /** 瀛楀吀鍊約pikes_and_valleys */ + @Excel(name = "瀛楀吀鍊約pikes_and_valleys") + private String electricityType; + + /** 鍖洪棿鑼冨洿鏈�灏忓�� */ + @Excel(name = "鍖洪棿鑼冨洿鏈�灏忓��") + private String slotsMin; + + /** 鍖洪棿鑼冨洿鏈�澶у�� */ + @Excel(name = "鍖洪棿鑼冨洿鏈�澶у��") + private String slotsMax; + + /** 鍗曚环 */ + @Excel(name = "鍗曚环") + private BigDecimal price; + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceRelevancyVo.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceRelevancyVo.java new file mode 100644 index 0000000..2368e8e --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceRelevancyVo.java @@ -0,0 +1,24 @@ +package com.zhitan.costmanagement.domain.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhitan.common.annotation.Excel; +import com.zhitan.common.core.domain.BaseEntity; +import com.zhitan.costmanagement.domain.CostPriceRelevancy; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 鍗曚环鍏宠仈瀵硅薄 cost_price_relevancy + * + * @author ZhiTan + * @date 2024-11-09 + */ +@Data +public class CostPriceRelevancyVo extends CostPriceRelevancy { + private BigDecimal price; + private String electricityType; + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceTacticsVo.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceTacticsVo.java new file mode 100644 index 0000000..0eb6569 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/CostPriceTacticsVo.java @@ -0,0 +1,22 @@ +package com.zhitan.costmanagement.domain.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.annotation.Excel; +import com.zhitan.common.core.domain.BaseEntity; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.zhitan.costmanagement.domain.CostPriceTacticsItem; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysItem; +import lombok.Data; + +import java.util.List; + +/** + * 鎴愭湰绛栫暐瀵硅薄 vo + * + * + */ +@Data +public class CostPriceTacticsVo extends CostPriceTactics { + List<CostPriceTacticsItem> itemList; + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/DeviationAnalysisDTO.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/DeviationAnalysisDTO.java new file mode 100644 index 0000000..2c9b91c --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/DeviationAnalysisDTO.java @@ -0,0 +1,50 @@ +package com.zhitan.costmanagement.domain.vo; + +import com.zhitan.common.enums.TimeType; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.Date; + + +/** + * 灏栧嘲骞宠胺鏁版嵁鍒楄〃瀹炰綋绫� electricityDataItem + * + * @author ruoyi + * @date 2024-06-19 + */ +@Data + +public class DeviationAnalysisDTO { + + /** + * 妯″瀷缂栧彿 + */ + @ApiModelProperty(value = "妯″瀷缂栧彿") + @NotBlank(message = "妯″瀷缂栧彿涓嶈兘涓虹┖!") + private String modelCode; + + /** + * 鑺傜偣id + */ + @ApiModelProperty(value = "鑺傜偣id") + @NotBlank(message = "鑺傜偣id涓嶈兘涓虹┖!") + private String nodeId; + + /** + * 鏃堕棿绫诲瀷 + */ + @ApiModelProperty(value = "鏃堕棿绫诲瀷") + @NotBlank(message = "鏃堕棿绫诲瀷涓嶈兘涓虹┖!") + private String timeType; + + + private String date; + + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOut.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOut.java new file mode 100644 index 0000000..3a32c1c --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOut.java @@ -0,0 +1,16 @@ +package com.zhitan.costmanagement.domain.vo; + +import lombok.Data; + +/** + * 鍋忓樊鍒嗘瀽杩斿洖瀵硅薄 + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Data + +public class ElectricityDataOut { + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOutItem.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOutItem.java new file mode 100644 index 0000000..bd61068 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityDataOutItem.java @@ -0,0 +1,54 @@ +package com.zhitan.costmanagement.domain.vo; + +import com.zhitan.common.annotation.Excel; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 鍋忓樊鍒嗘瀽杩斿洖瀵硅薄 + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Data + +public class ElectricityDataOutItem { + private BigDecimal electricityNum=BigDecimal.ZERO; + + private BigDecimal electricityFee=BigDecimal.ZERO; + + private BigDecimal powerFactor=BigDecimal.ZERO; + + private BigDecimal electricityNumLast=BigDecimal.ZERO; + + private BigDecimal electricityFeeLast=BigDecimal.ZERO; + + private BigDecimal powerFactorLast=BigDecimal.ZERO; + + private BigDecimal electricityNumYoy=BigDecimal.ZERO; + + private BigDecimal electricityFeeYoy=BigDecimal.ZERO; + + private BigDecimal powerFactorYoy=BigDecimal.ZERO; + + private BigDecimal electricityNumQoq=BigDecimal.ZERO; + + private BigDecimal electricityFeeQoq=BigDecimal.ZERO; + + private BigDecimal powerFactorQoq=BigDecimal.ZERO; + + /** 灏栨椂娈电敤鐢甸噺 */ + private BigDecimal sharpElectricity=BigDecimal.ZERO; + + /** 宄版椂娈电敤鐢甸噺 */ + private BigDecimal peakElectricity=BigDecimal.ZERO; + + /** 骞虫椂娈电敤鐢甸噺 */ + private BigDecimal flatElectricity=BigDecimal.ZERO; + + /** 璋锋椂娈电敤鐢甸噺 */ + private BigDecimal valleyElectricity=BigDecimal.ZERO; + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityPriceDateVo.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityPriceDateVo.java new file mode 100644 index 0000000..37e3255 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/ElectricityPriceDateVo.java @@ -0,0 +1,25 @@ +package com.zhitan.costmanagement.domain.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhitan.common.annotation.Excel; +import com.zhitan.common.core.domain.BaseEntity; +import com.zhitan.peakvalley.domain.ElectricityPrice; +import com.zhitan.peakvalley.domain.ElectricityPriceDate; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * 灏栧嘲骞宠胺鐢典环鏃堕棿娈靛璞� electricity_price_date + * + * @author ZhiTan + * @date 2024-10-10 + */ +@Data +public class ElectricityPriceDateVo extends ElectricityPriceDate { + List<ElectricityPrice>itemList; +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsData.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsData.java new file mode 100644 index 0000000..8694222 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsData.java @@ -0,0 +1,21 @@ +package com.zhitan.costmanagement.domain.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.annotation.Excel; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 鍋忓樊鍒嗘瀽杩斿洖瀵硅薄 + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Data + +public class StatisticsData { + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsDataOutItem.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsDataOutItem.java new file mode 100644 index 0000000..82b0d34 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsDataOutItem.java @@ -0,0 +1,84 @@ +package com.zhitan.costmanagement.domain.vo; + +import com.zhitan.common.annotation.Excel; +import lombok.Data; +import lombok.Value; +import org.springframework.boot.context.properties.bind.DefaultValue; + +import java.math.BigDecimal; + +/** + * 鍋忓樊鍒嗘瀽杩斿洖瀵硅薄 + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Data +public class StatisticsDataOutItem { + + private BigDecimal electricityNum=BigDecimal.ZERO; + + private BigDecimal electricityFee=BigDecimal.ZERO; + + private BigDecimal powerFactor=BigDecimal.ZERO; + + private BigDecimal electricityNumLast=BigDecimal.ZERO; + + private BigDecimal electricityFeeLast=BigDecimal.ZERO; + + private BigDecimal powerFactorLast=BigDecimal.ZERO; + + private BigDecimal electricityNumYoy=BigDecimal.ZERO; + + private BigDecimal electricityFeeYoy=BigDecimal.ZERO; + + private BigDecimal powerFactorYoy=BigDecimal.ZERO; + + private BigDecimal electricityNumQoq=BigDecimal.ZERO; + + private BigDecimal electricityFeeQoq=BigDecimal.ZERO; + + private BigDecimal powerFactorQoq=BigDecimal.ZERO; + /** 灏栨椂娈电敤鐢甸噺 */ + + private BigDecimal sharpElectricity=BigDecimal.ZERO; + + /** 宄版椂娈电敤鐢甸噺 */ + + private BigDecimal peakElectricity=BigDecimal.ZERO; + + /** 骞虫椂娈电敤鐢甸噺 */ + + private BigDecimal flatElectricity=BigDecimal.ZERO; + + /** 璋锋椂娈电敤鐢甸噺 */ + + private BigDecimal valleyElectricity=BigDecimal.ZERO; + + /** 灏栨椂娈电敤鐢甸噺宸�� */ + + private BigDecimal sharpElectricityDiff=BigDecimal.ZERO; + + /** 宄版椂娈电敤鐢甸噺宸�� */ + + private BigDecimal peakElectricityDiff=BigDecimal.ZERO; + + /** 骞虫椂娈电敤鐢甸噺宸�� */ + + private BigDecimal flatElectricityDiff=BigDecimal.ZERO; + + /** 璋锋椂娈电敤鐢甸噺宸�� */ + + private BigDecimal valleyElectricityDiff=BigDecimal.ZERO; + + private BigDecimal electricityNumDiff=BigDecimal.ZERO; + + private BigDecimal electricityFeeDiff=BigDecimal.ZERO; + + private BigDecimal powerFactorDiff=BigDecimal.ZERO; + + + + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsInfoListOut.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsInfoListOut.java new file mode 100644 index 0000000..81f57e1 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/domain/vo/StatisticsInfoListOut.java @@ -0,0 +1,47 @@ +package com.zhitan.costmanagement.domain.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 鍋忓樊鍒嗘瀽杩斿洖瀵硅薄 + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Data +public class StatisticsInfoListOut { + + private String nodeId; + + private BigDecimal electricityNum; + + private BigDecimal electricityFee; + + + /** 灏栨椂娈电敤鐢甸噺 */ + + private BigDecimal sharpElectricity; + + /** 宄版椂娈电敤鐢甸噺 */ + + private BigDecimal peakElectricity; + + /** 骞虫椂娈电敤鐢甸噺 */ + + private BigDecimal flatElectricity; + + /** 璋锋椂娈电敤鐢甸噺 */ + + private BigDecimal valleyElectricity; + + private BigDecimal electricityNumYoy; + + private BigDecimal electricityNumQoq; + + private BigDecimal electricityNumRadio; + + List<StatisticsInfoListOut>children; +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostElectricityInputMapper.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostElectricityInputMapper.java new file mode 100644 index 0000000..844a73a --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostElectricityInputMapper.java @@ -0,0 +1,61 @@ +package com.zhitan.costmanagement.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.costmanagement.domain.CostElectricityInput; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慚apper鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-08 + */ +public interface CostElectricityInputMapper extends BaseMapper<CostElectricityInput> { + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + public CostElectricityInput selectCostElectricityInputById(String id); + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚� + */ + public List<CostElectricityInput> selectCostElectricityInputList(CostElectricityInput costElectricityInput); + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int insertCostElectricityInput(CostElectricityInput costElectricityInput); + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int updateCostElectricityInput(CostElectricityInput costElectricityInput); + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + public int deleteCostElectricityInputById(String id); + + /** + * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteCostElectricityInputByIds(String[] ids); +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceRelevancyMapper.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceRelevancyMapper.java new file mode 100644 index 0000000..3af02f1 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceRelevancyMapper.java @@ -0,0 +1,75 @@ +package com.zhitan.costmanagement.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.costmanagement.domain.CostPriceRelevancy; +import com.zhitan.costmanagement.domain.vo.CostPriceRelevancyVo; +import org.apache.ibatis.annotations.Param; + +/** + * 鍗曚环鍏宠仈Mapper鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-09 + */ +public interface CostPriceRelevancyMapper extends BaseMapper<CostPriceRelevancy> { + /** + * 鏌ヨ鍗曚环鍏宠仈 + * + * @param id 鍗曚环鍏宠仈涓婚敭 + * @return 鍗曚环鍏宠仈 + */ + public CostPriceRelevancy selectCostPriceRelevancyById(String id); + + /** + * 鏌ヨ鍗曚环鍏宠仈鍒楄〃 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 鍗曚环鍏宠仈闆嗗悎 + */ + public List<CostPriceRelevancy> selectCostPriceRelevancyList(CostPriceRelevancy costPriceRelevancy); + + /** + * 鏂板鍗曚环鍏宠仈 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 缁撴灉 + */ + public int insertCostPriceRelevancy(CostPriceRelevancy costPriceRelevancy); + + /** + * 淇敼鍗曚环鍏宠仈 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 缁撴灉 + */ + public int updateCostPriceRelevancy(CostPriceRelevancy costPriceRelevancy); + + /** + * 鍒犻櫎鍗曚环鍏宠仈 + * + * @param id 鍗曚环鍏宠仈涓婚敭 + * @return 缁撴灉 + */ + public int deleteCostPriceRelevancyById(String id); + + /** + * 鎵归噺鍒犻櫎鍗曚环鍏宠仈 + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteCostPriceRelevancyByIds(String[] ids); + + + + /** + * 鏌ヨ鑼冨洿鍐呭敮涓�鐨勫崟浠风瓥鐣ュ叧鑱斾俊鎭� + * + + */ + public CostPriceRelevancyVo selectCostPriceRelevancyByNodeId(@Param("nodeId") String nodeId, + @Param("elType")String elType); + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsItemMapper.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsItemMapper.java new file mode 100644 index 0000000..d06b305 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsItemMapper.java @@ -0,0 +1,61 @@ +package com.zhitan.costmanagement.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.costmanagement.domain.CostPriceTacticsItem; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慚apper鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-08 + */ +public interface CostPriceTacticsItemMapper extends BaseMapper<CostPriceTacticsItem> { + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + public CostPriceTacticsItem selectCostPriceTacticsItemById(String id); + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚� + */ + public List<CostPriceTacticsItem> selectCostPriceTacticsItemList(CostPriceTacticsItem costPriceTacticsItem); + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int insertCostPriceTacticsItem(CostPriceTacticsItem costPriceTacticsItem); + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int updateCostPriceTacticsItem(CostPriceTacticsItem costPriceTacticsItem); + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsItemById(String id); + + /** + * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsItemByIds(String[] ids); +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsMapper.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsMapper.java new file mode 100644 index 0000000..8b912cc --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/mapper/CostPriceTacticsMapper.java @@ -0,0 +1,70 @@ +package com.zhitan.costmanagement.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.zhitan.costmanagement.domain.vo.CostPriceTacticsVo; + +/** + * 鎴愭湰绛栫暐Mapper鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-08 + */ +public interface CostPriceTacticsMapper extends BaseMapper<CostPriceTactics> { + /** + * 鏌ヨ鎴愭湰绛栫暐 + * + * @param id 鎴愭湰绛栫暐涓婚敭 + * @return 鎴愭湰绛栫暐 + */ + public CostPriceTactics selectCostPriceTacticsById(String id); + + /** + * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 + * + * @param costPriceTactics 鎴愭湰绛栫暐 + * @return 鎴愭湰绛栫暐闆嗗悎 + */ + public List<CostPriceTactics> selectCostPriceTacticsList(CostPriceTactics costPriceTactics); + + /** + * 鏂板鎴愭湰绛栫暐 + * + * @param costPriceTactics 鎴愭湰绛栫暐 + * @return 缁撴灉 + */ + public int insertCostPriceTactics(CostPriceTactics costPriceTactics); + + /** + * 淇敼鎴愭湰绛栫暐 + * + * @param costPriceTactics 鎴愭湰绛栫暐 + * @return 缁撴灉 + */ + public int updateCostPriceTactics(CostPriceTactics costPriceTactics); + + /** + * 鍒犻櫎鎴愭湰绛栫暐 + * + * @param id 鎴愭湰绛栫暐涓婚敭 + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsById(String id); + + /** + * 鎵归噺鍒犻櫎鎴愭湰绛栫暐 + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsByIds(String[] ids); + + /** + * 鏌ヨ鎵�鏈夊崟浠风瓥鐣ュ垪琛� + * + + * @return 鎴愭湰绛栫暐闆嗗悎 + */ + public List<CostPriceTacticsVo> selectCostPriceTacticsListAll(); +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/DeviationAnalysisService.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/DeviationAnalysisService.java new file mode 100644 index 0000000..c4d50fa --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/DeviationAnalysisService.java @@ -0,0 +1,33 @@ +package com.zhitan.costmanagement.service; + +import com.zhitan.costmanagement.domain.vo.DeviationAnalysisDTO; +import com.zhitan.costmanagement.domain.vo.ElectricityDataOutItem; +import com.zhitan.costmanagement.domain.vo.StatisticsDataOutItem; +import com.zhitan.costmanagement.domain.vo.StatisticsInfoListOut; + +import java.text.ParseException; +import java.util.List; +import java.util.Map; + +/** + * 鎴愭湰绛栫暐Service鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-08 + */ +public interface DeviationAnalysisService { + StatisticsDataOutItem getStatisticsDataItem(DeviationAnalysisDTO dto) throws ParseException; + + ElectricityDataOutItem getElectricityDataItem(DeviationAnalysisDTO dto) throws ParseException; + + + StatisticsInfoListOut getStatisticsInfoList(DeviationAnalysisDTO dto)throws ParseException; + List<StatisticsInfoListOut> getStatisticsInfoNewList(DeviationAnalysisDTO dto)throws ParseException; + + StatisticsInfoListOut getStatisticsInfoList2(DeviationAnalysisDTO dto)throws ParseException; + + + + + Map<String,Object>getEcharst(DeviationAnalysisDTO dto)throws ParseException; +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostElectricityInputService.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostElectricityInputService.java new file mode 100644 index 0000000..5ed6eb9 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostElectricityInputService.java @@ -0,0 +1,61 @@ +package com.zhitan.costmanagement.service; + +import java.util.List; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慡ervice鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-08 + */ +public interface ICostElectricityInputService extends IService<CostElectricityInput> { + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + public CostElectricityInput selectCostElectricityInputById(String id); + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚� + */ + public Page<CostElectricityInput> selectCostElectricityInputList(CostElectricityInput costElectricityInput,Long pageNum, Long pageSize); + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int insertCostElectricityInput(CostElectricityInput costElectricityInput) throws Exception; + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int updateCostElectricityInput(CostElectricityInput costElectricityInput) throws Exception; + + /** + * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param ids 闇�瑕佸垹闄ょ殑銆愯濉啓鍔熻兘鍚嶇О銆戜富閿泦鍚� + * @return 缁撴灉 + */ + public int deleteCostElectricityInputByIds(String[] ids); + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆戜俊鎭� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + public int deleteCostElectricityInputById(String id); +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceRelevancyService.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceRelevancyService.java new file mode 100644 index 0000000..37dec5e --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceRelevancyService.java @@ -0,0 +1,62 @@ +package com.zhitan.costmanagement.service; + +import java.util.List; +import com.zhitan.costmanagement.domain.CostPriceRelevancy; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +/** + * 鍗曚环鍏宠仈Service鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-09 + */ +public interface ICostPriceRelevancyService extends IService<CostPriceRelevancy> { + /** + * 鏌ヨ鍗曚环鍏宠仈 + * + * @param id 鍗曚环鍏宠仈涓婚敭 + * @return 鍗曚环鍏宠仈 + */ + public CostPriceRelevancy selectCostPriceRelevancyById(String id); + + /** + * 鏌ヨ鍗曚环鍏宠仈鍒楄〃 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 鍗曚环鍏宠仈闆嗗悎 + */ + public Page<CostPriceRelevancy> selectCostPriceRelevancyList(CostPriceRelevancy costPriceRelevancy,Long pageNum, Long pageSize); + + /** + * 鏂板鍗曚环鍏宠仈 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 缁撴灉 + */ + public int insertCostPriceRelevancy(CostPriceRelevancy costPriceRelevancy); + + /** + * 淇敼鍗曚环鍏宠仈 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 缁撴灉 + */ + public int updateCostPriceRelevancy(CostPriceRelevancy costPriceRelevancy); + + /** + * 鎵归噺鍒犻櫎鍗曚环鍏宠仈 + * + * @param ids 闇�瑕佸垹闄ょ殑鍗曚环鍏宠仈涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteCostPriceRelevancyByIds(String[] ids); + + /** + * 鍒犻櫎鍗曚环鍏宠仈淇℃伅 + * + * @param id 鍗曚环鍏宠仈涓婚敭 + * @return 缁撴灉 + */ + public int deleteCostPriceRelevancyById(String id); +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsItemService.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsItemService.java new file mode 100644 index 0000000..d95f012 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsItemService.java @@ -0,0 +1,61 @@ +package com.zhitan.costmanagement.service; + +import java.util.List; +import com.zhitan.costmanagement.domain.CostPriceTacticsItem; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慡ervice鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-08 + */ +public interface ICostPriceTacticsItemService extends IService<CostPriceTacticsItem> { + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + public CostPriceTacticsItem selectCostPriceTacticsItemById(String id); + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚� + */ + public List<CostPriceTacticsItem> selectCostPriceTacticsItemList(CostPriceTacticsItem costPriceTacticsItem); + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int insertCostPriceTacticsItem(CostPriceTacticsItem costPriceTacticsItem); + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int updateCostPriceTacticsItem(CostPriceTacticsItem costPriceTacticsItem); + + /** + * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param ids 闇�瑕佸垹闄ょ殑銆愯濉啓鍔熻兘鍚嶇О銆戜富閿泦鍚� + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsItemByIds(String[] ids); + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆戜俊鎭� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsItemById(String id); +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsService.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsService.java new file mode 100644 index 0000000..1ed7b26 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/ICostPriceTacticsService.java @@ -0,0 +1,71 @@ +package com.zhitan.costmanagement.service; + +import java.util.List; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.baomidou.mybatisplus.extension.service.IService; +import com.zhitan.costmanagement.domain.vo.CostPriceTacticsVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +/** + * 鎴愭湰绛栫暐Service鎺ュ彛 + * + * @author ZhiTan + * @date 2024-11-08 + */ +public interface ICostPriceTacticsService extends IService<CostPriceTactics> { + /** + * 鏌ヨ鎴愭湰绛栫暐 + * + * @param id 鎴愭湰绛栫暐涓婚敭 + * @return 鎴愭湰绛栫暐 + */ + public CostPriceTactics selectCostPriceTacticsById(String id); + + /** + * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 + * + * @param costPriceTactics 鎴愭湰绛栫暐 + * @return 鎴愭湰绛栫暐闆嗗悎 + */ + public Page<CostPriceTacticsVo> selectCostPriceTacticsList(CostPriceTactics costPriceTactics, Long pageNum, Long pageSize); + + /** + * 鏌ヨ鎵�鏈夊崟浠风瓥鐣ュ垪琛� + * + + * @return 鎴愭湰绛栫暐闆嗗悎 + */ + public List<CostPriceTacticsVo> selectCostPriceTacticsListAll(); + + /** + * 鏂板鎴愭湰绛栫暐 + * + * @param costPriceTacticsVo 鎴愭湰绛栫暐 + * @return 缁撴灉 + */ + public int insertCostPriceTactics(CostPriceTacticsVo costPriceTacticsVo) throws Exception; + + /** + * 淇敼鎴愭湰绛栫暐 + * + * @param costPriceTacticsVo 鎴愭湰绛栫暐 + * @return 缁撴灉 + */ + public int updateCostPriceTactics(CostPriceTacticsVo costPriceTacticsVo); + + /** + * 鎵归噺鍒犻櫎鎴愭湰绛栫暐 + * + * @param ids 闇�瑕佸垹闄ょ殑鎴愭湰绛栫暐涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsByIds(String[] ids); + + /** + * 鍒犻櫎鎴愭湰绛栫暐淇℃伅 + * + * @param id 鎴愭湰绛栫暐涓婚敭 + * @return 缁撴灉 + */ + public int deleteCostPriceTacticsById(String id); +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostElectricityInputServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostElectricityInputServiceImpl.java new file mode 100644 index 0000000..6dd7558 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostElectricityInputServiceImpl.java @@ -0,0 +1,126 @@ +package com.zhitan.costmanagement.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.List; +import java.util.UUID; + +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysItem; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysScheme; +import com.zhitan.spikesandvalleys.domain.vo.SpikesAndValleysSchemeVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhitan.costmanagement.mapper.CostElectricityInputMapper; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import com.zhitan.costmanagement.service.ICostElectricityInputService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慡ervice涓氬姟灞傚鐞� + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Service +public class CostElectricityInputServiceImpl extends ServiceImpl<CostElectricityInputMapper, CostElectricityInput> implements ICostElectricityInputService { + @Autowired + private CostElectricityInputMapper costElectricityInputMapper; + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + @Override + public CostElectricityInput selectCostElectricityInputById(String id) { + return costElectricityInputMapper.selectCostElectricityInputById(id); + } + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + @Override + public Page<CostElectricityInput> selectCostElectricityInputList(CostElectricityInput costElectricityInput,Long pageNum, Long pageSize) { + LambdaQueryWrapper<CostElectricityInput> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(costElectricityInput.getTime()),CostElectricityInput::getTime,costElectricityInput.getTime()); + queryWrapper.eq(StringUtils.isNotEmpty(costElectricityInput.getType()),CostElectricityInput::getType,costElectricityInput.getType()); + queryWrapper.orderByDesc(CostElectricityInput::getCreateTime); + Page<CostElectricityInput> page = costElectricityInputMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + + + return page; + } + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + @Override + @Transactional + public int insertCostElectricityInput(CostElectricityInput costElectricityInput) throws Exception { + costElectricityInput.setCreateTime(DateUtils.getNowDate()); + costElectricityInput.setId(UUID.randomUUID().toString()); + + CostElectricityInput search = costElectricityInputMapper.selectOne(new QueryWrapper<CostElectricityInput>(). + eq("type",costElectricityInput.getType()).eq("time",costElectricityInput.getTime())); + if (search!=null){ + throw new Exception("璇ユ椂闂存宸茬淮鎶ょ數閲忎俊鎭紒"); + } + return costElectricityInputMapper.insertCostElectricityInput(costElectricityInput); + } + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costElectricityInput 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + @Override + @Transactional + public int updateCostElectricityInput(CostElectricityInput costElectricityInput) throws Exception { + costElectricityInput.setUpdateTime(DateUtils.getNowDate()); + CostElectricityInput search = costElectricityInputMapper.selectOne(new QueryWrapper<CostElectricityInput>(). + eq("type",costElectricityInput.getType()).eq("time",costElectricityInput.getTime())); + if (search!=null){ + throw new Exception("璇ユ椂闂存宸茬淮鎶ょ數閲忎俊鎭紒"); + } + return costElectricityInputMapper.updateCostElectricityInput(costElectricityInput); + } + + /** + * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param ids 闇�瑕佸垹闄ょ殑銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + @Override + @Transactional + public int deleteCostElectricityInputByIds(String[] ids) { + return costElectricityInputMapper.deleteCostElectricityInputByIds(ids); + } + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆戜俊鎭� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + @Override + @Transactional + public int deleteCostElectricityInputById(String id) { + return costElectricityInputMapper.deleteCostElectricityInputById(id); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceRelevancyServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceRelevancyServiceImpl.java new file mode 100644 index 0000000..9a248f7 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceRelevancyServiceImpl.java @@ -0,0 +1,105 @@ +package com.zhitan.costmanagement.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.List; +import java.util.UUID; + +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhitan.costmanagement.mapper.CostPriceRelevancyMapper; +import com.zhitan.costmanagement.domain.CostPriceRelevancy; +import com.zhitan.costmanagement.service.ICostPriceRelevancyService; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +/** + * 鍗曚环鍏宠仈Service涓氬姟灞傚鐞� + * + * @author ZhiTan + * @date 2024-11-09 + */ +@Service +public class CostPriceRelevancyServiceImpl extends ServiceImpl<CostPriceRelevancyMapper, CostPriceRelevancy> implements ICostPriceRelevancyService { + @Autowired + private CostPriceRelevancyMapper costPriceRelevancyMapper; + + /** + * 鏌ヨ鍗曚环鍏宠仈 + * + * @param id 鍗曚环鍏宠仈涓婚敭 + * @return 鍗曚环鍏宠仈 + */ + @Override + public CostPriceRelevancy selectCostPriceRelevancyById(String id) { + return costPriceRelevancyMapper.selectCostPriceRelevancyById(id); + } + + /** + * 鏌ヨ鍗曚环鍏宠仈鍒楄〃 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 鍗曚环鍏宠仈 + */ + @Override + public Page<CostPriceRelevancy> selectCostPriceRelevancyList(CostPriceRelevancy costPriceRelevancy,Long pageNum, Long pageSize) { + LambdaQueryWrapper<CostPriceRelevancy> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StringUtils.isNotEmpty(costPriceRelevancy.getNodeId()),CostPriceRelevancy::getNodeId,costPriceRelevancy.getNodeId()); + if(costPriceRelevancy.getEnergyType()!=null){ + queryWrapper.eq(StringUtils.isNotEmpty(costPriceRelevancy.getEnergyType().toString()),CostPriceRelevancy::getEnergyType,costPriceRelevancy.getEnergyType()); + + } + queryWrapper.orderByDesc(CostPriceRelevancy::getCreateTime); + Page<CostPriceRelevancy> page = costPriceRelevancyMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + return page; + } + + /** + * 鏂板鍗曚环鍏宠仈 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 缁撴灉 + */ + @Override + public int insertCostPriceRelevancy(CostPriceRelevancy costPriceRelevancy) { + costPriceRelevancy.setCreateTime(DateUtils.getNowDate()); + costPriceRelevancy.setId(UUID.randomUUID().toString()); + return costPriceRelevancyMapper.insertCostPriceRelevancy(costPriceRelevancy); + } + + /** + * 淇敼鍗曚环鍏宠仈 + * + * @param costPriceRelevancy 鍗曚环鍏宠仈 + * @return 缁撴灉 + */ + @Override + public int updateCostPriceRelevancy(CostPriceRelevancy costPriceRelevancy) { + costPriceRelevancy.setUpdateTime(DateUtils.getNowDate()); + return costPriceRelevancyMapper.updateCostPriceRelevancy(costPriceRelevancy); + } + + /** + * 鎵归噺鍒犻櫎鍗曚环鍏宠仈 + * + * @param ids 闇�瑕佸垹闄ょ殑鍗曚环鍏宠仈涓婚敭 + * @return 缁撴灉 + */ + @Override + public int deleteCostPriceRelevancyByIds(String[] ids) { + return costPriceRelevancyMapper.deleteCostPriceRelevancyByIds(ids); + } + + /** + * 鍒犻櫎鍗曚环鍏宠仈淇℃伅 + * + * @param id 鍗曚环鍏宠仈涓婚敭 + * @return 缁撴灉 + */ + @Override + public int deleteCostPriceRelevancyById(String id) { + return costPriceRelevancyMapper.deleteCostPriceRelevancyById(id); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsItemServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsItemServiceImpl.java new file mode 100644 index 0000000..c5e2c5d --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsItemServiceImpl.java @@ -0,0 +1,90 @@ +package com.zhitan.costmanagement.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.List; + import com.zhitan.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhitan.costmanagement.mapper.CostPriceTacticsItemMapper; +import com.zhitan.costmanagement.domain.CostPriceTacticsItem; +import com.zhitan.costmanagement.service.ICostPriceTacticsItemService; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慡ervice涓氬姟灞傚鐞� + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Service +public class CostPriceTacticsItemServiceImpl extends ServiceImpl<CostPriceTacticsItemMapper, CostPriceTacticsItem> implements ICostPriceTacticsItemService { + @Autowired + private CostPriceTacticsItemMapper costPriceTacticsItemMapper; + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + @Override + public CostPriceTacticsItem selectCostPriceTacticsItemById(String id) { + return costPriceTacticsItemMapper.selectCostPriceTacticsItemById(id); + } + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + @Override + public List<CostPriceTacticsItem> selectCostPriceTacticsItemList(CostPriceTacticsItem costPriceTacticsItem) { + return costPriceTacticsItemMapper.selectCostPriceTacticsItemList(costPriceTacticsItem); + } + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + @Override + public int insertCostPriceTacticsItem(CostPriceTacticsItem costPriceTacticsItem) { + costPriceTacticsItem.setCreateTime(DateUtils.getNowDate()); + return costPriceTacticsItemMapper.insertCostPriceTacticsItem(costPriceTacticsItem); + } + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param costPriceTacticsItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + @Override + public int updateCostPriceTacticsItem(CostPriceTacticsItem costPriceTacticsItem) { + costPriceTacticsItem.setUpdateTime(DateUtils.getNowDate()); + return costPriceTacticsItemMapper.updateCostPriceTacticsItem(costPriceTacticsItem); + } + + /** + * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param ids 闇�瑕佸垹闄ょ殑銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + @Override + public int deleteCostPriceTacticsItemByIds(String[] ids) { + return costPriceTacticsItemMapper.deleteCostPriceTacticsItemByIds(ids); + } + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆戜俊鎭� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + @Override + public int deleteCostPriceTacticsItemById(String id) { + return costPriceTacticsItemMapper.deleteCostPriceTacticsItemById(id); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsServiceImpl.java new file mode 100644 index 0000000..8c7600a --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/CostPriceTacticsServiceImpl.java @@ -0,0 +1,201 @@ +package com.zhitan.costmanagement.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.costmanagement.domain.CostPriceTacticsItem; +import com.zhitan.costmanagement.domain.vo.CostPriceTacticsVo; +import com.zhitan.costmanagement.mapper.CostPriceTacticsItemMapper; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysItem; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysScheme; +import com.zhitan.spikesandvalleys.domain.vo.SpikesAndValleysSchemeVo; +import lombok.SneakyThrows; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhitan.costmanagement.mapper.CostPriceTacticsMapper; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.zhitan.costmanagement.service.ICostPriceTacticsService; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.transaction.annotation.Transactional; + +/** + * 鎴愭湰绛栫暐Service涓氬姟灞傚鐞� + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Service +public class CostPriceTacticsServiceImpl extends ServiceImpl<CostPriceTacticsMapper, CostPriceTactics> implements ICostPriceTacticsService { + @Autowired + private CostPriceTacticsMapper costPriceTacticsMapper; + @Autowired + private CostPriceTacticsItemMapper costPriceTacticsItemMapper; + + + /** + * 鏌ヨ鎴愭湰绛栫暐 + * + * @param id 鎴愭湰绛栫暐涓婚敭 + * @return 鎴愭湰绛栫暐 + */ + @Override + public CostPriceTactics selectCostPriceTacticsById(String id) { + CostPriceTacticsVo result = new CostPriceTacticsVo(); + CostPriceTactics info = costPriceTacticsMapper.selectCostPriceTacticsById(id); + BeanUtil.copyProperties(info,result); + LambdaQueryWrapper<CostPriceTacticsItem> queryWrapperItem = new LambdaQueryWrapper<>(); + queryWrapperItem.eq(CostPriceTacticsItem::getTacticsId,id); + List<CostPriceTacticsItem> itemListOld = costPriceTacticsItemMapper.selectList(queryWrapperItem); + result.setItemList(itemListOld); + return result ; + } + + /** + * 鏌ヨ鎴愭湰绛栫暐鍒楄〃 + * + * @param costPriceTactics 鎴愭湰绛栫暐 + * @return 鎴愭湰绛栫暐 + */ + @Override + public Page<CostPriceTacticsVo> selectCostPriceTacticsList(CostPriceTactics costPriceTactics, Long pageNum, Long pageSize) { + + LambdaQueryWrapper<CostPriceTactics> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(costPriceTactics.getTacticsName()),CostPriceTactics::getTacticsName,costPriceTactics.getTacticsName()); + queryWrapper.like(StringUtils.isNotEmpty(costPriceTactics.getTacticsNumber()),CostPriceTactics::getTacticsNumber,costPriceTactics.getTacticsNumber()); + + queryWrapper.eq(StringUtils.isNotEmpty(costPriceTactics.getType()),CostPriceTactics::getType,costPriceTactics.getType()); + queryWrapper.orderByDesc(CostPriceTactics::getCreateTime); + Page<CostPriceTactics> page = costPriceTacticsMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + IPage aa = page.convert(s->{ + CostPriceTacticsVo v = new CostPriceTacticsVo(); + BeanUtil.copyProperties(s, v); + LambdaQueryWrapper<CostPriceTacticsItem> queryWrapperItem = new LambdaQueryWrapper<>(); + queryWrapperItem.eq(CostPriceTacticsItem::getTacticsId,s.getId()); + List<CostPriceTacticsItem> itemListOld = costPriceTacticsItemMapper.selectList(queryWrapperItem); + v.setItemList(itemListOld); + return v; + }); + + return (Page<CostPriceTacticsVo>) aa; + } + + @Override + public List<CostPriceTacticsVo> selectCostPriceTacticsListAll() { + return costPriceTacticsMapper.selectCostPriceTacticsListAll(); + } + + /** + * 鏂板鎴愭湰绛栫暐 + * + * @param costPriceTacticsVo 鎴愭湰绛栫暐 + * @return 缁撴灉 + */ + @Override + @Transactional + public int insertCostPriceTactics(CostPriceTacticsVo costPriceTacticsVo) throws Exception { + + CostPriceTactics search = costPriceTacticsMapper.selectOne(new QueryWrapper<CostPriceTactics>().eq("tactics_number",costPriceTacticsVo.getTacticsNumber())); + if (search!=null){ + throw new Exception("璇ョ瓥鐣ョ紪鐮佸凡瀛樺湪锛�"); + } + costPriceTacticsVo.setCreateTime(DateUtils.getNowDate()); + costPriceTacticsVo.setId(UUID.randomUUID().toString()); + CostPriceTactics costPriceTactics = new CostPriceTactics(); + BeanUtil.copyProperties(costPriceTacticsVo,costPriceTactics); + int result = costPriceTacticsMapper.insert(costPriceTactics); + //鎻掑叆瀛愯〃 + List<CostPriceTacticsItem> itemList = costPriceTacticsVo.getItemList(); + itemList.stream().forEach(s->{ + s.setId(UUID.randomUUID().toString()); + s.setCreateTime(DateUtils.getNowDate()); + s.setCreateBy(costPriceTacticsVo.getCreateBy()); + s.setTacticsId(costPriceTacticsVo.getId()); + costPriceTacticsItemMapper.insert(s); + }); + + return result; + } + + /** + * 淇敼鎴愭湰绛栫暐 + * + * @param costPriceTacticsVo 鎴愭湰绛栫暐 + * @return 缁撴灉 + */ + @Override + @Transactional + public int updateCostPriceTactics(CostPriceTacticsVo costPriceTacticsVo) { + costPriceTacticsVo.setUpdateTime(DateUtils.getNowDate()); + CostPriceTactics costPriceTactics = new CostPriceTactics(); + BeanUtil.copyProperties(costPriceTacticsVo,costPriceTactics); + int result = costPriceTacticsMapper.updateCostPriceTactics(costPriceTactics); + //鍒犻櫎瀛愯〃 + LambdaQueryWrapper<CostPriceTacticsItem> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CostPriceTacticsItem::getTacticsId,costPriceTactics.getId()); + List<CostPriceTacticsItem> itemListOld = costPriceTacticsItemMapper.selectList(queryWrapper); + List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); + String[] ids = idList.toArray(new String[idList.size()]); + costPriceTacticsItemMapper.deleteCostPriceTacticsItemByIds(ids); + //鎻掑叆瀛愯〃 + List<CostPriceTacticsItem> itemList = costPriceTacticsVo.getItemList(); + itemList.stream().forEach(s->{ + s.setId(UUID.randomUUID().toString()); + s.setCreateTime(DateUtils.getNowDate()); + s.setCreateBy(costPriceTacticsVo.getCreateBy()); + s.setTacticsId(costPriceTacticsVo.getId()); + costPriceTacticsItemMapper.insert(s); + }); + return result; + } + + /** + * 鎵归噺鍒犻櫎鎴愭湰绛栫暐 + * + * @param ids 闇�瑕佸垹闄ょ殑鎴愭湰绛栫暐涓婚敭 + * @return 缁撴灉 + */ + @Override + @Transactional + public int deleteCostPriceTacticsByIds(String[] ids) { + //鍒犻櫎瀛愯〃 + List<String> list = Arrays.asList(ids); + list.stream().forEach(item->{ + LambdaQueryWrapper<CostPriceTacticsItem> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CostPriceTacticsItem::getTacticsId,item); + List<CostPriceTacticsItem> itemListOld = costPriceTacticsItemMapper.selectList(queryWrapper); + List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); + String[] itemIds = idList.toArray(new String[idList.size()]); + costPriceTacticsItemMapper.deleteCostPriceTacticsItemByIds(itemIds); + }); + + return costPriceTacticsMapper.deleteCostPriceTacticsByIds(ids); + } + + /** + * 鍒犻櫎鎴愭湰绛栫暐淇℃伅 + * + * @param id 鎴愭湰绛栫暐涓婚敭 + * @return 缁撴灉 + */ + @Override + @Transactional + public int deleteCostPriceTacticsById(String id) { + LambdaQueryWrapper<CostPriceTacticsItem> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CostPriceTacticsItem::getTacticsId,id); + List<CostPriceTacticsItem> itemListOld = costPriceTacticsItemMapper.selectList(queryWrapper); + List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); + String[] itemIds = idList.toArray(new String[idList.size()]); + costPriceTacticsItemMapper.deleteCostPriceTacticsItemByIds(itemIds); + return costPriceTacticsMapper.deleteCostPriceTacticsById(id); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/DeviationAnalysisServiceServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/DeviationAnalysisServiceServiceImpl.java new file mode 100644 index 0000000..3fdd440 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/costmanagement/service/impl/DeviationAnalysisServiceServiceImpl.java @@ -0,0 +1,572 @@ +package com.zhitan.costmanagement.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.zhitan.common.enums.ElectricityTypeEnum; +import com.zhitan.common.enums.TimeType; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import com.zhitan.costmanagement.domain.vo.*; +import com.zhitan.costmanagement.mapper.CostElectricityInputMapper; +import com.zhitan.costmanagement.mapper.CostPriceRelevancyMapper; +import com.zhitan.costmanagement.service.DeviationAnalysisService; +import com.zhitan.model.domain.ModelNode; +import com.zhitan.model.domain.vo.ModelNodeIndexInfor; +import com.zhitan.model.mapper.ModelInfoMapper; +import com.zhitan.model.mapper.ModelNodeMapper; +import com.zhitan.peakvalley.domain.ElectricityDataItem; +import com.zhitan.peakvalley.mapper.PeakValleyMapper; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.ParseException; +import java.time.Year; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +import static com.zhitan.common.utils.DateUtils.YYYY; +import static com.zhitan.common.utils.DateUtils.YYYY_MM; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慡ervice涓氬姟灞傚鐞� + * + * @author ZhiTan + * @date 2024-11-08 + */ +@Service +public class DeviationAnalysisServiceServiceImpl implements DeviationAnalysisService { + @Resource + private CostElectricityInputMapper costElectricityInputMapper; + @Resource + private ModelNodeMapper modelNodeMapper; + @Resource + private ModelInfoMapper modelInfoMapper; + @Resource + private PeakValleyMapper electricityDataItemMapper; + @Resource + CostPriceRelevancyMapper costPriceRelevancyMapper; + + + @Override + public ElectricityDataOutItem getElectricityDataItem(DeviationAnalysisDTO dto) throws ParseException { + ElectricityDataOutItem ed = new ElectricityDataOutItem(); + CostElectricityInput search = costElectricityInputMapper.selectOne(new QueryWrapper<CostElectricityInput>(). + eq("type",dto.getTimeType()).eq("time",dto.getDate())); + if(search!=null){ + ed.setElectricityFee(search.getElectricityFee()); + ed.setElectricityNum(search.getElectricityNum()); + ed.setPowerFactor(search.getPowerFactor()); + ed.setSharpElectricity(search.getSharpElectricity()); + ed.setPeakElectricity(search.getPeakElectricity()); + ed.setFlatElectricity(search.getFlatElectricity()); + ed.setValleyElectricity(search.getValleyElectricity()); + //濡傛灉缁熻鐨勬槸骞达紝鍏堣幏鍙栦笂涓�骞� + + DateTimeFormatter df = DateTimeFormatter.ofPattern(YYYY_MM); + String lastDate = ""; + + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + YearMonth yearMonth = YearMonth.parse(dto.getDate(), df); + + //濡傛灉缁熻鐨勬槸鏈� + String lastMonth = yearMonth.minusMonths(1).format(df); + CostElectricityInput searchMonth = costElectricityInputMapper.selectOne(new QueryWrapper<CostElectricityInput>(). + eq("type",dto.getTimeType()).eq("time",lastMonth)); + + ed.setElectricityFeeQoq(percentage(search.getElectricityFee(),searchMonth.getElectricityFee())); + ed.setElectricityNumQoq(percentage(search.getElectricityNum(),searchMonth.getElectricityNum())); + ed.setPowerFactorQoq(percentage(search.getPowerFactor(),searchMonth.getPowerFactor())); + lastDate = yearMonth.minusYears(1).format(df); + }else{ + df = DateTimeFormatter.ofPattern(YYYY); + Year year = Year.parse(dto.getDate(), df); + lastDate = year.minusYears(1).format(df); + } + + CostElectricityInput searchLastYear = costElectricityInputMapper.selectOne(new QueryWrapper<CostElectricityInput>(). + eq("type",dto.getTimeType()).eq("time",lastDate)); + if(searchLastYear!=null){ + ed.setElectricityFeeYoy(percentage(search.getElectricityFee(),searchLastYear.getElectricityFee())); + ed.setElectricityNumYoy(percentage(search.getElectricityNum(),searchLastYear.getElectricityNum())); + ed.setPowerFactorYoy(percentage(search.getPowerFactor(),searchLastYear.getPowerFactor())); + }else{ + ed.setElectricityFeeYoy(new BigDecimal(100)); + ed.setElectricityNumYoy(new BigDecimal(100)); + ed.setPowerFactorYoy(new BigDecimal(100)); + } + + } + + return ed; + + } + + @Override + public StatisticsInfoListOut getStatisticsInfoList(DeviationAnalysisDTO dto) throws ParseException { + StatisticsInfoListOut out = new StatisticsInfoListOut(); + List<ModelNode>modelNodeList = modelNodeMapper.getModelNodeByModelCode(dto.getModelCode()); + + List<ModelNode>modelNodeList2 = modelNodeList.stream().filter(s->s.getParentId()==null).collect(Collectors.toList()); + List<ModelNode>modelNodeList3 = modelNodeList.stream().filter(s->s.getParentId()!=null).collect(Collectors.toList()); + String nodeId = modelNodeList2.get(0).getNodeId(); + + List<ModelNode>childList = modelNodeList3.stream().filter(t->nodeId.equals(t.getParentId())).collect(Collectors.toList()); + + List<String>nodes = childList.stream().map(s->s.getNodeId()).collect(Collectors.toList()); + if(nodes!=null&& nodes.size()>0){ + out = computeInfoList(dto,nodes,modelNodeList,nodeId); + }else{ + out.setNodeId(nodeId); + List<StatisticsInfoListOut> child = new ArrayList<>(); + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), nodeId); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet, dto.getTimeType()); + StatisticsDataOutItem nowData = compute(dto.getTimeType(),dto.getDate(),nodeId,dataItemList); + BeanUtil.copyProperties(nowData,out); + out.setElectricityNumRadio(new BigDecimal(100)); + + DateTimeFormatter df = DateTimeFormatter.ofPattern(YYYY_MM); + String lastDate = ""; + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + //濡傛灉缁熻鐨勬槸鏈� + YearMonth yearMonth = YearMonth.parse(dto.getDate(), df); + lastDate = yearMonth.minusYears(1).format(df); + //濡傛灉缁熻鐨勬槸鏈� + String lastMonth = yearMonth.minusMonths(1).format(df); + + StatisticsDataOutItem lastMonthData = compute(dto.getTimeType(),lastMonth,nodeId,dataItemList); + out.setElectricityNumQoq(percentage(out.getElectricityNum(),lastMonthData.getElectricityNum())); + }else{ + df = DateTimeFormatter.ofPattern(YYYY); + Year year = Year.parse(dto.getDate(), df); + lastDate = year.minusYears(1).format(df); + + } + StatisticsDataOutItem lastYearData = compute(dto.getTimeType(),lastDate,nodeId,dataItemList); + out.setElectricityNumYoy(percentage(out.getElectricityNum(),lastYearData.getElectricityNum())); + } + out.setChildren(child); + } + + + return out; + } + + @Override + public List<StatisticsInfoListOut> getStatisticsInfoNewList(DeviationAnalysisDTO dto) throws ParseException { + List<StatisticsInfoListOut>result=new ArrayList<>(); + List<ModelNode>modelNodeList = modelNodeMapper.getModelNodeByModelCode(dto.getModelCode()); + List<ModelNode>modelNodeList2 = modelNodeList.stream().filter(s->s.getParentId()==null).collect(Collectors.toList()); + BigDecimal totalNum = new BigDecimal(0); + String nodeIdP = modelNodeList2.get(0).getNodeId(); + + for(ModelNode modelNode:modelNodeList){ + StatisticsInfoListOut out = new StatisticsInfoListOut(); + String nodeId = modelNode.getNodeId(); + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), nodeId); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet, dto.getTimeType()); + StatisticsDataOutItem nowData = compute(dto.getTimeType(),dto.getDate(),nodeId,dataItemList); + BeanUtil.copyProperties(nowData,out); + if (nodeIdP.equals(nodeId)) { + totalNum = nowData.getElectricityNum(); + } + out.setElectricityNumRadio(nowData.getElectricityNum().divide(totalNum)); + DateTimeFormatter df = DateTimeFormatter.ofPattern(YYYY_MM); + String lastDate = ""; + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + //濡傛灉缁熻鐨勬槸鏈� + YearMonth yearMonth = YearMonth.parse(dto.getDate(), df); + lastDate = yearMonth.minusYears(1).format(df); + //濡傛灉缁熻鐨勬槸鏈� + String lastMonth = yearMonth.minusMonths(1).format(df); + + StatisticsDataOutItem lastMonthData = compute(dto.getTimeType(),lastMonth,nodeId,dataItemList); + out.setElectricityNumQoq(percentage(out.getElectricityNum(),lastMonthData.getElectricityNum())); + }else{ + df = DateTimeFormatter.ofPattern(YYYY); + Year year = Year.parse(dto.getDate(), df); + lastDate = year.minusYears(1).format(df); + + } + StatisticsDataOutItem lastYearData = compute(dto.getTimeType(),lastDate,nodeId,dataItemList); + out.setElectricityNumYoy(percentage(out.getElectricityNum(),lastYearData.getElectricityNum())); + } + } + return result; + } + + @Override + public Map<String, Object> getEcharst(DeviationAnalysisDTO dto) throws ParseException { + List<String>xData = new ArrayList<>(); + List<String>xData2 = new ArrayList<>(); + List<BigDecimal>yData = new ArrayList<>(); + Map<String, Object>result = new HashMap<>(); + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), dto.getNodeId()); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + + String dateStr = dto.getDate(); + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + + List<ElectricityDataItem> dataItemList = new ArrayList<>(); + + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + dateStr = "D"+dateStr.replace("-",""); + dataItemList = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet, TimeType.DAY.name()); + }else{ + dateStr = "M"+dateStr; + dataItemList = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet, TimeType.MONTH.name()); + } + String finalDateStr1 = dateStr; + List<ElectricityDataItem>dataNow = new ArrayList<>(); + + dataNow = dataItemList.stream().filter(s->s.getTimeCode().substring(0,7).equals(finalDateStr1)).collect(Collectors.toList()); + + Map<String, List<ElectricityDataItem>> electricityDataMap = new HashMap<>(); + electricityDataMap = dataNow.stream() + .collect(Collectors.groupingBy(li -> DateUtil.formatDateTime(li.getDataTime()))); +// xData = dataNow.stream().map(s->DateUtil.formatDateTime(s.getDataTime())).collect(Collectors.toList()); + for(String date : electricityDataMap.keySet()){ + List<ElectricityDataItem> ylist = electricityDataMap.get(date); + BigDecimal allNum = BigDecimal.ZERO; + for(ElectricityDataItem i : ylist){ + allNum = allNum.add(i.getElectricity()); + } + yData.add(allNum); + String mapKey = DateUtil.formatDate(DateUtil.parseDate(date)); + xData2.add(mapKey); + } + + } + result.put("xData",xData2); + result.put("yData",yData); + + + + + return result; + } + + @Override + public StatisticsDataOutItem getStatisticsDataItem(DeviationAnalysisDTO dto) throws ParseException { + ElectricityDataOutItem electricityDataOutItem = this.getElectricityDataItem(dto); + StatisticsDataOutItem result = new StatisticsDataOutItem(); + +// // 鏌ヨ鐐逛綅淇℃伅 + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), dto.getNodeId()); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet, dto.getTimeType()); + StatisticsDataOutItem nowData = compute(dto.getTimeType(),dto.getDate(),dto.getNodeId(),dataItemList); + BeanUtil.copyProperties(nowData,result); + result.setPowerFactor(new BigDecimal(0.9).setScale(2, RoundingMode.HALF_UP)); + result.setPowerFactorQoq(new BigDecimal(0).setScale(2, RoundingMode.HALF_UP)); + result.setPowerFactorYoy(new BigDecimal(0.6).setScale(2, RoundingMode.HALF_UP)); + result.setPowerFactorDiff(result.getPowerFactor().subtract(electricityDataOutItem.getPowerFactor())); + result.setElectricityNumDiff(result.getElectricityNum().subtract(electricityDataOutItem.getElectricityNum())); + result.setElectricityFeeDiff(result.getElectricityFee().subtract(electricityDataOutItem.getElectricityFee())); + result.setSharpElectricityDiff(result.getSharpElectricity().subtract(electricityDataOutItem.getSharpElectricity())); + result.setPeakElectricityDiff(result.getPeakElectricity().subtract(electricityDataOutItem.getPeakElectricity())); + result.setFlatElectricityDiff(result.getFlatElectricity().subtract(electricityDataOutItem.getFlatElectricity())); + result.setValleyElectricityDiff(result.getValleyElectricity().subtract(electricityDataOutItem.getValleyElectricity())); + DateTimeFormatter df = DateTimeFormatter.ofPattern(YYYY_MM); + String lastDate = ""; + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + //濡傛灉缁熻鐨勬槸鏈� + YearMonth yearMonth = YearMonth.parse(dto.getDate(), df); + + //濡傛灉缁熻鐨勬槸鏈� + String lastMonth = yearMonth.minusMonths(1).format(df); + + StatisticsDataOutItem lastMonthData = compute(dto.getTimeType(),lastMonth,dto.getNodeId(),dataItemList); + result.setElectricityFeeQoq(percentage(result.getElectricityFee(),lastMonthData.getElectricityFee())); + result.setElectricityNumQoq(percentage(result.getElectricityNum(),lastMonthData.getElectricityNum())); + lastDate = yearMonth.minusYears(1).format(df); +// result.setPowerFactorQoq(percentage(result.getPowerFactor(),lastMonthData.getPowerFactor())); + }else{ + df = DateTimeFormatter.ofPattern(YYYY); + Year year = Year.parse(dto.getDate(), df); + lastDate = year.minusYears(1).format(df); +// result.setPowerFactorQoq(percentage(result.getPowerFactor(),lastYearData.getPowerFactor())); + } + StatisticsDataOutItem lastYearData = compute(dto.getTimeType(),lastDate,dto.getNodeId(),dataItemList); + result.setElectricityFeeYoy(percentage(result.getElectricityFee(),lastYearData.getElectricityFee())); + result.setElectricityNumYoy(percentage(result.getElectricityNum(),lastYearData.getElectricityNum())); + + + } + return result; + } + //璁$畻鐢佃垂銆佽�楃數閲� + private StatisticsDataOutItem compute(String timeType,String dateStr,String nodeId,List<ElectricityDataItem>dataItemList){ + StatisticsDataOutItem sd = new StatisticsDataOutItem(); + if(TimeType.MONTH.name().equals(timeType)){ + dateStr = "M"+dateStr.replace("-",""); + }else{ + dateStr = "Y"+dateStr; + } + + String finalDateStr = dateStr; + List<ElectricityDataItem>dataNow = new ArrayList<>(); + BigDecimal sharpFee = BigDecimal.ZERO; + BigDecimal sharpPower = BigDecimal.ZERO; + BigDecimal peakFee = BigDecimal.ZERO; + BigDecimal peakPower = BigDecimal.ZERO; + BigDecimal flatFee = BigDecimal.ZERO; + BigDecimal flatPower = BigDecimal.ZERO; + BigDecimal valleyFee = BigDecimal.ZERO; + BigDecimal valleyPower = BigDecimal.ZERO; + BigDecimal DeepFee = BigDecimal.ZERO; + BigDecimal DeepPower = BigDecimal.ZERO; + + dataNow = dataItemList.stream().filter(s->s.getTimeCode().equals(finalDateStr)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(dataNow)) { + for (ElectricityDataItem electricityDataItem : dataNow) { + String electricityType = electricityDataItem.getElectricityType(); + if (ElectricityTypeEnum.SHARP.name().equals(electricityType)) { + sharpPower = sharpPower.add(electricityDataItem.getElectricity()); + + } else if (ElectricityTypeEnum.PEAK.name().equals(electricityType)) { + + peakPower = peakPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.FLAT.name().equals(electricityType)) { + + flatPower = flatPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.VALLEY.name().equals(electricityType)){ + + valleyPower = valleyPower.add(electricityDataItem.getElectricity()); + }else if (ElectricityTypeEnum.DEEP.name().equals(electricityType)){ + + DeepPower = DeepPower.add(electricityDataItem.getElectricity()); + } + } + CostPriceRelevancyVo voS = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId,ElectricityTypeEnum.SHARP.name()); + if(voS!=null){ + sharpFee = voS.getPrice().multiply(sharpPower); + } + CostPriceRelevancyVo voP = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId,ElectricityTypeEnum.PEAK.name()); + if(voP!=null){ + peakFee = voP.getPrice().multiply(peakPower); + } + CostPriceRelevancyVo voF = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId,ElectricityTypeEnum.FLAT.name()); + if(voF!=null){ + flatFee = voF.getPrice().multiply(flatPower); + } + CostPriceRelevancyVo voV = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId, ElectricityTypeEnum.VALLEY.name()); + if(voV!=null){ + valleyFee = voV.getPrice().multiply(valleyPower); + } + CostPriceRelevancyVo voD = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId, ElectricityTypeEnum.DEEP.name()); + if(voV!=null){ + DeepFee = voV.getPrice().multiply(valleyPower); + } + BigDecimal allNum = sharpPower.add(peakPower).add(flatPower).add(valleyPower); + BigDecimal allFee = sharpFee.add(peakFee).add(flatFee).add(valleyFee); + sd.setSharpElectricity(sharpPower); + sd.setPeakElectricity(peakPower); + sd.setFlatElectricity(flatPower); + sd.setValleyElectricity(valleyPower); + sd.setElectricityFee(allFee); + sd.setElectricityNum(allNum); + + } + return sd; + } + /** + * 鍚岀幆姣旇绠� + * @param thisData + * @param lastData + * @return + */ + private BigDecimal percentage(BigDecimal thisData, BigDecimal lastData) { + BigDecimal rate = new BigDecimal(100); + if(lastData.compareTo(BigDecimal.ZERO)==1){ + BigDecimal differ = thisData.subtract(lastData); + rate = differ.multiply(new BigDecimal(100)).divide(lastData,BigDecimal.ROUND_CEILING).setScale(2, RoundingMode.HALF_UP); + + } + + return rate; + } + + private StatisticsInfoListOut computeInfoList(DeviationAnalysisDTO dto,List<String>nodes,List<ModelNode>modelNodeList,String nodeId){ + StatisticsInfoListOut out = new StatisticsInfoListOut(); + List<StatisticsInfoListOut> child = new ArrayList<>(); + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), nodeId); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet, dto.getTimeType()); + StatisticsDataOutItem nowData = compute(dto.getTimeType(),dto.getDate(),nodeId,dataItemList); + BeanUtil.copyProperties(nowData,out); + out.setElectricityNumRadio(new BigDecimal(100)); + out.setNodeId(nodeId); + DateTimeFormatter df = DateTimeFormatter.ofPattern(YYYY_MM); + String lastDate = ""; + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + //濡傛灉缁熻鐨勬槸鏈� + YearMonth yearMonth = YearMonth.parse(dto.getDate(), df); + + //濡傛灉缁熻鐨勬槸鏈� + String lastMonth = yearMonth.minusMonths(1).format(df); + + StatisticsDataOutItem lastMonthData = compute(dto.getTimeType(),lastMonth,nodeId,dataItemList); + out.setElectricityNumQoq(percentage(out.getElectricityNum(),lastMonthData.getElectricityNum())); + lastDate = yearMonth.minusYears(1).format(df); + }else{ + df = DateTimeFormatter.ofPattern(YYYY); + Year year = Year.parse(dto.getDate(), df); + lastDate = year.minusYears(1).format(df); + + } + StatisticsDataOutItem lastYearData = compute(dto.getTimeType(),lastDate,nodeId,dataItemList); + out.setElectricityNumYoy(percentage(out.getElectricityNum(),lastYearData.getElectricityNum())); + if(nodes!=null&&nodes.size()>0){ + for(String node : nodes){ + + StatisticsInfoListOut out2 = new StatisticsInfoListOut(); + out2.setNodeId(node); + List<ModelNodeIndexInfor> nodeIndexInfoList2 = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), node); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList2)) { + Set<String> indexSet2 = nodeIndexInfoList2.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList2 = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet2, dto.getTimeType()); + StatisticsDataOutItem nowData2 = compute(dto.getTimeType(),dto.getDate(),node,dataItemList2); + BeanUtil.copyProperties(nowData2,out2); + out2.setElectricityNumRadio(new BigDecimal(100)); + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + //濡傛灉缁熻鐨勬槸鏈� + YearMonth yearMonth = YearMonth.parse(dto.getDate(), df); + lastDate = yearMonth.minusYears(1).format(df); + //濡傛灉缁熻鐨勬槸鏈� + String lastMonth = yearMonth.minusMonths(1).format(df); + + StatisticsDataOutItem lastMonthData = compute(dto.getTimeType(),lastMonth,node,dataItemList2); + + out2.setElectricityNumQoq(percentage(out2.getElectricityNum(),lastMonthData.getElectricityNum())); + + + }else{ + df = DateTimeFormatter.ofPattern(YYYY); + Year year = Year.parse(dto.getDate(), df); + lastDate = year.minusYears(1).format(df); + + } + StatisticsDataOutItem lastYearData2 = compute(dto.getTimeType(),lastDate,dto.getNodeId(),dataItemList2); + out2.setElectricityNumYoy(percentage(out2.getElectricityNum(),lastYearData2.getElectricityNum())); + + } + child.add(out2); +// List<ModelNode>childList = modelNodeList.stream().filter(s->s.getParentId().equals(node)).collect(Collectors.toList()); +// List<String>node2s = childList.stream().map(s->s.getNodeId()).collect(Collectors.toList()); +// if(){ +// +// } + + + } + } + } + out.setChildren(child); + return out; + } + + + @Override + public StatisticsInfoListOut getStatisticsInfoList2(DeviationAnalysisDTO dto) throws ParseException { + + + + + + + + + + + + + + + + + + + + + + + StatisticsInfoListOut out = new StatisticsInfoListOut(); + List<ModelNode>modelNodeList = modelNodeMapper.getModelNodeByModelCode(dto.getModelCode()); + + List<ModelNode>modelNodeList2 = modelNodeList.stream().filter(s->s.getParentId()==null).collect(Collectors.toList()); + List<ModelNode>modelNodeList3 = modelNodeList.stream().filter(s->s.getParentId()!=null).collect(Collectors.toList()); + String nodeId = modelNodeList2.get(0).getNodeId(); + + List<ModelNode>childList = modelNodeList3.stream().filter(t->nodeId.equals(t.getParentId())).collect(Collectors.toList()); + + List<String>nodes = childList.stream().map(s->s.getNodeId()).collect(Collectors.toList()); + if(nodes!=null&& nodes.size()>0){ + out = computeInfoList(dto,nodes,modelNodeList,nodeId); + }else{ + out.setNodeId(nodeId); + List<StatisticsInfoListOut> child = new ArrayList<>(); + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), nodeId); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatisticsDeviationAnalysis(indexSet, dto.getTimeType()); + StatisticsDataOutItem nowData = compute(dto.getTimeType(),dto.getDate(),nodeId,dataItemList); + BeanUtil.copyProperties(nowData,out); + out.setElectricityNumRadio(new BigDecimal(100)); + + DateTimeFormatter df = DateTimeFormatter.ofPattern(YYYY_MM); + String lastDate = ""; + if(TimeType.MONTH.name().equals(dto.getTimeType())){ + //濡傛灉缁熻鐨勬槸鏈� + YearMonth yearMonth = YearMonth.parse(dto.getDate(), df); + lastDate = yearMonth.minusYears(1).format(df); + //濡傛灉缁熻鐨勬槸鏈� + String lastMonth = yearMonth.minusMonths(1).format(df); + + StatisticsDataOutItem lastMonthData = compute(dto.getTimeType(),lastMonth,nodeId,dataItemList); + out.setElectricityNumQoq(percentage(out.getElectricityNum(),lastMonthData.getElectricityNum())); + }else{ + df = DateTimeFormatter.ofPattern(YYYY); + Year year = Year.parse(dto.getDate(), df); + lastDate = year.minusYears(1).format(df); + + } + StatisticsDataOutItem lastYearData = compute(dto.getTimeType(),lastDate,nodeId,dataItemList); + out.setElectricityNumYoy(percentage(out.getElectricityNum(),lastYearData.getElectricityNum())); + } + out.setChildren(child); + } + + + return out; + } + + + /** + * 閫掑綊寤虹珛鏍戝舰缁撴瀯 锛堢畻娉曪級 + * @param lists + * @param pid + * @return + */ +// private List<StatisticsInfoListOut> createTree(List<StatisticsInfoListOut> lists, int pid) { +// List<StatisticsInfoListOut> tree = new ArrayList<>(); +// for (StatisticsInfoListOut catelog : lists) { +// if (catelog.get() == pid) { +// catelog.setChirldren(createTree(lists,catelog.getId())); +// tree.add(catelog); +// } +// } +// return tree; +// } + +} diff --git a/zhitan-system/src/main/java/com/zhitan/dataitem/mapper/DataItemMapper.java b/zhitan-system/src/main/java/com/zhitan/dataitem/mapper/DataItemMapper.java index e34439c..d33b810 100644 --- a/zhitan-system/src/main/java/com/zhitan/dataitem/mapper/DataItemMapper.java +++ b/zhitan-system/src/main/java/com/zhitan/dataitem/mapper/DataItemMapper.java @@ -1,5 +1,6 @@ package com.zhitan.dataitem.mapper; +import com.zhitan.carbonemission.domain.CarbonEmission; import com.zhitan.common.enums.TimeType; import com.zhitan.dataitem.domain.StagseDataEntry; import com.zhitan.realtimedata.domain.DataItem; @@ -75,4 +76,38 @@ */ BigDecimal getDataItemValueByIndexIds(@Param("timeCode") String timeCode, @Param("indexIds") List<String> indexIds); + + /** + * 鏍规嵁indexId涓庢椂闂磋寖鍥存煡璇㈢⒊鎺掓斁鏁版嵁锛屼笂鍗婇儴鍒� + * @param beginTime + * @param endTime + * @param timeType + * @param indexId + * @return + */ + List<CarbonEmission> getUpCarbonEmission(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime, + @Param("timeType") String timeType, @Param("indexId") String indexId); + + + /** + * 鏍规嵁indexId涓庢椂闂磋寖鍥存煡璇㈢⒊鎺掓斁鏁版嵁锛屼腑闂撮儴鍒� + * @param beginTime + * @param endTime + * @param timeType + * @param indexId + * @return + */ + List<CarbonEmission> getMiddleCarbonEmission(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime, + @Param("timeType") String timeType, @Param("indexId") String indexId,@Param("emissionType") String emissionType); + + /** + * 鏍规嵁indexId涓庢椂闂磋寖鍥存煡璇㈢⒊鎺掓斁鏁版嵁锛屼笅鍗婇儴鍒� + * @param beginTime + * @param endTime + * @param timeType + * @param indexId + * @return + */ + List<CarbonEmission> getDownCarbonEmission(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime, + @Param("timeType") String timeType, @Param("indexId") String indexId); } diff --git a/zhitan-system/src/main/java/com/zhitan/energydata/mapper/EnergyDataStatisticMapper.java b/zhitan-system/src/main/java/com/zhitan/energydata/mapper/EnergyDataStatisticMapper.java new file mode 100644 index 0000000..5a838ef --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/energydata/mapper/EnergyDataStatisticMapper.java @@ -0,0 +1,13 @@ +package com.zhitan.energydata.mapper; + +import com.zhitan.model.domain.CalcFunction; +import com.zhitan.model.domain.vo.ModelNodeIndexInfor; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface EnergyDataStatisticMapper +{ + List<ModelNodeIndexInfor> getModelNodeIndexIdByFixedNodeIds(@Param("modelCode")String modelCode,@Param("fixedNodeIds") List<String> fixedNodeIds); +} diff --git a/zhitan-system/src/main/java/com/zhitan/energydata/service/IEnergyDataStatisticService.java b/zhitan-system/src/main/java/com/zhitan/energydata/service/IEnergyDataStatisticService.java new file mode 100644 index 0000000..1f0f912 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/energydata/service/IEnergyDataStatisticService.java @@ -0,0 +1,30 @@ +package com.zhitan.energydata.service; + + +import com.zhitan.consumptionanalysis.domain.vo.RankingEnergyData; +import com.zhitan.energydata.vo.EnergyChainYoyVO; +import com.zhitan.energydata.vo.FactoryEnergyConsumptionVo; +import com.zhitan.energydata.vo.PurchaseConsumptionVo; +import com.zhitan.peakvalley.domain.dto.PeakValleyDTO; +import com.zhitan.peakvalley.domain.vo.peakvalley.PeakValleyDayVO; +import com.zhitan.peakvalley.domain.vo.peakvalley.PeakValleyHourVO; + +import java.util.List; + +public interface IEnergyDataStatisticService { + PeakValleyDayVO segmentAnalysisMonth(PeakValleyDTO dto); + + List<RankingEnergyData> energyConsumptionRanking(String modelCode, String timeType); + + FactoryEnergyConsumptionVo factoryEnergyConsumption(String timeType, String modelCode); + + List<PurchaseConsumptionVo> purchaseConsumption(String modelCode, String timeType ); + + List<PurchaseConsumptionVo> costProp(String modelCode, String timeType); + + List<EnergyChainYoyVO> energyConsumptionSummation(String timeType, String modelCode); + + PeakValleyDayVO segmentAnalysisDay(PeakValleyDTO dto); + + PeakValleyHourVO segmentAnalysisHour(PeakValleyDTO dto); +} diff --git a/zhitan-system/src/main/java/com/zhitan/energydata/service/impl/EnergyDataStatisticServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/energydata/service/impl/EnergyDataStatisticServiceImpl.java new file mode 100644 index 0000000..8d4e7f1 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/energydata/service/impl/EnergyDataStatisticServiceImpl.java @@ -0,0 +1,1208 @@ +package com.zhitan.energydata.service.impl; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zhitan.basicdata.domain.MeterImplement; +import com.zhitan.basicdata.domain.SysEnergy; +import com.zhitan.basicdata.mapper.MeterImplementMapper; +import com.zhitan.basicdata.mapper.SysEnergyMapper; +import com.zhitan.common.constant.CommonConst; +import com.zhitan.common.enums.ElectricityTypeEnum; +import com.zhitan.common.enums.TimeType; +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.bean.BeanUtils; +import com.zhitan.consumptionanalysis.domain.vo.RankingEnergyData; +import com.zhitan.costmanagement.domain.CostElectricityInput; +import com.zhitan.costmanagement.domain.vo.CostPriceRelevancyVo; +import com.zhitan.costmanagement.mapper.CostElectricityInputMapper; +import com.zhitan.costmanagement.mapper.CostPriceRelevancyMapper; +import com.zhitan.dataitem.service.IDataItemService; +import com.zhitan.energydata.mapper.EnergyDataStatisticMapper; +import com.zhitan.energydata.service.IEnergyDataStatisticService; +import com.zhitan.energydata.vo.EnergyChainYoyVO; +import com.zhitan.energydata.vo.FactoryEnergyConsumptionItemVo; +import com.zhitan.energydata.vo.FactoryEnergyConsumptionVo; +import com.zhitan.energydata.vo.PurchaseConsumptionVo; +import com.zhitan.home.domain.vo.HomeEnergyStatisticsVO; +import com.zhitan.model.domain.EnergyIndex; +import com.zhitan.model.domain.ModelNode; +import com.zhitan.model.domain.vo.ModelNodeIndexInfor; +import com.zhitan.model.mapper.EnergyIndexMapper; +import com.zhitan.model.mapper.ModelNodeMapper; +import com.zhitan.model.service.IEnergyIndexService; +import com.zhitan.model.service.IModelNodeService; +import com.zhitan.peakvalley.domain.ElectricityDataItem; +import com.zhitan.peakvalley.domain.dto.PeakValleyDTO; +import com.zhitan.peakvalley.domain.vo.peakvalley.*; +import com.zhitan.peakvalley.mapper.PeakValleyMapper; +import com.zhitan.realtimedata.domain.DataItem; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +/** + * 鎭掗偊缁煎悎娌荤悊澶у睆鎺ュ彛瀹炵幇绫� + */ +@Service +public class EnergyDataStatisticServiceImpl implements IEnergyDataStatisticService { + + @Autowired + private ModelNodeMapper modelNodeMapper; + @Autowired + private PeakValleyMapper electricityDataItemMapper; + @Autowired + CostPriceRelevancyMapper costPriceRelevancyMapper; + + @Autowired + CostElectricityInputMapper electricityInputMapper; + @Autowired + private IDataItemService dataItemService; + + @Autowired + private SysEnergyMapper sysEnergyMapper; + @Autowired + private IModelNodeService modelNodeService; + @Autowired + private IEnergyIndexService energyIndexService; + + @Autowired + private EnergyDataStatisticMapper statisticMapper; + + @Autowired + private EnergyIndexMapper energyIndexMapper; + + @Autowired + private MeterImplementMapper meterImplementMapper; + + @Override + public List<EnergyChainYoyVO> energyConsumptionSummation(String timeType, String modelcode) { + Date currentTime = new Date(); +// Date currentTime = DateUtil.parseDateTime("2023-04-11 00:00:00"); + + DateTime tongbiTime = DateUtil.offsetMonth(currentTime, -12); + DateTime huanbiTime = DateUtil.offsetMonth(currentTime, -1); + final List<EnergyChainYoyVO> resultData = new ArrayList<>(); + final List<HomeEnergyStatisticsVO> current = getEnergyTotalByTime(timeType, modelcode, currentTime); + final List<HomeEnergyStatisticsVO> tongbi = getEnergyTotalByTime(timeType, modelcode, tongbiTime); + final List<HomeEnergyStatisticsVO> huanbi = getEnergyTotalByTime(timeType, modelcode, huanbiTime); + + final Map<String, List<HomeEnergyStatisticsVO>> tongbiMap = tongbi.stream().collect(Collectors.groupingBy(HomeEnergyStatisticsVO::getEnergyNo)); + final Map<String, List<HomeEnergyStatisticsVO>> huanbiMap = huanbi.stream().collect(Collectors.groupingBy(HomeEnergyStatisticsVO::getEnergyNo)); + + current.stream().forEach(vo->{ + EnergyChainYoyVO chainYoyVO = new EnergyChainYoyVO(); + + final String energyNo = vo.getEnergyNo(); + final Double count = vo.getCount(); + final Double tongbiCount = tongbiMap.get(energyNo).stream().map(HomeEnergyStatisticsVO::getCount).mapToDouble(Double::doubleValue).sum(); + final Double huanbiCount = huanbiMap.get(energyNo).stream().map(HomeEnergyStatisticsVO::getCount).mapToDouble(Double::doubleValue).sum(); + + vo.setTonCount(format2Double( vo.getCount() * Double.valueOf(vo.getCoefficient()))); + if (tongbiCount != 0) { + vo.setTongbi(format2Double( (count - tongbiCount) / tongbiCount * 100)); + }else { + vo.setTongbi(0D); + } + + if (huanbiCount != 0) { + vo.setHuanbi (format2Double((count - huanbiCount) / huanbiCount * 100)); + }else { + vo.setHuanbi(0D); + } + + BeanUtils.copyProperties(vo, chainYoyVO); + chainYoyVO.setSamePeriodCount(BigDecimal.valueOf(tongbiCount)); + chainYoyVO.setCount(BigDecimal.valueOf(vo.getCount())); + chainYoyVO.setTongbi(BigDecimal.valueOf(vo.getTongbi())); + chainYoyVO.setHuanbi(BigDecimal.valueOf(vo.getHuanbi())); + chainYoyVO.setTonCount(BigDecimal.valueOf(vo.getTonCount())); + resultData.add(chainYoyVO); + }); + return resultData; + } + /** + * 鐢ㄧ數瓒嬪娍鍒嗘瀽--閫夋嫨骞� + * @param dto + * @return + */ + @Override + public PeakValleyDayVO segmentAnalysisMonth(PeakValleyDTO dto) { + PeakValleyDayVO peakValleyVO = new PeakValleyDayVO(); + List<PeakValleyDayDataVO> reportVOList = new ArrayList<>(); + //鑾峰彇nodeId + ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(dto.getModelCode()); + dto.setNodeId(modelNode.getNodeId()); + // 鏌ヨ鏃堕棿鑼冨洿 + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.DATE, 1); + calendar.set(Calendar.HOUR, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + Date endTime =calendar.getTime(); + calendar.add(Calendar.MONTH, -12); + Date startTime = calendar.getTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String timeType = dto.getTimeType(); + + Map<String, List<ElectricityDataItem>> electricityDataMap = new HashMap<>(); + // 鏌ヨ鐐逛綅淇℃伅 + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), dto.getNodeId()); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatistics(indexSet, startTime, endTime, timeType); + + electricityDataMap = dataItemList.stream() + .collect(Collectors.groupingBy(li -> DateUtil.formatDateTime(li.getDataTime()))); + } + while (!startTime.after(endTime)) { + String mapKey = DateUtil.formatDateTime(startTime); + List<ElectricityDataItem> dataItemList = electricityDataMap.get(mapKey); + + BigDecimal sharpFee = BigDecimal.ZERO; + BigDecimal sharpPower = BigDecimal.ZERO; + BigDecimal peakFee = BigDecimal.ZERO; + BigDecimal peakPower = BigDecimal.ZERO; + BigDecimal flatFee = BigDecimal.ZERO; + BigDecimal flatPower = BigDecimal.ZERO; + BigDecimal valleyFee = BigDecimal.ZERO; + BigDecimal valleyPower = BigDecimal.ZERO; + + if (CollectionUtils.isNotEmpty(dataItemList)) { + for (ElectricityDataItem electricityDataItem : dataItemList) { + String electricityType = electricityDataItem.getElectricityType(); + + if (ElectricityTypeEnum.SHARP.name().equals(electricityType)) { +// sharpFee = sharpFee.add(electricityDataItem.getCost()); + sharpPower = sharpPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.PEAK.name().equals(electricityType)) { +// peakFee = peakFee.add(electricityDataItem.getCost()); + peakPower = peakPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.FLAT.name().equals(electricityType)) { +// flatFee = flatFee.add(electricityDataItem.getCost()); + flatPower = flatPower.add(electricityDataItem.getElectricity()); + } else { +// valleyFee = valleyFee.add(electricityDataItem.getCost()); + valleyPower = valleyPower.add(electricityDataItem.getElectricity()); + } + } + //2024-11-12鏂板 + CostPriceRelevancyVo voS = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.SHARP.name()); + if(voS!=null){ + sharpFee = voS.getPrice().multiply(sharpPower); + } + CostPriceRelevancyVo voP = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.PEAK.name()); + if(voP!=null){ + peakFee = voP.getPrice().multiply(peakPower); + } + CostPriceRelevancyVo voF = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.FLAT.name()); + if(voF!=null){ + flatFee = voF.getPrice().multiply(flatPower); + } + CostPriceRelevancyVo voV = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(), ElectricityTypeEnum.VALLEY.name()); + if(voV!=null){ + valleyFee = voV.getPrice().multiply(valleyPower); + } + } + PeakValleyDayDataVO peakAndValleyReportVO = new PeakValleyDayDataVO(startTime, sharpFee, sharpPower, + peakFee, peakPower, flatFee, flatPower, valleyFee, valleyPower); + + reportVOList.add(peakAndValleyReportVO); + + startTime = DateUtil.offsetMonth(startTime, 1); + } + List<PeakValleyLineChatVO> costList = new ArrayList<>(); + List<PeakValleyLineChatVO> powerConsumptionList = new ArrayList<>(); + PeakValleyDayTotalVO peakValleyDayTotalVO = new PeakValleyDayTotalVO(); + + AtomicReference<BigDecimal> flatFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> tipFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> troughFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> peakFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> flatCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> tipCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> troughCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> peakCount = new AtomicReference<>(BigDecimal.ZERO); + + reportVOList.stream().forEach(r->{ + PeakValleyLineChatVO costVO = new PeakValleyLineChatVO(); + PeakValleyLineChatVO powerConsumptionVO = new PeakValleyLineChatVO(); + + /** + * 鐢ㄧ數閲� + */ + final BigDecimal peakPower = r.getPeakPower(); + final BigDecimal valleyPower = r.getValleyPower(); + final BigDecimal sharpPower = r.getSharpPower(); + final BigDecimal flatPower = r.getFlatPower(); + powerConsumptionVO.setXdata(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,r.getTime())); + powerConsumptionVO.setYtip(sharpPower); + powerConsumptionVO.setYpeak(peakPower); + powerConsumptionVO.setYtrough(valleyPower); + powerConsumptionVO.setYflat(flatPower); + powerConsumptionList.add(powerConsumptionVO); + + /** + * 鐢ㄧ數璐圭敤 + */ + final BigDecimal peakFee = r.getPeakFee(); + final BigDecimal valleyFee = r.getValleyFee(); + final BigDecimal sharpFee = r.getSharpFee(); + final BigDecimal flatFee = r.getFlatFee(); + costVO.setXdata(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,r.getTime())); + costVO.setYtip(sharpFee); + costVO.setYpeak(peakFee); + costVO.setYtrough(valleyFee); + costVO.setYflat(flatFee); + costList.add(costVO); + + flatCount.set(flatCount.get().add(r.getFlatPower())); + tipCount.set(tipCount.get().add(r.getSharpPower())); + troughCount.set(troughCount.get().add(r.getValleyPower())); + peakCount.set(peakCount.get().add(r.getPeakPower())); + + flatFreeCount.set(flatFreeCount.get().add(r.getFlatFee())); + tipFreeCount.set(tipFreeCount.get().add(r.getSharpFee())); + troughFreeCount.set(troughFreeCount.get().add(r.getValleyFee())); + peakFreeCount.set(peakFreeCount.get().add(r.getPeakFee())); + }); + + peakValleyDayTotalVO.setPeakPowerCost(peakFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setPeakPowerConsumption(peakCount.get().doubleValue()); + peakValleyDayTotalVO.setFlatPowerCost(flatFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setFlatPowerConsumption(flatCount.get().doubleValue()); + peakValleyDayTotalVO.setTipPowerCost(tipFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setTipPowerConsumption(tipCount.get().doubleValue()); + peakValleyDayTotalVO.setTroughPowerCost(troughFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setTroughPowerConsumption(troughCount.get().doubleValue()); + + BigDecimal powerTotal = peakCount.get().add(tipCount.get()).add(troughCount.get()).add(flatCount.get()); + if(powerTotal.compareTo(BigDecimal.ZERO) > 0) { + peakValleyDayTotalVO.setPeakPowerProportion(peakCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setFlatPowerProportion(flatCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTipPowerProportion(tipCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTroughPowerProportion(troughCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + }else { + peakValleyDayTotalVO.setPeakPowerProportion(0); + peakValleyDayTotalVO.setFlatPowerProportion(0); + peakValleyDayTotalVO.setTipPowerProportion(0); + peakValleyDayTotalVO.setTroughPowerProportion(0); + } + + BigDecimal freeTotal = peakFreeCount.get().add(tipFreeCount.get()).add(troughFreeCount.get()).add(flatFreeCount.get()); + if(freeTotal.compareTo(BigDecimal.ZERO) > 0) { + peakValleyDayTotalVO.setPeakPowerCostProportion(peakFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setFlatPowerCostProportion(flatFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTipPowerCostProportion(tipFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTroughPowerCostProportion(troughFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + }else { + peakValleyDayTotalVO.setPeakPowerCostProportion(0); + peakValleyDayTotalVO.setFlatPowerCostProportion(0); + peakValleyDayTotalVO.setTipPowerCostProportion(0); + peakValleyDayTotalVO.setTroughPowerCostProportion(0); + } + + peakValleyDayTotalVO.setTotalCost(powerTotal.doubleValue()); + peakValleyDayTotalVO.setTotalPowerConsumption(freeTotal.doubleValue()); + peakValleyVO.setTotalVO(peakValleyDayTotalVO); + peakValleyVO.setCostList(costList); + peakValleyVO.setPowerConsumptionList(powerConsumptionList); + + return peakValleyVO; + } + + @Override + public PeakValleyDayVO segmentAnalysisDay(PeakValleyDTO dto) { + PeakValleyDayVO peakValleyVO = new PeakValleyDayVO(); + List<PeakValleyDayDataVO> reportVOList = new ArrayList<>(); + //鑾峰彇nodeId + ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(dto.getModelCode()); + dto.setNodeId(modelNode.getNodeId()); + // 鏌ヨ鏃堕棿鑼冨洿 + Date startTime = DateUtil.beginOfMonth(dto.getQueryTime()); + Date endTime = DateUtil.endOfMonth(startTime); + String timeType = dto.getTimeType(); + + Map<String, List<ElectricityDataItem>> electricityDataMap = new HashMap<>(); + // 鏌ヨ鐐逛綅淇℃伅 + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), dto.getNodeId()); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatistics(indexSet, startTime, endTime, timeType); + + electricityDataMap = dataItemList.stream() + .collect(Collectors.groupingBy(li -> DateUtil.formatDateTime(li.getDataTime()))); + } + while (!startTime.after(endTime)) { + String mapKey = DateUtil.formatDateTime(startTime); + List<ElectricityDataItem> dataItemList = electricityDataMap.get(mapKey); + + BigDecimal sharpFee = BigDecimal.ZERO; + BigDecimal sharpPower = BigDecimal.ZERO; + BigDecimal peakFee = BigDecimal.ZERO; + BigDecimal peakPower = BigDecimal.ZERO; + BigDecimal flatFee = BigDecimal.ZERO; + BigDecimal flatPower = BigDecimal.ZERO; + BigDecimal valleyFee = BigDecimal.ZERO; + BigDecimal valleyPower = BigDecimal.ZERO; + + if (CollectionUtils.isNotEmpty(dataItemList)) { + for (ElectricityDataItem electricityDataItem : dataItemList) { + String electricityType = electricityDataItem.getElectricityType(); + + if (ElectricityTypeEnum.SHARP.name().equals(electricityType)) { +// sharpFee = sharpFee.add(electricityDataItem.getCost()); + + sharpPower = sharpPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.PEAK.name().equals(electricityType)) { +// peakFee = peakFee.add(electricityDataItem.getCost()); + peakPower = peakPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.FLAT.name().equals(electricityType)) { +// flatFee = flatFee.add(electricityDataItem.getCost()); + flatPower = flatPower.add(electricityDataItem.getElectricity()); + } else { +// valleyFee = valleyFee.add(electricityDataItem.getCost()); + valleyPower = valleyPower.add(electricityDataItem.getElectricity()); + } + } + //2024-11-12鏂板 + CostPriceRelevancyVo voS = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.SHARP.name()); + if(voS!=null){ + sharpFee = voS.getPrice().multiply(sharpPower); + } + CostPriceRelevancyVo voP = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.PEAK.name()); + if(voP!=null){ + peakFee = voP.getPrice().multiply(peakPower); + } + CostPriceRelevancyVo voF = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.FLAT.name()); + if(voF!=null){ + flatFee = voF.getPrice().multiply(flatPower); + } + CostPriceRelevancyVo voV = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(), ElectricityTypeEnum.VALLEY.name()); + if(voV!=null){ + valleyFee = voV.getPrice().multiply(valleyPower); + } +// CostPriceRelevancyVo voD = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(), ElectricityTypeEnum.DEEP.name()); +// if(voV!=null){ +// DeepFee = voV.getPrice().multiply(valleyPower); +// } + + + + + } + PeakValleyDayDataVO peakAndValleyReportVO = new PeakValleyDayDataVO(startTime, sharpFee, sharpPower, + peakFee, peakPower, flatFee, flatPower, valleyFee, valleyPower); + + reportVOList.add(peakAndValleyReportVO); + switch (TimeType.valueOf(timeType)) { + case HOUR: + startTime = DateUtil.offsetHour(startTime, 1); + break; + case DAY: + startTime = DateUtil.offsetDay(startTime, 1); + break; + case MONTH: + startTime = DateUtil.offsetMonth(startTime, 1); + break; + default: + startTime = DateUtil.offsetMonth(startTime, 12); + break; + } + } + List<PeakValleyLineChatVO> costList = new ArrayList<>(); + List<PeakValleyLineChatVO> powerConsumptionList = new ArrayList<>(); + PeakValleyDayTotalVO peakValleyDayTotalVO = new PeakValleyDayTotalVO(); + + AtomicReference<BigDecimal> flatFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> tipFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> troughFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> peakFreeCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> flatCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> tipCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> troughCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> peakCount = new AtomicReference<>(BigDecimal.ZERO); + + reportVOList.stream().forEach(r->{ + PeakValleyLineChatVO costVO = new PeakValleyLineChatVO(); + PeakValleyLineChatVO powerConsumptionVO = new PeakValleyLineChatVO(); + + /** + * 鐢ㄧ數閲� + */ + final BigDecimal peakPower = r.getPeakPower(); + final BigDecimal valleyPower = r.getValleyPower(); + final BigDecimal sharpPower = r.getSharpPower(); + final BigDecimal flatPower = r.getFlatPower(); + powerConsumptionVO.setXdata(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,r.getTime())); + powerConsumptionVO.setYtip(sharpPower); + powerConsumptionVO.setYpeak(peakPower); + powerConsumptionVO.setYtrough(valleyPower); + powerConsumptionVO.setYflat(flatPower); + powerConsumptionList.add(powerConsumptionVO); + + /** + * 鐢ㄧ數璐圭敤 + */ + final BigDecimal peakFee = r.getPeakFee(); + final BigDecimal valleyFee = r.getValleyFee(); + final BigDecimal sharpFee = r.getSharpFee(); + final BigDecimal flatFee = r.getFlatFee(); + costVO.setXdata(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,r.getTime())); + costVO.setYtip(sharpFee); + costVO.setYpeak(peakFee); + costVO.setYtrough(valleyFee); + costVO.setYflat(flatFee); + costList.add(costVO); + + flatCount.set(flatCount.get().add(r.getFlatPower())); + tipCount.set(tipCount.get().add(r.getSharpPower())); + troughCount.set(troughCount.get().add(r.getValleyPower())); + peakCount.set(peakCount.get().add(r.getPeakPower())); + + flatFreeCount.set(flatFreeCount.get().add(r.getFlatFee())); + tipFreeCount.set(tipFreeCount.get().add(r.getSharpFee())); + troughFreeCount.set(troughFreeCount.get().add(r.getValleyFee())); + peakFreeCount.set(peakFreeCount.get().add(r.getPeakFee())); + }); + + peakValleyDayTotalVO.setPeakPowerCost(peakFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setPeakPowerConsumption(peakCount.get().doubleValue()); + peakValleyDayTotalVO.setFlatPowerCost(flatFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setFlatPowerConsumption(flatCount.get().doubleValue()); + peakValleyDayTotalVO.setTipPowerCost(tipFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setTipPowerConsumption(tipCount.get().doubleValue()); + peakValleyDayTotalVO.setTroughPowerCost(troughFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setTroughPowerConsumption(troughCount.get().doubleValue()); + + BigDecimal powerTotal = peakCount.get().add(tipCount.get()).add(troughCount.get()).add(flatCount.get()); + if(powerTotal.compareTo(BigDecimal.ZERO) > 0) { + peakValleyDayTotalVO.setPeakPowerProportion(peakCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setFlatPowerProportion(flatCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTipPowerProportion(tipCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTroughPowerProportion(troughCount.get().divide(powerTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + }else { + peakValleyDayTotalVO.setPeakPowerProportion(0); + peakValleyDayTotalVO.setFlatPowerProportion(0); + peakValleyDayTotalVO.setTipPowerProportion(0); + peakValleyDayTotalVO.setTroughPowerProportion(0); + } + + BigDecimal freeTotal = peakFreeCount.get().add(tipFreeCount.get()).add(troughFreeCount.get()).add(flatFreeCount.get()); + if(freeTotal.compareTo(BigDecimal.ZERO) > 0) { + peakValleyDayTotalVO.setPeakPowerCostProportion(peakFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setFlatPowerCostProportion(flatFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTipPowerCostProportion(tipFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + peakValleyDayTotalVO.setTroughPowerCostProportion(troughFreeCount.get().divide(freeTotal.multiply(new BigDecimal(0.01)), 2, RoundingMode.HALF_UP).doubleValue()); + }else { + peakValleyDayTotalVO.setPeakPowerCostProportion(0); + peakValleyDayTotalVO.setFlatPowerCostProportion(0); + peakValleyDayTotalVO.setTipPowerCostProportion(0); + peakValleyDayTotalVO.setTroughPowerCostProportion(0); + } + +// peakValleyDayTotalVO.setTotalCost(powerTotal.doubleValue()); +// peakValleyDayTotalVO.setTotalPowerConsumption(freeTotal.doubleValue()); + peakValleyDayTotalVO.setTotalCost(freeTotal.doubleValue()); + peakValleyDayTotalVO.setTotalPowerConsumption(powerTotal.doubleValue()); + peakValleyVO.setTotalVO(peakValleyDayTotalVO); + peakValleyVO.setCostList(costList); + peakValleyVO.setPowerConsumptionList(powerConsumptionList); + + return peakValleyVO; + } + + @Override + public PeakValleyHourVO segmentAnalysisHour(PeakValleyDTO dto) { + PeakValleyHourVO peakValleyVO = new PeakValleyHourVO(); + List<PeakValleyHourDataVO> reportVOList = new ArrayList<>(); + //鑾峰彇nodeId + ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(dto.getModelCode()); + dto.setNodeId(modelNode.getNodeId()); + + // 鏌ヨ鏃堕棿鑼冨洿 + Date startTime = DateUtil.beginOfDay(dto.getQueryTime()); + Date endTime = DateUtil.endOfDay(startTime); + String timeType = dto.getTimeType(); + + Map<String, List<ElectricityDataItem>> electricityDataMap = new HashMap<>(); + // 鏌ヨ鐐逛綅淇℃伅 + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), dto.getNodeId()); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatistics(indexSet, startTime, endTime, timeType); + + electricityDataMap = dataItemList.stream() + .collect(Collectors.groupingBy(li -> DateUtil.formatDateTime(li.getDataTime()))); + } + while (!startTime.after(endTime)) { + String mapKey = DateUtil.formatDateTime(startTime); + List<ElectricityDataItem> dataItemList = electricityDataMap.get(mapKey); + + BigDecimal sharpFee = BigDecimal.ZERO; + BigDecimal sharpPower = BigDecimal.ZERO; + BigDecimal peakFee = BigDecimal.ZERO; + BigDecimal peakPower = BigDecimal.ZERO; + BigDecimal flatFee = BigDecimal.ZERO; + BigDecimal flatPower = BigDecimal.ZERO; + BigDecimal valleyFee = BigDecimal.ZERO; + BigDecimal valleyPower = BigDecimal.ZERO; + + if (CollectionUtils.isNotEmpty(dataItemList)) { + for (ElectricityDataItem electricityDataItem : dataItemList) { + String electricityType = electricityDataItem.getElectricityType(); + + if (ElectricityTypeEnum.SHARP.name().equals(electricityType)) { +// sharpFee = sharpFee.add(electricityDataItem.getCost()); + sharpPower = sharpPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.PEAK.name().equals(electricityType)) { +// peakFee = peakFee.add(electricityDataItem.getCost()); + peakPower = peakPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.FLAT.name().equals(electricityType)) { +// flatFee = flatFee.add(electricityDataItem.getCost()); + flatPower = flatPower.add(electricityDataItem.getElectricity()); + } else { +// valleyFee = valleyFee.add(electricityDataItem.getCost()); + valleyPower = valleyPower.add(electricityDataItem.getElectricity()); + } + } + //2024-11-12鏂板 + CostPriceRelevancyVo voS = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.SHARP.name()); + if(voS!=null){ + sharpFee = voS.getPrice().multiply(sharpPower); + } + CostPriceRelevancyVo voP = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.PEAK.name()); + if(voP!=null){ + peakFee = voP.getPrice().multiply(peakPower); + } + CostPriceRelevancyVo voF = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.FLAT.name()); + if(voF!=null){ + flatFee = voF.getPrice().multiply(flatPower); + } + CostPriceRelevancyVo voV = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(), ElectricityTypeEnum.VALLEY.name()); + if(voV!=null){ + valleyFee = voV.getPrice().multiply(valleyPower); + } + + + + } + PeakValleyHourDataVO peakAndValleyReportVO = new PeakValleyHourDataVO(startTime, sharpFee, sharpPower, + peakFee, peakPower, flatFee, flatPower, valleyFee, valleyPower); + + reportVOList.add(peakAndValleyReportVO); + switch (TimeType.valueOf(timeType)) { + case HOUR: + startTime = DateUtil.offsetHour(startTime, 1); + break; + case DAY: + startTime = DateUtil.offsetDay(startTime, 1); + break; + case MONTH: + startTime = DateUtil.offsetMonth(startTime, 1); + break; + default: + startTime = DateUtil.offsetMonth(startTime, 12); + break; + } + } + + peakValleyVO.setDataList(reportVOList); + List<PeakValleyLineChatVO> peakValleyLineChatVOS = new ArrayList<>(); + AtomicReference<BigDecimal> flatCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> tipCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> troughCount = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference<BigDecimal> peakCount = new AtomicReference<>(BigDecimal.ZERO); + reportVOList.stream().forEach(r->{ + PeakValleyLineChatVO lineChatVO = new PeakValleyLineChatVO(); + lineChatVO.setXdata(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,r.getTime())); + lineChatVO.setYtip(r.getSharpPower()); + lineChatVO.setYflat(r.getFlatPower()); + lineChatVO.setYtrough(r.getValleyPower()); + lineChatVO.setYpeak(r.getPeakPower()); + peakValleyLineChatVOS.add(lineChatVO); + BigDecimal flat = flatCount.get().add(r.getFlatPower()); + flatCount.set(flat); + BigDecimal tip = tipCount.get().add(r.getSharpPower()); + tipCount.set(tip); + BigDecimal trough = troughCount.get().add(r.getValleyPower()); + troughCount.set(trough); + BigDecimal peak = peakCount.get().add(r.getPeakPower()); + peakCount.set(peak); + + }); + PeakValleyPieChatVO peakValleyPieChatVO = new PeakValleyPieChatVO(); + BigDecimal total = peakCount.get().add(tipCount.get()).add(troughCount.get()).add(flatCount.get()).multiply(new BigDecimal(0.01)); + if(total.compareTo(BigDecimal.ZERO) > 0) { + peakValleyPieChatVO.setPeak(peakCount.get().divide(total, 2, RoundingMode.HALF_UP).toString()); + peakValleyPieChatVO.setFlat(flatCount.get().divide(total, 2, RoundingMode.HALF_UP).toString()); + peakValleyPieChatVO.setTip(tipCount.get().divide(total, 2, RoundingMode.HALF_UP).toString()); + peakValleyPieChatVO.setTrough(troughCount.get().divide(total, 2, RoundingMode.HALF_UP).toString()); + }else { + peakValleyPieChatVO.setPeak("0"); + peakValleyPieChatVO.setFlat("0"); + peakValleyPieChatVO.setTip("0"); + peakValleyPieChatVO.setTrough("0"); + } + peakValleyVO.setPieChat(peakValleyPieChatVO); + peakValleyVO.setLineChat(peakValleyLineChatVOS); + return peakValleyVO; + } + + /** + * 鑳借�楃瀹ゆ帓鍚嶅墠10 + * @param modelCode + * @param timeType + * @return + */ + @Override + public List<RankingEnergyData> energyConsumptionRanking(String modelCode, String timeType) { + List<RankingEnergyData> energyDataList = new ArrayList<>(); + String nodeCategory = "2"; + LambdaQueryWrapper<ModelNode> modelNodeLambdaQueryWrapper = new LambdaQueryWrapper<>(); + modelNodeLambdaQueryWrapper.eq(ModelNode::getModelCode,modelCode); + modelNodeLambdaQueryWrapper.eq(ModelNode::getNodeCategory,nodeCategory); + List<ModelNode> modelNodeList = modelNodeMapper.selectList(modelNodeLambdaQueryWrapper); + if(CollectionUtils.isEmpty(modelNodeList)){ + return energyDataList; + } + final List<String> nodeIds = modelNodeList.stream().map(ModelNode::getNodeId).collect(Collectors.toList()); + List<ModelNodeIndexInfor> nodeIndexInforList = modelNodeMapper.selectIndexByNodeIds(modelCode ,nodeIds); + + final Map<String, String> nodeNameMap = new HashMap<>(); + nodeIndexInforList.forEach(n->{ + final String id = n.getNodeId(); + final String name = n.getName(); + if(!nodeNameMap.containsKey(id)){ + nodeNameMap.put(id,name); + } + }); + + // 鎸夌収鐐逛綅杩涜鍒嗙粍 + Map<String, List<ModelNodeIndexInfor>> nodeIndexMap = nodeIndexInforList.stream().collect( + Collectors.groupingBy(ModelNodeIndexInfor::getNodeId)); + final List<String> eneryIdList = nodeIndexInforList.stream().map(ModelNodeIndexInfor::getEnergyId).distinct().collect(Collectors.toList()); + final LambdaQueryWrapper<SysEnergy> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(CollectionUtils.isNotEmpty(eneryIdList),SysEnergy::getEnersno,eneryIdList); + final List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(queryWrapper); + //鑳芥簮缂栧彿鍜岃兘婧愭姌鏍囩郴鏁� + final Map<String, Object> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno, SysEnergy::getCoefficient)); + //index鍜岃兘婧� + final Map<String, String> indexIdEnergyIdMap = new HashMap<>(); + nodeIndexInforList.forEach(n->{ + final String indexId = n.getIndexId(); + final String energyId = n.getEnergyId(); + if(!indexIdEnergyIdMap.containsKey(indexId)){ + indexIdEnergyIdMap.put(indexId,energyId); + } + }); + List<String> indexIds = nodeIndexInforList.stream().filter(l -> StringUtils.isNotEmpty(l.getIndexId())).map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); + Date queryTime = new Date(); + Date beginTime; + Date endTime; + String shixuTimeType; + if (TimeType.DAY.name().equals(timeType)) { + beginTime = DateUtil.beginOfDay(queryTime); + endTime = DateUtil.endOfDay(queryTime); + shixuTimeType = TimeType.HOUR.name(); + // 鏈� + } else if (TimeType.MONTH.name().equals(timeType)) { + beginTime = DateUtil.beginOfMonth(queryTime); + endTime = DateUtil.endOfMonth(queryTime); + shixuTimeType = TimeType.DAY.name(); + // 骞� + } else { + beginTime = DateUtil.beginOfYear(queryTime); + endTime = DateUtil.endOfYear(queryTime); + shixuTimeType = TimeType.MONTH.name(); + } + // 鏍规嵁indexId鏌ヨdataItem + List<DataItem> dataItemList = new ArrayList<>(); + if(CollectionUtils.isNotEmpty(indexIds)) { + dataItemList = dataItemService.getDataItemTimeRangeInforByIndexIds(beginTime, endTime, shixuTimeType, indexIds); + } + Map<String, List<DataItem>> dataItemMap = dataItemList.stream().collect(Collectors.groupingBy(DataItem::getIndexId)); + + Map<String,BigDecimal> resultMap = new HashMap<>(); + nodeIndexMap.forEach((key, value) -> { + // 鎵惧嚭indexIds + List<String> indexIdList = value.stream().map(ModelNodeIndexInfor::getIndexId).filter(Objects::nonNull).collect(Collectors.toList()); + if (null!=indexIdList &&!indexIdList.isEmpty()){ + indexIdList.forEach(indexId -> { + final List<DataItem> dataItems = dataItemMap.get(indexId); + final String energyId = indexIdEnergyIdMap.get(indexId); + BigDecimal coefficient = (BigDecimal) energyCoefficientMap.get(energyId); + + if (coefficient == null && StringUtils.isBlank(energyId)) { + EnergyIndex energyIndex = energyIndexMapper.selectEnergyIndexById(indexId); + MeterImplement meterImplement = meterImplementMapper.selectMeterImplementById(energyIndex.getMeterId()); + coefficient = (BigDecimal) energyCoefficientMap.get(meterImplement.getEnergyType()); + } + + if (CollectionUtils.isNotEmpty(dataItems)) { + BigDecimal sum = BigDecimal.valueOf(dataItems.stream() + .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP).multiply(coefficient); + + if (resultMap.containsKey(key)) { + resultMap.put(key, resultMap.get(key).add(sum)); + } else { + resultMap.put(key, sum); + } + } + }); + } + }); + + resultMap.forEach((key,value)->{ + RankingEnergyData rankingEnergyData = new RankingEnergyData(); + rankingEnergyData.setNodeId(key); + rankingEnergyData.setNodeName(nodeNameMap.get(key)); + rankingEnergyData.setEnergyConsumption(value.doubleValue()); + energyDataList.add(rankingEnergyData); + }); + Collections.sort(energyDataList, Comparator.comparingDouble((RankingEnergyData item) -> item.getEnergyConsumption()).reversed()); + // 鑾峰彇鍓�10鏉¤褰� + List<RankingEnergyData> top5Items = energyDataList.subList(0, Math.min(10, energyDataList.size())); + + return top5Items; + } + + /** + * 鍚勪釜杞﹂棿鑳借�楀垎鏋� + * @param timeType + * @param modelCode + * @return + */ + @Override + public FactoryEnergyConsumptionVo factoryEnergyConsumption(String timeType, String modelCode) { + ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(modelCode); + //椤堕儴鏈湀缁煎悎鑳借�� + FactoryEnergyConsumptionVo energyConsumptionVo=new FactoryEnergyConsumptionVo(); + final List<EnergyChainYoyVO> current = energyConsumptionSummation(timeType, modelCode); + //鏈湀鑳借�楄垂鐢� + BigDecimal monthEnergyAmount=getTotalConsumption(modelCode,modelNode.getNodeId(),timeType); + energyConsumptionVo.setMonthEnergyAmount(monthEnergyAmount); + //鍚勪釜杞﹂棿鑳借�� + final List<FactoryEnergyConsumptionItemVo> factoryCurrent = factoryEnergyConData(timeType, modelCode); + EnergyChainYoyVO homeEnergyStatisticsVO = current.get(0); + energyConsumptionVo.setItemVoList(factoryCurrent);// + energyConsumptionVo.setMonthConsumption(homeEnergyStatisticsVO.getCount()); + energyConsumptionVo.setCEmission(BigDecimal.ZERO); + energyConsumptionVo.setUseEnergyIndex(BigDecimal.ZERO); + return energyConsumptionVo; + + } + + /** + * 璐叆娑堣�楀姣� + * @param modelCode + * @param timeType + * @return + */ + @Override + public List<PurchaseConsumptionVo> purchaseConsumption(String modelCode, String timeType) { + ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(modelCode); + List<PurchaseConsumptionVo> voList=new ArrayList<>(); + + String queryTime=null; + if (TimeType.DAY.name().equals(timeType)) { + queryTime=DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,new Date()); + // 鏈� + } else if (TimeType.MONTH.name().equals(timeType)) { + queryTime=DateUtils.parseDateToStr(DateUtils.YYYY_MM,new Date()); + // 骞� + } else { + queryTime=DateUtils.parseDateToStr(DateUtils.YYYY,new Date()); + } + + //鑾峰彇璐叆閲� + LambdaQueryWrapper<CostElectricityInput> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(CostElectricityInput::getType,timeType); + queryWrapper.like(CostElectricityInput::getTime,queryTime); + List<CostElectricityInput> list=electricityInputMapper.selectList(queryWrapper); + + //鑾峰彇娑堣�楅噺 + BigDecimal totalConsumption=getTotalConsumption(modelCode,modelNode.getNodeId(),timeType); + //鍐欏叆瀹炰綋绫� + PurchaseConsumptionVo vo=new PurchaseConsumptionVo(); + vo.setEnergyNo("electric"); + vo.setEnergyName("鐢�"); + vo.setConsumptionSum(totalConsumption.divide(BigDecimal.valueOf(1000),RoundingMode.HALF_UP)); + if (!list.isEmpty()){ + vo.setPurchaseSum(list.get(0).getElectricityFee().divide(BigDecimal.valueOf(1000),RoundingMode.HALF_UP)); + }else{ + vo.setPurchaseSum(BigDecimal.ZERO); + } + voList.add(vo); + + return voList; + } + + /** + * 鑳芥簮鎴愭湰鍗犳瘮 + * @param modelCode + * @param timeType + * @return + */ + @Override + public List<PurchaseConsumptionVo> costProp(String modelCode, String timeType) { + List<PurchaseConsumptionVo> list=new ArrayList<>(); + ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(modelCode); + BigDecimal totalConsumption=getTotalConsumption(modelCode, modelNode.getNodeId(), timeType); + PurchaseConsumptionVo vo=new PurchaseConsumptionVo(); + vo.setEnergyNo("electric"); + vo.setEnergyName("鐢�"); + vo.setConsumptionSum(totalConsumption.divide(BigDecimal.valueOf(10000),RoundingMode.HALF_UP)); + list.add(vo); + return list; + } + + /** + * 鏍规嵁灏栧嘲骞宠胺鑾峰彇娑堣�楃數閲忛噾棰� + * @param modelCode + * @param nodeId + * @param timeType + * @return + */ + public BigDecimal getTotalConsumption(String modelCode,String nodeId,String timeType){ + BigDecimal totalConsumption = BigDecimal.ZERO; + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + Date queryTime =calendar.getTime(); + Date startTime =new Date(); + Date endTime =new Date(); + + if (TimeType.DAY.name().equals(timeType)) { + startTime = DateUtil.beginOfDay(queryTime); + endTime = DateUtil.endOfDay(queryTime); + // 鏈� + } else if (TimeType.MONTH.name().equals(timeType)) { + calendar.set(Calendar.DATE, 1); + startTime = DateUtil.beginOfMonth(queryTime); + endTime = DateUtil.endOfMonth(queryTime); + // 骞� + } else { + calendar.set(Calendar.DATE, 1); + startTime = DateUtil.beginOfYear(queryTime); + endTime = DateUtil.endOfYear(queryTime); + } + + + + Map<String, List<ElectricityDataItem>> electricityDataMap = new HashMap<>(); +// 鏌ヨ鐐逛綅淇℃伅 + List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(modelCode, nodeId); + if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) { + Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet()); + List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatistics(indexSet, startTime,endTime , timeType); + + electricityDataMap = dataItemList.stream() + .collect(Collectors.groupingBy(li -> DateUtil.formatDateTime(li.getDataTime()))); + } + while (!startTime.after(endTime)) { + String mapKey = DateUtil.formatDateTime(startTime); + List<ElectricityDataItem> dataItemList = electricityDataMap.get(mapKey); + + BigDecimal sharpFee = BigDecimal.ZERO; + BigDecimal sharpPower = BigDecimal.ZERO; + BigDecimal peakFee = BigDecimal.ZERO; + BigDecimal peakPower = BigDecimal.ZERO; + BigDecimal flatFee = BigDecimal.ZERO; + BigDecimal flatPower = BigDecimal.ZERO; + BigDecimal valleyFee = BigDecimal.ZERO; + BigDecimal valleyPower = BigDecimal.ZERO; + + if (CollectionUtils.isNotEmpty(dataItemList)) { + for (ElectricityDataItem electricityDataItem : dataItemList) { + String electricityType = electricityDataItem.getElectricityType(); + + if (ElectricityTypeEnum.SHARP.name().equals(electricityType)) { + sharpPower = sharpPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.PEAK.name().equals(electricityType)) { + peakPower = peakPower.add(electricityDataItem.getElectricity()); + } else if (ElectricityTypeEnum.FLAT.name().equals(electricityType)) { + flatPower = flatPower.add(electricityDataItem.getElectricity()); + } else { + valleyPower = valleyPower.add(electricityDataItem.getElectricity()); + } + } + //2024-11-12鏂板 + CostPriceRelevancyVo voS = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId,ElectricityTypeEnum.SHARP.name()); + if(voS!=null){ + sharpFee = voS.getPrice().multiply(sharpPower); + } + CostPriceRelevancyVo voP = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId,ElectricityTypeEnum.PEAK.name()); + if(voP!=null){ + peakFee = voP.getPrice().multiply(peakPower); + } + CostPriceRelevancyVo voF = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId,ElectricityTypeEnum.FLAT.name()); + if(voF!=null){ + flatFee = voF.getPrice().multiply(flatPower); + } + CostPriceRelevancyVo voV = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(nodeId, ElectricityTypeEnum.VALLEY.name()); + if(voV!=null){ + valleyFee = voV.getPrice().multiply(valleyPower); + } + } + totalConsumption = totalConsumption.add(sharpFee).add(peakFee).add(flatFee).add(valleyFee); + + if (TimeType.DAY.name().equals(timeType)) { + startTime = DateUtil.offsetDay(startTime, 1); + // 鏈� + } else if (TimeType.MONTH.name().equals(timeType)) { + startTime = DateUtil.offsetMonth(startTime, 1); + // 骞� + } else { + startTime = DateUtil.offsetMonth(startTime, 12); + } + + } + return totalConsumption; + } + + /** + * 鏍规嵁鍘傚尯銆佽兘婧愮被鍨嬪垎缁勮幏鍙栨瘡涓巶鍖恒�佹瘡绉嶈兘婧愮被鍨嬬殑娑堣�楅噺 + * @param timeType + * @param modelCode + * @return + */ + public List<FactoryEnergyConsumptionItemVo> factoryEnergyConData(String timeType, String modelCode){ + List<FactoryEnergyConsumptionItemVo> energyDataList=new ArrayList<>(); + + //鍘傚尯鍥哄畾涓哄綋鍓�6涓� + List<String> fixedNodeIds=new ArrayList<>(); + fixedNodeIds.add("d9a155d2-b2dd-4a70-a00b-f8ab5be91f00");//鍐朵竴 + fixedNodeIds.add("58dcb139-c943-41fe-a764-7cf79f987c9f");//鍐朵簩 + fixedNodeIds.add("dca20897-5977-40ae-a28a-88a6acdee335");//鍐朵笁 + fixedNodeIds.add("4912c751-0611-4f4b-afce-0f58629512b7");//绮剧偧 + fixedNodeIds.add("8eef471f-880c-4636-a428-620a4d2ccd5d");//鐭夸笟 + fixedNodeIds.add("6d6a0412-7c6d-4654-9cb3-0079655e23e5");//鎭掗偊鏂版潗鏂� + + LambdaQueryWrapper<ModelNode> nodeLambdaQueryWrapper = new LambdaQueryWrapper<>(); + nodeLambdaQueryWrapper.eq(ModelNode::getModelCode,modelCode); + nodeLambdaQueryWrapper.in(ModelNode::getNodeId,fixedNodeIds); + + List<ModelNode> nodeList=modelNodeMapper.selectList(nodeLambdaQueryWrapper); + + if (nodeList.isEmpty()){ + throw new RuntimeException("鏈煡璇㈠埌6涓巶鍖轰俊鎭紒"); + } + + Map<String,ModelNode> nodeMap=nodeList.stream().collect(Collectors.toMap(ModelNode::getNodeId,x->x)); + + List<ModelNodeIndexInfor> indexList=statisticMapper.getModelNodeIndexIdByFixedNodeIds(modelCode,fixedNodeIds); + + + // 鏍规嵁鍘傚尯鍒嗙粍 + Map<String, List<ModelNodeIndexInfor>> nodeIndexMap = indexList.stream().collect( + Collectors.groupingBy(ModelNodeIndexInfor::getNodeId)); + //鏌ヨ鎵�鏈夎兘婧愮被鍨� + final List<String> eneryIdList = indexList.stream().map(ModelNodeIndexInfor::getEnergyId).distinct().collect(Collectors.toList()); + final LambdaQueryWrapper<SysEnergy> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(CollectionUtils.isNotEmpty(eneryIdList),SysEnergy::getEnersno,eneryIdList); + + //index鍜岃兘婧� + final Map<String, String> indexIdEnergyIdMap = new HashMap<>(); + indexList.forEach(n->{ + final String indexId = n.getIndexId(); + final String energyId = n.getEnergyId(); + if(!indexIdEnergyIdMap.containsKey(indexId)){ + indexIdEnergyIdMap.put(indexId,energyId); + } + }); + List<String> indexIds = indexList.stream().filter(l -> StringUtils.isNotEmpty(l.getIndexId())).map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); +// Date queryTime = new Date(); + Date queryTime = new Date(); + Date beginTime; + Date endTime; + String shixuTimeType; + if (TimeType.DAY.name().equals(timeType)) { + beginTime = DateUtil.beginOfDay(queryTime); + endTime = DateUtil.endOfDay(queryTime); + shixuTimeType = TimeType.HOUR.name(); + // 鏈� + } else if (TimeType.MONTH.name().equals(timeType)) { + beginTime = DateUtil.beginOfMonth(queryTime); + endTime = DateUtil.endOfMonth(queryTime); + shixuTimeType = TimeType.DAY.name(); + // 骞� + } else { + beginTime = DateUtil.beginOfYear(queryTime); + endTime = DateUtil.endOfYear(queryTime); + shixuTimeType = TimeType.MONTH.name(); + } + // 鏍规嵁indexId鏌ヨdataItem + List<DataItem> dataItemList = new ArrayList<>(); + if(CollectionUtils.isNotEmpty(indexIds)) { + dataItemList = dataItemService.getDataItemTimeRangeInforByIndexIds(beginTime, endTime, shixuTimeType, indexIds); + } + Map<String, List<DataItem>> dataItemMap = dataItemList.stream().collect(Collectors.groupingBy(DataItem::getIndexId)); + + final List<SysEnergy> sysEnergies = sysEnergyMapper.selectList(queryWrapper); + //鑳芥簮缂栧彿鍜岃兘婧愭姌鏍囩郴鏁� + final Map<String, SysEnergy> energyCoefficientMap = sysEnergies.stream().collect(Collectors.toMap(SysEnergy::getEnersno,x->x)); + + //鑾峰彇鏁版嵁:nodeMap +// nodeIndexMap.forEach((key, value) -> { + nodeMap.forEach((key,nodeItem)->{ + + if (!nodeIndexMap.containsKey(key)){ + FactoryEnergyConsumptionItemVo voData = new FactoryEnergyConsumptionItemVo(); + voData.setNodeId(key); + voData.setNodeName(nodeItem.getName()); + BigDecimal kgceCount=BigDecimal.ZERO; + BigDecimal kgceTonCount=BigDecimal.ZERO; + voData.setKgceCount(kgceCount); + voData.setKgceTonCount(kgceTonCount); + voData.setEnergyItemList(new ArrayList<>()); + energyDataList.add(voData); + return; + } + + //node鍜宨ndex鍏宠仈闆嗗悎 + List<ModelNodeIndexInfor> value=nodeIndexMap.get(key); + + List<HomeEnergyStatisticsVO> itemVo=new ArrayList<>(); + //鏍规嵁鑳芥簮绫诲瀷鍒嗙粍 + Map<String, List<ModelNodeIndexInfor>> sysEnergyIds = value.stream().collect( + Collectors.groupingBy(ModelNodeIndexInfor::getEnergyId)); + + if (!sysEnergyIds.isEmpty()) { + //閬嶅巻 + for (Map.Entry<String, List<ModelNodeIndexInfor>> entry : sysEnergyIds.entrySet()) { + String energyIndex = entry.getKey(); + List<ModelNodeIndexInfor> energyValue = entry.getValue(); + if (energyCoefficientMap.containsKey(energyIndex)) { + SysEnergy sysEnergy = energyCoefficientMap.get(energyIndex); + HomeEnergyStatisticsVO item = new HomeEnergyStatisticsVO(); + item.setEnergyNo(sysEnergy.getEnersno()); + item.setEnergyName(sysEnergy.getEnername()); + item.setEnergyUnit(sysEnergy.getMuid()); + item.setCoefficient(sysEnergy.getCoefficient().toString()); + + BigDecimal totalConsumption = BigDecimal.ZERO; + BigDecimal totalCount = BigDecimal.ZERO; + //鍚堣鍊� + for (ModelNodeIndexInfor valueItem:entry.getValue()){ + List<DataItem> dataItems = dataItemMap.get(valueItem.getIndexId()); + if (CollectionUtils.isNotEmpty(dataItems)) { + BigDecimal sum = BigDecimal.valueOf(dataItems.stream() + .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP).multiply(sysEnergy.getCoefficient()); + totalConsumption = totalConsumption.add(sum); + totalCount = totalCount.add(BigDecimal.valueOf(dataItems.stream() + .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP)); + } + ; + } + + item.setTonCount(totalConsumption.doubleValue()); + item.setCount(totalCount.doubleValue()); + itemVo.add(item); + } + } + }; + + FactoryEnergyConsumptionItemVo voData = new FactoryEnergyConsumptionItemVo(); + voData.setNodeId(key); + voData.setNodeName(nodeItem.getName()); + BigDecimal kgceCount=BigDecimal.ZERO; + BigDecimal kgceTonCount=BigDecimal.ZERO; + if (!itemVo.isEmpty()){ + kgceCount=BigDecimal.valueOf(itemVo.stream().mapToDouble(HomeEnergyStatisticsVO::getCount).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); + kgceTonCount=BigDecimal.valueOf(itemVo.stream().mapToDouble(HomeEnergyStatisticsVO::getTonCount).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); + } + voData.setKgceCount(kgceCount); + voData.setKgceTonCount(kgceTonCount); + voData.setEnergyItemList(itemVo); + energyDataList.add(voData); + }); + return energyDataList; + } + + + private List<HomeEnergyStatisticsVO> getEnergyTotalByTime(String timeType, String modelCode, Date queryTime) { + List<HomeEnergyStatisticsVO> voList = new ArrayList<>(); + + Date beginTime; + Date endTime; + String shixuTimeType; + if (TimeType.DAY.name().equals(timeType)) { + beginTime = DateUtil.beginOfDay(queryTime); + endTime = DateUtil.endOfDay(beginTime); + shixuTimeType = TimeType.HOUR.name(); + // 鏈� + } else if (TimeType.MONTH.name().equals(timeType)) { + beginTime = DateUtil.beginOfMonth(queryTime); + endTime = DateUtil.endOfMonth(beginTime); + shixuTimeType = TimeType.DAY.name(); + // 骞� + } else { + beginTime = DateUtil.beginOfYear(queryTime); + endTime = DateUtil.endOfYear(beginTime); + shixuTimeType = TimeType.MONTH.name(); + } + + // 鏌ヨ鎵�鏈夎兘婧愮被鍨� + List<SysEnergy> sysEnergies = sysEnergyMapper.selectSysEnergyList(new SysEnergy()); + voList = sysEnergies.stream().map(dict -> { + HomeEnergyStatisticsVO vo = new HomeEnergyStatisticsVO(); + vo.setEnergyName(dict.getEnername()); + vo.setEnergyNo(dict.getEnersno()); + vo.setEnergyUnit(dict.getMuid()); + vo.setCount(0D); + vo.setTonCount(0D); + vo.setCoefficient(dict.getCoefficient().toString()); + return vo; + }).sorted(Comparator.comparing(HomeEnergyStatisticsVO::getEnergyName)).collect(Collectors.toList()); + // 閫氳繃code鑾峰彇modelnode瀵瑰簲index淇℃伅 + ModelNode modelNode = modelNodeService.getModelNodeByModelCodeByIndexCode(modelCode); + if (ObjectUtils.isEmpty(modelNode)) { + return voList; + } + List<ModelNodeIndexInfor> inforList = modelNodeService.getModelNodeIndexIdRelationInforByNodeId(modelNode.getNodeId()); + List<String> indexIds = inforList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); + // 閫氳繃indexIds鎵綿ata_Item鏁版嵁 + List<DataItem> itemList = dataItemService.getDataItemTimeRangeInforByIndexIds(beginTime, endTime, shixuTimeType, indexIds); + // 鏌ヨ鐐逛綅璇︾粏淇℃伅 + List<EnergyIndex> energyIndexInforList = energyIndexService.getEnergyIndexByIds(indexIds); + // 鑾峰彇鐐逛綅鑳芥簮绫诲瀷 + Map<String, List<String>> energyTypeMap = energyIndexInforList.stream() + .filter(l -> StringUtils.isNotEmpty(l.getEnergyId())).collect(Collectors.groupingBy( + EnergyIndex::getEnergyId, Collectors.mapping(EnergyIndex::getIndexId, Collectors.toList()) + )); + + for (HomeEnergyStatisticsVO ratioVO : voList) { + List<String> indexs = energyTypeMap.get(ratioVO.getEnergyNo()); + if (CollectionUtils.isEmpty(indexs)) { + ratioVO.setCount(0D); + }else { + // 鎵惧埌鍚堣鍊� + double doubleCount = itemList.stream().filter(li -> indexs.contains(li.getIndexId())).mapToDouble(DataItem::getValue).sum(); + ratioVO.setCount(format2Double(doubleCount)); + } + } + return voList; + } + + private double format2Double(double averageEnergy) { + // 鍒涘缓DecimalFormat瀵硅薄锛岃缃繚鐣欎袱浣嶅皬鏁� + DecimalFormat df = new DecimalFormat("#.00"); + + // 鏍煎紡鍖栫粨鏋� + String formattedResult = df.format(averageEnergy); + return Double.valueOf(formattedResult); + } + +} diff --git a/zhitan-system/src/main/java/com/zhitan/energydata/vo/EnergyChainYoyVO.java b/zhitan-system/src/main/java/com/zhitan/energydata/vo/EnergyChainYoyVO.java new file mode 100644 index 0000000..589c3ef --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/energydata/vo/EnergyChainYoyVO.java @@ -0,0 +1,53 @@ +package com.zhitan.energydata.vo; + +import lombok.Getter; +import lombok.Setter; + +import java.math.BigDecimal; + +@Getter +@Setter +public class EnergyChainYoyVO { + + /** + * 鑳芥簮绫诲瀷缂栧彿 + */ + private String energyNo; + /** + * 鑳芥簮绫诲瀷鍚嶇О + */ + private String energyName; + + /** + * 鑳芥簮鍗曚綅 + */ + private String energyUnit; + + /** + * 鍚堣鍊� + */ + private BigDecimal samePeriodCount; + /** + * 鍚堣鍊� + */ + private BigDecimal count; + + /** + * 鍚屾瘮 + */ + private BigDecimal tongbi; + + /** + * 鐜瘮 + */ + private BigDecimal huanbi; + + /** 绛変环鎶樻爣绯绘暟 */ + private String coefficient; + + /** + * 杞崲涓哄惃鏍囩叅 + */ + private BigDecimal tonCount; +} + diff --git a/zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionItemVo.java b/zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionItemVo.java new file mode 100644 index 0000000..d9dedbc --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionItemVo.java @@ -0,0 +1,29 @@ +package com.zhitan.energydata.vo; + +import com.zhitan.home.domain.vo.HomeEnergyStatisticsVO; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class FactoryEnergyConsumptionItemVo { + + /** + * 鍘傚尯涓婚敭 + */ + private String nodeId; + /** + * 鍘傚尯鍚嶇О + */ + private String nodeName; + + private BigDecimal kgceCount; + + private BigDecimal kgceTonCount; + + List<HomeEnergyStatisticsVO> energyItemList; + + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionVo.java b/zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionVo.java new file mode 100644 index 0000000..ad8ca74 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/energydata/vo/FactoryEnergyConsumptionVo.java @@ -0,0 +1,37 @@ +package com.zhitan.energydata.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class FactoryEnergyConsumptionVo { + /** + * 鏈湀缁煎悎鑳借�� + */ + private BigDecimal monthConsumption; + /** + * 鑳借�楄垂鐢� + */ + private BigDecimal monthEnergyAmount; + + /** + * 纰虫帓鏀� + */ + private BigDecimal cEmission; + + /** + * 鐢ㄨ兘瀹屾垚鎸囨爣 + */ + private BigDecimal useEnergyIndex; + + /** + * 鍚勫巶鍖烘暟鎹� + * + */ + private List<FactoryEnergyConsumptionItemVo> itemVoList; + + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/energydata/vo/PurchaseConsumptionVo.java b/zhitan-system/src/main/java/com/zhitan/energydata/vo/PurchaseConsumptionVo.java new file mode 100644 index 0000000..5d27b24 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/energydata/vo/PurchaseConsumptionVo.java @@ -0,0 +1,33 @@ +package com.zhitan.energydata.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class PurchaseConsumptionVo { + + /** + * 鑳芥簮绫诲瀷缂栧彿 + */ + private String energyNo; + /** + * 鑳芥簮绫诲瀷鍚嶇О + */ + private String energyName; + + /** + * 鑳芥簮鍗曚綅 + */ + private String energyUnit; + + /** + * 璐叆鎴愭湰 + */ + private BigDecimal purchaseSum; + + /** + * 娑堣�楁垚鏈� + */ + private BigDecimal consumptionSum; +} diff --git a/zhitan-system/src/main/java/com/zhitan/gatewaysetting/domain/GatewaySetting.java b/zhitan-system/src/main/java/com/zhitan/gatewaysetting/domain/GatewaySetting.java index a09a6f8..ec9787f 100644 --- a/zhitan-system/src/main/java/com/zhitan/gatewaysetting/domain/GatewaySetting.java +++ b/zhitan-system/src/main/java/com/zhitan/gatewaysetting/domain/GatewaySetting.java @@ -39,7 +39,7 @@ private String installLocation; /** ip鍦板潃 */ - @Excel(name = "ip鍦板潃") + @Excel(name = "IP鍦板潃") private String ipAdd; /** 杩愯鐘舵�侊細鏈煡銆佺绾裤�佸湪绾� */ @@ -48,7 +48,7 @@ /** 蹇冭烦鏃堕棿 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "蹇冭烦鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd") +// @Excel(name = "蹇冭烦鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd") private Date hbtTime; /** 璁¢噺鍣ㄥ叿鏁伴噺 */ diff --git a/zhitan-system/src/main/java/com/zhitan/home/service/HomePageServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/home/service/HomePageServiceImpl.java index 00d47cb..201c59f 100644 --- a/zhitan-system/src/main/java/com/zhitan/home/service/HomePageServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/home/service/HomePageServiceImpl.java @@ -237,7 +237,7 @@ final List<ElectricityDataItem> electricityDataItems = electricityDataMap.get(vo.getTimeType()); if(null != electricityDataItems) { final double sum = electricityDataItems.stream().map(ElectricityDataItem::getElectricity).mapToDouble(BigDecimal::doubleValue).sum(); - vo.setCount(sum); + vo.setCount(format2Double(sum)); if(totalElectric != 0) { vo.setPercentage(format2Double(sum / totalElectric * 100)); } @@ -390,8 +390,8 @@ } }); List<String> indexIds = nodeIndexInforList.stream().filter(l -> StringUtils.isNotEmpty(l.getIndexId())).map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); -// Date queryTime = new Date(); - Date queryTime = DateUtil.parseDateTime("2023-03-28 00:00:00"); + Date queryTime = new Date(); +// Date queryTime = DateUtil.parseDateTime("2023-03-28 00:00:00"); Date beginTime; Date endTime; String shixuTimeType; diff --git a/zhitan-system/src/main/java/com/zhitan/model/mapper/EnergyIndexMapper.java b/zhitan-system/src/main/java/com/zhitan/model/mapper/EnergyIndexMapper.java index e1e08e8..3c4928a 100644 --- a/zhitan-system/src/main/java/com/zhitan/model/mapper/EnergyIndexMapper.java +++ b/zhitan-system/src/main/java/com/zhitan/model/mapper/EnergyIndexMapper.java @@ -98,4 +98,6 @@ int insertNodeIndex(@Param("nodeId")String nodeId, @Param("indexId")String indexId); Page<EnergyIndex> selectEnergyIndexPage(@Param("page")Page<?> page, @Param("query") EnergyIndexQuery energyIndexQuery); + + List<EnergyIndex> getIndexByCode(@Param("code")String code, @Param("nodeId")String nodeId); } diff --git a/zhitan-system/src/main/java/com/zhitan/model/service/impl/EnergyIndexServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/model/service/impl/EnergyIndexServiceImpl.java index de563bb..2bb7ff0 100644 --- a/zhitan-system/src/main/java/com/zhitan/model/service/impl/EnergyIndexServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/model/service/impl/EnergyIndexServiceImpl.java @@ -311,17 +311,8 @@ @Override public List<EnergyIndex> getIndexByCode(String code, String nodeId) { - final List<MeterImplement> settingDevice = modelNodeMapper.getSettingDevice(nodeId); - if(CollectionUtils.isEmpty(settingDevice)){ - return new ArrayList<>(); - } - final List<String> deviceIds = settingDevice.stream().map(MeterImplement::getId).collect(Collectors.toList()); + List<EnergyIndex> energyIndexList = energyIndexMapper.getIndexByCode(code,nodeId); - LambdaQueryWrapper<EnergyIndex> queryWrapper = new LambdaQueryWrapper<>(); - if(StringUtils.isNotEmpty(code)) { - queryWrapper.like(EnergyIndex::getCode, code).or().like(EnergyIndex::getName, code); - } - queryWrapper.in(EnergyIndex::getMeterId,deviceIds); - return energyIndexMapper.selectList(queryWrapper); + return energyIndexList; } } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPrice.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPrice.java index 58ac0cb..1bf0ecd 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPrice.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPrice.java @@ -46,12 +46,22 @@ @Excel(name = "鏃舵缁撴潫鏃堕棿", width = 30, dateFormat = "HH:mm:ss") @NotNull(message = "鏃舵缁撴潫鏃堕棿涓嶈兘涓虹┖") private Date stopTime; +// @Excel(name = "鑼冨洿绫诲瀷瀛楀吀鍊糲ost_range_type") +// private String rangeType; /** 鐢典环 */ @Excel(name = "鐢典环") @NotEmpty(message = "鐢典环涓嶈兘涓虹┖") private BigDecimal effecticityPrice; - + +// public String getRangeType() { +// return rangeType; +// } +// +// public void setRangeType(String rangeType) { +// this.rangeType = rangeType; +// } + public void setId(String id) { this.id = id; diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPriceDate.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPriceDate.java index 05262a3..3cd8115 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPriceDate.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/ElectricityPriceDate.java @@ -32,6 +32,54 @@ @Excel(name = "缁撴潫鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd") private Date endDate; +// /** 鏄惁闃舵浠锋牸0鍚�1鏄� */ +// @Excel(name = "鏄惁闃舵浠锋牸0鍚�1鏄�") +// private String type; +// +// /** 绛栫暐缂栫爜 */ +// @Excel(name = "绛栫暐缂栫爜") +// private String tacticsNumber; +// +// /** 绛栫暐鍚嶇О */ +// @Excel(name = "绛栫暐鍚嶇О") +// private String tacticsName; +// +// /** 鑳芥簮鍝佺 */ +// @Excel(name = "鑳芥簮鍝佺") +// private Integer energyType; + +// public void setType(String type) { +// this.type = type; +// } +// +// public void setTacticsNumber(String tacticsNumber) { +// this.tacticsNumber = tacticsNumber; +// } +// +// public void setTacticsName(String tacticsName) { +// this.tacticsName = tacticsName; +// } +// +// public void setEnergyType(Integer energyType) { +// this.energyType = energyType; +// } +// +// public String getType() { +// return type; +// } +// +// public String getTacticsNumber() { +// return tacticsNumber; +// } +// +// public String getTacticsName() { +// return tacticsName; +// } +// +// public Integer getEnergyType() { +// return energyType; +// } + public void setId(String id) { this.id = id; diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/vo/peakvalley/PeakValleyDayVO.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/vo/peakvalley/PeakValleyDayVO.java index ef807cf..8930f1a 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/vo/peakvalley/PeakValleyDayVO.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/domain/vo/peakvalley/PeakValleyDayVO.java @@ -1,5 +1,6 @@ package com.zhitan.peakvalley.domain.vo.peakvalley; +import com.zhitan.home.domain.vo.HomeEnergyConsumptionTrendVO; import lombok.Getter; import lombok.Setter; @@ -15,4 +16,8 @@ List<PeakValleyLineChatVO> costList; List<PeakValleyLineChatVO> powerConsumptionList; PeakValleyDayTotalVO totalVO; + + HomeEnergyConsumptionTrendVO costNewList; + + HomeEnergyConsumptionTrendVO powerNewList; } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceDateMapper.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceDateMapper.java index 1f5343e..37bdcc6 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceDateMapper.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceDateMapper.java @@ -1,6 +1,7 @@ package com.zhitan.peakvalley.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.costmanagement.domain.vo.ElectricityPriceDateVo; import com.zhitan.peakvalley.domain.ElectricityPriceDate; import java.util.List; @@ -59,4 +60,11 @@ * @return 缁撴灉 */ public int deleteElectricityPriceDateByIds(String[] ids); + + + /** + * 鍗曚环绛栫暐鍒楄〃鏌ヨ锛堜笉鍒嗛〉锛� + * + */ + List<ElectricityPriceDate> selectElectricityPriceDatePageTacticsAll(); } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceMapper.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceMapper.java index 36d79f9..aea44a3 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceMapper.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/ElectricityPriceMapper.java @@ -59,4 +59,9 @@ * @return 缁撴灉 */ public int deleteElectricityPriceByIds(String[] ids); + + + + + } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/PeakValleyMapper.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/PeakValleyMapper.java index 22b3312..b11d097 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/PeakValleyMapper.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/mapper/PeakValleyMapper.java @@ -27,4 +27,15 @@ */ List<ElectricityDataItem> getDataStatistics(@Param("indexIdSet") Set<String> indexIdSet, @Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("timeType") String timeType); + + /** + * 鏌ヨ灏栧嘲骞宠胺缁熻鏁版嵁(鍋忓樊鍒嗘瀽) + * + * @param indexIdSet 鐐逛綅id闆嗗悎 + * @param timeType 鏃堕棿绫诲瀷 + * @return 缁撴灉 + */ + List<ElectricityDataItem> getDataStatisticsDeviationAnalysis(@Param("indexIdSet") Set<String> indexIdSet, + @Param("timeType") String timeType); + } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IElectricityPriceDateService.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IElectricityPriceDateService.java index 0d4d337..fcd57e6 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IElectricityPriceDateService.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IElectricityPriceDateService.java @@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.zhitan.costmanagement.domain.vo.CostPriceTacticsVo; +import com.zhitan.costmanagement.domain.vo.ElectricityPriceDateVo; import com.zhitan.peakvalley.domain.ElectricityPriceDate; import java.util.List; @@ -62,4 +65,58 @@ public int deleteElectricityPriceDateById(String id); Page<ElectricityPriceDate> selectElectricityPriceDatePage(ElectricityPriceDate electricityPriceDate, Long pageNum, Long pageSize); + + + +// /** +// * 鍗曚环绛栫暐鍒楄〃鏌ヨ +// * +// */ +// Page<ElectricityPriceDateVo> selectElectricityPriceDatePageTactics(ElectricityPriceDate electricityPriceDate, Long pageNum, Long pageSize); + +// /** +// * 鍗曚环绛栫暐鍒楄〃鏌ヨ锛堜笉鍒嗛〉锛� +// * +// */ +// List<ElectricityPriceDate> selectElectricityPriceDatePageTacticsAll(); +// +// /** +// * 鏌ヨ鎴愭湰绛栫暐 +// * +// * @param id 鎴愭湰绛栫暐涓婚敭 +// * @return 鎴愭湰绛栫暐 +// */ +// public ElectricityPriceDateVo selectCostPriceTacticsById(String id); +// /** +// * 鏂板鎴愭湰绛栫暐 +// * +// * @param electricityPriceDateVo 鎴愭湰绛栫暐 +// * @return 缁撴灉 +// */ +// public int insertCostPriceTactics(ElectricityPriceDateVo electricityPriceDateVo) throws Exception; +// +// /** +// * 淇敼鎴愭湰绛栫暐 +// * +// * @param electricityPriceDateVo 鎴愭湰绛栫暐 +// * @return 缁撴灉 +// */ +// public int updateCostPriceTactics(ElectricityPriceDateVo electricityPriceDateVo); +// +// /** +// * 鎵归噺鍒犻櫎鎴愭湰绛栫暐 +// * +// * @param ids 闇�瑕佸垹闄ょ殑鎴愭湰绛栫暐涓婚敭闆嗗悎 +// * @return 缁撴灉 +// */ +// public int deleteCostPriceTacticsByIds(String[] ids); +// +// /** +// * 鍒犻櫎鎴愭湰绛栫暐淇℃伅 +// * +// * @param id 鎴愭湰绛栫暐涓婚敭 +// * @return 缁撴灉 +// */ +// public int deleteCostPriceTacticsById(String id); + } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IPeakValleyService.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IPeakValleyService.java index f62ac2d..7dca861 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IPeakValleyService.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/IPeakValleyService.java @@ -42,4 +42,6 @@ PeakValleyHourVO segmentAnalysisHour(PeakValleyDTO dto); List<PeakValleyHourDataVO> segmentAnalysisHourExport(PeakValleyDTO dto); + + PeakValleyDayVO segmentAnalysisDayCustomize(PeakValleyDTO dto); } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/ElectricityPriceDateServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/ElectricityPriceDateServiceImpl.java index 00fa4b2..3a873ce 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/ElectricityPriceDateServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/ElectricityPriceDateServiceImpl.java @@ -1,18 +1,29 @@ package com.zhitan.peakvalley.service.impl; +import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zhitan.common.utils.DateUtils; import com.zhitan.common.utils.StringUtils; import com.zhitan.common.utils.uuid.UUID; +import com.zhitan.costmanagement.domain.CostPriceTactics; +import com.zhitan.costmanagement.domain.CostPriceTacticsItem; +import com.zhitan.costmanagement.domain.vo.CostPriceTacticsVo; +import com.zhitan.costmanagement.domain.vo.ElectricityPriceDateVo; +import com.zhitan.peakvalley.domain.ElectricityPrice; import com.zhitan.peakvalley.domain.ElectricityPriceDate; import com.zhitan.peakvalley.mapper.ElectricityPriceDateMapper; +import com.zhitan.peakvalley.mapper.ElectricityPriceMapper; import com.zhitan.peakvalley.service.IElectricityPriceDateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; /** * 灏栧嘲骞宠胺鐢典环鏃堕棿娈礢ervice涓氬姟灞傚鐞� @@ -24,6 +35,10 @@ public class ElectricityPriceDateServiceImpl extends ServiceImpl<ElectricityPriceDateMapper, ElectricityPriceDate> implements IElectricityPriceDateService { @Autowired private ElectricityPriceDateMapper electricityPriceDateMapper; + @Autowired + private ElectricityPriceMapper electricityPriceMapper; + + /** * 鏌ヨ灏栧嘲骞宠胺鐢典环鏃堕棿娈� @@ -103,4 +118,119 @@ Page<ElectricityPriceDate> page = electricityPriceDateMapper.selectPage(new Page<ElectricityPriceDate>(pageNum, pageSize), wrapper); return page; } + +// @Override +// public Page<ElectricityPriceDateVo> selectElectricityPriceDatePageTactics(ElectricityPriceDate electricityPriceDate, Long pageNum, Long pageSize) { +// LambdaQueryWrapper<ElectricityPriceDate> queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.like(StringUtils.isNotEmpty(electricityPriceDate.getTacticsName()),ElectricityPriceDate::getTacticsName,electricityPriceDate.getTacticsName()); +// queryWrapper.like(StringUtils.isNotEmpty(electricityPriceDate.getTacticsNumber()),ElectricityPriceDate::getTacticsNumber,electricityPriceDate.getTacticsNumber()); +// +// queryWrapper.eq(StringUtils.isNotEmpty(electricityPriceDate.getType()),ElectricityPriceDate::getType,electricityPriceDate.getType()); +// queryWrapper.orderByDesc(ElectricityPriceDate::getCreateTime); +// Page<ElectricityPriceDate> page = electricityPriceDateMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); +// IPage aa = page.convert(s->{ +// ElectricityPriceDateVo v = new ElectricityPriceDateVo(); +// BeanUtil.copyProperties(s, v); +// LambdaQueryWrapper<ElectricityPrice> queryWrapperItem = new LambdaQueryWrapper<>(); +// queryWrapperItem.eq(ElectricityPrice::getParentId,s.getId()); +// List<ElectricityPrice> itemListOld = electricityPriceMapper.selectList(queryWrapperItem); +// v.setItemList(itemListOld); +// return v; +// }); +// +// return (Page<ElectricityPriceDateVo>) aa; +// } +// +// @Override +// public List<ElectricityPriceDate> selectElectricityPriceDatePageTacticsAll() { +// return electricityPriceDateMapper.selectElectricityPriceDatePageTacticsAll(); +// } +// +// @Override +// public ElectricityPriceDateVo selectCostPriceTacticsById(String id) { +// ElectricityPriceDateVo result = new ElectricityPriceDateVo(); +// ElectricityPriceDate info = electricityPriceDateMapper.selectElectricityPriceDateById(id); +// BeanUtil.copyProperties(info,result); +// LambdaQueryWrapper<ElectricityPrice> queryWrapperItem = new LambdaQueryWrapper<>(); +// queryWrapperItem.eq(ElectricityPrice::getParentId,id); +// List<ElectricityPrice> itemListOld = electricityPriceMapper.selectList(queryWrapperItem); +// result.setItemList(itemListOld); +// return result ; +// } +// +// @Override +// public int insertCostPriceTactics(ElectricityPriceDateVo electricityPriceDateVo) throws Exception { +// ElectricityPriceDate search = electricityPriceDateMapper.selectOne(new QueryWrapper<ElectricityPriceDate>().eq("tactics_number",electricityPriceDateVo.getTacticsNumber())); +// if (search!=null){ +// throw new Exception("璇ョ瓥鐣ョ紪鐮佸凡瀛樺湪锛�"); +// } +// electricityPriceDateVo.setCreateTime(DateUtils.getNowDate()); +// electricityPriceDateVo.setId(java.util.UUID.randomUUID().toString()); +// ElectricityPriceDate electricityPriceDate = new ElectricityPriceDate(); +// BeanUtil.copyProperties(electricityPriceDateVo,electricityPriceDate); +// int result = electricityPriceDateMapper.insert(electricityPriceDate); +// //鎻掑叆瀛愯〃 +// List<ElectricityPrice> itemList = electricityPriceDateVo.getItemList(); +// itemList.stream().forEach(s->{ +// s.setId(java.util.UUID.randomUUID().toString()); +// s.setCreateTime(DateUtils.getNowDate()); +// s.setCreateBy(electricityPriceDateVo.getCreateBy()); +// s.setParentId(electricityPriceDateVo.getId()); +// electricityPriceMapper.insert(s); +// }); +// +// return result; +// } +// +// @Override +// public int updateCostPriceTactics(ElectricityPriceDateVo electricityPriceDateVo) { +// electricityPriceDateVo.setUpdateTime(DateUtils.getNowDate()); +// ElectricityPriceDate electricityPriceDate = new ElectricityPriceDate(); +// BeanUtil.copyProperties(electricityPriceDateVo,electricityPriceDate); +// int result = electricityPriceDateMapper.updateElectricityPriceDate(electricityPriceDate); +// //鍒犻櫎瀛愯〃 +// LambdaQueryWrapper<ElectricityPrice> queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(ElectricityPrice::getParentId,electricityPriceDate.getId()); +// List<ElectricityPrice> itemListOld = electricityPriceMapper.selectList(queryWrapper); +// List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); +// String[] ids = idList.toArray(new String[idList.size()]); +// electricityPriceMapper.deleteElectricityPriceByIds(ids); +// //鎻掑叆瀛愯〃 +// List<ElectricityPrice> itemList = electricityPriceDateVo.getItemList(); +// itemList.stream().forEach(s->{ +// s.setId(java.util.UUID.randomUUID().toString()); +// s.setCreateTime(DateUtils.getNowDate()); +// s.setCreateBy(electricityPriceDateVo.getCreateBy()); +// s.setParentId(electricityPriceDateVo.getId()); +// electricityPriceMapper.insert(s); +// }); +// return result; +// } +// +// @Override +// public int deleteCostPriceTacticsByIds(String[] ids) { +// //鍒犻櫎瀛愯〃 +// List<String> list = Arrays.asList(ids); +// list.stream().forEach(item->{ +// LambdaQueryWrapper<ElectricityPrice> queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(ElectricityPrice::getParentId,item); +// List<ElectricityPrice> itemListOld = electricityPriceMapper.selectList(queryWrapper); +// List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); +// String[] itemIds = idList.toArray(new String[idList.size()]); +// electricityPriceMapper.deleteElectricityPriceByIds(itemIds); +// }); +// +// return electricityPriceDateMapper.deleteElectricityPriceDateByIds(ids); +// } +// +// @Override +// public int deleteCostPriceTacticsById(String id) { +// LambdaQueryWrapper<ElectricityPrice> queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(ElectricityPrice::getParentId,id); +// List<ElectricityPrice> itemListOld = electricityPriceMapper.selectList(queryWrapper); +// List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); +// String[] itemIds = idList.toArray(new String[idList.size()]); +// electricityPriceMapper.deleteElectricityPriceByIds(itemIds); +// return electricityPriceDateMapper.deleteElectricityPriceDateById(id); +// } } diff --git a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/PeakValleyServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/PeakValleyServiceImpl.java index e607910..051b89b 100644 --- a/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/PeakValleyServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/PeakValleyServiceImpl.java @@ -5,6 +5,8 @@ import com.zhitan.common.enums.ElectricityTypeEnum; import com.zhitan.common.enums.TimeType; import com.zhitan.common.utils.DateUtils; +import com.zhitan.costmanagement.domain.vo.CostPriceRelevancyVo; +import com.zhitan.costmanagement.mapper.CostPriceRelevancyMapper; import com.zhitan.model.domain.vo.ModelNodeIndexInfor; import com.zhitan.model.mapper.ModelNodeMapper; import com.zhitan.peakvalley.domain.ElectricityDataItem; @@ -35,7 +37,8 @@ private ModelNodeMapper modelNodeMapper; @Resource private PeakValleyMapper electricityDataItemMapper; - + @Resource + CostPriceRelevancyMapper costPriceRelevancyMapper; /** * 鏌ヨ缁熻鏁版嵁 @@ -154,19 +157,45 @@ String electricityType = electricityDataItem.getElectricityType(); if (ElectricityTypeEnum.SHARP.name().equals(electricityType)) { - sharpFee = sharpFee.add(electricityDataItem.getCost()); +// sharpFee = sharpFee.add(electricityDataItem.getCost()); + sharpPower = sharpPower.add(electricityDataItem.getElectricity()); } else if (ElectricityTypeEnum.PEAK.name().equals(electricityType)) { - peakFee = peakFee.add(electricityDataItem.getCost()); +// peakFee = peakFee.add(electricityDataItem.getCost()); peakPower = peakPower.add(electricityDataItem.getElectricity()); } else if (ElectricityTypeEnum.FLAT.name().equals(electricityType)) { - flatFee = flatFee.add(electricityDataItem.getCost()); +// flatFee = flatFee.add(electricityDataItem.getCost()); flatPower = flatPower.add(electricityDataItem.getElectricity()); } else { - valleyFee = valleyFee.add(electricityDataItem.getCost()); +// valleyFee = valleyFee.add(electricityDataItem.getCost()); valleyPower = valleyPower.add(electricityDataItem.getElectricity()); } } + //2024-11-12鏂板 + CostPriceRelevancyVo voS = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.SHARP.name()); + if(voS!=null){ + sharpFee = voS.getPrice().multiply(sharpPower); + } + CostPriceRelevancyVo voP = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.PEAK.name()); + if(voP!=null){ + peakFee = voP.getPrice().multiply(peakPower); + } + CostPriceRelevancyVo voF = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.FLAT.name()); + if(voF!=null){ + flatFee = voF.getPrice().multiply(flatPower); + } + CostPriceRelevancyVo voV = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(), ElectricityTypeEnum.VALLEY.name()); + if(voV!=null){ + valleyFee = voV.getPrice().multiply(valleyPower); + } +// CostPriceRelevancyVo voD = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(), ElectricityTypeEnum.DEEP.name()); +// if(voV!=null){ +// DeepFee = voV.getPrice().multiply(valleyPower); +// } + + + + } PeakValleyDayDataVO peakAndValleyReportVO = new PeakValleyDayDataVO(startTime, sharpFee, sharpPower, peakFee, peakPower, flatFee, flatPower, valleyFee, valleyPower); @@ -199,11 +228,11 @@ AtomicReference<BigDecimal> tipCount = new AtomicReference<>(BigDecimal.ZERO); AtomicReference<BigDecimal> troughCount = new AtomicReference<>(BigDecimal.ZERO); AtomicReference<BigDecimal> peakCount = new AtomicReference<>(BigDecimal.ZERO); - + reportVOList.stream().forEach(r->{ PeakValleyLineChatVO costVO = new PeakValleyLineChatVO(); PeakValleyLineChatVO powerConsumptionVO = new PeakValleyLineChatVO(); - + /** * 鐢ㄧ數閲� */ @@ -243,7 +272,7 @@ peakFreeCount.set(peakFreeCount.get().add(r.getPeakFee())); }); - peakValleyDayTotalVO.setPeakPowerCost(peakFreeCount.get().doubleValue()); + peakValleyDayTotalVO.setPeakPowerCost(peakFreeCount.get().doubleValue()); peakValleyDayTotalVO.setPeakPowerConsumption(peakCount.get().doubleValue()); peakValleyDayTotalVO.setFlatPowerCost(flatFreeCount.get().doubleValue()); peakValleyDayTotalVO.setFlatPowerConsumption(flatCount.get().doubleValue()); @@ -277,13 +306,15 @@ peakValleyDayTotalVO.setTipPowerCostProportion(0); peakValleyDayTotalVO.setTroughPowerCostProportion(0); } - - peakValleyDayTotalVO.setTotalCost(powerTotal.doubleValue()); - peakValleyDayTotalVO.setTotalPowerConsumption(freeTotal.doubleValue()); + +// peakValleyDayTotalVO.setTotalCost(powerTotal.doubleValue()); +// peakValleyDayTotalVO.setTotalPowerConsumption(freeTotal.doubleValue()); + peakValleyDayTotalVO.setTotalCost(freeTotal.doubleValue()); + peakValleyDayTotalVO.setTotalPowerConsumption(powerTotal.doubleValue()); peakValleyVO.setTotalVO(peakValleyDayTotalVO); peakValleyVO.setCostList(costList); peakValleyVO.setPowerConsumptionList(powerConsumptionList); - + return peakValleyVO; } @@ -324,19 +355,39 @@ String electricityType = electricityDataItem.getElectricityType(); if (ElectricityTypeEnum.SHARP.name().equals(electricityType)) { - sharpFee = sharpFee.add(electricityDataItem.getCost()); +// sharpFee = sharpFee.add(electricityDataItem.getCost()); sharpPower = sharpPower.add(electricityDataItem.getElectricity()); } else if (ElectricityTypeEnum.PEAK.name().equals(electricityType)) { - peakFee = peakFee.add(electricityDataItem.getCost()); +// peakFee = peakFee.add(electricityDataItem.getCost()); peakPower = peakPower.add(electricityDataItem.getElectricity()); } else if (ElectricityTypeEnum.FLAT.name().equals(electricityType)) { - flatFee = flatFee.add(electricityDataItem.getCost()); +// flatFee = flatFee.add(electricityDataItem.getCost()); flatPower = flatPower.add(electricityDataItem.getElectricity()); } else { - valleyFee = valleyFee.add(electricityDataItem.getCost()); +// valleyFee = valleyFee.add(electricityDataItem.getCost()); valleyPower = valleyPower.add(electricityDataItem.getElectricity()); } } + //2024-11-12鏂板 + CostPriceRelevancyVo voS = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.SHARP.name()); + if(voS!=null){ + sharpFee = voS.getPrice().multiply(sharpPower); + } + CostPriceRelevancyVo voP = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.PEAK.name()); + if(voP!=null){ + peakFee = voP.getPrice().multiply(peakPower); + } + CostPriceRelevancyVo voF = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(),ElectricityTypeEnum.FLAT.name()); + if(voF!=null){ + flatFee = voF.getPrice().multiply(flatPower); + } + CostPriceRelevancyVo voV = costPriceRelevancyMapper.selectCostPriceRelevancyByNodeId(dto.getNodeId(), ElectricityTypeEnum.VALLEY.name()); + if(voV!=null){ + valleyFee = voV.getPrice().multiply(valleyPower); + } + + + } PeakValleyHourDataVO peakAndValleyReportVO = new PeakValleyHourDataVO(startTime, sharpFee, sharpPower, peakFee, peakPower, flatFee, flatPower, valleyFee, valleyPower); @@ -472,4 +523,9 @@ return reportVOList; } + + @Override + public PeakValleyDayVO segmentAnalysisDayCustomize(PeakValleyDTO dto) { + return null; + } } diff --git a/zhitan-system/src/main/java/com/zhitan/powerDistribution/domain/PowerDistribution.java b/zhitan-system/src/main/java/com/zhitan/powerDistribution/domain/PowerDistribution.java new file mode 100644 index 0000000..e74f2c3 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/powerDistribution/domain/PowerDistribution.java @@ -0,0 +1,37 @@ +package com.zhitan.powerDistribution.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * 閰嶇數瀹ゅ疄浣撶被 + */ +@Data +@TableName("power_distribution") +public class PowerDistribution extends BaseEntity { + + @TableId + private String id; + + /** + * 鍚嶇О + */ + private String name; + + /** + * 缂栫爜 + */ + private String code; + + /** + * 璐熻矗浜� + */ + private String principals; + + /** + * 璐熻矗浜虹數璇� + */ + private String principalsTel; +} diff --git a/zhitan-system/src/main/java/com/zhitan/powerDistribution/mapper/PowerDistributionMapper.java b/zhitan-system/src/main/java/com/zhitan/powerDistribution/mapper/PowerDistributionMapper.java new file mode 100644 index 0000000..34b1f0b --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/powerDistribution/mapper/PowerDistributionMapper.java @@ -0,0 +1,12 @@ +package com.zhitan.powerDistribution.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.powerDistribution.domain.PowerDistribution; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface PowerDistributionMapper extends BaseMapper<PowerDistribution> { + + int deletePowerDistributionByIds(@Param("ids") List<String> ids); +} diff --git a/zhitan-system/src/main/java/com/zhitan/powerDistribution/services/IPowerDistributionService.java b/zhitan-system/src/main/java/com/zhitan/powerDistribution/services/IPowerDistributionService.java new file mode 100644 index 0000000..6da1076 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/powerDistribution/services/IPowerDistributionService.java @@ -0,0 +1,16 @@ +package com.zhitan.powerDistribution.services; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.zhitan.powerDistribution.domain.PowerDistribution; + +import java.util.List; + +public interface IPowerDistributionService extends IService<PowerDistribution> { + List<PowerDistribution> selectPowerDistributionList(PowerDistribution powerDistribution); + + IPage<PowerDistribution> pageList(PowerDistribution powerDistribution, Page<PowerDistribution> page); + + int deleteByIds(List<String> ids); +} diff --git a/zhitan-system/src/main/java/com/zhitan/powerDistribution/services/impl/PowerDistributionServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/powerDistribution/services/impl/PowerDistributionServiceImpl.java new file mode 100644 index 0000000..f2b4957 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/powerDistribution/services/impl/PowerDistributionServiceImpl.java @@ -0,0 +1,66 @@ +package com.zhitan.powerDistribution.services.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhitan.basicdata.domain.MeterImplement; +import com.zhitan.basicdata.mapper.MeterImplementMapper; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.powerDistribution.domain.PowerDistribution; +import com.zhitan.powerDistribution.mapper.PowerDistributionMapper; +import com.zhitan.powerDistribution.services.IPowerDistributionService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Service +public class PowerDistributionServiceImpl extends ServiceImpl<PowerDistributionMapper, PowerDistribution> implements IPowerDistributionService { + + @Resource + private MeterImplementMapper meterImplementMapper; + + @Override + public List<PowerDistribution> selectPowerDistributionList(PowerDistribution powerDistribution) { + LambdaQueryWrapper<PowerDistribution> queryWrapper = new LambdaQueryWrapper<>(); + if(StringUtils.isNotEmpty(powerDistribution.getCode())){ + queryWrapper.like(PowerDistribution::getCode, powerDistribution.getCode()); + } + if (StringUtils.isNotEmpty(powerDistribution.getName())){ + queryWrapper.like(PowerDistribution::getName, powerDistribution.getName()); + } + if (StringUtils.isNotEmpty(powerDistribution.getPrincipals())){ + queryWrapper.like(PowerDistribution::getPrincipals, powerDistribution.getPrincipals()); + } + if (StringUtils.isNotEmpty(powerDistribution.getPrincipalsTel())){ + queryWrapper.like(PowerDistribution::getPrincipalsTel, powerDistribution.getPrincipalsTel()); + } + return list(queryWrapper); + } + + @Override + public Page<PowerDistribution> pageList(PowerDistribution powerDistribution, Page<PowerDistribution> page) { + LambdaQueryWrapper<PowerDistribution> queryWrapper = new LambdaQueryWrapper<>(); + if(StringUtils.isNotEmpty(powerDistribution.getCode())){ + queryWrapper.like(PowerDistribution::getCode, powerDistribution.getCode()); + } + if (StringUtils.isNotEmpty(powerDistribution.getName())){ + queryWrapper.like(PowerDistribution::getName, powerDistribution.getName()); + } + if (StringUtils.isNotEmpty(powerDistribution.getPrincipals())){ + queryWrapper.like(PowerDistribution::getPrincipals, powerDistribution.getPrincipals()); + } + if (StringUtils.isNotEmpty(powerDistribution.getPrincipalsTel())){ + queryWrapper.like(PowerDistribution::getPrincipalsTel, powerDistribution.getPrincipalsTel()); + } + return page(page, queryWrapper); + } + + @Override + public int deleteByIds(List<String> idList) { + return baseMapper.deletePowerDistributionByIds(idList); + } + +} diff --git a/zhitan-system/src/main/java/com/zhitan/singlelogin/service/ISingleLoginService.java b/zhitan-system/src/main/java/com/zhitan/singlelogin/service/ISingleLoginService.java new file mode 100644 index 0000000..ee6d691 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/singlelogin/service/ISingleLoginService.java @@ -0,0 +1,13 @@ +package com.zhitan.singlelogin.service; + +import com.zhitan.common.core.domain.entity.SysUser; + +/** + * description todu + * + * @author hmj + * @date 2024-11-15 17:08 + */ +public interface ISingleLoginService { + SysUser singleLogin(String token); +} diff --git a/zhitan-system/src/main/java/com/zhitan/singlelogin/service/impl/SingleLoginServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/singlelogin/service/impl/SingleLoginServiceImpl.java new file mode 100644 index 0000000..767ca2a --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/singlelogin/service/impl/SingleLoginServiceImpl.java @@ -0,0 +1,103 @@ +package com.zhitan.singlelogin.service.impl; + +import cn.hutool.http.HttpRequest; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.google.common.collect.Lists; +import com.zhitan.common.core.domain.entity.SysRole; +import com.zhitan.common.core.domain.entity.SysUser; +import com.zhitan.common.utils.SecurityUtils; +import com.zhitan.singlelogin.service.ISingleLoginService; +import com.zhitan.system.domain.SysUserRole; +import com.zhitan.system.mapper.SysUserRoleMapper; +import com.zhitan.system.service.ISysRoleService; +import com.zhitan.system.service.ISysUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Date; + +/** + * description todu + * + * @author hmj + * @date 2024-11-15 17:10 + */ +@Component +public class SingleLoginServiceImpl implements ISingleLoginService { + + private static final Logger log = LoggerFactory.getLogger(SingleLoginServiceImpl.class); + + @Value("${singleLoginUrl}") + private String singleLoginUrl; + + @Resource + private ISysUserService userService; + + @Resource + private ISysRoleService roleService; + + @Resource + private SysUserRoleMapper userRoleMapper; + + @Override + public SysUser singleLogin(String token) { + JSONObject jsonObject = checkToken(token); + log.info("璇锋眰缁煎悎娌荤悊" + jsonObject.toString()); + if(jsonObject.containsKey("code") && jsonObject.getInt("code") == 200) { + + final SysUser user = JSONUtil.toBean(jsonObject.getJSONObject("user"), SysUser.class); + + user.setSingleUser(String.valueOf(user.getUserId())); + user.setUserId(null); + //妫�娴嬩竴涓嬬敤鎴峰瓨鍦ㄤ笉瀛樺湪 + Long count = userService.checkThirdUserExist(user); + if (count > 0 ) { + return user; + } else { + //鐢ㄦ埛涓嶅瓨鍦ㄦ椂锛屽皢鐢ㄦ埛娣诲姞鍒版暟鎹簱涓� + //瀵嗙爜缁熶竴閮芥槸hrd123456 + user.setPassword(SecurityUtils.encryptPassword("hrd123456")); + //鍒涘缓鑰咃紝鏍囪瘑J骞冲彴杩囨潵鐨勭敤鎴� + user.setCreateBy("thirdPartGetAuth"); + //鍒涘缓鏃ユ湡 + user.setCreateTime(new Date()); + + int rows = userService.insertUser(user); + if (rows > 0) { + SysRole queryRole = new SysRole(); + queryRole.setRoleKey("zonghezhili"); + SysRole sysRoles = roleService.getRoleByKey(queryRole); + if(null != sysRoles){ + SysUserRole sysUserRole = new SysUserRole(); + sysUserRole.setUserId(user.getUserId()); + sysUserRole.setRoleId(sysRoles.getRoleId()); + userRoleMapper.batchUserRole(Lists.newArrayList(sysUserRole)); + } + } + return user; + } + }else { + return null; + } + } + + /** + * 閫氳繃绗笁鏂瑰钩鍙版帴鍙o紝閴村畾token鍚堟硶鎬э紝骞惰繑鍥瀠serName绛夌櫥褰曚俊鎭� + * 杩欎釜鏂规硶闇�瑕佹牴鎹疄闄呴渶瑕佽繘琛屼慨鏀� + * @param token + * @return + */ + public JSONObject checkToken(String token) { + + String result = HttpRequest.get(singleLoginUrl) + .header("Authorization","Bearer " + token) + .execute() + .body(); + JSONObject parseObj = JSONUtil.parseObj(result); + return parseObj; + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysItem.java b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysItem.java new file mode 100644 index 0000000..dc14118 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysItem.java @@ -0,0 +1,49 @@ +package com.zhitan.spikesandvalleys.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhitan.common.annotation.Excel; + +import java.math.BigDecimal; + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆戝璞� spikes_and_valleys_item + * + * @author ZhiTan + * @date 2024-10-29 + */ +@TableName("spikes_and_valleys_item") +@Data +public class SpikesAndValleysItem extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private String id; + + /** 鏃舵:灏栧嘲骞宠胺瀛楀吀鍊�1灏�2宄�3骞�4璋� */ + @Excel(name = "鏃舵:灏栧嘲骞宠胺瀛楀吀鍊�1灏�2宄�3骞�4璋�") + private String time; + + /** 鐢佃垂 */ + @Excel(name = "鐢佃垂") + private BigDecimal electrovalency; + + /** 寮�濮嬫椂闂� */ + @Excel(name = "寮�濮嬫椂闂�") + private String startTime; + + /** 缁撴潫鏃堕棿 */ + @Excel(name = "缁撴潫鏃堕棿") + private String endTime; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String schemeId; + + +} diff --git a/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysScheme.java b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysScheme.java new file mode 100644 index 0000000..1cf071e --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/SpikesAndValleysScheme.java @@ -0,0 +1,94 @@ +package com.zhitan.spikesandvalleys.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.zhitan.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhitan.common.annotation.Excel; + +/** + * 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗗璞� spikes_and_valleys_scheme + * + * @author ZhiTan + * @date 2024-10-29 + */ +@TableName("spikes_and_valleys_scheme") +public class SpikesAndValleysScheme extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private String id; + + /** 鏂规鍚嶇О */ + @Excel(name = "鏂规鍚嶇О") + private String schemeName; + + /** 鎵ц鏃堕棿 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "鎵ц鏃堕棿", width = 30, dateFormat = "yyyy-MM-dd") + private Date executeTime; + + /** 鏂规绫诲瀷1榛樿2鍚庡嫟3澶栭儴 */ + @Excel(name = "鏂规绫诲瀷1榛樿2鍚庡嫟3澶栭儴") + private String type; + + + public void setId(String id) + { + this.id = id; + } + + public String getId() + { + return id; + } + + public void setSchemeName(String schemeName) + { + this.schemeName = schemeName; + } + + public String getSchemeName() + { + return schemeName; + } + + public void setExecuteTime(Date executeTime) + { + this.executeTime = executeTime; + } + + public Date getExecuteTime() + { + return executeTime; + } + + public void setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) + .append("remark", getRemark()) + .append("schemeName", getSchemeName()) + .append("executeTime", getExecuteTime()) + .append("type", getType()) + .toString(); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/vo/SpikesAndValleysSchemeVo.java b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/vo/SpikesAndValleysSchemeVo.java new file mode 100644 index 0000000..52e3a57 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/domain/vo/SpikesAndValleysSchemeVo.java @@ -0,0 +1,25 @@ +package com.zhitan.spikesandvalleys.domain.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhitan.common.annotation.Excel; +import com.zhitan.common.core.domain.BaseEntity; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysItem; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysScheme; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗗璞� spikes_and_valleys_scheme + * + * @author ZhiTan + * @date 2024-10-29 + */ +@Data +public class SpikesAndValleysSchemeVo extends SpikesAndValleysScheme { + List<SpikesAndValleysItem> itemList; +} diff --git a/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysItemMapper.java b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysItemMapper.java new file mode 100644 index 0000000..15c79a3 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysItemMapper.java @@ -0,0 +1,62 @@ +package com.zhitan.spikesandvalleys.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysItem; + + +/** + * 銆愯濉啓鍔熻兘鍚嶇О銆慚apper鎺ュ彛 + * + * @author ZhiTan + * @date 2024-10-29 + */ +public interface SpikesAndValleysItemMapper extends BaseMapper<SpikesAndValleysItem> { + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆� + */ + public SpikesAndValleysItem selectSpikesAndValleysItemById(String id); + + /** + * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛� + * + * @param spikesAndValleysItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚� + */ + public List<SpikesAndValleysItem> selectSpikesAndValleysItemList(SpikesAndValleysItem spikesAndValleysItem); + + /** + * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param spikesAndValleysItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int insertSpikesAndValleysItem(SpikesAndValleysItem spikesAndValleysItem); + + /** + * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param spikesAndValleysItem 銆愯濉啓鍔熻兘鍚嶇О銆� + * @return 缁撴灉 + */ + public int updateSpikesAndValleysItem(SpikesAndValleysItem spikesAndValleysItem); + + /** + * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿� + * @return 缁撴灉 + */ + public int deleteSpikesAndValleysItemById(String id); + + /** + * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆� + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteSpikesAndValleysItemByIds(String[] ids); +} diff --git a/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysSchemeMapper.java b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysSchemeMapper.java new file mode 100644 index 0000000..c13f73c --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/mapper/SpikesAndValleysSchemeMapper.java @@ -0,0 +1,62 @@ +package com.zhitan.spikesandvalleys.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysScheme; + + +/** + * 灏栧嘲骞宠胺鏃堕棿娈垫槑缁哅apper鎺ュ彛 + * + * @author ZhiTan + * @date 2024-10-29 + */ +public interface SpikesAndValleysSchemeMapper extends BaseMapper<SpikesAndValleysScheme> { + /** + * 鏌ヨ灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param id 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿� + * @return 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + */ + public SpikesAndValleysScheme selectSpikesAndValleysSchemeById(String id); + + /** + * 鏌ヨ灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗗垪琛� + * + * @param spikesAndValleysScheme 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗛泦鍚� + */ + public List<SpikesAndValleysScheme> selectSpikesAndValleysSchemeList(SpikesAndValleysScheme spikesAndValleysScheme); + + /** + * 鏂板灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param spikesAndValleysScheme 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 缁撴灉 + */ + public int insertSpikesAndValleysScheme(SpikesAndValleysScheme spikesAndValleysScheme); + + /** + * 淇敼灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param spikesAndValleysScheme 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 缁撴灉 + */ + public int updateSpikesAndValleysScheme(SpikesAndValleysScheme spikesAndValleysScheme); + + /** + * 鍒犻櫎灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param id 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿� + * @return 缁撴灉 + */ + public int deleteSpikesAndValleysSchemeById(String id); + + /** + * 鎵归噺鍒犻櫎灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 + * @return 缁撴灉 + */ + public int deleteSpikesAndValleysSchemeByIds(String[] ids); +} diff --git a/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/ISpikesAndValleysSchemeService.java b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/ISpikesAndValleysSchemeService.java new file mode 100644 index 0000000..2b81912 --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/ISpikesAndValleysSchemeService.java @@ -0,0 +1,65 @@ +package com.zhitan.spikesandvalleys.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.zhitan.alarm.domain.LimitType; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysScheme; +import com.zhitan.spikesandvalleys.domain.vo.SpikesAndValleysSchemeVo; + +/** + * 灏栧嘲骞宠胺鏃堕棿娈垫槑缁哠ervice鎺ュ彛 + * + * @author ZhiTan + * @date 2024-10-29 + */ +public interface ISpikesAndValleysSchemeService extends IService<SpikesAndValleysScheme> { + /** + * 鏌ヨ灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param id 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿� + * @return 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + */ + public SpikesAndValleysSchemeVo selectSpikesAndValleysSchemeById(String id); + + /** + * 鏌ヨ灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗗垪琛� + * + * @param spikesAndValleysScheme 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗛泦鍚� + */ + public Page<SpikesAndValleysSchemeVo> selectSpikesAndValleysSchemeList(SpikesAndValleysScheme spikesAndValleysScheme, Long pageNum, Long pageSize); + + /** + * 鏂板灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param spikesAndValleysScheme 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 缁撴灉 + */ + public int insertSpikesAndValleysScheme(SpikesAndValleysSchemeVo spikesAndValleysScheme); + + /** + * 淇敼灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param spikesAndValleysScheme 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 缁撴灉 + */ + public int updateSpikesAndValleysScheme(SpikesAndValleysSchemeVo spikesAndValleysScheme); + + /** + * 鎵归噺鍒犻櫎灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param ids 闇�瑕佸垹闄ょ殑灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿泦鍚� + * @return 缁撴灉 + */ + public int deleteSpikesAndValleysSchemeByIds(String[] ids); + + /** + * 鍒犻櫎灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕俊鎭� + * + * @param id 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿� + * @return 缁撴灉 + */ + public int deleteSpikesAndValleysSchemeById(String id); +} diff --git a/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/impl/SpikesAndValleysSchemeServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/impl/SpikesAndValleysSchemeServiceImpl.java new file mode 100644 index 0000000..224d27f --- /dev/null +++ b/zhitan-system/src/main/java/com/zhitan/spikesandvalleys/service/impl/SpikesAndValleysSchemeServiceImpl.java @@ -0,0 +1,176 @@ +package com.zhitan.spikesandvalleys.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +import com.zhitan.alarm.domain.LimitType; +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysItem; +import com.zhitan.spikesandvalleys.domain.SpikesAndValleysScheme; +import com.zhitan.spikesandvalleys.domain.vo.SpikesAndValleysSchemeVo; +import com.zhitan.spikesandvalleys.mapper.SpikesAndValleysItemMapper; +import com.zhitan.spikesandvalleys.mapper.SpikesAndValleysSchemeMapper; +import com.zhitan.spikesandvalleys.service.ISpikesAndValleysSchemeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + * 灏栧嘲骞宠胺鏃堕棿娈垫槑缁哠ervice涓氬姟灞傚鐞� + * + * @author ZhiTan + * @date 2024-10-29 + */ +@Service +public class SpikesAndValleysSchemeServiceImpl extends ServiceImpl<SpikesAndValleysSchemeMapper, SpikesAndValleysScheme> implements ISpikesAndValleysSchemeService { + @Autowired + private SpikesAndValleysSchemeMapper spikesAndValleysSchemeMapper; + @Autowired + private SpikesAndValleysItemMapper spikesAndValleysItemMapper; + /** + * 鏌ヨ灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param id 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿� + * @return 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + */ + @Override + public SpikesAndValleysSchemeVo selectSpikesAndValleysSchemeById(String id) { + SpikesAndValleysSchemeVo result = new SpikesAndValleysSchemeVo(); + SpikesAndValleysScheme info = spikesAndValleysSchemeMapper.selectSpikesAndValleysSchemeById(id); + BeanUtil.copyProperties(info,result); + LambdaQueryWrapper<SpikesAndValleysItem> queryWrapperItem = new LambdaQueryWrapper<>(); + queryWrapperItem.eq(SpikesAndValleysItem::getSchemeId,id); + List<SpikesAndValleysItem> itemListOld = spikesAndValleysItemMapper.selectList(queryWrapperItem); + result.setItemList(itemListOld); + return result ; + } + + /** + * 鏌ヨ灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗗垪琛� + * + * @param spikesAndValleysScheme 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + */ + @Override + public Page<SpikesAndValleysSchemeVo> selectSpikesAndValleysSchemeList(SpikesAndValleysScheme spikesAndValleysScheme,Long pageNum, Long pageSize) { + + LambdaQueryWrapper<SpikesAndValleysScheme> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(spikesAndValleysScheme.getSchemeName()),SpikesAndValleysScheme::getSchemeName,spikesAndValleysScheme.getSchemeName()); + queryWrapper.eq(StringUtils.isNotEmpty(spikesAndValleysScheme.getType()),SpikesAndValleysScheme::getType,spikesAndValleysScheme.getType()); + queryWrapper.orderByDesc(SpikesAndValleysScheme::getCreateTime); + Page<SpikesAndValleysScheme> page = spikesAndValleysSchemeMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + IPage aa = page.convert(s->{ + SpikesAndValleysSchemeVo v = new SpikesAndValleysSchemeVo(); + BeanUtil.copyProperties(s, v); + LambdaQueryWrapper<SpikesAndValleysItem> queryWrapperItem = new LambdaQueryWrapper<>(); + queryWrapperItem.eq(SpikesAndValleysItem::getSchemeId,s.getId()); + List<SpikesAndValleysItem> itemListOld = spikesAndValleysItemMapper.selectList(queryWrapperItem); + v.setItemList(itemListOld); + return v; + }); + + return (Page<SpikesAndValleysSchemeVo>) aa; + } + + /** + * 鏂板灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param spikesAndValleysSchemeVo 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 缁撴灉 + */ + @Override + @Transactional + public int insertSpikesAndValleysScheme(SpikesAndValleysSchemeVo spikesAndValleysSchemeVo) { + spikesAndValleysSchemeVo.setCreateTime(DateUtils.getNowDate()); + spikesAndValleysSchemeVo.setId(UUID.randomUUID().toString()); + SpikesAndValleysScheme spikesAndValleysScheme = new SpikesAndValleysScheme(); + BeanUtil.copyProperties(spikesAndValleysSchemeVo,spikesAndValleysScheme); + int result = spikesAndValleysSchemeMapper.insert(spikesAndValleysScheme); + //鎻掑叆瀛愯〃 + List<SpikesAndValleysItem> itemList = spikesAndValleysSchemeVo.getItemList(); + itemList.stream().forEach(s->{ + s.setId(UUID.randomUUID().toString()); + s.setCreateTime(DateUtils.getNowDate()); + s.setCreateBy(spikesAndValleysSchemeVo.getCreateBy()); + s.setSchemeId(spikesAndValleysScheme.getId()); + spikesAndValleysItemMapper.insert(s); + }); + + return result; + } + + /** + * 淇敼灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param spikesAndValleysSchemeVo 灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * @return 缁撴灉 + */ + @Override + @Transactional + public int updateSpikesAndValleysScheme(SpikesAndValleysSchemeVo spikesAndValleysSchemeVo) { + spikesAndValleysSchemeVo.setUpdateTime(DateUtils.getNowDate()); + SpikesAndValleysScheme spikesAndValleysScheme = new SpikesAndValleysScheme(); + BeanUtil.copyProperties(spikesAndValleysSchemeVo,spikesAndValleysScheme); + int result = spikesAndValleysSchemeMapper.updateSpikesAndValleysScheme(spikesAndValleysScheme); + //鍒犻櫎瀛愯〃 + LambdaQueryWrapper<SpikesAndValleysItem> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SpikesAndValleysItem::getSchemeId,spikesAndValleysScheme.getId()); + List<SpikesAndValleysItem> itemListOld = spikesAndValleysItemMapper.selectList(queryWrapper); + List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); + String[] ids = idList.toArray(new String[idList.size()]); + spikesAndValleysItemMapper.deleteSpikesAndValleysItemByIds(ids); + //鎻掑叆瀛愯〃 + List<SpikesAndValleysItem> itemList = spikesAndValleysSchemeVo.getItemList(); + itemList.stream().forEach(s->{ + s.setId(UUID.randomUUID().toString()); + s.setCreateTime(DateUtils.getNowDate()); + s.setCreateBy(spikesAndValleysSchemeVo.getCreateBy()); + s.setSchemeId(spikesAndValleysScheme.getId()); + spikesAndValleysItemMapper.insert(s); + }); + return result; + } + + /** + * 鎵归噺鍒犻櫎灏栧嘲骞宠胺鏃堕棿娈垫槑缁� + * + * @param ids 闇�瑕佸垹闄ょ殑灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿� + * @return 缁撴灉 + */ + @Override + public int deleteSpikesAndValleysSchemeByIds(String[] ids) { + //鍒犻櫎瀛愯〃 + List<String> list = Arrays.asList(ids); + list.stream().forEach(item->{ + LambdaQueryWrapper<SpikesAndValleysItem> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SpikesAndValleysItem::getSchemeId,item); + List<SpikesAndValleysItem> itemListOld = spikesAndValleysItemMapper.selectList(queryWrapper); + List<String>idList = itemListOld.stream().map(s->s.getId()).collect(Collectors.toList()); + String[] itemIds = idList.toArray(new String[idList.size()]); + spikesAndValleysItemMapper.deleteSpikesAndValleysItemByIds(itemIds); + }); + + return spikesAndValleysSchemeMapper.deleteSpikesAndValleysSchemeByIds(ids); + } + + /** + * 鍒犻櫎灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕俊鎭� + * + * @param id 灏栧嘲骞宠胺鏃堕棿娈垫槑缁嗕富閿� + * @return 缁撴灉 + */ + @Override + public int deleteSpikesAndValleysSchemeById(String id) { + return spikesAndValleysSchemeMapper.deleteSpikesAndValleysSchemeById(id); + } +} diff --git a/zhitan-system/src/main/java/com/zhitan/system/domain/SysOperLog.java b/zhitan-system/src/main/java/com/zhitan/system/domain/SysOperLog.java index 92607b7..aea384b 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/domain/SysOperLog.java +++ b/zhitan-system/src/main/java/com/zhitan/system/domain/SysOperLog.java @@ -1,16 +1,17 @@ package com.zhitan.system.domain; -import java.util.Date; - +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.fasterxml.jackson.annotation.JsonFormat; import com.zhitan.common.annotation.Excel; import com.zhitan.common.annotation.Excel.ColumnType; import com.zhitan.common.core.domain.BaseEntity; +import java.util.Date; + /** * 鎿嶄綔鏃ュ織璁板綍琛� oper_log - * + * * @author zhitan */ public class SysOperLog extends BaseEntity @@ -31,6 +32,7 @@ private Integer businessType; /** 涓氬姟绫诲瀷鏁扮粍 */ + @TableField(exist = false) private Integer[] businessTypes; /** 璇锋眰鏂规硶 */ diff --git a/zhitan-system/src/main/java/com/zhitan/system/domain/SysPost.java b/zhitan-system/src/main/java/com/zhitan/system/domain/SysPost.java index be46283..282c0d3 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/domain/SysPost.java +++ b/zhitan-system/src/main/java/com/zhitan/system/domain/SysPost.java @@ -1,19 +1,20 @@ package com.zhitan.system.domain; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.zhitan.common.annotation.Excel; +import com.zhitan.common.annotation.Excel.ColumnType; +import com.zhitan.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import com.baomidou.mybatisplus.annotation.TableId; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.zhitan.common.annotation.Excel; -import com.zhitan.common.annotation.Excel.ColumnType; -import com.zhitan.common.core.domain.BaseEntity; - /** * 宀椾綅琛� sys_post - * + * * @author zhitan */ public class SysPost extends BaseEntity @@ -42,6 +43,7 @@ private String status; /** 鐢ㄦ埛鏄惁瀛樺湪姝ゅ矖浣嶆爣璇� 榛樿涓嶅瓨鍦� */ + @TableField(exist = false) private boolean flag = false; public Long getPostId() @@ -108,7 +110,7 @@ { this.flag = flag; } - + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/ISysDictDataService.java b/zhitan-system/src/main/java/com/zhitan/system/service/ISysDictDataService.java index f0c9153..00ad9d6 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/ISysDictDataService.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/ISysDictDataService.java @@ -1,11 +1,13 @@ package com.zhitan.system.service; -import java.util.List; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.core.domain.entity.SysDictData; + +import java.util.List; /** * 瀛楀吀 涓氬姟灞� - * + * * @author zhitan */ public interface ISysDictDataService @@ -14,7 +16,7 @@ /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瀛楀吀鏁版嵁 - * + * * @param dictData 瀛楀吀鏁版嵁淇℃伅 * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅 */ @@ -22,7 +24,7 @@ /** * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏搁敭鍊兼煡璇㈠瓧鍏告暟鎹俊鎭� - * + * * @param dictType 瀛楀吀绫诲瀷 * @param dictValue 瀛楀吀閿�� * @return 瀛楀吀鏍囩 @@ -31,7 +33,7 @@ /** * 鏍规嵁瀛楀吀鏁版嵁ID鏌ヨ淇℃伅 - * + * * @param dictCode 瀛楀吀鏁版嵁ID * @return 瀛楀吀鏁版嵁 */ @@ -39,14 +41,14 @@ /** * 鎵归噺鍒犻櫎瀛楀吀鏁版嵁淇℃伅 - * + * * @param dictCodes 闇�瑕佸垹闄ょ殑瀛楀吀鏁版嵁ID */ void deleteDictDataByIds(Long[] dictCodes); /** * 鏂板淇濆瓨瀛楀吀鏁版嵁淇℃伅 - * + * * @param dictData 瀛楀吀鏁版嵁淇℃伅 * @return 缁撴灉 */ @@ -54,7 +56,7 @@ /** * 淇敼淇濆瓨瀛楀吀鏁版嵁淇℃伅 - * + * * @param dictData 瀛楀吀鏁版嵁淇℃伅 * @return 缁撴灉 */ @@ -67,4 +69,6 @@ * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅 */ List<SysDictData> selectDictDataByType(String dictType); + + Page<SysDictData> selectDictDataPage(SysDictData dictData, Long pageNum, Long pageSize); } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/ISysLoginInfoService.java b/zhitan-system/src/main/java/com/zhitan/system/service/ISysLoginInfoService.java index c32aebe..bc9e8d8 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/ISysLoginInfoService.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/ISysLoginInfoService.java @@ -1,25 +1,27 @@ package com.zhitan.system.service; -import java.util.List; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.system.domain.SysLoginInfo; + +import java.util.List; /** * 绯荤粺璁块棶鏃ュ織鎯呭喌淇℃伅 鏈嶅姟灞� - * + * * @author zhitan */ public interface ISysLoginInfoService { /** * 鏂板绯荤粺鐧诲綍鏃ュ織 - * + * * @param loginInfo 璁块棶鏃ュ織瀵硅薄 */ void insertLoginInfo(SysLoginInfo loginInfo); /** * 鏌ヨ绯荤粺鐧诲綍鏃ュ織闆嗗悎 - * + * * @param loginInfo 璁块棶鏃ュ織瀵硅薄 * @return 鐧诲綍璁板綍闆嗗悎 */ @@ -27,7 +29,7 @@ /** * 鎵归噺鍒犻櫎绯荤粺鐧诲綍鏃ュ織 - * + * * @param infoIds 闇�瑕佸垹闄ょ殑鐧诲綍鏃ュ織ID * @return 缁撴灉 */ @@ -37,4 +39,6 @@ * 娓呯┖绯荤粺鐧诲綍鏃ュ織 */ void cleanLoginInfo(); + + Page<SysLoginInfo> selectLogininforPage(SysLoginInfo logininfor, Long pageNum, Long pageSize); } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/ISysOperLogService.java b/zhitan-system/src/main/java/com/zhitan/system/service/ISysOperLogService.java index 3878568..03786cf 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/ISysOperLogService.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/ISysOperLogService.java @@ -1,25 +1,27 @@ package com.zhitan.system.service; -import java.util.List; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.system.domain.SysOperLog; + +import java.util.List; /** * 鎿嶄綔鏃ュ織 鏈嶅姟灞� - * + * * @author zhitan */ public interface ISysOperLogService { /** * 鏂板鎿嶄綔鏃ュ織 - * + * * @param operLog 鎿嶄綔鏃ュ織瀵硅薄 */ void insertOperlog(SysOperLog operLog); /** * 鏌ヨ绯荤粺鎿嶄綔鏃ュ織闆嗗悎 - * + * * @param operLog 鎿嶄綔鏃ュ織瀵硅薄 * @return 鎿嶄綔鏃ュ織闆嗗悎 */ @@ -27,7 +29,7 @@ /** * 鎵归噺鍒犻櫎绯荤粺鎿嶄綔鏃ュ織 - * + * * @param operIds 闇�瑕佸垹闄ょ殑鎿嶄綔鏃ュ織ID * @return 缁撴灉 */ @@ -35,7 +37,7 @@ /** * 鏌ヨ鎿嶄綔鏃ュ織璇︾粏 - * + * * @param operId 鎿嶄綔ID * @return 鎿嶄綔鏃ュ織瀵硅薄 */ @@ -45,4 +47,6 @@ * 娓呯┖鎿嶄綔鏃ュ織 */ void cleanOperLog(); + + Page<SysOperLog> selectOperLogPage(SysOperLog operLog, Long pageNum, Long pageSize); } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/ISysPostService.java b/zhitan-system/src/main/java/com/zhitan/system/service/ISysPostService.java index c7a4cf6..6c8eda1 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/ISysPostService.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/ISysPostService.java @@ -1,18 +1,20 @@ package com.zhitan.system.service; -import java.util.List; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.system.domain.SysPost; + +import java.util.List; /** * 宀椾綅淇℃伅 鏈嶅姟灞� - * + * * @author zhitan */ public interface ISysPostService { /** * 鏌ヨ宀椾綅淇℃伅闆嗗悎 - * + * * @param post 宀椾綅淇℃伅 * @return 宀椾綅鍒楄〃 */ @@ -20,14 +22,14 @@ /** * 鏌ヨ鎵�鏈夊矖浣� - * + * * @return 宀椾綅鍒楄〃 */ List<SysPost> selectPostAll(); /** * 閫氳繃宀椾綅ID鏌ヨ宀椾綅淇℃伅 - * + * * @param postId 宀椾綅ID * @return 瑙掕壊瀵硅薄淇℃伅 */ @@ -35,7 +37,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鑾峰彇宀椾綅閫夋嫨妗嗗垪琛� - * + * * @param userId 鐢ㄦ埛ID * @return 閫変腑宀椾綅ID鍒楄〃 */ @@ -43,7 +45,7 @@ /** * 鏍¢獙宀椾綅鍚嶇О - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ @@ -51,7 +53,7 @@ /** * 鏍¢獙宀椾綅缂栫爜 - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ @@ -59,7 +61,7 @@ /** * 閫氳繃宀椾綅ID鏌ヨ宀椾綅浣跨敤鏁伴噺 - * + * * @param postId 宀椾綅ID * @return 缁撴灉 */ @@ -67,7 +69,7 @@ /** * 鍒犻櫎宀椾綅淇℃伅 - * + * * @param postId 宀椾綅ID * @return 缁撴灉 */ @@ -75,7 +77,7 @@ /** * 鎵归噺鍒犻櫎宀椾綅淇℃伅 - * + * * @param postIds 闇�瑕佸垹闄ょ殑宀椾綅ID * @return 缁撴灉 */ @@ -83,7 +85,7 @@ /** * 鏂板淇濆瓨宀椾綅淇℃伅 - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ @@ -91,9 +93,11 @@ /** * 淇敼淇濆瓨宀椾綅淇℃伅 - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ int updatePost(SysPost post); + + Page<SysPost> selectPostPage(SysPost post, Long pageNum, Long pageSize); } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/ISysRoleService.java b/zhitan-system/src/main/java/com/zhitan/system/service/ISysRoleService.java index e66d772..1f47450 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/ISysRoleService.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/ISysRoleService.java @@ -1,20 +1,22 @@ package com.zhitan.system.service; -import java.util.List; -import java.util.Set; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.core.domain.entity.SysRole; import com.zhitan.system.domain.SysUserRole; +import java.util.List; +import java.util.Set; + /** * 瑙掕壊涓氬姟灞� - * + * * @author zhitan */ public interface ISysRoleService { /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瑙掕壊鏁版嵁 - * + * * @param role 瑙掕壊淇℃伅 * @return 瑙掕壊鏁版嵁闆嗗悎淇℃伅 */ @@ -22,7 +24,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鏌ヨ瑙掕壊鍒楄〃 - * + * * @param userId 鐢ㄦ埛ID * @return 瑙掕壊鍒楄〃 */ @@ -30,7 +32,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鏌ヨ瑙掕壊鏉冮檺 - * + * * @param userId 鐢ㄦ埛ID * @return 鏉冮檺鍒楄〃 */ @@ -38,14 +40,14 @@ /** * 鏌ヨ鎵�鏈夎鑹� - * + * * @return 瑙掕壊鍒楄〃 */ List<SysRole> selectRoleAll(); /** * 鏍规嵁鐢ㄦ埛ID鑾峰彇瑙掕壊閫夋嫨妗嗗垪琛� - * + * * @param userId 鐢ㄦ埛ID * @return 閫変腑瑙掕壊ID鍒楄〃 */ @@ -53,7 +55,7 @@ /** * 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @return 瑙掕壊瀵硅薄淇℃伅 */ @@ -61,7 +63,7 @@ /** * 鏍¢獙瑙掕壊鍚嶇О鏄惁鍞竴 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -69,7 +71,7 @@ /** * 鏍¢獙瑙掕壊鏉冮檺鏄惁鍞竴 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -77,21 +79,21 @@ /** * 鏍¢獙瑙掕壊鏄惁鍏佽鎿嶄綔 - * + * * @param role 瑙掕壊淇℃伅 */ void checkRoleAllowed(SysRole role); /** * 鏍¢獙瑙掕壊鏄惁鏈夋暟鎹潈闄� - * + * * @param roleId 瑙掕壊id */ void checkRoleDataScope(Long roleId); /** * 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊浣跨敤鏁伴噺 - * + * * @param roleId 瑙掕壊ID * @return 缁撴灉 */ @@ -99,7 +101,7 @@ /** * 鏂板淇濆瓨瑙掕壊淇℃伅 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -107,7 +109,7 @@ /** * 淇敼淇濆瓨瑙掕壊淇℃伅 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -115,7 +117,7 @@ /** * 淇敼瑙掕壊鐘舵�� - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -123,7 +125,7 @@ /** * 淇敼鏁版嵁鏉冮檺淇℃伅 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -131,7 +133,7 @@ /** * 閫氳繃瑙掕壊ID鍒犻櫎瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @return 缁撴灉 */ @@ -139,7 +141,7 @@ /** * 鎵归噺鍒犻櫎瑙掕壊淇℃伅 - * + * * @param roleIds 闇�瑕佸垹闄ょ殑瑙掕壊ID * @return 缁撴灉 */ @@ -147,7 +149,7 @@ /** * 鍙栨秷鎺堟潈鐢ㄦ埛瑙掕壊 - * + * * @param userRole 鐢ㄦ埛鍜岃鑹插叧鑱斾俊鎭� * @return 缁撴灉 */ @@ -155,7 +157,7 @@ /** * 鎵归噺鍙栨秷鎺堟潈鐢ㄦ埛瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @param userIds 闇�瑕佸彇娑堟巿鏉冪殑鐢ㄦ埛鏁版嵁ID * @return 缁撴灉 @@ -164,10 +166,14 @@ /** * 鎵归噺閫夋嫨鎺堟潈鐢ㄦ埛瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @param userIds 闇�瑕佸垹闄ょ殑鐢ㄦ埛鏁版嵁ID * @return 缁撴灉 */ int insertAuthUsers(Long roleId, Long[] userIds); + + Page<SysRole> selectRolePage(SysRole role, Long pageNum, Long pageSize); + + SysRole getRoleByKey(SysRole queryRole); } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/ISysUserService.java b/zhitan-system/src/main/java/com/zhitan/system/service/ISysUserService.java index 851bfe0..33cbac4 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/ISysUserService.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/ISysUserService.java @@ -1,18 +1,20 @@ package com.zhitan.system.service; -import java.util.List; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhitan.common.core.domain.entity.SysUser; + +import java.util.List; /** * 鐢ㄦ埛 涓氬姟灞� - * + * * @author zhitan */ public interface ISysUserService { /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃 - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅 */ @@ -20,7 +22,7 @@ /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ宸插垎閰嶇敤鎴疯鑹插垪琛� - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅 */ @@ -28,7 +30,7 @@ /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鏈垎閰嶇敤鎴疯鑹插垪琛� - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅 */ @@ -36,7 +38,7 @@ /** * 閫氳繃鐢ㄦ埛鍚嶆煡璇㈢敤鎴� - * + * * @param userName 鐢ㄦ埛鍚� * @return 鐢ㄦ埛瀵硅薄淇℃伅 */ @@ -44,7 +46,7 @@ /** * 閫氳繃鐢ㄦ埛ID鏌ヨ鐢ㄦ埛 - * + * * @param userId 鐢ㄦ埛ID * @return 鐢ㄦ埛瀵硅薄淇℃伅 */ @@ -52,7 +54,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鏌ヨ鐢ㄦ埛鎵�灞炶鑹茬粍 - * + * * @param userName 鐢ㄦ埛鍚� * @return 缁撴灉 */ @@ -60,7 +62,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鏌ヨ鐢ㄦ埛鎵�灞炲矖浣嶇粍 - * + * * @param userName 鐢ㄦ埛鍚� * @return 缁撴灉 */ @@ -68,7 +70,7 @@ /** * 鏍¢獙鐢ㄦ埛鍚嶇О鏄惁鍞竴 - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 缁撴灉 */ @@ -92,21 +94,21 @@ /** * 鏍¢獙鐢ㄦ埛鏄惁鍏佽鎿嶄綔 - * + * * @param user 鐢ㄦ埛淇℃伅 */ void checkUserAllowed(SysUser user); /** * 鏍¢獙鐢ㄦ埛鏄惁鏈夋暟鎹潈闄� - * + * * @param userId 鐢ㄦ埛id */ void checkUserDataScope(Long userId); /** * 鏂板鐢ㄦ埛淇℃伅 - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 缁撴灉 */ @@ -114,7 +116,7 @@ /** * 娉ㄥ唽鐢ㄦ埛淇℃伅 - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 缁撴灉 */ @@ -122,7 +124,7 @@ /** * 淇敼鐢ㄦ埛淇℃伅 - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 缁撴灉 */ @@ -130,7 +132,7 @@ /** * 鐢ㄦ埛鎺堟潈瑙掕壊 - * + * * @param userId 鐢ㄦ埛ID * @param roleIds 瑙掕壊缁� */ @@ -138,7 +140,7 @@ /** * 淇敼鐢ㄦ埛鐘舵�� - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 缁撴灉 */ @@ -146,7 +148,7 @@ /** * 淇敼鐢ㄦ埛鍩烘湰淇℃伅 - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 缁撴灉 */ @@ -154,7 +156,7 @@ /** * 淇敼鐢ㄦ埛澶村儚 - * + * * @param userName 鐢ㄦ埛鍚� * @param avatar 澶村儚鍦板潃 * @return 缁撴灉 @@ -163,7 +165,7 @@ /** * 閲嶇疆鐢ㄦ埛瀵嗙爜 - * + * * @param user 鐢ㄦ埛淇℃伅 * @return 缁撴灉 */ @@ -171,7 +173,7 @@ /** * 閲嶇疆鐢ㄦ埛瀵嗙爜 - * + * * @param userName 鐢ㄦ埛鍚� * @param password 瀵嗙爜 * @return 缁撴灉 @@ -180,7 +182,7 @@ /** * 閫氳繃鐢ㄦ埛ID鍒犻櫎鐢ㄦ埛 - * + * * @param userId 鐢ㄦ埛ID * @return 缁撴灉 */ @@ -188,7 +190,7 @@ /** * 鎵归噺鍒犻櫎鐢ㄦ埛淇℃伅 - * + * * @param userIds 闇�瑕佸垹闄ょ殑鐢ㄦ埛ID * @return 缁撴灉 */ @@ -196,11 +198,15 @@ /** * 瀵煎叆鐢ㄦ埛鏁版嵁 - * + * * @param userList 鐢ㄦ埛鏁版嵁鍒楄〃 * @param isUpdateSupport 鏄惁鏇存柊鏀寔锛屽鏋滃凡瀛樺湪锛屽垯杩涜鏇存柊鏁版嵁 * @param operName 鎿嶄綔鐢ㄦ埛 * @return 缁撴灉 */ String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); + + Page<SysUser> selectUserPage(SysUser user, Long pageNum, Long pageSize); + + Long checkThirdUserExist(SysUser user); } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysDictDataServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysDictDataServiceImpl.java index 362be25..574621f 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysDictDataServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysDictDataServiceImpl.java @@ -1,18 +1,21 @@ package com.zhitan.system.service.impl; -import java.util.List; -import javax.annotation.Resource; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; import com.zhitan.common.core.domain.entity.SysDictData; import com.zhitan.common.utils.DictUtils; +import com.zhitan.common.utils.StringUtils; import com.zhitan.system.mapper.SysDictDataMapper; import com.zhitan.system.service.ISysDictDataService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; /** * 瀛楀吀 涓氬姟灞傚鐞� - * + * * @author zhitan */ @Service @@ -23,7 +26,7 @@ /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瀛楀吀鏁版嵁 - * + * * @param dictData 瀛楀吀鏁版嵁淇℃伅 * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅 */ @@ -35,7 +38,7 @@ /** * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏搁敭鍊兼煡璇㈠瓧鍏告暟鎹俊鎭� - * + * * @param dictType 瀛楀吀绫诲瀷 * @param dictValue 瀛楀吀閿�� * @return 瀛楀吀鏍囩 @@ -48,7 +51,7 @@ /** * 鏍规嵁瀛楀吀鏁版嵁ID鏌ヨ淇℃伅 - * + * * @param dictCode 瀛楀吀鏁版嵁ID * @return 瀛楀吀鏁版嵁 */ @@ -60,7 +63,7 @@ /** * 鎵归噺鍒犻櫎瀛楀吀鏁版嵁淇℃伅 - * + * * @param dictCodes 闇�瑕佸垹闄ょ殑瀛楀吀鏁版嵁ID */ @Override @@ -77,7 +80,7 @@ /** * 鏂板淇濆瓨瀛楀吀鏁版嵁淇℃伅 - * + * * @param data 瀛楀吀鏁版嵁淇℃伅 * @return 缁撴灉 */ @@ -95,7 +98,7 @@ /** * 淇敼淇濆瓨瀛楀吀鏁版嵁淇℃伅 - * + * * @param data 瀛楀吀鏁版嵁淇℃伅 * @return 缁撴灉 */ @@ -115,4 +118,12 @@ public List<SysDictData> selectDictDataByType(String dictType) { return dictDataMapper.selectDictDataByType(dictType); } + @Override + public Page<SysDictData> selectDictDataPage(SysDictData dictData, Long pageNum, Long pageSize) { + LambdaQueryWrapper<SysDictData> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(dictData.getDictLabel()),SysDictData::getDictLabel,dictData.getDictLabel()); + queryWrapper.eq(StringUtils.isNotEmpty(dictData.getDictType()),SysDictData::getDictType,dictData.getDictType()); + queryWrapper.eq(StringUtils.isNotEmpty(dictData.getStatus()),SysDictData::getStatus,dictData.getStatus()); + return dictDataMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + } } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysLoginInfoServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysLoginInfoServiceImpl.java index 2edd2fe..a1a837a 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysLoginInfoServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysLoginInfoServiceImpl.java @@ -1,17 +1,21 @@ package com.zhitan.system.service.impl; -import java.util.List; -import javax.annotation.Resource; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; import com.zhitan.system.domain.SysLoginInfo; import com.zhitan.system.mapper.SysLoginInfoMapper; import com.zhitan.system.service.ISysLoginInfoService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; /** * 绯荤粺璁块棶鏃ュ織鎯呭喌淇℃伅 鏈嶅姟灞傚鐞� - * + * * @author zhitan */ @Service @@ -23,7 +27,7 @@ /** * 鏂板绯荤粺鐧诲綍鏃ュ織 - * + * * @param loginInfo 璁块棶鏃ュ織瀵硅薄 */ @Override @@ -34,7 +38,7 @@ /** * 鏌ヨ绯荤粺鐧诲綍鏃ュ織闆嗗悎 - * + * * @param loginInfo 璁块棶鏃ュ織瀵硅薄 * @return 鐧诲綍璁板綍闆嗗悎 */ @@ -46,7 +50,7 @@ /** * 鎵归噺鍒犻櫎绯荤粺鐧诲綍鏃ュ織 - * + * * @param infoIds 闇�瑕佸垹闄ょ殑鐧诲綍鏃ュ織ID * @return 缁撴灉 */ @@ -64,4 +68,17 @@ { loginInfoMapper.cleanLoginInfo(); } + @Override + public Page<SysLoginInfo> selectLogininforPage(SysLoginInfo logininfor, Long pageNum, Long pageSize) { + LambdaQueryWrapper<SysLoginInfo> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(logininfor.getUserName()),SysLoginInfo::getUserName,logininfor.getUserName()); + queryWrapper.like(StringUtils.isNotEmpty(logininfor.getIpaddr()),SysLoginInfo::getIpaddr,logininfor.getIpaddr()); + queryWrapper.eq(StringUtils.isNotEmpty(logininfor.getStatus()),SysLoginInfo::getStatus,logininfor.getStatus()); + if(logininfor.getParams().containsKey("beginTime")) { + queryWrapper.between(SysLoginInfo::getCreateTime, + DateUtils.parseDate(logininfor.getParams().get("beginTime")), + DateUtils.parseDate(logininfor.getParams().get("endTime"))); + } + return loginInfoMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + } } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysOperLogServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysOperLogServiceImpl.java index f9534cc..d49a4b8 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysOperLogServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysOperLogServiceImpl.java @@ -1,17 +1,21 @@ package com.zhitan.system.service.impl; -import java.util.List; -import javax.annotation.Resource; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; +import com.zhitan.common.utils.DateUtils; +import com.zhitan.common.utils.StringUtils; import com.zhitan.system.domain.SysOperLog; import com.zhitan.system.mapper.SysOperLogMapper; import com.zhitan.system.service.ISysOperLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; /** * 鎿嶄綔鏃ュ織 鏈嶅姟灞傚鐞� - * + * * @author zhitan */ @Service @@ -22,7 +26,7 @@ /** * 鏂板鎿嶄綔鏃ュ織 - * + * * @param operLog 鎿嶄綔鏃ュ織瀵硅薄 */ @Override @@ -33,7 +37,7 @@ /** * 鏌ヨ绯荤粺鎿嶄綔鏃ュ織闆嗗悎 - * + * * @param operLog 鎿嶄綔鏃ュ織瀵硅薄 * @return 鎿嶄綔鏃ュ織闆嗗悎 */ @@ -45,7 +49,7 @@ /** * 鎵归噺鍒犻櫎绯荤粺鎿嶄綔鏃ュ織 - * + * * @param operIds 闇�瑕佸垹闄ょ殑鎿嶄綔鏃ュ織ID * @return 缁撴灉 */ @@ -57,7 +61,7 @@ /** * 鏌ヨ鎿嶄綔鏃ュ織璇︾粏 - * + * * @param operId 鎿嶄綔ID * @return 鎿嶄綔鏃ュ織瀵硅薄 */ @@ -75,4 +79,20 @@ { operLogMapper.cleanOperLog(); } + + @Override + public Page<SysOperLog> selectOperLogPage(SysOperLog operLog, Long pageNum, Long pageSize) { + LambdaQueryWrapper<SysOperLog> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(operLog.getOperIp()), SysOperLog::getOperIp,operLog.getOperIp()); + queryWrapper.like(StringUtils.isNotEmpty(operLog.getTitle()),SysOperLog::getTitle,operLog.getTitle()); + queryWrapper.like(StringUtils.isNotEmpty(operLog.getOperName()),SysOperLog::getOperName,operLog.getOperName()); + queryWrapper.eq(null != operLog.getBusinessType(),SysOperLog::getBusinessType,operLog.getBusinessType()); + queryWrapper.eq(null != operLog.getStatus(), SysOperLog::getStatus,operLog.getStatus()); + if(operLog.getParams().containsKey("beginTime")) { + queryWrapper.between(SysOperLog::getCreateTime, + DateUtils.parseDate(operLog.getParams().get("beginTime")), + DateUtils.parseDate(operLog.getParams().get("endTime"))); + } + return operLogMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + } } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysPostServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysPostServiceImpl.java index 20784a9..8a55d6b 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysPostServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysPostServiceImpl.java @@ -1,10 +1,8 @@ package com.zhitan.system.service.impl; -import java.util.List; -import javax.annotation.Resource; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; import com.zhitan.common.constant.UserConstants; import com.zhitan.common.exception.ServiceException; import com.zhitan.common.utils.StringUtils; @@ -12,10 +10,14 @@ import com.zhitan.system.mapper.SysPostMapper; import com.zhitan.system.mapper.SysUserPostMapper; import com.zhitan.system.service.ISysPostService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; /** * 宀椾綅淇℃伅 鏈嶅姟灞傚鐞� - * + * * @author zhitan */ @Service @@ -29,7 +31,7 @@ /** * 鏌ヨ宀椾綅淇℃伅闆嗗悎 - * + * * @param post 宀椾綅淇℃伅 * @return 宀椾綅淇℃伅闆嗗悎 */ @@ -41,7 +43,7 @@ /** * 鏌ヨ鎵�鏈夊矖浣� - * + * * @return 宀椾綅鍒楄〃 */ @Override @@ -52,7 +54,7 @@ /** * 閫氳繃宀椾綅ID鏌ヨ宀椾綅淇℃伅 - * + * * @param postId 宀椾綅ID * @return 瑙掕壊瀵硅薄淇℃伅 */ @@ -64,7 +66,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鑾峰彇宀椾綅閫夋嫨妗嗗垪琛� - * + * * @param userId 鐢ㄦ埛ID * @return 閫変腑宀椾綅ID鍒楄〃 */ @@ -76,7 +78,7 @@ /** * 鏍¢獙宀椾綅鍚嶇О鏄惁鍞竴 - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ @@ -94,7 +96,7 @@ /** * 鏍¢獙宀椾綅缂栫爜鏄惁鍞竴 - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ @@ -112,7 +114,7 @@ /** * 閫氳繃宀椾綅ID鏌ヨ宀椾綅浣跨敤鏁伴噺 - * + * * @param postId 宀椾綅ID * @return 缁撴灉 */ @@ -124,7 +126,7 @@ /** * 鍒犻櫎宀椾綅淇℃伅 - * + * * @param postId 宀椾綅ID * @return 缁撴灉 */ @@ -136,7 +138,7 @@ /** * 鎵归噺鍒犻櫎宀椾綅淇℃伅 - * + * * @param postIds 闇�瑕佸垹闄ょ殑宀椾綅ID * @return 缁撴灉 */ @@ -156,7 +158,7 @@ /** * 鏂板淇濆瓨宀椾綅淇℃伅 - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ @@ -168,7 +170,7 @@ /** * 淇敼淇濆瓨宀椾綅淇℃伅 - * + * * @param post 宀椾綅淇℃伅 * @return 缁撴灉 */ @@ -177,4 +179,14 @@ { return postMapper.updatePost(post); } + @Override + public Page<SysPost> selectPostPage(SysPost post, Long pageNum, Long pageSize) { + LambdaQueryWrapper<SysPost> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(post.getPostName()),SysPost::getPostName,post.getPostName()); + queryWrapper.like(StringUtils.isNotEmpty(post.getPostCode()),SysPost::getPostCode,post.getPostCode()); + queryWrapper.eq(StringUtils.isNotEmpty(post.getStatus()),SysPost::getStatus,post.getStatus()); + + + return postMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); + } } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysRoleServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysRoleServiceImpl.java index 4fa1fc9..8e6338e 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysRoleServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysRoleServiceImpl.java @@ -1,20 +1,14 @@ package com.zhitan.system.service.impl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import javax.annotation.Resource; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import com.zhitan.common.annotation.DataScope; import com.zhitan.common.constant.UserConstants; import com.zhitan.common.core.domain.entity.SysRole; import com.zhitan.common.core.domain.entity.SysUser; import com.zhitan.common.exception.ServiceException; +import com.zhitan.common.utils.DateUtils; import com.zhitan.common.utils.SecurityUtils; import com.zhitan.common.utils.StringUtils; import com.zhitan.common.utils.spring.SpringUtils; @@ -26,10 +20,15 @@ import com.zhitan.system.mapper.SysRoleMenuMapper; import com.zhitan.system.mapper.SysUserRoleMapper; import com.zhitan.system.service.ISysRoleService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.*; /** * 瑙掕壊 涓氬姟灞傚鐞� - * + * * @author zhitan */ @Service @@ -49,7 +48,7 @@ /** * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瑙掕壊鏁版嵁 - * + * * @param role 瑙掕壊淇℃伅 * @return 瑙掕壊鏁版嵁闆嗗悎淇℃伅 */ @@ -62,7 +61,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鏌ヨ瑙掕壊 - * + * * @param userId 鐢ㄦ埛ID * @return 瑙掕壊鍒楄〃 */ @@ -87,7 +86,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鏌ヨ鏉冮檺 - * + * * @param userId 鐢ㄦ埛ID * @return 鏉冮檺鍒楄〃 */ @@ -108,7 +107,7 @@ /** * 鏌ヨ鎵�鏈夎鑹� - * + * * @return 瑙掕壊鍒楄〃 */ @Override @@ -119,7 +118,7 @@ /** * 鏍规嵁鐢ㄦ埛ID鑾峰彇瑙掕壊閫夋嫨妗嗗垪琛� - * + * * @param userId 鐢ㄦ埛ID * @return 閫変腑瑙掕壊ID鍒楄〃 */ @@ -131,7 +130,7 @@ /** * 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @return 瑙掕壊瀵硅薄淇℃伅 */ @@ -143,7 +142,7 @@ /** * 鏍¢獙瑙掕壊鍚嶇О鏄惁鍞竴 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -161,7 +160,7 @@ /** * 鏍¢獙瑙掕壊鏉冮檺鏄惁鍞竴 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -179,7 +178,7 @@ /** * 鏍¢獙瑙掕壊鏄惁鍏佽鎿嶄綔 - * + * * @param role 瑙掕壊淇℃伅 */ @Override @@ -193,7 +192,7 @@ /** * 鏍¢獙瑙掕壊鏄惁鏈夋暟鎹潈闄� - * + * * @param roleId 瑙掕壊id */ @Override @@ -213,7 +212,7 @@ /** * 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊浣跨敤鏁伴噺 - * + * * @param roleId 瑙掕壊ID * @return 缁撴灉 */ @@ -225,7 +224,7 @@ /** * 鏂板淇濆瓨瑙掕壊淇℃伅 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -240,7 +239,7 @@ /** * 淇敼淇濆瓨瑙掕壊淇℃伅 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -257,7 +256,7 @@ /** * 淇敼瑙掕壊鐘舵�� - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -269,7 +268,7 @@ /** * 淇敼鏁版嵁鏉冮檺淇℃伅 - * + * * @param role 瑙掕壊淇℃伅 * @return 缁撴灉 */ @@ -287,7 +286,7 @@ /** * 鏂板瑙掕壊鑿滃崟淇℃伅 - * + * * @param role 瑙掕壊瀵硅薄 */ public int insertRoleMenu(SysRole role) @@ -335,7 +334,7 @@ /** * 閫氳繃瑙掕壊ID鍒犻櫎瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @return 缁撴灉 */ @@ -352,7 +351,7 @@ /** * 鎵归噺鍒犻櫎瑙掕壊淇℃伅 - * + * * @param roleIds 闇�瑕佸垹闄ょ殑瑙掕壊ID * @return 缁撴灉 */ @@ -379,7 +378,7 @@ /** * 鍙栨秷鎺堟潈鐢ㄦ埛瑙掕壊 - * + * * @param userRole 鐢ㄦ埛鍜岃鑹插叧鑱斾俊鎭� * @return 缁撴灉 */ @@ -391,7 +390,7 @@ /** * 鎵归噺鍙栨秷鎺堟潈鐢ㄦ埛瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @param userIds 闇�瑕佸彇娑堟巿鏉冪殑鐢ㄦ埛鏁版嵁ID * @return 缁撴灉 @@ -404,7 +403,7 @@ /** * 鎵归噺閫夋嫨鎺堟潈鐢ㄦ埛瑙掕壊 - * + * * @param roleId 瑙掕壊ID * @param userIds 闇�瑕佹巿鏉冪殑鐢ㄦ埛鏁版嵁ID * @return 缁撴灉 @@ -423,4 +422,24 @@ } return userRoleMapper.batchUserRole(list); } + @Override + public Page<SysRole> selectRolePage(SysRole role, Long pageNum, Long pageSize) { + LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(role.getRoleName()),SysRole::getRoleName,role.getRoleName()); + queryWrapper.like(StringUtils.isNotEmpty(role.getRoleKey()),SysRole::getRoleKey,role.getRoleKey()); + queryWrapper.eq(StringUtils.isNotEmpty(role.getStatus()),SysRole::getStatus,role.getStatus()); + if(role.getParams().containsKey("beginTime")) { + queryWrapper.between(SysRole::getCreateTime, + DateUtils.parseDate(role.getParams().get("beginTime")), + DateUtils.parseDate(role.getParams().get("endTime"))); + } + return roleMapper.selectPage(new Page<SysRole>(pageNum,pageSize),queryWrapper); + } + + @Override + public SysRole getRoleByKey(SysRole queryRole) { + LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysRole::getRoleKey,queryRole.getRoleKey()); + return roleMapper.selectOne(queryWrapper); + } } diff --git a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysUserServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysUserServiceImpl.java index 5c6544a..21b0613 100644 --- a/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysUserServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/system/service/impl/SysUserServiceImpl.java @@ -1,24 +1,14 @@ package com.zhitan.system.service.impl; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import javax.validation.Validator; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import com.zhitan.common.annotation.DataScope; import com.zhitan.common.constant.UserConstants; import com.zhitan.common.core.domain.entity.SysRole; import com.zhitan.common.core.domain.entity.SysUser; import com.zhitan.common.exception.ServiceException; +import com.zhitan.common.utils.DateUtils; import com.zhitan.common.utils.SecurityUtils; import com.zhitan.common.utils.StringUtils; import com.zhitan.common.utils.bean.BeanValidators; @@ -26,13 +16,20 @@ import com.zhitan.system.domain.SysPost; import com.zhitan.system.domain.SysUserPost; import com.zhitan.system.domain.SysUserRole; -import com.zhitan.system.mapper.SysPostMapper; -import com.zhitan.system.mapper.SysRoleMapper; -import com.zhitan.system.mapper.SysUserMapper; -import com.zhitan.system.mapper.SysUserPostMapper; -import com.zhitan.system.mapper.SysUserRoleMapper; +import com.zhitan.system.mapper.*; import com.zhitan.system.service.ISysConfigService; import com.zhitan.system.service.ISysUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import javax.validation.Validator; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; /** * 鐢ㄦ埛 涓氬姟灞傚鐞� @@ -491,4 +488,25 @@ } return successMsg.toString(); } + @Override + public Page<SysUser> selectUserPage(SysUser user, Long pageNum, Long pageSize) { + LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotEmpty(user.getUserName()),SysUser::getUserName,user.getUserName()); + queryWrapper.like(StringUtils.isNotEmpty(user.getPhoneNumber()),SysUser::getPhoneNumber,user.getPhoneNumber()); + queryWrapper.eq(StringUtils.isNotEmpty(user.getStatus()),SysUser::getStatus,user.getStatus()); + if(user.getParams().containsKey("beginTime")) { + queryWrapper.between(SysUser::getCreateTime, + DateUtils.parseDate(user.getParams().get("beginTime")), + DateUtils.parseDate(user.getParams().get("endTime"))); + } + final Page<SysUser> page = userMapper.selectPage(new Page<SysUser>(pageNum, pageSize),queryWrapper); + return page; + } + + @Override + public Long checkThirdUserExist(SysUser user) { + LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysUser::getUserName,user.getUserName()); + return userMapper.selectCount(queryWrapper); + } } diff --git a/zhitan-system/src/main/resources/mapper/basicdata/MeterImplementMapper.xml b/zhitan-system/src/main/resources/mapper/basicdata/MeterImplementMapper.xml index 2ec89c1..9635b86 100644 --- a/zhitan-system/src/main/resources/mapper/basicdata/MeterImplementMapper.xml +++ b/zhitan-system/src/main/resources/mapper/basicdata/MeterImplementMapper.xml @@ -127,6 +127,12 @@ JOIN node_index ni ON ni.node_id = nd.node_id where ni.node_id= #{nodeId} and index_id= #{indexId} </select> + <select id="listMeterImplByInstallLocation" resultType="com.zhitan.basicdata.domain.MeterImplement"> + <include refid="selectMeterImplementVo"/> + <where> + installaction_location = #{installactionLocation} + </where> + </select> <insert id="insertMeterImplement" parameterType="MeterImplement"> insert into meter_implement diff --git a/zhitan-system/src/main/resources/mapper/benchmarkmanage/EnergyBenchmarkManageMapper.xml b/zhitan-system/src/main/resources/mapper/benchmarkmanage/EnergyBenchmarkManageMapper.xml new file mode 100644 index 0000000..41c39e3 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/benchmarkmanage/EnergyBenchmarkManageMapper.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.benchmarkmanage.mapper.EnergyBenchmarkManageMapper"> + + <resultMap type="com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage" id="EnergyBenchmarkManageResult"> + <result property="id" column="id" /> + <result property="code" column="code" /> + <result property="type" column="type" /> + <result property="grade" column="grade" /> + <result property="value" column="value" /> + <result property="nationalNum" column="national_num" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + <result property="remark" column="remark" /> + </resultMap> + + <sql id="selectEnergyBenchmarkManageVo"> + select id, code, type, grade, value, national_num, create_by, create_time, update_by, update_time, remark from energy_benchmark_manage + </sql> + + <select id="selectEnergyBenchmarkManageList" parameterType="com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage" resultMap="EnergyBenchmarkManageResult"> + <include refid="selectEnergyBenchmarkManageVo"/> + <where> + <if test="code != null and code != ''"> and code like concat('%', #{code}, '%')</if> + <if test="type != null and type != ''"> and type = #{type}</if> + <if test="grade != null and grade != ''"> and grade = #{grade}</if> + <if test="value != null and value != ''"> and value = #{value}</if> + <if test="nationalNum != null and nationalNum != ''"> and national_num like concat('%', #{nationalNum}, '%')</if> + </where> + </select> + + <select id="selectEnergyBenchmarkManageById" parameterType="String" resultMap="EnergyBenchmarkManageResult"> + <include refid="selectEnergyBenchmarkManageVo"/> + where id = #{id} + </select> + + <insert id="insertEnergyBenchmarkManage" parameterType="com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage"> + insert into energy_benchmark_manage + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="code != null">code,</if> + <if test="type != null">type,</if> + <if test="grade != null">grade,</if> + <if test="value != null">value,</if> + <if test="nationalNum != null">national_num,</if> + <if test="createBy != null">create_by,</if> + <if test="createTime != null">create_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="remark != null">remark,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="code != null">#{code},</if> + <if test="type != null">#{type},</if> + <if test="grade != null">#{grade},</if> + <if test="value != null">#{value},</if> + <if test="nationalNum != null">#{nationalNum},</if> + <if test="createBy != null">#{createBy},</if> + <if test="createTime != null">#{createTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="remark != null">#{remark},</if> + </trim> + </insert> + + <update id="updateEnergyBenchmarkManage" parameterType="com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage"> + update energy_benchmark_manage + <trim prefix="SET" suffixOverrides=","> + <if test="code != null">code = #{code},</if> + <if test="type != null">type = #{type},</if> + <if test="grade != null">grade = #{grade},</if> + <if test="value != null">value = #{value},</if> + <if test="nationalNum != null">national_num = #{nationalNum},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="remark != null">remark = #{remark},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteEnergyBenchmarkManageById" parameterType="String"> + delete from energy_benchmark_manage where id = #{id} + </delete> + + <delete id="deleteEnergyBenchmarkManageByIds" parameterType="String"> + delete from energy_benchmark_manage where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> + + <select id="getList" parameterType="com.zhitan.benchmarkmanage.domain.EnergyBenchmarkManage" resultMap="EnergyBenchmarkManageResult"> + <include refid="selectEnergyBenchmarkManageVo"/> + <where> + <if test="id != null and id != ''"> and id != #{id}</if> + <if test="code != null and code != ''"> and code = #{code}</if> + <if test="type != null and type != ''"> and type = #{type}</if> + <if test="grade != null and grade != ''"> and grade = #{grade}</if> + </where> + </select> +</mapper> diff --git a/zhitan-system/src/main/resources/mapper/costmanagement/CostElectricityInputMapper.xml b/zhitan-system/src/main/resources/mapper/costmanagement/CostElectricityInputMapper.xml new file mode 100644 index 0000000..45198ea --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/costmanagement/CostElectricityInputMapper.xml @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.costmanagement.mapper.CostElectricityInputMapper"> + + <resultMap type="CostElectricityInput" id="CostElectricityInputResult"> + <result property="id" column="id" /> + <result property="type" column="type" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="remark" column="remark" /> + <result property="electricityNum" column="electricity_num" /> + <result property="time" column="time" /> + <result property="electricityFee" column="electricity_fee" /> + <result property="powerFactor" column="power_factor" /> + <result property="sharpElectricity" column="sharp_electricity" /> + <result property="peakElectricity" column="peak_electricity" /> + <result property="flatElectricity" column="flat_electricity" /> + <result property="valleyElectricity" column="valley_electricity" /> + </resultMap> + + <sql id="selectCostElectricityInputVo"> + select id, type, create_time, create_by, update_time, update_by, remark, electricity_num, time, + electricity_fee, power_factor, sharp_electricity, peak_electricity, flat_electricity, valley_electricity + from cost_electricity_input + </sql> + + <select id="selectCostElectricityInputList" parameterType="CostElectricityInput" resultMap="CostElectricityInputResult"> + <include refid="selectCostElectricityInputVo"/> + <where> + <if test="type != null and type != ''"> and type = #{type}</if> + <if test="electricityNum != null and electricityNum != ''"> and electricity_num = #{electricityNum}</if> + <if test="time != null and time != ''"> and time = #{time}</if> + <if test="electricityFee != null and electricityFee != ''"> and electricity_fee = #{electricityFee}</if> + <if test="powerFactor != null and powerFactor != ''"> and power_factor = #{powerFactor}</if> + <if test="sharpElectricity != null and sharpElectricity != ''"> and sharp_electricity = #{sharpElectricity}</if> + <if test="peakElectricity != null and peakElectricity != ''"> and peak_electricity = #{peakElectricity}</if> + <if test="flatElectricity != null and flatElectricity != ''"> and flat_electricity = #{flatElectricity}</if> + <if test="valleyElectricity != null and valleyElectricity != ''"> and valley_electricity = #{valleyElectricity}</if> + </where> + </select> + + <select id="selectCostElectricityInputById" parameterType="String" resultMap="CostElectricityInputResult"> + <include refid="selectCostElectricityInputVo"/> + where id = #{id} + </select> + + <insert id="insertCostElectricityInput" parameterType="CostElectricityInput"> + insert into cost_electricity_input + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="type != null">type,</if> + <if test="createTime != null">create_time,</if> + <if test="createBy != null">create_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="remark != null">remark,</if> + <if test="electricityNum != null">electricity_num,</if> + <if test="time != null">time,</if> + <if test="electricityFee != null">electricity_fee,</if> + <if test="powerFactor != null">power_factor,</if> + <if test="sharpElectricity != null">sharp_electricity,</if> + <if test="peakElectricity != null">peak_electricity,</if> + <if test="flatElectricity != null">flat_electricity,</if> + <if test="valleyElectricity != null">valley_electricity,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="type != null">#{type},</if> + <if test="createTime != null">#{createTime},</if> + <if test="createBy != null">#{createBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="remark != null">#{remark},</if> + <if test="electricityNum != null">#{electricityNum},</if> + <if test="time != null">#{time},</if> + <if test="electricityFee != null">#{electricityFee},</if> + <if test="powerFactor != null">#{powerFactor},</if> + <if test="sharpElectricity != null">#{sharpElectricity},</if> + <if test="peakElectricity != null">#{peakElectricity},</if> + <if test="flatElectricity != null">#{flatElectricity},</if> + <if test="valleyElectricity != null">#{valleyElectricity},</if> + </trim> + </insert> + + <update id="updateCostElectricityInput" parameterType="CostElectricityInput"> + update cost_electricity_input + <trim prefix="SET" suffixOverrides=","> + <if test="type != null">type = #{type},</if> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="electricityNum != null">electricity_num = #{electricityNum},</if> + <if test="time != null">time = #{time},</if> + <if test="electricityFee != null">electricity_fee = #{electricityFee},</if> + <if test="powerFactor != null">power_factor = #{powerFactor},</if> + <if test="sharpElectricity != null">sharp_electricity = #{sharpElectricity},</if> + <if test="peakElectricity != null">peak_electricity = #{peakElectricity},</if> + <if test="flatElectricity != null">flat_electricity = #{flatElectricity},</if> + <if test="valleyElectricity != null">valley_electricity = #{valleyElectricity},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteCostElectricityInputById" parameterType="String"> + delete from cost_electricity_input where id = #{id} + </delete> + + <delete id="deleteCostElectricityInputByIds" parameterType="String"> + delete from cost_electricity_input where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceRelevancyMapper.xml b/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceRelevancyMapper.xml new file mode 100644 index 0000000..c167f38 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceRelevancyMapper.xml @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.costmanagement.mapper.CostPriceRelevancyMapper"> + + <resultMap type="CostPriceRelevancy" id="CostPriceRelevancyResult"> + <result property="id" column="id" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="remark" column="remark" /> + <result property="nodeId" column="node_id" /> + <result property="tacticsId" column="tactics_id" /> + <result property="energyType" column="energy_type" /> + <result property="effectiveBeginTime" column="effective_begin_time" /> + <result property="effectiveEndTime" column="effective_end_time" /> + </resultMap> + + <sql id="selectCostPriceRelevancyVo"> + select id, create_time, create_by, update_time, update_by, remark, node_id, tactics_id, + energy_type, effective_begin_time, effective_end_time from cost_price_relevancy + </sql> + + <select id="selectCostPriceRelevancyList" parameterType="CostPriceRelevancy" resultMap="CostPriceRelevancyResult"> + <include refid="selectCostPriceRelevancyVo"/> + <where> + <if test="nodeId != null and nodeId != ''"> and node_id = #{nodeId}</if> + <if test="tacticsId != null and tacticsId != ''"> and tactics_id = #{tacticsId}</if> + <if test="energyType != null and energyType != ''"> and energy_type = #{energyType}</if> + <if test="effectiveBeginTime != null "> and effective_begin_time = #{effectiveBeginTime}</if> + <if test="effectiveEndTime != null "> and effective_end_time = #{effectiveEndTime}</if> + </where> + </select> + + <select id="selectCostPriceRelevancyById" parameterType="String" resultMap="CostPriceRelevancyResult"> + <include refid="selectCostPriceRelevancyVo"/> + where id = #{id} + </select> + + <insert id="insertCostPriceRelevancy" parameterType="CostPriceRelevancy"> + insert into cost_price_relevancy + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="createTime != null">create_time,</if> + <if test="createBy != null">create_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="remark != null">remark,</if> + <if test="nodeId != null">node_id,</if> + <if test="tacticsId != null">tactics_id,</if> + <if test="energyType != null">energy_type,</if> + <if test="effectiveBeginTime != null">effective_begin_time,</if> + <if test="effectiveEndTime != null">effective_end_time,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="createTime != null">#{createTime},</if> + <if test="createBy != null">#{createBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="remark != null">#{remark},</if> + <if test="nodeId != null">#{nodeId},</if> + <if test="tacticsId != null">#{tacticsId},</if> + <if test="energyType != null">#{energyType},</if> + <if test="effectiveBeginTime != null">#{effectiveBeginTime},</if> + <if test="effectiveEndTime != null">#{effectiveEndTime},</if> + </trim> + </insert> + + <update id="updateCostPriceRelevancy" parameterType="CostPriceRelevancy"> + update cost_price_relevancy + <trim prefix="SET" suffixOverrides=","> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="nodeId != null">node_id = #{nodeId},</if> + <if test="tacticsId != null">tactics_id = #{tacticsId},</if> + <if test="energyType != null">energy_type = #{energyType},</if> + <if test="effectiveBeginTime != null">effective_begin_time = #{effectiveBeginTime},</if> + <if test="effectiveEndTime != null">effective_end_time = #{effectiveEndTime},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteCostPriceRelevancyById" parameterType="String"> + delete from cost_price_relevancy where id = #{id} + </delete> + + <delete id="deleteCostPriceRelevancyByIds" parameterType="String"> + delete from cost_price_relevancy where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> + + <select id="selectCostPriceRelevancyByNodeId" parameterType="String" resultType="com.zhitan.costmanagement.domain.vo.CostPriceRelevancyVo"> + SELECT + item.electricity_type AS electricityType, + item.price + FROM + cost_price_relevancy re + INNER JOIN cost_price_tactics ta ON re.tactics_id = ta.ID + INNER JOIN cost_price_tactics_item item ON item.tactics_id = ta.ID + WHERE + re.node_id = #{nodeId} + and item.electricity_type=#{elType} + + </select> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsItemMapper.xml b/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsItemMapper.xml new file mode 100644 index 0000000..0d3b5f4 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsItemMapper.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.costmanagement.mapper.CostPriceTacticsItemMapper"> + + <resultMap type="CostPriceTacticsItem" id="CostPriceTacticsItemResult"> + <result property="id" column="id" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="remark" column="remark" /> + <result property="rangeType" column="range_type" /> + <result property="tacticsNumber" column="tactics_number" /> + <result property="tacticsId" column="tactics_id" /> + <result property="electricityType" column="electricity_type" /> + <result property="slotsMin" column="slots_min" /> + <result property="slotsMax" column="slots_max" /> + <result property="price" column="price" /> + </resultMap> + + <sql id="selectCostPriceTacticsItemVo"> + select id, create_time, create_by, update_time, update_by, remark, range_type, tactics_number, tactics_id, electricity_type, slots_min, slots_max, price from cost_price_tactics_item + </sql> + + <select id="selectCostPriceTacticsItemList" parameterType="CostPriceTacticsItem" resultMap="CostPriceTacticsItemResult"> + <include refid="selectCostPriceTacticsItemVo"/> + <where> + <if test="rangeType != null and rangeType != ''"> and range_type = #{rangeType}</if> + <if test="tacticsNumber != null and tacticsNumber != ''"> and tactics_number = #{tacticsNumber}</if> + <if test="tacticsId != null and tacticsId != ''"> and tactics_id = #{tacticsId}</if> + <if test="electricityType != null and electricityType != ''"> and electricity_type = #{electricityType}</if> + <if test="slotsMin != null and slotsMin != ''"> and slots_min = #{slotsMin}</if> + <if test="slotsMax != null and slotsMax != ''"> and slots_max = #{slotsMax}</if> + <if test="price != null and price != ''"> and price = #{price}</if> + </where> + </select> + + <select id="selectCostPriceTacticsItemById" parameterType="String" resultMap="CostPriceTacticsItemResult"> + <include refid="selectCostPriceTacticsItemVo"/> + where id = #{id} + </select> + + <insert id="insertCostPriceTacticsItem" parameterType="CostPriceTacticsItem"> + insert into cost_price_tactics_item + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="createTime != null">create_time,</if> + <if test="createBy != null">create_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="remark != null">remark,</if> + <if test="rangeType != null">range_type,</if> + <if test="tacticsNumber != null">tactics_number,</if> + <if test="tacticsId != null">tactics_id,</if> + <if test="electricityType != null">electricity_type,</if> + <if test="slotsMin != null">slots_min,</if> + <if test="slotsMax != null">slots_max,</if> + <if test="price != null">price,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="createTime != null">#{createTime},</if> + <if test="createBy != null">#{createBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="remark != null">#{remark},</if> + <if test="rangeType != null">#{rangeType},</if> + <if test="tacticsNumber != null">#{tacticsNumber},</if> + <if test="tacticsId != null">#{tacticsId},</if> + <if test="electricityType != null">#{electricityType},</if> + <if test="slotsMin != null">#{slotsMin},</if> + <if test="slotsMax != null">#{slotsMax},</if> + <if test="price != null">#{price},</if> + </trim> + </insert> + + <update id="updateCostPriceTacticsItem" parameterType="CostPriceTacticsItem"> + update cost_price_tactics_item + <trim prefix="SET" suffixOverrides=","> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="rangeType != null">range_type = #{rangeType},</if> + <if test="tacticsNumber != null">tactics_number = #{tacticsNumber},</if> + <if test="tacticsId != null">tactics_id = #{tacticsId},</if> + <if test="electricityType != null">electricity_type = #{electricityType},</if> + <if test="slotsMin != null">slots_min = #{slotsMin},</if> + <if test="slotsMax != null">slots_max = #{slotsMax},</if> + <if test="price != null">price = #{price},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteCostPriceTacticsItemById" parameterType="String"> + delete from cost_price_tactics_item where id = #{id} + </delete> + + <delete id="deleteCostPriceTacticsItemByIds" parameterType="String"> + delete from cost_price_tactics_item where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsMapper.xml b/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsMapper.xml new file mode 100644 index 0000000..9f5fcca --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/costmanagement/CostPriceTacticsMapper.xml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.costmanagement.mapper.CostPriceTacticsMapper"> + + <resultMap type="CostPriceTactics" id="CostPriceTacticsResult"> + <result property="id" column="id" /> + <result property="type" column="type" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="remark" column="remark" /> + <result property="tacticsNumber" column="tactics_number" /> + <result property="tacticsName" column="tactics_name" /> + <result property="energyType" column="energy_type" /> + </resultMap> + + <sql id="selectCostPriceTacticsVo"> + select id, type, create_time, create_by, update_time, update_by, remark, tactics_number, tactics_name, energy_type from cost_price_tactics + </sql> + + <select id="selectCostPriceTacticsList" parameterType="CostPriceTactics" resultMap="CostPriceTacticsResult"> + <include refid="selectCostPriceTacticsVo"/> + <where> + <if test="type != null and type != ''"> and type = #{type}</if> + <if test="tacticsNumber != null and tacticsNumber != ''"> and tactics_number = #{tacticsNumber}</if> + <if test="tacticsName != null and tacticsName != ''"> and tactics_name like concat('%', #{tacticsName}, '%')</if> + <if test="energyType != null and energyType != ''"> and energy_type = #{energyType}</if> + </where> + </select> + + <select id="selectCostPriceTacticsById" parameterType="String" resultMap="CostPriceTacticsResult"> + <include refid="selectCostPriceTacticsVo"/> + where id = #{id} + </select> + + <insert id="insertCostPriceTactics" parameterType="CostPriceTactics"> + insert into cost_price_tactics + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="type != null">type,</if> + <if test="createTime != null">create_time,</if> + <if test="createBy != null">create_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="remark != null">remark,</if> + <if test="tacticsNumber != null">tactics_number,</if> + <if test="tacticsName != null">tactics_name,</if> + <if test="energyType != null">energy_type,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="type != null">#{type},</if> + <if test="createTime != null">#{createTime},</if> + <if test="createBy != null">#{createBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="remark != null">#{remark},</if> + <if test="tacticsNumber != null">#{tacticsNumber},</if> + <if test="tacticsName != null">#{tacticsName},</if> + <if test="energyType != null">#{energyType},</if> + </trim> + </insert> + + <update id="updateCostPriceTactics" parameterType="CostPriceTactics"> + update cost_price_tactics + <trim prefix="SET" suffixOverrides=","> + <if test="type != null">type = #{type},</if> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="tacticsNumber != null">tactics_number = #{tacticsNumber},</if> + <if test="tacticsName != null">tactics_name = #{tacticsName},</if> + <if test="energyType != null">energy_type = #{energyType},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteCostPriceTacticsById" parameterType="String"> + delete from cost_price_tactics where id = #{id} + </delete> + + <delete id="deleteCostPriceTacticsByIds" parameterType="String"> + delete from cost_price_tactics where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> + + <select id="selectCostPriceTacticsListAll" resultMap="CostPriceTacticsResult"> + <include refid="selectCostPriceTacticsVo"/> + <where> + <if test="type != null and type != ''"> and type = #{type}</if> + <if test="tacticsNumber != null and tacticsNumber != ''"> and tactics_number = #{tacticsNumber}</if> + <if test="tacticsName != null and tacticsName != ''"> and tactics_name like concat('%', #{tacticsName}, '%')</if> + <if test="energyType != null and energyType != ''"> and energy_type = #{energyType}</if> + </where> + </select> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/dataitem/DataItemMapper.xml b/zhitan-system/src/main/resources/mapper/dataitem/DataItemMapper.xml index 327e8d1..d64ec15 100644 --- a/zhitan-system/src/main/resources/mapper/dataitem/DataItemMapper.xml +++ b/zhitan-system/src/main/resources/mapper/dataitem/DataItemMapper.xml @@ -136,4 +136,67 @@ </foreach> AND time_code = #{timeCode} </select> + <select id="getUpCarbonEmission" resultType="com.zhitan.carbonemission.domain.CarbonEmission"> + SELECT + di.index_id, + di.data_time, + di.value, + ei.energy_id + FROM + data_item di + JOIN energy_index ei ON di.index_id = ei.index_id + WHERE + ei.energy_id != '' and + di.index_id IN ( SELECT index_id FROM node_index WHERE node_id = #{indexId}) + AND di.data_time BETWEEN #{beginTime} AND #{endTime} + AND di.time_type = #{timeType} + </select> + <select id="getMiddleCarbonEmission" resultType="com.zhitan.carbonemission.domain.CarbonEmission"> + SELECT + di.index_id, + di.data_time, + CASE + WHEN di.time_type = 'MONTH' THEN + TO_CHAR( di.create_time, 'MM' ) + WHEN di.time_type = 'DAY' THEN + TO_CHAR( di.create_time, 'DD' ) + WHEN di.time_type = 'HOUR' THEN + TO_CHAR( di.data_time, 'HH' ) + ELSE TO_CHAR( di.data_time, 'YYMMDD' ) + END AS dataTimeStr, + di.value, + ei.energy_id, + di.time_type + FROM + data_item di + JOIN energy_index ei ON di.index_id = ei.index_id + WHERE + di.index_id IN ( SELECT index_id FROM node_index WHERE node_id = #{indexId}) + <if test="emissionType !='' and emissionType !=null and emissionType =='allType'"> + AND ei.energy_id != '' + </if> + <if test="emissionType !='' and emissionType !=null and emissionType !='allType'"> + AND ei.energy_id = #{emissionType} + </if> + AND di.data_time BETWEEN #{beginTime} AND #{endTime} + AND di.time_type = #{timeType} + </select> + <select id="getDownCarbonEmission" resultType="com.zhitan.carbonemission.domain.CarbonEmission"> + SELECT + di.index_id, + di.data_time, + di.value, + ei.energy_id, + mn.name as nodeName + FROM + model_node mn + LEFT JOIN node_index ni ON mn.node_id = ni.node_id + LEFT JOIN data_item di ON di.index_id = ni.index_id + LEFT JOIN energy_index ei ON di.index_id = ei.index_id + WHERE + ei.energy_id != '' + AND mn.parent_id = #{indexId} + AND di.data_time BETWEEN #{beginTime} AND #{endTime} + AND di.time_type = #{timeType} + </select> </mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/energyData/EnergyDataMapper.xml b/zhitan-system/src/main/resources/mapper/energyData/EnergyDataMapper.xml new file mode 100644 index 0000000..0b8a1df --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/energyData/EnergyDataMapper.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.energydata.mapper.EnergyDataStatisticMapper"> + + <select id="getModelNodeIndexIdByFixedNodeIds" resultType="com.zhitan.model.domain.vo.ModelNodeIndexInfor"> + SELECT mn.node_id nodeId, + mn."name" "name", + ni.index_id indexId, + ei.energy_id + FROM "model_node" mn + LEFT JOIN "node_index" ni ON mn.node_id = ni.node_id + left join energy_index ei on ni.index_id = ei.index_id + WHERE mn.model_code = #{modelCode} and ei.index_type = 'STATISTIC' + and mn.node_id in + <foreach collection="fixedNodeIds" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + </select> + + +</mapper> diff --git a/zhitan-system/src/main/resources/mapper/energydatastatistics/EnergyDataStatisticMapper.xml b/zhitan-system/src/main/resources/mapper/energydatastatistics/EnergyDataStatisticMapper.xml new file mode 100644 index 0000000..b0fcde2 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/energydatastatistics/EnergyDataStatisticMapper.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.model.mapper.EnergyDataStatisticMapper"> + + <resultMap type="com.zhitan.model.domain.CalcFunction" id="CalcFunctionResult"> + <result property="id" column="id"/> + <result property="info" column="info"/> + <result property="funcName" column="func_name"/> + <result property="funcText" column="func_text"/> + </resultMap> + + <sql id="selectCalcFunctionVo"> + select id, func_name, func_text, info + from calc_function + </sql> + + <select id="selectCalcFunctionList" parameterType="com.zhitan.model.domain.CalcFunction" resultMap="CalcFunctionResult"> + <include refid="selectCalcFunctionVo"/> + <where> + <if test="funcName != null and funcName != ''">and func_name like concat('%', #{funcName}, '%')</if> + </where> + </select> + + <select id="selectCalcFunctionById" parameterType="String" resultMap="CalcFunctionResult"> + <include refid="selectCalcFunctionVo"/> + where id = #{id} + </select> + + <insert id="insertCalcFunction" parameterType="com.zhitan.model.domain.CalcFunction"> + insert into calc_function + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="funcName != null and funcName != ''">func_name,</if> + <if test="funcText != null and funcText != ''">func_text,</if> + <if test="info != null and info != ''">info,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="funcName != null and funcName != ''">#{funcName},</if> + <if test="funcText != null and funcText != ''">#{funcText},</if> + <if test="info != null and info != ''">#{info},</if> + </trim> + </insert> + + <update id="updateCalcFunction" parameterType="com.zhitan.model.domain.CalcFunction"> + update calc_function + <trim prefix="SET" suffixOverrides=","> + <if test="info != null and info != ''">info = #{info},</if> + <if test="funcName != null and funcName != ''">func_name = #{funcName},</if> + <if test="funcText != null and funcText != ''">func_text = #{funcText},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteCalcFunctionById" parameterType="String"> + delete + from calc_function + where id = #{id} + </delete> + + <delete id="deleteCalcFunctionByIds" parameterType="String"> + delete from calc_function where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> + +</mapper> diff --git a/zhitan-system/src/main/resources/mapper/model/EnergyIndexMapper.xml b/zhitan-system/src/main/resources/mapper/model/EnergyIndexMapper.xml index d38240b..3ea43ac 100644 --- a/zhitan-system/src/main/resources/mapper/model/EnergyIndexMapper.xml +++ b/zhitan-system/src/main/resources/mapper/model/EnergyIndexMapper.xml @@ -184,7 +184,7 @@ <if test="energyId != null">#{energyId}, </if> </trim> - + </insert> <insert id="insertNodeIndex"> insert into node_index (node_id, index_id) values (#{nodeId}, #{indexId}); @@ -331,7 +331,7 @@ and ei.meter_id = me.id order by ei.order_num </select> - + <select id="selectEnergyIndexPage" resultMap="EnergyIndexResult"> select ni.index_id, name, code, index_type, remark, unit_id, index_category from energy_index ei left join node_index ni on ei.index_id = ni.index_id @@ -346,7 +346,7 @@ </if> </where> order by ei.order_num - + </select> <select id="listIndexByMeterIds" resultType="com.zhitan.model.domain.EnergyIndex"> select ei.index_id, @@ -363,7 +363,7 @@ from energy_index ei left join node_index ni on ei.index_id = ni.index_id <where> - + <if test="nodeId != null and nodeId != ''">and ni.node_id = #{nodeId}</if> <if test="meterIds != null"> and ei.meter_id in @@ -377,4 +377,18 @@ <include refid="selectEnergyIndexVo"/> where code = #{cdoe} </select> + <select id="getIndexByCode" resultType="com.zhitan.model.domain.EnergyIndex"> + SELECT ei.code,mi.meter_name||'_'||ei.name as name from energy_index ei + LEFT JOIN node_device nd on ei.meter_id = nd.device_id + LEFT JOIN meter_implement mi on mi."id" = nd.device_id + <where> + <if test="nodeId != null and nodeId != ''">and nd.node_id = #{nodeId}</if> + <if test="code != null and code != ''"> + and (mi.meter_name like concat('%', #{code}, '%') + or ei.code like concat('%', #{code}, '%') + or ei.name like concat('%', #{code}, '%') + ) + </if> + </where> + </select> </mapper> diff --git a/zhitan-system/src/main/resources/mapper/model/ModelNodeMapper.xml b/zhitan-system/src/main/resources/mapper/model/ModelNodeMapper.xml index 7fbb5b8..c704454 100644 --- a/zhitan-system/src/main/resources/mapper/model/ModelNodeMapper.xml +++ b/zhitan-system/src/main/resources/mapper/model/ModelNodeMapper.xml @@ -377,7 +377,7 @@ values (#{nodeId}, #{indexId}) </foreach> </insert> - + <select id="getModelNodeIndexIdByNodeId" resultType="com.zhitan.model.domain.vo.ModelNodeIndexInfor"> SELECT mn.node_id nodeId, mn."name" "name", @@ -386,7 +386,7 @@ FROM "model_node" mn LEFT JOIN "node_index" ni ON mn.node_id = ni.node_id LEFT JOIN energy_index ei on ni.index_id = ei.index_id - WHERE ni.node_id = #{nodeId} + WHERE ni.node_id = #{nodeId} <if test="energyType!=null and energyType!=''"> and ei.energy_id = #{energyType} </if> @@ -404,7 +404,7 @@ <select id="getFirstModeNodeInfo" resultType="com.zhitan.model.domain.ModelNode"> <include refid="selectModelNodeVo"/> where model_code = #{modelCode} AND parent_id is null - order by order_num + order by order_num </select> <select id="selectIndexByNodeIds" resultType="com.zhitan.model.domain.vo.ModelNodeIndexInfor"> SELECT mn.node_id nodeId, @@ -414,10 +414,17 @@ FROM "model_node" mn LEFT JOIN "node_index" ni ON mn.node_id = ni.node_id left join energy_index ei on ni.index_id = ei.index_id - WHERE mn.model_code = #{modelCode} + <where> + mn.model_code = #{modelCode} AND mn.node_id in <foreach collection="nodeIds" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> + <if test="modelCode!=null and modelCode!='' and nodeIds.size>0"> + and ei.index_type='STATISTIC' + </if> + + </where> + </select> </mapper> diff --git a/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityDataItemMapper.xml b/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityDataItemMapper.xml index 6680811..2676c7d 100644 --- a/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityDataItemMapper.xml +++ b/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityDataItemMapper.xml @@ -27,5 +27,26 @@ AND (data_time BETWEEN #{startTime} AND #{endTime}) AND time_type = #{timeType} </select> + <select id="getDataStatisticsDeviationAnalysis" + resultType="com.zhitan.peakvalley.domain.ElectricityDataItem"> + SELECT + index_code indexCode, + time_code timeCode, + electricity_type electricityType, + data_time dataTime, + electricity, + "cost", + time_type timeType, + price, + remark + FROM + "electricity_data_item" + WHERE + index_id IN + <foreach collection="indexIdSet" item="indexId" open="(" separator="," close=")"> + #{indexId} + </foreach> + AND time_type = #{timeType} + </select> </mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityPriceDateMapper.xml b/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityPriceDateMapper.xml index 9e56581..2672b6b 100644 --- a/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityPriceDateMapper.xml +++ b/zhitan-system/src/main/resources/mapper/peakvalley/ElectricityPriceDateMapper.xml @@ -80,4 +80,10 @@ #{id} </foreach> </delete> + + <select id="selectElectricityPriceDatePageTacticsAll" resultMap="ElectricityPriceDateResult"> + <include refid="selectElectricityPriceDateVo"/> + WHERE begin_date < CURRENT_TIMESTAMP + AND end_date > CURRENT_TIMESTAMP + </select> </mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/powerDistribution/powerDistributionMapper.xml b/zhitan-system/src/main/resources/mapper/powerDistribution/powerDistributionMapper.xml new file mode 100644 index 0000000..36648f4 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/powerDistribution/powerDistributionMapper.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.powerDistribution.mapper.PowerDistributionMapper"> + <delete id="deletePowerDistributionByIds" parameterType="String"> + delete from power_distribution + <where> + id in + <foreach collection="ids" item="id" open="(" separator="," close=")"> + #{id} + </foreach> + </where> + </delete> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysItemMapper.xml b/zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysItemMapper.xml new file mode 100644 index 0000000..c88fda2 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysItemMapper.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.spikesandvalleys.mapper.SpikesAndValleysItemMapper"> + + <resultMap type="SpikesAndValleysItem" id="SpikesAndValleysItemResult"> + <result property="id" column="id" /> + <result property="time" column="time" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="remark" column="remark" /> + <result property="electrovalency" column="electrovalency" /> + <result property="startTime" column="start_time" /> + <result property="endTime" column="end_time" /> + <result property="schemeId" column="scheme_id" /> + </resultMap> + + <sql id="selectSpikesAndValleysItemVo"> + select id, time, create_time, create_by, update_time, update_by, remark, electrovalency, start_time, end_time, scheme_id from spikes_and_valleys_item + </sql> + + <select id="selectSpikesAndValleysItemList" parameterType="SpikesAndValleysItem" resultMap="SpikesAndValleysItemResult"> + <include refid="selectSpikesAndValleysItemVo"/> + <where> + <if test="time != null and time != ''"> and time = #{time}</if> + <if test="electrovalency != null and electrovalency != ''"> and electrovalency = #{electrovalency}</if> + <if test="startTime != null and startTime != ''"> and start_time = #{startTime}</if> + <if test="endTime != null and endTime != ''"> and end_time = #{endTime}</if> + <if test="schemeId != null and schemeId != ''"> and scheme_id = #{schemeId}</if> + </where> + </select> + + <select id="selectSpikesAndValleysItemById" parameterType="String" resultMap="SpikesAndValleysItemResult"> + <include refid="selectSpikesAndValleysItemVo"/> + where id = #{id} + </select> + + <insert id="insertSpikesAndValleysItem" parameterType="SpikesAndValleysItem"> + insert into spikes_and_valleys_item + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="time != null">time,</if> + <if test="createTime != null">create_time,</if> + <if test="createBy != null">create_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="remark != null">remark,</if> + <if test="electrovalency != null">electrovalency,</if> + <if test="startTime != null">start_time,</if> + <if test="endTime != null">end_time,</if> + <if test="schemeId != null">scheme_id,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="time != null">#{time},</if> + <if test="createTime != null">#{createTime},</if> + <if test="createBy != null">#{createBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="remark != null">#{remark},</if> + <if test="electrovalency != null">#{electrovalency},</if> + <if test="startTime != null">#{startTime},</if> + <if test="endTime != null">#{endTime},</if> + <if test="schemeId != null">#{schemeId},</if> + </trim> + </insert> + + <update id="updateSpikesAndValleysItem" parameterType="SpikesAndValleysItem"> + update spikes_and_valleys_item + <trim prefix="SET" suffixOverrides=","> + <if test="time != null">time = #{time},</if> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="electrovalency != null">electrovalency = #{electrovalency},</if> + <if test="startTime != null">start_time = #{startTime},</if> + <if test="endTime != null">end_time = #{endTime},</if> + <if test="schemeId != null">scheme_id = #{schemeId},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteSpikesAndValleysItemById" parameterType="String"> + delete from spikes_and_valleys_item where id = #{id} + </delete> + + <delete id="deleteSpikesAndValleysItemByIds" parameterType="String"> + delete from spikes_and_valleys_item where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysSchemeMapper.xml b/zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysSchemeMapper.xml new file mode 100644 index 0000000..3cc6610 --- /dev/null +++ b/zhitan-system/src/main/resources/mapper/spikesandvalleys/SpikesAndValleysSchemeMapper.xml @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.zhitan.spikesandvalleys.mapper.SpikesAndValleysSchemeMapper"> + + <resultMap type="SpikesAndValleysScheme" id="SpikesAndValleysSchemeResult"> + <result property="id" column="id" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="remark" column="remark" /> + <result property="schemeName" column="scheme_name" /> + <result property="executeTime" column="execute_time" /> + <result property="type" column="type" /> + </resultMap> + + <sql id="selectSpikesAndValleysSchemeVo"> + select id, create_time, create_by, update_time, update_by, remark, scheme_name, execute_time, type from spikes_and_valleys_scheme + </sql> + + <select id="selectSpikesAndValleysSchemeList" parameterType="SpikesAndValleysScheme" resultMap="SpikesAndValleysSchemeResult"> + <include refid="selectSpikesAndValleysSchemeVo"/> + <where> + <if test="schemeName != null and schemeName != ''"> and scheme_name like concat('%', #{schemeName}, '%')</if> + <if test="executeTime != null "> and execute_time = #{executeTime}</if> + <if test="type != null and type != ''"> and type = #{type}</if> + </where> + </select> + + <select id="selectSpikesAndValleysSchemeById" parameterType="String" resultMap="SpikesAndValleysSchemeResult"> + <include refid="selectSpikesAndValleysSchemeVo"/> + where id = #{id} + </select> + + <insert id="insertSpikesAndValleysScheme" parameterType="SpikesAndValleysScheme"> + insert into spikes_and_valleys_scheme + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">id,</if> + <if test="createTime != null">create_time,</if> + <if test="createBy != null">create_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="remark != null">remark,</if> + <if test="schemeName != null">scheme_name,</if> + <if test="executeTime != null">execute_time,</if> + <if test="type != null">type,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null and id != ''">#{id},</if> + <if test="createTime != null">#{createTime},</if> + <if test="createBy != null">#{createBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="remark != null">#{remark},</if> + <if test="schemeName != null">#{schemeName},</if> + <if test="executeTime != null">#{executeTime},</if> + <if test="type != null">#{type},</if> + </trim> + </insert> + + <update id="updateSpikesAndValleysScheme" parameterType="SpikesAndValleysScheme"> + update spikes_and_valleys_scheme + <trim prefix="SET" suffixOverrides=","> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="schemeName != null">scheme_name = #{schemeName},</if> + <if test="executeTime != null">execute_time = #{executeTime},</if> + <if test="type != null">type = #{type},</if> + </trim> + where id = #{id} + </update> + + <delete id="deleteSpikesAndValleysSchemeById" parameterType="String"> + delete from spikes_and_valleys_scheme where id = #{id} + </delete> + + <delete id="deleteSpikesAndValleysSchemeByIds" parameterType="String"> + delete from spikes_and_valleys_scheme where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> +</mapper> \ No newline at end of file diff --git a/zhitan-system/src/main/resources/mapper/system/SysUserMapper.xml b/zhitan-system/src/main/resources/mapper/system/SysUserMapper.xml index 965abd8..68e0991 100644 --- a/zhitan-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/zhitan-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -23,6 +23,7 @@ <result property="updateBy" column="update_by"/> <result property="updateTime" column="update_time"/> <result property="remark" column="remark"/> + <result property="singleUser" column="single_user"/> <association property="dept" javaType="SysDept" resultMap="deptResult" /> <collection property="roles" javaType="java.util.List" resultMap="RoleResult"/> </resultMap> @@ -63,6 +64,7 @@ u.create_by, u.create_time, u.remark, + u.single_user, d.dept_id, d.parent_id, d.ancestors, @@ -84,7 +86,7 @@ <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phone_number, u.password, u.sex, - u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from + u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.single_user, d.dept_name, d.leader from sys_user u left join sys_dept d on u.dept_id = d.dept_id where u.del_flag = '0' @@ -147,6 +149,7 @@ <if test="status != null and status != ''">status,</if> <if test="createBy != null and createBy != ''">create_by,</if> <if test="remark != null and remark != ''">remark,</if> + <if test="singleUser != null and singleUser != ''">single_user,</if> create_time )values( <if test="userId != null and userId != ''">#{userId},</if> @@ -161,6 +164,7 @@ <if test="status != null and status != ''">#{status},</if> <if test="createBy != null and createBy != ''">#{createBy},</if> <if test="remark != null and remark != ''">#{remark},</if> + <if test="singleUser != null and singleUser != ''">#{singleUser},</if> now() ) </insert> @@ -181,6 +185,7 @@ <if test="loginDate != null">login_date = #{loginDate},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="remark != null">remark = #{remark},</if> + <if test="singleUser != null and singleUser != ''">single_user = #{singleUser},</if> update_time = now() </set> where user_id = #{userId} @@ -219,4 +224,4 @@ </foreach> </delete> -</mapper> +</mapper> -- Gitblit v1.9.3