package market.Mes.Lengthwise.Plan.mapper;

import java.util.HashMap;
import java.util.List;

import market.Api.Mes.impl.ProcessPoint;
import market.Mes.Lengthwise.Design.vo.PlnLengthwiseDsnMain;
import market.Mes.Lengthwise.Plan.vo.PlnMaterielDetail;
import market.Mes.Lengthwise.Plan.vo.PlnMaterielDetailLengthwiseDsnMain;
import market.Mes.Lengthwise.Plan.vo.PlnMaterielDetailSum;

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

import com.hnshituo.orm.GenericMapper;

public interface PlnMaterielDetailMapper extends GenericMapper<PlnMaterielDetail,Object> {

	List<PlnMaterielDetailSum> doQuery(PlnMaterielDetail mcsm);

	void doUpdate(PlnMaterielDetail pmd);

	void doDelete(String order_no);

	List<PlnMaterielDetailLengthwiseDsnMain> doActQuery(PlnMaterielDetail sum, String sWhere);

	void doMaterialReplaceUpdate(PlnMaterielDetail plnMaterielDetail);

	void doUpdateLwPlanNo(PlnMaterielDetail pmdu);
	
	// 虚拟物料表：修改各母卷，的横剪计划号[Cl_plan_no]字段
	void doUpdateClPlanNo(PlnMaterielDetail pmdu);

	int getObjectVtMaxNoForDate();

	List<HashMap> doSumOrderForDsnNo(PlnLengthwiseDsnMain pldm);

	List<HashMap> doSumProdOrderForDsnNo(PlnLengthwiseDsnMain pldm);

	void doUpdateCancelRelation(PlnMaterielDetail pmdu);

	void doUpdateRelease(PlnMaterielDetail pmdu);

	void doUpdateLengthwiseFinshSum(PlnMaterielDetail pmdu);

	int getObjectVtMaxNoForDate(String sDate);

	List<PlnMaterielDetail> doQueryInfo(PlnMaterielDetail pmd);

	void doDeleteId(PlnMaterielDetail pmdc);

	void doUpdateCancelDesigns(PlnMaterielDetail pmdc);

	List<PlnMaterielDetail> doQueryDsn(PlnMaterielDetail object);

	List<PlnMaterielDetailSum> doQueryMaterial_no(PlnMaterielDetail pmd);

	// 修改虚拟物料表的母卷记录：OBJECT_NO=NULL;  NEED_EXTOPT=1;  CL_PLAN_NO=NULL
	void doUpdateCuttoLengthFinshSum(PlnMaterielDetail pmdu);

	// 横剪释放接口 修改虚拟物料表【PLN_MATERIEL_DETAIL】信息
	void doUpdateReleaseCuttolength(PlnMaterielDetail pmdu);

	// 修改虚拟物料表的母卷记录：已横剪次数IS_FINISHED=1
	void doUpdateIs_Next_Finished(PlnMaterielDetail pmdu);

	// 获取虚拟物料对应的cut_type
	String findProcess(String object_no_vt);

	// 修改横剪虚拟物料信息
	void doUpdateCancelCLDesigns(PlnMaterielDetail pmdc);
    // 横剪计划编制查询子卷信息
	List<PlnMaterielDetail> doQueryCl_Sub_InfoWeb(PlnMaterielDetail object);

	List<PlnMaterielDetail> doQueryWeb2(String object_no_vt, String string);

	// 保存机台号
	void doUpdateMachine_code(PlnMaterielDetail pln);

	// 删除物料信息
	void doDeleteByOrdflg(PlnMaterielDetail pmddetele);

	// 修改纵剪虚拟物料子卷信息
	void updateLwByMat_No(PlnMaterielDetail child);
	
	// 修改横剪虚拟物料子卷信息
	void updateClByMat_No(PlnMaterielDetail child);

	// 查询罩退子卷信息
	List<PlnMaterielDetail> doQueryAn_Sub_InfoWeb(PlnMaterielDetail object);
	
	// 修改罩退虚拟物料子卷信息
	void updateAnByMat_No(PlnMaterielDetail child);

	@Update(" update PLN_MATERIEL_DETAIL set an_plan_no = #{an_plan_no} , status = #{status} where object_no_vt = #{object_no_vt}")
	void doUpdateAnPlanNo(PlnMaterielDetail pmdu);
	
