package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalProductPurchaseOrderItem;
import com.fs.hospital.vo.HospitalProductPurchaseOrderItemHVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 采购单明细Mapper接口
 *
 * @author fs
 * @date 2024-03-12
 */
public interface HospitalProductPurchaseOrderItemMapper
{
    /**
     * 查询采购单明细
     *
     * @param itemId 采购单明细主键
     * @return 采购单明细
     */
    public HospitalProductPurchaseOrderItem selectHospitalPurchaseOrderItemByItemId(Long itemId);

    /**
     * 查询采购单明细列表
     *
     * @param hospitalProductPurchaseOrderItem 采购单明细
     * @return 采购单明细集合
     */
    public List<HospitalProductPurchaseOrderItem> selectHospitalPurchaseOrderItemList(HospitalProductPurchaseOrderItem hospitalProductPurchaseOrderItem);

    /**
     * 新增采购单明细
     *
     * @param hospitalProductPurchaseOrderItem 采购单明细
     * @return 结果
     */
    public int insertHospitalPurchaseOrderItem(HospitalProductPurchaseOrderItem hospitalProductPurchaseOrderItem);

    /**
     * 修改采购单明细
     *
     * @param hospitalProductPurchaseOrderItem 采购单明细
     * @return 结果
     */
    public int updateHospitalPurchaseOrderItem(HospitalProductPurchaseOrderItem hospitalProductPurchaseOrderItem);

    /**
     * 删除采购单明细
     *
     * @param itemId 采购单明细主键
     * @return 结果
     */
    public int deleteHospitalPurchaseOrderItemByItemId(Long itemId);

    /**
     * 批量删除采购单明细
     *
     * @param itemIds 需要删除的数据主键集合
     * @return 结果
     */

    public int deleteHospitalPurchaseOrderItemByItemIds(Long[] itemIds);


    @Select({"<script> " +
            "select i.*,p.product_name,p.product_code,p.sell_price,p.product_type,p.unit from hospital_product_purchase_order_item i    " +
            "left join hospital_product p on p.product_id = i.product_id " +
            "where 1=1  " +
            "<if test = ' maps.hospitalId!=null  '> " +
            "and i.hospital_id = #{maps.hospitalId} " +
            "</if>" +
            "<if test = ' maps.orderId!=null  '> " +
            "and i.order_id = #{maps.orderId} " +
            "</if>" +
            "</script>"})
    List<HospitalProductPurchaseOrderItemHVO> selectHospitalPurchaseOrderItemListPVO(@Param("maps") HospitalProductPurchaseOrderItem hospitalProductPurchaseOrderItem);
    @Select("select * from  hospital_product_purchase_order_item where limit_count>0 AND product_id=#{hospitalId} and order_type=1 ")
    List<HospitalProductPurchaseOrderItem> selectHospitalPurchaseOrderItemByProductId(Long productId);
}
