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/InvProductNewDao.xml

579 lines
22 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.InvProductNewDao">
<select id="findGroupBySpace" resultType="com.glxp.api.res.inv.InvProductResponse">
select ipp.id,
ipp.nameCode,
bp.cpmctymc,
ipp.relIdFk as relId,
bp.ggxh,
bp.measname,
ipp.batchNo,
ipp.productionDate as produceDate,
ipp.expireDate,
bp.ylqxzcrbarmc,
bp.zczbhhzbapzbh,
bp.bzgg,
inCount,
outCount,
reCount,
basic_corp.name supName,
ipp.supId,
auth_dept.name deptName,
auth_warehouse.name invName,
as.name spaceName,
ipp.deptCode,
ipp.invCode,
ipp.invSpaceCode,
<!-- ipp.code as code,-->
bp.productsType,
bp.levelUnit,
bp.prepnUnit,
bp.packUnit,
bp.prepnSpec,
bp.specialCode,
bp.storageCondition,
bp.transportCondition,
bp.indate,
bp.useAttribute,
bp.packMatrial,
bp.majorType,
bp.majorStatus,
bp.physicType,
bp.medicareType
from inv_product ipp
inner join basic_udirel on ipp.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ipp.supId = basic_corp.erpId
left join auth_dept on auth_dept.code = ipp.deptCode
left join auth_warehouse on auth_warehouse.code = ipp.invCode
left join auth_space `as` on ipp.invSpaceCode = `as`.code
<where>
<if test="cpmctymc != null and cpmctymc != ''">
AND bp.cpmctymc like concat('%', #{cpmctymc}, '%')
</if>
<if test="nameCode != null and nameCode != ''">
AND ipp.nameCode like concat('%', #{nameCode}, '%')
</if>
<if test="relIdFk != null and relIdFk != ''">
AND ipp.relIdFk = #{relIdFk}
</if>
<if test="productsType != null ">
AND bp.productsType = #{productsType}
</if>
<if test="ggxh != null and ggxh != ''">
AND bp.ggxh like concat('%', #{ggxh}, '%')
</if>
<if test="bzgg != null and bzgg != ''">
AND bp.bzgg like concat('%', #{bzgg}, '%')
</if>
<if test="prepnSpec != null and prepnSpec != ''">
AND bp.prepnSpec like concat('%', #{prepnSpec}, '%')
</if>
<if test="batchNo != null and batchNo != ''">
AND ipp.batchNo like concat('%', #{batchNo}, '%')
</if>
<if test="productionDate != null and productionDate != ''">
AND ipp.productionDate = #{productionDate}
</if>
<if test="expireDate != null and expireDate != ''">
AND ipp.expireDate = #{expireDate}
</if>
<if test="ylqxzcrbarmc != null and ylqxzcrbarmc != ''">
AND (
bp.ylqxzcrbarmc like concat('%', #{ylqxzcrbarmc}, '%')
or bp.manufactory like concat('%', #{ylqxzcrbarmc}, '%')
)
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND bp.zczbhhzbapzbh like concat('%', #{zczbhhzbapzbh}, '%')
</if>
<if test="supId != null and supId != ''">
AND ipp.supId = #{supId}
</if>
<if test="deptCode != null and deptCode != ''">
AND ipp.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND ipp.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipp.invSpaceCode = #{invSpaceCode}
</if>
<if test="invCodes != null and invCodes.size() != 0">
AND ipp.invCode in
<foreach collection="invCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="keyWords != '' and keyWords != null">
AND (
bp.cpmctymc like concat('%', #{keyWords}, '%')
or ipp.nameCode like concat('%', #{keyWords}, '%')
or bp.ggxh like concat('%', #{keyWords}, '%')
or bp.bzgg like concat('%', #{keyWords}, '%')
or bp.prepnSpec LIKE concat('%', #{keyWords}, '%')
or ipp.batchNo like concat('%', #{keyWords}, '%')
or bp.zczbhhzbapzbh LIKE concat('%', #{keyWords}, '%')
or bp.manufactory LIKE concat('%', #{keyWords}, '%')
or bp.ylqxzcrbarywmc LIKE concat('%', #{keyWords}, '%'))
</if>
</where>
GROUP BY ipp.relIdFk, ipp.batchNo
order by ipp.updateTime desc
</select>
<select id="filterInvProductDetailList" resultType="com.glxp.api.vo.basic.InvProductNewVo"
parameterType="com.glxp.api.req.inv.FilterInvProductDetailRequest">
select *
from inv_product
<where>
<!-- <if test="code != null and code != ''">-->
<!-- AND code like concat('%', #{code}, '%')-->
<!-- </if>-->
<!-- <if test="mainAction != null and mainAction != ''">-->
<!-- AND mainAction = #{mainAction}-->
<!-- </if>-->
<!-- <if test="action != null and action != ''">-->
<!-- AND action = #{action}-->
<!-- </if>-->
<if test="supId != null and supId != ''">
and supId = #{supId}
</if>
<if test="relId != null and relId != ''">
AND relIdFk = #{relId}
</if>
<if test="nameCode != null and nameCode != ''">
AND nameCode like concat('%', #{nameCode}, '%')
</if>
<!-- <if test="orderId != null and orderId != ''">-->
<!-- AND orderId = #{orderId}-->
<!-- </if>-->
<if test="deptCode != null and deptCode != ''">
AND deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND invSpaceCode = #{invSpaceCode}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
<if test="price != null">
AND price = #{price}
</if>
<if test="price == null">
AND price is null
</if>
<if test="productionDate != null and productionDate != ''">
AND productionDate = #{productionDate}
</if>
<if test="expireDate != null and expireDate != ''">
AND expireDate = #{expireDate}
</if>
<if test="productIdList != null and productIdList.size() != 0">
AND relIdFk in
<foreach collection="productIdList" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="updateTime != null and updateTime != ''">
AND updateTime <![CDATA[ <= ]]> #{updateTime}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(updateTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
</if>
</where>
<choose>
<when test="(orderBy != null) and (sort == 'desc' or sort == 'asc')">
order by ${orderBy} ${sort}
</when>
<otherwise>
ORDER BY updateTime DESC
</otherwise>
</choose>
</select>
<delete id="deleteInvProductDetail">
delete
from inv_product
<where>
<if test="relId != null and relId != ''">
AND relIdFk = #{relId}
</if>
<if test="batchNo != null and batchNo != '' and batchNo != 'empty'">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == 'empty'">
AND batchNo is null
</if>
<if test="supId != null and supId != ''">
AND supId = #{supId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
</where>
</delete>
<select id="selectPlaceDetailList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
select pd.id,
<!-- pd.code,-->
pd.relIdFk as relId,
pd.batchNo,
pd.productionDate as productionDate,
pd.expireDate,
bp.ggxh,
bp.cpmctymc productName,
bp.zczbhhzbapzbh,
bp.ylqxzcrbarmc,
bp.nameCode,
bp.manufactory,
ad.name deptName,
aw.name invName,
sp.name invSpaceName
from inv_product pd
left join basic_udirel bu on pd.relIdFk = bu.id
left join basic_products bp on bp.uuid = bu.uuid
left join auth_dept ad on pd.deptCode = ad.code
left join auth_warehouse aw on pd.invCode = aw.code
left join auth_space sp on pd.invSpaceCode = sp.code
and sp.invStorageCode = pd.deptCode and sp.invWarehouseCode = pd.invCode
<where>
<if test="deptCode != null and deptCode != ''">
AND pd.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND pd.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND pd.invSpaceCode = #{invSpaceCode}
</if>
<if test="invSpaceCode == null or invSpaceCode == ''">
AND (pd.invSpaceCode is null or pd.invSpaceCode = '')
</if>
</where>
<!-- group by pd.code-->
</select>
<select id="findByGroupCode" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
select pd.id,
pd.code,
pd.relIdFk as relId,
pd.batchNo,
pd.productionDate productionDate,
pd.expireDate,
bp.ggxh,
bp.cpmctymc productName,
bp.zczbhhzbapzbh,
bp.ylqxzcrbarmc,
bp.nameCode,
bp.manufactory,
pd.invSpaceCode,
pd.invCode,
ad.name deptName,
aw.name invName,
sp.name invSpaceName,
inCount,
outCount,
reCount
from inv_product pd
left join basic_udirel bu on pd.relIdFk = bu.id
left join basic_products bp on bp.uuid = bu.uuid
left join auth_dept ad on pd.deptCode = ad.code
left join auth_warehouse aw on pd.invCode = aw.code
left join auth_space sp on pd.invSpaceCode = sp.code
and sp.invStorageCode = pd.deptCode and sp.invWarehouseCode = pd.invCode
<where>
<if test="invCode != null and invCode != ''">
AND pd.invCode = #{invCode}
</if>
<!-- <if test="code != null and code != ''">-->
<!-- AND pd.code = #{code}-->
<!-- </if>-->
<if test="isCheckSpace != null and isCheckSpace == true">
AND (pd.invSpaceCode is not null or pd.invSpaceCode != '')
</if>
</where>
group by pd.invSpaceCode
</select>
<update id="batchBindSpace">
update inv_product
set invSpaceCode = #{invSpaceCode}
where id in
<foreach collection="ids" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<select id="selectByInvAndCode" resultType="com.glxp.api.vo.basic.InvProductNewVo">
select *
from inv_product
where deptCode = #{deptCode}
and invCode = #{invCode}
<!-- and code = #{code}-->
limit 1
</select>
<select id="selectSupIdByCode" resultType="java.lang.String">
select supId
from inv_product_detail
where code = #{code}
</select>
<select id="selectCountOrderCodes" resultType="java.lang.String">
select distinct code
from inv_product_detail
<where>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND invSpaceCode = #{invSpaceCode}
</if>
<if test="relId != null">
AND relIdFk = #{relId}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
</where>
</select>
<select id="getInvProductInfo" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
select ipd.code,
ipd.relId,
ipd.batchNo,
ipd.serialNo,
ipd.invSpaceCode,
ipd.invCode,
bp.cpmctymc productName,
bp.ggxh,
bp.measname,
bp.zczbhhzbapzbh,
bp.manufactory,
(select name from auth_space s where s.code = ipd.invSpaceCode) invSpaceName,
(select name from basic_corp bc where bc.erpId = ipd.supId) supName
from inv_product_detail ipd
left join basic_udirel bu on bu.id = ipd.relId
left join basic_products bp on bp.uuid = bu.uuid
<where>
<if test="invCode != null and invCode != ''">
AND ipd.invCode = #{invCode}
</if>
<if test="invSpaceCode != null and invSpaceCode != ''">
AND ipd.invSpaceCode = #{invSpaceCode}
</if>
<if test="code != null and code != ''">
AND ipd.code = #{code}
</if>
<if test="orderId != null and orderId != ''">
AND ipd.orderId = #{orderId}
</if>
</where>
group by ipd.id
</select>
<select id="getInvPlaceOrderList" resultType="com.glxp.api.res.inout.IoOrderResponse">
select odr.orderIdFk billNo,
(select name from basic_bussiness_type where action = o.action) billTypeName,
o.mainAction,
o.fromCorp,
o.corpOrderId,
o.fromType,
o.createTime,
o.auditTime,
(select employeeName from auth_user where id = o.reviewUser) reviewUserName
from io_order_detail_biz odr
left join io_order o on o.billNo = odr.orderIdFk
<where>
<if test="invCode != null and invCode != ''">
AND odr.invCode = #{invCode}
</if>
<if test="orderId != null and orderId != ''">
AND odr.orderIdFk like concat('%', #{orderId}, '%')
</if>
</where>
group by odr.orderIdFk
</select>
<select id="getInventoryQuantity" resultType="java.lang.Integer">
SELECT reCount
FROM inv_product ipd
WHERE invCode = #{invCode}
and (invSpaceCode is null or invSpaceCode = '')
</select>
<select id="filterSpaceList" resultType="com.glxp.api.res.inv.InvPlaceDetailResponse">
SELECT t1.nameCode,
t1.relIdFk as relId,
(SELECT NAME FROM auth_dept WHERE auth_dept.`code` = t1.deptCode) AS deptName,
(SELECT NAME FROM auth_warehouse WHERE auth_warehouse.`code` = t1.invCode) AS invName,
(SELECT NAME FROM auth_space WHERE auth_space.`code` = t1.invSpaceCode) AS invSpaceName,
<include refid="inOrOutcount"/> as count,
bp.cpmctymc as productName,
bp.ggxh,
t1.batchNo,
t1.productionDate as produceDate as productionDate,
t1.expireDate,
bp.measname,
bp.zczbhhzbapzbh,
bp.ylqxzcrbarmc,
bp.manufactory,
(SELECT `name` FROM basic_corp WHERE erpId = t1.supId) supName
FROM inv_product t1
LEFT JOIN basic_udirel bu ON bu.id = t1.relIdFk
LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
<where>
<!-- <if test="code != null and code != ''">-->
<!-- AND t1.code = #{code}-->
<!-- </if>-->
<if test="invSpaceCode != null and invSpaceCode != ''">
AND t1.invSpaceCode = #{invSpaceCode}
</if>
</where>
GROUP BY invSpaceCode
</select>
<select id="selectLastInBatch" resultType="com.glxp.api.vo.basic.InvProductNewVo">
select <include refid="selectInvPreProduct"/>
from inv_product
<where>
<if test="relId != null and relId != ''">
AND relIdFk = #{relId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<!-- <if test="mainAction != null and mainAction != ''">-->
<!-- AND mainAction = #{mainAction}-->
<!-- </if>-->
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo desc
limit 1;
</select>
<select id="selectFirstInBatch" resultType="com.glxp.api.vo.basic.InvProductNewVo">
select <include refid="selectInvPreProduct"/>
from inv_product
<where>
<if test="relId != null and relId != ''">
AND relIdFk = #{relId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<!-- <if test="mainAction != null and mainAction != ''">-->
<!-- AND mainAction = #{mainAction}-->
<!-- </if>-->
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
order by inBatchNo
limit 1;
</select>
<select id="selectCountByInBatch" resultType="java.lang.Integer">
select
<include refid="inOrOutcount"/>
from inv_product
<where>
<if test="relId != null and relId != ''">
AND relIdFk = #{relId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="inBatchNo != null and inBatchNo != ''">
AND inBatchNo = #{inBatchNo}
</if>
<!-- <if test="mainAction != null and mainAction != ''">-->
<!-- AND mainAction = #{mainAction}-->
<!-- </if>-->
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
</where>
</select>
<select id="selectNextInBatch" resultType="com.glxp.api.vo.basic.InvProductNewVo">
select <include refid="selectInvPreProduct"/>
from inv_product
<where>
<if test="relId != null and relId != ''">
AND relIdFk = #{relId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<!-- <if test="mainAction != null and mainAction != ''">-->
<!-- AND mainAction = #{mainAction}-->
<!-- </if>-->
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="batchNo == null or batchNo == ''">
AND batchNo is null
</if>
and inBatchNo > #{inBatchNo}
LIMIT 1
</where>
</select>
<sql id="selectInvPreProduct">
*
</sql>
<sql id="inOrOutcount">
<choose>
<when test="mainAction =='WareHouseOut'.toString() ">
outCount
</when>
<when test="mainAction =='WareHouseIn'.toString() ">
inCount
</when>
</choose>
</sql>
<select id="selectOrderInfo" resultType="com.glxp.api.vo.basic.InvProductNewVo">
select t1.deptCode,t1.invCode,t1.mainAction,t2.* from io_order t1 inner join io_order_detail_biz t2 on t1.billNo = t2.orderIdFk
<where>
t2.orderIdFk = #{orderIdFk}
<if test="price != null and price != ''">
AND t2.price = #{price}
</if>
</where>
</select>
</mapper>