增加首页水库水位七日,一个月,半年水位查询;增加责任人板块;增加检测设备运行状况板块;增加预警信息水库超汛限查询。

master
hqx 2024-02-05 14:16:16 +08:00
parent a8271d6ce5
commit df18e330a7
8 changed files with 317 additions and 2 deletions

View File

@ -2,7 +2,12 @@ package com.gunshi.project.xyt.controller;
import com.gunshi.core.annotation.Get;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.vo.ReservoirLevelVo;
import com.gunshi.project.xyt.model.StResPersonRef;
import com.gunshi.project.xyt.service.MonitorEquipmentHealthService;
import com.gunshi.project.xyt.service.ReservoirLevelService;
import com.gunshi.project.xyt.service.StResPersonRefService;
import com.gunshi.project.xyt.service.WarningInfoService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
@ -12,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.List;
/**
* TODO
@ -29,6 +35,12 @@ public class HomePageController {
@Resource
private ReservoirLevelService reservoirLevelService;
@Resource
private StResPersonRefService stResPersonRefService;
@Resource
private WarningInfoService warningInfoService;
@Resource
private MonitorEquipmentHealthService monitorEquipmentHealthService;
@Get(path = "/reservoirLevel/queryChfllv",summary = "根据水库ID查询校核洪水位")
public R<BigDecimal> queryChfllvByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
@ -55,4 +67,41 @@ public class HomePageController {
return R.ok(reservoirLevelService.queryRzByResId(resId));
}
@Get(path = "/reservoirLevel/queryRzSevenDay",summary = "根据水库ID查询七日内每小时平均水库水位")
public R<List<ReservoirLevelVo>> queryRzSevenDayByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
return R.ok(reservoirLevelService.queryRzSevenDayByResId(resId));
}
@Get(path = "/reservoirLevel/queryRzMonth",summary = "根据水库ID查询一个月内每天八点水库水位")
public R<List<ReservoirLevelVo>> queryRzMonthByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
return R.ok(reservoirLevelService.queryRzMonthByResId(resId));
}
@Get(path = "/reservoirLevel/queryRzHalfYear",summary = "根据水库ID查询半年每天八点水库水位")
public R<List<ReservoirLevelVo>> queryRzHalfYearByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
return R.ok(reservoirLevelService.queryRzHalfYearByResId(resId));
}
@Get(path = "/personInCharge/queryStResPersonRef",summary = "根据水库ID查询责任人信息")
public R<List<StResPersonRef>> queryStResPersonRefByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
return R.ok(stResPersonRefService.queryStResPersonRefByResId(resId));
}
@Get(path = "/WarningInfo/ReservoirExceededLimit",summary = "判断水库超汛限是否正常")
public R<Boolean> ReservoirExceededLimit(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
return R.ok(warningInfoService.ReservoirExceededLimit(resId));
}
@Get(path = "/MonitorEquipmentHealth/queryAllStcdCount",summary = "查看监测设备总数")
public R<Long> queryAllStcdCount(){
return R.ok(monitorEquipmentHealthService.queryAllStcdCount());
}
@Get(path = "/MonitorEquipmentHealth/queryOnlineStcdCount",summary = "查看近一个小时检测设备在线数量")
public R<Long> queryOnlineStcdCount(){
return R.ok(monitorEquipmentHealthService.queryOnlineStcdCount());
}
}

View File

@ -0,0 +1,33 @@
package com.gunshi.project.xyt.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* TODO
*
* @ClassName ReservoirLevelVo
* @Author Huang Qianxiang
* @Date 2024/2/5 11:38
*/
@Data
public class ReservoirLevelVo {
/**
*
*/
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date time;
/**
*
*/
private BigDecimal avgRZ;
}

View File

@ -0,0 +1,15 @@
package com.gunshi.project.xyt.mapper;
import org.apache.ibatis.annotations.Select;
public interface StRcvRealMapper {
@Select("""
<script>
SELECT count(*)from ST_RCV_REAL
WHERE TM >= DATEADD(HOUR, -1, GETDATE());
</script>
""")
Long queryOnlineStcdCount();
}

