<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="钢管缴库管理">

	<query id="CorePipeInTemp.QueryOrder" desc="合同查询">
		<![CDATA[
	 SELECT T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO,
       T1.CUST_ALPHA_NO,
       T1.PSC,
       T1.PSC_DESC,
       T1.MSC,
       T1.MSC_DESC,
       T1.PRD_CLS,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.ORDER_SPEC_CODE,
       T1.ORDER_SPEC_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       to_char(T1.LEN_MIN,'FM999990.00') AS LEN_MIN,
       to_char(T1.LEN_MAX,'FM999990.00') AS LEN_MAX,
       to_char(T1.LEN_MIN,'FM999990.00')||'-'||to_char(T1.LEN_MAX,'FM999990.00') as LEN,
       T1.SHRT_LEN_RATO,
       T1.SHORTEST,
       T1.LONG_LEN_RATO,
       T1.LONGEST,
       T1.SHRT_STOVE,
       T1.AVG_LEN_MIN,
       T1.DIFRNC_LEN_MAX,
       T1.SIGL_LEN,
       T1.ORDER_UNIT,
       T1.ORDER_QTY,
       T1.ORD_ENSU_TOTL_LEN,
       TO_CHAR(T1.PRDCT_WGT,'FM9999990.000') AS PRDCT_WGT,
       T1.CREATE_NAME,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.UPDATE_NAME,
       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.DELETE_NAME,
       TO_CHAR(T1.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T2.CUSTM_ORDER_NO,
       T2.ORDER_TYP,
       T2.ORDER_TYP_DESC,
       T2.PROTCL_NO,
       T2.CUSTOMER_NO,
       T2.CUSTOMER_NM,
       T2.SALE_ORG,
       T2.SALE_ORG_DESC,
       T2.SALE_AREA_NO,
       T2.SALE_AREA_DESC,
       T2.ABRVITION,
       T1.DELVRY_RANGE_MIN,
       T1.DELVRY_RANGE_MAX,
       DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MIN, '') LOWERLIMT,
               DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MAX, '') UPPERLIMIT,
               '(-' || TO_CHAR(T1.DELVRY_RANGE_MIN) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ',' ||
               TO_CHAR(T1.DELVRY_RANGE_MAX) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ')' DELVRY_RANGE,
       to_char(NVL(T3.DELVRY_QTY,0),'FM999999990.000') AS DELVRY_QTY,
       to_char(NVL(T4.PLANWEIGHT,0),'FM999999990.000') AS PLANWEIGHT,
       to_char(NVL(T4.PAYDOWNWEIGHT,0),'FM999999990.000') AS PAYDOWNWEIGHT,
       NVL(T4.PAYDOWN_NUM,0) AS PAYDOWN_NUM,
       DECODE(T4.PORDERSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成',
              '6',
              '关闭') AS PORDERSTATUS,
        T2.ORD_PK,      
        T1.ORD_LN_PK,
        T3.ORD_LN_DLY_PK,
        T1.STD_STYLE,
        T1.STD_STYLE_DESC,
        A.DEPARTID AS CREATE_DEPT,
        A.SALE_AREA_DESC as DEPARTNAME,
        nvl(T4.ORDERWEIGHT,0) AS ORDERWEIGHT,
        S.PRODUCNAME AS PRODUC_NAME,
        T1.FINAL_USER_DESC
   FROM SLM_ORDER_LINE T1
     LEFT JOIN COM_BASE_PRODUCT S 
  ON  T1.PRODUCCODE = S.PRODUCCODE
  LEFT JOIN SLM_ORDER_HEAD T2
    ON T1.ORD_PK = T2.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY T3
    ON T1.ORD_LN_PK = T3.ORD_LN_PK
  LEFT JOIN PLN_SALEORD T4
    ON T4.ORD_LN_PK = T1.ORD_LN_PK
   AND T4.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
  LEFT JOIN SLM_BASE_SALE_AREA_TYP A ON A.DEPARTID=T2.CREATE_DEPT
 WHERE T1.VALIDFLAG = '1'
 AND ((A.VALIDFLAG = '1' AND T2.CREATE_DEPT IS NOT NULL) OR (T2.CREATE_DEPT IS NULL AND T2.Create_Name is NULL))
 AND T2.VALIDFLAG = '1'
 AND T3.VALIDFLAG = '1'
   AND  upper(T2.ORDER_NO) || '&' LIKE ('%' || upper(?) || '%')
   --AND DECODE(?, '', '1', T1.ORDER_SEQ) = DECODE(?, '', '1', ?)
   AND T4.PORDERSTATUS IN ('1','2','3','4')
		]]>
	</query>
	<query id = "CorePipeInTemp.queryOrder1" desc = "缴库完成后查询缴库合同信息">
	<![CDATA[
	 SELECT T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO,
       T1.CUST_ALPHA_NO,
       T1.PSC,
       T1.PSC_DESC,
       T1.MSC,
       T1.MSC_DESC,
       T1.PRD_CLS,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.ORDER_SPEC_CODE,
       T1.ORDER_SPEC_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       to_char(T1.LEN_MIN,'FM999990.00') AS LEN_MIN,
       to_char(T1.LEN_MAX,'FM999990.00') AS LEN_MAX,
       to_char(T1.LEN_MIN,'FM999990.00')||'-'||to_char(T1.LEN_MAX,'FM999990.00') as LEN,
       T1.SHRT_LEN_RATO,
       T1.SHORTEST,
       T1.LONG_LEN_RATO,
       T1.LONGEST,
       T1.SHRT_STOVE,
       T1.AVG_LEN_MIN,
       T1.DIFRNC_LEN_MAX,
       T1.SIGL_LEN,
       T1.ORDER_UNIT,
       T1.ORDER_QTY,
       T1.ORD_ENSU_TOTL_LEN,
       TO_CHAR(T1.PRDCT_WGT,'FM9999990.000') AS PRDCT_WGT,
       T1.CREATE_NAME,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.UPDATE_NAME,
       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.DELETE_NAME,
       TO_CHAR(T1.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T2.CUSTM_ORDER_NO,
       T2.ORDER_TYP,
       T2.ORDER_TYP_DESC,
       T2.PROTCL_NO,
       T2.CUSTOMER_NO,
       T2.CUSTOMER_NM,
       T2.SALE_ORG,
       T2.SALE_ORG_DESC,
       T2.SALE_AREA_NO,
       T2.SALE_AREA_DESC,
       T2.ABRVITION,
       T1.DELVRY_RANGE_MIN,
       T1.DELVRY_RANGE_MAX,
       DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MIN, '') LOWERLIMT,
               DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MAX, '') UPPERLIMIT,
               '(-' || TO_CHAR(T1.DELVRY_RANGE_MIN) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ',' ||
               TO_CHAR(T1.DELVRY_RANGE_MAX) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ')' DELVRY_RANGE,
       to_char(NVL(T3.DELVRY_QTY,0),'FM999999990.000') AS DELVRY_QTY,
       to_char(NVL(T4.PLANWEIGHT,0),'FM999999990.000') AS PLANWEIGHT,
       to_char(NVL(T4.PAYDOWNWEIGHT,0),'FM999999990.000') AS PAYDOWNWEIGHT,
       NVL(T4.PAYDOWN_NUM,0) AS PAYDOWN_NUM,
       DECODE(T4.PORDERSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成',
              '6',
              '关闭') AS PORDERSTATUS,
        T2.ORD_PK,      
        T1.ORD_LN_PK,
        T3.ORD_LN_DLY_PK,
        T1.STD_STYLE,
        T1.STD_STYLE_DESC,
        A.DEPARTID AS CREATE_DEPT,
        A.SALE_AREA_DESC as DEPARTNAME,
        nvl(T4.ORDERWEIGHT,0) AS ORDERWEIGHT,
        T1.FINAL_USER_DESC
  FROM SLM_ORDER_LINE T1
  LEFT JOIN SLM_ORDER_HEAD T2
    ON T1.ORD_PK = T2.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY T3
    ON T1.ORD_LN_PK = T3.ORD_LN_PK
  LEFT JOIN PLN_SALEORD T4
    ON T4.ORD_LN_PK = T1.ORD_LN_PK
   AND T4.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
  LEFT JOIN SLM_BASE_SALE_AREA_TYP A ON A.DEPARTID=T2.CREATE_DEPT
 WHERE T1.VALIDFLAG = '1'
 AND ((A.VALIDFLAG = '1' AND T2.CREATE_DEPT IS NOT NULL) OR (T2.CREATE_DEPT IS NULL AND T2.Create_Name is NULL))
 AND T2.VALIDFLAG = '1'
 AND T3.VALIDFLAG = '1'
 AND T2.ORDER_TYP <>'120104'
 AND upper(T2.ORDER_NO) = upper(?)
  -- AND  upper(T2.ORDER_NO) || '&' LIKE ('%' || upper(?) || '%')
   --AND DECODE(to_number(?), '', '1', T1.ORDER_SEQ) = DECODE(to_number(?), '', '1', to_number(?))
   --AND upper(T1.ORDER_SEQ) || '&' LIKE ('%' || upper(to_number(?)) || '%')
   AND lpad(T1.ORDER_SEQ,4,'0') = lpad(nvl(trim(?),'999'),4,'0')
   AND T4.PORDERSTATUS IN ('1','2','3','4')
		]]>
	</query>
	<query id = "CorePipeInTemp.queryOrder2" desc = "查询是否存在同合同号">
	<![CDATA[
	 SELECT T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO,
       T1.CUST_ALPHA_NO,
       T1.PSC,
       T1.PSC_DESC,
       T1.MSC,
       T1.MSC_DESC,
       T1.PRD_CLS,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.ORDER_SPEC_CODE,
       T1.ORDER_SPEC_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       to_char(T1.LEN_MIN,'FM999990.00') AS LEN_MIN,
       to_char(T1.LEN_MAX,'FM999990.00') AS LEN_MAX,
       to_char(T1.LEN_MIN,'FM999990.00')||'-'||to_char(T1.LEN_MAX,'FM999990.00') as LEN,
       T1.SHRT_LEN_RATO,
       T1.SHORTEST,
       T1.LONG_LEN_RATO,
       T1.LONGEST,
       T1.SHRT_STOVE,
       T1.AVG_LEN_MIN,
       T1.DIFRNC_LEN_MAX,
       T1.SIGL_LEN,
       T1.ORDER_UNIT,
       T1.ORDER_QTY,
       T1.ORD_ENSU_TOTL_LEN,
       TO_CHAR(T1.PRDCT_WGT,'FM9999990.000') AS PRDCT_WGT,
       T1.CREATE_NAME,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.UPDATE_NAME,
       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.DELETE_NAME,
       TO_CHAR(T1.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T2.CUSTM_ORDER_NO,
       T2.ORDER_TYP,
       T2.ORDER_TYP_DESC,
       T2.PROTCL_NO,
       T2.CUSTOMER_NO,
       T2.CUSTOMER_NM,
       T2.SALE_ORG,
       T2.SALE_ORG_DESC,
       T2.SALE_AREA_NO,
       T2.SALE_AREA_DESC,
       T2.ABRVITION,
       T1.DELVRY_RANGE_MIN,
       T1.DELVRY_RANGE_MAX,
       DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MIN, '') LOWERLIMT,
               DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MAX, '') UPPERLIMIT,
               '(-' || TO_CHAR(T1.DELVRY_RANGE_MIN) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ',' ||
               TO_CHAR(T1.DELVRY_RANGE_MAX) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ')' DELVRY_RANGE,
       to_char(NVL(T3.DELVRY_QTY,0),'FM999999990.000') AS DELVRY_QTY,
       to_char(NVL(T4.PLANWEIGHT,0),'FM999999990.000') AS PLANWEIGHT,
       to_char(NVL(T4.PAYDOWNWEIGHT,0),'FM999999990.000') AS PAYDOWNWEIGHT,
       NVL(T4.PAYDOWN_NUM,0) AS PAYDOWN_NUM,
       DECODE(T4.PORDERSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成',
              '6',
              '关闭') AS PORDERSTATUS,
        T2.ORD_PK,      
        T1.ORD_LN_PK,
        T3.ORD_LN_DLY_PK,
        T1.STD_STYLE,
        T1.STD_STYLE_DESC,
        A.DEPARTID AS CREATE_DEPT,
        A.SALE_AREA_DESC as DEPARTNAME,
        nvl(T4.ORDERWEIGHT,0) AS ORDERWEIGHT,
        T1.FINAL_USER_DESC
  FROM SLM_ORDER_LINE T1
  LEFT JOIN SLM_ORDER_HEAD T2
    ON T1.ORD_PK = T2.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY T3
    ON T1.ORD_LN_PK = T3.ORD_LN_PK
  LEFT JOIN PLN_SALEORD T4
    ON T4.ORD_LN_PK = T1.ORD_LN_PK
   AND T4.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
  LEFT JOIN SLM_BASE_SALE_AREA_TYP A ON A.DEPARTID=T2.CREATE_DEPT
 WHERE T1.VALIDFLAG = '1'
 AND ((A.VALIDFLAG = '1' AND T2.CREATE_DEPT IS NOT NULL) OR (T2.CREATE_DEPT IS NULL AND T2.Create_Name is NULL))
 AND T2.VALIDFLAG = '1'
 AND T3.VALIDFLAG = '1'
 AND T2.ORDER_TYP <>'120104'
 AND upper(T2.ORDER_NO) = upper(?)
   --AND  upper(T2.ORDER_NO) || '&' LIKE ('%' || upper(?) || '%')
   AND lpad(T1.ORDER_SEQ,4,'0') = lpad(nvl(trim(?),'999'),4,'0')
   --AND DECODE(to_number(?), '', '1', T1.ORDER_SEQ) = DECODE(to_number(?), '', '1', to_number(?))
   --AND upper(T1.ORDER_SEQ) || '&' LIKE ('%' || upper(to_number(?)) || '%')
   --AND T4.PORDERSTATUS IN ('1','2','3','4')
		]]>
	</query>
