<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="委托管理">
	<query id="frmEntrust.doQueryOffline" desc="产线">
		<![CDATA[
		  select*from (SELECT M.*,
		   DECODE(M.PROCESS,
               'D',
               (SELECT PRIORITY
                  FROM PLN_ORDER_ZG_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'E',
               (SELECT PRIORITY
                  FROM PLN_ORDER_DBK_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'F',
               (SELECT PRIORITY
                  FROM PLN_ORDER_RCL_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'G',
               (SELECT PRIORITY
                  FROM PLN_ORDER_JGX_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'H',
               (SELECT T1.PRIORITY
                  FROM PLN_SALEORD_PROC T1,
                       PLN_GX_JG_PROP_S T2,
                       PLN_ZY_JG_M      T3
                 WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                   AND T1.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
                   AND T2.PRO_PLAN_ID = T3.PRO_PLAN_ID
                   AND T2.GX_PLAN_NO = T3.GX_PLAN_NO
                   AND T3.HEAT_PLAN_NO = M.PRO_PLAN_ID),
               '') PRIORITY,
                 DECODE(M.PROCESS,
               'D',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_ZG_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'E',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_DBK_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'F',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_RCL_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'G',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_JGX_S
                 WHERE PRO_PLAN_ID = M.PRO_PLAN_ID
                   AND GX_PLAN_NO = M.GX_PLAN_NO),
               'H',
               (SELECT T1.PRIORITY_MEMO
                  FROM PLN_SALEORD_PROC T1,
                       PLN_GX_JG_PROP_S T2,
                       PLN_ZY_JG_M      T3
                 WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                   AND T1.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
                   AND T2.PRO_PLAN_ID = T3.PRO_PLAN_ID
                   AND T2.GX_PLAN_NO = T3.GX_PLAN_NO
                   AND T3.HEAT_PLAN_NO = M.PRO_PLAN_ID),
               '') PRIORITY_MEMO,
		  DECODE(PROCESS,'BC','BC','ZC','ZC',E.SUBCONTRACT_LOG) TYPE FROM
(
SELECT T.JUDGE_STOVE_NO || '_' ||  T.OFFLINE_PRO || '_' || T.OFFLINE_TYPE  RESULT_NO,
       T.PLINE_CODE ,
       (SELECT PLINE_NAME
          FROM COM_BASE_PLINE
         WHERE PLINE_CODE =T.PLINE_CODE) PLINE_NAME,
       T.OFFLINE_PRO STATION_CODE,
       DECODE(T.OFFLINE_PRO,
              'TS',
              '探伤',
              'ZJ',
              '质检',
              'JZ',
              '矫直',
              'XX',
              '交库') STATION_DESC,
       MAX(T1.ID) HEAT_PLAN_NO,
       MAX(T.LOT_NO)  ZY_BATCH_ID,
       MAX(T.PRO_PLAN_ID)  PRO_PLAN_ID,
       MAX(T.GX_PLAN_NO) GX_PLAN_NO ,
       (SELECT MAX(FLAG_STOVE_NO_ZG) FROM mat_bc_m  WHERE ZG_STOVE_SQE =  T.JUDGE_STOVE_NO)  FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
        NVL(P.BATCH_NO,'X') BATCH_NO,
      MAX(T.PRODUCCODE) PRODUCCODE,
       MAX(T.PRODUCNAME) PRODUCNAME,
       NVL(MAX(T.STEELCODE), MAX(T1.STEELCODE)) STEELCODE,
       MAX(T.STEELNAME) STEELNAME,
       NVL(MAX(T.GRADECODE), MAX(T1.GRADECODE)) GRADECODE,
       MAX(T.GRADENAME) GRADENAME,
       NVL(MAX(T.MODEL_CODE), MAX(T1.BUCKLE_TYPE_CODE)) MODEL_CODE,
       MAX(T.MODEL_DESC) MODEL_DESC,
       NVL(MAX(T.STD_CODE),MAX( T1.ROLL_STANDRAD_CODE)) STD_CODE,
       MAX(T.STD_NAME) STD_NAME,
       NVL(MAX(T.STD_STYLE), MAX(T1.STD_STYLE)) STD_STYLE,
       MAX(T.STD_STYLE_DESC)  STD_STYLE_DESC,
        MAX(T.SPEC_CODE)  SPEC_CODE,
        MAX(T.SPEC_NAME)  SPEC_NAME,
       MAX(T.DIAMETER) ACT_DIMATER,
       MAX(T.THICKNESS)  ACT_HEIGHT,
       MAX(T.LENGTH) ACT_LEN,
       CASE WHEN MAX(SUBCONTRACT_NUM) < 1 THEN
       MAX(T.LENGTH) * DECODE(MAX(P.MAT_NO),
              NULL,
              MAX(T.OFFLINE_NUM),
              COUNT(1))
              ELSE 
                MAX(T.LENGTH) * MAX(T.SUBCONTRACT_NUM) END SUM_LEN,
       MAX(ACT_LEN_RANGE) ACT_LEN_RANGE,
       MAX(T.CONTRACT_NO)  ORDER_NO,
        DECODE(MAX(P.MAT_NO),
              NULL,
              MAX(T.OFFLINE_NUM),
              COUNT(1)) OFFLINE_NUM,
       DECODE(MAX(P.MAT_NO),
              NULL,
              MAX(T.ZP_HEIGHT),
              SUM(P.ACT_THEORY_WEIGHT)) OFFLINE_WT,
       MAX(SUBCONTRACT_NO) SUBCONTRACT_NO,
       MAX(T.SUBCONTRACT_NUM) SUBCONTRACT_NUM,
       NULL SUBCONTRACT_WT,
       NULL SUBCONTRACT_TIME,
       '' SUBCONTRACT_NAME,
       MAX(T. SUBCONTRACTCOMPLETE_NUM) SUBCONTRACTCOMPLETE_NUM,
       MAX(T.SUBCONTRACTCOMPLETE_WGT) SUBCONTRACTCOMPLETE_WT,
       MAX(T.SUBCONTRACTSCRAP_NUM) HB_FP_NUM,
       NULL HB_FP_WT,
       MAX(SUBCONTRACTCOMPLETE_TIME) SUBCONTRACTCOMPLETE_TIME,
       MAX(SUBCONTRACTCOMPLETE_NAME) SUBCONTRACTCOMPLETE_NAME,
       MAX(T.COL_USER) PRO_USER,
       MAX(T.COL_SHIFT) PRO_SHIFT,
       MAX(T.COL_GROUP) PRO_GROUP,
       MAX(T.OFFLINE_TIME) PRO_TIME,
       MAX(T.REMARK) MEMO,
       'D' PROCESS,
       MAX(O.CIC) CIC,
       MAX(O.PIC) PIC,
       MAX(O.SIC) SIC,
       MAX(O.DIC) DIC,
       MAX(O.WIC) WIC,
       MAX(O.INDEX_SEQ)  MSC_PLINE,
     (SELECT DESGIN_KEY FROM CRAFT_ORD_DESIGN WHERE ORD_LN_PK =
     (SELECT ORD_LN_PK FROM PLN_SALEORD WHERE ORD_LN_DLY_PK =  O.ORD_LN_DLY_PK)  AND CRAFT_SEQ =O.CRAFT_SEQ)
       DESGIN_KEY,
       (SELECT DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(NVL(Y.STORAGE_NAME, '在途') || '/' ||
                                               COUNT(1)),
                               4000)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
          LEFT JOIN YDM_BS_STORAGE Y
            ON B.STORAGE_NO = Y.STORAGE_NO
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.OFFLINE_DOC
         GROUP BY STORAGE_NAME) Storage_Type_Name,
         (SELECT MAX(B.STORAGE_NO)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.OFFLINE_DOC) Storage_Type_No
  FROM MIL_OFFLINE_RESLUT T LEFT JOIN  MIL_PLAN T1 ON T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO AND T.PRO_PLAN_ID = T1.PRO_PLAN_ID
   AND T.GX_PLAN_NO = T1.GX_PLAN_NO
   LEFT JOIN PLN_ORDER_ZG_S O ON  O.PRO_PLAN_ID = T1.PRO_PLAN_ID
   AND O.GX_PLAN_NO = T1.GX_PLAN_NO
  LEFT JOIN  PORT_MIL_BATCH_SAMPLE_RESULT  P ON  P.STATUS='3' AND P.OP_PROCESS = DECODE(T.OFFLINE_PRO,'JZ','9','TS','10','ZJ','11','XX','12','') AND T.JUDGE_STOVE_NO=P.JUDGE_STOVE_NO
  --LEFT JOIN MIL_OFFLINE_GROUP G ON T.JUDGE_STOVE_NO = G.ZP_JUDGE_STOVE_NO
 WHERE T.STATUS = '0'
 -- AND   T.JUDGE_STOVE_NO = DECODE(T.ZP_FLAG,'1',G.ZP_JUDGE_STOVE_NO,T.JUDGE_STOVE_NO)
      AND   (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RECHECK_NUM, 0)) -
       TO_NUMBER(NVL(T.BACKLINE_NUM, 0)) -
         TO_NUMBER(NVL(T.SUBCONTRACTSCRAP_NUM, 0))
       ) >0
       AND '/' = '#STATUS1#'
       #TIME1#
       #JUDGESTOVE#
       #PLINECODE#
       GROUP BY T.JUDGE_STOVE_NO, T.OFFLINE_PRO, T.OFFLINE_TYPE,T.PLINE_CODE, P.BATCH_NO,O.ORD_LN_DLY_PK,O.CRAFT_SEQ,T.OFFLINE_DOC
       UNION ALL
       SELECT RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       STATION_CODE,
       STATION_DESC,
       M.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NVL(T.FLAG_STOVE_NO,T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       M.PRODUCCODE,
       M.PRODUCNAME,
       M.STEELCODE,
       M.STEELNAME,
       M.GRADECODE,
       M.GRADENAME,
       M.MODEL_CODE,
       M.MODEL_DESC,
       M.STD_CODE,
       M.STD_NAME,
       M.STD_STYLE,
       M.STD_STYLE_DESC,
        M.SPEC_CODE,
       M.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       CASE WHEN SUBCONTRACT_NUM < 1 THEN
       ACT_LEN *(TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )
       ELSE ACT_LEN * SUBCONTRACT_NUM END  SUM_LEN,
      ACT_LEN_MIN || '-'  || ACT_LEN_MAX  ACT_LEN_RANGE,
     T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )  OFFLINE_NUM,
       (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.GROUP_WT, 0)) -
       TO_NUMBER(NVL(T.RE_WT, 0)) -     TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0)) )   OFFLINE_WT,
       SUBCONTRACT_NO,
       SUBCONTRACT_NUM,
       SUBCONTRACT_WT,
       SUBCONTRACT_TIME,
       SUBCONTRACT_NAME,
       SUBCONTRACTCOMPLETE_NUM,
       SUBCONTRACTCOMPLETE_WT,
       HB_FP_NUM,
       HB_FP_WT,
       SUBCONTRACTCOMPLETE_TIME,
       SUBCONTRACTCOMPLETE_NAME,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       T.MEMO,
       'F' PROCESS,
       O.CIC,
       O.PIC,
       O.SIC,
       O.DIC,
       O.WIC,
       O.INDEX_SEQ  MSC_PLINE,
      (SELECT DESGIN_KEY FROM CRAFT_ORD_DESIGN WHERE ORD_LN_PK = (SELECT ORD_LN_PK FROM PLN_SALEORD WHERE ORD_LN_DLY_PK =O.ORD_LN_DLY_PK)  AND CRAFT_SEQ =O.CRAFT_SEQ)
       DESGIN_KEY,
       (SELECT DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(NVL(Y.STORAGE_NAME, '在途') || '/' ||
                                               COUNT(1)),
                               4000)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
          LEFT JOIN YDM_BS_STORAGE Y
            ON B.STORAGE_NO = Y.STORAGE_NO
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO
         GROUP BY STORAGE_NAME) Storage_Type_Name,
         (SELECT MAX(B.STORAGE_NO)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO) Storage_Type_No
         FROM HTT_OFFLINE_RESULT T
           LEFT JOIN PLN_ZY_RCL_M M ON  M.HEAT_PLAN_NO = NVL(T.HEAT_PLAN_NO,T.ZY_BATCH_ID1)
     LEFT JOIN PLN_ORDER_rcl_S O ON  O.PRO_PLAN_ID = T.PRO_PLAN_ID
   AND O.GX_PLAN_NO = T.GX_PLAN_NO
 WHERE 1=1
        AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.HB_FP_NUM, 0)) ) > 0
       #TIME2#
       #JUDGESTOVE#
       #PLINECODE#
       AND '/' = '#STATUS1#'
        UNION ALL
            SELECT RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       STATION_CODE,
       STATION_DESC,
       M.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
           NVL(T.FLAG_STOVE_NO,T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       M.PRODUCCODE,
       M.PRODUCNAME,
       M.STEELCODE,
       M.STEELNAME,
       M.GRADECODE,
       M.GRADENAME,
       M.MODEL_CODE,
       M.MODEL_DESC,
       M.STD_CODE,
       M.STD_NAME,
       M.STD_STYLE,
       M.STD_STYLE_DESC,
        M.SPEC_CODE,
       M.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       CASE WHEN SUBCONTRACT_NUM < 1 THEN
       ACT_LEN * (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )
       ELSE ACT_LEN * SUBCONTRACT_NUM END SUM_LEN,
      ACT_LEN_MIN || '-'  || ACT_LEN_MAX  ACT_LEN_RANGE,
       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )  OFFLINE_NUM,
       (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.GROUP_WT, 0)) -
       TO_NUMBER(NVL(T.RE_WT, 0)) -     TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0)) )   OFFLINE_WT,
       SUBCONTRACT_NO,
       SUBCONTRACT_NUM,
       SUBCONTRACT_WT,
       SUBCONTRACT_TIME,
       SUBCONTRACT_NAME,
       SUBCONTRACTCOMPLETE_NUM,
       SUBCONTRACTCOMPLETE_WT,
       HB_FP_NUM,
       HB_FP_WT,
       SUBCONTRACTCOMPLETE_TIME,
       SUBCONTRACTCOMPLETE_NAME,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       T.MEMO,
       'G' PROCESS,
          O.CIC,
       O.PIC,
       O.SIC,
       O.DIC,
       O.WIC,
       O.INDEX_SEQ  MSC_PLINE,
      (SELECT DESGIN_KEY FROM CRAFT_ORD_DESIGN WHERE ORD_LN_PK = (SELECT ORD_LN_PK FROM PLN_SALEORD WHERE ORD_LN_DLY_PK =O.ORD_LN_DLY_PK)  AND CRAFT_SEQ =O.CRAFT_SEQ)
       DESGIN_KEY,
        (SELECT DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(NVL(Y.STORAGE_NAME, '在途') || '/' ||
                                               COUNT(1)),
                               4000)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
          LEFT JOIN YDM_BS_STORAGE Y
            ON B.STORAGE_NO = Y.STORAGE_NO
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO
         GROUP BY STORAGE_NAME) Storage_Type_Name,
         (SELECT MAX(B.STORAGE_NO)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO) Storage_Type_No
  FROM MCH_OFFLINE_RESULT T
   LEFT JOIN PLN_ZY_JGX_M M ON  M.HEAT_PLAN_NO = NVL(T.HEAT_PLAN_NO,T.ZY_BATCH_ID1)
    LEFT JOIN PLN_ORDER_JGX_S O ON  O.PRO_PLAN_ID = T.PRO_PLAN_ID
   AND O.GX_PLAN_NO = T.GX_PLAN_NO
 WHERE 1=1
        AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.HB_FP_NUM, 0)) ) > 0
       #TIME2#
       #JUDGESTOVE#
       #PLINECODE#
       AND '/' = '#STATUS1#'
           UNION ALL
       SELECT RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       STATION_CODE,
       STATION_DESC,
       M.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
           NVL(T.FLAG_STOVE_NO,T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       M.PRODUCCODE,
       M.PRODUCNAME,
       M.STEELCODE,
       M.STEELNAME,
       M.GRADECODE,
       M.GRADENAME,
       M.MODEL_CODE,
       M.MODEL_DESC,
       M.STD_CODE,
       M.STD_NAME,
       M.STD_STYLE,
       M.STD_STYLE_DESC,
        M.SPEC_CODE,
       M.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       CASE WHEN SUBCONTRACT_NUM < 1 THEN
       ACT_LEN * (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )
       ELSE ACT_LEN * SUBCONTRACT_NUM END SUM_LEN,
      ACT_LEN_MIN || '-'  || ACT_LEN_MAX  ACT_LEN_RANGE,
       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )  OFFLINE_NUM,
       (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.GROUP_WT, 0)) -
       TO_NUMBER(NVL(T.RE_WT, 0)) -     TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0)) )   OFFLINE_WT,
       SUBCONTRACT_NO,
       SUBCONTRACT_NUM,
       SUBCONTRACT_WT,
       SUBCONTRACT_TIME,
       SUBCONTRACT_NAME,
       SUBCONTRACTCOMPLETE_NUM,
       SUBCONTRACTCOMPLETE_WT,
       HB_FP_NUM,
       HB_FP_WT,
       SUBCONTRACTCOMPLETE_TIME,
       SUBCONTRACTCOMPLETE_NAME,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       T.MEMO MEMO,
       'E' PROCESS,
        O.CIC,
       O.PIC,
       O.SIC,
       O.DIC,
       O.WIC,
       O.INDEX_SEQ  MSC_PLINE,
      (SELECT DESGIN_KEY FROM CRAFT_ORD_DESIGN WHERE ORD_LN_PK = (SELECT ORD_LN_PK FROM PLN_SALEORD WHERE ORD_LN_DLY_PK =O.ORD_LN_DLY_PK)  AND CRAFT_SEQ =O.CRAFT_SEQ)
       DESGIN_KEY,
        (SELECT DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(NVL(Y.STORAGE_NAME, '在途') || '/' ||
                                               COUNT(1)),
                               4000)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
          LEFT JOIN YDM_BS_STORAGE Y
            ON B.STORAGE_NO = Y.STORAGE_NO
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO
         GROUP BY STORAGE_NAME) Storage_Type_Name,
         (SELECT MAX(B.STORAGE_NO)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO) Storage_Type_No
  FROM VRP_OFFLINE_RESULT T
   LEFT JOIN PLN_ZY_DBK_M M ON  M.HEAT_PLAN_NO = NVL(T.HEAT_PLAN_NO,T.ZY_BATCH_ID1)
      LEFT JOIN PLN_ORDER_DBK_S O ON  O.PRO_PLAN_ID = T.PRO_PLAN_ID
   AND O.GX_PLAN_NO = T.GX_PLAN_NO
 WHERE 1=1
        AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.HB_FP_NUM, 0)) ) > 0
      #TIME2#
       #JUDGESTOVE#
       #PLINECODE#
          AND '/' = '#STATUS1#'
           UNION ALL
 SELECT RESULT_NO || '_' ||  OFF_XH RESULT_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        STATION_CODE,
        STATION_DESC,
        HEAT_PLAN_NO,
        '' ZY_BATCH_ID,
        T.WO_ID PRO_PLAN_ID,
        '' GX_PLAN_NO,
         T.JUDGE_STOVE_NO FLAG_STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        B.PRODUCCODE_JG PRODUCCODE,
        B.PRODUCCODE_JG_DESC PRODUCNAME,
        B.STEELCODE,
        B.STEELNAME,
        B.GRADECODE,
        B.GRADENAME,
        J.MODEL_CODE,
        J.MODEL_DESC,
        J.STD_CODE,
        J.STD_NAME,
        J.STD_STYLE,
        J.STD_STYLE_DESC,
        J.SPEC_JG SPEC_CODE,
        J.SPEC_JG_DESC  SPEC_NAME,
        J.DIAMETER_JG ACT_DIMATER,
        J.HEIGHT_JG ACT_HEIGHT,
        TO_NUMBER(J.LENGTH_JG) ACT_LEN,
        CASE WHEN SUBCONTRACT_NUM < 1 THEN
        TO_NUMBER(J.LENGTH_JG) * (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
        TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
        TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)))
        ELSE TO_NUMBER(J.LENGTH_JG) * SUBCONTRACT_NUM END SUM_LEN,
        J.LENGTH_MIN || '-' || J.LENGTH_MAX ACT_LEN_RANGE,
        B.ORDER_NO || '/' || B.ORDER_SEQ ORDER_NO,
        (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
        TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
        TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_NUM,
        (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.RE_WT, 0)) -
        TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +
        TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0))) OFFLINE_WT,
        T.SUBCONTRACT_NO,
        SUBCONTRACT_NUM,
        SUBCONTRACT_WT,
        SUBCONTRACT_TIME,
        SUBCONTRACT_NAME,
        SUBCONTRACTCOMPLETE_NUM,
        SUBCONTRACTCOMPLETE_WT,
        HB_FP_NUM,
        HB_FP_WT,
        SUBCONTRACTCOMPLETE_TIME,
        SUBCONTRACTCOMPLETE_NAME,
        COL_USER PRO_USER,
        COL_SHIFT PRO_SHIFT,
        COL_GROUP PRO_GROUP,
        COL_TIME PRO_TIME,
        '' MEMO,
        'H' PROCESS,
        '' CIC,
        '' PIC,
        '' SIC,
        '' DIC,
        '' WIC,
        '' MSC_PLINE,
        '' DESGIN_KEY,
         (SELECT DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(NVL(Y.STORAGE_NAME, '在途') || '/' ||
                                               COUNT(1)),
                               4000)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
          LEFT JOIN YDM_BS_STORAGE Y
            ON B.STORAGE_NO = Y.STORAGE_NO
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO
         GROUP BY STORAGE_NAME) Storage_Type_Name,
         (SELECT MAX(B.STORAGE_NO)
          FROM MAT_BC_M M, YDM_BC_BUTTRESS B
         WHERE M.MAT_NO = B.MAT_NO
           AND M.OFFLINE_DOC = T.RESULT_NO) Storage_Type_No
   FROM COUPLING_OFFLINE_RESULT T, PLN_ZY_JG_WORKBILL B, COM_MSC_JG J
  WHERE T.WO_ID = B.WO_ID
    AND B.CODE_JG = J.CODE_JG
    AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
        TO_NUMBER(NVL(T.HB_FP_NUM, 0))) > 0
          #TIME3#
       #JUDGESTOVE#
       #PLINECODE#
    AND '/' = '#STATUS1#'
    UNION ALL
     SELECT  '' RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
      '' STATION_CODE,
      '' STATION_DESC,
       T.HEAT_PLAN_NO,
       T.LOT_NO ZY_BATCH_ID,
       '' PRO_PLAN_ID,
       T.GX_PLAN_NO,
       FLAG_STOVE_NO_ZG,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
      T.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN * SUM(DECODE(T.MNG_LOCK_FLAG,'0',1,0 )) SUM_LEN,
       ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
       T.PRO_ORDER_NO ORDER_NO,
      SUM(DECODE(T.MNG_LOCK_FLAG,'0',1,0 ))  OFFLINE_NUM,
        SUM(DECODE(T.MNG_LOCK_FLAG,'0',T.ACT_WEIGHT,0 ))  OFFLINE_WT,
       SUBCONTRACT_NO,
            NULL SUBCONTRACT_NUM,
       NULL SUBCONTRACT_WT,
       NULL SUBCONTRACT_TIME,
       NULL SUBCONTRACT_NAME,
       NULL SUBCONTRACTCOMPLETE_NUM,
       NULL SUBCONTRACTCOMPLETE_WT,
       NULL HB_FP_NUM,
       NULL HB_FP_WT,
       NULL SUBCONTRACTCOMPLETE_TIME,
       '' SUBCONTRACTCOMPLETE_NAME,
       '' PRO_USER,
       '' PRO_SHIFT,
       '' PRO_GROUP,
       MAX(T.INSTOCK_TIME) PRO_TIME ,
      '' MEMO,
       'BC' PROCESS,
       '' CIC,
       '' PIC,
       '' SIC,
       '' DIC,
       '' WIC,
       '' MSC_PLINE,
       (SELECT DESGIN_KEY
          FROM CRAFT_ORD_DESIGN
         WHERE ORD_LN_PK =
               (SELECT ORD_LN_PK
                  FROM PLN_SALEORD
                 WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
           AND CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
           '',
           ''
  FROM MAT_BC_M T
   WHERE BELONG_CODE = '002001001'
   AND PRO_PLAN_ID_NEXT IS NULL
   AND GX_PLAN_NO_NEXT IS NULL
   AND HEAT_PLAN_NO_NEXT IS NULL
   AND QCM_STAUS = '00'
       #TIME4#
       #JUDGESTOVE#
       #PLINECODE1#
       AND 'BC' = '#STATUS1#'
   GROUP BY JUDGE_STOVE_NO,BATCH_NO,T.PLINE_CODE,T.PLINE_NAME,HEAT_PLAN_NO,LOT_NO,GX_PLAN_NO,FLAG_STOVE_NO_ZG,
   PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       SPEC_CODE,
      SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,ACT_LEN_MAX,PRO_ORDER_NO,ORD_LN_DLY_PK,CRAFT_SEQ,
      SUBCONTRACT_NO
      UNION ALL

     SELECT  '' RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
      '' STATION_CODE,
      '' STATION_DESC,
       T.HEAT_PLAN_NO,
       T.LOT_NO ZY_BATCH_ID,
       '' PRO_PLAN_ID,
       T.GX_PLAN_NO,
       FLAG_STOVE_NO_ZG,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
      T.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN * SUM(DECODE(T.MNG_LOCK_FLAG,'0',1,0 )) SUM_LEN,
       ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
       T.PRO_ORDER_NO ORDER_NO,
      SUM(DECODE(T.MNG_LOCK_FLAG,'0',1,0 ))  OFFLINE_NUM,
        SUM(DECODE(T.MNG_LOCK_FLAG,'0',T.ACT_WEIGHT,0 ))  OFFLINE_WT,
       SUBCONTRACT_NO,
            NULL SUBCONTRACT_NUM,
       NULL SUBCONTRACT_WT,
       NULL SUBCONTRACT_TIME,
       NULL SUBCONTRACT_NAME,
       NULL SUBCONTRACTCOMPLETE_NUM,
       NULL SUBCONTRACTCOMPLETE_WT,
       NULL HB_FP_NUM,
       NULL HB_FP_WT,
       NULL SUBCONTRACTCOMPLETE_TIME,
       '' SUBCONTRACTCOMPLETE_NAME,
       '' PRO_USER,
       '' PRO_SHIFT,
       '' PRO_GROUP,
       MAX(T.INSTOCK_TIME) PRO_TIME ,
      '' MEMO,
       'ZC' PROCESS,
       '' CIC,
       '' PIC,
       '' SIC,
       '' DIC,
       '' WIC,
       '' MSC_PLINE,
       '' DESGIN_KEY,
       '',
       ''
  FROM MAT_ZC_M T
   WHERE PRODUCT_FLAG= '801402'
       AND 'ZC' = '#STATUS1#'
       #TIME4#
       #JUDGESTOVE#
       #PLINECODE1#
       AND 'ZC' = '#STATUS1#'
   GROUP BY JUDGE_STOVE_NO,BATCH_NO,T.PLINE_CODE,T.PLINE_NAME,HEAT_PLAN_NO,LOT_NO,GX_PLAN_NO,FLAG_STOVE_NO_ZG,
   PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       SPEC_CODE,
      SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,ACT_LEN_MAX,PRO_ORDER_NO,ORD_LN_DLY_PK,
      SUBCONTRACT_NO
          )  M  LEFT JOIN  (SELECT SUBCONTRACT_NO,MIN(SUBCONTRACT_LOG) SUBCONTRACT_LOG FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO) E ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO
          WHERE 1=1
           #STATUS#
          Order by M.PLINE_CODE, M.PRO_TIME, M.JUDGE_STOVE_NO,M.BATCH_NO
          )  s   where  1=1
		]]>
	</query>


	<query id="frmEntrust.doQueryOfflineD" desc="产线">
		<![CDATA[
		SELECT M.*, E.SUBCONTRACT_LOG TYPE
  FROM (SELECT T.JUDGE_STOVE_NO || '_' || T.OFFLINE_PRO || '_' ||
               T.OFFLINE_TYPE RESULT_NO,
               max(T.LOAD_JUDGE_STOVE_NO) LOAD_JUDGE_STOVE_NO,
               T.PLINE_CODE,
               (SELECT PLINE_NAME
                  FROM COM_BASE_PLINE
                 WHERE PLINE_CODE = T.PLINE_CODE) PLINE_NAME,
               T.OFFLINE_PRO STATION_CODE,
               DECODE(T.OFFLINE_PRO,
                      'TS',
                      '探伤',
                      'ZJ',
                      '质检',
                      'JZ',
                      '矫直',
                      'XX',
                      '交库') STATION_DESC,
               MAX(T1.ID) HEAT_PLAN_NO,
               MAX(T.LOT_NO) ZY_BATCH_ID,
               MAX(T.PRO_PLAN_ID) PRO_PLAN_ID,
               MAX(T.GX_PLAN_NO) GX_PLAN_NO,
               (SELECT MAX(FLAG_STOVE_NO_ZG)
                  FROM mat_bc_m
                 WHERE ZG_STOVE_SQE = T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
               T.JUDGE_STOVE_NO,
               NVL(P.BATCH_NO,'X') BATCH_NO,
               MAX(T.PRODUCCODE) PRODUCCODE,
               MAX(T.PRODUCNAME) PRODUCNAME,
               NVL(MAX(T.STEELCODE), MAX(T1.STEELCODE)) STEELCODE,
               MAX(T.STEELNAME) STEELNAME,
               NVL(MAX(T.GRADECODE), MAX(T1.GRADECODE)) GRADECODE,
               MAX(T.GRADENAME) GRADENAME,
               NVL(MAX(T.MODEL_CODE), MAX(T1.BUCKLE_TYPE_CODE)) MODEL_CODE,
               MAX(T.MODEL_DESC) MODEL_DESC,
               NVL(MAX(T.STD_CODE), MAX(T1.ROLL_STANDRAD_CODE)) STD_CODE,
               MAX(T.STD_NAME) STD_NAME,
               NVL(MAX(T.STD_STYLE), MAX(T1.STD_STYLE)) STD_STYLE,
               MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
               MAX(T.SPEC_CODE) SPEC_CODE,
               MAX(T.SPEC_NAME) SPEC_NAME,
               MAX(T.DIAMETER) ACT_DIMATER,
               MAX(T.THICKNESS) ACT_HEIGHT,
               MAX(T.LENGTH) ACT_LEN,
               MAX(ACT_LEN_RANGE) ACT_LEN_RANGE,
               MAX(T.CONTRACT_NO) ORDER_NO,
               DECODE(MAX(P.MAT_NO), NULL, MAX(T.OFFLINE_NUM), COUNT(1)) OFFLINE_NUM,
               DECODE(MAX(P.MAT_NO),
                      NULL,
                      MAX(T.ZP_HEIGHT),
                      SUM(P.ACT_THEORY_WEIGHT)) OFFLINE_WT,
               MAX(SUBCONTRACT_NO) SUBCONTRACT_NO,
               MAX(T.SUBCONTRACT_NUM) SUBCONTRACT_NUM,
               NULL SUBCONTRACT_WT,
               NULL SUBCONTRACT_TIME,
               '' SUBCONTRACT_NAME,
               MAX(T. SUBCONTRACTCOMPLETE_NUM) SUBCONTRACTCOMPLETE_NUM,
               MAX(T.SUBCONTRACTCOMPLETE_WGT) SUBCONTRACTCOMPLETE_WT,
               MAX(T.SUBCONTRACTSCRAP_NUM) HB_FP_NUM,
               NULL HB_FP_WT,
               NULL SUBCONTRACTCOMPLETE_TIME,
               '' SUBCONTRACTCOMPLETE_NAME,
               MAX(T.COL_USER) PRO_USER,
               MAX(T.COL_SHIFT) PRO_SHIFT,
               MAX(T.COL_GROUP) PRO_GROUP,
               MAX(T.OFFLINE_TIME) PRO_TIME,
               MAX(T.REMARK) MEMO,
               'D' PROCESS,
               MAX(O.CIC) CIC,
               MAX(O.PIC) PIC,
               MAX(O.SIC) SIC,
               MAX(O.DIC) DIC,
               MAX(O.WIC) WIC,
               MAX(O.INDEX_SEQ) MSC_PLINE,
               MAX(O.OUTPUT_STANDARD) OUTPUT_STANDARD,
               (SELECT DESGIN_KEY
                  FROM CRAFT_ORD_DESIGN
                 WHERE ORD_LN_PK =
                       (SELECT ORD_LN_PK
                          FROM PLN_SALEORD
                         WHERE ORD_LN_DLY_PK = O.ORD_LN_DLY_PK)
                   AND CRAFT_SEQ = O.CRAFT_SEQ) DESGIN_KEY,
                   T.OFFLINE_DOC
          FROM MIL_OFFLINE_RESLUT T
          LEFT JOIN MIL_PLAN T1
            ON T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
           AND T.PRO_PLAN_ID = T1.PRO_PLAN_ID
           AND T.GX_PLAN_NO = T1.GX_PLAN_NO
          LEFT JOIN PLN_ORDER_ZG_S O
            ON O.PRO_PLAN_ID = T1.PRO_PLAN_ID
           AND O.GX_PLAN_NO = T1.GX_PLAN_NO
          LEFT JOIN PORT_MIL_BATCH_SAMPLE_RESULT P
            ON P.STATUS = '3'
           AND P.OP_PROCESS = DECODE(T.OFFLINE_PRO,
                                     'JZ',
                                     '9',
                                     'TS',
                                     '10',
                                     'ZJ',
                                     '11',
                                     'XX',
                                     '12',
                                     '')
           AND T.JUDGE_STOVE_NO = P.JUDGE_STOVE_NO
        /*LEFT JOIN MIL_OFFLINE_GROUP G
        ON T.JUDGE_STOVE_NO = G.ZP_JUDGE_STOVE_NO*/
         WHERE T.STATUS = '0'
              /*AND T.JUDGE_STOVE_NO =
              DECODE(T.ZP_FLAG, '1', G.ZP_JUDGE_STOVE_NO, T.JUDGE_STOVE_NO)*/
           AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) -
               TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
               TO_NUMBER(NVL(T.RECHECK_NUM, 0)) -
               TO_NUMBER(NVL(T.BACKLINE_NUM, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACTSCRAP_NUM, 0))) > 0
           AND T.JUDGE_STOVE_NO = ?
           AND T.OFFLINE_PRO = ?
           AND T.OFFLINE_TYPE = ?
        
         GROUP BY T.JUDGE_STOVE_NO,
                  T.OFFLINE_PRO,
                  T.OFFLINE_TYPE,
                  T.PLINE_CODE,
                  P.BATCH_NO,
                  O.ORD_LN_DLY_PK,
                  O.CRAFT_SEQ,
                  OFFLINE_DOC) M
  LEFT JOIN (SELECT SUBCONTRACT_NO, MIN(SUBCONTRACT_LOG) SUBCONTRACT_LOG
               FROM HTT_ENTRUST
              GROUP BY SUBCONTRACT_NO) E
    ON E.SUBCONTRACT_NO = M.SUBCONTRACT_NO
 WHERE 1 = 1
 Order by M.PLINE_CODE, M.PRO_TIME, M.JUDGE_STOVE_NO, M.BATCH_NO,M.OFFLINE_DOC
		]]>
	</query>

	<query id="frmEntrust.doQueryOfflineE" desc="产线">
		<![CDATA[
		SELECT M.*,E.SUBCONTRACT_LOG TYPE FROM
(
  SELECT RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       STATION_CODE,
       STATION_DESC,
       M.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NVL(T.FLAG_STOVE_NO,T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.LOAD_JUDGE_STOVE_NO,
       T.BATCH_NO,
       M.PRODUCCODE,
       M.PRODUCNAME,
       M.STEELCODE,
       M.STEELNAME,
       M.GRADECODE,
       M.GRADENAME,
       M.MODEL_CODE,
       M.MODEL_DESC,
       M.STD_CODE,
       M.STD_NAME,
       M.STD_STYLE,
       M.STD_STYLE_DESC,
       M.SPEC_CODE,
       M.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
      ACT_LEN_MIN || '-'  || ACT_LEN_MAX  ACT_LEN_RANGE,
     T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )  OFFLINE_NUM,
       (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.GROUP_WT, 0)) -
       TO_NUMBER(NVL(T.RE_WT, 0)) -     TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0)) )   OFFLINE_WT,
       SUBCONTRACT_NO,
       SUBCONTRACT_NUM,
       SUBCONTRACT_WT,
       SUBCONTRACT_TIME,
       SUBCONTRACT_NAME,
       SUBCONTRACTCOMPLETE_NUM,
       SUBCONTRACTCOMPLETE_WT,
       HB_FP_NUM,
       HB_FP_WT,
       SUBCONTRACTCOMPLETE_TIME,
       SUBCONTRACTCOMPLETE_NAME,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       '' MEMO,
       'E' PROCESS,
        O.CIC,
       O.PIC,
       O.SIC,
       O.DIC,
       O.WIC,
       O.INDEX_SEQ  MSC_PLINE,
        M.OUTPUT_STANDARD,
      (SELECT DESGIN_KEY FROM CRAFT_ORD_DESIGN WHERE ORD_LN_PK = (SELECT ORD_LN_PK FROM PLN_SALEORD WHERE ORD_LN_DLY_PK =O.ORD_LN_DLY_PK)  AND CRAFT_SEQ =O.CRAFT_SEQ)
       DESGIN_KEY
  FROM VRP_OFFLINE_RESULT T
     LEFT JOIN PLN_ZY_DBK_M M ON  M.HEAT_PLAN_NO = NVL(T.HEAT_PLAN_NO,T.ZY_BATCH_ID1)
      LEFT JOIN PLN_ORDER_DBK_S O ON  O.PRO_PLAN_ID = T.PRO_PLAN_ID
   AND O.GX_PLAN_NO = T.GX_PLAN_NO
 WHERE 1=1
        AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.HB_FP_NUM, 0)) ) > 0
        AND T.RESULT_NO =?
          )  M  LEFT JOIN  (SELECT SUBCONTRACT_NO,MIN(SUBCONTRACT_LOG) SUBCONTRACT_LOG FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO) E ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO
          WHERE 1=1
          Order by M.PLINE_CODE, M.PRO_TIME
		]]>
	</query>

	<query id="frmEntrust.doQueryOfflineF" desc="产线">
		<![CDATA[
		SELECT M.*,E.SUBCONTRACT_LOG TYPE FROM
(
    SELECT RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       STATION_CODE,
       STATION_DESC,
              M.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
           NVL(T.FLAG_STOVE_NO,T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.LOAD_JUDGE_STOVE_NO,
       T.BATCH_NO,
       M.PRODUCCODE,
       M.PRODUCNAME,
       M.STEELCODE,
       M.STEELNAME,
       M.GRADECODE,
       M.GRADENAME,
       M.MODEL_CODE,
       M.MODEL_DESC,
       M.STD_CODE,
       M.STD_NAME,
       M.STD_STYLE,
       M.STD_STYLE_DESC,
       M.SPEC_CODE,
       M.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
      ACT_LEN_MIN || '-'  || ACT_LEN_MAX  ACT_LEN_RANGE,
       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )  OFFLINE_NUM,
       (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.GROUP_WT, 0)) -
       TO_NUMBER(NVL(T.RE_WT, 0)) -     TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0)) )   OFFLINE_WT,
       SUBCONTRACT_NO,
       SUBCONTRACT_NUM,
       SUBCONTRACT_WT,
       SUBCONTRACT_TIME,
       SUBCONTRACT_NAME,
       SUBCONTRACTCOMPLETE_NUM,
       SUBCONTRACTCOMPLETE_WT,
       HB_FP_NUM,
       HB_FP_WT,
       SUBCONTRACTCOMPLETE_TIME,
       SUBCONTRACTCOMPLETE_NAME,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       T.MEMO,
       'F' PROCESS,
       O.CIC,
       O.PIC,
       O.SIC,
       O.DIC,
       O.WIC,
       O.INDEX_SEQ  MSC_PLINE,
        M.OUTPUT_STANDARD,
      (SELECT DESGIN_KEY FROM CRAFT_ORD_DESIGN WHERE ORD_LN_PK = (SELECT ORD_LN_PK FROM PLN_SALEORD WHERE ORD_LN_DLY_PK =O.ORD_LN_DLY_PK)  AND CRAFT_SEQ =O.CRAFT_SEQ)
       DESGIN_KEY
         FROM HTT_OFFLINE_RESULT T
          LEFT JOIN PLN_ZY_RCL_M M ON  M.HEAT_PLAN_NO = NVL(T.HEAT_PLAN_NO,T.ZY_BATCH_ID1)
     LEFT JOIN PLN_ORDER_rcl_S O ON  O.PRO_PLAN_ID = T.PRO_PLAN_ID
   AND O.GX_PLAN_NO = T.GX_PLAN_NO
 WHERE 1=1
        AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.HB_FP_NUM, 0)) ) > 0
        AND T.RESULT_NO =?
          )  M  LEFT JOIN  (SELECT SUBCONTRACT_NO,MIN(SUBCONTRACT_LOG) SUBCONTRACT_LOG FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO) E ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO
          WHERE 1=1
          Order by M.PLINE_CODE, M.PRO_TIME
		]]>
	</query>

	<query id="frmEntrust.doQueryOfflineG" desc="产线">
		<![CDATA[
		SELECT M.*,E.SUBCONTRACT_LOG TYPE FROM
(
     SELECT RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       STATION_CODE,
       STATION_DESC,
        M.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
           NVL(T.FLAG_STOVE_NO,T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.LOAD_JUDGE_STOVE_NO,
       T.BATCH_NO,
       M.PRODUCCODE,
       M.PRODUCNAME,
       M.STEELCODE,
       M.STEELNAME,
       M.GRADECODE,
       M.GRADENAME,
       M.MODEL_CODE,
       M.MODEL_DESC,
       M.STD_CODE,
       M.STD_NAME,
       M.STD_STYLE,
       M.STD_STYLE_DESC,
       M.SPEC_CODE,
       M.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
      ACT_LEN_MIN || '-'  || ACT_LEN_MAX  ACT_LEN_RANGE,
     T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)) )  OFFLINE_NUM,
       (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.GROUP_WT, 0)) -
       TO_NUMBER(NVL(T.RE_WT, 0)) -     TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +  TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0)) )   OFFLINE_WT,
       SUBCONTRACT_NO,
       SUBCONTRACT_NUM,
       SUBCONTRACT_WT,
       SUBCONTRACT_TIME,
       SUBCONTRACT_NAME,
       SUBCONTRACTCOMPLETE_NUM,
       SUBCONTRACTCOMPLETE_WT,
       HB_FP_NUM,
       HB_FP_WT,
       SUBCONTRACTCOMPLETE_TIME,
       SUBCONTRACTCOMPLETE_NAME,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       T.MEMO,
       'G' PROCESS,
          O.CIC,
       O.PIC,
       O.SIC,
       O.DIC,
       O.WIC,
       O.INDEX_SEQ  MSC_PLINE,
         M.OUTPUT_STANDARD,
      (SELECT DESGIN_KEY FROM CRAFT_ORD_DESIGN WHERE ORD_LN_PK = (SELECT ORD_LN_PK FROM PLN_SALEORD WHERE ORD_LN_DLY_PK =O.ORD_LN_DLY_PK)  AND CRAFT_SEQ =O.CRAFT_SEQ)
       DESGIN_KEY
  FROM MCH_OFFLINE_RESULT T
     LEFT JOIN PLN_ZY_JGX_M M ON  M.HEAT_PLAN_NO = NVL(T.HEAT_PLAN_NO,T.ZY_BATCH_ID1)
    LEFT JOIN PLN_ORDER_JGX_S O ON  O.PRO_PLAN_ID = T.PRO_PLAN_ID
   AND O.GX_PLAN_NO = T.GX_PLAN_NO
 WHERE 1=1
        AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) -   TO_NUMBER(NVL(T.HB_FP_NUM, 0)) ) > 0
        AND T.RESULT_NO =?
          )  M  LEFT JOIN  (SELECT SUBCONTRACT_NO,MIN(SUBCONTRACT_LOG) SUBCONTRACT_LOG FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO) E ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO
          WHERE 1=1
          Order by M.PLINE_CODE, M.PRO_TIME
		]]>
	</query>

	<query id="frmEntrust.doQueryOfflineH" desc="产线">
		<![CDATA[
		SELECT M.*,E.SUBCONTRACT_LOG TYPE FROM
(
  SELECT RESULT_NO || '_' ||  OFF_XH RESULT_NO,
        T.PLINE_CODE,
        T.PLINE_NAME,
        STATION_CODE,
        STATION_DESC,
        HEAT_PLAN_NO,
        '' ZY_BATCH_ID,
        T.WO_ID PRO_PLAN_ID,
        '' GX_PLAN_NO,
        T.JUDGE_STOVE_NO FLAG_STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.BATCH_GROUD_NO,
        B.PRODUCCODE_JG PRODUCCODE,
        B.PRODUCCODE_JG_DESC PRODUCNAME,
        B.STEELCODE,
        B.STEELNAME,
        B.GRADECODE,
        B.GRADENAME,
        J.MODEL_CODE,
        J.MODEL_DESC,
        J.STD_CODE,
        J.STD_NAME,
        J.STD_STYLE,
        J.STD_STYLE_DESC,
        J.SPEC_JG SPEC_CODE,
          J.SPEC_JG_DESC  SPEC_NAME,
        J.DIAMETER_JG ACT_DIMATER,
        J.HEIGHT_JG ACT_HEIGHT,
        TO_NUMBER(J.LENGTH_JG) ACT_LEN,
        J.LENGTH_MIN || '-' || J.LENGTH_MAX ACT_LEN_RANGE,
        B.ORDER_NO || '/' || B.ORDER_SEQ ORDER_NO,
        (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
        TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
        TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_NUM,
        (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.RE_WT, 0)) -
        TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +
        TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0))) OFFLINE_WT,
        T.SUBCONTRACT_NO,
        SUBCONTRACT_NUM,
        SUBCONTRACT_WT,
        SUBCONTRACT_TIME,
        SUBCONTRACT_NAME,
        SUBCONTRACTCOMPLETE_NUM,
        SUBCONTRACTCOMPLETE_WT,
        HB_FP_NUM,
        HB_FP_WT,
        SUBCONTRACTCOMPLETE_TIME,
        SUBCONTRACTCOMPLETE_NAME,
        COL_USER PRO_USER,
        COL_SHIFT PRO_SHIFT,
        COL_GROUP PRO_GROUP,
        COL_TIME PRO_TIME,
        '' MEMO,
        'H' PROCESS,
        '' CIC,
        '' PIC,
        '' SIC,
        '' DIC,
        '' WIC,
        '' MSC_PLINE,
        ''  OUTPUT_STANDARD,
        '' DESGIN_KEY
   FROM COUPLING_OFFLINE_RESULT T, PLN_ZY_JG_WORKBILL B, COM_MSC_JG J
  WHERE T.WO_ID = B.WO_ID
    AND B.CODE_JG = J.CODE_JG
    AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
        TO_NUMBER(NVL(T.HB_FP_NUM, 0))) > 0
        AND T.RESULT_NO =?
        AND T.OFF_XH =?
          )  M  LEFT JOIN  (SELECT SUBCONTRACT_NO,MIN(SUBCONTRACT_LOG) SUBCONTRACT_LOG FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO) E ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO
          WHERE 1=1
          Order by M.PLINE_CODE, M.PRO_TIME
		]]>
	</query>

	<query id="frmEntrust.doQueryApply" desc="产线">
		<![CDATA[
           SELECT T.*,
           REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO2,
        NVL(SP_NOTE, SUBCONTRACT_NOTE) SUBCONTRACT_NOTE,
        TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
        DECODE(SUBCONTRACT_LOG, '60', TO_CHAR(T.SP_TIME, 'YYYY-MM-DD'), '') SP_TIME,
        DECODE(T.PROCESS_CODE,
               'D',
               (SELECT PRIORITY
                  FROM PLN_ORDER_ZG_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'E',
               (SELECT PRIORITY
                  FROM PLN_ORDER_DBK_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'F',
               (SELECT PRIORITY
                  FROM PLN_ORDER_RCL_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'G',
               (SELECT PRIORITY
                  FROM PLN_ORDER_JGX_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'H',
               (SELECT T1.PRIORITY
                  FROM PLN_SALEORD_PROC T1,
                       PLN_GX_JG_PROP_S T2,
                       PLN_ZY_JG_M      T3
                 WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                   AND T1.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
                   AND T2.PRO_PLAN_ID = T3.PRO_PLAN_ID
                   AND T2.GX_PLAN_NO = T3.GX_PLAN_NO
                   AND T3.HEAT_PLAN_NO = T.PRO_PLAN_ID),
               '') PRIORITY,
                       DECODE(T.PROCESS_CODE,
               'D',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_ZG_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'E',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_DBK_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'F',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_RCL_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'G',
               (SELECT PRIORITY_MEMO
                  FROM PLN_ORDER_JGX_S
                 WHERE PRO_PLAN_ID = T.PRO_PLAN_ID
                   AND GX_PLAN_NO = T.GX_PLAN_NO),
               'H',
               (SELECT T1.PRIORITY_MEMO
                  FROM PLN_SALEORD_PROC T1,
                       PLN_GX_JG_PROP_S T2,
                       PLN_ZY_JG_M      T3
                 WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                   AND T1.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
                   AND T2.PRO_PLAN_ID = T3.PRO_PLAN_ID
                   AND T2.GX_PLAN_NO = T3.GX_PLAN_NO
                   AND T3.HEAT_PLAN_NO = T.PRO_PLAN_ID),
               '') PRIORITY_MEMO,
               (SELECT LENGTHDISC
  FROM PLN_SALEORD T1,CRAFT_ORD_DESIGN T2
  WHERE T1.ORD_LN_PK = T2.ORD_LN_PK  AND T2.DESGIN_KEY = T.DESGIN_KEY
  AND ROWNUM = 1) LENGTHDISC,
  (SELECT TO_CHAR(MAX(OPERATE_DATE), 'YYYY-MM-DD HH24:MI:SS')
  FROM HTT_ENTRUST_PROCESS
 WHERE SUBCONTRACT_NO = T.SUBCONTRACT_NO
   AND NEW_STATUS = DECODE(T.SUBCONTRACT_TARGET, '0', '24', '10'))  START_TIME,
   DECODE(T.IS_DOWN,'1','是','') IS_DOWN

   FROM HTT_ENTRUST T
  WHERE 1 = 1
		]]>
	</query>


	<query id="frmEntrust.doQueryStorage" desc="委托方仓库">
		<![CDATA[
               SELECT A.*
  FROM YDM_BS_STORAGE A, COM_BASE_INFO B
 WHERE A.STORAGE_NO = B.BASENAME
   AND B.SORTCODE = '7032'

		]]>
	</query>

	<query id="frmEntrust.doQueryStorage2" desc="委托方仓库">
		<![CDATA[
            SELECT A.*
  FROM YDM_BS_STORAGE A LEFT JOIN  COM_BASE_INFO B ON A.STORAGE_NO = B.BASENAME    AND B.SORTCODE = '7032'
  WHERE 1= 1

		]]>
	</query>

	<query id="frmEntrust.doQueryBC" desc="半成品库存">
		<![CDATA[
			  SELECT M.*,NVL(E.SUBCONTRACT_LOG,DECODE(PROCESS,'BC','BC','ZC','ZC',E.SUBCONTRACT_LOG)) TYPE FROM
(
               SELECT '' RESULT_NO,
       BELONG_CODE PLINE_CODE,
      BELONG_NAME PLINE_NAME,
         '' STATION_CODE,
         '' STATION_DESC,
         T.HEAT_PLAN_NO,
         T.LOT_NO ZY_BATCH_ID,
         '' PRO_PLAN_ID,
         T.GX_PLAN_NO,
         FLAG_STOVE_NO_ZG FLAG_STOVE_NO,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.PRODUCCODE,
         T.PRODUCNAME,
         T.STEELCODE,
         T.STEELNAME,
         T.GRADECODE,
         T.GRADENAME,
         T.MODEL_CODE,
         T.MODEL_DESC,
         T.STD_CODE,
         T.STD_NAME,
         T.STD_STYLE,
         T.STD_STYLE_DESC,
         T.SPEC_CODE,
         T.SPEC_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
         T.PRO_ORDER_NO ORDER_NO,
         SUM(DECODE(T.MNG_LOCK_FLAG, '0', 1, 0)) OFFLINE_NUM,
         SUM(DECODE(T.MNG_LOCK_FLAG, '0', T.ACT_WEIGHT, 0)) OFFLINE_WT,
         SUBCONTRACT_NO,
         SUBCONTRACT_NO_SEQ,
         NULL SUBCONTRACT_NUM,
         NULL SUBCONTRACT_WT,
         NULL SUBCONTRACT_TIME,
         NULL SUBCONTRACT_NAME,
         NULL SUBCONTRACTCOMPLETE_NUM,
         NULL SUBCONTRACTCOMPLETE_WT,
         NULL HB_FP_NUM,
         NULL HB_FP_WT,
         NULL SUBCONTRACTCOMPLETE_TIME,
         '' SUBCONTRACTCOMPLETE_NAME,
         '' PRO_USER,
         '' PRO_SHIFT,
         '' PRO_GROUP,
         MAX(T.INSTOCK_TIME) PRO_TIME,
         '' MEMO,
         'BC' PROCESS,
         '' CIC,
         '' PIC,
         '' SIC,
         '' DIC,
         '' WIC,
         '' MSC_PLINE,
         (SELECT DESGIN_KEY
            FROM CRAFT_ORD_DESIGN
           WHERE ORD_LN_PK =
                 (SELECT ORD_LN_PK
                    FROM PLN_SALEORD
                   WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
             AND CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
                  WMSYS.WM_CONCAT(T.MAT_NO) MAT_NOS
    FROM MAT_BC_M T
   WHERE BELONG_CODE = '002001001'
     AND PRO_PLAN_ID_NEXT IS NULL
     AND GX_PLAN_NO_NEXT IS NULL
     AND HEAT_PLAN_NO_NEXT IS NULL
     AND QCM_STAUS = '00' #TIME4# #JUDGESTOVE#
   #PLINECODE1#
     AND 'BC' = '#STATUS1#'
   GROUP BY
             BELONG_CODE,BELONG_NAME,
             JUDGE_STOVE_NO,
            BATCH_NO,
            T.PLINE_CODE,
            T.PLINE_NAME,
            HEAT_PLAN_NO,
            LOT_NO,
            GX_PLAN_NO,
            FLAG_STOVE_NO_ZG,
            PRODUCCODE,
            PRODUCNAME,
            STEELCODE,
            STEELNAME,
            GRADECODE,
            GRADENAME,
            MODEL_CODE,
            MODEL_DESC,
            STD_CODE,
            STD_NAME,
            STD_STYLE,
            STD_STYLE_DESC,
            SPEC_CODE,
            SPEC_NAME,
            ACT_DIMATER,
            ACT_HEIGHT,
            ACT_LEN_MIN,
            ACT_LEN_MAX,
            PRO_ORDER_NO,
            ORD_LN_DLY_PK,
            CRAFT_SEQ,
            SUBCONTRACT_NO,
            SUBCONTRACT_NO_SEQ
   )  M
    LEFT JOIN  (SELECT SUBCONTRACT_NO,
    SUBCONTRACT_NO_SEQ,
    MIN(SUBCONTRACT_LOG)
    SUBCONTRACT_LOG
    FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO,SUBCONTRACT_NO_SEQ) E
     ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO  AND E.SUBCONTRACT_NO_SEQ = M.SUBCONTRACT_NO_SEQ
          WHERE 1=1
           #STATUS#
          Order by M.PLINE_CODE, M.PRO_TIME, M.JUDGE_STOVE_NO,M.BATCH_NO

		]]>
	</query>

	<query id="frmEntrust.doQueryBC2" desc="半成品库存">
		<![CDATA[
  SELECT M.*,NVL(E.SUBCONTRACT_LOG,DECODE(PROCESS,'BC','BC','ZC','ZC',E.SUBCONTRACT_LOG)) TYPE FROM
(
               SELECT '' RESULT_NO,
       BELONG_CODE PLINE_CODE,
      BELONG_NAME PLINE_NAME,
         '' STATION_CODE,
         '' STATION_DESC,
         T.HEAT_PLAN_NO,
         T.LOT_NO ZY_BATCH_ID,
         '' PRO_PLAN_ID,
         T.GX_PLAN_NO,
         FLAG_STOVE_NO_ZG FLAG_STOVE_NO,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.PRODUCCODE,
         T.PRODUCNAME,
         T.STEELCODE,
         T.STEELNAME,
         T.GRADECODE,
         T.GRADENAME,
         T.MODEL_CODE,
         T.MODEL_DESC,
         T.STD_CODE,
         T.STD_NAME,
         T.STD_STYLE,
         T.STD_STYLE_DESC,
         T.SPEC_CODE,
         T.SPEC_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
         T.PRO_ORDER_NO ORDER_NO,
         SUM(DECODE(T.MNG_LOCK_FLAG, '0', 1, 0)) OFFLINE_NUM,
         SUM(DECODE(T.MNG_LOCK_FLAG, '0', T.ACT_WEIGHT, 0)) OFFLINE_WT,
         SUBCONTRACT_NO,
         SUBCONTRACT_NO_SEQ,
         NULL SUBCONTRACT_NUM,
         NULL SUBCONTRACT_WT,
         NULL SUBCONTRACT_TIME,
         NULL SUBCONTRACT_NAME,
         NULL SUBCONTRACTCOMPLETE_NUM,
         NULL SUBCONTRACTCOMPLETE_WT,
         NULL HB_FP_NUM,
         NULL HB_FP_WT,
         NULL SUBCONTRACTCOMPLETE_TIME,
         '' SUBCONTRACTCOMPLETE_NAME,
         '' PRO_USER,
         '' PRO_SHIFT,
         '' PRO_GROUP,
         MAX(T.INSTOCK_TIME) PRO_TIME,
         '' MEMO,
         'BC' PROCESS,
         '' CIC,
         '' PIC,
         '' SIC,
         '' DIC,
         '' WIC,
         '' MSC_PLINE,
         (SELECT DESGIN_KEY
            FROM CRAFT_ORD_DESIGN
           WHERE ORD_LN_PK =
                 (SELECT ORD_LN_PK
                    FROM PLN_SALEORD
                   WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
             AND CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
                  WMSYS.WM_CONCAT(T.MAT_NO) MAT_NOS
    FROM MAT_BC_M T
   WHERE BELONG_CODE = '002001001'
     AND PRO_PLAN_ID_NEXT IS NULL
     AND GX_PLAN_NO_NEXT IS NULL
     AND HEAT_PLAN_NO_NEXT IS NULL
     AND QCM_STAUS = '00'
       #MAT_NO#
   GROUP BY
             BELONG_CODE,BELONG_NAME,
             JUDGE_STOVE_NO,
            BATCH_NO,
            T.PLINE_CODE,
            T.PLINE_NAME,
            HEAT_PLAN_NO,
            LOT_NO,
            GX_PLAN_NO,
            FLAG_STOVE_NO_ZG,
            PRODUCCODE,
            PRODUCNAME,
            STEELCODE,
            STEELNAME,
            GRADECODE,
            GRADENAME,
            MODEL_CODE,
            MODEL_DESC,
            STD_CODE,
            STD_NAME,
            STD_STYLE,
            STD_STYLE_DESC,
            SPEC_CODE,
            SPEC_NAME,
            ACT_DIMATER,
            ACT_HEIGHT,
            ACT_LEN_MIN,
            ACT_LEN_MAX,
            PRO_ORDER_NO,
            ORD_LN_DLY_PK,
            CRAFT_SEQ,
            SUBCONTRACT_NO,
            SUBCONTRACT_NO_SEQ
   )  M
    LEFT JOIN  (SELECT SUBCONTRACT_NO,
    SUBCONTRACT_NO_SEQ,
    MIN(SUBCONTRACT_LOG)
    SUBCONTRACT_LOG
    FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO,SUBCONTRACT_NO_SEQ) E
     ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO  AND E.SUBCONTRACT_NO_SEQ = M.SUBCONTRACT_NO_SEQ
          WHERE 1=1
          Order by M.PLINE_CODE, M.PRO_TIME, M.JUDGE_STOVE_NO,M.BATCH_NO
		]]>
	</query>

	<query id="frmEntrust.doQueryZC" desc="成品库存">
		<![CDATA[
			  SELECT M.*,NVL(E.SUBCONTRACT_LOG,DECODE(PROCESS,'BC','BC','ZC','ZC','SP','SP',E.SUBCONTRACT_LOG)) TYPE  FROM
(
            SELECT  '' RESULT_NO,
           BELONG_CODE PLINE_CODE,
      BELONG_NAME PLINE_NAME,
      '' STATION_CODE,
      '' STATION_DESC,
       T.HEAT_PLAN_NO,
       T.LOT_NO ZY_BATCH_ID,
       '' PRO_PLAN_ID,
       T.GX_PLAN_NO,
       FLAG_STOVE_NO_ZG FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
      T.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
       T.PRO_ORDER_NO ORDER_NO,
      SUM(DECODE(T.MNG_LOCK_FLAG,'0',1,0 ))  OFFLINE_NUM,
        SUM(DECODE(T.MNG_LOCK_FLAG,'0',T.ACT_WEIGHT,0 ))  OFFLINE_WT,
       SUBCONTRACT_NO,
          SUBCONTRACT_NO_SEQ,
        NULL SUBCONTRACT_NUM,
       NULL SUBCONTRACT_WT,
       NULL SUBCONTRACT_TIME,
       NULL SUBCONTRACT_NAME,
       NULL SUBCONTRACTCOMPLETE_NUM,
       NULL SUBCONTRACTCOMPLETE_WT,
       NULL HB_FP_NUM,
       NULL HB_FP_WT,
       NULL SUBCONTRACTCOMPLETE_TIME,
       '' SUBCONTRACTCOMPLETE_NAME,
       '' PRO_USER,
       '' PRO_SHIFT,
       '' PRO_GROUP,
       MAX(T.INSTOCK_TIME) PRO_TIME ,
      '' MEMO,
       DECODE(PRODUCT_FLAG,'801402','ZC','801403','SP') PROCESS,
       '' CIC,
       '' PIC,
       '' SIC,
       '' DIC,
       '' WIC,
       '' MSC_PLINE,
       '' DESGIN_KEY,
            WMSYS.WM_CONCAT(T.MAT_NO) MAT_NOS,
             Y.STORAGE_NO STORAGE_TYPE_NO,
               (SELECT STORAGE_NAME
                  FROM YDM_BS_STORAGE
                 WHERE STORAGE_NO = Y.STORAGE_NO) STORAGE_TYPE_NAME
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS Y
   WHERE T.MAT_NO =Y.MAT_NO
       AND (PRODUCT_FLAG = '801402' OR (PRODUCT_FLAG = '801403' AND MAT_STATUS = '80150301'))
       -- AND 'ZC' = '#STATUS1#'
       #TIME4#
       #JUDGESTOVE#
       #ORDERNO#
       #PLINECODE1#
   GROUP BY
   BELONG_CODE,BELONG_NAME,PRODUCT_FLAG,
   T.JUDGE_STOVE_NO,T.BATCH_NO,T.PLINE_CODE,T.PLINE_NAME,HEAT_PLAN_NO,LOT_NO,GX_PLAN_NO,FLAG_STOVE_NO_ZG,
   PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       SPEC_CODE,
      SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
        Y.STORAGE_NO,
       ACT_LEN_MIN,ACT_LEN_MAX,PRO_ORDER_NO,ORD_LN_DLY_PK,
      SUBCONTRACT_NO,
         SUBCONTRACT_NO_SEQ
   )  M
     LEFT JOIN  (SELECT SUBCONTRACT_NO,
    SUBCONTRACT_NO_SEQ,
    MIN(SUBCONTRACT_LOG)
    SUBCONTRACT_LOG
    FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO,SUBCONTRACT_NO_SEQ) E
     ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO  AND E.SUBCONTRACT_NO_SEQ = M.SUBCONTRACT_NO_SEQ
         WHERE 1=1
           #STATUS#
           AND PROCESS  IN (#STATUS1#)
          Order by M.PLINE_CODE, M.PRO_TIME, M.JUDGE_STOVE_NO,M.BATCH_NO

		]]>
	</query>

	<query id="frmEntrust.doQueryZC2" desc="成品库存">
		<![CDATA[

	  SELECT M.*,NVL(E.SUBCONTRACT_LOG,DECODE(PROCESS,'BC','BC','ZC','ZC','SP','SP',E.SUBCONTRACT_LOG))  TYPE FROM
(
            SELECT  '' RESULT_NO,
           BELONG_CODE PLINE_CODE,
      BELONG_NAME PLINE_NAME,
      '' STATION_CODE,
      '' STATION_DESC,
       T.HEAT_PLAN_NO,
       T.LOT_NO ZY_BATCH_ID,
       '' PRO_PLAN_ID,
       T.GX_PLAN_NO,
       FLAG_STOVE_NO_ZG FLAG_STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
      T.SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
       T.PRO_ORDER_NO ORDER_NO,
      SUM(DECODE(T.MNG_LOCK_FLAG,'0',1,0 ))  OFFLINE_NUM,
        SUM(DECODE(T.MNG_LOCK_FLAG,'0',T.ACT_WEIGHT,0 ))  OFFLINE_WT,
       SUBCONTRACT_NO,
          SUBCONTRACT_NO_SEQ,
        NULL SUBCONTRACT_NUM,
       NULL SUBCONTRACT_WT,
       NULL SUBCONTRACT_TIME,
       NULL SUBCONTRACT_NAME,
       NULL SUBCONTRACTCOMPLETE_NUM,
       NULL SUBCONTRACTCOMPLETE_WT,
       NULL HB_FP_NUM,
       NULL HB_FP_WT,
       NULL SUBCONTRACTCOMPLETE_TIME,
       '' SUBCONTRACTCOMPLETE_NAME,
       '' PRO_USER,
       '' PRO_SHIFT,
       '' PRO_GROUP,
       MAX(T.INSTOCK_TIME) PRO_TIME ,
      '' MEMO,
       'ZC' PROCESS,
       '' CIC,
       '' PIC,
       '' SIC,
       '' DIC,
       '' WIC,
       '' MSC_PLINE,
       '' DESGIN_KEY,
            WMSYS.WM_CONCAT(T.MAT_NO) MAT_NOS
  FROM MAT_ZC_M T
   WHERE
   -- PRODUCT_FLAG= '801402'
     (PRODUCT_FLAG = '801402' OR (PRODUCT_FLAG = '801403' AND MAT_STATUS = '80150301'))
       	#MAT_NO#
   GROUP BY
   BELONG_CODE,BELONG_NAME,
   JUDGE_STOVE_NO,BATCH_NO,T.PLINE_CODE,T.PLINE_NAME,HEAT_PLAN_NO,LOT_NO,GX_PLAN_NO,FLAG_STOVE_NO_ZG,
   PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       SPEC_CODE,
      SPEC_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN_MIN,ACT_LEN_MAX,PRO_ORDER_NO,ORD_LN_DLY_PK,
      SUBCONTRACT_NO,
         SUBCONTRACT_NO_SEQ
   )  M
     LEFT JOIN  (SELECT SUBCONTRACT_NO,
    SUBCONTRACT_NO_SEQ,
    MIN(SUBCONTRACT_LOG)
    SUBCONTRACT_LOG
    FROM  HTT_ENTRUST GROUP BY SUBCONTRACT_NO,SUBCONTRACT_NO_SEQ) E
     ON E.SUBCONTRACT_NO =M.SUBCONTRACT_NO  AND E.SUBCONTRACT_NO_SEQ = M.SUBCONTRACT_NO_SEQ
         WHERE 1=1
          Order by M.PLINE_CODE, M.PRO_TIME, M.JUDGE_STOVE_NO,M.BATCH_NO


		]]>
	</query>

	<query id="frmEntrust.GetHttEntrustCutDetailEntity" desc="产线">
		<![CDATA[
                SELECT * FROM htt_entrust_mat_no WHERE RESULT_NO_OFFLINE =? AND MAT_NO = ?
		]]>
	</query>

	<query id="frmEntrust.GetHttEntrustCutDetailEntity3" desc="产线">
		<![CDATA[
                SELECT * FROM htt_entrust_mat_no WHERE RESULT_NO_OFFLINE =?
		]]>
	</query>

	<query id="frmEntrust.GetHttEntrustCutDetailEntity2" desc="产线">
		<![CDATA[
                SELECT *
     FROM HTT_ENTRUST_MAT_NO
    WHERE SUBCONTRACT_NO = ?
      AND SUBCONTRACT_NO_SEQ = ?
      AND MAT_NO = ?

		]]>
	</query>

	<query id="frmEntrust.GetHttEntrustUnCutMatNo" desc="产线">
		<![CDATA[
                   SELECT T.MAT_NO,
             SUM(M.ACT_LEN) ACT_LEN,
             SUM(M.ACT_WEIGHT) ACT_WEIGHT,
             SUM(M.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
        FROM HTT_ENTRUST_MAT_NO T
        LEFT JOIN MAT_BC_M M
          ON T.MAT_NO_CUT = M.MAT_NO
       WHERE T.SUBCONTRACT_NO = ?
         AND T.SUBCONTRACT_NO_SEQ = ?
       GROUP BY T.MAT_NO

		]]>
	</query>

	<query id="frmEntrust.GetHttEntrustZcUnCutMatNo" desc="产线">
		<![CDATA[
                   SELECT T.MAT_NO,
             SUM(M.ACT_LEN) ACT_LEN,
             SUM(M.ACT_WEIGHT) ACT_WEIGHT,
             SUM(M.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
        FROM HTT_ENTRUST_MAT_NO T
        LEFT JOIN  (SELECT * FROM  MAT_ZC_M UNION ALL SELECT * FROM MAT_ZC_BACKUP)  M
          ON T.MAT_NO_CUT = M.MAT_NO
       WHERE T.SUBCONTRACT_NO = ?
         AND T.SUBCONTRACT_NO_SEQ = ?
       GROUP BY T.MAT_NO

		]]>
	</query>

	<query id="frmEntrust.doQueryResult" desc="产线">
		<![CDATA[
                 SELECT 
       T.RESULT_NO,
       T.HEAT_PLAN_NO,
       T.BATCH_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PRO_NUM,
       T.PRO_WT,
       T.FAIL_NUM,
       T.FAIL_WT,
       T.PRO_YEAR_MONTH_DAY,
       T.BAL_YEAR_MONTH,
       T.PRO_SHIFT,
       T.PRO_GROUP,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.PRO_USER,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.JUDGE_STOVE_NO,
       T.MEMO,
       T.TEST_PRESSURE,
       T.HOLDTIME_TIME,
       T.TEST_PRESSURE_Y,
       T.OUTNUM_CUT,
       T.MIN_TEMP,
       T.HHEAT_TEMP,
       T.LHEAT_TEMP,
       T.SUBCONTRACT_TYPE,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       T.REPORT_PATH,
       T.TESTING_POSITION,
       T.TESTING_STANDARD,
       T.TESTING_GRADE,
       T.MACHINE_NO,
       T.NOTCH_LENGTH,
       T.NOTCH_WIDTH,
       T.NOTCH_DEPTH,
       T.TESTING_TYPE,
       T.HHEAT_TIME,
       T.LHEAT_TIME,
       T.PROJECT_CODE,
       T.PROJECT_NAME,
       T.REPORT_NO,
       T.INCISION_NUM,
       T.BUNDLING_NUM,
       DECODE(T.RETURN_FLAG,'0','未返库','1','已返库') RETURN_FLAG,
       T.RETURN_NAME,
       TO_CHAR(T.RETURN_TIME, 'YYYY-MM-DD HH24:MI:SS') RETURN_TIME
 FROM HTT_ENTRUST_RESULT T
 WHERE
SUBCONTRACT_NO=? AND SUBCONTRACT_NO_SEQ =?
		]]>
	</query>

	<query id="frmEntrust.doQueryResult2" desc="产线">
		<![CDATA[
                 SELECT T.* FROM HTT_ENTRUST_RESULT  T WHERE RESULT_NO=?
		]]>
	</query>

	<query id="frmEntrust.doQueryResultCount" desc="产线">
		<![CDATA[
                 SELECT COUNT(1) COUNT FROM HTT_ENTRUST_RESULT  T WHERE SUBCONTRACT_NO=?
		]]>
	</query>

	<query id="frmEntrust.doQueryMaxNo" desc="产线">
		<![CDATA[
                 SELECT ? ||  TO_CHAR(SYSDATE,'YYYYMM') ||
  LPAD(NVL(MAX(TO_NUMBER(SUBSTR(SUBCONTRACT_NO, LENGTH(SUBCONTRACT_NO) - 3))),
  0) + 1,
  4,
  '0') SUBCONTRACT_NO
  FROM htt_entrust
  WHERE SUBCONTRACT_NO LIKE  ? ||  TO_CHAR(SYSDATE,'NYYYYMM') || '____'
		]]>
	</query>

	<query id="frmEntrust.UpdateOfflineD" desc="产线">
		<![CDATA[
UPDATE MIL_OFFLINE_RESLUT T
   SET (SUBCONTRACT_NO, SUBCONTRACTCOMPLETE_NAME, SUBCONTRACTCOMPLETE_TIME) =
       (SELECT SUBCONTRACT_NO, RESPOND_USER, RESPOND_TIME
          FROM (SELECT RESULT_NO,
                       SUBCONTRACT_NO_SEQ,
                       RESPOND_USER,
                       RESPOND_TIME,
                       SUBCONTRACT_NO,
                       NVL(SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
                       ROW_NUMBER() OVER(PARTITION BY RESULT_NO ORDER BY SUBCONTRACT_TIME DESC) RK
                  FROM HTT_ENTRUST) E
         WHERE E.RESULT_NO = T.JUDGE_STOVE_NO || '_' || T.OFFLINE_PRO || '_' ||
               T.OFFLINE_TYPE
           AND RK = 1),
       (SUBCONTRACT_NUM,
        SUBCONTRACTCOMPLETE_NUM,
        SUBCONTRACTCOMPLETE_WGT,
        SUBCONTRACTSCRAP_NUM) =
      (SELECT SUM(SUBCONTRACT_NUM),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_WT, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_NUM, 0))
          FROM HTT_ENTRUST
                 WHERE SUBCONTRACT_LOG <> '20'
                 AND  RESULT_NO =T.JUDGE_STOVE_NO || '_' || T.OFFLINE_PRO || '_' ||
               T.OFFLINE_TYPE),
       SUBCONTRACT_COMPLETE_CUT =
       (SELECT T2.OUTNUM_CUT
          FROM HTT_ENTRUST T1, HTT_ENTRUST_RESULT T2
         WHERE T1.SUBCONTRACT_NO = T2.SUBCONTRACT_NO
           AND T1.SUBCONTRACT_NO_SEQ = T2.SUBCONTRACT_NO_SEQ
           AND T1.RESULT_NO = T.JUDGE_STOVE_NO || '_' || T.OFFLINE_PRO || '_' ||
               T.OFFLINE_TYPE
           AND T2.OUTNUM_CUT IS NOT NULL
           AND ROWNUM = 1)
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.OFFLINE_PRO = ?
   AND T.OFFLINE_TYPE = ?
		]]>
	</query>

	<query id="frmEntrust.UpdateOfflineE" desc="产线">
		<![CDATA[
 UPDATE VRP_OFFLINE_RESULT T
   SET (SUBCONTRACT_NO,
        SUBCONTRACT_NO_SEQ,
        SUBCONTRACT_NAME,
        SUBCONTRACT_TIME) =
       (SELECT SUBCONTRACT_NO,
               SUBCONTRACT_NO_SEQ,
               RESPOND_USER,
               RESPOND_TIME
          FROM (SELECT RESULT_NO,
                       SUBCONTRACT_NO_SEQ,
                       RESPOND_USER,
                       RESPOND_TIME,
                       SUBCONTRACT_NO,
                       NVL(SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
                       ROW_NUMBER() OVER(PARTITION BY RESULT_NO ORDER BY SUBCONTRACT_TIME DESC) RK
                  FROM HTT_ENTRUST) E
         WHERE E.RESULT_NO = T.RESULT_NO
           AND RK = 1),
        (SUBCONTRACT_NUM,
        SUBCONTRACT_WT,
        SUBCONTRACTCOMPLETE_NUM,
        SUBCONTRACTCOMPLETE_WT,
        HB_FP_NUM,
        HB_FP_WT) =
      (SELECT SUM(SUBCONTRACT_NUM),
               SUM(SUBCONTRACT_WT),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_WT, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_WT, 0))
          FROM HTT_ENTRUST
                 WHERE SUBCONTRACT_LOG <> '20'
                 AND  RESULT_NO = T.RESULT_NO)
 WHERE T.RESULT_NO = ?
		]]>
	</query>

	<query id="frmEntrust.UpdateOfflineF" desc="产线">
		<![CDATA[


UPDATE HTT_OFFLINE_RESULT T
   SET (SUBCONTRACT_NO,
        SUBCONTRACT_NO_SEQ,
        SUBCONTRACTCOMPLETE_NAME,
        SUBCONTRACTCOMPLETE_TIME,SUBCONTRACT_NAME,SUBCONTRACT_TIME) =
       (SELECT SUBCONTRACT_NO,
               SUBCONTRACT_NO_SEQ,
               RESPOND_USER,
               RESPOND_TIME,SUBCONTRACT_USER,SUBCONTRACT_TIME
          FROM (SELECT RESULT_NO,
                       SUBCONTRACT_NO_SEQ,
                       RESPOND_USER,
                       RESPOND_TIME,
                       SUBCONTRACT_NO,SUBCONTRACT_USER,SUBCONTRACT_TIME,
                       NVL(SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
                       ROW_NUMBER() OVER(PARTITION BY RESULT_NO ORDER BY SUBCONTRACT_TIME DESC) RK
                  FROM HTT_ENTRUST) E
         WHERE E.RESULT_NO = T.RESULT_NO
           AND RK = 1),
       (SUBCONTRACT_NUM,
        SUBCONTRACT_WT,
        SUBCONTRACTCOMPLETE_NUM,
        SUBCONTRACTCOMPLETE_WT,
        HB_FP_NUM,
        HB_FP_WT) =
       (SELECT SUM(SUBCONTRACT_NUM),
               SUM(SUBCONTRACT_WT),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_WT, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_WT, 0))
          FROM HTT_ENTRUST
                 WHERE SUBCONTRACT_LOG <> '20'
                 AND  RESULT_NO = T.RESULT_NO)
 WHERE T.RESULT_NO = ?
		]]>
	</query>

	<query id="frmEntrust.UpdateOfflineG" desc="产线">
		<![CDATA[


UPDATE MCH_OFFLINE_RESULT T
   SET (SUBCONTRACT_NO,
        SUBCONTRACT_NO_SEQ,
        SUBCONTRACTCOMPLETE_NAME,
        SUBCONTRACTCOMPLETE_TIME,SUBCONTRACT_NAME,SUBCONTRACT_TIME) =
       (SELECT SUBCONTRACT_NO,
               SUBCONTRACT_NO_SEQ,
               RESPOND_USER,
               RESPOND_TIME,SUBCONTRACT_USER,SUBCONTRACT_TIME
          FROM (SELECT RESULT_NO,
                       SUBCONTRACT_NO_SEQ,
                       RESPOND_USER,
                       RESPOND_TIME,
                       SUBCONTRACT_NO,SUBCONTRACT_USER,SUBCONTRACT_TIME,
                       NVL(SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
                       ROW_NUMBER() OVER(PARTITION BY RESULT_NO ORDER BY SUBCONTRACT_TIME DESC) RK
                  FROM HTT_ENTRUST) E
         WHERE E.RESULT_NO = T.RESULT_NO
           AND RK = 1),
        (SUBCONTRACT_NUM,
        SUBCONTRACT_WT,
        SUBCONTRACTCOMPLETE_NUM,
        SUBCONTRACTCOMPLETE_WT,
        HB_FP_NUM,
        HB_FP_WT) =
       (SELECT SUM(SUBCONTRACT_NUM),
               SUM(SUBCONTRACT_WT),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_WT, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_WT, 0))
          FROM HTT_ENTRUST
                 WHERE SUBCONTRACT_LOG <> '20'
                 AND  RESULT_NO = T.RESULT_NO)
 WHERE T.RESULT_NO = ?
		]]>
	</query>


	<query id="frmEntrust.UpdateOfflineH" desc="产线">
		<![CDATA[


UPDATE COUPLING_OFFLINE_RESULT T
   SET (SUBCONTRACT_NO,
        SUBCONTRACT_NO_SEQ,
        SUBCONTRACTCOMPLETE_NAME,
        SUBCONTRACTCOMPLETE_TIME,SUBCONTRACT_NAME,SUBCONTRACT_TIME) =
       (SELECT SUBCONTRACT_NO,
               SUBCONTRACT_NO_SEQ,
               RESPOND_USER,
               RESPOND_TIME,SUBCONTRACT_USER,SUBCONTRACT_TIME
          FROM (SELECT RESULT_NO,
                       SUBCONTRACT_NO_SEQ,
                       RESPOND_USER,
                       RESPOND_TIME,
                       SUBCONTRACT_NO,SUBCONTRACT_USER,SUBCONTRACT_TIME,
                       NVL(SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
                       ROW_NUMBER() OVER(PARTITION BY RESULT_NO ORDER BY SUBCONTRACT_TIME DESC) RK
                  FROM HTT_ENTRUST) E
         WHERE E.RESULT_NO = T.RESULT_NO || '_' || T.OFF_XH
           AND RK = 1),
        (SUBCONTRACT_NUM,
        SUBCONTRACT_WT,
        SUBCONTRACTCOMPLETE_NUM,
        SUBCONTRACTCOMPLETE_WT,
        HB_FP_NUM,
        HB_FP_WT) =
       (SELECT SUM(SUBCONTRACT_NUM),
               SUM(SUBCONTRACT_WT),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_COMPLETE_WT, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_NUM, 0)),
               SUM(DECODE(SUBCONTRACT_LOG, '60', HB_FP_WT, 0))
          FROM HTT_ENTRUST
                 WHERE SUBCONTRACT_LOG <> '20'
                 AND  RESULT_NO =  T.RESULT_NO || '_' || T.OFF_XH )
 WHERE T.RESULT_NO = ?
      AND T.OFF_XH =?
		]]>
	</query>


	<query id="frmEntrust.UpdateMatBcMBC" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?,MNG_LOCK_FLAG = ?
   WHERE T.BELONG_CODE = '002001001'

		]]>
	</query>


	<query id="frmEntrust.UpdateMatBcMBC2" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET MNG_LOCK_FLAG = ?
   WHERE T.BELONG_CODE = '002001001'
     AND T.SUBCONTRACT_NO =?

		]]>
	</query>

	<query id="frmEntrust.UpdateMatBcMBC3" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?
   WHERE 1=1
		]]>
	</query>


	<query id="frmEntrust.UpdateMatBcMZC" desc="产线">
		<![CDATA[
UPDATE MAT_ZC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?, MNG_LOCK_FLAG= ?
 WHERE (PRODUCT_FLAG = '801402' OR (PRODUCT_FLAG = '801403' AND MAT_STATUS = '80150301'))

		]]>
	</query>

	<query id="frmEntrust.UpdateMatBcMZC2" desc="产线">
		<![CDATA[
UPDATE MAT_ZC_M T
   SET MNG_LOCK_FLAG= ?
 WHERE (PRODUCT_FLAG = '801402' OR (PRODUCT_FLAG = '801403' AND MAT_STATUS = '80150301'))
 AND SUBCONTRACT_NO = ?

		]]>
	</query>

	<query id="frmEntrust.UpdateMatBcMD" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?
 WHERE OFFLINE_DOC IN (SELECT OFFLINE_DOC
                         FROM MIL_OFFLINE_RESLUT
                        WHERE JUDGE_STOVE_NO = ?
                          AND OFFLINE_PRO = ?
                          AND OFFLINE_TYPE = ?)

		]]>
	</query>


	<query id="frmEntrust.UpdateMatBcME" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?
 WHERE OFFLINE_DOC IN (SELECT OFFLINE_DOC
                         FROM MIL_OFFLINE_RESLUT
                        WHERE JUDGE_STOVE_NO = ?
                          AND OFFLINE_PRO = ?
                          AND OFFLINE_TYPE = ?)

		]]>
	</query>



	<query id="frmEntrust.UpdateMatBcMF" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?
 WHERE OFFLINE_DOC IN (SELECT OFFLINE_DOC
                         FROM MIL_OFFLINE_RESLUT
                        WHERE JUDGE_STOVE_NO = ?
                          AND OFFLINE_PRO = ?
                          AND OFFLINE_TYPE = ?)

		]]>
	</query>



	<query id="frmEntrust.UpdateMatBcMG" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?
 WHERE OFFLINE_DOC IN (SELECT OFFLINE_DOC
                         FROM MIL_OFFLINE_RESLUT
                        WHERE JUDGE_STOVE_NO = ?
                          AND OFFLINE_PRO = ?
                          AND OFFLINE_TYPE = ?)

		]]>
	</query>




	<query id="frmEntrust.UpdateMatBcM" desc="产线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET SUBCONTRACT_NO = ?, SUBCONTRACT_NO_SEQ = ?
 WHERE OFFLINE_DOC = ?

		]]>
	</query>

	<query id="frmEntrust.AddApply" desc="产线">
		<![CDATA[
       INSERT INTO HTT_ENTRUST
  (SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   PLINE_CODE,
   PLINE_NAME,
   HEAT_PLAN_NO,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   LOAD_JUDGE_STOVE_NO,
   BATCH_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   SUBCONTRACT_LOG,
   SUBCONTRACT_PLINE_CODE,
   SUBCONTRACT_PLINE_NAME,
   SUBCONTRACT_NOTE,
   SP_NOTE,
   RESULT_NO,
   SUBCONTRACT_USER,
   SUBCONTRACT_SHIFT,
   SUBCONTRACT_GROUP,
   SUBCONTRACT_TIME,
   SP_USER,
   SP_TIME,
   RESPOND_USER,
   RESPOND_TIME,
   SUBCONTRACT_TYPE,
   NEW_BATCH_NO,
   ORDER_NO,
   ACT_DIMATER,
   ACT_HEIGHT,
   SUBCONTRACT_NUM,
   SUBCONTRACT_WT,
   HB_COMPLETE_NUM,
   HB_COMPLETE_WT,
   HB_FP_NUM,
   HB_FP_WT,
   CUT_NUM,
   PROCESS_CODE,
   APPLY_NOTE,
   PROD_STANDARD,
   SPEC_CODE,
   SPEC_NAME,
   CIC,
   PIC,
   SIC,
   DIC,
   WIC,
   GIC,
   DESGIN_KEY,
   MSC_PLINE,
   SUBCONTRACT_TARGET,
   SUBCONTRACT_OPERATOR,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   IF_MONITOR,
   DRAWINGNO,
   FLAG_STOVE_NO,
   IS_RETURN,
   OUTPUT_STANDARD,
   SUBCONTRACT_LEN)
VALUES
  ('#SUBCONTRACT_NO#',
   '#SUBCONTRACT_NO_SEQ#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#HEAT_PLAN_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#LOAD_JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#PRO_PLAN_ID#',
   '#GX_PLAN_NO#',
   '#PRODUCCODE#',
   '#PRODUCNAME#',
   '#STEELCODE#',
   '#STEELNAME#',
   '#GRADECODE#',
   '#GRADENAME#',
   '#MODEL_CODE#',
   '#MODEL_DESC#',
   '#STD_CODE#',
   '#STD_NAME#',
   '#STD_STYLE#',
   '#STD_STYLE_DESC#',
   '#SUBCONTRACT_LOG#',
   '#SUBCONTRACT_PLINE_CODE#',
   '#SUBCONTRACT_PLINE_NAME#',
   '#SUBCONTRACT_NOTE#',
   '#SP_NOTE#',
   '#RESULT_NO#',
   '#SUBCONTRACT_USER#',
   '#SUBCONTRACT_SHIFT#',
   '#SUBCONTRACT_GROUP#',
   SYSDATE,
   '#SP_USER#',
   null,
   '#RESPOND_USER#',
   '#RESPOND_TIME#',
   '#SUBCONTRACT_TYPE#',
   '#NEW_BATCH_NO#',
   '#ORDER_NO#',
   '#ACT_DIMATER#',
   '#ACT_HEIGHT#',
   '#SUBCONTRACT_NUM#',
   '#SUBCONTRACT_WT#',
   '#HB_COMPLETE_NUM#',
   '#HB_COMPLETE_WT#',
   '#HB_FP_NUM#',
   '#HB_FP_WT#',
   '#CUT_NUM#',
   '#PROCESS_CODE#',
   '#APPLY_NOTE#',
   '#PROD_STANDARD#',
   '#SPEC_CODE#',
   '#SPEC_NAME#',
   '#CIC#',
   '#PIC#',
   '#SIC#',
   '#DIC#',
   '#WIC#',
   '#GIC#',
   '#DESGIN_KEY#',
   '#MSC_PLINE#',
   '#SUBCONTRACT_TARGET#',
   '#SUBCONTRACT_OPERATOR#',
   '#STORAGE_TYPE_NO#',
   (SELECT STORAGE_NAME
      FROM YDM_BS_STORAGE
     WHERE STORAGE_NO = '#STORAGE_TYPE_NO#'),
   '#IF_MONITOR#',
   '#DRAWINGNO#',
   '#FLAG_STOVE_NO#',
   '#IS_RETURN#',
   '#OUTPUT_STANDARD#',
   '#SUBCONTRACT_NUM#' * '#SUBCONTRACT_LEN#')
		]]>
	</query>

	<query id="frmEntrust.AddApplyProject" desc="产线">
		<![CDATA[
       INSERT INTO HTT_ENTRUST_PROJECT
  (PROJECT_CODE,
   PROJECT_NAME,
   PROJECT_STATUS,
   PROJECT_MEMO,
   PROJECT_FLAG,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   PROJECT_TYPE,
   PROJECT_MEMO_ORGIN,
   PROJECT_TYPE_ORGIN,
   PAY_DEPARTMENT_CODE,
   PAY_DEPARTMENT_NAME,
   PROJECT_SEQ)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?)
		]]>
	</query>

	<query id="frmEntrust.AddApplyProject2" desc="产线">
		<![CDATA[
       INSERT INTO HTT_ENTRUST_PROJECT
  (PROJECT_CODE,
   PROJECT_NAME,
   PROJECT_STATUS,
   PROJECT_MEMO,
   PROJECT_FLAG,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   PROJECT_TYPE,
   PROJECT_MEMO_ORGIN,
   PROJECT_TYPE_ORGIN,
   PAY_DEPARTMENT_CODE,
   PAY_DEPARTMENT_NAME)
SELECT
  ?,
   ?,
   ?,
   ?,
   ?,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   ?,
   ?,
   ?,
   ?,
   ?
   FROM HTT_ENTRUST WHERE SUBCONTRACT_NO =?
		]]>
	</query>

	<query id="frmEntrust.DeleteApplyProject" desc="产线">
		<![CDATA[
       DELETE FROM HTT_ENTRUST_PROJECT WHERE SUBCONTRACT_NO= ?
		]]>
	</query>

	<query id="frmEntrust.DeleteApply" desc="产线">
		<![CDATA[
        DELETE FROM HTT_ENTRUST  WHERE SUBCONTRACT_NO =?

		]]>
	</query>

	<query id="frmEntrust.UpdateEntrustStatus" desc="产线">
		<![CDATA[
        UPDATE HTT_ENTRUST T SET  SUBCONTRACT_LOG =  NVL(?,SUBCONTRACT_LOG),SUBCONTRACT_PLINE_CODE=?,
        SUBCONTRACT_PLINE_NAME = (SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE=?),
        SP_NOTE =?,SP_USER= ? , SP_TIME =SYSDATE, SUBCONTRACT_OPERATOR =?, DRAWINGNO = ?, SUBCONTRACT_NOTE=?,
         SUBCONTRACT_TYPE = DECODE((SELECT COUNT(1)
                                   FROM HTT_ENTRUST_PROJECT
                                  WHERE SUBCONTRACT_NO = T.SUBCONTRACT_NO
                                    AND SUBCONTRACT_NO_SEQ =
                                        T.SUBCONTRACT_NO_SEQ
                                    AND PROJECT_FLAG IN ('0', '1', '3')
                                    AND PROJECT_CODE LIKE '702202%'),
                                 0,
                                 '0',
                                 NULL,
                                 '0',
                                 '1')
        WHERE SUBCONTRACT_NO = ?
		]]>
	</query>


	<query id="frmEntrust.UpdateEntrustCheckNo" desc="产线">
		<![CDATA[
        UPDATE HTT_ENTRUST SET  CHECK_NO =?
        WHERE SUBCONTRACT_NO = ? AND SUBCONTRACT_NO_SEQ =?
		]]>
	</query>

	<query id="frmEntrust.UpdateEntrustStatus3" desc="产线">
		<![CDATA[
UPDATE HTT_ENTRUST T
   SET (RESPOND_USER, RESPOND_TIME) =
       (SELECT PRO_USER SUBCONTRACT_NO_SEQ, PRO_TIME
          FROM (SELECT SUBCONTRACT_NO,
                       SUBCONTRACT_NO_SEQ,
                       PRO_USER,
                       PRO_TIME,
                       ROW_NUMBER() OVER(PARTITION BY SUBCONTRACT_NO, SUBCONTRACT_NO_SEQ ORDER BY PRO_TIME DESC) RK
                  FROM HTT_ENTRUST_RESULT) E
         WHERE E.SUBCONTRACT_NO = T.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = T.SUBCONTRACT_NO_SEQ
           AND RK = 1),
       (HB_FP_NUM, HB_FP_WT, HB_COMPLETE_NUM, HB_COMPLETE_WT) =
      (SELECT SUM(FAIL_NUM),
               SUM(FAIL_WT),
               NVL(T.SUBCONTRACT_NUM_CUT, T.SUBCONTRACT_NUM) -
               NVL(SUM(DECODE(E.OUTNUM_CUT, NULL, FAIL_NUM, 1, FAIL_NUM, 0)),
                   0),
               T.SUBCONTRACT_WT - NVL(SUM(FAIL_WT), 0)
          FROM HTT_ENTRUST_RESULT E
          LEFT JOIN (SELECT SUBCONTRACT_NO,
                           SUBCONTRACT_NO_SEQ,
                           SUM(PRO_NUM) CUT_NUM,
                           SUM(PRO_NUM * OUTNUM_CUT) AFTER_CUT_NUM
                      FROM HTT_ENTRUST_RESULT
                     WHERE OUTNUM_CUT > 1
                     GROUP BY SUBCONTRACT_NO, SUBCONTRACT_NO_SEQ) R
            ON E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
         WHERE E.SUBCONTRACT_NO = T.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = T.SUBCONTRACT_NO_SEQ),
       SUBCONTRACT_LOG = '40'
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>

	<query id="frmEntrust.UpdateEntrustStatus4" desc="产线">
		<![CDATA[

UPDATE HTT_ENTRUST T
   SET  RESPOND_USER =null,
          RESPOND_TIME= null,
          HB_FP_NUM = 0,
          HB_FP_WT  =0,
      SUBCONTRACT_LOG = '30',
       HB_COMPLETE_NUM = 0,
       HB_COMPLETE_WT = 0
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>


	<query id="frmEntrust.UpdateEntrustStatus6" desc="产线">
		<![CDATA[

UPDATE HTT_ENTRUST T
   SET    SUBCONTRACT_LOG = ?
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>


	<query id="frmEntrust.Down" desc="产线">
		<![CDATA[

UPDATE HTT_ENTRUST T
   SET    IS_DOWN = ?
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>


	<query id="frmEntrust.UpdateEntrustStatus2" desc="产线">
		<![CDATA[
              UPDATE HTT_ENTRUST T
          SET SUBCONTRACT_LOG = DECODE((SELECT COUNT(1)
                                         FROM HTT_ENTRUST_RESULT R
                                        WHERE R.SUBCONTRACT_NO =
                                              T.SUBCONTRACT_NO
                                          AND R.SUBCONTRACT_NO_SEQ =
                                              T.SUBCONTRACT_NO_SEQ),
                                       0,
                                       29,
                                       '30')
        WHERE SUBCONTRACT_NO = ?
          AND SUBCONTRACT_NO_SEQ = ?


		]]>
	</query>

	<query id="frmEntrust.UpdateEntrustStatus5" desc="产线">
		<![CDATA[
   UPDATE HTT_ENTRUST T
     SET SUBCONTRACT_NUM_CUT =
         (SELECT NVL(SUM(PRO_NUM * OUTNUM_CUT), 0) +
                 (CASE
                    WHEN T.SUBCONTRACT_NUM > NVL(SUM(PRO_NUM), 0) - NVL(SUM(FAIL_NUM),0)  THEN
                     T.SUBCONTRACT_NUM - NVL(SUM(PRO_NUM), 0) - NVL(SUM(FAIL_NUM),0)
                    ELSE
                     0
                  END)
            FROM HTT_ENTRUST_RESULT
           WHERE OUTNUM_CUT > 1
             AND SUBCONTRACT_NO = T.SUBCONTRACT_NO
             AND SUBCONTRACT_NO_SEQ = T.SUBCONTRACT_NO_SEQ)
   WHERE SUBCONTRACT_NO =?
     AND SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>
	
	<query id="frmEntrust.queryFpNum" desc="产线">
		<![CDATA[
   select NVL(T.HB_FP_NUM, 0) ACOUNT, t.*, t.rowid
  from HTT_ENTRUST t
 where T.PLINE_CODE IN ('100101', '100102')
   AND t.subcontract_no = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>



	<query id="frmEntrust.DeleteResultNo" desc="产线">
		<![CDATA[
          DELETE FROM HTT_ENTRUST_RESULT WHERE RESULT_NO =?

		]]>
	</query>


	<query id="frmEntrust.AddResultNo" desc="产线">
		<![CDATA[
   INSERT INTO HTT_ENTRUST_RESULT
  (RESULT_NO,
   HEAT_PLAN_NO,
   BATCH_NO,
   PLINE_CODE,
   PLINE_NAME,
   PRO_NUM,
   PRO_WT,
   FAIL_NUM,
   FAIL_WT,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   PRO_SHIFT,
   PRO_GROUP,
   CREATE_TIME,
   PRO_USER,
   PRO_TIME,
   JUDGE_STOVE_NO,
   MEMO,
   TEST_PRESSURE,
   HOLDTIME_TIME,
   TEST_PRESSURE_Y,
   OUTNUM_CUT,
   MIN_TEMP,
   HHEAT_TEMP,
   LHEAT_TEMP,
   SUBCONTRACT_TYPE,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   REPORT_PATH,
   TESTING_POSITION,
   TESTING_STANDARD,
   TESTING_GRADE,
   MACHINE_NO,
   NOTCH_LENGTH,
   NOTCH_WIDTH,
   NOTCH_DEPTH,
   TESTING_TYPE,PROJECT_CODE,PROJECT_NAME,REPORT_NO)
  SELECT T.RESULT_NO,
         T.HEAT_PLAN_NO,
         T.BATCH_NO,
         T.PLINE_CODE,
         T.PLINE_NAME,
         T.TESTING_NUM,
         T.TESTING_WT,
         NVL(T.EWASTE_NUM, 0) + NVL(T.EWASTE_NUM_ET, 0) +
         NVL(T.REJECT_NUM, 0),
          NVL(T.EWASTE_WT,0),
         T.PRO_YEAR_MONTH_DAY,
         T.BAL_YEAR_MONTH,
         T.COL_SHIFT,
         T.COL_GROUP,
         SYSDATE,
         T.COL_USER,
         T.COL_TIME,
         T.JUDGE_STOVE_NO,
         P.MEMO,
         NULL,
         NULL,
         NULL,
         1,
         NULL,
         NULL,
         NULL,
         '1',
         ?,
         ?,
         NULL,
         T.TESTING_POSITION,
         T.TESTING_STANDARD,
         T.TESTING_GRADE,
         T.MACHINE_NO,
         T.NOTCH_LENGTH,
         T.NOTCH_WIDTH,
         T.NOTCH_DEPTH,
         T.TESTING_TYPE, '702202', (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE='702202'),T.REPORT_NO
    FROM HTT_CRACK_DETECTION_ET T, HTT_CRACK_DETECTION_PARA P
   WHERE T.RESULT_NO = P.RESULT_NO
     AND T.RESULT_NO = ?
		]]>
	</query>

	<query id="frmEntrust.AddNewResultNo" desc="产线">
	<![CDATA[
   INSERT INTO HTT_ENTRUST_RESULT
  (RESULT_NO,
   HEAT_PLAN_NO,
   BATCH_NO,
   PLINE_CODE,
   PLINE_NAME,
   PRO_NUM,
   PRO_WT,
   FAIL_NUM,
   FAIL_WT,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   PRO_SHIFT,
   PRO_GROUP,
   CREATE_TIME,
   PRO_USER,
   PRO_TIME,
   JUDGE_STOVE_NO,
   MEMO,
   TEST_PRESSURE,
   HOLDTIME_TIME,
   TEST_PRESSURE_Y,
   OUTNUM_CUT,
   MIN_TEMP,
   HHEAT_TEMP,
   LHEAT_TEMP,
   SUBCONTRACT_TYPE,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   REPORT_PATH,
   TESTING_POSITION,
   TESTING_STANDARD,
   TESTING_GRADE,
   MACHINE_NO,
   NOTCH_LENGTH,
   NOTCH_WIDTH,
   NOTCH_DEPTH,
   TESTING_TYPE,
   HHEAT_TIME,
   LHEAT_TIME,PROJECT_CODE,PROJECT_NAME,INCISION_NUM,BUNDLING_NUM,MEAS_HEAD,
        MEAS_MIDDLE,
        MEAS_END,
        MEAS_HEAD4,
        MEAS_MIDDLE4,
        MEAS_END4,
        MEAS_HEAD_AFTER,
        MEAS_MIDDLE_AFTER,
        MEAS_END_AFTER,
        PATCH_NO)
VALUES
  ('#RESULT_NO#',
   '#HEAT_PLAN_NO#',
   '#BATCH_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#PRO_NUM#',
   '#PRO_WT#',
   '#FAIL_NUM#',
   '#FAIL_WT#',
  TO_CHAR(TO_DATE('#PRO_TIME#', 'YYYY-MM-DD HH24:MI:SS'),'YYYYMMDD'),
   TO_CHAR(TO_DATE('#PRO_TIME#', 'YYYY-MM-DD HH24:MI:SS'),'YYYYMM'),
   '#PRO_SHIFT#',
   '#PRO_GROUP#',
   SYSDATE,
   '#PRO_USER#',
  TO_DATE('#PRO_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#JUDGE_STOVE_NO#',
   '#MEMO#',
   '#TEST_PRESSURE#',
   '#HOLDTIME_TIME#',
   '#TEST_PRESSURE_Y#',
   '#OUTNUM_CUT#',
   '#MIN_TEMP#',
   '#HHEAT_TEMP#',
   '#LHEAT_TEMP#',
   '#SUBCONTRACT_TYPE#',
   '#SUBCONTRACT_NO#',
   '#SUBCONTRACT_NO_SEQ#',
   '#REPORT_PATH#',
   '#TESTING_POSITION#',
   '#TESTING_STANDARD#',
   '#TESTING_GRADE#',
   '#MACHINE_NO#',
   '#NOTCH_LENGTH#',
   '#NOTCH_WIDTH#',
   '#NOTCH_DEPTH#',
   '#TESTING_TYPE#',
   '#HHEAT_TIME#',
   '#LHEAT_TIME#','#PROJECT_CODE#','#PROJECT_NAME#','#INCISION_NUM#','#BUNDLING_NUM#',
    '#MEAS_HEAD#',
        '#MEAS_MIDDLE#',
        '#MEAS_END#',
        '#MEAS_HEAD4#',
        '#MEAS_MIDDLE4#',
        '#MEAS_END4#',
        '#MEAS_HEAD_AFTER#',
        '#MEAS_MIDDLE_AFTER#',
        '#MEAS_END_AFTER#',
        '#PATCH_NO#')
		]]>
</query>

	<query id="frmEntrust.AddHyResultNo" desc="同步水压信息到加工线实绩">
		<![CDATA[
 INSERT INTO MCH_WATERGAGE_RESULT
  (RESULT_NO,
   HEAT_PLAN_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   PLINE_CODE,
   PLINE_NAME,
   IF_MONITOR_RCL,
   PRDCR_NO,
   PRODUCER,
   PRODUCER_TIME,
   TEST_PRESSURE,
   HOLDTIME_TIME,
   FLUSH_PRESSURE,
   FLUSH_TIME,
   FLUSH_RESULT,
   OUTNUM_CUT,
   PRO_USER,
   PRO_TIME,
   PRO_NUM,
   PRO_WT,
   FAIL_NUM,
   FAIL_WT,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   PRO_SHIFT,
   PRO_GROUP,
   CREATE_TIME,
   TEST_PRESSURE_Y,
   RE_PRO_NUM,
   RE_PRO_WT,
   MEMO,
   RESPONSIBLE,
   REPORT_PATH,
   FINAL_QUALIFIED_NUM,
   FINAL_QUALIFIED_WT,
   QUALIFIED_NUM,
   QUALIFIED_WT)
  SELECT RESULT_NO,
         HEAT_PLAN_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         PLINE_CODE,
         PLINE_NAME,
         '',
         '',
         '',
         '',
         TEST_PRESSURE,
         HOLDTIME_TIME,
         '',
         '',
         '',
         OUTNUM_CUT,
         PRO_USER,
         PRO_TIME,
         PRO_NUM,
         PRO_WT,
         FAIL_NUM,
         FAIL_WT,
         PRO_YEAR_MONTH_DAY,
         BAL_YEAR_MONTH,
         PRO_SHIFT,
         PRO_GROUP,
         CREATE_TIME,
         TEST_PRESSURE_Y,
         0,
         0,
         MEMO,
         '',
         REPORT_PATH,
         PRO_NUM-FAIL_NUM ,
        PRO_WT-FAIL_WT,
        PRO_NUM-FAIL_NUM ,
        PRO_WT-FAIL_WT
    FROM HTT_ENTRUST_RESULT
    WHERE RESULT_NO = ?

		]]>
	</query>

	<query id="frmEntrust.DeleteHyResultNo" desc="同步水压信息到加工线实绩">
		<![CDATA[
DELETE MCH_WATERGAGE_RESULT
    WHERE RESULT_NO = ?
		]]>
	</query>

	<query id="frmEntrust.QueryOfflineMatNoD" desc="产线">
		<![CDATA[
SELECT M.MAT_NO,
       '否' IS_SAMPLE_PIPE,
       '未入库' INSTORE_FLAG,
       M.ACT_LEN,
       M.ACT_WEIGHT,
       NVL(M.ACT_THEORY_WEIGHT,M.ACT_WEIGHT) ACT_THEORY_WEIGHT,
       '合格' MAT_STATUS
  FROM MAT_BC_M M, MIL_OFFLINE_RESLUT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.OFFLINE_PRO = ?
   AND T.OFFLINE_TYPE = ?
   AND ((T.ZP_FLAG = '0' AND T.JUDGE_STOVE_NO = M.ZG_STOVE_SQE) OR
       (T.ZP_FLAG = '1' AND
       M.ZG_STOVE_SQE IN
       (SELECT OLD_ZP_JUDGE_STOVE_NO
            FROM MIL_OFFLINE_GROUP
           WHERE ZP_JUDGE_STOVE_NO = T.JUDGE_STOVE_NO)))

		]]>
	</query>


	<query id="frmEntrust.QueryOfflineMatNoE" desc="产线">
		<![CDATA[
        SELECT  NVL(C.MAT_NO_CUT, P.MAT_NO) MAT_NO,
       DECODE(P.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       DECODE(P.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
      P.ACT_LEN/NVL(C.CUT_NUM,1)  ACT_LEN,
       P.ACT_WEIGHT/NVL(C.CUT_NUM,1) ACT_WEIGHT,
      P.ACT_THEORY_WEIGHT/NVL(C.CUT_NUM,1) ACT_THEORY_WEIGHT,
         DECODE(M.QCM_STAUS,'11','合格','剔除') MAT_STATUS,
              C.MAT_NO M_MAT_NO
  FROM PORT_VRP_BATCH_SAMPLE_RESULT P LEFT JOIN HTT_ENTRUST_MAT_NO C ON C.RESULT_NO_OFFLINE = P.RESULT_NO AND P.MAT_NO = C.MAT_NO AND C.MAT_STATUS='0', MAT_BC_M M
 WHERE P.MAT_NO = M.MAT_NO
   AND P.MAT_STATUS = '20'
  AND P.RESULT_NO IN (SELECT LX_RESULT_NO
                          FROM VRP_GROUP_RESULT
                         WHERE GROUP_ID IN
                               (SELECT GROUP_ID
                                  FROM VRP_OFFLINE_RESULT
                                 WHERE RESULT_NO = ?)
                        UNION
                        SELECT ?
                          FROM DUAL)
 ORDER BY  NVL(C.MAT_NO_CUT, P.MAT_NO)
		]]>
	</query>


	<query id="frmEntrust.QueryOfflineMatNoF" desc="产线">
		<![CDATA[
       SELECT  NVL(C.MAT_NO_CUT, P.MAT_NO) MAT_NO,
       DECODE(P.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       DECODE(P.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
      P.ACT_LEN/NVL(C.CUT_NUM,1)  ACT_LEN,
       P.ACT_WEIGHT/NVL(C.CUT_NUM,1) ACT_WEIGHT,
         P.ACT_THEORY_WEIGHT/NVL(C.CUT_NUM,1) ACT_THEORY_WEIGHT,
         DECODE(M.QCM_STAUS,'11','合格','剔除') MAT_STATUS,
                   C.MAT_NO M_MAT_NO
  FROM PORT_HTT_BATCH_SAMPLE_RESULT P LEFT JOIN HTT_ENTRUST_MAT_NO C ON C.RESULT_NO_OFFLINE = P.RESULT_NO AND P.MAT_NO = C.MAT_NO AND C.MAT_STATUS='0', MAT_BC_M M
 WHERE P.MAT_NO = M.MAT_NO
   AND P.MAT_STATUS = '20'
   AND P.RESULT_NO IN (SELECT LX_RESULT_NO
                          FROM HTT_GROUP_RESULT
                         WHERE GROUP_ID IN
                               (SELECT GROUP_ID
                                  FROM HTT_OFFLINE_RESULT
                                 WHERE RESULT_NO = ?)
                        UNION
                        SELECT ?
                          FROM DUAL)
 ORDER BY  NVL(C.MAT_NO_CUT, P.MAT_NO)
		]]>
	</query>

	<query id="frmEntrust.QueryOfflineMatNoG" desc="产线">
		<![CDATA[
   SELECT NVL(C.MAT_NO_CUT, P.MAT_NO) MAT_NO,
       DECODE(P.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       DECODE(P.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
       P.ACT_LEN/NVL(C.CUT_NUM,1)  ACT_LEN,
       P.ACT_WEIGHT/NVL(C.CUT_NUM,1) ACT_WEIGHT,
         P.ACT_THEORY_WEIGHT/NVL(C.CUT_NUM,1) ACT_THEORY_WEIGHT,
        DECODE(M.QCM_STAUS,'11','合格','剔除') MAT_STATUS,
              C.MAT_NO M_MAT_NO
  FROM  PORT_MCH_BATCH_SAMPLE_RESULT P LEFT JOIN HTT_ENTRUST_MAT_NO C ON C.RESULT_NO_OFFLINE = P.RESULT_NO AND P.MAT_NO = C.MAT_NO AND C.MAT_STATUS='0', MAT_BC_M M
   WHERE P.MAT_NO = M.MAT_NO
   AND P.MAT_STATUS = '20'
   AND P.RESULT_NO IN (SELECT LX_RESULT_NO
                          FROM MCH_GROUP_RESULT
                         WHERE GROUP_ID IN
                               (SELECT GROUP_ID
                                  FROM MCH_OFFLINE_RESULT
                                 WHERE RESULT_NO = ?)
                        UNION
                        SELECT ?
                          FROM DUAL)
 ORDER BY  NVL(C.MAT_NO_CUT, P.MAT_NO)
		]]>
	</query>

	<query id="frmEntrust.QueryOfflineMatNoH" desc="产线">
		<![CDATA[

SELECT JUDGE_STOVE_NO || BATCH_NO || LPAD(D.NO, 4, 0) MAT_NO,
       '否' IS_SAMPLE_PIPE,
       '未入库' INSTORE_FLAG,
       '' ACT_LEN,
       --  ROUND(OFFLINE_WT / OFFLINE_NUM, 3),
       '合格' MAT_STATUS
  FROM COUPLING_OFFLINE_RESULT T,
       (SELECT ROWNUM NO
          FROM DUAL
        CONNECT BY ROWNUM < =
                   (SELECT SUBCONTRACT_NUM
                      FROM COUPLING_OFFLINE_RESULT
                     WHERE RESULT_NO = ?
                     AND OFF_XH = ?)) D
 WHERE T.RESULT_NO = ?
 AND T.OFF_XH = ?

		]]>
	</query>


	<query id="frmEntrust.QueryOfflineMatNo" desc="产线">
		<![CDATA[
SELECT NVL(C.MAT_NO_CUT, P.MAT_NO) MAT_NO,
       '0' IS_SAMPLE_PIPE,
       '未入库' INSTORE_FLAG,
       P.ACT_LEN / NVL(C.CUT_NUM, 1) ACT_LEN,
       P.ACT_WEIGHT / NVL(C.CUT_NUM, 1) ACT_WEIGHT,
       NVL(P.ACT_THEORY_WEIGHT, P.ACT_WEIGHT)  / NVL(C.CUT_NUM, 1) ACT_THEORY_WEIGHT,
       DECODE(F.MAT_NO,
              NULL,
              DECODE(C.MAT_NO,
                     NULL,
                     '合格',
                     DECODE(C.MAT_STATUS, '0', '合格', '剔除')),
              '剔除') MAT_STATUS,
                   C.MAT_NO M_MAT_NO
  FROM MAT_BC_M P
  LEFT JOIN HTT_ENTRUST_MAT_NO C
    ON C.SUBCONTRACT_NO = P.SUBCONTRACT_NO
   AND C.SUBCONTRACT_NO_SEQ = P.SUBCONTRACT_NO_SEQ
   AND P.MAT_NO = C.MAT_NO
  LEFT JOIN (SELECT R.SUBCONTRACT_NO, R.SUBCONTRACT_NO_SEQ, M.MAT_NO
               FROM MCH_BUG_D D, MCH_WASTE_MAT_NO M, HTT_ENTRUST_RESULT R
              WHERE D.FAIL_BILL = M.FAIL_BILL
                AND D.FAIL_BILL_SQE = M.FAIL_BILL_SQE
                AND D.RESULT_NO = R.RESULT_NO
                AND D.FAIL_SORT = '10'
              GROUP BY R.SUBCONTRACT_NO, R.SUBCONTRACT_NO_SEQ, M.MAT_NO) F
    ON P.SUBCONTRACT_NO = F.SUBCONTRACT_NO
   AND P.SUBCONTRACT_NO_SEQ = F.SUBCONTRACT_NO_SEQ
   AND P.MAT_NO = F.MAT_NO
 WHERE P.SUBCONTRACT_NO = ?
   AND P.SUBCONTRACT_NO_SEQ = ?
 ORDER BY P.MAT_NO,C.MAT_NO_CUT

		]]>
	</query>

	<query id="frmEntrust.QueryZcMatNo" desc="产线">
		<![CDATA[
SELECT NVL(C.MAT_NO_CUT, P.MAT_NO) MAT_NO,
       '0' IS_SAMPLE_PIPE,
       '未入库' INSTORE_FLAG,
       P.ACT_LEN / NVL(C.CUT_NUM, 1) ACT_LEN,
       P.ACT_WEIGHT / NVL(C.CUT_NUM, 1) ACT_WEIGHT,
        NVL(P.ACT_THEORY_WEIGHT, P.ACT_WEIGHT)  / NVL(C.CUT_NUM, 1) ACT_THEORY_WEIGHT,
       DECODE(F.MAT_NO,
              NULL,
              DECODE(C.MAT_NO,
                     NULL,
                     '合格',
                     DECODE(C.MAT_STATUS, '0', '合格', '剔除')),
              '剔除') MAT_STATUS
  FROM MAT_ZC_M P
  LEFT JOIN HTT_ENTRUST_MAT_NO C
    ON C.SUBCONTRACT_NO = P.SUBCONTRACT_NO
   AND C.SUBCONTRACT_NO_SEQ = P.SUBCONTRACT_NO_SEQ
   AND P.MAT_NO = C.MAT_NO
  LEFT JOIN (SELECT R.SUBCONTRACT_NO, R.SUBCONTRACT_NO_SEQ, M.MAT_NO
               FROM MCH_BUG_D D, MCH_WASTE_MAT_NO M, HTT_ENTRUST_RESULT R
              WHERE D.FAIL_BILL = M.FAIL_BILL
                AND D.FAIL_BILL_SQE = M.FAIL_BILL_SQE
                AND D.RESULT_NO = R.RESULT_NO
                AND D.FAIL_SORT = '10'
              GROUP BY R.SUBCONTRACT_NO, R.SUBCONTRACT_NO_SEQ, M.MAT_NO) F
    ON P.SUBCONTRACT_NO = F.SUBCONTRACT_NO
   AND P.SUBCONTRACT_NO_SEQ = F.SUBCONTRACT_NO_SEQ
   AND P.MAT_NO = F.MAT_NO
 WHERE P.SUBCONTRACT_NO = ?
   AND P.SUBCONTRACT_NO_SEQ = ?
 ORDER BY P.MAT_NO,C.MAT_NO_CUT
		]]>
	</query>


	<query id="frmEntrust.GetNewBatchNoD" desc="产线">
		<![CDATA[

SELECT TO_NUMBER(MAX(BATCH_NO)) + 1 BATCH_NO
  FROM (SELECT MAX(BATCH_NO) BATCH_NO
          FROM QCM_ZC_CHECKCONSIGN
         WHERE JUDGE_STOVE_NO = ?
        UNION ALL
        SELECT MAX(BATCH_NO) BATCH_NO
          FROM PORT_MIL_BATCH_SAMPLE_RESULT
         WHERE JUDGE_STOVE_NO = ?)


		]]>
	</query>

	<query id="frmEntrust.GetNewBatchNoE" desc="产线">
		<![CDATA[

SELECT TO_NUMBER(MAX(BATCH_NO)) + 1 BATCH_NO
  FROM QCM_ZC_CHECKCONSIGN
 WHERE JUDGE_STOVE_NO = ?


		]]>
	</query>

	<query id="frmEntrust.GetNewBatchNoF" desc="产线">
		<![CDATA[

SELECT TO_NUMBER(MAX(BATCH_NO)) + 1 BATCH_NO
  FROM QCM_ZC_CHECKCONSIGN
 WHERE JUDGE_STOVE_NO = ?


		]]>
	</query>

	<query id="frmEntrust.GetNewBatchNoG" desc="产线">
		<![CDATA[

SELECT (TO_NUMBER(MAX(BATCH_NO)) + 1) BATCH_NO
  FROM QCM_ZC_CHECKCONSIGN
 WHERE JUDGE_STOVE_NO = ?


		]]>
	</query>

	<query id="frmEntrust.UpdatePortBatchNoD" desc="产线">
		<![CDATA[
UPDATE PORT_MIL_BATCH_SAMPLE_RESULT
   SET BATCH_NO = ?
 WHERE JUDGE_STOVE_NO = ?
   AND BATCH_NO = ?
   AND STATUS='3' AND OP_PROCESS = DECODE(?,'JZ','9','TS','10','ZJ','11','XX','12','')
   AND ROWNUM <= ?
		]]>
	</query>

	<query id="frmEntrust.UpdatePortBatchNoE" desc="产线">
		<![CDATA[
 UPDATE PORT_VRP_BATCH_SAMPLE_RESULT
   SET PHY_BATCH_NO = ?
 WHERE HEAT_PLAN_NO = ?
   AND PHY_BATCH_NO = ?
   AND ROWNUM <= ?
		]]>
	</query>

	<query id="frmEntrust.UpdatePortBatchNoF" desc="产线">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT
   SET PHY_BATCH_NO =?
 WHERE HEAT_PLAN_NO = ?
   AND PHY_BATCH_NO = ?
   AND RESULT_NO = ?
   AND ROWNUM < ?

		]]>
	</query>

	<query id="frmEntrust.UpdatePortBatchNoG" desc="产线">
		<![CDATA[

UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
   SET PHY_BATCH_NO = ?
 WHERE HEAT_PLAN_NO = ?
   AND PHY_BATCH_NO = ?
   AND RESULT_NO = ?
   AND ROWNUM < ?

		]]>
	</query>

	<query id="frmEntrust.CheckApproval0" desc="产线">
		<![CDATA[

SELECT *
  FROM QCM_ZC_CHECKCONSIGN
 WHERE JUDGE_STOVE_NO = ?
  AND BATCH_NO =?
		]]>
	</query>

	<query id="frmEntrust.QueryMaxResultNo" desc="产线">
		<![CDATA[
	SELECT ? ||
	LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
	0) + 1,
	6,
	'0') RESULT_NO
	FROM HTT_ENTRUST_RESULT
	WHERE RESULT_NO LIKE ? || '______'

		]]>
	</query>


	<query id="frmEntrust.UpdatePortE" desc="产线">
		<![CDATA[
    UPDATE PORT_HTT_BATCH_SAMPLE_RESULT
   SET MAT_STATUS = DECODE((SELECT MIN(SUBCONTRACT_LOG)
                             FROM HTT_ENTRUST
                            WHERE SUBCONTRACT_NO = ?),
                           '40',
                           '30',
                           '20')
 WHERE (HEAT_PLAN_NO, MAT_NO) IN
       (SELECT D.HEAT_PLAN_NO, M.MAT_NO
          FROM MCH_BUG_D D, MCH_WASTE_MAT_NO M
         WHERE RESULT_NO IN
               (SELECT RESULT_NO
                  FROM HTT_ENTRUST_RESULT
                 WHERE SUBCONTRACT_NO = ?)
           AND D.FAIL_BILL = M.FAIL_BILL
           AND D.FAIL_BILL_SQE = D.FAIL_BILL_SQE
           AND FAIL_SORT = '20')


		]]>
	</query>


	<query id="frmEntrust.AddProcess" desc="产线">
		<![CDATA[
INSERT INTO HTT_ENTRUST_PROCESS
  (SUBCONTRACT_NO,
   OPERATE_SEQ,
   OPERATE_ACTION,
   OPERATE_NAME,
   OPERATE_DATE,
   MEMO,OLD_STATUS,NEW_STATUS)
VALUES
  (?,
   (SELECT NVL(MAX(OPERATE_SEQ), 0) + 1
      FROM HTT_ENTRUST_PROCESS
     WHERE SUBCONTRACT_NO = ?),
   ?,
   ?,
   SYSDATE,
   ?,?,?)
		]]>
	</query>


	<query id="frmEntrust.AddProcessAuto" desc="产线">
		<![CDATA[
INSERT INTO HTT_ENTRUST_AUTO
  (SUBCONTRACT_NO, APPROVAL_NO, APPROVAL_TYPE)
VALUES
  (?, ?, ?)

		]]>
	</query>

	<query id="frmEntrust.deleteProcess" desc="产线">
		<![CDATA[
DELETE FROM HTT_ENTRUST_PROCESS WHERE SUBCONTRACT_NO = ?
		]]>
	</query>

	<query id="frmEntrust.deleteProcessAuto" desc="产线">
		<![CDATA[
DELETE FROM HTT_ENTRUST_AUTO WHERE SUBCONTRACT_NO = ?
		]]>
	</query>


	<query id="frmEntrust.deletemessge" desc="产线">
		<![CDATA[
UPDATE APP_MESSAGE SET VALIDFLAG='00' WHERE REFER_KEY = ? AND VALIDFLAG='20'
		]]>
	</query>


	<query id="frmEntrust.selectProject" desc="产线">
		<![CDATA[
SELECT * FROM HTT_ENTRUST_PROJECT T WHERE 1=1
		]]>
	</query>
	
	<query id="frmEntrust.getMaxSeq" desc="产线">
		<![CDATA[
 SELECT  ? || TO_CHAR(SYSDATE,'YYYYMMDD' ) ||
  LPAD(NVL(MAX(TO_NUMBER(SUBSTR(DEMAND_NO, LENGTH(DEMAND_NO) - 4))),
  0) + 1,
  5,
  '0') DEMAND_NO
  FROM TMS_DEMAND_M
  WHERE DEMAND_NO LIKE ? || TO_CHAR(SYSDATE,'YYYYMMDD' )  ||  '_____'
		]]>
	</query>
	
	<query id="frmEntrust.deleteWlInfo" desc="产线">
		<![CDATA[
	delete  TMS_DEMAND_M where refe_no= ?
		]]>
	</query>
	
		<query id="frmEntrust.deleteWlInfoByBillNo" desc="产线">
		<![CDATA[
	delete  TMS_DEMAND_M where refe_no like ? ||'%'
		]]>
	</query>
	
		<query id="frmEntrust.UpdateEntrustTransCode" desc="产线">
		<![CDATA[
	UPDATE HTT_ENTRUST SET TRANSCODE = ? WHERE SUBCONTRACT_NO =?  AND SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>
	
	<query id="frmEntrust.getWlFromDbk" desc="产线">
		<![CDATA[
select t.outwl_id wlCode,t.outwl_desc wlName,t.aimlength,t.aimlength_max,t.aimlength_min,t.upper_heatplan_id  from pln_zy_dbk_m t  where t.heat_plan_no=?
		]]>
	</query>
	
	<query id="frmEntrust.getWlFromJg" desc="产线">
		<![CDATA[
select t.outwl_id wlCode,t.outwl_desc wlName,t.aimlength,t.LENGTH_MAX,t.LENGTH_MIN,t.upper_heatplan_id  from pln_zy_jg_m t  where t.heat_plan_no=?
		]]>
	</query>
	
	<query id="frmEntrust.getWlFromRcl" desc="产线">
		<![CDATA[
select t.outwl_id wlCode,t.outwl_desc wlName,t.aimlength,t.aimlength_max,t.aimlength_min,t.upper_heatplan_id  from pln_zy_rcl_m t  where t.heat_plan_no=?
		]]>
	</query>
	
	<query id="frmEntrust.getWlFromJgx" desc="产线">
		<![CDATA[
select t.outwl_id wlCode,t.outwl_desc wlName,t.aimlength,t.aimlength_max,t.aimlength_min,t.upper_heatplan_id  from pln_zy_jgx_m t  where t.heat_plan_no=?
		]]>
	</query>
	
	<query id="frmEntrust.getWlFromZg" desc="产线">
		<![CDATA[
select t.outwl_id wlCode,t.outwl_desc wlName,t.aimlength,t.aimlength_max,t.aimlength_min,t.upper_heatplan_id  from pln_zy_zg_m t  where t.heat_plan_no=?
		]]>
	</query>
	
	<query id="frmEntrust.InsertWlInfo" desc="产线">
		<![CDATA[
		INSERT INTO TMS_DEMAND_M
  			(DEMAND_NO,
  			DEMAND_DESC,
  			EXECUTE_SQE,
  			URGENCY_TYPE_CODE,
  			URGENCY_TYPE_DESC,
  			TRAN_CLASS_CODE,
  			TRAN_CLASS_DESC,
  			REFE_NO,
  			START_NODE_CODE,
  			START_NODE_DESC,
  			START_AREA_CODE,
  			START_AREA_DESC,
  			CAR_USE_CODE,
  			CAR_USE_DESC,
  			CAR_TYPE_CODE,
  			CAR_TYPE_DESC,
  			CAR_WT_VAL,
  			WEIGHING_IF,
  			HEAT_NO,
  			BATCH_NO,
  			LOGO_NO,
  			MATERIALS_CODE,
  			MATERIALS_DESC,
  			MATERIALS_SPEC,
  			DIMATER_VAL,
  			HEIGHT_VAL,
  			LEN_VAL,
  			LEN_MIN_VAL,
  			LEN_MAX_VAL,
  			DEMAND_QTY_VAL,
  			DEMAND_WT_VAL,
  			SCRAP_QTY_VAL,
  			SCRAP_WT_VAL,
  			PRO_ORDER_NO,
  			PRO_ORDER_SQE,
  			CURRENT_JOB_NO,
  			PREVIOUS_JOB_NO,
  			SOURCE_SIGN,
  			VALIDFLAG,
  			STATUS,
  			ARCHIVE_FLAG,
  			CREATE_NAME,
  			CREATE_TIME)
			VALUES
  			(?,?,(select to_char(nvl(max(to_number(execute_sqe)),0)+1) execute_sqe from TMS_DEMAND_M),?,?
  			,?,?,?,?,?
  			,?,?,?,?,?
  			,?,?,?,?,?
  			,?,?,?,?,?
  			,?,?,?,?,?
  			,?,?,?,?,?
  			,?,?,?,?,?
  			,?,?,SYSDATE)
		]]>
	</query>

	<query id="frmEntrust.selectProcess" desc="产线">
		<![CDATA[
SELECT * FROM HTT_ENTRUST_PROCESS T WHERE 1=1
		]]>
	</query>

	<query id="frmEntrust.UpdatePath" desc="">
		<![CDATA[
UPDATE HTT_ENTRUST_RESULT SET REPORT_PATH = ? WHERE RESULT_NO =?

			]]>
	</query>


	<query id="frmEntrust.UpdateEntrutPath" desc="">
		<![CDATA[
UPDATE HTT_ENTRUST SET REPORT_PATH = ? WHERE SUBCONTRACT_NO =?  AND SUBCONTRACT_NO_SEQ = ?

			]]>
	</query>



	<query id="frmEntrust.AddCutDetail" desc="">
		<![CDATA[
		INSERT INTO HTT_ENTRUST_MAT_NO
  (RESULT_NO, RESULT_NO_OFFLINE, MAT_NO, MAT_NO_CUT, MAT_STATUS,CUT_NUM,SUBCONTRACT_NO,SUBCONTRACT_NO_SEQ)
VALUES
  (?, nvl(?,'/'), ?, ?, ?,?,?,?)

	]]>
	</query>

	<query id="frmEntrust.DeleteCutDetail" desc="">
		<![CDATA[
		DELETE HTT_ENTRUST_MAT_NO WHERE RESULT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddPortG" desc="">
		<![CDATA[

	INSERT INTO PORT_MCH_BATCH_SAMPLE_RESULT
	(HEAT_PLAN_NO,
	MAT_NO,
	M_MAT_NO,
	M_M_MAT_NO,
	LOT_NO,
	LOT_NO_SQE,
	PRO_PLAN_ID,
	GX_PLAN_NO,
	PLINE_CODE,
	PLINE_NAME,
	JUDGE_STOVE_NO,
	BATCH_NO,
	GROUP_NO,
	STOVE_NO,
	FLAG_STOVE_NO,
	ACT_DIMATER,
	ACT_HEIGHT,
	OUTNUM_CUT,
	ACT_LEN,
	ACT_LEN_MIN,
	ACT_LEN_MAX,
	ACT_COUNT,
	ACT_WEIGHT,
	ACT_THEORY_WEIGHT,
	IS_SAMPLE_PIPE,
	SAMPLE_PIPE_LEN,
	GET_SAMPLE_SHIFT,
	GET_SAMPLE_CLASS,
	GET_SAMPLE_NAME,
	GET_SAMPLE_TIME,
	OLD_JUDGE_STOVE_NO,
	GROUP_FLAG,
	OP_PROCESS,
	MAT_STATUS,
	LEVE_LOG,
	INSTORE_FLAG,
	PRC_TECHNOLOGY_PATH,
	VM_INSTORE_FLAG,
	RETURN_PROCESS,
	PHY_BATCH_NO,
	PRO_YEAR_MONTH_DAY,
	BAL_YEAR_MONTH,
	JUGDE_APPLY_CODE,
	JUGDE_APPLY,
	VALIDFLAG,
	PRO_USER,
	PRO_SHIFT,
	PRO_GROUP,
	PRO_TIME,
	REMARK,
	TR_FLAG,
	PHY_CODE_GROUP,
	PHY_CODE_GROUPB,
	FEED_HEAT_NO,
	BAR_CODE,
	RESULT_NO)
	SELECT HEAT_PLAN_NO,
	?,
	MAT_NO,
	M_M_MAT_NO,
	LOT_NO,
	LOT_NO_SQE,
	PRO_PLAN_ID,
	GX_PLAN_NO,
	PLINE_CODE,
	PLINE_NAME,
	JUDGE_STOVE_NO,
	BATCH_NO,
	GROUP_NO,
	STOVE_NO,
	FLAG_STOVE_NO,
	ACT_DIMATER,
	ACT_HEIGHT,
	?,
	ROUND(ACT_LEN/?,3) ,
	ACT_LEN_MIN,
	ACT_LEN_MAX,
	ACT_COUNT,
	ROUND(ACT_WEIGHT/?,3),
	ROUND(ACT_THEORY_WEIGHT/?,3),
	IS_SAMPLE_PIPE,
	SAMPLE_PIPE_LEN,
	GET_SAMPLE_SHIFT,
	GET_SAMPLE_CLASS,
	GET_SAMPLE_NAME,
	GET_SAMPLE_TIME,
	OLD_JUDGE_STOVE_NO,
	GROUP_FLAG,
	OP_PROCESS,
	?,
	LEVE_LOG,
	'0',
	PRC_TECHNOLOGY_PATH,
	'',
	'',
	PHY_BATCH_NO,
	PRO_YEAR_MONTH_DAY,
	BAL_YEAR_MONTH,
	JUGDE_APPLY_CODE,
	JUGDE_APPLY,
	1,
	PRO_USER,
	PRO_SHIFT,
	PRO_GROUP,
	PRO_TIME,
	REMARK,
	TR_FLAG,
	PHY_CODE_GROUP,
	PHY_CODE_GROUPB,
	FEED_HEAT_NO,
	DECODE(BAR_CODE,NULL,NULL,BAR_CODE+'-' + LPAD(?,2,'0')) ,
	RESULT_NO
	FROM PORT_MCH_BATCH_SAMPLE_RESULT
	WHERE RESULT_NO =? AND MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddPortG2" desc="">
		<![CDATA[

	INSERT INTO PORT_MCH_BATCH_SAMPLE_RESULT
	(HEAT_PLAN_NO,
	MAT_NO,
	M_MAT_NO,
	M_M_MAT_NO,
	LOT_NO,
	LOT_NO_SQE,
	PRO_PLAN_ID,
	GX_PLAN_NO,
	PLINE_CODE,
	PLINE_NAME,
	JUDGE_STOVE_NO,
	BATCH_NO,
	GROUP_NO,
	STOVE_NO,
	FLAG_STOVE_NO,
	ACT_DIMATER,
	ACT_HEIGHT,
	OUTNUM_CUT,
	ACT_LEN,
	ACT_LEN_MIN,
	ACT_LEN_MAX,
	ACT_COUNT,
	ACT_WEIGHT,
	ACT_THEORY_WEIGHT,
	IS_SAMPLE_PIPE,
	SAMPLE_PIPE_LEN,
	GET_SAMPLE_SHIFT,
	GET_SAMPLE_CLASS,
	GET_SAMPLE_NAME,
	GET_SAMPLE_TIME,
	OLD_JUDGE_STOVE_NO,
	GROUP_FLAG,
	OP_PROCESS,
	MAT_STATUS,
	LEVE_LOG,
	INSTORE_FLAG,
	PRC_TECHNOLOGY_PATH,
	VM_INSTORE_FLAG,
	RETURN_PROCESS,
	PHY_BATCH_NO,
	PRO_YEAR_MONTH_DAY,
	BAL_YEAR_MONTH,
	JUGDE_APPLY_CODE,
	JUGDE_APPLY,
	VALIDFLAG,
	PRO_USER,
	PRO_SHIFT,
	PRO_GROUP,
	PRO_TIME,
	REMARK,
	TR_FLAG,
	PHY_CODE_GROUP,
	PHY_CODE_GROUPB,
	FEED_HEAT_NO,
	BAR_CODE,
	RESULT_NO)
	SELECT HEAT_PLAN_NO,
	?,
	MAT_NO,
	M_M_MAT_NO,
	LOT_NO,
	LOT_NO_SQE,
	PRO_PLAN_ID,
	GX_PLAN_NO,
	PLINE_CODE,
	PLINE_NAME,
	JUDGE_STOVE_NO,
	BATCH_NO,
	GROUP_NO,
	STOVE_NO,
	FLAG_STOVE_NO,
	ACT_DIMATER,
	ACT_HEIGHT,
	?,
	ACT_LEN- (?-1) *  ROUND(ACT_LEN/?,3)  ,
	ACT_LEN_MIN,
	ACT_LEN_MAX,
	ACT_COUNT,
    ACT_WEIGHT-  (?-1) * ROUND(ACT_WEIGHT/?,3),
	ACT_THEORY_WEIGHT - (?-1) * ROUND(ACT_THEORY_WEIGHT/?,3),
	IS_SAMPLE_PIPE,
	SAMPLE_PIPE_LEN,
	GET_SAMPLE_SHIFT,
	GET_SAMPLE_CLASS,
	GET_SAMPLE_NAME,
	GET_SAMPLE_TIME,
	OLD_JUDGE_STOVE_NO,
	GROUP_FLAG,
	OP_PROCESS,
	?,
	LEVE_LOG,
	'0',
	PRC_TECHNOLOGY_PATH,
	'',
	'',
	PHY_BATCH_NO,
	PRO_YEAR_MONTH_DAY,
	BAL_YEAR_MONTH,
	JUGDE_APPLY_CODE,
	JUGDE_APPLY,
	1,
	PRO_USER,
	PRO_SHIFT,
	PRO_GROUP,
	PRO_TIME,
	REMARK,
	TR_FLAG,
	PHY_CODE_GROUP,
	PHY_CODE_GROUPB,
	FEED_HEAT_NO,
	DECODE(BAR_CODE,NULL,NULL,BAR_CODE+'-' + LPAD(?,2,'0')) ,
	RESULT_NO
	FROM PORT_MCH_BATCH_SAMPLE_RESULT
	WHERE RESULT_NO =? AND MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddPortF" desc="">
		<![CDATA[
INSERT INTO PORT_HTT_BATCH_SAMPLE_RESULT
  (HEAT_PLAN_NO,
   MAT_NO,
   M_MAT_NO,
   M_M_MAT_NO,
   LOT_NO,
   LOT_NO_SQE,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   IS_SAMPLE_PIPE,
   SAMPLE_PIPE_LEN,
   GET_SAMPLE_SHIFT,
   GET_SAMPLE_CLASS,
   GET_SAMPLE_NAME,
   GET_SAMPLE_TIME,
   OLD_JUDGE_STOVE_NO,
   GROUP_FLAG,
   OP_PROCESS,
   MAT_STATUS,
   LEVE_LOG,
   INSTORE_FLAG,
   VM_INSTORE_FLAG,
   PRC_TECHNOLOGY_PATH,
   RETURN_PROCESS,
   PHY_BATCH_NO,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   REMARK,
   SAMPLE_PIPE_LEN_A,
   SAMPLE_PIPE_LEN_B,
   CHEM_RESULT_CODE,
   PHY_RESULT_CODE,
   HEAT_PLAN_SQE,
   PHY_CODE_GROUP,
   PHY_CODE_GROUPB,
   TR_FLAG,
   FEED_HEAT_NO,
   PROCESS_SEQ,
   RESULT_NO,
   IS_BATCH,
   SAMPLE_PIPE_LEN_C,
   SAMPLE_PIPE_LEN_D,
   PHY_CODE_GROUPC,
   PHY_CODE_GROUPD,
   CHECK_NO,
   SAMPLE_PIPE_LEN_M,
   PHY_CODE_GROUPM,
   MAT_NO_OLD,
   SAMPLE_PIPE_LEN_E,
   PHY_CODE_GROUPE,
   SAMPLE_PIPE_LEN_F,
   PHY_CODE_GROUPF,
   SAMPLE_PIPE_LEN_P,
   PHY_CODE_GROUPP,
   SAMPLE_PIPE_LEN_Q,
   PHY_CODE_GROUPQ,
   CRAFT_SOURCE,
   BAR_CODE,
   RE_GET_SAMPLE_NAME,
   RE_GET_SAMPLE_TIME,
   RE_GET_SAMPLE_STATUS,
   RESAMPLE_PIPE_LEN_A,
   RESAMPLE_PIPE_LEN_B,
   RESAMPLE_PIPE_LEN_C,
   RESAMPLE_PIPE_LEN_D,
   RESAMPLE_PIPE_LEN_E,
   RESAMPLE_PIPE_LEN_F,
   RESAMPLE_PIPE_LEN_P,
   RESAMPLE_PIPE_LEN_Q,
   RESAMPLE_PIPE_LEN_M,
   RE_CHECK_NO)
  SELECT HEAT_PLAN_NO,
         ?,
         MAT_NO,
         M_M_MAT_NO,
         LOT_NO,
         LOT_NO_SQE,
         PLINE_CODE,
         PLINE_NAME,
         JUDGE_STOVE_NO,
         BATCH_NO,
         GROUP_NO,
         STOVE_NO,
         FLAG_STOVE_NO,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN/?,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ROUND(ACT_WEIGHT/?,3),
         ROUND(ACT_THEORY_WEIGHT/?,3),
         IS_SAMPLE_PIPE,
         SAMPLE_PIPE_LEN,
         GET_SAMPLE_SHIFT,
         GET_SAMPLE_CLASS,
         GET_SAMPLE_NAME,
         GET_SAMPLE_TIME,
         OLD_JUDGE_STOVE_NO,
         GROUP_FLAG,
         OP_PROCESS,
         ?,
         LEVE_LOG,
         INSTORE_FLAG,
         VM_INSTORE_FLAG,
         PRC_TECHNOLOGY_PATH,
         RETURN_PROCESS,
         PHY_BATCH_NO,
         PRO_YEAR_MONTH_DAY,
         BAL_YEAR_MONTH,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY,
         PRO_USER,
         PRO_SHIFT,
         PRO_GROUP,
         PRO_TIME,
         REMARK,
         SAMPLE_PIPE_LEN_A,
         SAMPLE_PIPE_LEN_B,
         CHEM_RESULT_CODE,
         PHY_RESULT_CODE,
         HEAT_PLAN_SQE,
         PHY_CODE_GROUP,
         PHY_CODE_GROUPB,
         TR_FLAG,
         FEED_HEAT_NO,
         PROCESS_SEQ,
         RESULT_NO,
         IS_BATCH,
         SAMPLE_PIPE_LEN_C,
         SAMPLE_PIPE_LEN_D,
         PHY_CODE_GROUPC,
         PHY_CODE_GROUPD,
         CHECK_NO,
         SAMPLE_PIPE_LEN_M,
         PHY_CODE_GROUPM,
         MAT_NO_OLD,
         SAMPLE_PIPE_LEN_E,
         PHY_CODE_GROUPE,
         SAMPLE_PIPE_LEN_F,
         PHY_CODE_GROUPF,
         SAMPLE_PIPE_LEN_P,
         PHY_CODE_GROUPP,
         SAMPLE_PIPE_LEN_Q,
         PHY_CODE_GROUPQ,
         CRAFT_SOURCE,
         BAR_CODE,
         RE_GET_SAMPLE_NAME,
         RE_GET_SAMPLE_TIME,
         RE_GET_SAMPLE_STATUS,
         RESAMPLE_PIPE_LEN_A,
         RESAMPLE_PIPE_LEN_B,
         RESAMPLE_PIPE_LEN_C,
         RESAMPLE_PIPE_LEN_D,
         RESAMPLE_PIPE_LEN_E,
         RESAMPLE_PIPE_LEN_F,
         RESAMPLE_PIPE_LEN_P,
         RESAMPLE_PIPE_LEN_Q,
         RESAMPLE_PIPE_LEN_M,
         RE_CHECK_NO
    FROM PORT_HTT_BATCH_SAMPLE_RESULT
   WHERE RESULT_NO = ?
     AND MAT_NO = ?


	]]>
	</query>

	<query id="frmEntrust.AddPortF2" desc="">
		<![CDATA[
INSERT INTO PORT_HTT_BATCH_SAMPLE_RESULT
  (HEAT_PLAN_NO,
   MAT_NO,
   M_MAT_NO,
   M_M_MAT_NO,
   LOT_NO,
   LOT_NO_SQE,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   IS_SAMPLE_PIPE,
   SAMPLE_PIPE_LEN,
   GET_SAMPLE_SHIFT,
   GET_SAMPLE_CLASS,
   GET_SAMPLE_NAME,
   GET_SAMPLE_TIME,
   OLD_JUDGE_STOVE_NO,
   GROUP_FLAG,
   OP_PROCESS,
   MAT_STATUS,
   LEVE_LOG,
   INSTORE_FLAG,
   VM_INSTORE_FLAG,
   PRC_TECHNOLOGY_PATH,
   RETURN_PROCESS,
   PHY_BATCH_NO,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   REMARK,
   SAMPLE_PIPE_LEN_A,
   SAMPLE_PIPE_LEN_B,
   CHEM_RESULT_CODE,
   PHY_RESULT_CODE,
   HEAT_PLAN_SQE,
   PHY_CODE_GROUP,
   PHY_CODE_GROUPB,
   TR_FLAG,
   FEED_HEAT_NO,
   PROCESS_SEQ,
   RESULT_NO,
   IS_BATCH,
   SAMPLE_PIPE_LEN_C,
   SAMPLE_PIPE_LEN_D,
   PHY_CODE_GROUPC,
   PHY_CODE_GROUPD,
   CHECK_NO,
   SAMPLE_PIPE_LEN_M,
   PHY_CODE_GROUPM,
   MAT_NO_OLD,
   SAMPLE_PIPE_LEN_E,
   PHY_CODE_GROUPE,
   SAMPLE_PIPE_LEN_F,
   PHY_CODE_GROUPF,
   SAMPLE_PIPE_LEN_P,
   PHY_CODE_GROUPP,
   SAMPLE_PIPE_LEN_Q,
   PHY_CODE_GROUPQ,
   CRAFT_SOURCE,
   BAR_CODE,
   RE_GET_SAMPLE_NAME,
   RE_GET_SAMPLE_TIME,
   RE_GET_SAMPLE_STATUS,
   RESAMPLE_PIPE_LEN_A,
   RESAMPLE_PIPE_LEN_B,
   RESAMPLE_PIPE_LEN_C,
   RESAMPLE_PIPE_LEN_D,
   RESAMPLE_PIPE_LEN_E,
   RESAMPLE_PIPE_LEN_F,
   RESAMPLE_PIPE_LEN_P,
   RESAMPLE_PIPE_LEN_Q,
   RESAMPLE_PIPE_LEN_M,
   RE_CHECK_NO)
  SELECT HEAT_PLAN_NO,
         ?,
         MAT_NO,
         M_M_MAT_NO,
         LOT_NO,
         LOT_NO_SQE,
         PLINE_CODE,
         PLINE_NAME,
         JUDGE_STOVE_NO,
         BATCH_NO,
         GROUP_NO,
         STOVE_NO,
         FLAG_STOVE_NO,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN * ?,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT * ?,
         ACT_THEORY_WEIGHT *?,
         IS_SAMPLE_PIPE,
         SAMPLE_PIPE_LEN,
         GET_SAMPLE_SHIFT,
         GET_SAMPLE_CLASS,
         GET_SAMPLE_NAME,
         GET_SAMPLE_TIME,
         OLD_JUDGE_STOVE_NO,
         GROUP_FLAG,
         OP_PROCESS,
         ?,
         LEVE_LOG,
         INSTORE_FLAG,
         VM_INSTORE_FLAG,
         PRC_TECHNOLOGY_PATH,
         RETURN_PROCESS,
         PHY_BATCH_NO,
         PRO_YEAR_MONTH_DAY,
         BAL_YEAR_MONTH,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY,
         PRO_USER,
         PRO_SHIFT,
         PRO_GROUP,
         PRO_TIME,
         REMARK,
         SAMPLE_PIPE_LEN_A,
         SAMPLE_PIPE_LEN_B,
         CHEM_RESULT_CODE,
         PHY_RESULT_CODE,
         HEAT_PLAN_SQE,
         PHY_CODE_GROUP,
         PHY_CODE_GROUPB,
         TR_FLAG,
         FEED_HEAT_NO,
         PROCESS_SEQ,
         RESULT_NO,
         IS_BATCH,
         SAMPLE_PIPE_LEN_C,
         SAMPLE_PIPE_LEN_D,
         PHY_CODE_GROUPC,
         PHY_CODE_GROUPD,
         CHECK_NO,
         SAMPLE_PIPE_LEN_M,
         PHY_CODE_GROUPM,
         MAT_NO_OLD,
         SAMPLE_PIPE_LEN_E,
         PHY_CODE_GROUPE,
         SAMPLE_PIPE_LEN_F,
         PHY_CODE_GROUPF,
         SAMPLE_PIPE_LEN_P,
         PHY_CODE_GROUPP,
         SAMPLE_PIPE_LEN_Q,
         PHY_CODE_GROUPQ,
         CRAFT_SOURCE,
         BAR_CODE,
         RE_GET_SAMPLE_NAME,
         RE_GET_SAMPLE_TIME,
         RE_GET_SAMPLE_STATUS,
         RESAMPLE_PIPE_LEN_A,
         RESAMPLE_PIPE_LEN_B,
         RESAMPLE_PIPE_LEN_C,
         RESAMPLE_PIPE_LEN_D,
         RESAMPLE_PIPE_LEN_E,
         RESAMPLE_PIPE_LEN_F,
         RESAMPLE_PIPE_LEN_P,
         RESAMPLE_PIPE_LEN_Q,
         RESAMPLE_PIPE_LEN_M,
         RE_CHECK_NO
    FROM PORT_HTT_BATCH_SAMPLE_RESULT
   WHERE RESULT_NO = ?
     AND MAT_NO = ?


	]]>
	</query>


	<query id="frmEntrust.AddPortE" desc="">
		<![CDATA[

INSERT INTO PORT_VRP_BATCH_SAMPLE_RESULT
  (HEAT_PLAN_NO,
   MAT_NO,
   M_MAT_NO,
   M_M_MAT_NO,
   LOT_NO,
   LOT_NO_SQE,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   IS_SAMPLE_PIPE,
   SAMPLE_PIPE_LEN,
   GET_SAMPLE_SHIFT,
   GET_SAMPLE_CLASS,
   GET_SAMPLE_NAME,
   GET_SAMPLE_TIME,
   OLD_JUDGE_STOVE_NO,
   GROUP_FLAG,
   OP_PROCESS,
   MAT_STATUS,
   LEVE_LOG,
   INSTORE_FLAG,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   REMARK,
   PRC_TECHNOLOGY_PATH,
   VM_INSTORE_FLAG,
   RETURN_PROCESS,
   PHY_BATCH_NO,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY,
   SAMPLE_PIPE_LEN_A,
   SAMPLE_PIPE_LEN_B,
   CHEM_RESULT_CODE,
   PHY_RESULT_CODE,
   CRATE_TIME,
   FEED_HEAT_NO,
   HEAT_PLAN_SQE,
   TR_FLAG,
   PHY_CODE_GROUP,
   PHY_CODE_GROUPB,
   RE_GET_SAMPLE_NAME,
   RE_GET_SAMPLE_TIME,
   RE_GET_SAMPLE_STATUS,
   RESAMPLE_PIPE_LEN_A,
   RESAMPLE_PIPE_LEN_B,
   REPHY_CODE_GROUP,
   REPHY_CODE_GROUPB,
   RESULT_NO)
  SELECT HEAT_PLAN_NO,
         ?,
         MAT_NO,
         M_M_MAT_NO,
         LOT_NO,
         LOT_NO_SQE,
         PLINE_CODE,
         PLINE_NAME,
         JUDGE_STOVE_NO,
         BATCH_NO,
         GROUP_NO,
         STOVE_NO,
         FLAG_STOVE_NO,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN/?,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ROUND(ACT_WEIGHT/?,3),
         ROUND(ACT_THEORY_WEIGHT/?,3),
         IS_SAMPLE_PIPE,
         SAMPLE_PIPE_LEN,
         GET_SAMPLE_SHIFT,
         GET_SAMPLE_CLASS,
         GET_SAMPLE_NAME,
         GET_SAMPLE_TIME,
         OLD_JUDGE_STOVE_NO,
         GROUP_FLAG,
         OP_PROCESS,
         ?,
         LEVE_LOG,
         INSTORE_FLAG,
         PRO_USER,
         PRO_SHIFT,
         PRO_GROUP,
         PRO_TIME,
         REMARK,
         PRC_TECHNOLOGY_PATH,
         VM_INSTORE_FLAG,
         RETURN_PROCESS,
         PHY_BATCH_NO,
         PRO_YEAR_MONTH_DAY,
         BAL_YEAR_MONTH,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY,
         SAMPLE_PIPE_LEN_A,
         SAMPLE_PIPE_LEN_B,
         CHEM_RESULT_CODE,
         PHY_RESULT_CODE,
         CRATE_TIME,
         FEED_HEAT_NO,
         HEAT_PLAN_SQE,
         TR_FLAG,
         PHY_CODE_GROUP,
         PHY_CODE_GROUPB,
         RE_GET_SAMPLE_NAME,
         RE_GET_SAMPLE_TIME,
         RE_GET_SAMPLE_STATUS,
         RESAMPLE_PIPE_LEN_A,
         RESAMPLE_PIPE_LEN_B,
         REPHY_CODE_GROUP,
         REPHY_CODE_GROUPB,
         RESULT_NO
    FROM PORT_VRP_BATCH_SAMPLE_RESULT
   WHERE RESULT_NO = ?
     AND MAT_NO = ?


	]]>
	</query>


	<query id="frmEntrust.AddPortE2" desc="">
		<![CDATA[

INSERT INTO PORT_VRP_BATCH_SAMPLE_RESULT
  (HEAT_PLAN_NO,
   MAT_NO,
   M_MAT_NO,
   M_M_MAT_NO,
   LOT_NO,
   LOT_NO_SQE,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   IS_SAMPLE_PIPE,
   SAMPLE_PIPE_LEN,
   GET_SAMPLE_SHIFT,
   GET_SAMPLE_CLASS,
   GET_SAMPLE_NAME,
   GET_SAMPLE_TIME,
   OLD_JUDGE_STOVE_NO,
   GROUP_FLAG,
   OP_PROCESS,
   MAT_STATUS,
   LEVE_LOG,
   INSTORE_FLAG,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   REMARK,
   PRC_TECHNOLOGY_PATH,
   VM_INSTORE_FLAG,
   RETURN_PROCESS,
   PHY_BATCH_NO,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY,
   SAMPLE_PIPE_LEN_A,
   SAMPLE_PIPE_LEN_B,
   CHEM_RESULT_CODE,
   PHY_RESULT_CODE,
   CRATE_TIME,
   FEED_HEAT_NO,
   HEAT_PLAN_SQE,
   TR_FLAG,
   PHY_CODE_GROUP,
   PHY_CODE_GROUPB,
   RE_GET_SAMPLE_NAME,
   RE_GET_SAMPLE_TIME,
   RE_GET_SAMPLE_STATUS,
   RESAMPLE_PIPE_LEN_A,
   RESAMPLE_PIPE_LEN_B,
   REPHY_CODE_GROUP,
   REPHY_CODE_GROUPB,
   RESULT_NO)
  SELECT HEAT_PLAN_NO,
         ?,
         MAT_NO,
         M_M_MAT_NO,
         LOT_NO,
         LOT_NO_SQE,
         PLINE_CODE,
         PLINE_NAME,
         JUDGE_STOVE_NO,
         BATCH_NO,
         GROUP_NO,
         STOVE_NO,
         FLAG_STOVE_NO,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN*?,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT*?,
         ACT_THEORY_WEIGHT*?,
         IS_SAMPLE_PIPE,
         SAMPLE_PIPE_LEN,
         GET_SAMPLE_SHIFT,
         GET_SAMPLE_CLASS,
         GET_SAMPLE_NAME,
         GET_SAMPLE_TIME,
         OLD_JUDGE_STOVE_NO,
         GROUP_FLAG,
         OP_PROCESS,
         ?,
         LEVE_LOG,
         INSTORE_FLAG,
         PRO_USER,
         PRO_SHIFT,
         PRO_GROUP,
         PRO_TIME,
         REMARK,
         PRC_TECHNOLOGY_PATH,
         VM_INSTORE_FLAG,
         RETURN_PROCESS,
         PHY_BATCH_NO,
         PRO_YEAR_MONTH_DAY,
         BAL_YEAR_MONTH,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY,
         SAMPLE_PIPE_LEN_A,
         SAMPLE_PIPE_LEN_B,
         CHEM_RESULT_CODE,
         PHY_RESULT_CODE,
         CRATE_TIME,
         FEED_HEAT_NO,
         HEAT_PLAN_SQE,
         TR_FLAG,
         PHY_CODE_GROUP,
         PHY_CODE_GROUPB,
         RE_GET_SAMPLE_NAME,
         RE_GET_SAMPLE_TIME,
         RE_GET_SAMPLE_STATUS,
         RESAMPLE_PIPE_LEN_A,
         RESAMPLE_PIPE_LEN_B,
         REPHY_CODE_GROUP,
         REPHY_CODE_GROUPB,
         RESULT_NO
    FROM PORT_VRP_BATCH_SAMPLE_RESULT
   WHERE RESULT_NO = ?
     AND MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddBc" desc="">
		<![CDATA[
		INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT,
   CODE_JG_BL,
   CIC,
   SCRAP_REASON,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   ZBS_FLAG,
   SCRAP_TYPE,
   ZBS_ID,
   HEAT_PLAN_NO_OLD,
   MEASURING_SEQ,
   SCRAP_FLAG,
   LIKU_PROCESS_CODE,
   JG_ZBS_ID,
   FAIL_APPROVAL_CODE)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ROUND(ACT_WEIGHT/?,3),
         ROUND(ACT_THEORY_WEIGHT/?,3),
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         ?,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT,
         CODE_JG_BL,
         CIC,
         SCRAP_REASON,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         ZBS_FLAG,
         SCRAP_TYPE,
         ZBS_ID,
         HEAT_PLAN_NO_OLD,
         MEASURING_SEQ,
         SCRAP_FLAG,
         LIKU_PROCESS_CODE,
         JG_ZBS_ID,
         FAIL_APPROVAL_CODE
    FROM MAT_BC_M
   WHERE MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddBc2" desc="">
		<![CDATA[
		INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT,
   CODE_JG_BL,
   CIC,
   SCRAP_REASON,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   ZBS_FLAG,
   SCRAP_TYPE,
   ZBS_ID,
   HEAT_PLAN_NO_OLD,
   MEASURING_SEQ,
   SCRAP_FLAG,
   LIKU_PROCESS_CODE,
   JG_ZBS_ID,
   FAIL_APPROVAL_CODE,
   OFFLINE_DOC,
   SUBCONTRACT_NO,
   SCRAP_FRIM_FLAG,
   ZZB_FLAG,
   BAL_YEAR_MONTH_FAIL,
   SUBCONTRACT_NO_SEQ,
   SCRAP_NAME,
   SCRAP_TIME)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN- (?-1) *  ROUND(ACT_LEN/?,3)  ,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT -  (?-1)  * ROUND(ACT_WEIGHT/?,3),
         ACT_THEORY_WEIGHT - (?-1) * ROUND(ACT_THEORY_WEIGHT/?,3),
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         ?,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT,
         CODE_JG_BL,
         CIC,
         SCRAP_REASON,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         ZBS_FLAG,
         SCRAP_TYPE,
         ZBS_ID,
         HEAT_PLAN_NO_OLD,
         MEASURING_SEQ,
         SCRAP_FLAG,
         LIKU_PROCESS_CODE,
         JG_ZBS_ID,
         FAIL_APPROVAL_CODE,
         OFFLINE_DOC,
         SUBCONTRACT_NO,
         SCRAP_FRIM_FLAG,
         ZZB_FLAG,
         BAL_YEAR_MONTH_FAIL,
         SUBCONTRACT_NO_SEQ,
         SCRAP_NAME,
         SCRAP_TIME
    FROM MAT_BC_M
   WHERE MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddBc3" desc="">
		<![CDATA[
	INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT,
   CODE_JG_BL,
   CIC,
   SCRAP_REASON,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   ZBS_FLAG,
   SCRAP_TYPE,
   ZBS_ID,
   HEAT_PLAN_NO_OLD,
   MEASURING_SEQ,
   SCRAP_FLAG,
   LIKU_PROCESS_CODE,
   JG_ZBS_ID,
   FAIL_APPROVAL_CODE,
   OFFLINE_DOC,
   SUBCONTRACT_NO,
   SCRAP_FRIM_FLAG,
   ZZB_FLAG,
   BAL_YEAR_MONTH_FAIL,
   SUBCONTRACT_NO_SEQ,
   SCRAP_NAME,
   SCRAP_TIME)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ROUND(ACT_LEN/?,3),
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ROUND(ACT_WEIGHT/?,3),
         ROUND(ACT_THEORY_WEIGHT/?,3),
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         ?,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT,
         CODE_JG_BL,
         CIC,
         SCRAP_REASON,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         ZBS_FLAG,
         SCRAP_TYPE,
         ZBS_ID,
         HEAT_PLAN_NO_OLD,
         MEASURING_SEQ,
         SCRAP_FLAG,
         LIKU_PROCESS_CODE,
         JG_ZBS_ID,
         FAIL_APPROVAL_CODE,
         OFFLINE_DOC,
         SUBCONTRACT_NO,
         SCRAP_FRIM_FLAG,
         ZZB_FLAG,
         BAL_YEAR_MONTH_FAIL,
         SUBCONTRACT_NO_SEQ,
         SCRAP_NAME,
         SCRAP_TIME
    FROM MAT_BC_M
   WHERE MAT_NO = ?

	]]>
	</query>


	<query id="frmEntrust.AddZc" desc="">
		<![CDATA[
	INSERT INTO MAT_ZC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   MAT_SQE_NO,
   SAMPLE_FLAG,
   CUTTING_FLAG,
   ORIGIN_MAT_NO,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   INPUT_ORIGIN_CODE,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_NO1,
   PRO_ORDER_ID,
   PRO_ORDER_ID1,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   DIMATER,
   HEIGHT,
   LEN_NO,
   LEN_DESC,
   LEN_UNIT,
   LEN_MIN,
   LEN_MAX,
   TARG_DIMATER,
   TARG_HEIGHT,
   TARG_LEN_MIN,
   TARG_LEN_MAX,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   PACK_TYPE_CODE,
   PACK_TYPE_NAME,
   PACK_NO,
   PACK_TIME,
   PACK_MAT_WT,
   MAT_GROSS_WT,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   COOL_HOT_FLAG,
   MAT_RETURN_FLAG,
   HEAT_TREAT_NO,
   POST_FLAG,
   LOCK_FLAG,
   MNG_LOCK_RSN_CODE,
   MNG_LOCK_TIME,
   MNG_LOCK_MAKER,
   MNG_LOCK_REMARK,
   LOCK_RSN_CODE,
   LOCK_TIME,
   LOCK_MAKER,
   LOCK_REMARK,
   UNLOCK_TIME,
   UNLOCK_MAKER,
   UNLOCK_REMARK,
   OLD_ORDER_NO,
   OLD_ORDER_SEQ,
   OLD_ORDER_SEQ_NO,
   OLD_MATERIAL_NO,
   OLD_MATERIAL_NAME,
   REMAIN_RSN_CODE,
   REMAIN_JUGDE_TIME,
   REMAIN_JUGDE_MAKER,
   REMAIN_JUGDE_CODE,
   REMAIN_REMARK,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   JUGDE_SCAN_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_REPORT_NO,
   DETECT_RESULT_CODE,
   WPRESSURE_REPORT_NO,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   BUG_NO,
   BUG_DEAL,
   REPAIR_FLAG,
   REPAIR_REMARK,
   SAMPLING_FLAG,
   SAMPLING_TYPE,
   SAMPLING_NO,
   CHECKOUT_NO,
   CHEM_STCHECK_NO,
   CHEM_PROCHECK_NO,
   SH_CHECK_NO,
   COME_PROC_FLAG,
   CONFM_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   OUTSTOCK_TIME,
   PRO_BC,
   PRO_BZ,
   RPO_TIME,
   BAR_CODE,
   BEGINNING_FLAG,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   REQ_BL_ID,
   IF_BATCHED_JG,
   COUPCUT_BATCH_ID,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   OLD_ORD_PK,
   OLD_ORD_LN_PK,
   OLD_ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   JUDGE_GRADE,
   PIPMEMO,
   TEST,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   MEMO1,
   JUDGE_ID,
   MNG_LOCK_FLAG,
   LOCK_ID,
   PRO_NO,
   LOCK_LIKU,
   PLN_GRADECODE,
   PLN_GRADENAME,
   PLN_STEELCODE,
   PLN_STEELNAME,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   FINISHPRO_MOLD,
   IN_MOLD,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   GX_PLAN_NO1,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   ZG_PHY_RESULT_PATH,
   ZG_FACE_RESULT_PATH,
   ZG_SPEC_RESULT_PATH,
   VRP_HEAT_PLAN_NO,
   VRP_LOT_NO,
   VRP_SAMPLE_FLAG,
   VRP_PRO_ORDER_NO,
   VRP_PRO_ORDER_NO1,
   VRP_PRO_ORDER_ID,
   VRP_PRO_ORDER_ID1,
   VRP_ACT_DIMATER,
   VRP_ACT_HEIGHT,
   VRP_JUGDE_APPLY_FLAG,
   VRP_JUGDE_APPLY_CODE,
   VRP_JUGDE_APPLY_TIME,
   VRP_FACE_RESULT_CODE,
   VRP_FACE_RESULT_TIME,
   VRP_FACE_MAKER,
   VRP_FACE_RESULT_PATH,
   VRP_SPEC_RESULT_CODE,
   VRP_SPEC_RESULT_TIME,
   VRP_SPEC_MAKER,
   VRP_SPEC_RESULT_PATH,
   VRP_PHY_RESULT_CODE,
   VRP_PHY_RESULT_TIME,
   VRP_PHY_MAKER,
   VRP_PHY_RESULT_PATH,
   VRP_JUDGE_RESULT_CODE,
   VRP_JUDGE_RESULT_TIME,
   VRP_JUDGE_MAKER,
   VRP_GX_PLAN_NO,
   VRP_GX_PLAN_NO1,
   VPR_JUGDE_CONVICTED,
   VPR_QUALITY_GROUP_ZG,
   VPR_FLAG_STOVE_NO_ZG,
   HTT_HEAT_PLAN_NO,
   HTT_LOT_NO,
   HTT_SAMPLE_FLAG,
   HTT_PRO_ORDER_NO,
   HTT_PRO_ORDER_NO1,
   HTT_PRO_ORDER_ID,
   HTT_PRO_ORDER_ID1,
   HTT_GX_PLAN_NO,
   HTT_GX_PLAN_NO1,
   HTT_JUGDE_APPLY_FLAG,
   HTT_JUGDE_APPLY_CODE,
   HTT_JUGDE_APPLY_TIME,
   HTT_FACE_RESULT_CODE,
   HTT_FACE_RESULT_TIME,
   HTT_FACE_MAKER,
   HTT_FACE_RESULT_PATH,
   HTT_SPEC_RESULT_CODE,
   HTT_SPEC_RESULT_TIME,
   HTT_SPEC_MAKER,
   HTT_SPEC_RESULT_PATH,
   HTT_PHY_RESULT_CODE,
   HTT_PHY_RESULT_TIME,
   HTT_PHY_MAKER,
   HTT_PHY_RESULT_PATH,
   HTT_JUDGE_RESULT_CODE,
   HTT_JUDGE_RESULT_TIME,
   HTT_JUDGE_MAKER,
   HTT_JUGDE_CONVICTED,
   HTT_QUALITY_GROUP_ZG,
   HTT_FLAG_STOVE_NO_ZG,
   PRC_LOT_NO,
   PRC_SAMPLE_FLAG,
   PRC_PRO_ORDER_NO,
   PRC_PRO_ORDER_NO1,
   PRC_PRO_ORDER_ID,
   PRC_PRO_ORDER_ID1,
   PRC_GX_PLAN_NO,
   PRC_GX_PLAN_NO1,
   PRC_JUGDE_APPLY_FLAG,
   PRC_JUGDE_APPLY_CODE,
   PRC_JUGDE_APPLY_TIME,
   PRC_FACE_RESULT_CODE,
   PRC_FACE_RESULT_TIME,
   PRC_FACE_MAKER,
   PRC_FACE_RESULT_PATH,
   PRC_SPEC_RESULT_CODE,
   PRC_SPEC_RESULT_TIME,
   PRC_SPEC_MAKER,
   PRC_SPEC_RESULT_PATH,
   PRC_PHY_RESULT_CODE,
   PRC_PHY_RESULT_TIME,
   PRC_PHY_MAKER,
   PRC_PHY_RESULT_PATH,
   PRC_JUDGE_RESULT_CODE,
   PRC_JUDGE_RESULT_TIME,
   PRC_JUDGE_MAKER,
   PRC_JUGDE_CONVICTED,
   PRC_QUALITY_GROUP_ZG,
   PRC_FLAG_STOVE_NO_ZG,
   PRC_HEAT_PLAN_NO,
   VRP_JUDGE_STD_NAME,
   VRP_JUDGE_STD_CODE,
   HTT_JUDGE_STD_NAME,
   HTT_JUDGE_STD_CODE,
   PRC_JUDGE_STD_NAME,
   PRC_JUDGE_STD_CODE,
   VRP_CRAF_NO,
   HTT_CRAF_NO,
   PRC_CRAF_NO,
   VRP_CHEM_RESULT_CODE,
   VRP_CHEM_RESULT_TIME,
   VRP_CHEM_MAKER,
   HTT_CHEM_RESULT_CODE,
   HTT_CHEM_RESULT_TIME,
   HTT_CHEM_MAKER,
   PRC_CHEM_RESULT_CODE,
   PRC_CHEM_RESULT_TIME,
   PRC_CHEM_MAKER,
   DETECT_REPORT_NO1,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   ZG_PLINE_CODE,
   ZG_PLINE_NAME,
   VRP_PLINE_CODE,
   VRP_PLINE_NAME,
   HTT_PLINE_CODE,
   HTT_PLINE_NAME,
   PRC_PLINE_CODE,
   PRC_PLINE_NAME,
   VRP_QCM_STAUS,
   HTT_QCM_STAUS,
   PRC_QCM_STAUS,
   ZG_MEMO,
   ZBS_FLAG,
   ZBS_ID,
   MEASURING_SEQ,
   INSTOCK_DOC,
   JG_ZBS_ID,
   CHANGE_DOC,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   LOCK_BILL_FLAG)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         MAT_SQE_NO,
         SAMPLE_FLAG,
         CUTTING_FLAG,
         ORIGIN_MAT_NO,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         INPUT_ORIGIN_CODE,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_NO1,
         PRO_ORDER_ID,
         PRO_ORDER_ID1,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         DIMATER,
         HEIGHT,
         LEN_NO,
         LEN_DESC,
         LEN_UNIT,
         LEN_MIN,
         LEN_MAX,
         TARG_DIMATER,
         TARG_HEIGHT,
         TARG_LEN_MIN,
         TARG_LEN_MAX,
         ACT_DIMATER,
         ACT_HEIGHT,
          ROUND(ACT_LEN/?,3),
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
          ROUND(ACT_WEIGHT/?,3),
         ROUND(ACT_THEORY_WEIGHT/?,3),
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         PACK_TYPE_CODE,
         PACK_TYPE_NAME,
         PACK_NO,
         PACK_TIME,
         PACK_MAT_WT,
         MAT_GROSS_WT,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         COOL_HOT_FLAG,
         MAT_RETURN_FLAG,
         HEAT_TREAT_NO,
         POST_FLAG,
         LOCK_FLAG,
         MNG_LOCK_RSN_CODE,
         MNG_LOCK_TIME,
         MNG_LOCK_MAKER,
         MNG_LOCK_REMARK,
         LOCK_RSN_CODE,
         LOCK_TIME,
         LOCK_MAKER,
         LOCK_REMARK,
         UNLOCK_TIME,
         UNLOCK_MAKER,
         UNLOCK_REMARK,
         OLD_ORDER_NO,
         OLD_ORDER_SEQ,
         OLD_ORDER_SEQ_NO,
         OLD_MATERIAL_NO,
         OLD_MATERIAL_NAME,
         REMAIN_RSN_CODE,
         REMAIN_JUGDE_TIME,
         REMAIN_JUGDE_MAKER,
         REMAIN_JUGDE_CODE,
         REMAIN_REMARK,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         JUGDE_SCAN_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_REPORT_NO,
         DETECT_RESULT_CODE,
         WPRESSURE_REPORT_NO,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         BUG_NO,
         BUG_DEAL,
         REPAIR_FLAG,
         REPAIR_REMARK,
         SAMPLING_FLAG,
         SAMPLING_TYPE,
         SAMPLING_NO,
         CHECKOUT_NO,
         CHEM_STCHECK_NO,
         CHEM_PROCHECK_NO,
         SH_CHECK_NO,
         COME_PROC_FLAG,
         CONFM_FLAG,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         OUTSTOCK_TIME,
         PRO_BC,
         PRO_BZ,
         RPO_TIME,
         BAR_CODE,
         BEGINNING_FLAG,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         REQ_BL_ID,
         IF_BATCHED_JG,
         COUPCUT_BATCH_ID,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         OLD_ORD_PK,
         OLD_ORD_LN_PK,
         OLD_ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         JUDGE_GRADE,
         PIPMEMO,
         TEST,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         MEMO1,
         JUDGE_ID,
         MNG_LOCK_FLAG,
         LOCK_ID,
         PRO_NO,
         LOCK_LIKU,
         PLN_GRADECODE,
         PLN_GRADENAME,
         PLN_STEELCODE,
         PLN_STEELNAME,
         QCM_STAUS,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         FINISHPRO_MOLD,
         IN_MOLD,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         GX_PLAN_NO1,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         ZG_PHY_RESULT_PATH,
         ZG_FACE_RESULT_PATH,
         ZG_SPEC_RESULT_PATH,
         VRP_HEAT_PLAN_NO,
         VRP_LOT_NO,
         VRP_SAMPLE_FLAG,
         VRP_PRO_ORDER_NO,
         VRP_PRO_ORDER_NO1,
         VRP_PRO_ORDER_ID,
         VRP_PRO_ORDER_ID1,
         VRP_ACT_DIMATER,
         VRP_ACT_HEIGHT,
         VRP_JUGDE_APPLY_FLAG,
         VRP_JUGDE_APPLY_CODE,
         VRP_JUGDE_APPLY_TIME,
         VRP_FACE_RESULT_CODE,
         VRP_FACE_RESULT_TIME,
         VRP_FACE_MAKER,
         VRP_FACE_RESULT_PATH,
         VRP_SPEC_RESULT_CODE,
         VRP_SPEC_RESULT_TIME,
         VRP_SPEC_MAKER,
         VRP_SPEC_RESULT_PATH,
         VRP_PHY_RESULT_CODE,
         VRP_PHY_RESULT_TIME,
         VRP_PHY_MAKER,
         VRP_PHY_RESULT_PATH,
         VRP_JUDGE_RESULT_CODE,
         VRP_JUDGE_RESULT_TIME,
         VRP_JUDGE_MAKER,
         VRP_GX_PLAN_NO,
         VRP_GX_PLAN_NO1,
         VPR_JUGDE_CONVICTED,
         VPR_QUALITY_GROUP_ZG,
         VPR_FLAG_STOVE_NO_ZG,
         HTT_HEAT_PLAN_NO,
         HTT_LOT_NO,
         HTT_SAMPLE_FLAG,
         HTT_PRO_ORDER_NO,
         HTT_PRO_ORDER_NO1,
         HTT_PRO_ORDER_ID,
         HTT_PRO_ORDER_ID1,
         HTT_GX_PLAN_NO,
         HTT_GX_PLAN_NO1,
         HTT_JUGDE_APPLY_FLAG,
         HTT_JUGDE_APPLY_CODE,
         HTT_JUGDE_APPLY_TIME,
         HTT_FACE_RESULT_CODE,
         HTT_FACE_RESULT_TIME,
         HTT_FACE_MAKER,
         HTT_FACE_RESULT_PATH,
         HTT_SPEC_RESULT_CODE,
         HTT_SPEC_RESULT_TIME,
         HTT_SPEC_MAKER,
         HTT_SPEC_RESULT_PATH,
         HTT_PHY_RESULT_CODE,
         HTT_PHY_RESULT_TIME,
         HTT_PHY_MAKER,
         HTT_PHY_RESULT_PATH,
         HTT_JUDGE_RESULT_CODE,
         HTT_JUDGE_RESULT_TIME,
         HTT_JUDGE_MAKER,
         HTT_JUGDE_CONVICTED,
         HTT_QUALITY_GROUP_ZG,
         HTT_FLAG_STOVE_NO_ZG,
         PRC_LOT_NO,
         PRC_SAMPLE_FLAG,
         PRC_PRO_ORDER_NO,
         PRC_PRO_ORDER_NO1,
         PRC_PRO_ORDER_ID,
         PRC_PRO_ORDER_ID1,
         PRC_GX_PLAN_NO,
         PRC_GX_PLAN_NO1,
         PRC_JUGDE_APPLY_FLAG,
         PRC_JUGDE_APPLY_CODE,
         PRC_JUGDE_APPLY_TIME,
         PRC_FACE_RESULT_CODE,
         PRC_FACE_RESULT_TIME,
         PRC_FACE_MAKER,
         PRC_FACE_RESULT_PATH,
         PRC_SPEC_RESULT_CODE,
         PRC_SPEC_RESULT_TIME,
         PRC_SPEC_MAKER,
         PRC_SPEC_RESULT_PATH,
         PRC_PHY_RESULT_CODE,
         PRC_PHY_RESULT_TIME,
         PRC_PHY_MAKER,
         PRC_PHY_RESULT_PATH,
         PRC_JUDGE_RESULT_CODE,
         PRC_JUDGE_RESULT_TIME,
         PRC_JUDGE_MAKER,
         PRC_JUGDE_CONVICTED,
         PRC_QUALITY_GROUP_ZG,
         PRC_FLAG_STOVE_NO_ZG,
         PRC_HEAT_PLAN_NO,
         VRP_JUDGE_STD_NAME,
         VRP_JUDGE_STD_CODE,
         HTT_JUDGE_STD_NAME,
         HTT_JUDGE_STD_CODE,
         PRC_JUDGE_STD_NAME,
         PRC_JUDGE_STD_CODE,
         VRP_CRAF_NO,
         HTT_CRAF_NO,
         PRC_CRAF_NO,
         VRP_CHEM_RESULT_CODE,
         VRP_CHEM_RESULT_TIME,
         VRP_CHEM_MAKER,
         HTT_CHEM_RESULT_CODE,
         HTT_CHEM_RESULT_TIME,
         HTT_CHEM_MAKER,
         PRC_CHEM_RESULT_CODE,
         PRC_CHEM_RESULT_TIME,
         PRC_CHEM_MAKER,
         DETECT_REPORT_NO1,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         ZG_PLINE_CODE,
         ZG_PLINE_NAME,
         VRP_PLINE_CODE,
         VRP_PLINE_NAME,
         HTT_PLINE_CODE,
         HTT_PLINE_NAME,
         PRC_PLINE_CODE,
         PRC_PLINE_NAME,
         VRP_QCM_STAUS,
         HTT_QCM_STAUS,
         PRC_QCM_STAUS,
         ZG_MEMO,
         ZBS_FLAG,
         ZBS_ID,
         MEASURING_SEQ,
         INSTOCK_DOC,
         JG_ZBS_ID,
         CHANGE_DOC,
         SUBCONTRACT_NO,
         SUBCONTRACT_NO_SEQ,
         LOCK_BILL_FLAG
    FROM MAT_ZC_M
   WHERE  MAT_NO = ?

	]]>
	</query>


	<query id="frmEntrust.AddZc2" desc="">
		<![CDATA[
	INSERT INTO MAT_ZC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   MAT_SQE_NO,
   SAMPLE_FLAG,
   CUTTING_FLAG,
   ORIGIN_MAT_NO,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   INPUT_ORIGIN_CODE,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_NO1,
   PRO_ORDER_ID,
   PRO_ORDER_ID1,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   DIMATER,
   HEIGHT,
   LEN_NO,
   LEN_DESC,
   LEN_UNIT,
   LEN_MIN,
   LEN_MAX,
   TARG_DIMATER,
   TARG_HEIGHT,
   TARG_LEN_MIN,
   TARG_LEN_MAX,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   PACK_TYPE_CODE,
   PACK_TYPE_NAME,
   PACK_NO,
   PACK_TIME,
   PACK_MAT_WT,
   MAT_GROSS_WT,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   COOL_HOT_FLAG,
   MAT_RETURN_FLAG,
   HEAT_TREAT_NO,
   POST_FLAG,
   LOCK_FLAG,
   MNG_LOCK_RSN_CODE,
   MNG_LOCK_TIME,
   MNG_LOCK_MAKER,
   MNG_LOCK_REMARK,
   LOCK_RSN_CODE,
   LOCK_TIME,
   LOCK_MAKER,
   LOCK_REMARK,
   UNLOCK_TIME,
   UNLOCK_MAKER,
   UNLOCK_REMARK,
   OLD_ORDER_NO,
   OLD_ORDER_SEQ,
   OLD_ORDER_SEQ_NO,
   OLD_MATERIAL_NO,
   OLD_MATERIAL_NAME,
   REMAIN_RSN_CODE,
   REMAIN_JUGDE_TIME,
   REMAIN_JUGDE_MAKER,
   REMAIN_JUGDE_CODE,
   REMAIN_REMARK,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   JUGDE_SCAN_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_REPORT_NO,
   DETECT_RESULT_CODE,
   WPRESSURE_REPORT_NO,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   BUG_NO,
   BUG_DEAL,
   REPAIR_FLAG,
   REPAIR_REMARK,
   SAMPLING_FLAG,
   SAMPLING_TYPE,
   SAMPLING_NO,
   CHECKOUT_NO,
   CHEM_STCHECK_NO,
   CHEM_PROCHECK_NO,
   SH_CHECK_NO,
   COME_PROC_FLAG,
   CONFM_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   OUTSTOCK_TIME,
   PRO_BC,
   PRO_BZ,
   RPO_TIME,
   BAR_CODE,
   BEGINNING_FLAG,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   REQ_BL_ID,
   IF_BATCHED_JG,
   COUPCUT_BATCH_ID,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   OLD_ORD_PK,
   OLD_ORD_LN_PK,
   OLD_ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   JUDGE_GRADE,
   PIPMEMO,
   TEST,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   MEMO1,
   JUDGE_ID,
   MNG_LOCK_FLAG,
   LOCK_ID,
   PRO_NO,
   LOCK_LIKU,
   PLN_GRADECODE,
   PLN_GRADENAME,
   PLN_STEELCODE,
   PLN_STEELNAME,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   FINISHPRO_MOLD,
   IN_MOLD,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   GX_PLAN_NO1,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   ZG_PHY_RESULT_PATH,
   ZG_FACE_RESULT_PATH,
   ZG_SPEC_RESULT_PATH,
   VRP_HEAT_PLAN_NO,
   VRP_LOT_NO,
   VRP_SAMPLE_FLAG,
   VRP_PRO_ORDER_NO,
   VRP_PRO_ORDER_NO1,
   VRP_PRO_ORDER_ID,
   VRP_PRO_ORDER_ID1,
   VRP_ACT_DIMATER,
   VRP_ACT_HEIGHT,
   VRP_JUGDE_APPLY_FLAG,
   VRP_JUGDE_APPLY_CODE,
   VRP_JUGDE_APPLY_TIME,
   VRP_FACE_RESULT_CODE,
   VRP_FACE_RESULT_TIME,
   VRP_FACE_MAKER,
   VRP_FACE_RESULT_PATH,
   VRP_SPEC_RESULT_CODE,
   VRP_SPEC_RESULT_TIME,
   VRP_SPEC_MAKER,
   VRP_SPEC_RESULT_PATH,
   VRP_PHY_RESULT_CODE,
   VRP_PHY_RESULT_TIME,
   VRP_PHY_MAKER,
   VRP_PHY_RESULT_PATH,
   VRP_JUDGE_RESULT_CODE,
   VRP_JUDGE_RESULT_TIME,
   VRP_JUDGE_MAKER,
   VRP_GX_PLAN_NO,
   VRP_GX_PLAN_NO1,
   VPR_JUGDE_CONVICTED,
   VPR_QUALITY_GROUP_ZG,
   VPR_FLAG_STOVE_NO_ZG,
   HTT_HEAT_PLAN_NO,
   HTT_LOT_NO,
   HTT_SAMPLE_FLAG,
   HTT_PRO_ORDER_NO,
   HTT_PRO_ORDER_NO1,
   HTT_PRO_ORDER_ID,
   HTT_PRO_ORDER_ID1,
   HTT_GX_PLAN_NO,
   HTT_GX_PLAN_NO1,
   HTT_JUGDE_APPLY_FLAG,
   HTT_JUGDE_APPLY_CODE,
   HTT_JUGDE_APPLY_TIME,
   HTT_FACE_RESULT_CODE,
   HTT_FACE_RESULT_TIME,
   HTT_FACE_MAKER,
   HTT_FACE_RESULT_PATH,
   HTT_SPEC_RESULT_CODE,
   HTT_SPEC_RESULT_TIME,
   HTT_SPEC_MAKER,
   HTT_SPEC_RESULT_PATH,
   HTT_PHY_RESULT_CODE,
   HTT_PHY_RESULT_TIME,
   HTT_PHY_MAKER,
   HTT_PHY_RESULT_PATH,
   HTT_JUDGE_RESULT_CODE,
   HTT_JUDGE_RESULT_TIME,
   HTT_JUDGE_MAKER,
   HTT_JUGDE_CONVICTED,
   HTT_QUALITY_GROUP_ZG,
   HTT_FLAG_STOVE_NO_ZG,
   PRC_LOT_NO,
   PRC_SAMPLE_FLAG,
   PRC_PRO_ORDER_NO,
   PRC_PRO_ORDER_NO1,
   PRC_PRO_ORDER_ID,
   PRC_PRO_ORDER_ID1,
   PRC_GX_PLAN_NO,
   PRC_GX_PLAN_NO1,
   PRC_JUGDE_APPLY_FLAG,
   PRC_JUGDE_APPLY_CODE,
   PRC_JUGDE_APPLY_TIME,
   PRC_FACE_RESULT_CODE,
   PRC_FACE_RESULT_TIME,
   PRC_FACE_MAKER,
   PRC_FACE_RESULT_PATH,
   PRC_SPEC_RESULT_CODE,
   PRC_SPEC_RESULT_TIME,
   PRC_SPEC_MAKER,
   PRC_SPEC_RESULT_PATH,
   PRC_PHY_RESULT_CODE,
   PRC_PHY_RESULT_TIME,
   PRC_PHY_MAKER,
   PRC_PHY_RESULT_PATH,
   PRC_JUDGE_RESULT_CODE,
   PRC_JUDGE_RESULT_TIME,
   PRC_JUDGE_MAKER,
   PRC_JUGDE_CONVICTED,
   PRC_QUALITY_GROUP_ZG,
   PRC_FLAG_STOVE_NO_ZG,
   PRC_HEAT_PLAN_NO,
   VRP_JUDGE_STD_NAME,
   VRP_JUDGE_STD_CODE,
   HTT_JUDGE_STD_NAME,
   HTT_JUDGE_STD_CODE,
   PRC_JUDGE_STD_NAME,
   PRC_JUDGE_STD_CODE,
   VRP_CRAF_NO,
   HTT_CRAF_NO,
   PRC_CRAF_NO,
   VRP_CHEM_RESULT_CODE,
   VRP_CHEM_RESULT_TIME,
   VRP_CHEM_MAKER,
   HTT_CHEM_RESULT_CODE,
   HTT_CHEM_RESULT_TIME,
   HTT_CHEM_MAKER,
   PRC_CHEM_RESULT_CODE,
   PRC_CHEM_RESULT_TIME,
   PRC_CHEM_MAKER,
   DETECT_REPORT_NO1,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   ZG_PLINE_CODE,
   ZG_PLINE_NAME,
   VRP_PLINE_CODE,
   VRP_PLINE_NAME,
   HTT_PLINE_CODE,
   HTT_PLINE_NAME,
   PRC_PLINE_CODE,
   PRC_PLINE_NAME,
   VRP_QCM_STAUS,
   HTT_QCM_STAUS,
   PRC_QCM_STAUS,
   ZG_MEMO,
   ZBS_FLAG,
   ZBS_ID,
   MEASURING_SEQ,
   INSTOCK_DOC,
   JG_ZBS_ID,
   CHANGE_DOC,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   LOCK_BILL_FLAG)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         MAT_SQE_NO,
         SAMPLE_FLAG,
         CUTTING_FLAG,
         ORIGIN_MAT_NO,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         INPUT_ORIGIN_CODE,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_NO1,
         PRO_ORDER_ID,
         PRO_ORDER_ID1,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         DIMATER,
         HEIGHT,
         LEN_NO,
         LEN_DESC,
         LEN_UNIT,
         LEN_MIN,
         LEN_MAX,
         TARG_DIMATER,
         TARG_HEIGHT,
         TARG_LEN_MIN,
         TARG_LEN_MAX,
         ACT_DIMATER,
         ACT_HEIGHT,
        ACT_LEN- (?-1) *  ROUND(ACT_LEN/?,3)  ,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
           ACT_WEIGHT- (?-1) *  ROUND(ACT_WEIGHT/?,3)  ,
       ACT_THEORY_WEIGHT- (?-1) *  ROUND(ACT_THEORY_WEIGHT/?,3)  ,
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         PACK_TYPE_CODE,
         PACK_TYPE_NAME,
         PACK_NO,
         PACK_TIME,
         PACK_MAT_WT,
         MAT_GROSS_WT,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         COOL_HOT_FLAG,
         MAT_RETURN_FLAG,
         HEAT_TREAT_NO,
         POST_FLAG,
         LOCK_FLAG,
         MNG_LOCK_RSN_CODE,
         MNG_LOCK_TIME,
         MNG_LOCK_MAKER,
         MNG_LOCK_REMARK,
         LOCK_RSN_CODE,
         LOCK_TIME,
         LOCK_MAKER,
         LOCK_REMARK,
         UNLOCK_TIME,
         UNLOCK_MAKER,
         UNLOCK_REMARK,
         OLD_ORDER_NO,
         OLD_ORDER_SEQ,
         OLD_ORDER_SEQ_NO,
         OLD_MATERIAL_NO,
         OLD_MATERIAL_NAME,
         REMAIN_RSN_CODE,
         REMAIN_JUGDE_TIME,
         REMAIN_JUGDE_MAKER,
         REMAIN_JUGDE_CODE,
         REMAIN_REMARK,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         JUGDE_SCAN_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_REPORT_NO,
         DETECT_RESULT_CODE,
         WPRESSURE_REPORT_NO,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         BUG_NO,
         BUG_DEAL,
         REPAIR_FLAG,
         REPAIR_REMARK,
         SAMPLING_FLAG,
         SAMPLING_TYPE,
         SAMPLING_NO,
         CHECKOUT_NO,
         CHEM_STCHECK_NO,
         CHEM_PROCHECK_NO,
         SH_CHECK_NO,
         COME_PROC_FLAG,
         CONFM_FLAG,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         OUTSTOCK_TIME,
         PRO_BC,
         PRO_BZ,
         RPO_TIME,
         BAR_CODE,
         BEGINNING_FLAG,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         REQ_BL_ID,
         IF_BATCHED_JG,
         COUPCUT_BATCH_ID,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         OLD_ORD_PK,
         OLD_ORD_LN_PK,
         OLD_ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         JUDGE_GRADE,
         PIPMEMO,
         TEST,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         MEMO1,
         JUDGE_ID,
         MNG_LOCK_FLAG,
         LOCK_ID,
         PRO_NO,
         LOCK_LIKU,
         PLN_GRADECODE,
         PLN_GRADENAME,
         PLN_STEELCODE,
         PLN_STEELNAME,
         QCM_STAUS,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         FINISHPRO_MOLD,
         IN_MOLD,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         GX_PLAN_NO1,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         ZG_PHY_RESULT_PATH,
         ZG_FACE_RESULT_PATH,
         ZG_SPEC_RESULT_PATH,
         VRP_HEAT_PLAN_NO,
         VRP_LOT_NO,
         VRP_SAMPLE_FLAG,
         VRP_PRO_ORDER_NO,
         VRP_PRO_ORDER_NO1,
         VRP_PRO_ORDER_ID,
         VRP_PRO_ORDER_ID1,
         VRP_ACT_DIMATER,
         VRP_ACT_HEIGHT,
         VRP_JUGDE_APPLY_FLAG,
         VRP_JUGDE_APPLY_CODE,
         VRP_JUGDE_APPLY_TIME,
         VRP_FACE_RESULT_CODE,
         VRP_FACE_RESULT_TIME,
         VRP_FACE_MAKER,
         VRP_FACE_RESULT_PATH,
         VRP_SPEC_RESULT_CODE,
         VRP_SPEC_RESULT_TIME,
         VRP_SPEC_MAKER,
         VRP_SPEC_RESULT_PATH,
         VRP_PHY_RESULT_CODE,
         VRP_PHY_RESULT_TIME,
         VRP_PHY_MAKER,
         VRP_PHY_RESULT_PATH,
         VRP_JUDGE_RESULT_CODE,
         VRP_JUDGE_RESULT_TIME,
         VRP_JUDGE_MAKER,
         VRP_GX_PLAN_NO,
         VRP_GX_PLAN_NO1,
         VPR_JUGDE_CONVICTED,
         VPR_QUALITY_GROUP_ZG,
         VPR_FLAG_STOVE_NO_ZG,
         HTT_HEAT_PLAN_NO,
         HTT_LOT_NO,
         HTT_SAMPLE_FLAG,
         HTT_PRO_ORDER_NO,
         HTT_PRO_ORDER_NO1,
         HTT_PRO_ORDER_ID,
         HTT_PRO_ORDER_ID1,
         HTT_GX_PLAN_NO,
         HTT_GX_PLAN_NO1,
         HTT_JUGDE_APPLY_FLAG,
         HTT_JUGDE_APPLY_CODE,
         HTT_JUGDE_APPLY_TIME,
         HTT_FACE_RESULT_CODE,
         HTT_FACE_RESULT_TIME,
         HTT_FACE_MAKER,
         HTT_FACE_RESULT_PATH,
         HTT_SPEC_RESULT_CODE,
         HTT_SPEC_RESULT_TIME,
         HTT_SPEC_MAKER,
         HTT_SPEC_RESULT_PATH,
         HTT_PHY_RESULT_CODE,
         HTT_PHY_RESULT_TIME,
         HTT_PHY_MAKER,
         HTT_PHY_RESULT_PATH,
         HTT_JUDGE_RESULT_CODE,
         HTT_JUDGE_RESULT_TIME,
         HTT_JUDGE_MAKER,
         HTT_JUGDE_CONVICTED,
         HTT_QUALITY_GROUP_ZG,
         HTT_FLAG_STOVE_NO_ZG,
         PRC_LOT_NO,
         PRC_SAMPLE_FLAG,
         PRC_PRO_ORDER_NO,
         PRC_PRO_ORDER_NO1,
         PRC_PRO_ORDER_ID,
         PRC_PRO_ORDER_ID1,
         PRC_GX_PLAN_NO,
         PRC_GX_PLAN_NO1,
         PRC_JUGDE_APPLY_FLAG,
         PRC_JUGDE_APPLY_CODE,
         PRC_JUGDE_APPLY_TIME,
         PRC_FACE_RESULT_CODE,
         PRC_FACE_RESULT_TIME,
         PRC_FACE_MAKER,
         PRC_FACE_RESULT_PATH,
         PRC_SPEC_RESULT_CODE,
         PRC_SPEC_RESULT_TIME,
         PRC_SPEC_MAKER,
         PRC_SPEC_RESULT_PATH,
         PRC_PHY_RESULT_CODE,
         PRC_PHY_RESULT_TIME,
         PRC_PHY_MAKER,
         PRC_PHY_RESULT_PATH,
         PRC_JUDGE_RESULT_CODE,
         PRC_JUDGE_RESULT_TIME,
         PRC_JUDGE_MAKER,
         PRC_JUGDE_CONVICTED,
         PRC_QUALITY_GROUP_ZG,
         PRC_FLAG_STOVE_NO_ZG,
         PRC_HEAT_PLAN_NO,
         VRP_JUDGE_STD_NAME,
         VRP_JUDGE_STD_CODE,
         HTT_JUDGE_STD_NAME,
         HTT_JUDGE_STD_CODE,
         PRC_JUDGE_STD_NAME,
         PRC_JUDGE_STD_CODE,
         VRP_CRAF_NO,
         HTT_CRAF_NO,
         PRC_CRAF_NO,
         VRP_CHEM_RESULT_CODE,
         VRP_CHEM_RESULT_TIME,
         VRP_CHEM_MAKER,
         HTT_CHEM_RESULT_CODE,
         HTT_CHEM_RESULT_TIME,
         HTT_CHEM_MAKER,
         PRC_CHEM_RESULT_CODE,
         PRC_CHEM_RESULT_TIME,
         PRC_CHEM_MAKER,
         DETECT_REPORT_NO1,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         ZG_PLINE_CODE,
         ZG_PLINE_NAME,
         VRP_PLINE_CODE,
         VRP_PLINE_NAME,
         HTT_PLINE_CODE,
         HTT_PLINE_NAME,
         PRC_PLINE_CODE,
         PRC_PLINE_NAME,
         VRP_QCM_STAUS,
         HTT_QCM_STAUS,
         PRC_QCM_STAUS,
         ZG_MEMO,
         ZBS_FLAG,
         ZBS_ID,
         MEASURING_SEQ,
         INSTOCK_DOC,
         JG_ZBS_ID,
         CHANGE_DOC,
         SUBCONTRACT_NO,
         SUBCONTRACT_NO_SEQ,
         LOCK_BILL_FLAG
    FROM MAT_ZC_M
   WHERE  MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddZc3" desc="">
		<![CDATA[
	INSERT INTO MAT_ZC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   MAT_SQE_NO,
   SAMPLE_FLAG,
   CUTTING_FLAG,
   ORIGIN_MAT_NO,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   INPUT_ORIGIN_CODE,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_NO1,
   PRO_ORDER_ID,
   PRO_ORDER_ID1,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   DIMATER,
   HEIGHT,
   LEN_NO,
   LEN_DESC,
   LEN_UNIT,
   LEN_MIN,
   LEN_MAX,
   TARG_DIMATER,
   TARG_HEIGHT,
   TARG_LEN_MIN,
   TARG_LEN_MAX,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   PACK_TYPE_CODE,
   PACK_TYPE_NAME,
   PACK_NO,
   PACK_TIME,
   PACK_MAT_WT,
   MAT_GROSS_WT,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   COOL_HOT_FLAG,
   MAT_RETURN_FLAG,
   HEAT_TREAT_NO,
   POST_FLAG,
   LOCK_FLAG,
   MNG_LOCK_RSN_CODE,
   MNG_LOCK_TIME,
   MNG_LOCK_MAKER,
   MNG_LOCK_REMARK,
   LOCK_RSN_CODE,
   LOCK_TIME,
   LOCK_MAKER,
   LOCK_REMARK,
   UNLOCK_TIME,
   UNLOCK_MAKER,
   UNLOCK_REMARK,
   OLD_ORDER_NO,
   OLD_ORDER_SEQ,
   OLD_ORDER_SEQ_NO,
   OLD_MATERIAL_NO,
   OLD_MATERIAL_NAME,
   REMAIN_RSN_CODE,
   REMAIN_JUGDE_TIME,
   REMAIN_JUGDE_MAKER,
   REMAIN_JUGDE_CODE,
   REMAIN_REMARK,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   JUGDE_SCAN_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_REPORT_NO,
   DETECT_RESULT_CODE,
   WPRESSURE_REPORT_NO,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   BUG_NO,
   BUG_DEAL,
   REPAIR_FLAG,
   REPAIR_REMARK,
   SAMPLING_FLAG,
   SAMPLING_TYPE,
   SAMPLING_NO,
   CHECKOUT_NO,
   CHEM_STCHECK_NO,
   CHEM_PROCHECK_NO,
   SH_CHECK_NO,
   COME_PROC_FLAG,
   CONFM_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   OUTSTOCK_TIME,
   PRO_BC,
   PRO_BZ,
   RPO_TIME,
   BAR_CODE,
   BEGINNING_FLAG,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   REQ_BL_ID,
   IF_BATCHED_JG,
   COUPCUT_BATCH_ID,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   OLD_ORD_PK,
   OLD_ORD_LN_PK,
   OLD_ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   JUDGE_GRADE,
   PIPMEMO,
   TEST,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   MEMO1,
   JUDGE_ID,
   MNG_LOCK_FLAG,
   LOCK_ID,
   PRO_NO,
   LOCK_LIKU,
   PLN_GRADECODE,
   PLN_GRADENAME,
   PLN_STEELCODE,
   PLN_STEELNAME,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   FINISHPRO_MOLD,
   IN_MOLD,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   GX_PLAN_NO1,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   ZG_PHY_RESULT_PATH,
   ZG_FACE_RESULT_PATH,
   ZG_SPEC_RESULT_PATH,
   VRP_HEAT_PLAN_NO,
   VRP_LOT_NO,
   VRP_SAMPLE_FLAG,
   VRP_PRO_ORDER_NO,
   VRP_PRO_ORDER_NO1,
   VRP_PRO_ORDER_ID,
   VRP_PRO_ORDER_ID1,
   VRP_ACT_DIMATER,
   VRP_ACT_HEIGHT,
   VRP_JUGDE_APPLY_FLAG,
   VRP_JUGDE_APPLY_CODE,
   VRP_JUGDE_APPLY_TIME,
   VRP_FACE_RESULT_CODE,
   VRP_FACE_RESULT_TIME,
   VRP_FACE_MAKER,
   VRP_FACE_RESULT_PATH,
   VRP_SPEC_RESULT_CODE,
   VRP_SPEC_RESULT_TIME,
   VRP_SPEC_MAKER,
   VRP_SPEC_RESULT_PATH,
   VRP_PHY_RESULT_CODE,
   VRP_PHY_RESULT_TIME,
   VRP_PHY_MAKER,
   VRP_PHY_RESULT_PATH,
   VRP_JUDGE_RESULT_CODE,
   VRP_JUDGE_RESULT_TIME,
   VRP_JUDGE_MAKER,
   VRP_GX_PLAN_NO,
   VRP_GX_PLAN_NO1,
   VPR_JUGDE_CONVICTED,
   VPR_QUALITY_GROUP_ZG,
   VPR_FLAG_STOVE_NO_ZG,
   HTT_HEAT_PLAN_NO,
   HTT_LOT_NO,
   HTT_SAMPLE_FLAG,
   HTT_PRO_ORDER_NO,
   HTT_PRO_ORDER_NO1,
   HTT_PRO_ORDER_ID,
   HTT_PRO_ORDER_ID1,
   HTT_GX_PLAN_NO,
   HTT_GX_PLAN_NO1,
   HTT_JUGDE_APPLY_FLAG,
   HTT_JUGDE_APPLY_CODE,
   HTT_JUGDE_APPLY_TIME,
   HTT_FACE_RESULT_CODE,
   HTT_FACE_RESULT_TIME,
   HTT_FACE_MAKER,
   HTT_FACE_RESULT_PATH,
   HTT_SPEC_RESULT_CODE,
   HTT_SPEC_RESULT_TIME,
   HTT_SPEC_MAKER,
   HTT_SPEC_RESULT_PATH,
   HTT_PHY_RESULT_CODE,
   HTT_PHY_RESULT_TIME,
   HTT_PHY_MAKER,
   HTT_PHY_RESULT_PATH,
   HTT_JUDGE_RESULT_CODE,
   HTT_JUDGE_RESULT_TIME,
   HTT_JUDGE_MAKER,
   HTT_JUGDE_CONVICTED,
   HTT_QUALITY_GROUP_ZG,
   HTT_FLAG_STOVE_NO_ZG,
   PRC_LOT_NO,
   PRC_SAMPLE_FLAG,
   PRC_PRO_ORDER_NO,
   PRC_PRO_ORDER_NO1,
   PRC_PRO_ORDER_ID,
   PRC_PRO_ORDER_ID1,
   PRC_GX_PLAN_NO,
   PRC_GX_PLAN_NO1,
   PRC_JUGDE_APPLY_FLAG,
   PRC_JUGDE_APPLY_CODE,
   PRC_JUGDE_APPLY_TIME,
   PRC_FACE_RESULT_CODE,
   PRC_FACE_RESULT_TIME,
   PRC_FACE_MAKER,
   PRC_FACE_RESULT_PATH,
   PRC_SPEC_RESULT_CODE,
   PRC_SPEC_RESULT_TIME,
   PRC_SPEC_MAKER,
   PRC_SPEC_RESULT_PATH,
   PRC_PHY_RESULT_CODE,
   PRC_PHY_RESULT_TIME,
   PRC_PHY_MAKER,
   PRC_PHY_RESULT_PATH,
   PRC_JUDGE_RESULT_CODE,
   PRC_JUDGE_RESULT_TIME,
   PRC_JUDGE_MAKER,
   PRC_JUGDE_CONVICTED,
   PRC_QUALITY_GROUP_ZG,
   PRC_FLAG_STOVE_NO_ZG,
   PRC_HEAT_PLAN_NO,
   VRP_JUDGE_STD_NAME,
   VRP_JUDGE_STD_CODE,
   HTT_JUDGE_STD_NAME,
   HTT_JUDGE_STD_CODE,
   PRC_JUDGE_STD_NAME,
   PRC_JUDGE_STD_CODE,
   VRP_CRAF_NO,
   HTT_CRAF_NO,
   PRC_CRAF_NO,
   VRP_CHEM_RESULT_CODE,
   VRP_CHEM_RESULT_TIME,
   VRP_CHEM_MAKER,
   HTT_CHEM_RESULT_CODE,
   HTT_CHEM_RESULT_TIME,
   HTT_CHEM_MAKER,
   PRC_CHEM_RESULT_CODE,
   PRC_CHEM_RESULT_TIME,
   PRC_CHEM_MAKER,
   DETECT_REPORT_NO1,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   ZG_PLINE_CODE,
   ZG_PLINE_NAME,
   VRP_PLINE_CODE,
   VRP_PLINE_NAME,
   HTT_PLINE_CODE,
   HTT_PLINE_NAME,
   PRC_PLINE_CODE,
   PRC_PLINE_NAME,
   VRP_QCM_STAUS,
   HTT_QCM_STAUS,
   PRC_QCM_STAUS,
   ZG_MEMO,
   ZBS_FLAG,
   ZBS_ID,
   MEASURING_SEQ,
   INSTOCK_DOC,
   JG_ZBS_ID,
   CHANGE_DOC,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ,
   LOCK_BILL_FLAG)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         MAT_SQE_NO,
         SAMPLE_FLAG,
         CUTTING_FLAG,
         ORIGIN_MAT_NO,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         INPUT_ORIGIN_CODE,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_NO1,
         PRO_ORDER_ID,
         PRO_ORDER_ID1,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         DIMATER,
         HEIGHT,
         LEN_NO,
         LEN_DESC,
         LEN_UNIT,
         LEN_MIN,
         LEN_MAX,
         TARG_DIMATER,
         TARG_HEIGHT,
         TARG_LEN_MIN,
         TARG_LEN_MAX,
         ACT_DIMATER,
         ACT_HEIGHT,
         ?,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
          ?,
         ?,
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         PACK_TYPE_CODE,
         PACK_TYPE_NAME,
         PACK_NO,
         PACK_TIME,
         PACK_MAT_WT,
         MAT_GROSS_WT,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         COOL_HOT_FLAG,
         MAT_RETURN_FLAG,
         HEAT_TREAT_NO,
         POST_FLAG,
         LOCK_FLAG,
         MNG_LOCK_RSN_CODE,
         MNG_LOCK_TIME,
         MNG_LOCK_MAKER,
         MNG_LOCK_REMARK,
         LOCK_RSN_CODE,
         LOCK_TIME,
         LOCK_MAKER,
         LOCK_REMARK,
         UNLOCK_TIME,
         UNLOCK_MAKER,
         UNLOCK_REMARK,
         OLD_ORDER_NO,
         OLD_ORDER_SEQ,
         OLD_ORDER_SEQ_NO,
         OLD_MATERIAL_NO,
         OLD_MATERIAL_NAME,
         REMAIN_RSN_CODE,
         REMAIN_JUGDE_TIME,
         REMAIN_JUGDE_MAKER,
         REMAIN_JUGDE_CODE,
         REMAIN_REMARK,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         JUGDE_SCAN_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_REPORT_NO,
         DETECT_RESULT_CODE,
         WPRESSURE_REPORT_NO,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         BUG_NO,
         BUG_DEAL,
         REPAIR_FLAG,
         REPAIR_REMARK,
         SAMPLING_FLAG,
         SAMPLING_TYPE,
         SAMPLING_NO,
         CHECKOUT_NO,
         CHEM_STCHECK_NO,
         CHEM_PROCHECK_NO,
         SH_CHECK_NO,
         COME_PROC_FLAG,
         CONFM_FLAG,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         OUTSTOCK_TIME,
         PRO_BC,
         PRO_BZ,
         RPO_TIME,
         BAR_CODE,
         BEGINNING_FLAG,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         REQ_BL_ID,
         IF_BATCHED_JG,
         COUPCUT_BATCH_ID,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         OLD_ORD_PK,
         OLD_ORD_LN_PK,
         OLD_ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         JUDGE_GRADE,
         PIPMEMO,
         TEST,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         MEMO1,
         JUDGE_ID,
         MNG_LOCK_FLAG,
         LOCK_ID,
         PRO_NO,
         LOCK_LIKU,
         PLN_GRADECODE,
         PLN_GRADENAME,
         PLN_STEELCODE,
         PLN_STEELNAME,
         QCM_STAUS,
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         FINISHPRO_MOLD,
         IN_MOLD,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         GX_PLAN_NO1,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         ZG_PHY_RESULT_PATH,
         ZG_FACE_RESULT_PATH,
         ZG_SPEC_RESULT_PATH,
         VRP_HEAT_PLAN_NO,
         VRP_LOT_NO,
         VRP_SAMPLE_FLAG,
         VRP_PRO_ORDER_NO,
         VRP_PRO_ORDER_NO1,
         VRP_PRO_ORDER_ID,
         VRP_PRO_ORDER_ID1,
         VRP_ACT_DIMATER,
         VRP_ACT_HEIGHT,
         VRP_JUGDE_APPLY_FLAG,
         VRP_JUGDE_APPLY_CODE,
         VRP_JUGDE_APPLY_TIME,
         VRP_FACE_RESULT_CODE,
         VRP_FACE_RESULT_TIME,
         VRP_FACE_MAKER,
         VRP_FACE_RESULT_PATH,
         VRP_SPEC_RESULT_CODE,
         VRP_SPEC_RESULT_TIME,
         VRP_SPEC_MAKER,
         VRP_SPEC_RESULT_PATH,
         VRP_PHY_RESULT_CODE,
         VRP_PHY_RESULT_TIME,
         VRP_PHY_MAKER,
         VRP_PHY_RESULT_PATH,
         VRP_JUDGE_RESULT_CODE,
         VRP_JUDGE_RESULT_TIME,
         VRP_JUDGE_MAKER,
         VRP_GX_PLAN_NO,
         VRP_GX_PLAN_NO1,
         VPR_JUGDE_CONVICTED,
         VPR_QUALITY_GROUP_ZG,
         VPR_FLAG_STOVE_NO_ZG,
         HTT_HEAT_PLAN_NO,
         HTT_LOT_NO,
         HTT_SAMPLE_FLAG,
         HTT_PRO_ORDER_NO,
         HTT_PRO_ORDER_NO1,
         HTT_PRO_ORDER_ID,
         HTT_PRO_ORDER_ID1,
         HTT_GX_PLAN_NO,
         HTT_GX_PLAN_NO1,
         HTT_JUGDE_APPLY_FLAG,
         HTT_JUGDE_APPLY_CODE,
         HTT_JUGDE_APPLY_TIME,
         HTT_FACE_RESULT_CODE,
         HTT_FACE_RESULT_TIME,
         HTT_FACE_MAKER,
         HTT_FACE_RESULT_PATH,
         HTT_SPEC_RESULT_CODE,
         HTT_SPEC_RESULT_TIME,
         HTT_SPEC_MAKER,
         HTT_SPEC_RESULT_PATH,
         HTT_PHY_RESULT_CODE,
         HTT_PHY_RESULT_TIME,
         HTT_PHY_MAKER,
         HTT_PHY_RESULT_PATH,
         HTT_JUDGE_RESULT_CODE,
         HTT_JUDGE_RESULT_TIME,
         HTT_JUDGE_MAKER,
         HTT_JUGDE_CONVICTED,
         HTT_QUALITY_GROUP_ZG,
         HTT_FLAG_STOVE_NO_ZG,
         PRC_LOT_NO,
         PRC_SAMPLE_FLAG,
         PRC_PRO_ORDER_NO,
         PRC_PRO_ORDER_NO1,
         PRC_PRO_ORDER_ID,
         PRC_PRO_ORDER_ID1,
         PRC_GX_PLAN_NO,
         PRC_GX_PLAN_NO1,
         PRC_JUGDE_APPLY_FLAG,
         PRC_JUGDE_APPLY_CODE,
         PRC_JUGDE_APPLY_TIME,
         PRC_FACE_RESULT_CODE,
         PRC_FACE_RESULT_TIME,
         PRC_FACE_MAKER,
         PRC_FACE_RESULT_PATH,
         PRC_SPEC_RESULT_CODE,
         PRC_SPEC_RESULT_TIME,
         PRC_SPEC_MAKER,
         PRC_SPEC_RESULT_PATH,
         PRC_PHY_RESULT_CODE,
         PRC_PHY_RESULT_TIME,
         PRC_PHY_MAKER,
         PRC_PHY_RESULT_PATH,
         PRC_JUDGE_RESULT_CODE,
         PRC_JUDGE_RESULT_TIME,
         PRC_JUDGE_MAKER,
         PRC_JUGDE_CONVICTED,
         PRC_QUALITY_GROUP_ZG,
         PRC_FLAG_STOVE_NO_ZG,
         PRC_HEAT_PLAN_NO,
         VRP_JUDGE_STD_NAME,
         VRP_JUDGE_STD_CODE,
         HTT_JUDGE_STD_NAME,
         HTT_JUDGE_STD_CODE,
         PRC_JUDGE_STD_NAME,
         PRC_JUDGE_STD_CODE,
         VRP_CRAF_NO,
         HTT_CRAF_NO,
         PRC_CRAF_NO,
         VRP_CHEM_RESULT_CODE,
         VRP_CHEM_RESULT_TIME,
         VRP_CHEM_MAKER,
         HTT_CHEM_RESULT_CODE,
         HTT_CHEM_RESULT_TIME,
         HTT_CHEM_MAKER,
         PRC_CHEM_RESULT_CODE,
         PRC_CHEM_RESULT_TIME,
         PRC_CHEM_MAKER,
         DETECT_REPORT_NO1,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         ZG_PLINE_CODE,
         ZG_PLINE_NAME,
         VRP_PLINE_CODE,
         VRP_PLINE_NAME,
         HTT_PLINE_CODE,
         HTT_PLINE_NAME,
         PRC_PLINE_CODE,
         PRC_PLINE_NAME,
         VRP_QCM_STAUS,
         HTT_QCM_STAUS,
         PRC_QCM_STAUS,
         ZG_MEMO,
         ZBS_FLAG,
         ZBS_ID,
         MEASURING_SEQ,
         INSTOCK_DOC,
         JG_ZBS_ID,
         CHANGE_DOC,
         SUBCONTRACT_NO,
         SUBCONTRACT_NO_SEQ,
         LOCK_BILL_FLAG
    FROM MAT_ZC_M
   WHERE  MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddYdmButress" desc="">
		<![CDATA[
		INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
  SELECT ?,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC
    FROM YDM_BC_BUTTRESS
   WHERE MAT_NO =?

	]]>
	</query>

	<query id="frmEntrust.AddYdmZcButress" desc="">
		<![CDATA[
	INSERT INTO YDM_ZC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
  SELECT ?,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC
    FROM YDM_ZC_BUTTRESS
   WHERE MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.DeletePortG" desc="">
		<![CDATA[
		DELETE FROM PORT_MCH_BATCH_SAMPLE_RESULT 	WHERE RESULT_NO =? AND MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.DeletePortF" desc="">
		<![CDATA[
		DELETE FROM PORT_HTT_BATCH_SAMPLE_RESULT 	WHERE RESULT_NO =? AND MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.DeletePortE" desc="">
		<![CDATA[
		DELETE FROM PORT_VRP_BATCH_SAMPLE_RESULT 	WHERE RESULT_NO =? AND MAT_NO = ?

	]]>
	</query>




	<query id="frmEntrust.AddBc1" desc="">
		<![CDATA[
		INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT,
   CODE_JG_BL,
   CIC,
   SCRAP_REASON,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   ZBS_FLAG,
   SCRAP_TYPE,
   ZBS_ID,
   HEAT_PLAN_NO_OLD,
   MEASURING_SEQ,
   SCRAP_FLAG,
   LIKU_PROCESS_CODE,
   JG_ZBS_ID,
   FAIL_APPROVAL_CODE,
    OFFLINE_DOC,
       SUBCONTRACT_NO,
       SCRAP_FRIM_FLAG,
       ZZB_FLAG,
       BAL_YEAR_MONTH_FAIL,
       SUBCONTRACT_NO_SEQ,
       SCRAP_NAME,
       SCRAP_TIME)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT * ?,
         ACT_THEORY_WEIGHT * ?,
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         '11',
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT,
         CODE_JG_BL,
         CIC,
         SCRAP_REASON,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         ZBS_FLAG,
         SCRAP_TYPE,
         ZBS_ID,
         HEAT_PLAN_NO_OLD,
         MEASURING_SEQ,
         SCRAP_FLAG,
         LIKU_PROCESS_CODE,
         JG_ZBS_ID,
         FAIL_APPROVAL_CODE,
          OFFLINE_DOC,
       SUBCONTRACT_NO,
       SCRAP_FRIM_FLAG,
       ZZB_FLAG,
       BAL_YEAR_MONTH_FAIL,
       SUBCONTRACT_NO_SEQ,
       SCRAP_NAME,
       SCRAP_TIME
    FROM MAT_BC_M
   WHERE MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddBc5" desc="">
		<![CDATA[
		INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT,
   CODE_JG_BL,
   CIC,
   SCRAP_REASON,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   ZBS_FLAG,
   SCRAP_TYPE,
   ZBS_ID,
   HEAT_PLAN_NO_OLD,
   MEASURING_SEQ,
   SCRAP_FLAG,
   LIKU_PROCESS_CODE,
   JG_ZBS_ID,
   FAIL_APPROVAL_CODE,
    OFFLINE_DOC,
       SUBCONTRACT_NO,
       SCRAP_FRIM_FLAG,
       ZZB_FLAG,
       BAL_YEAR_MONTH_FAIL,
       SUBCONTRACT_NO_SEQ,
       SCRAP_NAME,
       SCRAP_TIME)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ?,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
          ?,
          ?,
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         '11',
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT,
         CODE_JG_BL,
         CIC,
         SCRAP_REASON,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         ZBS_FLAG,
         SCRAP_TYPE,
         ZBS_ID,
         HEAT_PLAN_NO_OLD,
         MEASURING_SEQ,
         SCRAP_FLAG,
         LIKU_PROCESS_CODE,
         JG_ZBS_ID,
         FAIL_APPROVAL_CODE,
          OFFLINE_DOC,
       SUBCONTRACT_NO,
       SCRAP_FRIM_FLAG,
       ZZB_FLAG,
       BAL_YEAR_MONTH_FAIL,
       SUBCONTRACT_NO_SEQ,
       SCRAP_NAME,
       SCRAP_TIME
    FROM MAT_BC_M
   WHERE MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddBc4" desc="">
		<![CDATA[
INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   JUGDE_APPLY_CODE,
   JUGDE_APPLY_TIME,
   FACE_RESULT_CODE,
   FACE_RESULT_TIME,
   FACE_MAKER,
   SPEC_RESULT_CODE,
   SPEC_RESULT_TIME,
   SPEC_MAKER,
   CHEM_RESULT_CODE,
   CHEM_RESULT_TIME,
   CHEM_MAKER,
   PHY_RESULT_CODE,
   PHY_RESULT_TIME,
   PHY_MAKER,
   DETECT_RESULT_CODE,
   WPRESSURE_RESULT_CODE,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   PROCESS_STATUS,
   JUGDE_CONVICTED,
   FIXTYPE_CODE,
   QUALITY_GROUP_ZG,
   FLAG_STOVE_NO_ZG,
   DETECT_RESULT_CODE1,
   TESTING_GRADE,
   TESTING_TYPE,
   TESTING_GRADE1,
   TESTING_TYPE1,
   JUDGE_STOVE_NO_UP,
   CRAFT_SEQ,
   PRO_PLAN_ID_NEXT,
   GX_PLAN_NO_NEXT,
   HANGING_FLAG,
   CUT_NUM,
   JUDGE_TOLRESULT_CODE,
   JUDGE_TOLRESULT,
   JUDGE_TOLRESULT_TIME,
   JUDGE_TOLMAKER,
   INSTANCY_FLAG,
   JUGDE_TOLCONVICTED,
   JUDGE_STD_DES,
   MNG_LOCK_REMARK,
   LOCK_REMARK,
   JUGDE_APPLY_SEQUENO,
   HEAT_PLAN_NO_NEXT,
   CODE_JG_BL,
   CIC,
   SCRAP_REASON,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   ZBS_FLAG,
   SCRAP_TYPE,
   ZBS_ID,
   HEAT_PLAN_NO_OLD,
   MEASURING_SEQ,
   SCRAP_FLAG,
   LIKU_PROCESS_CODE,
   JG_ZBS_ID,
   FAIL_APPROVAL_CODE,
   OFFLINE_DOC,
   SUBCONTRACT_NO,
   SCRAP_FRIM_FLAG,
   ZZB_FLAG,
   BAL_YEAR_MONTH_FAIL,
   SUBCONTRACT_NO_SEQ,
   SCRAP_NAME,
   SCRAP_TIME)
  SELECT ?,
         PRODUCT_FLAG,
         MAT_STATUS,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         SAMPLE_FLAG,
         MATERIAL_NO,
         MATERIAL_NAME,
         INPUT_MATERIAL_NAME,
         INPUT_MATERIAL_NO,
         PRODUCCODE,
         PRODUCNAME,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         PRO_ORDER_NO,
         PRO_ORDER_ID,
         ORDER_NO,
         ORDER_SEQ,
         ORDER_SEQ_NO,
         CRAF_NO,
         PROCESS_CDOE,
         PROCESS_DESC,
         NEXT_PROCESS_CDOE,
         NEXT_PROCESS_DESC,
         PLINE_CODE,
         PLINE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ?,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ?,
          ?,
         MEASURE_FLAG,
         BELONG_CODE,
         BELONG_NAME,
         PACK_FLAG,
         MAT_GOWHERE_CODE,
         MAT_GOWHERE_NAME,
         MAT_RETURN_FLAG,
         LOCK_FLAG,
         MNG_LOCK_FLAG,
         JUGDE_APPLY_FLAG,
         JUGDE_APPLY_CODE,
         JUGDE_APPLY_TIME,
         FACE_RESULT_CODE,
         FACE_RESULT_TIME,
         FACE_MAKER,
         SPEC_RESULT_CODE,
         SPEC_RESULT_TIME,
         SPEC_MAKER,
         CHEM_RESULT_CODE,
         CHEM_RESULT_TIME,
         CHEM_MAKER,
         PHY_RESULT_CODE,
         PHY_RESULT_TIME,
         PHY_MAKER,
         DETECT_RESULT_CODE,
         WPRESSURE_RESULT_CODE,
         JUDGE_RESULT_CODE,
         JUDGE_RESULT,
         JUDGE_RESULT_TIME,
         JUDGE_MAKER,
         INSTOCK_FLAG,
         INSTOCK_TIME,
         BAR_CODE,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         BAL_YEAR_MONTH,
         JUDGE_STD_NAME,
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         PONDER_NO,
         PONDER_GROSS_WT,
         JUDGE_ID,
         LOCK_LIKU,
         '00',
         OUTSTOCK_DOC,
         HEAT_PLAN_NO,
         ZG_STOVE_SQE,
         GX_PLAN_NO,
         ZG_MAT_NO,
         TARGET,
         PROCESS_STATUS,
         JUGDE_CONVICTED,
         FIXTYPE_CODE,
         QUALITY_GROUP_ZG,
         FLAG_STOVE_NO_ZG,
         DETECT_RESULT_CODE1,
         TESTING_GRADE,
         TESTING_TYPE,
         TESTING_GRADE1,
         TESTING_TYPE1,
         JUDGE_STOVE_NO_UP,
         CRAFT_SEQ,
         PRO_PLAN_ID_NEXT,
         GX_PLAN_NO_NEXT,
         HANGING_FLAG,
         CUT_NUM,
         JUDGE_TOLRESULT_CODE,
         JUDGE_TOLRESULT,
         JUDGE_TOLRESULT_TIME,
         JUDGE_TOLMAKER,
         INSTANCY_FLAG,
         JUGDE_TOLCONVICTED,
         JUDGE_STD_DES,
         MNG_LOCK_REMARK,
         LOCK_REMARK,
         JUGDE_APPLY_SEQUENO,
         HEAT_PLAN_NO_NEXT,
         CODE_JG_BL,
         CIC,
         SCRAP_REASON,
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         ZBS_FLAG,
         SCRAP_TYPE,
         ZBS_ID,
         HEAT_PLAN_NO_OLD,
         MEASURING_SEQ,
         SCRAP_FLAG,
         LIKU_PROCESS_CODE,
         JG_ZBS_ID,
         FAIL_APPROVAL_CODE,
         OFFLINE_DOC,
         SUBCONTRACT_NO,
         SCRAP_FRIM_FLAG,
         ZZB_FLAG,
         BAL_YEAR_MONTH_FAIL,
         SUBCONTRACT_NO_SEQ,
         SCRAP_NAME,
         SCRAP_TIME
    FROM MAT_BC_M
   WHERE MAT_NO = ?

	]]>
	</query>

	<query id="frmEntrust.AddYdmButress1" desc="">
		<![CDATA[
		INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
  SELECT ?,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC
    FROM YDM_BC_BUTTRESS
   WHERE MAT_NO =?

	]]>
	</query>



	<query id = "frmEntrust.doQueryMMatNo" desc = "查分切前母管号">
		<![CDATA[
       SELECT T.MAT_NO,
             SUM(M.ACT_LEN) ACT_LEN,
             SUM(M.ACT_WEIGHT) ACT_WEIGHT,
             SUM(M.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
        FROM HTT_ENTRUST_MAT_NO T
        LEFT JOIN MAT_BC_M M
          ON T.MAT_NO_CUT = M.MAT_NO
       WHERE RESULT_NO_OFFLINE  = ?
       GROUP BY T.MAT_NO
]]>
	</query>

	<query id = "frmEntrust.doQueryPrice" desc = "查询价格表">
		<![CDATA[
         SELECT * FROM HTT_ENTRUST_PRICE WHERE PROJECT_TYPE = NVL(?,PROJECT_TYPE) AND VALIDFLAG= NVL(?,VALIDFLAG) ORDER BY PROJECT_CODE, SPEC_CODE,STEELCODE,MODEL_CODE
]]>
	</query>

	<query id = "frmEntrust.doQueryApplyMemo" desc = "查询申请备注">
		<![CDATA[
         SELECT * FROM HTT_ENTRUST_APPLYMEMO WHERE PROJECT_CODE = ? ORDER BY SEQ
]]>
	</query>

	<query id = "frmEntrust.QueryOffMatNo" desc = "">
		<![CDATA[
                SELECT *
  FROM (SELECT T.*
          FROM port_MCH_batch_sample_result T
         WHERE T.MAT_STATUS = '20'
           AND T.RESULT_NO IN (SELECT LX_RESULT_NO
                          FROM MCH_GROUP_RESULT
                         WHERE GROUP_ID IN
                               (SELECT GROUP_ID
                                  FROM MCH_OFFLINE_RESULT
                                 WHERE RESULT_NO = ?)
                        UNION
                        SELECT ?
                          FROM DUAL)
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM <= ?
]]>
	</query>
	
	<query id="frmEntrust.QueryOffMatNo3" desc="查询管号队列离线材料号">
		<![CDATA[
SELECT *
          FROM PORT_VRP_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '20'
           AND T.RESULT_NO =?
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>

	<query id = "frmEntrust.QueryBcMatNo" desc = "">
		<![CDATA[
         SELECT * FROM MAT_BC_M WHERE SUBCONTRACT_NO = ? AND SUBCONTRACT_NO_SEQ =?
]]>
	</query>


	<query id = "frmEntrust.QueryZcMatNo2" desc = "">
		<![CDATA[
         SELECT * FROM MAT_ZC_M WHERE SUBCONTRACT_NO = ? AND SUBCONTRACT_NO_SEQ =?
]]>
	</query>

	<query id = "frmEntrust.doQueryDefaultPay" desc = "">
		<![CDATA[
SELECT PAY,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = PAY) PAY_NAME
  FROM (

        SELECT DECODE(FACTORY_CODE,
                       '410501',
                       '702901',
                       '410502',
                       '702902',
                       '410505',
                       '702903',
                       '410506',
                       '702905',
                       '410507',
                       '702904',
                       '410508',  --250
                       '702917',
                       '410509',  -- 258,
                       '702912',
                       '410510',  --460
                       '702913',
                       '410511',  --168
                       '702911',
                       '410512',  --冷轧
                       '702915',
                       '410513',  --720
                       '702914',
                       '410514',
                       '702916',
                       '') PAY
          FROM COM_BASE_PLINE
         WHERE PLINE_CODE = ?)

]]>
	</query>

	<query id = "frmEntrust.doAddPrice" desc = "">
		<![CDATA[
 INSERT INTO HTT_ENTRUST_PRICE(
        PROJECT_CODE,
        PROJECT_NAME,
        SPEC_CODE,
        SPEC_NAME,
        STEELCODE,
        STEELNAME,
        UNIT_PRICE,
        UNIT_PROCE_TAX,
        PROJECT_TYPE,
        UNIT,
        REMARK,
        CREATE_NAME,
        CREATE_TIME,
        MODEL_CODE,
        MODEL_DESC)
 VALUES(
        '#PROJECT_CODE#',
        '#PROJECT_NAME#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#UNIT_PRICE#',
        '#UNIT_PROCE_TAX#',
        '#PROJECT_TYPE#',
        '#UNIT#',
        '#REMARK#',
        '#CREATE_NAME#',
        SYSDATE,
        '#MODEL_CODE#',
        '#MODEL_DESC#')
]]>
	</query>

	<query id = "frmEntrust.doUpdatePrice" desc = "">
		<![CDATA[
 UPDATE HTT_ENTRUST_PRICE T
   SET
        T.PROJECT_CODE = '#PROJECT_CODE#',
        T.PROJECT_NAME = '#PROJECT_NAME#',
        T.SPEC_CODE = '#SPEC_CODE#',
        T.SPEC_NAME = '#SPEC_NAME#',
        T.STEELCODE = '#STEELCODE#',
        T.STEELNAME = '#STEELNAME#',
        T.UNIT_PRICE = '#UNIT_PRICE#',
        T.UNIT_PROCE_TAX = '#UNIT_PROCE_TAX#',
        T.PROJECT_TYPE = '#PROJECT_TYPE#',
        T.UNIT = '#UNIT#',
        T.REMARK = '#REMARK#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.MODEL_CODE = '#MODEL_CODE#',
        T.MODEL_DESC = '#MODEL_DESC#',
        T.ID = '#ID#'
 WHERE
T.ID = '#ID#'
]]>
	</query>

	<query id = "frmEntrust.doDeletePrice" desc = "">
		<![CDATA[
 UPDATE HTT_ENTRUST_PRICE T
   SET  VALIDFLAG =?,
   DELETE_NAME =?,
   DELETE_TIME = sysdate
 WHERE
T.ID =?
]]>
	</query>


	<query id = "frmEntrust.deleteApplyMemo" desc = "">
		<![CDATA[
     DELETE FROM HTT_ENTRUST_APPLYMEMO WHERE PROJECT_CODE = ?
]]>
	</query>

	<query id = "frmEntrust.addApplyMemo" desc = "">
		<![CDATA[
     INSERT INTO HTT_ENTRUST_APPLYMEMO
  (PROJECT_CODE, PROJECT_NAME, PROJECT_MEMO, SEQ)
VALUES
  (?, ?, ?, ?)
]]>
	</query>

	<query id = "frmEntrust.QueryExists" desc = "">
		<![CDATA[
   SELECT COUNT(1) COUNT FROM HTT_ENTRUST_PRICE WHERE PROJECT_CODE=? AND  STEELCODE =? AND SPEC_CODE=?  AND MODEL_CODE=? AND ID <> ? AND VALIDFLAG = '1'
]]>
	</query>




	<query id = "frmEntrust.UpdateFailMatPortE" desc = "">
		<![CDATA[
		UPDATE PORT_VRP_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS = ?
 WHERE MAT_NO IN
       (SELECT  W1.MAT_NO
          FROM MCH_WASTE_MAT_NO   W1,
               MCH_BUG_D          W2,
               HTT_ENTRUST        E,
               HTT_ENTRUST_RESULT R
         WHERE E.SUBCONTRACT_NO = ?
           AND E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND R.RESULT_NO = W2.RESULT_NO
           AND W2.FAIL_BILL = W1.FAIL_BILL
           AND W2.FAIL_BILL_SQE = W2.FAIL_BILL_SQE
           AND W2.FAIL_SORT = '10')
  AND MAT_STATUS  IN ('20','40')
  ]]>
	</query>

	<query id = "frmEntrust.UpdateFailMatPortF" desc = "">
		<![CDATA[

UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS = ?
 WHERE MAT_NO IN
       (SELECT W1.MAT_NO
          FROM MCH_WASTE_MAT_NO   W1,
               MCH_BUG_D          W2,
               HTT_ENTRUST        E,
               HTT_ENTRUST_RESULT R
         WHERE E.SUBCONTRACT_NO = ?
           AND E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND R.RESULT_NO = W2.RESULT_NO
           AND W2.FAIL_BILL = W1.FAIL_BILL
           AND W2.FAIL_BILL_SQE = W2.FAIL_BILL_SQE
           AND W2.FAIL_SORT = '10')
     AND MAT_STATUS  IN ('20','40')

  ]]>
	</query>


	<query id = "frmEntrust.UpdateFailMatPortG" desc = "">
		<![CDATA[
	UPDATE PORT_MCH_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS = ?
 WHERE MAT_NO IN
       (SELECT  W1.MAT_NO
          FROM MCH_WASTE_MAT_NO   W1,
               MCH_BUG_D          W2,
               HTT_ENTRUST        E,
               HTT_ENTRUST_RESULT R
         WHERE E.SUBCONTRACT_NO = ?
           AND E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND R.RESULT_NO = W2.RESULT_NO
           AND W2.FAIL_BILL = W1.FAIL_BILL
           AND W2.FAIL_BILL_SQE = W2.FAIL_BILL_SQE
           AND W2.FAIL_SORT = '10')
    AND MAT_STATUS  IN ('20','40')
  ]]>
	</query>


	<query id = "frmEntrust.UpdateFailMat" desc = "">
		<![CDATA[

UPDATE MAT_BC_M T
   SET QCM_STAUS    = ?,
       SCRAP_REASON = DECODE(?,'22',
       (SELECT W2.FAIL_TYPE_NAME
          FROM MCH_WASTE_MAT_NO W1, MCH_BUG_D W2
         WHERE W2.FAIL_BILL = W1.FAIL_BILL
           AND W2.FAIL_BILL_SQE = W1.FAIL_BILL_SQE
           AND W1.MAT_NO = T.MAT_NO
            AND W2.FAIL_SORT = '10'),'')
 WHERE  MAT_NO IN
       (SELECT  W1.MAT_NO
          FROM MCH_WASTE_MAT_NO   W1,
               MCH_BUG_D          W2,
               HTT_ENTRUST        E,
               HTT_ENTRUST_RESULT R
         WHERE E.SUBCONTRACT_NO =?
           AND E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND R.RESULT_NO = W2.RESULT_NO
           AND W2.FAIL_BILL = W1.FAIL_BILL
           AND W2.FAIL_BILL_SQE = W2.FAIL_BILL_SQE
           AND W2.FAIL_SORT = '10')

  ]]>
	</query>


	<query id = "frmEntrust.UpdateZcFailMat" desc = "">
		<![CDATA[

DECLARE
BEGIN

  FOR EROW1 IN (SELECT W1.MAT_NO
                  FROM MCH_WASTE_MAT_NO   W1,
                       MCH_BUG_D          W2,
                       HTT_ENTRUST        E,
                       HTT_ENTRUST_RESULT R
                 WHERE E.SUBCONTRACT_NO = ?
                   AND E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
                   AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
                   AND R.RESULT_NO = W2.RESULT_NO
                   AND W2.FAIL_BILL = W1.FAIL_BILL
                   AND W2.FAIL_BILL_SQE = W2.FAIL_BILL_SQE
                   AND W2.FAIL_SORT = '10') LOOP

    DELETE FROM MAT_ZC_BACKUP WHERE MAT_NO = EROW1.MAT_NO;

    DELETE FROM YDM_ZC_BUTTRESS_BAK WHERE MAT_NO = EROW1.MAT_NO;

    INSERT INTO MAT_ZC_BACKUP
      SELECT * FROM MAT_ZC_M WHERE MAT_NO = EROW1.MAT_NO;

    INSERT INTO YDM_ZC_BUTTRESS_BAK
      SELECT * FROM YDM_ZC_BUTTRESS WHERE MAT_NO = EROW1.MAT_NO;

    DELETE FROM MAT_ZC_M T WHERE T.MAT_NO = EROW1.MAT_NO;
    DELETE FROM YDM_ZC_BUTTRESS T WHERE T.MAT_NO = EROW1.MAT_NO;

  END LOOP;
END;

  ]]>
	</query>

	<query id = "frmEntrust.UpdateZcFailMat2" desc = "">
		<![CDATA[

DECLARE
BEGIN

  FOR EROW1 IN (SELECT W1.MAT_NO
                  FROM MCH_WASTE_MAT_NO   W1,
                       MCH_BUG_D          W2,
                       HTT_ENTRUST        E,
                       HTT_ENTRUST_RESULT R
                 WHERE E.SUBCONTRACT_NO = ?
                   AND E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
                   AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
                   AND R.RESULT_NO = W2.RESULT_NO
                   AND W2.FAIL_BILL = W1.FAIL_BILL
                   AND W2.FAIL_BILL_SQE = W2.FAIL_BILL_SQE
                   AND W2.FAIL_SORT = '10') LOOP

    INSERT INTO MAT_ZC_M
      SELECT * FROM MAT_ZC_BACKUP WHERE MAT_NO = EROW1.MAT_NO;
      
    INSERT INTO MAT_ZC_M_XS
      SELECT * FROM MAT_ZC_BACKUP WHERE MAT_NO = EROW1.MAT_NO;

    INSERT INTO YDM_ZC_BUTTRESS
      SELECT * FROM YDM_ZC_BUTTRESS_BAK WHERE MAT_NO = EROW1.MAT_NO;
      
    INSERT INTO YDM_ZC_BUTTRESS_XS
      SELECT * FROM YDM_ZC_BUTTRESS_BAK WHERE MAT_NO = EROW1.MAT_NO;

    DELETE FROM MAT_ZC_BACKUP WHERE MAT_NO = EROW1.MAT_NO;

    DELETE FROM YDM_ZC_BUTTRESS_BAK WHERE MAT_NO = EROW1.MAT_NO;

  END LOOP;
END;


  ]]>
	</query>


	<query id = "frmEntrust.GetMaxReportNo" desc = "">
		<![CDATA[

SELECT T.REPORT_NO, LPAD(TO_CHAR(MAX(TO_NUMBER(P.REPORT_NUMBER)) + 1), 3, '0') REPORT_NUMBER
  FROM HTT_CRACK_DETECTION_PARA P, HTT_CRACK_DETECTION_ET T
 WHERE P.RESULT_NO = T.RESULT_NO
   AND REGEXP_LIKE(P.REPORT_NUMBER, '^[[:digit:]]+$')
   AND T.PLINE_CODE IN ('C084','C085')
   AND TO_CHAR(T.COL_TIME,'YYYY') = TO_CHAR(SYSDATE,'YYYY')
  GROUP BY T.PLINE_CODE, T.REPORT_NO
  ]]>
	</query>


	<query id = "frmEntrust.doQuerBal" desc = "">
		<![CDATA[
SELECT T.CHK,
       T.SUBCONTRACT_TIME,
       T.SP_TIME,
       T.PROJECT_STATUS,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       T.PLINE_NAME,
       T.SUBCONTRACT_PLINE_NAME,
       T.BASENAME,
       T.PROJECT_TYPE,
       T.PAY_DEPARTMENT_CODE,
       T.SUBCONTRACT_OPERATOR,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.SUBCONTRACT_NUM,
       T.SUBCONTRACT_WT,
       T.PROJECT_CODE,
       T.PROJECT_NAME,
       T.PRO_NUM,
       T.PRO_WT,
       T.INCISION_NUM,
       T.BUNDLING_NUM,
       NVL(T.BAL_PRICE, Q.UNIT_PRICE) BAL_PRICE,
       Q.UNIT,
       NVL(T.BAL_PRICE_TOTAL,
           DECODE(Q.UNIT,
                  '0',
                  T.PRO_NUM,
                  '1',
                  T.PRO_WT,
                  '2',
                  T.INCISION_NUM,
                  '3',
                  T.BUNDLING_NUM,
                  0) * NVL(T.BAL_PRICE, Q.UNIT_PRICE)) BAL_PRICE_TOTAL,
       T.ORDER_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ORDER_BLONG
  FROM (SELECT DECODE(P.PROJECT_STATUS, '00', 'TRUE', 'FALSE') CHK,
               TO_CHAR(M.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
               TO_CHAR(M.SP_TIME, 'YYYY-MM-DD HH24:MI:SS') SP_TIME,
               P.PROJECT_STATUS,
               M.SUBCONTRACT_NO,
               M.SUBCONTRACT_NO_SEQ,
               M.PLINE_NAME,
               M.SUBCONTRACT_PLINE_NAME,
               C1.BASENAME,
               P.PROJECT_TYPE,
               P.PAY_DEPARTMENT_CODE,
               DECODE(M.PROCESS_CODE,'H',M.SUBCONTRACT_OPERATOR,'') SUBCONTRACT_OPERATOR,
               M.JUDGE_STOVE_NO,
               M.BATCH_NO,
               M.SUBCONTRACT_NUM,
               M.SUBCONTRACT_WT,
               P.PROJECT_CODE,
               P.PROJECT_NAME,
               R.PRO_NUM,
               R.PRO_WT,
               R.INCISION_NUM,
               R.BUNDLING_NUM,
               P.BAL_PRICE,
               P.BAL_PRICE_TOTAL,
               M.ORDER_NO,
               M.PRODUCCODE,
               M.PRODUCNAME,
               M.GRADECODE,
               M.GRADENAME,
               M.STEELCODE,
               M.STEELNAME,
               M.SPEC_CODE,
               M.SPEC_NAME,
               M.MODEL_CODE,
               M.MODEL_DESC,
               CASE
                 WHEN M.ORDER_NO LIKE 'EX%' THEN
                  '国贸'
                 ELSE
                  '国内'
               END ORDER_BLONG
          FROM HTT_ENTRUST M
          LEFT JOIN COM_BASE_PLINE B1
            ON M.PLINE_CODE = B1.PLINE_CODE
          LEFT JOIN COM_BASE_INFO C1
            ON B1.FACTORY_CODE = C1.BASECODE, HTT_ENTRUST_PROJECT P
          LEFT JOIN (SELECT SUBCONTRACT_NO,
                           SUBCONTRACT_NO_SEQ,
                           PROJECT_CODE,
                           TESTING_TYPE,
                           SUM(PRO_NUM) PRO_NUM,
                           SUM(PRO_WT) PRO_WT,
                           SUM(INCISION_NUM) INCISION_NUM,
                           SUM(BUNDLING_NUM) BUNDLING_NUM
                      FROM (SELECT RESULT_NO,
                                   SUBCONTRACT_NO,
                                   SUBCONTRACT_NO_SEQ,
                                   TESTING_TYPE,
                                   PRO_NUM,
                                   PRO_WT,
                                   INCISION_NUM,
                                   BUNDLING_NUM,
                                   SUBSTR(A.PROJECT_CODE,
                                          INSTR(A.PROJECT_CODE,
                                                ',',
                                                1,
                                                LEVELS.LVL) + 1,
                                          INSTR(A.PROJECT_CODE,
                                                ',',
                                                1,
                                                LEVELS.LVL + 1) -
                                          (INSTR(A.PROJECT_CODE,
                                                 ',',
                                                 1,
                                                 LEVELS.LVL) + 1)) AS PROJECT_CODE
                              FROM (SELECT RESULT_NO,
                                           SUBCONTRACT_NO,
                                           SUBCONTRACT_NO_SEQ,
                                           TESTING_TYPE,
                                           PRO_NUM,
                                           PRO_WT,
                                           INCISION_NUM,
                                           BUNDLING_NUM,
                                           ',' || PROJECT_CODE || ',' AS PROJECT_CODE,
                                           LENGTH(PROJECT_CODE) -
                                           NVL(LENGTH(REPLACE(PROJECT_CODE,
                                                              ',')),
                                               0) + 1 AS CNT
                                      FROM HTT_ENTRUST_RESULT) A,
                                   (SELECT ROWNUM AS LVL
                                      FROM (SELECT MAX(LENGTH(PROJECT_CODE || ',') -
                                                       NVL(LENGTH(REPLACE(PROJECT_CODE,
                                                                          ',')),
                                                           0)) MAX_LEN
                                              FROM HTT_ENTRUST_RESULT)
                                    CONNECT BY LEVEL <= MAX_LEN) LEVELS
                             WHERE LEVELS.LVL <= A.CNT)
                     GROUP BY SUBCONTRACT_NO,
                              SUBCONTRACT_NO_SEQ,
                              PROJECT_CODE,
                              TESTING_TYPE) R
            ON P.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND P.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND DECODE(R.PROJECT_CODE,
                      '702202',
                      R.PROJECT_CODE || TESTING_TYPE,
                      R.PROJECT_CODE) =
               DECODE(P.PROJECT_CODE,
                      '70220201',
                      '702202UT',
                      '70220202',
                      '702202UT',
                      '70220208',
                      '702202UT',
                      '70220203',
                      '702202MT',
                      '70220204',
                      '702202MT',
                      '70220205',
                      '702202MT',
                      P.PROJECT_CODE)
         WHERE M.SUBCONTRACT_NO = P.SUBCONTRACT_NO
           AND M.SUBCONTRACT_NO_SEQ = P.SUBCONTRACT_NO_SEQ
           AND P.PROJECT_FLAG <> '2'
           AND M.SUBCONTRACT_TARGET = '0'
           AND M.SUBCONTRACT_LOG = '60'
              #PLINECODE#
           AND P.BAL_YEAR_MONTH = ?  ) T
  LEFT JOIN HTT_ENTRUST_PRICE Q
    ON Q.PROJECT_CODE = T.PROJECT_CODE
   AND T.SPEC_CODE = DECODE(Q.SPEC_CODE, '/', T.SPEC_CODE, Q.SPEC_CODE)
   AND T.STEELCODE = DECODE(Q.STEELCODE, '/', T.STEELCODE, Q.STEELCODE)
   AND T.MODEL_CODE = DECODE(Q.MODEL_CODE, '/', T.MODEL_CODE, Q.MODEL_CODE)
   AND Q.VALIDFLAG = '1'
 ORDER BY PROJECT_STATUS DESC, SUBCONTRACT_TIME,
          PLINE_NAME,
          SUBCONTRACT_PLINE_NAME,
          SUBCONTRACT_NO,
          SUBCONTRACT_NO_SEQ,
          JUDGE_STOVE_NO,
          BATCH_NO
  ]]>
	</query>

	<query id = "frmEntrust.doQuerUnBal" desc = "">
		<![CDATA[
SELECT T.CHK,
       T.SUBCONTRACT_TIME,
       T.SP_TIME,
       T.PROJECT_STATUS,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       T.PLINE_NAME,
       T.SUBCONTRACT_PLINE_NAME,
       T.BASENAME,
       T.PROJECT_TYPE,
       T.PAY_DEPARTMENT_CODE,
       T.SUBCONTRACT_OPERATOR,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.SUBCONTRACT_NUM,
       T.SUBCONTRACT_WT,
       T.PROJECT_CODE,
       T.PROJECT_NAME,
       T.PRO_NUM,
       T.PRO_WT,
       T.INCISION_NUM,
       T.BUNDLING_NUM,
       NVL(T.BAL_PRICE, Q.UNIT_PRICE) BAL_PRICE,
       Q.UNIT,
       ROUND(NVL(T.BAL_PRICE_TOTAL,
           DECODE(Q.UNIT,
                  '0',
                  T.PRO_NUM,
                  '1',
                  T.PRO_WT,
                  '2',
                  T.INCISION_NUM,
                  '3',
                  T.BUNDLING_NUM,
                  0) * NVL(T.BAL_PRICE, Q.UNIT_PRICE)),2) BAL_PRICE_TOTAL,
       T.ORDER_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ORDER_BLONG
  FROM (SELECT DECODE(P.PROJECT_STATUS, '00', 'TRUE', 'FALSE') CHK,
               TO_CHAR(M.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
               TO_CHAR(M.SP_TIME, 'YYYY-MM-DD HH24:MI:SS') SP_TIME,
               P.PROJECT_STATUS,
               M.SUBCONTRACT_NO,
               M.SUBCONTRACT_NO_SEQ,
               M.PLINE_NAME,
               M.SUBCONTRACT_PLINE_NAME,
               C1.BASENAME,
               P.PROJECT_TYPE,
               P.PAY_DEPARTMENT_CODE,
               DECODE(M.PROCESS_CODE,'H',M.SUBCONTRACT_OPERATOR,'') SUBCONTRACT_OPERATOR,
               M.JUDGE_STOVE_NO,
               M.BATCH_NO,
               M.SUBCONTRACT_NUM,
               M.SUBCONTRACT_WT,
               P.PROJECT_CODE,
               P.PROJECT_NAME,
               R.PRO_NUM,
               R.PRO_WT,
               R.INCISION_NUM,
               R.BUNDLING_NUM,
               P.BAL_PRICE,
               P.BAL_PRICE_TOTAL,
               M.ORDER_NO,
               M.PRODUCCODE,
               M.PRODUCNAME,
               M.GRADECODE,
               M.GRADENAME,
               M.STEELCODE,
               M.STEELNAME,
               M.SPEC_CODE,
               M.SPEC_NAME,
               M.MODEL_CODE,
               M.MODEL_DESC,
               CASE
                 WHEN M.ORDER_NO LIKE 'EX%' THEN
                  '国贸'
                 ELSE
                  '国内'
               END ORDER_BLONG
          FROM HTT_ENTRUST M
          LEFT JOIN COM_BASE_PLINE B1
            ON M.PLINE_CODE = B1.PLINE_CODE
          LEFT JOIN COM_BASE_INFO C1
            ON B1.FACTORY_CODE = C1.BASECODE, HTT_ENTRUST_PROJECT P
          LEFT JOIN (SELECT SUBCONTRACT_NO,
                           SUBCONTRACT_NO_SEQ,
                           PROJECT_CODE,
                           TESTING_TYPE,
                           SUM(PRO_NUM) PRO_NUM,
                           SUM(PRO_WT) PRO_WT,
                           SUM(INCISION_NUM) INCISION_NUM,
                           SUM(BUNDLING_NUM) BUNDLING_NUM
                      FROM (SELECT RESULT_NO,
                                   SUBCONTRACT_NO,
                                   SUBCONTRACT_NO_SEQ,
                                   TESTING_TYPE,
                                   PRO_NUM,
                                   PRO_WT,
                                   INCISION_NUM,
                                   BUNDLING_NUM,
                                   SUBSTR(A.PROJECT_CODE,
                                          INSTR(A.PROJECT_CODE,
                                                ',',
                                                1,
                                                LEVELS.LVL) + 1,
                                          INSTR(A.PROJECT_CODE,
                                                ',',
                                                1,
                                                LEVELS.LVL + 1) -
                                          (INSTR(A.PROJECT_CODE,
                                                 ',',
                                                 1,
                                                 LEVELS.LVL) + 1)) AS PROJECT_CODE
                              FROM (SELECT RESULT_NO,
                                           SUBCONTRACT_NO,
                                           SUBCONTRACT_NO_SEQ,
                                           TESTING_TYPE,
                                           PRO_NUM,
                                           PRO_WT,
                                           INCISION_NUM,
                                           BUNDLING_NUM,
                                           ',' || PROJECT_CODE || ',' AS PROJECT_CODE,
                                           LENGTH(PROJECT_CODE) -
                                           NVL(LENGTH(REPLACE(PROJECT_CODE,
                                                              ',')),
                                               0) + 1 AS CNT
                                      FROM HTT_ENTRUST_RESULT) A,
                                   (SELECT ROWNUM AS LVL
                                      FROM (SELECT MAX(LENGTH(PROJECT_CODE || ',') -
                                                       NVL(LENGTH(REPLACE(PROJECT_CODE,
                                                                          ',')),
                                                           0)) MAX_LEN
                                              FROM HTT_ENTRUST_RESULT)
                                    CONNECT BY LEVEL <= MAX_LEN) LEVELS
                             WHERE LEVELS.LVL <= A.CNT)
                     GROUP BY SUBCONTRACT_NO,
                              SUBCONTRACT_NO_SEQ,
                              PROJECT_CODE,
                              TESTING_TYPE) R
            ON P.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND P.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND DECODE(R.PROJECT_CODE,
                      '702202',
                      R.PROJECT_CODE || TESTING_TYPE,
                      R.PROJECT_CODE) =
               DECODE(P.PROJECT_CODE,
                      '70220201',
                      '702202UT',
                      '70220202',
                      '702202UT',
                      '70220208',
                      '702202UT',
                      '70220203',
                      '702202MT',
                      '70220204',
                      '702202MT',
                      '70220205',
                      '702202MT',
                      P.PROJECT_CODE)
         WHERE M.SUBCONTRACT_NO = P.SUBCONTRACT_NO
           AND M.SUBCONTRACT_NO_SEQ = P.SUBCONTRACT_NO_SEQ
           AND P.PROJECT_FLAG <> '2'
           AND M.SUBCONTRACT_TARGET = '0'
           AND M.SUBCONTRACT_LOG = '60'
              #PLINECODE#
           AND P.BAL_YEAR_MONTH IS NULL ) T
  LEFT JOIN HTT_ENTRUST_PRICE Q
    ON Q.PROJECT_CODE = T.PROJECT_CODE
   AND T.SPEC_CODE = DECODE(Q.SPEC_CODE, '/', T.SPEC_CODE, Q.SPEC_CODE)
   AND T.STEELCODE = DECODE(Q.STEELCODE, '/', T.STEELCODE, Q.STEELCODE)
   AND T.MODEL_CODE = DECODE(Q.MODEL_CODE, '/', T.MODEL_CODE, Q.MODEL_CODE)
   AND Q.VALIDFLAG = '1'
 ORDER BY PROJECT_STATUS DESC, SUBCONTRACT_TIME,
          PLINE_NAME,
          SUBCONTRACT_PLINE_NAME,
          SUBCONTRACT_NO,
          SUBCONTRACT_NO_SEQ,
          JUDGE_STOVE_NO,
          BATCH_NO
  ]]>
	</query>


	<query id = "frmEntrust.doUpdateSettle" desc = "">
		<![CDATA[
UPDATE HTT_ENTRUST_PROJECT
   SET PROJECT_TYPE        = ?,
       PAY_DEPARTMENT_CODE = ?,
       PAY_DEPARTMENT_NAME =
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ?),
       BAL_PRICE           = ?,
       BAL_PRICE_TOTAL     = ?
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
   AND PROJECT_CODE = ?

  ]]>
	</query>


	<query id = "frmEntrust.doUpdateSettle2" desc = "">
		<![CDATA[
UPDATE HTT_ENTRUST_PROJECT
   SET PROJECT_TYPE        = ?,
       PAY_DEPARTMENT_CODE = ?,
       PAY_DEPARTMENT_NAME =
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ?),
       BAL_PRICE           = ?,
       BAL_PRICE_TOTAL     = ?,
       PROJECT_STATUS = '10',
       BAL_YEAR_MONTH = TO_CHAR(SYSDATE,'YYYYMM'),
       BAL_NUM=?,
       BAL_WT= ?,
       BAL_INCISION_NUM =?,
       BAL_BUNDLING_NUM =?
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
   AND PROJECT_CODE = ?

  ]]>
	</query>



	<query id = "frmEntrust.doUpdateSettle3" desc = "">
		<![CDATA[
UPDATE HTT_ENTRUST_PROJECT
   SET PROJECT_TYPE        = ?,
       PAY_DEPARTMENT_CODE = ?,
       PAY_DEPARTMENT_NAME =
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ?),
       BAL_PRICE           = ?,
       BAL_PRICE_TOTAL     = ?,
       PROJECT_STATUS = '00',
       BAL_YEAR_MONTH = NULL
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
   AND PROJECT_CODE = ?

  ]]>
	</query>

	<query id = "frmEntrust.GetProject" desc = "">
		<![CDATA[
SELECT *
  FROM HTT_ENTRUST_PROJECT
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
   AND PROJECT_CODE = ?

  ]]>
	</query>

	<query id = "frmEntrust.CheckRelay" desc = "">
		<![CDATA[
SELECT P.* FROM  HTT_ENTRUST_PROJECT P
          LEFT JOIN (SELECT SUBCONTRACT_NO,
                           SUBCONTRACT_NO_SEQ,
                           PROJECT_CODE,
                           TESTING_TYPE,
                           SUM(PRO_NUM) PRO_NUM,
                           SUM(PRO_WT) PRO_WT,
                           SUM(INCISION_NUM) INCISION_NUM,
                           SUM(BUNDLING_NUM) BUNDLING_NUM
                      FROM (SELECT RESULT_NO,
                                   SUBCONTRACT_NO,
                                   SUBCONTRACT_NO_SEQ,
                                   TESTING_TYPE,
                                   PRO_NUM,
                                   PRO_WT,
                                   INCISION_NUM,
                                   BUNDLING_NUM,
                                   SUBSTR(A.PROJECT_CODE,
                                          INSTR(A.PROJECT_CODE,
                                                ',',
                                                1,
                                                LEVELS.LVL) + 1,
                                          INSTR(A.PROJECT_CODE,
                                                ',',
                                                1,
                                                LEVELS.LVL + 1) -
                                          (INSTR(A.PROJECT_CODE,
                                                 ',',
                                                 1,
                                                 LEVELS.LVL) + 1)) AS PROJECT_CODE
                              FROM (SELECT RESULT_NO,
                                           SUBCONTRACT_NO,
                                           SUBCONTRACT_NO_SEQ,
                                           TESTING_TYPE,
                                           PRO_NUM,
                                           PRO_WT,
                                           INCISION_NUM,
                                           BUNDLING_NUM,
                                           ',' || PROJECT_CODE || ',' AS PROJECT_CODE,
                                           LENGTH(PROJECT_CODE) -
                                           NVL(LENGTH(REPLACE(PROJECT_CODE,
                                                              ',')),
                                               0) + 1 AS CNT
                                      FROM HTT_ENTRUST_RESULT) A,
                                   (SELECT ROWNUM AS LVL
                                      FROM (SELECT MAX(LENGTH(PROJECT_CODE || ',') -
                                                       NVL(LENGTH(REPLACE(PROJECT_CODE,
                                                                          ',')),
                                                           0)) MAX_LEN
                                              FROM HTT_ENTRUST_RESULT)
                                    CONNECT BY LEVEL <= MAX_LEN) LEVELS
                             WHERE LEVELS.LVL <= A.CNT)
                     GROUP BY SUBCONTRACT_NO,
                              SUBCONTRACT_NO_SEQ,
                              PROJECT_CODE,
                              TESTING_TYPE) R
            ON P.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND P.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND DECODE(R.PROJECT_CODE,
                      '702202',
                      R.PROJECT_CODE || TESTING_TYPE,
                      R.PROJECT_CODE) =
               DECODE(P.PROJECT_CODE,
                      '70220201',
                      '702202UT',
                      '70220202',
                      '702202UT',
                      '70220208',
                      '702202UT',
                      '70220203',
                      '702202MT',
                      '70220204',
                      '702202MT',
                      '70220205',
                      '702202MT',
                      P.PROJECT_CODE)
         WHERE  P.SUBCONTRACT_NO =?
           AND P.SUBCONTRACT_NO_SEQ = ?
           AND P.PROJECT_FLAG <> '2'
           AND R.PRO_NUM IS NULL  OR PRO_NUM = 0
  ]]>
	</query>




	<query id="frmEntrust.QueryEntrustBcMatNoBySubNo" desc="获取委托的材料信息">
		<![CDATA[
SELECT     WMSYS.WM_CONCAT(T.MAT_NO) MAT_NOS FROM  MAT_BC_M T
 WHERE T.SUBCONTRACT_NO = ?
		]]>
	</query>



	<query id="frmEntrust.QueryEntrustZcMatNoBySubNo" desc="产线">
		<![CDATA[
SELECT     WMSYS.WM_CONCAT(T.MAT_NO) MAT_NOS FROM  MAT_ZC_M T  WHERE T.SUBCONTRACT_NO = ?

		]]>
	</query>



	<query id="frmEntrust.InsertBcOutList" desc="写出库记录">
		<![CDATA[
INSERT INTO YDM_BC_OUTLIST
  (OUTSTOCK_SQE,
   OUTSTOCK_PLAN_NO,
   OUTSTOCK_DOC,
   OUTSTOCK_TYPE_CODE,
   OUTSTOCK_TYPE_NAME,
   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,
   BAR_CODE,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   TAR_STORAGE_NO,
   TAR_LOCATION_NO,
   TAR_LARY_NO,
   TAR_LOC_NO,
   TAR_STORAGE_ATTR,
   TAR_STORAGE_ATTR_NAME,
   TAR_STORAGE_TYPE_NO,
   TAR_STORAGE_TYPE_NAME,
   TAR_MANAGEMENT_NO,
   TAR_MANAGEMENT_NAME,
   TAR_REC_FLAG,
   RPO_TIME,
   PRO_BC,
   PRO_BZ,
   INSTOCK_TIME,
   IN_BC,
   IN_BZ,
   OUTSTOCK_TIME,
   OUT_BC,
   OUT_BZ,
   MEMO,
   HAND_FLAG,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   TAR_DEPARTMENT_CODE,
   TAR_DEPARTMENT_DESC,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   PONDER_NO,
   PONDER_GROSS_WT,
   VSTEL,
   VSTEL_DESC,
   BAL_YEAR_MONTH,
   M_BILL_NO,
   SEND_NUM,
   RECEIV_NO,
   RECEIV_NM,
   FINISHPRO_MOLD,
   IN_MOLD,
   LOAD_PLINE_CODE,
   LOAD_PLINE_NAME,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   DATA_SUORCE,
   QCM_STAUS,
   LEAVE_FACTORY_NAME,
   LEAVE_FACTORY_TIME,
   LEAVE_FACTORY_FLAG,
   SCRAP_REASON,
   DRIVER,
   LEAVE_MANAGEMENT_NO,
   LEAVE_MANAGEMENT_NAME,
   CUT_FLAG,
   OUT_TYPE,
   FLAG_STOVE_NO_ZG)
  SELECT ( ? ||  LPAD ( ROWNUM || '' ,4,0)),
         M.SUBCONTRACT_NO,
         ?,
         '800808',
         '改判出库',
         '',
         '',
         m.MAT_NO,
         M.LOT_NO,
         M.STOVE_NO,
         M.JUDGE_STOVE_NO,
         M.BATCH_NO,
         M.BATCH_GROUD_NO,
         M.MATERIAL_NO,
         M.MATERIAL_NAME,
         M.PRODUCCODE,
         M.PRODUCNAME,
         M.STD_CODE,
         M.STD_NAME,
         M.GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         STD_STYLE,
         STD_STYLE_DESC,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         PRO_ORDER_NO,
         M.PLINE_CODE,
         M.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,
         BAR_CODE,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         INSTOCK_TIME,
         '',
         '',
         SYSDATE,
         '',
         '',
         M.MEMO,
         '0',
         '1',
         ?,
         M.CREATE_TIME,
         M.UPDATE_NAME,
         M.UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         '',
         '',
         ORDER_NO,
         ORDER_SEQ,
         '',
         PRODUCT_FLAG,
         MAT_STATUS,
         '',
         '',
         PONDER_NO,
         PONDER_GROSS_WT,
         '',
         '',
         TO_CHAR(SYSDATE,'YYYYMM'),
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         BELONG_CODE_RESPONSE,
         BELONG_NAME_RESPONSE,
         '0',
         QCM_STAUS,
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         FLAG_STOVE_NO_ZG
    FROM MAT_BC_M M, YDM_BC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
   AND M.SUBCONTRACT_NO =?
		]]>
	</query>

	<query id="frmEntrust.DeleteBcOutList" desc="删除出库记录">
		<![CDATA[
DELETE FROM YDM_BC_OUTLIST WHERE OUTSTOCK_PLAN_NO =?
		]]>
	</query>

	<query id="frmEntrust.SelectBcOutListBalyear" desc="删除出库记录">
		<![CDATA[
SELECT MIN(BAL_YEAR_MONTH) BAL_YEAR_MONTH FROM  YDM_BC_OUTLIST WHERE OUTSTOCK_PLAN_NO =?
		]]>
	</query>

	<query id="frmEntrust.SelectZcOutListBalyear" desc="删除出库记录">
		<![CDATA[
SELECT MIN(BAL_YEAR_MONTH) BAL_YEAR_MONTH FROM  YDM_ZC_OUTLIST WHERE OUTSTOCK_PLAN_NO =?
		]]>
	</query>

	<query id="frmEntrust.InsertBcInList" desc="写入库记录">
		<![CDATA[
INSERT INTO YDM_BC_INLIST
  (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,
   RPO_TIME,
   PRO_BC,
   PRO_BZ,
   INSTOCK_TIME,
   IN_BC,
   IN_BZ,
   BAR_CODE,
   HAND_FLAG,
   MEMO,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   ZB_RCDID,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   IN_TIME_F,
   BAL_YEAR_MONTH,
   LEN_NO,
   LEN_DESC,
   LEN_UNIT,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   AFFIRM_LOG,
   M_BILL_NO,
   ZG_STOVE_SQE,
   IN_MOLD,
   PACK_NO,
   QCM_STAUS,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   SUBCONTRACT_NO,
   DATA_SUORCE,
   OUTSTOCK_DOC,
   CUT_FLAG,
   OUT_TYPE,
   OUTSTOCK_TIME,
   FLAG_STOVE_NO_ZG,
   PONDER_GROSS_WT)
  SELECT ( ? ||  LPAD ( ROWNUM || '' ,4,0)),
         ?,
         '800706',
         '改判入库',
         '',
         '',
         '',
         M.MAT_NO,
         LOT_NO,
         STOVE_NO,
         M.JUDGE_STOVE_NO,
         M.BATCH_NO,
         M.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,
         M.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,
         '',
         '',
         '',
         SYSDATE,
         '',
         '',
         BAR_CODE,
         '0',
         '',
         '1',
         ?,
         SYSDATE,
         '',
         '',
         DELETE_NAME,
         DELETE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         ORDER_NO,
         ORDER_SEQ,
         '',
         PRODUCT_FLAG,
         MAT_STATUS,
         '',
         JUDGE_STD_NAME,
         '',
         '',
         TO_CHAR(SYSDATE,'YYYYMM'),
         '',
         '',
         '',
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         '',
         '',
         ZG_STOVE_SQE,
         '',
         '',
         QCM_STAUS,
         '',
         GX_PLAN_NO,
         SUBCONTRACT_NO,
         '',
         '',
         '',
         '',
         SYSDATE,
         FLAG_STOVE_NO_ZG,
         PONDER_GROSS_WT
    FROM MAT_BC_M M, YDM_BC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
   AND M.SUBCONTRACT_NO =?
  AND M.QCM_STAUS = '00'
		]]>
	</query>

	<query id="frmEntrust.DeleteBcInList" desc="删除入库记录">
		<![CDATA[
DELETE FROM YDM_BC_INLIST WHERE SUBCONTRACT_NO =?
		]]>
	</query>

	<query id="frmEntrust.InsertZcOutList" desc="写出库记录">
		<![CDATA[
INSERT INTO YDM_ZC_OUTLIST
  (OUTSTOCK_SQE,
   OUTSTOCK_PLAN_NO,
   OUTSTOCK_DOC,
   OUTSTOCK_TYPE_CODE,
   OUTSTOCK_TYPE_NAME,
   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_TEMP,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   BAR_CODE,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   TAR_STORAGE_NO,
   TAR_LOCATION_NO,
   TAR_LARY_NO,
   TAR_LOC_NO,
   TAR_STORAGE_ATTR,
   TAR_STORAGE_ATTR_NAME,
   TAR_STORAGE_TYPE_NO,
   TAR_STORAGE_TYPE_NAME,
   TAR_MANAGEMENT_NO,
   TAR_MANAGEMENT_NAME,
   TAR_REC_FLAG,
   RPO_TIME,
   PRO_BC,
   PRO_BZ,
   INSTOCK_TIME,
   IN_BC,
   IN_BZ,
   OUTSTOCK_TIME,
   OUT_BC,
   OUT_BZ,
   MEMO,
   HAND_FLAG,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   TAR_DEPARTMENT_CODE,
   TAR_DEPARTMENT_DESC,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   PONDER_NO,
   PONDER_GROSS_WT,
   VSTEL,
   VSTEL_DESC,
   BAL_YEAR_MONTH,
   M_BILL_NO,
   SEND_NUM,
   RECEIV_NO,
   RECEIV_NM,
   FINISHPRO_MOLD,
   IN_MOLD,
   ACT_LEN)
  SELECT (? || LPAD(ROWNUM || '', 4, 0)),
         M.SUBCONTRACT_NO,
         ?,
         '800813',
         '复检出库',
         '',
         '',
         M.MAT_NO,
         M.LOT_NO,
         M.STOVE_NO,
         M.JUDGE_STOVE_NO,
         M.BATCH_NO,
         M.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_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         BELONG_CODE,
         BELONG_NAME,
         BAR_CODE,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         '',
         RPO_TIME,
         PRO_BC,
         PRO_BZ,
         INSTOCK_TIME,
         '',
         '',
         SYSDATE,
         '',
         '',
         M.MEMO,
         '0',
         '1',
         ?,
         SYSDATE,
         '',
         '',
         DELETE_NAME,
         DELETE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         '',
         '',
         ORDER_NO,
         ORDER_SEQ,
         '',
         PRODUCT_FLAG,
         MAT_STATUS,
         JUDGE_STD_NAME,
         JUDGE_STD_CODE,
         PONDER_NO,
         PONDER_GROSS_WT,
         '',
         '',
         TO_CHAR(SYSDATE, 'YYYYMM'),
         '',
         '',
         '',
         '',
         FINISHPRO_MOLD,
         IN_MOLD,
         M.ACT_LEN
    FROM MAT_ZC_M M, YDM_ZC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
     AND M.SUBCONTRACT_NO = ?

		]]>
	</query>


	<query id="frmEntrust.DeleteZcOutList" desc="删除出库记录">
		<![CDATA[
DELETE FROM YDM_ZC_OUTLIST WHERE OUTSTOCK_PLAN_NO =?
		]]>
	</query>

	<query id="frmEntrust.InsertZcInList" desc="写入库记录">
		<![CDATA[
INSERT INTO YDM_ZC_INLIST
  (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,
   RPO_TIME,
   PRO_BC,
   PRO_BZ,
   INSTOCK_TIME,
   IN_BC,
   IN_BZ,
   BAR_CODE,
   HAND_FLAG,
   MEMO,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   ZB_RCDID,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   IN_TIME_F,
   BAL_YEAR_MONTH,
   LEN_NO,
   LEN_DESC,
   LEN_UNIT,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   AFFIRM_LOG,
   M_BILL_NO,
   ZG_STOVE_SQE,
   FINISHPRO_MOLD,
   IN_MOLD,
   PACK_NO,
   QCM_STAUS,
   SUBCONTRACT_NO,
   GX_PLAN_NO)
  SELECT  ( ? ||  LPAD ( ROWNUM || '' ,4,0)),
         ?,
         '800713',
         '复检入库',
         '',
         '',
         '',
         M.MAT_NO,
         LOT_NO,
         M.STOVE_NO,
         M.JUDGE_STOVE_NO,
         M.BATCH_NO,
         M.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,
         M.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,
         '',
         '',
         '',
         SYSDATE,
         '',
         '',
         BAR_CODE,
         '0',
         '',
         '1',
         ?,
         SYSDATE,
         '',
         '',
         DELETE_NAME,
         DELETE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         ORDER_NO,
         ORDER_SEQ,
         '',
         PRODUCT_FLAG,
         MAT_STATUS,
         '',
         '',
         '',
         '',
         TO_CHAR(SYSDATE,'YYYYMM'),
         '',
         '',
         '',
         PIPMEMO,
         SOURE_CODE,
         SOURE_NAME,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         '',
         '',
         ZG_STOVE_SQE,
         '',
         '',
         '',
         QCM_STAUS,
         SUBCONTRACT_NO,
         GX_PLAN_NO
       FROM MAT_ZC_M M, YDM_ZC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
   AND M.SUBCONTRACT_NO =?
		]]>
	</query>

	<query id="frmEntrust.DeleteZcInList" desc="删除入库记录">
		<![CDATA[
DELETE FROM YDM_ZC_INLIST WHERE SUBCONTRACT_NO =?
		]]>
	</query>


	<query id="frmEntrust.QueryProcessByAuto" desc="查询自动审批流程">
		<![CDATA[
SELECT T.* FROM HTT_ENTRUST_PROCESS_DEFAUL T, HTT_ENTRUST_AUTO A
WHERE T.APPROVAL_NO = A.APPROVAL_NO
     AND T.APPROVAL_TYPE = A.APPROVAL_TYPE
     AND T.STATUS_PREVIOUS = ?
     AND T.SUBCONTRACT_TARGET = ?
     AND A.SUBCONTRACT_NO = ?
		]]>
	</query>



	<query id="frmEntrust.GetJGOfflieMatEntity" desc="查询接箍离线库存">
		<![CDATA[
SELECT WMSYS.WM_CONCAT(MAT_NO) MAT_NO
  FROM (SELECT T.MAT_NO
          FROM MAT_BC_M T
         WHERE T.QCM_STAUS = '11'
           AND T.PROCESS_CDOE = 'H'
           AND T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
           AND T.BATCH_GROUD_NO = ?
              AND (T.SUBCONTRACT_NO IS NULL OR EXISTS
                (SELECT 1
                   FROM HTT_ENTRUST
                  WHERE SUBCONTRACT_NO = T.SUBCONTRACT_NO
                    AND SUBCONTRACT_LOG IN ('60', '20')))
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM <= ?
		]]>
	</query>




	<query id="frmEntrust.DeleteMat" desc="删除离线库存">
		<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_M
                 WHERE SUBCONTRACT_NO = ?
                   AND SUBCONTRACT_NO_SEQ = ?) LOOP

  DELETE MAT_BC_BACKUP
 WHERE MAT_NO = MYROW.MAT_NO
   AND PLINE_CODE =MYROW.PLINE_CODE
   AND PRODUCT_FLAG =  MYROW.PRODUCT_FLAG;

    INSERT INTO MAT_BC_BACKUP
      SELECT * FROM MAT_BC_M WHERE MAT_NO = MYROW.MAT_NO;

    DELETE FROM YDM_BC_BUTTRESS_BACK
     WHERE MAT_NO = MYROW.MAT_NO
       AND PLINE_CODE = MYROW.PLINE_CODE;

    INSERT INTO YDM_BC_BUTTRESS_BACK
      SELECT MAT_NO,
             JUDGE_STOVE_NO,
             BATCH_NO,
             BATCH_GROUD_NO,
             STORAGE_NO,
             LOCATION_NO,
             LARY_NO,
             LOC_NO,
             STORAGE_ATTR,
             STORAGE_ATTR_NAME,
             STORAGE_TYPE_NO,
             STORAGE_TYPE_NAME,
             MANAGEMENT_NO,
             MANAGEMENT_NAME,
             MEMO,
             CREATE_NAME,
             CREATE_TIME,
             UPDATE_NAME,
             UPDATE_TIME,
             DELETE_NAME,
             DELETE_TIME,
             DEPARTMENT_CODE,
             DEPARTMENT_DESC,
             MYROW.PLINE_CODE
        FROM YDM_BC_BUTTRESS
       WHERE MAT_NO = MYROW.MAT_NO;

    DELETE FROM MAT_BC_M WHERE MAT_NO = MYROW.MAT_NO;

    DELETE FROM YDM_BC_BUTTRESS WHERE MAT_NO = MYROW.MAT_NO;
  END LOOP;
END;
		]]>
	</query>

	<query id="frmEntrust.revertMat" desc="还原库存">
		<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_BACKUP
                 WHERE SUBCONTRACT_NO = ?
                   AND SUBCONTRACT_NO_SEQ = ?) LOOP

    INSERT INTO MAT_BC_M
      SELECT *
        FROM MAT_BC_BACKUP
       WHERE MAT_NO = MYROW.MAT_NO
         AND SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
         AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ;

    INSERT INTO YDM_BC_BUTTRESS
      SELECT *
        FROM YDM_BC_BUTTRESS_BACK
       WHERE MAT_NO = MYROW.MAT_NO
         AND PLINE_CODE = MYROW.PLINE_CODE;

    DELETE FROM MAT_BC_BACKUP
     WHERE MAT_NO = MYROW.MAT_NO
       AND SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
       AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ;
  END LOOP;
END;

		]]>
	</query>
	
	<query id="frmEntrust.QueryHttEntrustResult" desc="查询委托实绩">
		<![CDATA[
          select T.PRO_NUM,
       INSTR(T.PROJECT_NAME, '成品加工') isCpjg,
       T.RETURN_FLAG,
       T1.WO_ID,
       T1.HEAT_PLAN_NO
  from HTT_ENTRUST_RESULT t, PLN_ZY_JG_WORKBILL T1
 WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO(+)
   AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO(+)
   AND T.BATCH_NO = T1.BATCH_NO(+)
   AND T.SUBCONTRACT_NO = ?
   AND T.RESULT_NO = ?
		]]>
	</query>
	<query id="frmEntrust.QueryHttEntrust" desc="查询通用委托单信息">
		<![CDATA[
          select t.*  from HTT_ENTRUST t WHERE T.SUBCONTRACT_NO = ? AND T.SUBCONTRACT_NO_SEQ = ?
		]]>
	</query>
	
	<query id="frmEntrust.updateHttEntrustResult" desc="更新委外实绩返库标识">
		<![CDATA[
         UPDATE HTT_ENTRUST_RESULT T
   SET T.RETURN_FLAG = ?
 WHERE T.SUBCONTRACT_NO = ?
   AND T.RESULT_NO = ?
		]]>
	</query>
	
	<query id="frmEntrust.QueryCouplingPhosphateResult" desc="查询返库的磷化实绩">
		<![CDATA[
          select t.* from COUPLING_PHOSPHATE_RESULT t WHERE T.WO_ID = ? and t.spray_count = ? and t.remark = '返线交库'
		]]>
	</query>

	<query id="frmEntrust.addMessage" desc="增加消息">
		<![CDATA[
         INSERT INTO APP_MESSAGE
  (MESSAGE_NO,
   MESSAGE_TITLE,
   MESSAGE_LEVEL_CODE,
   MESSAGE_LEVEL_DESC,
   MESSAGE_CLASS_CODE,
   MESSAGE_CLASS_DESC,
   MESSAGE_CONTENT,
   MESSAGE_PATH,
   RELEASE_ORG_CODE,
   RELEASE_ORG_DESC,
   RELEASE_USERID,
   RELEASE_NAME,
   RELEASE_TIME,
   VALIDFLAG,
   MEMO,
   CREATE_USERID,
   CREATE_NAME,
   CREATE_TIME,
   REFER_KEY,
   APPROVAL_NODE,
   WINDOW_KEY,
   EVENT_KEY,
   NEED_GROUP,
   IS_PUSH)
VALUES
  ('#MESSAGE_NO#',
   '#MESSAGE_TITLE#',
   '#MESSAGE_LEVEL_CODE#',
   (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=  '#MESSAGE_LEVEL_CODE#'),
   '#MESSAGE_CLASS_CODE#',
   (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE=  '#MESSAGE_CLASS_CODE#'),
   '#MESSAGE_CONTENT#',
   '#MESSAGE_PATH#',
   '#RELEASE_ORG_CODE#',
   '#RELEASE_ORG_DESC#',
   '#RELEASE_USERID#',
   '#RELEASE_NAME#',
   DECODE('#VALIDFLAG#','20',SYSDATE,NULL),
   '#VALIDFLAG#',
   '#MEMO#',
   '#CREATE_USERID#',
   '#CREATE_NAME#',
   SYSDATE,
   '#REFER_KEY#',
   '#APPROVAL_NODE#',
   '#WINDOW_KEY#',
   '#EVENT_KEY#',
   '#NEED_GROUP#',
   '#IS_PUSH#')
		]]>
	</query>

	<query id="frmEntrust.getMessageNo" desc="获取消息No">
		<![CDATA[
      	SELECT  'C' || TO_CHAR(SYSDATE,'YYYYMMDD' ) ||
	LPAD(NVL(MAX(TO_NUMBER(SUBSTR(MESSAGE_NO, LENGTH(MESSAGE_NO) - 4))),
	0) + 1,
	5,
	'0') MESSAGE_NO
	FROM APP_MESSAGE
	WHERE MESSAGE_NO LIKE 'C' || TO_CHAR(SYSDATE,'YYYYMMDD' )  ||  '_____'
		]]>
	</query>



	<query id="frmEntrust.updateEntrustType" desc="更新是否带探伤">
		<![CDATA[
     UPDATE HTT_ENTRUST T
   SET SUBCONTRACT_TYPE = DECODE((SELECT COUNT(1)
                                   FROM HTT_ENTRUST_PROJECT
                                  WHERE SUBCONTRACT_NO = T.SUBCONTRACT_NO
                                    AND SUBCONTRACT_NO_SEQ =
                                        T.SUBCONTRACT_NO_SEQ
                                    AND PROJECT_FLAG IN ('0', '1', '3')
                                    AND PROJECT_CODE LIKE '702202%'),
                                 0,
                                 '0',
                                 NULL,
                                 '0',
                                 '1')
 WHERE T.SUBCONTRACT_NO =?
		]]>
	</query>
	
	<query id = "frmEntrust.Split" desc = "拆分接箍外委单">
    <![CDATA[
         DECLARE
  V_SUBCONTRACT_NO     HTT_ENTRUST.SUBCONTRACT_NO%type := ?;
  V_SUBCONTRACT_NO_SEQ HTT_ENTRUST.SUBCONTRACT_NO_SEQ%type := ?;
  V_SUBCONTRACT_NUM    HTT_ENTRUST.SUBCONTRACT_NUM%type := ?; --拆分支数
  V_SUBCONTRACT_WT     HTT_ENTRUST.SUBCONTRACT_WT%type := NULL; --拆分重量
  V_WO_ID              PLN_ZY_JG_WORKBILL.WO_ID%type := NULL;
  V_RESULT_NO          COUPLING_LOADING_RESULT.RESULT_NO%type := NULL;
  V_SUBCONTRACT_NO_NEW HTT_ENTRUST.SUBCONTRACT_NO%type := NULL;
BEGIN
  FOR MYROW IN (SELECT *
                  FROM HTT_ENTRUST T
                 WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
                   AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ) LOOP
  
    --生成工单号
    select MYROW.HEAT_PLAN_NO ||
           LPAD(NVL(MAX(SUBSTR(T.WO_ID, 19)), 0) + 1, 4, 0)
      INTO V_WO_ID
      from PLN_ZY_JG_WORKBILL t
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE;
  
    --生成实绩编号
    SELECT MYROW.PLINE_CODE || '01' || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
           LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                    0) + 1,
                6,
                '0')
      INTO V_RESULT_NO
      FROM COUPLING_LOADING_RESULT
     WHERE RESULT_NO LIKE MYROW.PLINE_CODE || '01' ||
           TO_CHAR(SYSDATE, 'yyyyMMDD') || '______';
  
    --生成委托单号
    SELECT V_SUBCONTRACT_NO || '-' || LPAD(NVL(MAX(SUBSTR(T.SUBCONTRACT_NO,
                                                          LENGTH(T.SUBCONTRACT_NO) - 1)),
                                               0) + 1,
                                           2,
                                           0)
      INTO V_SUBCONTRACT_NO_NEW
      FROM HTT_ENTRUST T
     WHERE SUBCONTRACT_NO LIKE V_SUBCONTRACT_NO || '___';
  
    --拆分重量
    SELECT TO_CHAR(V_SUBCONTRACT_NUM * T.SUBCONTRACT_WT / T.SUBCONTRACT_NUM,
                   'FM999999.000')
      INTO V_SUBCONTRACT_WT
      FROM HTT_ENTRUST T
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
       AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ;
  
    --拆分工单
    INSERT INTO PLN_ZY_JG_WORKBILL
      SELECT V_WO_ID,
             T.HEAT_PLAN_NO,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             T.BATCH_GROUD_NO,
             T.PLINE_CODE,
             T.PLINE_NAME,
             T.IF_ALL_OUT_WORK,
             T.IF_OUT_CUT,
             T.IF_OUT_CJG,
             T.IF_OUT_IMPRESS,
             T.IF_OUT_LATHE,
             T.IF_OUT_DETECT,
             T.IF_OUT_BLAST,
             T.IF_OUT_COAT,
             T.COAT_TYPE,
             T.PLAN_JG_NUM,
             T.CS_JG_NUM,
             T.XQ_JG_NUM,
             T.DEMAND_COPPER,
             T.LATHE_GRP_NO,
             T.LATHE_GRP_NM,
             T.DEMAND_DETECTION,
             T.DEMAND_BLAST,
             T.DEMAND_BONDERIZING,
             T.ZY_BILL_STATUS,
             T.MEMO,
             T.CREATE_NAME,
             T.CREATE_TIME,
             T.UPDATE_NAME,
             T.UPDATE_TIME,
             T.IF_OUT_COPPER,
             T.CLOSE_TIME,
             V_SUBCONTRACT_NUM,
             V_SUBCONTRACT_WT,
             T.IF_OUT_THREAD,
             V_SUBCONTRACT_NUM,
             V_SUBCONTRACT_WT,
             T.STOVE_NO,
             T.FLAG_STOVE_NO,
             T.OUT_NUM,
             T.OUT_WT,
             T.STEELCODE,
             T.STEELNAME,
             T.GRADECODE,
             T.GRADENAME,
             T.SPEC_JG_DESC,
             T.SPEC_JG,
             T.STYLE_JG,
             T.STD_CODE,
             T.STD_NAME,
             T.STD_STYLE,
             T.STD_STYLE_DESC,
             T.PRODUCCODE_JG,
             T.PRODUCCODE_JG_DESC,
             T.CODE_JG,
             T.CODE_JG_BL,
             T.CODE_BL_ALL,
             T.MODEL_CODE,
             T.MODEL_DESC,
             T.IF_MONITOR_JG,
             T.PRDCR_NO,
             T.HEAT_PLAN_SQE,
             T.KEY,
             T.BL_WL_ID,
             T.BL_WL_DESC,
             T.OUTWL_ID,
             T.OUTWL_DESC,
             T.AIMLENGTH_BL,
             T.AIM_CUT_LEN,
             T.SINGLE_CUT_NUN,
             T.SINGLEWEIGHT,
             T.PER_STATUS,
             T.BESIDE_STATUS,
             T.JG_ORDERNO_ALL,
             T.CRAFT_NO_JG2,
             T.CRAFT_SEQ2,
             T.CRAFT_PATH,
             T.ORD_LN_DLY_PK,
             T.ORDER_NO,
             T.ORDER_SEQ,
             T.DELIVERY_NO,
             T.LATHE_CUT_NM,
             T.PLINE_CODE_W,
             T.PLINE_NAME_W,
             T.DECISION,
             T.INDEX_SEQ,
             T.CRAFT_SEQ,
             T.CRAFT_FILE_NO,
             T.GX_PRO_SEQ,
             T.BUYER_ID,
             T.BUYER_NAME,
             T.MONITOR_POINT,
             T.MIN_D,
             T.MIN_H,
             T.MONITORDEMAND,
             T.IFSPLIT,
             T.BELONG_CODE,
             T.BELONG_NAME,
             T.IS_LOAD_FLAG,
             V_SUBCONTRACT_NO_NEW
        FROM PLN_ZY_JG_WORKBILL T
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.BATCH_NO = MYROW.BATCH_NO
         AND T.HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE
         AND T.SUBCONTRACT_NO IS NULL
         AND ROWNUM = 1;
  
    UPDATE PLN_ZY_JG_WORKBILL T
       SET T.PLAN_BL_NUM = T.PLAN_BL_NUM - V_SUBCONTRACT_NUM,
           T.PLAN_BL_WT  = T.PLAN_BL_WT - V_SUBCONTRACT_WT,
           T.REAL_BL_NUM = T.REAL_BL_NUM - V_SUBCONTRACT_NUM,
           T.REAL_BL_WT  = T.REAL_BL_WT - V_SUBCONTRACT_WT
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND T.SUBCONTRACT_NO IS NULL
       AND ROWNUM = 1;
  
    --拆分上料实绩
    INSERT INTO COUPLING_LOADING_RESULT
      SELECT V_RESULT_NO,
             T.ZY_PLAN_ID,
             V_WO_ID,
             V_SUBCONTRACT_NUM,
             T.LOAD_SHIFT,
             T.LOAD_GROUP,
             T.LOAD_USER,
             T.LOAD_TIME,
             V_SUBCONTRACT_WT,
             T.PLINE_CODE,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             T.GRADECODE,
             T.GRADENAME,
             T.STEELCODE,
             T.STEELNAME,
             T.CREATE_TIME,
             T.ACT_DIMATER,
             T.ACT_HEIGHT,
             T.PRO_TIME,
             T.PLINE_NAME,
             T.SPEC_JG_DESC,
             T.SPEC_JG,
             T.STYLE_JG,
             T.STD_CODE,
             T.STD_NAME,
             T.STD_STYLE,
             T.STD_STYLE_DESC,
             T.PRODUCCODE_JG,
             T.PRODUCCODE_JG_DESC,
             T.CODE_JG,
             T.CODE_JG_BL,
             T.MODEL_CODE,
             T.MODEL_DESC,
             T.IF_MONITOR_JG,
             T.PRDCR_NO,
             T.BATCH_GROUD_NO,
             T.OFF_NUM,
             T.IS_AUDITE,
             T.MEMO,
             T.CONFIRM,
             T.CONFIRM_NAME,
             T.CONFIRM_TIME,
             T.PLACE,
             T.MACHINE_NO,
             V_SUBCONTRACT_NO_NEW
        FROM COUPLING_LOADING_RESULT T
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.BATCH_NO = MYROW.BATCH_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE
         AND T.SUBCONTRACT_NO IS NULL
         AND ROWNUM = 1;
  
    UPDATE COUPLING_LOADING_RESULT T
       SET T.LOAD_PIECES = T.LOAD_PIECES - V_SUBCONTRACT_NUM,
           T.LOAD_WEIGHT = T.LOAD_WEIGHT - V_SUBCONTRACT_WT
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND T.SUBCONTRACT_NO IS NULL
       AND ROWNUM = 1;
    --拆分上料的接箍公共信息
    INSERT INTO COUPLING_COM_INFO
      SELECT V_RESULT_NO,
             V_WO_ID,
             T.PRO_PLAN_ID,
             T.CODE_JG_BL,
             T.JG_GROUP_ID,
             T.IF_OUT_RPO,
             T.PLINE_CODE,
             T.PLINE_NAME,
             T.STATION_CODE,
             T.STATION_DESC,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             T.BL_WL_ID,
             T.BL_WL_DESC,
             T.MIN_D,
             T.MIN_H,
             T.AIMLENGTH_BL,
             T.AIM_CUT_LEN,
             T.LENGTH_MIN,
             T.LENGTH_MAX,
             T.TAPER,
             T.CODE_JG,
             T.GRADECODE,
             T.GRADENAME,
             T.STEELCODE,
             T.STEELNAME,
             T.MODEL_CODE,
             T.MODEL_DESC,
             T.OUTDIAMETER,
             T.WALLTHICK,
             T.SPEC_JG,
             T.SPEC_JG_DESC,
             T.STYLE_JG,
             T.DIAMETER,
             T.CHECK_J_VAL,
             T.AIMLENGTH,
             T.SINGLEWEIGHT,
             T.MONITORDEMAND,
             T.IF_MONITOR_JG,
             T.PRDCR_NO,
             T.PRODUCER,
             T.PRODUCER_TIME,
             T.MACH_NO,
             T.MACH_NM,
             V_SUBCONTRACT_NUM,
             V_SUBCONTRACT_WT,
             T.FAIL_NUM,
             T.FAIL_WT,
             T.OFFLINE_NUM,
             T.OFFLINE_WT,
             T.STATION_STATUS,
             T.RRO_TIME,
             T.RRO_TIME_NU,
             T.PRO_USER,
             T.PRO_SHIFT,
             T.PRO_GROUP,
             T.IF_ALL_OUT_WORK,
             T.CREATE_TIME,
             T.COL_OPERATOR,
             T.COL_OPERATOR2,
             T.JG_ORDERNO,
             T.OUTWL_ID,
             T.OUTWL_DESC,
             T.PRODUCCODE_JG,
             T.PRODUCCODE_JG_DESC,
             T.STD_CODE,
             T.STD_NAME,
             T.STD_STYLE,
             T.STD_STYLE_DESC,
             V_SUBCONTRACT_NO_NEW
        FROM COUPLING_COM_INFO T
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.BATCH_NO = MYROW.BATCH_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE
         AND T.SUBCONTRACT_NO IS NULL
         AND T.STATION_CODE = '700301'
         AND ROWNUM = 1;
    UPDATE COUPLING_COM_INFO T
       SET T.PRO_NUM = T.PRO_NUM - V_SUBCONTRACT_NUM,
           T.PRO_WT  = T.PRO_WT - V_SUBCONTRACT_WT
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND T.SUBCONTRACT_NO IS NULL
       AND T.STATION_CODE = '700301'
       AND ROWNUM = 1;
  
    --拆分离线实绩表
    INSERT INTO COUPLING_OFFLINE_RESULT
      SELECT V_RESULT_NO,
             T.PLINE_CODE,
             T.ZY_PLAN_ID,
             V_WO_ID,
             T.STATION_CODE,
             T.STATION_DESC,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             V_SUBCONTRACT_NUM,
             V_SUBCONTRACT_WT,
             T.IF_ALL_OUT_WORK,
             T.HARSH_TYPE,
             T.COATING_TYPE,
             T.MACHINE_NO,
             T.COL_MODE,
             T.COL_TIME,
             T.COL_USER,
             T.COL_SHIFT,
             T.COL_GROUP,
             T.CREATE_TIME,
             T.OFF_XH,
             T.RE_NUM,
             T.RE_WT,
             T.RETURN_PROCESS,
             T.RE_TIME,
             T.RE_NAME,
             V_SUBCONTRACT_NO_NEW,
             T.SUBCONTRACT_NO_SEQ,
             V_SUBCONTRACT_NUM,
             V_SUBCONTRACT_WT,
             T.SUBCONTRACT_TIME,
             T.SUBCONTRACT_NAME,
             T.SUBCONTRACTCOMPLETE_NUM,
             T.SUBCONTRACTCOMPLETE_WT,
             T.HB_FP_NUM,
             T.HB_FP_WT,
             T.SUBCONTRACTCOMPLETE_TIME,
             T.SUBCONTRACTCOMPLETE_NAME,
             T.MEMO,
             T.BATCH_GROUD_NO,
             T.PLINE_NAME
        FROM COUPLING_OFFLINE_RESULT T
       WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
         AND T.BATCH_NO = MYROW.BATCH_NO
         AND T.PLINE_CODE = MYROW.PLINE_CODE
         AND T.SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
         AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ
         AND ROWNUM = 1;
    UPDATE COUPLING_OFFLINE_RESULT T
       SET T.OFFLINE_NUM     = T.OFFLINE_NUM - V_SUBCONTRACT_NUM,
           T.OFFLINE_WT      = T.OFFLINE_WT - V_SUBCONTRACT_WT,
           T.SUBCONTRACT_NUM = T.SUBCONTRACT_NUM - V_SUBCONTRACT_NUM,
           T.SUBCONTRACT_WT  = T.SUBCONTRACT_WT - V_SUBCONTRACT_WT
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND T.SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
       AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ
       AND ROWNUM = 1;
    --拆分外委单
    INSERT INTO HTT_ENTRUST
      SELECT V_SUBCONTRACT_NO_NEW,
             T.SUBCONTRACT_NO_SEQ,
             T.PLINE_CODE,
             T.PLINE_NAME,
             T.HEAT_PLAN_NO,
             T.LOT_NO,
             T.STOVE_NO,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             T.PRO_PLAN_ID,
             T.GX_PLAN_NO,
             T.PRODUCCODE,
             T.PRODUCNAME,
             T.STEELCODE,
             T.STEELNAME,
             T.GRADECODE,
             T.GRADENAME,
             T.MODEL_CODE,
             T.MODEL_DESC,
             T.STD_CODE,
             T.STD_NAME,
             T.STD_STYLE,
             T.STD_STYLE_DESC,
             T.SUBCONTRACT_LOG,
             T.SUBCONTRACT_PLINE_CODE,
             T.SUBCONTRACT_PLINE_NAME,
             T.SUBCONTRACT_NOTE,
             T.SP_NOTE,
             V_RESULT_NO,
             T.SUBCONTRACT_USER,
             T.SUBCONTRACT_SHIFT,
             T.SUBCONTRACT_GROUP,
             T.SUBCONTRACT_TIME,
             T.SP_USER,
             T.SP_TIME,
             T.RESPOND_USER,
             T.RESPOND_TIME,
             T.SUBCONTRACT_TYPE,
             T.NEW_BATCH_NO,
             T.ORDER_NO,
             T.ACT_DIMATER,
             T.ACT_HEIGHT,
             V_SUBCONTRACT_NUM,
             V_SUBCONTRACT_WT,
             T.HB_COMPLETE_NUM,
             T.HB_COMPLETE_WT,
             T.HB_FP_NUM,
             T.HB_FP_WT,
             T.CUT_NUM,
             T.PROCESS_CODE,
             T.APPLY_NOTE,
             T.PROD_STANDARD,
             T.SPEC_CODE,
             T.SPEC_NAME,
             T.CIC,
             T.PIC,
             T.SIC,
             T.DIC,
             T.WIC,
             T.GIC,
             T.DESGIN_KEY,
             T.MSC_PLINE,
             T.CHECK_NO,
             T.SUBCONTRACT_NUM_CUT,
             T.SUBCONTRACT_TYPE_NAME,
             T.SUBCONTRACT_TARGET,
             T.SUBCONTRACT_OPERATOR,
             T.STORAGE_TYPE_NO,
             T.STORAGE_TYPE_NAME,
             T.IF_MONITOR,
             T.DRAWINGNO,
             T.PRE_COMPLETE_NUM,
             T.PRE_COMPLETE_WT,
             T.FLAG_STOVE_NO,
             T.REPORT_PATH,
             T.IS_DOWN,
             T.IS_RETURN,
             T.TRANSCODE
        FROM HTT_ENTRUST T
       WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
         AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ;
    UPDATE HTT_ENTRUST T
       SET T.SUBCONTRACT_NUM     = T.SUBCONTRACT_NUM - V_SUBCONTRACT_NUM,
           T.SUBCONTRACT_WT      = T.SUBCONTRACT_WT - V_SUBCONTRACT_WT
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
       AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ;
  
    --增加一套委托单审批流程 
    FOR MYROW1 IN (SELECT *
                     FROM HTT_ENTRUST_PROCESS T
                    WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO) LOOP
      INSERT INTO HTT_ENTRUST_PROCESS
        SELECT V_SUBCONTRACT_NO_NEW,
               T.OPERATE_SEQ,
               T.OPERATE_ACTION,
               T.OPERATE_NAME,
               T.OPERATE_DATE,
               T.MEMO,
               T.OLD_STATUS,
               T.NEW_STATUS
          FROM HTT_ENTRUST_PROCESS T
         WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
           AND T.OPERATE_SEQ = MYROW1.OPERATE_SEQ;
    END LOOP;
  
    --增加一套委外项目明细 
    FOR MYROW2 IN (SELECT *
                     FROM HTT_ENTRUST_PROJECT T
                    WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
                      AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ) LOOP
      INSERT INTO HTT_ENTRUST_PROJECT
        SELECT T.PROJECT_CODE,
               T.PROJECT_NAME,
               T.PROJECT_STATUS,
               T.PROJECT_MEMO,
               T.PROJECT_FLAG,
               V_SUBCONTRACT_NO_NEW,
               T.SUBCONTRACT_NO_SEQ,
               T.PROJECT_TYPE,
               T.PROJECT_MEMO_ORGIN,
               T.PROJECT_TYPE_ORGIN,
               T.PAY_DEPARTMENT_CODE,
               T.PAY_DEPARTMENT_NAME,
               T.BAL_YEAR_MONTH,
               T.BAL_PRICE,
               T.BAL_PRICE_TOTAL,
               T.BAL_NUM,
               T.BAL_WT,
               T.BAL_INCISION_NUM,
               T.BAL_BUNDLING_NUM,
               T.PROJECT_SEQ
          FROM HTT_ENTRUST_PROJECT T
         WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
           AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ
           AND T.PROJECT_CODE = MYROW2.PROJECT_CODE;
    END LOOP;
    --离线数据更新委托单号
    UPDATE MAT_BC_M T
       SET T.SUBCONTRACT_NO = V_SUBCONTRACT_NO_NEW
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
       AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ
       AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND ROWNUM <= V_SUBCONTRACT_NUM;
  END LOOP;
END;
    ]]>
  </query>
  
  <query id="frmEntrust.CancelSplit" desc="撤销拆分接箍外委单">
    <![CDATA[
    DECLARE
  V_SUBCONTRACT_NO     HTT_ENTRUST.SUBCONTRACT_NO%type := ?;
  V_SUBCONTRACT_NO_SEQ HTT_ENTRUST.SUBCONTRACT_NO_SEQ%type := ?;
  V_SUBCONTRACT_NUM    HTT_ENTRUST.SUBCONTRACT_NUM%type := ?; --拆分支数
  V_SUBCONTRACT_WT     HTT_ENTRUST.SUBCONTRACT_WT%type := ?; --拆分重量
  V_RESULT_NO          COUPLING_LOADING_RESULT.RESULT_NO%type := NULL;
BEGIN
  SELECT T.RESULT_NO
    INTO V_RESULT_NO
    FROM HTT_ENTRUST T
   WHERE T.SUBCONTRACT_NO = SUBSTR(V_SUBCONTRACT_NO, 1, 20)
     AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ;

  FOR MYROW IN (SELECT *
                  FROM HTT_ENTRUST T
                 WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
                   AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ) LOOP
    --撤销工单
    DELETE FROM PLN_ZY_JG_WORKBILL T
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO;
    UPDATE PLN_ZY_JG_WORKBILL T
       SET T.PLAN_BL_NUM = T.PLAN_BL_NUM + V_SUBCONTRACT_NUM,
           T.PLAN_BL_WT  = T.PLAN_BL_WT + V_SUBCONTRACT_WT,
           T.REAL_BL_NUM = T.REAL_BL_NUM + V_SUBCONTRACT_NUM,
           T.REAL_BL_WT  = T.REAL_BL_WT + V_SUBCONTRACT_WT
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND T.SUBCONTRACT_NO IS NULL
       AND ROWNUM = 1;
  
    --撤销上料实绩
    DELETE FROM COUPLING_LOADING_RESULT T
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO;
    UPDATE COUPLING_LOADING_RESULT T
       SET T.LOAD_PIECES = T.LOAD_PIECES + V_SUBCONTRACT_NUM,
           T.LOAD_WEIGHT = T.LOAD_WEIGHT + V_SUBCONTRACT_WT
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND T.SUBCONTRACT_NO IS NULL
       AND ROWNUM = 1;
    --撤销拆分上料的接箍公共信息
     DELETE FROM COUPLING_COM_INFO T
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
       AND T.STATION_CODE = '700301'
       AND ROWNUM = 1;
    UPDATE COUPLING_COM_INFO T
       SET T.PRO_NUM = T.PRO_NUM + V_SUBCONTRACT_NUM,
           T.PRO_WT  = T.PRO_WT + V_SUBCONTRACT_WT
     WHERE T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND T.STATION_CODE = '700301'
       AND ROWNUM = 1;
  
    --撤销拆分离线实绩表
    DELETE FROM COUPLING_OFFLINE_RESULT T
     WHERE T.SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
       AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ
       AND ROWNUM = 1;
    UPDATE COUPLING_OFFLINE_RESULT T
       SET T.OFFLINE_NUM     = T.OFFLINE_NUM + V_SUBCONTRACT_NUM,
           T.OFFLINE_WT      = T.OFFLINE_WT + V_SUBCONTRACT_WT,
           T.SUBCONTRACT_NUM = T.SUBCONTRACT_NUM + V_SUBCONTRACT_NUM,
           T.SUBCONTRACT_WT  = T.SUBCONTRACT_WT + V_SUBCONTRACT_WT
     WHERE T.SUBCONTRACT_NO = SUBSTR(MYROW.SUBCONTRACT_NO, 1, 14)
       AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ
       AND ROWNUM = 1;
    --撤销拆分外委单
    DELETE FROM HTT_ENTRUST T
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
       AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ;
    UPDATE HTT_ENTRUST T
       SET T.SUBCONTRACT_NUM = T.SUBCONTRACT_NUM + V_SUBCONTRACT_NUM,
           T.SUBCONTRACT_WT  = T.SUBCONTRACT_WT + V_SUBCONTRACT_WT
     WHERE T.SUBCONTRACT_NO = SUBSTR(MYROW.SUBCONTRACT_NO, 1, 14)
       AND T.SUBCONTRACT_NO_SEQ = V_SUBCONTRACT_NO_SEQ;
  
    --撤销增加一套委托单审批流程 
    DELETE FROM HTT_ENTRUST_PROCESS T
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO;
    --撤销增加一套委外项目明细 
    DELETE FROM HTT_ENTRUST_PROJECT T
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO;
    --撤销离线数据更新委托单号 
    UPDATE MAT_BC_M T
       SET T.SUBCONTRACT_NO = SUBSTR(MYROW.SUBCONTRACT_NO, 1, 14)
     WHERE T.SUBCONTRACT_NO = V_SUBCONTRACT_NO
       AND T.SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ
       AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE
       AND ROWNUM <= V_SUBCONTRACT_NUM;
  END LOOP;
END;
    ]]>
  </query>




	<query id="frmEntrust.BatchInsertEntrustCutPortVrp" desc="批量插入分切管">
		INSERT INTO PORT_VRP_BATCH_SAMPLE_RESULT
		(HEAT_PLAN_NO,
		MAT_NO,
		M_MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		PRC_TECHNOLOGY_PATH,
		VM_INSTORE_FLAG,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		CRATE_TIME,
		FEED_HEAT_NO,
		HEAT_PLAN_SQE,
		TR_FLAG,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		REPHY_CODE_GROUP,
		REPHY_CODE_GROUPB,
		RESULT_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		VALIDFLAG,
		JUGDE_APPLY_SEQUENO,
		CUT_ACT_LEN,
		CUT_ACT_WEIGHT)
		SELECT HEAT_PLAN_NO,
		T.MAT_NO_CUT MAT_NO,
		M.MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_LEN-  (T.CUT_NUM-1) * ROUND(ACT_LEN/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_LEN/T.CUT_NUM ,3)
		END ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		END ACT_WEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_THEORY_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		END ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		DECODE(T.MAT_STATUS,1,'40','20') MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		PRC_TECHNOLOGY_PATH,
		VM_INSTORE_FLAG,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		CRATE_TIME,
		FEED_HEAT_NO,
		HEAT_PLAN_SQE,
		TR_FLAG,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		REPHY_CODE_GROUP,
		REPHY_CODE_GROUPB,
		M.RESULT_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		VALIDFLAG,
		JUGDE_APPLY_SEQUENO,
		CUT_ACT_LEN,
		CUT_ACT_WEIGHT
		FROM PORT_VRP_BATCH_SAMPLE_RESULT M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO
		--AND M.RESULT_NO = T.RESULT_NO_OFFLINE
		AND T.RESULT_NO_OFFLINE = ?
		AND (M.RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM VRP_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM VRP_OFFLINE_RESULT
		WHERE RESULT_NO = T.RESULT_NO_OFFLINE)) OR
		M.RESULT_NO = T.RESULT_NO_OFFLINE)

	</query>

	<query id="frmEntrust.BatchInsertEntrustPortVrp" desc="批量插入分切管">
		INSERT INTO PORT_VRP_BATCH_SAMPLE_RESULT
		(HEAT_PLAN_NO,
		MAT_NO,
		M_MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		PRC_TECHNOLOGY_PATH,
		VM_INSTORE_FLAG,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		CRATE_TIME,
		FEED_HEAT_NO,
		HEAT_PLAN_SQE,
		TR_FLAG,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		REPHY_CODE_GROUP,
		REPHY_CODE_GROUPB,
		RESULT_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		VALIDFLAG,
		JUGDE_APPLY_SEQUENO,
		CUT_ACT_LEN,
		CUT_ACT_WEIGHT)
		SELECT HEAT_PLAN_NO,
		T.MAT_NO,
		M_MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		(SELECT SUM(ACT_LEN) FROM PORT_VRP_BATCH_SAMPLE_RESULT A, HTT_ENTRUST_MAT_NO B
		WHERE A.HEAT_PLAN_NO = M.HEAT_PLAN_NO
		AND A.MAT_NO = B.MAT_NO_CUT
		AND A.RESULT_NO = B.RESULT_NO_OFFLINE
		AND B.MAT_NO = T.MAT_NO),
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		(SELECT SUM(ACT_WEIGHT) FROM PORT_VRP_BATCH_SAMPLE_RESULT A, HTT_ENTRUST_MAT_NO B
		WHERE A.HEAT_PLAN_NO = M.HEAT_PLAN_NO
		AND A.MAT_NO = B.MAT_NO_CUT
		AND A.RESULT_NO = B.RESULT_NO_OFFLINE
		AND B.MAT_NO = T.MAT_NO),
		(SELECT SUM(ACT_WEIGHT) FROM PORT_VRP_BATCH_SAMPLE_RESULT A, HTT_ENTRUST_MAT_NO B
		WHERE A.HEAT_PLAN_NO = M.HEAT_PLAN_NO
		AND A.MAT_NO = B.MAT_NO_CUT
		AND A.RESULT_NO = B.RESULT_NO_OFFLINE
		AND B.MAT_NO = T.MAT_NO),
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		'20' MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		PRC_TECHNOLOGY_PATH,
		VM_INSTORE_FLAG,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		CRATE_TIME,
		FEED_HEAT_NO,
		HEAT_PLAN_SQE,
		TR_FLAG,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		REPHY_CODE_GROUP,
		REPHY_CODE_GROUPB,
		M.RESULT_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		VALIDFLAG,
		JUGDE_APPLY_SEQUENO,
		CUT_ACT_LEN,
		CUT_ACT_WEIGHT
		FROM PORT_VRP_BATCH_SAMPLE_RESULT M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO_CUT
		--AND M.RESULT_NO = T.RESULT_NO_OFFLINE
		AND T.MAT_NO_CUT LIKE '%01'
		AND T.RESULT_NO_OFFLINE = ?
		AND (M.RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM VRP_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM VRP_OFFLINE_RESULT
		WHERE RESULT_NO = T.RESULT_NO_OFFLINE)) OR
		M.RESULT_NO = T.RESULT_NO_OFFLINE)

	</query>

	<query id="frmEntrust.BatchDeleteEntrustPortVrp" desc="批量插入分切管">


		DELETE FROM PORT_VRP_BATCH_SAMPLE_RESULT
		WHERE MAT_NO IN
		(SELECT MAT_NO
		FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE = ?)
		AND (RESULT_NO = ? OR
		RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM VRP_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM VRP_OFFLINE_RESULT
		WHERE RESULT_NO = ?)))

	</query>

	<query id="frmEntrust.BatchDeleteEntrustCutPortVrp" desc="批量插入分切管">
		DELETE
		FROM PORT_VRP_BATCH_SAMPLE_RESULT
		WHERE  MAT_NO IN (SELECT MAT_NO_CUT  FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
		AND (RESULT_NO = ? OR
		RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM VRP_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM VRP_OFFLINE_RESULT
		WHERE RESULT_NO = ?)))
	</query>

	<query id="frmEntrust.BatchInsertEntrustCutPortMch">

		INSERT INTO PORT_MCH_BATCH_SAMPLE_RESULT
		(HEAT_PLAN_NO,
		MAT_NO,
		M_MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PRO_PLAN_ID,
		GX_PLAN_NO,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		OUTNUM_CUT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		PRC_TECHNOLOGY_PATH,
		VM_INSTORE_FLAG,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		VALIDFLAG,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		TR_FLAG,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		FEED_HEAT_NO,
		BAR_CODE,
		RESULT_NO,
		MEASURING_SEQ,
		HEAT_PLAN_SQE,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		SAMPLE_PIPE_LEN_C,
		SAMPLE_PIPE_LEN_D,
		SAMPLE_PIPE_LEN_E,
		SAMPLE_PIPE_LEN_F,
		SAMPLE_PIPE_LEN_P,
		SAMPLE_PIPE_LEN_Q,
		SAMPLE_PIPE_LEN_M,
		PHY_CODE_GROUPC,
		PHY_CODE_GROUPD,
		PHY_CODE_GROUPE,
		PHY_CODE_GROUPF,
		PHY_CODE_GROUPP,
		PHY_CODE_GROUPQ,
		PHY_CODE_GROUPM,
		CRAFT_SOURCE,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		RESAMPLE_PIPE_LEN_C,
		RESAMPLE_PIPE_LEN_D,
		RESAMPLE_PIPE_LEN_E,
		RESAMPLE_PIPE_LEN_F,
		RESAMPLE_PIPE_LEN_P,
		RESAMPLE_PIPE_LEN_Q,
		RESAMPLE_PIPE_LEN_M,
		RE_CHECK_NO,
		IS_BATCH,
		CHECK_NO,
		MAT_NO_OLD,
		IS_FINALCHECK,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		JUGDE_APPLY_SEQUENO)
		SELECT HEAT_PLAN_NO,
		T.MAT_NO_CUT,
		M.MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PRO_PLAN_ID,
		GX_PLAN_NO,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		1 OUTNUM_CUT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_LEN-  (T.CUT_NUM-1) * ROUND(ACT_LEN/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_LEN/T.CUT_NUM ,3)
		END ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		END ACT_WEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_THEORY_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		END ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		DECODE(T.MAT_STATUS,1,'40','20') MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		PRC_TECHNOLOGY_PATH,
		VM_INSTORE_FLAG,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		VALIDFLAG,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		TR_FLAG,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		FEED_HEAT_NO,
		BAR_CODE,
		M.RESULT_NO,
		MEASURING_SEQ,
		HEAT_PLAN_SQE,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		SAMPLE_PIPE_LEN_C,
		SAMPLE_PIPE_LEN_D,
		SAMPLE_PIPE_LEN_E,
		SAMPLE_PIPE_LEN_F,
		SAMPLE_PIPE_LEN_P,
		SAMPLE_PIPE_LEN_Q,
		SAMPLE_PIPE_LEN_M,
		PHY_CODE_GROUPC,
		PHY_CODE_GROUPD,
		PHY_CODE_GROUPE,
		PHY_CODE_GROUPF,
		PHY_CODE_GROUPP,
		PHY_CODE_GROUPQ,
		PHY_CODE_GROUPM,
		CRAFT_SOURCE,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		RESAMPLE_PIPE_LEN_C,
		RESAMPLE_PIPE_LEN_D,
		RESAMPLE_PIPE_LEN_E,
		RESAMPLE_PIPE_LEN_F,
		RESAMPLE_PIPE_LEN_P,
		RESAMPLE_PIPE_LEN_Q,
		RESAMPLE_PIPE_LEN_M,
		RE_CHECK_NO,
		IS_BATCH,
		CHECK_NO,
		MAT_NO_OLD,
		IS_FINALCHECK,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		JUGDE_APPLY_SEQUENO
		FROM PORT_MCH_BATCH_SAMPLE_RESULT M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO
		--AND M.RESULT_NO = T.RESULT_NO_OFFLINE
		AND T.RESULT_NO_OFFLINE =?
        AND (M.RESULT_NO IN
        (SELECT LX_RESULT_NO
        FROM MCH_GROUP_RESULT
        WHERE GROUP_ID IN
        (SELECT GROUP_ID
        FROM MCH_OFFLINE_RESULT
        WHERE RESULT_NO = T.RESULT_NO_OFFLINE)) OR
        M.RESULT_NO = T.RESULT_NO_OFFLINE)
	</query>
	<query id="frmEntrust.BatchInsertEntrustPortMch">
		UPDATE  PORT_MCH_BATCH_SAMPLE_RESULT  SET VALIDFLAG ='1'
		WHERE MAT_NO IN (SELECT MAT_NO FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
        AND (RESULT_NO = ? OR
        RESULT_NO IN
        (SELECT LX_RESULT_NO
        FROM MCH_GROUP_RESULT
        WHERE GROUP_ID IN
        (SELECT GROUP_ID
        FROM MCH_OFFLINE_RESULT
        WHERE RESULT_NO = ?)))
	</query>
	<query id= "frmEntrust.BatchDeleteEntrustPortMch">
		UPDATE  PORT_MCH_BATCH_SAMPLE_RESULT  SET VALIDFLAG ='0'
		WHERE MAT_NO IN (SELECT MAT_NO FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
		AND (RESULT_NO = ? OR
		RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM MCH_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM MCH_OFFLINE_RESULT
		WHERE RESULT_NO = ?)))
	</query>
	<query id="frmEntrust.BatchDeleteEntrustCutPortMch">
		DELETE
		FROM PORT_MCH_BATCH_SAMPLE_RESULT
		WHERE MAT_NO IN (SELECT MAT_NO_CUT  FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
		AND (RESULT_NO = ? OR
		RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM MCH_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM MCH_OFFLINE_RESULT
		WHERE RESULT_NO = ?)))
	</query>


	<query id="frmEntrust.BatchInsertEntrustCutPortHtt">
		INSERT INTO PORT_HTT_BATCH_SAMPLE_RESULT
		(HEAT_PLAN_NO,
		MAT_NO,
		M_MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		VM_INSTORE_FLAG,
		PRC_TECHNOLOGY_PATH,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		HEAT_PLAN_SQE,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		TR_FLAG,
		FEED_HEAT_NO,
		PROCESS_SEQ,
		RESULT_NO,
		IS_BATCH,
		SAMPLE_PIPE_LEN_C,
		SAMPLE_PIPE_LEN_D,
		PHY_CODE_GROUPC,
		PHY_CODE_GROUPD,
		CHECK_NO,
		SAMPLE_PIPE_LEN_M,
		PHY_CODE_GROUPM,
		MAT_NO_OLD,
		SAMPLE_PIPE_LEN_E,
		PHY_CODE_GROUPE,
		SAMPLE_PIPE_LEN_F,
		PHY_CODE_GROUPF,
		SAMPLE_PIPE_LEN_P,
		PHY_CODE_GROUPP,
		SAMPLE_PIPE_LEN_Q,
		PHY_CODE_GROUPQ,
		CRAFT_SOURCE,
		BAR_CODE,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		RESAMPLE_PIPE_LEN_C,
		RESAMPLE_PIPE_LEN_D,
		RESAMPLE_PIPE_LEN_E,
		RESAMPLE_PIPE_LEN_F,
		RESAMPLE_PIPE_LEN_P,
		RESAMPLE_PIPE_LEN_Q,
		RESAMPLE_PIPE_LEN_M,
		RE_CHECK_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		JUGDE_APPLY_SEQUENO)
		SELECT HEAT_PLAN_NO,
		T.MAT_NO_CUT MAT_NO,
		M.MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_LEN-  (T.CUT_NUM-1) * ROUND(ACT_LEN/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_LEN/T.CUT_NUM ,3)
		END ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		END ACT_WEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_THEORY_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		END ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		DECODE(T.MAT_STATUS,1,'40','20') MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		VM_INSTORE_FLAG,
		PRC_TECHNOLOGY_PATH,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		HEAT_PLAN_SQE,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		TR_FLAG,
		FEED_HEAT_NO,
		PROCESS_SEQ,
		M.RESULT_NO,
		IS_BATCH,
		SAMPLE_PIPE_LEN_C,
		SAMPLE_PIPE_LEN_D,
		PHY_CODE_GROUPC,
		PHY_CODE_GROUPD,
		CHECK_NO,
		SAMPLE_PIPE_LEN_M,
		PHY_CODE_GROUPM,
		MAT_NO_OLD,
		SAMPLE_PIPE_LEN_E,
		PHY_CODE_GROUPE,
		SAMPLE_PIPE_LEN_F,
		PHY_CODE_GROUPF,
		SAMPLE_PIPE_LEN_P,
		PHY_CODE_GROUPP,
		SAMPLE_PIPE_LEN_Q,
		PHY_CODE_GROUPQ,
		CRAFT_SOURCE,
		BAR_CODE,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		RESAMPLE_PIPE_LEN_C,
		RESAMPLE_PIPE_LEN_D,
		RESAMPLE_PIPE_LEN_E,
		RESAMPLE_PIPE_LEN_F,
		RESAMPLE_PIPE_LEN_P,
		RESAMPLE_PIPE_LEN_Q,
		RESAMPLE_PIPE_LEN_M,
		RE_CHECK_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		JUGDE_APPLY_SEQUENO
		FROM PORT_HTT_BATCH_SAMPLE_RESULT M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO
		--AND M.RESULT_NO = T.RESULT_NO_OFFLINE
		AND T.RESULT_NO_OFFLINE =?
		AND (M.RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM HTT_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM HTT_OFFLINE_RESULT
		WHERE RESULT_NO = T.RESULT_NO_OFFLINE)) OR
		M.RESULT_NO = T.RESULT_NO_OFFLINE)

	</query>
	<query id="frmEntrust.BatchInsertEntrustPortHtt">


		INSERT INTO PORT_HTT_BATCH_SAMPLE_RESULT
		(HEAT_PLAN_NO,
		MAT_NO,
		M_MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		VM_INSTORE_FLAG,
		PRC_TECHNOLOGY_PATH,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		HEAT_PLAN_SQE,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		TR_FLAG,
		FEED_HEAT_NO,
		PROCESS_SEQ,
		RESULT_NO,
		IS_BATCH,
		SAMPLE_PIPE_LEN_C,
		SAMPLE_PIPE_LEN_D,
		PHY_CODE_GROUPC,
		PHY_CODE_GROUPD,
		CHECK_NO,
		SAMPLE_PIPE_LEN_M,
		PHY_CODE_GROUPM,
		MAT_NO_OLD,
		SAMPLE_PIPE_LEN_E,
		PHY_CODE_GROUPE,
		SAMPLE_PIPE_LEN_F,
		PHY_CODE_GROUPF,
		SAMPLE_PIPE_LEN_P,
		PHY_CODE_GROUPP,
		SAMPLE_PIPE_LEN_Q,
		PHY_CODE_GROUPQ,
		CRAFT_SOURCE,
		BAR_CODE,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		RESAMPLE_PIPE_LEN_C,
		RESAMPLE_PIPE_LEN_D,
		RESAMPLE_PIPE_LEN_E,
		RESAMPLE_PIPE_LEN_F,
		RESAMPLE_PIPE_LEN_P,
		RESAMPLE_PIPE_LEN_Q,
		RESAMPLE_PIPE_LEN_M,
		RE_CHECK_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		JUGDE_APPLY_SEQUENO)
		SELECT HEAT_PLAN_NO,
		T.MAT_NO,
		M_MAT_NO,
		M_M_MAT_NO,
		LOT_NO,
		LOT_NO_SQE,
		PLINE_CODE,
		PLINE_NAME,
		JUDGE_STOVE_NO,
		BATCH_NO,
		GROUP_NO,
		STOVE_NO,
		FLAG_STOVE_NO,
		ACT_DIMATER,
		ACT_HEIGHT,
		(SELECT SUM(ACT_LEN) FROM PORT_HTT_BATCH_SAMPLE_RESULT A, HTT_ENTRUST_MAT_NO B
		WHERE A.HEAT_PLAN_NO = M.HEAT_PLAN_NO
		AND A.MAT_NO = B.MAT_NO_CUT
		AND A.RESULT_NO = B.RESULT_NO_OFFLINE
		AND B.MAT_NO = T.MAT_NO),
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		(SELECT SUM(ACT_WEIGHT) FROM PORT_HTT_BATCH_SAMPLE_RESULT A, HTT_ENTRUST_MAT_NO B
		WHERE A.HEAT_PLAN_NO = M.HEAT_PLAN_NO
		AND A.MAT_NO = B.MAT_NO_CUT
		AND A.RESULT_NO = B.RESULT_NO_OFFLINE
		AND B.MAT_NO = T.MAT_NO),
		(SELECT SUM(ACT_WEIGHT) FROM PORT_HTT_BATCH_SAMPLE_RESULT A, HTT_ENTRUST_MAT_NO B
		WHERE A.HEAT_PLAN_NO = M.HEAT_PLAN_NO
		AND A.MAT_NO = B.MAT_NO_CUT
		AND A.RESULT_NO = B.RESULT_NO_OFFLINE
		AND B.MAT_NO = T.MAT_NO),
		IS_SAMPLE_PIPE,
		SAMPLE_PIPE_LEN,
		GET_SAMPLE_SHIFT,
		GET_SAMPLE_CLASS,
		GET_SAMPLE_NAME,
		GET_SAMPLE_TIME,
		OLD_JUDGE_STOVE_NO,
		GROUP_FLAG,
		OP_PROCESS,
		'20' MAT_STATUS,
		LEVE_LOG,
		INSTORE_FLAG,
		VM_INSTORE_FLAG,
		PRC_TECHNOLOGY_PATH,
		RETURN_PROCESS,
		PHY_BATCH_NO,
		PRO_YEAR_MONTH_DAY,
		BAL_YEAR_MONTH,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY,
		PRO_USER,
		PRO_SHIFT,
		PRO_GROUP,
		PRO_TIME,
		REMARK,
		SAMPLE_PIPE_LEN_A,
		SAMPLE_PIPE_LEN_B,
		CHEM_RESULT_CODE,
		PHY_RESULT_CODE,
		HEAT_PLAN_SQE,
		PHY_CODE_GROUP,
		PHY_CODE_GROUPB,
		TR_FLAG,
		FEED_HEAT_NO,
		PROCESS_SEQ,
		M.RESULT_NO,
		IS_BATCH,
		SAMPLE_PIPE_LEN_C,
		SAMPLE_PIPE_LEN_D,
		PHY_CODE_GROUPC,
		PHY_CODE_GROUPD,
		CHECK_NO,
		SAMPLE_PIPE_LEN_M,
		PHY_CODE_GROUPM,
		MAT_NO_OLD,
		SAMPLE_PIPE_LEN_E,
		PHY_CODE_GROUPE,
		SAMPLE_PIPE_LEN_F,
		PHY_CODE_GROUPF,
		SAMPLE_PIPE_LEN_P,
		PHY_CODE_GROUPP,
		SAMPLE_PIPE_LEN_Q,
		PHY_CODE_GROUPQ,
		CRAFT_SOURCE,
		BAR_CODE,
		RE_GET_SAMPLE_NAME,
		RE_GET_SAMPLE_TIME,
		RE_GET_SAMPLE_STATUS,
		RESAMPLE_PIPE_LEN_A,
		RESAMPLE_PIPE_LEN_B,
		RESAMPLE_PIPE_LEN_C,
		RESAMPLE_PIPE_LEN_D,
		RESAMPLE_PIPE_LEN_E,
		RESAMPLE_PIPE_LEN_F,
		RESAMPLE_PIPE_LEN_P,
		RESAMPLE_PIPE_LEN_Q,
		RESAMPLE_PIPE_LEN_M,
		RE_CHECK_NO,
		IS_FAIL_CHECK,
		BAL_YEAR_MONTH_FAIL,
		JUGDE_APPLY_SEQUENO
		FROM PORT_HTT_BATCH_SAMPLE_RESULT M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO_CUT
	--	AND M.RESULT_NO = T.RESULT_NO_OFFLINE
		AND T.MAT_NO_CUT LIKE '%01'
		AND T.RESULT_NO_OFFLINE =?
		AND (M.RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM HTT_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM HTT_OFFLINE_RESULT
		WHERE RESULT_NO = T.RESULT_NO_OFFLINE)) OR
		M.RESULT_NO = T.RESULT_NO_OFFLINE)

	</query>
	<query id= "frmEntrust.BatchDeleteEntrustPortHtt">
		DELETE FROM  PORT_HTT_BATCH_SAMPLE_RESULT
		WHERE MAT_NO IN (SELECT MAT_NO FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
		AND (RESULT_NO = ? OR
		RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM MCH_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM MCH_OFFLINE_RESULT
		WHERE RESULT_NO = ?)))
	</query>
	<query id="frmEntrust.BatchDeleteEntrustCutPortHtt">
		DELETE
		FROM PORT_HTT_BATCH_SAMPLE_RESULT
		WHERE  MAT_NO IN (SELECT MAT_NO_CUT  FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
		AND (RESULT_NO = ? OR
		RESULT_NO IN
		(SELECT LX_RESULT_NO
		FROM MCH_GROUP_RESULT
		WHERE GROUP_ID IN
		(SELECT GROUP_ID
		FROM MCH_OFFLINE_RESULT
		WHERE RESULT_NO = ?)))
	</query>

	<query id="frmEntrust.BatchInsertEntrustCutMat" desc="批量插入分切管">
		INSERT INTO MAT_BC_M
		(MAT_NO,
		PRODUCT_FLAG,
		MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		SAMPLE_FLAG,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_ID,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		MAT_RETURN_FLAG,
		LOCK_FLAG,
		MNG_LOCK_FLAG,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_RESULT_CODE,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		BAR_CODE,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		PIPMEMO,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		JUDGE_ID,
		LOCK_LIKU,
		QCM_STAUS,
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		JUDGE_STOVE_NO_UP,
		CRAFT_SEQ,
		PRO_PLAN_ID_NEXT,
		GX_PLAN_NO_NEXT,
		HANGING_FLAG,
		CUT_NUM,
		JUDGE_TOLRESULT_CODE,
		JUDGE_TOLRESULT,
		JUDGE_TOLRESULT_TIME,
		JUDGE_TOLMAKER,
		INSTANCY_FLAG,
		JUGDE_TOLCONVICTED,
		JUDGE_STD_DES,
		MNG_LOCK_REMARK,
		LOCK_REMARK,
		JUGDE_APPLY_SEQUENO,
		HEAT_PLAN_NO_NEXT,
		CODE_JG_BL,
		CIC,
		SCRAP_REASON,
		BELONG_CODE_RESPONSE,
		BELONG_NAME_RESPONSE,
		ZBS_FLAG,
		SCRAP_TYPE,
		ZBS_ID,
		HEAT_PLAN_NO_OLD,
		MEASURING_SEQ,
		SCRAP_FLAG,
		LIKU_PROCESS_CODE,
		JG_ZBS_ID,
		FAIL_APPROVAL_CODE,
		OFFLINE_DOC,
		SUBCONTRACT_NO,
		SCRAP_FRIM_FLAG,
		ZZB_FLAG,
		BAL_YEAR_MONTH_FAIL,
		SUBCONTRACT_NO_SEQ,
		SCRAP_NAME,
		SCRAP_TIME)
		SELECT T.MAT_NO_CUT,
		PRODUCT_FLAG,
		M.MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		SAMPLE_FLAG,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_ID,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		ACT_DIMATER,
		ACT_HEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_LEN-  (T.CUT_NUM-1) * ROUND(ACT_LEN/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_LEN/T.CUT_NUM ,3)
		END ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		END ACT_WEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_THEORY_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		END ACT_THEORY_WEIGHT,
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		MAT_RETURN_FLAG,
		LOCK_FLAG,
		MNG_LOCK_FLAG,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_RESULT_CODE,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		BAR_CODE,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		PIPMEMO,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		JUDGE_ID,
		LOCK_LIKU,
		DECODE(T.MAT_STATUS,'0', ?,'22') QCM_STAUS,
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		JUDGE_STOVE_NO_UP,
		CRAFT_SEQ,
		PRO_PLAN_ID_NEXT,
		GX_PLAN_NO_NEXT,
		HANGING_FLAG,
		M.CUT_NUM,
		JUDGE_TOLRESULT_CODE,
		JUDGE_TOLRESULT,
		JUDGE_TOLRESULT_TIME,
		JUDGE_TOLMAKER,
		INSTANCY_FLAG,
		JUGDE_TOLCONVICTED,
		JUDGE_STD_DES,
		MNG_LOCK_REMARK,
		LOCK_REMARK,
		JUGDE_APPLY_SEQUENO,
		HEAT_PLAN_NO_NEXT,
		CODE_JG_BL,
		CIC,
		SCRAP_REASON,
		BELONG_CODE_RESPONSE,
		BELONG_NAME_RESPONSE,
		ZBS_FLAG,
		SCRAP_TYPE,
		ZBS_ID,
		HEAT_PLAN_NO_OLD,
		MEASURING_SEQ,
		SCRAP_FLAG,
		LIKU_PROCESS_CODE,
		JG_ZBS_ID,
		FAIL_APPROVAL_CODE,
		OFFLINE_DOC,
		M.SUBCONTRACT_NO,
		SCRAP_FRIM_FLAG,
		ZZB_FLAG,
		BAL_YEAR_MONTH_FAIL,
		M.SUBCONTRACT_NO_SEQ,
		SCRAP_NAME,
		SCRAP_TIME
		FROM MAT_BC_M M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO
		AND T.RESULT_NO_OFFLINE = ?
	</query>

	<insert id="frmEntrust.BatchInsertEntrustMat">
		INSERT INTO MAT_BC_M
		(MAT_NO,
		PRODUCT_FLAG,
		MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		SAMPLE_FLAG,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_ID,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		MAT_RETURN_FLAG,
		LOCK_FLAG,
		MNG_LOCK_FLAG,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_RESULT_CODE,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		BAR_CODE,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		PIPMEMO,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		JUDGE_ID,
		LOCK_LIKU,
		QCM_STAUS,
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		JUDGE_STOVE_NO_UP,
		CRAFT_SEQ,
		PRO_PLAN_ID_NEXT,
		GX_PLAN_NO_NEXT,
		HANGING_FLAG,
		CUT_NUM,
		JUDGE_TOLRESULT_CODE,
		JUDGE_TOLRESULT,
		JUDGE_TOLRESULT_TIME,
		JUDGE_TOLMAKER,
		INSTANCY_FLAG,
		JUGDE_TOLCONVICTED,
		JUDGE_STD_DES,
		MNG_LOCK_REMARK,
		LOCK_REMARK,
		JUGDE_APPLY_SEQUENO,
		HEAT_PLAN_NO_NEXT,
		CODE_JG_BL,
		CIC,
		SCRAP_REASON,
		BELONG_CODE_RESPONSE,
		BELONG_NAME_RESPONSE,
		ZBS_FLAG,
		SCRAP_TYPE,
		ZBS_ID,
		HEAT_PLAN_NO_OLD,
		MEASURING_SEQ,
		SCRAP_FLAG,
		LIKU_PROCESS_CODE,
		JG_ZBS_ID,
		FAIL_APPROVAL_CODE,
		OFFLINE_DOC,
		SUBCONTRACT_NO,
		SCRAP_FRIM_FLAG,
		ZZB_FLAG,
		BAL_YEAR_MONTH_FAIL,
		SUBCONTRACT_NO_SEQ,
		SCRAP_NAME,
		SCRAP_TIME)
		SELECT T.MAT_NO,
		PRODUCT_FLAG,
		M.MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		SAMPLE_FLAG,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_ID,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		ACT_DIMATER,
		ACT_HEIGHT,
		(SELECT SUM(ACT_LEN) FROM MAT_BC_M A, HTT_ENTRUST_MAT_NO B
		WHERE  A.MAT_NO = B.MAT_NO_CUT
		AND B.MAT_NO_CUT = T.MAT_NO),
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		(SELECT SUM(ACT_WEIGHT) FROM MAT_BC_M A, HTT_ENTRUST_MAT_NO B
		WHERE  A.MAT_NO = B.MAT_NO_CUT
		AND B.MAT_NO_CUT = T.MAT_NO),
		(SELECT SUM(ACT_THEORY_WEIGHT) FROM MAT_BC_M A, HTT_ENTRUST_MAT_NO B
		WHERE  A.MAT_NO = B.MAT_NO_CUT
		AND B.MAT_NO_CUT = T.MAT_NO),
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		MAT_RETURN_FLAG,
		LOCK_FLAG,
		MNG_LOCK_FLAG,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_RESULT_CODE,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		BAR_CODE,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		PIPMEMO,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		JUDGE_ID,
		LOCK_LIKU,
		? QCM_STAUS,
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		JUDGE_STOVE_NO_UP,
		CRAFT_SEQ,
		PRO_PLAN_ID_NEXT,
		GX_PLAN_NO_NEXT,
		HANGING_FLAG,
		M.CUT_NUM,
		JUDGE_TOLRESULT_CODE,
		JUDGE_TOLRESULT,
		JUDGE_TOLRESULT_TIME,
		JUDGE_TOLMAKER,
		INSTANCY_FLAG,
		JUGDE_TOLCONVICTED,
		JUDGE_STD_DES,
		MNG_LOCK_REMARK,
		LOCK_REMARK,
		JUGDE_APPLY_SEQUENO,
		HEAT_PLAN_NO_NEXT,
		CODE_JG_BL,
		CIC,
		SCRAP_REASON,
		BELONG_CODE_RESPONSE,
		BELONG_NAME_RESPONSE,
		ZBS_FLAG,
		SCRAP_TYPE,
		ZBS_ID,
		HEAT_PLAN_NO_OLD,
		MEASURING_SEQ,
		SCRAP_FLAG,
		LIKU_PROCESS_CODE,
		JG_ZBS_ID,
		FAIL_APPROVAL_CODE,
		OFFLINE_DOC,
		M.SUBCONTRACT_NO,
		SCRAP_FRIM_FLAG,
		ZZB_FLAG,
		BAL_YEAR_MONTH_FAIL,
		M.SUBCONTRACT_NO_SEQ,
		SCRAP_NAME,
		SCRAP_TIME
		FROM MAT_BC_M M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO_CUT
		AND T.MAT_NO_CUT LIKE '%01'
		AND T.RESULT_NO_OFFLINE =?
	</insert>

	<query id="frmEntrust.BatchInsertEntrustCutBut">
		INSERT INTO YDM_BC_BUTTRESS
		(MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC,
		PLINE_CODE)
		SELECT t.mat_no_cut MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC,
		PLINE_CODE
		FROM YDM_BC_BUTTRESS M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO
		AND T.RESULT_NO_OFFLINE = ?
		AND M.STORAGE_NO IS NOT NULL
	</query>

	<query id="frmEntrust.BatchInsertEntrustBut">
		INSERT INTO YDM_BC_BUTTRESS
		(MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC,
		PLINE_CODE)
		SELECT t.MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC,
		PLINE_CODE
		FROM YDM_BC_BUTTRESS M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO_CUT
		AND T.RESULT_NO_OFFLINE =?
		AND T.MAT_NO_CUT LIKE '%01'
		AND M.STORAGE_NO IS NOT NULL
	</query>

	<query id="frmEntrust.BatchDeleteEntrustMat">
	DELETE
	FROM MAT_BC_M
	WHERE MAT_NO IN (SELECT MAT_NO FROM HTT_ENTRUST_MAT_NO
	WHERE RESULT_NO_OFFLINE =?)
</query>

	<query id="frmEntrust.BatchDeleteEntrustCutMat">
		DELETE
		FROM MAT_BC_M
		WHERE MAT_NO IN (SELECT MAT_NO_CUT FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
	</query>

	<query id="frmEntrust.BatchDeleteEntrustBut">
		DELETE
		FROM YDM_BC_BUTTRESS
		WHERE MAT_NO IN (SELECT MAT_NO FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
	</query>

	<query id="frmEntrust.BatchDeleteEntrustCutBut">
		DELETE
		FROM YDM_BC_BUTTRESS
		WHERE MAT_NO IN (SELECT MAT_NO_CUT FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
	</query>



	<query id="frmEntrust.BatchInsertEntrustCutZcMat">
		INSERT INTO MAT_ZC_M
		(MAT_NO,
		PRODUCT_FLAG,
		MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		MAT_SQE_NO,
		SAMPLE_FLAG,
		CUTTING_FLAG,
		ORIGIN_MAT_NO,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		INPUT_ORIGIN_CODE,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_NO1,
		PRO_ORDER_ID,
		PRO_ORDER_ID1,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		DIMATER,
		HEIGHT,
		LEN_NO,
		LEN_DESC,
		LEN_UNIT,
		LEN_MIN,
		LEN_MAX,
		TARG_DIMATER,
		TARG_HEIGHT,
		TARG_LEN_MIN,
		TARG_LEN_MAX,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		PACK_TYPE_CODE,
		PACK_TYPE_NAME,
		PACK_NO,
		PACK_TIME,
		PACK_MAT_WT,
		MAT_GROSS_WT,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		COOL_HOT_FLAG,
		MAT_RETURN_FLAG,
		HEAT_TREAT_NO,
		POST_FLAG,
		LOCK_FLAG,
		MNG_LOCK_RSN_CODE,
		MNG_LOCK_TIME,
		MNG_LOCK_MAKER,
		MNG_LOCK_REMARK,
		LOCK_RSN_CODE,
		LOCK_TIME,
		LOCK_MAKER,
		LOCK_REMARK,
		UNLOCK_TIME,
		UNLOCK_MAKER,
		UNLOCK_REMARK,
		OLD_ORDER_NO,
		OLD_ORDER_SEQ,
		OLD_ORDER_SEQ_NO,
		OLD_MATERIAL_NO,
		OLD_MATERIAL_NAME,
		REMAIN_RSN_CODE,
		REMAIN_JUGDE_TIME,
		REMAIN_JUGDE_MAKER,
		REMAIN_JUGDE_CODE,
		REMAIN_REMARK,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		JUGDE_SCAN_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_REPORT_NO,
		DETECT_RESULT_CODE,
		WPRESSURE_REPORT_NO,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		BUG_NO,
		BUG_DEAL,
		REPAIR_FLAG,
		REPAIR_REMARK,
		SAMPLING_FLAG,
		SAMPLING_TYPE,
		SAMPLING_NO,
		CHECKOUT_NO,
		CHEM_STCHECK_NO,
		CHEM_PROCHECK_NO,
		SH_CHECK_NO,
		COME_PROC_FLAG,
		CONFM_FLAG,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		OUTSTOCK_TIME,
		PRO_BC,
		PRO_BZ,
		RPO_TIME,
		BAR_CODE,
		BEGINNING_FLAG,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		REQ_BL_ID,
		IF_BATCHED_JG,
		COUPCUT_BATCH_ID,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		OLD_ORD_PK,
		OLD_ORD_LN_PK,
		OLD_ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		JUDGE_STD_CODE,
		JUDGE_GRADE,
		PIPMEMO,
		TEST,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		MEMO1,
		JUDGE_ID,
		MNG_LOCK_FLAG,
		LOCK_ID,
		PRO_NO,
		LOCK_LIKU,
		PLN_GRADECODE,
		PLN_GRADENAME,
		PLN_STEELCODE,
		PLN_STEELNAME,
		QCM_STAUS,
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		FINISHPRO_MOLD,
		IN_MOLD,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		GX_PLAN_NO1,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		ZG_PHY_RESULT_PATH,
		ZG_FACE_RESULT_PATH,
		ZG_SPEC_RESULT_PATH,
		VRP_HEAT_PLAN_NO,
		VRP_LOT_NO,
		VRP_SAMPLE_FLAG,
		VRP_PRO_ORDER_NO,
		VRP_PRO_ORDER_NO1,
		VRP_PRO_ORDER_ID,
		VRP_PRO_ORDER_ID1,
		VRP_ACT_DIMATER,
		VRP_ACT_HEIGHT,
		VRP_JUGDE_APPLY_FLAG,
		VRP_JUGDE_APPLY_CODE,
		VRP_JUGDE_APPLY_TIME,
		VRP_FACE_RESULT_CODE,
		VRP_FACE_RESULT_TIME,
		VRP_FACE_MAKER,
		VRP_FACE_RESULT_PATH,
		VRP_SPEC_RESULT_CODE,
		VRP_SPEC_RESULT_TIME,
		VRP_SPEC_MAKER,
		VRP_SPEC_RESULT_PATH,
		VRP_PHY_RESULT_CODE,
		VRP_PHY_RESULT_TIME,
		VRP_PHY_MAKER,
		VRP_PHY_RESULT_PATH,
		VRP_JUDGE_RESULT_CODE,
		VRP_JUDGE_RESULT_TIME,
		VRP_JUDGE_MAKER,
		VRP_GX_PLAN_NO,
		VRP_GX_PLAN_NO1,
		VPR_JUGDE_CONVICTED,
		VPR_QUALITY_GROUP_ZG,
		VPR_FLAG_STOVE_NO_ZG,
		HTT_HEAT_PLAN_NO,
		HTT_LOT_NO,
		HTT_SAMPLE_FLAG,
		HTT_PRO_ORDER_NO,
		HTT_PRO_ORDER_NO1,
		HTT_PRO_ORDER_ID,
		HTT_PRO_ORDER_ID1,
		HTT_GX_PLAN_NO,
		HTT_GX_PLAN_NO1,
		HTT_JUGDE_APPLY_FLAG,
		HTT_JUGDE_APPLY_CODE,
		HTT_JUGDE_APPLY_TIME,
		HTT_FACE_RESULT_CODE,
		HTT_FACE_RESULT_TIME,
		HTT_FACE_MAKER,
		HTT_FACE_RESULT_PATH,
		HTT_SPEC_RESULT_CODE,
		HTT_SPEC_RESULT_TIME,
		HTT_SPEC_MAKER,
		HTT_SPEC_RESULT_PATH,
		HTT_PHY_RESULT_CODE,
		HTT_PHY_RESULT_TIME,
		HTT_PHY_MAKER,
		HTT_PHY_RESULT_PATH,
		HTT_JUDGE_RESULT_CODE,
		HTT_JUDGE_RESULT_TIME,
		HTT_JUDGE_MAKER,
		HTT_JUGDE_CONVICTED,
		HTT_QUALITY_GROUP_ZG,
		HTT_FLAG_STOVE_NO_ZG,
		PRC_LOT_NO,
		PRC_SAMPLE_FLAG,
		PRC_PRO_ORDER_NO,
		PRC_PRO_ORDER_NO1,
		PRC_PRO_ORDER_ID,
		PRC_PRO_ORDER_ID1,
		PRC_GX_PLAN_NO,
		PRC_GX_PLAN_NO1,
		PRC_JUGDE_APPLY_FLAG,
		PRC_JUGDE_APPLY_CODE,
		PRC_JUGDE_APPLY_TIME,
		PRC_FACE_RESULT_CODE,
		PRC_FACE_RESULT_TIME,
		PRC_FACE_MAKER,
		PRC_FACE_RESULT_PATH,
		PRC_SPEC_RESULT_CODE,
		PRC_SPEC_RESULT_TIME,
		PRC_SPEC_MAKER,
		PRC_SPEC_RESULT_PATH,
		PRC_PHY_RESULT_CODE,
		PRC_PHY_RESULT_TIME,
		PRC_PHY_MAKER,
		PRC_PHY_RESULT_PATH,
		PRC_JUDGE_RESULT_CODE,
		PRC_JUDGE_RESULT_TIME,
		PRC_JUDGE_MAKER,
		PRC_JUGDE_CONVICTED,
		PRC_QUALITY_GROUP_ZG,
		PRC_FLAG_STOVE_NO_ZG,
		PRC_HEAT_PLAN_NO,
		VRP_JUDGE_STD_NAME,
		VRP_JUDGE_STD_CODE,
		HTT_JUDGE_STD_NAME,
		HTT_JUDGE_STD_CODE,
		PRC_JUDGE_STD_NAME,
		PRC_JUDGE_STD_CODE,
		VRP_CRAF_NO,
		HTT_CRAF_NO,
		PRC_CRAF_NO,
		VRP_CHEM_RESULT_CODE,
		VRP_CHEM_RESULT_TIME,
		VRP_CHEM_MAKER,
		HTT_CHEM_RESULT_CODE,
		HTT_CHEM_RESULT_TIME,
		HTT_CHEM_MAKER,
		PRC_CHEM_RESULT_CODE,
		PRC_CHEM_RESULT_TIME,
		PRC_CHEM_MAKER,
		DETECT_REPORT_NO1,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		ZG_PLINE_CODE,
		ZG_PLINE_NAME,
		VRP_PLINE_CODE,
		VRP_PLINE_NAME,
		HTT_PLINE_CODE,
		HTT_PLINE_NAME,
		PRC_PLINE_CODE,
		PRC_PLINE_NAME,
		VRP_QCM_STAUS,
		HTT_QCM_STAUS,
		PRC_QCM_STAUS,
		ZG_MEMO,
		ZBS_FLAG,
		ZBS_ID,
		MEASURING_SEQ,
		INSTOCK_DOC,
		JG_ZBS_ID,
		CHANGE_DOC,
		SUBCONTRACT_NO,
		SUBCONTRACT_NO_SEQ,
		LOCK_BILL_FLAG)
		SELECT T.MAT_NO_CUT,
		PRODUCT_FLAG,
		M.MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		MAT_SQE_NO,
		SAMPLE_FLAG,
		CUTTING_FLAG,
		ORIGIN_MAT_NO,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		INPUT_ORIGIN_CODE,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_NO1,
		PRO_ORDER_ID,
		PRO_ORDER_ID1,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		DIMATER,
		HEIGHT,
		LEN_NO,
		LEN_DESC,
		LEN_UNIT,
		LEN_MIN,
		LEN_MAX,
		TARG_DIMATER,
		TARG_HEIGHT,
		TARG_LEN_MIN,
		TARG_LEN_MAX,
		ACT_DIMATER,
		ACT_HEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_LEN-  (T.CUT_NUM-1) * ROUND(ACT_LEN/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_LEN/T.CUT_NUM ,3)
		END ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_WEIGHT/T.CUT_NUM ,3)
		END ACT_WEIGHT,
		CASE WHEN T.MAT_NO_CUT LIKE '%01' THEN
		ACT_THEORY_WEIGHT-  (T.CUT_NUM-1) * ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		ELSE
		ROUND(ACT_THEORY_WEIGHT/T.CUT_NUM ,3)
		END ACT_THEORY_WEIGHT,
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		PACK_TYPE_CODE,
		PACK_TYPE_NAME,
		PACK_NO,
		PACK_TIME,
		PACK_MAT_WT,
		MAT_GROSS_WT,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		COOL_HOT_FLAG,
		MAT_RETURN_FLAG,
		HEAT_TREAT_NO,
		POST_FLAG,
		LOCK_FLAG,
		MNG_LOCK_RSN_CODE,
		MNG_LOCK_TIME,
		MNG_LOCK_MAKER,
		MNG_LOCK_REMARK,
		LOCK_RSN_CODE,
		LOCK_TIME,
		LOCK_MAKER,
		LOCK_REMARK,
		UNLOCK_TIME,
		UNLOCK_MAKER,
		UNLOCK_REMARK,
		OLD_ORDER_NO,
		OLD_ORDER_SEQ,
		OLD_ORDER_SEQ_NO,
		OLD_MATERIAL_NO,
		OLD_MATERIAL_NAME,
		REMAIN_RSN_CODE,
		REMAIN_JUGDE_TIME,
		REMAIN_JUGDE_MAKER,
		REMAIN_JUGDE_CODE,
		REMAIN_REMARK,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		JUGDE_SCAN_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_REPORT_NO,
		DETECT_RESULT_CODE,
		WPRESSURE_REPORT_NO,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		BUG_NO,
		BUG_DEAL,
		REPAIR_FLAG,
		REPAIR_REMARK,
		SAMPLING_FLAG,
		SAMPLING_TYPE,
		SAMPLING_NO,
		CHECKOUT_NO,
		CHEM_STCHECK_NO,
		CHEM_PROCHECK_NO,
		SH_CHECK_NO,
		COME_PROC_FLAG,
		CONFM_FLAG,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		OUTSTOCK_TIME,
		PRO_BC,
		PRO_BZ,
		RPO_TIME,
		BAR_CODE,
		BEGINNING_FLAG,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		REQ_BL_ID,
		IF_BATCHED_JG,
		COUPCUT_BATCH_ID,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		OLD_ORD_PK,
		OLD_ORD_LN_PK,
		OLD_ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		JUDGE_STD_CODE,
		JUDGE_GRADE,
		PIPMEMO,
		TEST,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		MEMO1,
		JUDGE_ID,
		MNG_LOCK_FLAG,
		LOCK_ID,
		PRO_NO,
		LOCK_LIKU,
		PLN_GRADECODE,
		PLN_GRADENAME,
		PLN_STEELCODE,
		PLN_STEELNAME,
		DECODE(T.MAT_STATUS,'0', '00','22') ,
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		FINISHPRO_MOLD,
		IN_MOLD,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		GX_PLAN_NO1,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		ZG_PHY_RESULT_PATH,
		ZG_FACE_RESULT_PATH,
		ZG_SPEC_RESULT_PATH,
		VRP_HEAT_PLAN_NO,
		VRP_LOT_NO,
		VRP_SAMPLE_FLAG,
		VRP_PRO_ORDER_NO,
		VRP_PRO_ORDER_NO1,
		VRP_PRO_ORDER_ID,
		VRP_PRO_ORDER_ID1,
		VRP_ACT_DIMATER,
		VRP_ACT_HEIGHT,
		VRP_JUGDE_APPLY_FLAG,
		VRP_JUGDE_APPLY_CODE,
		VRP_JUGDE_APPLY_TIME,
		VRP_FACE_RESULT_CODE,
		VRP_FACE_RESULT_TIME,
		VRP_FACE_MAKER,
		VRP_FACE_RESULT_PATH,
		VRP_SPEC_RESULT_CODE,
		VRP_SPEC_RESULT_TIME,
		VRP_SPEC_MAKER,
		VRP_SPEC_RESULT_PATH,
		VRP_PHY_RESULT_CODE,
		VRP_PHY_RESULT_TIME,
		VRP_PHY_MAKER,
		VRP_PHY_RESULT_PATH,
		VRP_JUDGE_RESULT_CODE,
		VRP_JUDGE_RESULT_TIME,
		VRP_JUDGE_MAKER,
		VRP_GX_PLAN_NO,
		VRP_GX_PLAN_NO1,
		VPR_JUGDE_CONVICTED,
		VPR_QUALITY_GROUP_ZG,
		VPR_FLAG_STOVE_NO_ZG,
		HTT_HEAT_PLAN_NO,
		HTT_LOT_NO,
		HTT_SAMPLE_FLAG,
		HTT_PRO_ORDER_NO,
		HTT_PRO_ORDER_NO1,
		HTT_PRO_ORDER_ID,
		HTT_PRO_ORDER_ID1,
		HTT_GX_PLAN_NO,
		HTT_GX_PLAN_NO1,
		HTT_JUGDE_APPLY_FLAG,
		HTT_JUGDE_APPLY_CODE,
		HTT_JUGDE_APPLY_TIME,
		HTT_FACE_RESULT_CODE,
		HTT_FACE_RESULT_TIME,
		HTT_FACE_MAKER,
		HTT_FACE_RESULT_PATH,
		HTT_SPEC_RESULT_CODE,
		HTT_SPEC_RESULT_TIME,
		HTT_SPEC_MAKER,
		HTT_SPEC_RESULT_PATH,
		HTT_PHY_RESULT_CODE,
		HTT_PHY_RESULT_TIME,
		HTT_PHY_MAKER,
		HTT_PHY_RESULT_PATH,
		HTT_JUDGE_RESULT_CODE,
		HTT_JUDGE_RESULT_TIME,
		HTT_JUDGE_MAKER,
		HTT_JUGDE_CONVICTED,
		HTT_QUALITY_GROUP_ZG,
		HTT_FLAG_STOVE_NO_ZG,
		PRC_LOT_NO,
		PRC_SAMPLE_FLAG,
		PRC_PRO_ORDER_NO,
		PRC_PRO_ORDER_NO1,
		PRC_PRO_ORDER_ID,
		PRC_PRO_ORDER_ID1,
		PRC_GX_PLAN_NO,
		PRC_GX_PLAN_NO1,
		PRC_JUGDE_APPLY_FLAG,
		PRC_JUGDE_APPLY_CODE,
		PRC_JUGDE_APPLY_TIME,
		PRC_FACE_RESULT_CODE,
		PRC_FACE_RESULT_TIME,
		PRC_FACE_MAKER,
		PRC_FACE_RESULT_PATH,
		PRC_SPEC_RESULT_CODE,
		PRC_SPEC_RESULT_TIME,
		PRC_SPEC_MAKER,
		PRC_SPEC_RESULT_PATH,
		PRC_PHY_RESULT_CODE,
		PRC_PHY_RESULT_TIME,
		PRC_PHY_MAKER,
		PRC_PHY_RESULT_PATH,
		PRC_JUDGE_RESULT_CODE,
		PRC_JUDGE_RESULT_TIME,
		PRC_JUDGE_MAKER,
		PRC_JUGDE_CONVICTED,
		PRC_QUALITY_GROUP_ZG,
		PRC_FLAG_STOVE_NO_ZG,
		PRC_HEAT_PLAN_NO,
		VRP_JUDGE_STD_NAME,
		VRP_JUDGE_STD_CODE,
		HTT_JUDGE_STD_NAME,
		HTT_JUDGE_STD_CODE,
		PRC_JUDGE_STD_NAME,
		PRC_JUDGE_STD_CODE,
		VRP_CRAF_NO,
		HTT_CRAF_NO,
		PRC_CRAF_NO,
		VRP_CHEM_RESULT_CODE,
		VRP_CHEM_RESULT_TIME,
		VRP_CHEM_MAKER,
		HTT_CHEM_RESULT_CODE,
		HTT_CHEM_RESULT_TIME,
		HTT_CHEM_MAKER,
		PRC_CHEM_RESULT_CODE,
		PRC_CHEM_RESULT_TIME,
		PRC_CHEM_MAKER,
		DETECT_REPORT_NO1,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		ZG_PLINE_CODE,
		ZG_PLINE_NAME,
		VRP_PLINE_CODE,
		VRP_PLINE_NAME,
		HTT_PLINE_CODE,
		HTT_PLINE_NAME,
		PRC_PLINE_CODE,
		PRC_PLINE_NAME,
		VRP_QCM_STAUS,
		HTT_QCM_STAUS,
		PRC_QCM_STAUS,
		ZG_MEMO,
		ZBS_FLAG,
		ZBS_ID,
		MEASURING_SEQ,
		INSTOCK_DOC,
		JG_ZBS_ID,
		CHANGE_DOC,
		M.SUBCONTRACT_NO,
		M.SUBCONTRACT_NO_SEQ,
		LOCK_BILL_FLAG
		FROM MAT_ZC_M M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO
		AND T.RESULT_NO_OFFLINE =?
	</query>
	<query id="frmEntrust.BatchInsertEntrustZcMat">
		INSERT INTO MAT_ZC_M
		(MAT_NO,
		PRODUCT_FLAG,
		MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		MAT_SQE_NO,
		SAMPLE_FLAG,
		CUTTING_FLAG,
		ORIGIN_MAT_NO,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		INPUT_ORIGIN_CODE,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_NO1,
		PRO_ORDER_ID,
		PRO_ORDER_ID1,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		DIMATER,
		HEIGHT,
		LEN_NO,
		LEN_DESC,
		LEN_UNIT,
		LEN_MIN,
		LEN_MAX,
		TARG_DIMATER,
		TARG_HEIGHT,
		TARG_LEN_MIN,
		TARG_LEN_MAX,
		ACT_DIMATER,
		ACT_HEIGHT,
		ACT_LEN,
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		ACT_WEIGHT,
		ACT_THEORY_WEIGHT,
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		PACK_TYPE_CODE,
		PACK_TYPE_NAME,
		PACK_NO,
		PACK_TIME,
		PACK_MAT_WT,
		MAT_GROSS_WT,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		COOL_HOT_FLAG,
		MAT_RETURN_FLAG,
		HEAT_TREAT_NO,
		POST_FLAG,
		LOCK_FLAG,
		MNG_LOCK_RSN_CODE,
		MNG_LOCK_TIME,
		MNG_LOCK_MAKER,
		MNG_LOCK_REMARK,
		LOCK_RSN_CODE,
		LOCK_TIME,
		LOCK_MAKER,
		LOCK_REMARK,
		UNLOCK_TIME,
		UNLOCK_MAKER,
		UNLOCK_REMARK,
		OLD_ORDER_NO,
		OLD_ORDER_SEQ,
		OLD_ORDER_SEQ_NO,
		OLD_MATERIAL_NO,
		OLD_MATERIAL_NAME,
		REMAIN_RSN_CODE,
		REMAIN_JUGDE_TIME,
		REMAIN_JUGDE_MAKER,
		REMAIN_JUGDE_CODE,
		REMAIN_REMARK,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		JUGDE_SCAN_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_REPORT_NO,
		DETECT_RESULT_CODE,
		WPRESSURE_REPORT_NO,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		BUG_NO,
		BUG_DEAL,
		REPAIR_FLAG,
		REPAIR_REMARK,
		SAMPLING_FLAG,
		SAMPLING_TYPE,
		SAMPLING_NO,
		CHECKOUT_NO,
		CHEM_STCHECK_NO,
		CHEM_PROCHECK_NO,
		SH_CHECK_NO,
		COME_PROC_FLAG,
		CONFM_FLAG,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		OUTSTOCK_TIME,
		PRO_BC,
		PRO_BZ,
		RPO_TIME,
		BAR_CODE,
		BEGINNING_FLAG,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		REQ_BL_ID,
		IF_BATCHED_JG,
		COUPCUT_BATCH_ID,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		OLD_ORD_PK,
		OLD_ORD_LN_PK,
		OLD_ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		JUDGE_STD_CODE,
		JUDGE_GRADE,
		PIPMEMO,
		TEST,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		MEMO1,
		JUDGE_ID,
		MNG_LOCK_FLAG,
		LOCK_ID,
		PRO_NO,
		LOCK_LIKU,
		PLN_GRADECODE,
		PLN_GRADENAME,
		PLN_STEELCODE,
		PLN_STEELNAME,
		QCM_STAUS,
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		FINISHPRO_MOLD,
		IN_MOLD,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		GX_PLAN_NO1,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		ZG_PHY_RESULT_PATH,
		ZG_FACE_RESULT_PATH,
		ZG_SPEC_RESULT_PATH,
		VRP_HEAT_PLAN_NO,
		VRP_LOT_NO,
		VRP_SAMPLE_FLAG,
		VRP_PRO_ORDER_NO,
		VRP_PRO_ORDER_NO1,
		VRP_PRO_ORDER_ID,
		VRP_PRO_ORDER_ID1,
		VRP_ACT_DIMATER,
		VRP_ACT_HEIGHT,
		VRP_JUGDE_APPLY_FLAG,
		VRP_JUGDE_APPLY_CODE,
		VRP_JUGDE_APPLY_TIME,
		VRP_FACE_RESULT_CODE,
		VRP_FACE_RESULT_TIME,
		VRP_FACE_MAKER,
		VRP_FACE_RESULT_PATH,
		VRP_SPEC_RESULT_CODE,
		VRP_SPEC_RESULT_TIME,
		VRP_SPEC_MAKER,
		VRP_SPEC_RESULT_PATH,
		VRP_PHY_RESULT_CODE,
		VRP_PHY_RESULT_TIME,
		VRP_PHY_MAKER,
		VRP_PHY_RESULT_PATH,
		VRP_JUDGE_RESULT_CODE,
		VRP_JUDGE_RESULT_TIME,
		VRP_JUDGE_MAKER,
		VRP_GX_PLAN_NO,
		VRP_GX_PLAN_NO1,
		VPR_JUGDE_CONVICTED,
		VPR_QUALITY_GROUP_ZG,
		VPR_FLAG_STOVE_NO_ZG,
		HTT_HEAT_PLAN_NO,
		HTT_LOT_NO,
		HTT_SAMPLE_FLAG,
		HTT_PRO_ORDER_NO,
		HTT_PRO_ORDER_NO1,
		HTT_PRO_ORDER_ID,
		HTT_PRO_ORDER_ID1,
		HTT_GX_PLAN_NO,
		HTT_GX_PLAN_NO1,
		HTT_JUGDE_APPLY_FLAG,
		HTT_JUGDE_APPLY_CODE,
		HTT_JUGDE_APPLY_TIME,
		HTT_FACE_RESULT_CODE,
		HTT_FACE_RESULT_TIME,
		HTT_FACE_MAKER,
		HTT_FACE_RESULT_PATH,
		HTT_SPEC_RESULT_CODE,
		HTT_SPEC_RESULT_TIME,
		HTT_SPEC_MAKER,
		HTT_SPEC_RESULT_PATH,
		HTT_PHY_RESULT_CODE,
		HTT_PHY_RESULT_TIME,
		HTT_PHY_MAKER,
		HTT_PHY_RESULT_PATH,
		HTT_JUDGE_RESULT_CODE,
		HTT_JUDGE_RESULT_TIME,
		HTT_JUDGE_MAKER,
		HTT_JUGDE_CONVICTED,
		HTT_QUALITY_GROUP_ZG,
		HTT_FLAG_STOVE_NO_ZG,
		PRC_LOT_NO,
		PRC_SAMPLE_FLAG,
		PRC_PRO_ORDER_NO,
		PRC_PRO_ORDER_NO1,
		PRC_PRO_ORDER_ID,
		PRC_PRO_ORDER_ID1,
		PRC_GX_PLAN_NO,
		PRC_GX_PLAN_NO1,
		PRC_JUGDE_APPLY_FLAG,
		PRC_JUGDE_APPLY_CODE,
		PRC_JUGDE_APPLY_TIME,
		PRC_FACE_RESULT_CODE,
		PRC_FACE_RESULT_TIME,
		PRC_FACE_MAKER,
		PRC_FACE_RESULT_PATH,
		PRC_SPEC_RESULT_CODE,
		PRC_SPEC_RESULT_TIME,
		PRC_SPEC_MAKER,
		PRC_SPEC_RESULT_PATH,
		PRC_PHY_RESULT_CODE,
		PRC_PHY_RESULT_TIME,
		PRC_PHY_MAKER,
		PRC_PHY_RESULT_PATH,
		PRC_JUDGE_RESULT_CODE,
		PRC_JUDGE_RESULT_TIME,
		PRC_JUDGE_MAKER,
		PRC_JUGDE_CONVICTED,
		PRC_QUALITY_GROUP_ZG,
		PRC_FLAG_STOVE_NO_ZG,
		PRC_HEAT_PLAN_NO,
		VRP_JUDGE_STD_NAME,
		VRP_JUDGE_STD_CODE,
		HTT_JUDGE_STD_NAME,
		HTT_JUDGE_STD_CODE,
		PRC_JUDGE_STD_NAME,
		PRC_JUDGE_STD_CODE,
		VRP_CRAF_NO,
		HTT_CRAF_NO,
		PRC_CRAF_NO,
		VRP_CHEM_RESULT_CODE,
		VRP_CHEM_RESULT_TIME,
		VRP_CHEM_MAKER,
		HTT_CHEM_RESULT_CODE,
		HTT_CHEM_RESULT_TIME,
		HTT_CHEM_MAKER,
		PRC_CHEM_RESULT_CODE,
		PRC_CHEM_RESULT_TIME,
		PRC_CHEM_MAKER,
		DETECT_REPORT_NO1,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		ZG_PLINE_CODE,
		ZG_PLINE_NAME,
		VRP_PLINE_CODE,
		VRP_PLINE_NAME,
		HTT_PLINE_CODE,
		HTT_PLINE_NAME,
		PRC_PLINE_CODE,
		PRC_PLINE_NAME,
		VRP_QCM_STAUS,
		HTT_QCM_STAUS,
		PRC_QCM_STAUS,
		ZG_MEMO,
		ZBS_FLAG,
		ZBS_ID,
		MEASURING_SEQ,
		INSTOCK_DOC,
		JG_ZBS_ID,
		CHANGE_DOC,
		SUBCONTRACT_NO,
		SUBCONTRACT_NO_SEQ,
		LOCK_BILL_FLAG)
		SELECT T.MAT_NO,
		PRODUCT_FLAG,
		M.MAT_STATUS,
		LOT_NO,
		STOVE_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		MAT_SQE_NO,
		SAMPLE_FLAG,
		CUTTING_FLAG,
		ORIGIN_MAT_NO,
		MATERIAL_NO,
		MATERIAL_NAME,
		INPUT_MATERIAL_NAME,
		INPUT_MATERIAL_NO,
		INPUT_ORIGIN_CODE,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		PRO_ORDER_NO,
		PRO_ORDER_NO1,
		PRO_ORDER_ID,
		PRO_ORDER_ID1,
		ORDER_NO,
		ORDER_SEQ,
		ORDER_SEQ_NO,
		CRAF_NO,
		PROCESS_CDOE,
		PROCESS_DESC,
		NEXT_PROCESS_CDOE,
		NEXT_PROCESS_DESC,
		PLINE_CODE,
		PLINE_NAME,
		MAT_ORIGIN_CODE,
		MAT_ORIGIN_NAME,
		DIMATER,
		HEIGHT,
		LEN_NO,
		LEN_DESC,
		LEN_UNIT,
		LEN_MIN,
		LEN_MAX,
		TARG_DIMATER,
		TARG_HEIGHT,
		TARG_LEN_MIN,
		TARG_LEN_MAX,
		ACT_DIMATER,
		ACT_HEIGHT,
		(SELECT SUM(ACT_LEN) FROM MAT_ZC_M A, HTT_ENTRUST_MAT_NO B
		WHERE  A.MAT_NO = B.MAT_NO_CUT
		AND B.MAT_NO = T.MAT_NO),
		ACT_LEN_MIN,
		ACT_LEN_MAX,
		ACT_COUNT,
		(SELECT SUM(ACT_WEIGHT) FROM MAT_ZC_M A, HTT_ENTRUST_MAT_NO B
		WHERE  A.MAT_NO = B.MAT_NO_CUT
		AND B.MAT_NO = T.MAT_NO),
		(SELECT SUM(ACT_THEORY_WEIGHT) FROM MAT_ZC_M A, HTT_ENTRUST_MAT_NO B
		WHERE  A.MAT_NO = B.MAT_NO_CUT
		AND B.MAT_NO = T.MAT_NO),
		MEASURE_FLAG,
		BELONG_CODE,
		BELONG_NAME,
		PACK_FLAG,
		PACK_TYPE_CODE,
		PACK_TYPE_NAME,
		PACK_NO,
		PACK_TIME,
		PACK_MAT_WT,
		MAT_GROSS_WT,
		MAT_GOWHERE_CODE,
		MAT_GOWHERE_NAME,
		COOL_HOT_FLAG,
		MAT_RETURN_FLAG,
		HEAT_TREAT_NO,
		POST_FLAG,
		LOCK_FLAG,
		MNG_LOCK_RSN_CODE,
		MNG_LOCK_TIME,
		MNG_LOCK_MAKER,
		MNG_LOCK_REMARK,
		LOCK_RSN_CODE,
		LOCK_TIME,
		LOCK_MAKER,
		LOCK_REMARK,
		UNLOCK_TIME,
		UNLOCK_MAKER,
		UNLOCK_REMARK,
		OLD_ORDER_NO,
		OLD_ORDER_SEQ,
		OLD_ORDER_SEQ_NO,
		OLD_MATERIAL_NO,
		OLD_MATERIAL_NAME,
		REMAIN_RSN_CODE,
		REMAIN_JUGDE_TIME,
		REMAIN_JUGDE_MAKER,
		REMAIN_JUGDE_CODE,
		REMAIN_REMARK,
		JUGDE_APPLY_FLAG,
		JUGDE_APPLY_CODE,
		JUGDE_APPLY_TIME,
		JUGDE_SCAN_TIME,
		FACE_RESULT_CODE,
		FACE_RESULT_TIME,
		FACE_MAKER,
		SPEC_RESULT_CODE,
		SPEC_RESULT_TIME,
		SPEC_MAKER,
		CHEM_RESULT_CODE,
		CHEM_RESULT_TIME,
		CHEM_MAKER,
		PHY_RESULT_CODE,
		PHY_RESULT_TIME,
		PHY_MAKER,
		DETECT_REPORT_NO,
		DETECT_RESULT_CODE,
		WPRESSURE_REPORT_NO,
		WPRESSURE_RESULT_CODE,
		JUDGE_RESULT_CODE,
		JUDGE_RESULT,
		JUDGE_RESULT_TIME,
		JUDGE_MAKER,
		BUG_NO,
		BUG_DEAL,
		REPAIR_FLAG,
		REPAIR_REMARK,
		SAMPLING_FLAG,
		SAMPLING_TYPE,
		SAMPLING_NO,
		CHECKOUT_NO,
		CHEM_STCHECK_NO,
		CHEM_PROCHECK_NO,
		SH_CHECK_NO,
		COME_PROC_FLAG,
		CONFM_FLAG,
		INSTOCK_FLAG,
		INSTOCK_TIME,
		OUTSTOCK_TIME,
		PRO_BC,
		PRO_BZ,
		RPO_TIME,
		BAR_CODE,
		BEGINNING_FLAG,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		REQ_BL_ID,
		IF_BATCHED_JG,
		COUPCUT_BATCH_ID,
		ORD_PK,
		ORD_LN_PK,
		ORD_LN_DLY_PK,
		OLD_ORD_PK,
		OLD_ORD_LN_PK,
		OLD_ORD_LN_DLY_PK,
		BAL_YEAR_MONTH,
		JUDGE_STD_NAME,
		JUDGE_STD_CODE,
		JUDGE_GRADE,
		PIPMEMO,
		TEST,
		SOURE_CODE,
		SOURE_NAME,
		PONDER_NO,
		PONDER_GROSS_WT,
		MEMO1,
		JUDGE_ID,
		MNG_LOCK_FLAG,
		LOCK_ID,
		PRO_NO,
		LOCK_LIKU,
		PLN_GRADECODE,
		PLN_GRADENAME,
		PLN_STEELCODE,
		PLN_STEELNAME,
		'00',
		OUTSTOCK_DOC,
		HEAT_PLAN_NO,
		ZG_STOVE_SQE,
		GX_PLAN_NO,
		ZG_MAT_NO,
		FINISHPRO_MOLD,
		IN_MOLD,
		TARGET,
		PROCESS_STATUS,
		JUGDE_CONVICTED,
		GX_PLAN_NO1,
		FIXTYPE_CODE,
		QUALITY_GROUP_ZG,
		FLAG_STOVE_NO_ZG,
		ZG_PHY_RESULT_PATH,
		ZG_FACE_RESULT_PATH,
		ZG_SPEC_RESULT_PATH,
		VRP_HEAT_PLAN_NO,
		VRP_LOT_NO,
		VRP_SAMPLE_FLAG,
		VRP_PRO_ORDER_NO,
		VRP_PRO_ORDER_NO1,
		VRP_PRO_ORDER_ID,
		VRP_PRO_ORDER_ID1,
		VRP_ACT_DIMATER,
		VRP_ACT_HEIGHT,
		VRP_JUGDE_APPLY_FLAG,
		VRP_JUGDE_APPLY_CODE,
		VRP_JUGDE_APPLY_TIME,
		VRP_FACE_RESULT_CODE,
		VRP_FACE_RESULT_TIME,
		VRP_FACE_MAKER,
		VRP_FACE_RESULT_PATH,
		VRP_SPEC_RESULT_CODE,
		VRP_SPEC_RESULT_TIME,
		VRP_SPEC_MAKER,
		VRP_SPEC_RESULT_PATH,
		VRP_PHY_RESULT_CODE,
		VRP_PHY_RESULT_TIME,
		VRP_PHY_MAKER,
		VRP_PHY_RESULT_PATH,
		VRP_JUDGE_RESULT_CODE,
		VRP_JUDGE_RESULT_TIME,
		VRP_JUDGE_MAKER,
		VRP_GX_PLAN_NO,
		VRP_GX_PLAN_NO1,
		VPR_JUGDE_CONVICTED,
		VPR_QUALITY_GROUP_ZG,
		VPR_FLAG_STOVE_NO_ZG,
		HTT_HEAT_PLAN_NO,
		HTT_LOT_NO,
		HTT_SAMPLE_FLAG,
		HTT_PRO_ORDER_NO,
		HTT_PRO_ORDER_NO1,
		HTT_PRO_ORDER_ID,
		HTT_PRO_ORDER_ID1,
		HTT_GX_PLAN_NO,
		HTT_GX_PLAN_NO1,
		HTT_JUGDE_APPLY_FLAG,
		HTT_JUGDE_APPLY_CODE,
		HTT_JUGDE_APPLY_TIME,
		HTT_FACE_RESULT_CODE,
		HTT_FACE_RESULT_TIME,
		HTT_FACE_MAKER,
		HTT_FACE_RESULT_PATH,
		HTT_SPEC_RESULT_CODE,
		HTT_SPEC_RESULT_TIME,
		HTT_SPEC_MAKER,
		HTT_SPEC_RESULT_PATH,
		HTT_PHY_RESULT_CODE,
		HTT_PHY_RESULT_TIME,
		HTT_PHY_MAKER,
		HTT_PHY_RESULT_PATH,
		HTT_JUDGE_RESULT_CODE,
		HTT_JUDGE_RESULT_TIME,
		HTT_JUDGE_MAKER,
		HTT_JUGDE_CONVICTED,
		HTT_QUALITY_GROUP_ZG,
		HTT_FLAG_STOVE_NO_ZG,
		PRC_LOT_NO,
		PRC_SAMPLE_FLAG,
		PRC_PRO_ORDER_NO,
		PRC_PRO_ORDER_NO1,
		PRC_PRO_ORDER_ID,
		PRC_PRO_ORDER_ID1,
		PRC_GX_PLAN_NO,
		PRC_GX_PLAN_NO1,
		PRC_JUGDE_APPLY_FLAG,
		PRC_JUGDE_APPLY_CODE,
		PRC_JUGDE_APPLY_TIME,
		PRC_FACE_RESULT_CODE,
		PRC_FACE_RESULT_TIME,
		PRC_FACE_MAKER,
		PRC_FACE_RESULT_PATH,
		PRC_SPEC_RESULT_CODE,
		PRC_SPEC_RESULT_TIME,
		PRC_SPEC_MAKER,
		PRC_SPEC_RESULT_PATH,
		PRC_PHY_RESULT_CODE,
		PRC_PHY_RESULT_TIME,
		PRC_PHY_MAKER,
		PRC_PHY_RESULT_PATH,
		PRC_JUDGE_RESULT_CODE,
		PRC_JUDGE_RESULT_TIME,
		PRC_JUDGE_MAKER,
		PRC_JUGDE_CONVICTED,
		PRC_QUALITY_GROUP_ZG,
		PRC_FLAG_STOVE_NO_ZG,
		PRC_HEAT_PLAN_NO,
		VRP_JUDGE_STD_NAME,
		VRP_JUDGE_STD_CODE,
		HTT_JUDGE_STD_NAME,
		HTT_JUDGE_STD_CODE,
		PRC_JUDGE_STD_NAME,
		PRC_JUDGE_STD_CODE,
		VRP_CRAF_NO,
		HTT_CRAF_NO,
		PRC_CRAF_NO,
		VRP_CHEM_RESULT_CODE,
		VRP_CHEM_RESULT_TIME,
		VRP_CHEM_MAKER,
		HTT_CHEM_RESULT_CODE,
		HTT_CHEM_RESULT_TIME,
		HTT_CHEM_MAKER,
		PRC_CHEM_RESULT_CODE,
		PRC_CHEM_RESULT_TIME,
		PRC_CHEM_MAKER,
		DETECT_REPORT_NO1,
		DETECT_RESULT_CODE1,
		TESTING_GRADE,
		TESTING_TYPE,
		TESTING_GRADE1,
		TESTING_TYPE1,
		ZG_PLINE_CODE,
		ZG_PLINE_NAME,
		VRP_PLINE_CODE,
		VRP_PLINE_NAME,
		HTT_PLINE_CODE,
		HTT_PLINE_NAME,
		PRC_PLINE_CODE,
		PRC_PLINE_NAME,
		VRP_QCM_STAUS,
		HTT_QCM_STAUS,
		PRC_QCM_STAUS,
		ZG_MEMO,
		ZBS_FLAG,
		ZBS_ID,
		MEASURING_SEQ,
		INSTOCK_DOC,
		JG_ZBS_ID,
		CHANGE_DOC,
		M.SUBCONTRACT_NO,
		M.SUBCONTRACT_NO_SEQ,
		LOCK_BILL_FLAG

		FROM MAT_ZC_M M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO_CUT
		AND T.MAT_NO_CUT LIKE '%01'
		AND T.RESULT_NO_OFFLINE =?
	</query>
	<query id="frmEntrust.BatchDeleteEntrustZcMat">
		DELETE
		FROM MAT_ZC_M
		WHERE MAT_NO IN (SELECT MAT_NO FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
	</query>
	<query id="frmEntrust.BatchDeleteEntrustCutZcMat">
		DELETE
		FROM MAT_ZC_M
		WHERE MAT_NO IN (SELECT MAT_NO_CUT FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
	</query>

	<query id="frmEntrust.BatchInsertEntrustCutZcBut">
		INSERT INTO YDM_ZC_BUTTRESS
		(MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC)
		SELECT t.mat_no_cut MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC
		FROM YDM_ZC_BUTTRESS M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO
		AND T.RESULT_NO_OFFLINE =?
		AND M.STORAGE_NO IS NOT NULL
	</query>
	<query id="frmEntrust.BatchInsertEntrustZcBut">
		INSERT INTO YDM_ZC_BUTTRESS
		(MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC)
		SELECT t.MAT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		BATCH_GROUD_NO,
		STORAGE_NO,
		LOCATION_NO,
		LARY_NO,
		LOC_NO,
		STORAGE_ATTR,
		STORAGE_ATTR_NAME,
		STORAGE_TYPE_NO,
		STORAGE_TYPE_NAME,
		MANAGEMENT_NO,
		MANAGEMENT_NAME,
		MEMO,
		CREATE_NAME,
		CREATE_TIME,
		UPDATE_NAME,
		UPDATE_TIME,
		DELETE_NAME,
		DELETE_TIME,
		DEPARTMENT_CODE,
		DEPARTMENT_DESC
		FROM YDM_ZC_BUTTRESS M, HTT_ENTRUST_MAT_NO T
		WHERE M.MAT_NO = T.MAT_NO_CUT
		AND T.RESULT_NO_OFFLINE =?
		AND T.MAT_NO_CUT LIKE '%01'
		AND M.STORAGE_NO IS NOT NULL
	</query>
	<query id="frmEntrust.BatchDeleteEntrustZcBut">
		DELETE
		FROM YDM_ZC_BUTTRESS
		WHERE MAT_NO IN (SELECT MAT_NO FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
	</query>
	<query id="frmEntrust.BatchDeleteEntrustCutZcBut">
		DELETE
		FROM YDM_ZC_BUTTRESS
		WHERE MAT_NO IN (SELECT MAT_NO_CUT FROM HTT_ENTRUST_MAT_NO
		WHERE RESULT_NO_OFFLINE =?)
	</query>
</queryMap>