<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="现货合同弹窗">
<query id="CoreMatInfo.queryMatInfo" desc="查询材料信息">
	<![CDATA[
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.PRODUCT_FLAG) PRODUCT_FLAG,
       (SELECT T3.BASENAME
          FROM COM_BASE_INFO T3
         WHERE T3.BASECODE = T1.MAT_STATUS) MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       NVL(T1.STEELCODE,T1.GRADECODE) STEELCODE,
       NVl(T1.STEELNAME,T1.GRADENAME) STEELNAME,
       NVL(T1.STD_CODE,'/') STD_CODE ,
       NVL(T1.STD_NAME,'/') STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS LKACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.MNG_LOCK_FLAG，
       T1.SUPPLY_UNIT_CODE,
       T1.SUPPLY_UNIT
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
  WHERE T1.MAT_NO = T2.MAT_NO
   AND  T1.PRODUCT_FLAG = '801402'
   AND  T1.MAT_STATUS IN ('80150202','80150203','80150204','80150205')
   AND  T1.LOCK_FLAG = '0'

	]]>
	</query>
	
	<query id="CoreMatInfo.doAddLine" desc="合同行新增">
		<![CDATA[
			INSERT INTO SLM_ORDER_LINE
  (ORD_PK,
   ORD_LN_PK,
   ORDER_SEQ,
   PSC,
   PSC_DESC,
   PRODUCCODE,
   PRODUCNAME,
   PRD_CLS,
   STD_STYLE,
   STD_STYLE_DESC,
   STD_CODE,
   STD_NAME,
   STEELCODE,
   STEELNAME,
   ORDER_SPEC_CODE,
   ORDER_SPEC_DESC,
   SPEC_CODE,
   SPEC_NAME,
   DIMATER,
   HEIGHT,
   MODEL_CODE,
   MODEL_DESC,
   LEN_DESC,
   LEN_MIN,
   LEN_MAX,
   ORDER_UNIT,
   ORDER_QTY,
   PRDCT_WGT,
   DELVRY_RANGE_TPE,
   DELVRY_RANGE_MIN,
   DELVRY_RANGE_MAX,
   FINAL_USER,
   FINAL_USER_DESC,
   ORDER_LN_STATUS,
   CREATE_NAME,
   CREATE_TIME,
   ORDER_COUNT)
   VALUES
   ('#ORD_PK#','#ORD_LN_PK#',
   (SELECT DECODE(MAX(ORDER_SEQ),
                  '',
                  '001',
                  LPAD(MAX(ORDER_SEQ) + 1, 3, '0'))
      FROM SLM_ORDER_LINE
     WHERE ORD_PK = '#ORD_PK#'
       AND VALIDFLAG = '1'),
   '#PSC#','#PSC_DESC#','#PRODUCCODE#','#PRODUCNAME#',(SELECT A.PRODUC_STYLE FROM COM_BASE_PRODUCT A WHERE A.PRODUCCODE = '#PRODUCCODE#'),
   '#STD_STYLE#','#STD_STYLE_DESC#',NVL('#STD_CODE#','N/A'),'#STD_NAME#','#STEELCODE#',
   '#STEELNAME#','#ORDER_SPEC_CODE#','#ORDER_SPEC_DESC#','#SPEC_CODE#','#SPEC_NAME#','#DIMATER#','#HEIGHT#','#MODEL_CODE#',
   '#MODEL_DESC#','#LEN_DESC#','#LEN_MIN#','#LEN_MAX#','#ORDER_UNIT#','#ORDER_QTY#','#PRDCT_WGT#','#DELVRY_RANGE_TPE#',
   '#DELVRY_RANGE_MIN#','#DELVRY_RANGE_MAX#','#FINAL_USER#','#FINAL_USER_DESC#','#ORDER_LN_STATUS#','#CREATE_NAME#',SYSDATE,'#ORDER_COUNT#'
   )
				
		]]>
	</query>
	
	<query id="CoreMatInfo.GetOrderLinePkWithAdd" desc="合同行新增时LnPk">
		<![CDATA[
    SELECT ? || LPAD(TO_NUMBER(NVL(MAX(SUBSTR(ORD_LN_PK, 33, 3)), '0')) + 1,
                   3,
                   '0')
  
    FROM SLM_ORDER_LINE
    WHERE ORD_PK = ?

		]]>
	</query>
	
	<query id="CoreMatInfo.ISExistsMat" desc="是否存在指定炉批组号的材料库存">
		<![CDATA[
   		  SELECT 1
       FROM (SELECT COUNT(*) NUM
           FROM MAT_ZC_M T , YDM_ZC_BUTTRESS T2
           WHERE T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
           AND T.BATCH_GROUD_NO = ?
           AND T.MAT_NO = T2.MAT_NO
           AND T.PRODUCT_FLAG = '801402'
           AND T.MAT_STATUS IN ('80150202','80150203','80150204','80150205')
           AND T.MNG_LOCK_FLAG <> '1'
           AND T.LOCK_FLAG <> '1'
           )
       WHERE NUM >= ?

		]]>
	</query>
	
	<query id="CoreMatInfo.Liku" desc="利库修改材料状态信息">
	<![CDATA[
	DECLARE
  V_RESUME_SEQ MAT_ZC_TRACK.RESUME_SEQ%TYPE := NULL; --履历单号
  V_ELIM_NUM PROCESS_ORDER_M.ELIM_NUM%TYPE :=NULL;
  V_ELIM_WGT PROCESS_ORDER_M.ELIM_WGT%TYPE := NULL;
  V_ELIM_LEN PROCESS_ORDER_M.ELIM_LEN%TYPE := NULL;
  V_OCOUNT   NUMBER := 1;
  V_TIME     MAT_ZC_TRACK.CREATE_TIME%TYPE := SYSDATE;
BEGIN
  --生成履历序号
  SELECT
         LPAD(NVL(MAX(SUBSTR(T.RESUME_SEQ, 15)), 0) + 1, 10, 0) RESUME_SEQ
    INTO V_OCOUNT
    FROM MAT_ZC_TRACK T
   WHERE T.RESUME_SEQ LIKE TO_CHAR(SYSDATE, 'YYYYMMDD')||'________________';
     FOR MYROW IN (SELECT T1.*,
                       S.STORAGE_NO
                  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS S
                 WHERE T1.MAT_NO = S.MAT_NO
				AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
				AND T1.BATCH_NO = '#BATCH_NO#'
				AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
				AND T1.PRODUCT_FLAG = '801402'
				AND T1.MAT_STATUS IN ('80150202','80150203','80150204','80150205')
				AND T1.MAT_NO IN (SELECT T2.MAT_NO FROM  YDM_ZC_BUTTRESS T2  WHERE T2.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#' )
				AND DECODE('#ACT_LEN_MIN#','',1,T1.ACT_LEN_MIN)  = DECODE('#ACT_LEN_MIN#','',1,'#ACT_LEN_MIN#')
				AND DECODE('#ACT_LEN_MAX#','',1,T1.ACT_LEN_MAX) = DECODE('#ACT_LEN_MAX#','',1,'#ACT_LEN_MAX#')
				AND T1.MNG_LOCK_FLAG <> '1'
				AND T1.LOCK_FLAG <> '1'
				AND T1.BELONG_CODE = '#OLD_BELONG_CODE#'
				AND ROWNUM <= #NUM#) LOOP
    V_RESUME_SEQ := TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') || LPAD(V_OCOUNT, 10, 0);
	 UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '#ORDER_NO#',
       T1.ORDER_SEQ         = (SELECT ORDER_SEQ FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK  = '#ORD_LN_PK#' ),
       T1.PRODUCT_FLAG      = '801403',
       T1.MAT_STATUS        = '80150301',
       T1.ORD_PK            = '#ORD_PK#',
       T1.ORD_LN_PK         = '#ORD_LN_PK#',
       T1.BELONG_CODE       = '#BELONG_CODE#',
       T1.BELONG_NAME       = '#BELONG_NAME#',
       T1.LOCK_LIKU         = '0'
	WHERE
	T1.MAT_NO = MYROW.MAT_NO;
	UPDATE MAT_ZC_M_XS T1
   SET T1.ORDER_NO          = '#ORDER_NO#',
       T1.ORDER_SEQ         = (SELECT ORDER_SEQ FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK  = '#ORD_LN_PK#' ),
       T1.PRODUCT_FLAG      = '801403',
       T1.MAT_STATUS        = '80150301',
       T1.ORD_PK            = '#ORD_PK#',
       T1.ORD_LN_PK         = '#ORD_LN_PK#',
       T1.BELONG_CODE       = '#BELONG_CODE#',
       T1.BELONG_NAME       = '#BELONG_NAME#',
       T1.LOCK_LIKU         = '0'
	WHERE
	T1.MAT_NO = MYROW.MAT_NO;
	INSERT INTO MAT_ZC_TRACK(
        RESUME_SEQ,
        EVENT_ID,
        EVENT_DESC,
        FORM_NAME,
        CALL_FUNC_CODING,
        KEYVALUE_1,
        KEYVALUE_1_DESC,
        KEYVALUE_2,
        KEYVALUE_2_DESC2,
        KEYVALUE_3,
        KEYVALUE_3_DESC3,
        KEYVALUE_4,
        KEYVALUE_4_DESC4,
        KEYVALUE_5,
        KEYVALUE_5_DESC5,
        KEYVALUE_6,
        KEYVALUE_6_DESC6,
        KEYVALUE_7,
        KEYVALUE_7_DESC7,
        MAT_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        ACT_THEORY_WEIGHT,
        PRO_ORDER_NO,
        PRO_ORDER_ID,
        PRO_ORDER_NO1,
        PRO_ORDER_ID1,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        OLD_ORD_PK,
        OLD_ORD_LN_PK,
        OLD_ORD_LN_DLY_PK,
        OLD_ORDER_NO,
        OLD_ORDER_SEQ,
        OLD_ORDER_SEQ_NO,
        BELONG_CODE,
        BELONG_NAME,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        IN_MOLD,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT)
 VALUES(
        V_RESUME_SEQ,
        '900103',
        '现货利库',
        'Core.StlMes.Client.SaleOrder.frmOrderManager',
        'doForceLiku',
        'ArrayList<MatZcMEntity> paramList',
        '物料主表关键字(group)实体类集合',
        '',
        '',
        '',
        '',
        'String userName',
        '操作人',
        'String deptId',
        '操作人部门ID',
        '',
        '',
        '',
        '',
         MYROW.MAT_NO,
        MYROW.PRODUCT_FLAG,
        MYROW.MAT_STATUS,
        MYROW.LOT_NO,
        MYROW.STOVE_NO,
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.MATERIAL_NO,
        MYROW.MATERIAL_NAME,
        MYROW.PRODUCCODE,
        MYROW.PRODUCNAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.STD_CODE,
        MYROW.STD_NAME,
        MYROW.STD_STYLE,
        MYROW.STD_STYLE_DESC,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.MODEL_CODE,
        MYROW.MODEL_DESC,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        MYROW.ACT_THEORY_WEIGHT,
        MYROW.PRO_ORDER_NO,
        MYROW.PRO_ORDER_ID,
        MYROW.PRO_ORDER_NO1,
        MYROW.PRO_ORDER_ID1,
        '#ORD_PK#',
        '#ORD_LN_PK#',
        MYROW.ORD_LN_DLY_PK,
        '#ORDER_NO#',
        (SELECT ORDER_SEQ FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK  = '#ORD_LN_PK#' ),
        MYROW.ORDER_SEQ_NO,
        MYROW.OLD_ORD_PK,
        MYROW.OLD_ORD_LN_PK,
        MYROW.OLD_ORD_LN_DLY_PK,
        MYROW.OLD_ORDER_NO,
        MYROW.OLD_ORDER_SEQ,
        MYROW.OLD_ORDER_SEQ_NO,
        MYROW.BELONG_CODE,
        MYROW.BELONG_NAME,
        '现货合同，系统写入',
        'SYSTEM',
        SYSDATE,
        MYROW.IN_MOLD,
        MYROW.SUPPLY_UNIT_CODE,
        MYROW.SUPPLY_UNIT);
            V_OCOUNT := V_OCOUNT + 1;
  END LOOP;
END;
	]]>
    </query>
    
    <query id="CoreMatInfo.updateSpotOrderLine" desc="利库修改材料状态信息">
	<![CDATA[
	 UPDATE SLM_ORDER_LINE
     SET 
       DELVRY_RANGE_MIN = TO_NUMBER(?),
       DELVRY_RANGE_MAX = TO_NUMBER(?),
       DELVRY_RANGE_TPE = ?,
       FINAL_USER       = ?,
       FINAL_USER_DESC  = ?,
       OUTBOUND_CALCULATE = ?
       --ORDER_QTY        = ?,
       --PRDCT_WGT        = ?
     WHERE ORD_LN_PK = ?
	   
	]]>
    </query>
    
    <query id="CoreMatInfo.UpdateOrderLineDesc" desc="是否存在指定炉批组号的材料库存">
	 <![CDATA[
   		 UPDATE  SLM_ORDER_LINE T
   		 SET T.DELVRY_DESC  = ?,
   		     T.DELVRY_EDATE = (SELECT MAX(DELVRY_EDATE) FROM  SLM_ORDER_LINE_DELIVERY A 
   		     WHERE A.ORD_LN_PK = ? AND A.VALIDFLAG = '1')
   		 WHERE T.ORD_LN_PK = ?
   		 
		]]>
	 </query>
	 
	 <query id="CoreMatInfo.UpdateMatWithLnDlyPk" desc="是否存在指定炉批组号的材料库存">
	 <![CDATA[
   		 UPDATE MAT_ZC_M T
   		 SET T.ORD_LN_DLY_PK = (SELECT A.ORD_LN_DLY_PK FROM  SLM_ORDER_LINE_DELIVERY  A  WHERE A.ORD_LN_PK = ?),
   		     T.ORDER_SEQ_NO  = (SELECT A.DELIVERY_NO FROM  SLM_ORDER_LINE_DELIVERY  A  WHERE A.ORD_LN_PK = ?)
   		 WHERE ORD_LN_PK = ?
   		 
		]]>
	 </query>
	 
	  <query id="CoreMatInfo.UpdateOrderLineQty" desc="是否存在指定炉批组号的材料库存">
	 <![CDATA[
   		 UPDATE SLM_ORDER_LINE T 
   		 SET T.ORDER_QTY = (SELECT SUM(NVL(T.ACT_WEIGHT, 0)) FROM MAT_ZC_M T WHERE T.ORD_LN_PK = ?),
   		     T.PRDCT_WGT = (SELECT SUM(NVL(T.ACT_WEIGHT, 0)) FROM MAT_ZC_M T WHERE T.ORD_LN_PK = ?)
   		 WHERE T.ORD_LN_PK = ?
   		 AND T.ORDER_UNIT='吨'
   		 
		]]>
	 </query>
	 
	 <query id="CoreMatInfo.UpdateOrderLineOnlyQty" desc="是否存在指定炉批组号的材料库存">
	 <![CDATA[
   		 UPDATE SLM_ORDER_LINE T 
   		 SET 
   		     T.PRDCT_WGT = (SELECT SUM(NVL(T.ACT_WEIGHT, 0)) FROM MAT_ZC_M T WHERE T.ORD_LN_PK = ?)
   		 WHERE T.ORD_LN_PK = ?
   		 
		]]>
	 </query>
    
     <query id="CoreMatInfo.updateSpotLineFinaUser" desc="利库修改材料状态信息">
	<![CDATA[
	 UPDATE SLM_ORDER_LINE T
     SET T.FINAL_USER       = ?,
         T.FINAL_USER_DESC  = ?
     
     WHERE T.ORD_PK = ? 
     AND (TRIM(T.FINAL_USER) IS NULL OR T.FINAL_USER = 'N/A')
	   
	]]>
    </query>
    <query id = "CoreMatInfo.InsertInlistOut" desc = "现货合同所属权不一致的写入出记录">
		<![CDATA[
		DECLARE
		V_INSTOCK_SEQ  YDM_ZC_INLIST.INSTOCK_SQE%TYPE := NULL;
		V_INCOUNT      NUMBER := 1;
		V_OUTSTOCK_SQE YDM_ZC_OUTLIST.OUTSTOCK_SQE%TYPE := NULL;
		V_OUTCOUNT     NUMBER := 1;
		BEGIN
		SELECT NVL(MAX(SUBSTR(T.INSTOCK_SQE, LENGTH(T.INSTOCK_SQE) - 4)), 0) + 1
		INTO V_INCOUNT
		FROM YDM_ZC_INLIST T
		WHERE T.INSTOCK_DOC = '#INSTOCK_DOC#';

		SELECT NVL(MAX(SUBSTR(T.OUTSTOCK_SQE, LENGTH(T.OUTSTOCK_SQE) - 4)), 0) + 1
		INTO V_OUTCOUNT
		FROM YDM_ZC_OUTLIST T
		WHERE T.OUTSTOCK_DOC = '#OUTSTOCK_DOC#';
		FOR MYROW IN (SELECT * FROM (SELECT T.*,
		S.STORAGE_NO,
		S.LOCATION_NO,
		S.LARY_NO,
		S.LOC_NO,
		S.STORAGE_ATTR,
		S.STORAGE_ATTR_NAME,
		S.STORAGE_TYPE_NO,
		S.STORAGE_TYPE_NAME
		FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
		WHERE T.MAT_NO = S.MAT_NO
		AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
		AND T.BATCH_NO = '#BATCH_NO#'
		AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
		AND T.BELONG_CODE = '#BELONG_CODE#'
		AND T.PRODUCT_FLAG = '801402'
		ORDER BY T.MAT_NO ASC)
		WHERE ROWNUM <= #ACT_COUNT#
		) LOOP
		V_INSTOCK_SEQ  := '#INSTOCK_DOC#' || LPAD(V_INCOUNT, 4, 0);
		V_OUTSTOCK_SQE := '#OUTSTOCK_DOC#' || LPAD(V_OUTCOUNT, 4, 0);
		INSERT INTO YDM_ZC_INLIST
		(INSTOCK_SQE,
		INSTOCK_DOC,
		INSTOCK_TYPE_CODE,
		INSTOCK_TYPE_NAME,
		MAT_NO,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		PRODUCCODE,
		PRODUCNAME,
		STD_CODE,
		STD_NAME,
		STEELCODE,
		STEELNAME,
		STD_STYLE,
		STD_STYLE_DESC,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		BELONG_CODE,
		BELONG_NAME,
		STORAGE_NO,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		PRODUCT_FLAG,
		MAT_STATUS,
		INSTOCK_TIME,
		ACT_LEN,
		JUDGE_STD_NAME,
		PLINE_CODE,
		PLINE_NAME,
		GRADECODE,
		GRADENAME,
		BAL_YEAR_MONTH,
		IN_TIME_F,
		PIPMEMO,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		SOURE_CODE,
		SOURE_NAME,
		MATERIAL_NO,
		MATERIAL_NAME,
		IN_MOLD,
		PACK_NO,
		PRO_ORDER_NO)
		VALUES
		(V_INSTOCK_SEQ,
		'#INSTOCK_DOC#',
		'800712',
		'转所属权入库',
		MYROW.MAT_NO,
		MYROW.LOT_NO,
		MYROW.STOVE_NO,
		MYROW.JUDGE_STOVE_NO,
		MYROW.BATCH_NO,
		MYROW.BATCH_GROUD_NO,
		MYROW.PRODUCCODE,
		MYROW.PRODUCNAME,
		MYROW.STD_CODE,
		MYROW.STD_NAME,
		MYROW.STEELCODE,
		MYROW.STEELNAME,
		MYROW.STD_STYLE,
		MYROW.STD_STYLE_DESC,
		MYROW.SPEC_CODE,
		MYROW.SPEC_NAME,
		MYROW.MODEL_CODE,
		MYROW.MODEL_DESC,
		MYROW.ACT_DIMATER,
		MYROW.ACT_HEIGHT,
		MYROW.ACT_LEN_MIN,
		MYROW.ACT_LEN_MAX,
		MYROW.ACT_COUNT,
		MYROW.ACT_WEIGHT,
		'#NEWBELONG_CODE#',
		'#NEWBELONG_NAME#',
		MYROW.STORAGE_NO,
		MYROW.MEMO,
		'#CREATE_NAME#',
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		MYROW.PRODUCT_FLAG,
		MYROW.MAT_STATUS,
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		MYROW.ACT_LEN,
		MYROW.JUDGE_STD_NAME,
		MYROW.PLINE_CODE,
		MYROW.PLINE_NAME,
		MYROW.GRADECODE,
		MYROW.GRADENAME,
		'#BAL_YEAR_MONTH#',
		MYROW.INSTOCK_TIME,
		MYROW.PIPMEMO,
		'801302',
		'产线',
		'#BELONG_CODE#',
		'#BELONG_NAME#',
		MYROW.MATERIAL_NO,
		MYROW.MATERIAL_NAME,
		MYROW.IN_MOLD,
		MYROW.PACK_NO,
		MYROW.PRO_ORDER_NO);
		INSERT INTO YDM_ZC_INLIST_XS
		(INSTOCK_SQE,
		INSTOCK_DOC,
		INSTOCK_TYPE_CODE,
		INSTOCK_TYPE_NAME,
		MAT_NO,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		PRODUCCODE,
		PRODUCNAME,
		STD_CODE,
		STD_NAME,
		STEELCODE,
		STEELNAME,
		STD_STYLE,
		STD_STYLE_DESC,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		BELONG_CODE,
		BELONG_NAME,
		STORAGE_NO,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		PRODUCT_FLAG,
		MAT_STATUS,
		INSTOCK_TIME,
		ACT_LEN,
		JUDGE_STD_NAME,
		PLINE_CODE,
		PLINE_NAME,
		GRADECODE,
		GRADENAME,
		BAL_YEAR_MONTH,
		IN_TIME_F,
		PIPMEMO,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		SOURE_CODE,
		SOURE_NAME,
		MATERIAL_NO,
		MATERIAL_NAME,
		IN_MOLD,
		PACK_NO,
		PRO_ORDER_NO)
		VALUES
		(V_INSTOCK_SEQ,
		'#INSTOCK_DOC#',
		'800712',
		'转所属权入库',
		MYROW.MAT_NO,
		MYROW.LOT_NO,
		MYROW.STOVE_NO,
		MYROW.JUDGE_STOVE_NO,
		MYROW.BATCH_NO,
		MYROW.BATCH_GROUD_NO,
		MYROW.PRODUCCODE,
		MYROW.PRODUCNAME,
		MYROW.STD_CODE,
		MYROW.STD_NAME,
		MYROW.STEELCODE,
		MYROW.STEELNAME,
		MYROW.STD_STYLE,
		MYROW.STD_STYLE_DESC,
		MYROW.SPEC_CODE,
		MYROW.SPEC_NAME,
		MYROW.MODEL_CODE,
		MYROW.MODEL_DESC,
		MYROW.ACT_DIMATER,
		MYROW.ACT_HEIGHT,
		MYROW.ACT_LEN_MIN,
		MYROW.ACT_LEN_MAX,
		MYROW.ACT_COUNT,
		MYROW.ACT_WEIGHT,
		'#NEWBELONG_CODE#',
		'#NEWBELONG_NAME#',
		MYROW.STORAGE_NO,
		MYROW.MEMO,
		'#CREATE_NAME#',
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		MYROW.PRODUCT_FLAG,
		MYROW.MAT_STATUS,
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		MYROW.ACT_LEN,
		MYROW.JUDGE_STD_NAME,
		MYROW.PLINE_CODE,
		MYROW.PLINE_NAME,
		MYROW.GRADECODE,
		MYROW.GRADENAME,
		'#BAL_YEAR_MONTH#',
		MYROW.INSTOCK_TIME,
		MYROW.PIPMEMO,
		'801302',
		'产线',
		'#BELONG_CODE#',
		'#BELONG_NAME#',
		MYROW.MATERIAL_NO,
		MYROW.MATERIAL_NAME,
		MYROW.IN_MOLD,
		MYROW.PACK_NO,
		MYROW.PRO_ORDER_NO);
		INSERT INTO YDM_ZC_OUTLIST
		(OUTSTOCK_SQE,
		OUTSTOCK_DOC,
		OUTSTOCK_TYPE_CODE,
		OUTSTOCK_TYPE_NAME,
		MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		MATERIAL_NO,
		MATERIAL_NAME,
		PRODUCCODE,
		PRODUCNAME,
		STD_CODE,
		STD_NAME,
		GRADECODE,
		GRADENAME,
		STEELCODE,
		STEELNAME,
		STD_STYLE,
		STD_STYLE_DESC,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		PRO_ORDER_NO,
		PLINE_CODE,
		PLINE_NAME,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		BELONG_CODE,
		BELONG_NAME,
		STORAGE_NO,
		LOCATION_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		OUTSTOCK_TIME,
		CREATE_NAME,
		CREATE_TIME,
		PRODUCT_FLAG,
		MAT_STATUS,
		JUDGE_STD_NAME,
		JUDGE_STD_CODE,
		BAL_YEAR_MONTH,
		FINISHPRO_MOLD,
		IN_MOLD)
		VALUES
		(V_OUTSTOCK_SQE,
		'#OUTSTOCK_DOC#',
		'800812',
		'转所属权出库',
		MYROW.MAT_NO,
		MYROW.JUDGE_STOVE_NO,
		MYROW.BATCH_NO,
		MYROW.BATCH_GROUD_NO,
		MYROW.MATERIAL_NO,
		MYROW.MATERIAL_NAME,
		MYROW.PRODUCCODE,
		MYROW.PRODUCNAME,
		MYROW.STD_CODE,
		MYROW.STD_NAME,
		MYROW.GRADECODE,
		MYROW.GRADENAME,
		MYROW.STEELCODE,
		MYROW.STEELNAME,
		MYROW.STD_STYLE,
		MYROW.STD_STYLE_DESC,
		MYROW.SPEC_CODE,
		MYROW.SPEC_NAME,
		MYROW.MODEL_CODE,
		MYROW.MODEL_DESC,
		MYROW.PRO_ORDER_NO,
		MYROW.PLINE_CODE,
		MYROW.PLINE_NAME,
		MYROW.ACT_DIMATER,
		MYROW.HEIGHT,
		MYROW.ACT_LEN,
		MYROW.ACT_LEN_MIN,
		MYROW.ACT_LEN_MAX,
		MYROW.ACT_COUNT,
		MYROW.ACT_WEIGHT,
		MYROW.ACT_THEORY_WEIGHT,
		MYROW.BELONG_CODE,
		MYROW.BELONG_NAME,
		MYROW.STORAGE_NO,
		MYROW.LOCATION_NO,
		MYROW.STORAGE_ATTR,
		MYROW.STORAGE_ATTR_NAME,
		MYROW.STORAGE_TYPE_NO,
		MYROW.STORAGE_TYPE_NAME,
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		'#CREATE_NAME#',
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		MYROW.PRODUCT_FLAG,
		MYROW.MAT_STATUS,
		MYROW.JUDGE_STD_NAME,
		MYROW.JUDGE_STD_CODE,
		'#BAL_YEAR_MONTH#',
		MYROW.FINISHPRO_MOLD,
		MYROW.IN_MOLD);
		INSERT INTO YDM_ZC_OUTLIST_XS
		(OUTSTOCK_SQE,
		OUTSTOCK_DOC,
		OUTSTOCK_TYPE_CODE,
		OUTSTOCK_TYPE_NAME,
		MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		MATERIAL_NO,
		MATERIAL_NAME,
		PRODUCCODE,
		PRODUCNAME,
		STD_CODE,
		STD_NAME,
		GRADECODE,
		GRADENAME,
		STEELCODE,
		STEELNAME,
		STD_STYLE,
		STD_STYLE_DESC,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		PRO_ORDER_NO,
		PLINE_CODE,
		PLINE_NAME,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		BELONG_CODE,
		BELONG_NAME,
		STORAGE_NO,
		LOCATION_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		OUTSTOCK_TIME,
		CREATE_NAME,
		CREATE_TIME,
		PRODUCT_FLAG,
		MAT_STATUS,
		JUDGE_STD_NAME,
		JUDGE_STD_CODE,
		BAL_YEAR_MONTH,
		FINISHPRO_MOLD,
		IN_MOLD)
		VALUES
		(V_OUTSTOCK_SQE,
		'#OUTSTOCK_DOC#',
		'800812',
		'转所属权出库',
		MYROW.MAT_NO,
		MYROW.JUDGE_STOVE_NO,
		MYROW.BATCH_NO,
		MYROW.BATCH_GROUD_NO,
		MYROW.MATERIAL_NO,
		MYROW.MATERIAL_NAME,
		MYROW.PRODUCCODE,
		MYROW.PRODUCNAME,
		MYROW.STD_CODE,
		MYROW.STD_NAME,
		MYROW.GRADECODE,
		MYROW.GRADENAME,
		MYROW.STEELCODE,
		MYROW.STEELNAME,
		MYROW.STD_STYLE,
		MYROW.STD_STYLE_DESC,
		MYROW.SPEC_CODE,
		MYROW.SPEC_NAME,
		MYROW.MODEL_CODE,
		MYROW.MODEL_DESC,
		MYROW.PRO_ORDER_NO,
		MYROW.PLINE_CODE,
		MYROW.PLINE_NAME,
		MYROW.ACT_DIMATER,
		MYROW.HEIGHT,
		MYROW.ACT_LEN,
		MYROW.ACT_LEN_MIN,
		MYROW.ACT_LEN_MAX,
		MYROW.ACT_COUNT,
		MYROW.ACT_WEIGHT,
		MYROW.ACT_THEORY_WEIGHT,
		MYROW.BELONG_CODE,
		MYROW.BELONG_NAME,
		MYROW.STORAGE_NO,
		MYROW.LOCATION_NO,
		MYROW.STORAGE_ATTR,
		MYROW.STORAGE_ATTR_NAME,
		MYROW.STORAGE_TYPE_NO,
		MYROW.STORAGE_TYPE_NAME,
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		'#CREATE_NAME#',
		TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
		MYROW.PRODUCT_FLAG,
		MYROW.MAT_STATUS,
		MYROW.JUDGE_STD_NAME,
		MYROW.JUDGE_STD_CODE,
		'#BAL_YEAR_MONTH#',
		MYROW.FINISHPRO_MOLD,
		MYROW.IN_MOLD);
		V_INCOUNT  := V_INCOUNT + 1;
		V_OUTCOUNT := V_OUTCOUNT + 1;
		  UPDATE MAT_ZC_M T1
   SET T1.ORDER_NO          = '#ORDER_NO#',
       T1.ORDER_SEQ         = (SELECT ORDER_SEQ FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK  = '#ORD_LN_PK#' ),
       T1.PRODUCT_FLAG      = '801403',
       T1.MAT_STATUS        = '80150301',
       T1.ORD_PK            = '#ORD_PK#',
       T1.ORD_LN_PK         = '#ORD_LN_PK#',
       T1.BELONG_CODE       = '#NEWBELONG_CODE#',
       T1.BELONG_NAME       = '#NEWBELONG_NAME#',
       T1.LOCK_LIKU         = '0'
    WHERE
    T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    AND T1.BATCH_NO = '#BATCH_NO#'
    AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
    AND T1.PRODUCT_FLAG = '801402'
    AND T1.MAT_NO = MYROW.MAT_NO;
    
     UPDATE MAT_ZC_M_XS T1
   SET T1.ORDER_NO          = '#ORDER_NO#',
       T1.ORDER_SEQ         = (SELECT ORDER_SEQ FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK  = '#ORD_LN_PK#' ),
       T1.PRODUCT_FLAG      = '801403',
       T1.MAT_STATUS        = '80150301',
       T1.ORD_PK            = '#ORD_PK#',
       T1.ORD_LN_PK         = '#ORD_LN_PK#',
       T1.BELONG_CODE       = '#NEWBELONG_CODE#',
       T1.BELONG_NAME       = '#NEWBELONG_NAME#',
       T1.LOCK_LIKU         = '0'
    WHERE
    T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    AND T1.BATCH_NO = '#BATCH_NO#'
    AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
    AND T1.PRODUCT_FLAG = '801402'
    AND T1.MAT_NO = MYROW.MAT_NO;
    
		END LOOP;
		END;
		]]>
	</query>
    
	
</queryMap>
