Commit 10f14fac by huluobin

# 周转 aims 预测销量

parent 0c179787
package com.bailuntec.domain.entity;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
@Data
public class DcAimsTransferWarehouseSales {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_aims_transfer_warehouse_sales.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_aims_transfer_warehouse_sales.bailun_sku
*
* @mbg.generated
*/
private String bailunSku;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_aims_transfer_warehouse_sales.warehouse_code
*
* @mbg.generated
*/
private String warehouseCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_aims_transfer_warehouse_sales.bailun_sku_warehouse_code
*
* @mbg.generated
*/
private String bailunSkuWarehouseCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_aims_transfer_warehouse_sales.date
*
* @mbg.generated
*/
private LocalDateTime date;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_aims_transfer_warehouse_sales.date_str
*
* @mbg.generated
*/
private String dateStr;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_aims_transfer_warehouse_sales.sales
*
* @mbg.generated
*/
private BigDecimal sales;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", bailunSku=").append(bailunSku);
sb.append(", warehouseCode=").append(warehouseCode);
sb.append(", bailunSkuWarehouseCode=").append(bailunSkuWarehouseCode);
sb.append(", date=").append(date);
sb.append(", dateStr=").append(dateStr);
sb.append(", sales=").append(sales);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
DcAimsTransferWarehouseSales other = (DcAimsTransferWarehouseSales) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getBailunSku() == null ? other.getBailunSku() == null : this.getBailunSku().equals(other.getBailunSku()))
&& (this.getWarehouseCode() == null ? other.getWarehouseCode() == null : this.getWarehouseCode().equals(other.getWarehouseCode()))
&& (this.getBailunSkuWarehouseCode() == null ? other.getBailunSkuWarehouseCode() == null : this.getBailunSkuWarehouseCode().equals(other.getBailunSkuWarehouseCode()))
&& (this.getDate() == null ? other.getDate() == null : this.getDate().equals(other.getDate()))
&& (this.getDateStr() == null ? other.getDateStr() == null : this.getDateStr().equals(other.getDateStr()))
&& (this.getSales() == null ? other.getSales() == null : this.getSales().equals(other.getSales()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getBailunSku() == null) ? 0 : getBailunSku().hashCode());
result = prime * result + ((getWarehouseCode() == null) ? 0 : getWarehouseCode().hashCode());
result = prime * result + ((getBailunSkuWarehouseCode() == null) ? 0 : getBailunSkuWarehouseCode().hashCode());
result = prime * result + ((getDate() == null) ? 0 : getDate().hashCode());
result = prime * result + ((getDateStr() == null) ? 0 : getDateStr().hashCode());
result = prime * result + ((getSales() == null) ? 0 : getSales().hashCode());
return result;
}
}
\ No newline at end of file
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcAimsTransferWarehouseSales;
import com.bailuntec.domain.example.DcAimsTransferWarehouseSalesExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface DcAimsTransferWarehouseSalesMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
long countByExample(DcAimsTransferWarehouseSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int deleteByExample(DcAimsTransferWarehouseSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int insert(DcAimsTransferWarehouseSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int insertSelective(DcAimsTransferWarehouseSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcAimsTransferWarehouseSales selectOneByExample(DcAimsTransferWarehouseSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
List<DcAimsTransferWarehouseSales> selectByExample(DcAimsTransferWarehouseSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
DcAimsTransferWarehouseSales selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcAimsTransferWarehouseSales record, @Param("example") DcAimsTransferWarehouseSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcAimsTransferWarehouseSales record, @Param("example") DcAimsTransferWarehouseSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcAimsTransferWarehouseSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
*/
int updateByPrimaryKey(DcAimsTransferWarehouseSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcAimsTransferWarehouseSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_aims_transfer_warehouse_sales
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcAimsTransferWarehouseSales record);
}
\ No newline at end of file
...@@ -2,9 +2,11 @@ package com.bailuntec.mapper; ...@@ -2,9 +2,11 @@ package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcAutoSalesForecastStageConfig; import com.bailuntec.domain.entity.DcAutoSalesForecastStageConfig;
import com.bailuntec.domain.entity.DcAutoTurnover; import com.bailuntec.domain.entity.DcAutoTurnover;
import com.bailuntec.domain.entity.DcBaseOmsSku;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -26,8 +28,10 @@ public interface DcAutoSalesForecastStageConfigMapper extends BaseMapper<DcAutoS ...@@ -26,8 +28,10 @@ public interface DcAutoSalesForecastStageConfigMapper extends BaseMapper<DcAutoS
* @param warehouseCode 仓库编码 * @param warehouseCode 仓库编码
* @return 命中的预测规则 * @return 命中的预测规则
*/ */
DcAutoSalesForecastStageConfig selectMatchStage(@Param("bailunSku") String bailunSku, @Param("warehouseCode") String warehouseCode); DcAutoSalesForecastStageConfig selectMatchStage(@Param("bailunSku") String bailunSku,
@Param("warehouseCode") String warehouseCode,
@Param("firstOrderDays") Integer firstOrderDays,
@Param("avgOrderCount30") BigDecimal avgOrderCount30);
/** /**
...@@ -38,4 +42,10 @@ public interface DcAutoSalesForecastStageConfigMapper extends BaseMapper<DcAutoS ...@@ -38,4 +42,10 @@ public interface DcAutoSalesForecastStageConfigMapper extends BaseMapper<DcAutoS
* @return * @return
*/ */
List<DcAutoTurnover> selectTestSyncAutoTurnoverList(); List<DcAutoTurnover> selectTestSyncAutoTurnoverList();
DcBaseOmsSku firsOrder(@Param("bailunSku") String bailunSku,
@Param("warehouseCode") String warehouseCode);
BigDecimal avgOrderCount30(@Param("bailunSku") String bailunSku,
@Param("warehouseCode") String warehouseCode);
} }
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
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})
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})
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)
...@@ -78,4 +82,22 @@ ...@@ -78,4 +82,22 @@
ORDER BY t5.`level` desc) aaa ORDER BY t5.`level` desc) aaa
GROUP BY bailun_sku, warehouse_code; GROUP BY bailun_sku, warehouse_code;
</select> </select>
<select id="firsOrder" resultType="com.bailuntec.domain.entity.DcBaseOmsSku">
select create_time, bailun_order_id
from dc_base_oms_sku
where bailun_sku = #{bailunSku}
and warehouse_code = #{warehouseCode}
order by create_time asc
limit 1;
</select>
<select id="avgOrderCount30" resultType="java.math.BigDecimal">
select count(DISTINCT bailun_order_id) / 30
from dc_base_oms_sku
where bailun_sku = #{bailunSku}
and warehouse_code = #{warehouseCode}
and create_time >= date_sub(now(), interval 31 day)
</select>
</mapper> </mapper>
This source diff could not be displayed because it is too large. You can view the blob instead.
table-name=dc_auto_turnover table-name=dc_aims_transfer_warehouse_sales
...@@ -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>
......
...@@ -22,6 +22,5 @@ class DcAutoSalesForecastStageConfigMapperTest { ...@@ -22,6 +22,5 @@ class DcAutoSalesForecastStageConfigMapperTest {
void selectMatchStage() { void selectMatchStage() {
DcAutoSalesForecastStageConfigMapper dcAutoSalesForecastStageConfigMapper = SessionUtil.getSession().getMapper(DcAutoSalesForecastStageConfigMapper.class); DcAutoSalesForecastStageConfigMapper dcAutoSalesForecastStageConfigMapper = SessionUtil.getSession().getMapper(DcAutoSalesForecastStageConfigMapper.class);
DcAutoSalesForecastStageConfig dcAutoSalesForecastStageConfig = dcAutoSalesForecastStageConfigMapper.selectMatchStage("946776911", "GZBLWH");
} }
} }
...@@ -17,4 +17,8 @@ public class DataNode { ...@@ -17,4 +17,8 @@ public class DataNode {
private BigDecimal x; private BigDecimal x;
private BigDecimal y; private BigDecimal y;
public synchronized BigDecimal getXY() {
return this.x.multiply(this.y);
}
} }
...@@ -428,6 +428,7 @@ public class AutoTurnoverJob extends PointJob { ...@@ -428,6 +428,7 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover.setGmtModified(LocalDateTime.now()); dcAutoTurnover.setGmtModified(LocalDateTime.now());
forecastSalesList = salesDetailItemList.stream().map(SalesDetailItem::getShowSales).collect(Collectors.toList()); forecastSalesList = salesDetailItemList.stream().map(SalesDetailItem::getShowSales).collect(Collectors.toList());
// dcAutoTurnover.setSalesDetails("[" + salesDetailItemList.stream().map(SalesDetailItem::getShowSales).map(BigDecimal::toString).collect(Collectors.joining(",")) + "]"); // dcAutoTurnover.setSalesDetails("[" + salesDetailItemList.stream().map(SalesDetailItem::getShowSales).map(BigDecimal::toString).collect(Collectors.joining(",")) + "]");
/*周系数end*/ /*周系数end*/
......
...@@ -3,6 +3,7 @@ package com.bailuntec.service.impl; ...@@ -3,6 +3,7 @@ package com.bailuntec.service.impl;
import com.bailuntec.domain.entity.DcAutoSalesForecastConfig; import com.bailuntec.domain.entity.DcAutoSalesForecastConfig;
import com.bailuntec.domain.entity.DcAutoSalesForecastStageConfig; import com.bailuntec.domain.entity.DcAutoSalesForecastStageConfig;
import com.bailuntec.domain.entity.DcAutoTurnover; import com.bailuntec.domain.entity.DcAutoTurnover;
import com.bailuntec.domain.entity.DcBaseOmsSku;
import com.bailuntec.mapper.DcAutoSalesForecastConfigMapper; import com.bailuntec.mapper.DcAutoSalesForecastConfigMapper;
import com.bailuntec.mapper.DcAutoSalesForecastStageConfigMapper; import com.bailuntec.mapper.DcAutoSalesForecastStageConfigMapper;
import com.bailuntec.mapper.DcBaseOmsSkuMapper; import com.bailuntec.mapper.DcBaseOmsSkuMapper;
...@@ -15,6 +16,7 @@ import java.math.BigDecimal; ...@@ -15,6 +16,7 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.Period;
import java.util.*; import java.util.*;
/** /**
...@@ -42,13 +44,16 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService { ...@@ -42,13 +44,16 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
DcBaseOmsSkuMapper dcBaseOmsSkuMapper = session.getMapper(DcBaseOmsSkuMapper.class); DcBaseOmsSkuMapper dcBaseOmsSkuMapper = session.getMapper(DcBaseOmsSkuMapper.class);
DcAutoSalesForecastConfigMapper dcAutoSalesForecastConfigMapper = session.getMapper(DcAutoSalesForecastConfigMapper.class); DcAutoSalesForecastConfigMapper dcAutoSalesForecastConfigMapper = session.getMapper(DcAutoSalesForecastConfigMapper.class);
DcBaseOmsSku orderFirstCreateTime = dcAutoSalesForecastStageConfigMapper.firsOrder(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
Integer day = Period.between(orderFirstCreateTime.getCreateTime().toLocalDate(), LocalDateTime.now().toLocalDate()).getDays();
BigDecimal avgOrderCount30 = dcAutoSalesForecastStageConfigMapper.avgOrderCount30(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
//命中的预测规则 //命中的预测规则
DcAutoSalesForecastStageConfig dcAutoSalesForecastStageConfig = dcAutoSalesForecastStageConfigMapper.selectMatchStage(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode()); DcAutoSalesForecastStageConfig dcAutoSalesForecastStageConfig = dcAutoSalesForecastStageConfigMapper.selectMatchStage(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode(), day, avgOrderCount30);
// LocalDateTime localDateTime = dcAutoSalesForecastStageConfigMapper.selectFr
//周转天数 //周转天数
/* //每个时间段的销量预测是dcAutoSalesForecastStageConfig对应时间段的三个参数对应的过去时间段的销量的加权平均*/
* 每个时间段的销量预测是dcAutoSalesForecastStageConfig对应时间段的三个参数对应的过去时间段的销量的加权平均*/
//今天0点 //今天0点
LocalDateTime midNight = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); LocalDateTime midNight = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
...@@ -63,7 +68,11 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService { ...@@ -63,7 +68,11 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
dcAutoTurnover.setDcAutoSalesForecastStageConfigId(dcAutoSalesForecastStageConfig.getId()); dcAutoTurnover.setDcAutoSalesForecastStageConfigId(dcAutoSalesForecastStageConfig.getId());
dcAutoTurnover.setDcAutoSalesForecastTitle(dcAutoSalesForecastConfig.getTitle()); dcAutoTurnover.setDcAutoSalesForecastTitle(dcAutoSalesForecastConfig.getTitle());
log.debug("匹配到一条规则 id:{}", dcAutoSalesForecastStageConfig.getConfigId()); dcAutoTurnover.setFirstOrderDate(orderFirstCreateTime.getCreateTime());
dcAutoTurnover.setFirstOrderBailunOrderId(orderFirstCreateTime.getBailunOrderId());
dcAutoTurnover.setOrdersAvg(avgOrderCount30);
log.info("匹配到一条规则 id:{}", dcAutoSalesForecastStageConfig.getConfigId());
int duration1 = BigDecimal.valueOf(turnoverDays).multiply(dcAutoSalesForecastStageConfig.getOneRatio()).intValue(); int duration1 = BigDecimal.valueOf(turnoverDays).multiply(dcAutoSalesForecastStageConfig.getOneRatio()).intValue();
int duration2 = BigDecimal.valueOf(turnoverDays).multiply(dcAutoSalesForecastStageConfig.getTwoRatio()).intValue(); int duration2 = BigDecimal.valueOf(turnoverDays).multiply(dcAutoSalesForecastStageConfig.getTwoRatio()).intValue();
...@@ -155,8 +164,14 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService { ...@@ -155,8 +164,14 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
DcAutoSalesForecastStageConfigMapper dcAutoSalesForecastStageConfigMapper = session.getMapper(DcAutoSalesForecastStageConfigMapper.class); DcAutoSalesForecastStageConfigMapper dcAutoSalesForecastStageConfigMapper = session.getMapper(DcAutoSalesForecastStageConfigMapper.class);
DcBaseOmsSkuMapper dcBaseOmsSkuMapper = session.getMapper(DcBaseOmsSkuMapper.class); 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();
BigDecimal avgOrderCount30 = dcAutoSalesForecastStageConfigMapper.avgOrderCount30(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
//命中的预测规则 //命中的预测规则
DcAutoSalesForecastStageConfig dcAutoSalesForecastStageConfig = dcAutoSalesForecastStageConfigMapper.selectMatchStage(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode()); DcAutoSalesForecastStageConfig dcAutoSalesForecastStageConfig = dcAutoSalesForecastStageConfigMapper.selectMatchStage(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode(), day, avgOrderCount30);
//今天0点 //今天0点
LocalDateTime midNight = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); LocalDateTime midNight = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
...@@ -235,6 +250,4 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService { ...@@ -235,6 +250,4 @@ public class AutoTurnoverServiceImpl implements AutoTurnoverService {
} }
} }
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