<query id = "CorePipeInTemp.queryOrderClick" desc = "单击查询合同">
<![CDATA[
	 SELECT T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO,
       T2.ORDER_NO ||'/'|| T1.ORDER_SEQ AS SORDER,
       T1.CUST_ALPHA_NO,
       T1.PSC,
       T1.PSC_DESC,
       T1.MSC,
       T1.MSC_DESC,
       T1.PRD_CLS,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.ORDER_SPEC_CODE,
       T1.ORDER_SPEC_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       to_char(T1.LEN_MIN,'FM999990.00') AS LEN_MIN,
       to_char(T1.LEN_MAX,'FM999990.00') AS LEN_MAX,
       to_char(T1.LEN_MIN,'FM999990.00')||'-'||to_char(T1.LEN_MAX,'FM999990.00') as LEN,
       T1.SHRT_LEN_RATO,
       T1.SHORTEST,
       T1.LONG_LEN_RATO,
       T1.LONGEST,
       T1.SHRT_STOVE,
       T1.AVG_LEN_MIN,
       T1.DIFRNC_LEN_MAX,
       T1.SIGL_LEN,
       T1.ORDER_UNIT,
       T1.ORDER_QTY,
       T1.ORD_ENSU_TOTL_LEN,
       TO_CHAR(T1.PRDCT_WGT,'FM9999990.000') AS PRDCT_WGT,
       T1.CREATE_NAME,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.UPDATE_NAME,
       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.DELETE_NAME,
       TO_CHAR(T1.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T2.CUSTM_ORDER_NO,
       T2.ORDER_TYP,
       T2.ORDER_TYP_DESC,
       T2.PROTCL_NO,
       T2.CUSTOMER_NO,
       T2.CUSTOMER_NM,
       T2.SALE_ORG,
       T2.SALE_ORG_DESC,
       T2.SALE_AREA_NO,
       T2.SALE_AREA_DESC,
       T2.ABRVITION,
       T1.DELVRY_RANGE_MIN,
       T1.DELVRY_RANGE_MAX,
       DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MIN, '') LOWERLIMT,
               DECODE(T1.DELVRY_RANGE_TPE, '绝对值', T1.DELVRY_RANGE_MAX, '') UPPERLIMIT,
               '(-' || TO_CHAR(T1.DELVRY_RANGE_MIN) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ',' ||
               TO_CHAR(T1.DELVRY_RANGE_MAX) ||
               DECODE(T1.DELVRY_RANGE_TPE, '%', '%', T1.ORDER_UNIT) || ')' DELVRY_RANGE,
       to_char(NVL(T3.DELVRY_QTY,0),'FM999999990.000') AS DELVRY_QTY,
       to_char(NVL(T4.PLANWEIGHT,0),'FM999999990.000') AS PLANWEIGHT,
       to_char(NVL(T4.PAYDOWNWEIGHT,0),'FM999999990.000') AS PAYDOWNWEIGHT,
       NVL(T4.PAYDOWN_NUM,0) AS PAYDOWN_NUM,
       DECODE(T4.PORDERSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成',
              '6',
              '关闭') AS PORDERSTATUS,
        T2.ORD_PK,      
        T1.ORD_LN_PK,
        T3.ORD_LN_DLY_PK,
        T1.STD_STYLE,
        T1.STD_STYLE_DESC,
        A.DEPARTID AS CREATE_DEPT,
        '合同匹配' AS MATCHORDER,
        A.SALE_AREA_DESC as DEPARTNAME,
         nvl(T4.ORDERWEIGHT,0) AS ORDERWEIGHT,
          S.PRODUCNAME AS PRODUC_NAME,
          T1.FINAL_USER_DESC,
          T4.CRAFT_FILE_NO,
          T4.ROLL_MONTH
  FROM SLM_ORDER_LINE T1
  LEFT JOIN COM_BASE_PRODUCT S 
  ON  T1.PRODUCCODE = S.PRODUCCODE
  LEFT JOIN SLM_ORDER_HEAD T2
    ON T1.ORD_PK = T2.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY T3
    ON T1.ORD_LN_PK = T3.ORD_LN_PK
  LEFT JOIN PLN_SALEORD T4
    ON T4.ORD_LN_PK = T1.ORD_LN_PK
   AND T4.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
  LEFT JOIN SLM_BASE_SALE_AREA_TYP A ON A.DEPARTID=T2.CREATE_DEPT
  --LEFT JOIN PLN_ORD_CRAFT_FILE T5 ON T5.ORDER_NO = T2.ORDER_NO
  --AND lpad(T5.ORDER_SEQ,4,0) = lpad(T1.ORDER_SEQ,4,0)
 WHERE T1.VALIDFLAG = '1'
 AND ((A.VALIDFLAG = '1' AND T2.CREATE_DEPT IS NOT NULL) OR (T2.CREATE_DEPT IS NULL AND T2.Create_Name is NULL))
 AND T2.VALIDFLAG = '1'
 AND T3.VALIDFLAG = '1'
 AND T2.ORDER_TYP <>'120104'
 AND upper(T2.ORDER_NO) = upper(?)
   --AND  upper(T2.ORDER_NO) || '&' LIKE ('%' || upper(?) || '%')
   --AND DECODE(?, '', '1', T1.ORDER_SEQ) = DECODE(?, '', '1', ?)
   AND lpad(T1.ORDER_SEQ,4,'0') = lpad(nvl(trim(?),'999'),4,'0')
   AND T4.PORDERSTATUS IN ('1','2','3','4')
		]]>
</query>
<query id = "CorePipeInTemp.getMatchOrderNo" desc = "查询是否有新增合同">
<![CDATA[
	SELECT A.ORDER_NO,
	    B.ORDER_SEQ ,
	    --AS ORDERSEQ,
       B.PRODUCNAME,
       B.STEELNAME,
       B.SPEC_NAME,
       B.MODEL_DESC
  FROM SLM_ORDER_LINE B
  LEFT JOIN SLM_ORDER_HEAD A ON B.ORD_PK = A.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY D
   ON D.ORD_LN_PK = B.ORD_LN_PK
  LEFT JOIN PLN_SALEORD C 
  ON C.ORD_LN_PK = B.ORD_LN_PK
  AND C.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK
  LEFT JOIN SLM_BASE_SALE_AREA_TYP E ON E.DEPARTID = A.CREATE_DEPT
 WHERE ((E.VALIDFLAG = '1' AND A.CREATE_DEPT IS NOT NULL) OR (A.CREATE_DEPT IS NULL AND A.Create_Name is NULL))
   AND B.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
   AND C.PORDERSTATUS IN ('1','2', '3', '4')
   AND B.PRODUCNAME=?
   AND B.STEELNAME=?
   AND B.SPEC_NAME=?
   AND B.MODEL_DESC=?
   
		]]>
</query>
	<query id="CorePipeInTemp.QueryMatData" desc="查询质量判定数据">
		<![CDATA[
	SELECT T.ORDERNO,
       T.RCDID,
       T.FACTORY,
       T.KIND,
       T.LCODE,
       T.LOTNO,
       T.STEELLEVEL,
       T.STEELGRADE,   
       T.SPEC,
       T.THICKNESS,
       T.GG,
       T.TYPEOFTHREAD,
       T.HGUNIT,
       T.HGM,
       T.HGWEIGHT,
       T.ORDERNAME,
       T.LENG,
       T.STANDARD,
       T.TESTIDEA,
       CONVERT(varchar(100), T.TESTDATE, 23) AS TESTDATE,
       T.DESTINATION, 
       CASE T.CXSTU when 20 then '已缴库' else '未缴库' end as CXSTU ,
       CASE T.CXSTU when 01 then '物料匹配' 
       --WHEN 02 THEN '合同号匹配，物料不匹配'
      -- WHEN 03 THEN '合同号不匹配，物料匹配'
      -- WHEN 04 THEN '合同号不匹配，物料不匹配'
       WHEN 02 THEN '物料不匹配'
       end as CXSTUPP ,
       T.CXKIND,
       T.CXSTEELLEVEL,
       T.CXSTEELGRADE,
       T.CXTYPEOFTHREAD,
       T.CXSTANDARD,
       T.CXGG,
       T.STDSTYLE,
       T.DEPARTM,
       CONVERT(varchar(100),T.CXUPDATEDATE, 20) AS CXUPDATEDATE
  FROM tabcxzljk T  where 1 = 1 
		]]>
	</query>