View File

@ -1,6 +1,7 @@
package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.xyt.entity.vo.ReservoirLevelVo;
import com.gunshi.project.xyt.model.StResStcdRef;
import java.math.BigDecimal;
@ -11,6 +12,7 @@ import org.apache.ibatis.annotations.Select;
@Mapper
public interface StResStcdRefMapper extends BaseMapper<StResStcdRef> {
int batchInsert(@Param("list") List<StResStcdRef> list);
@Select("""
@ -22,4 +24,47 @@ public interface StResStcdRefMapper extends BaseMapper<StResStcdRef> {
</script>
""")
BigDecimal queryRzByResId(@Param("resId") String resId);
@Select("""
<script>
SELECT DATEADD(HOUR, DATEDIFF(HOUR, 0, ST_RSVR_R.TM), 0) as time,
AVG(RZ) as avgRZ
FROM ST_RES_STCD_REF,ST_RSVR_R
WHERE ST_RSVR_R.TM &gt;= dateadd(day,-7,getdate()) AND ST_RSVR_R.TM &lt; GETDATE() AND
ST_RES_STCD_REF.STCD = ST_RSVR_R.STCD and
ST_RES_STCD_REF.RES_ID = #{resId}
GROUP BY DATEADD(HOUR, DATEDIFF(HOUR, 0, ST_RSVR_R.TM), 0)
</script>
""")
List<ReservoirLevelVo> queryRzSevenDayByResId(@Param("resId") String resId);
@Select("""
<script>
SELECT DATEADD(HOUR, DATEDIFF(HOUR, 0, ST_RSVR_R.TM), 0) as time,
AVG(RZ) as avgRZ
FROM ST_RES_STCD_REF,ST_RSVR_R
WHERE ST_RSVR_R.TM &gt;= dateadd(day,-30,getdate()) AND ST_RSVR_R.TM &lt; GETDATE() AND
ST_RES_STCD_REF.STCD = ST_RSVR_R.STCD and
DATEPART(HOUR, ST_RSVR_R.TM) = 8 AND
ST_RES_STCD_REF.RES_ID = #{resId}
GROUP BY DATEADD(HOUR, DATEDIFF(HOUR, 0, ST_RSVR_R.TM), 0)
</script>
""")
List<ReservoirLevelVo> queryRzMonthByResId(@Param("resId") String resId);
@Select("""
<script>
SELECT DATEADD(HOUR, DATEDIFF(HOUR, 0, ST_RSVR_R.TM), 0) as time,
AVG(RZ) as avgRZ
FROM ST_RES_STCD_REF,ST_RSVR_R
WHERE ST_RSVR_R.TM &gt;= dateadd(MONTH,-6,getdate()) AND ST_RSVR_R.TM &lt; GETDATE() AND
ST_RES_STCD_REF.STCD = ST_RSVR_R.STCD and
DATEPART(HOUR, ST_RSVR_R.TM) = 8 AND
ST_RES_STCD_REF.RES_ID = #{resId}
GROUP BY DATEADD(HOUR, DATEDIFF(HOUR, 0, ST_RSVR_R.TM), 0)
</script>
""")
List<ReservoirLevelVo> queryRzHalfYearByResId(@Param("resId") String resId);
}

View File

@ -0,0 +1,46 @@
package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gunshi.project.xyt.mapper.StRcvRealMapper;
import com.gunshi.project.xyt.model.StRcvReal;
import com.gunshi.project.xyt.model.StRcvRealAutoDao;
import com.gunshi.project.xyt.model.StStbprpBAutoDao;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* TODO
*
* @ClassName MonitorEquipmentHealthService
* @Author Huang Qianxiang
* @Date 2024/2/2 11:27
*/
@Service
@Slf4j
public class MonitorEquipmentHealthService {
@Resource
private StStbprpBAutoDao stStbprpBAutoDao;
@Resource
private StRcvRealMapper stRcvRealMapper;
/**
*
* @retur
*/
public Long queryAllStcdCount(){
return stStbprpBAutoDao.count();
}
/**
* 线
* @return
*/
public Long queryOnlineStcdCount(){
return stRcvRealMapper.queryOnlineStcdCount();
}
}

