<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_ZC_JUDGE （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
	<query id="JdgQcmZcJudge.queryCntByJudgeStoveNo" desc="通过判定炉号查询个数">
        <![CDATA[
SELECT COUNT(1)
  FROM QCM_ZC_JUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    <query id="JdgQcmZcJudge.Query" desc="查询">
        <![CDATA[
SELECT MIN(T.JUDGE_ID) JUDGE_ID,
       MIN(T.STOVE_NO) STOVE_NO,
       MIN(T.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
       MIN(T.BATCH_NO) BATCH_NO,
       MIN(T.OBJECTNO2) OBJECTNO2,
       MIN(T.PLINE_CODE) PLINE_CODE,
       MIN(E.PLINE_NAME) PLINE_NAME,
       MIN(T.PROCESS_CDOE) PROCESS_CDOE,
       MIN(T.PROCESS_DESC) PROCESS_DESC,
       MIN(A.BASENAME) CHEM_RESULT,
       MIN(T.CHEM_RESULT) CHEM_RESULT_CODE,
       MIN(B.BASENAME) PHY_RESULT,
       MIN(T.PHY_RESULT) PHY_RESULT_CODE,
       MIN(C.BASENAME) FACE_RESULT,
       MIN(D.BASENAME) SPEC_RESULT,
       MIN(F.BASENAME) JUDGE_RESULT,
       MIN(T.JUDGE_RESULT) JUDGE_RESULT_CODE,
       MIN(T.ASSAYNO) ASSAYNO,
       MIN(T.PHY_RESULT_ID) PHY_RESULT_ID,
       MIN(T.MEMO) MEMO,
       MIN(T.VALIDFLAG) VALIDFLAG,
       DECODE(MIN(T.VALIDFLAG), '1', '有效', '0', '无效') VALIDFLAG_DESC,
       MIN(T.CREATE_NAME) CREATE_NAME,
       TO_CHAR(MIN(T.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       MIN(T.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
       SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT,
       MIN(T2.ACT_DIMATER) ACT_DIMATER,
       MIN(T2.ACT_HEIGHT) ACT_HEIGHT,
       MIN(T3.ORDER_NO) || '/' || MIN(T3.ORDER_SEQ) ORDER_NO,
       MIN(T2.GRADENAME) GRADENAME,
       MIN(T2.STEELNAME) STEELNAME,
       MIN(T2.TARGET) TARGET
  FROM QCM_ZC_JUDGE T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.CHEM_RESULT
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = T.PHY_RESULT
  LEFT JOIN COM_BASE_INFO C
    ON C.BASECODE = T.FACE_RESULT
  LEFT JOIN COM_BASE_INFO D
    ON D.BASECODE = T.SPEC_RESULT
  LEFT JOIN COM_BASE_PLINE E
    ON E.PLINE_CODE = T.PLINE_CODE
  LEFT JOIN COM_BASE_INFO F
    ON F.BASECODE = T.JUDGE_RESULT
  LEFT JOIN QCM_ZG_JUGDE_APPLY T2
    ON T2.JUGDE_APPLY_CODE = T.JUGDE_APPLY_CODE
   AND T2.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND T2.BATCH_NO = T.BATCH_NO
   AND T2.PROCESS_CODE = T.PROCESS_CDOE
   AND T2.IS_FLAG = '0'
  LEFT JOIN PLN_SALEORD T3
    ON T3.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
 WHERE ({0} IS NULL OR T.BATCH_NO LIKE '%' || {0} || '%')
   AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
   AND ({2} IS NULL OR T.JUDGE_RESULT = {2})
   AND ({3} IS NULL OR
       T.CREATE_TIME >= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS') AND
       T.CREATE_TIME <= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({5} = '0' OR T.PLINE_CODE IN {6})
   AND T.VALIDFLAG = '1'
   AND T.ORD_LN_DLY_PK NOT LIKE 'ZZB%'
   GROUP BY T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO
   ORDER BY MIN(T.JUDGE_ID) DESC
        ]]>
    </query>
    
    <query id="JdgQcmZcJudge.updateValid" desc="修改有效标志">
        <![CDATA[
UPDATE QCM_ZC_JUDGE T
   SET T.VALIDFLAG = {3}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.JUGDE_APPLY_CODE = {2}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="JdgQcmZcJudge.GetMaxPk0" desc="获取最大主键(刷新尾号是0)">
        <![CDATA[
SELECT  NVL(SUBSTR(MAX(T.JUDGE_ID), 1, 13), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 || '0' MAX_VALUE
  FROM QCM_ZC_JUDGE T
 WHERE T.JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
        ]]>
    </query>
    
    <query id="JdgQcmZcJudge.GetMaxPk1" desc="获取最大主键（判定尾号是1）">
        <![CDATA[
SELECT  NVL(SUBSTR(MAX(T.JUDGE_ID), 1, 13), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 || '1' MAX_VALUE
  FROM QCM_ZC_JUDGE T
 WHERE T.JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
        ]]>
    </query>
    
    <query id="JdgQcmZcJudge.Insert" desc="新增记录">
        <![CDATA[
INSERT INTO QCM_ZC_JUDGE
  (JUDGE_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   OBJECTNO2,
   PLINE_CODE,
   PROCESS_CDOE,
   PROCESS_DESC,
   CHEM_RESULT,
   PHY_RESULT,
   FACE_RESULT,
   SPEC_RESULT,
   DETECT_RESULT,
   WATER_RESULT,
   PROCESS_RESULT,
   JUDGE_RESULT,
   ASSAYNO,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   CHEM_JUDGE_ID,
   PHY_RESULT_ID,
   OLD_GRADECODE,
   OLD_GRADENAME,
   OLD_CIC,
   DETECT_RESULT2,
   ZG_JUDGE_ID,
   ZG_APPLY_CODE,
   DBK_JUDGE_ID,
   DBK_APPLY_CODE,
   RCL_JUDGE_ID,
   RCL_APPLY_CODE,
   JGX_JUDGE_ID,
   JGX_APPLY_CODE,
   DELIVERY_STATE_CODE,
   DELIVERY_STATE_NAME,
   JUGDE_APPLY_CODE,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   ORD_LN_DLY_PK)
VALUES
  ('#JUDGE_ID#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#OBJECTNO2#',
   '#PLINE_CODE#',
   '#PROCESS_CDOE#',
   (SELECT T.PROCESS_DESC
  FROM COM_BASE_PROCESS T
 WHERE T.PROCESS_CODE = '#PROCESS_CDOE#'),
   '#CHEM_RESULT#',
   '#PHY_RESULT#',
   '#FACE_RESULT#',
   '#SPEC_RESULT#',
   '#DETECT_RESULT#',
   '#WATER_RESULT#',
   '#PROCESS_RESULT#',
   '#JUDGE_RESULT#',
   '#ASSAYNO#',
   '#MEMO#',
   '#CREATE_NAME#',
   SYSDATE,
   '#CHEM_JUDGE_ID#',
   '#PHY_RESULT_ID#',
   '#OLD_GRADECODE#',
   '#OLD_GRADENAME#',
   '#OLD_CIC#',
   '#DETECT_RESULT2#',
   '#ZG_JUDGE_ID#',
   '#ZG_APPLY_CODE#',
   '#DBK_JUDGE_ID#',
   '#DBK_APPLY_CODE#',
   '#RCL_JUDGE_ID#',
   '#RCL_APPLY_CODE#',
   '#JGX_JUDGE_ID#',
   '#JGX_APPLY_CODE#',
   '#DELIVERY_STATE_CODE#',
   '#DELIVERY_STATE_NAME#',
   '#JUGDE_APPLY_CODE#',
   '#ACT_COUNT#',
   '#ACT_WEIGHT#',
   '#ACT_THEORY_WEIGHT#',
   '#ORD_LN_DLY_PK#')
        ]]>
    </query>
    
    <query id="JdgQcmZcJudge.updateMemo" desc="修改备注">
        <![CDATA[
UPDATE QCM_ZC_JUDGE T
   SET T.MEMO = {3}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="JdgQcmZcJudge.getByPk" desc="通过主键查询">
        <![CDATA[
SELECT T.* FROM QCM_ZC_JUDGE T WHERE T.JUDGE_ID = {0}
        ]]>
    </query>
    
    <query id="JdgQcmZcJudge.getByBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT T.* FROM QCM_ZC_JUDGE T WHERE T.JUDGE_STOVE_NO = {0}
AND T.BATCH_NO = {1} AND T.PROCESS_CDOE = {2}
AND T.JUGDE_APPLY_CODE = {3}
AND T.VALIDFLAG = '1'
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.updateDeliveryStateZG" desc="修改生产批号">
        update QCM_ZG_JUGDE_APPLY T
        set T.DELIVERY_STATE_CODE = {3},
            t.DELIVERY_STATE_NAME = (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = {3} AND VALIDFLAG = '1' AND ROWNUM =1)
        WHERE T.JUDGE_STOVE_NO = {0}
        AND T.BATCH_NO = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.updateZcLotNo" desc="修改生产批号">
        update QCM_ZC_CHECKCONSIGN T set T.LOT_NO = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.check_No = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>
    <query id="QcmZgJugdeApplyDAL.updateZgLotNo" desc="修改生产批号">
        update QCM_ZG_JUGDE_APPLY T set T.LOT_NO = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.BATCH_NO = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.updateZcLotNoGroup" desc="修改炉归组">
        update QCM_ZC_CHECKCONSIGN T set T.LOT_NO_GROUP = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.check_No = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>
    <query id="QcmZgJugdeApplyDAL.updateZgLotNoGroup" desc="修改炉归组">
        update QCM_ZG_JUGDE_APPLY T set T.LOT_NO_GROUP = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.BATCH_NO = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.updateZgCic" desc="修改成分索引码">
        update QCM_ZG_JUGDE_APPLY T set T.CIC = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.BATCH_NO = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.updateZgPic" desc="修改理化索引码">
        update QCM_ZG_JUGDE_APPLY T set T.PIC = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.BATCH_NO = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.updateZcCic" desc="修改成分索引码">
        update QCM_ZC_CHECKCONSIGN T set T.CIC = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.check_No = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.updateZcPic" desc="修改理化索引码">
        update QCM_ZC_CHECKCONSIGN T set T.PIC = {3} WHERE T.JUDGE_STOVE_NO = {0}
        AND T.check_No = {1}
        AND T.PROCESS_CODE = {2}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.insertLotNoRecord" desc="修改生产批号记录">
        INSERT INTO QCM_LOT_NO_RECORD(
        ID,
        JUDGE_STOVE_NO,
        BATCH_NO,
        OLD_LOT_NO,
        NEW_LOT_NO,
        CREATE_NAME,
        CREATE_TIME,
        PROCESS_CODE,
        JUDGE_TYPE,FLAG)
        VALUES(
        {7},
        {0},
        {1},
        {4},
        {3},
        {6},
        SYSDATE,
        {2},
        {5},{8})
    </query>


    <query id="QcmZgJugdeApplyDAL.updateCraftNo" desc="修改工艺版本">
        update QCM_ZG_JUGDE_APPLY T set T.CRAFT_SEQ = {0},T.CRAF_NO = {1} WHERE T.JUGDE_APPLY_CODE = {2} and T.JUDGE_STOVE_NO = {3}
        AND T.BATCH_NO = {4}
        AND T.IS_FLAG = '0'
    </query>

    <query id="QcmZgJugdeApplyDAL.updateJhyCraftNo" desc="修改工艺版本">
        update QCM_ZC_CHECKCONSIGN T set T.CRAFT_SEQ = {0},T.CRAF_NO = {1} WHERE T.JUDGE_STOVE_NO = {2} and T.check_No = {3}
        AND T.PROCESS_CODE = {4}
        AND T.IS_FLAG = '0'
    </query>

</queryMap>