<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "配料基础信息">
<query id = "FrmTqnqd01.QueryCf" desc = "查询">
with  
t1 as (select *
  from (
  select  chem_name, stdmax
          from CRAFT_LG2_cic
         where cic_gid = ?)
pivot(max(stdmax)
   for chem_name in('C' as maxC,
                    'Si' as MAXSi,
                    'Mn' as MAXMn,
                    'P' as MAXP,
                    'S' as MAXS,
                    'Ni' as MAXNi,
                    'Cr' as MAXCr,
                    'Mo' as MAXMo,
                    'Cu' as MAXCu,
                    'Als' as MAXAls,
                    'Al' as MAXAl,
                    'H' as MAXh,
                    'N' as MAXN,
                    'o' as MAXo,
                    'b' as MAXb,
                    'ca' as MAXca,
                    'bi' as MAXbi,
                    'pb' as MAXpb,
                    'sb' as MAXsb,
                    'Asn' as MAXasn,
                    'Sn' as MAXSn,
                    'NB' AS MAXNB,
                    'V' AS MAXV,
                    'Ti' as MAXTI,
                    'w' as MAXw,
                    'zn' as MAXzn,
                    'co' as MAXco,
                    'ce' as MAXce,
                    'CEⅡw' as MAXCEⅡw,
                    'CEPCM' as MAXCEPCM,
                    'Alt' as MAXalt,
                    'ta' as MAXta,
                    'se' as MAXse,
                    'ceq' as MAXceq,
                    'cev' as MAXcev,
                    'fe' as MAXfe))),
t2 as (select *
  from (select  chem_name, stdmin
          from CRAFT_LG2_cic
         where cic_gid = ?)
pivot(max(stdmin)
   for chem_name in('C' as MINC,
                    'Si' as MINSi,
                    'Mn' as MINMn,
                    'P' as MINP,
                    'S' as MINS,
                    'Ni' as MINNi,
                    'Cr' as MINCr,
                    'Mo' as MINMo,
                    'Cu' as MINCu,
                    'Als' as MINAls,
                    'Al' as MINAl,
                    'H' as MINh,
                    'N' as MINN,
                    'o' as MINo,
                    'b' as MINb,
                    'ca' as MINca,
                    'bi' as MINbi,
                    'pb' as MINpb,
                    'sb' as MINsb,
                    'Asn' as MINasn,
                    'Sn' as MINSn,
                    'NB' AS MINNB,
                    'V' AS MINV,
                    'Ti' as MINTI,
                    'w' as MINw,
                    'zn' as MINzn,
                    'co' as MINco,
                    'ce' as MINce,
                    'CEⅡw' as MINCEⅡw,
                    'CEPCM' as MINCEPCM,
                    'Alt' as MINalt,
                    'ta' as MINta,
                    'se' as MINse,
                    'ceq' as MINceq,
                    'cev' as MINcev,
                    'fe' as MINfe)))
select

CASE WHEN T1.MaxC is not null and t2.minc is not null
THEN
(t1.maxc+t2.minc)/2
else 
(t1.maxc+ nvl(t2.minc,0.00))
end In_C,

CASE WHEN (T1.MAXSi is not null and t2.minSi is not null)
THEN
(t1.maxSi+t2.minSi)/2
else 
(t1.maxSi+nvl(t2.minSi,0.00))
end In_Si,

CASE WHEN (T1.MAXMN is not null and t2.minMN is not null)
THEN
(t1.maxMN+t2.minMN)/2
else 
(t1.maxMN+nvl(t2.minMN,0.00))
end In_MN,

CASE WHEN (T1.MAXP is not null and t2.minP is not null)
THEN
(t1.maxP+t2.minP)/2
else 
(t1.maxP+nvl(t2.minP,0.00))
end In_P,

CASE WHEN (T1.MAXS is not null and t2.minS is not null)
THEN
(t1.maxS+t2.minS)/2
else 
(t1.maxS+nvl(t2.minS,0.00))
end In_S,