<query id ="CorePipeInTemp.getSqlServerStaus" desc = "查询sqlserver数据是否已缴库">
select T.CXSTU from tabcxzljk T
</query>
	<query id="CorePipeInTemp.GetStoveNo" desc="炉号查询">
		<![CDATA[
	   SELECT  T.lcode
       FROM tabcxzljk T
       WHERE 
        T.cxstu!='20' AND
        T.testdate >= ? and T.testdate <= ?
		]]>
	</query>

	<query id="CorePipeInTemp.GetOrderNo" desc="查询合同号">
		<![CDATA[
	   SELECT ORDER_NO FROM SLM_ORDER_HEAD
	   WHERE VALIDFLAG = '1' ORDER BY ORDER_NO 
		]]>
	</query>

	<query id="CorePipeInTemp.GetOrderNoSeq" desc="查询合同号，合同行号">
		<![CDATA[
	SELECT A.ORDER_NO || '/' || B.ORDER_SEQ AS ORDERSEQ,
       B.PRODUCNAME,
       B.STEELNAME,
       B.SPEC_NAME,
       B.MODEL_DESC
  FROM SLM_ORDER_LINE B
  LEFT JOIN SLM_ORDER_HEAD A ON B.ORD_PK = A.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY D
   ON D.ORD_LN_PK = B.ORD_LN_PK
  LEFT JOIN PLN_SALEORD C 
  ON C.ORD_LN_PK = B.ORD_LN_PK
  AND C.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK
 WHERE 
((A.VALIDFLAG = '1' AND A.CREATE_DEPT IS NOT NULL) OR (A.CREATE_DEPT IS NULL AND A.Create_Name is NULL))
   AND B.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
   AND C.PORDERSTATUS IN ('1','2', '3', '4')
   AND A.ORDER_NO=?
    AND lpad(B.ORDER_SEQ,3,'0') = lpad(nvl(trim(?),'999'),3,'0')
   ORDER BY A.ORDER_NO,B.ORDER_SEQ ASC
		]]>
	</query>
	<query id="CorePipeInTemp.GetVARIETIES" desc="查询品种(扣型不为空)">
		<![CDATA[
	SELECT A.ORDER_NO || '/' || B.ORDER_SEQ AS ORDERSEQ,
       B.PRODUCNAME,
       B.STEELNAME,
       B.SPEC_NAME,
       B.MODEL_DESC
  FROM SLM_ORDER_LINE B
  LEFT JOIN SLM_ORDER_HEAD A ON B.ORD_PK = A.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY D
   ON D.ORD_LN_PK = B.ORD_LN_PK
  LEFT JOIN PLN_SALEORD C 
  ON C.ORD_LN_PK = B.ORD_LN_PK
  AND C.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK
 WHERE A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
   AND C.PORDERSTATUS IN ('1','2', '3', '4')
   AND B.PRODUCCODE=?
   AND B.STEELCODE=?
   AND B.SPEC_CODE=?
   AND B.MODEL_CODE=?
   ORDER BY A.ORDER_NO,B.ORDER_SEQ ASC
		]]>
	</query>
	
	<query id = "CorePipeInTemp.queryOrderCx" desc = "根据4个字段查询合同">
	<![CDATA[
	SELECT T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO,
       T2.ORDER_NO ||'/'||T1.ORDER_SEQ AS SORDER,
       T1.CUST_ALPHA_NO,
       T1.PSC,
       T1.PSC_DESC,
       T1.MSC,
       T1.MSC_DESC,
       T1.PRD_CLS,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.ORDER_SPEC_CODE,
       T1.ORDER_SPEC_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       T1.LEN_MIN,
       T1.LEN_MAX,
       T1.LEN_MIN||'-'||T1.LEN_MAX as LEN,
       T1.SHRT_LEN_RATO,
       T1.SHORTEST,
       T1.LONG_LEN_RATO,
       T1.LONGEST,
       T1.SHRT_STOVE,
       T1.AVG_LEN_MIN,
       T1.DIFRNC_LEN_MAX,
       T1.SIGL_LEN,
       T1.ORDER_UNIT,
       T1.ORDER_QTY,
       T1.ORD_ENSU_TOTL_LEN,
       TO_CHAR(T1.PRDCT_WGT,'FM9999990.000') AS PRDCT_WGT,
       T1.CREATE_NAME,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.UPDATE_NAME,
       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.DELETE_NAME,
       TO_CHAR(T1.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T2.CUSTM_ORDER_NO,
       T2.ORDER_TYP,
       T2.ORDER_TYP_DESC,
       T2.PROTCL_NO,
       T2.CUSTOMER_NO,
       T2.CUSTOMER_NM,
       T2.SALE_ORG,
       T2.SALE_ORG_DESC,
       T2.SALE_AREA_NO,
       T2.SALE_AREA_DESC,
       T2.ABRVITION,
       T1.DELVRY_RANGE_MIN,
       T1.DELVRY_RANGE_MAX,
       '(-' || TO_CHAR(T1.DELVRY_RANGE_MIN) ||
                DECODE(T1.DELVRY_RANGE_TPE, '%', '%', '') || ',' ||
                TO_CHAR(T1.DELVRY_RANGE_MAX) ||
                DECODE(T1.DELVRY_RANGE_TPE, '%', '%', '') || ')'as DELVRY_RANGE,
       --'-'||T1.DELVRY_RANGE_MIN||T1.DELVRY_RANGE_TPE||'~'||'+'||T1.DELVRY_RANGE_MAX||T1.DELVRY_RANGE_TPE as DELVRY_RANGE,
       to_char(NVL(T3.DELVRY_QTY,0),'FM999999990.000') AS DELVRY_QTY,
       to_char(NVL(T4.PLANWEIGHT,0),'FM999999990.000') AS PLANWEIGHT,
       to_char(NVL(T4.PAYDOWNWEIGHT,0),'FM999999990.000') AS PAYDOWNWEIGHT,
       NVL(T4.PAYDOWN_NUM,0) AS PAYDOWN_NUM,
       DECODE(T4.PORDERSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成',
              '6',
              '关闭') AS PORDERSTATUS,
        T2.ORD_PK,      
        T1.ORD_LN_PK,
        T3.ORD_LN_DLY_PK,
        T1.STD_STYLE,
        T1.STD_STYLE_DESC,
        T4.ORDERWEIGHT,
        A.DEPARTID AS CREATE_DEPT,
        '' AS MATCHORDER,
        A.SALE_AREA_DESC as DEPARTNAME,
        S.PRODUCNAME AS PRODUC_NAME,
        T1.FINAL_USER_DESC,
        T4.ROLL_MONTH
  FROM SLM_ORDER_LINE T1
  LEFT JOIN COM_BASE_PRODUCT S 
  ON  T1.PRODUCCODE = S.PRODUCCODE
  LEFT JOIN SLM_ORDER_HEAD T2
    ON T1.ORD_PK = T2.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY T3
  on T1.ORD_LN_PK = T3.ORD_LN_PK
  LEFT JOIN PLN_SALEORD T4
    ON  T4.ORD_LN_PK = T1.ORD_LN_PK
   AND T4.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
  LEFT JOIN SLM_BASE_SALE_AREA_TYP A ON A.DEPARTID=T2.CREATE_DEPT
 WHERE T1.VALIDFLAG = '1'
   AND ((A.VALIDFLAG = '1' AND T2.CREATE_DEPT IS NOT NULL) OR (T2.CREATE_DEPT IS NULL AND T2.Create_Name is NULL))
   AND T4.PORDERSTATUS IN ('1','2','3','4')
   AND T2.ORDER_TYP <> '120104'
   AND T1.PRODUCCODE=?
   AND T1.STEELCODE=?
   AND T1.SPEC_CODE=?
   AND T1.MODEL_CODE=?
   ]]>
	</query>
	<query id = "CorePipeInTemp.queryOrderCxN" desc = "根据4个字段查询合同(N80Q)">
	<![CDATA[
	SELECT T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO,
       T2.ORDER_NO ||'/'|| T1.ORDER_SEQ AS SORDER,
       T1.CUST_ALPHA_NO,
       T1.PSC,
       T1.PSC_DESC,
       T1.MSC,
       T1.MSC_DESC,
       T1.PRD_CLS,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.ORDER_SPEC_CODE,
       T1.ORDER_SPEC_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       T1.LEN_MIN,
       T1.LEN_MAX,
       T1.LEN_MIN||'-'||T1.LEN_MAX as LEN,
       T1.SHRT_LEN_RATO,
       T1.SHORTEST,
       T1.LONG_LEN_RATO,
       T1.LONGEST,
       T1.SHRT_STOVE,
       T1.AVG_LEN_MIN,
       T1.DIFRNC_LEN_MAX,
       T1.SIGL_LEN,
       T1.ORDER_UNIT,
       T1.ORDER_QTY,
       T1.ORD_ENSU_TOTL_LEN,
       TO_CHAR(T1.PRDCT_WGT,'FM9999990.000') AS PRDCT_WGT,
       T1.CREATE_NAME,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.UPDATE_NAME,
       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.DELETE_NAME,
       TO_CHAR(T1.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T2.CUSTM_ORDER_NO,
       T2.ORDER_TYP,
       T2.ORDER_TYP_DESC,
       T2.PROTCL_NO,
       T2.CUSTOMER_NO,
       T2.CUSTOMER_NM,
       T2.SALE_ORG,
       T2.SALE_ORG_DESC,
       T2.SALE_AREA_NO,
       T2.SALE_AREA_DESC,
       T2.ABRVITION,
       T1.DELVRY_RANGE_MIN,
       T1.DELVRY_RANGE_MAX,
       '(-' || TO_CHAR(T1.DELVRY_RANGE_MIN) ||
                DECODE(T1.DELVRY_RANGE_TPE, '%', '%', '') || ',' ||
                TO_CHAR(T1.DELVRY_RANGE_MAX) ||
                DECODE(T1.DELVRY_RANGE_TPE, '%', '%', '') || ')'as DELVRY_RANGE,
       --'-'||T1.DELVRY_RANGE_MIN||T1.DELVRY_RANGE_TPE||'~'||'+'||T1.DELVRY_RANGE_MAX||T1.DELVRY_RANGE_TPE as DELVRY_RANGE,
       to_char(NVL(T3.DELVRY_QTY,0),'FM999999990.000') AS DELVRY_QTY,
       to_char(NVL(T4.PLANWEIGHT,0),'FM999999990.000') AS PLANWEIGHT,
       to_char(NVL(T4.PAYDOWNWEIGHT,0),'FM999999990.000') AS PAYDOWNWEIGHT,
       NVL(T4.PAYDOWN_NUM,0) AS PAYDOWN_NUM,
       DECODE(T4.PORDERSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成',
              '6',
              '关闭') AS PORDERSTATUS,
        T2.ORD_PK,      
        T1.ORD_LN_PK,
        T3.ORD_LN_DLY_PK,
        T1.STD_STYLE,
        T1.STD_STYLE_DESC,
        T4.ORDERWEIGHT,
        A.DEPARTID AS CREATE_DEPT,
        '' AS MATCHORDER,
        A.SALE_AREA_DESC as DEPARTNAME,
        S.PRODUCNAME AS PRODUC_NAME,
        T1.FINAL_USER_DESC,
        --to_char(T4.ROLL_MONTH,'yyyy-MM')ROLL_MONTH
        T4.ROLL_MONTH
  FROM SLM_ORDER_LINE T1
  LEFT JOIN COM_BASE_PRODUCT S 
  ON  T1.PRODUCCODE = S.PRODUCCODE
  LEFT JOIN SLM_ORDER_HEAD T2
    ON T1.ORD_PK = T2.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY T3
  on T1.ORD_LN_PK = T3.ORD_LN_PK
  LEFT JOIN PLN_SALEORD T4
    ON  T4.ORD_LN_PK = T1.ORD_LN_PK
   AND T4.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
  LEFT JOIN SLM_BASE_SALE_AREA_TYP A ON A.DEPARTID=T2.CREATE_DEPT
 WHERE T1.VALIDFLAG = '1'
   AND ((A.VALIDFLAG = '1' AND T2.CREATE_DEPT IS NOT NULL) OR (T2.CREATE_DEPT IS NULL AND T2.Create_Name is NULL))
   AND T4.PORDERSTATUS IN ('1','2','3','4')
   AND T2.ORDER_TYP <> '120104'
   AND T1.PRODUCCODE=?
   AND T1.STEELCODE in('C333','C335')
   AND T1.SPEC_CODE=?
   AND T1.MODEL_CODE=?
   ]]>
	</query>
	<query id="CorePipeInTemp.GetVARIETIES1" desc="查询品种(扣型为空)">
		<![CDATA[
	SELECT A.ORDER_NO || '/' || B.ORDER_SEQ AS ORDERSEQ,
       B.PRODUCNAME,
       B.STEELNAME,
       B.SPEC_NAME,
       B.MODEL_DESC
  FROM SLM_ORDER_LINE B
  LEFT JOIN SLM_ORDER_HEAD A ON B.ORD_PK = A.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY D
   ON D.ORD_LN_PK = B.ORD_LN_PK
  LEFT JOIN PLN_SALEORD C 
  ON C.ORD_LN_PK = B.ORD_LN_PK
  AND C.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK
 WHERE ((A.CREATE_DEPT IS NOT NULL) OR (A.CREATE_DEPT IS NULL AND A.Create_Name is NULL))
   AND B.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
   AND C.PORDERSTATUS IN ('1','2', '3', '4')
   AND B.PRODUCCODE=?
   AND B.STEELCODE=?
   AND B.SPEC_CODE=?
   AND B.MODEL_CODE IS NULL
   ORDER BY A.ORDER_NO,B.ORDER_SEQ ASC
		]]>
	</query>
	<query id="CorePipeInTemp.QuerySameOrderNoData" desc="材料查询">
		<![CDATA[
       SELECT  T.*,'FALSE' CHK
       FROM tabcxzljk T
	   WHERE  1=1 and T.orderno=?
	   AND T.testdate >= ? and T.testdate <= ?
	  -- AND cx_stu='00'
		]]>
	</query>

	<query id="CorePipeInTemp.GetStorageDetail" desc="获取仓库号，描述">
		<![CDATA[
	    SELECT STORAGE_NAME,STORAGE_NO,STORAGE_TYPE_NO,STORAGE_TYPE_NAME
      ,MANAGEMENT_NO,MANAGEMENT_NAME
      FROM YDM_BS_STORAGE 
      WHERE VALIDFLAG='1'
      AND STORAGE_TYPE_NO IN('800202','800205')
		]]>
	</query>
<query id = "CorePipeInTemp.getFactoryDetail" desc = "查询所有产线">
SELECT DISTINCT T.PLINE_NAME,T.PLINE_CODE FROM LIN_BASE_PLINE T
</query>
<query id = "CorePipeInTemp.getGradeDetail" desc = "查询所有钢种">
SELECT DISTINCT T.GRADENAME,T.GRADECODE FROM LIN_BASE_GRADE T
</query>
<query id = "CorePipeInTemp.getWg" desc = "查询外购下产线">
SELECT  DISTINCT T.BASENAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '801301' 
</query>
<query id = "CorePipeInTemp.getDk" desc = "查询倒库下产线">
SELECT DISTINCT T.BASENAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '801303' 
</query>
<query id = "CorePipeInTemp.getWw" desc = "查询外委下产线">
SELECT DISTINCT T.BASENAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '801304' 
</query>
	<query id="CorePipeInTemp.InsertButtress" 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 = "CorePipeInTemp.deleteButtress" desc = "删除位置表">
<![CDATA[
DELETE FROM YDM_ZC_BUTTRESS S WHERE S.MAT_NO = ?
]]>
<!-- DELETE FROM YDM_ZC_BUTTRESS S WHERE S.MAT_NO = (SELECT MIN(T.MAT_NO)MAT_NO FROM MAT_ZC_M T,YDM_ZC_BUTTRESS D WHERE T.MAT_NO = D.MAT_NO AND T.PRODUCT_FLAG = '801403' AND T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? AND T.BATCH_GROUD_NO = ?) -->
</query>
	<query id="CorePipeInTemp.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,
     PIPMEMO,
     OLD_ORDER_NO,
     JUDGE_RESULT_TIME,
     MAT_ORIGIN_CODE,
     MAT_ORIGIN_NAME,
     SOURE_CODE,
     SOURE_NAME,
     MATERIAL_NO,
     MATERIAL_NAME,
     PACK_NO,
     IN_MOLD,
     ZBS_FLAG,
     JUDGE_RESULT_CODE,
     JUDGE_RESULT,
     SUPPLY_UNIT_CODE,
     SUPPLY_UNIT
     --OUT_FACTORY_FLAG,
     --TREASURY_TIME
     ) 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(?),?,?,?,?,?,?,?,?,TO_DATE(?,'YYYY-MM-DD'),?,?,?,?,?,?,?,?,'2','40740701','合格','120501','天津钢管制造有限公司')
		]]>
	</query>
	<query id = "CorePipeInTemp.INSERTMAT2" desc = "插入材料表3">
	<![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,
     PIPMEMO,
     OLD_ORDER_NO,
     JUDGE_RESULT_TIME,
     MAT_ORIGIN_CODE,
     MAT_ORIGIN_NAME,
     SOURE_CODE,
     SOURE_NAME,
     MATERIAL_NO,
     MATERIAL_NAME,
     PACK_NO,
     IN_MOLD,
     ZBS_FLAG,
     JUDGE_RESULT_CODE,
     JUDGE_RESULT,
     --OUT_FACTORY_FLAG,
     --TREASURY_TIME,
     SUPPLY_UNIT_CODE,
     SUPPLY_UNIT
     ) 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(?),?,?,?,?,?,?,?,?,TO_DATE(?,'YYYY-MM-DD'),?,?,?,?,?,?,?,?,'2','40740701','合格','120501','天津钢管制造有限公司')
		]]>
	</query>
	<query id="CorePipeInTemp.INSERTMAT1" desc="插入材料1">
		<![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,
     PIPMEMO,
     OLD_ORDER_NO,
     JUDGE_RESULT_TIME,
     MAT_ORIGIN_CODE,
     MAT_ORIGIN_NAME,
     SOURE_CODE,
     SOURE_NAME,
     MATERIAL_NO,
     MATERIAL_NAME,
     PACK_NO,
     IN_MOLD,
     ZBS_FLAG,
     JUDGE_RESULT_CODE,
     JUDGE_RESULT,
     --OUT_FACTORY_FLAG,
     --TREASURY_TIME
      SUPPLY_UNIT_CODE,
     SUPPLY_UNIT
     ) 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(?),?,?,?,?,?,?,?,?,TO_DATE(?,'YYYY-MM-DD'),?,?,?,?,?,?,?,?,'2','40740701','合格','120501','天津钢管制造有限公司')
		]]>
	</query>
	

	<query id="CorePipeInTemp.UPDATEINTERFACE" desc="更新数据状态">
		<![CDATA[
	    UPDATE tabcxzljk
	    SET cxstu='20'
	    where lcode=? AND  lotno=? AND  factory=?
	    AND  testdate=? AND  hgunit=? AND  hgweight=? and RCDID=?
 
		]]>
	</query>
    <query id = "CorePipeInTemp.UPDATEINTERFACE1" desc = "修改质保数据(红冲)">
    <![CDATA[
    UPDATE tabcxzljk
	    SET cxstu='20'
	    where RCDID=?
	    ]]>
    </query>
	<query id="CorePipeInTemp.QUERYMAT" desc="库存查询">
		<![CDATA[
      SELECT T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.LEN_NO,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.GRADECODE,
       T1.GRADENAME,
      sum(T1.ACT_COUNT)
            UNIT,
            to_char(sum(T1.Act_Weight),'FM999999990.000')
           WEIGHT,
       sum(nvl(T1.ACT_LEN,0)) as ACT_LEN,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       to_char(T1.ACT_LEN_MIN,'FM999990.00') AS ACT_LEN_MIN,
       to_char(T1.ACT_LEN_MAX,'FM999990.00') AS ACT_LEN_MAX,
       to_char(T1.ACT_LEN_MIN,'FM999990.00')||'-'||to_char(T1.ACT_LEN_MAX,'FM999990.00') as LEN,
       T1.CREATE_NAME,
       max(TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS')) CREATE_TIME,
       max(to_char(T1.INSTOCK_TIME,'YYYY-MM-DD')) INSTOCK_TIME,
       T2.STORAGE_NO,
       S.STORAGE_NAME,
       T1.MEMO,
       T1.PIPMEMO,
       T1.JUDGE_STD_CODE,
       T1.JUDGE_STD_NAME,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.OLD_ORDER_NO,
       T1.MAT_STATUS,
       --T1.BAL_YEAR_MONTH,
       to_char(to_date(T1.BAL_YEAR_MONTH,'YYYY-MM'),'yyyy-MM') as BAL_YEAR_MONTH,
       DECODE(T1.PRODUCT_FLAG,'801401','在制品','801402','成品','801403','商品')PRODUCT_FLAG,
       T1.FINISHPRO_MOLD,
       T1.IN_MOLD
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 LEFT JOIN ydm_bs_storage S ON S.STORAGE_NO=T2.STORAGE_NO
 WHERE T1.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T1.BATCH_NO = T2.BATCH_NO
    AND T1.MAT_NO=T2.MAT_NO
  
		]]>
	</query>
	<!-- 
	AND T1.JUDGE_STOVE_NO  || '&' LIKE ('%' || upper(?) || '%')
  AND T1.ORDER_NO || '&' LIKE ('%' || upper(?) || '%')
  AND S.STORAGE_NO || '&' LIKE ('%' || upper(?) || '%')
	AND T1.CREATE_TIME >=
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   AND T1.CREATE_TIME <=
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') -->
       
       <query id = "CorePipeInTemp.queryGroupNo" desc = "查询同炉同批组号">
       SELECT LPAD(NVL(MAX(T.Batch_Groud_No), 0) + 1, 3, 0) BATCH_GROUD_NO
          FROM (SELECT T.BATCH_GROUD_NO
            FROM MAT_ZC_M T
           WHERE T.JUDGE_STOVE_NO = ?
             AND T.BATCH_NO = ?
          UNION ALL
          SELECT T.BATCH_GROUD_NO
            FROM MAT_ZC_BACKUP T
           WHERE T.JUDGE_STOVE_NO = ?
             AND T.BATCH_NO = ?)T
       </query>
       <query id = "CorePipeInTemp.queryInListGroupNo" desc = "查询同炉同批组号(入库表)">
       SELECT T.BATCH_GROUD_NO FROM YDM_ZC_INLIST T WHERE T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? ORDER BY T.BATCH_GROUD_NO DESC
       </query>
       <query id = "CorePipeInTemp.queryGroupNoButress" desc = "查询同炉批组号(位置表)">
       SELECT T.BATCH_GROUD_NO FROM YDM_ZC_BUTTRESS T WHERE T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? ORDER BY T.BATCH_GROUD_NO DESC
       </query>
<query id = "CorePipeInTemp.queryInList" desc = "缴库实绩查询">
<![CDATA[
 SELECT 
       t.INSTOCK_DOC,
       t.JUDGE_STOVE_NO,
       t.BATCH_NO,
       t.PRODUCCODE,
       t.PRODUCNAME,
       t.STD_CODE,
       t.STD_NAME,
       t.STEELCODE,
       t.STEELNAME,
       t.STD_STYLE,
       t.STD_STYLE_DESC,
       t.SPEC_CODE,
       t.SPEC_NAME,
       t.MODEL_CODE,
       t.MODEL_DESC,
       t.ACT_DIMATER,
       t.ACT_HEIGHT,
       to_char(t.ACT_LEN_MIN,'FM999990.00') AS ACT_LEN_MIN,
       to_char(t.ACT_LEN_MAX,'FM999990.00') AS ACT_LEN_MAX,
       to_char(t.ACT_LEN_MIN,'FM999990.00')||'-'||to_char(t.ACT_LEN_MAX,'FM999990.00') as LEN,
       sum(t.ACT_COUNT) as ACT_COUNT,
       to_char(sum(t.ACT_WEIGHT),'FM999999990.000') as ACT_WEIGHT,
       sum(nvl(t.ACT_LEN,0)) as ACT_LEN,
       t.BELONG_CODE,
       t.BELONG_NAME,
       s.STORAGE_NAME,
       t.MEMO,
       t.CREATE_NAME,
       max(to_char(t.INSTOCK_TIME,'YYYY-MM-DD HH24:MI:SS')) as INSTOCK_TIME,
       max(to_char(t.IN_TIME_F,'YYYY-MM-DD')) AS IN_TIME_F,
       to_char(to_date(t.BAL_YEAR_MONTH,'YYYY-MM'),'yyyy-MM') as BAL_YEAR_MONTH,
       --t.BAL_YEAR_MONTH,
       t.ORDER_NO,
     t.ORDER_SEQ,
     t.DELIVERY_NO,
     t.JUDGE_STD_CODE,
     t.JUDGE_STD_NAME,
     t.PLINE_CODE,
     t.PLINE_NAME,
     t.GRADECODE,
     t.GRADENAME,
     DECODE(t.PRODUCT_FLAG,'801401','在制品','801402','成品','801403','商品')PRODUCT_FLAG,
     t.ZB_RCDID,
     d.SALE_AREA_DESC,
       d.create_name AS ordercreatename,
       t.PIPMEMO,
       t.BATCH_GROUD_NO,
       m.basename as GROUPNAME
 FROM YDM_ZC_INLIST t
  left join  ydm_bs_storage s
  on t.STORAGE_NO = s.STORAGE_NO
  left join  SLM_ORDER_HEAD d on 
   t.ord_pk = d.ord_pk
   left join (select m.pline_code,g.basename
  from com_base_pline m, com_base_info g
 where m.group_pay = g.basecode) m on m.pline_code = t.pline_code
 where t.INSTOCK_TYPE_CODE ='800701'
   AND t.HAND_FLAG = '0'
   ]]>
       
</query>
	<query id="CorePipeInTemp.UPDATEINTERFACE2" desc="撤销更改状态">
		<![CDATA[
	    UPDATE tabcxzljk
	    SET cxstu='00'
	    where lcode=? AND  lotno=?  and rcdid = ?
	     
		]]>
	</query>
	<!-- and HGUnit=? and HGWeight=? -->
	<query id = "CorePipeInTemp.updateStoreNo" desc = "修改入库仓库位置">
	UPDATE YDM_ZC_INLIST T SET T.STORAGE_NO = ? WHERE T.MAT_NO = ?
	</query>
	<query id = "CorePipeInTemp.updatePipMemo" desc = "修改入库备注">
	UPDATE MAT_ZC_M T SET T.PIPMEMO = ? WHERE T.MAT_NO = ?
	</query>
	<query id = "CorePipeInTemp.updateCarryOverDate" desc = "修改入库结转年月">
	<![CDATA[
	UPDATE YDM_ZC_INLIST T SET T.BAL_YEAR_MONTH = ?,T.INSTOCK_TIME = to_date(?,'yyyy-MM-dd HH24:mi:ss')  WHERE T.MAT_NO = ?
	]]>
	</query>
	<query id = "CorePipeInTemp.SelectMatNo" desc = "查询所有物料号">
	SELECT T.MAT_NO
  FROM MAT_ZC_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.PRODUCNAME = ?
   --AND T.STD_NAME = ?
   AND T.STEELNAME = ?
   AND T.SPEC_NAME =?
   AND T.MODEL_DESC = ?
   --AND NVL(T.ACT_LEN_MIN,'0') = NVL(?,'0')
   --AND NVL(T.ACT_LEN_MAX,'0') = NVL(?,'0')
   AND T.BATCH_GROUD_NO = ?
   AND T.PRODUCT_FLAG = ?
   AND T.MAT_STATUS IN('80150301', '80150202', '80150204', '80150205')
	</query>
	<query id = "CorePipeInTemp.SelectInList" desc = "在入库表中查找材料号">
	SELECT T.MAT_NO
  FROM YDM_ZC_INLIST T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.PRODUCNAME = ?
   --AND T.STD_NAME = ?
   AND T.STEELNAME = ?
   AND T.SPEC_NAME =?
   AND T.MODEL_DESC = ?
   AND to_number(T.ACT_LEN_MIN) = to_number(?)
   AND to_number(T.ACT_LEN_MAX) = to_number(?)
   AND T.BATCH_GROUD_NO = ?
   AND T.INSTOCK_DOC = ?
	</query>
<query id = "CorePipeInTemp.querySaleOrg" desc = "查询销售组织代码">
SELECT S.SALE_ORG,S.SALE_AREA_NO,S.SALE_AREA_DESC FROM SLM_BASE_SALE_AREA_TYP S WHERE S.DEPARTID = ? 
</query>
<query id = "canclePipein.sqlQuery" desc = "查询物料号">
SELECT MAT_NO FROM MAT_ZC_M  WHERE JUDGE_STOVE_NO=? AND BATCH_NO= ? and BATCH_GROUD_NO = ?
</query>
	<query id="CorePipeInTemp.DELETELOCATION" desc="消除仓库">
		<![CDATA[
	     DELETE FROM YDM_ZC_BUTTRESS
	     WHERE  MAT_NO = ?
		]]>
	</query>

	<query id="CorePipeInTemp.DELETEPIPEDIN" desc="撤销缴库">
		<![CDATA[
	     DELETE FROM MAT_ZC_M
	     WHERE  JUDGE_STOVE_NO=? AND BATCH_NO= ? and BATCH_GROUD_NO = ?
		]]>
	</query>
	<query id="CorePipeInTemp.UpdatePln" desc="撤销销售合同提报">
		<![CDATA[
	     UPDATE PLN_SALEORD
   SET PAYDOWN_NUM  =
       (SELECT T.PAYDOWN_NUM
          FROM PLN_SALEORD T
         WHERE T.ORDER_NO = ?
           AND T.ORDER_SEQ = ?
           AND T.DELIVERY_NO = ?) - ?,
       PAYDOWNWEIGHT =
       (SELECT T.PAYDOWNWEIGHT
          FROM PLN_SALEORD T
         WHERE T.ORDER_NO = ?
           AND T.ORDER_SEQ = ?
           AND T.DELIVERY_NO = ?) -?
 WHERE ORDER_NO = ?
   AND ORDER_SEQ = ?
   AND DELIVERY_NO = ?
		]]>
	</query>

	<query id="CorePipeInTemp.GETPRODUCT" desc="查询品名">
		<![CDATA[
	    SELECT 
	    PRODUC_JX,PRODUCCODE
	    FROM COM_BASE_PRODUCT T
	    WHERE T.VALIDFLAG ='1'
	    ORDER BY PRODUCNAME
		]]>
	</query>

	<query id="CorePipeInTemp.GETSPEC" desc="查询产品规格">
		<![CDATA[
	     SELECT SPEC_NAME,SPEC_CODE
	     FROM COM_BASE_SPEC T
	     WHERE T.VALIDFLAG ='1'
	     ORDER BY SPEC_NAME
		]]>
	</query>

	<query id="CorePipeInTemp.GETSTEEL" desc="查询产品标准">
		<![CDATA[
	     SELECT STEELNAME,STEELCODE
	     FROM COM_BASE_STEEL T
	     WHERE T.VALIDFLAG ='1'
	     ORDER BY STEELNAME
		]]>
	</query>

	<query id="CorePipeInTemp.GETMODEL" desc="查询钢级">
		<![CDATA[
	    SELECT MODEL_DESC,MODEL_CODE
	    FROM COM_BASE_MODEL T
	    WHERE T.VALIDFLAG ='1'
	    ORDER BY MODEL_DESC
		]]>
	</query>
	<query id="CorePipeInTemp.QuerySendPlan" desc="查询该合同是否做计划">
		<![CDATA[
	  SELECT T.SEND_PLAN_NO FROM YDM_ZC_SENDPLAN_C T WHERE T.ORDER_NO=? AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	<query id = "CorePipeInTemp.queryMatNoStatus" desc = "查询物料表状态是否有改变">
	SELECT T1.MAT_STATUS
  FROM YDM_ZC_INLIST T, MAT_ZC_M T1
 WHERE T.MAT_NO = T1.MAT_NO
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
   AND T.INSTOCK_DOC = ?
 GROUP BY T1.MAT_STATUS
	</query>
	<query id="CorePipeInTemp.updatePln1" desc="更改销售合同提报缴库量">
		<![CDATA[
		UPDATE PLN_SALEORD
   SET PAYDOWN_NUM  =
       to_number(nvl((SELECT T.PAYDOWN_NUM
          FROM PLN_SALEORD T
         WHERE T.ORDER_NO = ?
           AND T.ORDER_SEQ = ?
           AND T.DELIVERY_NO = ?),0)) + to_number(?),
       PAYDOWNWEIGHT =
       to_number(nvl((SELECT T.PAYDOWNWEIGHT
          FROM PLN_SALEORD T
         WHERE T.ORDER_NO = ?
           AND T.ORDER_SEQ = ?
           AND T.DELIVERY_NO = ?),0)) + to_number(?)
 WHERE ORDER_NO = ?
   AND ORDER_SEQ = ?
   AND DELIVERY_NO = ?
		]]>
	</query>
	<query id = "CorePipeInTemp.updatePln2" desc = "更改销售合同提报缴库量(冲销)">
	<![CDATA[
	UPDATE PLN_SALEORD
   SET PAYDOWN_NUM  =
       to_number(nvl((SELECT T.PAYDOWN_NUM
          FROM PLN_SALEORD T
         WHERE T.ORDER_NO = ?
           AND T.ORDER_SEQ = ?
           AND T.DELIVERY_NO = ?),0)) - to_number(?),
       PAYDOWNWEIGHT =
       to_number(nvl((SELECT T.PAYDOWNWEIGHT
          FROM PLN_SALEORD T
         WHERE T.ORDER_NO = ?
           AND T.ORDER_SEQ = ?
           AND T.DELIVERY_NO = ?),0)) - to_number(?)
       -- UPDATE_NAME=?,
        --UPDATE_TIME=SYSDATE
 WHERE ORDER_NO = ?
   AND ORDER_SEQ = ?
   AND DELIVERY_NO = ?
   ]]>
	</query>
	<!-- 
	UPDATE pln_saleorder
   SET PAYDOWNWEIGHT = ?, PAYDOWN_NUM=?,UPDATE_NAME = ?, UPDATE_TIME = SYSDATE
 WHERE ORDER_NO = ?
   AND ORDER_SEQ = ?
   AND DELIVERY_NO = ?
   AND PORDERSTATUS IN ('2','3','4') 
	 -->
	<query id="CorePipeInTemp.getUpdateZbMatch" desc="更改质保状态">
		<![CDATA[
	    update tabcxzljk set 
		cxstu=?,
		CXKIND=?,
		CXSTEELLEVEL=?,
		CXGG=?,
		CXTYPEOFTHREAD=?,
		cxupdatedate=getdate()
		where RCDID=? AND LCODE=? AND LOTNO=? and ordername=?
		]]>
	</query>
	
	<query id="CorePipeInTemp.GetOrderByProduct" desc="根据合同查询">
		<![CDATA[
	     SELECT T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO,
       T1.CUST_ALPHA_NO,
       T1.PSC,
       T1.PSC_DESC,
       T1.MSC,
       T1.MSC_DESC,
       T1.PRD_CLS,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.ORDER_SPEC_CODE,
       T1.ORDER_SPEC_DESC,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.DIMATER,
       T1.HEIGHT,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.LEN_NO,
       T1.LEN_DESC,
       T1.LEN_UNIT,
       T1.LEN_MIN,
       T1.LEN_MAX,
       T1.SHRT_LEN_RATO,
       T1.SHORTEST,
       T1.LONG_LEN_RATO,
       T1.LONGEST,
       T1.SHRT_STOVE,
       T1.AVG_LEN_MIN,
       T1.DIFRNC_LEN_MAX,
       T1.SIGL_LEN,
       T1.ORDER_UNIT,
       T1.ORDER_QTY,
       T1.ORD_ENSU_TOTL_LEN,
       T1.PRDCT_WGT,
       T1.CREATE_NAME,
       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T1.UPDATE_NAME,
       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T1.DELETE_NAME,
       TO_CHAR(T1.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T2.CUSTM_ORDER_NO,
       T2.ORDER_TYP,
       T2.ORDER_TYP_DESC,
       T2.PROTCL_NO,
       T2.CUSTOMER_NO,
       T2.CUSTOMER_NM,
       T2.SALE_ORG,
       T2.SALE_ORG_DESC,
       T2.SALE_AREA_NO,
       T2.SALE_AREA_DESC,
       T2.ABRVITION,
       T1.DELVRY_RANGE_MIN,
       T1.DELVRY_RANGE_MAX,
       NVL(T3.DELVRY_QTY,0) AS DELVRY_QTY,
       NVL(T4.PLANWEIGHT,0) AS PLANWEIGHT,
       NVL(T4.PAYDOWNWEIGHT,0) AS PAYDOWNWEIGHT,
       NVL(T4.PAYDOWN_NUM,0) AS PAYDOWN_NUM,
       DECODE(T4.PORDERSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成',
              '6',
              '关闭') AS PORDERSTATUS
  FROM SLM_ORDER_LINE T1
  LEFT JOIN SLM_ORDER_HEAD T2
    ON T1.ORD_PK = T2.ORD_PK
  LEFT JOIN SLM_ORDER_LINE_DELIVERY T3
  on T1.ORD_LN_PK = T3.ORD_LN_PK
  LEFT JOIN PLN_SALEORD T4
    ON  T4.ORD_LN_PK = T1.ORD_LN_PK
   AND T4.ORD_LN_DLY_PK = T3.ORD_LN_DLY_PK
 WHERE T1.VALIDFLAG = '1'
 AND ((T2.CREATE_DEPT IS NOT NULL) OR (T2.CREATE_DEPT IS NULL AND T2.Create_Name is NULL))
   AND T4.PORDERSTATUS IN ('2','3','4')
       AND  T1.PRODUCCODE = ?
       AND  T1.SPEC_CODE  = ?
       AND  T1.STEELCODE  = ?
       AND  T1.MODEL_CODE = ?
   ORDER BY T2.ORDER_NO,
       T1.ORDER_SEQ,
       T3.DELIVERY_NO 
		]]>
	</query>
<query id="CorePipeInTemp.QueryMatNo" desc="自动生存材料号">
		<![CDATA[
	  SELECT T.MAT_NO FROM YDM_ZC_BUTTRESS T WHERE T.JUDGE_STOVE_NO=? AND T.BATCH_NO=? ORDER BY T.MAT_NO DESC
		]]>
	</query>
<query id="CorePipeInTemp.QueryMatNoM" desc="自动生存材料号">
		<![CDATA[
	 SELECT T.MAT_NO FROM MAT_ZC_M T WHERE T.JUDGE_STOVE_NO=? AND T.BATCH_NO=? ORDER BY T.MAT_NO DESC
		]]>
	</query>
	<query id="CorePipeInTemp.QueryMatNoM1" desc="自动生存材料号">
		<![CDATA[
	 SELECT ? || ? ||
       LPAD(NVL(MAX(SUBSTR(T2.MAT_NO, LENGTH(T2.MAT_NO) - 3)), 0) + 1, 4, 0) MAT_NO
  FROM (SELECT MAX(T.MAT_NO)MAT_NO
          FROM MAT_ZC_M T
         WHERE T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
        UNION ALL
        SELECT MAX(T1.MAT_NO)MAT_NO
          FROM YDM_ZC_INLIST T1
         WHERE T1.JUDGE_STOVE_NO = ?
           AND T1.BATCH_NO = ?
         UNION ALL
         SELECT MAX(T3.MAT_NO)MAT_NO
         FROM MAT_ZC_BACKUP T3
         WHERE T3.JUDGE_STOVE_NO = ?
         AND T3.BATCH_NO = ?) T2
		]]>
	</query>	
	<!-- SELECT ?||?||LPAD(NVL(MAX(SUBSTR(T.MAT_NO, LENGTH(T.MAT_NO) - 3)), 0)+1,4,0) MAT_NO FROM MAT_ZC_M T WHERE T.JUDGE_STOVE_NO=? AND T.BATCH_NO=? -->
	<query id = "CorePipeInTemp.queryInListMatNoM" desc = "生成入库表中材料号">
	SELECT T.MAT_NO FROM YDM_ZC_INLIST T WHERE T.JUDGE_STOVE_NO=? AND T.BATCH_NO=? ORDER BY T.MAT_NO DESC
	</query>
	<query id = "CorePipeInTemp.getInListDoc" desc = "查询入库单号">
	select INSTOCK_SQE,INSTOCK_DOC from ydm_zc_inlist 
    where 
    --CREATE_TIME LIKE '%'|| to_date(?,'YYYY/MM/DD')||'%'
    TRUNC(CREATE_TIME) =  to_date(?,'YYYY/MM/DD')
    --AND INSTOCK_TYPE_CODE LIKE '%'|| ? ||'%'
    AND INSTOCK_TYPE_CODE  = ?
    order by INSTOCK_SQE desc
	</query>
	<query id = "CorePipeInTemp.getInListDocNew" desc = "查询入库单号">
	 SELECT ?||TO_CHAR(SYSDATE,'YYMMDD')||LPAD(NVL(MAX(SUBSTR(T.INSTOCK_DOC, LENGTH(T.INSTOCK_DOC) - 4)), 0)+1,5,0) INSTOCK_DOC FROM YDM_ZC_INLIST T
    WHERE 
    TRUNC(T.CREATE_TIME) = TRUNC(SYSDATE)
    AND T.INSTOCK_TYPE_CODE  = ?
    AND T.BELONG_CODE IN ('100101', '100103', '100102','100105')
	</query>
	
	
	<query id = "CorePipeInTemp.getInListDoc1" desc = "生成入库流水">
	SELECT ?||LPAD(NVL(MAX(SUBSTR(T.INSTOCK_SQE, LENGTH(T.INSTOCK_SQE) - 4)), 0)+1,5,0)INSTOCK_SQE FROM YDM_ZC_INLIST T
    WHERE 
    TRUNC(T.CREATE_TIME) =  TRUNC(SYSDATE)
    AND T.INSTOCK_DOC = ?
	</query>
	<query id = "CorePipeInTemp.insertInList" desc = "对入库表进行插入">
	 INSERT INTO YDM_ZC_INLIST
  (MANAGEMENT_NO,
   MANAGEMENT_NAME,
   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,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   STORAGE_NO,
   
   MEMO,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   ORDER_NO,
     ORDER_SEQ,
     DELIVERY_NO,
     ORD_PK,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     PRODUCT_FLAG,
     MAT_STATUS,
     INSTOCK_TIME,ZB_RCDID,ACT_LEN,DEPARTMENT_CODE,DEPARTMENT_DESC,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,SUPPLY_UNIT_CODE,SUPPLY_UNIT)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,'801403','80150301',to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,?,?,to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,?,'120501','天津钢管制造有限公司')

	</query>
	
	<query id = "CorePipeInTemp.insertInList1" desc = "对入库表进行插入1">
	 INSERT INTO YDM_ZC_INLIST
  (MANAGEMENT_NO,
   MANAGEMENT_NAME,
   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,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   STORAGE_NO,
   
   MEMO,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
     PRODUCT_FLAG,
     MAT_STATUS,
     INSTOCK_TIME,ZB_RCDID,ACT_LEN,DEPARTMENT_CODE,DEPARTMENT_DESC,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,SUPPLY_UNIT_CODE,SUPPLY_UNIT)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,'801402','80150205',to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,?,?,to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,?,'120501','天津钢管制造有限公司')

	</query>
	
	<query id = "CorePipeInTemp.redInsertInList" desc = "红冲插入入库表">
	INSERT INTO YDM_ZC_INLIST
  (MANAGEMENT_NO,
   MANAGEMENT_NAME,
   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,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   STORAGE_NO,
   
   MEMO,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   ORDER_NO,
     ORDER_SEQ,
     DELIVERY_NO,
     ORD_PK,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     PRODUCT_FLAG,
     MAT_STATUS,
     INSTOCK_TIME,ZB_RCDID,ACT_LEN,DEPARTMENT_CODE,DEPARTMENT_DESC,JUDGE_STD_NAME,PLINE_CODE,PLINE_NAME,GRADECODE,GRADENAME,BAL_YEAR_MONTH,IN_TIME_F,SUPPLY_UNIT_CODE,SUPPLY_UNIT)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,to_date(?,'YYYY-MM-DD HH24:MI:SS'),?,?,?,?,?,?,?,?,?,?,to_date(?,'YYYY-MM-DD HH24:MI:SS'),'120501','天津钢管制造有限公司')
	</query>
	<query id = "CorePipeInTemp.DeleteInList" desc ="删除入库表信息">
	DELETE FROM YDM_ZC_INLIST T WHERE T.INSTOCK_DOC =  ? and T.JUDGE_STOVE_NO = ? and t.BATCH_NO = ? and t.BATCH_GROUD_NO = ?
	</query>
	
	<query id = "CorePipeInTemp.deleteMat" desc = "删除物料表">
	
	<![CDATA[
	delete from mat_zc_m t where t.MAT_NO = ?
	]]>
	</query>
	<!-- DELETE FROM  mat_zc_m S
WHERE S.MAT_NO = (SELECT MIN(T.MAT_NO)MAT_NO FROM MAT_ZC_M T ,YDM_ZC_BUTTRESS D WHERE  T.MAT_NO = D.MAT_NO AND T.PRODUCT_FLAG = '801403' AND T.ORDER_NO = ? AND T.ORDER_SEQ = ? AND T.ORDER_SEQ_NO = ?) -->
	<query id = "CorePipeInTemp.getSumWgt" desc = "查询总支数总重量">
	SELECT SUM(T.ACT_COUNT)ACT_COUNT,SUM(T.ACT_WEIGHT) ACT_WEIGHT FROM YDM_ZC_INLIST T WHERE T.INSTOCK_DOC = ?
	</query>
	<query id = "CorePipeInTemp.getFactory" desc = "获取产销产线">
	SELECT T.PLINE_NAME,T.PLINE_CODE FROM LIN_BASE_PLINE T WHERE T.ZB_PLINENAME = ?
	</query>
	<query id = "CorePipeInTemp.getGrade" desc = "获取产销钢种">
	SELECT T.GRADENAME,T.GRADECODE FROM LIN_BASE_GRADE T WHERE T.ZB_GRADENAME = ?
	</query>
	
	<query id = "CorePipeInTemp.getOrderWgt" desc = "查询总量">
	<![CDATA[
	SELECT SUM(NVL(T.ORDERWEIGHT, 0)) AS ORDERWEIGHT,
       SUM(NVL(T.PAYDOWNWEIGHT, 0)) AS PAYDOWNWEIGHT,
       SUM(NVL(T.ORDER_QTY, 0)) AS ORDER_QTY
  FROM PLN_SALEORD T
 WHERE T.ORDER_NO = ?
 ]]>
	</query>
	<query id = "CorePipeInTemp.getDiamter" desc = "查找外径壁厚">
	SELECT T.DIMATER,T.HEIGHT FROM COM_BASE_SPEC T WHERE T.SPEC_CODE = ?
	</query>
	<query id = "CorePipeInTemp.getSqlServerData" desc = "根据rccid查询质保数据">
	<![CDATA[
	SELECT T.ORDERNO,
       T.RCDID,
       T.FACTORY,
       T.KIND,
       T.LCODE,
       T.LOTNO,
       T.STEELLEVEL,
       T.STEELGRADE,   
       T.SPEC,
       T.THICKNESS,
       T.GG,
       T.TYPEOFTHREAD,
       T.HGUNIT,
       T.HGM,
       T.HGWEIGHT,
       T.ORDERNAME,
       T.LENG,
       T.STANDARD,
       T.TESTIDEA,
       CONVERT(varchar(100), T.TESTDATE, 23) AS TESTDATE,
       T.DESTINATION, 
       CASE T.CXSTU when 20 then '已缴库' else '未缴库' end as CXSTU ,
       CASE T.CXSTU when 01 then '物料匹配' 
       --WHEN 02 THEN '合同号匹配，物料不匹配'
      -- WHEN 03 THEN '合同号不匹配，物料匹配'
      -- WHEN 04 THEN '合同号不匹配，物料不匹配'
       WHEN 02 THEN '物料不匹配'
       end as CXSTUPP ,
       T.CXKIND,
       T.CXSTEELLEVEL,
       T.CXSTEELGRADE,
       T.CXTYPEOFTHREAD,
       T.CXSTANDARD,
       T.CXGG,
       T.STDSTYLE,
       T.DEPARTM,
       CONVERT(varchar(100),T.CXUPDATEDATE, 20) AS CXUPDATEDATE
  FROM tabcxzljk T  where 1 = 1   
		]]>
	</query>
	<query id = "CorePipeInTemp.getInListData" desc = "根据炉批查找缴库数据">
	<![CDATA[
 SELECT 
       t.INSTOCK_DOC,
       t.JUDGE_STOVE_NO,
       t.BATCH_NO,
       t.BATCH_GROUD_NO,
       t.PRODUCCODE,
       t.PRODUCNAME,
       t.STD_CODE,
       t.STD_NAME,
       t.STEELCODE,
       t.STEELNAME,
       t.STD_STYLE,
       t.STD_STYLE_DESC,
       t.SPEC_CODE,
       t.SPEC_NAME,
       t.MODEL_CODE,
       t.MODEL_DESC,
       t.ACT_DIMATER,
       t.ACT_HEIGHT,
       to_char(t.ACT_LEN_MIN,'FM999990.00') AS ACT_LEN_MIN,
       to_char(t.ACT_LEN_MAX,'FM999990.00') AS ACT_LEN_MAX,
       to_char(t.ACT_LEN_MIN,'FM999990.00')||'-'||to_char(t.ACT_LEN_MAX,'FM999990.00') as LEN,
       sum(t.ACT_COUNT) as ACT_COUNT,
       to_char(sum(t.ACT_WEIGHT),'FM999999990.000') as ACT_WEIGHT,
       sum(nvl(t.ACT_LEN,0)) as ACT_LEN,
       t.BELONG_CODE,
       t.BELONG_NAME,
       s.STORAGE_NAME,
       t.MEMO,
       t.CREATE_NAME,
       max(to_char(t.INSTOCK_TIME,'YYYY-MM-DD HH24:MI:SS')) as INSTOCK_TIME,
       max(to_char(t.IN_TIME_F,'YYYY-MM-DD HH24:MI:SS')) AS IN_TIME_F,
       t.BAL_YEAR_MONTH,
       t.ORDER_NO,
     t.ORDER_SEQ,
     t.DELIVERY_NO,
     t.JUDGE_STD_CODE,
     t.JUDGE_STD_NAME,
     t.PLINE_CODE,
     t.PLINE_NAME,
     t.GRADECODE,
     t.GRADENAME,
     t.PRODUCT_FLAG,
     t.ZB_RCDID,
     d.SALE_AREA_DESC,
       d.create_name AS ordercreatename,
       t.ORD_PK,
       t.ORD_LN_PK,
       t.ORD_LN_DLY_PK,
       t.STORAGE_NO
 FROM YDM_ZC_INLIST t
  left join  ydm_bs_storage s
  on t.STORAGE_NO = s.STORAGE_NO
  left join  SLM_ORDER_HEAD d on 
   t.ord_pk = d.ord_pk
 where t.INSTOCK_TYPE_CODE = '800701'
   AND t.JUDGE_STOVE_NO =?
   AND t.BATCH_NO = ?
   group by t.JUDGE_STOVE_NO,
          t.BATCH_NO,
          t.BATCH_GROUD_NO,
          t.INSTOCK_DOC,
          t.PRODUCCODE,
          t.PRODUCNAME,
          t.STD_CODE,
          t.STD_NAME,
          t.STEELCODE,
          t.STEELNAME,
          t.STD_STYLE,
          t.STD_STYLE_DESC,
          t.SPEC_CODE,
          t.SPEC_NAME,
          t.JUDGE_STD_CODE,
          t.JUDGE_STD_NAME,
          t.GRADECODE,
          t.GRADENAME,
          t.BAL_YEAR_MONTH,
          t.MODEL_DESC,
          t.ACT_DIMATER,
          t.ACT_HEIGHT,
          t.ACT_LEN_MIN,
          t.ACT_LEN_MAX,
          t.BELONG_CODE,
          t.BELONG_NAME,
          s.STORAGE_NAME,
          t.MEMO,
          t.CREATE_NAME,
          t.ORDER_NO,
          t.ORDER_SEQ,
          t.DELIVERY_NO,
          t.MODEL_CODE,
          t.PRODUCT_FLAG,
          t.ZB_RCDID,
          t.PLINE_CODE,
          t.PLINE_NAME,
          d.SALE_AREA_DESC,
          d.create_name,
          t.ORD_PK,
       t.ORD_LN_PK,
       t.ORD_LN_DLY_PK,
       t.STORAGE_NO
 order by t.instock_doc desc
   ]]>
	</query>
	<query id = "CorePipeInTemp.queryMatCount" desc = "根据炉批组查找支数重量">
	SELECT SUM(NVL(T.ACT_COUNT,0)) ACOUNT, SUM(NVL(T.ACT_WEIGHT,0)) AWEIGHT,SUM(NVL(T.ACT_LEN,0)) LEN
  FROM MAT_ZC_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   --AND T.BATCH_GROUD_NO = ?
   --AND T.PRODUCT_FLAG = ?
	</query>
	<query id = "CorePipeInTemp.queryInListCountWgt" desc = "查询出入库的负支数重量">
	<![CDATA[
	SELECT SUM(NVL(T.ACT_COUNT,0)) ACOUNT, SUM(NVL(T.ACT_WEIGHT,0)) AWEIGHT,SUM(NVL(T.ACT_LEN,0)) LEN
  FROM YDM_ZC_INLIST T
 WHERE T.JUDGE_STOVE_NO = ?
  AND T.BATCH_NO = ?
  AND T.BATCH_GROUD_NO = ?
  AND T.PRODUCT_FLAG = ?
  --AND T.ACT_COUNT<'0'
  --AND T.ACT_WEIGHT<'0'
  ]]>
	</query>
	<query id = "CorePipeInTemp.getInListMatNo" desc = "查找材料号(红冲)">
	   SELECT T.MAT_NO
     FROM YDM_ZC_INLIST T
    WHERE T.JUDGE_STOVE_NO = ?
      AND T.BATCH_NO = ?
      AND T.BATCH_GROUD_NO = ?
      AND T.PRODUCT_FLAG = ?
      order by T.MAT_NO
	</query>
	<query id = "CorePipeInTemp.updateMatWgtLen" desc = "修改材料表重量长度">
	UPDATE MAT_ZC_M T SET T.ACT_WEIGHT = ?,T.ACT_LEN = ? WHERE T.MAT_NO = ?
	</query>
	<query id = "CorePipeInTemp.updateInListWgtLen" desc = "修改入库表重量长度">
	UPDATE YDM_ZC_INLIST T SET T.ACT_WEIGHT = ?,T.ACT_LEN = ? WHERE T.MAT_NO = ?
	</query>
	<query id = "CorePipeInTemp.QueryInList" desc = "根据入库单号查询入库表物料号">
	SELECT
	PRODUCT_FLAG,
       MAT_STATUS,
       ZB_RCDID,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       TO_CHAR(IN_TIME_F, 'YYYY-MM-DD HH24:MI:SS') IN_TIME_F,
       BAL_YEAR_MONTH,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       INSTOCK_SQE,
       INSTOCK_DOC,
       INSTOCK_TYPE_CODE,
       INSTOCK_TYPE_NAME,
       INSTOCK_BAR_CODE,
       ICCAR_NO,
       VEHICLE_NO,
       MAT_NO,
       LOT_NO,
       STOVE_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,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       TO_CHAR(RPO_TIME, 'YYYY-MM-DD HH24:MI:SS') RPO_TIME,
       PRO_BC,
       PRO_BZ,
       TO_CHAR(INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       IN_BC,
       IN_BZ,
       BAR_CODE,
       HAND_FLAG,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME 
	 FROM YDM_ZC_INLIST T WHERE T.INSTOCK_DOC = ? order by T.MAT_NO desc
	</query>
<query id="CorePipeInTemp.REDINSERTMAT" 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
     ) VALUES  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
             ?,?,?,?,?,?,?,?,?,?,?,?,
             TO_NUMBER(?),ROUND(TO_NUMBER(?),4),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
             ?,?,?,?,?,?,TO_NUMBER(?),?,?,?,?,?,?)
		]]>
	</query>
	<query id = "CorePipeInTemp.REDINSERTMAT1" 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
     ) VALUES  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
             ?,?,?,?,?,?,?,?,
             TO_NUMBER(?),ROUND(TO_NUMBER(?),4),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
             ?,?,?,?,?,?,TO_NUMBER(?),?,?,?,?,?,?)
		]]>
	</query>
	<query id = "CorePipeInTemp.ReddeleteInList" desc = "删除入库信息(红冲)">
	DELETE FROM YDM_ZC_INLIST T WHERE T.MAT_NO = ? AND T.INSTOCK_DOC = ?
	</query>
	<query id = "CorePipeInTemp.queryCancelInListCountWgt" desc = "查询撤销单号下商品总量">
	SELECT SUM(NVL(T.ACT_COUNT,0)) ACOUNT, SUM(NVL(T.ACT_WEIGHT,0)) AWEIGHT,SUM(NVL(T.ACT_LEN,0)) LEN,MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK
  FROM YDM_ZC_INLIST T
 WHERE T.INSTOCK_DOC = ?
 AND T.Product_Flag = '801403'
	</query>
	<query id = "CorePipeInTemp.updateProcess" desc = "缴库写进程表">
	UPDATE PROCESS_ORDER_M T
   SET T.PAY_NUM = TO_NUMBER(NVL(T.PAY_NUM,0)) + TO_NUMBER(?),
       T.PAY_WGT = TO_NUMBER(NVL(T.PAY_WGT,0)) + TO_NUMBER(?),
       T.PAY_LEN = TO_NUMBER(NVL(T.PAY_LEN,0)) + TO_NUMBER(?)
   WHERE ORD_LN_DLY_PK = ?
	</query>
	<query id = "CorePipeInTemp.updateRedProcess" desc = "缴库写进程表(红冲)">
	UPDATE PROCESS_ORDER_M T
   SET T.NEG_PAY_NUM = TO_NUMBER(NVL(T.NEG_PAY_NUM,0)) + TO_NUMBER(?),
       T.NEG_PAY_WGT = TO_NUMBER(NVL(T.NEG_PAY_WGT,0)) + TO_NUMBER(?),
       T.NEG_PAY_LEN = TO_NUMBER(NVL(T.NEG_PAY_LEN,0)) + TO_NUMBER(?)
   WHERE ORD_LN_DLY_PK = ?
	</query>
	<query id = "CorePipeInTemp.updateCancelProcess" desc = "撤销缴库写进程表">
	UPDATE PROCESS_ORDER_M T
   SET T.PAY_NUM = TO_NUMBER(NVL(T.PAY_NUM,0)) - TO_NUMBER(?),
       T.PAY_WGT = TO_NUMBER(NVL(T.PAY_WGT,0)) - TO_NUMBER(?),
       T.PAY_LEN = TO_NUMBER(NVL(T.PAY_LEN,0)) - TO_NUMBER(?)
   WHERE ORD_LN_DLY_PK = ?
	</query>
	<query id = "CorePipeInTemp.updateCancelRedProcess" desc = "撤销红冲写进程表">
	UPDATE PROCESS_ORDER_M T
   SET T.NEG_PAY_NUM = TO_NUMBER(NVL(T.NEG_PAY_NUM,0)) - TO_NUMBER(?),
       T.NEG_PAY_WGT = TO_NUMBER(NVL(T.NEG_PAY_WGT,0)) - TO_NUMBER(?),
       T.NEG_PAY_LEN = TO_NUMBER(NVL(T.NEG_PAY_LEN,0)) - TO_NUMBER(?)
   WHERE ORD_LN_DLY_PK = ?
	</query>
	<query id = "CorePipeInTemp.updateStausZB" desc = "修改质保状态">
	<![CDATA[
	    UPDATE tabcxzljk
	    SET cxstu='20'
	    where rcdid = ?
		]]>
	</query>
	<query id = "CorePipeInTemp.getLockFlag" desc = "查询是否封锁">
	<![CDATA[
	SELECT COUNT(1) ACOUNT
FROM MAT_ZC_M T,YDM_ZC_BUTTRESS S
WHERE T.MAT_NO = S.MAT_NO
 AND T.JUDGE_STOVE_NO = ?
 AND T.BATCH_NO = ?
 AND T.BATCH_GROUD_NO = ?
 AND T.LOCK_FLAG <>'0'
	]]>
	</query>
	<query id = "CorePipeInTemp.updateButessStoreNo" desc = "修改位置表库存地点">
	UPDATE YDM_ZC_BUTTRESS T SET T.STORAGE_NO = ?,T.LOCATION_NO = ? WHERE T.MAT_NO = ?
	</query>
	<query id = "CorePipeInTemp.SelectMaterialCode" desc = "查询物料码是否存在">
	SELECT COUNT(1)ACOUNT FROM SLM_BASE_MATERIAL T WHERE T.FIRST_PRDC = '1' AND T.MATERIAL_NO = ?
	</query>
	<query id = "CorePipeInTemp.updateMaterial" desc = "修改物料码状态">
	UPDATE SLM_BASE_MATERIAL T SET T.FIRST_PRDC = '0' WHERE T.MATERIAL_NO = ?
	</query>
	<query id = "CorePipeInTemp.doQueryOrderType" desc = "查询合同类型">
	SELECT T.ORDER_TYP FROM SLM_ORDER_HEAD T WHERE T.VALIDFLAG = '1' AND T.ORDER_NO = ? 
	</query>
	<query id = "CorePipeInTemp.doQueryProFlag" desc = "查询该入库单下是否存在商品">
	SELECT NVL(COUNT(1),0)ACOUNT FROM YDM_ZC_INLIST T WHERE T.INSTOCK_DOC = ? AND T.JUDGE_STOVE_NO = ? AND T.BATCH_NO = ? AND T.BATCH_GROUD_NO = ? AND T.PRODUCT_FLAG = '801403'
	</query>
	<query id = "CorePipeInTemp.getFinishedProduct" desc = "查询成品类别">
	SELECT T.BASENAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '8018' ORDER BY BASECODE ASC
	</query>
	<query id = "CorePipeInTemp.getFinishedProduct1" desc = "查询成品区分">
	--SELECT T.BASENAME,T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '8017' AND T.BASECODE NOT IN ('801701','801702')ORDER BY BASECODE ASC
	</query>
	<query id = "CorePipeInTemp.updateFinishedProduct" desc = "修改成品区分">
	DECLARE
