统计添加按年按月

This commit is contained in:
cjw 2024-05-21 16:57:28 +08:00
parent b05caaeda5
commit eebc4f3ca1
5 changed files with 49 additions and 28 deletions

View File

@ -106,8 +106,8 @@ public class StatisticController extends BaseController {
* 获取总预警数
*/
@GetMapping("/warn/num")
public R<Integer> getWarnNum() {
return R.ok(statisticService.getWarnNum());
public R<Integer> getWarnNum(String select) {
return R.ok(statisticService.getWarnNum(select));
}
/**
@ -130,16 +130,16 @@ public class StatisticController extends BaseController {
* 获取年级统计包含年级下发布次数和测评次数
*/
@GetMapping("/grade/publish-evaluation")
public R<List<StatisticNumVo>> getGrade() {
return R.ok(statisticService.getPublishAndEvaluationNumByGrade());
public R<List<StatisticNumVo>> getGrade(String select) {
return R.ok(statisticService.getPublishAndEvaluationNumByGrade(select));
}
/**
* 获取年级统计包含年级下各严重度
*/
@GetMapping("/grade/conclusion")
public R<List<StatisticWarnVo>> getConclusion() {
return R.ok(statisticService.getConclusion());
public R<List<StatisticWarnVo>> getConclusion(String select) {
return R.ok(statisticService.getConclusion(select));
}
/**

View File

@ -29,13 +29,13 @@ public interface StatisticMapper {
int selectUserNum();
int selectEvaluationNum();
int selectWarnNum();
int selectWarnNum(@Param("startTime") String startTime);
int selectInterveneNum();
List<StatisticNumVo> selectScalePublishNum();
List<StatisticNumVo> selectPublishNumByGrade();
List<StatisticNumVo> selectEvaluationNumByGrade();
List<StatisticWarnVo> selectConclusion();
List<StatisticNumVo> selectPublishNumByGrade(@Param("startTime") String startTime);
List<StatisticNumVo> selectEvaluationNumByGrade(@Param("startTime") String startTime);
List<StatisticWarnVo> selectConclusion(@Param("startTime") String startTime);
List<StatisticPublishVo> selectPublish();

View File

@ -28,12 +28,12 @@ public interface IStatisticService {
int getUserNum();
int getEvaluationNum();
int getWarnNum();
int getWarnNum(String select);
int getInterveneNum();
List<StatisticNumVo> getScalePublishNum();
List<StatisticNumVo> getPublishAndEvaluationNumByGrade();
List<StatisticNumVo> getPublishAndEvaluationNumByGrade(String select);
List<StatisticWarnVo> getConclusion();
List<StatisticWarnVo> getConclusion(String select);
List<StatisticPublishVo> getPublish();
List<StatisticNumVo> getInterveneAndWarnByYear();

View File

@ -178,8 +178,9 @@ public class StatisticServiceImpl implements IStatisticService {
}
@Override
public int getWarnNum() {
return statisticMapper.selectWarnNum();
public int getWarnNum(String select) {
String startTime = getStartTimeBySelect(select);
return statisticMapper.selectWarnNum(startTime);
}
@Override
@ -193,9 +194,10 @@ public class StatisticServiceImpl implements IStatisticService {
}
@Override
public List<StatisticNumVo> getPublishAndEvaluationNumByGrade() {
List<StatisticNumVo> publishNum = statisticMapper.selectPublishNumByGrade();
List<StatisticNumVo> evaluationNum = statisticMapper.selectEvaluationNumByGrade();
public List<StatisticNumVo> getPublishAndEvaluationNumByGrade(String select) {
String startTime = getStartTimeBySelect(select);
List<StatisticNumVo> publishNum = statisticMapper.selectPublishNumByGrade(startTime);
List<StatisticNumVo> evaluationNum = statisticMapper.selectEvaluationNumByGrade(startTime);
for (StatisticNumVo publish : publishNum) {
for (StatisticNumVo evaluation : evaluationNum) {
if (publish.getName().equals(evaluation.getName())) {
@ -207,8 +209,9 @@ public class StatisticServiceImpl implements IStatisticService {
}
@Override
public List<StatisticWarnVo> getConclusion() {
return statisticMapper.selectConclusion();
public List<StatisticWarnVo> getConclusion(String select) {
String startTime = getStartTimeBySelect(select);
return statisticMapper.selectConclusion(startTime);
}
@Override
@ -234,8 +237,8 @@ public class StatisticServiceImpl implements IStatisticService {
@Override
public List<StatisticNumVo> getInterveneAndWarnByMoth() {
String s = DateUtils.dateTimeNow("yyyy");
String startTime = s + "年01月01日";
String s = DateUtils.dateTimeNow("yyyy月MM月");
String startTime = s + "01日";
List<StatisticNumVo> warnNum = statisticMapper.selectWarnNumByMonth(startTime);
List<StatisticNumVo> interveneNum = statisticMapper.selectInterveneNumByMonth(startTime);
for (StatisticNumVo intervene : interveneNum) {
@ -257,8 +260,20 @@ public class StatisticServiceImpl implements IStatisticService {
@Override
public List<StatisticNumVo> getEvaluationByMonth() {
String s = DateUtils.dateTimeNow("yyyy");
String startTime = s + "年01月01日";
String s = DateUtils.dateTimeNow("yyyy月MM月");
String startTime = s + "01日";
return statisticMapper.selectEvaluationByMouth(startTime);
}
private String getStartTimeBySelect(String select) {
String startTime = null;
if ("year".equals(select)) {
String s = DateUtils.dateTimeNow("yyyy");
startTime = s + "-01-01 00:00:00";
} else if ("month".equals(select)) {
String s = DateUtils.dateTimeNow("yyyy-MM");
startTime = s + "-01 00:00:00";
}
return startTime;
}
}

View File

@ -75,6 +75,7 @@
<select id="selectWarnNum" resultType="int">
select count(*)
from sys_warn_record
where warn_time &gt;= #{startTime}
</select>
<select id="selectInterveneNum" resultType="int">
@ -96,6 +97,7 @@
from sys_dept parent
left join sys_dept d on d.parent_id = parent.dept_id
left join sys_scale_publish sp on FIND_IN_SET(d.dept_id, sp.dept_ids)
<if test="startTime != null"> and sp.create_time &gt;= #{startTime}</if>
where parent.parent_id = 100
group by parent.dept_id
order by parent.order_num
@ -106,6 +108,7 @@
from sys_dept parent
left join sys_dept d on d.parent_id = parent.dept_id
left join sys_evaluation_record er on er.dept_id = d.dept_id
<if test="startTime != null"> and er.create_time &gt;= #{startTime}</if>
where parent.parent_id = 100
group by parent.dept_id
order by parent.order_num
@ -119,10 +122,13 @@
count(if(sfr.situation = 4, 1, null)) as `highNum`,
count(if(sfr.situation = 5, 1, null)) as `majorNum`
from sys_dept parent
left join sys_dept d on d.parent_id = parent.dept_id
left join sys_evaluation_record er on er.dept_id = d.dept_id and er.status = 1
left join sys_evaluation_conclusion ec on ec.record_id = er.record_id and ec.status = 1
left join sys_scale_factor_range sfr on sfr.range_id = ec.factor_range_id
left join sys_dept d on d.parent_id = parent.dept_id
left join sys_evaluation_record er on er.dept_id = d.dept_id and er.status = 1
<if test="startTime != null">
and er.create_time &gt;= #{startTime}
</if>
left join sys_evaluation_conclusion ec on ec.record_id = er.record_id and ec.status = 1
left join sys_scale_factor_range sfr on sfr.range_id = ec.factor_range_id
where parent.parent_id = 100
group by parent.dept_id
order by parent.order_num