liujie
6 天以前 1e90b1eea46cf72e7111a1ced9eff8c451304240
供应商erp
8个文件已修改
4个文件已添加
401 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpSupplierWarehousingController.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/InventoryDto.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/InventoryGoodsDto.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpSupplierWarehousing.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsInventoryQuery.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsInventoryVO.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpSupplierWarehousingController.java
@@ -5,15 +5,16 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.InventoryDto;
import com.ruoyi.system.dto.InventoryGoodsDto;
import com.ruoyi.system.dto.WarehousingGoodsDto;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpGoodsWarehouseQuery;
import com.ruoyi.system.query.TErpInventoryQuery;
import com.ruoyi.system.query.ValidityPeriodWarningQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.service.TErpGoodsService;
import com.ruoyi.system.service.TErpSupplierWarehousingService;
import com.ruoyi.system.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -34,11 +35,13 @@
public class TErpSupplierWarehousingController {
    private final TErpSupplierWarehousingService erpSupplierWarehousingService;
    private final TErpGoodsService erpGoodsService;
    private final TokenService tokenService;
    @Autowired
    public TErpSupplierWarehousingController(TErpSupplierWarehousingService erpSupplierWarehousingService, TokenService tokenService) {
    public TErpSupplierWarehousingController(TErpSupplierWarehousingService erpSupplierWarehousingService, TErpGoodsService erpGoodsService, TokenService tokenService) {
        this.erpSupplierWarehousingService = erpSupplierWarehousingService;
        this.erpGoodsService = erpGoodsService;
        this.tokenService = tokenService;
    }
@@ -109,6 +112,22 @@
    }
    @ApiOperation(value = "供应商 盘点 商品选择")
    @PostMapping(value = "/pageInventoryGoodsPageList")
    public R<PageInfo<TErpGoodsInventoryVO>> pageInventoryGoodsPageList(@RequestBody @Valid TErpGoodsInventoryQuery query) {
        SysUser user = tokenService.getLoginUser().getUser();
        return R.ok(erpGoodsService.pageInventoryGoodsPageList(query,user));
    }
    @ApiOperation(value = "供应商 确认盘点")
    @PostMapping(value = "/inventoryGoods")
    public R<?> inventoryGoods(@RequestBody @Valid InventoryDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        erpGoodsService.inventoryGoods(dto,user);
        return R.ok();
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/InventoryDto.java
New file
@@ -0,0 +1,22 @@
package com.ruoyi.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@ApiModel(value = "盘点Dto一级")
public class InventoryDto {
    @ApiModelProperty(value = "仓库id")
    @NotBlank(message = "仓库id不能为空")
    private String warehouseId;
    @ApiModelProperty(value = "商品信息")
    private List<InventoryGoodsDto> dtos;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/InventoryGoodsDto.java
New file
@@ -0,0 +1,30 @@
package com.ruoyi.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(value = "盘点Dto")
public class InventoryGoodsDto {
    @ApiModelProperty(value = "批次id")
    @NotBlank(message = "批次id不能为空")
    private String id;
    @ApiModelProperty(value = "目前数量")
    @NotNull(message = "目前数量不能为空")
    private Integer num;
    @ApiModelProperty(value = "盘点数量")
    @NotNull(message = "盘点数量不能为空")
    private Integer inventoryCount;
    @ApiModelProperty(value = "破损数量")
    @NotNull(message = "破损数量不能为空")
    private Integer damagedCount;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java
@@ -4,7 +4,9 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.query.TErpGoodsInventoryQuery;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.vo.TErpGoodsInventoryVO;
import com.ruoyi.system.vo.TErpGoodsVO;
import org.apache.ibatis.annotations.Param;
@@ -23,4 +25,6 @@
    List<TErpGoodsVO> pageList(@Param("query") TErpGoodsQuery query, @Param("pageInfo") PageInfo<TErpGoodsVO> pageInfo, @Param("user") SysUser user);
    List<TErpGoodsVO> listExport(@Param("query") TErpGoodsQuery query, @Param("user") SysUser user);
    List<TErpGoodsInventoryVO> pageInventoryGoodsPageList(@Param("query") TErpGoodsInventoryQuery query, @Param("pageInfo") PageInfo<TErpGoodsInventoryVO> pageInfo, @Param("user") SysUser user);
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TErpSupplierWarehousing.java
@@ -58,6 +58,8 @@
    @TableField("total_price")
    private BigDecimal totalPrice;
    private Integer type;
    @ApiModelProperty(value = "入库单号")
    @TableField("warehouse_no")
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsInventoryQuery.java
New file
@@ -0,0 +1,38 @@
package com.ruoyi.system.query;
import com.ruoyi.common.core.domain.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
@ApiModel(value = "erp商品信息查询参数query")
public class TErpGoodsInventoryQuery extends BasePage {
    @ApiModelProperty(value = "商品名称")
    private String goodsName;
    @ApiModelProperty(value = "入库单号")
    private String warehouseNo;
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;
    @ApiModelProperty(value = "商品类型id")
    private String typeId;
    @ApiModelProperty(value = "国药准字号")
    private String quasiNumber;
    @ApiModelProperty(value = "批次号 盘点使用")
    private String batchNumber;
    @ApiModelProperty(value = "仓库id")
    @NotBlank(message = "仓库id不能为空")
    private String warehouseId;
}
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java
@@ -28,4 +28,5 @@
    @ApiModelProperty(value = "库存管理条件 不足传1")
    private Integer type;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java
@@ -3,10 +3,15 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.dto.InventoryDto;
import com.ruoyi.system.dto.InventoryGoodsDto;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.query.TErpGoodsInventoryQuery;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.vo.TErpGoodsInventoryVO;
import com.ruoyi.system.vo.TErpGoodsVO;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;
@@ -38,5 +43,10 @@
    boolean isExit(String goodsIdCode,String quasiNumber);
    PageInfo<TErpGoodsInventoryVO> pageInventoryGoodsPageList(@Valid TErpGoodsInventoryQuery query, SysUser user);
    void inventoryGoods(InventoryDto dto, SysUser user);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -4,17 +4,22 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.dto.InventoryDto;
import com.ruoyi.system.dto.InventoryGoodsDto;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.model.TErpGoodsType;
import com.ruoyi.system.model.TErpGoodsUnit;
import com.ruoyi.system.model.TSysBanner;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TErpGoodsInventoryQuery;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.service.TErpGoodsService;
import com.ruoyi.system.service.TErpSupplierInventoryGoodsService;
import com.ruoyi.system.vo.TErpGoodsInventoryVO;
import com.ruoyi.system.vo.TErpGoodsVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -36,6 +41,23 @@
    @Resource
    private TErpGoodsUnitMapper erpGoodsUnitMapper;
    @Resource
    private TErpSupplierInventoryMapper erpSupplierInventoryMapper;
    @Resource
    private TErpSupplierInventoryGoodsMapper erpSupplierInventoryGoodsMapper;
    @Resource
    private TErpSupplierWarehousingMapper erpSupplierWarehousingMapper;
    @Resource
    private TErpSupplierWarehousingBatchMapper erpSupplierWarehousingBatchMapper;
    @Resource
    private TErpSupplierOutboundMapper erpSupplierOutboundMapper;
    @Resource
    private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper;
    @Override
@@ -80,7 +102,7 @@
        }
        List<String> packingUnitId = list.stream().map(TErpGoods::getPackingUnitId).collect(Collectors.toList());
        if(!packingUnitId.isEmpty()){
            List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(lowUnitIds);
            List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId);
            for (TErpGoodsVO tErpGoodsVO : list) {
                tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName()));
            }
@@ -97,4 +119,125 @@
        return false;
    }
    @Override
    public PageInfo<TErpGoodsInventoryVO> pageInventoryGoodsPageList(TErpGoodsInventoryQuery query, SysUser user) {
        PageInfo<TErpGoodsInventoryVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsPageList(query, pageInfo, user);
        if (list.isEmpty()) {
            return pageInfo;
        }
        List<String> typeIds = list.stream().map(TErpGoodsInventoryVO::getTypeId).collect(Collectors.toList());
        if (!typeIds.isEmpty()) {
            List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
            for (TErpGoodsInventoryVO tErpGoodsVO : list) {
                typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
                tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName());
            }
        }
        List<String> packingUnitId = list.stream().map(TErpGoodsInventoryVO::getPackingUnitId).collect(Collectors.toList());
        if (!packingUnitId.isEmpty()) {
            List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId);
            for (TErpGoodsInventoryVO tErpGoodsVO : list) {
                tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName()));
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public void inventoryGoods(InventoryDto dto, SysUser user) {
        TErpSupplierInventory tErpSupplierInventory = new TErpSupplierInventory();
        String s = DateUtils.dateTimeNow();
        tErpSupplierInventory.setInventoryNumber("P" + s);
        tErpSupplierInventory.setWarehouseId(dto.getWarehouseId());
        tErpSupplierInventory.setSupplierId(String.valueOf(user.getUserId()));
        erpSupplierInventoryMapper.insert(tErpSupplierInventory);
        List<InventoryGoodsDto> dtos = dto.getDtos();
        for (InventoryGoodsDto inventoryGoodsDto : dtos) {
            // 根据入库批次id查询入库信息
            TErpSupplierWarehousing tErpSupplierWarehousing = new TErpSupplierWarehousing();
            TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(inventoryGoodsDto.getId());
            String warehousingId = tErpSupplierWarehousingBatch.getWarehousingId();
            TErpSupplierWarehousing tErpSupplierWarehousing1 = erpSupplierWarehousingMapper.selectById(warehousingId);
            TErpGoods erpGoods = this.getById(tErpSupplierWarehousing1.getGoodsId());
            // 盘点是盘亏盘盈   赢
            if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) {
                // 添加入库信息
                tErpSupplierWarehousing.setWarehouseId(dto.getWarehouseId());
                tErpSupplierWarehousing.setSupplierId(String.valueOf(user.getUserId()));
                tErpSupplierWarehousing.setGoodsId(tErpSupplierWarehousing1.getGoodsId());
                tErpSupplierWarehousing.setGoodsName(erpGoods.getGoodsName());
                tErpSupplierWarehousing.setGoodsCount(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum());
                tErpSupplierWarehousing.setUnitAmount(erpGoods.getSalesAmount());
                tErpSupplierWarehousing.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(tErpSupplierWarehousing.getGoodsCount())));
                // 当前年月日时分秒
                String time = DateUtils.dateTimeNow();
                tErpSupplierWarehousing.setWarehouseNo("G" + time);
                tErpSupplierWarehousing.setType(2);
                erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
                // 添加批次信息
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpSupplierWarehousingBatch();
                tErpSupplierWarehousingBatch1.setWarehousingId(tErpSupplierWarehousing.getId());
                tErpSupplierWarehousingBatch1.setWarehousingNumber(tErpSupplierWarehousing.getGoodsCount());
                tErpSupplierWarehousingBatch1.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                tErpSupplierWarehousingBatch1.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate());
                tErpSupplierWarehousingBatch1.setExpiryDate(tErpSupplierWarehousingBatch.getExpiryDate());
                erpSupplierWarehousingBatchMapper.insert(tErpSupplierWarehousingBatch1);
                // 添加盘点信息
                TErpSupplierInventoryGoods tErpSupplierInventoryGoods = new TErpSupplierInventoryGoods();
                tErpSupplierInventoryGoods.setInventoryId(tErpSupplierInventory.getId());
                tErpSupplierInventoryGoods.setWarehousingId(tErpSupplierWarehousing.getId());
                tErpSupplierInventoryGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch1.getId());
                tErpSupplierInventoryGoods.setInventoryCount(inventoryGoodsDto.getInventoryCount());
                tErpSupplierInventoryGoods.setDamagedCount(inventoryGoodsDto.getDamagedCount());
                tErpSupplierInventoryGoods.setInventoryType(1);
                tErpSupplierInventoryGoods.setGoodsId(tErpSupplierWarehousing1.getGoodsId());
                erpSupplierInventoryGoodsMapper.insert(tErpSupplierInventoryGoods);
            } else {
                TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
                tErpSupplierOutbound.setSupplierId(String.valueOf(user.getUserId()));
                tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing1.getGoodsId());
                tErpSupplierOutbound.setOutboundType(6);
                tErpSupplierOutbound.setOutboundNumber("G" + s);
                int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount();
                tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
                tErpSupplierOutbound.setGoodsId(erpGoods.getId());
                erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
                TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
                tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
                tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing.getId());
                tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                tErpSupplierOutboundGoods.setOutboundCount(count);
                tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
                erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
                // 添加盘点信息
                TErpSupplierInventoryGoods tErpSupplierInventoryGoods = new TErpSupplierInventoryGoods();
                tErpSupplierInventoryGoods.setInventoryId(tErpSupplierInventory.getId());
                tErpSupplierInventoryGoods.setWarehousingId(tErpSupplierOutbound.getId());
                tErpSupplierInventoryGoods.setWarehousingBatchId(tErpSupplierOutboundGoods.getId());
                tErpSupplierInventoryGoods.setInventoryCount(inventoryGoodsDto.getInventoryCount());
                tErpSupplierInventoryGoods.setDamagedCount(inventoryGoodsDto.getDamagedCount());
                tErpSupplierInventoryGoods.setInventoryType(2);
                tErpSupplierInventoryGoods.setGoodsId(tErpSupplierWarehousing1.getGoodsId());
                erpSupplierInventoryGoodsMapper.insert(tErpSupplierInventoryGoods);
            }
        }
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -354,7 +354,6 @@
            return inventoryDetailVos;
        }
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsInventoryVO.java
New file
@@ -0,0 +1,61 @@
package com.ruoyi.system.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.system.model.TErpGoods;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@ApiModel(value = "供应商erp盘点商品VO")
public class TErpGoodsInventoryVO{
    @ApiModelProperty(value = "批次id")
    private String id;
    @ApiModelProperty(value = "入库单号")
    private String warehouseNo;
    @ApiModelProperty (value = "商品名称")
    private String goodsName;
    @ApiModelProperty (value = "供应商名称")
    private String supplierName;
    @ApiModelProperty (value = "商品类型名称")
    private String typeName;
    @ApiModelProperty(value = "国药准字号")
    private String quasiNumber;
    @ApiModelProperty(value = "商品标识码")
    private String goodsIdCode;
    @ApiModelProperty(value = "批次号")
    private String batchNumber;
    @ApiModelProperty(value = "商品数量")
    private Integer num;
    private String typeId;
    @ApiModelProperty(value = "商品包装单位")
    private String packingUnitName;
    private String packingUnitId;
    @ApiModelProperty(value = "商品单价")
    private BigDecimal salesAmount;
    @ApiModelProperty(value = "失效日期")
    private LocalDateTime expiryDate;
}
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -105,4 +105,54 @@
        order by create_time desc
    </select>
    <select id="pageInventoryGoodsPageList" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
