<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "期初数据操作">
<query id = "FrmPipeManualIn.queryManualIn" desc = "查询期初数据">
<![CDATA[
 SELECT 
       STORAGE_NAME,
       LOCATION_NO,
       PRO_ORDER_NO,
       PRO_ORDER_ID,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       ORDER_SEQ_NO,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       MEMO,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       BAL_YEAR_MONTH,
       GRADENAME,
       PLINE_CODE,
       PLINE_NAME,
       HANDLE_LOG,
       ORIGINAL_DATE,
       GRADECODE,
       INITIAL_ID,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       DIMATER,
       HEIGHT,
       LEN,
       LEN_MIN,
       LEN_MAX,
       ACT_COUNT,
       ACT_WEIGHT,
       STORAGE_NO,
       ACT_THEORY_WEIGHT,
       JUDGE_RESULT_CODE,
       JUDGE_RESULT,
       JUDGE_GRADE,
       INSTOCK_TIME,
       BELONG_CODE,
       BELONG_NAME
 FROM YDM_ZC_INITIAL 
 WHERE ORIGINAL_DATE || '&' LIKE ('%' || ? || '%')
 AND JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
 AND BATCH_NO || '&' LIKE ('%' || ? || '%')
 AND STORAGE_NO || '&' LIKE ('%' || ? || '%')
 AND HANDLE_LOG = '0'
 ]]>
</query>

<query id = "FrmPipeManualIn.queryManualInHalog" desc = "已处理期初">
<![CDATA[
 SELECT 
       t.STORAGE_NAME,
       t.LOCATION_NO,
       t.PRO_ORDER_NO,
       t.PRO_ORDER_ID,
       t.ORD_PK,
       t.ORD_LN_PK,
       t.ORD_LN_DLY_PK,
       t.ORDER_NO,
       t.ORDER_SEQ,
       t.ORDER_SEQ_NO,
       t.DEPARTMENT_CODE,
       t.DEPARTMENT_DESC,
       t.MANAGEMENT_NO,
       t.MANAGEMENT_NAME,
       t.MEMO,
       t.CREATE_NAME,
       TO_CHAR(t.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       t.BAL_YEAR_MONTH,
       t.GRADENAME,
       t.PLINE_CODE,
       t.PLINE_NAME,
       t.HANDLE_LOG,
       t.ORIGINAL_DATE,
       t.GRADECODE,
       t.INITIAL_ID,
       t.JUDGE_STOVE_NO,
       t.BATCH_NO,
       t.BATCH_GROUD_NO,
       t.PRODUCT_FLAG,
       t.MAT_STATUS,
       t.MATERIAL_NO,
       t.MATERIAL_NAME,
       t.PRODUCCODE,
       t.PRODUCNAME,
       t.STEELCODE,
       t.STEELNAME,
       t.SPEC_CODE,
       t.SPEC_NAME,
       t.MODEL_CODE,
       t.MODEL_DESC,
       t.STD_CODE,
       t.STD_NAME,
       t.STD_STYLE,
       t.STD_STYLE_DESC,
       t.DIMATER,
       t.HEIGHT,
       t.LEN,
       t.LEN_MIN,
       t.LEN_MAX,
       t.ACT_COUNT,
       t.ACT_WEIGHT,
       t.STORAGE_NO,
       t.ACT_THEORY_WEIGHT,
       t.JUDGE_RESULT_CODE,
       t.JUDGE_RESULT,
       t.JUDGE_GRADE,
       t.INSTOCK_TIME,
       t.BELONG_CODE,
       t.BELONG_NAME
  FROM YDM_ZC_INITIAL t
 where t.BAL_YEAR_MONTH || '&' LIKE ('%' || ? || '%')
   AND t.JUDGE_STOVE_NO || '&' LIKE ('%' || ? || '%')
   AND t.BATCH_NO || '&' LIKE ('%' || ? || '%')
   AND t.BELONG_CODE || '&' LIKE ('%' || ? || '%')
   AND t.HANDLE_LOG = '1'

 ]]>
</query>
<query id = "FrmPipeManualIn.getOrderPk" desc = "获取键值">
   SELECT distinct
T1.SALE_ORG,
       T1.SALE_ORG_DESC,
       T1.ORD_PK,
       T2.ORD_LN_PK,
       T3.ORD_LN_DLY_PK,
       T2.STD_CODE,
       T2.STD_NAME,
       T2.LEN_NO,
       T2.LEN_DESC,
       T2.LEN_UNIT,
       T3.DELIVERY_NO
  from SLM_ORDER_HEAD          t1,
       SLM_ORDER_LINE          T2,
       SLM_ORDER_LINE_DELIVERY T3,
      YDM_ZC_INITIAL          T
 where T1.ORD_PK = T2.ORD_PK
   AND T1.ORD_PK = T3.ORD_PK
   --AND T1.ORD_PK = T.ORD_PK
   AND T2.ORD_LN_PK = T3.ORD_LN_PK
   AND T1.ORDER_NO = T.ORDER_NO
   AND LPAD(T2.ORDER_SEQ,4,'0') = LPAD(T.Order_Seq,4,'0')
   AND t.order_no = ?
   AND LPAD(T.ORDER_SEQ, 4, '0') = LPAD(?, 4, '0')
   --AND LPAD(T.ORDER_SEQ_NO,4,'0') = LPAD(?,4,'0')
   AND T1.VALIDFLAG = '1'
   AND T2.VALIDFLAG = '1'
   AND T3.VALIDFLAG = '1'
</query>
<!-- 
SELECT T1.SALE_ORG,
       T1.SALE_ORG_DESC,
       T1.ORD_PK,
       T2.ORD_LN_PK,
       T3.ORD_LN_DLY_PK,
       T2.STD_CODE,
       T2.STD_NAME,
       T2.LEN_NO,
       T2.LEN_DESC,
       T2.LEN_UNIT,
       T3.DELIVERY_NO
  from SLM_ORDER_HEAD t1, SLM_ORDER_LINE T2, SLM_ORDER_LINE_DELIVERY T3,
  YDM_ZC_INITIAL T

 where T1.ORD_PK = T2.ORD_PK
   AND T1.ORD_PK = T3.ORD_PK
   AND T1.ORD_PK = T.ORD_PK(+)
   AND t1.order_no = ?
   AND LPAD(T2.ORDER_SEQ, 4, '0') = LPAD(?, 4, '0')
   AND T1.VALIDFLAG = '1'
   AND T2.VALIDFLAG = '1'
   AND T3.VALIDFLAG = '1'
 -->
<query id = "FrmPipeManualIn.insertMat" desc = "插入材料表(商品)">
<![CDATA[
	   INSERT INTO MAT_ZC_M
     (
     JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     SPEC_CODE,
     SPEC_NAME,
     MODEL_CODE,
     MODEL_DESC,
     STD_CODE,
     STD_NAME,
     BELONG_CODE,
     BELONG_NAME,
     STD_STYLE,
     STD_STYLE_DESC,
     ORDER_NO,
     ORDER_SEQ,
     ORDER_SEQ_NO,
     ORD_PK,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     ACT_DIMATER,
     ACT_HEIGHT,
     LEN_NO,
     LEN_DESC,
     LEN_UNIT,
     ACT_LEN_MIN,
     ACT_LEN_MAX,
     CREATE_NAME,
 	 
     ACT_COUNT,		 
     ACT_WEIGHT,
     CREATE_TIME, 
     INSTOCK_TIME,  
     MAT_NO,
     MEMO,
     JUGDE_APPLY_FLAG,
     INSTOCK_FLAG,
     PRODUCT_FLAG,
     MAT_STATUS,
     ACT_LEN,
     JUDGE_STD_NAME,
     BAL_YEAR_MONTH,
     PLINE_CODE,
     PLINE_NAME,
     GRADECODE,
     GRADENAME,
     BEGINNING_FLAG,
     JUDGE_GRADE  
     ) VALUES  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
             ?,?,?,?,?,?,?,?,?,?,?,?,
             TO_NUMBER(?),ROUND(TO_NUMBER(?),4),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
             ?,?,'1','1','801403','80150301',TO_NUMBER(?),?,?,?,?,?,?,'1',?)
		]]>