CASE WHEN (T1.MAXNi is not null and t2.minNi is not null)
THEN
(t1.maxNi+t2.minNi)/2
else 
(t1.maxNi+nvl(t2.minNi,0.00))
end In_Ni,

CASE WHEN (T1.MAXCr is not null and t2.minCr is not null)
THEN
(t1.maxCr+t2.minCr)/2
else 
(t1.maxCr+nvl(t2.minCr,0.00))
end In_Cr,

CASE WHEN (T1.MAXMo is not null and t2.minMo is not null)
THEN
(t1.maxMo+t2.minMo)/2
else 
(t1.maxMo+nvl(t2.minMo,0.00))
end In_Mo,

CASE WHEN (T1.MAXCu is not null and t2.minCu is not null)
THEN
(t1.maxCu+t2.minCu)/2
else 
(t1.maxCu+nvl(t2.minCu,0.00))
end In_Cu,

CASE WHEN (T1.MAXAls is not null and t2.minAls is not null)
THEN
(t1.maxAls+t2.minAls)/2
else 
(t1.maxAls+nvl(t2.minAls,0.00))
end In_Als,

CASE WHEN (T1.MAXAl is not null and t2.minAl is not null)
THEN
(t1.maxAl+t2.minAl)/2
else 
(t1.maxAl+nvl(t2.minAl,0.00))
end In_Al,

CASE WHEN (T1.MAXH is not null and t2.minH is not null)
THEN
(t1.maxH+t2.minH)/2
else 
(t1.maxH+nvl(t2.minH,0.00))
end In_H,

CASE WHEN (T1.MAXN is not null and t2.minN is not null)
THEN
(t1.maxN+t2.minN)/2
else 
(t1.maxN+nvl(t2.minN,0.00))
end In_N,

CASE WHEN (T1.MAXo is not null and t2.mino is not null)
THEN
(t1.maxo+t2.mino)/2
else 
(t1.maxo+nvl(t2.mino,0.00))
end In_o,

CASE WHEN (T1.MAXb is not null and t2.minb is not null)
THEN
(t1.maxb+t2.minb)/2
else 
(t1.maxb+nvl(t2.minb,0.00))
end In_b,

CASE WHEN (T1.MAXca is not null and t2.minca is not null)
THEN
(t1.maxca+t2.minca)/2
else 
(t1.maxca+nvl(t2.minca,0.00))
end In_ca,

CASE WHEN (T1.MAXbi is not null and t2.minbi is not null)
THEN
(t1.maxbi+t2.minbi)/2
else 
(t1.maxbi+nvl(t2.minbi,0.00))
end In_bi,

CASE WHEN (T1.MAXpb is not null and t2.minpb is not null)
THEN
(t1.maxpb+t2.minpb)/2
else 
(t1.maxpb+nvl(t2.minpb,0.00))
end In_pb,

CASE WHEN (T1.MAXsb is not null and t2.minsb is not null)
THEN
(t1.maxsb+t2.minsb)/2
else 
(t1.maxsb+nvl(t2.minsb,0.00))
end In_sb,

CASE WHEN (T1.MAXAsn is not null and t2.minAsn is not null)
THEN
(t1.maxAsn+t2.minAsn)/2
else 
(t1.maxAsn+nvl(t2.minAsn,0.00))
end In_Asn,

CASE WHEN (T1.MAXSn is not null and t2.minSn is not null)
THEN
(t1.maxSn+t2.minSn)/2
else 
(t1.maxSn+nvl(t2.minSn,0.00))
end In_Sn,

CASE WHEN (T1.MAXNB is not null and t2.minNB is not null)
THEN
(t1.maxNB+t2.minNB)/2
else 
(t1.maxNB+nvl(t2.minNB,0.00))
end In_NB,

CASE WHEN (T1.MAXV is not null and t2.minV is not null)
THEN
(t1.maxV+t2.minV)/2
else 
(t1.maxV+nvl(t2.minV,0.00))
end In_V,

