| | |
| | | import cn.gistack.nky.vo.HstPredictVO; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class HstPredictServiceImpl extends ServiceImpl<HstPredictMapper, HstPredict> implements IHstPredictService { |
| | | @Autowired |
| | | private INkyService nkyService; |
| | |
| | | List<DataResChildrenPo> cdList = getCdList(type); |
| | | //暂时筛选出数据 |
| | | // List<DataResChildrenPo> collect = cdList.stream().filter( |
| | | // item -> item.getRes_cd().equals("42011640018") || item.getRes_cd().equals("42130350046")|| item.getRes_cd().equals("42092250024")|| item.getRes_cd().equals("42022250039")|| item.getRes_cd().equals("42132150292") |
| | | //// item -> item.getRes_cd().equals("42011640018") || item.getRes_cd().equals("42130350046")|| item.getRes_cd().equals("42092250024")|| item.getRes_cd().equals("42022250039")|| item.getRes_cd().equals("42132150292") |
| | | // item -> item.getRes_cd().equals("42050659003") ||item.getRes_cd().equals("42032240005") |
| | | // ).collect(Collectors.toList()); |
| | | |
| | | // predict(collect,type); |
| | |
| | | if (collect.size() == 0){ |
| | | return; |
| | | } |
| | | int no = 0; |
| | | List<NewSwFuturePo> future = new ArrayList<>(); |
| | | if (type.equals("1") || type.equals("2")){ |
| | | |
| | |
| | | DataResChildrenPo dataResChildrenPo = collect.get(i); |
| | | String currentResCd = dataResChildrenPo.getRes_cd(); |
| | | |
| | | //第一个水库 |
| | | if (future.size() == 0 && resCd.equals("")){ |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //当前水库 |
| | | resCd = currentResCd; |
| | | } else if (!resCd.equals(currentResCd)) { |
| | | //其他水库,获取新的预测数据 |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //更换为新水库 |
| | | resCd = currentResCd; |
| | | try { |
| | | //第一个水库 |
| | | if (future.size() == 0 && resCd.equals("")){ |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //当前水库 |
| | | resCd = currentResCd; |
| | | no = no +1; |
| | | log.info("当前为第{}个水库,水库id为{}",no,currentResCd); |
| | | } else if (!resCd.equals(currentResCd)) { |
| | | //其他水库,获取新的预测数据 |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //更换为新水库 |
| | | resCd = currentResCd; |
| | | no = no +1; |
| | | log.info("当前为第{}个水库,水库id为{}",no,currentResCd); |
| | | } |
| | | |
| | | //预测数据构造请求数据 |
| | | if (future != null && future.size() > 0) { |
| | | List<PredictWatersPo> po = new ArrayList<>(); |
| | | future.forEach(item -> { |
| | | PredictWatersPo predictWatersPo = new PredictWatersPo(); |
| | | //设置时间 |
| | | predictWatersPo.setTime(item.getTime()); |
| | | //设置预测水位 |
| | | predictWatersPo.setValue(Double.parseDouble(item.getSw())); |
| | | po.add(predictWatersPo); |
| | | }); |
| | | HstPredictReqPo arimaPredictReqPo = new HstPredictReqPo(dataResChildrenPo, type, po); |
| | | //循环预测请求 |
| | | nkyService.hstPredict(arimaPredictReqPo); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //预测数据构造请求数据 |
| | | if (future != null && future.size() > 0) { |
| | | List<PredictWatersPo> po = new ArrayList<>(); |
| | | future.forEach(item -> { |
| | | PredictWatersPo predictWatersPo = new PredictWatersPo(); |
| | | //设置时间 |
| | | predictWatersPo.setTime(item.getTime()); |
| | | //设置预测水位 |
| | | predictWatersPo.setValue(Double.parseDouble(item.getSw())); |
| | | po.add(predictWatersPo); |
| | | }); |
| | | HstPredictReqPo arimaPredictReqPo = new HstPredictReqPo(dataResChildrenPo, type, po); |
| | | //循环预测请求 |
| | | nkyService.hstPredict(arimaPredictReqPo); |
| | | } |
| | | |
| | | |
| | | } |
| | | }else if (type.equals("3") || type.equals("4") || type.equals("5")){ |
| | | |
| | |
| | | DataResChildrenPo dataResChildrenPo = collect.get(i); |
| | | String currentResCd = dataResChildrenPo.getRes_cd(); |
| | | |
| | | //第一个水库 |
| | | if (future.size() == 0 && resCd.equals("")){ |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //当前水库 |
| | | resCd = currentResCd; |
| | | } else if (!resCd.equals(currentResCd)) { |
| | | //其他水库,获取新的预测数据 |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //更换为新水库 |
| | | resCd = currentResCd; |
| | | try { |
| | | //第一个水库 |
| | | if (future.size() == 0 && resCd.equals("")){ |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //当前水库 |
| | | resCd = currentResCd; |
| | | no = no +1; |
| | | log.info("当前为第{}个水库,水库id为{}",no,currentResCd); |
| | | } else if (!resCd.equals(currentResCd)) { |
| | | //其他水库,获取新的预测数据 |
| | | future = hsybService.getNewFuture(currentResCd); |
| | | //更换为新水库 |
| | | resCd = currentResCd; |
| | | no = no +1; |
| | | log.info("当前为第{}个水库,水库id为{}",no,currentResCd); |
| | | } |
| | | |
| | | //预测数据构造请求数据 |
| | | if (future != null && future.size() > 0) { |
| | | List<PredictWatersPo> po = new ArrayList<>(); |
| | | future.forEach(item -> { |
| | | PredictWatersPo predictWatersPo = new PredictWatersPo(); |
| | | //设置时间 |
| | | predictWatersPo.setTime(item.getTime()); |
| | | //设置预测水位 |
| | | predictWatersPo.setValue(Double.parseDouble(item.getSw())); |
| | | po.add(predictWatersPo); |
| | | }); |
| | | //循环预测请求(位移一起请求减少请求次数) |
| | | HstPredictReqPo arimaPredictReqPoX = new HstPredictReqPo(dataResChildrenPo, "3", po); |
| | | nkyService.hstPredict(arimaPredictReqPoX); |
| | | |
| | | HstPredictReqPo arimaPredictReqPoY = new HstPredictReqPo(dataResChildrenPo, "4", po); |
| | | nkyService.hstPredict(arimaPredictReqPoY); |
| | | |
| | | HstPredictReqPo arimaPredictReqPoZ = new HstPredictReqPo(dataResChildrenPo, "5", po); |
| | | nkyService.hstPredict(arimaPredictReqPoZ); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //预测数据构造请求数据 |
| | | if (future != null && future.size() > 0) { |
| | | List<PredictWatersPo> po = new ArrayList<>(); |
| | | future.forEach(item -> { |
| | | PredictWatersPo predictWatersPo = new PredictWatersPo(); |
| | | //设置时间 |
| | | predictWatersPo.setTime(item.getTime()); |
| | | //设置预测水位 |
| | | predictWatersPo.setValue(Double.parseDouble(item.getSw())); |
| | | po.add(predictWatersPo); |
| | | }); |
| | | //循环预测请求(位移一起请求减少请求次数) |
| | | HstPredictReqPo arimaPredictReqPoX = new HstPredictReqPo(dataResChildrenPo, "3", po); |
| | | nkyService.hstPredict(arimaPredictReqPoX); |
| | | |
| | | HstPredictReqPo arimaPredictReqPoY = new HstPredictReqPo(dataResChildrenPo, "4", po); |
| | | nkyService.hstPredict(arimaPredictReqPoY); |
| | | |
| | | HstPredictReqPo arimaPredictReqPoZ = new HstPredictReqPo(dataResChildrenPo, "5", po); |
| | | nkyService.hstPredict(arimaPredictReqPoZ); |
| | | } |
| | | } |
| | | } |
| | | |