zhitan-admin/src/main/java/com/zhitan/web/controller/energydatastatistics/EnergyDataStatisticsController.java
@@ -44,7 +44,7 @@ public AjaxResult energyConsumptionSummationDay() { try { String timeType = "DAY"; String modelCode = "COMPREHENSIVE_CODE"; String modelCode = "LBJT"; return AjaxResult.success(homepageService.energyConsumptionSummation(timeType,modelCode)); } catch (Exception ex) { logger.error("获取出错!", ex); @@ -60,7 +60,7 @@ @GetMapping("/energyConsumptionSummation") public AjaxResult energyConsumptionSummation(String timeType) { try { String modelCode = "COMPREHENSIVE_CODE"; String modelCode = "LBJT"; return AjaxResult.success(statisticService.energyConsumptionSummation(timeType,modelCode)); } catch (Exception ex) { logger.error("获取出错!", ex); @@ -76,7 +76,7 @@ public AjaxResult factoryEnergyConsumption() { try { String timeType = "MONTH"; String modelCode = "COMPREHENSIVE_CODE"; String modelCode = "LBJT"; FactoryEnergyConsumptionVo vo=statisticService.factoryEnergyConsumption(timeType,modelCode); return AjaxResult.success(vo); } catch (Exception ex) { @@ -92,7 +92,7 @@ @GetMapping("/segmentAnalysis/year") public AjaxResult segmentAnalysisMonth() { PeakValleyDTO dto =new PeakValleyDTO(); dto.setModelCode("COMPREHENSIVE_CODE"); dto.setModelCode("LBJT"); dto.setTimeType("YEAR"); dto.setQueryTime(new Date()); return AjaxResult.success(statisticService.segmentAnalysisMonth(dto)); @@ -106,7 +106,7 @@ @GetMapping("/segmentAnalysis/month") public AjaxResult segmentAnalysisDay() { PeakValleyDTO dto =new PeakValleyDTO(); dto.setModelCode("COMPREHENSIVE_CODE"); dto.setModelCode("LBJT"); dto.setTimeType("MONTH"); dto.setQueryTime(new Date()); return AjaxResult.success(statisticService.segmentAnalysisDay(dto)); @@ -119,7 +119,7 @@ @GetMapping("/segmentAnalysis/day") public AjaxResult segmentAnalysisHour() { PeakValleyDTO dto =new PeakValleyDTO(); dto.setModelCode("COMPREHENSIVE_CODE"); dto.setModelCode("LBJT"); dto.setTimeType("DAY"); dto.setQueryTime(new Date()); return AjaxResult.success(statisticService.segmentAnalysisHour(dto)); @@ -132,7 +132,7 @@ @GetMapping("/purchaseConsumption") public AjaxResult purchaseConsumption() { String timeType="MONTH"; String modelCode = "COMPREHENSIVE_CODE"; String modelCode = "LBJT"; List<PurchaseConsumptionVo> consumptionAnalysisVO = statisticService.purchaseConsumption(modelCode,timeType); return AjaxResult.success(consumptionAnalysisVO); } @@ -143,7 +143,7 @@ */ @GetMapping("/energyConsumptionRanking") public AjaxResult energyConsumptionRanking(String timeType) { String modelCode = "COMPREHENSIVE_CODE"; String modelCode = "LBJT"; List<RankingEnergyData> consumptionAnalysisVO = statisticService.energyConsumptionRanking(modelCode,timeType); return AjaxResult.success(consumptionAnalysisVO); } @@ -154,7 +154,7 @@ */ @GetMapping("/costProp") public AjaxResult costProp(String timeType) { String modelCode = "COMPREHENSIVE_CODE"; String modelCode = "LBJT"; List<PurchaseConsumptionVo> consumptionAnalysisVO = statisticService.costProp(modelCode, timeType); return AjaxResult.success(consumptionAnalysisVO); @@ -167,7 +167,7 @@ @GetMapping("/peakValley") public AjaxResult peakValley(String timeType) { try { String modelcode = "COMPREHENSIVE_CODE"; String modelcode = "LBJT"; List<HomePeakValleyVO> vo = homepageService.peakValley(timeType,modelcode); return AjaxResult.success(vo); } catch (Exception ex) { zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java
@@ -32,7 +32,7 @@ @GetMapping("/energyConsumptionSummation") public AjaxResult energyConsumptionSummation(String timeType) { try { String modelcode = "COMPREHENSIVE_CODE"; String modelcode = "LBJT"; return AjaxResult.success(homepageService.energyConsumptionSummation(timeType, modelcode)); } catch (Exception ex) { logger.error("获取出错!", ex); @@ -49,7 +49,7 @@ @GetMapping("/energyConsumptionTrend") public AjaxResult energyConsumptionTrend(String timeType) { try { String modelcode = "COMPREHENSIVE_CODE"; String modelcode = "LBJT"; HomeEnergyConsumptionTrendVO vo = homepageService.energyConsumptionTrend(timeType, modelcode); return AjaxResult.success(vo); @@ -67,7 +67,7 @@ @GetMapping("/energyConsumptionRanking") public AjaxResult energyConsumptionRanking(String timeType) { try { String modelcode = "COMPREHENSIVE_CODE"; String modelcode = "LBJT"; List<RankingEnergyData> consumptionAnalysisVO = homepageService.energyConsumptionRanking(modelcode, timeType); return AjaxResult.success(consumptionAnalysisVO); } catch (Exception ex) { @@ -84,7 +84,7 @@ @GetMapping("/peakValley") public AjaxResult peakValley(String timeType) { try { String modelcode = "COMPREHENSIVE_CODE"; String modelcode = "LBJT"; List<HomePeakValleyVO> vo = homepageService.peakValley(timeType, modelcode); return AjaxResult.success(vo); } catch (Exception ex) { zhitan-admin/src/main/java/com/zhitan/web/controller/model/EnergyIndexController.java
@@ -18,18 +18,12 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; /** * 指标信息Controller * * @author fanxinfu * @date 2020-02-14 * 指标信息控制器 */ @RestController @RequestMapping("/basicsetting/energyindex") @@ -39,7 +33,11 @@ private IEnergyIndexService energyIndexService; /** * 查询指标信息列表 * 分页查询指标信息 * @param energyIndex 查询条件 * @param pageNum 当前页码 * @param pageSize 页面大小 * @return 分页数据 */ @PreAuthorize("@ss.hasPermi('energyindex:energyindex:query')") @GetMapping("/list") @@ -51,7 +49,9 @@ } /** * 查询指标信息列表 * 条件查询指标信息(不带分页) * @param query 查询条件 * @return 指标列表 */ @GetMapping("/filter") public AjaxResult filter(EnergyIndexQuery query) { @@ -60,7 +60,9 @@ } /** * 查询指标信息列表 * 查询采集指标列表(用于设备关联) * @param deviceId 设备ID * @return 分页数据 */ @PreAuthorize("@ss.hasPermi('energyindex:energyindex:query')") @GetMapping("/collectIndex") @@ -132,20 +134,19 @@ @Log(title = "指标信息", businessType = BusinessType.DELETE) @DeleteMapping("/{indexIds}") public AjaxResult remove(@PathVariable String[] indexIds) { // 步骤1: 参数校验 if (ObjectUtils.isEmpty(indexIds)) return AjaxResult.success(); List<String> indexIdList = Arrays.asList(indexIds); if (ObjectUtils.isEmpty(indexIdList)) { return AjaxResult.success(); } // 查询模型节点点位信息 // 步骤2: 检查是否被模型关联 List<ModelNodeIndexInfo> modelNodeIndexInfoList = energyIndexService.getModelNodeIndexInfoListByIndexIds(indexIds); if (ObjectUtils.isNotEmpty(modelNodeIndexInfoList)) { ModelNodeIndexInfo modelNodeIndexInfo = modelNodeIndexInfoList.stream().findFirst().get(); return AjaxResult.error("采集指标 " + modelNodeIndexInfo.getIndexName() + " 已被模型 " + modelNodeIndexInfo.getModelName() + " 关联,不能删除!"); if (!modelNodeIndexInfoList.isEmpty()) { // 存在关联关系返回错误 ModelNodeIndexInfo firstItem = modelNodeIndexInfoList.get(0); return AjaxResult.error("指标 " + firstItem.getIndexName() + " 已被模型 " + firstItem.getModelName() + " 关联,不能删除!"); } energyIndexService.removeEnergyIndex(indexIdList); // 步骤3: 执行删除 energyIndexService.removeEnergyIndex(Arrays.asList(indexIds)); return AjaxResult.success(); } zhitan-admin/src/main/resources/application-prod.yml
@@ -6,8 +6,8 @@ druid: # 主库数据源 master: url: jdbc:postgresql://127.0.0.1:5432/energy_ml username: root url: jdbc:postgresql://127.0.0.1:5432/postgres username: postgres password: 123456 # 从库数据源 slave: @@ -35,7 +35,7 @@ # 配置一个连接在池中最大生存的时间,单位是毫秒 maxEvictableIdleTimeMillis: 900000 # 配置检测连接是否有效 validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false @@ -59,3 +59,11 @@ wall: config: multi-statement-allow: true keycloak: # keycloak 服务器地址 server-url: https://lanbaosystem.shlanbao.cn:8443 realm: lanbao client-id: DataCapture client-secret: kplisa4lJHEIM6knqefVbxln85QbA5NX redirect-uri: http://192.168.12.236:80/social-callback scopes: [openid, email, phone, profile] zhitan-admin/src/main/resources/application.yml
@@ -17,7 +17,7 @@ # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8080 port: 8088 servlet: # 应用的访问路径 context-path: / @@ -143,7 +143,8 @@ kickoutAfter: false rtdb: host: http://127.0.0.1:8086 # 用户名root 密码12345678 token: AminQagYp5rjb09mFPYvriK0T0vlF-zmwboqtUzdcq3nkXNuhnEpMuG_Ht5vtfWC4xBIVOThvoxy5reTer9XcQ== #token: AminQagYp5rjb09mFPYvriK0T0vlF-zmwboqtUzdcq3nkXNuhnEpMuG_Ht5vtfWC4xBIVOThvoxy5reTer9XcQ== token: i8WwVZz3RvkEVF3qGaY8uIDXTFEe2PzjgrKebDzcxlYGKnR-kOK5Hf1S5G4z3p-lc9UO7MQS4qKGL4lIeHSw1A== org: lanbao bucket: nygl measurement: data zhitan-system/src/main/java/com/zhitan/model/service/impl/IndexStorageServiceImpl.java
@@ -12,13 +12,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.*; import java.util.stream.Collectors; import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; /** * 指标存储服务实现类 */ @Service public class IndexStorageServiceImpl implements IIndexStorageService { @@ -29,56 +30,89 @@ @Autowired private IEnergyIndexService energyIndexService; /** * 保存指标存储信息 * @param indexId 指标ID * @param indexStorage 指标存储列表 */ @Override public void saveIndexStorage(String indexId, List<IndexStorage> indexStorage) { // 遍历每个存储对象进行存储操作 indexStorage.forEach(storage -> { storage.setIndexId(indexId); if (StringUtils.isEmpty(storage.getId())) { storage.setIndexId(indexId); // 设置指标ID if (StringUtils.isEmpty(storage.getId())) { // 新增记录 storage.setId(UUID.randomUUID().toString()); indexStorageMapper.insertIndexStorage(storage); } else { } else { // 更新记录 indexStorageMapper.updateIndexStorage(storage); } // 保存参数关联关系 indexStorageMapper.saveParams(storage.getId(), storage.getParamIndex()); }); } /** * 保存公式及存储信息(事务方法) * @param indexFormula 公式对象 * @param indexStorage 存储列表 * @param indexId 指标ID */ @Override @Transactional(rollbackFor = Exception.class) public void saveFormulaAndStorage(IndexFormula indexFormula, List<IndexStorage> indexStorage, String indexId) { // 1. 保存公式信息 indexFormulaService.saveIndexFormula(indexFormula); // 2. 处理公式文本参数替换 String calcText = indexFormula.getFormulaText(); List<String> paramNames = new ArrayList<>(); for (IndexFormulaParam param : indexFormula.getIndexFormulaParams()) { calcText = calcText .replace("(" + param.getParamName() + ")", "(" + String.format("'%s'", param.getParamValue()) + ")"); paramNames.add(param.getParamValue()); paramNames.add(param.getParamValue()); // 记录参数名称 } // 3. 获取参数指标 List<EnergyIndex> energyIndexList = energyIndexService.getEnergyIndexByCodes(paramNames); List<String> paramIndex = energyIndexList.stream() .map(EnergyIndex::getIndexId) .collect(Collectors.toList()); // 4. 补充存储对象信息 for (IndexStorage storage : indexStorage) { storage.setCalcText(calcText); storage.setIsPvCalc(indexFormula.getIsPvCalc()); storage.getParamIndex().addAll(paramIndex); storage.setCalcText(calcText); // 存储计算公式文本 storage.setIsPvCalc(indexFormula.getIsPvCalc()); // 存储实时计算标识 storage.getParamIndex().addAll(paramIndex); // 添加参数指标ID } // 5. 保存存储信息 saveIndexStorage(indexId, indexStorage); } /** * 根据指标ID获取存储信息 * @param indexId 指标ID * @return 指标存储列表 */ @Override public List<IndexStorage> getIndexStorage(String indexId) { return indexStorageMapper.getIndexStorage(indexId); } /** * 获取所有计算类存储信息 * @return 包含参数的存储列表 */ @Override public List<IndexStorage> getAllCalcIndexStorage() { // 1. 查询计算类型存储 List<IndexStorage> indexStorageList = indexStorageMapper.getAllCalcIndexStorage(CalcType.CALC); // 2. 查询所有参数信息 List<IndexStorageParam> params = indexStorageMapper.getAllParameter(); // 3. 将参数信息合并到存储对象 indexStorageList.forEach(storage -> { List<String> indexIds = params.stream() .filter(f -> equalsIgnoreCase(f.getStorageId(), storage.getId())) @@ -88,13 +122,17 @@ storage.getParamIndex().addAll(indexIds); } }); return indexStorageList; } /** * 根据指标ID和时间类型获取特定存储 * @param indexId 指标ID * @param timeType 时间类型 * @return 指定时间类型的存储信息 */ @Override public IndexStorage getIndexStorage(String indexId, TimeType timeType) { return indexStorageMapper.getWithTimetype(indexId, timeType); } } zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/PeakValleyServiceImpl.java
@@ -1,6 +1,5 @@ package com.zhitan.peakvalley.service.impl; import cn.hutool.core.date.DateUtil; import com.zhitan.common.enums.ElectricityTypeEnum; import com.zhitan.common.enums.TimeType; @@ -40,10 +39,16 @@ CostPriceRelevancyMapper costPriceRelevancyMapper; /** * 查询统计数据 * 查询尖峰平谷统计数据 * @param dto 请求参数,包含模型代码、节点ID、查询时间、时间类型等 * @return 按时间段分隔的统计结果列表 * * @param dto 请求参数 * @return 结果 * 业务步骤: * 1. 根据查询时间确定起止时间范围 * 2. 查询模型节点关联的指标信息 * 3. 根据指标ID集合查询原始数据 * 4. 按时间分组处理数据 * 5. 循环遍历时间区间,统计各时段的费用和用电量 */ @Override public List<PeakValleyHourDataVO> getDataStatistics(ElectricityDataItemListDTO dto) { @@ -119,6 +124,19 @@ } /** * 按天维度进行尖峰平谷分时段分析 * @param dto 请求参数,包含模型代码、节点ID、查询时间等 * @return 包含日统计总览和图表数据的VO对象 * * 业务步骤: * 1. 初始化统计容器和时间范围 * 2. 查询关联指标并获取原始数据 * 3. 按天聚合数据并计算各时段费用和用电量 * 4. 生成费用/用电量折线图数据 * 5. 计算总消耗量及各时段占比 * 6. 汇总生成最终结果对象 */ @Override public PeakValleyDayVO segmentAnalysisDay(PeakValleyDTO dto) { PeakValleyDayVO peakValleyVO = new PeakValleyDayVO(); @@ -300,6 +318,19 @@ return peakValleyVO; } /** * 按小时维度进行尖峰平谷分时段分析 * @param dto 请求参数,包含模型代码、节点ID、查询时间等 * @return 包含小时级数据和可视化图表的VO对象 * * 业务步骤: * 1. 初始化统计容器和时间范围 * 2. 查询关联指标并获取原始数据 * 3. 按小时统计各时段费用和用电量 * 4. 生成用电量折线图数据 * 5. 计算总用电量及各时段占比饼图数据 * 6. 汇总生成最终结果对象 */ @Override public PeakValleyHourVO segmentAnalysisHour(PeakValleyDTO dto) { PeakValleyHourVO peakValleyVO = new PeakValleyHourVO(); @@ -413,6 +444,17 @@ return peakValleyVO; } /** * 导出小时级尖峰平谷分析数据 * @param dto 请求参数,包含模型代码、节点ID、查询时间等 * @return 小时级详细统计数据列表 * * 业务步骤: * 1. 初始化时间范围 * 2. 查询关联指标并获取原始数据 * 3. 按小时统计各时段数据 * 4. 生成可导出的详细数据列表 */ @Override public List<PeakValleyHourDataVO> segmentAnalysisHourExport(PeakValleyDTO dto) { List<PeakValleyHourDataVO> reportVOList = new ArrayList<>(); @@ -486,6 +528,13 @@ return reportVOList; } /** * 自定义时段的尖峰平谷分析(预留接口) * @param dto 请求参数,包含自定义时间范围等 * @return 分析结果对象 * * 当前实现:暂未开发,返回空值 */ @Override public PeakValleyDayVO segmentAnalysisDayCustomize(PeakValleyDTO dto) { return null; zhitan-vue/src/assets/styles/sidebar.scss
@@ -52,7 +52,7 @@ .scrollbar-wrapper { overflow-x: hidden !important; height: calc(100% - 290px) !important; height: calc(100% - 194px) !important; } .el-scrollbar__bar.is-vertical { zhitan-vue/src/components/LeftTree/index.vue
@@ -64,7 +64,7 @@ query.value.modelCode = useRoute().query.modelCode; } else { // 最后使用默认值 query.value.modelCode = 'JCZBK_CODE'; query.value.modelCode = 'LBJT'; } console.log('LeftTree getTree modelCode:', query.value.modelCode); zhitan-vue/src/layout/components/Navbar.vue
@@ -53,7 +53,7 @@ function handleAlarm() { // 跳转到报警管理页面 router.push('/alarmmanage/measuremen?modelCode=BJGL') router.push('/alarmmanage/measuremen?modelCode=LBJT') } function handleRobot() { zhitan-vue/src/layout/index.vue
@@ -86,7 +86,7 @@ // 跳转到报警页面 function goToAlarm() { router.push('/alarmmanage/measuremen?modelCode=BJGL') router.push('/alarmmanage/measuremen?modelCode=LBJT') } // 打开AI大模型对话框 zhitan-vue/src/views/index.vue
@@ -336,6 +336,7 @@ }) const { queryParams } = toRefs(data) function handleTimeType(item, type) { console.log("itemtype",item,type) queryParams.value.timeType = item queryParams.value.type = type queryParams.value.dataTime = proxy.dayjs(new Date()).format("YYYY-MM-DD") zhitan-vue/src/views/modelconfiguration/businessmodel/businessModel.vue
@@ -126,7 +126,7 @@ modelInfoOptions.value = response.data if (flag) { if (modelInfoOptions.value.length > 0) { modelData.value = modelInfoOptions.value[0].modelCode modelData.value = modelInfoOptions.value[1].modelCode getTreeList(modelData.value) } } zhitan-vue/src/views/modelconfiguration/businessmodel/components/statisticalIndicators/StatisticModal.vue
@@ -110,7 +110,7 @@ let isFirstLeafNode = ref(false) //获取树列表 function getTreeList() { treeList({ modelCode: "JCZBK_CODE" }).then((res) => { treeList({ modelCode: "LBJT" }).then((res) => { let { data } = res treeData.value = data let chooseNode = null zhitan-vue/src/views/modelconfiguration/calculationformula/calculationFormula.vue
@@ -9,9 +9,9 @@ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button> </el-form-item> <!-- <el-form-item style="float: right"> <el-button type="primary" icon="plus" @click="handleAdd">新增</el-button> </el-form-item> --> <!-- <el-form-item style="float: right">--> <!-- <el-button type="primary" icon="plus" @click="handleAdd">新增</el-button>--> <!-- </el-form-item>--> </el-form> </div> <div class="table-bg-style"> zhitan-vue/src/views/modelconfiguration/indexwarehouse/indexWarehouse.vue
@@ -83,7 +83,7 @@ let treeRef = ref() let tab = ref(1) let treeData = ref([]) const modelCode = proxy.$route.query.modelCode || "JCZBK_CODE" const modelCode = proxy.$route.query.modelCode || "LBJT" const defaultProps = ref({ children: "children", @@ -114,7 +114,7 @@ let statisticalIndicatorManagementRef = ref(null) //获取树列表 function getTreeList() { treeList({ modelCode: proxy.$route.query.modelCode || "JCZBK_CODE" }).then((res) => { treeList({ modelCode: proxy.$route.query.modelCode || "LBJT" }).then((res) => { let { data } = res treeData.value = data let chooseNode = null zhitan-vue/src/views/realtimemonitor/realtimemonitor/realtimemonitor.vue
@@ -2,7 +2,7 @@ <div class="page"> <div class="page-container"> <div class="page-container-left"> <LeftTree ref="leftTreeRef" @handleNodeClick="handleNodeClick" ParentModelCode="YSCJMX" /> <LeftTree ref="leftTreeRef" @handleNodeClick="handleNodeClick" ParentModelCode="LBJT" /> </div> <div class="page-container-right"> <div class="form-card"> @@ -128,6 +128,7 @@ const energyTypeList = ref(undefined) let energyRealTimeMonitorList = ref([]) const loading = ref(false) const tabIndex = ref(0) const data = reactive({ queryParams: { nodeId: null, @@ -137,6 +138,39 @@ query: { ...useRoute().query }, }) const { queryParams, query } = toRefs(data) const refresher = () => { console.log("refresher") listEnergyRealTimeMonitor( proxy.addDateRange({ ...queryParams.value, ...query.value, }) ).then((res) => { if (!!res.code && res.code == 200) { res.data.map((item) => { item.activeIndex = tabIndex.value }) energyRealTimeMonitorList.value = res.data } }) } // 添加定时器 let refreshTimer = null onMounted(() => { refreshTimer = setInterval(() => { refresher() }, 30000) }) onBeforeUnmount(() => { if (refreshTimer) { clearInterval(refreshTimer) } }) /** 节点单击事件 */ function handleNodeClick(data) { queryParams.value.nodeId = data.id @@ -149,6 +183,7 @@ } function handleClick(item, index) { item.activeIndex = index tabIndex.value = index } // 能源实时监控-能源实时监控-列表 function getList() {