CASE WHEN (T1.MAXTi is not null and t2.minTi is not null)
THEN
(t1.maxTi+t2.minTi)/2
else 
(t1.maxTi+nvl(t2.minTi,0.00))
end In_Ti,

CASE WHEN (T1.MAXw is not null and t2.minw is not null)
THEN
(t1.maxw+t2.minw)/2
else 
(t1.maxw+nvl(t2.minw,0.00))
end In_w,

CASE WHEN (T1.MAXzn is not null and t2.minzn is not null)
THEN
(t1.maxzn+t2.minzn)/2
else 
(t1.maxzn+nvl(t2.minzn,0.00))
end In_zn,

CASE WHEN (T1.MAXco is not null and t2.minco is not null)
THEN
(t1.maxco+t2.minco)/2
else 
(t1.maxco+nvl(t2.minco,0.00))
end In_co,

CASE WHEN (T1.MAXce is not null and t2.mince is not null)
THEN
(t1.maxce+t2.mince)/2
else 
(t1.maxce+nvl(t2.mince,0.00))
end In_ce,

CASE WHEN (T1.MAXCEⅡw is not null and t2.minCEⅡw is not null)
THEN
(t1.maxCEⅡw+t2.minCEⅡw)/2
else 
(t1.maxCEⅡw+nvl(t2.minCEⅡw,0.00))
end In_Ceiiw,

CASE WHEN (T1.MAXCEPCM is not null and t2.minCEPCM is not null)
THEN
(t1.maxCEPCM+t2.minCEPCM)/2
else 
(t1.maxCEPCM+nvl(t2.minCEPCM,0.00))
end In_Cepcm,

CASE WHEN (T1.MAXalt is not null and t2.minalt is not null)
THEN
(t1.maxalt+t2.minalt)/2
else 
(t1.maxalt+nvl(t2.minalt,0.00))
end In_alt,


CASE WHEN (T1.MAXta is not null and t2.minta is not null)
THEN
(t1.maxta+t2.minta)/2
else 
(t1.maxta+nvl(t2.minta,0.00))
end In_ta,

CASE WHEN (T1.MAXse is not null and t2.minse is not null)
THEN
(t1.maxse+t2.minse)/2
else 
(t1.maxse+nvl(t2.minse,0.00))
end In_se,

CASE WHEN (T1.MAXceq is not null and t2.minceq is not null)
THEN
(t1.maxceq+t2.minceq)/2
else
(t1.maxceq+nvl(t2.minceq,0.00))
end In_ceq,

CASE WHEN (T1.MAXcev is not null and t2.mincev is not null)
THEN
(t1.maxcev+t2.mincev)/2
else
(t1.maxcev+nvl(t2.mincev,0.00))
end In_cev,

CASE WHEN (T1.MAXfe is not null and t2.minfe is not null)
THEN
(t1.maxfe+t2.minfe)/2
else
(t1.maxfe+nvl(t2.minfe,0.00))
end In_fe
from t1,t2
</query>

