Ver Fonte

[1019] 修复功率频率分布统计场站取值错误: 接口参数stationCode改为前端直传stationId(config_station_id), 删除后端resolveStationId解析逻辑, Vue页面与spec同步修正

taosj há 1 semana atrás
pai
commit
0fd9b36948

+ 3 - 24
forecast-backend-server/src/main/java/com/ufo/project/data/controller/DataController.java

@@ -56,8 +56,6 @@ import com.ufo.project.forecast.shortterm.power.domain.DataShortTermPowerForecas
 import com.ufo.project.forecast.shortterm.power.service.IDataShortTermPowerForecastIssuedService;
 import com.ufo.project.forecast.shortterm.weather.domain.DataShortTermWeatherForecastIssued;
 import com.ufo.project.forecast.shortterm.weather.service.IDataShortTermWeatherForecastIssuedService;
-import com.ufo.project.config.domain.ConfigStation;
-import com.ufo.project.config.service.IConfigStationService;
 import com.ufo.project.model.domain.DataElectricityLocal;
 import com.ufo.project.model.service.IDataElectricityLocalService;
 import com.ufo.project.weather.domain.DataWeatherLocal;
@@ -102,9 +100,6 @@ public class DataController extends BaseController
     @Autowired
     private IPowerErrorStatService powerErrorStatService;
 
-    @Autowired
-    private IConfigStationService configStationService;
-
     /**
      * 辐照度功率对比
      */
@@ -314,7 +309,7 @@ public class DataController extends BaseController
     public TableDataInfo powerFrequencyDistribution(@RequestBody PowerFrequencyDistributionQuery query)
     {
         List<PowerFrequencyDistributionVO> list = buildFrequencyDistributionList(
-                query.getStationCode(), query.getStartDay(), query.getEndDay());
+                query.getStationId(), query.getStartDay(), query.getEndDay());
         return getDataTable(list);
     }
 
@@ -327,7 +322,7 @@ public class DataController extends BaseController
     public void powerFrequencyDistributionExport(HttpServletResponse response, @RequestBody PowerFrequencyDistributionQuery query)
     {
         List<PowerFrequencyDistributionVO> list = buildFrequencyDistributionList(
-                query.getStationCode(), query.getStartDay(), query.getEndDay());
+                query.getStationId(), query.getStartDay(), query.getEndDay());
         ExcelUtil<PowerFrequencyDistributionVO> util = new ExcelUtil<>(PowerFrequencyDistributionVO.class);
         util.exportExcel(response, list, "日功率频率分布统计");
     }
@@ -399,9 +394,8 @@ public class DataController extends BaseController
      * 构建日功率频率分布统计列表(按日分组,无数据的日期补零)
      * <p>取数区间左闭右开: tm &gt;= startDay 00:00(+08:00), tm &lt; endDay 00:00(+08:00)。</p>
      */
-    private List<PowerFrequencyDistributionVO> buildFrequencyDistributionList(String stationCode, String startDay, String endDay)
+    private List<PowerFrequencyDistributionVO> buildFrequencyDistributionList(Long stationId, String startDay, String endDay)
     {
-        Long stationId = resolveStationId(stationCode);
         List<DataElectricityLocal> rows = stationId == null
                 ? new ArrayList<>()
                 : electricityLocalService.selectActualPowerRange(stationId, startDay, endDay);
@@ -432,21 +426,6 @@ public class DataController extends BaseController
         return result;
     }
 
-    /**
-     * 场站编码解析为场站id,未匹配返回 null
-     */
-    private Long resolveStationId(String stationCode)
-    {
-        ConfigStation condition = new ConfigStation();
-        condition.setStationCode(stationCode);
-        List<ConfigStation> list = configStationService.selectConfigStationList(condition);
-        if (list == null || list.isEmpty())
-        {
-            return null;
-        }
-        return list.get(0).getId();
-    }
-
     /*
      * 辐照度累计值报表
      */

+ 8 - 7
forecast-backend-server/src/main/java/com/ufo/project/data/domain/vo/PowerFrequencyDistributionQuery.java

@@ -1,6 +1,7 @@
 package com.ufo.project.data.domain.vo;
 
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 
 /**
  * 日功率频率分布统计查询参数
@@ -10,9 +11,9 @@ import javax.validation.constraints.NotBlank;
  */
 public class PowerFrequencyDistributionQuery
 {
-    /** 场站编码 */
-    @NotBlank(message = "场站编码不能为空")
-    private String stationCode;
+    /** 场站ID(config_station_id) */
+    @NotNull(message = "场站ID不能为空")
+    private Long stationId;
 
     /** 起始日期 yyyy-MM-dd(包含) */
     @NotBlank(message = "起始日期不能为空")
@@ -22,14 +23,14 @@ public class PowerFrequencyDistributionQuery
     @NotBlank(message = "结束日期不能为空")
     private String endDay;
 
-    public String getStationCode()
+    public Long getStationId()
     {
-        return stationCode;
+        return stationId;
     }
 
-    public void setStationCode(String stationCode)
+    public void setStationId(Long stationId)
     {
-        this.stationCode = stationCode;
+        this.stationId = stationId;
     }
 
     public String getStartDay()

+ 8 - 8
forecast-backend-vue/src/views/ufo/electricity/statanalysis/powerFrequencyDistribution.vue

@@ -3,7 +3,7 @@
     <a-card :bordered="false">
       <a-row :gutter="[12, 12]" align="middle">
         <a-col :xs="24" :md="6">
-          <StationSelector v-model:value="query.stationCode" :options="stationOptions" :multiple="false" />
+          <StationSelector v-model:value="query.stationId" :options="stationOptions" :multiple="false" />
         </a-col>
         <a-col :xs="24" :md="5">
           <a-date-picker
@@ -66,13 +66,13 @@ const stationOptions = ref([]);
 const rows = ref([]);
 
 const query = reactive({
-  stationCode: undefined,
+  stationId: undefined,
   startDay: dayjs().subtract(7, 'day').format('YYYY-MM-DD'),
   endDay: dayjs().format('YYYY-MM-DD')
 });
 
 const queryValid = computed(() => {
-  if (!query.stationCode || !query.startDay || !query.endDay) return false;
+  if (!query.stationId || !query.startDay || !query.endDay) return false;
   const start = dayjs(query.startDay);
   const end = dayjs(query.endDay);
   if (!start.isValid() || !end.isValid()) return false;
@@ -111,13 +111,13 @@ const columns = [
 const loadStationOptions = async () => {
   const res = await listStation({pageNum: 1, pageSize: 500});
   stationOptions.value = toStationOptions(normalizeRows(res));
-  if (!query.stationCode && stationOptions.value.length) {
-    query.stationCode = stationOptions.value[0].value;
+  if (!query.stationId && stationOptions.value.length) {
+    query.stationId = stationOptions.value[0].value;
   }
 };
 
 const buildParams = () => ({
-  stationCode: query.stationCode,
+  stationId: query.stationId,
   startDay: query.startDay,
   endDay: query.endDay
 });
@@ -128,7 +128,7 @@ const fetchList = async () => {
 };
 
 const handleQuery = async () => {
-  if (!query.stationCode) {
+  if (!query.stationId) {
     message.warning('请先选择场站');
     return;
   }
@@ -143,7 +143,7 @@ const handleQuery = async () => {
 };
 
 const handleExport = async () => {
-  if (!query.stationCode) {
+  if (!query.stationId) {
     message.warning('请先选择场站');
     return;
   }