|
|
|
@ -47,6 +47,9 @@ public class SupplierPartNewProductAuditServiceImpl implements ISupplierPartNewP |
|
|
|
|
|
|
|
private static final String LATEST_STATUS_REJECTED = "REJECTED"; |
|
|
|
|
|
|
|
/** 采购部门用户自动登记审核时写入的审核意见 - rqrq */ |
|
|
|
private static final String AUTO_PURCHASE_OPINION = "采购部门自动审核-同意"; |
|
|
|
|
|
|
|
/** 未审核新品首页提醒权限码:Y=可查看全站未发起+审核中;否则只看本人发起的审核中 - rqrq */ |
|
|
|
private static final String PERMISSION_CODE_NEW_PRODUCT_AUDIT_REMINDER = "SRM0005"; |
|
|
|
|
|
|
|
@ -111,6 +114,8 @@ public class SupplierPartNewProductAuditServiceImpl implements ISupplierPartNewP |
|
|
|
throw new RuntimeException("已有审核在进行"); |
|
|
|
} |
|
|
|
createAuditRound(site, supplierCode, partNo, 1); |
|
|
|
// 采购部门用户开始审核时,自动完成采购部门的登记审核(结论=同意,无需测试)- rqrq |
|
|
|
autoAgreePurchaseIfProcurement(site, supplierCode, partNo, 1); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -137,6 +142,8 @@ public class SupplierPartNewProductAuditServiceImpl implements ISupplierPartNewP |
|
|
|
// 开启新一轮前,重置“是否需要提交测试”,避免沿用上一轮状态 - rqrq |
|
|
|
mapper.updateSupplierPartAuditFlags(site, supplierCode, partNo, null, null, "N"); |
|
|
|
createAuditRound(site, supplierCode, partNo, nextRoundNo); |
|
|
|
// 采购部门用户重新审核开启新一轮时,同样自动完成采购部门的登记审核 - rqrq |
|
|
|
autoAgreePurchaseIfProcurement(site, supplierCode, partNo, nextRoundNo); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -204,47 +211,8 @@ public class SupplierPartNewProductAuditServiceImpl implements ISupplierPartNewP |
|
|
|
throw new RuntimeException("审核提交失败,请刷新后重试"); |
|
|
|
} |
|
|
|
|
|
|
|
String site = recordSite; |
|
|
|
String supplierCode = recordSupplier; |
|
|
|
String partNo = recordPartNo; |
|
|
|
Integer roundNo = record.getAuditRoundNo(); |
|
|
|
List<SupplierPartNewProductAuditRecordVo> roundRecords = mapper.listAuditRecordByRound(site, supplierCode, partNo, roundNo); |
|
|
|
if (roundRecords == null || roundRecords.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
boolean hasReject = false; |
|
|
|
boolean allDone = true; |
|
|
|
boolean allAgree = true; |
|
|
|
boolean hasNeedTest = false; |
|
|
|
for (SupplierPartNewProductAuditRecordVo row : roundRecords) { |
|
|
|
String rowStatus = trimToEmpty(row.getStatus()).toUpperCase(); |
|
|
|
String rowResult = trimToEmpty(row.getAuditResult()).toUpperCase(); |
|
|
|
String rowNeedTest = trimToEmpty(row.getNeedTest()).toUpperCase(); |
|
|
|
if (!STATUS_DONE.equals(rowStatus)) { |
|
|
|
allDone = false; |
|
|
|
} |
|
|
|
if (!RESULT_AGREE.equals(rowResult)) { |
|
|
|
allAgree = false; |
|
|
|
} |
|
|
|
if (RESULT_REJECT.equals(rowResult)) { |
|
|
|
hasReject = true; |
|
|
|
} |
|
|
|
if ("Y".equals(rowNeedTest)) { |
|
|
|
hasNeedTest = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (hasNeedTest) { |
|
|
|
mapper.updateSupplierPartAuditFlags(site, supplierCode, partNo, null, null, "Y"); |
|
|
|
} |
|
|
|
if (hasReject) { |
|
|
|
mapper.updateSupplierPartAuditFlags(site, supplierCode, partNo, "N", "N", null); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (allDone && allAgree) { |
|
|
|
mapper.updateSupplierPartAuditFlags(site, supplierCode, partNo, "Y", "N", null); |
|
|
|
} |
|
|
|
// 汇总本轮各部门审核结果并回写供应商物料审核标记(与采购自动同意复用同一判定)- rqrq |
|
|
|
applyRoundOutcome(recordSite, recordSupplier, recordPartNo, record.getAuditRoundNo()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -333,6 +301,75 @@ public class SupplierPartNewProductAuditServiceImpl implements ISupplierPartNewP |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 汇总某轮次所有部门审核结果并回写供应商物料审核标记(从 submitAuditRecord 抽取,供人工登记与采购自动同意复用)- rqrq |
|
|
|
*/ |
|
|
|
private void applyRoundOutcome(String site, String supplierCode, String partNo, Integer roundNo) { |
|
|
|
List<SupplierPartNewProductAuditRecordVo> roundRecords = mapper.listAuditRecordByRound(site, supplierCode, partNo, roundNo); |
|
|
|
if (roundRecords == null || roundRecords.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
boolean hasReject = false; |
|
|
|
boolean allDone = true; |
|
|
|
boolean allAgree = true; |
|
|
|
boolean hasNeedTest = false; |
|
|
|
for (SupplierPartNewProductAuditRecordVo row : roundRecords) { |
|
|
|
String rowStatus = trimToEmpty(row.getStatus()).toUpperCase(); |
|
|
|
String rowResult = trimToEmpty(row.getAuditResult()).toUpperCase(); |
|
|
|
String rowNeedTest = trimToEmpty(row.getNeedTest()).toUpperCase(); |
|
|
|
if (!STATUS_DONE.equals(rowStatus)) { |
|
|
|
allDone = false; |
|
|
|
} |
|
|
|
if (!RESULT_AGREE.equals(rowResult)) { |
|
|
|
allAgree = false; |
|
|
|
} |
|
|
|
if (RESULT_REJECT.equals(rowResult)) { |
|
|
|
hasReject = true; |
|
|
|
} |
|
|
|
if ("Y".equals(rowNeedTest)) { |
|
|
|
hasNeedTest = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (hasNeedTest) { |
|
|
|
mapper.updateSupplierPartAuditFlags(site, supplierCode, partNo, null, null, "Y"); |
|
|
|
} |
|
|
|
if (hasReject) { |
|
|
|
mapper.updateSupplierPartAuditFlags(site, supplierCode, partNo, "N", "N", null); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (allDone && allAgree) { |
|
|
|
mapper.updateSupplierPartAuditFlags(site, supplierCode, partNo, "Y", "N", null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 采购部门用户触发开始/重新审核后,自动将该轮“采购部门”记录登记为同意(needTest=N),并复用整轮完成判定 - rqrq |
|
|
|
*/ |
|
|
|
private void autoAgreePurchaseIfProcurement(String site, String supplierCode, String partNo, Integer roundNo) { |
|
|
|
String user = resolveCurrentUserName(); |
|
|
|
Integer purchaseDeptCount; |
|
|
|
try { |
|
|
|
purchaseDeptCount = mapper.countPurchaseDeptMember(site, user); |
|
|
|
} catch (Exception ignored) { |
|
|
|
purchaseDeptCount = null; |
|
|
|
} |
|
|
|
if (purchaseDeptCount == null || purchaseDeptCount <= 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
List<SupplierPartNewProductAuditRecordVo> roundRecords = mapper.listAuditRecordByRound(site, supplierCode, partNo, roundNo); |
|
|
|
if (roundRecords == null || roundRecords.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
for (SupplierPartNewProductAuditRecordVo row : roundRecords) { |
|
|
|
if (DEPT_PURCHASE.equalsIgnoreCase(trimToEmpty(row.getDeptType())) |
|
|
|
&& STATUS_PENDING.equalsIgnoreCase(trimToEmpty(row.getStatus()))) { |
|
|
|
mapper.submitAuditRecordById(row.getId(), RESULT_AGREE, "N", AUTO_PURCHASE_OPINION, user, new Date()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
applyRoundOutcome(site, supplierCode, partNo, roundNo); |
|
|
|
} |
|
|
|
|
|
|
|
private void createAuditRound(String site, String supplierCode, String partNo, Integer roundNo) { |
|
|
|
String currentUser = resolveCurrentUserName(); |
|
|
|
int purchaseRows = mapper.insertAuditRecord(site, supplierCode, partNo, roundNo, DEPT_PURCHASE, currentUser); |
|
|
|
|