parent
afe18d25b0
commit
90612356eb
|
|
@ -2,6 +2,7 @@ package com.gunshi.project.hsz.controller;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.model.AlarmSet;
|
||||
import com.gunshi.project.hsz.service.AlarmSetService;
|
||||
|
|
@ -69,4 +70,11 @@ public class AlarmSetController {
|
|||
public void test(){
|
||||
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.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.vo.WaterAlarmCount;
|
||||
import com.gunshi.project.hsz.entity.vo.WaterAlarmTypeCount;
|
||||
|
|
@ -78,4 +79,10 @@ public class WaterAlarmController {
|
|||
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.gunshi.project.hsz.common.model.StStbprpB;
|
||||
import com.gunshi.project.hsz.model.AlarmSet;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AlarmSetMapper extends BaseMapper<AlarmSet> {
|
||||
|
||||
|
|
@ -20,4 +23,12 @@ public interface AlarmSetMapper extends BaseMapper<AlarmSet> {
|
|||
)
|
||||
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("""
|
||||
<script>
|
||||
WITH month_series AS (
|
||||
SELECT
|
||||
TO_CHAR(generate_series(
|
||||
DATE_TRUNC('month', #{dto.start}::timestamp),
|
||||
DATE_TRUNC('month', #{dto.end}::timestamp) - INTERVAL '1 month',
|
||||
'1 month'
|
||||
), 'YYYY-MM') AS month
|
||||
)
|
||||
SELECT
|
||||
TO_CHAR(found_time, 'YYYY-MM') AS month,
|
||||
COUNT(*) AS hidden_count
|
||||
FROM hidden_info
|
||||
WHERE found_time >= DATE_TRUNC('month', #{dto.start}::timestamp)
|
||||
AND found_time < DATE_TRUNC('month', #{dto.end}::timestamp) + INTERVAL '1 month'
|
||||
GROUP BY TO_CHAR(found_time, 'YYYY-MM')
|
||||
ORDER BY month;
|
||||
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>
|
||||
""")
|
||||
List<MentenceInfoCount12Vo> selectCount12(@Param("dto") MonthRangeSo monthRangeSo);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
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.WaterAlarmTypeCount;
|
||||
import com.gunshi.project.hsz.model.WaterAlarm;
|
||||
|
|
@ -15,22 +16,28 @@ import java.util.Map;
|
|||
@Mapper
|
||||
public interface WaterAlarmMapper extends BaseMapper<WaterAlarm> {
|
||||
|
||||
@Select("""
|
||||
SELECT
|
||||
EXTRACT(YEAR FROM alarm_time)::INTEGER AS year,
|
||||
TO_CHAR(alarm_time, 'MM') AS month,
|
||||
COUNT(*) AS alarmCount
|
||||
FROM
|
||||
water_alarm
|
||||
WHERE
|
||||
EXTRACT(YEAR FROM alarm_time) = #{year}
|
||||
GROUP BY
|
||||
EXTRACT(YEAR FROM alarm_time),
|
||||
TO_CHAR(alarm_time, 'MM')
|
||||
-- 按月份升序
|
||||
ORDER BY
|
||||
TO_CHAR(alarm_time, 'MM') ASC;
|
||||
""")
|
||||
@Select("""
|
||||
WITH months AS (
|
||||
SELECT
|
||||
#{year} AS year,
|
||||
LPAD(series::text, 2, '0') AS month
|
||||
FROM generate_series(1, 12) AS series
|
||||
)
|
||||
SELECT
|
||||
m.year,
|
||||
m.month,
|
||||
COALESCE(COUNT(wa.alarm_time), 0) AS alarmCount
|
||||
FROM
|
||||
months m
|
||||
LEFT JOIN
|
||||
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);
|
||||
|
||||
|
||||
|
|
@ -61,4 +68,15 @@ ORDER BY
|
|||
limit 1
|
||||
""")
|
||||
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.extension.plugins.pagination.Page;
|
||||
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.mapper.AlarmSetMapper;
|
||||
import com.gunshi.project.hsz.model.AlarmSet;
|
||||
|
|
@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -38,4 +40,8 @@ public class AlarmSetService extends ServiceImpl<AlarmSetMapper, AlarmSet> {
|
|||
}
|
||||
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.extension.plugins.pagination.Page;
|
||||
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.vo.WaterAlarmCount;
|
||||
|
|
@ -55,4 +56,8 @@ public class WaterAlarmService extends ServiceImpl<WaterAlarmMapper, WaterAlarm>
|
|||
List<WaterAlarmTypeCount> res = this.baseMapper.countTypeByYear(year);
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<StStbprpB> listStation() {
|
||||
return this.baseMapper.listStation();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue