<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.ruoyi.system.mapper.TErpSupplierWarehousingMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.system.model.TErpSupplierWarehousing">
|
<id column="id" property="id" />
|
<result column="warehouse_id" property="warehouseId" />
|
<result column="supplier_id" property="supplierId" />
|
<result column="goods_id" property="goodsId" />
|
<result column="goods_name" property="goodsName" />
|
<result column="goods_count" property="goodsCount" />
|
<result column="unit_amount" property="unitAmount" />
|
<result column="total_price" property="totalPrice" />
|
<result column="create_time" property="createTime" />
|
<result column="update_time" property="updateTime" />
|
<result column="create_by" property="createBy" />
|
<result column="update_by" property="updateBy" />
|
<result column="disabled" property="disabled" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, warehouse_id, supplier_id, goods_id, goods_name, goods_count, unit_amount, total_price, create_time, update_time, create_by, update_by, disabled
|
</sql>
|
|
<sql id="Base_Column_List1">
|
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.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,
|
</sql>
|
<select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO">
|
select * from (
|
select <include refid="Base_Column_List1"/>
|
COALESCE(sum(t2.goods_count), 0) - COALESCE(sum(t3.outbound_count), 0) as allNum,
|
COALESCE(sum(t2.total_price), 0) * ( COALESCE(sum(t2.goods_count), 0) - COALESCE(sum(t3.outbound_count), 0)) as allTotalPrice,
|
COALESCE(sum(t3.outbound_count), 0) as outNum
|
from t_erp_goods t1 left join t_erp_supplier_warehousing t2 on t1.id = t2.goods_id
|
left join t_erp_supplier_outbound_goods t3 on t2.id = t3.warehousing_id
|
where t1.disabled = 0
|
<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 t1.goods_id_code like concat('%',#{query.goodsIdCode},'%')
|
</if>
|
<if test="query.typeId != null and query.typeId != ''">
|
and t1.type_id = #{query.typeId}
|
</if>
|
<if test="query.quasiNumber != null and query.quasiNumber != ''">
|
and t1.quasi_number like concat('%',#{query.quasiNumber},'%')
|
</if>
|
<if test="query.state != null ">
|
and t1.state = #{query.state}
|
</if>
|
<if test="user.roleType != null and user.roleType == 4 ">
|
and t1.goods_source =1 and t1.supplier_clinic_id =#{query.supplierClinicId}
|
</if>
|
<if test="user.roleType != null and user.roleType == 5 ">
|
and t1.goods_source =2 and t1.supplier_clinic_id =#{query.supplierClinicId}
|
</if>
|
) o where 1=1
|
<if test="query.type != null and query.type ==1">
|
and o.warning_inventory > (o.allNum-o.outNum)
|
</if>
|
order by o.create_time desc
|
</select>
|
|
|
<select id="pageWarehouseList" resultType="com.ruoyi.system.vo.TErpGoodsWarehouseRecordLastVO">
|
|
select * from (
|
select t1.id,t1.warehouse_id houseId,t2.warehouse_name houseName,t1.total_price allTotalPrice,t1.type,1 category,null as outboundReason,t1.create_time operationTime
|
from t_erp_supplier_warehousing t1 left join t_crm_warehouse t2 on t1.warehouse_id = t2.id
|
where t1.disabled = 0 and t1.goods_id = #{query.goodsId}
|
<if test="user.roleType != null and user.roleType == 4 ">
|
and t1.supplier_id =#{query.supplierClinicId}
|
</if>
|
<if test="query.warehouseName != null and query.warehouseName != ''">
|
and t2.warehouse_name =#{query.warehouseName}
|
</if>
|
<if test="sTime != null and eTime !=null ">
|
and t1.create_time between #{sTime} and #{eTime}
|
</if>
|
|
union all
|
|
select t1.id,t1.warehouse_id houseId,t2.warehouse_name houseName,t1.total_money allTotalPrice,t1.outbound_type as type,2 category,t1.outbound_reason as outboundReason,t1.create_time operationTime
|
from t_erp_supplier_outbound t1 left join t_crm_warehouse t2 on t1.warehouse_id = t2.id
|
where t1.disabled = 0 and t1.goods_id = #{query.goodsId}
|
<if test="user.roleType != null and user.roleType == 4 ">
|
and t1.supplier_id =#{query.supplierClinicId}
|
</if>
|
|
<if test="query.warehouseName != null and query.warehouseName != ''">
|
and t2.warehouse_name =#{query.warehouseName}
|
</if>
|
<if test="sTime != null and eTime !=null ">
|
and t1.create_time between #{sTime} and #{eTime}
|
</if>
|
) as o where 1=1
|
<if test="query.type != null">
|
and o.type = #{query.type}
|
</if>
|
order by o.operationTime desc
|
|
</select>
|
|
|
<select id="validityPeriodWarning" resultType="com.ruoyi.system.vo.ValidityPeriodWarningVo">
|
select t2.warehouse_no, t4.goods_name, t4.quasi_number, t1.batch_number, 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
|
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_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>
|
<if test="query.name != null and query.name != ''">
|
and t4.goods_name like concat('%',#{query.goodsName},'%')
|
</if>
|
<if test="query.quasiNumber != null and query.quasiNumber != ''">
|
and t4.quasi_number like concat('%',#{query.quasiNumber},'%')
|
</if>
|
<if test="query.batchNumber != null and query.batchNumber != ''">
|
and t1.batch_number like concat('%',#{query.batchNumber},'%')
|
</if>
|
<if test="query.typeId != null and query.typeId != ''">
|
and t4.type_id = #{query.typeId}
|
</if>
|
order by t1.expiry_date
|
|
</select>
|
<select id="pageInventoryList" resultType="com.ruoyi.system.vo.PageInventoryListVo">
|
select t1.id,t1.create_time,t2.user_name createBy,t3.warehouse_name
|
from t_erp_supplier_inventory t1 left join sys_user t2 on t1.create_id = t2.user_id
|
left join t_crm_warehouse t3 on t1.warehouse_id =t3.id
|
where t1.disabled = 0
|
<if test="user.roleType !=null and user.roleType ==4">
|
and t1.supplier_id = #{supplierClinicId}
|
</if>
|
<if test="query.warehouseId != null and query.warehouseId != ''">
|
and t1.warehouse_id = #{query.warehouseId}
|
</if>
|
<if test="query.createBy != null and query.createBy != ''">
|
and t2.user_name like concat('%',#{query.createBy},'%')
|
</if>
|
<if test="sTime != null and eTime !=null ">
|
and t1.create_time between #{sTime} and #{eTime}
|
</if>
|
order by t1.create_time desc
|
</select>
|
|
|
</mapper>
|