package com.sw.common.accessory.server.mapper;

import com.sw.common.accessory.server.entity.AccessoryProductionOrder;
import com.sw.common.mybatisplus.base.BaseDao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lf
 * @description
 * @date 2024/3/9 20:12
 */
@Mapper
public interface AccessoryProductionOrderMapper extends BaseDao<AccessoryProductionOrder> {
    @Select("select * from accessory_production_order where material_code = #{materialCode} and production_no = #{productionNo} and device_code =  #{deviceCode} and del = 0")
    AccessoryProductionOrder findMaterialCodeAndProductionNo(String materialCode, String productionNo,String deviceCode);
    @Select("select * from accessory_production_order where material_code = #{materialCode} and accessory_id = #{accessoryId} and device_code =  #{deviceCode} and del = 0")
    AccessoryProductionOrder findMaterialCodeAndAccessoryId(String materialCode, Long accessoryId, String deviceCode);
    @Select("select * from accessory_production_order where order_no_id = #{orderNoId} and device_code =  #{deviceCode} and del = 0 and material_del = 0")
    AccessoryProductionOrder productionMaterialToSAP(Long orderNoId, String deviceCode);
    @Select("select * from accessory_production_order where order_no_id = #{orderNoId} and device_code =  #{deviceCode} and del = 0 and production_del = 0")
    AccessoryProductionOrder productionOrderToSAP(Long orderNoId, String deviceCode);
    @Select("select * from accessory_production_order where order_no_id = #{orderNoId} and del = 0 and production_del = 0 order by id desc limit 1")
    AccessoryProductionOrder findOrderNoId(Long orderNoId);
    @Select("select * from accessory_production_order where order_no_id = #{orderNoId} and del = 0 order by id desc limit 1")
    AccessoryProductionOrder findByOrderNoId(Long orderNoId);
    @Select("select * from accessory_production_order where del = 0 and production_del = 0")
    List<AccessoryProductionOrder> findAllProductionOrderNo();
    @Select("select * from accessory_production_order where del = 0 and material_del = 0")
    List<AccessoryProductionOrder> findAllMaterialOrderNo();
}
