diff --git a/src/main/java/com/gunshi/project/xyt/controller/HomePageController.java b/src/main/java/com/gunshi/project/xyt/controller/HomePageController.java index 220507d..12271ab 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/HomePageController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/HomePageController.java @@ -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 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> queryRzSevenDayByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryRzSevenDayByResId(resId)); + } + + @Get(path = "/reservoirLevel/queryRzMonth",summary = "根据水库ID查询一个月内每天八点水库水位") + public R> queryRzMonthByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryRzMonthByResId(resId)); + } + + @Get(path = "/reservoirLevel/queryRzHalfYear",summary = "根据水库ID查询半年每天八点水库水位") + public R> queryRzHalfYearByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(reservoirLevelService.queryRzHalfYearByResId(resId)); + } + + @Get(path = "/personInCharge/queryStResPersonRef",summary = "根据水库ID查询责任人信息") + public R> queryStResPersonRefByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(stResPersonRefService.queryStResPersonRefByResId(resId)); + } + + @Get(path = "/WarningInfo/ReservoirExceededLimit",summary = "判断水库超汛限是否正常") + public R ReservoirExceededLimit(@Parameter(description = "水库ID") @RequestParam("resId") String resId){ + return R.ok(warningInfoService.ReservoirExceededLimit(resId)); + } + + @Get(path = "/MonitorEquipmentHealth/queryAllStcdCount",summary = "查看监测设备总数") + public R queryAllStcdCount(){ + return R.ok(monitorEquipmentHealthService.queryAllStcdCount()); + } + + @Get(path = "/MonitorEquipmentHealth/queryOnlineStcdCount",summary = "查看近一个小时检测设备在线数量") + public R queryOnlineStcdCount(){ + return R.ok(monitorEquipmentHealthService.queryOnlineStcdCount()); + } + + + } diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/ReservoirLevelVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/ReservoirLevelVo.java new file mode 100644 index 0000000..3877af5 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/ReservoirLevelVo.java @@ -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; + +} diff --git a/src/main/java/com/gunshi/project/xyt/mapper/StRcvRealMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/StRcvRealMapper.java new file mode 100644 index 0000000..f5bbb03 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/mapper/StRcvRealMapper.java @@ -0,0 +1,15 @@ +package com.gunshi.project.xyt.mapper; + +import org.apache.ibatis.annotations.Select; + +public interface StRcvRealMapper { + + @Select(""" + + """) + Long queryOnlineStcdCount(); + +} diff --git a/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java index 50c67c5..5cd04e3 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/StResStcdRefMapper.java @@ -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 { + int batchInsert(@Param("list") List list); @Select(""" @@ -22,4 +24,47 @@ public interface StResStcdRefMapper extends BaseMapper { """) BigDecimal queryRzByResId(@Param("resId") String resId); + + @Select(""" + + """) + List queryRzSevenDayByResId(@Param("resId") String resId); + + @Select(""" + + """) + List queryRzMonthByResId(@Param("resId") String resId); + + + @Select(""" + + """) + List queryRzHalfYearByResId(@Param("resId") String resId); + } \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/service/MonitorEquipmentHealthService.java b/src/main/java/com/gunshi/project/xyt/service/MonitorEquipmentHealthService.java new file mode 100644 index 0000000..603c557 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/MonitorEquipmentHealthService.java @@ -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(); + } + + + +} diff --git a/src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java b/src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java index 8d89357..a02c82c 100644 --- a/src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java +++ b/src/main/java/com/gunshi/project/xyt/service/ReservoirLevelService.java @@ -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 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 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 queryRzHalfYearByResId(String resId){ + StResB stResB = stResBAutoDao.getById(resId); + if (stResB == null){ + throw new IllegalArgumentException("该水库ID不存在"); + } + return stResStcdRefMapper.queryRzHalfYearByResId(resId); + } + } diff --git a/src/main/java/com/gunshi/project/xyt/service/StResPersonRefService.java b/src/main/java/com/gunshi/project/xyt/service/StResPersonRefService.java new file mode 100644 index 0000000..f0175bd --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/StResPersonRefService.java @@ -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 queryStResPersonRefByResId(String resId){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(StResPersonRef.COL_RES_ID,resId); + List resPersonRefList = stResPersonRefAutoDao.list(queryWrapper); + if (resPersonRefList == null){ + throw new IllegalArgumentException("未查到该水库相关责任人信息"); + } + return resPersonRefList; + } + +} diff --git a/src/main/java/com/gunshi/project/xyt/service/WarningInfoService.java b/src/main/java/com/gunshi/project/xyt/service/WarningInfoService.java new file mode 100644 index 0000000..552393b --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/WarningInfoService.java @@ -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; + + } +}