| | |
| | | <sql id="Base_Column_List"> |
| | | id, procurement_id, clinic_id, goods_id, goods_name, supplier_name, quasi_number, sales_amount, purchase_count, total_price, warehousing_type, create_time, update_time, create_by, update_by, disabled |
| | | </sql> |
| | | <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_clinic_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 ==5"> |
| | | and t1.clinic_id = #{supplierClinicId} |
| | | </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> |
| | | |
| | | |
| | | <select id="validityPeriodWarning" resultType="com.ruoyi.system.vo.ValidityPeriodWarningVo"> |
| | | select 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 |
| | | from t_erp_clinic_warehousing_batch t1 |
| | | left join t_erp_clinic_warehousing t2 on t1.warehousing_id = t2.id |
| | | LEFT JOIN t_erp_clinic_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 ==5"> |
| | | and t2.clinic_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> |
| | | |
| | | <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, |
| | | SUM(t2.unit_amount * (t2.goods_count - COALESCE(t3.outbound_count, 0))) as allTotalPrice, |
| | | |
| | | COALESCE(sum(t3.outbound_count), 0) as outNum |
| | | from t_erp_goods t1 left join t_erp_clinic_warehousing t2 on t1.id = t2.goods_id |
| | | left join t_erp_clinic_outbound_goods t3 on t2.id = t3.warehousing_id |
| | | where t1.disabled = 0 and t2.id is not null |
| | | <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} ) or find_in_set(#{query.supplierClinicId},t1.clinic_ids) ) |
| | | </if> |
| | | GROUP BY t1.id |
| | | ) 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> |
| | | |
| | | </mapper> |