Browse Source

```

feat(inspection): 添加打样单取消审核时清空验货数据功能

- 实现了 clearSamplePoOfficeInspectionOnRollback 方法用于清空验货完成时回写的 c_china_office_inspection_date 与 c_inspection_result
- 与 syncSamplePoOfficeInspectionOnCompleted 对称处理 order_type='Sample' 的订单
- 采用相同的定位/去重/容错策略确保审核-取消审核可反复往返不残留脏数据
- 在 rollbackInspectionResult 方法中调用清空逻辑确保数据一致性
- 添加了 SQL Server 驱动的 jdbcType 显式指定避免 DATE 列转换错误
- 实现了详细的日志记录用于跟踪清空操作的成功与失败情况
```
master
qiankanghui 1 week ago
parent
commit
fc0c27ca0e
  1. 58
      src/main/java/com/xujie/modules/inspection/service/impl/InspectionRequestServiceImpl.java

58
src/main/java/com/xujie/modules/inspection/service/impl/InspectionRequestServiceImpl.java

@ -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>()

Loading…
Cancel
Save