opt:优化倒扣逻辑,后续倒扣不走回传

This commit is contained in:
zhangzq
2026-09-23 10:44:31 +08:00
parent 8b85de3de9
commit be36b45dda
7 changed files with 41 additions and 67 deletions

View File

@@ -52,7 +52,7 @@ public class WorkOrderBomItem {
private String DeptCode;
/**
* 反冲料
* 反冲料如果是就是1
*/
private String REEKZ;

View File

@@ -416,7 +416,7 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
for (WorkOrderBomItem bomItem : workOrderBomItems) {
final String materialCode = bomItem.getMaterialCode();
final BigDecimal bomQty = bomItem.getBomQty();
if (bomQty == null || bomQty.intValue() == 0){
if (bomQty == null || bomQty.intValue() == 0 || !"1".equals(bomItem.getREEKZ())){
continue;
}
boolean hasBom = feedingRecordBoms.stream().anyMatch(i -> Objects.equals(i.getMaterial_code(), bomItem.getMaterialCode()));

View File

@@ -36,7 +36,7 @@ public class ReceiveReturnAutoTask {
log.info("========>倒冲领料定时回传列表:{}", list.stream().map(ReceiveOutReturn::getBillno).collect(Collectors.joining(",")));
for (ReceiveOutReturn item : list) {
try {
receiveOutReturnService.uploadErp(item);
receiveOutReturnService.uploadWms(item);
} catch (Exception e) {
log.error("========>倒冲领料定时回传错误:{}", e.getMessage());
}

View File

@@ -76,7 +76,7 @@ public class ReceiveOutReturnController {
@PostMapping("/upload")
@Log("EAS过账")
public ResponseEntity<Object> upload(@RequestBody ReceiveOutReturn receive) {
receiveOutReturnService.uploadErp(receive);
receiveOutReturnService.uploadWms(receive);
return ResponseData.build();
}
@GetMapping("/easStock")

View File

@@ -41,7 +41,7 @@ public interface IReceiveOutReturnService extends IService<ReceiveOutReturn> {
void restoreDetails(Set<Long> detailIds);
void uploadErp(ReceiveOutReturn mst);
void uploadWms(ReceiveOutReturn mst);
/**
* 抽出事物方法

View File

@@ -323,7 +323,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
@Override
@Transactional
public void uploadErp(ReceiveOutReturn mst) {
public void uploadWms(ReceiveOutReturn mst) {
if (mst == null || mst.getId() == null) {throw new BadRequestException("请选择需要回传的数据");}
ReceiveOutReturn entity = this.getById(mst.getId());
if (entity == null) {throw new BadRequestException("回传记录不存在");}
@@ -365,19 +365,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
BigDecimal::add
));
final QueryEasStockRequest easStockRequest = new QueryEasStockRequest();
easStockRequest.setOrgno("01.09.14");
easStockRequest.setWarehouseno(details.get(0).getWarehouseno());
final List<QueryEasStockResponse> easStockResponses = easApi.queryStock(easStockRequest);
// 将库存列表转换为 Map,key 为 materialno,value 为 qty(转为 BigDecimal)
Map<String, BigDecimal> stockMap = easStockResponses.stream()
.collect(Collectors.toMap(
QueryEasStockResponse::getMaterialno,
response -> new BigDecimal(response.getQty()),
(existing, replacement) -> existing // 如果有重复物料号,保留第一个
));
final List<ReceiveOutReturnDetail> failDetailWMS = new ArrayList<>();
final List<ReceiveOutReturnDetail> failDetailEAS = new ArrayList<>();
final List<ReceiveOutReturnDetail> needDetail = new ArrayList<>();
//出入库过账数据
@@ -392,23 +380,17 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
List<OutFinishParam> outFinsParams = new ArrayList<>();
for (ReceiveOutReturnDetail detail : details) {
//已经生成单子但是回传EAS报错了
if (detail.getStatus().equals(StockReturnStatusEnum.ERROR.getCode())){
needDetail.add(detail);
//已经生成单子但是倒扣报错了
if (detail.getStatus().equals(StockReturnStatusEnum.SUCESS.getCode())||detail.getStatus().equals(StockReturnStatusEnum.IGNORE.getCode())){
continue;
}
final String materialCode = detail.getMaterialno();
final BigDecimal qty = detail.getQty();
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode);
final BigDecimal easQty = stockMap.get(materialCode) == null?BigDecimal.ZERO:stockMap.get(materialCode);
if (qty.compareTo(actualQty) > 0) {
failDetailWMS.add(detail);
continue;
}
if (qty.compareTo(easQty)>0) {
failDetailEAS.add(detail);
continue;
}
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
ioStorInvDtl.setIostorinv_id(invId);
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
@@ -424,7 +406,6 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
ioStorInvDtl.setSource_bill_code(mst.getBillno());
ioStorInvDtl.setSource_bill_type("work_order");
totalQty.add(qty);
// 分配
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
@@ -457,7 +438,6 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
needDetail.add(detail);
//内存更新库存,保证物料库存准确判断
groupInventoryMap.put(materialCode,actualQty.subtract(qty));
stockMap.put(materialCode,easQty.subtract(qty));
}
if (!CollectionUtils.isEmpty(ioStorInvDtls)){
IOStorInv ioStorInv = new IOStorInv();
@@ -491,18 +471,12 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
.in(ReceiveOutReturnDetail::getId,failDetailWMS.stream()
.map(ReceiveOutReturnDetail::getId).collect(Collectors.toList())));
}
if (!CollectionUtils.isEmpty(failDetailEAS)){
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
.set(ReceiveOutReturnDetail::getRemark,"EAS库存不足")
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.TODO.getCode())
.set(ReceiveOutReturnDetail::getUpdateTime,now)
.in(ReceiveOutReturnDetail::getId,failDetailEAS.stream()
.map(ReceiveOutReturnDetail::getId).collect(Collectors.toList())));
}
log.info("======>请求EAS领料出库单数据条:"+needDetail.size());
if (!CollectionUtils.isEmpty(needDetail)){
final ErpUtil login = ErpUtil.create().login();
iReceiveOutReturnService.callEasByAllBill(entity, needDetail, now, login);
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.SUCESS.getCode())
.set(ReceiveOutReturnDetail::getRemark,"")
.set(ReceiveOutReturnDetail::getUpdateTime,now)
.in(ReceiveOutReturnDetail::getId,details.stream()));
}
this.refreshUploadResult(entity.getId());
}
@@ -740,11 +714,11 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
entity.setUpdateTime(DateUtil.now());
if (present){
entity.setStatus(StockReturnStatusEnum.FAIL.getCode());
entity.setRemark("存在回传失败明细");
entity.setRemark("存在倒扣失败明细");
entity.setUpdateTime(DateUtil.now());
}else {
entity.setStatus(StockReturnStatusEnum.SUCESS.getCode());
entity.setRemark("回传成功");
entity.setRemark("倒扣成功");
}
this.updateById(entity);
}

View File

@@ -50,17 +50,17 @@
</el-form>
</div>
<crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="warning"
icon="el-icon-position"
size="mini"
:disabled="uploadFlag"
@click="upload"
>
回传EAS
</el-button>
<!-- <el-button-->
<!-- slot="right"-->
<!-- class="filter-item"-->
<!-- type="warning"-->
<!-- icon="el-icon-position"-->
<!-- size="mini"-->
<!-- :disabled="uploadFlag"-->
<!-- @click="upload"-->
<!-- >-->
<!-- 回传EAS-->
<!-- </el-button>-->
<el-button
slot="right"
class="filter-item"
@@ -157,14 +157,14 @@
<el-descriptions-item label="出入库单号">{{ currentRow.requestId }}</el-descriptions-item>
<el-descriptions-item :span="2" label="报工参数">{{ currentRow.reportParam }}</el-descriptions-item>
</el-descriptions>
<div style="margin-top: 12px;">
<el-button size="mini" type="warning" plain :disabled="!canBatchIgnore" @click="handleBatchIgnore">
批量忽略过账
</el-button>
<el-button size="mini" type="success" plain :disabled="!canBatchRestore" @click="handleBatchRestore">
批量恢复过账
</el-button>
</div>
<!-- <div style="margin-top: 12px;">-->
<!-- <el-button size="mini" type="warning" plain :disabled="!canBatchIgnore" @click="handleBatchIgnore">-->
<!-- 批量忽略过账-->
<!-- </el-button>-->
<!-- <el-button size="mini" type="success" plain :disabled="!canBatchRestore" @click="handleBatchRestore">-->
<!-- 批量恢复过账-->
<!-- </el-button>-->
<!-- </div>-->
<el-table ref="detailTable" :data="pagedDetails" size="mini" style="width: 100%; margin-top: 8px;" @selection-change="onDetailSelectionChange">
<el-table-column type="selection" width="40" />
<el-table-column prop="seq" label="序号" width="60" />
@@ -181,13 +181,13 @@
<el-table-column prop="warehouseno" label="仓库" min-width="60" />
<el-table-column prop="remark" label="备注" min-width="180" />
<el-table-column prop="updateTime" label="更新时间" min-width="130" />
<el-table-column label="操作" width="110" align="center" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="primary" plain @click="handleSyncEasStock(scope.row)">
EAS库存
</el-button>
</template>
</el-table-column>
<!-- <el-table-column label="操作" width="110" align="center" fixed="right">-->
<!-- <template slot-scope="scope">-->
<!-- <el-button size="mini" type="primary" plain @click="handleSyncEasStock(scope.row)">-->
<!-- EAS库存-->
<!-- </el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table>
<el-pagination
style="margin-top: 8px; text-align: right;"