<?xml version="1.0" encoding="UTF-8"?>
	<queryMap desc="合同投入产出物料综合信息">
		<query id="CoreOrderDesignBom.getOrdDesignBom" desc="查询bom主表">
			<![CDATA[
				SELECT T.MATERIAL_NO,
				       T.MATERIAL_DESC,
				       T.BOM,
				       DECODE(T.BOM_TYP,'A','产品','B','产品配接','C','产品备料','D','接箍备料') BOM_TYP,
				       T.MSC_PLINE,
				       T.WHOLE_BACKLOG,
				       T.WHOLE_BACKLOG_DESC,
				       T.MSC,
				       T.MSC_DESC,
				       T.GRADECODE,
				       T.GRADENAME,
				       T.SPEC_CODE_C,
				       T.SPEC_NAME_C,
				       T.SPEC_CODE_R,
				       T.SPEC_NAME_R,
				       T.SPEC_CODE_D,
				       T.SPEC_NAME_D,
				       T.SPEC_CODE_Z,
				       T.SPEC_NAME_Z,
				       T.A_IN_MATERIAL_NO,
				       T.A_IN_MATERIAL_DESC,
				       T.A_OUT_MATERIAL_NO,
				       T.A_OUT_MATERIAL_DESC,
				       T.B_IN_MATERIAL_NO,
				       T.B_IN_MATERIAL_DESC,
				       T.B_OUT_MATERIAL_NO,
				       T.B_OUT_MATERIAL_DESC,
				       T.C_IN_MATERIAL_NO,
				       T.C_IN_MATERIAL_DESC,
				       T.C_OUT_MATERIAL_NO,
				       T.C_OUT_MATERIAL_DESC,
				       T.D_IN_MATERIAL_NO,
				       T.D_IN_MATERIAL_DESC,
				       T.D_OUT_MATERIAL_NO,
				       T.D_OUT_MATERIAL_DESC,
				       T.E_IN_MATERIAL_NO,
				       T.E_IN_MATERIAL_DESC,
				       T.E_OUT_MATERIAL_NO,
				       T.E_OUT_MATERIAL_DESC,
				       T.F_IN_MATERIAL_NO,
				       T.F_IN_MATERIAL_DESC,
				       T.F_OUT_MATERIAL_NO,
				       T.F_OUT_MATERIAL_DESC,
				       T.J_IN_MATERIAL_NO,
				       T.J_IN_MATERIAL_DESC,
				       T.J_OUT_MATERIAL_NO,
				       T.J_OUT_MATERIAL_DESC,
				       (SELECT LISTAGG(T1.IN_MATERIAL_NO, ' 和 ') WITHIN GROUP(ORDER BY IN_MATERIAL_NO)
				          FROM SLM_ORD_DESIGN_BOM_I T1
				         WHERE T1.BOM = T.BOM
				           AND (SUBSTR(T1.IN_MATERIAL_NO, 0, 2) != 'JG' OR
				               INSTR((SELECT LISTAGG(B.CODE_JG, ',') WITHIN GROUP(ORDER BY B.DESGIN_KEY)
				                        FROM SLM_ORD_DESIGN_MSC_JG B
				                       WHERE B.DESGIN_KEY = ?),
				                      T1.IN_MATERIAL_NO) > 0)) I_IN_MATERIAL_NO,
				       (SELECT LISTAGG(T1.IN_MATERIAL_DESC, ' 和 ') WITHIN GROUP(ORDER BY IN_MATERIAL_NO)
				          FROM SLM_ORD_DESIGN_BOM_I T1
				         WHERE T1.BOM = T.BOM
				           AND (SUBSTR(T1.IN_MATERIAL_NO, 0, 2) != 'JG' OR
				               INSTR((SELECT LISTAGG(B.CODE_JG, ',') WITHIN GROUP(ORDER BY B.DESGIN_KEY)
				                        FROM SLM_ORD_DESIGN_MSC_JG B
				                       WHERE B.DESGIN_KEY = ?),
				                      T1.IN_MATERIAL_NO) > 0)) I_IN_MATERIAL_DESC,
				       (SELECT MIN(T1.OUT_MATERIAL_NO)
				          FROM SLM_ORD_DESIGN_BOM_I T1
				         WHERE T1.BOM = T.BOM) I_OUT_MATERIAL_NO,
				       (SELECT MIN(T1.OUT_MATERIAL_DESC)
				          FROM SLM_ORD_DESIGN_BOM_I T1
				         WHERE T1.BOM = T.BOM) I_OUT_MATERIAL_DESC,
				       T.PROCESS_CODE_CS,
				       (SELECT LISTAGG(B.PLINE_NAME, ',') WITHIN GROUP(ORDER BY B.IN_MATERIAL_NO, B.OUT_MATERIAL_NO)
				          FROM SLM_BASE_MATERIAL_D_PL B
				         WHERE B.IN_MATERIAL_NO = T.D_IN_MATERIAL_NO
				           AND B.OUT_MATERIAL_NO = T.D_OUT_MATERIAL_NO
				           AND (B.DISABLE_FL!='1' OR B.DISABLE_FL IS NULL)) D_PLINE,
				       (SELECT LISTAGG(B.PLINE_NAME, ',') WITHIN GROUP(ORDER BY B.IN_MATERIAL_NO, B.OUT_MATERIAL_NO)
				          FROM SLM_BASE_MATERIAL_E_PL B
				         WHERE B.IN_MATERIAL_NO = T.E_IN_MATERIAL_NO
				           AND B.OUT_MATERIAL_NO = T.E_OUT_MATERIAL_NO
				           AND (B.DISABLE_FL!='1' OR B.DISABLE_FL IS NULL)) E_PLINE,
				       (SELECT LISTAGG(B.PLINE_NAME, ',') WITHIN GROUP(ORDER BY B.IN_MATERIAL_NO, B.OUT_MATERIAL_NO)
				          FROM SLM_BASE_MATERIAL_F_PL B
				         WHERE B.IN_MATERIAL_NO = T.F_IN_MATERIAL_NO
				           AND B.OUT_MATERIAL_NO = T.F_OUT_MATERIAL_NO
				           AND (B.DISABLE_FL!='1' OR B.DISABLE_FL IS NULL)) F_PLINE,
				       (SELECT LISTAGG(B.PLINE_NAME, ',') WITHIN GROUP(ORDER BY B.OUT_MATERIAL_NO)
				          FROM SLM_BASE_MATERIAL_I_PL B
				         WHERE B.OUT_MATERIAL_NO = 
				               (SELECT MIN(T1.OUT_MATERIAL_NO)
				                  FROM SLM_ORD_DESIGN_BOM_I T1
				                 WHERE T1.BOM = T.BOM)) I_PLINE,
			       (SELECT B.DIMATER
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) DIMATER,
			       (SELECT B.HEIGHT
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) HEIGHT
				  FROM SLM_ORD_DESIGN_BOM T
				 WHERE T.MSC_PLINE = ?
				   AND T.MSC = ?
				   AND T.MATERIAL_NO = ?
				   AND DECODE(?, '', '1', T.E_IN_MATERIAL_NO) = NVL(?, '1')
				   AND DECODE(?, '', '1', T.BOM) = NVL(?, '1')
			]]>
		</query>
		
		<query id="CoreOrderDesignBom.getOrdMscBom" desc="查询bom主表">
			<![CDATA[
				SELECT T.BOM,
				       T.MSC_PLINE,
				       T.WHOLE_BACKLOG,
				       T.WHOLE_BACKLOG_DESC,
				       T.GRADECODE,
				       T.GRADENAME,
				       T.A_IN_MATERIAL_NO,
				       T.A_IN_MATERIAL_DESC,
				       T.A_OUT_MATERIAL_NO,
				       T.A_OUT_MATERIAL_DESC,
				       T.B_IN_MATERIAL_NO,
				       T.B_IN_MATERIAL_DESC,
				       T.B_OUT_MATERIAL_NO,
				       T.B_OUT_MATERIAL_DESC,
				       T.C_IN_MATERIAL_NO,
				       T.C_IN_MATERIAL_DESC,
				       T.C_OUT_MATERIAL_NO,
				       T.C_OUT_MATERIAL_DESC,
				       T.D_IN_MATERIAL_NO,
				       T.D_IN_MATERIAL_DESC,
				       T.D_OUT_MATERIAL_NO,
				       T.D_OUT_MATERIAL_DESC,
				       T.E_IN_MATERIAL_NO,
				       T.E_IN_MATERIAL_DESC,
				       T.E_OUT_MATERIAL_NO,
				       T.E_OUT_MATERIAL_DESC,
				       (SELECT LISTAGG(B.PLINE_NAME, ',') WITHIN GROUP(ORDER BY B.IN_MATERIAL_NO, B.OUT_MATERIAL_NO)
				          FROM SLM_BASE_MATERIAL_D_PL B
				         WHERE B.IN_MATERIAL_NO = T.D_IN_MATERIAL_NO
				           AND B.OUT_MATERIAL_NO = T.D_OUT_MATERIAL_NO
				           AND (B.DISABLE_FL!='1' OR B.DISABLE_FL IS NULL)) D_PLINE,
			       (SELECT B.DIMATER
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) DIMATER,
			       (SELECT B.HEIGHT
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) HEIGHT
				  FROM SLM_ORD_DESIGN_BOM T
				 WHERE T.MSC_PLINE = ?
				   AND T.MSC = ?
				   AND T.MATERIAL_NO = ?
				   ORDER BY T.BOM
			]]>
		</query>
		
		
		<query id="CoreOrderDesignBom.getDesignBomInf" desc="查询bom主表">
			<![CDATA[
				SELECT T.MATERIAL_NO,
				       T.MATERIAL_DESC,
				       T.BOM,
				       DECODE(T.BOM_TYP,'A','产品','B','产品配接','C','产品备料','D','接箍备料') BOM_TYP,
				       T.MSC_PLINE,
				       T.WHOLE_BACKLOG,
				       T.WHOLE_BACKLOG_DESC,
				       T.MSC,
				       T.MSC_DESC,
				       T.GRADECODE,
				       T.GRADENAME,
				       T.SPEC_CODE_C,
				       T.SPEC_NAME_C,
				       T.SPEC_CODE_R,
				       T.SPEC_NAME_R,
				       T.SPEC_CODE_D,
				       T.SPEC_NAME_D,
				       T.SPEC_CODE_Z,
				       T.SPEC_NAME_Z,
				       T.A_IN_MATERIAL_NO,
				       T.A_IN_MATERIAL_DESC,
				       T.A_OUT_MATERIAL_NO,
				       T.A_OUT_MATERIAL_DESC,
				       T.B_IN_MATERIAL_NO,
				       T.B_IN_MATERIAL_DESC,
				       T.B_OUT_MATERIAL_NO,
				       T.B_OUT_MATERIAL_DESC,
				       T.C_IN_MATERIAL_NO,
				       T.C_IN_MATERIAL_DESC,
				       T.C_OUT_MATERIAL_NO,
				       T.C_OUT_MATERIAL_DESC,
				       T.D_IN_MATERIAL_NO,
				       T.D_IN_MATERIAL_DESC,
				       T.D_OUT_MATERIAL_NO,
				       T.D_OUT_MATERIAL_DESC,
				       T.E_IN_MATERIAL_NO,
				       T.E_IN_MATERIAL_DESC,
				       T.E_OUT_MATERIAL_NO,
				       T.E_OUT_MATERIAL_DESC,
				       T.F_IN_MATERIAL_NO,
				       T.F_IN_MATERIAL_DESC,
				       T.F_OUT_MATERIAL_NO,
				       T.F_OUT_MATERIAL_DESC,
				       T.J_IN_MATERIAL_NO,
				       T.J_IN_MATERIAL_DESC,
				       T.J_OUT_MATERIAL_NO,
				       T.J_OUT_MATERIAL_DESC,
				       (SELECT LISTAGG(B.PLINE_NAME, ',') WITHIN GROUP(ORDER BY B.IN_MATERIAL_NO, B.OUT_MATERIAL_NO)
				          FROM SLM_BASE_MATERIAL_D_PL B
				         WHERE B.IN_MATERIAL_NO = T.D_IN_MATERIAL_NO
				           AND B.OUT_MATERIAL_NO = T.D_OUT_MATERIAL_NO
				           AND (B.DISABLE_FL!='1' OR B.DISABLE_FL IS NULL)) D_PLINE,
			       (SELECT B.DIMATER
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) DIMATER,
			       (SELECT B.HEIGHT
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) HEIGHT
				  FROM SLM_ORD_DESIGN_BOM T
				 WHERE T.BOM = ?
			]]>
		</query>
	
	<query id="CoreOrderDesignBom.getCustomRpline" desc="查询最终用户认定产线">
		<![CDATA[
			SELECT R.PLINE_CODE, R.PLINE_NAME
			  FROM COM_BASE_CUSTOM_R_PLINE R
			 WHERE R.VALIDFLAG = '1'
			   AND R.CUSTOMER_NO = ?
			   AND R.PRODUCCODE = ?
		]]>
	</query>
	
	<query id="CoreOrderDesignBom.getBomCustomRDpl" desc="轧管投入产出-产线能力经过最终用户认定">
		<![CDATA[
			SELECT R.PLINE_CODE, R.PLINE_NAME
			  FROM COM_BASE_CUSTOM_R_PLINE R
			 WHERE R.VALIDFLAG = '1'
			   AND R.CUSTOMER_NO = ?
			   AND R.PRODUCCODE = ?
			INTERSECT
			SELECT PLINE_CODE, PLINE_NAME
			  FROM SLM_BASE_MATERIAL_D_PL T
			 WHERE T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND (T.DISABLE_FL != '0' OR T.DISABLE_FL IS NULL)
			MINUS
			SELECT B.PLINE_CODE, B.PLINE_NAME
			  FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL B
			 WHERE B.PROCESS_CODE = 'D'
			   AND B.DESGIN_KEY = ?
			   AND B.MSC_PLINE = ?
			   AND B.VALIDFLAG = '0'
		]]>
	</query>
	
	<query id="CoreOrderDesignBom.getBomMaterialDpl" desc="轧管投入产出-产线能力">
		<![CDATA[
			SELECT PLINE_CODE, PLINE_NAME
			  FROM SLM_BASE_MATERIAL_D_PL T
			 WHERE T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND (T.DISABLE_FL != '0' OR T.DISABLE_FL IS NULL)
			MINUS
			SELECT B.PLINE_CODE, B.PLINE_NAME
			  FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL B
			 WHERE B.PROCESS_CODE = 'D'
			   AND B.DESGIN_KEY = ?
			   AND B.MSC_PLINE = ?
			   AND B.VALIDFLAG = '0'
		]]>
	</query>
		
	<query id="CoreOrderDesignBom.setBomChanged" desc="更新销售合同信息">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.INDEX_SEQ          = ?,
			       T.BOM                = ?,
			       T.GROUP_JGX          = ?,
			       T.GROUP_RCL          = ?,
			       T.BJ_TYPE            = ?,
			       T.ENDGXNAME          = ?,
			       T.PROCESS_SEQ        = ?,
			       T.PRODUCE_SORT       = ?,
			       T.E_IN_MATERIAL_NO   = ?,
			       T.E_IN_MATERIAL_DESC = ?,
			       T.DIMATER_YLG        = ?,
			       T.HEIGHT_YLG         = ?,
			       T.HEIGHT_NK_MIN      = ?,
			       T.HEIGHT_NK_MAX      = ?,
			       T.AIMWALLTHICK_ZG    = ?,
			       T.GROUP_ROLL_ALL     = ?,
			       T.GROUP_ROLL         = ?,
			       T.GRADECODE_ALL      = ?,
			       T.GRADECODE          = ?,
			       T.STUFF_PROPERTY     = ?,
			       T.MONITORDEMAND      = ?,
			       T.D_IS_OK            = ?,
			       T.E_IS_OK            = ?,
			       T.F_IS_OK            = ?,
			       T.G_IS_OK            = ?,
			       T.GRADECODE_IS_OK    = '0'
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
		
	<query id="CoreOrderDesignBom.setSaleOrderBom" desc="更新销售合同BOM信息">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.BOM                = ?,
			       T.E_IN_MATERIAL_NO   = ?,
			       T.E_IN_MATERIAL_DESC = ?,
			       T.DIMATER_YLG        = ?,
			       T.HEIGHT_YLG         = ?,
			       T.HEIGHT_NK_MIN      = ?,
			       T.HEIGHT_NK_MAX      = ?,
			       T.AIMWALLTHICK_ZG    = ?,
			       T.GROUP_ROLL_ALL     = ?,
			       T.GROUP_ROLL         = ?,
			       T.GRADECODE_ALL      = ?,
			       T.GRADECODE          = ?,
			       T.STUFF_PROPERTY     = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreOrderDesignBom.setModifySale" desc="修改销售合同状态">
		<![CDATA[
			UPDATE PLN_SALEORDER T SET T.PORDERSTATUS = ? WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreOrderDesignBom.setLineStatus" desc="修改销售交货行表状态">
		<![CDATA[
			UPDATE SLM_ORDER_LINE_DELIVERY T SET T.DELIVERY_STATUS = ? WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreOrderDesignBom.getBaseSpec" desc="验证规格是否存在">
		<![CDATA[
			SELECT T.SPEC_CODE, T.SPEC_NAME, T.DIMATER, T.HEIGHT, T.WEIGHT, T.MSC_STYLE
			  FROM COM_BASE_SPEC T
			 WHERE T.DIMATER = TO_NUMBER(?)
			   AND T.HEIGHT = TO_NUMBER(?)
			   AND T.VALIDFLAG = '1'
			   AND T.MSC_STYLE = 'A'
		]]>
	</query>
	
	</queryMap>
