<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	 <query id="JdgQcmZcCheckconsign.groupQuery" desc="查询委托表">
        <![CDATA[
SELECT TT.*
  FROM (SELECT T.JUDGE_STOVE_NO,
               MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK,
               MIN(T.GRADENAME) GRADENAME,
               MIN(T.STEELNAME) STEELNAME,
               MIN(T.ACT_DIMATER) ACT_DIMATER,
               MIN(T.ACT_HEIGHT) ACT_HEIGHT,
               MIN(T2.BASENAME) PHY_RESULT_NAME,
               MIN(T3.BASENAME) CHEM_RESULT_NAME,
               MAX(T.PLINE_NAME) PLINE_NAME,
               T.CHECK_NO,
               TO_CHAR(MAX(T.JUDGE_TIME), 'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
               MIN(T.JUDGE_MAKER) JUDGE_MAKER,
               MAX(T.JUDGE_MEMO) JUDGE_MEMO,
               '正常' LK_FLAG,
               MIN(T.STEEL_STANDRAD) STEEL_STANDRAD,
               CASE
                 WHEN MIN(T.CHECK_NO) LIKE '%F%' THEN
                  '复验'
                 ELSE
                  '初验'
               END SAMPLE_TYPE,
               MIN(T.CONSIGN_NAME) CONSIGN_NAME,
               MIN(T.CONSIGN_MEMO) CONSIGN_MEMO,
               TO_CHAR(MAX(T.CONSIGN_TIME), 'YYYY-MM-DD HH24:MI:SS') CONSIGN_TIME,
               MIN(T.TARGET) TARGET,
               CASE
                 WHEN EXISTS (SELECT 1
                         FROM QCM_ZC_CHECKCONSIGN T7
                        WHERE T7.CHECK_NO = T.CHECK_NO
                          AND T7.JUDGE_RESULT_CODE IS NULL) THEN
                  '未判'
                 ELSE
                  '已判'
               END CHECK_RESULT,
               DECODE(MIN(T.QUOTE_STATE),
                      '0',
                      '未报出',
                      '1',
                      '部分报出',
                      '报齐') QUOTE_STATE,
               MIN(T4.MODEL_DESC) MODEL_DESC,
               MIN(T4.BUYER_NAME) BUYER_NAME,
               MIN(T4.ORDER_NO) || '/' || MIN(T4.ORDER_SEQ) ORDER_NO,
               MIN(T4.SPEC_NAME) SPEC_NAME,
               MIN(T4.PRODUCNAME) PRODUCNAME,
               MIN(T4.STD_STYLE_DESC) STD_STYLE_DESC,
               MIN(T4.STD_NAME) STD_NAME,
               DECODE(MIN(T.CRAFT_SOURCE),
                      '0',
                      '生产样',
                      '1',
                      '首日检',
                      '4',
                      '外购管') CRAFT_SOURCE_DESC,
               MIN(T.CRAFT_SOURCE) CRAFT_SOURCE,
               MIN(T.LOT_NO) LOT_NO,
               MIN(T.LOT_NO_GROUP) LOT_NO_GROUP,
               MIN(T.CIC) CIC,
               MIN(T.PIC) PIC,
               MIN(T5.CRAFT_NO) CRAFT_NO,
               MIN(T5.CRAFT_PATH) CRAFT_PATH
          FROM QCM_ZC_CHECKCONSIGN T
          LEFT JOIN COM_BASE_INFO T2
            ON T2.BASECODE = T.PHY_RESULT_CODE
          LEFT JOIN COM_BASE_INFO T3
            ON T3.BASECODE = T.CHEM_RESULT_CODE
          LEFT JOIN PLN_SALEORD T4
            ON T4.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
          LEFT JOIN CRAFT_ORD_DESIGN T5
            ON T5.ORD_LN_PK = T4.ORD_LN_PK
           AND T5.CRAFT_SEQ = T.CRAFT_SEQ
         WHERE ({0} IS NULL OR T.LOT_NO LIKE '%' || {0} || '%')
           AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
           AND ({2} IS NULL OR {2} = '0' AND EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN A
                  WHERE A.CHECK_NO = T.CHECK_NO
                    AND A.IS_FLAG = '0'
                    AND A.JUDGE_RESULT_CODE IS NULL) OR
                {2} = '1' AND NOT EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN A
                  WHERE A.CHECK_NO = T.CHECK_NO
                    AND A.IS_FLAG = '0'
                    AND A.JUDGE_RESULT_CODE IS NULL))
           AND ({3} IS NULL OR
               T.CONSIGN_TIME >= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS'))
           AND ({4} IS NULL OR
               T.CONSIGN_TIME <= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS'))
           AND T.CONSIGN_TIME >=
               TO_DATE('2018-07-30 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
           AND ({5} = '0' OR T.PLINE_CODE IN {6})
           AND ({7} IS NULL OR {8} = '1' AND T.CHECK_NO NOT LIKE '%F%' OR
               {7} = '2' AND T.CHECK_NO LIKE '%F%')
           AND ({8} IS NULL OR
               {8} = '1' AND T.PLINE_CODE NOT IN ('C065', 'C066') OR
               {8} = '2' AND T.PLINE_CODE IN ('C065', 'C066'))
           AND T.PROCESS_CODE = {9}
           AND ({10} IS NULL OR T.CHECK_NO LIKE '%' || {10} || '%')
           AND ({11} IS NULL OR T.QUOTE_STATE = {11})
           AND ({12} IS NULL OR
               T.JUDGE_TIME >= TO_DATE({12}, 'YYYY-MM-DD HH24:MI:SS'))
           AND ({13} IS NULL OR
               T.JUDGE_TIME <= TO_DATE({13}, 'YYYY-MM-DD HH24:MI:SS'))
           AND T.IS_FLAG = '0'
         GROUP BY T.CHECK_NO, T.JUDGE_STOVE_NO) TT
 ORDER BY TT.JUDGE_STOVE_NO, TT.CRAFT_SOURCE
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryAllByCheckNo" desc="查询委托表">
        <![CDATA[
SELECT T.*, T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.CHECK_NO = {0}
   AND T.IS_FLAG = '0'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryAllByCheckNoFirstRow" desc="查询委托表">
        <![CDATA[
SELECT T.*
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.CHECK_NO = {0}
   AND T.IS_FLAG = '0'
   AND ROWNUM <= 1
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryByCheckNo" desc="查询委托表">
        <![CDATA[
SELECT T.BATCH_NO,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.CHEM_RESULT_CODE,
       T.PHY_RESULT_CODE,
       T.CHEM_RESULT_CODE CHEM_RESULT_CODE_OLD,
       T.PHY_RESULT_CODE PHY_RESULT_CODE_OLD,
       T2.BASENAME CHEM_RESULT_NAME,
       T3.BASENAME PHY_RESULT_NAME,
       DECODE(T.CYCLES_FLAG, '1', '是', '0', '否') CYCLES_FLAG,
       T.JUDGE_MEMO,
       DECODE(T.APPLY_RESAMPLE, '1', '是', '否') APPLY_RESAMPLE,
       T4.BASENAME JUDGE_RESULT_NAME,
       T.JUDGE_RESULT_CODE,
       T6.CRAFT_NO,
       T6.CRAFT_PATH
  FROM QCM_ZC_CHECKCONSIGN T
  LEFT JOIN COM_BASE_INFO T2
    ON T2.BASECODE = T.CHEM_RESULT_CODE
  LEFT JOIN COM_BASE_INFO T3
    ON T3.BASECODE = T.PHY_RESULT_CODE
  LEFT JOIN COM_BASE_INFO T4
    ON T4.BASECODE = T.JUDGE_RESULT_CODE
  LEFT JOIN PLN_SALEORD T5
    ON T5.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
  LEFT JOIN CRAFT_ORD_DESIGN T6
    ON T5.ORD_LN_DLY_PK IS NOT NULL
    AND T.CRAFT_SEQ IS NOT NULL
    AND T6.ORD_LN_PK = T5.ORD_LN_PK
    AND T6.CRAFT_SEQ = T.CRAFT_SEQ
 WHERE T.CHECK_NO = {0}
   AND T.IS_FLAG = '0'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryByBatchNo" desc="查询委托表">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryByCheckNoJudgeStoveNo" desc="查询委托表">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryByBatchNoNoCheckNo" desc="查询委托表">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.CRAFT_SOURCE IN {3}
        ]]>
    </query>
    
        <query id="JdgQcmZcCheckconsign.queryByLotNoNoCheckNo" desc="查询委托表">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE ({0} IS NULL OR T.LOT_NO = {0})
   AND ({1} IS NULL OR T.LOT_NO_GROUP = {1})
   AND T.PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.CRAFT_SOURCE IN {3}
   AND T.PLINE_CODE = {4}
   AND T.ORD_LN_DLY_PK like {5} || '%'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryByJudgeStoveNo" desc="通过炉号查询委托表">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CODE = {1}
   AND T.CRAFT_SOURCE = {2}
   AND T.ORD_LN_DLY_PK = {3}
   AND T.IS_FLAG = '0'
   ORDER BY T.BATCH_NO
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryOriginalByJudgeStoveNo" desc="通过炉号查询委托表">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CODE = {1}
   AND T.CRAFT_SOURCE = {2}
   AND (T.CHECK_NO NOT LIKE '%P%' AND T.CHECK_NO NOT LIKE '%L%')
   AND T.IS_FLAG = '0'
   ORDER BY T.BATCH_NO
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryMaxResampleCheckNo" desc="查询最大复样检验编号">
        <![CDATA[
SELECT MAX(T.CHECK_NO) CHECK_NO
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.CHECK_NO LIKE '%F%'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.queryMaxCheckNo" desc="查询最大检验编号">
        <![CDATA[
SELECT MAX(T.CHECK_NO) CHECK_NO
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.CHECK_NO NOT LIKE '%F%'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateChemResult" desc="修改委托表成分结果">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.CHEM_RESULT_CODE = {4}
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateResult" desc="修改委托表判定结果">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.PHY_RESULT_CODE   = {4},
       T.CHEM_RESULT_CODE  = {5},
       T.JUDGE_RESULT_CODE = {6},
       T.JUDGE_MAKER       = {7},
       T.JUDGE_TIME        = SYSDATE,
       T.JUDGE_MEMO        = {8},
       T.CHEM_JUDGE_ID     = {9},
       T.PHY_JUDGE_ID      = {10},
       T.VALIDFLAG         = {11},
       T.RESAMPLE = {12},
       T.IS_NO_SSC = {13},
       T.IS_NO_HIC = {14}
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateConsignFirstDate" desc="修改委托表判定结果">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.FIRST_JUDGE_DATE        = SYSDATE
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.FIRST_JUDGE_DATE IS NULL
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updatePipeFlag" desc="修改委托表判定结果">
        <![CDATA[
UPDATE PIPE_CHECKCONSIGN_BASEINFO T
   SET T.OK_FLAG = {0}
 WHERE T.CHECK_NO = {1}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.isLxPhy" desc="修改委托表判定结果">
        <![CDATA[
	SELECT COUNT(1) from COM_BASE_PHY_C t WHERE T.PHY_CODE=? AND T.PHY_DEPTNAME LIKE '%力学%'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateQuoteState" desc="修改委托表的是否报齐">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.QUOTE_STATE = {1}
 WHERE T.CHECK_NO = {0}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateCyClesFlag" desc="修改重新热处理标志">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.CYCLES_FLAG = {3}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateCyClesFlagByCheckNo" desc="修改重新热处理标志">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.CYCLES_FLAG = {1}
 WHERE T.CHECK_NO = {0}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateMemo" desc="修改备注">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.JUDGE_MEMO = {2}
 WHERE T.CHECK_NO = {0}
   AND T.PROCESS_CODE = {1}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.updateResampleData" desc="修改重取样信息">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.APPLY_RESAMPLE = {4}
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getPhyChemJudgeInfo" desc="获取判定记录">
        <![CDATA[
SELECT TT.*,
       (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = TT.DELIVERY_STATE_CODE) DELIVERY_STATE_NAME
  FROM (SELECT T.PHY_JUDGE_ID,
               T.CHEM_JUDGE_ID,
               T.STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.PLINE_NAME,
               T9.PROCESS_DESC,
               T4.Basename PHY_RESULT,
               T.PHY_RESULT_CODE,
               T5.BASENAME CHEM_RESULT,
               T.CHEM_RESULT_CODE,
               T6.BASENAME JUDGE_RESULT,
               T.JUDGE_RESULT_CODE,
               T.STEELNAME,
               T.GRADENAME,
               T.JUDGE_MAKER,
               TO_CHAR(T.JUDGE_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_TIME,
               CASE
                 WHEN T.CHECK_NO LIKE '%F%' THEN
                  '复样'
                 ELSE
                  '初样'
               END SAMPLE_TYPE,
               T.ACT_COUNT,
               T.ACT_WEIGHT,
               GET_DELIVERY_STATE(T3.DESGIN_KEY, T.INDEX_SEQ) DELIVERY_STATE_CODE,
               T7.MEMO CHEM_MEMO,
               T8.MEMO PHY_MEMO,
               T2.ORDER_NO || '/' || T2.ORDER_SEQ ORDER_NO,
               T.ACT_DIMATER,
               T.ACT_HEIGHT
          FROM QCM_ZC_CHECKCONSIGN T
          LEFT JOIN PLN_SALEORD T2
            ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
          LEFT JOIN CRAFT_ORD_DESIGN T3
            ON T3.ORD_LN_PK = T2.ORD_LN_PK
           AND T3.CRAFT_SEQ = T.CRAFT_SEQ
          LEFT JOIN COM_BASE_INFO T4
            ON T4.BASECODE = T.PHY_RESULT_CODE
          LEFT JOIN COM_BASE_INFO T5
            ON T5.BASECODE = T.CHEM_RESULT_CODE
          LEFT JOIN COM_BASE_INFO T6
            ON T6.BASECODE = T.JUDGE_RESULT_CODE
          LEFT JOIN QCM_BC_CHEMJUDGE T7
            ON T7.CHEM_JUDGE_ID = T.CHEM_JUDGE_ID
           AND T7.JUDGE_SEQ = 1
          LEFT JOIN QCM_BC_PHYJUDGE T8
            ON T8.PHY_JUDGE_ID = T.PHY_JUDGE_ID
           AND T8.JUDGE_SEQ = 1
          LEFT JOIN COM_BASE_PROCESS T9
            ON T9.PROCESS_CODE = T.PROCESS_CODE
         WHERE ({0} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {0} || '%')
           AND ({1} IS NULL OR T.BATCH_NO LIKE '%' || {1} || '%')
           AND ({2} IS NULL OR T.JUDGE_RESULT_CODE = {2})
           AND ({3} IS NULL OR
               T.JUDGE_TIME >= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS'))
           AND ({4} IS NULL OR
               T.JUDGE_TIME <= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS'))
           AND ({5} = '0' OR T.PLINE_CODE IN {6})
           AND T.PROCESS_CODE = {7}
           AND T.IS_FLAG = '0'
         ORDER BY T.JUDGE_TIME DESC) TT
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getCyclesInfo" desc="获取需要重新热处理的性能批号">
        <![CDATA[
SELECT T.BATCH_NO, 'False' CHK FROM QCM_ZC_CHECKCONSIGN T WHERE T.CHECK_NO = {0}
ORDER BY T.BATCH_NO
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.copyByBatchNo" desc="通过炉批复制委托">
        <![CDATA[
INSERT INTO QCM_ZC_CHECKCONSIGN
  (CHECK_NO,
   LOT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   STOVE_NO,
   PROCESS_CODE,
   PLINE_CODE,
   PLINE_NAME,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   CHEM_RESULT_PATH,
   PHY_RESULT_PATH,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   PRO_ORDER_ID,
   GX_PLAN_NO,
   ORD_LN_DLY_PK,
   CRAF_NO,
   CRAFT_SEQ,
   INDEX_SEQ,
   STEEL_STANDRAD,
   CIC,
   PIC,
   BAL_YEAR_MONTH,
   LK_FLAG,
   AUDIT_RESULT,
   AUDIT_MEMO,
   VALIDFLAG,
   CONSIGN_NAME,
   CONSIGN_TIME,
   CONSIGN_MEMO,
   CAILI_PATH,
   FUSHI_PATH,
   JINWU_PATH,
   GONGCHENG_PATH,
   DIBEI_PATH,
   HUAXUE_PATH,
   IS_FLAG,
   TARGET,
   CRAFT_SOURCE,
   IS_NO_SSC,
   IS_NO_HIC,
   LOT_NO_GROUP,
   QUOTE_STATE)
  (SELECT {5},
          {6},
          {7},
          {8},
          STOVE_NO,
          PROCESS_CODE,
          PLINE_CODE,
          PLINE_NAME,
          ACT_COUNT,
          ACT_WEIGHT,
          ACT_THEORY_WEIGHT,
          CHEM_RESULT_PATH,
          PHY_RESULT_PATH,
          MATERIAL_NO,
          MATERIAL_NAME,
          PRODUCCODE,
          PRODUCNAME,
          STEELCODE,
          STEELNAME,
          GRADECODE,
          GRADENAME,
          SPEC_CODE,
          SPEC_NAME,
          MODEL_CODE,
          MODEL_DESC,
          STD_CODE,
          STD_NAME,
          STD_STYLE,
          STD_STYLE_DESC,
          ACT_DIMATER,
          ACT_HEIGHT,
          ACT_LEN_MIN,
          ACT_LEN_MAX,
          PRO_ORDER_ID,
          GX_PLAN_NO,
          {9},
          CRAF_NO,
          {10},
          {11},
          STEEL_STANDRAD,
          {12},
          {13},
          BAL_YEAR_MONTH,
          LK_FLAG,
          AUDIT_RESULT,
          AUDIT_MEMO,
          VALIDFLAG,
          CONSIGN_NAME,
          CONSIGN_TIME,
          CONSIGN_MEMO,
          CAILI_PATH,
          FUSHI_PATH,
          JINWU_PATH,
          GONGCHENG_PATH,
          DIBEI_PATH,
          HUAXUE_PATH,
          IS_FLAG,
          TARGET,
          CRAFT_SOURCE,
          IS_NO_SSC,
          IS_NO_HIC,
          LOT_NO_GROUP,
          QUOTE_STATE
     FROM QCM_ZC_CHECKCONSIGN T
     WHERE T.JUDGE_STOVE_NO = {0}
     AND T.BATCH_NO = {1}
     AND T.PROCESS_CODE = {2}
     AND T.CRAFT_SOURCE = {3}
     AND T.ORD_LN_DLY_PK = {4})
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.insert" desc="通过炉批复制委托">
        <![CDATA[
INSERT INTO QCM_ZC_CHECKCONSIGN
    (CHECK_NO,
     LOT_NO,
     JUDGE_STOVE_NO,
     BATCH_NO,
     STOVE_NO,
     PROCESS_CODE,
     PLINE_CODE,
     PLINE_NAME,
     ACT_COUNT,
     ACT_WEIGHT,
     ACT_THEORY_WEIGHT,
     CHEM_RESULT_PATH,
     PHY_RESULT_PATH,
     MATERIAL_NO,
     MATERIAL_NAME,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     GRADECODE,
     GRADENAME,
     SPEC_CODE,
     SPEC_NAME,
     MODEL_CODE,
     MODEL_DESC,
     STD_CODE,
     STD_NAME,
     STD_STYLE,
     STD_STYLE_DESC,
     ACT_DIMATER,
     ACT_HEIGHT,
     ACT_LEN_MIN,
     ACT_LEN_MAX,
     PRO_ORDER_ID,
     GX_PLAN_NO,
     ORD_LN_DLY_PK,
     CRAF_NO,
     CRAFT_SEQ,
     INDEX_SEQ,
     STEEL_STANDRAD,
     CIC,
     PIC,
     BAL_YEAR_MONTH,
     LK_FLAG,
     AUDIT_RESULT,
     AUDIT_MEMO,
     VALIDFLAG,
     CONSIGN_NAME,
     CONSIGN_TIME,
     CONSIGN_MEMO,
     CAILI_PATH,
     FUSHI_PATH,
     JINWU_PATH,
     GONGCHENG_PATH,
     DIBEI_PATH,
     HUAXUE_PATH,
     IS_FLAG,
     TARGET,
     CRAFT_SOURCE,
     IS_NO_SSC,
     IS_NO_HIC,
     LOT_NO_GROUP,
     QUOTE_STATE,
     LIKU_PROCESS_CODE,
     JUDGE_RESULT_CODE)
     VALUES
    ('#CHECK_NO#',
     '#LOT_NO#',
     '#JUDGE_STOVE_NO#',
     '#BATCH_NO#',
     '#STOVE_NO#',
     '#PROCESS_CODE#',
     '#PLINE_CODE#',
     '#PLINE_NAME#',
     '#ACT_COUNT#',
     '#ACT_WEIGHT#',
     '#ACT_THEORY_WEIGHT#',
     '#CHEM_RESULT_PATH#',
     '#PHY_RESULT_PATH#',
     '#MATERIAL_NO#',
     '#MATERIAL_NAME#',
     '#PRODUCCODE#',
     '#PRODUCNAME#',
     '#STEELCODE#',
     '#STEELNAME#',
     '#GRADECODE#',
     '#GRADENAME#',
     '#SPEC_CODE#',
     '#SPEC_NAME#',
     '#MODEL_CODE#',
     '#MODEL_DESC#',
     '#STD_CODE#',
     '#STD_NAME#',
     '#STD_STYLE#',
     '#STD_STYLE_DESC#',
     '#ACT_DIMATER#',
     '#ACT_HEIGHT#',
     '#ACT_LEN_MIN#',
     '#ACT_LEN_MAX#',
     '#PRO_ORDER_ID#',
     '#GX_PLAN_NO#',
     '#ORD_LN_DLY_PK#',
     '#CRAF_NO#',
     '#CRAFT_SEQ#',
     '#INDEX_SEQ#',
     '#STEEL_STANDRAD#',
     '#CIC#',
     '#PIC#',
     '#BAL_YEAR_MONTH#',
     '#LK_FLAG#',
     '#AUDIT_RESULT#',
     '#AUDIT_MEMO#',
     '#VALIDFLAG#',
     '#CONSIGN_NAME#',
     SYSDATE,
     '#CONSIGN_MEMO#',
     '#CAILI_PATH#',
     '#FUSHI_PATH#',
     '#JINWU_PATH#',
     '#GONGCHENG_PATH#',
     '#DIBEI_PATH#',
     '#HUAXUE_PATH#',
     '#IS_FLAG#',
     '#TARGET#',
     '#CRAFT_SOURCE#',
     '#IS_NO_SSC#',
     '#IS_NO_HIC#',
     '#LOT_NO_GROUP#',
     '#QUOTE_STATE#',
     '#LIKU_PROCESS_CODE#',
     '#JUDGE_RESULT_CODE#')
        ]]>
    </query>
    <query id = "JdgQcmZcCheckconsign.insertPipeBaseInfo" desc = "修改检化验主表信息">
    INSERT INTO PIPE_CHECKCONSIGN_BASEINFO
  (CHECK_NO,
   LOT_NO,
   STOVE_NO,
   HEAT_NO,
   STEEL_GRADE,
   STEEL_NO,
   PRODUCT_NAME,
   PRODUCT_STD,
   CRAFT_FILE_NO,
   CONTRACT_NO,
   CHECK_COUNT,
   PLINE_CODE,
   DIMATER,
   HEIGHT,
   BUCKLE_TYPE,
   PROCESS_STATUS,
   CONSIGN_DEPT,
   CONSIGN_NAME,
   CONSIGN_TIME,
   ISPRODUCER,
   SPEC_REQ,
   GET_NAME,
   GET_TIME,
   CONSIGNDEPT_SEND_NAME,
   CONSIGNDEPT_SEND_TIME,
   JG_RECEIVE_NAME,
   JG_RECEIVE_TIME,
   IS_RUSH,
   RUSH_NAME,
   RUSH_TIME,
   FLAG,
   SAMPLE_REMARK,
   REMARK,
   DATA_TYPE,
   VALIDFLAG,
   STD_STYLE_DESC,
   PROCESS_CODE,
   MERGER_NO,
   CRAFT_SOURCE,
   JG_PRINT_COUNT,
   JG_PRINT_NAME,
   JG_PRINT_TIME,
   INDEX_SEQ,
   PIC,
   CIC,
   LOT_NO_GROUP
   )
  (SELECT '#CHECK_NO#',
          LOT_NO,
          STOVE_NO,
          HEAT_NO,
          STEEL_GRADE,
          STEEL_NO,
          PRODUCT_NAME,
          PRODUCT_STD,
          '#CRAF_NO#',
          '#CONTRACT_NO#',
          CHECK_COUNT,
          PLINE_CODE,
          DIMATER,
          HEIGHT,
          BUCKLE_TYPE,
          PROCESS_STATUS,
          CONSIGN_DEPT,
          CONSIGN_NAME,
          CONSIGN_TIME,
          ISPRODUCER,
          SPEC_REQ,
          GET_NAME,
          GET_TIME,
          CONSIGNDEPT_SEND_NAME,
          CONSIGNDEPT_SEND_TIME,
          JG_RECEIVE_NAME,
          JG_RECEIVE_TIME,
          IS_RUSH,
          RUSH_NAME,
          RUSH_TIME,
          FLAG,
          SAMPLE_REMARK,
          REMARK,
          DATA_TYPE,
          VALIDFLAG,
          STD_STYLE_DESC,
          PROCESS_CODE,
          MERGER_NO,
          CRAFT_SOURCE,
          JG_PRINT_COUNT,
          JG_PRINT_NAME,
          JG_PRINT_TIME,
          '#INDEX_SEQ#',
          '#PIC#',
          '#CIC#',
          LOT_NO_GROUP
     FROM PIPE_CHECKCONSIGN_BASEINFO T
    WHERE T.CHECK_NO = '#OLD_CHECK_NO#')
    </query>
    <query id="JdgQcmZcCheckconsign.getByBatchNoOrdLnPkCheckNo" desc="通过炉批+合同行PK删除">
        <![CDATA[
SELECT T.* FROM QCM_ZC_CHECKCONSIGN T
      WHERE T.JUDGE_STOVE_NO = {0}
        AND T.BATCH_NO = {1}
        AND T.PROCESS_CODE = {2}
        AND T.CRAFT_SOURCE = {3}
        AND T.ORD_LN_DLY_PK = {4}
        AND T.CHECK_NO LIKE '%' || {5} || '%'
        ]]>
    </query>
    <query id="JdgQcmZcCheckconsign.deleteByBatchNoOrdLnPkCheckNo" desc="通过炉批+合同行PK删除">
        <![CDATA[
DELETE FROM QCM_ZC_CHECKCONSIGN T
      WHERE T.JUDGE_STOVE_NO = {0}
        AND T.BATCH_NO = {1}
        AND T.PROCESS_CODE = {2}
        AND T.CRAFT_SOURCE = {3}
        AND T.ORD_LN_DLY_PK = {4}
        AND T.CHECK_NO LIKE '%' || {5} || '%'
        ]]>
    </query>
    <query id="JdgQcmZcCheckconsign.deleteByBatchNoOrdLnPkCheckNo1" desc="通过炉批+合同行PK删除">
        <![CDATA[
DELETE FROM QCM_ZC_CHECKCONSIGN T
      WHERE T.CHECK_NO = {0}
        ]]>
    </query>
    <query id="JdgQcmZcCheckconsign.getMinConsignByBatchNo" desc="通过炉批查询最小的检验单号">
        <![CDATA[
 SELECT T.*
   FROM QCM_ZC_CHECKCONSIGN T
  WHERE T.JUDGE_STOVE_NO = {0}
    AND T.BATCH_NO = {1}
    AND T.CRAFT_SOURCE = {2}
    AND T.PROCESS_CODE = {3}
    AND T.ORD_LN_DLY_PK = {4}
    AND T.IS_FLAG = '0'
 ORDER BY T.CHECK_NO
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getByBatchNoOrdLnDlyPk" desc="通过炉批+交货行PK查询">
        <![CDATA[
 SELECT T.*
   FROM QCM_ZC_CHECKCONSIGN T
  WHERE T.JUDGE_STOVE_NO = {0}
    AND T.BATCH_NO = {1}
    AND T.CRAFT_SOURCE = {2}
    AND T.PROCESS_CODE = {3}
    AND T.ORD_LN_DLY_PK = {4}
    AND T.IS_FLAG = '0'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getOriginalByBatchNo" desc="查询原始检验委托">
        <![CDATA[
 SELECT T.*
   FROM QCM_ZC_CHECKCONSIGN T
  WHERE T.JUDGE_STOVE_NO = {0}
    AND T.BATCH_NO = {1}
    AND T.CRAFT_SOURCE = {2}
    AND T.PROCESS_CODE = {3}
    AND (T.CHECK_NO NOT LIKE '%P%' AND T.CHECK_NO NOT LIKE '%L%')
    AND T.IS_FLAG = '0'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getOriginalNoBatchNo" desc="查询原始检验委托">
        <![CDATA[
 SELECT T.*
   FROM QCM_ZC_CHECKCONSIGN T
  WHERE T.JUDGE_STOVE_NO = {0}
    AND T.CRAFT_SOURCE = {1}
    AND T.PROCESS_CODE = {2}
    AND (T.CHECK_NO NOT LIKE '%P%' AND T.CHECK_NO NOT LIKE '%L%')
    AND T.IS_FLAG = '0'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getPipeBaseInfo" desc="查询原始检验委托">
        <![CDATA[
        SELECT T.*
  FROM PIPE_CHECKCONSIGN_BASEINFO T
 WHERE T.HEAT_NO = {0}
   AND T.CONTRACT_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.CHECK_NO LIKE '%L%'
        ]]>
    </query>
    <query id = "JdgQcmZcCheckconsign.deletePipeBase" desc = "删除委托信息">
    DECLARE
BEGIN
DELETE FROM PIPE_CHECKCONSIGN_BASEINFO T WHERE T.CHECK_NO = '#CHECK_NO#';
DELETE FROM PIPE_CHECKCONSIGN_DETAIL T WHERE T.CHECK_NO = '#CHECK_NO#';
DELETE FROM PIPE_CHECKCONSIGN_CHEMDETAIL T WHERE T.CHECK_NO = '#CHECK_NO#';
DELETE FROM PIPE_CHECKCONSIGN_PHYDETAIL T WHERE T.CHECK_NO = '#CHECK_NO#';
END;
    </query>
    
    <query id="JdgQcmZcCheckconsign.getByLotNo" desc="通过生产批号查询">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T2
 WHERE T2.CHECK_NO IN
       (SELECT MIN(T.CHECK_NO)
          FROM QCM_ZC_CHECKCONSIGN T
         WHERE T.LOT_NO = {0}
           AND ({1} IS NULL OR T.LOT_NO_GROUP = {1})
           AND T.CRAFT_SOURCE = {2}
           AND T.PROCESS_CODE = {3}
         GROUP BY T.JUDGE_STOVE_NO, T.BATCH_NO, T.ORD_LN_DLY_PK)
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getByJudgeStoveNo" desc="通过炉号查询">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T2
 WHERE T2.CHECK_NO IN
       (SELECT MIN(T.CHECK_NO) CHECK_NO
          FROM QCM_ZC_CHECKCONSIGN T
         WHERE T.JUDGE_STOVE_NO = {0}
           AND T.CRAFT_SOURCE = {1}
           AND T.PROCESS_CODE = {2}
         GROUP BY T.BATCH_NO, T.ORD_LN_DLY_PK)
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getByOrdLnDlyPkPline" desc="通过合同行、产线查询">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T2
 WHERE T2.CHECK_NO IN
       (SELECT MIN(T.CHECK_NO)
          FROM QCM_ZC_CHECKCONSIGN T, PLN_SALEORD A, PLN_SALEORD A2
         WHERE T.PLINE_CODE = {1}
           AND T.CRAFT_SOURCE = {2}
           AND T.PROCESS_CODE = {3}
           AND A.ORD_LN_DLY_PK = {0}
           AND A2.ORD_LN_PK = A.ORD_LN_PK
           AND T.ORD_LN_DLY_PK = A2.ORD_LN_DLY_PK
         GROUP BY T.LOT_NO, T.JUDGE_STOVE_NO, T.BATCH_NO, T.ORD_LN_DLY_PK)
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getMaxGroupCheckNo" desc="通过炉批查询最小的检验单号">
        <![CDATA[
SELECT MAX(T.CHECK_NO) CHECK_NO
    FROM QCM_ZC_CHECKCONSIGN T
   WHERE T.JUDGE_STOVE_NO = {0}
     AND T.BATCH_NO = {1}
     AND T.CRAFT_SOURCE = {2}
     AND T.PROCESS_CODE = {3}
     AND T.IS_FLAG = '0'
     AND T.CHECK_NO LIKE '%P%'
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.getMaxLkCheckNo" desc="通过炉批查询最小的检验单号">
        <![CDATA[
SELECT MAX(T.CHECK_NO) CHECK_NO
    FROM QCM_ZC_CHECKCONSIGN T
   WHERE T.JUDGE_STOVE_NO = {0}
     AND T.BATCH_NO = {1}
     AND T.CRAFT_SOURCE = {2}
     AND T.PROCESS_CODE = {3}
     AND T.CHECK_NO LIKE '%' || {4}
     AND T.IS_FLAG = '0'
     AND T.CHECK_NO LIKE '%L%'
        ]]>
    </query>
    
        <query id="JdgQcmZcCheckconsign.getMaxLkCheckNoNew" desc="通过炉批查询最小的检验单号">
        <![CDATA[
SELECT MAX(T.CHECK_NO) CHECK_NO
    FROM QCM_ZC_CHECKCONSIGN T
   WHERE T.JUDGE_STOVE_NO = {0}
     AND T.CRAFT_SOURCE = {1}
     AND T.PROCESS_CODE = {2}
     AND T.CHECK_NO LIKE '%' || {3}
     AND T.IS_FLAG = '0'
     AND T.CHECK_NO LIKE '%L%'
        ]]>
    </query>
    
     <query id="JdgQcmZcCheckconsign.setCraftInfo" desc="修改工艺信息">
        <![CDATA[
 UPDATE QCM_ZC_CHECKCONSIGN T
    SET T.CRAFT_SEQ      = {1},
        T.CRAF_NO        = {2},
        T.CIC            = {3},
        T.STEEL_STANDRAD = {4}
  WHERE EXISTS (SELECT 1
           FROM PLN_SALEORD A
          WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
            AND A.ORD_LN_PK = {0})
        ]]>
    </query>
    
    <query id="JdgQcmZcCheckconsign.setCraftSeq" desc="修改工艺版本">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.CRAF_NO        = {4},
       T.CRAFT_SEQ      = {5},
       T.CIC            = {6},
       T.PIC            = {7},
       T.STEEL_STANDRAD = {8}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.ORD_LN_DLY_PK = {3}
        ]]>
    </query>
    <query id = "JdgQcmZcCheckconsign.selectMilPlan" desc = "查询轧管炉计划标识">
SELECT COUNT(1) ACOUNT
  FROM PLN_ZY_ZG_M T
 WHERE T.HEAT_PLAN_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
    </query>
    <query id = "JdgQcmZcCheckconsign.selectDbkPlan" desc = "查询镦拔扩炉计划标识">
    SELECT COUNT(1) ACOUNT
  FROM PLN_ZY_DBK_M T
 WHERE T.HEAT_PLAN_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.IF_MATCH_ODD IN ('0', '1')
    </query>
    <query id = "JdgQcmZcCheckconsign.selectRclPlan" desc = "查询热处理炉计划标识">
       SELECT COUNT(1) ACOUNT
     FROM PLN_ZY_RCL_M T
    WHERE T.HEAT_PLAN_NO = {0}
      AND T.JUDGE_STOVE_NO = {1}
      AND T.IF_MATCH_ODD IN ('0', '1')
    </query>
     <query id = "JdgQcmZcCheckconsign.selectJgxPlan" desc = "查询热处理炉计划标识">
       SELECT COUNT(1) ACOUNT
     FROM PLN_ZY_JGX_M T
    WHERE T.HEAT_PLAN_NO = {0}
      AND T.JUDGE_STOVE_NO = {1}
      AND T.IF_MATCH_ODD IN ('0', '1')
    </query>
    <query id = "JdgQcmZcCheckconsign.setIsFlag" desc = "修改有效标识">
UPDATE QCM_ZC_CHECKCONSIGN T SET T.IS_FLAG = '1' WHERE T.CHECK_NO = {0}
    </query>
</queryMap>