emis-service/emis-biz/src/main/resources/mapper/EmisWarehouseInMapper.xml

486 lines
26 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.xdadan.erp.emis.mapper.EmisWarehouseInMapper">
<resultMap type="EmisWarehouseIn" id="BaseEmisWarehouseInResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="serialNo" column="serial_no" />
<result property="inNo" column="in_no" />
<result property="orderSn" column="order_sn" />
<result property="billCode" column="bill_code" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
<result property="entryDate" column="entry_date" />
<result property="confirmStatus" column="confirm_status" />
<result property="confirmDate" column="confirm_date" />
<result property="usedStatus" column="used_status" />
<result property="status" column="status" />
<result property="stockInFlag" column="stock_in_flag" />
<result property="blUploadPic" column="bl_upload_pic" />
<result property="totalParcelQty" column="total_parcel_qty" />
<result property="totalVolume" column="total_volume" />
<result property="totalWeight" column="total_weight" />
</resultMap>
<resultMap id="EmisWarehouseInResult" type="EmisWarehouseIn" extends="BaseEmisWarehouseInResult" >
<association property="waybillDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
</resultMap>
<!-- 结果映射 -->
<resultMap id="SelectEmisWarehouseInByInNosResult" type="EmisWarehouseIn">
<id property="id" column="id"/>
<result property="inNo" column="in_no"/>
<result property="billCode" column="bill_code"/>
<result property="orderSn" column="order_sn"/>
<result property="confirmStatus" column="confirm_status"/>
<result property="entryDate" column="entry_date"/>
<result property="totalParcelQty" column="total_parcel_qty"/>
<result property="totalWeight" column="total_weight"/>
<result property="totalVolume" column="total_volume"/>
<collection property="stockInBatchList" ofType="EmisWarehouseInBatch">
<id property="id" column="batch_id"/>
<result property="inNo" column="batch_in_no"/>
<result property="inBatchNo" column="in_batch_no"/>
<result property="entryDate" column="batch_entry_date"/>
<result property="totalParcelQty" column="batch_total_parcel_qty"/>
<result property="totalWeight" column="batch_total_weight"/>
<result property="totalVolume" column="batch_total_volume"/>
<result property="prepareInExpress" column="prepare_in_express"/>
<result property="prepareInBillCode" column="prepare_in_bill_code"/>
<result property="prepareInSupplier" column="prepare_in_supplier"/>
<result property="picUrl" column="pic_url"/>
<collection property="cargoList" ofType="EmisWarehouseInDtl">
<id property="id" column="dtl_id"/>
<result property="goodsName" column="goods_name"/>
</collection>
</collection>
</resultMap>
<!-- <resultMap id="EmisWarehouseInDetailWithBatchListResult" type="EmisWarehouseIn" extends="BaseEmisWarehouseInResult" >-->
<!-- <association property="stockInBatchList"-->
<!-- column="in_no"-->
<!-- select="com.xdadan.erp.emis.mapper.EmisWarehouseInBatchMapper.selectInBatchListByInNo"-->
<!-- fetchType="lazy"-->
<!-- />-->
<!-- </resultMap>-->
<sql id="selectEmisWarehouseInVo">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_warehouse_in
</sql>
<select id="selectEmisWarehouseInListByOms" parameterType="EmisWarehouseIn" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="serialNo != null and serialNo != ''"> and serial_no like concat('%', #{serialNo}, '%')</if>
<if test="inNo != null and inNo != ''">
and ( FIND_IN_SET(`in_no`,#{inNo}) or in_no like concat('%', #{inNo}, '%') )
</if>
<if test="orderSn != null and orderSn != ''"> and order_sn like concat('%', #{orderSn}, '%')</if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(`bill_code`,#{billCode}) or bill_code like concat('%', #{billCode}, '%') )</if>
<if test="customerCode != null and customerCode != ''"> and customer_code=#{customerCode}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="entryDate != null "> and entry_date = #{entryDate}</if>
<if test="confirmStatus != null and confirmStatus != ''"> and confirm_status=#{confirmStatus}</if>
<if test="confirmDate != null "> and confirm_date = #{confirmDate}</if>
<if test="blUploadPic != null and blUploadPic != ''"> and bl_upload_pic=#{blUploadPic}</if>
<if test="status != null and status != ''"> and status=#{status}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id like concat('%', #{tenantId}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
<if test="stockInFlag != null and stockInFlag != ''"> and stock_in_flag=#{stockInFlag}</if>
<if test="params.queryStatusType != null and params.queryStatusType == 0">
and confirm_status= '0'
</if>
<if test="params.queryStatusType != null and params.queryStatusType == 1">
and confirm_status= '1'
</if>
<if test="params.queryStatusType != null and params.queryStatusType == 2">
and confirm_status= '2'
</if>
and EXISTS (
select 1 from emis_waybill ewb
where a.bill_code=ewb.bill_code and ewb.pickup_method in('1','3') and ewb.order_status in ('0','1','3')
)
<if test="searchValue != null and searchValue !='' ">
and (
a.in_no like concat('%', #{searchValue}, '%')
or a.bill_code like concat('%', #{searchValue}, '%')
or a.order_sn like concat('%', #{searchValue}, '%')
or exists (
select 1 from emis_waybill ew where a.bill_code=ew.bill_code and ew.pickup_method in('1','3') and ew.order_status in ('0','1','3') and (
ew.receive_name like concat('%', #{searchValue}, '%') or ew.receive_mobile like concat('%', #{searchValue}, '%')
)
)
)
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
</where>
order by create_time desc
</select>
<select id="selectEmisWarehouseInList" parameterType="EmisWarehouseIn" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="serialNo != null and serialNo != ''"> and serial_no like concat('%', #{serialNo}, '%')</if>
<if test="inNo != null and inNo != ''">
and FIND_IN_SET(`in_no`,#{inNo})
</if>
<if test="orderSn != null and orderSn != ''"> and order_sn like concat('%', #{orderSn}, '%')</if>
<if test="billCode != null and billCode != ''"> and FIND_IN_SET(`bill_code`,#{billCode}) </if>
<if test="customerCode != null and customerCode != ''"> and customer_code=#{customerCode}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="entryDate != null "> and entry_date = #{entryDate}</if>
<if test="confirmStatus != null and confirmStatus != ''"> and confirm_status=#{confirmStatus}</if>
<if test="confirmDate != null "> and confirm_date = #{confirmDate}</if>
<if test="blUploadPic != null and blUploadPic != ''"> and bl_upload_pic=#{blUploadPic}</if>
<if test="status != null and status != ''"> and status=#{status}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id like concat('%', #{tenantId}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
<if test="stockInFlag != null and stockInFlag != ''"> and stock_in_flag=#{stockInFlag}</if>
<if test="usedStatus != null and usedStatus == 1">
and used_status= '1'
</if>
<if test="usedStatus != null and usedStatus == 0">
and used_status= '0'
</if>
<if test="params.queryStatusType != null and params.queryStatusType == 0">
and confirm_status= '0'
</if>
<if test="params.queryStatusType != null and params.queryStatusType == 1">
and confirm_status= '1'
</if>
<if test="params.queryStatusType != null and params.queryStatusType == 2">
and confirm_status= '2'
</if>
<if test="searchValue != null and searchValue !='' ">
and (
a.in_no like concat('%', #{searchValue}, '%')
or a.bill_code like concat('%', #{searchValue}, '%')
or a.order_sn like concat('%', #{searchValue}, '%')
or exists (
select 1 from emis_waybill ew where a.bill_code=ew.bill_code and (
ew.receive_name like concat('%', #{searchValue}, '%') or ew.receive_mobile like concat('%', #{searchValue}, '%')
)
)
)
</if>
and EXISTS (
select 1 from emis_waybill ewb
where a.bill_code=ewb.bill_code and ewb.pickup_method in('1','3') and ewb.order_status in ('0','1','3')
<if test="params.beginPickStartDate != null and params.beginPickStartDate != ''">
and ewb.pick_start_date <![CDATA[ >= ]]> #{params.beginPickStartDate}
</if>
<if test="params.endPickStartDate != null and params.endPickStartDate != ''">
and ewb.pick_start_date <![CDATA[ <= ]]> #{params.endPickStartDate}
</if>
<if test="params.salesmen != null and params.salesmen != ''">
and ewb.salesmen like concat('%', #{params.salesmen}, '%')
</if>
<if test="params.sendName != null and params.sendName != ''">
and ewb.send_name like concat('%', #{params.sendName}, '%')
</if>
<if test="params.sendMobile != null and params.sendMobile != ''">
and ewb.send_mobile like concat('%', #{params.sendMobile}, '%')
</if>
<if test="params.sendCompany != null and params.sendCompany != ''">
and ewb.send_company like concat('%', #{params.sendCompany}, '%')
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and ewb.into_warehouse_code=#{params.privSiteCode}
</if>
<if test="params.intoWarehouseCode != null and params.intoWarehouseCode != ''">
and ewb.into_warehouse_code=#{params.intoWarehouseCode}
</if>
<if test="params.orderStatus != null and params.orderStatus != ''">
and ewb.order_status=#{params.orderStatus}
</if>
<if test="params.sendSiteCode != null and params.sendSiteCode != ''">
and ewb.send_site_code=#{params.sendSiteCode}
</if>
<if test="params.sendCountry != null and params.sendCountry != ''">
and ewb.send_country=#{params.sendCountry}
</if>
<if test="params.receiveCountry != null and params.receiveCountry != ''">
and ewb.receive_country=#{params.receiveCountry}
</if>
<if test="params.transLineType != null and params.transLineType != ''">
and ewb.trans_line_type=#{params.transLineType}
</if>
<if test="params.productType != null and params.productType != ''">
and ewb.product_type=#{params.productType}
</if>
)
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
</where>
order by create_time desc
</select>
<select id="selectEmisWarehouseInById" parameterType="Long" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
where a.id = #{id}
</select>
<select id="selectEmisWarehouseInByInNo" parameterType="String" resultMap="EmisWarehouseInResult">
select id, serial_no, in_no, order_sn, bill_code, customer_code, customer_name, entry_date, confirm_status, confirm_date, used_status, status, stock_in_flag, bl_upload_pic, total_parcel_qty, total_volume, total_weight, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_warehouse_in a
where a.in_no = #{inNo} limit 1
</select>
<!-- 批量查询进仓单信息 -->
<select id="selectEmisWarehouseInByInNos" resultMap="SelectEmisWarehouseInByInNosResult">
SELECT
wi.id,
wi.in_no,
wi.bill_code,
wi.order_sn,
wi.confirm_status,
wi.entry_date,
wi.total_parcel_qty,
wi.total_weight,
wi.total_volume,
wib.id as batch_id,
wib.in_no as batch_in_no,
wib.in_batch_no as in_batch_no,
wib.entry_date as batch_entry_date,
wib.parcel_qty as batch_total_parcel_qty,
wib.bill_weight as batch_total_weight,
wib.total_volume as batch_total_volume,
wib.prepare_in_express,
wib.prepare_in_bill_code,
wib.prepare_in_supplier,
wib.pic_url,
wid.id as dtl_id,
wid.goods_name
FROM emis_warehouse_in wi
LEFT JOIN emis_warehouse_in_batch wib ON wi.in_no = wib.in_no
LEFT JOIN emis_warehouse_in_dtl wid ON wib.serial_no = wid.in_serial_no
WHERE wi.in_no IN
<foreach collection="list" item="inNo" open="(" separator="," close=")">
#{inNo}
</foreach>
ORDER BY wi.id, wib.id, wid.id
</select>
<insert id="insertEmisWarehouseIn" parameterType="EmisWarehouseIn" useGeneratedKeys="true" keyProperty="id">
insert into emis_warehouse_in
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="serialNo != null and serialNo != ''">serial_no,</if>
<if test="inNo != null and inNo != ''">in_no,</if>
<if test="orderSn != null and orderSn != ''">order_sn,</if>
<if test="billCode != null and billCode != ''">bill_code,</if>
<if test="customerCode != null and customerCode != ''">customer_code,</if>
<if test="customerName != null and customerName != ''">customer_name,</if>
<if test="entryDate != null">entry_date,</if>
<if test="confirmStatus != null and confirmStatus != ''">confirm_status,</if>
<if test="confirmDate != null">confirm_date,</if>
<if test="usedStatus != null and usedStatus != ''">used_status,</if>
<if test="status != null and status != ''">status,</if>
<if test="stockInFlag != null and stockInFlag != ''">stock_in_flag,</if>
<if test="blUploadPic != null and blUploadPic != ''">bl_upload_pic,</if>
<if test="totalParcelQty != null">total_parcel_qty,</if>
<if test="totalVolume != null">total_volume,</if>
<if test="totalWeight != null">total_weight,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="serialNo != null and serialNo != ''">#{serialNo},</if>
<if test="inNo != null and inNo != ''">#{inNo},</if>
<if test="orderSn != null and orderSn != ''">#{orderSn},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
<if test="customerName != null and customerName != ''">#{customerName},</if>
<if test="entryDate != null">#{entryDate},</if>
<if test="confirmStatus != null and confirmStatus != ''">#{confirmStatus},</if>
<if test="confirmDate != null">#{confirmDate},</if>
<if test="usedStatus != null and usedStatus != ''">#{usedStatus},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="stockInFlag != null and stockInFlag != ''">#{stockInFlag},</if>
<if test="blUploadPic != null and blUploadPic != ''">#{blUploadPic},</if>
<if test="totalParcelQty != null">#{totalParcelQty},</if>
<if test="totalVolume != null">#{totalVolume},</if>
<if test="totalWeight != null">#{totalWeight},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisWarehouseIn" parameterType="EmisWarehouseIn">
update emis_warehouse_in
<trim prefix="SET" suffixOverrides=",">
<if test="serialNo != null and serialNo != ''">serial_no = #{serialNo},</if>
<if test="inNo != null and inNo != ''">in_no = #{inNo},</if>
<if test="orderSn != null and orderSn != ''">order_sn = #{orderSn},</if>
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="customerCode != null and customerCode != ''">customer_code = #{customerCode},</if>
<if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
<if test="entryDate != null">entry_date = #{entryDate},</if>
<if test="confirmStatus != null and confirmStatus != ''">confirm_status = #{confirmStatus},</if>
<if test="confirmDate != null">confirm_date = #{confirmDate},</if>
<if test="usedStatus != null and usedStatus != ''">used_status = #{usedStatus},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="stockInFlag != null and stockInFlag != ''">stock_in_flag = #{stockInFlag},</if>
<if test="blUploadPic != null and blUploadPic != ''">bl_upload_pic = #{blUploadPic},</if>
<if test="totalParcelQty != null">total_parcel_qty = #{totalParcelQty},</if>
<if test="totalVolume != null">total_volume = #{totalVolume},</if>
<if test="totalWeight != null">total_weight = #{totalWeight},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<update id="changeUseStatusByUse" parameterType="EmisWarehouseIn">
update emis_warehouse_in
<trim prefix="SET" suffixOverrides=",">
bill_code = #{billCode},
used_status ='1',
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where in_no = #{inNo}
</update>
<update id="changeUseStatusByUnUse" parameterType="EmisWarehouseIn">
update emis_warehouse_in
<trim prefix="SET" suffixOverrides=",">
bill_code =null,
used_status ='0',
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where in_no = #{inNo}
</update>
<update id="updateTotalWeightInfo" parameterType="EmisWarehouseIn">
update emis_warehouse_in
set stock_in_flag = '1',
total_parcel_qty=#{totalParcelQty},
total_volume=#{totalVolume},
total_weight=#{totalWeight},
bl_upload_pic=#{blUploadPic}
where in_no = #{inNo}
</update>
<update id="useInNo" parameterType="EmisWarehouseIn">
update emis_warehouse_in set used_status='1'
where bill_code = #{billCode} and in_no = #{inNo}
</update>
<delete id="deleteEmisWarehouseInById" parameterType="Long">
update emis_warehouse_in set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisWarehouseInByIds" parameterType="String">
update emis_warehouse_in set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>