Commit f1e1ff79 by wqc

app修改s

parent aa5e3cc2
......@@ -65,8 +65,8 @@ public class ShjzStatsController {
@ApiOperation("获取区域统计列表")
@PostMapping(value = "/getAreaShjzStats")
public ResultVo getAreaShjzStats(@RequestBody StatsReqVo vo) {
AssertUtils.notNull(vo.getYear(), "年份不能为空");
return ResultVo.success(shjzStatsService.getAreaShjzStats(vo));
// AssertUtils.notNull(vo.getYear(), "年份不能为空");
return ResultVo.success(shjzStatsService.getCacheAreaShjzStats(vo));
}
}
......@@ -125,4 +125,9 @@ public abstract class PortalCacheKeys {
public static String getFivesYearEnbuzEnjoyStatsKey(StatsReqVo vo) {
return PREFIX + "getFivesYearEnbuzEnjoyStats." + vo.getAreaCode();
}
// 获取区域下的救助统计
public static String getAreaShjzStats(StatsReqVo vo) {
return PREFIX + "getAreaShjzStats." + vo.getAreaCode();
}
}
......@@ -210,6 +210,7 @@ public class CjStatsService {
}
SystemArea systemArea = areaDao.selectById(vo.getAreaCode());
vo.setSubAreaCode(systemArea.subAreaCode());
vo.setSize(SystemArea.getNextLevelLength(systemArea.getType()));
List<String> areaList = new ArrayList<>();
List<String> severeIssueNumList = new ArrayList<>();
......@@ -222,13 +223,17 @@ public class CjStatsService {
vo.setType("1"); // 重度
List<StatsVo> severeAreaIssueStats = cjStatsDao.getAreaIssueStats(vo);
for (StatsVo severeAreaIssueStat : severeAreaIssueStats) {
areaList.add(severeAreaIssueStat.getName());
SystemArea area = areaDao.selectById(SystemArea.patchZero(severeAreaIssueStat.getCode()));
if(area==null){
continue;
}
areaList.add(area.getName());
severeIssueNumList.add(String.valueOf(severeAreaIssueStat.getNum()));
severeIssueAmountList.add(severeAreaIssueStat.getAmount());
vo.setSubAreaCode(severeAreaIssueStat.getCode());
Map<String, Object> data = new HashMap<>();
data.put("areaName", severeAreaIssueStat.getName());
data.put("areaName", area.getName());
data.put("areaCode",severeAreaIssueStat.getCode());
data.put("severePeopleNum", cjStatsDao.getSeverePeopleNumStats(vo).getNum());
data.put("issueNum", severeAreaIssueStat.getNum());
......@@ -239,16 +244,17 @@ public class CjStatsService {
vo.setSubAreaCode(systemArea.subAreaCode());
vo.setType("2"); // 困难
List<StatsVo> difficultAreaIssueStats = cjStatsDao.getAreaIssueStats(vo);
for (int i = 0; i < difficultAreaIssueStats.size(); i++) {
difficultIssueNumList.add(String.valueOf(difficultAreaIssueStats.get(i).getNum()));
difficultIssueAmountList.add(difficultAreaIssueStats.get(i).getAmount());
for (StatsVo statsVo : difficultAreaIssueStats) {
// 拿上面的数据下来累加
Map<String, Object> data = areaPeopleNumList.get(i);
BigDecimal issueNum = new BigDecimal(data.get("issueNum").toString()).add(BigDecimal.valueOf(difficultAreaIssueStats.get(i).getNum()));
BigDecimal issueAmount = new BigDecimal(data.get("issueAmount").toString()).add(new BigDecimal(difficultAreaIssueStats.get(i).getAmount()));
Optional<Map<String, Object>> oData = areaPeopleNumList.stream().filter(m -> m.get("areaCode").toString().equals(statsVo.getCode())).findFirst();
oData.ifPresent(data -> {
difficultIssueNumList.add(String.valueOf(statsVo.getNum()));
difficultIssueAmountList.add(statsVo.getAmount());
BigDecimal issueNum = new BigDecimal(data.get("issueNum").toString()).add(BigDecimal.valueOf(statsVo.getNum()));
BigDecimal issueAmount = new BigDecimal(data.get("issueAmount").toString()).add(new BigDecimal(statsVo.getAmount()));
data.put("issueNum", issueNum);
data.put("issueAmount", issueAmount);
});
}
Map<String, Object> returnData = new HashMap<>();
......@@ -259,7 +265,7 @@ public class CjStatsService {
returnData.put("difficultIssueAmountList", difficultIssueAmountList);
returnData.put("areaPeopleNumList", areaPeopleNumList);
redisUtils.setObj(PortalCacheKeys.getAreaDisabledIssueStatsKey(vo), returnData);
// redisUtils.setObj(PortalCacheKeys.getAreaDisabledIssueStatsKey(vo), returnData);
return returnData;
}
......
......@@ -332,6 +332,14 @@ public class ShjzStatsService {
return toatlNum;
}
public Object getCacheAreaShjzStats(StatsReqVo vo) {
Object obj = redisUtils.getObj(PortalCacheKeys.getAreaShjzStats(vo));
if(obj!=null){
return obj;
}
return getAreaShjzStats(vo);
}
public Object getAreaShjzStats(StatsReqVo vo) {
if (StringUtils.isBlank(vo.getAreaCode())) {
vo.setAreaCode("450000000000");
......@@ -342,56 +350,48 @@ public class ShjzStatsService {
vo.setSize(SystemArea.getNextLevelLength(systemArea.getType()));
// 人数
vo.setType("农村低保");// 城市
List<StatsVo> cityPeopleNumStats = shjzStatsDao.getPeopleNumStats(vo);
vo.setType("城市低保");// 农村
List<StatsVo> villagePeopleNumStats = shjzStatsDao.getPeopleNumStats(vo);
vo.setType("1");// 城市
List<StatsVo> cityMonyStats = shjzStatsDao.getMonyNumStats(vo);
vo.setType("0");// 农村
List<StatsVo> villageMonyStats = shjzStatsDao.getMonyNumStats(vo);
List<StatsVo> peopleNumStats = shjzStatsDao.getPeopleNumStats(vo);
// 金额
List<StatsVo> monyStats = shjzStatsDao.getMonyNumStats(vo);
Map<String, Map<String, Object>> map = new HashMap<>();
// 添加城市低保人数
List<StatsVo> cityPeopleNumStats = peopleNumStats.stream().filter(statsVo -> "农村低保".equals(statsVo.getType())).collect(Collectors.toList());
cityPeopleNumStats.forEach(statsVo -> {
Map<String, Object> data = map.get(statsVo.getCode());
if (data == null) {
data = new HashMap<>();
}
Map<String, Object> data = map.computeIfAbsent(statsVo.getCode(), k -> new HashMap<>());
data.put("cityPeopleNum", statsVo.getNum());
});
// 添加农村低保人数
List<StatsVo> villagePeopleNumStats = peopleNumStats.stream().filter(statsVo -> "城市低保".equals(statsVo.getType())).collect(Collectors.toList());
villagePeopleNumStats.forEach(statsVo -> {
Map<String, Object> data = map.get(statsVo.getCode());
if (data == null) {
data = new HashMap<>();
}
Map<String, Object> data = map.computeIfAbsent(statsVo.getCode(), k -> new HashMap<>());
data.put("villagePeopleNum", statsVo.getNum());
});
// 添加城市发放金额
List<StatsVo> cityMonyStats = monyStats.stream().filter(statsVo -> "1".equals(statsVo.getType())).collect(Collectors.toList());
cityMonyStats.forEach(statsVo -> {
Map<String, Object> data = map.get(statsVo.getCode());
if (data == null) {
data = new HashMap<>();
}
Map<String, Object> data = map.computeIfAbsent(statsVo.getCode(), k -> new HashMap<>());
data.put("cityMony", statsVo.getAmount());
});
// 添加农村发放金额
List<StatsVo> villageMonyStats = monyStats.stream().filter(statsVo -> "0".equals(statsVo.getType())).collect(Collectors.toList());
villageMonyStats.forEach(statsVo -> {
Map<String, Object> data = map.get(statsVo.getCode());
if (data == null) {
data = new HashMap<>();
}
Map<String, Object> data = map.computeIfAbsent(statsVo.getCode(), k -> new HashMap<>());
data.put("villageMony", statsVo.getAmount());
});
List<Map<String, Object>> returnData = new ArrayList<>();
List<Map<String, Object>> dataList = new ArrayList<>();
// map数据转成list,提示添加key为区域码
map.forEach((k, v) -> {
SystemArea area = areaDao.selectById(SystemArea.patchZero(k));
v.put("areaCode", k);
returnData.add(v);
v.put("city", area!=null?area.getName():"");
dataList.add(v);
});
List<Map<String,Object>> returnData = dataList.stream().sorted(Comparator.comparing(m -> m.get("areaCode").toString())).collect(Collectors.toList());
redisUtils.setObj(PortalCacheKeys.getAreaShjzStats(vo), returnData);
return returnData;
// // 人数
......
......@@ -302,6 +302,7 @@ public class StatsTimingTask {
shjzStatsService.getEnjoyNum(StatsReqVo.builder().areaCode(areaCode).year(year).build());
shjzStatsService.getAreaUnderNumStats(StatsReqVo.builder().areaCode(areaCode).year(year).build());
shjzStatsService.getFivesYearEnjoyStats(StatsReqVo.builder().areaCode(areaCode).build());
shjzStatsService.getAreaShjzStats(StatsReqVo.builder().areaCode(areaCode).build());
}
}
......@@ -7,7 +7,6 @@
LEFT(d.ups, #{size}) 'code',
COUNT( 1 ) 'num'
FROM
FROM
dic_city d
LEFT JOIN fis_cremation_info_sum f ON d.P_ID = f.POPULACE
WHERE 1=1
......
......@@ -66,17 +66,20 @@
</select>
<select id="getAreaIssueStats" resultType="com.zq.portal.vo.StatsVo">
SELECT LEFT(UNIT_ID, #{size}) 'code',UNIT_NAME 'name', APPLY_TYPE_ID 'type', GRANT_YEAR 'year', COUNT_PEOPLE 'num', SUM_MONEY
SELECT LEFT(UNIT_ID, #{size}) 'code', APPLY_TYPE_ID 'type', GRANT_YEAR 'year', COUNT_PEOPLE 'num', SUM_MONEY
'amount'
FROM `statics_grant`
WHERE DATE_FORMAT(create_time, '%Y-%m-%d') = (SELECT DATE_FORMAT(create_time, '%Y-%m-%d') FROM statics_grant
ORDER BY create_time DESC LIMIT 1)
WHERE DATE_FORMAT(create_time, '%Y-%m-%d') = (SELECT DATE_FORMAT(create_time, '%Y-%m-%d') FROM statics_grant ORDER BY create_time DESC LIMIT 1)
AND CHAR_LENGTH (LEFT ( UNIT_ID, #{size} )) = #{size}
<if test="year != null">
AND GRANT_YEAR = #{year}
</if>
<if test="type != null">
AND APPLY_TYPE_ID = #{type}
</if>
<if test="subAreaCode != null and subAreaCode != ''">
AND UNIT_ID LIKE CONCAT(#{subAreaCode}, '%')
</if>
GROUP BY LEFT(UNIT_ID, #{size})
</select>
......
......@@ -189,6 +189,7 @@
<select id="getPeopleNumStats" resultType="com.zq.portal.vo.StatsVo">
SELECT
LEFT ( a.area_code, #{size} ) 'code',
a.type 'type',
SUM(a.people_num) 'num'
FROM city_coutry_all a
WHERE
......@@ -200,13 +201,15 @@
AND a.type = #{type}
</if>
GROUP BY
LEFT ( a.area_code, #{size} )
LEFT ( a.area_code, #{size} ),
a.type
</select>
<!-- iscity = 1 是城市 0是农村 -->
<select id="getMonyNumStats" resultType="com.zq.portal.vo.StatsVo">
SELECT
LEFT(p.unit_id, #{size}) 'code',
p.iscity 'type',
SUM( p.money ) 'amount'
FROM
mon_pay p
......@@ -223,7 +226,8 @@
AND p.iscity = #{type}
</if>
GROUP BY
LEFT(p.unit_id, #{size})
LEFT(p.unit_id, #{size}),
p.iscity
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment