package market.Mes.Tpm.mapper;
import java.util.List;

import market.Mes.Tpm.vo.PlnSkinrollingPlan;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.hnshituo.orm.GenericMapper;

public interface PlnSkinrollingPlanMapper extends GenericMapper<PlnSkinrollingPlan,Object> {

	@Update ("update PLN_SKINROLLING_PLAN set status =#{status} where sr_plan_no=#{sr_plan_no}")
	void doUpdate(PlnSkinrollingPlan plp);

	@Delete("delete from PLN_SKINROLLING_PLAN t where t.sr_plan_no = #{sr_plan_no}")
	void doDeleteSrPlanNo(PlnSkinrollingPlan pp);

	@Update ("update PLN_SKINROLLING_PLAN set mat_quantity = nvl(mat_quantity,0) + #{mat_quantity} , mat_weight = nvl(mat_weight,0) + #{mat_weight} where sr_plan_no=#{sr_plan_no}")
	void doUpdatePlaned(PlnSkinrollingPlan plp);

	Integer doCount1(String v_mch_code, String v_entry_coil_no);

	PlnSkinrollingPlan doQuery1(String v_mch_code, String v_entry_coil_no);

	Integer doCount2(String v_mch_code, String string);

	Long doCount3(String v_mch_code, String string);

	Long doCount4(String v_mch_code, Long v_plan_seq);

	List<PlnSkinrollingPlan> doQuery2(String v_mch_code, Long v_plan_seq);

	Integer doCount5(String v_mch_code, String string);

	Integer doCount6(String v_mch_code, String v_plan_no, String v_entry_coil_no);

	@Update(" update PLN_SKINROLLING_PLAN set plan_seq = #{param1.plan_seq} where sr_plan_no = #{param1.sr_plan_no} and plan_seq = #{param2}")
	int doUpdateSeq(PlnSkinrollingPlan pln, Integer i);
	
	@Select("select OBJECT_NO from PLN_ROLLING_PLAN_DETAIL where OBJECT_NO = #{coil}\n" +
              "union\n" +
              "select OBJECT_NO from PLN_PICKLE_PLAN_DETAIL where OBJECT_NO = #{coil}\n" +
              "union\n" +
              "select OBJECT_NO from PLN_CUTTOLENGTH_PLAN_DETAIL where OBJECT_NO = #{coil}\n" +
              "union\n" +
              "select OBJECT_NO from PLN_ANNEAL_PLAN_DETAIL where OBJECT_NO = #{coil}\n" +
              "union\n" +
              "select OBJECT_NO from PLN_LENGTHWISE_PLAN_DETAIL where OBJECT_NO = #{coil}\n" +
              "union\n" +
              "select OBJECT_NO from PLN_SKINROLLING_PLAN_DETAIL where OBJECT_NO = #{coil}")
	List<String> isCoilNext(@Param("coil") String coil);
}
