| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | return CommonResult.success(respVO); |
| | | } |
| | | |
| | | @PostMapping("/predict-data/missDataList") |
| | | @Operation(summary = "缺失历史数据表单") |
| | | public CommonResult<List<Map<String,Object>>> getPreDataMissDataList(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody PreDataBarLineReqVO reqVO) throws Exception { |
| | | apiSecurityUtils.validate(request); |
| | | |
| | | PreDataBarLineRespVO respVO = new PreDataBarLineRespVO(); |
| | | List<Map<String,Object>> result = new ArrayList<>(); |
| | | try { |
| | | respVO = mcsApi.getPreDataCharts(reqVO); |
| | | for (int i = 0; i < respVO.getDataViewList().size()-1; i++) { |
| | | |
| | | Map<String,Object> real = getMissDataMap(respVO.getDataViewList().get(i).getRealData(),respVO.getDataViewList().get(i).getOutId(),respVO.getDataViewList().get(i).getResultName()+"(真实)"); |
| | | Map<String,Object> preN = getMissDataMap(respVO.getDataViewList().get(i).getPreDataN(),respVO.getDataViewList().get(i).getOutId(),respVO.getDataViewList().get(i).getResultName()+"(T+N)"); |
| | | Map<String,Object> preL = getMissDataMap(respVO.getDataViewList().get(i).getPreDataL(),respVO.getDataViewList().get(i).getOutId(),respVO.getDataViewList().get(i).getResultName()+"(T+L)"); |
| | | result.add(real); |
| | | result.add(preN); |
| | | result.add(preL); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return CommonResult.success(result); |
| | | } |
| | | |
| | | private Map<String,Object> getMissDataMap( List<Object[]> list,String outId,String resultName){ |
| | | Map<String,Object> missDataMap = new HashMap<>(); |
| | | |
| | | if (list == null || list.size() < 2) { |
| | | return missDataMap; |
| | | } |
| | | for (int i = 1; i < list.size(); i++) { |
| | | LocalDateTime startTime = (LocalDateTime) list.get(i-1)[0]; |
| | | LocalDateTime endTime = (LocalDateTime) list.get(i)[0]; |
| | | long gap = ChronoUnit.MINUTES.between(startTime, endTime); |
| | | if (gap > 10) { |
| | | missDataMap.put("outId",outId); |
| | | missDataMap.put("resultName",resultName); |
| | | missDataMap.put("startTime",startTime); |
| | | missDataMap.put("endTime",endTime); |
| | | missDataMap.put("random",10); |
| | | missDataMap.put("gap",gap); |
| | | } |
| | | } |
| | | return missDataMap; |
| | | } |
| | | |
| | | @PostMapping("/predict-data/item-chart") |
| | |
| | | reqVO.setItemId(itemId); |
| | | try { |
| | | if (startTime == "") { |
| | | reqVO.setStartTime(new Date((new Date()).getTime() - 60 * 60 * 1000)); |
| | | reqVO.setStartTime(null); |
| | | } else { |
| | | reqVO.setStartTime(formatter.parse(startTime)); |
| | | |
| | | } |
| | | if (endTime == "") { |
| | | reqVO.setEndTime(new Date((new Date()).getTime() + 60 * 60 * 1000)); |
| | | reqVO.setEndTime(null); |
| | | } else { |
| | | reqVO.setEndTime(formatter.parse(endTime)); |
| | | } |
| | |
| | | } |
| | | |
| | | @GetMapping("/schedule-suggest/last-limit") |
| | | @Operation(summary = "根据监控对象获取最新预警信息") |
| | | @Operation(summary = "根据监控对象获取最新调度建议") |
| | | public CommonResult<List<ScheduleSuggestRespDTO>> getLastLimitScheduleSuggest(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestParam("scheduleObj") String scheduleObj, @RequestParam("limit") Integer limit) { |
| | | List<ScheduleSuggestRespDTO> data = mcsApi.getLastLimitScheduleSuggest(scheduleObj, limit); |
| | | return CommonResult.success(data); |
| | | } |
| | | |
| | | @PostMapping("/schedule-suggest/list") |
| | | @Operation(summary = "获取调度建议") |
| | | public CommonResult<List<ScheduleSuggestRespDTO>> listScheduleSuggest(@RequestBody ScheduleSuggestReqDTO vo) { |
| | | List<ScheduleSuggestRespDTO> list = mcsApi.listScheduleSuggest(vo); |
| | | return CommonResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/alarm-suggest/page") |
| | |
| | | |
| | | @GetMapping("/electricityPrice/list") |
| | | @Operation(summary = "电价表") |
| | | public CommonResult<List<ElectricityPriceSegmentedDTO>> getElectricityPriceList(@RequestParam String year) { |
| | | List<ElectricityPriceSegmentedDTO> electricityPriceSegmentedList = mcsApi.getElectricityPriceList(year); |
| | | public CommonResult<List<ElectricityPriceSegmentedDTO>> getElectricityPriceList(@RequestParam("year") String year, @RequestParam("time") String time) { |
| | | List<ElectricityPriceSegmentedDTO> electricityPriceSegmentedList = mcsApi.getElectricityPriceList(year, time); |
| | | return CommonResult.success(electricityPriceSegmentedList); |
| | | } |
| | | |
| | | @GetMapping("/schedule/model/setting/update") |
| | | @Operation(summary = "修改调度模型配置") |
| | | public CommonResult<Boolean> updateScheduleModelSetting(@RequestParam("modelCode") String modelCode, @RequestParam("key") String key, @RequestParam("value") String value){ |
| | | mcsApi.updateScheduleModelSetting(modelCode, key, value); |
| | | return success( true); |
| | | } |
| | | |
| | | @GetMapping("/alarm-config/update") |
| | | @Operation(summary = "修改预警配置列表") |
| | | public CommonResult<Boolean> updateAlarmConfig(@RequestParam("alarmObj")String alarmObj, @RequestParam("upperLimit")String upperLimit, @RequestParam("lowerLimit")String lowerLimit){ |
| | | mcsApi.updateAlarmConfig(alarmObj, upperLimit, lowerLimit); |
| | | return success( true); |
| | | } |
| | | |
| | | @PostMapping("/chart/param/update") |
| | | @Operation(summary = "修改图表参数配置") |
| | | public CommonResult<Boolean> updateChartParam(@RequestBody ChartDTO chartDTO){ |
| | | mcsApi.updateChartParam(chartDTO); |
| | | return success( true); |
| | | } |
| | | |
| | | @PostMapping("/item/result") |
| | | public CommonResult<List<Object[]>> getItemResult(@RequestBody PreItemResultReqVO reqVO){ |
| | | List<Object[]> list = mcsApi.getItemResult(reqVO); |
| | | return CommonResult.success(list); |
| | | } |
| | | |
| | | @GetMapping("/predict-item/itemNo") |
| | | public CommonResult<PredictItemVO> getPredictItemByItemNo(@RequestParam("itemNo") String itemNo){ |
| | | PredictItemVO proVo = mcsApi.getPredictItemByItemNo(itemNo); |
| | | return CommonResult.success(proVo); |
| | | } |
| | | |
| | | @PostMapping("/item/result/last-point") |
| | | public CommonResult<List<Object[]>> getItemResultLastPoint(@RequestBody PreItemResultReqVO reqVO){ |
| | | List<Object[]> list = mcsApi.getItemResultLastPoint(reqVO); |
| | | return CommonResult.success(list); |
| | | } |
| | | |
| | | @GetMapping("/schedule-suggest/last-one") |
| | | @Operation(summary = "获取15分钟内最新预警建议信息") |
| | | public CommonResult<List<ScheduleSuggestRespDTO>> getLastSuggest(@RequestParam Map<String, Object> params) { |
| | | List<ScheduleSuggestRespDTO> data = mcsApi.getLastSuggest(params); |
| | | return CommonResult.success(data); |
| | | } |
| | | |
| | | @GetMapping("/predict/model/setting/update") |
| | | @Operation(summary = "修改调度模型配置") |
| | | public CommonResult<Boolean> updatePredictModelSetting(@RequestParam("modelCode") String modelCode, @RequestParam("key") String key, @RequestParam("value") String value){ |
| | | mcsApi.updatePredictModelSetting(modelCode, key, value); |
| | | return success( true); |
| | | } |
| | | } |