SELECT zt,bcshzl,slfkrq,pwfkrq,llfkrq,hxfkrq,qgfkrq
from dm_ydjh
WHERE
jssj BETWEEN #{from} and #{to} and zt>='2'
SELECT
DISTINCT CONVERT(VARCHAR, MONTH(CONVERT(DATE, jssj, 111))) month,
sum(1) over(PARTITION by CONVERT(VARCHAR, MONTH(CONVERT(DATE, jssj, 111))) ) n,
sum(isnull(bcshzl,0)/1000) over(PARTITION by CONVERT(VARCHAR, MONTH(CONVERT(DATE, jssj, 111))) ) t
from dm_ydjh WHERE zt='62'
SELECT
DISTINCT zt, sum(isnull(bcshzl,0)/1000) over(PARTITION by zt) as t
from
dm_ydjh
WHERE jssj BETWEEN #{from} and #{to} and zt>='2'
SELECT
DISTINCT b.BMSM,a.kw ,sum(isnull(a.bcshzl,0)/1000) over(PARTITION by a.kw ) as t
from
dm_ydjh a,DM_ZHBMP b
WHERE
b.BMLB ='QGKW' and a.kw=b.bm and a.jssj BETWEEN #{from} and #{to} and zt>#{zt}
SELECT dm_sygd_mx.id,
dm_sygd_mx.parent_id,
t.DC_CH,
dm_sygd_mx.dc_ch1,
t.DC_PL,
dm_sygd_mx.LQLB,
dm_sygd_mx.tzbh,
dm_sygd_mx.wpgg,
dm_sygd_mx.wpxh,
dm_sygd_mx.hxcd,
dm_sygd_mx.qgcd,
dm_sygd_mx.qbs,
dm_sygd_mx.pklx,
dm_sygd_mx.pkcd,
dm_sygd_mx.ljsl,
dm_sygd_mx.zl,
dm_sygd_mx.lx,
dm_sygd_mx.xcms,
dm_sygd_mx.kw,
dm_sygd_mx.slrq,
dm_sygd_mx.slry,
dm_sygd_mx.pw,
dm_sygd_mx.pwry,
dm_sygd_mx.pwrq,
dm_sygd_mx.hxsb,
dm_sygd_mx.hxry,
dm_sygd_mx.hxrq,
dm_sygd_mx.qgsb,
dm_sygd_mx.qgry,
dm_sygd_mx.qgrq,
dm_sygd_mx.dmcd,
dm_sygd_mx.dmsb,
dm_sygd_mx.dmry,
dm_sygd_mx.dmrq,
dm_sygd_mx.pwsb,
dm_sygd_mx.pksb,
dm_sygd_mx.pkry,
dm_sygd_mx.pkrq,
dm_sygd_mx.DC_FD,
dm_sygd_mx.gjjs_dz,
dm_sygd_mx.gjjs_xz,
dm_sygd_mx.jsq_tlt,
dm_sygd_mx.jsq_lqb,
dm_sygd_mx.dhqd,
dm_sygd_mx.order_bs,
dm_sygd_mx.arrival_bs,
dm_sygd_mx.qy,
dm_sygd_mx.jzbs,
dm_sygd_mx.jzsb,
dm_sygd_mx.jzry,
dm_sygd_mx.qjgsb,
dm_sygd_mx.qjgry,
dm_sygd_mx.qjgrq,
dm_sygd_mx.dcCh2,
dm_sygd_mx.gjks,
dm_sygd_mx.gxsj,
dm_sygd_mx.hxkc_cd,
dm_sygd_mx.qgkc_cd,
dm_sygd_mx.jzrq,
dm_sygd_mx.zt,
dm_sygd_mx.xcgs,
dm_sygd_mx.bclqzl,
dm_sygd_mx.bcshzl,
dm_sygd_mx.bcylzl,
dm_sygd_mx.bcljtlzl,
dm_sygd_mx.bcqpyld,
dm_sygd_mx.ylbhgg,t.xqsj as jssj from
( SELECT DC_CH,DC_PL,DC_FD,tzbh,xqsj,rn FROM
( SELECT dm_qfxq.xzglxq as xqsj,dm_bom.tzbh,
dm_qfxq.DC_CH,dm_qfxq.DC_PL,dm_qfxq.DC_FD,
row_number() over(partition by dm_qfxq.DC_CH,dm_qfxq.DC_PL,dm_bom.tzbh order by dm_qfxq.xzglxq ) rn
from dm_qfxq LEFT JOIN dm_bom
on dm_bom.dcch = dm_qfxq.DC_CH
and dm_bom.pl = dm_qfxq.DC_PL
and dm_bom.fd = dm_qfxq.DC_FD
where
substring(dm_qfxq.xzglxq, 0, 8) =#{nextMonth}) r where r.rn=1
)t LEFT JOIN dm_sygd_mx
on dm_sygd_mx.dc_ch=t.DC_CH and dm_sygd_mx.dc_pl=t.DC_PL and dm_sygd_mx.tzbh=t.TZBH
order BY t.xqsj,t.DC_CH,t.DC_PL
INSERT into pgd_tzjh(
tzzt,
zt,
czbh,
pl,
fd,
lqbxfrq,
lqbjsrq,
tltxfrq,
tltjsrq,
qgxqrq,
qfxqrqxz,
qfxqrqdz,
id,bzry,bzrq
)
SELECT
'00' as tzzt,
'01' as zt,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.dc_fd as fd,
dm_czplp_new.xfq_lqb as lqbxfrq,
dm_czplp_new.jsq_lqb as lqbjsrq,
dm_czplp_new.xfq_tlt as tltxfrq,
dm_czplp_new.jsq_tlt as tltjsrq,
MIN(dm_ydjh.qgrq) as qgxqrq,
MIN(dm_ydjh.jssj) as qfxqrqxz,
MIN(dm_ydjh.gjjs_dz) as qfxqrqdz,
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')
as id,
#{bzry},
#{bzrq}
from
dm_ydjh
LEFT JOIN dm_czplp_new
on
dm_ydjh.dc_ch=dm_czplp_new.DC_CH and
dm_ydjh.dc_pl=dm_czplp_new.DC_pl
WHERE
dm_ydjh.id in
#{id}
GROUP BY
dm_ydjh.dc_ch,
dm_ydjh.dc_pl,
dm_ydjh.dc_fd,
dm_czplp_new.xfq_lqb,
dm_czplp_new.jsq_lqb,
dm_czplp_new.xfq_tlt,
dm_czplp_new.jsq_tlt
SELECT
'00' as tzzt,
'01' as zt,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.dc_fd as fd,
dm_czplp_new.xfq_lqb as lqbxfrq,
dm_czplp_new.jsq_lqb as lqbjsrq,
dm_czplp_new.xfq_tlt as tltxfrq,
dm_czplp_new.jsq_tlt as tltjsrq,
MIN(dm_ydjh.qgrq) as qgxqrq,
MIN(dm_ydjh.jssj) as qfxqrqxz,
MIN(dm_ydjh.gjjs_dz) as qfxqrqdz,
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')
as id
from
dm_ydjh
LEFT JOIN dm_czplp_new
on
dm_ydjh.dc_ch=dm_czplp_new.DC_CH and
dm_ydjh.dc_pl=dm_czplp_new.DC_pl
WHERE
dm_ydjh.qgrq BETWEEN #{begin} and #{end}
GROUP BY
dm_ydjh.dc_ch,
dm_ydjh.dc_pl,
dm_ydjh.dc_fd,
dm_czplp_new.xfq_lqb,
dm_czplp_new.jsq_lqb,
dm_czplp_new.xfq_tlt,
dm_czplp_new.jsq_tlt
SELECT
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.dhqd as dhqdh,
dhxx.RKXH as wpcz,
dm_ydjh.slrq as slxqrq,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz,
dhxx.ddmc as hth,
dhxx.dc_ch as xhth,
dhxx.HDSL as dhsl,
(CASE dm_ydjh.wpgg
WHEN null THEN null
WHEN '' THEN null
ELSE CAST( left(dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)-1)as char)
END)as hd,
(CASE dm_ydjh.wpgg
WHEN null THEN null
WHEN '' THEN null
ELSE CAST( SUBSTRING(dm_ydjh.wpgg, charindex('*',dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)+1)+1,LEN(dm_ydjh.wpgg))as char)
END) as cd,
(CASE dm_ydjh.wpgg
WHEN null THEN null
WHEN '' THEN null
ELSE CAST( left(SUBSTRING(dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)+1, LEN(dm_ydjh.wpgg)),
charindex('*',SUBSTRING(dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)+1, LEN(dm_ydjh.wpgg)),1)-1)as char)
END) as kd,
dhxx.DHSL as xqsl
from dm_ydjh left join
(select MS_DDJBP.CGFLM,
MS_DDJBP.DDH,
MS_DDJBP.ddmc as ddmc,
MS_DDMXP.dc_ch as dc_ch,
sum(MS_DDMXP.DHSL) as DHSL,
sum(im_crklsz.HDSL) as HDSL,
MS_DDMXP.WPHD as WPHD,
MS_DDMXP.WPCD as WPCD,
MS_DDMXP.WPKD as WPKD,
MS_DDMXP.RKXH as RKXH,
MS_DDJBP.dhqdh as dhqdh,
'00' as zt
from MS_DDJBP,
MS_DDMXP,
im_crklsz
where MS_DDJBP.ddmc = im_crklsz.dc_fd
and MS_DDMXP.dc_ch = im_crklsz.GCDDH
and RTRIM(MS_DDJBP.CGFLM) = MS_DDMXP.cgflm
and RTRIM(MS_DDJBP.DDH) = MS_DDMXP.DDH
and (MS_DDJBP.DDLX) = 'B'
and im_crklsz.CKH = '01'
and im_crklsz.CRKBS = 'RK'
and im_crklsz.HDLX ]]> '99'
GROUP BY MS_DDJBP.CGFLM, MS_DDJBP.DDH, MS_DDJBP.ddmc, MS_DDMXP.dc_ch, MS_DDMXP.WPHD, MS_DDMXP.WPCD,
MS_DDMXP.WPKD, MS_DDMXP.RKXH, MS_DDJBP.dhqdh) dhxx
on dhxx.dhqdh = dm_ydjh.dhqd
where
dm_ydjh.slrq BETWEEN #{begin} and #{end}
ORDER BY dm_ydjh.dc_ch,
dm_ydjh.dc_pl
SELECT
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.dhqd as dhqdh,
dhxx.RKXH as wpcz,
dm_ydjh.slrq as slxqrq,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz,
dhxx.ddmc as hth,
dhxx.dc_ch as xhth,
dhxx.HDSL as dhsl,
'01' as zt,
(CASE dm_ydjh.wpgg
WHEN null THEN null
WHEN '' THEN null
ELSE CAST( left(dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)-1)as char)
END)as hd,
(CASE dm_ydjh.wpgg
WHEN null THEN null
WHEN '' THEN null
ELSE CAST( SUBSTRING(dm_ydjh.wpgg, charindex('*',dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)+1)+1,LEN(dm_ydjh.wpgg))as char)
END) as cd,
(CASE dm_ydjh.wpgg
WHEN null THEN null
WHEN '' THEN null
ELSE CAST( left(SUBSTRING(dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)+1, LEN(dm_ydjh.wpgg)),
charindex('*',SUBSTRING(dm_ydjh.wpgg,charindex('*',dm_ydjh.wpgg,1)+1, LEN(dm_ydjh.wpgg)),1)-1)as char)
END) as kd,
dhxx.DHSL as xqsl
from dm_ydjh left join
(select MS_DDJBP.CGFLM,
MS_DDJBP.DDH,
MS_DDJBP.ddmc as ddmc,
MS_DDMXP.dc_ch as dc_ch,
sum(MS_DDMXP.DHSL) as DHSL,
sum(im_crklsz.HDSL) as HDSL,
MS_DDMXP.WPHD as WPHD,
MS_DDMXP.WPCD as WPCD,
MS_DDMXP.WPKD as WPKD,
MS_DDMXP.RKXH as RKXH,
MS_DDJBP.dhqdh as dhqdh,
'00' as zt
from MS_DDJBP,
MS_DDMXP,
im_crklsz
where MS_DDJBP.ddmc = im_crklsz.dc_fd
and MS_DDMXP.dc_ch = im_crklsz.GCDDH
and RTRIM(MS_DDJBP.CGFLM) = MS_DDMXP.cgflm
and RTRIM(MS_DDJBP.DDH) = MS_DDMXP.DDH
and (MS_DDJBP.DDLX) = 'B'
and im_crklsz.CKH = '01'
and im_crklsz.CRKBS = 'RK'
and im_crklsz.HDLX ]]> '99'
GROUP BY MS_DDJBP.CGFLM, MS_DDJBP.DDH, MS_DDJBP.ddmc, MS_DDMXP.dc_ch, MS_DDMXP.WPHD, MS_DDMXP.WPCD,
MS_DDMXP.WPKD, MS_DDMXP.RKXH, MS_DDJBP.dhqdh) dhxx
on dhxx.dhqdh = dm_ydjh.dhqd
where
dm_ydjh.id =#{id}
insert into pgd_sljh
(
id,
czbh,
pl,
fd,
zl,
lqlb,
kw,
tlth,
wpgg,
wpcz,
wpzl,
hth,
xhth,
lph,
kwh,
cs,
sljhrq,
zt,bzry,bzrq
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.dc_fd as fd,
dm_ydjh.zl as zl,
dm_ydjh.LQLB as lqlb,
dm_ydjh.kw as kw,
dm_ydjh.tzbh as tlth,
dm_ydjh.wpgg as wpgg,
dm_ydjh.wpxh as wpcz,
dm_ydjh.bclqzl as wpzl,
(IM_CKWPKWP.dc_fd) AS hth,
IM_CKWPKWP.GCDDH as xhth,
(IM_CKWPKWP.LPH) AS lph,
(IM_CKWPKWP.KWH) AS kwh ,
(IM_CKWPKWP.CFCS1) AS cs,
dm_ydjh.slrq as sljhrq,
'01' as zt,
#{bzry},
#{bzrq}
from dm_ydjh LEFT JOIN IM_CKWPKWP on
dm_ydjh.dc_ch=IM_CKWPKWP.DC_CH and
dm_ydjh.dc_pl=IM_CKWPKWP.DC_pl and
dm_ydjh.tzbh=IM_CKWPKWP.DC_th
WHERE
dm_ydjh.id in
#{id}
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.dc_fd as fd,
dm_ydjh.zl as zl,
dm_ydjh.LQLB as lqlb,
dm_ydjh.kw as kw,
dm_ydjh.tzbh as tlth,
dm_ydjh.wpgg as wpgg,
dm_ydjh.wpxh as wpcz,
dm_ydjh.bclqzl as wpzl,
(IM_CKWPKWP.dc_fd) AS hth,
IM_CKWPKWP.GCDDH as xhth,
(IM_CKWPKWP.LPH) AS lph,
(IM_CKWPKWP.KWH) AS kwh ,
(IM_CKWPKWP.CFCS1) AS cs,
dm_ydjh.slrq as sljhrq,
'00' as zt
from dm_ydjh LEFT JOIN IM_CKWPKWP on
dm_ydjh.dc_ch=IM_CKWPKWP.DC_CH and
dm_ydjh.dc_pl=IM_CKWPKWP.DC_pl and
dm_ydjh.tzbh=IM_CKWPKWP.DC_th
WHERE dm_ydjh.slrq BETWEEN #{begin} and #{end}
insert into pgd_pwjh
(
id,
czbh,
pl,
fd,
zl,
lqlb,
kw,
tlth,
wpgg,
wpcz,
wpzl,
pwwz,
pwjhrq,
qfxqrqxz,
qfxqrqdz,
zt,bzry,bzrq
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.DC_FD as fd,
dm_ydjh.zl as zl,
dm_ydjh.LQLB as lqlb,
dm_ydjh.kw as kw,
dm_ydjh.tzbh as tlth,
dm_ydjh.wpgg as wpgg,
dm_ydjh.wpxh as wpcz,
dm_ydjh.bclqzl as wpzl,
dm_ydjh.pw as pwwz,
dm_ydjh.pwrq as pwjhrq,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz,
'01' as zt,
#{bzry},
#{bzrq}
from dm_ydjh
WHERE dm_ydjh.id in
#{id}
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.DC_FD as fd,
dm_ydjh.zl as zl,
dm_ydjh.LQLB as lqlb,
dm_ydjh.kw as kw,
dm_ydjh.tzbh as tlth,
dm_ydjh.wpgg as wpgg,
dm_ydjh.wpxh as wpcz,
dm_ydjh.bclqzl as wpzl,
dm_ydjh.pw as pwwz,
dm_ydjh.pwrq as pwjhrq,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz,
'01' as zt
from dm_ydjh
WHERE dm_ydjh.pwrq BETWEEN #{begin} and #{end}
insert into pgd_qgjh
(
id,
czbh,
pl,
fd,
zl,
lqlb,
kw,
tlth,
wpgg,
wpcz,
wpzl,
qgjhrq,
qfxqrqxz,
qfxqrqdz,
pwjhwgrq,
hxcd,
qgcd,
hxkccd,
qgkccd,
zt,
bzry,
bzrq
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.DC_FD as fd,
dm_ydjh.zl as zl,
dm_ydjh.LQLB as lqlb,
dm_ydjh.kw as kw,
dm_ydjh.tzbh as tlth,
dm_ydjh.wpgg as wpgg,
dm_ydjh.wpxh as wpcz,
dm_ydjh.bclqzl as wpzl,
dm_ydjh.qgrq as qgjhrq,
dm_ydjh.pwrq as pwjhwgrq,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz,
hxcd,
qgcd,
hxkc_cd as hxkccd,
qgkc_cd as qgkccd,
'01' as zt,
#{bzry},
#{bzrq}
from dm_ydjh
where dm_ydjh.id in
#{id}
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','')as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.DC_FD as fd,
dm_ydjh.zl as zl,
dm_ydjh.LQLB as lqlb,
dm_ydjh.kw as kw,
dm_ydjh.tzbh as tlth,
dm_ydjh.wpgg as wpgg,
dm_ydjh.wpxh as wpcz,
dm_ydjh.bclqzl as wpzl,
dm_ydjh.qgrq as qgjhrq,
dm_ydjh.pwrq as pwjhwgrq,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz,
hxcd,
qgcd,
hxkc_cd as hxkccd,
qgkc_cd as qgkccd,
'01' as zt
from dm_ydjh
where dm_ydjh.qgrq BETWEEN #{begin} and #{end}
SELECT
DISTINCT dc_ch ,
SUM(1) over(PARTITION by dc_ch) total,
SUM(CASE isnull(qgfkrq,'') WHEN '' then 0 else 1 end) over(PARTITION by dc_ch) complete
from
dm_ydjh
where zt>='2' and dc_ch in
#{item}
order by dc_ch
update pgd_tzjh
set zt='01'
from pgd_tzjh,dm_ydjh
where pgd_tzjh.czbh= dm_ydjh.dc_ch and pgd_tzjh.pl=dm_ydjh.dc_pl
and dm_ydjh.id in
#{item}
update pgd_dh
set zt='01'
from pgd_dh,dm_ydjh
where pgd_dh.czbh= dm_ydjh.dc_ch and pgd_dh.dhqdh=dm_ydjh.dhqdh
and dm_ydjh.id in
#{item}
update pgd_sljh
set zt='01'
from pgd_sljh,dm_ydjh
where pgd_sljh.czbh= dm_ydjh.dc_ch and pgd_sljh.pl=dm_ydjh.dc_pl and pgd_sljh.tlth=dm_ydjh.tzbh
and dm_ydjh.id in
#{item}
update pgd_pwjh
set zt='01'
from pgd_pwjh,dm_ydjh
where pgd_pwjh.czbh= dm_ydjh.dc_ch and pgd_pwjh.pl=dm_ydjh.dc_pl and pgd_pwjh.tlth=dm_ydjh.tzbh
and dm_ydjh.id in
#{item}
update pgd_qgjh
set zt='01'
from pgd_qgjh,dm_ydjh
where pgd_qgjh.czbh= dm_ydjh.dc_ch and pgd_qgjh.pl=dm_ydjh.dc_pl and pgd_qgjh.tlth=dm_ydjh.tzbh
and dm_ydjh.id in
#{item}
insert into dm_ydjh_lj (
id,
czbh,
pl,
fd,
kw,
zl,
tlth,
ptblx,
ljbh,
ljmc,
ljgg,
ljcz,
wpfl,
jldw,
sl,
qfxqrqxz,
qfxqrqdz,
gylx,
pklx,
pkcd,
pkbs,
dmbs,
dmcd,
qbs,
qjg_zt,
pk_zt,
dm_zt,dmjhrq,pkjhrq,qjgjhrq,ppzt
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','') as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_bom.fd as fd,
dm_ydjh.kw as kw,
dm_bom.zl as zl,
dm_bom.tzbh as tlth,
'' as ptblx,
dm_bom.ljbh as ljbh,
'' as ljmc,
dm_bom.wpgg as ljgg,
dm_bom.wpcz as ljcz,
'' as wpfl,
'' as jldw,
dm_bom.ljsl as sl,
dm_qfxq.xzglxq as qfxqrqxz,
dm_qfxq.dzglxq as qfxqrqdz,
'' as gylx,
dm_bom.pklx as pklx,
dm_bom.pkcd as pkcd,
case when isnull(dm_ydjh.pkrq,'')<>''
then 'Y'
else '' end ,
case when isnull(dm_ydjh.dmrq,'')<>''
then 'Y'
else '' end ,
dm_bom.dmcd as dmcd,
case when isnull(dm_ydjh.qjgrq,'')<>''
then 'Y'
else '' end,
'01',
'01','01',dm_ydjh.dmrq dmjhrq,dm_ydjh.pkrq pkjhrq,dm_ydjh.qjgrq qjgjhrq,'01'
from dm_ydjh,dm_bom
LEFT JOIN dm_qfxq on dm_qfxq.DC_CH=dm_bom.dcch and dm_qfxq.DC_PL=dm_bom.pl and dm_qfxq.DC_FD=dm_bom.fd
WHERE
dm_ydjh.dc_ch= dm_bom.dcch
and dm_ydjh.dc_pl=dm_bom.pl
and dm_ydjh.tzbh=dm_bom.tzbh
and dm_ydjh.dc_fd=dm_bom.fd
and dm_ydjh.id in
#{item}
insert into dm_ydjh_lj (
id,
czbh,
pl,
fd,
kw,
zl,
tlth,
ptblx,
ljbh,
ljmc,
ljgg,
ljcz,
wpfl,
jldw,
sl,
qfxqrqxz,
qfxqrqdz,
gylx,
pklx,
pkcd,
pkbs,
dmbs,
dmcd,
qbs,
qjg_zt,
pk_zt,
dm_zt,dmjhrq,pkjhrq,qjgjhrq,ppzt
)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','') as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_bom.fd as fd,
dm_ydjh.kw as kw,
dm_bom.zl as zl,
dm_bom.tzbh as tlth,
'' as ptblx,
dm_bom.ljbh as ljbh,
'' as ljmc,
dm_bom.wpgg as ljgg,
dm_bom.wpcz as ljcz,
'' as wpfl,
'' as jldw,
dm_bom.ljsl as sl,
dm_qfxq.xzglxq as qfxqrqxz,
dm_qfxq.dzglxq as qfxqrqdz,
'' as gylx,
dm_bom.pklx as pklx,
dm_bom.pkcd as pkcd,
case when isnull(dm_ydjh.pkrq,'')<>''
then 'Y'
else '' end ,
case when isnull(dm_ydjh.dmrq,'')<>''
then 'Y'
else '' end ,
dm_bom.dmcd as dmcd,
case when isnull(dm_ydjh.qjgrq,'')<>''
then 'Y'
else '' end,
'01',
'01','01',dm_ydjh.dmrq dmjhrq,dm_ydjh.pkrq pkjhrq,dm_ydjh.qjgrq qjgjhrq,'01'
from dm_ydjh,dm_bom
LEFT JOIN dm_qfxq on dm_qfxq.DC_CH=dm_bom.dcch and dm_qfxq.DC_PL=dm_bom.pl and dm_qfxq.DC_FD=dm_bom.fd
WHERE
dm_ydjh.dc_ch= dm_bom.dcch
and dm_ydjh.dc_pl=dm_bom.pl
and dm_ydjh.tzbh=dm_bom.tzbh
and dm_ydjh.dc_fd=dm_bom.fd
and dm_ydjh.dc_ch=#{dcCh} and dm_ydjh.dc_pl=#{dcPl} and dm_ydjh.tzbh=#{tzbh}
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','') as id,
dm_ydjh.dc_ch as czbh,
dm_ydjh.dc_pl as pl,
dm_ydjh.sllph as sllph,
dm_bom.fd as fd,
dm_ydjh.kw as kw,
dm_bom.zl as zl,
dm_bom.tzbh as tlth,
'' as ptblx,
dm_bom.ljbh as ljbh,
'' as ljmc,
dm_bom.wpgg as ljgg,
dm_bom.wpcz as ljcz,
'' as wpfl,
'' as jldw,
dm_bom.ljsl as sl,
dm_qfxq.xzglxq as qfxqrqxz,
dm_qfxq.dzglxq as qfxqrqdz,
'' as gylx,
dm_bom.pklx as pklx,
dm_bom.pkcd as pkcd,
case when isnull(dm_ydjh.pkrq,'')<>''
then 'Y'
else '' end ,
case when isnull(dm_ydjh.dmrq,'')<>''
then 'Y'
else '' end ,
dm_bom.dmcd as dmcd,
case when isnull(dm_ydjh.qjgrq,'')<>''
then 'Y'
else '' end,
'01' qjg_zt,
'01' pk_zt,'01' dm_zt,dm_ydjh.dmrq dmjhrq,dm_ydjh.pkrq pkjhrq,dm_ydjh.qjgrq qjgjhrq,'01' ppzt
from dm_ydjh,dm_bom
LEFT JOIN dm_qfxq on dm_qfxq.DC_CH=dm_bom.dcch and dm_qfxq.DC_PL=dm_bom.pl and dm_qfxq.DC_FD=dm_bom.fd
WHERE
dm_ydjh.dc_ch= dm_bom.dcch and dm_bom.type='b'
and dm_ydjh.dc_pl=dm_bom.pl
and dm_ydjh.tzbh=dm_bom.tzbh
and dm_ydjh.dc_ch=#{dcCh} and dm_ydjh.dc_pl=#{dcPl} and dm_ydjh.tzbh=#{tzbh}
select isnull(min (slrq),'') as slrq,
isnull(min (pwrq),'') as pwrq,
isnull( min (hxrq),'') as hxrq,
isnull( min (qgrq),'') as qgrq,
isnull( min (dmrq),'') as dmrq,
isnull( min (qjgrq),'') as qjgrq,
isnull( min (jssj) ,'')as jssj,
isnull( min (sljhrq),'') as sljhrq,
isnull( min (pwjhrq),'') as pwjhrq,
isnull( min (lljhrq),'') as lljhrq,
isnull( min (hxjhrq),'') as hxjhrq,
isnull( min (qgjhrq),'') as qgjhrq from dm_ydjh
where dc_ch=#{dcch} and dc_pl =#{dcpl}
SELECT
dm_ydjh.dc_ch,
dm_ydjh.dc_pl,
isnull( min (dm_ydjh.jssj) ,'')as jssj,
isnull( min (dm_ydjh.sljhrq) ,'')as sljhrq,
-- isnull( min (dm_ydjh.pwjhrq) ,'')as pwjhrq,
-- isnull( min (dm_ydjh.lljhrq) ,'')as lljhrq,
-- isnull( min (dm_ydjh.hxjhrq) ,'')as hxjhrq,
-- isnull( min (dm_ydjh.qgjhrq) ,'')as qgjhrq,
isnull( min(CASE WHEN ISNULL(dm_ydjh.sljhrq, '') != '' THEN dm_ydjh.sljhrq END),'')as sljhrq,
isnull( min(CASE WHEN ISNULL(dm_ydjh.pwjhrq, '') != '' THEN dm_ydjh.pwjhrq END),'')as pwjhrq,
isnull( min(CASE WHEN ISNULL(dm_ydjh.lljhrq, '') != '' THEN dm_ydjh.lljhrq END),'')as lljhrq,
isnull( min(CASE WHEN ISNULL(dm_ydjh.hxjhrq, '') != '' THEN dm_ydjh.hxjhrq END),'')as hxjhrq,
isnull( min(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' THEN dm_ydjh.qgjhrq END),'')as qgjhrq,
COUNT(dm_ydjh.id) AS bs,
SUM(CASE WHEN ISNULL(dm_ydjh.slxhth, '') != '' THEN 1 ELSE 0 END) AS slxhth_count,
SUM(CASE WHEN ISNULL(dm_ydjh.slfkry, '') != '' THEN 1 ELSE 0 END) AS sl_count,
SUM(CASE WHEN ISNULL(dm_ydjh.pwfkry, '') != '' THEN 1 ELSE 0 END) AS pw_count,
SUM(CASE WHEN ISNULL(dm_ydjh.llfkrq, '') != '' THEN 1 ELSE 0 END) AS ll_count,
SUM(CASE WHEN ISNULL(dm_ydjh.hxfkrq, '') != '' THEN 1 ELSE 0 END) AS hx_count,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' THEN 1 ELSE 0 END) AS qg_count,
SUM(CASE WHEN ISNULL(dm_ydjh.ylbs, 'N') = 'Y' THEN 1 ELSE 0 END) AS ylbs,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and dm_ydjh.kw in (1,7,8)
THEN 1 ELSE 0 END) AS qg_count1k,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and dm_ydjh.kw in (10,11,12,2,5,9)
THEN 1 ELSE 0 END) AS qg_count2k,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and dm_ydjh.kw in (13,14,3,6)
THEN 1 ELSE 0 END) AS qg_count3k,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and dm_ydjh.kw in (15,4)
THEN 1 ELSE 0 END) AS qg_count4k,
SUM(CASE WHEN isnull(dm_ydjh.qgfkrq, '') = '' and ISNULL(dm_ydjh.slxhth, '') != '' and ((dm_ydjh.kw in (1,7,8) and dm_ydjh.zyq='FP2Q') or (dm_ydjh.kw not in (13,14,3,6) and dm_ydjh.zyq='FP2Q'))
THEN 1 ELSE 0 END) AS qg_count1kw,
SUM(CASE WHEN isnull(dm_ydjh.qgfkrq, '') = '' and ISNULL(dm_ydjh.slxhth, '') != '' and dm_ydjh.zyq='FP3Q'
THEN 1 ELSE 0 END) AS qg_count2kw,
SUM(CASE WHEN isnull(dm_ydjh.qgfkrq, '') = '' and ISNULL(dm_ydjh.slxhth, '') != '' and dm_ydjh.kw in (13,14,3,6) and dm_ydjh.zyq='FP2Q'
THEN 1 ELSE 0 END) AS qg_count3kw,
SUM(CASE WHEN isnull(dm_ydjh.qgfkrq, '') = '' and ISNULL(dm_ydjh.slxhth, '') != '' and dm_ydjh.zyq='FP4Q'
THEN 1 ELSE 0 END) AS qg_count4kw
FROM
dm_ydjh
where 1=1 AND lx='B' and ( isnull(dm_ydjh.zt,'') != '-1' and isnull(dm_ydjh.zt,'') !='99' )
and dm_ydjh.kw!='17'
and dm_ydjh.dc_ch=#{dcCh}
and dm_ydjh.zt=#{zt}
and dm_ydjh.jssj>=#{yf}
and dm_ydjh.jssj<=#{yf1}
GROUP BY
dm_ydjh.dc_ch,
dm_ydjh.dc_pl
order by dc_ch,dc_pl,jssj
SELECT
*
from
(select
dc_ch dcCh,dc_pl dcPl,zt,gxsj,ROW_NUMBER() over(PARTITION by dc_ch,dc_pl,zt order by dc_ch,dc_pl) rn
from
dm_ydjh
where
zt>=2 and zt<62 ) a
where a.rn=1
order by dcCh asc ,dcPl desc ,zt
select
dc_ch dcCh,dc_pl dcPl,count(1) total,plxh,
sum(case when isnull(qgfkrq,'')='' then 1 else 0 end) wwg,
sum(case when isnull(qgfkrq,'')!='' then 1 else 0 end) comp,
sum(case when isnull(hxfkrq,'')='' then 1 else 0 end) wwg,
sum(case when isnull(hxfkrq,'')!='' then 1 else 0 end) comp,
sum(case when isnull(pwfkrq,'')='' then 1 else 0 end) wwg,
sum(case when isnull(pwfkrq,'')!='' then 1 else 0 end) comp,
sum(case when zt>=#{zt} then 1 else 0 end) compOnLastGx,
sum(case when isnull(qgpgrq,'')='' then 1 else 0 end) wpg
sum(case when isnull(hxpgrq,'')='' then 1 else 0 end) wpg
sum(case when isnull(pwpgrq,'')='' then 1 else 0 end) wpg
from
dm_ydjh
where zt>=11 and zt>=#{zt} and (zyq=#{zyq} or zyq1=#{zyq})
and isnull(qgfkrq,'')=''
and isnull(hxfkrq,'')=''
and isnull(pwfkrq,'')=''
group by dc_ch, dc_pl,plxh
order by dc_ch,dc_pl
SELECT
top 1
mp_sycljljbp.clpzh,
mp_sycljljbp.zdr,
mp_sycljljbp.zdrq,
mp_sycljljbp.dc_tz,
mp_sycljljbp.dc_th,
mp_sycljljbp.dc_tpbh,
mp_sycljljbp.dc_tpmc,
mp_sycljljbp.dc_ch,
mp_sycljljbp.dc_cm,
MP_SYCLJLJBP.JHKSRQG1 ,
MP_SYCLJLJBP.JHJHRQG1 ,
MP_SYCLJLJBP.JHKSRQG2 ,
MP_SYCLJLJBP.JHJHRQG2 ,
MP_SYCLJLJBP.JHKSRQG3 ,
MP_SYCLJLJBP.JHJHRQG3,
MP_SYCLJLJBP.YLZD1,
MP_SYCLJLJBP.YLZD2,
MP_SYCLJLJBP.LLKW,
MP_SYCLJLJBP.DC_YJ,
MP_SYCLJLJBP.XGRQ2,
MP_SYCLJLJBP.XGRQ3,
MP_SYCLJLJBP.TZDH,
MP_SYCLJLJBP.DC_YS,
MP_SYCLJLJBP.RWZXZT,
MP_SYCLJLJBP.RWSCPZ,
MP_SYCLJLJBP.RWSCLL,
MP_SYCLJLJBP.ZZK1,
RTRIM(MP_SYCLJLJBP.GZZX1) AS GZZX1,
RTRIM(MP_SYCLJLJBP.JGZ1) AS JGZ1,
RTRIM(MP_SYCLJLJBP.WGRQ1) AS WGRQ1,
RTRIM(MP_SYCLJLJBP.HBRY1) AS HBRY1,
RTRIM(MP_SYCLJLJBP.HBRQ1) AS HBRQ1,
RTRIM(MP_SYCLJLJBP.GZZX2) AS GZZX2,
RTRIM(MP_SYCLJLJBP.JGZ2) AS JGZ2,
RTRIM(MP_SYCLJLJBP.WGRQ2) AS WGRQ2,
RTRIM(MP_SYCLJLJBP.HBRY2) AS HBRY2,
RTRIM(MP_SYCLJLJBP.HBRQ2) AS HBRQ2,
RTRIM(MP_SYCLJLJBP.GZZX3) AS GZZX3,
RTRIM(MP_SYCLJLJBP.JGZ3) AS JGZ3,
RTRIM(MP_SYCLJLJBP.WGRQ3) AS WGRQ3,
RTRIM(MP_SYCLJLJBP.HBRY3) AS HBRY3,
RTRIM(MP_SYCLJLJBP.HBRQ3) AS HBRQ3,
RTRIM(MP_SYCLJLJBP.DC_PL) AS DC_PL,
RTRIM(MP_SYCLJLJBP.DC_ZL) AS DC_ZL,
RTRIM(MP_SYCLJLJBP.DC_FD) AS DC_FD,
RTRIM(DM_BCHXJBP.XTRQ) AS XTRQ,
DM_BCHXJBP.LJSL,
DM_BCHXJBP.YCLZL,
DM_BCHXJBP.HXCD,
RTRIM(DM_BCHXJBP.GCBH) AS GCBH,
RTRIM(DM_BCHXJBP.YLZD1) AS YLZD11,
DM_BCHXJBP.YLZD4 AS YLZD4,
RTRIM(MP_SYCLJLJBP.HXFL) AS HXFL,
0 AS BS ,
RTRIM(MP_SYCLJLJBP.ywh) AS ywh,
MP_SYCLJLJBP.dc_lph AS dc_lph,
DM_BCHXJBP.YLZL,
RTRIM(DM_BCHXJBP.YLBH) AS YLBH,
RTRIM(DM_BCHXJBP.CLMC) AS CLMC,
0 as kjbs,
RTRIM(MP_SYCLJLJBP.CLLY) AS CLLY,
'' as dc_th_old ,
'' as clpzh_new ,
RTRIM(MP_SYCLJLJBP.QGCJ) AS QGCJ,
RTRIM(MP_SYCLJLJBP.DC_YLBH ) AS DC_YLBH ,
RTRIM(MP_SYCLJLJBP.QGLX) AS QGLX,
RTRIM(MP_SYCLJLJBP.YLCJBM) AS YLCJBM,
RTRIM(MP_SYCLJLJBP.YLKWH) AS YLKWH,
RTRIM(MP_SYCLJLJBP.sbbh) AS sbbh,
'' as sxh,
'' as ylsxh,
MP_SYCLJLJBP.BZXX
FROM MP_SYCLJLJBP,DM_BCHXJBP
WHERE (MP_SYCLJLJBP.DC_TH) = (DM_BCHXJBP.TZBH)
and (MP_SYCLJLJBP.DC_ch) = (DM_BCHXJBP.dc_ch)
and MP_SYCLJLJBP.DC_CH =#{dcCh} and MP_SYCLJLJBP.DC_TH =#{tzbh}
select a.dc_ch,a.dc_pl,b.id,b.tlth
from dm_yppyz a inner join dm_ydjh_lj b on a.dc_ch=b.czbh and a.dc_pl=b.pl
left join dm_ydjh c on b.czbh=c.dc_ch and b.pl=c.dc_pl and b.tlth =c.tzbh
where
a.status='设置垛位' and b.ppzt='01' and c.zyq1=#{zyq1}
select
case when isnull(a.djh,'')!='' then a.djh else b.print_id end as djh,
a.id,a.dc_ch,a.dc_ch1,a.dc_pl,a.LQLB,a.tzbh,a.wpgg,a.wpxh,a.hxcd,a.qgcd,a.qbs,a.pklx,a.pkcd,a.ljsl,a.zl,a.lx,a.xcms,
a.kw,a.slrq,a.slry,a.pw,a.pwry,a.pwrq,a.hxsb,a.hxry,a.hxrq,a.qgsb,a.qgry,a.qgrq,a.dmcd,a.dmsb,a.dmry,a.dmrq,a.pwsb,
a.pksb,a.pkry,a.pkrq,a.DC_FD,a.gjjs_dz,a.gjjs_xz,a.jsq_tlt,a.jsq_lqb,a.dhqd,a.order_bs,a.arrival_bs,a.qy,a.jzbs,a.jzsb,
a.jzry,a.qjgsb,a.qjgry,a.qjgrq,a.dcCh2,a.gjks,a.gxsj,a.hxkc_cd,a.qgkc_cd,a.jssj,a.jzrq,a.zt,a.xcgs,a.bclqzl,a.bcshzl,
a.bcylzl,a.bcljtlzl,a.bcqpyld,a.ylbs,a.plxh,a.ylbhgg,a.parent_id,a.db,a.cx,a.txc,a.jhlx,a.jssj_old,a.sczt,a.slxzxqrq,
a.sldzxqrq,a.ckbzrq,a.ckbzry,a.bmbzrq,a.bmbzry,a.bmxgry,a.bmxgrq,a.slkcdw,a.slcs,a.slxhth,a.slhth,a.slwlh,a.kcch,a.slkcxx,
a.slycldw,a.slyclcs,a.nbsbm,a.sllsh,a.sldrry,a.sldrrq,a.sllph,a.slpgry,a.slfkry,a.slfkrq,a.slbz,a.pwxcldw,a.pwcs,a.pwpgry,
a.slpgrq,a.pwpgrq,a.pwfkry,a.pwfkrq,a.pwbz,a.lldw,a.llcs,a.llpgry,a.llpgrq,a.llry,a.llfkry,a.llfkrq,a.llbz,a.hxdw,a.hxcs,
a.hxpgry,a.hxpgrq,a.hxfkrq,a.hxfkry,a.hxjybs,a.hxjych,a.hxjypl,a.hxjyfd,a.hxjyzl,a.hxjykw,a.hxjytlth,a.hxbz,a.qgdw,a.qgcs,
a.qgpgry,a.qgpgrq,a.qgfkrq,a.qgfkry,a.qgjybs,a.qgjych,a.qgjypl,a.qgjyfd,a.qgjyzl,a.qgjykw,a.qgjytlth,a.qgbz,a.qjgbs,a.pkbs,
a.ycbs,a.hxjhrq,a.qgjhrq,a.zcljhrq,a.sljhrq,a.pwjhrq,a.lljhrq,a.kcbs,a.lphqrry,a.lphqrrq,a.zyq,a.zyq1,a.ykw,a.kwmc,a.zylx
from
dm_ydjh a left join dm_tlt_print_wh b on a.dc_ch=b.dc_ch and a.dc_pl=b.dc_pl and a.tzbh=b.dc_tlt
zt>=#{zt} and zt>11
and zyq1=#{zyq}
and isnull(pwfkry,'')=''
and isnull(hxfkry,'')=''
and isnull(qgfkry,'')=''
order by a.dc_ch,a.dc_pl,a.tzbh
SELECT count(1)
from
dm_bom a,dm_ydjh b
WHERE
a.dcch=b.dc_ch and a.pl=b.dc_pl and a.tzbh=b.tzbh
and a.dcch =#{dcch} and a.pl=#{pl} and a.fd=#{fd} and a.type='b' and b.ylbs='N'
and not EXISTS (SELECT czbh,tlth from dm_ydjh_lj b where a.dcch=b.czbh and a.tzbh=b.tlth and isnull(b.qq,'')!='' and isnull(b.dw,'')!='')
select
case when isnull(a.djh,'')!='' then a.djh else b.print_id end as djh,
a.id,a.dc_ch,a.dc_ch1,a.dc_pl,a.LQLB,a.tzbh,a.wpgg,a.wpxh,a.hxcd,a.qgcd,a.qbs,a.pklx,a.pkcd,a.ljsl,a.zl,a.lx,a.xcms,
a.kw,a.slrq,a.slry,a.pw,a.pwry,a.pwrq,a.hxsb,a.hxry,a.hxrq,a.qgsb,a.qgry,a.qgrq,a.dmcd,a.dmsb,a.dmry,a.dmrq,a.pwsb,
a.pksb,a.pkry,a.pkrq,a.DC_FD,a.gjjs_dz,a.gjjs_xz,a.jsq_tlt,a.jsq_lqb,a.dhqd,a.order_bs,a.arrival_bs,a.qy,a.jzbs,a.jzsb,
a.jzry,a.qjgsb,a.qjgry,a.qjgrq,a.dcCh2,a.gjks,a.gxsj,a.hxkc_cd,a.qgkc_cd,a.jssj,a.jzrq,a.zt,a.xcgs,a.bclqzl,a.bcshzl,
a.bcylzl,a.bcljtlzl,a.bcqpyld,a.ylbs,a.plxh,a.ylbhgg,a.parent_id,a.db,a.cx,a.txc,a.jhlx,a.jssj_old,a.sczt,a.slxzxqrq,
a.sldzxqrq,a.ckbzrq,a.ckbzry,a.bmbzrq,a.bmbzry,a.bmxgry,a.bmxgrq,a.slkcdw,a.slcs,a.slxhth,a.slhth,a.slwlh,a.kcch,a.slkcxx,
a.slycldw,a.slyclcs,a.nbsbm,a.sllsh,a.sldrry,a.sldrrq,a.sllph,a.slpgry,a.slfkry,a.slfkrq,a.slbz,a.pwxcldw,a.pwcs,a.pwpgry,
a.slpgrq,a.pwpgrq,a.pwfkry,a.pwfkrq,a.pwbz,a.lldw,a.llcs,a.llpgry,a.llpgrq,a.llry,a.llfkry,a.llfkrq,a.llbz,a.hxdw,a.hxcs,
a.hxpgry,a.hxpgrq,a.hxfkrq,a.hxfkry,a.hxjybs,a.hxjych,a.hxjypl,a.hxjyfd,a.hxjyzl,a.hxjykw,a.hxjytlth,a.hxbz,a.qgdw,a.qgcs,
a.qgpgry,a.qgpgrq,a.qgfkrq,a.qgfkry,a.qgjybs,a.qgjych,a.qgjypl,a.qgjyfd,a.qgjyzl,a.qgjykw,a.qgjytlth,a.qgbz,a.qjgbs,a.pkbs,
a.ycbs,a.hxjhrq,a.qgjhrq,a.zcljhrq,a.sljhrq,a.pwjhrq,a.lljhrq,a.kcbs,a.lphqrry,a.lphqrrq,a.zyq,a.zyq1,a.ykw,a.kwmc,a.zylx
from
dm_ydjh a left join dm_tlt_print_wh b on a.dc_ch=b.dc_ch and a.dc_pl=b.dc_pl and a.tzbh=b.dc_tlt
where
zt=#{zt}
and a.sllsh=#{sllsh}
and a.dc_ch=#{dcch}
and a.dc_pl=#{dcPl}
and a.kw=#{kw}
and a.zylx=#{zylx}
and a.slkcdw like #{slkcdw}+'%'
UPDATE dm_ydjh set dm_ydjh.ylbs=dm_bchxylp.sfyl
from dm_ydjh inner JOIN dm_bchxylp ON dm_ydjh.dc_ch=dm_bchxylp.dc_ch AND dm_ydjh.dc_pl=dm_bchxylp.dc_pl AND
dm_ydjh.tzbh=dm_bchxylp.tzbh AND dm_ydjh.wpgg=dm_bchxylp.wpgg and dm_ydjh.wpxh=dm_bchxylp.wpxh where isnull(dm_ydjh.ylbs,'')=''
and dm_ydjh.DC_CH=#{dcch} and dm_ydjh.dc_pl=#{dcpl}
UPDATE dm_ydjh set
dm_ydjh.zyq= (CASE substring(RTRIM(dm_ydjh.tzbh),6,1)
WHEN '1' THEN 'FP2Q'
WHEN '3' THEN 'FP2Q'
WHEN '2' THEN 'FP3Q'
WHEN '4' THEN 'FP4Q'
WHEN '5' THEN 'FP4Q'
WHEN '6' THEN 'FP4Q'
ELSE ''
END), dm_ydjh.zyq1= (CASE substring(RTRIM(dm_ydjh.tzbh),6,1)
WHEN '1' THEN '二区'
WHEN '3' THEN '二区'
WHEN '2' THEN '三区'
WHEN '4' THEN '四区'
WHEN '5' THEN '四区'
WHEN '6' THEN '四区'
ELSE ''
END)
where dm_ydjh.DC_CH=#{dcch} and dm_ydjh.dc_pl=#{dcpl}
SELECT
RTRIM(DM_BCLQJBP.DC_CH) AS dc_ch,
RTRIM(DM_BCLQJBP.DC_PL) AS dc_pl,
RTRIM(DM_BCLQJBP.DC_FD) AS dc_fd,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='7' THEN DM_BCLQMXP.sl ELSE 0 END) as lm1,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='7' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_lm1,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='7' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_lm1,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='7' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 龙门1余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='7' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 龙门1前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='7' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 龙门1零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='8' THEN DM_BCLQMXP.sl ELSE 0 END) as s1,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='8' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_s1,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='8' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_s1,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='8' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 数1余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='8' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 数1前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='8' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 数1零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='9' THEN DM_BCLQMXP.sl ELSE 0 END) as sx2,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='9' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sx2,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='9' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sx2,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='9' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 数小2余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='9' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 数小2前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='9' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 数小2零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='9' THEN DM_BCLQMXP.sl ELSE 0 END) as szd2,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='9' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_szd2,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='9' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_szd2,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='9' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 数中大2余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='9' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 数中大2前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='9' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 数中大2零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='11' THEN DM_BCLQMXP.sl ELSE 0 END) as xf,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='11' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xf,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='11' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xf,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='11' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 小腹余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='11' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 小腹前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='11' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 小腹零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='11' THEN DM_BCLQMXP.sl ELSE 0 END) as df,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='11' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_df,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='11' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_df,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='11' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 大腹余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='11' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 大腹前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='11' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 大腹零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='14' THEN DM_BCLQMXP.sl ELSE 0 END) as xzhb,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='14' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xzhb,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='14' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xzhb,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='14' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 小组厚板余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='14' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 小组厚板前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='14' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 小组厚板零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='14' THEN DM_BCLQMXP.sl ELSE 0 END) as dzhb,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='14' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dzhb,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='14' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dzhb,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='14' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 大组厚板余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='14' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 大组厚板前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='14' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 大组厚板零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.sl ELSE 0 END) as sx4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='15' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sx4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='15' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sx4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 数小4余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 数小4前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='15' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 数小4零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.sl ELSE 0 END) as jz4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='15' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_jz4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='15' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_jz4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 机肘4余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 机肘4前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='15' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 机肘4零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='5' THEN DM_BCLQMXP.sl ELSE 0 END) as xm,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='5' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xm,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='5' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xm,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='5' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 小面余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='5' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 小面前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='5' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 小面零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='5' THEN DM_BCLQMXP.sl ELSE 0 END) as dm,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='5' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dm,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='5' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dm,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='5' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 大面余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='5' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 大面前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='5' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 大面零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.sl ELSE 0 END) as sx3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='6' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sx3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='6' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sx3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 手小3余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 手小3前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='6' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 手小3零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.sl ELSE 0 END) as sj3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='6' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sj3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='6' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sj3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 手机3余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 手机3前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '4230' and DM_BCLQJBP.zzcj='6' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 手机3零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.sl ELSE 0 END) as szd3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='6' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_szd3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='6' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_szd3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 手中大3余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='6' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 手中大3前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='6' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 手中大3零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.delx!='B' THEN DM_BCLQMXP.sl ELSE 0 END) as xzgs,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.delx!='B' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xz,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.delx!='B' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xz,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.delx!='B' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 小组型材余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.delx!='B' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 小组型材前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.delx!='B' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 小组型材零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.delx!='B' THEN DM_BCLQMXP.sl ELSE 0 END) as dzgs,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.delx!='B' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dz,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.delx!='B' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dz,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.delx!='B' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 大组型材余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.delx!='B' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 大组型材前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.delx!='B' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 大组型材零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.sl ELSE 0 END) as szd4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='15' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_szd4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='15' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_szd4,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 数中大4余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='15' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 数中大4前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='15' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 数中大4零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='10' THEN DM_BCLQMXP.sl ELSE 0 END) as sq2x,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='10' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sq2x,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='10' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sq2x,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='10' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 数曲2小余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='10' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 数曲2小前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='10' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 数曲2小零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='10' THEN DM_BCLQMXP.sl ELSE 0 END) as sq2d,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='10' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sq2d,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='10' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sq2d,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='10' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 数曲2大余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='10' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 数曲2大前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='10' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 数曲2大零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='13' THEN DM_BCLQMXP.sl ELSE 0 END) as xq3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='13' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xq3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='13' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xq3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='13' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 小曲3余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='13' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 小曲3前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQJBP.zzcj='13' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 小曲3零件重量,
SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='13' THEN DM_BCLQMXP.sl ELSE 0 END) as dq3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='13' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dq3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='13' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dq3,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='13' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 大曲3余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='13' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 大曲3前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQJBP.zzcj='13' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 大曲3零件重量,
SUM(CASE WHEN DM_BCLQJBP.zzcj='17' THEN DM_BCLQMXP.sl ELSE 0 END) as gd,
CAST(SUM(CASE WHEN DM_BCLQJBP.zzcj='17' THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_gd,
CAST(SUM(CASE WHEN DM_BCLQJBP.zzcj='17' THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_gd,
CAST(SUM(CASE WHEN DM_BCLQJBP.zzcj='17' THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 光电余料重量,
CAST(SUM(CASE WHEN DM_BCLQJBP.zzcj='17' THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 光电前批余料代,
CAST(SUM(CASE WHEN DM_BCLQJBP.zzcj='17' THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 光电零件重量,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.sl ELSE 0 END) as dzxcgs,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.lqms ELSE 0 END) as 大组型材领取米数,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.shms ELSE 0 END) as 大组型材实耗米数,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as lqzl_dzxc,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as shzl_dzxc,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 大组型材余料重量,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 大组型材前批余料代,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1110' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 大组型材零件重量,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.sl ELSE 0 END) as xzxcgs,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.lqms ELSE 0 END) as 小组型材领取米数,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.shms ELSE 0 END) as 小组型材实耗米数,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as lqzl_xzxc,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as shzl_xzxc,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 小组型材余料重量,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 小组型材前批余料代,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQJBP.DC_ZL= '1010' and DM_BCLQMXP.WPMC in ('球扁钢','角钢') THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 小组型材零件重量,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN DM_BCLQMXP.sl ELSE 0 END) as fggs,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN DM_BCLQMXP.lqms ELSE 0 END) as 方钢领取米数,
SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN DM_BCLQMXP.shms ELSE 0 END) as 方钢实耗米数,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN isnull(DM_BCLQMXP.LQZL,0) ELSE 0 END)/1000 as decimal(18,1)) as lqzl_fg,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN isnull( DM_BCLQMXP.SHZL,0) ELSE 0 END)/1000 as decimal(18,1)) as shzl_fg,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN DM_BCLQMXP.YLZL ELSE 0 END)/1000 as decimal(18,1)) as 方钢余料重量,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN DM_BCLQMXP.QPYLD ELSE 0 END)/1000 as decimal(18,1)) as 方钢前批余料代,
CAST(SUM(CASE WHEN DM_BCLQMXP.DELX_z='X' and DM_BCLQMXP.WPMC not in ('球扁钢','角钢') THEN isnull( DM_BCLQMXP.ljzl,0) ELSE 0 END)/1000 as decimal(18,1)) as 方钢零件重量
FROM DM_BCLQJBP,DM_BCLQMXP left join DM_WPJBP on DM_BCLQMXP.WPH = DM_WPJBP.WPH
WHERE
DM_BCLQMXP.LQBH = DM_BCLQJBP.LQBH and DM_BCLQJBP.DC_CH=#{ch}
and DM_BCLQJBP.dc_pl=#{dcpl}
and DM_BCLQJBP.dc_pl>=#{dcpl} and DM_BCLQJBP.dc_pl<=#{dcpl1}
and DM_BCLQJBP.dc_pl<=#{dcpl1}
GROUP BY DM_BCLQJBP.DC_CH,DM_BCLQJBP.DC_PL,DM_BCLQJBP.DC_FD
ORDER BY DM_BCLQJBP.DC_CH,DM_BCLQJBP.DC_PL
SELECT
dc_ch,
dc_pl,
stuff((SELECT ' ' + c.dc_FD
FROM dm_ydjh c
WHERE c.dc_ch = dm_ydjh.dc_ch and c.dc_pl = dm_ydjh.dc_pl
group by c.dc_FD FOR xml path ( '') ), 1, 1, ''
) AS dc_fd,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='7' THEN 1 ELSE 0 END) as lm1,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='7'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as lmdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='7' THEN dm_ydjh.bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_lm1,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='7' THEN dm_ydjh.bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_lm1,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='7' THEN dm_ydjh.bcylzl ELSE 0 END)/1000 as decimal(18,1)) as 龙门1余料重量,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='7' THEN dm_ydjh.bcqpyld ELSE 0 END)/1000 as decimal(18,1)) as 龙门1前批余料代,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='7' THEN dm_ydjh.bcljtlzl ELSE 0 END)/1000 as decimal(18,1)) as 龙门1零件重量,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='8' THEN 1 ELSE 0 END) as s1,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='8'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as s1dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='8' THEN dm_ydjh.bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_s1,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='8' THEN dm_ydjh.bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_s1,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='9' THEN 1 ELSE 0 END) as sx2,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='9'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as sx2dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='9' THEN dm_ydjh.bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sx2,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='9' THEN dm_ydjh.bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sx2,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='9' THEN 1 ELSE 0 END) as szd2,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='9'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as szd2dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='9' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_szd2,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='9' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_szd2,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='11' THEN 1 ELSE 0 END) as xf,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='11'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as xfdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='11' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xf,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='11' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xf,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='11' THEN 1 ELSE 0 END) as df,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='11'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as dfdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='11' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_df,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='11' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_df,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='14' THEN 1 ELSE 0 END) as xzhb,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='14'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as xzhbdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='14' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xzhb,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='14' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xzhb,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='14' THEN 1 ELSE 0 END) as dzhb,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='14'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as dzhbdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='14' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dzhb,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='14' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dzhb,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='15' THEN 1 ELSE 0 END) as sx4,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='15'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as sx4dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='15' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sx4,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='15' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sx4,
SUM(CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='15' THEN 1 ELSE 0 END) as jz4,
CAST(SUM( CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='15'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as jz4dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='15' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_jz4,
CAST(SUM(CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='15' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_jz4,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='5' THEN 1 ELSE 0 END) as xm,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='5'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as xmdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='5' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xm,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='5' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xm,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='5' THEN 1 ELSE 0 END) as dm,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='5'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as dmdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='5' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dm,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='5' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dm,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='6' THEN 1 ELSE 0 END) as sx3,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='6'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as sx3dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='6' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sx3,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='6' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sx3,
SUM(CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='6' THEN 1 ELSE 0 END) as sj3,
CAST(SUM( CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='6'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as sj3dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='6' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sj3,
CAST(SUM(CASE WHEN dm_ydjh.zl= '4230' and dm_ydjh.kw='6' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sj3,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='6' THEN 1 ELSE 0 END) as szd3,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='6'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as szd3dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='6' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_szd3,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='6' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_szd3,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.lx!='B' THEN 1 ELSE 0 END) as xzgs,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.lx!='B' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xz,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.lx!='B' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xz,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.lx!='B' THEN 1 ELSE 0 END) as dzgs,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.lx!='B' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dz,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.lx!='B' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dz,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='15' THEN 1 ELSE 0 END) as szd4,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='15'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as szd4dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='15' THEN bclqzl ELSE 0 END) /1000 as decimal(18,1)) as bclqzl_szd4,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='15' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_szd4,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='10' THEN 1 ELSE 0 END) as sq2x,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='10'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as sq2xdw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='10' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sq2x,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='10' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_sq2x,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='10' THEN 1 ELSE 0 END) as sq2d,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='10'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as sq2ddw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='10' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_sq2d,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='10' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshl_sq2d,
SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='13' THEN 1 ELSE 0 END) as xq3,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='13'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as xq3dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='13' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_xq3,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1010' and dm_ydjh.kw='13' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_xq3,
SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='13' THEN 1 ELSE 0 END) as dq3,
CAST(SUM( CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='13'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as dq3dw,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='13' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_dq3,
CAST(SUM(CASE WHEN dm_ydjh.zl= '1110' and dm_ydjh.kw='13' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_dq3,
SUM(CASE WHEN dm_ydjh.kw='17' THEN 1 ELSE 0 END) as gd,
CAST(SUM( CASE WHEN dm_ydjh.kw='17'
THEN
convert(decimal(10,1),left(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)-1)) *
convert(integer,substring(dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1 ,charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) - charindex('*',dm_ydjh.WPGG,1)- 1 )) / 1000 *
convert(integer,right(dm_ydjh.WPGG,len(dm_ydjh.WPGG )- charindex('*',dm_ydjh.WPGG,charindex('*',dm_ydjh.WPGG,1)+1) )) * 7.85 /1000000
ELSE 0
END) as decimal(18,1)) as gddw,
CAST(SUM(CASE WHEN dm_ydjh.kw='17' THEN bclqzl ELSE 0 END)/1000 as decimal(18,1)) as bclqzl_gd,
CAST(SUM(CASE WHEN dm_ydjh.kw='17' THEN bcshzl ELSE 0 END)/1000 as decimal(18,1)) as bcshzl_gd
from dm_ydjh
WHERE
dm_ydjh.dc_ch=#{ch}
GROUP BY dc_ch,dc_pl
ORDER BY dc_pl
SELECT
SUM(CASE WHEN ISNULL(dm_ydjh.pwfkrq, '') != '' and substring(pwfkrq,0,11)=#{date} THEN 1 ELSE 0 END) AS pwnum,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and kw='8' THEN 1 ELSE 0 END) AS sk1num,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and kw='7' THEN 1 ELSE 0 END) AS lm1num,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and kw='12' THEN 1 ELSE 0 END) AS sk2num,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and (kw='9' or kw='10') THEN 1 ELSE 0 END) AS lm2num,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and kw='14' THEN 1 ELSE 0 END) AS sk3num,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and kw='13' THEN 1 ELSE 0 END) AS lm3num,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and (kw='15' or kw='11') THEN 1 ELSE 0 END) AS sk4num,
SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,11)=#{date} and kw='16' THEN 1 ELSE 0 END) AS xcnum
from dm_ydjh WHERE
1=1
and (substring(qgfkrq,0,11)=#{date} or substring(pwfkrq,0,11)=#{date} )
SELECT
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.pwfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} THEN 1 ELSE 0 END)/#{num}) AS pwnum,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and kw='8' THEN 1 ELSE 0 END)/#{num}) AS sk1num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and kw='7' THEN 1 ELSE 0 END)/#{num}) AS lm1num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and kw='12' THEN 1 ELSE 0 END)/#{num}) AS sk2num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and (kw='9' or kw='10') THEN 1 ELSE 0 END)/#{num}) AS lm2num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and kw='14' THEN 1 ELSE 0 END)/#{num}) AS sk3num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and kw='13' THEN 1 ELSE 0 END)/#{num}) AS lm3num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and (kw='15' or kw='11') THEN 1 ELSE 0 END)/#{num}) AS sk4num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgfkrq, '') != '' and substring(qgfkrq,0,8)=#{yf} and kw='16' THEN 1 ELSE 0 END)/#{num}) AS xcnum
from dm_ydjh WHERE
1=1
and (substring(qgfkrq,0,8)=#{yf} or substring(pwfkrq,0,8)=#{yf} )
SELECT
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.pwjhrq, '') != '' and substring(pwjhrq,0,8)=#{yf} THEN 1 ELSE 0 END)/#{num}) AS pwnum,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and kw='8' THEN 1 ELSE 0 END)/#{num}) AS sk1num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and kw='7' THEN 1 ELSE 0 END)/#{num}) AS lm1num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and kw='12' THEN 1 ELSE 0 END)/#{num}) AS sk2num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and (kw='9' or kw='10') THEN 1 ELSE 0 END)/#{num}) AS lm2num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and kw='14' THEN 1 ELSE 0 END)/#{num}) AS sk3num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and kw='13' THEN 1 ELSE 0 END)/#{num}) AS lm3num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and (kw='15' or kw='11') THEN 1 ELSE 0 END)/#{num}) AS sk4num,
CONVERT(decimal(10,1),SUM(CASE WHEN ISNULL(dm_ydjh.qgjhrq, '') != '' and substring(qgjhrq,0,8)=#{yf} and kw='16' THEN 1 ELSE 0 END)/#{num}) AS xcnum
from dm_ydjh WHERE
1=1
and (substring(qgjhrq,0,8)=#{yf} or substring(pwjhrq,0,8)=#{yf} )