parent
afe18d25b0
commit
90612356eb
|
|
@ -2,6 +2,7 @@ package com.gunshi.project.hsz.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.gunshi.core.result.R;
|
import com.gunshi.core.result.R;
|
||||||
|
import com.gunshi.project.hsz.common.model.StStbprpB;
|
||||||
import com.gunshi.project.hsz.entity.so.AlarmSetPageSo;
|
import com.gunshi.project.hsz.entity.so.AlarmSetPageSo;
|
||||||
import com.gunshi.project.hsz.model.AlarmSet;
|
import com.gunshi.project.hsz.model.AlarmSet;
|
||||||
import com.gunshi.project.hsz.service.AlarmSetService;
|
import com.gunshi.project.hsz.service.AlarmSetService;
|
||||||
|
|
@ -69,4 +70,11 @@ public class AlarmSetController {
|
||||||
public void test(){
|
public void test(){
|
||||||
alarmTask.updateAlarmSet();
|
alarmTask.updateAlarmSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "获取河道站点")
|
||||||
|
@GetMapping("/listStation")
|
||||||
|
public R<List<StStbprpB>> listStation(){
|
||||||
|
return R.ok(service.listStation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.gunshi.project.hsz.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.gunshi.core.result.R;
|
import com.gunshi.core.result.R;
|
||||||
|
import com.gunshi.project.hsz.common.model.StStbprpB;
|
||||||
import com.gunshi.project.hsz.entity.so.WaterAlarmPageSo;
|
import com.gunshi.project.hsz.entity.so.WaterAlarmPageSo;
|
||||||
import com.gunshi.project.hsz.entity.vo.WaterAlarmCount;
|
import com.gunshi.project.hsz.entity.vo.WaterAlarmCount;
|
||||||
import com.gunshi.project.hsz.entity.vo.WaterAlarmTypeCount;
|
import com.gunshi.project.hsz.entity.vo.WaterAlarmTypeCount;
|
||||||
|
|
@ -78,4 +79,10 @@ public class WaterAlarmController {
|
||||||
return R.ok(res);
|
return R.ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取河道和水库站点")
|
||||||
|
@GetMapping("/listStation")
|
||||||
|
public R<List<StStbprpB>> listStation(){
|
||||||
|
return R.ok(service.listStation());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,14 @@ package com.gunshi.project.hsz.mapper;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.hsz.common.model.StStbprpB;
|
||||||
import com.gunshi.project.hsz.model.AlarmSet;
|
import com.gunshi.project.hsz.model.AlarmSet;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AlarmSetMapper extends BaseMapper<AlarmSet> {
|
public interface AlarmSetMapper extends BaseMapper<AlarmSet> {
|
||||||
|
|
||||||
|
|
@ -20,4 +23,12 @@ public interface AlarmSetMapper extends BaseMapper<AlarmSet> {
|
||||||
)
|
)
|
||||||
AlarmSet queryByStcd(@Param("stcd") String stcd);
|
AlarmSet queryByStcd(@Param("stcd") String stcd);
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
select t1.* from st_stbprp_b t1
|
||||||
|
join st_stbprp_b_elem t2
|
||||||
|
on t1.stcd = t2.stcd
|
||||||
|
where t2.elem = 'z'
|
||||||
|
""")
|
||||||
|
List<StStbprpB> listStation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,23 @@ public interface HiddenInfoMapper extends BaseMapper<HiddenInfo> {
|
||||||
|
|
||||||
@Select("""
|
@Select("""
|
||||||
<script>
|
<script>
|
||||||
|
WITH month_series AS (
|
||||||
SELECT
|
SELECT
|
||||||
TO_CHAR(found_time, 'YYYY-MM') AS month,
|
TO_CHAR(generate_series(
|
||||||
COUNT(*) AS hidden_count
|
DATE_TRUNC('month', #{dto.start}::timestamp),
|
||||||
FROM hidden_info
|
DATE_TRUNC('month', #{dto.end}::timestamp) - INTERVAL '1 month',
|
||||||
WHERE found_time >= DATE_TRUNC('month', #{dto.start}::timestamp)
|
'1 month'
|
||||||
AND found_time < DATE_TRUNC('month', #{dto.end}::timestamp) + INTERVAL '1 month'
|
), 'YYYY-MM') AS month
|
||||||
GROUP BY TO_CHAR(found_time, 'YYYY-MM')
|
)
|
||||||
ORDER BY month;
|
SELECT
|
||||||
|
ms.month,
|
||||||
|
COALESCE(COUNT(hi.found_time), 0) AS hidden_count
|
||||||
|
FROM month_series ms
|
||||||
|
LEFT JOIN hidden_info hi ON ms.month = TO_CHAR(hi.found_time, 'YYYY-MM')
|
||||||
|
AND hi.found_time >= DATE_TRUNC('month', #{dto.start}::timestamp)
|
||||||
|
AND hi.found_time < DATE_TRUNC('month', #{dto.end}::timestamp) + INTERVAL '1 month'
|
||||||
|
GROUP BY ms.month
|
||||||
|
ORDER BY ms.month;
|
||||||
</script>
|
</script>
|
||||||
""")
|
""")
|
||||||
List<MentenceInfoCount12Vo> selectCount12(@Param("dto") MonthRangeSo monthRangeSo);
|
List<MentenceInfoCount12Vo> selectCount12(@Param("dto") MonthRangeSo monthRangeSo);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.gunshi.project.hsz.mapper;
|
package com.gunshi.project.hsz.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.hsz.common.model.StStbprpB;
|
||||||
import com.gunshi.project.hsz.entity.vo.WaterAlarmCount;
|
import com.gunshi.project.hsz.entity.vo.WaterAlarmCount;
|
||||||
import com.gunshi.project.hsz.entity.vo.WaterAlarmTypeCount;
|
import com.gunshi.project.hsz.entity.vo.WaterAlarmTypeCount;
|
||||||
import com.gunshi.project.hsz.model.WaterAlarm;
|
import com.gunshi.project.hsz.model.WaterAlarm;
|
||||||
|
|
@ -16,21 +17,27 @@ import java.util.Map;
|
||||||
public interface WaterAlarmMapper extends BaseMapper<WaterAlarm> {
|
public interface WaterAlarmMapper extends BaseMapper<WaterAlarm> {
|
||||||
|
|
||||||
@Select("""
|
@Select("""
|
||||||
SELECT
|
WITH months AS (
|
||||||
EXTRACT(YEAR FROM alarm_time)::INTEGER AS year,
|
SELECT
|
||||||
TO_CHAR(alarm_time, 'MM') AS month,
|
#{year} AS year,
|
||||||
COUNT(*) AS alarmCount
|
LPAD(series::text, 2, '0') AS month
|
||||||
FROM
|
FROM generate_series(1, 12) AS series
|
||||||
water_alarm
|
)
|
||||||
WHERE
|
SELECT
|
||||||
EXTRACT(YEAR FROM alarm_time) = #{year}
|
m.year,
|
||||||
GROUP BY
|
m.month,
|
||||||
EXTRACT(YEAR FROM alarm_time),
|
COALESCE(COUNT(wa.alarm_time), 0) AS alarmCount
|
||||||
TO_CHAR(alarm_time, 'MM')
|
FROM
|
||||||
-- 按月份升序
|
months m
|
||||||
ORDER BY
|
LEFT JOIN
|
||||||
TO_CHAR(alarm_time, 'MM') ASC;
|
water_alarm wa ON m.year = EXTRACT(YEAR FROM wa.alarm_time)
|
||||||
""")
|
AND m.month = TO_CHAR(wa.alarm_time, 'MM')
|
||||||
|
AND EXTRACT(YEAR FROM wa.alarm_time) = #{year}
|
||||||
|
GROUP BY
|
||||||
|
m.year, m.month
|
||||||
|
ORDER BY
|
||||||
|
m.month ASC;
|
||||||
|
""")
|
||||||
List<WaterAlarmCount> count12(@Param("year") Integer year);
|
List<WaterAlarmCount> count12(@Param("year") Integer year);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -61,4 +68,15 @@ ORDER BY
|
||||||
limit 1
|
limit 1
|
||||||
""")
|
""")
|
||||||
WaterAlarm selectByStcdNew(@Param("stcd") String stcd);
|
WaterAlarm selectByStcdNew(@Param("stcd") String stcd);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
select t1.* from st_stbprp_b t1
|
||||||
|
join st_stbprp_b_elem t2
|
||||||
|
on t1.stcd = t2.stcd
|
||||||
|
where t2.elem in ('rz','z')
|
||||||
|
""")
|
||||||
|
List<StStbprpB> listStation();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.hsz.common.model.StStbprpB;
|
||||||
import com.gunshi.project.hsz.entity.so.AlarmSetPageSo;
|
import com.gunshi.project.hsz.entity.so.AlarmSetPageSo;
|
||||||
import com.gunshi.project.hsz.mapper.AlarmSetMapper;
|
import com.gunshi.project.hsz.mapper.AlarmSetMapper;
|
||||||
import com.gunshi.project.hsz.model.AlarmSet;
|
import com.gunshi.project.hsz.model.AlarmSet;
|
||||||
|
|
@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
@ -38,4 +40,8 @@ public class AlarmSetService extends ServiceImpl<AlarmSetMapper, AlarmSet> {
|
||||||
}
|
}
|
||||||
return save(dto);
|
return save(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<StStbprpB> listStation() {
|
||||||
|
return this.baseMapper.listStation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.hsz.common.model.StStbprpB;
|
||||||
import com.gunshi.project.hsz.entity.so.WaterAlarmPageSo;
|
import com.gunshi.project.hsz.entity.so.WaterAlarmPageSo;
|
||||||
|
|
||||||
import com.gunshi.project.hsz.entity.vo.WaterAlarmCount;
|
import com.gunshi.project.hsz.entity.vo.WaterAlarmCount;
|
||||||
|
|
@ -55,4 +56,8 @@ public class WaterAlarmService extends ServiceImpl<WaterAlarmMapper, WaterAlarm>
|
||||||
List<WaterAlarmTypeCount> res = this.baseMapper.countTypeByYear(year);
|
List<WaterAlarmTypeCount> res = this.baseMapper.countTypeByYear(year);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<StStbprpB> listStation() {
|
||||||
|
return this.baseMapper.listStation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue