修改首页统计查询条件-liyuchen
This commit is contained in:
parent
cfc85721db
commit
742827006e
|
@ -59,11 +59,11 @@ public interface DisasterInfoMapper extends BaseMapper<DisasterInfo> {
|
||||||
* 获取灾害数据 关联字典项
|
* 获取灾害数据 关联字典项
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DisasterInfo> getAllData();
|
List<DisasterInfo> getAllData(@Param("chiefId") Long chiefId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询每个月响应的灾害
|
* 查询每个月响应的灾害
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Map<String, Object>> getDisasterInfoByMouth(@Param("start") String start,@Param("end") String end,@Param("type") Integer type);
|
List<Map<String, Object>> getDisasterInfoByMouth(@Param("start") String start,@Param("end") String end,@Param("type") Integer type,@Param("chief") Long chief);
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,6 +205,11 @@
|
||||||
bdb.dict_value AS dictValue
|
bdb.dict_value AS dictValue
|
||||||
from disaster_info di
|
from disaster_info di
|
||||||
left join blade_dict_biz bdb on bdb.dict_key = di.disaster_type
|
left join blade_dict_biz bdb on bdb.dict_key = di.disaster_type
|
||||||
|
<where>
|
||||||
|
<if test="chiefId != null" >
|
||||||
|
di.chief_id = #{chiefId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getDisasterInfoByMouth" resultType="java.util.Map">
|
<select id="getDisasterInfoByMouth" resultType="java.util.Map">
|
||||||
|
@ -223,6 +228,9 @@
|
||||||
<if test="type == 2">
|
<if test="type == 2">
|
||||||
AND di.respond_status > 1
|
AND di.respond_status > 1
|
||||||
</if>
|
</if>
|
||||||
|
<if test="chiefId != null" >
|
||||||
|
di.chief_id = #{chiefId}
|
||||||
|
</if>
|
||||||
GROUP BY date
|
GROUP BY date
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ import com.kening.vordm.vo.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springblade.common.cache.CacheNames;
|
import org.springblade.common.cache.CacheNames;
|
||||||
import org.springblade.core.redis.cache.BladeRedis;
|
import org.springblade.core.redis.cache.BladeRedis;
|
||||||
|
import org.springblade.core.secure.utils.AuthUtil;
|
||||||
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.api.R;
|
||||||
|
import org.springblade.core.tool.constant.BladeConstant;
|
||||||
import org.springblade.core.tool.utils.DigestUtil;
|
import org.springblade.core.tool.utils.DigestUtil;
|
||||||
import org.springblade.core.tool.utils.StringUtil;
|
import org.springblade.core.tool.utils.StringUtil;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
@ -192,18 +194,19 @@ public class DisasterInfoServiceImpl extends ServiceImpl<DisasterInfoMapper, Dis
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> statistics() {
|
public Map<String, Object> statistics() {
|
||||||
Map<String,Object> resultMap = Maps.newHashMap();
|
Map<String,Object> resultMap = Maps.newHashMap();
|
||||||
//查询灾害表全部数据数据(tip:暂时没有条件 需要的话后期改)
|
boolean isAdmin = AuthUtil.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? true : false;
|
||||||
List<DisasterInfo> disasterInfoList = list();
|
//查询灾害表数据
|
||||||
|
List<DisasterInfo> disasterInfoList = isAdmin ? list():list(Wrappers.<DisasterInfo>lambdaQuery().eq(DisasterInfo::getChiefId,AuthUtil.getUserId()));
|
||||||
//统计head头部的数据
|
//统计head头部的数据
|
||||||
Map<String,Object> headMap = headData(disasterInfoList);
|
Map<String,Object> headMap = headData(disasterInfoList);
|
||||||
//统计灾害发生区域占比
|
//统计灾害发生区域占比
|
||||||
Map<String,Long> countryData = disasterCountryProportion(disasterInfoList);
|
Map<String,Long> countryData = disasterCountryProportion(disasterInfoList);
|
||||||
//统计当年的灾害申请次数 按月查询
|
//统计当年的灾害申请次数 按月查询
|
||||||
List<Map<String,Object>> applyMonth = getDisasterReponseByMouth(1);
|
List<Map<String,Object>> applyMonth = getDisasterReponseByMouth(1,isAdmin);
|
||||||
//统计灾害数量占比
|
//统计灾害数量占比
|
||||||
Map<String,Long> disasterNum = disasterNumProportion();
|
Map<String,Long> disasterNum = disasterNumProportion(isAdmin);
|
||||||
//统计当年的灾害响应次数 按月查询
|
//统计当年的灾害响应次数 按月查询
|
||||||
List<Map<String,Object>> responseMonth = getDisasterReponseByMouth(2);
|
List<Map<String,Object>> responseMonth = getDisasterReponseByMouth(2,isAdmin);
|
||||||
resultMap.put("header",headMap);
|
resultMap.put("header",headMap);
|
||||||
resultMap.put("country",countryData);
|
resultMap.put("country",countryData);
|
||||||
resultMap.put("disasterNum",disasterNum);
|
resultMap.put("disasterNum",disasterNum);
|
||||||
|
@ -249,8 +252,8 @@ public class DisasterInfoServiceImpl extends ServiceImpl<DisasterInfoMapper, Dis
|
||||||
* 计算每个灾害发生的次数
|
* 计算每个灾害发生的次数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Map<String,Long> disasterNumProportion(){
|
private Map<String,Long> disasterNumProportion(boolean type){
|
||||||
List<DisasterInfo> disasterInfoList = baseMapper.getAllData();
|
List<DisasterInfo> disasterInfoList = baseMapper.getAllData(type ? null:AuthUtil.getUserId());
|
||||||
Map<String,Long> proportionMap = disasterInfoList.stream().filter(data->data.getDictValue()!=null).collect(Collectors.groupingBy(DisasterInfo::getDictValue,Collectors.counting()));
|
Map<String,Long> proportionMap = disasterInfoList.stream().filter(data->data.getDictValue()!=null).collect(Collectors.groupingBy(DisasterInfo::getDictValue,Collectors.counting()));
|
||||||
return proportionMap;
|
return proportionMap;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +262,7 @@ public class DisasterInfoServiceImpl extends ServiceImpl<DisasterInfoMapper, Dis
|
||||||
* 按月统计当年每个月的响应或者申请量
|
* 按月统计当年每个月的响应或者申请量
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<Map<String, Object>> getDisasterReponseByMouth(Integer type){
|
private List<Map<String, Object>> getDisasterReponseByMouth(Integer type,boolean isAdmin){
|
||||||
//统计每个月的个数
|
//统计每个月的个数
|
||||||
final String[] MONTH = new String[]{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
|
final String[] MONTH = new String[]{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
|
||||||
int year = LocalDate.now().getYear();
|
int year = LocalDate.now().getYear();
|
||||||
|
@ -268,7 +271,7 @@ public class DisasterInfoServiceImpl extends ServiceImpl<DisasterInfoMapper, Dis
|
||||||
String start = year + "-01-01 00:00:00";
|
String start = year + "-01-01 00:00:00";
|
||||||
//查询结束时间
|
//查询结束时间
|
||||||
String end = year + 1 + "-01-01 00:00:00";
|
String end = year + 1 + "-01-01 00:00:00";
|
||||||
List<Map<String, Object>> mapList = baseMapper.getDisasterInfoByMouth(start,end,type);
|
List<Map<String, Object>> mapList = baseMapper.getDisasterInfoByMouth(start,end,type,isAdmin ? null:AuthUtil.getUserId());
|
||||||
List<DisasterData> disasterList = mapList.stream().map((map) -> {
|
List<DisasterData> disasterList = mapList.stream().map((map) -> {
|
||||||
return cn.hutool.core.bean.BeanUtil.mapToBean(map, DisasterData.class, true);
|
return cn.hutool.core.bean.BeanUtil.mapToBean(map, DisasterData.class, true);
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
Loading…
Reference in New Issue