View File

@ -1,14 +1,15 @@
package com.gunshi.project.xyt.service;
import com.gunshi.project.xyt.entity.vo.ReservoirLevelVo;
import com.gunshi.project.xyt.mapper.StResStcdRefMapper;
import com.gunshi.project.xyt.model.StResB;
import com.gunshi.project.xyt.model.StResBAutoDao;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
/**
* TODO
@ -19,7 +20,6 @@ import java.math.BigDecimal;
*/
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class ReservoirLevelService {
@Resource
@ -91,4 +91,45 @@ public class ReservoirLevelService {
}
return stResStcdRefMapper.queryRzByResId(resId);
}
/**
* ID
* @param resId ID
* @return
*/
public List<ReservoirLevelVo> queryRzSevenDayByResId(String resId){
StResB stResB = stResBAutoDao.getById(resId);
if (stResB == null){
throw new IllegalArgumentException("该水库ID不存在");
}
return stResStcdRefMapper.queryRzSevenDayByResId(resId);
}
/**
* ID
* @param resId ID
* @return
*/
public List<ReservoirLevelVo> queryRzMonthByResId(String resId){
StResB stResB = stResBAutoDao.getById(resId);
if (stResB == null){
throw new IllegalArgumentException("该水库ID不存在");
}
return stResStcdRefMapper.queryRzMonthByResId(resId);
}
/**
* ID
* @param resId ID
* @return
*/
public List<ReservoirLevelVo> queryRzHalfYearByResId(String resId){
StResB stResB = stResBAutoDao.getById(resId);
if (stResB == null){
throw new IllegalArgumentException("该水库ID不存在");
}
return stResStcdRefMapper.queryRzHalfYearByResId(resId);
}
}

View File

@ -0,0 +1,41 @@
package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gunshi.project.xyt.model.StResPersonRef;
import com.gunshi.project.xyt.model.StResPersonRefAutoDao;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* TODO
*
* @ClassName StResPersonRefService
* @Author Huang Qianxiang
* @Date 2024/2/2 9:28
*/
@Service
@Slf4j
public class StResPersonRefService {
@Resource
private StResPersonRefAutoDao stResPersonRefAutoDao;
/**
* ID
* @param resId ID
* @return
*/
public List<StResPersonRef> queryStResPersonRefByResId(String resId){
QueryWrapper<StResPersonRef> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StResPersonRef.COL_RES_ID,resId);
List<StResPersonRef> resPersonRefList = stResPersonRefAutoDao.list(queryWrapper);
if (resPersonRefList == null){
throw new IllegalArgumentException("未查到该水库相关责任人信息");
}
return resPersonRefList;
}
}

View File

@ -0,0 +1,45 @@
package com.gunshi.project.xyt.service;
import com.gunshi.project.xyt.mapper.StResStcdRefMapper;
import com.gunshi.project.xyt.model.StResB;
import com.gunshi.project.xyt.model.StResBAutoDao;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* TODO
*
* @ClassName WarningInfoService
* @Author Huang Qianxiang
* @Date 2024/2/2 10:00
*/
@Service
@Slf4j
public class WarningInfoService {
@Resource
private StResBAutoDao stResBAutoDao;
@Resource
private StResStcdRefMapper stResStcdRefMapper;
/**
*
* @param resId ID
* @return
*/
public Boolean ReservoirExceededLimit(String resId){
StResB stResB = stResBAutoDao.getById(resId);
if (stResB == null){
throw new IllegalArgumentException("该水库ID不存在");
}
//汛限水位
BigDecimal flLowLimLev = stResB.getFlLowLimLev();
//实时水位
BigDecimal rz = stResStcdRefMapper.queryRzByResId(resId);
return flLowLimLev.compareTo(rz) >= 0;
}
}