|
|
|
@ -185,7 +185,18 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
//查询业务单据
|
|
|
|
|
StockOrderEntity stockOrderEntity = stockOrderDao.selectByBillNo(billNo);
|
|
|
|
|
//查询扫码单据
|
|
|
|
|
OrderEntity orderEntity = orderDao.selectByBillNo(billNo);
|
|
|
|
|
OrderEntity orderEntity=new OrderEntity();
|
|
|
|
|
List<OrderEntity> orderEntityList = orderDao.selectByBillNoAndStatus(billNo);
|
|
|
|
|
if(orderEntityList.size()>1){
|
|
|
|
|
for (OrderEntity obj:orderEntityList){
|
|
|
|
|
if(obj.getErpFk().equals(billNo)){
|
|
|
|
|
orderEntity=obj;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
orderEntity=orderEntityList.get(0);
|
|
|
|
|
}
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(orderEntity.getAction());
|
|
|
|
|
if (stockOrderEntity.getStatus().equals(ConstantStatus.SORDER_CHECKED)) {
|
|
|
|
|
//回退未验收单据
|
|
|
|
@ -202,11 +213,11 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
stockOrderEntity.setStatus(ConstantStatus.SORDER_CHECK);
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
orderEntity.setErpFk("");
|
|
|
|
|
stockOrderEntity.setOrderIdFk("");
|
|
|
|
|
stockOrderDao.updateById(stockOrderEntity);
|
|
|
|
|
orderDao.updateOrder(orderEntity);
|
|
|
|
|
//置空扫码单据详情关联的业务单据号
|
|
|
|
|
orderDetailDao.updateErpOrderId(orderEntity.getId(), null);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
orderEntity.setErpFk("");
|
|
|
|
|
stockOrderDao.deleteById(stockOrderEntity.getId());
|
|
|
|
@ -214,6 +225,12 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
orderDao.updateOrder(orderEntity);
|
|
|
|
|
//置空扫码单据详情关联的业务单据号
|
|
|
|
|
orderDetailDao.updateErpOrderId(orderEntity.getId(), null);
|
|
|
|
|
|
|
|
|
|
List<WarehouseEntity> warehouseEntityList = codesDao.findByReceiptId(orderEntity.getId());
|
|
|
|
|
if (CollUtil.isNotEmpty(warehouseEntityList)) {
|
|
|
|
|
codesTempService.insertCodesTemp(warehouseEntityList);
|
|
|
|
|
codesDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//回退已完成单据
|
|
|
|
@ -225,48 +242,52 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
不是预验收单据,则正常扣减库存,回滚业务单据状态
|
|
|
|
|
*/
|
|
|
|
|
if (isPreInOrder(orderEntity)) {
|
|
|
|
|
//查询预验收库库存详情
|
|
|
|
|
FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|
|
filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId());
|
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
|
|
|
|
|
List<InvProductEntity> invPreInProductList = new ArrayList<>();
|
|
|
|
|
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
|
|
|
|
|
FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
|
|
|
|
|
filterInvProductRequest.setRelIdFk(invProductDetailEntity.getProductIdFk());
|
|
|
|
|
filterInvProductRequest.setSupId(invProductDetailEntity.getSupId());
|
|
|
|
|
filterInvProductRequest.setInvWarehouseCode(invProductDetailEntity.getInvWarehouseCode());
|
|
|
|
|
filterInvProductRequest.setInvStorageCode(invProductDetailEntity.getInvStorageCode());
|
|
|
|
|
if (StrUtil.isBlank(invProductDetailEntity.getBatchNo())) {
|
|
|
|
|
filterInvProductRequest.setBatchNo("empty");
|
|
|
|
|
} else {
|
|
|
|
|
filterInvProductRequest.setBatchNo(invProductDetailEntity.getBatchNo());
|
|
|
|
|
}
|
|
|
|
|
List<InvProductEntity> invProductEntities = invPreInProductDao.filterInvProduct(filterInvProductRequest);
|
|
|
|
|
if (CollUtil.isNotEmpty(invProductEntities) && invProductEntities.size() > 0) {
|
|
|
|
|
InvProductEntity invProductEntity = invProductEntities.get(0);
|
|
|
|
|
calculateInvCount(invProductEntity, invProductDetailEntity);
|
|
|
|
|
invPreInProductList.add(invProductEntity);
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//删除库存详情
|
|
|
|
|
|
|
|
|
|
invPreInProductDetailDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
|
//更新库存
|
|
|
|
|
for (InvProductEntity invProductEntity : invPreInProductList) {
|
|
|
|
|
//查询库存码详情,如果库存码详情为空,则删除此库存
|
|
|
|
|
FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest();
|
|
|
|
|
detailParams.setBatchNo(invProductEntity.getBatchNo());
|
|
|
|
|
detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode()));
|
|
|
|
|
detailParams.setProductIdFk(invProductEntity.getRelIdFk());
|
|
|
|
|
int count = invPreInProductDetailDao.statCount(detailParams);
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
//如果库存码详情为空,则删除此库存
|
|
|
|
|
invPreInProductDao.deleteById(String.valueOf(invProductEntity.getId()));
|
|
|
|
|
} else {
|
|
|
|
|
invPreInProductDao.updateInvProduct(invProductEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
invPreInProductDao.deleteByOrderIdFk(orderEntity.getId());
|
|
|
|
|
|
|
|
|
|
// //查询预验收库库存详情
|
|
|
|
|
// FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|
|
// filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId());
|
|
|
|
|
// List<InvProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
|
|
|
|
|
// List<InvProductEntity> invPreInProductList = new ArrayList<>();
|
|
|
|
|
// for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
|
|
|
|
|
// FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
|
|
|
|
|
// filterInvProductRequest.setRelIdFk(invProductDetailEntity.getProductIdFk());
|
|
|
|
|
// filterInvProductRequest.setSupId(invProductDetailEntity.getSupId());
|
|
|
|
|
// filterInvProductRequest.setInvWarehouseCode(invProductDetailEntity.getInvWarehouseCode());
|
|
|
|
|
// filterInvProductRequest.setInvStorageCode(invProductDetailEntity.getInvStorageCode());
|
|
|
|
|
// if (StrUtil.isBlank(invProductDetailEntity.getBatchNo())) {
|
|
|
|
|
// filterInvProductRequest.setBatchNo("empty");
|
|
|
|
|
// } else {
|
|
|
|
|
// filterInvProductRequest.setBatchNo(invProductDetailEntity.getBatchNo());
|
|
|
|
|
// }
|
|
|
|
|
// List<InvProductEntity> invProductEntities = invPreInProductDao.filterInvProduct(filterInvProductRequest);
|
|
|
|
|
// if (CollUtil.isNotEmpty(invProductEntities) && invProductEntities.size() > 0) {
|
|
|
|
|
// InvProductEntity invProductEntity = invProductEntities.get(0);
|
|
|
|
|
// calculateInvCount(invProductEntity, invProductDetailEntity);
|
|
|
|
|
// invPreInProductList.add(invProductEntity);
|
|
|
|
|
// } else {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// //删除库存详情
|
|
|
|
|
// invPreInProductDetailDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
|
// //更新库存
|
|
|
|
|
// for (InvProductEntity invProductEntity : invPreInProductList) {
|
|
|
|
|
// //查询库存码详情,如果库存码详情为空,则删除此库存
|
|
|
|
|
// FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest();
|
|
|
|
|
// detailParams.setBatchNo(invProductEntity.getBatchNo());
|
|
|
|
|
// detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode()));
|
|
|
|
|
// detailParams.setProductIdFk(invProductEntity.getRelIdFk());
|
|
|
|
|
// int count = invPreInProductDetailDao.statCount(detailParams);
|
|
|
|
|
// if (count == 0) {
|
|
|
|
|
// //如果库存码详情为空,则删除此库存
|
|
|
|
|
// invPreInProductDao.deleteById(String.valueOf(invProductEntity.getId()));
|
|
|
|
|
// } else {
|
|
|
|
|
// invPreInProductDao.updateInvProduct(invProductEntity);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
//非预验收单据库存,正常扣减库存
|
|
|
|
|
FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|
@ -330,7 +351,7 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
orderEntity.setErpFk("");
|
|
|
|
|
stockOrderDao.updateById(stockOrderEntity);
|
|
|
|
|
orderDao.updateOrder(orderEntity);
|
|
|
|
|
// orderDao.updateOrder(orderEntity);
|
|
|
|
|
} else {
|
|
|
|
|
orderEntity.setErpFk("");
|
|
|
|
|
stockOrderDao.deleteById(stockOrderEntity.getId());
|
|
|
|
@ -339,12 +360,11 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
List<WarehouseEntity> warehouseEntityList = codesDao.findByReceiptId(orderEntity.getId());
|
|
|
|
|
if (CollUtil.isNotEmpty(warehouseEntityList)) {
|
|
|
|
|
codesTempService.insertCodesTemp(warehouseEntityList);
|
|
|
|
|
codesDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
|
// codesDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新业务单据数据
|
|
|
|
|