Commit b5446692 by wutong

自动周转加入加权日均销量字段

parent be9ee0c9
......@@ -575,6 +575,15 @@ public class DcAutoTurnover {
private BigDecimal historyThirtydaySalesEbay;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_turnover.daily_weighted_sales
*
* @mbg.generated
*/
private BigDecimal dailyWeightedSales;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_turnover
*
......@@ -649,6 +658,7 @@ public class DcAutoTurnover {
sb.append(", historySevendaySalesEbay=").append(historySevendaySalesEbay);
sb.append(", historyFourteendaySalesEbay=").append(historyFourteendaySalesEbay);
sb.append(", historyThirtydaySalesEbay=").append(historyThirtydaySalesEbay);
sb.append(", dailyWeightedSales=").append(dailyWeightedSales);
sb.append("]");
return sb.toString();
}
......@@ -733,7 +743,8 @@ public class DcAutoTurnover {
&& (this.getSuppliersName() == null ? other.getSuppliersName() == null : this.getSuppliersName().equals(other.getSuppliersName()))
&& (this.getHistorySevendaySalesEbay() == null ? other.getHistorySevendaySalesEbay() == null : this.getHistorySevendaySalesEbay().equals(other.getHistorySevendaySalesEbay()))
&& (this.getHistoryFourteendaySalesEbay() == null ? other.getHistoryFourteendaySalesEbay() == null : this.getHistoryFourteendaySalesEbay().equals(other.getHistoryFourteendaySalesEbay()))
&& (this.getHistoryThirtydaySalesEbay() == null ? other.getHistoryThirtydaySalesEbay() == null : this.getHistoryThirtydaySalesEbay().equals(other.getHistoryThirtydaySalesEbay()));
&& (this.getHistoryThirtydaySalesEbay() == null ? other.getHistoryThirtydaySalesEbay() == null : this.getHistoryThirtydaySalesEbay().equals(other.getHistoryThirtydaySalesEbay()))
&& (this.getDailyWeightedSales() == null ? other.getDailyWeightedSales() == null : this.getDailyWeightedSales().equals(other.getDailyWeightedSales()));
}
/**
......@@ -809,6 +820,7 @@ public class DcAutoTurnover {
result = prime * result + ((getHistorySevendaySalesEbay() == null) ? 0 : getHistorySevendaySalesEbay().hashCode());
result = prime * result + ((getHistoryFourteendaySalesEbay() == null) ? 0 : getHistoryFourteendaySalesEbay().hashCode());
result = prime * result + ((getHistoryThirtydaySalesEbay() == null) ? 0 : getHistoryThirtydaySalesEbay().hashCode());
result = prime * result + ((getDailyWeightedSales() == null) ? 0 : getDailyWeightedSales().hashCode());
return result;
}
}
\ No newline at end of file
......@@ -4320,6 +4320,66 @@ public class DcAutoTurnoverExample {
addCriterion("history_thirtyday_sales_ebay not between", value1, value2, "historyThirtydaySalesEbay");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesIsNull() {
addCriterion("daily_weighted_sales is null");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesIsNotNull() {
addCriterion("daily_weighted_sales is not null");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesEqualTo(BigDecimal value) {
addCriterion("daily_weighted_sales =", value, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesNotEqualTo(BigDecimal value) {
addCriterion("daily_weighted_sales <>", value, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesGreaterThan(BigDecimal value) {
addCriterion("daily_weighted_sales >", value, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("daily_weighted_sales >=", value, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesLessThan(BigDecimal value) {
addCriterion("daily_weighted_sales <", value, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesLessThanOrEqualTo(BigDecimal value) {
addCriterion("daily_weighted_sales <=", value, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesIn(List<BigDecimal> values) {
addCriterion("daily_weighted_sales in", values, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesNotIn(List<BigDecimal> values) {
addCriterion("daily_weighted_sales not in", values, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("daily_weighted_sales between", value1, value2, "dailyWeightedSales");
return (Criteria) this;
}
public Criteria andDailyWeightedSalesNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("daily_weighted_sales not between", value1, value2, "dailyWeightedSales");
return (Criteria) this;
}
}
/**
......
......@@ -8,7 +8,6 @@ import com.bailuntec.domain.constant.Constant;
import com.bailuntec.domain.dto.CatagoryDTO;
import com.bailuntec.domain.dto.SalesVolumeAvgDTO;
import com.bailuntec.domain.dto.SalesVolumeDTO;
import com.bailuntec.domain.dto.TurnoverSkuDTO;
import com.bailuntec.domain.entity.*;
import com.bailuntec.domain.enumerate.PlatformType;
import com.bailuntec.domain.example.*;
......@@ -20,7 +19,9 @@ import com.bailuntec.utils.PropertiesUtil;
import com.bailuntec.utils.SessionUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
......@@ -297,7 +298,7 @@ public class AutoTurnoverJob extends PointJob {
* 可以支持配置
* 2019-04-22更新 不管逾期
*/
BigDecimal totalSafeInventory = calculateSafeInventory(bailunSku, warehouseCode, bailunFirstLevelCatagoryId, dcAutoSales, JSON.toJSONString(forecastSalesList));
BigDecimal totalSafeInventory = calculateSafeInventory(bailunSku, warehouseCode, bailunFirstLevelCatagoryId, dcAutoSales, JSON.toJSONString(forecastSalesList), dcAutoTurnover);
Integer moq = turnoverSku.getMoq();
/*
......@@ -984,7 +985,7 @@ public class AutoTurnoverJob extends PointJob {
}
private BigDecimal calculateSafeInventory(String bailunSku, String warehouseCode, Integer
bailunFirstLevelCatagoryId, DcAutoSales dcAutoSales, String forecastSalesListJson) throws Exception {
bailunFirstLevelCatagoryId, DcAutoSales dcAutoSales, String forecastSalesListJson,DcAutoTurnover dcAutoTurnover) {
/*
* 手动设置
* 1. 根据仓库 + SKU在表里找dc_auto_config_safe_inventory
......@@ -1039,6 +1040,8 @@ public class AutoTurnoverJob extends PointJob {
dcAutoConfigSafeInventory = autoConfigSafeInventoryMapper.selectOneByExample(DcAutoConfigSafeInventoryExample.newAndCreateCriteria().andVariableCodeEqualTo("").andWarehouseCodeEqualTo(warehouseCode).andStatusEqualTo(1).andTypeEqualTo(3).example());
if (dcAutoConfigSafeInventory != null) {
weightingAvgSales = caculateWeightingAvgSales(dcAutoConfigSafeInventory.getWeightingCoefficientSeven(), dcAutoConfigSafeInventory.getWeightingCoefficientFourteen(), dcAutoConfigSafeInventory.getWeightingCoefficientThirty(), historyThirtySalesList);
//进来这里就存一份没乘倍数的加权日均销量
dcAutoTurnover.setDailyWeightedSales(weightingAvgSales);
if (weightingAvgSales.compareTo(BigDecimal.ONE) == 1) {
weightingAvgSales = weightingAvgSales.multiply(dcAutoConfigSafeInventory.getParam()).setScale(3, RoundingMode.HALF_EVEN);
} else {
......@@ -1047,6 +1050,7 @@ public class AutoTurnoverJob extends PointJob {
} else {
//啥配置都没有就给个默认取值
weightingAvgSales = caculateWeightingAvgSales(BigDecimal.valueOf(0.3), BigDecimal.valueOf(0.3), BigDecimal.valueOf(0.4), historyThirtySalesList);
dcAutoTurnover.setDailyWeightedSales(weightingAvgSales);
}
}
}
......
......@@ -69,6 +69,7 @@
<result column="history_sevenday_sales_ebay" jdbcType="DECIMAL" property="historySevendaySalesEbay" />
<result column="history_fourteenday_sales_ebay" jdbcType="DECIMAL" property="historyFourteendaySalesEbay" />
<result column="history_thirtyday_sales_ebay" jdbcType="DECIMAL" property="historyThirtydaySalesEbay" />
<result column="daily_weighted_sales" jdbcType="DECIMAL" property="dailyWeightedSales" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
......@@ -154,7 +155,7 @@
history_thirtyday_sales, sales_explain_details, forecast_turnoverday_sales, stock_up_sales,
quantity_begin_advise, stock_up_days, payment_before_delivery, product_code, product_inner_code,
bailun_category_id, buyer_name, suppliers_name, history_sevenday_sales_ebay, history_fourteenday_sales_ebay,
history_thirtyday_sales_ebay
history_thirtyday_sales_ebay, daily_weighted_sales
</sql>
<select id="selectByExample" parameterType="com.bailuntec.domain.example.DcAutoTurnoverExample" resultMap="BaseResultMap">
<!--
......@@ -239,7 +240,8 @@
payment_before_delivery, product_code, product_inner_code,
bailun_category_id, buyer_name, suppliers_name,
history_sevenday_sales_ebay, history_fourteenday_sales_ebay,
history_thirtyday_sales_ebay)
history_thirtyday_sales_ebay, daily_weighted_sales
)
values (#{id,jdbcType=INTEGER}, #{purchaseAdviceId,jdbcType=VARCHAR}, #{bailunSku,jdbcType=VARCHAR},
#{warehouseCode,jdbcType=VARCHAR}, #{quantityInitAdvise,jdbcType=DECIMAL}, #{quantityMinimumOrder,jdbcType=INTEGER},
#{quantityFinalAdvise,jdbcType=DECIMAL}, #{warehouseName,jdbcType=VARCHAR}, #{quantityPromotion,jdbcType=INTEGER},
......@@ -264,7 +266,8 @@
#{paymentBeforeDelivery,jdbcType=INTEGER}, #{productCode,jdbcType=VARCHAR}, #{productInnerCode,jdbcType=VARCHAR},
#{bailunCategoryId,jdbcType=INTEGER}, #{buyerName,jdbcType=VARCHAR}, #{suppliersName,jdbcType=VARCHAR},
#{historySevendaySalesEbay,jdbcType=DECIMAL}, #{historyFourteendaySalesEbay,jdbcType=DECIMAL},
#{historyThirtydaySalesEbay,jdbcType=DECIMAL})
#{historyThirtydaySalesEbay,jdbcType=DECIMAL}, #{dailyWeightedSales,jdbcType=DECIMAL}
)
</insert>
<insert id="insertSelective" parameterType="com.bailuntec.domain.entity.DcAutoTurnover">
<!--
......@@ -462,6 +465,9 @@
<if test="historyThirtydaySalesEbay != null">
history_thirtyday_sales_ebay,
</if>
<if test="dailyWeightedSales != null">
daily_weighted_sales,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -653,6 +659,9 @@
<if test="historyThirtydaySalesEbay != null">
#{historyThirtydaySalesEbay,jdbcType=DECIMAL},
</if>
<if test="dailyWeightedSales != null">
#{dailyWeightedSales,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.bailuntec.domain.example.DcAutoTurnoverExample" resultType="java.lang.Long">
......@@ -861,6 +870,9 @@
<if test="record.historyThirtydaySalesEbay != null">
history_thirtyday_sales_ebay = #{record.historyThirtydaySalesEbay,jdbcType=DECIMAL},
</if>
<if test="record.dailyWeightedSales != null">
daily_weighted_sales = #{record.dailyWeightedSales,jdbcType=DECIMAL},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -934,7 +946,8 @@
suppliers_name = #{record.suppliersName,jdbcType=VARCHAR},
history_sevenday_sales_ebay = #{record.historySevendaySalesEbay,jdbcType=DECIMAL},
history_fourteenday_sales_ebay = #{record.historyFourteendaySalesEbay,jdbcType=DECIMAL},
history_thirtyday_sales_ebay = #{record.historyThirtydaySalesEbay,jdbcType=DECIMAL}
history_thirtyday_sales_ebay = #{record.historyThirtydaySalesEbay,jdbcType=DECIMAL},
daily_weighted_sales = #{record.dailyWeightedSales,jdbcType=DECIMAL}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -1132,6 +1145,9 @@
<if test="historyThirtydaySalesEbay != null">
history_thirtyday_sales_ebay = #{historyThirtydaySalesEbay,jdbcType=DECIMAL},
</if>
<if test="dailyWeightedSales != null">
daily_weighted_sales = #{dailyWeightedSales,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......@@ -1202,7 +1218,8 @@
suppliers_name = #{suppliersName,jdbcType=VARCHAR},
history_sevenday_sales_ebay = #{historySevendaySalesEbay,jdbcType=DECIMAL},
history_fourteenday_sales_ebay = #{historyFourteendaySalesEbay,jdbcType=DECIMAL},
history_thirtyday_sales_ebay = #{historyThirtydaySalesEbay,jdbcType=DECIMAL}
history_thirtyday_sales_ebay = #{historyThirtydaySalesEbay,jdbcType=DECIMAL},
daily_weighted_sales = #{dailyWeightedSales,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
<insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcAutoTurnover">
......@@ -1402,6 +1419,9 @@
<if test="historyThirtydaySalesEbay != null">
history_thirtyday_sales_ebay,
</if>
<if test="dailyWeightedSales != null">
daily_weighted_sales,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -1594,6 +1614,9 @@
<if test="historyThirtydaySalesEbay != null">
#{historyThirtydaySalesEbay,jdbcType=DECIMAL},
</if>
<if test="dailyWeightedSales != null">
#{dailyWeightedSales,jdbcType=DECIMAL},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
......@@ -1786,6 +1809,9 @@
<if test="historyThirtydaySalesEbay != null">
history_thirtyday_sales_ebay = #{historyThirtydaySalesEbay,jdbcType=DECIMAL},
</if>
<if test="dailyWeightedSales != null">
daily_weighted_sales = #{dailyWeightedSales,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<insert id="upsert" parameterType="com.bailuntec.domain.entity.DcAutoTurnover">
......@@ -1809,7 +1835,7 @@
forecast_turnoverday_sales, stock_up_sales, quantity_begin_advise, stock_up_days,
payment_before_delivery, product_code, product_inner_code, bailun_category_id,
buyer_name, suppliers_name, history_sevenday_sales_ebay, history_fourteenday_sales_ebay,
history_thirtyday_sales_ebay)
history_thirtyday_sales_ebay, daily_weighted_sales)
values
(#{id,jdbcType=INTEGER}, #{purchaseAdviceId,jdbcType=VARCHAR}, #{bailunSku,jdbcType=VARCHAR},
#{warehouseCode,jdbcType=VARCHAR}, #{quantityInitAdvise,jdbcType=DECIMAL}, #{quantityMinimumOrder,jdbcType=INTEGER},
......@@ -1835,7 +1861,8 @@
#{paymentBeforeDelivery,jdbcType=INTEGER}, #{productCode,jdbcType=VARCHAR}, #{productInnerCode,jdbcType=VARCHAR},
#{bailunCategoryId,jdbcType=INTEGER}, #{buyerName,jdbcType=VARCHAR}, #{suppliersName,jdbcType=VARCHAR},
#{historySevendaySalesEbay,jdbcType=DECIMAL}, #{historyFourteendaySalesEbay,jdbcType=DECIMAL},
#{historyThirtydaySalesEbay,jdbcType=DECIMAL})
#{historyThirtydaySalesEbay,jdbcType=DECIMAL}, #{dailyWeightedSales,jdbcType=DECIMAL}
)
on duplicate key update
id = #{id,jdbcType=INTEGER},
purchase_advice_id = #{purchaseAdviceId,jdbcType=VARCHAR},
......@@ -1899,7 +1926,8 @@
suppliers_name = #{suppliersName,jdbcType=VARCHAR},
history_sevenday_sales_ebay = #{historySevendaySalesEbay,jdbcType=DECIMAL},
history_fourteenday_sales_ebay = #{historyFourteendaySalesEbay,jdbcType=DECIMAL},
history_thirtyday_sales_ebay = #{historyThirtydaySalesEbay,jdbcType=DECIMAL}
history_thirtyday_sales_ebay = #{historyThirtydaySalesEbay,jdbcType=DECIMAL},
daily_weighted_sales = #{dailyWeightedSales,jdbcType=DECIMAL}
</insert>
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcAutoTurnoverExample" resultMap="BaseResultMap">
<!--
......@@ -1920,6 +1948,7 @@
</select>
<delete id="truncateAutoInboundTable">
TRUNCATE dc_auto_inbound
</delete>
......
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