|
@@ -1,10 +1,12 @@
|
|
|
package com.example.opc_da.controller;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.example.opc_common.entity.ReportDataPolicy;
|
|
|
import com.example.opc_common.enums.ModelEnum;
|
|
|
import com.example.opc_common.enums.OperationEnum;
|
|
|
import com.example.opc_common.enums.ResultEnum;
|
|
|
import com.example.opc_common.enums.ServerEnum;
|
|
|
+import com.example.opc_common.exception.CustomException;
|
|
|
import com.example.opc_common.util.Blank;
|
|
|
import com.example.opc_common.util.Result;
|
|
|
import com.example.opc_da.annotation.WebLog;
|
|
@@ -13,7 +15,9 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 报表数据策略
|
|
@@ -176,23 +180,31 @@ public class ReportDataPolicyController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 通过策略数据项itemIdList获取对应的实时数据
|
|
|
+ * 通过策略数据项itemIdList获取对应的历史数据
|
|
|
*
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
/**
|
|
|
- * @param idList
|
|
|
+ * @param idList 报表策略数据项对应的id集合
|
|
|
* @param valueType 取值类型:0原始值,1计算值
|
|
|
* @param startTime 开始时间
|
|
|
* @param endTime 结束时间
|
|
|
* @param limit 为空则查全部
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/getPolicyHistoryDataByItemIdList", method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/getPolicyHistoryDataByItemIdList", method = RequestMethod.POST)
|
|
|
@WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.REPORTDATAPOLICY, OperationEnum = OperationEnum.SELECT)
|
|
|
- public Result getPolicyHistoryDataByItemIdList(@RequestParam List<Integer> idList, @RequestParam Integer valueType
|
|
|
+ public Result getPolicyHistoryDataByItemIdList(@RequestParam String idList, @RequestParam Integer valueType
|
|
|
, @RequestParam String startTime, @RequestParam String endTime, Integer limit) {
|
|
|
- return reportDataPolicyService.getPolicyHistoryDataByItemIdList(idList, valueType, startTime, endTime, limit);
|
|
|
+ idList = idList.substring(1, idList.length() - 1);
|
|
|
+ // 将字符串分割并转换成整数集合
|
|
|
+ List<Integer> newIdList = Arrays.stream(idList.split(","))
|
|
|
+ .map(Integer::parseInt)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollUtil.isEmpty(newIdList)) {
|
|
|
+ throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表数据策略数据项不能为空");
|
|
|
+ }
|
|
|
+ return reportDataPolicyService.getPolicyHistoryDataByItemIdList(newIdList, valueType, startTime, endTime, limit);
|
|
|
}
|
|
|
}
|