package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalProductOutOrderItem;
import com.fs.hospital.vo.HospitalProductOutOrderItemListHVO;
import org.apache.ibatis.annotations.Select;

/**
 * 领用单明细Mapper接口
 *
 * @author fs
 * @date 2024-03-14
 */
public interface HospitalProductOutOrderItemMapper
{
    /**
     * 查询领用单明细
     *
     * @param itemId 领用单明细主键
     * @return 领用单明细
     */
    public HospitalProductOutOrderItem selectHospitalProductOutOrderItemByItemId(Long itemId);

    /**
     * 查询领用单明细列表
     *
     * @param hospitalProductOutOrderItem 领用单明细
     * @return 领用单明细集合
     */
    public List<HospitalProductOutOrderItem> selectHospitalProductOutOrderItemList(HospitalProductOutOrderItem hospitalProductOutOrderItem);

    /**
     * 新增领用单明细
     *
     * @param hospitalProductOutOrderItem 领用单明细
     * @return 结果
     */
    public int insertHospitalProductOutOrderItem(HospitalProductOutOrderItem hospitalProductOutOrderItem);

    /**
     * 修改领用单明细
     *
     * @param hospitalProductOutOrderItem 领用单明细
     * @return 结果
     */
    public int updateHospitalProductOutOrderItem(HospitalProductOutOrderItem hospitalProductOutOrderItem);

    /**
     * 删除领用单明细
     *
     * @param itemId 领用单明细主键
     * @return 结果
     */
    public int deleteHospitalProductOutOrderItemByItemId(Long itemId);

    /**
     * 批量删除领用单明细
     *
     * @param itemIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalProductOutOrderItemByItemIds(Long[] itemIds);

    @Select({"<script>     select i.*,p.product_name,p.product_code from hospital_product_out_order_item i  LEFT JOIN hospital_product p ON p.product_id=i.product_id  " +
            "<where>  \n" +
            "            <if test=\"orderId != null \"> and i.order_id = #{orderId}</if>\n" +
            "            <if test=\"hospitalId != null \"> and i.hospital_id = #{hospitalId}</if>\n" +
            "            <if test=\"productId != null \"> and i.product_id = #{productId}</if>\n" +
            "            <if test=\"batch != null  and batch != ''\"> and i.batch = #{batch}</if>\n" +
            "            <if test=\"batchNumber != null  and batchNumber != ''\"> and i.batch_number = #{batchNumber}</if>\n" +
            "            <if test=\"limitDate != null \"> and i.limit_date = #{limitDate}</if>\n" +
            "            <if test=\"money != null \"> and i.money = #{money}</if>\n" +
            "            <if test=\"count != null \"> and i.count = #{count}</if>\n" +
            "        </where> order by i.item_id desc"+
            "</script>"})

    List<HospitalProductOutOrderItemListHVO> selectHospitalProductOutOrderItemListPVO(HospitalProductOutOrderItem hospitalProductOutOrderItem);
}
