美文网首页
dualMapper文件批量插入

dualMapper文件批量插入

作者: 逆风踏雷 | 来源:发表于2022-05-31 19:41 被阅读0次

<insert id="bathInsertNotExist" parameterType="OverduestorageSkuEntity">
<trim>
insert into t_settlement_overdue_storage
(pop_id, sku_id, sku_name, city_id, warehouse_id, batch_id, stock_amount, in_stock_time,
stock_day, warm_layer, box_gauge, stock_state, storage_service_charge, business_model,small_business_model,warehouse_type,c_t, u_t)
<foreach collection="list" item="item" open="" close="" separator=" UNION ALL ">
SELECT
#{item.popId},#{item.skuId},#{item.skuName},#{item.cityId},#{item.warehouseId},#{item.batchId},
#{item.stockAmount},#{item.inStockTime},#{item.stockDay},#{item.warmLayer},#{item.boxGauge},#{item.stockState},
#{item.storageServiceCharge},#{item.businessModel},#{item.smallBusinessModel},#{item.warehouseType},
<choose>
<when test="item.CT != null and item.CT gt 0">
#{item.CT},
</when>
<otherwise>
UNIX_TIMESTAMP(),
</otherwise>
</choose>
<choose>
<when test="item.UT != null and item.UT gt 0">
#{item.UT}
</when>
<otherwise>
UNIX_TIMESTAMP()
</otherwise>
</choose>
FROM dual
WHERE NOT EXISTS
(
SELECT 1 FROM t_settlement_overdue_storage
where
sku_id=#{item.skuId}
and pop_id=#{item.popId}
and city_id=#{item.cityId}
and warehouse_id=#{item.warehouseId}
and batch_id=#{item.batchId}
and stock_day=#{item.stockDay}
)
</foreach>
</trim>
</insert>

相关文章

网友评论

      本文标题:dualMapper文件批量插入

      本文链接:https://www.haomeiwen.com/subject/bzuwgktx.html