Commit 9fca1c10 by huluobin

# AIms 周转

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