|
|
|
@ -104,13 +104,13 @@ public class RfidCountHeaderServiceImpl extends ServiceImpl<RfidCountHeaderMappe |
|
|
|
* |
|
|
|
* <p><b>业务逻辑:</b></p> |
|
|
|
* <pre> |
|
|
|
* 1. 查询未填充的主表记录(is_used='N' AND label_count IS NULL) |
|
|
|
* 1. 查询未处理的主表记录(is_used='N') |
|
|
|
* 2. 遍历每条记录: |
|
|
|
* - 从pallet_detail查询标签列表 |
|
|
|
* - 从handling_unit查询标签详细信息 |
|
|
|
* - 批量保存到rfid_count_detail |
|
|
|
* - 更新或新增到rfid_count_snapshot |
|
|
|
* - 更新rfid_count_header的label_count |
|
|
|
* - 更新rfid_count_header:label_count=标签数量,is_used='Y' |
|
|
|
* 3. 每条主表记录独立事务处理 |
|
|
|
* </pre> |
|
|
|
* |
|
|
|
@ -122,24 +122,23 @@ public class RfidCountHeaderServiceImpl extends ServiceImpl<RfidCountHeaderMappe |
|
|
|
log.info("开始填充RFID日常入库盘点明细和快照表 - rqrq"); |
|
|
|
|
|
|
|
try { |
|
|
|
// 1. 查询未填充的主表记录 - rqrq |
|
|
|
List<RfidCountHeader> unfilledHeaders = this.lambdaQuery() |
|
|
|
// 1. 查询未处理的主表记录(只查is_used='N')- rqrq |
|
|
|
List<RfidCountHeader> unprocessedHeaders = this.lambdaQuery() |
|
|
|
.eq(RfidCountHeader::getIsUsed, "N") |
|
|
|
.isNull(RfidCountHeader::getLabelCount) |
|
|
|
.list(); |
|
|
|
|
|
|
|
if (unfilledHeaders.isEmpty()) { |
|
|
|
log.info("没有待填充的盘点记录 - rqrq"); |
|
|
|
if (unprocessedHeaders.isEmpty()) { |
|
|
|
log.info("没有待处理的盘点记录 - rqrq"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
log.info("查询到{}条待填充的盘点记录 - rqrq", unfilledHeaders.size()); |
|
|
|
log.info("查询到{}条待处理的盘点记录 - rqrq", unprocessedHeaders.size()); |
|
|
|
|
|
|
|
int successCount = 0; |
|
|
|
int failCount = 0; |
|
|
|
|
|
|
|
// 2. 遍历处理每条记录 - rqrq |
|
|
|
for (RfidCountHeader header : unfilledHeaders) { |
|
|
|
for (RfidCountHeader header : unprocessedHeaders) { |
|
|
|
try { |
|
|
|
processOneHeader(header); |
|
|
|
successCount++; |
|
|
|
@ -152,7 +151,7 @@ public class RfidCountHeaderServiceImpl extends ServiceImpl<RfidCountHeaderMappe |
|
|
|
} |
|
|
|
|
|
|
|
log.info("填充RFID日常入库盘点明细完成 - rqrq,总数={}, 成功={}, 失败={}", |
|
|
|
unfilledHeaders.size(), successCount, failCount); |
|
|
|
unprocessedHeaders.size(), successCount, failCount); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("填充RFID日常入库盘点明细失败 - rqrq:{}", e.getMessage(), e); |
|
|
|
@ -178,8 +177,9 @@ public class RfidCountHeaderServiceImpl extends ServiceImpl<RfidCountHeaderMappe |
|
|
|
if (palletDetailList == null || palletDetailList.isEmpty()) { |
|
|
|
log.warn("托盘无标签明细 - rqrq,site={}, palletId={}", |
|
|
|
header.getSite(), header.getPalletId()); |
|
|
|
// 更新label_count为0 - rqrq |
|
|
|
// 更新label_count为0,is_used='Y' - rqrq |
|
|
|
header.setLabelCount(0); |
|
|
|
header.setIsUsed("Y"); |
|
|
|
this.updateById(header); |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -245,7 +245,7 @@ public class RfidCountHeaderServiceImpl extends ServiceImpl<RfidCountHeaderMappe |
|
|
|
log.info("保存{}条明细记录 - rqrq,palletId={}", detailList.size(), header.getPalletId()); |
|
|
|
} |
|
|
|
|
|
|
|
// 6. 更新或新增快照 - rqrq |
|
|
|
// 6. 更新或新增快照(联合主键需要用LambdaUpdateWrapper)- rqrq |
|
|
|
if (!snapshotList.isEmpty()) { |
|
|
|
for (RfidCountSnapshot snapshot : snapshotList) { |
|
|
|
// 查询是否已存在 - rqrq |
|
|
|
@ -256,19 +256,25 @@ public class RfidCountHeaderServiceImpl extends ServiceImpl<RfidCountHeaderMappe |
|
|
|
); |
|
|
|
|
|
|
|
if (existSnapshot != null) { |
|
|
|
// 存在则更新 - rqrq |
|
|
|
existSnapshot.setPartNo(snapshot.getPartNo()); |
|
|
|
existSnapshot.setQty(snapshot.getQty()); |
|
|
|
existSnapshot.setBatchNo(snapshot.getBatchNo()); |
|
|
|
existSnapshot.setLocationId(snapshot.getLocationId()); |
|
|
|
existSnapshot.setWarehouseId(snapshot.getWarehouseId()); |
|
|
|
existSnapshot.setWdr(snapshot.getWdr()); |
|
|
|
existSnapshot.setLastCountDate(snapshot.getLastCountDate()); |
|
|
|
existSnapshot.setPalletId(snapshot.getPalletId()); |
|
|
|
existSnapshot.setCountResult(snapshot.getCountResult()); |
|
|
|
existSnapshot.setCountTimes(existSnapshot.getCountTimes() + 1); // 累加次数 - rqrq |
|
|
|
existSnapshot.setUpdatedDate(new Date()); |
|
|
|
rfidCountSnapshotMapper.updateById(existSnapshot); |
|
|
|
// 存在则更新(使用LambdaUpdateWrapper,因为是联合主键)- rqrq |
|
|
|
int countTimes = existSnapshot.getCountTimes() != null ? existSnapshot.getCountTimes() + 1 : 1; |
|
|
|
|
|
|
|
rfidCountSnapshotMapper.update(null, |
|
|
|
new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<RfidCountSnapshot>() |
|
|
|
.eq(RfidCountSnapshot::getSite, snapshot.getSite()) |
|
|
|
.eq(RfidCountSnapshot::getUnitId, snapshot.getUnitId()) |
|
|
|
.set(RfidCountSnapshot::getPartNo, snapshot.getPartNo()) |
|
|
|
.set(RfidCountSnapshot::getQty, snapshot.getQty()) |
|
|
|
.set(RfidCountSnapshot::getBatchNo, snapshot.getBatchNo()) |
|
|
|
.set(RfidCountSnapshot::getLocationId, snapshot.getLocationId()) |
|
|
|
.set(RfidCountSnapshot::getWarehouseId, snapshot.getWarehouseId()) |
|
|
|
.set(RfidCountSnapshot::getWdr, snapshot.getWdr()) |
|
|
|
.set(RfidCountSnapshot::getLastCountDate, snapshot.getLastCountDate()) |
|
|
|
.set(RfidCountSnapshot::getPalletId, snapshot.getPalletId()) |
|
|
|
.set(RfidCountSnapshot::getCountResult, snapshot.getCountResult()) |
|
|
|
.set(RfidCountSnapshot::getCountTimes, countTimes) |
|
|
|
.set(RfidCountSnapshot::getUpdatedDate, new Date()) |
|
|
|
); |
|
|
|
} else { |
|
|
|
// 不存在则新增 - rqrq |
|
|
|
snapshot.setCountTimes(1); |
|
|
|
@ -280,11 +286,12 @@ public class RfidCountHeaderServiceImpl extends ServiceImpl<RfidCountHeaderMappe |
|
|
|
log.info("更新{}条快照记录 - rqrq,palletId={}", snapshotList.size(), header.getPalletId()); |
|
|
|
} |
|
|
|
|
|
|
|
// 7. 更新主表的label_count - rqrq |
|
|
|
// 7. 更新主表:label_count=标签数量,is_used='Y'(标记已处理)- rqrq |
|
|
|
header.setLabelCount(detailList.size()); |
|
|
|
header.setIsUsed("Y"); |
|
|
|
this.updateById(header); |
|
|
|
|
|
|
|
log.info("处理盘点记录完成 - rqrq,site={}, palletId={}, labelCount={}", |
|
|
|
log.info("处理盘点记录完成 - rqrq,site={}, palletId={}, labelCount={}, is_used=Y", |
|
|
|
header.getSite(), header.getPalletId(), detailList.size()); |
|
|
|
} |
|
|
|
} |