BEGIN
  FOR MYROW IN (SELECT T.MAT_NO
                  FROM MAT_ZC_M T,YDM_ZC_BUTTRESS S
                 WHERE T.MAT_NO = S.MAT_NO
                   AND T.JUDGE_STOVE_NO = ?
                   AND T.BATCH_NO = ?
                   AND T.BATCH_GROUD_NO = ?
                   AND T.PRODUCT_FLAG = ?
                   AND NVL(T.PIPMEMO, '/') = NVL(?, '/')
                   AND T.IN_MOLD = ?
                 ORDER BY T.MAT_NO ASC) LOOP
    UPDATE MAT_ZC_M T
       SET T.FINISHPRO_MOLD = ?
     WHERE T.MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;
	</query>
	<query id = "CorePipeInTemp.getRealTimeStore" desc = "获取实时期末库存">
	DECLARE
BEGIN
  FOR MYROW IN (SELECT JUDGE_STOVE_NO,
                       BATCH_NO,
                       BATCH_GROUD_NO,
                       SUM(ACT_WEIGHT)ACT_WEIGHT FROM
               (SELECT F.JUDGE_STOVE_NO,
                       F.BATCH_NO,
                       F.BATCH_GROUD_NO,
                       SUM(F.ACT_COUNT) ACT_COUNT,
                       SUM(F.ACT_WEIGHT) ACT_WEIGHT
                  FROM MAT_ZC_M F, YDM_ZC_BUTTRESS G
                 WHERE F.MAT_NO = G.MAT_NO
                 AND F.PRODUCT_FLAG = '801402'
                 #CONDITIONS#
                 GROUP BY F.JUDGE_STOVE_NO, F.BATCH_NO, F.BATCH_GROUD_NO
                 UNION ALL
                 SELECT F.JUDGE_STOVE_NO,
                       F.BATCH_NO,
                       F.BATCH_GROUD_NO,
                       SUM(F.ACT_COUNT) ACT_COUNT,
                       SUM(F.ACT_WEIGHT) ACT_WEIGHT
                  FROM MAT_ZC_M F, YDM_ZC_BUTTRESS G
                 WHERE F.MAT_NO = G.MAT_NO
                 AND F.PRODUCT_FLAG = '801403'
                 #CONDITIONS#
                 GROUP BY F.JUDGE_STOVE_NO, F.BATCH_NO, F.BATCH_GROUD_NO)
                 GROUP BY JUDGE_STOVE_NO,BATCH_NO,BATCH_GROUD_NO) LOOP
                 UPDATE YDM_ZC_INITIAL T
   SET T.ACT_WEIGHT_S = MYROW.ACT_WEIGHT
 WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
   AND T.BATCH_NO = MYROW.BATCH_NO
   AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
   AND T.BAL_YEAR_MONTH = TO_CHAR(SYSDATE, 'YYYYMM');
  END LOOP;
  DELETE FROM MAT_ZC_INITIAL T1 WHERE T1.BAL_YEAR_MONTH = ? #CONDITIONS1#; 
  FOR MYROW1 IN (select T1.ORDER_NO || '/' || T1.ORDER_SEQ AS SORDER,
       T1.OLD_ORDER_NO || '/' || T1.OLD_ORDER_SEQ AS OLDORDER,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.STEELCODE,
       T1.SPEC_CODE,
       T1.MODEL_CODE,
       T1.STD_CODE,
       T1.GRADECODE,
       T1.STEELNAME,
       T1.SPEC_NAME,
       T1.MODEL_DESC,
       T1.STD_NAME,
       T1.JUDGE_STD_NAME,
       T1.GRADENAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       d.SALE_AREA_DESC,
       d.CREATE_NAME AS ORDERCREATENAME,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       S.STORAGE_NAME,
       d.CUSTOMER_NM,
       g.RECEIV_NM,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.MEMO,
       T1.PIPMEMO,
       to_char(T1.INSTOCK_TIME, 'YYYY-MM-DD') as INSTOCK_TIME,
       DECODE(g.TRANSIT_TYP,
              '110501',
              '汽运',
              '110502',
              '铁运',
              '110503',
              '船运',
              '110504',
              '航运') TRANSIT_TYP,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T1.IN_MOLD AND ROWNUM = 1) IN_MOLD,
       DECODE(t1.FINISHPRO_MOLD,
              '801801',
              '合同变更',
              '801802',
              '超交货期',
              '801803',
              '超载甩量',
              '801804',
              '成品备库',
              '801805',
              '质量异议待处理') FINISHPRO_MOLD,
       sum(T1.ACT_COUNT) as ACT_COUNT,
       sum(T1.ACT_WEIGHT) as ACT_WEIGHT,
       sum(T1.ACT_LEN) as ACT_LEN
  FROM MAT_ZC_M                T1,
       YDM_ZC_BUTTRESS         T2,
       ydm_bs_storage          S,
       SLM_ORDER_HEAD          D,
       slm_order_line_delivery G
 WHERE T1.MAT_NO = T2.MAT_NO
   AND T2.STORAGE_NO = S.STORAGE_NO(+)
   AND T1.Ord_Pk = d.ord_pk(+)
   AND T1.Ord_Ln_Dly_Pk = g.ord_ln_dly_pk(+)
   and T1.product_flag = '801403'  
   #CONDITIONS1#
 group by T1.ORDER_NO || '/' || T1.ORDER_SEQ,
          T1.OLD_ORDER_NO || '/' || T1.OLD_ORDER_SEQ,
          T1.ORDER_NO,
          T1.ORDER_SEQ,
          T1.ORDER_SEQ_NO,
          T1.JUDGE_STOVE_NO,
          T1.BATCH_NO,
          T1.BATCH_GROUD_NO,
          T1.PRODUCCODE,
          T1.PRODUCNAME,
          T1.STD_STYLE,
          T1.STD_STYLE_DESC,
          T1.STEELCODE,
          T1.SPEC_CODE,
          T1.MODEL_CODE,
          T1.STD_CODE,
          T1.GRADECODE,
          T1.STEELNAME,
          T1.SPEC_NAME,
          T1.MODEL_DESC,
          T1.STD_NAME,
          T1.JUDGE_STD_NAME,
          T1.GRADENAME,
          T1.ACT_DIMATER,
          T1.ACT_HEIGHT,
          T1.ACT_LEN_MIN,
          T1.ACT_LEN_MAX,
          T1.BELONG_CODE,
          T1.BELONG_NAME,
          d.SALE_AREA_DESC,
          d.CREATE_NAME,
          T1.PLINE_CODE,
          T1.PLINE_NAME,
          S.STORAGE_NAME,
          d.CUSTOMER_NM,
          g.RECEIV_NM,
          T1.PRODUCT_FLAG,
          T1.MAT_STATUS,
          T1.MEMO,
          T1.PIPMEMO,
          to_char(T1.INSTOCK_TIME, 'YYYY-MM-DD'),
          g.TRANSIT_TYP,
          t1.IN_MOLD,
          t1.FINISHPRO_MOLD
