You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/resources/mybatis/mapper/inv/invProductDao.xml

576 lines
24 KiB
XML

<?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.glxp.api.dao.inv.InvProductDao">
<select id="filterList" resultType="com.glxp.api.res.inv.InvProductResponse"
parameterType="com.glxp.api.req.inv.FilterInvProductRequest">
select ip.id,
ip.nameCode,
bp.cpmctymc,
bp.measname,
bp.bzgg,
ip.relIdFk,
bp.ggxh,
ip.batchNo,
ip.productionDate,
ip.expireDate,
bp.ylqxzcrbarmc,
bp.zczbhhzbapzbh,
ip.inCount,
ip.outCount,
ip.reCount,
ip.customerId,
basic_corp.name supName,
ip.supId,
auth_dept.name deptName,
auth_warehouse.name invName,
ip.deptCode,
ip.invCode,
as.name spaceName,
bp.basicPrductRemak1,
bp.basicPrductRemak2,
bp.basicPrductRemak3,
bp.basicPrductRemak4,
bp.basicPrductRemak5,
bp.basicPrductRemak6,
bp.basicPrductRemak7,
bp.basicPrductRemak8,
ip.price
from inv_product ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId
left join auth_dept on auth_dept.code = ip.deptCode
left join auth_warehouse on auth_warehouse.code = ip.invCode
left join auth_space `as` on ip.invSpaceCode = `as`.code
<where>
<if test="cpmctymc != null and cpmctymc != ''">
AND bp.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="nameCode != null and nameCode != ''">
AND bp.nameCode like concat('%', #{nameCode}, '%')
</if>
<if test="relIdFk != null and relIdFk != ''">
AND ip.relIdFk = #{relIdFk}
</if>
<if test="ggxh != null and ggxh != ''">
AND bp.ggxh like concat('%', #{ggxh}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND ip.batchNo like concat('%', #{batchNo}, '%')
</if>
<if test="productionDate != null and productionDate != ''">
AND ip.productionDate = #{productionDate}
</if>
<if test="expireDate != null and expireDate != ''">
AND ip.expireDate = #{expireDate}
</if>
<if test="ylqxzcrbarmc != null and ylqxzcrbarmc != ''">
AND bp.ylqxzcrbarmc like concat('%', #{ylqxzcrbarmc}, '%')
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND bp.zczbhhzbapzbh like concat('%', #{zczbhhzbapzbh}, '%')
</if>
<if test="basicPrductRemak1 != null and basicPrductRemak1 != ''">
AND bp.basicPrductRemak1 like concat('%', #{basicPrductRemak1}, '%')
</if>
<if test="basicPrductRemak2 != null and basicPrductRemak2 != ''">
AND bp.basicPrductRemak2 like concat('%', #{basicPrductRemak2}, '%')
</if>
<if test="customerId != null and customerId != ''">
AND ip.customerId = #{customerId}
</if>
<if test="supId != null and supId != ''">
AND ip.supId = #{supId}
</if>
<if test="deptCode != null and deptCode != ''">
AND ip.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND invSpaceCode = #{invSpaceCode}
</if>
<if test="filterNoInv != null and filterNoInv == 1">
AND ip.reCount <![CDATA[ > ]]> 0
</if>
<if test="filterNoInv != null and filterNoInv == 2">
AND ip.reCount <![CDATA[ = ]]> 0
</if>
<if test="filterNoInv != null and filterNoInv == 3">
AND ip.reCount <![CDATA[ < ]]> 0
</if>
<if test="attributeType != '' and attributeType != null">
AND basic_udirel.attributeType = #{attributeType}
</if>
<if test="invCodes != null and invCodes.size() != 0">
AND ip.invCode in
<foreach collection="invCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
GROUP BY ip.relIdFk, ip.batchNo, ip.supId, ip.price
order by ip.updateTime desc
</select>
<select id="stockStatistics" resultType="com.glxp.api.res.inv.InvProductResponse">
select bp.cpmctymc,
bp.nameCode,
bp.ylqxzcrbarmc,
bp.zczbhhzbapzbh,
bc.name supName,
bp.ggxh,
aw.name invName,
ip.batchNo,
ip.relIdFk,
ip.productionDate,
ip.expireDate,
ip.customerId,
ip.supId,
sum(ip.inCount) inCount,
sum(ip.outCount) outCount,
sum(ip.reCount) reCount
from inv_product ip
inner join basic_udirel bu on ip.relIdFk = bu.id
inner join basic_products bp on bu.uuid = bp.uuid
left join basic_corp bc on ip.supId = bc.erpId
left join auth_warehouse aw on aw.code = ip.invCode
<where>
bp.diType = 1
<if test="cpmctymc != null and cpmctymc != ''">
AND bp.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="nameCode != null and nameCode != ''">
AND ip.nameCode like concat('%', #{nameCode}, '%')
</if>
<if test="ggxh != null and ggxh != ''">
AND bp.ggxh like concat('%', #{ggxh}, '%')
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND bp.zczbhhzbapzbh like concat('%', #{zczbhhzbapzbh}, '%')
</if>
<if test="ylqxzcrbarmc != null and ylqxzcrbarmc != ''">
AND bp.ylqxzcrbarmc like concat('%', #{ylqxzcrbarmc}, '%')
</if>
<if test="supId != null and supId != ''">
AND ip.supId like concat('%', #{supId}, '%')
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="invCodes != null and invCodes.size() != 0">
AND invCode in
<foreach collection="invCodes" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo like concat('%', #{batchNo}, '%')
</if>
group by ip.relIdFk, ip.batchNo
</where>
</select>
<select id="getMAInvProducts" resultType="com.glxp.api.res.inv.InvProductResponse">
SELECT ip.id,
bp.nameCode,
bp.cpmctymc,
bp.ggxh,
ip.batchNo,
ip.code,
ip.produceDate productionDate,
ip.expireDate,
ip.serialNo,
basic_corp.NAME supName,
bp.manufactory,
bp.zczbhhzbapzbh
FROM inv_product_detail ip
LEFT JOIN basic_udirel bu ON bu.id = ip.relId
LEFT JOIN basic_products bp ON bu.uuid = bp.uuid
LEFT JOIN basic_corp ON ip.supId = basic_corp.erpId
<where>
<if test="nameCode != null and nameCode != ''">
AND bp.nameCode like concat('%', #{nameCode}, '%')
</if>
<if test="cpmctymc != null and cpmctymc != ''">
AND bp.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND ip.batchNo like concat('%', #{batchNo}, '%')
</if>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
<if test="cplb != null and cplb != ''">
AND bp.cplb = #{cplb}
</if>
<if test="manufactory != null and manufactory != ''">
AND bp.manufactory = #{manufactory}
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND bp.zczbhhzbapzbh = #{zczbhhzbapzbh}
</if>
<if test="supName != null and supName != ''">
AND basic_corp.NAME like concat('%', #{supName}, '%')
</if>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
</where>
GROUP BY ip.`code`, ip.supId
ORDER BY ip.`code`
</select>
<select id="selectProductInfo" resultType="com.glxp.api.entity.inv.InvProductEntity">
select ip.*
from inv_product ip
left join inv_product_detail ipd on ip.relIdFk = ipd.relId
and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
and ip.deptCode = ipd.deptCode
and ip.invCode = ipd.invCode
<where>
<if test="relId != null and relId != ''">
AND ip.relIdFk = #{relId}
</if>
<if test="batchNo != null and batchNo != ''">
AND ip.batchNo = #{batchNo}
</if>
<if test="deptCode != null and deptCode != ''">
AND ip.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipd.invSpaceCode = #{invSpaceCode}
</if>
<!-- <if test="supId != null and supId != ''">-->
<!-- AND ipd.supId = #{supId}-->
<!-- </if>-->
</where>
group by ip.id
</select>
<select id="getCountInvProduct" resultType="com.glxp.api.res.inv.InvProductResponse">
select inv_product_detail.id,
inv_product.relIdFk,
inv_product.nameCode,
inv_product.batchNo,
inv_product.productionDate,
inv_product.expireDate,
basic_products.ggxh,
inv_product.inCount,
inv_product.outCount,
inv_product.reCount,
-- sum(inv_product.inCount - inv_product.outCount) reCount,
basic_products.cpmctymc
from inv_product_detail
left join inv_product on inv_product_detail.relId = inv_product.relIdFk
and inv_product.invCode = inv_product_detail.invCode
AND IFNULL(inv_product.batchNo, 'empty') = IFNULL(inv_product_detail.batchNo, 'empty')
left join basic_udirel on inv_product_detail.relId = basic_udirel.id
left join basic_products on basic_products.uuid = basic_udirel.uuid
<where>
<if test="invCode != null and invCode != ''">
AND inv_product_detail.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND inv_product_detail.invSpaceCode = #{invSpaceCode}
</if>
<if test="nameCode != null and nameCode != ''">
AND inv_product.nameCode like concat('%', #{nameCode}, '%')
</if>
<if test="cpmctymc != null and cpmctymc != ''">
AND basic_products.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND inv_product.batchNo like concat('%', #{batchNo}, '%')
</if>
group by inv_product_detail.relId, inv_product_detail.batchNo
</where>
</select>
<select id="selectInvProductInfo" resultType="com.glxp.api.entity.inv.InvProductEntity">
select ip.relIdFk,
ip.deptCode,
ip.invCode,
ipd.invSpaceCode,
ip.batchNo,
ip.productionDate,
ip.expireDate,
ip.supId,
ip.inCount,
ip.outCount,
ip.reCount
from inv_product ip
left join inv_product_detail ipd
on ip.relIdFk = ipd.relId and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
<where>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipd.invSpaceCode = #{invSpaceCode}
</if>
<if test="relId != null and relId != ''">
AND ip.relIdFk = #{relId}
</if>
</where>
group by ip.relIdFk, ip.batchNo
</select>
<select id="filterProductNames" resultType="com.glxp.api.res.inv.InvProductResponse">
select ip.relIdFk, bp.cpmctymc, bp.ggxh, bp.ylqxzcrbarmc, bp.zczbhhzbapzbh
from inv_product ip
left join inv_product_detail ipd on ip.relIdFk = ipd.relId and ip.invCode = ipd.invCode and
ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
left join basic_udirel bu on bu.id = ip.relIdFk
left join basic_products bp on bp.uuid = bu.uuid
<where>
<if test="cpmctymc != null and cpmctymc != ''">
AND bp.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipd.invSpaceCode = #{invSpaceCode}
</if>
</where>
group by ip.relIdFk, bp.ggxh
</select>
<select id="filterProductList" resultType="com.glxp.api.res.inv.InvProductResponse"
parameterType="com.glxp.api.req.inv.FilterInvProductRequest">
select ip.id,
ip.nameCode,
bp.cpmctymc,
ip.relIdFk,
bp.ggxh,
ip.batchNo,
ip.productionDate,
ip.expireDate,
bp.ylqxzcrbarmc,
bp.zczbhhzbapzbh,
basic_udirel.thirdId thrCode,
sum(ip.inCount) as inCount,
sum(ip.outCount) as outCount,
sum(ip.reCount) as reCount,
ip.customerId,
basic_corp.name supName,
ip.supId,
auth_dept.name deptName,
auth_warehouse.name invName,
ip.deptCode,
ip.invCode
from inv_product ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId
left join auth_dept on auth_dept.code = ip.deptCode
left join auth_warehouse on auth_warehouse.code = ip.invCode
left join inv_product_detail ipd on ip.invCode = ipd.invCode and ip.relIdFk = ipd.relId and
ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
<where>
bp.diType = 1
<if test="cpmctymc != null and cpmctymc != ''">
AND bp.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="nameCode != null and nameCode != ''">
AND bp.nameCode like concat('%', #{nameCode}, '%')
</if>
<if test="relIdFk != null and relIdFk != ''">
AND ip.relIdFk = #{relIdFk}
</if>
<if test="ggxh != null and ggxh != ''">
AND bp.ggxh like concat('%', #{ggxh}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND ip.batchNo like concat('%', #{batchNo}, '%')
</if>
<if test="productionDate != null and productionDate != ''">
AND ip.productionDate = #{productionDate}
</if>
<if test="expireDate != null and expireDate != ''">
AND ip.expireDate = #{expireDate}
</if>
<if test="ylqxzcrbarmc != null and ylqxzcrbarmc != ''">
AND bp.ylqxzcrbarmc like concat('%', #{ylqxzcrbarmc}, '%')
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND bp.zczbhhzbapzbh like concat('%', #{zczbhhzbapzbh}, '%')
</if>
<if test="customerId != null and customerId != ''">
AND ip.customerId = #{customerId}
</if>
<if test="supId != null and supId != ''">
AND ip.supId = #{supId}
</if>
<if test="deptCode != null and deptCode != ''">
AND ip.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
<if test="invCodes != null and invCodes.size() != 0">
AND ip.invCode in
<foreach collection="invCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="supName != null and supName != ''">
AND basic_corp.name like concat('%', #{supName}, '%')
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipd.invSpaceCode = #{invSpaceCode}
</if>
</where>
group by ip.relIdFk
order by ip.updateTime desc
</select>
<select id="filterProductListStock" resultType="com.glxp.api.res.inv.InvProductResponse"
parameterType="com.glxp.api.req.inv.FilterInvProductRequest">
select ip.id,
ip.nameCode,
bp.cpmctymc,
bp.measname,
ip.relIdFk,
bp.ggxh,
ip.batchNo,
ip.productionDate,
ip.expireDate,
bp.ylqxzcrbarmc,
bp.zczbhhzbapzbh,
sum(ip.inCount) as inCount,
sum(ip.outCount) as outCount,
sum(ip.reCount) as reCount,
ip.customerId,
basic_corp.name supName,
ip.supId,
auth_dept.name deptName,
auth_warehouse.name invName,
ip.deptCode,
ip.price,
ip.invCode
from inv_product ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId
left join auth_dept on auth_dept.code = ip.deptCode
left join auth_warehouse on auth_warehouse.code = ip.invCode
left join basic_product_category_rel on basic_product_category_rel.relId = basic_udirel.id
left join basic_product_category on basic_product_category_rel.code = basic_product_category.code
<where>
bp.diType = 1
<if test="cpmctymc != null and cpmctymc != ''">
AND bp.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="nameCode != null and nameCode != ''">
AND bp.nameCode like concat('%', #{nameCode}, '%')
</if>
<if test="diCode != null and diCode != ''">
AND bp.nameCode = #{diCode}
</if>
<if test="relIdFk != null and relIdFk != ''">
AND ip.relIdFk = #{relIdFk}
</if>
<if test="ggxh != null and ggxh != ''">
AND bp.ggxh like concat('%', #{ggxh}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND ip.batchNo like concat('%', #{batchNo}, '%')
</if>
<if test="productionDate != null and productionDate != ''">
AND ip.productionDate = #{productionDate}
</if>
<if test="expireDate != null and expireDate != ''">
AND ip.expireDate = #{expireDate}
</if>
<if test="ylqxzcrbarmc != null and ylqxzcrbarmc != ''">
AND bp.ylqxzcrbarmc like concat('%', #{ylqxzcrbarmc}, '%')
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND bp.zczbhhzbapzbh like concat('%', #{zczbhhzbapzbh}, '%')
</if>
<if test="customerId != null and customerId != ''">
AND ip.customerId = #{customerId}
</if>
<if test="supId != null and supId != ''">
AND ip.supId = #{supId}
</if>
<if test="deptCode != null and deptCode != ''">
AND ip.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND ip.invCode = #{invCode}
</if>
<if test="invCodes != null and invCodes.size() != 0">
AND ip.invCode in
<foreach collection="invCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="supName != null and supName != ''">
AND basic_corp.name like concat('%', #{supName}, '%')
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipd.invSpaceCode = #{invSpaceCode}
</if>
<if test="basicPrductRemak1 != '' and basicPrductRemak1 != null">
AND bp.basicPrductRemak1 like concat('%', #{basicPrductRemak1}, '%')
</if>
<if test="manufactory != null and manufactory != ''">
and bp.manufactory LIKE concat('%', #{manufactory}, '%')
</if>
<if test="category != '' and category != null">
AND basic_product_category.name = #{category}
</if>
</where>
group by ip.relIdFk
having reCount > 0
order by ip.updateTime desc
</select>
<select id="selectExitCount" resultType="java.lang.Integer">
select sum(reCount)
from inv_product
<where>
<if test="relIdFk != null">
AND relIdFk = #{relIdFk}
</if>
<if test="supId != null">
AND supId = #{supId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
</where>
</select>
<select id="filterReCount" resultType="string">
select ip.supId
from inv_product ip
<where>
AND ip.reCount > 0
<if test="relId != null and relId != ''">
AND ip.relIdFk = #{relId}
</if>
<if test="batchNo != null and batchNo != ''">
AND ip.batchNo = #{batchNo}
</if>
<if test="unitFks != null and unitFks.size() != 0">
AND ip.supId in
<foreach collection="unitFks" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>