	@Update(" update PLN_MATERIEL_DETAIL t set t.mat_object_no_vt=null,t.an_design_no=null,t.is_prev_dsn_finished=null where t.serial_no = #{serial_no} ")
	void doUpdateCancelANDesigns(PlnMaterielDetail pmdc);

	void doUpdateAnnealFinshSum(PlnMaterielDetail pmdu);

	@Update(" update PLN_MATERIEL_DETAIL set pline_code = #{pline_code} , machine_code = #{machine_code} where object_no = #{object_no} ")
	void updateMachine_Code(PlnMaterielDetail pmdM);
	
	@Update(" update PLN_MATERIEL_DETAIL set invalid_flg = '1'  where serial_no = #{serial_no} ")
	void ChildToInvalid(PlnMaterielDetail pln);
	
	@Update(" update PLN_MATERIEL_DETAIL set invalid_flg = '0'  where serial_no = #{serial_no} ")
	void ChildToValid(PlnMaterielDetail pln);

	void doUpdateSkinrollingFinshSum(PlnMaterielDetail pmdu);

	// 平整查询子卷
	List<PlnMaterielDetail> doQuerySr_Sub_InfoWeb(PlnMaterielDetail object);

	void updateSrByMat_No(PlnMaterielDetail child);
	
	@Update(" update PLN_MATERIEL_DETAIL set sr_plan_no = #{sr_plan_no} ,status = #{status}  where object_no_vt = #{object_no_vt}")
	void doUpdateSrPlanNo(PlnMaterielDetail pmdu);

	void doUpdateAnStatus(PlnMaterielDetail pmdu);

	void doUpdateSrStatus(PlnMaterielDetail pmdu);

	// 查讯已挂单未完成的虚拟物料信息
	List<PlnMaterielDetail> doQueryMaterielInfo(PlnMaterielDetail pme, String sWhere, ProcessPoint processpoint);

	@Delete(" delete from PLN_MATERIEL_DETAIL where mat_object_no_vt = #{mat_object_no_vt}")
	void doDeleteByMat(PlnMaterielDetail pmd);

	void doUpdateRollingFinshSum(PlnMaterielDetail pmdu);
	
	// 轧制相关查询
	@Update(" update PLN_MATERIEL_DETAIL set rl_plan_no = #{rl_plan_no} , status = #{status} where object_no_vt = #{object_no_vt}")
	void doUpdateRlPlanNo(PlnMaterielDetail pmdu);
	
	void updateRlByMat_No(PlnMaterielDetail child);
	
	void doUpdateRlStatus(PlnMaterielDetail pmdu);
	
	List<PlnMaterielDetail> doQueryRl_Sub_InfoWeb(PlnMaterielDetail object);

	void doUpdatePickleFinshSum(PlnMaterielDetail pmdu);

	// ----------------酸洗工序-------------
	// 修改酸洗虚拟物料子卷信息
	void updatePcByMat_No(PlnMaterielDetail child);

	void doUpdatePcStatus(PlnMaterielDetail pmdu);

	void doUpdatePcPlanNo(PlnMaterielDetail pmdu);

	List<PlnMaterielDetail> doQueryPC_Sub_InfoWeb(PlnMaterielDetail object);

	
	@Update(" update PLN_MATERIEL_DETAIL set invalid_flg = '1'  where mat_object_no_vt = #{object_no_vt} ")
	void MatToInvalid(@Param("object_no_vt") String object_no_vt);
	
	@Update(" update PLN_MATERIEL_DETAIL set invalid_flg = '0'  where mat_object_no_vt = #{object_no_vt} ")
	void MatToValid(@Param("object_no_vt") String object_no_vt);

	@Delete(" delete from PLN_MATERIEL_DETAIL where mat_object_no_vt = #{obv} and nvl(invalid_flg,0) = 0")
	void delByMat(@Param("obv")String object_no_vt);

	@Update(" update PLN_MATERIEL_DETAIL set is_main_mat = '0'  where object_no_vt = #{object_no_vt} ")
	void updateMainMat(String object_no_vt);

	@Update("update pln_materiel_detail t set t.next_process_code = null, t.STATUS = #{status} where t.object_no_vt = #{object_no_vt} ")
	void doReMoveNextProcess(@Param("object_no_vt")String object_no_vt, @Param("status")String status);
}
