新增统计
This commit is contained in:
parent
c7d310271d
commit
2346b115a6
@ -155,7 +155,7 @@ public class CountController extends AbstractController {
|
|||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("counthiddendangerreportdetail/{year}")
|
@GetMapping("counthiddendangerreportdetail/{year}")
|
||||||
public SuccessResultData<Map<String, Object>> countHiddenDangerReportDetail(@PathVariable("year") String year) {
|
public SuccessResultData<Map<String, Object>> countHiddenDangerReportDetail(@PathVariable("year") String year) throws Exception {
|
||||||
return countService.countHiddenDangerReportDetail(year);
|
return countService.countHiddenDangerReportDetail(year);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,5 +71,5 @@ public interface ICountService {
|
|||||||
* @return
|
* @return
|
||||||
* @throws SearchException
|
* @throws SearchException
|
||||||
*/
|
*/
|
||||||
SuccessResultData<Map<String, Object>> countHiddenDangerReportDetail(String year) throws SearchException;
|
SuccessResultData<Map<String, Object>> countHiddenDangerReportDetail(String year) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -228,23 +229,26 @@ public class CountServiceImpl extends BaseService implements ICountService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SuccessResultData<Map<String, Object>> countHiddenDangerReportDetail(String year) throws SearchException {
|
public SuccessResultData<Map<String, Object>> countHiddenDangerReportDetail(String year) throws Exception {
|
||||||
LOG.debug("获取三级区域");
|
LOG.debug("获取三级区域");
|
||||||
List<DataDictionaryDTO> areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8");
|
List<DataDictionaryDTO> areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8");
|
||||||
// 获取检查项列表
|
// 获取检查项列表
|
||||||
List<CheckItemDTO> checkItemDTOs = listCheckItemDTO();
|
List<CheckItemDTO> checkItemDTOs = listCheckItemDTO();
|
||||||
// 检查项详细列表
|
// 检查项详细列表
|
||||||
List<CheckItemOptionDTO> checkItemOptionDTOs = listCheckItemOptionDTO();
|
List<CheckItemOptionDTO> checkItemOptionDTOs = listCheckItemOptionDTO();
|
||||||
// 组合检查项
|
// 检查结果
|
||||||
|
List<Map<String, Object>> listCheckItemOptionArea = new ArrayList<>();
|
||||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
||||||
for (DataDictionaryDTO areaDTO : areaDTOs) {
|
for (DataDictionaryDTO areaDTO : areaDTOs) {
|
||||||
Map<String, Object> resultListMap = getHashMap(3);
|
Map<String, Object> areaMap = getHashMap(4);
|
||||||
resultListMap.put("areaName", areaDTO.getDictionaryName());
|
areaMap.put("areaName", areaDTO.getDictionaryName());
|
||||||
// 网格员的Id列表
|
// 网格员的Id列表
|
||||||
List<String> userIdList = listGridPersonnelUserId(areaDTO.getDictionaryId());
|
List<String> userIdList = listGridPersonnelUserId(areaDTO.getDictionaryId());
|
||||||
|
// 网格员的所有上报项
|
||||||
List<HiddenDangerReportDTO> listHiddenDangerReport = hiddenDangerReportService.listHiddenDangerReportSimpleByUserIdsYear(userIdList, year);
|
List<HiddenDangerReportDTO> listHiddenDangerReport = hiddenDangerReportService.listHiddenDangerReportSimpleByUserIdsYear(userIdList, year);
|
||||||
|
// 遍历所有的检查项
|
||||||
|
List<Map<String, Object>> listCheckItemOption = new ArrayList<>();
|
||||||
for (CheckItemOptionDTO checkItemOptionDTO : checkItemOptionDTOs) {
|
for (CheckItemOptionDTO checkItemOptionDTO : checkItemOptionDTOs) {
|
||||||
|
Map<String, Object> checkItemOptionMap = HashMapUtil.beanToMap(checkItemOptionDTO);
|
||||||
int checkCount = 0;
|
int checkCount = 0;
|
||||||
for (HiddenDangerReportDTO hiddenDangerReportDTO : listHiddenDangerReport) {
|
for (HiddenDangerReportDTO hiddenDangerReportDTO : listHiddenDangerReport) {
|
||||||
// 检查项相同
|
// 检查项相同
|
||||||
@ -253,43 +257,138 @@ public class CountServiceImpl extends BaseService implements ICountService {
|
|||||||
checkCount++;
|
checkCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, Object> checkItemOptionMap = HashMapUtil.beanToMap(checkItemOptionDTO);
|
|
||||||
checkItemOptionMap.put("checkCount", checkCount);
|
checkItemOptionMap.put("checkCount", checkCount);
|
||||||
|
listCheckItemOption.add(checkItemOptionMap);
|
||||||
}
|
}
|
||||||
|
areaMap.put("listCheckItemOption", listCheckItemOption);
|
||||||
|
listCheckItemOptionArea.add(areaMap);
|
||||||
}
|
}
|
||||||
return null;
|
// 封装结果
|
||||||
|
// 构建检查项列表
|
||||||
|
List<Map<String, Object>> checkItemList = buildCheckItem(checkItemDTOs);
|
||||||
|
// 检查详细结果加入地区的结果列表
|
||||||
|
List<Map<String, Object>> checkItemOptionList = buildCheckItemOptionArea(checkItemOptionDTOs, listCheckItemOptionArea);
|
||||||
|
// 构建检查项详细列表,检查项、检查详细项合并
|
||||||
|
buildCheckItemAndCheckItemOption(checkItemList, checkItemOptionList);
|
||||||
|
|
||||||
|
// 返回结果
|
||||||
|
Map<String, Object> result = getHashMap(4);
|
||||||
|
result.put("year", year);
|
||||||
|
result.put("checkItemList", checkItemList);
|
||||||
|
return new SuccessResultData<>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> listCheckItem(List<CheckItemDTO> checkItemDTOs) throws Exception {
|
/**
|
||||||
List<Map<String, Object>> checkItemMapList = new ArrayList<>();
|
* 构建检查结果到检查项中
|
||||||
if (checkItemDTOs) {
|
*
|
||||||
return checkItemMapList;
|
* @param checkItemList
|
||||||
}
|
* @param checkItemOptionList
|
||||||
// 处理一级选项
|
*/
|
||||||
for (CheckItemDTO checkItemDTO : checkItemDTOs) {
|
private void buildCheckItemAndCheckItemOption(List<Map<String, Object>> checkItemList, List<Map<String, Object>> checkItemOptionList) {
|
||||||
if (checkItemDTO.getCheckItemParentId() == null || checkItemDTO.getCheckItemParentId() == 0) {
|
for (Map<String, Object> checkItem : checkItemList) {
|
||||||
checkItemMapList.add(HashMapUtil.beanToMap(checkItemDTO));
|
List<Map<String, Object>> checkItemOptions = new ArrayList<>();
|
||||||
}
|
for (int i = 0; i < checkItemOptionList.size(); i++) {
|
||||||
}
|
Map<String, Object> checkItemOption = checkItemOptionList.get(i);
|
||||||
// 处理二级选项
|
if (StringUtils.equals(checkItem.get("checkItemId").toString(), checkItemOption.get("checkItemId").toString())) {
|
||||||
for (Map<String, Object> checkItemMap : checkItemMapList) {
|
checkItemOptions.add(checkItemOption);
|
||||||
List<Map<String, Object>> subCheckItemList = new ArrayList<>();
|
checkItemOptionList.remove(i);
|
||||||
for (CheckItemDTO checkItemDTO : checkItemDTOs) {
|
i--;
|
||||||
if (StringUtils.equals(checkItemMap.get("checkItemId").toString(), checkItemDTO.getCheckItemParentId())) {
|
|
||||||
subCheckItemList.add(HashMapUtil.beanToMap(checkItemDTO));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 处理选项
|
List<Map<String, Object>> subCheckItem = (List<Map<String, Object>>) checkItem.get("subCheckItem");
|
||||||
|
if (subCheckItem != null && !subCheckItem.isEmpty()) {
|
||||||
|
buildCheckItemAndCheckItemOption(subCheckItem, checkItemOptionList);
|
||||||
|
}
|
||||||
|
checkItem.put("checkItemOptions", checkItemOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildCheckItem(List<CheckItemDTO> checkItemDTOs) {
|
/**
|
||||||
List<Map<String, Object>> checkItemMapList = new ArrayList<>();
|
* 构建具体的检查项结果,将地区的检查结果根据检查项的不同重新构建;
|
||||||
for (CheckItemDTO checkItemDTO : checkItemDTOs) {
|
* 比如说,原来的结果是地区1下面的各个检查总数的统计,
|
||||||
if (checkItemDTO.getCheckItemParentId() == null || StringUtils.equals(checkItemDTO.getCheckItemParentId(), "0")) {
|
* 现在将其转换为每一个检查结果下,地区的总数统计。
|
||||||
|
* <p>
|
||||||
|
* 格式如下所示:option1中包含了[{area1: 0}, {area2: 0}]数组
|
||||||
|
* <p>
|
||||||
|
* | | area1 | area2 | area3 | area4 | area5 |
|
||||||
|
* | option1 | 0 | 0 | 0 | 0 | 0 |
|
||||||
|
* | option2 | 0 | 0 | 0 | 0 | 0 |
|
||||||
|
* | option3 | 0 | 0 | 0 | 0 | 0 |
|
||||||
|
* | option4 | 0 | 0 | 0 | 0 | 0 |
|
||||||
|
*
|
||||||
|
* @param checkItemOptionDTOs
|
||||||
|
* @param listCheckItemOptionArea
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private List<Map<String, Object>> buildCheckItemOptionArea(List<CheckItemOptionDTO> checkItemOptionDTOs, List<Map<String, Object>> listCheckItemOptionArea) throws Exception {
|
||||||
|
List<Map<String, Object>> checkItemOptionList = new ArrayList<>();
|
||||||
|
for (CheckItemOptionDTO checkItemOptionDTO : checkItemOptionDTOs) {
|
||||||
|
Map<String, Object> checkItemOptionMap = HashMapUtil.beanToMap(checkItemOptionDTO);
|
||||||
|
List<Map<String, Object>> areaList = new ArrayList<>();
|
||||||
|
for (Map<String, Object> checkItemOptionArea : listCheckItemOptionArea) {
|
||||||
|
Map<String, Object> areaMap = getHashMap(3);
|
||||||
|
areaMap.put("areaName", checkItemOptionArea.get("areaName"));
|
||||||
|
List<Map<String, Object>> checkItemOptions = (List<Map<String, Object>>) checkItemOptionArea.get("listCheckItemOption");
|
||||||
|
for (Map<String, Object> checkItemOption : checkItemOptions) {
|
||||||
|
if (StringUtils.equals(checkItemOptionDTO.getCheckItemOptionId(), checkItemOption.get("checkItemOptionId").toString())) {
|
||||||
|
areaMap.put("checkCount", checkItemOption.get("checkCount"));
|
||||||
|
areaList.add(areaMap);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkItemOptionMap.put("areaList", areaList);
|
||||||
|
checkItemOptionList.add(checkItemOptionMap);
|
||||||
|
}
|
||||||
|
return checkItemOptionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建检查项列表。由于检查项是动态的,不确定层级,要动态构建列表
|
||||||
|
*
|
||||||
|
* @param checkItemDTOs
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private List<Map<String, Object>> buildCheckItem(List<CheckItemDTO> checkItemDTOs) throws Exception {
|
||||||
|
// 中间变量
|
||||||
|
Map<String, List<Map<String, Object>>> tempMap = new HashMap<>(20);
|
||||||
|
for (CheckItemDTO checkItemDTO : checkItemDTOs) {
|
||||||
|
String parentId = checkItemDTO.getCheckItemParentId();
|
||||||
|
if (StringUtils.isBlank(parentId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<Map<String, Object>> tempList = tempMap.get(parentId);
|
||||||
|
if (tempList == null) {
|
||||||
|
tempList = new ArrayList<>();
|
||||||
|
tempMap.put(parentId, tempList);
|
||||||
|
}
|
||||||
|
tempList.add(HashMapUtil.beanToMap(checkItemDTO));
|
||||||
|
}
|
||||||
|
// 组合列表
|
||||||
|
for (Map.Entry<String, List<Map<String, Object>>> kv : tempMap.entrySet()) {
|
||||||
|
// 取出当前的键值
|
||||||
|
String key = kv.getKey();
|
||||||
|
List<Map<String, Object>> value = kv.getValue();
|
||||||
|
// 从temp找到对应的父级
|
||||||
|
for (Map.Entry<String, List<Map<String, Object>>> kv2 : tempMap.entrySet()) {
|
||||||
|
List<Map<String, Object>> value2 = kv2.getValue();
|
||||||
|
boolean find = false;
|
||||||
|
for (Map<String, Object> map : value2) {
|
||||||
|
// 加入父级
|
||||||
|
if (StringUtils.equals(map.get("checkItemId").toString(), key)) {
|
||||||
|
map.put("subCheckItem", value);
|
||||||
|
find = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (find) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return tempMap.get("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -354,7 +453,9 @@ public class CountServiceImpl extends BaseService implements ICountService {
|
|||||||
/**
|
/**
|
||||||
* 统计隐患问题
|
* 统计隐患问题
|
||||||
*
|
*
|
||||||
* @param checkIds
|
* @param checkItemOptionDTOs
|
||||||
|
* @param userIdList
|
||||||
|
* @param year
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Integer countCheckHiddenDanger(List<CheckItemOptionDTO> checkItemOptionDTOs, List<String> userIdList, String year) {
|
private Integer countCheckHiddenDanger(List<CheckItemOptionDTO> checkItemOptionDTOs, List<String> userIdList, String year) {
|
||||||
@ -481,7 +582,7 @@ public class CountServiceImpl extends BaseService implements ICountService {
|
|||||||
/**
|
/**
|
||||||
* 获取检查ID列表
|
* 获取检查ID列表
|
||||||
*
|
*
|
||||||
* @param userIds
|
* @param userIdList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<String> listNeedReCheckIds(List<String> userIdList) {
|
private List<String> listNeedReCheckIds(List<String> userIdList) {
|
||||||
|
Loading…
Reference in New Issue
Block a user