qms回传质检报告优化为批量新增审核

This commit is contained in:
lihao 2025-10-29 17:02:10 +08:00
parent 2c040f55fe
commit 0d78eafcc6
1 changed files with 38 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus; import nc.vo.pub.VOStatus;
import nc.vo.pub.lang.UFBoolean; import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDouble; import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nc.vo.pubapp.pflow.PfUserObject; import nc.vo.pubapp.pflow.PfUserObject;
import nc.vo.qc.c003.entity.ReportHeaderVO; import nc.vo.qc.c003.entity.ReportHeaderVO;
import nc.vo.qc.c003.entity.ReportItemVO; import nc.vo.qc.c003.entity.ReportItemVO;
@ -93,7 +94,14 @@ public class QcconclusionRestResource extends QcBaseRestResource {
if (pkReportbill == null) { if (pkReportbill == null) {
continue; continue;
} }
ReportItemVO[] itemVO= vo.getBVO();
UFDouble crowno=UFDouble.ZERO_DBL;
for (ReportItemVO itemVO1 : itemVO) {
if(new UFDouble(itemVO1.getCrowno()).compareTo(crowno) > 0) {
crowno = new UFDouble(itemVO1.getCrowno());
}
}
for (Map<String, Object> itemMap : itemMaps) { for (Map<String, Object> itemMap : itemMaps) {
// 校验itemMap的id是否为必填存在且不为null // 校验itemMap的id是否为必填存在且不为null
if (itemMap == null || !itemMap.containsKey("id") || itemMap.get("id") == null) { if (itemMap == null || !itemMap.containsKey("id") || itemMap.get("id") == null) {
@ -247,11 +255,23 @@ public class QcconclusionRestResource extends QcBaseRestResource {
ISCMPubSaveCommitService service = NCLocator.getInstance().lookup(ISCMPubSaveCommitService.class);; ISCMPubSaveCommitService service = NCLocator.getInstance().lookup(ISCMPubSaveCommitService.class);;
try { try {
SCMScriptResultDTO obj = service.saveCommit(vos, (PfUserObject)null, ReportVO.class, "SAVEBASE", "SAVE", QCBillType.ReportBill.getCode()); List<ReportVO> reportVOList=new ArrayList<>(Arrays.asList(vos));
resultVos = (ReportVO[]) obj.getSucessVOs(); for (ReportVO reportVO:vos){
SCMScriptResultDTO obj = service.saveCommit(new ReportVO[]{reportVO}, (PfUserObject)null, ReportVO.class, "SAVEBASE", "SAVE", QCBillType.ReportBill.getCode());
if(obj.getErrorMessage()!=null && !"".equals(obj.getErrorMessage())){
throw new BusinessException(obj.getErrorMessage());
}
if(obj!=null){
reportVOList.add((ReportVO) obj.getSucessVOs()[0]);
}
}
resultVos = reportVOList.toArray(new ReportVO[0]);
// SCMScriptResultDTO obj = service.saveCommit(vos, (PfUserObject)null, ReportVO.class, "SAVEBASE", "SAVE", QCBillType.ReportBill.getCode());
// resultVos =(ReportVO[]) obj.getSucessVOs();
// resultVos = reportMaintain.saveBase(vos, new Object(), updatevos); // resultVos = reportMaintain.saveBase(vos, new Object(), updatevos);
} catch (BusinessException e) { } catch (BusinessException e) {
return ResultMessageUtil.exceptionToJSON(e); throw new BusinessException(e.getMessage());
// return ResultMessageUtil.exceptionToJSON(e);
} }
} else { } else {
for (ReportVO vo : vos) { for (ReportVO vo : vos) {
@ -270,7 +290,21 @@ public class QcconclusionRestResource extends QcBaseRestResource {
IBatchRunScriptService iReportApprove = NCLocator.getInstance().lookup(IBatchRunScriptService.class); IBatchRunScriptService iReportApprove = NCLocator.getInstance().lookup(IBatchRunScriptService.class);
SCMScriptResultDTO obj = iReportApprove.runBacth(context, ReportVO.class); SCMScriptResultDTO obj = iReportApprove.runBacth(context, ReportVO.class);
resultVos=(ReportVO[]) obj.getSucessVOs(); if(obj.getErrorMessage()!=null && !"".equals(obj.getErrorMessage()) ){
// return ResultMessageUtil.exceptionToJSON(new BusinessException(obj.getErrorMessage()));
throw new BusinessException(obj.getErrorMessage());
}
// 1. 先获取原始数组明确类型为AbstractBill[]
AbstractBill[] originalVOs = obj.getSucessVOs();
// 2. 创建同长度的ReportVO数组
resultVos = new ReportVO[originalVOs.length];
// 3. 逐个元素转换需确保每个元素实际是ReportVO类型否则会抛ClassCastException
for (int i = 0; i < originalVOs.length; i++) {
// 这里的转换需要确保originalVOs[i]确实是ReportVO实例
resultVos[i] = (ReportVO) originalVOs[i];
}
} }