feat(wms): 补全出入库明细中的单位信息
- 在新增出入库明细时,如果单位信息为空,自动从商品或原材料表中获取 - 支持产品和原材料两种物料类型的单位信息补全 - 优化了数据录入流程,提高了系统易用性
This commit is contained in:
@@ -7,6 +7,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.klp.common.utils.StringUtils;
|
import com.klp.common.utils.StringUtils;
|
||||||
|
import com.klp.domain.WmsProduct;
|
||||||
|
import com.klp.domain.WmsRawMaterial;
|
||||||
|
import com.klp.mapper.WmsProductMapper;
|
||||||
|
import com.klp.mapper.WmsRawMaterialMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -37,6 +41,8 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
|||||||
|
|
||||||
private final WmsStockIoDetailMapper baseMapper;
|
private final WmsStockIoDetailMapper baseMapper;
|
||||||
private final WmsStockIoMapper stockIoMapper;
|
private final WmsStockIoMapper stockIoMapper;
|
||||||
|
private final WmsProductMapper productMapper;
|
||||||
|
private final WmsRawMaterialMapper rawMaterialMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询出入库单明细
|
* 查询出入库单明细
|
||||||
@@ -102,7 +108,19 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
|||||||
if (stockIo != null && stockIo.getStatus() >= 2) {
|
if (stockIo != null && stockIo.getStatus() >= 2) {
|
||||||
throw new ServiceException("已审核的单据不能修改明细");
|
throw new ServiceException("已审核的单据不能修改明细");
|
||||||
}
|
}
|
||||||
|
// 如果unit为空,自动查item表补全(新增逻辑)
|
||||||
|
String unit = bo.getUnit();
|
||||||
|
if (unit == null || unit.trim().isEmpty()) {
|
||||||
|
if ("product".equals(bo.getItemType())) {
|
||||||
|
WmsProduct p = productMapper.selectById(bo.getItemId());
|
||||||
|
unit = p != null ? p.getUnit() : null;
|
||||||
|
} else if ("raw_material".equals(bo.getItemType())) {
|
||||||
|
WmsRawMaterial r = rawMaterialMapper.selectById(bo.getItemId());
|
||||||
|
unit = r != null ? r.getUnit() : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 将获取到的unit设置回bo对象
|
||||||
|
bo.setUnit(unit);
|
||||||
WmsStockIoDetail add = BeanUtil.toBean(bo, WmsStockIoDetail.class);
|
WmsStockIoDetail add = BeanUtil.toBean(bo, WmsStockIoDetail.class);
|
||||||
validEntityBeforeSave(add);
|
validEntityBeforeSave(add);
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user