From e4278e30cb7746acb99df5aede525f7b3beb7434 Mon Sep 17 00:00:00 2001 From: lihao Date: Wed, 13 Aug 2025 10:45:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qc/resource/QcconclusionRestResource.java | 123 +++++++++++++----- 1 file changed, 94 insertions(+), 29 deletions(-) diff --git a/qc/src/public/nc/api/qc/resource/QcconclusionRestResource.java b/qc/src/public/nc/api/qc/resource/QcconclusionRestResource.java index 4cec296..87c15c4 100644 --- a/qc/src/public/nc/api/qc/resource/QcconclusionRestResource.java +++ b/qc/src/public/nc/api/qc/resource/QcconclusionRestResource.java @@ -84,41 +84,106 @@ public class QcconclusionRestResource extends QcBaseRestResource { } } for (ReportVO vo : vos) { + // 先判断vo和其HVO是否为null(避免NPE) + if (vo == null || vo.getHVO() == null) { + continue; + } + Object pkReportbill = vo.getHVO().getPk_reportbill(); + // 校验HVO的pk_reportbill是否为必填(不为null) + if (pkReportbill == null) { + continue; + } + for (Map itemMap : itemMaps) { - if(itemMap.get("id").equals(vo.getHVO().getPk_reportbill())){ -//nchecknum 检验主数量 -//ncheckastnum 检验数量 -//neliginum 合格主数量 -//neligiastnum 合格数量 -//nuneliginum 不合格主数量 -//nuneligiastnum 不合格数量 - vo.getHVO().setStatus(VOStatus.UPDATED); - // 检验主数量 - vo.getHVO().setNchecknum(new UFDouble((Double)itemMap.get("nchecknum"))); - // 检验数量 + // 校验itemMap的id是否为必填(存在且不为null) + if (itemMap == null || !itemMap.containsKey("id") || itemMap.get("id") == null) { + continue; + } + // 比较id是否匹配(双方都已校验非null) + if (!itemMap.get("id").equals(pkReportbill)) { + continue; + } + + // 匹配成功,更新状态 + vo.getHVO().setStatus(VOStatus.UPDATED); + + // 处理数量字段(存在且不为null才赋值) + // 检验主数量 + if (itemMap.containsKey("nchecknum") && itemMap.get("nchecknum") instanceof Double) { + vo.getHVO().setNchecknum(new UFDouble((Double) itemMap.get("nchecknum"))); + } + // 检验数量 + if (itemMap.containsKey("ncheckastnum") && itemMap.get("ncheckastnum") instanceof Double) { vo.getHVO().setNcheckastnum(new UFDouble((Double) itemMap.get("ncheckastnum"))); - // 合格主数量 + } + // 合格主数量 + if (itemMap.containsKey("neliginum") && itemMap.get("neliginum") instanceof Double) { vo.getHVO().setNeliginum(new UFDouble((Double) itemMap.get("neliginum"))); - // 合格数量 - vo.getHVO().setNeligiastnum(new UFDouble((Double)itemMap.get("neligiastnum"))); - // 不合格主数量 + } + // 合格数量 + if (itemMap.containsKey("neligiastnum") && itemMap.get("neligiastnum") instanceof Double) { + vo.getHVO().setNeligiastnum(new UFDouble((Double) itemMap.get("neligiastnum"))); + } + // 不合格主数量 + if (itemMap.containsKey("nuneliginum") && itemMap.get("nuneliginum") instanceof Double) { vo.getHVO().setNuneliginum(new UFDouble((Double) itemMap.get("nuneliginum"))); - // 不合格数量 - vo.getHVO().setNuneligiastnum(new UFDouble((Double)itemMap.get("nuneligiastnum"))); - this.appendPseudoColumn(vo); - List> mapList = (List>) itemMap.get("children"); - if(!mapList.isEmpty()){ - for (int i = 0; i < vo.getBVO().length; i++) { - for (Map childMap : mapList) { - if(vo.getBVO()[i].getCrowno().equals(childMap.get("crowno"))){ - vo.getBVO()[i].setNnum(new UFDouble((Double)childMap.get("nnum"))); - vo.getBVO()[i].setFprocessjudge(((Double)childMap.get("fprocessjudge")).intValue()); - vo.getBVO()[i].setStatus(VOStatus.UPDATED); - } - } + } + // 不合格数量 + if (itemMap.containsKey("nuneligiastnum") && itemMap.get("nuneligiastnum") instanceof Double) { + vo.getHVO().setNuneligiastnum(new UFDouble((Double) itemMap.get("nuneligiastnum"))); + } + + this.appendPseudoColumn(vo); + + // 处理子列表(先判断是否为有效列表) + Object childrenObj = itemMap.get("children"); + if (!(childrenObj instanceof List)) { + continue; + } + List> mapList = (List>) childrenObj; + if (mapList.isEmpty()) { + continue; + } + + // 处理BVO数组(先判断数组是否为null) + ReportItemVO[] bvos = vo.getBVO(); + if (bvos == null) { + continue; + } + + for (int i = 0; i < bvos.length; i++) { + ReportItemVO bvo = bvos[i]; + // 跳过null的BVO + if (bvo == null) { + continue; + } + // 校验BVO的crowno是否为必填(不为null) + String bvoCrowno = bvo.getCrowno(); + if (bvoCrowno == null) { + continue; + } + + for (Map childMap : mapList) { + // 校验childMap的crowno是否为必填(存在且不为null) + if (childMap == null || !childMap.containsKey("crowno") || childMap.get("crowno") == null) { + continue; + } + // 比较crowno是否匹配 + if (!bvoCrowno.equals(childMap.get("crowno"))) { + continue; + } + + // 匹配成功,更新子项字段(存在且不为null才赋值) + bvo.setStatus(VOStatus.UPDATED); + // 子项数量 + if (childMap.containsKey("nnum") && childMap.get("nnum") instanceof Double) { + bvo.setNnum(new UFDouble((Double) childMap.get("nnum"))); + } + // 处理判断状态 + if (childMap.containsKey("fprocessjudge") && childMap.get("fprocessjudge") instanceof Double) { + bvo.setFprocessjudge(((Double) childMap.get("fprocessjudge")).intValue()); } } - } } }