<?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" >
<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" />
</resultMap>
<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
( SELECT dm_qfxq.db 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.db ) 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.db, 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
</select>
<select id= "getTzjh" resultType= "com.dsic.gj_erp.bean.pgd.PgdTzjh" >
INSERT into pgd_tzjh(
tzzt,
czbh,
pl,
fd,
lqbxfrq,
lqbjsrq,
tltxfrq,
tltjsrq,
qgxqrq,
qfxqrqxz,
qfxqrqdz,
id
)
SELECT
'00' as tzzt,
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,
dm_ydjh.qgrq as qgxqrq,
dm_ydjh.jssj as qfxqrqxz,
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
(SELECT dm_czplp_new.DC_CH,dm_czplp_new.DC_PL,dm_czplp_new.jsq_lqb,dm_czplp_new.jsq_tlt,dm_czplp_new.xfq_lqb,dm_czplp_new.xfq_tlt,dm_czplp_new.jsq_ptb,dm_czplp_new.xfq_ptb
from dm_czplp_new
GROUP BY dm_czplp_new.DC_CH,dm_czplp_new.DC_PL,dm_czplp_new.jsq_lqb,dm_czplp_new.jsq_tlt,dm_czplp_new.xfq_lqb,dm_czplp_new.xfq_tlt,dm_czplp_new.jsq_ptb,dm_czplp_new.xfq_ptb)
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}
</select>
<select id= "getDhjh" resultType= "com.dsic.gj_erp.bean.pgd.PgdDh" >
insert into pgd_dh
(id,
czbh,
dhqdh,
wpcz,
slxqrq,
qfxqrqxz,
qfxqrqdz,
hth,
xhth,
dhsl,
hd,
kd,
cd,
xqsl)
SELECT
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','') as id,
dm_ydjh.dc_ch as czbh,
dm_czplp_new.dhqd as dhqdh,
dm_ydjh.jssj as qfxqrqxz,
dm_ydjh.gjjs_dz as qfxqrqdz,
dm_ydjh.slrq as slxqrq,
dhxx.ddmc as hth,
dhxx.dc_ch as xhth,
dhxx.DHSL as xqsl,
dhxx.HDSL as dhsl,
dhxx.WPHD as hd,
dhxx.WPCD as cd,
dhxx.WPKD as kd,
dhxx.RKXH as wpcz
from dm_ydjh
LEFT JOIN
(SELECT DC_CH, DC_PL, dhqd
from dm_czplp_new
GROUP BY DC_CH, DC_PL, dhqd) dm_czplp_new
on
dm_ydjh.dc_ch = dm_czplp_new.DC_CH and
dm_ydjh.dc_pl = dm_czplp_new.DC_pl
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
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_czplp_new.dhqd
where dm_ydjh.slrq BETWEEN #{begin} and #{end}
ORDER BY dm_ydjh.dc_ch,
dm_ydjh.dc_pl
</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,
sljhrq
)
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.slrq as sljhrq,
(IM_CKWPKWP.KWH) AS kwh ,
IM_CKWPKWP.GCDDH as xhth,
(IM_CKWPKWP.LPH) AS lph,
(IM_CKWPKWP.CFCS1) AS cs,
(IM_CKWPKWP.dc_fd) AS hth
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}
</select>
<select id= "getPwjh" resultType= "com.dsic.gj_erp.bean.pgd.PgdPwjh" >
insert into pgd_pwjh
(
id,
czbh,
pl,
fd,
zl,
lqlb,
kw,
tlth,
wpgg,
wpcz,
wpzl,
pwwz,
pwjhrq,
qfxqrqxz,
qfxqrqdz
)
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
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,
qgkccd
)
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
from dm_ydjh
where dm_ydjh.qgrq BETWEEN #{begin} and #{end}
</select>
</mapper>