</query>
<query id = "FrmPipeManualIn.insertMat1" desc = "插入材料表(成品)">
<![CDATA[
	   INSERT INTO MAT_ZC_M
     (
     JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     SPEC_CODE,
     SPEC_NAME,
     MODEL_CODE,
     MODEL_DESC,
     STD_CODE,
     STD_NAME,
     BELONG_CODE,
     BELONG_NAME,
     STD_STYLE,
     STD_STYLE_DESC,
     
     ACT_DIMATER,
     ACT_HEIGHT,
     LEN_NO,
     LEN_DESC,
     LEN_UNIT,
     ACT_LEN_MIN,
     ACT_LEN_MAX,
     CREATE_NAME,
 	 
     ACT_COUNT,		 
     ACT_WEIGHT,
     CREATE_TIME, 
     INSTOCK_TIME,  
     MAT_NO,
     MEMO,
     JUGDE_APPLY_FLAG,
     INSTOCK_FLAG,
     PRODUCT_FLAG,
     MAT_STATUS,
     ACT_LEN,
     JUDGE_STD_NAME,
     BAL_YEAR_MONTH,
     PLINE_CODE,
     PLINE_NAME,
     GRADECODE,
     GRADENAME,
     BEGINNING_FLAG,
     JUDGE_GRADE
     ) VALUES  (?,?,?,?,?,?,?,?,?,?,?,?,?,
             ?,?,?,?,?,?,?,?,?,?,?,?,
             TO_NUMBER(?),ROUND(TO_NUMBER(?),4),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
             ?,?,'1','1','801402','80150202',TO_NUMBER(?),?,?,?,?,?,?,'1',?)
		]]>
</query>
<query id = "FrmPipeManualIn.insertButess" desc = "插入位置表">
<![CDATA[
       INSERT INTO YDM_ZC_BUTTRESS
    (
     JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     STORAGE_NO,
     LOCATION_NO,
     STORAGE_TYPE_NO,
     STORAGE_TYPE_NAME,
     
     CREATE_NAME,
     MAT_NO,
     CREATE_TIME,
     MANAGEMENT_NO,
     MANAGEMENT_NAME,
     DEPARTMENT_CODE,
     DEPARTMENT_DESC
     )
    VALUES ( ?,?,?,?,?,?,?,?,?,to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?)
		]]>
</query>

<query id = "FrmPipeManualIn.updateIntal" desc = "修改期初处理标志">
UPDATE YDM_ZC_INITIAL T SET T.HANDLE_LOG ='1' WHERE T.INITIAL_ID=?
</query>

<query id = "FrmPipeManualIn.updateMat" desc = "修改材料键值">
UPDATE MAT_ZC_M T
   SET T.ORD_PK        = ?,
       T.ORD_LN_PK     = ?,
       T.ORD_LN_DLY_PK = ?
       --T.PRODUCT_FLAG  = ?
       --T.MAT_STATUS    = ?
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
</query>
<query id = "FrmPipeManualIn.updateLog" desc = "修改处理标志">
UPDATE YDM_ZC_INITIAL T SET T.HANDLE_LOG ='5' WHERE T.INITIAL_ID=?
</query>
</queryMap>