|
|
|
@ -2066,6 +2066,61 @@ public class InspectionRequestServiceImpl extends ServiceImpl<InspectionRequestH |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 打样单取消审核后,清空验货完成时回写的 c_china_office_inspection_date 与 c_inspection_result。 |
|
|
|
* 与 syncSamplePoOfficeInspectionOnCompleted 对称:同样仅处理 order_type='Sample' 的订单, |
|
|
|
* 定位/去重/容错策略保持一致,保证审核-取消审核可反复往返不残留脏数据。 |
|
|
|
*/ |
|
|
|
private void clearSamplePoOfficeInspectionOnRollback(String site, |
|
|
|
String requestNo, |
|
|
|
Integer itemNo, |
|
|
|
List<InspectionRequestDetailSub> subList) { |
|
|
|
if (subList == null || subList.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Set<String> updatedPoKeys = new HashSet<>(); |
|
|
|
Map<String, Boolean> samplePoCache = new HashMap<>(); |
|
|
|
for (InspectionRequestDetailSub sub : subList) { |
|
|
|
if (sub == null || !StringUtils.hasText(sub.getPoNo()) || sub.getPoItemNo() == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
String poNo = sub.getPoNo().trim(); |
|
|
|
String poKey = poNo + "#" + sub.getPoItemNo(); |
|
|
|
if (!updatedPoKeys.add(poKey)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Boolean isSamplePo = samplePoCache.computeIfAbsent(poNo, key -> { |
|
|
|
POHeader poHeader = poheaderMapper.selectOne( |
|
|
|
new LambdaQueryWrapper<POHeader>() |
|
|
|
.eq(POHeader::getSite, site) |
|
|
|
.eq(POHeader::getOrderNo, key) |
|
|
|
); |
|
|
|
return poHeader != null && "Sample".equals(poHeader.getOrderType()); |
|
|
|
}); |
|
|
|
if (!Boolean.TRUE.equals(isSamplePo)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
int affectedRows = podetailMapper.update(null, |
|
|
|
new LambdaUpdateWrapper<PODetail>() |
|
|
|
.eq(PODetail::getSite, site) |
|
|
|
.eq(PODetail::getOrderNo, poNo) |
|
|
|
.eq(PODetail::getItemNo, sub.getPoItemNo()) |
|
|
|
// SQL Server 驱动会把未声明 jdbcType 的 null 按 varbinary 绑定,DATE 列不接受隐式转换,必须显式指定 |
|
|
|
.set(PODetail::getChinaOfficeInspectionDate, null, "jdbcType=DATE") |
|
|
|
.set(PODetail::getInspectionResult, null, "jdbcType=VARCHAR") |
|
|
|
); |
|
|
|
if (affectedRows == 0) { |
|
|
|
log.warn("打样单取消审核清空PODetail回写未命中: site={}, requestNo={}, itemNo={}, poNo={}, poItemNo={}", |
|
|
|
site, requestNo, itemNo, poNo, sub.getPoItemNo()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
log.info("打样单取消审核清空PODetail回写成功: site={}, requestNo={}, itemNo={}, poNo={}, poItemNo={}", |
|
|
|
site, requestNo, itemNo, poNo, sub.getPoItemNo()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void rollbackInspectionResult(String site, String requestNo, Integer itemNo) { |
|
|
|
@ -2097,6 +2152,9 @@ public class InspectionRequestServiceImpl extends ServiceImpl<InspectionRequestH |
|
|
|
); |
|
|
|
applyApproveQtyToPoDetails(site, detail, subList, false); |
|
|
|
|
|
|
|
// 3.1 打样单取消审核时,清空验货完成时回写的 China office 验货日期与检验结论 |
|
|
|
clearSamplePoOfficeInspectionOnRollback(site, requestNo, itemNo, subList); |
|
|
|
|
|
|
|
// 4. 更新指定明细状态为验货中,并清空检验通过数量 |
|
|
|
int updateCount = inspectionRequestDetailMapper.update(null, |
|
|
|
new LambdaUpdateWrapper<InspectionRequestDetail>() |
|
|
|
|