package com.sw.mes.yb.production.dao;

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.production.entity.ProductionCircleDosingList;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
* @Author
* @Description：
* @Date:
* @Modified By:
*/
public interface ProductionCircleDosingListDao extends BaseDao<ProductionCircleDosingList, Integer>{

    @Modifying
    @Transactional
    @Query(value = "UPDATE production_circle_dosing_list SET `status`=?2 WHERE id =?1 ", nativeQuery = true)
    void updateStatus(Long id, int i);

    @Query(value = "select * from production_circle_dosing_list where recipe_id = ?1", nativeQuery = true)
    List<ProductionCircleDosingList> getObjectByRecipeOId(Long id);

    @Query(value = "select product_name from production_circle_dosing_list where del = 0 GROUP BY product_name", nativeQuery = true)
    List<String> getAllProductName();

    @Query(value = "select * from production_circle_dosing_list where id = ?1", nativeQuery = true)
    ProductionCircleDosingList getOneById(Long pId);

    @Query(value = "select * from production_circle_dosing_list where product_name = ?1", nativeQuery = true)
	List<ProductionCircleDosingList> findByProductName(String matnr);


    @Modifying
    @Query(value = "UPDATE production_circle_dosing_list SET `del`=?2 WHERE id =?1 ", nativeQuery = true)
	void updateDel(Long id, int del);
}
