<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="成品判定">

    <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="QcmZgJugdeApplyDAL.setJudgeResultZc" desc="回写综合判定记录">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_TOLRESULT_CODE = {4},
       T.JUDGE_TOLRESULT     =
       (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = {4}),
       T.JUDGE_TOLMAKER       = {5},
       T.JUDGE_TOLORDER       = {6},
       T.JUDGE_TOLGROUP       = {7},
       T.JUDGE_TOLMEMO        = {8},
       T.JUGDE_TOLCONVICTED = {9},
       T.JUDGE_FILE_TOLMEMO = {10},
       T.ZC_JUDGE_CONDITION = {11}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.setJudgeTimeZc" desc="回写综合判定时间">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.JUDGE_TOLRESULT_TIME = TO_DATE(DECODE({4}, NULL, NULL, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.setBalYearMonth" desc="修改结转年月">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.BAL_YEAR_MONTH = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
		]]>
    </query>


    <query id="JdgMatBcQcmTrack.setJudgeTolResult" desc="修改成品综合判定结果">
        <![CDATA[

UPDATE MAT_BC_QCMTRACK T
   SET T.JUGDE_TOLCONVICTED   = {4},
       T.JUDGE_TOLSTD_DES     = {5},
       T.JUDGE_TOLRESULT_CODE = {6},
       T.JUDGE_TOLRESULT_TIME = sysdate,
       T.JUDGE_TOLMAKER       = {7},
       T.JUDGE_TOLMEMO        = {8}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CDOE = {2}
   AND T.JUGDE_APPLY_CODE = {3}
        ]]>
    </query>


    <query id="JdgMatBcM.updateTolJudgeResult" desc="更成品判定结果">
        <![CDATA[
UPDATE MAT_BC_M T
   SET T.JUDGE_TOLRESULT_CODE = {3},
       T.JUDGE_TOLRESULT     =
       (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = {3}),
       T.JUDGE_TOLMAKER       = {4},
       T.JUGDE_TOLCONVICTED   = {5}
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.QCM_STAUS = '00'
        ]]>
    </query>


    <query id="JdgMatBcM.updateTolJudgeTime" desc="更成品判定时间">
        <![CDATA[
UPDATE MAT_BC_M T
   SET T.JUDGE_TOLRESULT_TIME = TO_DATE(DECODE({3}, NULL, NULL, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.QCM_STAUS = '00'
        ]]>
    </query>


    <query id="JdgMatBcBackup.updateTolJudgeResult" desc="更新成品判定结果">
        <![CDATA[
 UPDATE MAT_BC_BACKUP T
    SET T.JUDGE_TOLRESULT_CODE = {3},
        T.JUDGE_TOLRESULT      = (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = {3}),
        T.JUDGE_TOLMAKER       = {4},
        T.JUGDE_TOLCONVICTED = {5}
  WHERE T.JUGDE_APPLY_CODE = {0}
    AND T.JUDGE_STOVE_NO = {1}
    AND T.BATCH_NO = {2}
    AND T.QCM_STAUS = '00'
        ]]>
    </query>


    <query id="JdgMatBcBackup.updateTolJudgeTime" desc="更新成品判定时间">
        <![CDATA[
 UPDATE MAT_BC_BACKUP T
    SET T.JUDGE_TOLRESULT_TIME = TO_DATE(DECODE({3}, NULL, NULL, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')
  WHERE T.JUGDE_APPLY_CODE = {0}
    AND T.JUDGE_STOVE_NO = {1}
    AND T.BATCH_NO = {2}
    AND T.QCM_STAUS = '00'
        ]]>
    </query>


    <query id="JdgQcmLkJudgeChange.setAgreeFlag" desc="">
        <![CDATA[
UPDATE QCM_LK_JUDGE_CHANGE T SET T.AGREE_FLAG = {1} WHERE T.JUGDE_APPLY_CODE = {0}
        ]]>
    </query>


    <query id="JdgMatZcM.setJudgeResult" desc="修改判定结果">
        <![CDATA[
UPDATE MAT_ZC_M T
   SET T.JUDGE_RESULT_CODE = {4},
   T.JUDGE_RESULT     =
       (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = {4})
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.BATCH_GROUD_NO = {2}
   AND T.ORD_LN_DLY_PK = {3}
   AND T.JUDGE_RESULT_CODE != '40740701'
        ]]>
    </query>


    <query id="QcmZgJugdeApplyDAL.QueryByBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT T.*,
       T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK, T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>


    <query id="QcmZgJugdeApplyDAL.QueryByBatchNo2" desc="通过批号查询2">
        <![CDATA[
SELECT T.*, T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK, T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND ({3} IS NULL OR T.HEAT_PLAN_NO = {3})
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>

    <query id="QcmZgJugdeApplyDAL.Query" desc="通过成品判定查询">
        <![CDATA[
SELECT T.*,
       T.ORD_LN_DLY_PK PRO_ORD_LN_DLY_PK, T2.PROCESS_DESC
  FROM QCM_ZG_JUGDE_APPLY T
  LEFT JOIN PLN_ZY_DBK_M B
    ON B.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_RCL_M C
    ON C.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JGX_M D
    ON D.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ZY_JG_M E
    ON E.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN COM_BASE_PROCESS T2
    ON T2.PROCESS_CODE = T.PROCESS_CODE
 WHERE T.IS_FLAG = '0'
   AND T.MEMO IS NOT NULL
   AND T.JUDGE_TOLRESULT_CODE IS NULL
   AND T.IS_ALL_SCRAP IN ('7', '8')
        ]]>
    </query>


    <query id="JdgMatZcM.setLkLock" desc="修改利库封锁标志">
        <![CDATA[
UPDATE MAT_ZC_M T
   SET T.LOCK_LIKU = {4},
       T.LOCK_FLAG = {5}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.BATCH_GROUD_NO = {2}
   AND T.ORD_LN_DLY_PK = {3}
        ]]>
    </query>


    <query id="JdgMatBcM.updateBelongZc" desc="更新炼钢、锻造生产物料主表的所属权">
        <![CDATA[
UPDATE MAT_BC_M T
   SET T.BELONG_CODE       = {3},
       T.BELONG_NAME       = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
       AND T.JUDGE_STOVE_NO = {1}
       AND T.BATCH_NO = {2}
       AND T.QCM_STAUS = '00'
       AND T.TARGET = 'A'
        ]]>
    </query>

    <query id="JdgMatBcBackup.updateBelongZc" desc="更新炼钢、锻造生产物料历史表的所属权">
        <![CDATA[
UPDATE MAT_BC_BACKUP T
   SET T.BELONG_CODE       = {3},
       T.BELONG_NAME       = {4}
 WHERE T.JUGDE_APPLY_CODE = {0}
       AND T.JUDGE_STOVE_NO = {1}
       AND T.BATCH_NO = {2}
       AND T.QCM_STAUS = '00'
       AND T.TARGET = 'A'
        ]]>
    </query>

    <query id="JdgCouplingMatM.setTolJudgeInfo" desc="修改成品判定信息">
        <![CDATA[
UPDATE COUPLING_MAT_M T
   SET T.JUDGE_TOLRESULT_CODE = '#JUDGE_TOLRESULT_CODE#',
       T.JUDGE_TOLRESULT      = (SELECT BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = '#JUDGE_TOLRESULT_CODE#'),
       T.JUDGE_TOLRESULT_TIME = TO_DATE(DECODE('#JUDGE_TOLRESULT_CODE#', NULL, NULL, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS'),
       T.judge_tolmaker       = '#JUDGE_TOLMAKER#',
       T.JUGDE_TOLCONVICTED   = '#JUGDE_TOLCONVICTED#'
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.DETER_NO = '#DETER_NO#'
   AND T.WO_ID = '#WO_ID#'
		]]>
    </query>


    <query id="QcmZgJugdeApplyDAL.QueryGroupInfoByBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT) ACT_THEORY_WEIGHT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUGDE_APPLY_CODE = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
 GROUP BY T.JUGDE_APPLY_CODE, T.JUDGE_STOVE_NO, T.BATCH_NO
        ]]>
    </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.setZbsFlagByJudgeStoveNo" desc="修改质保书标志">
        <![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
    SET T.ZBS_FLAG = {2}
    WHERE T.JUDGE_STOVE_NO = {0}
      AND T.PROCESS_CODE = {1}
      AND T.IS_FLAG = '0'
      AND T.IS_ALL_SCRAP IN ('0', '4', '5', '6', '7', '8')
        ]]>
    </query>


    <query id="JdgMatBcM.setZbsFlagByJudgeStoveNo" desc="修改质保书标志">
        <![CDATA[
UPDATE MAT_BC_M T
   SET T.ZBS_FLAG = {2}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.QCM_STAUS = '00'
        ]]>
    </query>


    <query id="JdgMatBcBackup.setZbsFlagByJudgeStoveNo" desc="修改质保书标志">
        <![CDATA[
UPDATE MAT_BC_BACKUP T
   SET T.ZBS_FLAG = {2}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.QCM_STAUS = '00'
        ]]>
    </query>


    <query id="JdgMatZcM.setZbsFlagNoPk" desc="修改质保书FLAG">
        <![CDATA[
UPDATE MAT_ZC_M T
   SET T.ZBS_FLAG = {4}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.BATCH_GROUD_NO = {2}
        ]]>
    </query>


    <query id="JdgPlnZyZgM.queryUpperByPk" desc="查询炉计划">
        <![CDATA[
SELECT T.UPPER_HEATPLAN_ID, T.UPPER_PROCESS_CODE FROM PLN_ZY_ZG_M T WHERE T.HEAT_PLAN_NO = {0}
        ]]>
    </query>


    <query id="JdgPlnZyDbkM.queryUpperByPk" desc="查询炉计划">
        <![CDATA[
SELECT T.UPPER_HEATPLAN_ID, T.UPPER_PROCESS_CODE FROM PLN_ZY_DBK_M T WHERE T.HEAT_PLAN_NO = {0}
        ]]>
    </query>


    <query id="JdgPlnZyRclM.queryUpperByPk" desc="查询炉计划">
        <![CDATA[
SELECT T.UPPER_HEATPLAN_ID, T.UPPER_PROCESS_CODE FROM PLN_ZY_RCL_M T WHERE T.HEAT_PLAN_NO = {0}
        ]]>
    </query>


    <query id="JdgPlnZyJgxM.queryUpperByPk" desc="查询炉计划">
        <![CDATA[
SELECT T.UPPER_HEATPLAN_ID, T.UPPER_PROCESS_CODE FROM PLN_ZY_JGX_M T WHERE T.HEAT_PLAN_NO = {0}
        ]]>
    </query>

    <query id="JdgPlnZyJgM.queryUpperByPk" desc="查询炉计划">
        <![CDATA[
SELECT T.UPPER_HEATPLAN_ID, T.UPPER_PROCESS_CODE FROM PLN_ZY_JG_M T WHERE T.HEAT_PLAN_NO = {0}
        ]]>
    </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="JdgQcmGpJudgeChange.getJudgeStoveNo" desc="查询改判前炉号">
        <![CDATA[
SELECT T.JUDGE_STOVE_NO FROM QCM_GP_JUDGE_CHANGE T WHERE T.JUDGE_STOVE_NO_GP = {0}
AND T.VALID_FLAG = '1'
		]]>
    </query>

    <query id="JdgQcmJudgeLock.getLockInfo" desc="查询">
        <![CDATA[
SELECT T.*, A.USERNAME LOCK_NAME
   FROM QCM_JUDGE_LOCK T
   LEFT JOIN CORE_APP_USER A
     ON A.USERID = T.LOCK_USER_ID
  WHERE T.JUDGE_STOVE_NO = {0}
    AND (T.BATCH_NO IS NULL OR T.BATCH_NO = {1})
    AND T.PROCESS_CODE = {2}
    AND T.LOCK_PROCESS_CODE = {3}
    AND T.LOCK_FLAG = '1'
        ]]>
    </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.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.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>

</queryMap>