|
|
|
|
@ -6,11 +6,21 @@ import cn.iocoder.yudao.module.common.enums.CodeTypeEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.pallet.enums.ErpPalletStatusEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.WarehouseAreaPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.WarehouseAreaSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.pallet.ErpPalletDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.mysql.pallet.ErpPalletMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInItemMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockOutItemMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.mysql.warehousearea.WarehouseAreaMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.mysql.warehouselocation.WarehouseLocationMapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -19,6 +29,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@ -26,6 +37,10 @@ import java.util.List;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_CODE_EXISTS;
|
|
|
|
|
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_DELETE_FAIL_EXISTS_LOCATION;
|
|
|
|
|
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_DELETE_FAIL_EXISTS_OCCUPIED_PALLET;
|
|
|
|
|
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_DELETE_FAIL_EXISTS_STOCK;
|
|
|
|
|
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_DELETE_FAIL_EXISTS_STOCK_IN_ITEM;
|
|
|
|
|
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_DELETE_FAIL_EXISTS_STOCK_OUT_ITEM;
|
|
|
|
|
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_NOT_EXISTS;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@ -41,6 +56,18 @@ public class WarehouseAreaServiceImpl implements WarehouseAreaService {
|
|
|
|
|
@Resource
|
|
|
|
|
private WarehouseLocationMapper warehouseLocationMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpStockMapper stockMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpStockInItemMapper stockInItemMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpStockOutItemMapper stockOutItemMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpPalletMapper palletMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private AutoCodeUtil autoCodeUtil;
|
|
|
|
|
|
|
|
|
|
@ -80,10 +107,34 @@ public class WarehouseAreaServiceImpl implements WarehouseAreaService {
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteWarehouseArea(Long id) {
|
|
|
|
|
validateWarehouseAreaExists(id);
|
|
|
|
|
validateWarehouseAreaDeletable(id);
|
|
|
|
|
warehouseAreaMapper.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void validateWarehouseAreaDeletable(Long id) {
|
|
|
|
|
if (!warehouseLocationMapper.selectListByAreaId(id).isEmpty()) {
|
|
|
|
|
throw exception(WAREHOUSE_AREA_DELETE_FAIL_EXISTS_LOCATION);
|
|
|
|
|
}
|
|
|
|
|
warehouseAreaMapper.deleteById(id);
|
|
|
|
|
if (stockMapper.selectCount(Wrappers.<ErpStockDO>lambdaQuery()
|
|
|
|
|
.eq(ErpStockDO::getAreaId, id)
|
|
|
|
|
.gt(ErpStockDO::getCount, BigDecimal.ZERO)) > 0) {
|
|
|
|
|
throw exception(WAREHOUSE_AREA_DELETE_FAIL_EXISTS_STOCK);
|
|
|
|
|
}
|
|
|
|
|
if (stockInItemMapper.selectCount(Wrappers.<ErpStockInItemDO>lambdaQuery()
|
|
|
|
|
.eq(ErpStockInItemDO::getAreaId, id)) > 0) {
|
|
|
|
|
throw exception(WAREHOUSE_AREA_DELETE_FAIL_EXISTS_STOCK_IN_ITEM);
|
|
|
|
|
}
|
|
|
|
|
if (stockOutItemMapper.selectCount(Wrappers.<ErpStockOutItemDO>lambdaQuery()
|
|
|
|
|
.eq(ErpStockOutItemDO::getAreaId, id)) > 0) {
|
|
|
|
|
throw exception(WAREHOUSE_AREA_DELETE_FAIL_EXISTS_STOCK_OUT_ITEM);
|
|
|
|
|
}
|
|
|
|
|
if (palletMapper.selectCount(Wrappers.<ErpPalletDO>lambdaQuery()
|
|
|
|
|
.eq(ErpPalletDO::getAreaId, id)
|
|
|
|
|
.and(wrapper -> wrapper.eq(ErpPalletDO::getStatus, ErpPalletStatusEnum.OCCUPIED.getStatus())
|
|
|
|
|
.or()
|
|
|
|
|
.gt(ErpPalletDO::getProductCount, BigDecimal.ZERO))) > 0) {
|
|
|
|
|
throw exception(WAREHOUSE_AREA_DELETE_FAIL_EXISTS_OCCUPIED_PALLET);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void validateWarehouseAreaExists(Long id) {
|
|
|
|
|
|