|
|
@ -1,5 +1,6 @@
|
|
|
|
package com.glxp.sale.admin.service.inout.impl;
|
|
|
|
package com.glxp.sale.admin.service.inout.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.glxp.sale.admin.constant.ConstantStatus;
|
|
|
|
import com.glxp.sale.admin.constant.ConstantStatus;
|
|
|
@ -165,7 +166,6 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
public boolean rollbackOrder(String billNo) {
|
|
|
|
public boolean rollbackOrder(String billNo) {
|
|
|
|
//查询业务单据
|
|
|
|
//查询业务单据
|
|
|
|
StockOrderEntity stockOrderEntity = stockOrderDao.selectByBillNo(billNo);
|
|
|
|
StockOrderEntity stockOrderEntity = stockOrderDao.selectByBillNo(billNo);
|
|
|
|
|
|
|
|
|
|
|
|
//查询扫码单据
|
|
|
|
//查询扫码单据
|
|
|
|
OrderEntity orderEntity = orderDao.selectByBillNo(billNo);
|
|
|
|
OrderEntity orderEntity = orderDao.selectByBillNo(billNo);
|
|
|
|
if (stockOrderEntity.getStatus().equals(ConstantStatus.SORDER_CHECKED)) {
|
|
|
|
if (stockOrderEntity.getStatus().equals(ConstantStatus.SORDER_CHECKED)) {
|
|
|
@ -198,7 +198,9 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId());
|
|
|
|
filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId());
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, List<InvProductDetailEntity>> invPreInProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk));
|
|
|
|
Map<String, List<InvProductDetailEntity>> invPreInProductDetailMap = invProductDetailEntities
|
|
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk));
|
|
|
|
|
|
|
|
|
|
|
|
List<InvProductEntity> invPreInProductList = new ArrayList<>(invPreInProductDetailMap.keySet().size());
|
|
|
|
List<InvProductEntity> invPreInProductList = new ArrayList<>(invPreInProductDetailMap.keySet().size());
|
|
|
|
|
|
|
|
|
|
|
@ -248,42 +250,43 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId());
|
|
|
|
filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId());
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
|
|
|
|
|
|
|
|
|
|
|
|
//合并各个产品集合数据
|
|
|
|
// //合并各个产品集合数据
|
|
|
|
Map<String, List<InvProductDetailEntity>> invProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk));
|
|
|
|
// Map<String, List<InvProductDetailEntity>> invProductDetailMap =
|
|
|
|
|
|
|
|
// invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk));
|
|
|
|
List<InvProductEntity> invProductList = new ArrayList<>(invProductDetailMap.keySet().size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String productId : invProductDetailMap.keySet()) {
|
|
|
|
List<InvProductEntity> invProductList = new ArrayList<>();
|
|
|
|
List<InvProductDetailEntity> detailList = invProductDetailMap.get(productId);
|
|
|
|
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
|
|
|
|
//查询库存
|
|
|
|
|
|
|
|
FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
|
|
|
|
FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
|
|
|
|
filterInvProductRequest.setRelIdFk(productId);
|
|
|
|
filterInvProductRequest.setRelIdFk(invProductDetailEntity.getProductIdFk());
|
|
|
|
filterInvProductRequest.setSupId(detailList.get(0).getSupId());
|
|
|
|
filterInvProductRequest.setSupId(invProductDetailEntity.getSupId());
|
|
|
|
filterInvProductRequest.setInvWarehouseCode(detailList.get(0).getInvWarehouseCode());
|
|
|
|
filterInvProductRequest.setInvWarehouseCode(invProductDetailEntity.getInvWarehouseCode());
|
|
|
|
filterInvProductRequest.setInvStorageCode(detailList.get(0).getInvStorageCode());
|
|
|
|
filterInvProductRequest.setInvStorageCode(invProductDetailEntity.getInvStorageCode());
|
|
|
|
if (StrUtil.isNotBlank(detailList.get(0).getBatchNo())) {
|
|
|
|
if (StrUtil.isBlank(invProductDetailEntity.getBatchNo())) {
|
|
|
|
filterInvProductRequest.setBatchNo("empty");
|
|
|
|
filterInvProductRequest.setBatchNo("empty");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
filterInvProductRequest.setBatchNo(detailList.get(0).getBatchNo());
|
|
|
|
filterInvProductRequest.setBatchNo(invProductDetailEntity.getBatchNo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<InvProductEntity> invProductEntities = invProductDao.filterInvProduct(filterInvProductRequest);
|
|
|
|
List<InvProductEntity> invProductEntities = invProductDao.filterInvProduct(filterInvProductRequest);
|
|
|
|
InvProductEntity invProductEntity = invProductEntities.get(0);
|
|
|
|
if (CollUtil.isNotEmpty(invProductEntities) && invProductEntities.size() > 0) {
|
|
|
|
|
|
|
|
InvProductEntity invProductEntity = invProductEntities.get(0);
|
|
|
|
detailList.forEach(invProductDetailEntity -> calculateInvCount(invProductEntity, invProductDetailEntity));
|
|
|
|
calculateInvCount(invProductEntity, invProductDetailEntity);
|
|
|
|
|
|
|
|
invProductList.add(invProductEntity);
|
|
|
|
invProductList.add(invProductEntity);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//删除库存详情
|
|
|
|
//删除库存详情
|
|
|
|
invProductDetailDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
invProductDetailDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
//删除码详情
|
|
|
|
//删除码详情
|
|
|
|
codesDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
// codesDao.deleteByOrderId(orderEntity.getId());
|
|
|
|
//更新库存
|
|
|
|
//更新库存
|
|
|
|
for (InvProductEntity invProductEntity : invProductList) {
|
|
|
|
for (InvProductEntity invProductEntity : invProductList) {
|
|
|
|
//查询库存码详情,如果库存码详情为空,则删除此库存
|
|
|
|
//查询库存码详情,如果库存码详情为空,则删除此库存
|
|
|
|
FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest();
|
|
|
|
FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest();
|
|
|
|
detailParams.setBatchNo(invProductEntity.getBatchNo());
|
|
|
|
detailParams.setBatchNo(invProductEntity.getBatchNo());
|
|
|
|
detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode()));
|
|
|
|
detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode()));
|
|
|
|
|
|
|
|
detailParams.setInvWarehouseCode(invProductEntity.getInvWarehouseCode());
|
|
|
|
|
|
|
|
detailParams.setSupId(invProductEntity.getSupId());
|
|
|
|
detailParams.setProductIdFk(invProductEntity.getRelIdFk());
|
|
|
|
detailParams.setProductIdFk(invProductEntity.getRelIdFk());
|
|
|
|
int count = invProductDetailDao.statCount(detailParams);
|
|
|
|
int count = invProductDetailDao.statCount(detailParams);
|
|
|
|
if (count == 0) {
|
|
|
|
if (count == 0) {
|
|
|
@ -294,7 +297,6 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//修改单据状态到未验收
|
|
|
|
//修改单据状态到未验收
|
|
|
|
stockOrderEntity.setStatus(ConstantStatus.SORDER_CHECKED);
|
|
|
|
stockOrderEntity.setStatus(ConstantStatus.SORDER_CHECKED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|