Commit 9fca1c10 by huluobin

# AIms 周转

parent 10f14fac
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcAutoSalesForecastConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
......@@ -11,6 +10,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author robbendev
* @since 2021-01-14
*/
public interface DcAutoSalesForecastConfigMapper extends BaseMapper<DcAutoSalesForecastConfig> {
public interface DcAutoSalesForecastConfigMapper {
DcAutoSalesForecastConfig selectById(Integer id);
}
......@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bailuntec.mapper.DcAutoSalesForecastConfigMapper">
<select id="selectById" resultType="com.bailuntec.domain.entity.DcAutoSalesForecastConfig">
select *
from dc_auto_sales_forecast_config
where id = #{id}
</select>
</mapper>
......@@ -21,10 +21,14 @@
and (t2.product_type = t5.category or length(trim(t5.category)) = 0)
and (t6.area_id = t5.warehouse_area_id or length(trim(t5.warehouse_area_id)) = 0)
and t5.is_delete = 0
and (t5.first_order_days_min = 0 or t5.first_order_days_min &lt;= #{firstOrderDays})
and (t5.first_order_days_max = 0 or t5.first_order_days_max &gt;= #{firstOrderDays})
and (t5.orders_avg_min = 0 or t5.orders_avg_min &lt;= #{avgOrderCount30})
and (t5.orders_avg_max = 0 or t5.orders_avg_max &gt;= #{avgOrderCount30})
<if test="firstOrderDays!=null and firstOrderDays!=0">
and (t5.first_order_days_min = 0 or t5.first_order_days_min &lt;= #{firstOrderDays})
and (t5.first_order_days_max = 0 or t5.first_order_days_max &gt;= #{firstOrderDays})
</if>
<if test="avgOrderCount30!=null and avgOrderCount30!=0">
and (t5.orders_avg_min = 0 or t5.orders_avg_min &lt;= #{avgOrderCount30})
and (t5.orders_avg_max = 0 or t5.orders_avg_max &gt;= #{avgOrderCount30})
</if>
LEFT JOIN dc_auto_sales_forecast_stage_config t7 on t7.config_id = t5.id
and (IF(t5.screen_type = 1,
((t8.first_inbound_date &lt;= t7.duration_upper_limit or t7.duration_upper_limit = 0)
......
......@@ -3741,23 +3741,26 @@
</select>
<select id="omsSkuSellerCount" resultType="java.math.BigDecimal">
select (select coalesce(sum(bailun_sku_quantity_ordered), 0)
from dc_base_oms_sku t1
left join dc_aims_transfer_warehouse_sales t2
on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
where t1.paid_time &gt;= #{lowerTime}
and t1.paid_time &lt;= #{upperTime}
and t1.bailun_sku = #{bailunSku}
and t1.warehouse_code = #{warehouseCode}
and t1.has_fba_s = 0
and t1.has_delete = 0
and t1.has_scalp = 0
and t1.has_buyer_remark = 0
and t1.has_platsku_remark = 0
and t1.has_innersale = 0
and t1.bailun_order_status != 'Canceled'
and t1.platform_order_type != '手工单'
) / #{days}
SELECT (SELECT coalesce(sum(ifnull(tt2.sales, tt1.bailun_sku_quantity_ordered)), 0)
from (
select coalesce(sum(t1.bailun_sku_quantity_ordered), 0) as bailun_sku_quantity_ordered,
DATE_FORMAT(paid_time, '%y%m%d') as paid_date
from dc_base_oms_sku t1
where t1.paid_time &gt;= #{lowerTime}
and t1.paid_time &lt;= #{upperTime}
and t1.bailun_sku = #{bailunSku}
and t1.warehouse_code = #{warehouseCode}
and t1.has_fba_s = 0
and t1.has_delete = 0
and t1.has_scalp = 0
and t1.has_buyer_remark = 0
and t1.has_platsku_remark = 0
and t1.has_innersale = 0
and t1.bailun_order_status != 'Canceled'
and t1.platform_order_type != '手工单'
GROUP BY DATE_FORMAT(paid_time, '%y%m%d')) tt1
LEFT JOIN dc_aims_transfer_warehouse_sales tt2 on tt1.paid_date = tt2.date)
/ #{days}
</select>
......
......@@ -5,8 +5,8 @@
<configuration>
<!--<properties resource="db-tj.properties"/>-->
<properties resource="db-dev.properties"/>
<!-- <properties resource="db-prod.properties"/>-->
<!-- <properties resource="db-dev.properties"/>-->
<properties resource="db-prod.properties"/>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
......
......@@ -30,6 +30,10 @@ import java.util.*;
@Slf4j
public class AutoTurnoverServiceImpl implements AutoTurnoverService {
private BigDecimal omsSkuSellerCount(String bailunSku, String wareshouseCode) {
return BigDecimal.ZERO;
}
@Override
public List<BigDecimal> getAutoTurnoverSaleDetails(DcAutoTurnover dcAutoTurnover, int turnoverDays, int autoForecastDay) {
......@@ -46,7 +50,9 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
DcBaseOmsSku orderFirstCreateTime = dcAutoSalesForecastStageConfigMapper.firsOrder(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
Integer day = Period.between(orderFirstCreateTime.getCreateTime().toLocalDate(), LocalDateTime.now().toLocalDate()).getDays();
Integer day = Optional.ofNullable(orderFirstCreateTime).map(var -> Period.between(var.getCreateTime().toLocalDate(), LocalDateTime.now().toLocalDate()).getDays()).orElse(null);
BigDecimal avgOrderCount30 = dcAutoSalesForecastStageConfigMapper.avgOrderCount30(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
//命中的预测规则
......@@ -68,8 +74,8 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
dcAutoTurnover.setDcAutoSalesForecastStageConfigId(dcAutoSalesForecastStageConfig.getId());
dcAutoTurnover.setDcAutoSalesForecastTitle(dcAutoSalesForecastConfig.getTitle());
dcAutoTurnover.setFirstOrderDate(orderFirstCreateTime.getCreateTime());
dcAutoTurnover.setFirstOrderBailunOrderId(orderFirstCreateTime.getBailunOrderId());
dcAutoTurnover.setFirstOrderDate(Optional.ofNullable(orderFirstCreateTime).map(DcBaseOmsSku::getCreateTime).orElse(null));
dcAutoTurnover.setFirstOrderBailunOrderId(Optional.ofNullable(orderFirstCreateTime).map(DcBaseOmsSku::getBailunOrderId).orElse(null));
dcAutoTurnover.setOrdersAvg(avgOrderCount30);
log.info("匹配到一条规则 id:{}", dcAutoSalesForecastStageConfig.getConfigId());
......@@ -166,7 +172,7 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
DcBaseOmsSkuMapper dcBaseOmsSkuMapper = session.getMapper(DcBaseOmsSkuMapper.class);
DcBaseOmsSku orderFirstCreateTime = dcAutoSalesForecastStageConfigMapper.firsOrder(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
Integer day = Period.between(orderFirstCreateTime.getCreateTime().toLocalDate(), LocalDateTime.now().toLocalDate()).getDays();
Integer day = Optional.ofNullable(orderFirstCreateTime).map(var -> Period.between(var.getCreateTime().toLocalDate(), LocalDateTime.now().toLocalDate()).getDays()).orElse(null);
BigDecimal avgOrderCount30 = dcAutoSalesForecastStageConfigMapper.avgOrderCount30(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
......
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