| | |
| | | import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; |
| | | import com.iailab.module.model.mcs.pre.service.*; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; |
| | | import com.iailab.module.model.mdk.vo.ItemVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public PreDataItemChartRespVO getPreDataItemChart(PreDataItemChartReqVO reqVO) { |
| | | PreDataItemChartRespVO result = new PreDataItemChartRespVO(); |
| | | ItemVO predictItem = mmPredictItemService.getItemById(reqVO.getItemId()); |
| | | if (predictItem == null) { |
| | | return result; |
| | | } |
| | | if (predictItem.getLastTime() == null) { |
| | | return result; |
| | | } |
| | | result.setLastTime(predictItem.getLastTime()); |
| | | Date startTime = reqVO.getStartTime(); |
| | | if (startTime == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictItem.getLastTime()); |
| | | calendar.add(Calendar.HOUR_OF_DAY, -1); |
| | | startTime = calendar.getTime(); |
| | | } |
| | | Date endTime = reqVO.getEndTime(); |
| | | if (endTime == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictItem.getLastTime()); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 1); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | List<String> categories = DateUtils.getTimeScale(startTime, endTime, predictItem.getGranularity()); |
| | | List<String> legend = new ArrayList<>(); |
| | | LinkedHashMap<String, PreDataSampleViewRespDTO> viewMap = new LinkedHashMap<>(); |
| | | List<MmItemOutputEntity> outs = mmItemOutputService.getByItemid(reqVO.getItemId()); |
| | | if (CollectionUtils.isEmpty(outs)) { |
| | | return result; |
| | | } |
| | | for (MmItemOutputEntity out : outs) { |
| | | legend.add(out.getResultstr()); |
| | | PreDataSampleViewRespDTO viewDto = new PreDataSampleViewRespDTO(); |
| | | viewDto.setRealData(getHisData(out.getPointid(), startTime, endTime)); |
| | | viewDto.setPreDataN(mmItemResultService.getData(out.getId(), startTime, endTime)); |
| | | viewMap.put(out.getResultstr(), viewDto); |
| | | } |
| | | result.setStartTime(startTime); |
| | | result.setEndTime(endTime); |
| | | result.setCategories(categories); |
| | | result.setLegend(legend); |
| | | result.setViewMap(viewMap); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取真实值 |
| | | * |