2026-01-29 13:49:41 +08:00
|
|
|
package com.gunshi.project.ss.service;
|
|
|
|
|
|
|
|
|
|
|
2026-01-29 17:12:39 +08:00
|
|
|
import com.gunshi.project.ss.common.model.StRsvrR;
|
2026-01-29 13:49:41 +08:00
|
|
|
import com.gunshi.project.ss.common.model.StStbprpB;
|
|
|
|
|
import com.gunshi.project.ss.entity.vo.AttResBaseVo;
|
|
|
|
|
import com.gunshi.project.ss.entity.vo.ScreenRsvrVo;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList;
|
2026-01-29 17:12:39 +08:00
|
|
|
import java.util.Date;
|
2026-01-29 13:49:41 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class ScreenMoniotrService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StStbprpBService stStbprpBService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AttResBaseService attResBaseService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ReservoirWaterService reservoirWaterService;
|
|
|
|
|
|
2026-01-29 17:12:39 +08:00
|
|
|
@Autowired
|
|
|
|
|
private StRsvrRService stRsvrRService;
|
|
|
|
|
|
2026-01-29 13:49:41 +08:00
|
|
|
public List<ScreenRsvrVo> getScreenRsvr() {
|
|
|
|
|
//查询所有的水库水情站点
|
|
|
|
|
List<ScreenRsvrVo> res = new ArrayList<>();
|
|
|
|
|
List<AttResBaseVo> attResBaseVos = reservoirWaterService.listV2();
|
|
|
|
|
for (AttResBaseVo rsvrStation : attResBaseVos) {
|
|
|
|
|
ScreenRsvrVo entity = new ScreenRsvrVo();
|
|
|
|
|
entity.setStcd(rsvrStation.getStcd());
|
|
|
|
|
entity.setStnm(rsvrStation.getStnm());
|
|
|
|
|
entity.setLgtd(rsvrStation.getLgtd());
|
|
|
|
|
entity.setLttd(rsvrStation.getLttd());
|
|
|
|
|
BigDecimal rz = rsvrStation.getRz();
|
|
|
|
|
entity.setRz(rz);
|
|
|
|
|
BigDecimal nowCap = rsvrStation.getNowCap();
|
|
|
|
|
BigDecimal deadCap = rsvrStation.getDeadCap();
|
|
|
|
|
entity.setNowCap(rsvrStation.getNowCap());
|
|
|
|
|
if(nowCap != null && deadCap != null){
|
|
|
|
|
entity.setEffectiveCap(nowCap.subtract(deadCap));
|
|
|
|
|
}
|
|
|
|
|
BigDecimal flLowLimLev = rsvrStation.getFlLowLimLev();
|
|
|
|
|
entity.setFlLowLimLev(rsvrStation.getFlLowLimLev());
|
|
|
|
|
if(rz != null && flLowLimLev != null){
|
|
|
|
|
entity.setGapFlLowLimLev(rz.subtract(flLowLimLev));
|
|
|
|
|
}
|
2026-01-29 17:12:39 +08:00
|
|
|
|
|
|
|
|
Date tm = rsvrStation.getTm();
|
|
|
|
|
if(tm == null){
|
|
|
|
|
entity.setStatus(0);
|
|
|
|
|
}else{
|
|
|
|
|
StRsvrR one = stRsvrRService.lambdaQuery()
|
|
|
|
|
.eq(StRsvrR::getStcd, rsvrStation.getStcd())
|
|
|
|
|
.lt(StRsvrR::getTm, tm).orderByDesc(StRsvrR::getTm)
|
|
|
|
|
.last("limit 1").one();
|
|
|
|
|
if(one == null){
|
|
|
|
|
entity.setStatus(0);
|
|
|
|
|
}else{
|
|
|
|
|
//如果过去时刻水位高于当前水位 ->表示下降
|
|
|
|
|
String lastRz = one.getRz();
|
|
|
|
|
BigDecimal decimalRz = new BigDecimal(lastRz);
|
|
|
|
|
if(rz.compareTo(decimalRz) < 0){
|
|
|
|
|
entity.setStatus(2);
|
|
|
|
|
}else if(rz.compareTo(decimalRz) > 0){
|
|
|
|
|
entity.setStatus(1);
|
|
|
|
|
}else{
|
|
|
|
|
entity.setStatus(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-29 13:49:41 +08:00
|
|
|
res.add(entity);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|