union all
select T1.ORDER_NO || '/' || T1.ORDER_SEQ AS SORDER,
       T1.OLD_ORDER_NO || '/' || T1.OLD_ORDER_SEQ AS OLDORDER,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.STEELCODE,
       T1.SPEC_CODE,
       T1.MODEL_CODE,
       T1.STD_CODE,
       T1.GRADECODE,
       T1.STEELNAME,
       T1.SPEC_NAME,
       T1.MODEL_DESC,
       T1.STD_NAME,
       T1.JUDGE_STD_NAME,
       T1.GRADENAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.BELONG_CODE,
       T1.BELONG_NAME,
       d.SALE_AREA_DESC,
       d.CREATE_NAME AS ORDERCREATENAME,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       S.STORAGE_NAME,
       d.CUSTOMER_NM,
       g.RECEIV_NM,
       T1.PRODUCT_FLAG,
       T1.MAT_STATUS,
       T1.MEMO,
       T1.PIPMEMO,
       to_char(T1.INSTOCK_TIME, 'YYYY-MM-DD') as INSTOCK_TIME,
       DECODE(g.TRANSIT_TYP,
              '110501',
              '汽运',
              '110502',
              '铁运',
              '110503',
              '船运',
              '110504',
              '航运') TRANSIT_TYP,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T1.IN_MOLD AND ROWNUM = 1) IN_MOLD,
       DECODE(t1.FINISHPRO_MOLD,
              '801801',
              '合同变更',
              '801802',
              '超交货期',
              '801803',
              '超载甩量',
              '801804',
              '成品备库',
              '801805',
              '质量异议待处理') FINISHPRO_MOLD,
       sum(T1.ACT_COUNT) as ACT_COUNT,
       sum(T1.ACT_WEIGHT) as ACT_WEIGHT,
       sum(T1.ACT_LEN) as ACT_LEN
  FROM MAT_ZC_M T1,
       YDM_ZC_BUTTRESS T2,
       ydm_bs_storage S,
       (select e.SALE_AREA_DESC, e.CREATE_NAME, e.CUSTOMER_NM, e.order_no
          from SLM_ORDER_HEAD e
         where e.validflag = '1') d,
       slm_order_line_delivery g
 WHERE t1.mat_no = t2.mat_no
   and t2.STORAGE_NO = S.STORAGE_NO(+)
   and substr(T1.OLD_ORDER_NO,
              1,
              decode(instr(T1.OLD_ORDER_NO, '/'),
                     0,
                     length(T1.OLD_ORDER_NO),
                     instr(T1.OLD_ORDER_NO, '/') - 1)) = d.order_no(+)
   and T1.Ord_Ln_Dly_Pk = g.ord_ln_dly_pk(+)
   and T1.product_flag = '801402'  
   #CONDITIONS1#
 group by T1.ORDER_NO || '/' || T1.ORDER_SEQ,
          T1.OLD_ORDER_NO || '/' || T1.OLD_ORDER_SEQ,
          T1.ORDER_NO,
          T1.ORDER_SEQ,
          T1.ORDER_SEQ_NO,
          T1.JUDGE_STOVE_NO,
          T1.BATCH_NO,
          T1.BATCH_GROUD_NO,
          T1.PRODUCCODE,
          T1.PRODUCNAME,
          T1.STD_STYLE,
          T1.STD_STYLE_DESC,
          T1.STEELCODE,
          T1.SPEC_CODE,
          T1.MODEL_CODE,
          T1.STD_CODE,
          T1.GRADECODE,
          T1.STEELNAME,
          T1.SPEC_NAME,
          T1.MODEL_DESC,
          T1.STD_NAME,
          T1.JUDGE_STD_NAME,
          T1.GRADENAME,
          T1.ACT_DIMATER,
          T1.ACT_HEIGHT,
          T1.ACT_LEN_MIN,
          T1.ACT_LEN_MAX,
          T1.BELONG_CODE,
          T1.BELONG_NAME,
          d.SALE_AREA_DESC,
          d.CREATE_NAME,
          T1.PLINE_CODE,
          T1.PLINE_NAME,
          S.STORAGE_NAME,
          d.CUSTOMER_NM,
          g.RECEIV_NM,
          T1.PRODUCT_FLAG,
          T1.MAT_STATUS,
          T1.MEMO,
          T1.PIPMEMO,
          to_char(T1.INSTOCK_TIME, 'YYYY-MM-DD'),
          g.TRANSIT_TYP,
          t1.IN_MOLD,
          t1.FINISHPRO_MOLD
)LOOP
   INSERT INTO MAT_ZC_INITIAL(
        SORDER,
        OLDORDER,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        PRODUCCODE,
        PRODUCNAME,
        STD_STYLE,
        STD_STYLE_DESC,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_CODE,
        STD_NAME,
        JUDGE_STD_NAME,
        GRADECODE,
        GRADENAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        BELONG_CODE,
        BELONG_NAME,
        SALE_AREA_DESC,
        ORDERCREATENAME,
        PLINE_CODE,
        PLINE_NAME,
        STORAGE_NAME,
        CUSTOMER_NM,
        RECEIV_NM,
        PRODUCT_FLAG,
        MAT_STATUS,
        MEMO,
        PIPMEMO,
        TRANSIT_TYP,
        ACT_LEN,
        FINISHPRO_MOLD,
        IN_MOLD,
        INSTOCK_TIME)
 VALUES( 
        MYROW1.SORDER,
        MYROW1.OLDORDER,
        MYROW1.ORDER_NO,
        MYROW1.ORDER_SEQ,
        MYROW1.ORDER_SEQ_NO,
        MYROW1.JUDGE_STOVE_NO,
        MYROW1.BATCH_NO,
        MYROW1.BATCH_GROUD_NO,
        MYROW1.PRODUCCODE,
        MYROW1.PRODUCNAME,
        MYROW1.STD_STYLE,
        MYROW1.STD_STYLE_DESC,
        MYROW1.STEELCODE,
        MYROW1.STEELNAME,
        MYROW1.SPEC_CODE,
        MYROW1.SPEC_NAME,
        MYROW1.MODEL_CODE,
        MYROW1.MODEL_DESC,
        MYROW1.STD_CODE,
        MYROW1.STD_NAME,
        MYROW1.JUDGE_STD_NAME,
        MYROW1.GRADECODE,
        MYROW1.GRADENAME,
        MYROW1.ACT_DIMATER,
        MYROW1.ACT_HEIGHT,
        MYROW1.ACT_LEN_MIN,
        MYROW1.ACT_LEN_MAX,
        MYROW1.ACT_COUNT,
        MYROW1.ACT_WEIGHT,
        MYROW1.BELONG_CODE,
        MYROW1.BELONG_NAME,
        MYROW1.SALE_AREA_DESC,
        MYROW1.ORDERCREATENAME,
        MYROW1.PLINE_CODE,
        MYROW1.PLINE_NAME,
        MYROW1.STORAGE_NAME,
        MYROW1.CUSTOMER_NM,
        MYROW1.RECEIV_NM,
        MYROW1.PRODUCT_FLAG,
        MYROW1.MAT_STATUS,
        MYROW1.MEMO,
        MYROW1.PIPMEMO,
        MYROW1.TRANSIT_TYP,
        MYROW1.ACT_LEN,
        MYROW1.FINISHPRO_MOLD,
        MYROW1.IN_MOLD,
        TO_DATE(MYROW1.INSTOCK_TIME,'YYYY-MM-DD'));
  END LOOP;
END;
	</query>
	<query id = "CorePipeInTemp.selectNowInial" desc = "查询是否有期初数据">
	SELECT COUNT(1) FROM YDM_ZC_INITIAL T WHERE T.BAL_YEAR_MONTH = ?
	</query>
	</queryMap>