select  * from (
        SELECT t1.id,t2.warehouse_no,
               t3.goods_name,
               t4.supplier_name,
               t3.type_id,
               t3.packing_unit_id,
               t3.quasi_number,
               t3.goods_id_code,
               t1.batch_number,
               coalesce(sum(t5.outbound_count),0) as outbound_count,
               t1.warehousing_number,
               t2.create_time,
               t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num,
               t3.sales_amount,
               t1.expiry_date
        from t_erp_supplier_warehousing_batch t1
                 LEFT JOIN t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id
                 LEFT JOIN t_erp_goods t3 on t2.goods_id = t3.id
                 LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id
                 LEFT JOIN t_erp_supplier_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0 and t2.warehouse_id = #{query.warehouseId}
        <if test="query.goodsName != null and query.goodsName != ''">
            and t3.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="user.roleType ==4">
            and t3.supplier_clinic_id =#{user.userId}
        </if>
        <if test="query.supplierName != null and query.supplierName != ''">
            and t4.supplier_name like concat('%',#{query.supplierName},'%')
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and t3.type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and t3.quasi_number =#{query.quasiNumber}
        </if>
        <if test="query.batchNumber != null and query.batchNumber != ''">
            and t1.batch_number =#{query.batchNumber}
        </if>
        <if test="query.warehouseNo != null and query.warehouseNo != ''">
            and t2.warehouse_no = #{query.warehouseNo}
        </if>
) as o
where (o.warehousing_number -o.outbound_count) >0
order by o.create_time desc
    </select>
</mapper>