提交代码

This commit is contained in:
遥望-倪浩天 2024-08-13 12:46:30 +08:00
parent 98612bc0c8
commit 8f25db4ef2
5 changed files with 120 additions and 7 deletions

View File

@ -857,8 +857,72 @@ public class DisasterInfoController {
//home页面 受影响国家统计 //home页面 受影响国家统计
@GetMapping("/getAffectedCountryCount") @GetMapping("/getAffectedCountryCount")
public R<Integer> getAffectedCountryCount() { public R<Integer> getAffectedCountryCount(@RequestParam Map<String, String> params) {
return R.data(disasterInfoService.getAffectedCountryCount()); String dateType = String.valueOf(params.get("dateType"));
if (StringUtils.isNotBlank(dateType) && !"4".equals(dateType) && !"null".equals(dateType)) {
LocalDate date = LocalDate.now();
//如果有时间类型
switch (dateType) {
case "1":
//Latest week 上一周
date = LocalDate.now().minusWeeks(1);
params.put("startTime",date.toString());
break;
case "2":
//Latest month 上一个月
date = LocalDate.now().minusMonths(1);
params.put("startTime",date.toString());
break;
case "3":
//Latest six month 上3个月
date = LocalDate.now().minusMonths(3);
params.put("startTime",date.toString());
break;
case "5":
//Latest six month 上6个月
date = LocalDate.now().minusMonths(6);
params.put("startTime",date.toString());
break;
default:
break;
}
}
return R.data(disasterInfoService.getAffectedCountryCount(params));
}
//home页面 灾害类型数量统计
@GetMapping("/getDisasterCountryCount")
public R<Integer> getDisasterCountryCount(@RequestParam Map<String, String> params) {
String dateType = String.valueOf(params.get("dateType"));
if (StringUtils.isNotBlank(dateType) && !"4".equals(dateType) && !"null".equals(dateType)) {
LocalDate date = LocalDate.now();
//如果有时间类型
switch (dateType) {
case "1":
//Latest week 上一周
date = LocalDate.now().minusWeeks(1);
params.put("startTime",date.toString());
break;
case "2":
//Latest month 上一个月
date = LocalDate.now().minusMonths(1);
params.put("startTime",date.toString());
break;
case "3":
//Latest six month 上3个月
date = LocalDate.now().minusMonths(3);
params.put("startTime",date.toString());
break;
case "5":
//Latest six month 上6个月
date = LocalDate.now().minusMonths(6);
params.put("startTime",date.toString());
break;
default:
break;
}
}
return R.data(disasterInfoService.getDisasterCountryCount(params));
} }
} }

View File

@ -118,5 +118,7 @@ public interface DisasterInfoMapper extends BaseMapper<DisasterInfo> {
void updateApplyForCount(@Param("id") Long id); void updateApplyForCount(@Param("id") Long id);
Integer getAffectedCountryCount(); Integer getAffectedCountryCount(@Param("params")Map<String, String> params);
Integer getDisasterCountryCount(@Param("params")Map<String, String> params);
} }

View File

@ -1723,6 +1723,46 @@
<select id="getAffectedCountryCount" resultType="java.lang.Integer"> <select id="getAffectedCountryCount" resultType="java.lang.Integer">
SELECT count(*) FROM SELECT count(*) FROM
(SELECT disaster_country FROM `disaster_info` where respond_status = 2 GROUP BY disaster_country) disaster (SELECT disaster_country FROM `disaster_info`
<where>
<if test="params.respondStatus!=null and params.respondStatus!=''">
and respond_status = #{params.respondStatus}
</if>
<if test="params.affectedArea!=null and params.affectedArea!=''">
and disaster_country = #{params.affectedArea}
</if>
<if test="params.disasterType!=null and params.disasterType!=''">
and disaster_type = #{params.disasterType}
</if>
<if test="params.startTime!=null and params.startTime!=''">
and disaster_time &gt;= #{params.startTime}
</if>
<if test="params.endTime!=null and params.endTime!=''">
and disaster_time &lt;= #{params.endTime}
</if>
</where>
GROUP BY disaster_country) disaster
</select>
<select id="getDisasterCountryCount" resultType="java.lang.Integer">
SELECT count(*) FROM
(SELECT disaster_type FROM `disaster_info`
<where>
<if test="params.respondStatus!=null and params.respondStatus!=''">
and respond_status = #{params.respondStatus}
</if>
<if test="params.affectedArea!=null and params.affectedArea!=''">
and disaster_country = #{params.affectedArea}
</if>
<if test="params.disasterType!=null and params.disasterType!=''">
and disaster_type = #{params.disasterType}
</if>
<if test="params.startTime!=null and params.startTime!=''">
and disaster_time &gt;= #{params.startTime}
</if>
<if test="params.endTime!=null and params.endTime!=''">
and disaster_time &lt;= #{params.endTime}
</if>
</where>
GROUP BY disaster_type) disaster
</select> </select>
</mapper> </mapper>

View File

@ -99,5 +99,7 @@ public interface DisasterInfoService extends IService<DisasterInfo> {
void updateApplyForCount(Long disasterId); void updateApplyForCount(Long disasterId);
Integer getAffectedCountryCount(); Integer getAffectedCountryCount(Map<String, String> params);
Integer getDisasterCountryCount(Map<String, String> params);
} }

View File

@ -628,7 +628,12 @@ public class DisasterInfoServiceImpl extends ServiceImpl<DisasterInfoMapper, Dis
} }
@Override @Override
public Integer getAffectedCountryCount() { public Integer getAffectedCountryCount(Map<String, String> params) {
return baseMapper.getAffectedCountryCount(); return baseMapper.getAffectedCountryCount(params);
}
@Override
public Integer getDisasterCountryCount(Map<String, String> params) {
return baseMapper.getDisasterCountryCount(params);
} }
} }