|
|
@ -175,11 +175,11 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean rollbackOrder(String billNo,Integer contrastStatus) {
|
|
|
|
public boolean rollbackOrder(String billNo, Integer contrastStatus) {
|
|
|
|
//查询业务单据
|
|
|
|
//查询业务单据
|
|
|
|
StockOrderEntity stockOrderEntity = stockOrderDao.selectByBillNo(billNo);
|
|
|
|
StockOrderEntity stockOrderEntity = stockOrderDao.selectByBillNo(billNo);
|
|
|
|
//查询扫码单据
|
|
|
|
//查询扫码单据
|
|
|
|
OrderEntity orderEntity = orderDao.selectByBillNoAndStatus(billNo,contrastStatus);
|
|
|
|
OrderEntity orderEntity = orderDao.selectByBillNoAndStatus(billNo, contrastStatus);
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(orderEntity.getAction());
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(orderEntity.getAction());
|
|
|
|
if (stockOrderEntity.getStatus().equals(ConstantStatus.SORDER_CHECKED)) {
|
|
|
|
if (stockOrderEntity.getStatus().equals(ConstantStatus.SORDER_CHECKED)) {
|
|
|
|
//回退未验收单据
|
|
|
|
//回退未验收单据
|
|
|
@ -222,48 +222,53 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
不是预验收单据,则正常扣减库存,回滚业务单据状态
|
|
|
|
不是预验收单据,则正常扣减库存,回滚业务单据状态
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (isPreInOrder(orderEntity)) {
|
|
|
|
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());
|
|
|
|
invPreInProductDetailDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
//更新库存
|
|
|
|
invPreInProductDao.deleteByOrderIdFk(orderEntity.getId());
|
|
|
|
for (InvProductEntity invProductEntity : invPreInProductList) {
|
|
|
|
|
|
|
|
//查询库存码详情,如果库存码详情为空,则删除此库存
|
|
|
|
|
|
|
|
FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest();
|
|
|
|
//查询预验收库库存详情
|
|
|
|
detailParams.setBatchNo(invProductEntity.getBatchNo());
|
|
|
|
// FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|
detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode()));
|
|
|
|
// filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId());
|
|
|
|
detailParams.setProductIdFk(invProductEntity.getRelIdFk());
|
|
|
|
// List<InvProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
|
|
|
|
int count = invPreInProductDetailDao.statCount(detailParams);
|
|
|
|
// List<InvProductEntity> invPreInProductList = new ArrayList<>();
|
|
|
|
if (count == 0) {
|
|
|
|
// for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
|
|
|
|
//如果库存码详情为空,则删除此库存
|
|
|
|
// FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
|
|
|
|
invPreInProductDao.deleteById(String.valueOf(invProductEntity.getId()));
|
|
|
|
// filterInvProductRequest.setRelIdFk(invProductDetailEntity.getProductIdFk());
|
|
|
|
} else {
|
|
|
|
// filterInvProductRequest.setSupId(invProductDetailEntity.getSupId());
|
|
|
|
invPreInProductDao.updateInvProduct(invProductEntity);
|
|
|
|
// 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 {
|
|
|
|
} else {
|
|
|
|
//非预验收单据库存,正常扣减库存
|
|
|
|
//非预验收单据库存,正常扣减库存
|
|
|
|
FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|
FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|