emis-service/emis-biz/src/main/resources/mapper/EmisTmsCostQuotePriceMapper.xml
2025-07-01 00:05:16 +08:00

219 lines
12 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.EmisTmsCostQuotePriceMapper">
<resultMap type="EmisTmsCostQuotePrice" id="EmisTmsCostQuotePriceResult">
<result property="id" column="id" />
<result property="startSiteCode" column="start_site_code" />
<result property="nextSiteCode" column="next_site_code" />
<result property="distance" column="distance" />
<result property="feeType" column="fee_type" />
<result property="price" column="price" />
<result property="currency" column="currency" />
<result property="billType" column="bill_type" />
<result property="supplierCode" column="supplier_code" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="batchNo" column="batch_no" />
<result property="carNo" column="car_no" />
<result property="etd" column="etd" />
<result property="transWeight" column="trans_weight" />
<result property="totalVolume" column="total_volume" />
<result property="totalWeight" column="total_weight" />
<association property="startSiteName" column="start_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="nextSiteName" column="next_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="supplierName" column="supplier_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSupplierNameByCode"/>
</resultMap>
<sql id="selectEmisTmsCostQuotePriceVo">
select id, start_site_code, next_site_code, distance, fee_type, price, currency, bill_type, supplier_code, start_date, end_date, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_cost_quote_price
</sql>
<select id="selectEmisTmsCostQuotePriceList" parameterType="EmisTmsCostQuotePrice" resultMap="EmisTmsCostQuotePriceResult">
<include refid="selectEmisTmsCostQuotePriceVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="startSiteCode != null and startSiteCode != ''"> and start_site_code = #{startSiteCode}</if>
<if test="nextSiteCode != null and nextSiteCode != ''"> and next_site_code = #{nextSiteCode}</if>
<if test="distance != null "> and distance = #{distance}</if>
<if test="feeType != null and feeType != ''"> and fee_type = #{feeType}</if>
<if test="price != null "> and price = #{price}</if>
<if test="currency != null and currency != ''"> and currency = #{currency}</if>
<if test="billType != null and billType != ''"> and bill_type = #{billType}</if>
<if test="supplierCode != null and supplierCode != ''"> and supplier_code = #{supplierCode}</if>
<if test="startDate != null "> and start_date = #{startDate}</if>
<if test="endDate != null "> and end_date = #{endDate}</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>
</where>
order by create_time desc
</select>
<select id="matchTmsCostQuotePriceListByBillCode" parameterType="String" resultMap="EmisTmsCostQuotePriceResult">
SELECT
DISTINCT
a.start_site_code,
a.next_site_code,
a.distance,
a.fee_type,
a.price,
a.currency,
a.bill_type,
a.supplier_code,
a.start_date,
a.end_date,
b.batch_no,
b.car_no,
b.etd,
b.trans_weight,
b.total_weight
FROM
emis_tms_cost_quote_price a,
emis_tms_site_batch b,
emis_tms_site_batch_dtl c
WHERE
a.del_flag = '0'
AND b.del_flag = '0'
AND c.del_flag = '0'
AND a.start_site_code = b.start_site_code
AND a.next_site_code = b.next_site_code
AND a.supplier_code = b.supplier_code
AND b.batch_no = c.batch_no
and a.start_date <![CDATA[ <= ]]> b.etd and b.etd <![CDATA[ < ]]> a.end_date
AND c.bill_code = #{billCode}
</select>
<select id="checkUnique" parameterType="EmisTmsCostQuotePrice" resultType="int">
select count(1) from emis_tms_cost_quote_price
where del_flag='0'
and id = #{id}
and start_site_code = #{startSiteCode}
and next_site_code = #{nextSiteCode}
and distance = #{distance}
and fee_type = #{feeType}
and price = #{price}
and currency = #{currency}
and bill_type = #{billType}
and supplier_code = #{supplierCode}
and start_date = #{startDate}
and end_date = #{endDate}
and remark = #{remark}
and tenant_id = #{tenantId}
and del_flag = #{delFlag}
and create_by = #{createBy}
and create_time = #{createTime}
and update_by = #{updateBy}
and update_time = #{updateTime}
and create_site = #{createSite}
and update_site = #{updateSite}
limit 1
</select>
<select id="selectEmisTmsCostQuotePriceById" parameterType="Long" resultMap="EmisTmsCostQuotePriceResult">
select id, start_site_code, next_site_code, distance, fee_type, price, currency, bill_type, supplier_code, start_date, end_date, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_cost_quote_price a
where a.id = #{id}
</select>
<insert id="insertEmisTmsCostQuotePrice" parameterType="EmisTmsCostQuotePrice" useGeneratedKeys="true" keyProperty="id">
insert into emis_tms_cost_quote_price
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="startSiteCode != null and startSiteCode != ''">start_site_code,</if>
<if test="nextSiteCode != null and nextSiteCode != ''">next_site_code,</if>
<if test="distance != null">distance,</if>
<if test="feeType != null and feeType != ''">fee_type,</if>
<if test="price != null">price,</if>
<if test="currency != null and currency != ''">currency,</if>
<if test="billType != null and billType != ''">bill_type,</if>
<if test="supplierCode != null and supplierCode != ''">supplier_code,</if>
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</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="id != null">#{id},</if>
<if test="startSiteCode != null and startSiteCode != ''">#{startSiteCode},</if>
<if test="nextSiteCode != null and nextSiteCode != ''">#{nextSiteCode},</if>
<if test="distance != null">#{distance},</if>
<if test="feeType != null and feeType != ''">#{feeType},</if>
<if test="price != null">#{price},</if>
<if test="currency != null and currency != ''">#{currency},</if>
<if test="billType != null and billType != ''">#{billType},</if>
<if test="supplierCode != null and supplierCode != ''">#{supplierCode},</if>
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</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="updateEmisTmsCostQuotePrice" parameterType="EmisTmsCostQuotePrice">
update emis_tms_cost_quote_price
<trim prefix="SET" suffixOverrides=",">
<if test="startSiteCode != null and startSiteCode != ''">start_site_code = #{startSiteCode},</if>
<if test="nextSiteCode != null and nextSiteCode != ''">next_site_code = #{nextSiteCode},</if>
<if test="distance != null">distance = #{distance},</if>
<if test="feeType != null and feeType != ''">fee_type = #{feeType},</if>
<if test="price != null">price = #{price},</if>
<if test="currency != null and currency != ''">currency = #{currency},</if>
<if test="billType != null and billType != ''">bill_type = #{billType},</if>
<if test="supplierCode != null and supplierCode != ''">supplier_code = #{supplierCode},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</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>
<delete id="deleteEmisTmsCostQuotePriceById" parameterType="Long">
delete from emis_tms_cost_quote_price where id = #{id}
</delete>
<delete id="deleteEmisTmsCostQuotePriceByIds" parameterType="String">
delete from emis_tms_cost_quote_price where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>