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.

239 lines
8.3 KiB

<?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.DmSygdxqMapper">
<resultMap id="sqgdxqVo" type="dmSygdxq">
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="dc_ch" property="dcCh" jdbcType="VARCHAR" />
<result column="dc_pl" property="dcPl" jdbcType="VARCHAR" />
<result column="dc_fd" property="dcFd" jdbcType="VARCHAR" />
<result column="zdh" property="zdh" jdbcType="VARCHAR" />
<result column="xzglxq" property="xzglxq" jdbcType="VARCHAR" />
<result column="dzglxq" property="dzglxq" jdbcType="VARCHAR" />
<collection property="bomList" ofType="dmBom" javaType="java.util.ArrayList" columnPrefix="bom_" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="dcch" property="dcch" jdbcType="VARCHAR" />
<result column="mbch" property="mbch" jdbcType="VARCHAR" />
<result column="pl" property="pl" jdbcType="VARCHAR" />
<result column="fd" property="fd" jdbcType="VARCHAR" />
<result column="kw" property="kw" jdbcType="VARCHAR" />
<result column="zl" property="zl" jdbcType="VARCHAR" />
<result column="tzbh" property="tzbh" jdbcType="VARCHAR" />
<result column="wpgg" property="wpgg" jdbcType="VARCHAR" />
<result column="wpcz" property="wpcz" jdbcType="VARCHAR" />
<result column="ljsl" property="ljsl" jdbcType="DOUBLE" />
<result column="fkgs" property="fkgs" jdbcType="VARCHAR" />
<result column="tlsl" property="tlsl" jdbcType="VARCHAR" />
</collection>
</resultMap>
<select id="getXqWithBom" resultMap="sqgdxqVo">
select * from
(select
xq.id,
xq.dc_ch,
xq.dc_pl,
xq.dc_fd,
xq.xzglxq,
xq.dzglxq,
bom.id as bom_id,
bom.dcch as bom_dcch,
bom.mbch as bom_mbch,
bom.pl as bom_pl,
bom.fd as bom_fd,
bom.kw as bom_kw,
bom.zl as bom_zl,
bom.tzbh as bom_tzbh,
bom.wpgg as bom_wpgg,
bom.wpcz as bom_wpcz,
bom.ljsl as bom_ljsl,
bom.fkgs as bom_fkgs,
bom.tlsl as bom_tlsl,
ROW_NUMBER() over(partition by xq.dc_ch,xq.dc_pl,bom.tzbh order by bom.tzbh) rn
from
dm_sygdxq xq left join dm_bom bom on bom.dcch = xq.DC_CH and bom.pl = xq.DC_PL and bom.fd = xq.DC_FD
where
xq.xzglxq between #{from} and #{to} and (bom.type='b' or isnull(bom.type,'')='')
<if test="dcch!=null and dcch!=''">
and xq.DC_CH=#{dcch}
</if>
<if test="pl!=null and pl!=''">
and bom.pl=#{pl}
</if>
) a
where a.rn=1
order by a.dc_ch,a.dc_pl
</select>
<select id="getXqWithBom2" resultMap="sqgdxqVo">
select * from
(select
xq.id,
xq.dc_ch,
xq.dc_pl,
xq.dc_fd,
xq.xzglxq,
xq.dzglxq,
bom.id as bom_id,
bom.dcch as bom_dcch,
bom.mbch as bom_mbch,
bom.pl as bom_pl,
bom.fd as bom_fd,
bom.kw as bom_kw,
bom.zl as bom_zl,
bom.tzbh as bom_tzbh,
bom.wpgg as bom_wpgg,
bom.wpcz as bom_wpcz,
bom.ljsl as bom_ljsl,
bom.fkgs as bom_fkgs,
bom.tlsl as bom_tlsl,
ROW_NUMBER() over(partition by bom.dcch,bom.pl,bom.tzbh order by bom.tzbh) rn
from
dm_sygdxq xq left join dm_bom bom on bom.dcch = xq.sczbh and bom.pl = xq.DC_PL and bom.fd = xq.DC_FD
where
xq.xzglxq between #{from} and #{to} and bom.type='b'
<if test="dcch!=null and dcch!=''">
and xq.DC_CH=#{dcch}
</if>
<if test="pl!=null and pl!=''">
and bom.pl=#{pl}
</if>
) a
where a.rn=1
order by a.xzglxq
</select>
<select id="getSygdLjMx" resultType="dmSygdMxLj">
SELECT
dm_sygdxq.xzglxq ,
dm_sygdxq.dzglxq ,
dm_sygdxq.DC_CH as dcch,
dm_sygdxq.DC_PL as pl,
dm_sygdxq.DC_FD as fd,
dm_bom.mbch,
dm_bom.pw,
dm_bom.lqlb,
dm_bom.kw,
dm_bom.zl,
dm_bom.wpcz,
dm_bom.wpgg,
dm_bom.bh,
dm_bom.bc,
dm_bom.yqyl,
dm_bom.qgcd,
(SELECT (CASE WHEN dm_bom.tzbh is null THEN '' ELSE dm_bom.tzbh END)) as tzbh,
dm_bom.tlsl,
dm_bom.pklx,
dm_bom.qbs,
dm_bom.pkbs,
dm_bom.pkcd,
dm_bom.dmbs,
dm_bom.dmcd,
dm_bom.zpsx,
dm_bom.ljbh,
dm_bom.ljsl,
dm_bom.ljsx,
dm_bom.djmj,
dm_bom.ljdz,
dm_bom.blgs,
dm_bom.pwgs,
dm_bom.llgs,
dm_bom.hxgs,
dm_bom.qggs,
dm_bom.pkgs,
dm_bom.qgs,
dm_bom.dmgs,
dm_bom.zpgs,
dm_bom.hxcd,
dm_bom.xcgs,
dm_bom.xcshms,
dm_bom.bclqzl,
dm_bom.bcshzl,
dm_bom.bcylzl,
dm_bom.bcljtlzl,
dm_bom.ylbhgg,
dm_bom.bcqpyld,
bc.sfyl ylbs,
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','') as id
from
dm_sygdxq LEFT JOIN dm_bom on dm_bom.dcch = dm_sygdxq.DC_CH and dm_bom.pl = dm_sygdxq.DC_PL and dm_bom.fd = dm_sygdxq.DC_FD
left join
(select
dc_ch,dc_pl,tzbh,sfyl,rn
from
(select dc_ch,dc_pl,tzbh,sfyl,
ROW_NUMBER() over(PARTITION by dc_ch ,dc_pl,tzbh order by tzbh) rn from dm_bchxylp) a where a.rn=1) bc
on dm_bom.dcch =bc.dc_ch and dm_bom.pl =bc.dc_pl and dm_bom.tzbh =bc.tzbh
where
dm_sygdxq.xzglxq between #{begin} and #{end} and dm_bom.type = 'b'
ORDER BY dm_sygdxq.xzglxq,dm_sygdxq.DC_CH,dm_sygdxq.DC_PL,dm_bom.TZBH,dm_sygdxq.DC_FD
</select>
<select id="getSygdLjMx1" resultType="dmSygdMxLj">
SELECT
dm_sygdxq.xzglxq ,
dm_sygdxq.dzglxq ,
dm_sygdxq.DC_CH as dcch,
dm_sygdxq.DC_PL as pl,
dm_sygdxq.DC_FD as fd,
dm_bom.mbch,
dm_bom.pw,
dm_bom.lqlb,
dm_bom.kw,
dm_bom.zl,
dm_bom.wpcz,
dm_bom.wpgg,
dm_bom.bh,
dm_bom.bc,
dm_bom.yqyl,
dm_bom.qgcd,
(SELECT (CASE WHEN dm_bom.tzbh is null THEN '' ELSE dm_bom.tzbh END)) as tzbh,
dm_bom.tlsl,
dm_bom.pklx,
dm_bom.qbs,
dm_bom.pkbs,
dm_bom.pkcd,
dm_bom.dmbs,
dm_bom.dmcd,
dm_bom.zpsx,
dm_bom.ljbh,
dm_bom.ljsl,
dm_bom.ljsx,
dm_bom.djmj,
dm_bom.ljdz,
dm_bom.blgs,
dm_bom.pwgs,
dm_bom.llgs,
dm_bom.hxgs,
dm_bom.qggs,
dm_bom.pkgs,
dm_bom.qgs,
dm_bom.dmgs,
dm_bom.zpgs,
dm_bom.hxcd,
dm_bom.xcgs,
dm_bom.xcshms,
dm_bom.bclqzl,
dm_bom.bcshzl,
dm_bom.bcylzl,
dm_bom.bcljtlzl,
dm_bom.ylbhgg,
dm_bom.bcqpyld,
bc.sfyl ylbs,
REPLACE(CAST(CAST(NEWID()AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER),'-','') as id
from
dm_sygdxq LEFT JOIN dm_bom on dm_bom.dcch = dm_sygdxq.DC_CH and dm_bom.pl = dm_sygdxq.DC_PL and dm_bom.fd = dm_sygdxq.DC_FD
left join
(select
dc_ch,dc_pl,tzbh,sfyl,rn
from
(select dc_ch,dc_pl,tzbh,sfyl,
ROW_NUMBER() over(PARTITION by dc_ch ,dc_pl,tzbh order by tzbh) rn from dm_bchxylp) a where a.rn=1) bc
on dm_bom.dcch =bc.dc_ch and dm_bom.pl =bc.dc_pl and dm_bom.tzbh =bc.tzbh
where
dm_bom.type = 'b' and dm_sygdxq.dc_ch=#{dcch} and dm_sygdxq.dc_pl=#{pl}
ORDER BY dm_sygdxq.xzglxq,dm_sygdxq.DC_CH,dm_sygdxq.DC_PL,dm_bom.TZBH,dm_sygdxq.DC_FD
</select>
</mapper>