<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="PLN_STEELFORFURNACE （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="PlnSteelforfurnaceDAL.QueryCic" desc="查询">
        <![CDATA[
SELECT T.FURNACENO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       DECODE(T.STATUS,
              '0',
              '组炉',
              '1',
              '组浇',
              '2',
              '下发',
              '3',
              '生产中',
              '4',
              '生产完成') STATUS,
       T.GRADECODE,
       T.GRADENAME,
       T.QUANTITY,
       T.WEIGHT,
       T.AIM_STEEL_QTY,
       T.CAST_NO,
       T.CAST_SEQ,
       TO_CHAR(T.STARTTIME, 'YYYY-MM-DD HH24:MI:SS') STARTTIME,
       TO_CHAR(T.ENDTIME, 'YYYY-MM-DD HH24:MI:SS') ENDTIME,
       TO_CHAR(T.BOF_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_STARTTIME,
       TO_CHAR(T.BOF_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_ENDTIME,
       TO_CHAR(T.CAS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_STARTTIME,
       TO_CHAR(T.CAS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_ENDTIME,
       TO_CHAR(T.VD_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') VD_STARTTIME,
       TO_CHAR(T.VD_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') VD_ENDTIME,
       TO_CHAR(T.RH_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') RH_STARTTIME,
       TO_CHAR(T.RH_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') RH_ENDTIME,
       TO_CHAR(T.LFS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_STARTTIME,
       TO_CHAR(T.LFS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_ENDTIME,
       TO_CHAR(T.CCM_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_STARTTIME,
       TO_CHAR(T.CCM_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_ENDTIME,
       DECODE(T.CASTINGTYPE, '1', '连铸', '2', '模铸') CASTINGTYPE,
       T.CCMID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CIC,
       DECODE(T.SURPLUSFLAG, '0', '否', '1', '是') SURPLUSFLAG,
       DECODE(T.IF_MONITOR_LG, '0', '否', '1', '是') IF_MONITOR_LG,
       T.PRDCR_NO,
       T.PLANREMARK,
       T.REMARK,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.EF_AGE,
       T.STOVE_NO,
       T.CHEM_JUDGE_ID,
       DECODE(T.CHEM_JUDGE_ID, NULL, '未判', '已判') JUDGE_STATE,
       B.BASENAME JUDGE_RESULT
  FROM PLN_STEELFORFURNACE T
  LEFT JOIN QCM_LG_CHEMJUDGE A
    ON A.CHEM_JUDGE_ID = T.CHEM_JUDGE_ID
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = A.JUDGERESULT_CHEM
 WHERE 1 = 1
        ]]>
    </query>
    
    <query id="PlnSteelforfurnaceDAL.QueryPic" desc="查询">
        <![CDATA[
SELECT T.FURNACENO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       DECODE(T.STATUS,
              '0',
              '组炉',
              '1',
              '组浇',
              '2',
              '下发',
              '3',
              '生产中',
              '4',
              '生产完成') STATUS,
       T.GRADECODE,
       T.GRADENAME,
       T.QUANTITY,
       T.WEIGHT,
       T.AIM_STEEL_QTY,
       T.CAST_NO,
       T.CAST_SEQ,
       TO_CHAR(T.STARTTIME, 'YYYY-MM-DD HH24:MI:SS') STARTTIME,
       TO_CHAR(T.ENDTIME, 'YYYY-MM-DD HH24:MI:SS') ENDTIME,
       TO_CHAR(T.BOF_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_STARTTIME,
       TO_CHAR(T.BOF_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_ENDTIME,
       TO_CHAR(T.CAS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_STARTTIME,
       TO_CHAR(T.CAS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_ENDTIME,
       TO_CHAR(T.VD_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') VD_STARTTIME,
       TO_CHAR(T.VD_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') VD_ENDTIME,
       TO_CHAR(T.RH_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') RH_STARTTIME,
       TO_CHAR(T.RH_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') RH_ENDTIME,
       TO_CHAR(T.LFS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_STARTTIME,
       TO_CHAR(T.LFS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_ENDTIME,
       TO_CHAR(T.CCM_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_STARTTIME,
       TO_CHAR(T.CCM_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_ENDTIME,
       DECODE(T.CASTINGTYPE, '1', '连铸', '2', '模铸') CASTINGTYPE,
       T.CCMID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       DECODE(T.SURPLUSFLAG, '0', '否', '1', '是') SURPLUSFLAG,
       DECODE(T.IF_MONITOR_LG, '0', '否', '1', '是') IF_MONITOR_LG,
       T.PRDCR_NO,
       DECODE(T.IF_BATCHED_ZG,
              '0',
              '未组批',
              '1',
              '已组批',
              '2',
              '坯料下线') IF_BATCHED_ZG,
       T.PLANREMARK,
       T.REMARK,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.EF_PLINE_CODE,
       T.EF_PLINE_NAME,
       T.EF_WORK_SEQ,
       T.EF_AGE,
       T.STOVE_NO,
       T.CHEM_JUDGE_ID,
       DECODE(T.CHEM_JUDGE_ID, NULL, '未判', '已判') JUDGE_STATE,
       B.BASENAME JUDGE_RESULT
  FROM PLN_STEELFORFURNACE T
  LEFT JOIN QCM_LG_PHYJUDGE A
    ON A.PHY_JUDGE_ID = T.CHEM_JUDGE_ID
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = A.JUDGERESULT_PHY
 WHERE 1 = 1
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.QueryStoveNo" desc="查询">
        <![CDATA[
SELECT T.STOVE_NO,
       DECODE(T.CHEM_JUDGE_ID, NULL, '未判', '已判') JUDGE_STATE,
       B.BASENAME JUDGE_RESULT
  FROM PLN_STEELFORFURNACE T
  LEFT JOIN QCM_LG_CHEMJUDGE A
    ON A.CHEM_JUDGE_ID = T.CHEM_JUDGE_ID
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = A.JUDGERESULT_CHEM
 WHERE 1 = 1
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.FURNACENO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.WLID_IN,
       T.WLDESC_IN,
       T.STATUS,
       T.GRADECODE,
       T.GRADENAME,
       T.QUANTITY,
       T.WEIGHT,
       T.AIM_STEEL_QTY,
       T.CAST_NO,
       T.CAST_SEQ,
       TO_CHAR(T.STARTTIME, 'YYYY-MM-DD HH24:MI:SS') STARTTIME,
       TO_CHAR(T.ENDTIME, 'YYYY-MM-DD HH24:MI:SS') ENDTIME,
       TO_CHAR(T.BOF_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_STARTTIME,
       TO_CHAR(T.BOF_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') BOF_ENDTIME,
       TO_CHAR(T.CAS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_STARTTIME,
       TO_CHAR(T.CAS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CAS_ENDTIME,
       TO_CHAR(T.VD_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') VD_STARTTIME,
       TO_CHAR(T.VD_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') VD_ENDTIME,
       TO_CHAR(T.RH_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') RH_STARTTIME,
       TO_CHAR(T.RH_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') RH_ENDTIME,
       TO_CHAR(T.LFS_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_STARTTIME,
       TO_CHAR(T.LFS_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') LFS_ENDTIME,
       TO_CHAR(T.CCM_STARTTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_STARTTIME,
       TO_CHAR(T.CCM_ENDTIME, 'YYYY-MM-DD HH24:MI:SS') CCM_ENDTIME,
       T.CASTINGTYPE,
       T.CCMID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.SURPLUSFLAG,
       T.IF_MONITOR_LG,
       T.PRDCR_NO,
       T.IF_BATCHED_ZG,
       T.PLANREMARK,
       T.REMARK,
       T.MAKEMAN,
       TO_CHAR(T.MAKETIME, 'YYYY-MM-DD HH24:MI:SS') MAKETIME,
       T.STOVE_NO,
       T.CHEM_JUDGE_ID
 FROM PLN_STEELFORFURNACE T
 WHERE
       T.FURNACENO = {0}
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.Insert" desc="新增">
        <![CDATA[
 INSERT INTO PLN_STEELFORFURNACE(
        FURNACENO,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        WLID_IN,
        WLDESC_IN,
        STATUS,
        GRADECODE,
        GRADENAME,
        QUANTITY,
        WEIGHT,
        AIM_STEEL_QTY,
        CAST_NO,
        CAST_SEQ,
        STARTTIME,
        ENDTIME,
        BOF_STARTTIME,
        BOF_ENDTIME,
        CAS_STARTTIME,
        CAS_ENDTIME,
        VD_STARTTIME,
        VD_ENDTIME,
        RH_STARTTIME,
        RH_ENDTIME,
        LFS_STARTTIME,
        LFS_ENDTIME,
        CCM_STARTTIME,
        CCM_ENDTIME,
        CASTINGTYPE,
        CCMID,
        PLINE_CODE,
        PLINE_NAME,
        CIC,
        PIC,
        SIC,
        DIC,
        WIC,
        GIC,
        SURPLUSFLAG,
        IF_MONITOR_LG,
        PRDCR_NO,
        IF_BATCHED_ZG,
        PLANREMARK,
        REMARK,
        MAKEMAN,
        MAKETIME,
        STOVE_NO,
        CHEM_JUDGE_ID)
 VALUES( 
        '#FURNACENO#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#MATERIAL_NO#',
        '#MATERIAL_NAME#',
        '#WLID_IN#',
        '#WLDESC_IN#',
        '#STATUS#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#QUANTITY#',
        '#WEIGHT#',
        '#AIM_STEEL_QTY#',
        '#CAST_NO#',
        '#CAST_SEQ#',
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        SYSDATE,
        '#CASTINGTYPE#',
        '#CCMID#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#CIC#',
        '#PIC#',
        '#SIC#',
        '#DIC#',
        '#WIC#',
        '#GIC#',
        '#SURPLUSFLAG#',
        '#IF_MONITOR_LG#',
        '#PRDCR_NO#',
        '#IF_BATCHED_ZG#',
        '#PLANREMARK#',
        '#REMARK#',
        '#MAKEMAN#',
        SYSDATE,
        '#STOVE_NO#',
        '#CHEM_JUDGE_ID#')
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.Update" desc="修改">
        <![CDATA[
 UPDATE PLN_STEELFORFURNACE T
   SET 
        T.FURNACENO = '#FURNACENO#',
        T.PRO_PLAN_ID = '#PRO_PLAN_ID#',
        T.GX_PLAN_NO = '#GX_PLAN_NO#',
        T.MATERIAL_NO = '#MATERIAL_NO#',
        T.MATERIAL_NAME = '#MATERIAL_NAME#',
        T.WLID_IN = '#WLID_IN#',
        T.WLDESC_IN = '#WLDESC_IN#',
        T.STATUS = '#STATUS#',
        T.GRADECODE = '#GRADECODE#',
        T.GRADENAME = '#GRADENAME#',
        T.QUANTITY = '#QUANTITY#',
        T.WEIGHT = '#WEIGHT#',
        T.AIM_STEEL_QTY = '#AIM_STEEL_QTY#',
        T.CAST_NO = '#CAST_NO#',
        T.CAST_SEQ = '#CAST_SEQ#',
        T.STARTTIME = SYSDATE,
        T.ENDTIME = SYSDATE,
        T.BOF_STARTTIME = SYSDATE,
        T.BOF_ENDTIME = SYSDATE,
        T.CAS_STARTTIME = SYSDATE,
        T.CAS_ENDTIME = SYSDATE,
        T.VD_STARTTIME = SYSDATE,
        T.VD_ENDTIME = SYSDATE,
        T.RH_STARTTIME = SYSDATE,
        T.RH_ENDTIME = SYSDATE,
        T.LFS_STARTTIME = SYSDATE,
        T.LFS_ENDTIME = SYSDATE,
        T.CCM_STARTTIME = SYSDATE,
        T.CCM_ENDTIME = SYSDATE,
        T.CASTINGTYPE = '#CASTINGTYPE#',
        T.CCMID = '#CCMID#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PLINE_NAME = '#PLINE_NAME#',
        T.CIC = '#CIC#',
        T.PIC = '#PIC#',
        T.SIC = '#SIC#',
        T.DIC = '#DIC#',
        T.WIC = '#WIC#',
        T.GIC = '#GIC#',
        T.SURPLUSFLAG = '#SURPLUSFLAG#',
        T.IF_MONITOR_LG = '#IF_MONITOR_LG#',
        T.PRDCR_NO = '#PRDCR_NO#',
        T.IF_BATCHED_ZG = '#IF_BATCHED_ZG#',
        T.PLANREMARK = '#PLANREMARK#',
        T.REMARK = '#REMARK#',
        T.MAKEMAN = '#MAKEMAN#',
        T.MAKETIME = SYSDATE,
        T.STOVE_NO = '#STOVE_NO#',
        T.CHEM_JUDGE_ID = '#CHEM_JUDGE_ID#'
 WHERE
       T.FURNACENO = '#FURNACENO#'
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT NVL(MAX(FURNACENO), 0) + 1 MAX_VALUE FROM PLN_STEELFORFURNACE T
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.Delete" desc="作废">
        <![CDATA[
UPDATE PLN_STEELFORFURNACE T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.FURNACENO = '#FURNACENO#'
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE PLN_STEELFORFURNACE T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.FURNACENO = '#FURNACENO#'
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.QueryLgChemMeltingStoveNo" desc="查询熔炼炉号">
        <![CDATA[
SELECT T.STOVE_NO STOVENO,
       (SELECT COUNT(1) FROM STL_INCISION A WHERE A.STOVE_NO = T.STOVE_NO) STL_INCISION_CNT,
       DECODE((SELECT 1
                FROM QCM_LG_CHEMJUDGE B
               WHERE B.STOVE_NO = T.STOVE_NO
                 AND B.VALIDFLAG = '1'
                 AND ROWNUM <= 1),
              NULL,
              '未判',
              '已判') JUDGE_STATE
  FROM PLN_STEELFORFURNACE T
 WHERE T.STOVE_NO IS NOT NULL
   AND ({0} = '0' OR T.STATUS IN {1})
   AND ({2} IS NULL OR T.STOVE_NO LIKE '%' || {2} || '%')
   AND ({3} IS NULL OR T.EF_PLINE_CODE = {3})
   AND ({4} IS NULL OR {4} = '0' AND NOT EXISTS
        (SELECT 1
           FROM QCM_LG_CHEMJUDGE C
          WHERE C.STOVE_NO = T.STOVE_NO
            AND C.VALIDFLAG = '1') OR {4} = '1' AND EXISTS
        (SELECT 1
           FROM QCM_LG_CHEMJUDGE C
          WHERE C.STOVE_NO = T.STOVE_NO
            AND C.VALIDFLAG = '1'))
   AND ({5} IS NULL OR T.STARTTIME >= TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({5} IS NULL OR T.STARTTIME <= TO_DATE({6}, 'YYYY-MM-DD HH24:MI:SS'))
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.QueryLgColligateMeltingStoveNo" desc="查询熔炼炉号">
        <![CDATA[
SELECT T.STOVE_NO STOVENO,
       (SELECT COUNT(1)
          FROM QCM_GP_JUDGE_APPLY A
         WHERE A.STOVE_NO = T.STOVE_NO) STL_INCISION_CNT,
       DECODE((SELECT 1
                FROM QCM_LG_JUDGE B
               WHERE B.STOVE_NO = T.STOVE_NO
                 AND B.VALIDFLAG = '1'
                 AND ROWNUM <= 1),
              NULL,
              '未判',
              '已判') JUDGE_STATE
  FROM PLN_STEELFORFURNACE T
 WHERE T.STOVE_NO IS NOT NULL
   AND ({0} = '0' OR T.STATUS IN {1})
   AND ({2} IS NULL OR T.STOVE_NO LIKE '%' || {2} || '%')
   AND ({3} IS NULL OR T.EF_PLINE_CODE = {3})
   AND ({4} IS NULL OR {4} = '0' AND NOT EXISTS
        (SELECT 1
           FROM QCM_LG_JUDGE C
          WHERE C.STOVE_NO = T.STOVE_NO
            AND C.VALIDFLAG = '1') OR {4} = '1' AND EXISTS
        (SELECT 1
           FROM QCM_LG_JUDGE C
          WHERE C.STOVE_NO = T.STOVE_NO
            AND C.VALIDFLAG = '1'))
   AND ({5} IS NULL OR T.STARTTIME >= TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({5} IS NULL OR T.STARTTIME <= TO_DATE({6}, 'YYYY-MM-DD HH24:MI:SS'))
        ]]>
    </query>
    <query id="PlnSteelforfurnaceDAL.QueryZgColligateMeltingStoveNo" desc="查询熔炼炉号">
        <![CDATA[
SELECT T.STOVE_NO STOVENO,
       (SELECT COUNT(1) FROM QCM_ZG_JUGDE_APPLY A WHERE A.STOVE_NO = T.STOVE_NO) STL_INCISION_CNT
  FROM PLN_STEELFORFURNACE T
 WHERE T.STOVE_NO IS NOT NULL
   AND ({0} = '0' OR T.STATUS IN {1})
   AND ({2} IS NULL OR T.STOVE_NO LIKE '%' || {2} || '%')
   AND ({3} IS NULL OR T.EF_PLINE_CODE = {3})
        ]]>
    </query>
    
    <query id="PlnSteelforfurnaceDAL.updateJudgeFlag" desc="更新炼钢炉次计划表">
		<![CDATA[
UPDATE PLN_STEELFORFURNACE T SET T.JUDGE_FLAG = {0} WHERE T.FURNACENO = {1}
		]]>
	</query>
</queryMap>