<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_LG_JUDGE （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="QcmLgJudgeDAL.Query" desc="查询">
        <![CDATA[
SELECT T.JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.OBJECTNO2,
       T.PLINE_CODE,
       E.PLINE_NAME,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.JUDGERESULT_CHEM,
       A.BASENAME JUDGERESULT_CHEM_DESC,
       T.JUDGERESULT_PHY,
       B.BASENAME JUDGERESULT_PHY_DESC,
       T.JUDGERESULT_FACE,
       C.BASENAME JUDGERESULT_FACE_DESC,
       T.JUDGERESULT_SPEC,
       D.BASENAME JUDGERESULT_SPEC_DESC,
       T.JUDGERESULT,
       F.BASENAME JUDGERESULT_DESC,
       T.JUDGEREASON,
       T.ASSAYNO,
       T.PHY_RESULT_ID,
       T.MEMO_CHEM,
       T.MEMO_PHY,
       T.MEMO_FACE,
       T.MEMO_SPEC,
       T.MEMO,
       T.VALIDFLAG,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG_DESC,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       (SELECT SUM(ACT_COUNT) FROM QCM_GP_JUDGE_APPLY G WHERE T.JUGDE_APPLY_CODE=G.JUGDE_APPLY_CODE AND T.JUGDE_APPLY_SQE=G.JUGDE_APPLY_SQE) ACT_COUNT,
       (SELECT SUM(ACT_THEORY_WEIGHT) FROM QCM_GP_JUDGE_APPLY G WHERE T.JUGDE_APPLY_CODE=G.JUGDE_APPLY_CODE AND T.JUGDE_APPLY_SQE=G.JUGDE_APPLY_SQE) ACT_WEIGHT,
       (SELECT MAX(PRO_ORDER_NO) FROM QCM_GP_JUDGE_APPLY G WHERE T.JUGDE_APPLY_CODE=G.JUGDE_APPLY_CODE AND T.JUGDE_APPLY_SQE=G.JUGDE_APPLY_SQE) ORDER_NO
  FROM QCM_LG_JUDGE T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.JUDGERESULT_CHEM
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = T.JUDGERESULT_PHY
  LEFT JOIN COM_BASE_INFO C
    ON C.BASECODE = T.JUDGERESULT_FACE
  LEFT JOIN COM_BASE_INFO D
    ON D.BASECODE = T.JUDGERESULT_SPEC
  LEFT JOIN COM_BASE_PLINE E
    ON E.PLINE_CODE = T.PLINE_CODE
  LEFT JOIN COM_BASE_INFO F
    ON F.BASECODE = T.JUDGERESULT
 WHERE ({0} IS NULL OR T.STOVE_NO LIKE '%' || {0} || '%')
   AND ({1} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {1} || '%')
   AND ({2} IS NULL OR T.JUDGERESULT = {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 ({7} IS NULL OR T.CREATE_NAME LIKE '%' || {7} || '%')
   AND T.VALIDFLAG = '1'
   AND EXISTS (SELECT 1 FROM QCM_GP_JUDGE_APPLY G 
   WHERE T.JUGDE_APPLY_CODE=G.JUGDE_APPLY_CODE 
   AND T.JUGDE_APPLY_SQE=G.JUGDE_APPLY_SQE
   AND G.SUPPLY_UNIT_CODE={8})
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.QueryZg" desc="查询轧管综合">
        <![CDATA[
SELECT T.JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.OBJECTNO2,
       T.PLINE_CODE,
       E.PLINE_NAME,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.JUDGERESULT_CHEM,
       A.BASENAME JUDGERESULT_CHEM_DESC,
       T.JUDGERESULT_PHY,
       B.BASENAME JUDGERESULT_PHY_DESC,
       T.JUDGERESULT_FACE,
       C.BASENAME JUDGERESULT_FACE_DESC,
       T.JUDGERESULT_SPEC,
       D.BASENAME JUDGERESULT_SPEC_DESC,
       T.JUDGERESULT,
       F.BASENAME JUDGERESULT_DESC,
       T.JUDGEREASON,
       T.ASSAYNO,
       T.PHY_RESULT_ID,
       T.MEMO_CHEM,
       T.MEMO_PHY,
       T.MEMO_FACE,
       T.MEMO_SPEC,
       T.MEMO,
       T.VALIDFLAG,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG_DESC,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME
  FROM QCM_LG_JUDGE T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.JUDGERESULT_CHEM
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = T.JUDGERESULT_PHY
  LEFT JOIN COM_BASE_INFO C
    ON C.BASECODE = T.JUDGERESULT_FACE
  LEFT JOIN COM_BASE_INFO D
    ON D.BASECODE = T.JUDGERESULT_SPEC
  LEFT JOIN COM_BASE_PLINE E
    ON E.PLINE_CODE = T.PLINE_CODE
  LEFT JOIN COM_BASE_INFO F
    ON F.BASECODE = T.JUDGERESULT
 WHERE ({0} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {0} || '%')
   AND ({1} IS NULL OR T.JUDGERESULT = {1})
   AND ({2} IS NULL OR
       T.CREATE_TIME >= TO_DATE({2}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({3} IS NULL OR
       T.CREATE_TIME <= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS'))
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.OBJECTNO2,
       T.PLINE_CODE,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.JUDGERESULT_CHEM,
       T.JUDGERESULT_PHY,
       T.JUDGERESULT_FACE,
       T.JUDGERESULT_SPEC,
       T.JUDGERESULT,
       T.JUDGEREASON,
       T.ASSAYNO,
       T.PHY_RESULT_ID,
       T.MEMO_CHEM,
       T.MEMO_PHY,
       T.MEMO_FACE,
       T.MEMO_SPEC,
       T.MEMO,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME
 FROM QCM_LG_JUDGE T
 WHERE
       T.JUDGE_ID = '#JUDGE_ID#'
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO QCM_LG_JUDGE(
        JUDGE_ID,
        STOVE_NO,
        JUDGE_STOVE_NO,
        OBJECTNO2,
        PLINE_CODE,
        PROCESS_CDOE,
        PROCESS_DESC,
        JUDGERESULT_CHEM,
        JUDGERESULT_PHY,
        JUDGERESULT_FACE,
        JUDGERESULT_SPEC,
        JUDGERESULT,
        JUDGEREASON,
        ASSAYNO,
        PHY_RESULT_ID,
        MEMO_CHEM,
        MEMO_PHY,
        MEMO_FACE,
        MEMO_SPEC,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        CHEM_JUDGE_ID,
        OLD_GRADECODE,
        OLD_GRADENAME,
        OLD_CIC,
        JUGDE_APPLY_CODE,
        JUGDE_APPLY_SQE)
 VALUES( 
        '#JUDGE_ID#',
        '#STOVE_NO#',
        '#JUDGE_STOVE_NO#',
        '#OBJECTNO2#',
        '#PLINE_CODE#',
        '#PROCESS_CDOE#',
        '#PROCESS_DESC#',
        '#JUDGERESULT_CHEM#',
        '#JUDGERESULT_PHY#',
        '#JUDGERESULT_FACE#',
        '#JUDGERESULT_SPEC#',
        '#JUDGERESULT#',
        '#JUDGEREASON#',
        '#ASSAYNO#',
        '#PHY_RESULT_ID#',
        '#MEMO_CHEM#',
        '#MEMO_PHY#',
        '#MEMO_FACE#',
        '#MEMO_SPEC#',
        '#MEMO#',
        '#CREATE_NAME#',
        SYSDATE,
        '#CHEM_JUDGE_ID#',
        '#OLD_GRADECODE#',
        '#OLD_GRADENAME#',
        '#OLD_CIC#',
        '#JUGDE_APPLY_CODE#',
        '#JUGDE_APPLY_SQE#')
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.Update" desc="修改">
        <![CDATA[
 UPDATE QCM_LG_JUDGE T
   SET 
        T.JUDGE_ID = '#JUDGE_ID#',
        T.STOVE_NO = '#STOVE_NO#',
        T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        T.OBJECTNO2 = '#OBJECTNO2#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PROCESS_CDOE = '#PROCESS_CDOE#',
        T.PROCESS_DESC = '#PROCESS_DESC#',
        T.JUDGERESULT_CHEM = '#JUDGERESULT_CHEM#',
        T.JUDGERESULT_PHY = '#JUDGERESULT_PHY#',
        T.JUDGERESULT_FACE = '#JUDGERESULT_FACE#',
        T.JUDGERESULT_SPEC = '#JUDGERESULT_SPEC#',
        T.JUDGERESULT = '#JUDGERESULT#',
        T.JUDGEREASON = '#JUDGEREASON#',
        T.ASSAYNO = '#ASSAYNO#',
        T.PHY_RESULT_ID = '#PHY_RESULT_ID#',
        T.MEMO_CHEM = '#MEMO_CHEM#',
        T.MEMO_PHY = '#MEMO_PHY#',
        T.MEMO_FACE = '#MEMO_FACE#',
        T.MEMO_SPEC = '#MEMO_SPEC#',
        T.MEMO = '#MEMO#',
        T.VALIDFLAG = '#VALIDFLAG#',
        T.CREATE_NAME = '#CREATE_NAME#',
        T.CREATE_TIME = SYSDATE
 WHERE
       T.JUDGE_ID = '#JUDGE_ID#'
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT NVL(MAX(T.JUDGE_ID), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 MAX_VALUE
  FROM QCM_LG_JUDGE T
 WHERE T.JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.Delete" desc="作废">
        <![CDATA[
UPDATE QCM_LG_JUDGE T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.JUDGE_ID = '#JUDGE_ID#'
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE QCM_LG_JUDGE T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.JUDGE_ID = '#JUDGE_ID#'
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.getChemJudge" desc="获取成分判定记录">
        <![CDATA[
SELECT CHEM_JUDGE_ID,
       STOVE_NO,
       JUDGE_STOVE_NO,
       MAT_NO,
       PLINE_CODE,
       PROCESS_CDOE,
       PROCESS_DESC,
       PLAN_ORDERNO,
       JUDGE_ORDERNO,
       JUDGERESULT_CHEM,
       ORDERISUNCHAIN,
       ASSAYNO,
       VALIDFLAG,
       MEMO,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       JUGDE_APPLY_CODE,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       DESIGN_KEY,
       MSC_PLINE,
       CIC
  FROM QCM_LG_CHEMJUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.getPhyJudge" desc="获取理化判定记录">
        <![CDATA[
SELECT *
  FROM QCM_LG_PHYJUDGE T
 WHERE T.STOVE_NO = {0}
   AND T.PHY_JUDGE_ID = (SELECT MAX(A.PHY_JUDGE_ID)
                           FROM QCM_LG_PHYJUDGE A
                          WHERE A.STOVE_NO = T.STOVE_NO)
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.insertLgPhyJudge" desc="新增轧管判定记录">
        <![CDATA[
INSERT INTO QCM_LG_PHYJUDGE
  (PHY_JUDGE_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   PLINE_CODE,
   PROCESS_CDOE,
   PROCESS_DESC,
   JUDGERESULT_PHY,
   JUDGEGRADECODE,
   MEMO,
   PHY_RESULT_ID,
   CREATE_NAME,
   CREATE_TIME,
   DESIGN_KEY,
   MSC_PLINE,
   PIC,
   SAMPLE_NO,
   JUDGE_SEQ,
   PRO_PLAN_ID)
VALUES
  ('#PHY_JUDGE_ID#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#PLINE_CODE#',
   '#PROCESS_CDOE#',
   '#PROCESS_DESC#',
   '#JUDGERESULT_PHY#',
   '#JUDGEGRADECODE#',
   '#MEMO#',
   '#PHY_RESULT_ID#',
   '#CREATE_NAME#',
   SYSDATE,
   '#DESIGN_KEY#',
   '#MSC_PLINE#',
   '#PIC#',
   '#SAMPLE_NO#',
   '#JUDGE_SEQ#',
   '#PRO_PLAN_ID#')
        ]]>
    </query>
    <query id="QcmLgJudgeDAL.insertLgPhyResult" desc="新增轧管判定结果">
        <![CDATA[
INSERT INTO QCM_LG_PHYRESULT
  (PHY_RESULT_ID,
   PHY_RESULT_SEQ,
   STOVE_NO,
   JUDGE_STOVE_NO,
   PHY_CODE_MAX,
   PHY_CODE_MIN,
   PHY_CODE,
   PHY_NAME,
   VALUE1,
   SAMPLE_ID,
   XH,
   INDEX_SEQ,
   CREATE_NAME,
   CREATE_TIME,
   QUALIFIED,
   NK_RANGE)
VALUES
  ('#PHY_RESULT_ID#',
   '#PHY_RESULT_SEQ#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '/',
   '/',
   '#PHY_CODE#',
   '#PHY_NAME#',
   '#VALUE1#',
   '#SAMPLE_ID#',
   '#XH#',
   '#INDEX_SEQ#',
   '#CREATE_NAME#',
   SYSDATE,
   '#QUALIFIED#',
   '#NK_RANGE#')
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.updateMatGpM" desc="更新炼钢、锻造生产物料主表">
        <![CDATA[
UPDATE MAT_GP_M T
   SET T.JUDGE_RESULT_CODE = {1},
       T.JUDGE_RESULT_TIME = sysdate,
       T.JUDGE_MAKER       = {2},
       T.INSTOCK_FLAG      = {3},
       T.JUGDE_APPLY_FLAG  = {4},
       T.MAT_STATUS        = {5},
       T.FACE_RESULT_CODE  = {6},
       T.FACE_RESULT_TIME  = SYSDATE,
       T.FACE_MAKER        = {7},
       T.CHEM_RESULT_CODE  = {8},
       T.CHEM_RESULT_TIME  = TO_DATE({9}, 'YYYY-MM-DD HH24:MI:SS'),
       T.CHEM_MAKER        = {10},
       T.PHY_RESULT_CODE   = {11},
       T.PHY_RESULT_TIME   = SYSDATE,
       T.PHY_MAKER         = {12},
       T.CHEM_JUDGE_ID     = {13},
       T.PHY_JUDGE_ID      = {14},
       T.PHY_RESULT_ID = {15}
 WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.updateMatGpMInstancy" desc="更新炼钢、锻造生产物料主表的紧急放行标志">
        <![CDATA[
UPDATE MAT_GP_M T
   SET T.INSTANCY_FLAG = {1}
 WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>
    
     <query id="QcmLgJudgeDAL.updateMatGpMBelong" desc="更新炼钢、锻造生产物料主表的所属权">
        <![CDATA[
UPDATE MAT_GP_M T
   SET T.BELONG_CODE       = {1},
       T.BELONG_NAME       = {2}
 WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.updateMatGpMHistory" desc="更新炼钢、锻造生产物料主表">
        <![CDATA[
UPDATE MAT_GP_M_HISTORY T
   SET T.JUDGE_RESULT_CODE = {1},
       T.JUDGE_RESULT_TIME = sysdate,
       T.JUDGE_MAKER       = {2},
       T.INSTOCK_FLAG      = {3},
       T.JUGDE_APPLY_FLAG  = {4},
       T.MAT_STATUS        = {5},
       T.FACE_RESULT_CODE  = {6},
       T.FACE_RESULT_TIME  = SYSDATE,
       T.FACE_MAKER        = {7},
       T.CHEM_RESULT_CODE  = {8},
       T.CHEM_RESULT_TIME  = TO_DATE({9}, 'YYYY-MM-DD HH24:MI:SS'),
       T.CHEM_MAKER        = {10},
       T.PHY_RESULT_CODE   = {11},
       T.PHY_RESULT_TIME   = SYSDATE,
       T.PHY_MAKER         = {12},
       T.CHEM_JUDGE_ID     = {13},
       T.PHY_JUDGE_ID      = {14},
       T.PHY_RESULT_ID = {15}
 WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.updateMatGpMHistoryInstancy" desc="更新炼钢、锻造生产物料主表的紧急放行标志">
        <![CDATA[
UPDATE MAT_GP_M_HISTORY T
   SET T.INSTANCY_FLAG = {1}
 WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.updateMatGpMHistoryBelong" desc="更新炼钢、锻造生产物料主表的所属权">
        <![CDATA[
UPDATE MAT_GP_M T
   SET T.BELONG_CODE       = {1},
       T.BELONG_NAME       = {2}
 WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.updateLgJudgeValid" desc="更新炼钢、锻造生产物料主表">
        <![CDATA[
UPDATE QCM_LG_JUDGE T
   SET T.VALIDFLAG = {2}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.JUGDE_APPLY_CODE = {3}
   AND T.JUGDE_APPLY_SQE = {4}
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.updateMemo" desc="修改备注">
        <![CDATA[
UPDATE QCM_LG_JUDGE T
   SET T.MEMO = {2}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.queryCntByJudgeStoveNo" desc="通过判定炉号查询个数">
        <![CDATA[
SELECT COUNT(1)
  FROM QCM_LG_JUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
     <query id="QcmLgJudgeDAL.queryByJudgeStoveNo" desc="通过判定炉号查询">
        <![CDATA[
SELECT *
  FROM QCM_LG_JUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="QcmLgJudgeDAL.getLgJudgeCountByStoveNo" desc="查询炼钢判定数">
        <![CDATA[
SELECT COUNT(1) COUNT
  FROM QCM_LG_JUDGE T
 WHERE T.STOVE_NO = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
</queryMap>