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