arima预测和hst预测更新最新数据;对预报水位去重
| | |
| | | |
| | | public interface ArimaPredictMapper extends BaseMapper<ArimaPredict>{ |
| | | List<ArimaPredict> getFutureData(@Param("resCd") String resCd,@Param("type") String type); |
| | | |
| | | List<ArimaPredict> selectTodayData(@Param("entity") ArimaPredict entity); |
| | | } |
| | |
| | | AND (type = '3' or type = '4' or type = '5') |
| | | </if> |
| | | </select> |
| | | <select id="selectTodayData" resultType="cn.gistack.nky.entity.ArimaPredict"> |
| | | SELECT * FROM NKY_ARIMA_PREDICT |
| | | WHERE 1=1 |
| | | <if test="entity.createTime != null "> |
| | | AND DATE_FORMAT(create_time,'%Y-%m-%d')>= DATE_FORMAT(#{entity.createTime},'%Y-%m-%d') |
| | | </if> |
| | | <if test="entity.damId != null and entity.damId != ''"> |
| | | AND DAM_ID = #{entity.damId} |
| | | </if> |
| | | <if test="entity.pointId != null and entity.pointId !=''"> |
| | | AND POINT_ID = #{entity.pointId} |
| | | </if> |
| | | <if test="entity.type != null and entity.type !='' "> |
| | | AND type = #{entity.type} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | import cn.gistack.nky.entity.HstPredict; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface HstPredictMapper extends BaseMapper<HstPredict> { |
| | | List<HstPredict> getFutureData(String resCd, String type); |
| | | |
| | | List<HstPredict> selectTodayData(@Param("entity") HstPredict entity); |
| | | } |
| | |
| | | AND (type = '3' or type = '4' or type = '5') |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="selectTodayData" resultType="cn.gistack.nky.entity.HstPredict"> |
| | | SELECT * FROM NKY_HST_PREDICT |
| | | WHERE 1= 1 |
| | | <if test="entity.createTime != null "> |
| | | AND DATE_FORMAT(create_time,'%Y-%m-%d')>= DATE_FORMAT(#{entity.createTime},'%Y-%m-%d') |
| | | </if> |
| | | <if test="entity.damId != null and entity.damId != ''"> |
| | | AND DAM_ID = #{entity.damId} |
| | | </if> |
| | | <if test="entity.pointId != null and entity.pointId !=''"> |
| | | AND POINT_ID = #{entity.pointId} |
| | | </if> |
| | | <if test="entity.type != null and entity.type !='' "> |
| | | AND type = #{entity.type} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | return false; |
| | | } |
| | | |
| | | //遍历表中当前水库,当前测点,当前类型的数据,检查是否有重复数据 |
| | | ArimaPredict params = new ArimaPredict(); |
| | | params.setDamId(entity.getDamId()); |
| | | params.setPointId(entity.getPointId()); |
| | | params.setType(entity.getType()); |
| | | params.setCreateTime(entity.getCreateTime()); |
| | | |
| | | List<ArimaPredict> list = list(Condition.getQueryWrapper(params)); |
| | | List<ArimaPredict> list = baseMapper.selectTodayData(entity); |
| | | |
| | | if (list.size()>0){ |
| | | return false; |
| | | //删除该数据,添加最新数据 |
| | | baseMapper.deleteById(list.get(0)); |
| | | return super.save(entity); |
| | | }else { |
| | | return super.save(entity); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | HstPredict params = new HstPredict(); |
| | | params.setDamId(entity.getDamId()); |
| | | params.setPointId(entity.getPointId()); |
| | | params.setType(entity.getType()); |
| | | params.setCreateTime(entity.getCreateTime()); |
| | | List<HstPredict> list = baseMapper.selectTodayData(entity); |
| | | |
| | | List<HstPredict> list = list(Condition.getQueryWrapper(params)); |
| | | |
| | | if (list.size() > 0) { |
| | | return false; |
| | | } else { |
| | | if (list.size()>0){ |
| | | //删除该数据,添加最新数据 |
| | | baseMapper.deleteById(list.get(0)); |
| | | return super.save(entity); |
| | | }else { |
| | | return super.save(entity); |
| | | } |
| | | } |
| | |
| | | List<List<String>> collect = data.stream().filter(item -> item.get(0) != null).collect(Collectors.toList()); |
| | | Integer index = findIndex(collect, "/"); |
| | | |
| | | //对0点时间添加日期 |
| | | if (index>-1){ |
| | | collect.get(index).set(0,tomorrow + collect.get(index).get(0).substring(5)); |
| | | } |
| | |
| | | collect.get(i).set(0,today + " " + collect.get(i).get(0)); |
| | | } |
| | | } |
| | | List<List<String>> filterData = data.stream().filter(item -> item.get(0) != null).filter(item -> CommonUtil.strToDate(item.get(0)).after(DateUtil.now())).collect(Collectors.toList()); |
| | | |
| | | //筛选出未来时间 |
| | | List<List<String>> filterData = collect.stream().filter(item -> CommonUtil.strToDate(item.get(0)).after(DateUtil.now())).collect(Collectors.toList()); |
| | | |
| | | //截取掉时间部分 |
| | | filterData.forEach(e->{ |
| | | e.set(0,e.get(0).split(" ")[0]); |
| | | }); |
| | | |
| | | return filterData; |
| | | //去除重复数据 |
| | | List<List<String>> collect1 = filterData.stream().distinct().collect(Collectors.toList()); |
| | | |
| | | return collect1; |
| | | } |
| | | |
| | | public Integer findIndex(List<List<String>> list,String reg){ |