<query id = "FrmTqnqd01.add" desc = "增加">
<![CDATA[
 INSERT INTO TQNQD01(
        REC_CREATOR,
        REC_CREATE_TIME,
        SMELT_CODE,
        SG_STD,
        SG_SIGN,
        IN_STEEL_TYPE_CODE,
        IN_C,
        IN_MN,
        IN_SI,
        IN_P,
        IN_S,
        IN_CR,
        IN_NI,
        IN_MO,
        IN_V,
        IN_NB,
        IN_AL,
        IN_TI,
        IN_B,
        IN_N,
        IN_CA,
        IN_CU,
        IN_W,
        IN_CO,
        IN_ALS,
        IN_PB,
        IN_SB,
        IN_SN,
        IN_BI,
        IN_CE,
        IN_SE,
        IN_FE,
        OUT_SMELT_CODE,
        OUT_SG_SIGN,
        OUT_SG_STD,
        OUT_STEEL_TYPE_CODE,
        IN_H,
        IN_O,
        IN_ASN,
        IN_ZN,
        IN_CEIIW,
        IN_CEPCM,
        IN_ALT,
        IN_TA,
        IN_CEQ,
        IN_CEV,
        OUT_SIFE,
        OUT_HC_MNFE,
        OUT_MC_MNFE,
        OUT_LC_MNFE,
        OUT_HC_CRFE,
        OUT_MC_CRFE,
        OUT_LC_CRFE,
        OUT_WC_CRFE,
        OUT_MOFE,
        OUT_VFE,
        OUT_NBFE,
        OUT_ENI,
        OUT_CATHODE_COPPER,
        OUT_WFE,
        OUT_LFRB,
        OUT_SICABA,
        OUT_AL,
        OUT_AL_WIRE,
        OUT_TIFE_CORE_WIRE,
        OUT_BFE_CORE_WIRE,
        OUT_S_WIRE,
        OUT_CA_WIRE,
        OUT_AL_POWDER,
        OUT_NICALON,
        OUT_FERROSILICON_POWDER,
        OUT_BLOW_GRAPHITE_POWDER,
        OUT_SLAG_CARBURIZING_BALL,
		CIC,
		CICGID,
		OUT_TIESHUI,
		OUT_FEIGANG)
 VALUES( 
        '#REC_CREATOR#',
         to_char(sysdate,'yyyymmdd hh24mihh24'),
        '#SMELT_CODE#',
        '#SG_STD#',
        '#SG_SIGN#',
        '#IN_STEEL_TYPE_CODE#',
        '#IN_C#',
        '#IN_MN#',
        '#IN_SI#',
        '#IN_P#',
        '#IN_S#',
        '#IN_CR#',
        '#IN_NI#',
        '#IN_MO#',
        '#IN_V#',
        '#IN_NB#',
        '#IN_AL#',
        '#IN_TI#',
        '#IN_B#',
        '#IN_N#',
        '#IN_CA#',
        '#IN_CU#',
        '#IN_W#',
        '#IN_CO#',
        '#IN_ALS#',
        '#IN_PB#',
        '#IN_SB#',
        '#IN_SN#',
        '#IN_BI#',
        '#IN_CE#',
        '#IN_SE#',
        '#IN_FE#',
        '#OUT_SMELT_CODE#',
        '#OUT_SG_SIGN#',
        '#OUT_SG_STD#',
        '#OUT_STEEL_TYPE_CODE#',
        '#IN_H#',
        '#IN_O#',
        '#IN_ASN#',
        '#IN_ZN#',
        '#IN_CEIIW#',
        '#IN_CEPCM#',
        '#IN_ALT#',
        '#IN_TA#',
        '#IN_CEQ#',
        '#IN_CEV#',
        '#OUT_SIFE#',
        '#OUT_HC_MNFE#',
        '#OUT_MC_MNFE#',
        '#OUT_LC_MNFE#',
        '#OUT_HC_CRFE#',
        '#OUT_MC_CRFE#',
        '#OUT_LC_CRFE#',
        '#OUT_WC_CRFE#',
        '#OUT_MOFE#',
        '#OUT_VFE#',
        '#OUT_NBFE#',
        '#OUT_ENI#',
        '#OUT_CATHODE_COPPER#',
        '#OUT_WFE#',
        '#OUT_LFRB#',
        '#OUT_SICABA#',
        '#OUT_AL#',
        '#OUT_AL_WIRE#',
        '#OUT_TIFE_CORE_WIRE#',
        '#OUT_BFE_CORE_WIRE#',
        '#OUT_S_WIRE#',
        '#OUT_CA_WIRE#',
        '#OUT_AL_POWDER#',
        '#OUT_NICALON#',
        '#OUT_FERROSILICON_POWDER#',
        '#OUT_BLOW_GRAPHITE_POWDER#',
        '#OUT_SLAG_CARBURIZING_BALL#',
		'#CIC#',
		'#CICGID#',
		'#OUT_TIESHUI#',
		'#OUT_FEIGANG#')
        ]]>
</query>
</queryMap>