| | |
| | | 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; |
| | |
| | | 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") |
| | | @Operation(summary = "预测数据图表") |
| | | public CommonResult<PreDataItemChartRespVO> getPreDataItemChart(HttpServletResponse response, HttpServletRequest |