You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

957 lines
34 KiB

2 years ago
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dsic.gj_erp.mapper.jhgk.DmYdjhMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.dsic.gj_erp.bean.jhgk.DmYdjh">
1 year ago
<id column="id" property="id"/>
<result column="dc_ch" property="dcCh"/>
<result column="dc_ch1" property="dcCh1"/>
<result column="dc_pl" property="dcPl"/>
<result column="LQLB" property="lqlb"/>
<result column="tzbh" property="tzbh"/>
<result column="wpgg" property="wpgg"/>
<result column="wpxh" property="wpxh"/>
<result column="hxcd" property="hxcd"/>
<result column="qgcd" property="qgcd"/>
<result column="qbs" property="qbs"/>
<result column="pklx" property="pklx"/>
<result column="pkcd" property="pkcd"/>
<result column="ljsl" property="ljsl"/>
<result column="zl" property="zl"/>
<result column="lx" property="lx"/>
<result column="xcms" property="xcms"/>
<result column="kw" property="kw"/>
<result column="slrq" property="slrq"/>
<result column="slry" property="slry"/>
<result column="pw" property="pw"/>
<result column="pwry" property="pwry"/>
<result column="pwrq" property="pwrq"/>
<result column="hxsb" property="hxsb"/>
<result column="hxry" property="hxry"/>
<result column="hxrq" property="hxrq"/>
<result column="qgsb" property="qgsb"/>
<result column="qgry" property="qgry"/>
<result column="qgrq" property="qgrq"/>
<result column="dmcd" property="dmcd"/>
<result column="dmsb" property="dmsb"/>
<result column="dmry" property="dmry"/>
<result column="dmrq" property="dmrq"/>
<result column="pwsb" property="pwsb"/>
<result column="pksb" property="pksb"/>
<result column="pkry" property="pkry"/>
<result column="pkrq" property="pkrq"/>
<result column="DC_FD" property="dcFd"/>
<result column="gjjs_dz" property="gjjsDz"/>
<result column="gjjs_xz" property="gjjsXz"/>
<result column="jsq_tlt" property="jsqTlt"/>
<result column="jsq_lqb" property="jsqLqb"/>
<result column="dhqd" property="dhqd"/>
<result column="order_bs" property="orderBs"/>
<result column="arrival_bs" property="arrivalBs"/>
<result column="qy" property="qy"/>
<result column="jzbs" property="jzbs"/>
<result column="jzsb" property="jzsb"/>
<result column="jzry" property="jzry"/>
<result column="qjgsb" property="qjgsb"/>
<result column="qjgry" property="qjgry"/>
<result column="qjgrq" property="qjgrq"/>
<result column="dcCh2" property="dcCh2"/>
<result column="gjks" property="gjks"/>
<result column="gxsj" property="gxsj"/>
<result column="hxkc_cd" property="hxkcCd"/>
<result column="qgkc_cd" property="qgkcCd"/>
<result column="jssj" property="jssj"/>
<result column="jzrq" property="jzrq"/>
<result column="zt" property="zt"/>
<result column="xcgs" property="xcgs"/>
<result column="bclqzl" property="bclqzl"/>
<result column="bcshzl" property="bcshzl"/>
<result column="bcylzl" property="bcylzl"/>
<result column="bcljtlzl" property="bcljtlzl"/>
<result column="bcqpyld" property="bcqpyld"/>
<result column="ylbhgg" property="ylbhgg"/>
<result column="parent_id" property="parentId"/>
2 years ago
</resultMap>
<select id="gxjhwcqk" resultType="java.util.Map">
SELECT zt,bcshzl,slfkrq,pwfkrq,llfkrq,hxfkrq,qgfkrq
from dm_ydjh
WHERE
jssj BETWEEN #{from} and #{to} and zt>='2'
</select>
<select id="gyfcl" resultType="map">
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>
<select id="jhwcqk" resultType="map">
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>
<select id="gekuachaliang" resultType="java.util.Map">
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>
1 year ago
<select id="getSygdmx" resultType="com.dsic.gj_erp.bean.jhgk.DmSygdMx">
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
1 year ago
( SELECT dm_qfxq.xzglxq as xqsj,dm_bom.tzbh,
1 year ago
dm_qfxq.DC_CH,dm_qfxq.DC_PL,dm_qfxq.DC_FD,
1 year ago
row_number() over(partition by dm_qfxq.DC_CH,dm_qfxq.DC_PL,dm_bom.tzbh order by dm_qfxq.xzglxq ) rn
1 year ago
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
1 year ago
substring(dm_qfxq.xzglxq, 0, 8) =#{nextMonth}) r where r.rn=1
1 year ago
)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
</select>
<!-- <select id="getTzjh" resultType="com.dsic.gj_erp.bean.pgd.PgdTzjh">-->
<!-- INSERT into pgd_tzjh(-->
<!-- tzzt,-->
<!-- zt,-->
<!-- czbh,-->
<!-- pl,-->
<!-- fd,-->
<!-- lqbxfrq,-->
<!-- lqbjsrq,-->
<!-- tltxfrq,-->
<!-- tltjsrq,-->
<!-- qgxqrq,-->
<!-- qfxqrqxz,-->
<!-- qfxqrqdz,-->
<!-- id-->
<!-- )-->
<!-- 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>-->
<select id="getTzjh" resultType="com.dsic.gj_erp.bean.pgd.PgdTzjh" parameterType="map">
INSERT into pgd_tzjh(
tzzt,
1 year ago
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
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
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>
<select id="getTzjh1" resultType="com.dsic.gj_erp.bean.pgd.PgdTzjh">
SELECT
'00' as tzzt,
1 year ago
'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,
1 year ago
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
1 year ago
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}
1 year ago
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>
1 year ago
<select id="getDhjh" resultType="com.dsic.gj_erp.bean.pgd.PgdDh">
SELECT
1 year ago
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,
1 year ago
(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,
1 year ago
dhxx.DHSL as xqsl
1 year ago
from dm_ydjh left join
1 year ago
(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,
1 year ago
MS_DDJBP.dhqdh as dhqdh,
'00' as zt
1 year ago
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 <![CDATA[ <> ]]> '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
1 year ago
on dhxx.dhqdh = dm_ydjh.dhqd
where
1 year ago
dm_ydjh.slrq BETWEEN #{begin} and #{end}
ORDER BY dm_ydjh.dc_ch,
1 year ago
dm_ydjh.dc_pl
</select>
<select id="getDhjh1" resultType="com.dsic.gj_erp.bean.pgd.PgdDh">
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 <![CDATA[ <> ]]> '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}
</select>
<select id="getSljh" resultType="com.dsic.gj_erp.bean.pgd.PgdSljh">
insert into pgd_sljh
(
id,
czbh,
pl,
fd,
zl,
lqlb,
kw,
tlth,
wpgg,
wpcz,
wpzl,
hth,
xhth,
lph,
kwh,
cs,
1 year ago
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
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getSljh1" resultType="com.dsic.gj_erp.bean.pgd.PgdSljh">
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,
1 year ago
'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}
1 year ago
</select>
<select id="getPwjh" resultType="com.dsic.gj_erp.bean.pgd.PgdPwjh">
1 year ago
insert into pgd_pwjh
(
id,
czbh,
pl,
fd,
zl,
lqlb,
kw,
tlth,
wpgg,
wpcz,
wpzl,
pwwz,
pwjhrq,
qfxqrqxz,
1 year ago
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,
1 year ago
dm_ydjh.gjjs_dz as qfxqrqdz,
'01' as zt,
#{bzry},
#{bzrq}
from dm_ydjh
WHERE dm_ydjh.id in
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getPwjh1" resultType="com.dsic.gj_erp.bean.pgd.PgdPwjh">
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}
</select>
<select id="getQgjh" resultType="com.dsic.gj_erp.bean.pgd.PgdQgjh">
insert into pgd_qgjh
(
id,
czbh,
pl,
fd,
zl,
lqlb,
kw,
tlth,
wpgg,
wpcz,
wpzl,
qgjhrq,
qfxqrqxz,
qfxqrqdz,
pwjhwgrq,
hxcd,
qgcd,
hxkccd,
1 year ago
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,
1 year ago
qgkc_cd as qgkccd,
'01' as zt,
#{bzry},
#{bzrq}
from dm_ydjh
where dm_ydjh.id in
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="getQgjh1" resultType="com.dsic.gj_erp.bean.pgd.PgdQgjh">
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>
<select id="gcjd" resultType="java.util.Map">
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
<foreach collection="czbh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
order by dc_ch
</select>
1 year ago
<update id="xfbc" parameterType="arraylist">
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
<foreach collection="ids" index="index" item="item" open="(" separator="," close=");">
#{item}
</foreach>
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
<foreach collection="ids" index="index" item="item" open="(" separator="," close=");">
#{item}
</foreach>
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
<foreach collection="ids" index="index" item="item" open="(" separator="," close=");">
#{item}
</foreach>
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
<foreach collection="ids" index="index" item="item" open="(" separator="," close=");">
#{item}
</foreach>
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
<foreach collection="ids" index="index" item="item" open="(" separator="," close=");">
#{item}
</foreach>
</update>
<insert id="tqlj" parameterType="arraylist">
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,
8 months ago
qbs,
qjg_zt,
pk_zt,
8 months ago
dm_zt,dmjhrq,pkjhrq,qjgjhrq,ppzt
8 months ago
1 year ago
)
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,
8 months ago
case when isnull(dm_ydjh.pkrq,'')&lt;&gt;''
then 'Y'
else '' end ,
case when isnull(dm_ydjh.dmrq,'')&lt;&gt;''
then 'Y'
else '' end ,
1 year ago
dm_bom.dmcd as dmcd,
8 months ago
case when isnull(dm_ydjh.qjgrq,'')&lt;&gt;''
then 'Y'
else '' end,
'01',
'01','01',dm_ydjh.dmrq dmjhrq,dm_ydjh.pkrq pkjhrq,dm_ydjh.qjgrq qjgjhrq,'01'
1 year ago
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
1 year ago
and dm_ydjh.id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=");">
#{item}
</foreach>
</insert>
<select id="getYdjhMin" parameterType="string" resultType="com.dsic.gj_erp.bean.jhgk.DmYdjh">
6 months ago
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>
6 months ago
<select id="getydjhhz" parameterType="string" resultType="com.dsic.gj_erp.bean.jhgk.DmYdjh">
SELECT
dm_ydjh.dc_ch,
dm_ydjh.dc_pl,
dm_ydjh.jssj,
dm_ydjh.sljhrq,
dm_ydjh.pwjhrq,
dm_ydjh.lljhrq,
dm_ydjh.hxjhrq,
dm_ydjh.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,
6 months ago
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
6 months ago
FROM
dm_ydjh
5 months ago
where 1=1 AND lx='B'
6 months ago
<if test=" dcCh!=null and dcCh!=''">
and dm_ydjh.dc_ch=#{dcCh}
</if>
<if test=" zt!=null and zt!=''">
and dm_ydjh.zt=#{zt}
</if>
<if test="yf != null and yf!=''">
and dm_ydjh.jssj&gt;=#{yf}
</if>
<if test="yf != null and yf!=''">
6 months ago
and dm_ydjh.jssj&lt;=#{yf1}
6 months ago
</if>
GROUP BY
dm_ydjh.dc_ch,
dm_ydjh.dc_pl,
dm_ydjh.jssj,
dm_ydjh.sljhrq,
dm_ydjh.pwjhrq,
dm_ydjh.lljhrq,
dm_ydjh.hxjhrq,
dm_ydjh.qgjhrq
6 months ago
order by dc_ch,dc_pl,jssj
6 months ago
</select>
<select id="getWcl" resultType="java.util.Map">
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&lt;62 ) a
where a.rn=1
order by dcCh asc ,dcPl desc ,zt
</select>
6 months ago
<select id="getYdjhByZt" resultType="map">
select
dc_ch dcCh,dc_pl dcPl,count(1) total,plxh,
<if test="wgzt=='62'">
sum(case when isnull(qgfkrq,'')='' then 1 else 0 end) wwg,
sum(case when isnull(qgfkrq,'')!='' then 1 else 0 end) comp,
</if>
<if test="wgzt=='52'">
sum(case when isnull(hxfkrq,'')='' then 1 else 0 end) wwg,
sum(case when isnull(hxfkrq,'')!='' then 1 else 0 end) comp,
</if>
<if test="wgzt=='32'">
sum(case when isnull(pwfkrq,'')='' then 1 else 0 end) wwg,
sum(case when isnull(pwfkrq,'')!='' then 1 else 0 end) comp,
</if>
<if test="zt!=null and zt!=''">
sum(case when zt>=#{zt} then 1 else 0 end) compOnLastGx,
</if>
<if test="wgzt=='62'">
sum(case when isnull(qgpgrq,'')='' then 1 else 0 end) wpg
</if>
<if test="wgzt=='52'">
sum(case when isnull(hxpgrq,'')='' then 1 else 0 end) wpg
</if>
<if test="wgzt=='32'">
sum(case when isnull(pwpgrq,'')='' then 1 else 0 end) wpg
</if>
from
dm_ydjh
where zt>=11
<if test="wgzt=='62'">
and isnull(qgfkrq,'')=''
</if>
<if test="wgzt=='52'">
and isnull(hxfkrq,'')=''
</if>
<if test="wgzt=='32'">
and isnull(pwfkrq,'')=''
</if>
group by dc_ch, dc_pl,plxh
order by dc_ch,dc_pl
</select>
6 months ago
5 months ago
<update id="xzylbs" parameterType="string" >
UPDATE dm_ydjh set dm_ydjh.ylbs=dm_bchxylp.sfyl from dm_ydjh LEFT 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>
2 years ago
</mapper>