| | |
| | | package cn.gistack.nky.service.impl; |
| | | |
| | | import cn.gistack.common.utils.CommonUtil; |
| | | import cn.gistack.nky.entity.ArimaPredict; |
| | | import cn.gistack.nky.mapper.ArimaPredictMapper; |
| | | import cn.gistack.nky.requestpojo.ArimaPredictReqPo; |
| | |
| | | import cn.gistack.nky.service.IArimaPredictService; |
| | | import cn.gistack.nky.service.INkyService; |
| | | import cn.gistack.nky.service.IZtApiService; |
| | | import cn.gistack.nky.vo.ArimaPredictVO; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | |
| | | }); |
| | | }else if (type.equals("2")){ |
| | | //渗流 |
| | | cdList.forEach(dataResChildrenPo -> { |
| | | ArimaPredictReqPo arimaPredictReqPo = new ArimaPredictReqPo(dataResChildrenPo, type); |
| | | //循环预测请求 |
| | | nkyService.arimaPredict(arimaPredictReqPo); |
| | | }); |
| | | }else if (type.equals("3") || type.equals("4") || type.equals("5")){ |
| | | cdList.forEach(dataResChildrenPo -> { |
| | | //循环预测请求 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ArimaPredict> getFutureData(String resCd,String type) { |
| | | List<ArimaPredict> futureData = baseMapper.getFutureData(resCd, type); |
| | | public List<ArimaPredictVO> getFutureData(String resCd, String type) { |
| | | List<ArimaPredictVO> futureData = new ArrayList<>(); |
| | | if (type.equals("3")){ |
| | | //位移另一张表 |
| | | // futureData=baseMapper.getFutureDataWy(resCd,type); |
| | | futureData=baseMapper.getFutureDataWy2(resCd,type); |
| | | }else{ |
| | | // futureData = baseMapper.getFutureData(resCd, type); |
| | | futureData = baseMapper.getFutureData2(resCd, type); |
| | | } |
| | | |
| | | futureData.forEach(arimaPredict -> { |
| | | arimaPredict.setPredicts(JSON.parse(arimaPredict.getPredicts().toString())); |
| | | // arimaPredict.setValue(JSON.parse(arimaPredict.getValue()).toString()); |
| | | if (!Strings.isBlank(arimaPredict.getValue())) { |
| | | arimaPredict.setPredicts(JSON.parse(arimaPredict.getValue())); |
| | | } |
| | | }); |
| | | return futureData; |
| | | } |
| | |
| | | |
| | | if (list.size()>0){ |
| | | //删除该数据,添加最新数据 |
| | | baseMapper.deleteById(list.get(0)); |
| | | return super.save(entity); |
| | | // baseMapper.deleteById(list.get(0)); |
| | | // return super.save(entity); |
| | | return false; |
| | | }else { |
| | | return super.save(entity); |
| | | } |
| | |
| | | cdList = ztApiService.getSy(); |
| | | }else if (type.equals("2")){ |
| | | //获取渗流测点 |
| | | return null; |
| | | cdList = ztApiService.getSl(); |
| | | }else if (type.equals("3") || type.equals("4") || type.equals("5")){ |
| | | //获取位移测点 |
| | | cdList = ztApiService.getWy(); |
| | | }else { |
| | | return null; |
| | | } |
| | | return cdList; |
| | | List<DataResChildrenPo> filterList = filterTimeList(cdList, 24); |
| | | return filterList; |
| | | } |
| | | |
| | | /** |
| | | * 筛选时间内的集合 |
| | | * @param sourceList |
| | | * @param timeGap |
| | | * @return |
| | | */ |
| | | public List<DataResChildrenPo> filterTimeList(List<DataResChildrenPo> sourceList,Integer timeGap){ |
| | | //当前时间的时间戳 |
| | | Long todayTimeStamp = DateUtil.now().getTime(); |
| | | |
| | | //过去时间的时间戳 |
| | | Long beforeTimeStamp = todayTimeStamp - 1000*60*60*timeGap; |
| | | |
| | | //过去时间的日期 |
| | | Date beforeDate = new Date(beforeTimeStamp); |
| | | |
| | | List<DataResChildrenPo> collect = sourceList.stream().filter(item -> CommonUtil.strToDate(item.getTm()).after(beforeDate)).collect(Collectors.toList()); |
| | | |
| | | return collect; |
| | | } |
| | | } |