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/inout/IoOrderDetailResultDao.xml

306 lines
13 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.inout.IoOrderDetailResultDao">
<select id="filterList" resultType="com.glxp.api.res.inout.IoOrderDetailResultResponse">
select *
from io_order_detail_result
<where>
<if test="orderIdFk != null and orderIdFk != ''">
AND orderIdFk = #{orderIdFk}
</if>
<if test="nameCode != null and nameCode != ''">
AND nameCode = #{nameCode}
</if>
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="coName != null and coName != ''">
AND coName = #{productName}
</if>
<if test="productName != null and productName != ''">
AND coName like concat('%', #{productName}, '%')
</if>
</where>
</select>
<select id="filterOrderList" resultType="com.glxp.api.res.inout.IoOrderDetailResultResponse">
SELECT a2.*,
aw.name as fromInvName,
a1.mainAction,
a1.confirmTime,
a1.auditTime,
bu.isStack,
bu.groupBuy,
bp.prepnSpec,
COALESCE(bp.ylqxzcrbarmc,bp.manufactory) as manufactory,
bp.zczbhhzbapzbh,
GROUP_CONCAT(ioi.invoiceEncode ORDER BY ioi.invoiceEncode SEPARATOR ',') AS invoiceCodes,
b1.NAME AS fromCorpName,
basic_bussiness_type.name billTypeName
FROM io_order_detail_result a2
LEFT JOIN io_order a1 ON a1.billNo = a2.orderIdFk
LEFT JOIN basic_corp b1 ON b1.erpId = a1.fromCorp
LEFT JOIN basic_udirel bu ON a2.bindRlFk = bu.id
inner JOIN basic_products bp ON bp.uuid = bu.uuid
left join basic_bussiness_type on a1.action = basic_bussiness_type.action
LEFT JOIN io_order_invoice ioi ON a1.billNo = ioi.orderIdFk
left join auth_warehouse aw on aw.code = a1.fromInvCode
<where>
a1.status = 7
<if test="orderIdFk != null and orderIdFk != ''">
AND a2.orderIdFk = #{orderIdFk}
</if>
<if test="groupBuy != null ">
AND bu.groupBuy = #{groupBuy}
</if>
<if test="productType != null and productType != ''">
AND a1.productType = #{productType}
</if>
<!-- <if test="keyWords != null and keyWords != ''">-->
<!-- AND (aw.name like concat('%', #{keyWords}, '%') or b1.name like concat('%', #{keyWords}, '%'))-->
<!-- </if>-->
<if test="nameCode != null and nameCode != ''">
AND a2.nameCode = #{nameCode}
</if>
<if test="inoutPrintStatus != null">
AND a2.inoutPrintStatus = #{inoutPrintStatus}
</if>
<if test="action != null and action != ''">
AND a1.action = #{action}
</if>
<if test="mainAction != null and mainAction != ''">
AND a1.mainAction = #{mainAction}
</if>
<if test="isStack != null">
AND bu.isStack = #{isStack}
</if>
<if test="invCode != null and invCode != ''">
AND a1.invCode = #{invCode}
</if>
<if test="invoiceEncode != null and invoiceEncode != ''">
AND ioi.invoiceEncode = #{invoiceEncode}
</if>
<if test="spec != null and spec != ''">
AND a2.spec like concat('%', #{spec}, '%')
</if>
<if test="fromCorp != null and fromCorp != ''">
AND a1.fromCorp = #{fromCorp}
</if>
<if test="fromCorpName != null and fromCorpName != ''">
AND b1.name = #{fromCorpName}
</if>
<if test="manufacturer != null and manufacturer != ''">
AND a2.manufacturer like concat('%', #{manufacturer}, '%')
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND a2.certCode like concat('%', #{zczbhhzbapzbh}, '%')
</if>
<if test="corpName != null and corpName != ''">
AND b1.name like concat('%', #{corpName}, '%')
</if>
<if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''">
AND date_format(a1.auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and date_format(#{endAduditTime}, '%Y-%m-%d')
</if>
<if test="confirmStarTime != null and confirmStarTime != '' and confirmEndTime != null and confirmEndTime != ''">
AND date_format(a1.confirmTime, '%Y-%m-%d') between date_format(#{confirmStarTime}, '%Y-%m-%d') and date_format(#{confirmEndTime}, '%Y-%m-%d')
</if>
<if test="batchNo != null and batchNo != ''">
AND a2.batchNo like concat('%', #{batchNo}, '%')
</if>
<if test="coName != null and coName != ''">
AND a2.coName like concat('%', #{coName}, '%')
</if>
<if test="productName != null and productName != ''">
AND a2.coName like concat('%', #{productName}, '%')
</if>
<if test="prepnSpec != null and prepnSpec != ''">
AND bp.prepnSpec like concat('%', #{prepnSpec}, '%')
</if>
<if test="actions != null and actions.size() != 0">
AND a1.`action` in
<foreach collection="actions" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="keyWords != '' and keyWords != null">
AND (
a2.nameCode LIKE concat('%', #{keyWords}, '%')
or a2.coName like concat('%', #{keyWords}, '%')
or a2.orderIdFk LIKE concat('%', #{keyWords}, '%')
or a2.spec LIKE concat('%', #{keyWords}, '%')
or bp.prepnSpec LIKE concat('%', #{keyWords}, '%')
or a2.batchNo like concat('%', #{keyWords}, '%')
or bp.zczbhhzbapzbh LIKE concat('%', #{keyWords}, '%')
or bp.manufactory LIKE concat('%', #{keyWords}, '%')
or bp.ylqxzcrbarywmc LIKE concat('%', #{keyWords}, '%')
or b1.name like concat('%', #{keyWords}, '%'))
or aw.name like concat('%', #{keyWords}, '%')
</if>
</where>
group by a2.id
</select>
<select id="selectStatDataByTime" resultType="com.glxp.api.res.inv.IoOrderDetailStatRsponse">
select orderIdFk,
bindRlFk,
nameCode,
batchNo,
coName,
spec,
price,
reCount,
io_order.deptCode,
io_order.invCode,
bbt.mainAction
from io_order_detail_result
left JOIN io_order on io_order.billNo = io_order_detail_result.orderIdFk
left join basic_bussiness_type bbt on io_order.action = bbt.action
<where>
<if test="list != null and list.size() > 0">
and io_order_detail_result.orderIdFk in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
group by io_order_detail_result.id
</select>
<select id="cptTrace" parameterType="com.glxp.api.req.inout.CptTraceRequest"
resultType="com.glxp.api.res.inout.CptTraceOrderResponse">
select io.billNo,
io.createTime,
io.mainAction,
bbt.`name` billType,
basic_corp.`name` fromCorpName,
basic_corp.creditNo,
basic_corp.outType,
basic_corp.corpType,
io.action,
io.fromInvCode
from io_order_detail_result iodr
INNER JOIN io_order io on iodr.orderIdFk = io.billNo
inner join basic_corp on io.fromCorp = basic_corp.erpId
INNER JOIN basic_bussiness_type bbt on io.action = bbt.action
<where>
and bbt.inStock = true
<if test="batchNo != null and batchNo != ''">
AND batchNo = #{batchNo}
</if>
<if test="diList != null and diList.size() != 0">
AND iodr.`nameCode` in
<foreach collection="diList" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="cptCodeTrace" parameterType="com.glxp.api.req.inout.CptTraceRequest"
resultType="com.glxp.api.res.inout.CptTraceOrderResponse">
select io.billNo,
io.createTime,
io.mainAction,
bbt.`name` billType,
basic_corp.`name` fromCorpName,
basic_corp.creditNo,
io.action,
io.fromInvCode,
bbt.corpType,
iodr.reCount count
from io_code iodr
INNER JOIN io_order io on iodr.orderId = io.billNo
left join basic_corp on io.fromCorp = basic_corp.erpId
INNER JOIN basic_bussiness_type bbt on io.action = bbt.action
<where>
and bbt.inStock = true
<if test="batchNo != null and batchNo != ''">
AND iodr.batchNo = #{batchNo}
</if>
<if test="diList != null and diList.size() != 0">
AND iodr.`nameCode` in
<foreach collection="diList" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="serialNo != null and serialNo != ''">
AND iodr.serialNo = #{serialNo}
</if>
</where>
</select>
<select id="exFilterOrderDetail" resultType="com.glxp.api.res.inout.IoExOrderDetailResultResponse">
SELECT a2.*,
basic_bussiness_type.`name` billTypeName,
a1.createTime,
a1.auditTime,
aw.name invName,
basic_bussiness_type.mainAction
FROM io_order_detail_result a2
LEFT JOIN io_order a1 ON a1.billNo = a2.orderIdFk
left join auth_warehouse aw on aw.code = a1.invCode
left join basic_bussiness_type ON a1.action = basic_bussiness_type.action
<where>
a1.status = 7
and a1.mainAction = 'WareHouseOut'
and aw.spUse = 0
<if test="orderIdFk != null and orderIdFk != ''">
AND a2.orderIdFk = #{orderIdFk}
</if>
<if test="nameCode != null and nameCode != ''">
AND a2.nameCode = #{nameCode}
</if>
<if test="action != null and action != ''">
AND a1.action = #{action}
</if>
<if test="mainAction != null and mainAction != ''">
AND a1.mainAction = #{mainAction}
</if>
<if test="invCode != null and invCode != ''">
AND a1.invCode = #{invCode}
</if>
<if test="invName != null and invName != ''">
AND aw.name like concat('%'
, #{invName}
, '%')
</if>
<if test="manufacturer != null and manufacturer != ''">
AND a2.manufacturer like concat('%'
, #{manufacturer}
, '%')
</if>
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
AND a2.certCode like concat('%'
, #{zczbhhzbapzbh}
, '%')
</if>
<if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''">
AND date_format(a1.auditTime
, '%Y-%m-%d') between date_format(#{startAduditTime}
, '%Y-%m-%d')
and date_format(#{endAduditTime}
, '%Y-%m-%d')
</if>
<if test="batchNo != null and batchNo != ''">
AND a2.batchNo like concat('%'
, #{batchNo}
, '%')
</if>
<if test="coName != null and coName != ''">
AND a2.coName like concat('%'
, #{coName}
, '%')
</if>
<if test="productName != null and productName != ''">
AND a2.coName like concat('%'
, #{productName}
, '%')
</if>
</where>
</select>
</mapper>