<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_BC_JUDGE （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
	<query id="JdgQcmBcJudge.queryCntByJudgeStoveNo" desc="通过判定炉号查询个数">
        <![CDATA[
SELECT COUNT(1)
  FROM QCM_BC_JUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    <query id="JdgQcmBcJudge.Query" desc="查询">
        <![CDATA[
SELECT T.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,
       MIN(T.ACT_COUNT) ACT_COUNT,
       MIN(T.ACT_WEIGHT) ACT_WEIGHT,
       MIN(T.DELIVERY_STATE_NAME) DELIVERY_STATE_NAME,
       MIN(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_BC_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  ({7} IS NULL OR t3.ORDER_NO LIKE '%' || {7} || '%')
 GROUP BY T.JUDGE_ID
 ORDER BY T.JUDGE_ID DESC
        ]]>
    </query>
    
    <query id="JdgQcmBcJudge.updateValid" desc="修改有效标志">
        <![CDATA[
UPDATE QCM_BC_JUDGE T
   SET T.VALIDFLAG = {4}
 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="JdgQcmBcJudge.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT NVL(MAX(T.JUDGE_ID), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 MAX_VALUE
  FROM QCM_BC_JUDGE T
 WHERE T.JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
        ]]>
    </query>
    
    <query id="JdgQcmBcJudge.Insert" desc="新增记录">
        <![CDATA[
INSERT INTO QCM_BC_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,
   DELIVERY_STATE_CODE,
   DELIVERY_STATE_NAME,
   JUGDE_APPLY_CODE,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT)
VALUES
  ('#JUDGE_ID#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#OBJECTNO2#',
   '#PLINE_CODE#',
   '#PROCESS_CDOE#',
   (SELECT A.PROCESS_DESC
      FROM COM_BASE_PROCESS A
     WHERE A.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#',
   '#DELIVERY_STATE_CODE#',
   '#DELIVERY_STATE_NAME#',
   '#JUGDE_APPLY_CODE#',
   '#ACT_COUNT#',
   '#ACT_WEIGHT#',
   '#ACT_THEORY_WEIGHT#')
        ]]>
    </query>
    
    <query id="JdgQcmBcJudge.updateMemo" desc="修改备注">
        <![CDATA[
UPDATE QCM_BC_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="JdgQcmBcJudge.getByJudgeStoveNo" desc="通过判定炉号查询">
        <![CDATA[
SELECT * FROM QCM_BC_JUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="JdgQcmBcJudge.getByBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT *
   FROM QCM_BC_JUDGE T
  WHERE T.JUGDE_APPLY_CODE = {0}
    AND T.JUDGE_STOVE_NO = {1}
    AND T.BATCH_NO = {2}
    AND T.PROCESS_CDOE = {3}
    AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="JdgQcmBcJudge.getByJudgeId" desc="通过主键查询">
        <![CDATA[
SELECT T.* FROM QCM_BC_JUDGE T WHERE T.JUDGE_ID = {0}
        ]]>
    </query>
</queryMap>