Commit 9523a187 by huluobin

调拨在途

parent bfa9e6b7
...@@ -7,6 +7,7 @@ import java.time.LocalDateTime; ...@@ -7,6 +7,7 @@ import java.time.LocalDateTime;
@Data @Data
public class TransferTransitQuantity { public class TransferTransitQuantity {
/*bailunSku*/
private String bailunSku; private String bailunSku;
private String warehouseCode; private String warehouseCode;
private String sourceWarehouseCode; private String sourceWarehouseCode;
......
...@@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Select; ...@@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Map;
public interface DcMidTransitMapper { public interface DcMidTransitMapper {
/** /**
...@@ -135,6 +134,7 @@ public interface DcMidTransitMapper { ...@@ -135,6 +134,7 @@ public interface DcMidTransitMapper {
void insertMidDailyTransit(); void insertMidDailyTransit();
List<OutStockQuantity> selectQuantityOutStock(); List<OutStockQuantity> selectQuantityOutStock();
List<PurchaseTransitQuantity> selectQuantityPurchaseTransit(); List<PurchaseTransitQuantity> selectQuantityPurchaseTransit();
List<TransferTransitQuantity> selectQuantityTransferTransit(); List<TransferTransitQuantity> selectQuantityTransferTransit();
...@@ -145,12 +145,17 @@ public interface DcMidTransitMapper { ...@@ -145,12 +145,17 @@ public interface DcMidTransitMapper {
String printTransactionLevel(); String printTransactionLevel();
void updateOldTransferToZero(@Param("transferModified") String transferModified); void updateOldTransferToZero(@Param("transferModified") String transferModified);
void updateOldPurchaseToZero(@Param("purchaseModified") String purchaseModified); void updateOldPurchaseToZero(@Param("purchaseModified") String purchaseModified);
void updateOldOutStockToZero(@Param("outStockModified") String outStockModified); void updateOldOutStockToZero(@Param("outStockModified") String outStockModified);
LocalDateTime selectMaxOutStockModified(); LocalDateTime selectMaxOutStockModified();
LocalDateTime selectMaxTransferModified(); LocalDateTime selectMaxTransferModified();
LocalDateTime selectMaxPurchaseModified(); LocalDateTime selectMaxPurchaseModified();
LocalDateTime selectMaxUnshippedModified(); LocalDateTime selectMaxUnshippedModified();
void updateOldUnshippedToZero(@Param("unshippedModified") LocalDateTime unshippedModified); void updateOldUnshippedToZero(@Param("unshippedModified") LocalDateTime unshippedModified);
......
...@@ -6,19 +6,19 @@ ...@@ -6,19 +6,19 @@
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="INTEGER" property="id"/>
<result column="bailun_sku" jdbcType="VARCHAR" property="bailunSku" /> <result column="bailun_sku" jdbcType="VARCHAR" property="bailunSku"/>
<result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode" /> <result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode"/>
<result column="quantity_purchase" jdbcType="INTEGER" property="quantityPurchase" /> <result column="quantity_purchase" jdbcType="INTEGER" property="quantityPurchase"/>
<result column="gmt_purchase_modified" jdbcType="TIMESTAMP" property="gmtPurchaseModified" /> <result column="gmt_purchase_modified" jdbcType="TIMESTAMP" property="gmtPurchaseModified"/>
<result column="quantity_transfer" jdbcType="INTEGER" property="quantityTransfer" /> <result column="quantity_transfer" jdbcType="INTEGER" property="quantityTransfer"/>
<result column="gmt_transfer_modified" jdbcType="TIMESTAMP" property="gmtTransferModified" /> <result column="gmt_transfer_modified" jdbcType="TIMESTAMP" property="gmtTransferModified"/>
<result column="quantity_out_stock" jdbcType="INTEGER" property="quantityOutStock" /> <result column="quantity_out_stock" jdbcType="INTEGER" property="quantityOutStock"/>
<result column="gmt_out_stock_modified" jdbcType="TIMESTAMP" property="gmtOutStockModified" /> <result column="gmt_out_stock_modified" jdbcType="TIMESTAMP" property="gmtOutStockModified"/>
<result column="quantity_unshipped" jdbcType="INTEGER" property="quantityUnshipped" /> <result column="quantity_unshipped" jdbcType="INTEGER" property="quantityUnshipped"/>
<result column="gmt_unshipped_modified" jdbcType="TIMESTAMP" property="gmtUnshippedModified" /> <result column="gmt_unshipped_modified" jdbcType="TIMESTAMP" property="gmtUnshippedModified"/>
<result column="company_id" jdbcType="INTEGER" property="companyId" /> <result column="company_id" jdbcType="INTEGER" property="companyId"/>
<result column="amount_purchase_transit" jdbcType="DECIMAL" property="amountPurchaseTransit" /> <result column="amount_purchase_transit" jdbcType="DECIMAL" property="amountPurchaseTransit"/>
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!-- <!--
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
...@@ -75,7 +76,8 @@ ...@@ -75,7 +76,8 @@
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue">
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
...@@ -95,7 +97,8 @@ ...@@ -95,7 +97,8 @@
gmt_transfer_modified, quantity_out_stock, gmt_out_stock_modified, quantity_unshipped, gmt_transfer_modified, quantity_out_stock, gmt_out_stock_modified, quantity_unshipped,
gmt_unshipped_modified, company_id, amount_purchase_transit gmt_unshipped_modified, company_id, amount_purchase_transit
</sql> </sql>
<select id="selectByExample" parameterType="com.bailuntec.domain.example.DcMidTransitExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.bailuntec.domain.example.DcMidTransitExample"
resultMap="BaseResultMap">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
...@@ -104,10 +107,10 @@ ...@@ -104,10 +107,10 @@
<if test="distinct"> <if test="distinct">
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
from dc_mid_transit from dc_mid_transit
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null">
order by ${orderByClause} order by ${orderByClause}
...@@ -127,7 +130,7 @@ ...@@ -127,7 +130,7 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
from dc_mid_transit from dc_mid_transit
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
...@@ -146,7 +149,7 @@ ...@@ -146,7 +149,7 @@
--> -->
delete from dc_mid_transit delete from dc_mid_transit
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.bailuntec.domain.entity.DcMidTransit"> <insert id="insert" parameterType="com.bailuntec.domain.entity.DcMidTransit">
...@@ -256,14 +259,15 @@ ...@@ -256,14 +259,15 @@
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.bailuntec.domain.example.DcMidTransitExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.bailuntec.domain.example.DcMidTransitExample"
resultType="java.lang.Long">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
select count(*) from dc_mid_transit select count(*) from dc_mid_transit
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <update id="updateByExampleSelective" parameterType="map">
...@@ -314,7 +318,7 @@ ...@@ -314,7 +318,7 @@
</if> </if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</update> </update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
...@@ -337,7 +341,7 @@ ...@@ -337,7 +341,7 @@
company_id = #{record.companyId,jdbcType=INTEGER}, company_id = #{record.companyId,jdbcType=INTEGER},
amount_purchase_transit = #{record.amountPurchaseTransit,jdbcType=DECIMAL} amount_purchase_transit = #{record.amountPurchaseTransit,jdbcType=DECIMAL}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcMidTransit"> <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcMidTransit">
...@@ -571,17 +575,18 @@ ...@@ -571,17 +575,18 @@
company_id = #{companyId,jdbcType=INTEGER}, company_id = #{companyId,jdbcType=INTEGER},
amount_purchase_transit = #{amountPurchaseTransit,jdbcType=DECIMAL} amount_purchase_transit = #{amountPurchaseTransit,jdbcType=DECIMAL}
</insert> </insert>
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcMidTransitExample" resultMap="BaseResultMap"> <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcMidTransitExample"
resultMap="BaseResultMap">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
from dc_mid_transit from dc_mid_transit
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause"/>
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null">
order by ${orderByClause} order by ${orderByClause}
...@@ -589,85 +594,121 @@ ...@@ -589,85 +594,121 @@
limit 1 limit 1
</select> </select>
<!-- <select id="selectQuantityTransferTransit" resultType="com.bailuntec.domain.dto.TransferTransitQuantity">-->
<!-- SELECT bailun_sku as bailunSku,-->
<!-- warehouse_code as warehouseCode,-->
<!-- sum(count) as count,-->
<!-- sum(countplan) as countplan,-->
<!-- sum(IF(transport_type = '国内陆运', count, 0)) as landCount,-->
<!-- sum(IF(transport_type = '海运', count, 0)) as oceanCount,-->
<!-- sum(IF(transport_type = '空运', count, 0)) as airCount,-->
<!-- sum(IF(transport_type = '铁路运输', count, 0)) as railwayCount-->
<!-- FROM (-->
<!-- SELECT tb5.bailun_sku bailun_sku,-->
<!-- tb5.warehouse_code warehouse_code,-->
<!-- (-->
<!-- tb5.count - IFNULL(tb4.count, 0)) AS count,-->
<!-- 0 as countplan,-->
<!-- tb5.transport_type transport_type-->
<!-- FROM (-->
<!-- SELECT tb1.bailun_sku,-->
<!-- tb1.warehouse_code,-->
<!-- sum(tb1.count) count,-->
<!-- tb1.transport_type-->
<!-- FROM dc_base_transfer_bale tb1-->
<!-- LEFT JOIN dc_base_transfer_complete tb2 ON tb1.transfer_order_id = tb2.transfer_order_id-->
<!-- WHERE tb2.transfer_order_id IS NULL-->
<!-- AND tb1.deleted = 0-->
<!-- GROUP BY bailun_sku,-->
<!-- warehouse_code-->
<!-- ) tb5-->
<!-- LEFT JOIN (-->
<!-- SELECT bailun_sku,-->
<!-- warehouse_code,-->
<!-- sum(count) count-->
<!-- FROM (-->
<!-- SELECT t1.bailun_sku,-->
<!-- t1.warehouse_code,-->
<!-- (case WHEN t2.count > tbb.count then tbb.count else t2.count end) as count,-->
<!-- t1.transfer_order_id-->
<!-- FROM (SELECT max(create_time) AS create_time, bailun_sku, warehouse_code, transfer_order_id-->
<!-- FROM dc_base_transfer_inbound-->
<!-- WHERE deleted = 0-->
<!-- GROUP BY bailun_sku, warehouse_code, transfer_order_id) t1-->
<!-- INNER JOIN dc_base_transfer_inbound t2 ON t1.bailun_sku = t2.bailun_sku-->
<!-- AND t1.warehouse_code = t2.warehouse_code-->
<!-- AND t1.transfer_order_id = t2.transfer_order_id-->
<!-- AND t1.create_time = t2.create_time-->
<!-- LEFT JOIN dc_base_transfer_bale tbb-->
<!-- on t1.bailun_sku = tbb.bailun_sku and t1.warehouse_code = tbb.warehouse_code and-->
<!-- t1.transfer_order_id = tbb.transfer_order_id-->
<!-- LEFT JOIN dc_base_transfer_complete tb2 ON t1.transfer_order_id = tb2.transfer_order_id-->
<!-- WHERE tb2.bailun_sku IS NULL-->
<!-- ) tb3-->
<!-- GROUP BY bailun_sku,-->
<!-- warehouse_code-->
<!-- ) tb4 ON tb5.bailun_sku = tb4.bailun_sku-->
<!-- AND tb5.warehouse_code = tb4.warehouse_code-->
<!-- WHERE (-->
<!-- tb5.count - IFNULL(tb4.count, 0)) > 0-->
<!-- UNION ALL-->
<!-- SELECT bailun_sku,-->
<!-- warehouse_code,-->
<!-- sum(count) AS count,-->
<!-- sum(count) AS countplan,-->
<!-- transport_type-->
<!-- FROM dc_base_transfer_plan-->
<!-- WHERE STATUS = 1-->
<!-- AND deleted = 0-->
<!-- GROUP BY bailun_sku,-->
<!-- warehouse_code-->
<!-- ) t-->
<!-- GROUP BY bailun_sku,-->
<!-- warehouse_code-->
<!-- </select>-->
<select id="selectQuantityTransferTransit" resultType="com.bailuntec.domain.dto.TransferTransitQuantity"> <select id="selectQuantityTransferTransit" resultType="com.bailuntec.domain.dto.TransferTransitQuantity">
SELECT bailun_sku as bailunSku, SELECT bailun_sku as bailunSku,
warehouse_code as warehouseCode, warehouse_code as warehouseCode,
sum(count) as count, sum(count) as `count`,
sum(countplan) as countplan, sum(countplan) as countplan,
sum(IF(transport_type = '国内陆运', count, 0)) as landCount, sum(IF(transport_type = '国内陆运', count, 0)) as landCount,
sum(IF(transport_type = '海运', count, 0)) as oceanCount, sum(IF(transport_type = '海运', count, 0)) as oceanCount,
sum(IF(transport_type = '空运', count, 0)) as airCount, sum(IF(transport_type = '空运', count, 0)) as airCount,
sum(IF(transport_type = '铁路运输', count, 0)) as railwayCount sum(IF(transport_type = '铁路运输', count, 0)) as railwayCount
FROM ( FROM (
SELECT tb5.bailun_sku bailun_sku, SELECT t1.targetwareno as warehouse_code,
tb5.warehouse_code warehouse_code, t2.sku as bailun_sku,
( t1.transporttype as transport_type,
tb5.count - IFNULL(tb4.count, 0)) AS count, t2.deliverycount - t2.storagecount as `count`,
0 as countplan, 0 as countplan
tb5.transport_type transport_type FROM dc_base_transfer_info t1
FROM ( LEFT JOIN dc_base_transfer_info_skus t2 on t1.dataid = t2.dataid
SELECT tb1.bailun_sku, where t1.stateid &lt; 5
tb1.warehouse_code, and t1.isdeleted = 0
sum(tb1.count) count,
tb1.transport_type
FROM dc_base_transfer_bale tb1
LEFT JOIN dc_base_transfer_complete tb2 ON tb1.transfer_order_id = tb2.transfer_order_id
WHERE tb2.transfer_order_id IS NULL
AND tb1.deleted = 0
GROUP BY bailun_sku,
warehouse_code
) tb5
LEFT JOIN (
SELECT bailun_sku,
warehouse_code,
sum(count) count
FROM (
SELECT t1.bailun_sku,
t1.warehouse_code,
(case WHEN t2.count > tbb.count then tbb.count else t2.count end) as count,
t1.transfer_order_id
FROM (SELECT max(create_time) AS create_time, bailun_sku, warehouse_code, transfer_order_id
FROM dc_base_transfer_inbound
WHERE deleted = 0
GROUP BY bailun_sku, warehouse_code, transfer_order_id) t1
INNER JOIN dc_base_transfer_inbound t2 ON t1.bailun_sku = t2.bailun_sku
AND t1.warehouse_code = t2.warehouse_code
AND t1.transfer_order_id = t2.transfer_order_id
AND t1.create_time = t2.create_time
LEFT JOIN dc_base_transfer_bale tbb
on t1.bailun_sku = tbb.bailun_sku and t1.warehouse_code = tbb.warehouse_code and
t1.transfer_order_id = tbb.transfer_order_id
LEFT JOIN dc_base_transfer_complete tb2 ON t1.transfer_order_id = tb2.transfer_order_id
WHERE tb2.bailun_sku IS NULL
) tb3
GROUP BY bailun_sku,
warehouse_code
) tb4 ON tb5.bailun_sku = tb4.bailun_sku
AND tb5.warehouse_code = tb4.warehouse_code
WHERE (
tb5.count - IFNULL(tb4.count, 0)) > 0
UNION ALL UNION ALL
SELECT bailun_sku, SELECT bailun_sku,
warehouse_code, warehouse_code,
sum(count) AS count, `count`,
sum(count) AS countplan, `count` AS countplan,
transport_type transport_type
FROM dc_base_transfer_plan FROM dc_base_transfer_plan
WHERE STATUS = 1 WHERE STATUS = 1
AND deleted = 0 AND deleted = 0
GROUP BY bailun_sku,
warehouse_code
) t ) t
GROUP BY bailun_sku, GROUP BY bailun_sku, warehouse_code
warehouse_code
</select> </select>
<insert id="calculateTransferTransit"> <insert id="calculateTransferTransit">
insert into dc_mid_transit(bailun_sku, warehouse_code, quantity_transfer,quantity_transfer_plan,quantity_land_transfer,quantity_ocean_transfer,quantity_air_transfer,quantity_railway_transfer, gmt_transfer_modified) insert into dc_mid_transit(bailun_sku, warehouse_code,
quantity_transfer,quantity_transfer_plan,quantity_land_transfer,quantity_ocean_transfer,quantity_air_transfer,quantity_railway_transfer,
gmt_transfer_modified)
values values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
( (
#{item.bailunSku,jdbcType=VARCHAR}, #{item.warehouseCode,jdbcType=VARCHAR}, #{item.count,jdbcType=INTEGER},#{item.countplan,jdbcType=INTEGER},#{item.landCount,jdbcType=INTEGER},#{item.oceanCount,jdbcType=INTEGER},#{item.airCount,jdbcType=INTEGER},#{item.railwayCount,jdbcType=INTEGER}, #{localDateTime,jdbcType=TIMESTAMP} #{item.bailunSku,jdbcType=VARCHAR}, #{item.warehouseCode,jdbcType=VARCHAR},
#{item.count,jdbcType=INTEGER},#{item.countplan,jdbcType=INTEGER},#{item.landCount,jdbcType=INTEGER},#{item.oceanCount,jdbcType=INTEGER},#{item.airCount,jdbcType=INTEGER},#{item.railwayCount,jdbcType=INTEGER},
#{localDateTime,jdbcType=TIMESTAMP}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE quantity_transfer = values(quantity_transfer), ON DUPLICATE KEY UPDATE quantity_transfer = values(quantity_transfer),
...@@ -680,62 +721,81 @@ ...@@ -680,62 +721,81 @@
</insert> </insert>
<insert id="calculatePurchaseTransit"> <insert id="calculatePurchaseTransit">
insert into dc_mid_transit(bailun_sku, warehouse_code, quantity_purchase,amount_purchase_transit,quantity_land_purchase,quantity_ocean_purchase,quantity_air_purchase,quantity_railway_purchase,gmt_purchase_modified) insert into dc_mid_transit(bailun_sku, warehouse_code,
quantity_purchase,amount_purchase_transit,quantity_land_purchase,quantity_ocean_purchase,quantity_air_purchase,quantity_railway_purchase,gmt_purchase_modified)
values values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
( (
#{item.bailunSku,jdbcType=VARCHAR}, #{item.warehouseCode,jdbcType=VARCHAR}, #{item.count,jdbcType=INTEGER}, #{item.amountPurchaseTransit,jdbcType=DECIMAL},#{item.landCount,jdbcType=INTEGER},#{item.oceanCount,jdbcType=INTEGER},#{item.airCount,jdbcType=INTEGER},#{item.railwayCount,jdbcType=INTEGER}, #{localDateTime,jdbcType=TIMESTAMP} #{item.bailunSku,jdbcType=VARCHAR}, #{item.warehouseCode,jdbcType=VARCHAR}, #{item.count,jdbcType=INTEGER},
#{item.amountPurchaseTransit,jdbcType=DECIMAL},#{item.landCount,jdbcType=INTEGER},#{item.oceanCount,jdbcType=INTEGER},#{item.airCount,jdbcType=INTEGER},#{item.railwayCount,jdbcType=INTEGER},
#{localDateTime,jdbcType=TIMESTAMP}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE quantity_purchase = values(quantity_purchase), amount_purchase_transit = values(amount_purchase_transit),quantity_land_purchase = values(quantity_land_purchase),quantity_ocean_purchase = values(quantity_ocean_purchase),quantity_air_purchase = values(quantity_air_purchase),quantity_railway_purchase = values(quantity_railway_purchase), gmt_purchase_modified = values(gmt_purchase_modified) ON DUPLICATE KEY UPDATE quantity_purchase = values(quantity_purchase), amount_purchase_transit =
values(amount_purchase_transit),quantity_land_purchase = values(quantity_land_purchase),quantity_ocean_purchase
= values(quantity_ocean_purchase),quantity_air_purchase =
values(quantity_air_purchase),quantity_railway_purchase = values(quantity_railway_purchase),
gmt_purchase_modified = values(gmt_purchase_modified)
</insert> </insert>
<insert id="calculateOutStock"> <insert id="calculateOutStock">
insert into dc_mid_transit(bailun_sku, warehouse_code, quantity_out_stock,gmt_out_stock_modified, quantity_out_stock_aliexpress) insert into dc_mid_transit(bailun_sku, warehouse_code, quantity_out_stock,gmt_out_stock_modified,
quantity_out_stock_aliexpress)
values values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
( (
#{item.bailunSku,jdbcType=VARCHAR}, #{item.warehouseCode,jdbcType=VARCHAR}, #{item.quantityOutStock,jdbcType=INTEGER}, #{localDateTime,jdbcType=TIMESTAMP}, #{item.aliexpressQuantity, jdbcType=INTEGER} #{item.bailunSku,jdbcType=VARCHAR}, #{item.warehouseCode,jdbcType=VARCHAR},
#{item.quantityOutStock,jdbcType=INTEGER}, #{localDateTime,jdbcType=TIMESTAMP},
#{item.aliexpressQuantity, jdbcType=INTEGER}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE quantity_out_stock = values(quantity_out_stock) ,gmt_out_stock_modified = values(gmt_out_stock_modified), quantity_out_stock_aliexpress = values(quantity_out_stock_aliexpress) ON DUPLICATE KEY UPDATE quantity_out_stock = values(quantity_out_stock) ,gmt_out_stock_modified =
values(gmt_out_stock_modified), quantity_out_stock_aliexpress = values(quantity_out_stock_aliexpress)
</insert> </insert>
<insert id="insertMidDailyTransit"> <insert id="insertMidDailyTransit">
INSERT into dc_daily_transit ( INSERT into dc_daily_transit (`bailun_sku`,
`bailun_sku` ,
`warehouse_code`, `warehouse_code`,
`quantity_purchase` , `quantity_purchase`,
`quantity_transfer`, `quantity_transfer`,
`quantity_transfer_plan`, `quantity_transfer_plan`,
`record_time`) `record_time`)
SELECT `bailun_sku` , SELECT `bailun_sku`,
`warehouse_code`, `warehouse_code`,
`quantity_purchase` , `quantity_purchase`,
`quantity_transfer`,`quantity_transfer_plan`, DATE_SUB( CURDATE( ), INTERVAL 1 DAY ) `quantity_transfer`,
`quantity_transfer_plan`,
DATE_SUB(CURDATE(), INTERVAL 1 DAY)
FROM dc_mid_transit FROM dc_mid_transit
</insert> </insert>
<update id="updateSkuUnitPrice"> <update id="updateSkuUnitPrice">
update dc_daily_transit t1, dc_base_sku t2 set t1.unit_price = t2.unit_price WHERE t1.record_time = DATE_SUB( CURDATE( ), INTERVAL 1 DAY ) and t1.bailun_sku=t2.bailun_sku update dc_daily_transit t1, dc_base_sku t2
set t1.unit_price = t2.unit_price
WHERE t1.record_time = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
and t1.bailun_sku = t2.bailun_sku
</update> </update>
<select id="selectQuantityOutStock" resultType="com.bailuntec.domain.dto.OutStockQuantity"> <select id="selectQuantityOutStock" resultType="com.bailuntec.domain.dto.OutStockQuantity">
SELECT SELECT t1.bailun_sku as bailunSku,
t1.bailun_sku as bailunSku,
t1.warehouse_code as warehouseCode, t1.warehouse_code as warehouseCode,
t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_pushed - t2.usable_stock - t2.occupy_stock + ifnull(t3.safe_stock, 0) as quantityOutStock, t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_pushed - t2.usable_stock - t2.occupy_stock +
if((t1.aliexpress_quantity - t2.usable_stock - t2.occupy_stock + ifnull(t3.safe_stock, 0)) &lt; 0, 0, (t1.aliexpress_quantity - t2.usable_stock - t2.occupy_stock + ifnull(t3.safe_stock, 0))) as aliexpressQuantity ifnull(t3.safe_stock, 0) as quantityOutStock,
FROM if((t1.aliexpress_quantity - t2.usable_stock - t2.occupy_stock + ifnull(t3.safe_stock, 0)) &lt; 0, 0,
( (t1.aliexpress_quantity - t2.usable_stock - t2.occupy_stock +
SELECT ifnull(t3.safe_stock, 0))) as aliexpressQuantity
bailun_sku,warehouse_code,SUM(bailun_sku_quantity_ordered) AS bailun_sku_quantity_ordered,SUM(bailun_sku_quantity_pushed) AS bailun_sku_quantity_pushed, FROM (
sum(case when platform_type = 'Aliexpress' then bailun_sku_quantity_ordered - bailun_sku_quantity_pushed else 0 end) as aliexpress_quantity SELECT bailun_sku,
FROM warehouse_code,
dc_base_oms_sku SUM(bailun_sku_quantity_ordered) AS bailun_sku_quantity_ordered,
WHERE SUM(bailun_sku_quantity_pushed) AS bailun_sku_quantity_pushed,
bailun_order_status = 'Handling' sum(case
and bailun_interception_status in('None','Failed') when platform_type = 'Aliexpress'
then bailun_sku_quantity_ordered - bailun_sku_quantity_pushed
else 0 end) as aliexpress_quantity
FROM dc_base_oms_sku
WHERE bailun_order_status = 'Handling'
and bailun_interception_status in ('None', 'Failed')
and warehouse_code != '' and warehouse_code != ''
and platform_type != 'FBA' and platform_type != 'FBA'
and company_id = 1 and company_id = 1
...@@ -747,125 +807,136 @@ ...@@ -747,125 +807,136 @@
and has_innersale = 0 and has_innersale = 0
and paid_time >= '2019-03-01 12:00:00' and paid_time >= '2019-03-01 12:00:00'
and bailun_sku_quantity_ordered > bailun_sku_quantity_shipped and bailun_sku_quantity_ordered > bailun_sku_quantity_shipped
GROUP BY GROUP BY bailun_sku,
bailun_sku,
warehouse_code warehouse_code
) t1 INNER JOIN dc_base_stock t2 ON t1.bailun_sku=t2.bailun_sku and t1.warehouse_code=t2.warehouse_code ) t1
LEFT JOIN dc_auto_jit_inventory t3 ON t1.bailun_sku=t3.bailun_sku and t1.warehouse_code=t3.warehouse_code and t3.status = 1 INNER JOIN dc_base_stock t2 ON t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
WHERE (t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_pushed - t2.usable_stock - t2.occupy_stock + ifnull(t3.safe_stock, 0)) >= 0 LEFT JOIN dc_auto_jit_inventory t3
ON t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code and t3.status = 1
WHERE (t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_pushed - t2.usable_stock - t2.occupy_stock +
ifnull(t3.safe_stock, 0)) >= 0
</select> </select>
<select id="selectQuantityPurchaseTransit" resultType="com.bailuntec.domain.dto.PurchaseTransitQuantity"> <select id="selectQuantityPurchaseTransit" resultType="com.bailuntec.domain.dto.PurchaseTransitQuantity">
SELECT SELECT bailun_sku as bailunSku,
bailun_sku as bailunSku,
warehouse_code as warehouseCode, warehouse_code as warehouseCode,
sum( count ) as count, sum(count) as count,
sum( count * price ) AS amountPurchaseTransit, sum(count * price) AS amountPurchaseTransit,
sum(case when transport_type = 1 then count else 0 end) as landCount, sum(case when transport_type = 1 then count else 0 end) as landCount,
sum(case when transport_type = 2 then count else 0 end) as oceanCount, sum(case when transport_type = 2 then count else 0 end) as oceanCount,
sum(case when transport_type = 3 then count else 0 end) as airCount, sum(case when transport_type = 3 then count else 0 end) as airCount,
sum(case when transport_type = 4 then count else 0 end) as railwayCount sum(case when transport_type = 4 then count else 0 end) as railwayCount
FROM FROM (
( SELECT tb1.bailun_sku AS bailun_sku,
SELECT
tb1.bailun_sku AS bailun_sku,
tb1.warehouse_code AS warehouse_code, tb1.warehouse_code AS warehouse_code,
tb1.purchase_id AS purchase_id, tb1.purchase_id AS purchase_id,
sum( if((tb1.count - IFNULL( tb2.count, 0 )) &lt; 0, 0, (tb1.count - IFNULL( tb2.count, 0 ))) ) AS count, sum(if((tb1.count - IFNULL(tb2.count, 0)) &lt; 0, 0,
(tb1.count - IFNULL(tb2.count, 0)))) AS count,
tb1.transport_type AS transport_type, tb1.transport_type AS transport_type,
price price
FROM FROM (
( SELECT bailun_sku,
SELECT
bailun_sku,
warehouse_code, warehouse_code,
parent_id, parent_id,
purchase_id, purchase_id,
estimated_arrival_time, estimated_arrival_time,
has_transfer, has_transfer,
sum( count ) AS count, sum(count) AS count,
price, price,
transport_type transport_type
FROM FROM dc_base_purchase
dc_base_purchase WHERE buy_status IN (0, 1, 2, 3)
WHERE
buy_status IN ( 0, 1, 2, 3 )
AND has_delete = 0 AND has_delete = 0
GROUP BY GROUP BY bailun_sku,
bailun_sku,
parent_id parent_id
) tb1 ) tb1
LEFT JOIN ( LEFT JOIN (
SELECT SELECT bailun_sku,
bailun_sku,
warehouse_code, warehouse_code,
parent_id, parent_id,
sum( count ) AS count sum(count) AS count
FROM FROM dc_base_purchase_inbound
dc_base_purchase_inbound WHERE 1 = 1
WHERE GROUP BY bailun_sku,
1=1
GROUP BY
bailun_sku,
parent_id parent_id
) tb2 ON tb1.bailun_sku = tb2.bailun_sku ) tb2 ON tb1.bailun_sku = tb2.bailun_sku
AND tb1.parent_id = tb2.parent_id AND tb1.parent_id = tb2.parent_id
GROUP BY GROUP BY tb1.bailun_sku,
tb1.bailun_sku,
tb1.warehouse_code, tb1.warehouse_code,
tb1.purchase_id tb1.purchase_id
) t ) t
GROUP BY GROUP BY bailun_sku,
bailun_sku,
warehouse_code warehouse_code
HAVING HAVING count > 0
count > 0
</select> </select>
<update id="updateOldOutStockToZero"> <update id="updateOldOutStockToZero">
update dc_mid_transit set quantity_out_stock =0, quantity_out_stock_aliexpress = 0 where gmt_out_stock_modified &lt; #{outStockModified,jdbcType=TIMESTAMP} update dc_mid_transit
set quantity_out_stock =0,
quantity_out_stock_aliexpress = 0
where gmt_out_stock_modified &lt; #{outStockModified,jdbcType=TIMESTAMP}
</update> </update>
<update id="updateOldTransferToZero"> <update id="updateOldTransferToZero">
update dc_mid_transit set quantity_transfer =0, quantity_transfer_plan =0, quantity_land_transfer = 0,quantity_ocean_transfer = 0,quantity_air_transfer = 0,quantity_railway_transfer = 0 where gmt_transfer_modified &lt; #{transferModified,jdbcType=TIMESTAMP} update dc_mid_transit
set quantity_transfer =0,
quantity_transfer_plan =0,
quantity_land_transfer = 0,
quantity_ocean_transfer = 0,
quantity_air_transfer = 0,
quantity_railway_transfer = 0
where gmt_transfer_modified &lt; #{transferModified,jdbcType=TIMESTAMP}
</update> </update>
<update id="updateOldPurchaseToZero"> <update id="updateOldPurchaseToZero">
update dc_mid_transit set quantity_purchase =0,amount_purchase_transit=0, quantity_land_purchase = 0,quantity_ocean_purchase = 0,quantity_air_purchase = 0,quantity_railway_purchase = 0 where gmt_purchase_modified &lt; #{purchaseModified,jdbcType=TIMESTAMP} update dc_mid_transit
set quantity_purchase =0,
amount_purchase_transit=0,
quantity_land_purchase = 0,
quantity_ocean_purchase = 0,
quantity_air_purchase = 0,
quantity_railway_purchase = 0
where gmt_purchase_modified &lt; #{purchaseModified,jdbcType=TIMESTAMP}
</update> </update>
<update id="updateOldUnshippedToZero"> <update id="updateOldUnshippedToZero">
update dc_mid_transit set quantity_unshipped =0 where gmt_unshipped_modified &lt; #{unshippedModified,jdbcType=TIMESTAMP} update dc_mid_transit
set quantity_unshipped =0
where gmt_unshipped_modified &lt; #{unshippedModified,jdbcType=TIMESTAMP}
</update> </update>
<select id="selectMaxOutStockModified" resultType="java.time.LocalDateTime"> <select id="selectMaxOutStockModified" resultType="java.time.LocalDateTime">
select max(gmt_out_stock_modified) from dc_mid_transit select max(gmt_out_stock_modified)
from dc_mid_transit
</select> </select>
<select id="selectMaxTransferModified" resultType="java.time.LocalDateTime"> <select id="selectMaxTransferModified" resultType="java.time.LocalDateTime">
select max(gmt_transfer_modified) from dc_mid_transit select max(gmt_transfer_modified)
from dc_mid_transit
</select> </select>
<select id="selectMaxPurchaseModified" resultType="java.time.LocalDateTime"> <select id="selectMaxPurchaseModified" resultType="java.time.LocalDateTime">
select max(gmt_purchase_modified) from dc_mid_transit select max(gmt_purchase_modified)
from dc_mid_transit
</select> </select>
<select id="selectMaxUnshippedModified" resultType="java.time.LocalDateTime"> <select id="selectMaxUnshippedModified" resultType="java.time.LocalDateTime">
select max(gmt_unshipped_modified) from dc_mid_transit select max(gmt_unshipped_modified)
from dc_mid_transit
</select> </select>
<insert id="calculateUnshipped"> <insert id="calculateUnshipped">
insert into dc_mid_transit(bailun_sku, warehouse_code, quantity_unshipped,gmt_unshipped_modified,bailun_order_ids) insert into dc_mid_transit(bailun_sku, warehouse_code, quantity_unshipped, gmt_unshipped_modified,
SELECT bailun_order_ids)
t1.bailun_sku, SELECT t1.bailun_sku,
t1.warehouse_code, t1.warehouse_code,
t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_shipped, t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_shipped,
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP,
t1.bailun_order_ids t1.bailun_order_ids
FROM FROM (
( SELECT bailun_sku,
SELECT warehouse_code,
bailun_sku,warehouse_code,SUM(bailun_sku_quantity_ordered) AS bailun_sku_quantity_ordered,SUM(bailun_sku_quantity_shipped) AS bailun_sku_quantity_shipped, SUM(bailun_sku_quantity_ordered) AS bailun_sku_quantity_ordered,
GROUP_CONCAT(DISTINCT (case when warehouse_code='BLGZ03' then bailun_order_id else '' end)) as 'bailun_order_ids' SUM(bailun_sku_quantity_shipped) AS bailun_sku_quantity_shipped,
FROM GROUP_CONCAT(DISTINCT
dc_base_oms_sku (case when warehouse_code = 'BLGZ03' then bailun_order_id else '' end)) as 'bailun_order_ids'
WHERE FROM dc_base_oms_sku
bailun_order_status = 'Handling' WHERE bailun_order_status = 'Handling'
and bailun_interception_status in('None','Failed') and bailun_interception_status in ('None', 'Failed')
and warehouse_code != '' and warehouse_code != ''
and platform_type != 'FBA' and platform_type != 'FBA'
and has_delete = 0 and has_delete = 0
...@@ -876,11 +947,12 @@ ...@@ -876,11 +947,12 @@
and has_innersale = 0 and has_innersale = 0
and paid_time >= '2019-03-01 12:00:00' and paid_time >= '2019-03-01 12:00:00'
and bailun_sku_quantity_ordered > bailun_sku_quantity_shipped and bailun_sku_quantity_ordered > bailun_sku_quantity_shipped
GROUP BY GROUP BY bailun_sku,
bailun_sku,
warehouse_code warehouse_code
) t1 ) t1
WHERE (t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_shipped) >= 0 WHERE (t1.bailun_sku_quantity_ordered - t1.bailun_sku_quantity_shipped) >= 0
ON DUPLICATE KEY UPDATE quantity_unshipped = VALUES(quantity_unshipped),gmt_unshipped_modified = VALUES(gmt_unshipped_modified),bailun_order_ids = VALUES(bailun_order_ids) ON DUPLICATE KEY UPDATE quantity_unshipped = VALUES(quantity_unshipped),
gmt_unshipped_modified = VALUES(gmt_unshipped_modified),
bailun_order_ids = VALUES(bailun_order_ids)
</insert> </insert>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment