<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_BC_PHYJUDGE （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="JdgQcmBcPhyjudgeDAL.Query" desc="查询">
        <![CDATA[
SELECT T.PHY_JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.OBJECTNO,
       T.PLINE_CODE,
       B.PLINE_NAME,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.JUDGERESULT_PHY,
       A.BASENAME JUDGERESULT_PHY_DESC,
       T.JUDGESTEELCODE,
       D.STEELNAME JUDGESTEELNAME,
       T.JUDGEGRADECODE,
       C.GRADENAME JUDGEGRADEDESC,
       T.MEMO,
       T.PHY_RESULT_ID,
       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,
       T.BATCH_NO,
       DECODE(T.SAMPLE_TYPE, '1', '初样', '2', '复样') SAMPLE_TYPE,
       T2.BASENAME JF_PHY_RESULT
  FROM QCM_BC_PHYJUDGE T
  LEFT JOIN COM_BASE_INFO T2
    ON T2.BASECODE = T.JF_PHY_RESULT
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.JUDGERESULT_PHY
  LEFT JOIN COM_BASE_PLINE B
    ON B.PLINE_CODE = T.PLINE_CODE
  LEFT JOIN COM_BASE_GRADE C
    ON C.GRADECODE = T.JUDGEGRADECODE
  LEFT JOIN COM_BASE_STEEL D
    ON D.STEELCODE = T.JUDGESTEELCODE
 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.JUDGERESULT_PHY = {2})
   AND ({3} IS NULL OR
       T.CREATE_TIME >= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({4} IS NULL OR
       T.CREATE_TIME <= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({5} = '0' OR T.PLINE_CODE IN {6})
   AND T.PROCESS_CDOE = {7}
   AND T.VALIDFLAG = '1'
 ORDER BY T.PHY_JUDGE_ID DESC
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.PHY_JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.OBJECTNO,
       T.PLINE_CODE,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.JUDGERESULT_PHY,
       T.JUDGESTEELCODE,
       T.JUDGEGRADECODE,
       T.MEMO,
       T.PHY_RESULT_ID,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME
 FROM QCM_BC_PHYJUDGE T
 WHERE
       T.PHY_JUDGE_ID = '#PHY_JUDGE_ID#'
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.Insert" desc="新增">
        <![CDATA[
INSERT INTO QCM_BC_PHYJUDGE
  (PHY_JUDGE_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   OBJECTNO,
   PLINE_CODE,
   PROCESS_CDOE,
   PROCESS_DESC,
   JUDGERESULT_PHY,
   JUDGESTEELCODE,
   JUDGEGRADECODE,
   MEMO,
   PHY_RESULT_ID,
   CREATE_NAME,
   CREATE_TIME,
   JUGDE_APPLY_CODE,
   BATCH_NO,
   HEAT_PLAN_NO,
   DESIGN_KEY,
   MSC_PLINE,
   PIC,
   SAMPLE_NO,
   JUDGE_SEQ,
   PRO_PLAN_ID,
   SAMPLE_TYPE,
   MERGE_PHY_RESULT,
   JF_PHY_RESULT,
   ORD_LN_DLY_PK,
   CRAFT_SEQ,
   SAMPLE_ID,
   LOT_NO,
   CRAFT_SOURCE)
VALUES
  ('#PHY_JUDGE_ID#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#OBJECTNO#',
   '#PLINE_CODE#',
   '#PROCESS_CDOE#',
   (SELECT A.PROCESS_DESC
      FROM COM_BASE_PROCESS A
     WHERE A.PROCESS_CODE = '#PROCESS_CDOE#'),
   '#JUDGERESULT_PHY#',
   '#JUDGESTEELCODE#',
   '#JUDGEGRADECODE#',
   '#MEMO#',
   '#PHY_RESULT_ID#',
   '#CREATE_NAME#',
   SYSDATE,
   '#JUGDE_APPLY_CODE#',
   '#BATCH_NO#',
   '#HEAT_PLAN_NO#',
   '#DESIGN_KEY#',
   '#MSC_PLINE#',
   '#PIC#',
   '#SAMPLE_NO#',
   '#JUDGE_SEQ#',
   '#PRO_PLAN_ID#',
   '#SAMPLE_TYPE#',
   '#MERGE_PHY_RESULT#',
   '#JF_PHY_RESULT#',
   '#ORD_LN_DLY_PK#',
   '#CRAFT_SEQ#',
   '#SAMPLE_ID#',
   '#LOT_NO#',
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.Update" desc="修改">
        <![CDATA[
 UPDATE QCM_BC_PHYJUDGE T
   SET 
        T.PHY_JUDGE_ID = '#PHY_JUDGE_ID#',
        T.STOVE_NO = '#STOVE_NO#',
        T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        T.OBJECTNO = '#OBJECTNO#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PROCESS_CDOE = '#PROCESS_CDOE#',
        T.PROCESS_DESC = '#PROCESS_DESC#',
        T.JUDGERESULT_PHY = '#JUDGERESULT_PHY#',
        T.JUDGESTEELCODE = '#JUDGESTEELCODE#',
        T.JUDGEGRADECODE = '#JUDGEGRADECODE#',
        T.MEMO = '#MEMO#',
        T.PHY_RESULT_ID = '#PHY_RESULT_ID#',
        T.VALIDFLAG = '#VALIDFLAG#',
        T.CREATE_NAME = '#CREATE_NAME#',
        T.CREATE_TIME = SYSDATE
 WHERE
       T.PHY_JUDGE_ID = '#PHY_JUDGE_ID#'
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT NVL(MAX(PHY_JUDGE_ID), 0) + 1 MAX_VALUE FROM QCM_BC_PHYJUDGE T
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.getMaxPhyJudgeId" desc="查询最大的理化判定记录号（人工判定位数为1）">
		<![CDATA[
SELECT NVL(SUBSTR(MAX(T.PHY_JUDGE_ID), 1, 13), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 || '1' MAX_VALUE
  FROM QCM_BC_PHYJUDGE T
 WHERE T.PHY_JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
		]]>
	</query>
	<query id="JdgQcmBcPhyjudgeDAL.getMaxPhyResultId" desc="查询最大的理化判定结果集号">
		<![CDATA[
SELECT NVL(MAX(T.PHY_RESULT_ID), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 MAX_VALUE
  FROM QCM_LG_PHYRESULT T
 WHERE T.PHY_RESULT_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
		]]>
	</query>
    <query id="JdgQcmBcPhyjudgeDAL.Delete" desc="作废">
        <![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.PHY_JUDGE_ID = '#PHY_JUDGE_ID#'
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.PHY_JUDGE_ID = '#PHY_JUDGE_ID#'
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.updatePhyJudgeValid" desc="修改理化判定记录的有效标志">
        <![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET T.VALIDFLAG = {5}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.SAMPLE_NO = {2}
   AND T.SAMPLE_ID = {3}
   AND T.PROCESS_CDOE = {4}
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.updatePhyJudgeValidByCheckNo" desc="修改理化判定记录的有效标志">
        <![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET T.VALIDFLAG = {1}
 WHERE T.SAMPLE_ID = {0}
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.updatePhyResultValid" desc="修改判定明细记录的有效标志">
        <![CDATA[
UPDATE QCM_BC_PHYRESULT T
   SET T.VALIDFLAG = {4}
 WHERE EXISTS (SELECT 1
          FROM QCM_BC_PHYJUDGE A
         WHERE A.SAMPLE_ID = {0}
           AND A.JUDGE_STOVE_NO = {1}
           AND A.BATCH_NO = {2}
           AND A.PROCESS_CDOE = {3}
           AND A.PHY_RESULT_ID = T.PHY_RESULT_ID)
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.updatePhyResultValidByCheckNo" desc="修改判定明细记录的有效标志">
        <![CDATA[
UPDATE QCM_BC_PHYRESULT T
   SET T.VALIDFLAG = {1}
 WHERE EXISTS (SELECT 1
          FROM QCM_BC_PHYJUDGE A
         WHERE A.SAMPLE_ID = {0}
           AND A.PHY_RESULT_ID = T.PHY_RESULT_ID)
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.queryByJudgeStoveNo" desc="">
        <![CDATA[
SELECT *
  FROM QCM_BC_PHYJUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    <query id="JdgQcmBcPhyjudgeDAL.setSampleType" desc="修改试样类型和合并成分结果">
		<![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET T.SAMPLE_TYPE      = DECODE((SELECT COUNT(1)
                                     FROM QCM_BC_PHYJUDGE A
                                    WHERE A.PHY_JUDGE_ID = T.PHY_JUDGE_ID
                                      AND A.SAMPLE_NO LIKE '%F%'),
                                   0,
                                   '1',
                                   '2'),
       T.MERGE_PHY_RESULT = {1}
 WHERE T.PHY_JUDGE_ID = {0}
		]]>
	</query>
	
	<query id="JdgQcmBcPhyJudgeDAL.updateMemo" desc="修改备注">
		<![CDATA[
UPDATE QCM_BC_PHYJUDGE 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="JdgQcmBcPhyJudgeDAL.queryCntByBatchNo" desc="通过批号查询判定记录数">
		<![CDATA[
SELECT COUNT(1) COUNT FROM QCM_BC_PHYJUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.CRAFT_SOURCE IN {3}
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="JdgQcmBcPhyJudgeDAL.queryByBatchNo" desc="通过批号查询判定记录数">
		<![CDATA[
SELECT T.PHY_JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.OBJECTNO,
       T.PLINE_CODE,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.JUDGERESULT_PHY,
       T.JUDGESTEELCODE,
       T.JUDGEGRADECODE,
       T.MEMO,
       T.PHY_RESULT_ID,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.JUGDE_APPLY_CODE,
       T.BATCH_NO,
       T.HEAT_PLAN_NO,
       T.DESIGN_KEY,
       T.MSC_PLINE,
       T.PIC,
       T.SAMPLE_NO,
       T.JUDGE_SEQ,
       T.PRO_PLAN_ID,
       T.SAMPLE_TYPE,
       T.MERGE_PHY_RESULT,
       T.JF_PHY_RESULT
  FROM QCM_BC_PHYJUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="JdgQcmBcPhyJudgeDAL.queryByJudgeId" desc="通过判定ID查询判定记录数">
		<![CDATA[
SELECT T.PHY_JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.OBJECTNO,
       T.PLINE_CODE,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.JUDGERESULT_PHY,
       T.JUDGESTEELCODE,
       T.JUDGEGRADECODE,
       T.MEMO,
       T.PHY_RESULT_ID,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.JUGDE_APPLY_CODE,
       T.BATCH_NO,
       T.HEAT_PLAN_NO,
       T.DESIGN_KEY,
       T.MSC_PLINE,
       T.PIC,
       T.SAMPLE_NO,
       T.JUDGE_SEQ,
       T.PRO_PLAN_ID,
       T.SAMPLE_TYPE,
       T.MERGE_PHY_RESULT,
       T.JF_PHY_RESULT
  FROM QCM_BC_PHYJUDGE T
 WHERE T.PHY_JUDGE_ID = {0}
		]]>
	</query>
	
	<query id="JdgQcmBcPhyjudgeDAL.updatePhyJudge" desc="修改理化判定结果">
        <![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET T.JUDGERESULT_PHY  = {4},
       T.MERGE_PHY_RESULT = {4},
       T.JF_PHY_RESULT = {5}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.SAMPLE_ID = {2}
   AND T.PROCESS_CDOE = {3}
   AND T.VALIDFLAG = '1'
        ]]>
    </query>
</queryMap>