liujie
2025-10-14 a5a5dddc7c8d7ec5c2c6b5219a88081172809327
bug修改
9个文件已修改
1个文件已添加
316 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysGoodsController.java 119 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/ExchangeGoodsDto.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmClinicPoints.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TSysGoodsService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysGoodsServiceImpl.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpMaintenanceReminderListVo.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpMaintenanceReminderMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysGoodsController.java
@@ -9,6 +9,7 @@
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.ExchangeGoodsDto;
import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TSysGoodsExchangeQuery;
@@ -20,7 +21,10 @@
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -40,21 +44,25 @@
    private final TokenService tokenService;
    private final TCrmSupplierService crmSupplierService;
    private final TSysGoodsExchangeService sysGoodsExchangeService;
    private final TCrmClinicService crmClinicService;
    private final TCrmClinicPointsService crmClinicPointsService;
    @Autowired
    public TSysGoodsController(TokenService tokenService, TSysGoodsService sysGoodsService, TCrmSupplierService crmSupplierService, TSysGoodsExchangeService sysGoodsExchangeService) {
    public TSysGoodsController(TokenService tokenService, TSysGoodsService sysGoodsService, TCrmSupplierService crmSupplierService, TSysGoodsExchangeService sysGoodsExchangeService, TCrmClinicService crmClinicService, TCrmClinicPointsService crmClinicPointsService) {
        this.sysGoodsService = sysGoodsService;
        this.tokenService = tokenService;
        this.crmSupplierService = crmSupplierService;
        this.sysGoodsExchangeService = sysGoodsExchangeService;
        this.crmClinicService = crmClinicService;
        this.crmClinicPointsService = crmClinicPointsService;
    }
    /**
     * 获取积分商品列表
     */
    @ApiOperation(value = "获取积分商品列表")
    @ApiOperation(value = "获取积分商品列表--供应商")
    @PostMapping(value = "/pageList")
    public R<PageInfo<TSysGoods>> pageList(@RequestBody TSysGoodsQuery query) {
@@ -92,8 +100,7 @@
    }
    @ApiOperation(value = "添加积分商品")
    @ApiOperation(value = "添加积分商品--供应商")
    @PostMapping(value = "/add")
    public R<String> add(@RequestBody TSysGoods goods) {
        SysUser user = tokenService.getLoginUser().getUser();
@@ -110,7 +117,7 @@
        return R.ok();
    }
    @ApiOperation(value = "编辑积分商品")
    @ApiOperation(value = "编辑积分商品--供应商")
    @PostMapping(value = "/update")
    public R<String> update(@RequestBody TSysGoods goods) {
        SysUser user = tokenService.getLoginUser().getUser();
@@ -118,7 +125,7 @@
        List<TSysGoodsExchange> list = sysGoodsExchangeService.list(new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getGoodsId, goods.getId()));
        int sum = list.stream().mapToInt(TSysGoodsExchange::getGoodsCount).sum();
        if(goods.getGoodsTotal()< sum){
        if (goods.getGoodsTotal() < sum) {
            return R.fail("商品总数不能小于已兑换数量");
        }
        if (roleType == 4) {
@@ -134,8 +141,7 @@
    }
    @ApiOperation(value = "删除积分商品")
    @ApiOperation(value = "删除积分商品--供应商")
    @DeleteMapping(value = "/delete/{id}")
    public R<String> delete(@PathVariable String id) {
        SysUser user = tokenService.getLoginUser().getUser();
@@ -146,9 +152,9 @@
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            TSysGoods goods = sysGoodsService.getById(id);
            if(goods.getSupplierId().equals(crmSupplier.getId())){
            if (goods.getSupplierId().equals(crmSupplier.getId())) {
                sysGoodsService.removeById(id);
            }else {
            } else {
                return R.fail("没有权限");
            }
        }
@@ -156,7 +162,7 @@
    }
    @ApiOperation(value = "积分商品 上下架")
    @ApiOperation(value = "积分商品 上下架--供应商")
    @PostMapping(value = "/updateStatus")
    public R<String> updateStatus(@RequestBody @Valid TErpGoodsUpdateStatusDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
@@ -167,10 +173,10 @@
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            TSysGoods goods = sysGoodsService.getById(dto.getId());
            if(goods.getSupplierId().equals(crmSupplier.getId())){
            if (goods.getSupplierId().equals(crmSupplier.getId())) {
                goods.setStatus(dto.getState());
                sysGoodsService.updateById(goods);
            }else {
            } else {
                return R.fail("没有权限");
            }
        }
@@ -179,18 +185,18 @@
    // 获取兑换记录
    @ApiOperation(value = "获取兑换记录")
    @ApiOperation(value = "获取兑换记录--供应商")
    @PostMapping(value = "/getExchangeRecord")
    public R<PageInfo<TSysGoodsExchange>> getExchangeRecord(@RequestBody @Valid TSysGoodsExchangeQuery query) {
        PageInfo<TSysGoodsExchange> page = new PageInfo<>(query.getPageNum(), query.getPageSize());
        LambdaQueryWrapper<TSysGoodsExchange> wrapper = new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getGoodsId, query.getId());
        if(query.getClinicName()!=null && !query.getClinicName().isEmpty()){
        if (query.getClinicName() != null && !query.getClinicName().isEmpty()) {
            wrapper.like(TSysGoodsExchange::getClinicName, query.getClinicName());
        }
        if(query.getTime()!=null && !query.getTime().isEmpty()){
            wrapper.between(TSysGoodsExchange::getCreateTime, query.getTime().split(" - ")[0]+ " 00:00:00", query.getTime().split(" - ")[1]+ " 23:59:59");
        if (query.getTime() != null && !query.getTime().isEmpty()) {
            wrapper.between(TSysGoodsExchange::getCreateTime, query.getTime().split(" - ")[0] + " 00:00:00", query.getTime().split(" - ")[1] + " 23:59:59");
        }
        if(query.getStatus()!=null){
        if (query.getStatus() != null) {
            wrapper.eq(TSysGoodsExchange::getStatus, query.getStatus());
        }
        wrapper.orderByDesc(BaseModel::getCreateTime);
@@ -199,11 +205,11 @@
    }
    // 获取兑换记录
    @ApiOperation(value = "发货")
    @ApiOperation(value = "发货--供应商")
    @PostMapping(value = "/sendGoods")
    public R<?> sendGoods(@RequestBody @Valid TSysGoodsExchange exchange) {
        TSysGoodsExchange exchange1 = sysGoodsExchangeService.getById(exchange.getId());
        if(exchange1.getStatus()==2){
        if (exchange1.getStatus() == 2) {
            return R.fail("该订单已发货");
        }
        exchange1.setStatus(2);
@@ -212,5 +218,78 @@
        return R.ok();
    }
    /**
     * 获取积分商品列表
     */
    @ApiOperation(value = "获取积分商品列表--诊所")
    @PostMapping(value = "/pageListClinic")
    public R<HashMap<String, Object>> pageListClinic(@RequestBody TSysGoodsQuery query) {
        PageInfo<TSysGoods> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        LambdaQueryWrapper<TSysGoods> tSysGoodsLambdaQueryWrapper = new LambdaQueryWrapper<>();
        tSysGoodsLambdaQueryWrapper.eq(TSysGoods::getStatus,1);
        if (query.getGoodsName() != null && !query.getGoodsName().isEmpty()) {
            tSysGoodsLambdaQueryWrapper.like(TSysGoods::getGoodsName, query.getGoodsName());
        }
        tSysGoodsLambdaQueryWrapper.orderByDesc(BaseModel::getCreateTime);
        Page<TSysGoods> page = sysGoodsService.page(pageInfo, tSysGoodsLambdaQueryWrapper);
        List<TSysGoods> records = page.getRecords();
        if (!records.isEmpty()) {
            List<TSysGoodsExchange> list = sysGoodsExchangeService.list(new LambdaQueryWrapper<TSysGoodsExchange>().in(TSysGoodsExchange::getGoodsId, records.stream().map(TSysGoods::getId).collect(Collectors.toList())));
            records.forEach(item -> {
                item.setExchangeQuantity(list.stream().filter(item1 -> item1.getGoodsId().equals(item.getId())).mapToInt(TSysGoodsExchange::getGoodsCount).sum());
                item.setSurplusQuantity(item.getGoodsTotal() - item.getExchangeQuantity());
            });
        }
        pageInfo.setRecords(records);
        HashMap<String, Object> map = new HashMap<>();
        map.put("data",pageInfo);
        // 获取我的可用积分
        map.put("total",sysGoodsService.count(tSysGoodsLambdaQueryWrapper));
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            List<TCrmClinicPoints> list = crmClinicPointsService.list(new LambdaQueryWrapper<TCrmClinicPoints>().eq(TCrmClinicPoints::getClinicId, crmClinic.getId()).ge(TCrmClinicPoints::getExpireTime, new Date()).last(" and points > use_points"));
            map.put("myPoints",list.stream().mapToInt(item -> item.getPoints() - item.getUsePoints()).sum());
        }
        return R.ok(map);
    }
    /**
     * 获取积分商品详情
     */
    @ApiOperation(value = "获取积分商品列表--详情")
    @GetMapping(value = "/detail/{id}")
    public R<TSysGoods> detail(@PathVariable String id) {
        TSysGoods goods= sysGoodsService.getById(id);
        return R.ok(goods);
    }
    /**
     * 兑换商品
     */
    @ApiOperation(value = "兑换商品--诊所")
    @PostMapping(value = "/exchangeGoods")
    public R<?> exchangeGoods(@RequestBody @Valid ExchangeGoodsDto dto) {
        SysUser user = tokenService.getLoginUser().getUser();
        Integer roleType = user.getRoleType();
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            sysGoodsService.exchangeGoods(crmClinic, dto);
            return R.ok();
        }
        return R.fail("请选择正确的角色");
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/ExchangeGoodsDto.java
New file
@@ -0,0 +1,21 @@
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("诊所兑换商品dto")
public class ExchangeGoodsDto {
    @ApiModelProperty("商品id")
    @NotBlank(message = "商品id不能为空")
    private String goodsId;
    @ApiModelProperty("数量")
    @NotNull(message = "数量不能为空")
    private Integer count;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TCrmClinicPoints.java
@@ -49,7 +49,7 @@
    @ApiModelProperty(value = "已使用")
    @TableField("use_points")
    private Double usePoints;
    private Integer usePoints;
}
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java
@@ -10,6 +10,9 @@
@ApiModel(value = "erp商品库存信息查询参数query")
public class TErpGoodsQuery extends BasePage {
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;
    @ApiModelProperty(value = "商品名称")
    private String goodsName;
ruoyi-system/src/main/java/com/ruoyi/system/service/TSysGoodsService.java
@@ -1,7 +1,11 @@
package com.ruoyi.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.dto.ExchangeGoodsDto;
import com.ruoyi.system.model.TCrmClinic;
import com.ruoyi.system.model.TSysGoods;
import javax.validation.Valid;
/**
 * <p>
@@ -13,4 +17,7 @@
 */
public interface TSysGoodsService extends IService<TSysGoods> {
    void exchangeGoods(TCrmClinic crmClinic, ExchangeGoodsDto dto);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysGoodsServiceImpl.java
@@ -1,10 +1,22 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.dto.ExchangeGoodsDto;
import com.ruoyi.system.mapper.TCrmChangePointsMapper;
import com.ruoyi.system.mapper.TCrmClinicPointsMapper;
import com.ruoyi.system.mapper.TSysGoodsExchangeMapper;
import com.ruoyi.system.mapper.TSysGoodsMapper;
import com.ruoyi.system.model.TSysGoods;
import com.ruoyi.system.model.*;
import com.ruoyi.system.service.TSysGoodsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
 * <p>
@@ -17,4 +29,72 @@
@Service
public class TSysGoodsServiceImpl extends ServiceImpl<TSysGoodsMapper, TSysGoods> implements TSysGoodsService {
    @Resource
    private TSysGoodsExchangeMapper sysGoodsExchangeMapper;
    @Resource
    private TCrmClinicPointsMapper crmClinicPointsMapper;
    @Resource
    private TCrmChangePointsMapper crmChangePointsMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void exchangeGoods(TCrmClinic crmClinic, ExchangeGoodsDto dto) {
        // 盘点库存是否足够  判断积分是否足够  减积分  记录积分变更 添加购买记录
        TSysGoods tSysGoods = this.getById(dto.getGoodsId());
        int needPoints = tSysGoods.getRequiredPoints().intValue() * dto.getCount();
        // 判断已经购买的了多少
        List<TSysGoodsExchange> list = sysGoodsExchangeMapper.selectList(new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getGoodsId, dto.getGoodsId()));
        int sum = list.stream().mapToInt(TSysGoodsExchange::getGoodsCount).sum();
        if(sum+dto.getCount()>tSysGoods.getGoodsTotal()){
            throw new RuntimeException("商品库存不足");
        }
        if(sum+dto.getCount()>tSysGoods.getConvertibleQuantity()){
            throw new RuntimeException("可兑换数量不足");
        }
        List<TCrmClinicPoints> points = crmClinicPointsMapper.selectList(new LambdaQueryWrapper<TCrmClinicPoints>().eq(TCrmClinicPoints::getClinicId, crmClinic.getId()).ge(TCrmClinicPoints::getExpireTime, new Date()).last(" and points > use_points").orderByAsc(TCrmClinicPoints::getCreateTime));
        // 可用积分
        int userPoints = points.stream().mapToInt(item -> item.getPoints() - item.getUsePoints()).sum();
        if(userPoints<needPoints){
            throw new RuntimeException("积分不足");
        }
        for (TCrmClinicPoints point : points) {
            if(needPoints==0){
                break;
            }
            if(point.getPoints()-point.getUsePoints()>=needPoints){
                point.setUsePoints(point.getUsePoints()+needPoints);
                crmClinicPointsMapper.updateById(point);
                needPoints = 0;
            }else {
                point.setUsePoints(point.getPoints());
                crmClinicPointsMapper.updateById(point);
                needPoints= needPoints - (point.getPoints() - point.getUsePoints());
            }
        }
        // 添加兑换记录
        TSysGoodsExchange exchange = new TSysGoodsExchange();
        exchange.setClinicName(crmClinic.getClinicName());
        exchange.setGoodsName(tSysGoods.getGoodsName());
        exchange.setGoodsId(tSysGoods.getId());
        exchange.setGoodsCount(dto.getCount());
        exchange.setUsePoints(tSysGoods.getRequiredPoints().intValue() * dto.getCount());
        exchange.setExchangeTime(LocalDateTime.now());
        sysGoodsExchangeMapper.insert(exchange);
        // 记录
        TCrmChangePoints tCrmChangePoints = new TCrmChangePoints();
        tCrmChangePoints.setBranchSalespersonId(crmClinic.getId());
        tCrmChangePoints.setExchangeId(exchange.getId());
        tCrmChangePoints.setUserType(3);
        tCrmChangePoints.setChangeType(2);
        tCrmChangePoints.setChangeReason(2);
        tCrmChangePoints.setChangeValue(exchange.getUsePoints());
        crmChangePointsMapper.insert(tCrmChangePoints);
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpMaintenanceReminderListVo.java
@@ -41,6 +41,11 @@
    private LocalDateTime maintenanceTime;
    @ApiModelProperty(value = "维护完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime successTime;
    @ApiModelProperty(value = "状态 1=未维护 2=已维护")
    private Integer status;
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -53,33 +53,58 @@
storage,supplier_name
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select
        <include refid="Base_Column_List"/>
        from t_erp_goods where disabled = 0
        <if test="query.goodsName != null and query.goodsName != ''">
            and goods_name like concat('%',#{query.goodsName},'%')
       t1.id
        ,  t1.supplier_clinic_id,  t1.goods_source,  t1.goods_name,  t1.goods_id_code,  t1.quasi_number,  t1.manufacturer,  t1.formulation_spec,  t1.packing_spec,  t1.type_id,  t1.goods_yards,  t1.maintenance_interval, t1.maintenance_interval_unit,  t1.low_purchase_quantity,  t1.low_unit_id,  t1.is_prescription_drug,  t1.goods_spec,  t1.warning_inventory,  t1.sales_amount,  t1.packing_unit_id,  t1.instructions_use,  t1.side_effect,  t1.clinic_purchase_price,  t1.platform_commission_price,  t1.create_time,  t1.update_time,  t1.create_by, t1.`state`,  t1.update_by,  t1.disabled,
        t1.simplified_code,
        t1.dosage_form,
        t1.usage_classification,
        t1.product_brand,
        t1.place_of_origin,
        t1.ingredient,
        t1.trait,
        t1.indication,
        t1.taboo,
        t1.precautions,
        t1.interaction,
        t1.storage,
        case t1.goods_source
        when 1 then t2.supplier_name
        when 2 then t1.supplier_name
        end as supplierName
        from t_erp_goods t1 left join t_crm_supplier t2 on t1.supplier_clinic_id = t2.id where  t1.disabled = 0
        <if test="query.supplierName != null and query.supplierName != ''">
            and  (t1.supplier_name like concat('%',#{query.supplierName},'%') or t2.supplier_name like concat('%',#{query.supplierName},'%'))
        </if>
        <if test="query.goodsName != null and query.goodsName != ''">
            and  t1.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.goodsIdCode != null and query.goodsIdCode != ''">
            and goods_id_code like concat('%',#{query.goodsIdCode},'%')
            and  t1.goods_id_code like concat('%',#{query.goodsIdCode},'%')
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and type_id = #{query.typeId}
            and  t1.type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and quasi_number like concat('%',#{query.quasiNumber},'%')
            and  t1.quasi_number like concat('%',#{query.quasiNumber},'%')
        </if>
        <if test="query.state != null ">
            and state = #{query.state}
            and  t1.state = #{query.state}
        </if>
        <if test="user.roleType != null and user.roleType == 4 ">
            and goods_source =1 and supplier_clinic_id = #{query.supplierClinicId}
            and  t1.goods_source =1 and  t1.supplier_clinic_id = #{query.supplierClinicId}
        </if>
        <if test="user.roleType != null and user.roleType == 5 ">
            and  ( (goods_source =2 and supplier_clinic_id = #{query.supplierClinicId} ) or (FIND_IN_SET(#{query.supplierClinicId},clinic_ids) and state =1))
            and  ( ( t1.goods_source =2 and  t1.supplier_clinic_id = #{query.supplierClinicId} ) or (FIND_IN_SET(#{query.supplierClinicId}, t1.clinic_ids) and  t1.state =1))
        </if>
        order by create_time desc
        order by  t1.create_time desc
    </select>
    <select id="listExport" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select
        <include refid="Base_Column_List"/>
ruoyi-system/src/main/resources/mapper/system/TErpMaintenanceReminderMapper.xml
@@ -31,7 +31,8 @@
               t1.maintenance_person_id,
               t1.maintenance_time,
               t1.`status`,
               t3.warehouse_no
               t3.warehouse_no,
               t1.success_time as successTime
        from t_erp_maintenance_reminder t1
                 LEFT JOIN t_erp_supplier_warehousing_batch t2 on t1.warehousing_batch_id = t2.id
                 left join t_erp_supplier_warehousing t3 on t2.warehousing_id = t3.id
ruoyi-system/src/main/resources/mapper/system/TErpSupplierWarehousingMapper.xml
@@ -108,21 +108,20 @@
    <select id="validityPeriodWarning" resultType="com.ruoyi.system.vo.ValidityPeriodWarningVo">
        select t2.warehouse_id,t2.warehouse_no warehousingNo, t4.goods_name, t4.quasi_number, t1.batch_number, t1.id as batchId,t1.expiry_date, t4.id as goodsId,t5.type_name,t6.unit_name packingUnitName,
               case
                  when t3.id is null then t1.warehousing_number
                  else t1.warehousing_number -t3.outbound_count
               end as num
        select * from (select t2.warehouse_id,t2.warehouse_no warehousingNo, t4.goods_name, t4.quasi_number,
        t1.batch_number, t1.id as batchId,t1.expiry_date, t4.id as goodsId,t5.type_name,t6.unit_name packingUnitName,
        case
        when t3.id is null then t1.warehousing_number
        else t1.warehousing_number -t3.outbound_count
        end as num,t3.id as ogid
        from t_erp_supplier_warehousing_batch t1
                 left join t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id
                 LEFT JOIN t_erp_supplier_outbound_goods t3 on t3.warehousing_batch_id = t1.id
                 LEFT JOIN t_erp_goods t4 on t2.goods_id = t4.id
                left join t_erp_goods_type t5 on t4.type_id = t5.id
        left join t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_supplier_outbound_goods t3 on t3.warehousing_batch_id = t1.id
        LEFT JOIN t_erp_goods t4 on t2.goods_id = t4.id
        left join t_erp_goods_type t5 on t4.type_id = t5.id
        left join t_erp_goods_unit t6 on t4.packing_unit_id = t6.id
        where #{time} > t1.expiry_date
          and (t1.warehousing_number - t3.outbound_count > 0 or t3.id is null)
          <if test="user.roleType !=null and user.roleType ==4">
              and t2.supplier_id =#{supplierClinicId}
          <if test="user.roleType !=null and user.roleType ==4">  and t2.supplier_id =#{supplierClinicId}
          </if>
        <if test="query.name != null and query.name != ''">
            and t4.goods_name like concat('%',#{query.goodsName},'%')
@@ -136,7 +135,9 @@
        <if test="query.typeId != null and query.typeId != ''">
            and t4.type_id = #{query.typeId}
        </if>
        order by t1.expiry_date
        group by t1.id
        ) as o where (o.num > 0 or o.ogid is null)
        order by o.expiry_date
    </select>
    <select id="pageInventoryList" resultType="com.ruoyi.system.vo.PageInventoryListVo">