综合统计初始化多线程处理
This commit is contained in:
parent
05dd5b0fbb
commit
f37142db29
@ -155,7 +155,7 @@ public class CountController extends AbstractController {
|
||||
@RequestParam(name = "areaId", required = false) String areaId,
|
||||
@RequestParam(name = "areaLevel", required = false) Integer areaLevel) {
|
||||
Map<String, Object> result = CheckDetailTable.getInstance().get(year, areaId);
|
||||
if(result == null) {
|
||||
if (result == null) {
|
||||
return countService.countCheckDetailTable(areaId, areaLevel, year);
|
||||
}
|
||||
return new SuccessResultData<>(result);
|
||||
@ -172,7 +172,10 @@ public class CountController extends AbstractController {
|
||||
public SuccessResultData<Map<String, Object>> countGridCheckDetailTable(@PathVariable("year") String year,
|
||||
@PathVariable("areaId") String areaId,
|
||||
@PathVariable("areaLevel") Integer areaLevel) {
|
||||
Map<String, Object> result = countService.countGridCheckDetailTable(areaId, areaLevel, year);
|
||||
Map<String, Object> result = CheckDetailTable.getInstance().getGrid(year, areaId);
|
||||
if (result == null) {
|
||||
result = countService.countGridCheckDetailTable(areaId, areaLevel, year);
|
||||
}
|
||||
return new SuccessResultData<>(result);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -28,7 +31,12 @@ public class CheckDetailTable {
|
||||
* 保存报表内容,结构为 {year:{areaId:{具体内容}}}
|
||||
*/
|
||||
public Map<String, Map<String, Map<String, Object>>> detailTableMap = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* 保存网格员内容,结构为 {year:{areaId:{具体内容}}}
|
||||
*/
|
||||
public Map<String, Map<String, Map<String, Object>>> gridDetailTableMap = new ConcurrentHashMap<>();
|
||||
private static CheckDetailTable checkDetailTable = CheckDetailTableBuilder.checkDetailTable;
|
||||
private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2, 10, 6000L, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
|
||||
private ICountService countService;
|
||||
|
||||
private CheckDetailTable() {
|
||||
@ -63,6 +71,26 @@ public class CheckDetailTable {
|
||||
return areaIdMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到网格员内容
|
||||
*
|
||||
* @param year
|
||||
* @param areaId
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getGrid(String year, String areaId) {
|
||||
Map<String, Map<String, Object>> yearMap = gridDetailTableMap.get(year);
|
||||
if (yearMap == null) {
|
||||
return null;
|
||||
}
|
||||
areaId = StringUtils.isEmpty(areaId) ? CountServiceImpl.DEFAULT_AREA_ID : areaId;
|
||||
Map<String, Object> areaIdMap = yearMap.get(areaId);
|
||||
if (areaIdMap == null) {
|
||||
return null;
|
||||
}
|
||||
return areaIdMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新统计内容
|
||||
*/
|
||||
@ -85,10 +113,10 @@ public class CheckDetailTable {
|
||||
* @param year
|
||||
*/
|
||||
private void refresh(String areaId, Integer level, String year) {
|
||||
Map<String, Object> detailMap = getData(areaId, level, year);
|
||||
if (StringUtils.isEmpty(areaId)) {
|
||||
areaId = CountServiceImpl.DEFAULT_AREA_ID;
|
||||
}
|
||||
Map<String, Object> detailMap = getData(areaId, level, year);
|
||||
List<Map<String, Object>> resultMapList = (List<Map<String, Object>>) detailMap.get("resultList");
|
||||
if (resultMapList.isEmpty()) {
|
||||
return;
|
||||
@ -101,7 +129,18 @@ public class CheckDetailTable {
|
||||
}
|
||||
yearMap.put(areaId, detailMap);
|
||||
String resultAreaId = (String) resultMap.get("areaId");
|
||||
threadPoolExecutor.execute(() -> {
|
||||
refresh(resultAreaId, level + 1, year);
|
||||
});
|
||||
threadPoolExecutor.execute(() -> {
|
||||
Map<String, Object> gridDetailMap = getGridData(resultAreaId, level, year);
|
||||
Map<String, Map<String, Object>> yearGridMap = gridDetailTableMap.get(year);
|
||||
if (yearGridMap == null) {
|
||||
yearGridMap = new HashMap<>();
|
||||
gridDetailTableMap.put(year, yearGridMap);
|
||||
}
|
||||
yearGridMap.put(resultAreaId, gridDetailMap);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +156,18 @@ public class CheckDetailTable {
|
||||
return countService.countCheckDetailTable(areaId, level, year).getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计网格员数据
|
||||
*
|
||||
* @param areaId
|
||||
* @param level
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> getGridData(String areaId, Integer level, String year) {
|
||||
return countService.countGridCheckDetailTable(areaId, level, year);
|
||||
}
|
||||
|
||||
private static class CheckDetailTableBuilder {
|
||||
public final static CheckDetailTable checkDetailTable = new CheckDetailTable();
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ public class CountServiceImpl extends BaseService implements ICountService {
|
||||
} else {
|
||||
params.put("area1", areaId);
|
||||
}
|
||||
params.put("level", areaLevel);
|
||||
// params.put("level", areaLevel);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
List<GridPersonnelDTO> gridPersonnelDTOs = gridPersonnelService.listGridPersonnel(params);
|
||||
for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) {
|
||||
|
@ -30,7 +30,7 @@ spring:
|
||||
password: root
|
||||
initial-size: 2
|
||||
min-idle: 2
|
||||
max-active: 5
|
||||
max-active: 100
|
||||
max-wait: 60000
|
||||
time-between-eviction-runs-millis: 60000
|
||||
min-evictable-idle-time-millis: 300000
|
||||
@ -102,9 +102,9 @@ security:
|
||||
api-path:
|
||||
user-center: ${security.oauth2.oauth-server}
|
||||
notice-url: http://192.168.0.103:7001/usercenter
|
||||
version: 2
|
||||
version: 1
|
||||
report-form:
|
||||
check-detail: false
|
||||
check-detail: true
|
||||
|
||||
# 访问控制
|
||||
access-control:
|
||||
|
@ -161,7 +161,7 @@
|
||||
var areaName = this.dataset.areaName;
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/count/list-countcheckdetailtable-grid.html?areaId={areaId}&areaLevel={areaLevel}', [areaId, parseInt(areaLevel)]),
|
||||
title: areaName +'本级网格员综合统计',
|
||||
title: areaName +'网格员综合统计',
|
||||
width: '99%',
|
||||
height: '99%'
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user