Browse Source

物料清单管理

master
廉洪喜 2 years ago
parent
commit
99c205eff3
  1. 28
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java

28
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java

@ -44,7 +44,7 @@ public class BomServiceImpl implements BomService {
@Override @Override
public Long createBom(BomCreateReqVO createReqVO) { public Long createBom(BomCreateReqVO createReqVO) {
validateBomForCreateOrUpdate(createReqVO.getId(),createReqVO.getProductItemCode(),createReqVO.getComponentItemCode(),createReqVO.getComponentUom(),createReqVO.getComponentQty(), validateBomForCreateOrUpdate(createReqVO.getId(),createReqVO.getProductItemCode(),createReqVO.getComponentItemCode(),createReqVO.getVersion(),createReqVO.getComponentUom(),createReqVO.getComponentQty(),
createReqVO.getProcessCode(),createReqVO.getAvailable()); createReqVO.getProcessCode(),createReqVO.getAvailable());
// 插入 // 插入
BomDO bom = BomConvert.INSTANCE.convert(createReqVO); BomDO bom = BomConvert.INSTANCE.convert(createReqVO);
@ -53,12 +53,21 @@ public class BomServiceImpl implements BomService {
return bom.getId(); return bom.getId();
} }
public BomDO existBom(String productItemCode,String componentItemCode,String version){
QueryWrapper<BomDO> queryWrapper = new QueryWrapper();
queryWrapper.eq("product_item_code",productItemCode);
queryWrapper.eq("component_item_code",componentItemCode);
queryWrapper.eq("version",version);
BomDO bomDO = bomMapper.selectOne(queryWrapper);
return bomDO;
}
@Override @Override
public void updateBom(BomUpdateReqVO updateReqVO) { public void updateBom(BomUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
validateBomForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getProductItemCode(),updateReqVO.getComponentItemCode(),updateReqVO.getComponentUom(), validateBomForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getProductItemCode(),updateReqVO.getComponentItemCode(),updateReqVO.getVersion(),updateReqVO.getComponentUom(),
updateReqVO.getComponentQty(),updateReqVO.getProcessCode(),updateReqVO.getAvailable()); updateReqVO.getComponentQty(),updateReqVO.getProcessCode(),updateReqVO.getAvailable());
// 更新 // 更新
BomDO updateObj = BomConvert.INSTANCE.convert(updateReqVO); BomDO updateObj = BomConvert.INSTANCE.convert(updateReqVO);
bomMapper.updateById(updateObj); bomMapper.updateById(updateObj);
@ -105,7 +114,7 @@ public class BomServiceImpl implements BomService {
message.append(ex.getMessage()).append(","); message.append(ex.getMessage()).append(",");
} }
try { try {
validateProductItemCodeExists(null,bomDo.getProductItemCode()); validateProductItemCodeExists(null,bomDo.getProductItemCode(),bomDo.getComponentItemCode(),bomDo.getVersion());
} catch (ServiceException ex) { } catch (ServiceException ex) {
message.append(ex.getMessage()).append(","); message.append(ex.getMessage()).append(",");
} }
@ -185,16 +194,16 @@ public class BomServiceImpl implements BomService {
} }
} }
private void validateBomForCreateOrUpdate(Long id,String productItemCode,String componentItemCode, private void validateBomForCreateOrUpdate(Long id,String productItemCode,String componentItemCode,String version,
String componentUom,BigDecimal componentQty,String processCode,String available) { String componentUom,BigDecimal componentQty,String processCode,String available) {
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
DataPermissionUtils.executeIgnore(() -> { DataPermissionUtils.executeIgnore(() -> {
validateBomExists(id); validateBomExists(id);
// 校验code唯一 // 校验code唯一
validateProductItemCodeExists(id,productItemCode);
validateComponentUomExists(componentUom); validateComponentUomExists(componentUom);
validateAvailableExists(available); validateAvailableExists(available);
validateComponentItemCodeExists(componentItemCode); validateComponentItemCodeExists(componentItemCode);
validateProductItemCodeExists(id,productItemCode,componentItemCode,version);
validateComponentQtyExists(componentQty); validateComponentQtyExists(componentQty);
validateProcessCodeExists(processCode); validateProcessCodeExists(processCode);
}); });
@ -209,15 +218,18 @@ public class BomServiceImpl implements BomService {
throw exception(BOM_NOT_EXISTS); throw exception(BOM_NOT_EXISTS);
} }
} }
@VisibleForTesting @VisibleForTesting
private void validateProductItemCodeExists(Long id,String productItemCode) { private void validateProductItemCodeExists(Long id,String productItemCode,String componentItemCode,String version) {
if (productItemCode.isEmpty()) { if (productItemCode.isEmpty()) {
throw exception(BOM_PRODUCT_ITEM_CODE_NOT_EXISTS); throw exception(BOM_PRODUCT_ITEM_CODE_NOT_EXISTS);
} }
if (StrUtil.isBlank(productItemCode)) { if (StrUtil.isBlank(productItemCode)) {
return; return;
} }
BomDO bom = bomMapper.selectByProductItemCode(productItemCode); BomDO bom = existBom(productItemCode,componentItemCode,version);
if (bom == null) { if (bom == null) {
return; return;
} }

Loading…
Cancel
Save