Commit af162784 authored by zhangsen's avatar zhangsen

任务23724 :消防巡检列表API优化

parent ff3abd7b
...@@ -190,24 +190,26 @@ public class CheckServiceImpl implements ICheckService { ...@@ -190,24 +190,26 @@ public class CheckServiceImpl implements ICheckService {
return new PageImpl<>(content, param, total); return new PageImpl<>(content, param, total);
} }
content = checkMapper.getPeopleCheckPage(param); content = checkMapper.getPeopleCheckPage(param);
for (CheckInfoVo infoVo : content) { String checkIds = String.join(",", content.stream().map(CheckInfoVo::getId).collect(Collectors.toList()));
FeignClientResult responseModel = new FeignClientResult(); FeignClientResult responseModel = new FeignClientResult();
List result = new ArrayList(); List<Map<String, String>> result = new ArrayList();
try { try {
responseModel = idxFeign.queryDefectByCodes(new ArrayList<>(), infoVo.getId()); responseModel = idxFeign.queryDefectByCodes(new ArrayList<>(), checkIds);
result = (List) responseModel.getResult(); result = (List) responseModel.getResult();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
List<DefectVo> res = new ArrayList(); Map<String, Map<String, String>> checkIdMap = new HashMap<>();
if (result != null && 0 < result.size()) { if (result != null && 0 < result.size()) {
for(Object object : result) { checkIdMap = result.stream().collect(Collectors.toMap(t -> t.get("checkId"), t -> t, (k1, k2) -> k2));
DefectVo vo = JSON.parseObject(JSON.toJSONString(object), DefectVo.class);
res.add(vo);
} }
infoVo.setError(ObjectUtils.isEmpty(res.get(0)) ? "" : res.get(0).getDefectDescribe()); for (CheckInfoVo infoVo : content) {
infoVo.setProblemNum(ObjectUtils.isEmpty(res.get(0)) ? "" : res.get(0).getDefectNum()); if (!ObjectUtils.isEmpty(checkIdMap) && checkIdMap.containsKey(infoVo.getId()) && !ObjectUtils.isEmpty(checkIdMap.get(infoVo.getId()))) {
infoVo.setHandleStatus(ObjectUtils.isEmpty(res.get(0)) ? "" : String.valueOf(res.get(0).getDefectStatus())); Map<String, String> map = checkIdMap.get(infoVo.getId());
DefectVo vo = JSON.parseObject(JSON.toJSONString(map), DefectVo.class);
infoVo.setError(vo.getDefectDescribe());
infoVo.setProblemNum(vo.getDefectNum());
infoVo.setHandleStatus(String.valueOf(vo.getDefectStatus()));
} }
} }
return new PageImpl<>(content, param, total); return new PageImpl<>(content, param, total);
......
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