修改设备状态监测代码逻辑
parent
cb45704288
commit
9ffb7c93d5
|
|
@ -56,4 +56,8 @@ public class OsmoticShiftListVo2 {
|
|||
@JsonIgnore
|
||||
private String direction;
|
||||
|
||||
|
||||
private BigDecimal lttd;
|
||||
|
||||
private BigDecimal lgtd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,8 @@ public class OsmoticPressVo {
|
|||
@Schema(description = "是否超过预警(0否 1是)")
|
||||
private Integer status = 0;
|
||||
|
||||
private BigDecimal lttd;
|
||||
|
||||
private BigDecimal lgtd;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,23 +21,32 @@ public class StStatusListVo {
|
|||
@Schema(description = "报到率")
|
||||
private BigDecimal reportPercentage;
|
||||
|
||||
|
||||
@Schema(description = "雨量站")
|
||||
private Map<String,List<StStatusVo>> rainStationMap;
|
||||
private List<StStatusVo> rainStationList;
|
||||
|
||||
|
||||
@Schema(description = "水库水位站")
|
||||
private Map<String,List<StStatusVo>> rsvrStationMap;
|
||||
private List<StStatusVo> rsvrStationList;
|
||||
|
||||
|
||||
@Schema(description = "河道水位站")
|
||||
private Map<String,List<StStatusVo>> riverStationMap;
|
||||
private List<StStatusVo> riverStationList;
|
||||
|
||||
|
||||
@Schema(description = "流量站")
|
||||
private Map<String,List<StStatusVo>> flowStationMap;
|
||||
private List<StStatusVo> flowStationList;
|
||||
|
||||
@Schema(description = "视频站")
|
||||
private Map<String,List<StStatusVo>> cctvStationMap;
|
||||
private List<StStatusVo> cctvStationList;
|
||||
|
||||
@Schema(description = "渗压")
|
||||
private List<StStatusVo> syStationList;
|
||||
|
||||
@Schema(description = "渗流")
|
||||
private List<StStatusVo> slStationList;
|
||||
|
||||
@Schema(description = "位移")
|
||||
private List<StStatusVo> wyStationList;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,7 @@ public class StStatusVo {
|
|||
@Schema(description = "纬度")
|
||||
private BigDecimal lttd;
|
||||
|
||||
@Schema(description = "状态 0 离线 1在线")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,7 +197,8 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
|
|||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT st.dvcd as stationCode,r.spprwl as value, to_char(r.mstm,'YYYY-MM-DD HH24:MI:SS') as tm,st.dm as profileName FROM jcsk_sy_b st
|
||||
SELECT st.dvcd as stationCode,r.spprwl as value, to_char(r.mstm,'YYYY-MM-DD HH24:MI:SS') as tm,st.dm as profileName,st.lttd,st.lgtd
|
||||
FROM jcsk_sy_b st
|
||||
LEFT JOIN (SELECT mpcd,MAX(mstm) tm FROM jcsk_sy_r GROUP BY mpcd) maxr ON st.mpcd = maxr.mpcd
|
||||
LEFT JOIN jcsk_sy_r r ON maxr.mpcd = r.mpcd and maxr.tm = r.mstm
|
||||
</script>
|
||||
|
|
@ -206,7 +207,8 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
|
|||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT st.mpcd,r.spqn as value, to_char(r.mstm,'YYYY-MM-DD HH24:MI:SS') as tm,st.dvcd as stationCode,st.dm as profileName FROM
|
||||
SELECT st.mpcd,r.spqn as value, to_char(r.mstm,'YYYY-MM-DD HH24:MI:SS') as tm,st.dvcd as stationCode,st.dm as profileName ,st.lgtd,st.lttd
|
||||
FROM
|
||||
jcsk_sl_b st
|
||||
LEFT JOIN (SELECT mpcd,MAX(mstm) tm FROM jcsk_sl_r GROUP BY mpcd) maxr ON st.mpcd = maxr.mpcd
|
||||
LEFT JOIN jcsk_sl_r r ON maxr.mpcd = r.mpcd AND maxr.tm = r.mstm
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ public interface OsmoticShiftRMapper extends BaseMapper<OsmoticShiftR> {
|
|||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT st.cd,st.cd_nm as cdNm ,r.de,r.dn,r.du,to_char(r.tm,'YYYY-MM-DD HH24:MI:SS') as tm FROM
|
||||
SELECT st.cd,st.cd_nm as cdNm ,r.de,r.dn,r.du,to_char(r.tm,'YYYY-MM-DD HH24:MI:SS') as tm ,st.lttd,st.lgtd
|
||||
FROM
|
||||
jcsk_gnss_b st
|
||||
LEFT JOIN (SELECT cd,MAX(tm) tm FROM jcsk_gnss_r GROUP BY cd) maxr ON st.cd = maxr.cd
|
||||
LEFT JOIN jcsk_gnss_r r ON maxr.cd = r.cd AND maxr.tm = r.tm
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public interface StbprpBVoMapper {
|
|||
<script>
|
||||
SELECT st.stcd,st.stnm,r.tm,st.lgtd,st.lttd FROM st_stbprp_b st
|
||||
LEFT JOIN st_rsvr_r_real r ON st.stcd = r.stcd
|
||||
WHERE st.stcd in (select distinct(stcd) from st_stbprp_b_elem where elem ='z')
|
||||
WHERE st.stcd in (select distinct(stcd) from st_stbprp_b_elem where elem ='rz')
|
||||
</script>
|
||||
""")
|
||||
List<StStatusVo> rzList();
|
||||
|
|
@ -120,7 +120,7 @@ public interface StbprpBVoMapper {
|
|||
@Select("""
|
||||
<script>
|
||||
SELECT st.stcd,st.stnm,r.tm,st.lgtd,st.lttd FROM st_stbprp_b st
|
||||
JOIN st_rsvr_r_real r ON st.stcd = r.stcd
|
||||
JOIN st_river_r_real r ON st.stcd = r.stcd
|
||||
WHERE st.stcd in (select distinct(stcd) from st_stbprp_b_elem where elem ='z')
|
||||
</script>
|
||||
""")
|
||||
|
|
|
|||
|
|
@ -92,85 +92,137 @@ public class StStbprpBService extends ServiceImpl<StStbprpBMapper, StStbprpB> {
|
|||
//水雨情站超过2小时为离线;渗压,渗流,位移暂定超过24小时为离线
|
||||
//雨量站
|
||||
List<StStatusVo> rainList = stbprpBVoMapper.realRainList();
|
||||
Map<String,List<StStatusVo>> rainStationMap = new HashMap<>();
|
||||
rainStationMap.put("online",new ArrayList<>());
|
||||
rainStationMap.put("offline",new ArrayList<>());
|
||||
res.setRainStationMap(rainStationMap);
|
||||
for (StStatusVo stStatusVo : rainList) {
|
||||
String tm = stStatusVo.getTm();
|
||||
if(tm != null && !(DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(tm), new Date()) > 24 )){
|
||||
rainStationMap.get("online").add(stStatusVo);
|
||||
stStatusVo.setStatus(1);
|
||||
onlineCount++;
|
||||
}else{
|
||||
rainStationMap.get("offline").add(stStatusVo);
|
||||
stStatusVo.setStatus(0);
|
||||
offlineCount++;
|
||||
}
|
||||
}
|
||||
//河道水位站
|
||||
res.setRainStationList(rainList);
|
||||
//水库水位站
|
||||
List<StStatusVo> rzList = stbprpBVoMapper.rzList();
|
||||
Map<String,List<StStatusVo>> riverStationMap = new HashMap<>();
|
||||
riverStationMap.put("online",new ArrayList<>());
|
||||
riverStationMap.put("offline",new ArrayList<>());
|
||||
res.setRiverStationMap(riverStationMap);
|
||||
for (StStatusVo stStatusVo : rzList) {
|
||||
String tm = stStatusVo.getTm();
|
||||
if(tm != null && !(DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(tm), new Date()) > 24 )){
|
||||
riverStationMap.get("online").add(stStatusVo);
|
||||
stStatusVo.setStatus(1);
|
||||
onlineCount++;
|
||||
}else{
|
||||
riverStationMap.get("offline").add(stStatusVo);
|
||||
stStatusVo.setStatus(0);
|
||||
offlineCount++;
|
||||
}
|
||||
}
|
||||
//水库水情
|
||||
res.setRsvrStationList(rzList);
|
||||
//河道
|
||||
List<StStatusVo> zList = stbprpBVoMapper.zList();
|
||||
Map<String,List<StStatusVo>> rsvrStationMap = new HashMap<>();
|
||||
rsvrStationMap.put("online",new ArrayList<>());
|
||||
rsvrStationMap.put("offline",new ArrayList<>());
|
||||
res.setRsvrStationMap(rsvrStationMap);
|
||||
for (StStatusVo stStatusVo : zList) {
|
||||
String tm = stStatusVo.getTm();
|
||||
if(tm != null && !(DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(tm), new Date()) > 24 )){
|
||||
rsvrStationMap.get("online").add(stStatusVo);
|
||||
stStatusVo.setStatus(1);
|
||||
onlineCount++;
|
||||
}else{
|
||||
rsvrStationMap.get("offline").add(stStatusVo);
|
||||
stStatusVo.setStatus(0);
|
||||
offlineCount++;
|
||||
}
|
||||
}
|
||||
res.setRiverStationList(zList);
|
||||
// 视频点
|
||||
List<AttCctvBase> attCctvBases = attCctvBaseService.queryList();
|
||||
Map<String,List<StStatusVo>> cctvStationMap = new HashMap<>();
|
||||
cctvStationMap.put("online",new ArrayList<>());
|
||||
cctvStationMap.put("offline",new ArrayList<>());
|
||||
res.setCctvStationMap(cctvStationMap);
|
||||
List<StStatusVo> cctvList = new ArrayList<>();
|
||||
for (AttCctvBase attCctvBase : attCctvBases) {
|
||||
StStatusVo stStatusVo = new StStatusVo();
|
||||
stStatusVo.setStnm(attCctvBase.getName());
|
||||
stStatusVo.setLgtd(attCctvBase.getLgtd() == null?null:new BigDecimal(attCctvBase.getLgtd()));
|
||||
stStatusVo.setLttd(attCctvBase.getLttd() == null?null:new BigDecimal(attCctvBase.getLttd()));
|
||||
cctvStationMap.get("offline").add(stStatusVo);
|
||||
stStatusVo.setStatus(0);
|
||||
cctvList.add(stStatusVo);
|
||||
offlineCount++;
|
||||
}
|
||||
res.setCctvStationList(cctvList);
|
||||
//流量站
|
||||
//TODO 站点编码等真实站点编码来之后需要更改
|
||||
List<StStatusVo> flowList = stbprpBVoMapper.flowStationList();
|
||||
Map<String,List<StStatusVo>> flowStationMap = new HashMap<>();
|
||||
flowStationMap.put("online",new ArrayList<>());
|
||||
flowStationMap.put("offline",new ArrayList<>());
|
||||
res.setFlowStationMap(flowStationMap);
|
||||
for (StStatusVo stStatusVo : flowList) {
|
||||
String tm = stStatusVo.getTm();
|
||||
if(tm != null && !(DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(tm), new Date()) > 24 )){
|
||||
flowStationMap.get("online").add(stStatusVo);
|
||||
stStatusVo.setStatus(1);
|
||||
onlineCount++;
|
||||
}else{
|
||||
flowStationMap.get("offline").add(stStatusVo);
|
||||
stStatusVo.setStatus(0);
|
||||
offlineCount++;
|
||||
}
|
||||
}
|
||||
res.setFlowStationList(flowList);
|
||||
|
||||
//大坝安全监测 渗流 渗压 位移
|
||||
//渗压
|
||||
List<OsmoticPressVo> pressList = pressRMapper.listValue2();
|
||||
List<StStatusVo> syStationList = new ArrayList<>();
|
||||
for (OsmoticPressVo osmoticPressVo : pressList) {
|
||||
StStatusVo vo = new StStatusVo();
|
||||
vo.setStcd(osmoticPressVo.getStationCode());
|
||||
vo.setStnm(osmoticPressVo.getStationCode());
|
||||
vo.setLttd(osmoticPressVo.getLttd());
|
||||
vo.setLgtd(osmoticPressVo.getLgtd());
|
||||
String tm = osmoticPressVo.getTm();
|
||||
if(tm != null && !(DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(tm), new Date()) > 24 )){
|
||||
vo.setStatus(1);
|
||||
onlineCount++;
|
||||
}else{
|
||||
vo.setStatus(0);
|
||||
offlineCount++;
|
||||
}
|
||||
syStationList.add(vo);
|
||||
}
|
||||
res.setSyStationList(syStationList);
|
||||
//渗流
|
||||
List<OsmoticPressVo> slList = pressRMapper.flowListValue2();
|
||||
List<StStatusVo> slStationList = new ArrayList<>();
|
||||
for (OsmoticPressVo osmoticPressVo : slList) {
|
||||
StStatusVo vo = new StStatusVo();
|
||||
vo.setStcd(osmoticPressVo.getStationCode());
|
||||
vo.setStnm(osmoticPressVo.getStationCode());
|
||||
vo.setLttd(osmoticPressVo.getLttd());
|
||||
vo.setLgtd(osmoticPressVo.getLgtd());
|
||||
String tm = osmoticPressVo.getTm();
|
||||
if(tm != null && !(DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(tm), new Date()) > 24 )){
|
||||
vo.setStatus(1);
|
||||
onlineCount++;
|
||||
}else{
|
||||
vo.setStatus(0);
|
||||
offlineCount++;
|
||||
}
|
||||
slStationList.add(vo);
|
||||
}
|
||||
res.setSlStationList(slStationList);
|
||||
//位移
|
||||
List<OsmoticShiftListVo2> wyList = shiftRMapper.listValue2();
|
||||
List<StStatusVo> wyStationList = new ArrayList<>();
|
||||
for (OsmoticShiftListVo2 wy : wyList) {
|
||||
StStatusVo vo = new StStatusVo();
|
||||
vo.setStcd(wy.getCdNm());
|
||||
vo.setStnm(wy.getCdNm());
|
||||
vo.setLttd(wy.getLttd());
|
||||
vo.setLgtd(wy.getLgtd());
|
||||
String tm = wy.getTm();
|
||||
if(tm != null && !(DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(tm), new Date()) > 24 )){
|
||||
vo.setStatus(1);
|
||||
onlineCount++;
|
||||
}else{
|
||||
vo.setStatus(0);
|
||||
offlineCount++;
|
||||
}
|
||||
wyStationList.add(vo);
|
||||
}
|
||||
res.setWyStationList(wyStationList);
|
||||
BigDecimal totalCount = new BigDecimal(onlineCount).add(new BigDecimal(offlineCount));
|
||||
BigDecimal reportPercentage =new BigDecimal(onlineCount).divide(totalCount).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
|
||||
BigDecimal reportPercentage = new BigDecimal(onlineCount)
|
||||
.divide(totalCount, 4, RoundingMode.HALF_UP) // 这里先设置精度
|
||||
.multiply(BigDecimal.valueOf(100))
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
res.setOnlineCount(onlineCount);
|
||||
res.setOffLineCount(offlineCount);
|
||||
res.setReportPercentage(reportPercentage);
|
||||
|
|
|
|||
Loading…
Reference in New Issue