# Conflicts:
#	src/main/java/com/gunshi/project/xyt/mapper/StPptnRHMapper.java
#	src/main/resources/mapper/StPptnRHMapper.xml
master
wany 2024-09-03 11:24:04 +08:00
commit fb8020f097
4 changed files with 57 additions and 2 deletions

View File

@ -2,7 +2,6 @@ package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.xyt.entity.vo.StRzVo; import com.gunshi.project.xyt.entity.vo.StRzVo;
import com.gunshi.project.xyt.model.StPptnRD;
import com.gunshi.project.xyt.model.StPptnRH; import com.gunshi.project.xyt.model.StPptnRH;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -22,4 +21,8 @@ public interface StPptnRHMapper extends BaseMapper<StPptnRH> {
List<StRzVo> queryRzList(@Param("start") String start,@Param("end") String end); List<StRzVo> queryRzList(@Param("start") String start,@Param("end") String end);
List<StPptnRD> queryDayDrp(@Param("year") Integer year); List<StPptnRD> queryDayDrp(@Param("year") Integer year);
}
List<StPptnRH> reorganizePptnRHData(@Param("stcd") String stcd, @Param("maxData") StPptnRH maxData);
StPptnRH getMaxData(String stcd);
}

View File

@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* : * :
* author: cxw * author: cxw
@ -18,6 +20,13 @@ import org.springframework.transaction.annotation.Transactional;
public class StPptnRHService extends ServiceImpl<StPptnRHMapper, StPptnRH> public class StPptnRHService extends ServiceImpl<StPptnRHMapper, StPptnRH>
{ {
public List<StPptnRH> reorganizePptnRHData(String stcd, StPptnRH maxData) {
return baseMapper.reorganizePptnRHData(stcd, maxData);
}
public StPptnRH getMaxData(String stcd) {
return baseMapper.getMaxData(stcd);
}
} }

View File

@ -15,6 +15,7 @@ import com.gunshi.project.xyt.model.StImgR;
import com.gunshi.project.xyt.model.StImgRReal; import com.gunshi.project.xyt.model.StImgRReal;
import com.gunshi.project.xyt.model.StPptnR; import com.gunshi.project.xyt.model.StPptnR;
import com.gunshi.project.xyt.model.StPptnRD; import com.gunshi.project.xyt.model.StPptnRD;
import com.gunshi.project.xyt.model.StPptnRH;
import com.gunshi.project.xyt.model.StPptnRReal; import com.gunshi.project.xyt.model.StPptnRReal;
import com.gunshi.project.xyt.model.StRsvrR; import com.gunshi.project.xyt.model.StRsvrR;
import com.gunshi.project.xyt.model.StRsvrRReal; import com.gunshi.project.xyt.model.StRsvrRReal;
@ -22,6 +23,7 @@ import com.gunshi.project.xyt.model.StStbprpB;
import com.gunshi.project.xyt.service.StImgRRealService; import com.gunshi.project.xyt.service.StImgRRealService;
import com.gunshi.project.xyt.service.StImgRService; import com.gunshi.project.xyt.service.StImgRService;
import com.gunshi.project.xyt.service.StPptnRDService; import com.gunshi.project.xyt.service.StPptnRDService;
import com.gunshi.project.xyt.service.StPptnRHService;
import com.gunshi.project.xyt.service.StPptnRRealService; import com.gunshi.project.xyt.service.StPptnRRealService;
import com.gunshi.project.xyt.service.StPptnRService; import com.gunshi.project.xyt.service.StPptnRService;
import com.gunshi.project.xyt.service.StRsvrRRealService; import com.gunshi.project.xyt.service.StRsvrRRealService;
@ -116,6 +118,10 @@ public class DataTask {
@Autowired @Autowired
private StPptnRService stPptnRService; private StPptnRService stPptnRService;
// 小时雨情
@Autowired
private StPptnRHService stPptnRHService;
// 按天雨情 // 按天雨情
@Autowired @Autowired
private StPptnRDService stPptnRDService; private StPptnRDService stPptnRDService;
@ -298,6 +304,23 @@ public class DataTask {
stPptnRService.saveBatch(rlist); stPptnRService.saveBatch(rlist);
// 更新到实时数据表 // 更新到实时数据表
stPptnRRealService.updatePptnRReal(stPptnR.getStcd()); stPptnRRealService.updatePptnRReal(stPptnR.getStcd());
// 整编降雨量小时表数据
StPptnRH maxData = stPptnRHService.getMaxData(stPptnR.getStcd());
List<StPptnRH> list = stPptnRHService.reorganizePptnRHData(stPptnR.getStcd(), maxData);
if(CollectionUtils.isNotEmpty(list)){
StPptnRH LastData = list.get(0);
if(LastData.getTm().equals(maxData.getTm())){
list.remove(0);
UpdateWrapper<StPptnRH> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("stcd", LastData.getStcd()).eq("tm", LastData.getTm());
LastData.setDrp(LastData.getDrp());
LastData.setChtm(LastData.getChtm());
stPptnRHService.saveOrUpdate(LastData, updateWrapper);
}
if(list.size() > 0){
stPptnRHService.saveBatch(list);
}
}
} }
} }
} }

View File

@ -20,4 +20,24 @@
and stcd = (select stcd from public.att_res_base where res_code = '42120250085') and stcd = (select stcd from public.att_res_base where res_code = '42120250085')
order by tm asc order by tm asc
</select> </select>
<select id="reorganizePptnRHData" resultType="com.gunshi.project.xyt.model.StPptnRH">
SELECT h.stcd, h.hour_tm tm, h.drp
from (SELECT r.stcd,
DATE_TRUNC('hour', r.tm - INTERVAL '1 second') + INTERVAL '1 hour' AS hour_tm, SUM ( r.drp ) AS drp
FROM
st_pptn_r r
WHERE
r.stcd = #{stcd}
AND r.tm >= #{maxData.tm}
GROUP BY
r.stcd,
hour_tm
ORDER BY
hour_tm) h
</select>
<select id="getMaxData" resultType="com.gunshi.project.xyt.model.StPptnRH">
SELECT #{stcd} stcd, COALESCE(max(tm), '2021-01-01 00:00:00') tm FROM st_pptn_r_h
</select>
</mapper> </mapper>