Commit 6784d946 by huluobin

采购在途 周转

parent 1a831e4f
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
<groupId>com.bailuntec</groupId> <groupId>com.bailuntec</groupId>
<artifactId>data-common</artifactId> <artifactId>data-common</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.github.linus87</groupId> <groupId>io.github.linus87</groupId>
<artifactId>ebaycalls</artifactId> <artifactId>ebaycalls</artifactId>
......
package com.bailuntec.job; package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.bailuntec.domain.constant.CommonConstant; import com.bailuntec.domain.constant.CommonConstant;
import com.bailuntec.domain.constant.Constant; import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.entity.*; import com.bailuntec.mapper.DcBaseOmsSku30Mapper;
import com.bailuntec.domain.enumerate.OrderExceptionStatus;
import com.bailuntec.domain.enumerate.OrderExceptionType;
import com.bailuntec.domain.enumerate.PlatformType;
import com.bailuntec.domain.example.*;
import com.bailuntec.domain.pojo.*;
import com.bailuntec.mapper.*;
import com.bailuntec.support.CallBailunSystem;
import com.bailuntec.support.PointJob; import com.bailuntec.support.PointJob;
import com.bailuntec.utils.ExceptionUtil;
import com.bailuntec.utils.OkHttpUtil;
import com.bailuntec.utils.PropertiesUtil;
import com.bailuntec.utils.SessionUtil; import com.bailuntec.utils.SessionUtil;
import com.dangdang.ddframe.job.api.ShardingContext; import com.dangdang.ddframe.job.api.ShardingContext;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient; import org.apache.ibatis.session.SqlSession;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
public class OrderSyncJob30 extends PointJob { public class OrderSyncJob30 extends PointJob {
...@@ -42,7 +18,14 @@ public class OrderSyncJob30 extends PointJob { ...@@ -42,7 +18,14 @@ public class OrderSyncJob30 extends PointJob {
@Override @Override
public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) { public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) {
String queryTime = DateTimeFormatter.ofPattern(CommonConstant.DATE_FORMAT).format(LocalDate.now()); String queryTime = DateTimeFormatter.ofPattern(CommonConstant.DATE_FORMAT).format(LocalDate.now());
DcBaseOmsSku30Mapper dcBaseOmsSku30Mapper = SessionUtil.getSession().getMapper(DcBaseOmsSku30Mapper.class);
SqlSession sqlSession = SessionUtil.getFactory().openSession(true);
DcBaseOmsSku30Mapper dcBaseOmsSku30Mapper = sqlSession.getMapper(DcBaseOmsSku30Mapper.class);
try {
dcBaseOmsSku30Mapper.truncateTable();
dcBaseOmsSku30Mapper.upsertByOmsSku(queryTime); dcBaseOmsSku30Mapper.upsertByOmsSku(queryTime);
} finally {
sqlSession.close();
}
} }
} }
...@@ -57,9 +57,8 @@ public class OrderSyncJobTest { ...@@ -57,9 +57,8 @@ public class OrderSyncJobTest {
@Test @Test
public void testBigDecimal() { public void testBigDecimal() {
BigDecimal totalCost = BigDecimal.ONE; OrderSyncJob30 orderSyncJob30 = new OrderSyncJob30();
totalCost = this.calc(totalCost); orderSyncJob30.executeJob(null, null);
System.out.println(totalCost);
} }
......
package com.bailuntec.domain.dto;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/11/28 3:56 下午
*/
@Data
public class SalesDetailItem {
private BigDecimal sales;
private LocalDate date;
private BigDecimal weekCoefficient;
private BigDecimal salesDayConfig;
private String bailunSku;
private String warehouseCode;
private BigDecimal showSales;
public void calcShowSales() {
this.showSales = sales;
if (salesDayConfig != null) {
this.showSales = salesDayConfig;
}
if (weekCoefficient != null) {
this.showSales = showSales.multiply(weekCoefficient);
}
}
}
package com.bailuntec.domain.entity; package com.bailuntec.domain.entity;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import lombok.Data; import lombok.Data;
...@@ -77,6 +78,9 @@ public class DcBaseWeekCoefficient { ...@@ -77,6 +78,9 @@ public class DcBaseWeekCoefficient {
*/ */
private String formula; private String formula;
private LocalDate weekDate;
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_week_coefficient * This method corresponds to the database table dc_base_week_coefficient
......
...@@ -123,4 +123,6 @@ public interface DcBaseOmsSku30Mapper { ...@@ -123,4 +123,6 @@ public interface DcBaseOmsSku30Mapper {
int upsertSelective(DcBaseOmsSku30 record); int upsertSelective(DcBaseOmsSku30 record);
int upsertByOmsSku(@Param("queryTime")String queryTime); int upsertByOmsSku(@Param("queryTime")String queryTime);
void truncateTable();
} }
...@@ -3494,118 +3494,122 @@ ...@@ -3494,118 +3494,122 @@
where pay_time &gt;= DATE_SUB(#{queryTime}, INTERVAL 31 DAY) where pay_time &gt;= DATE_SUB(#{queryTime}, INTERVAL 31 DAY)
and pay_time &lt; #{queryTime} and pay_time &lt; #{queryTime}
on duplicate key update on duplicate key update
origin_order_id = values(origin_order_id), origin_order_id = values(origin_order_id),
platform_type = values(platform_type), platform_type = values(platform_type),
transaction_id = values(transaction_id), transaction_id = values(transaction_id),
pay_time = values(pay_time), pay_time = values(pay_time),
pay_method = values(pay_method), pay_method = values(pay_method),
pay_account = values(pay_account), pay_account = values(pay_account),
pay_status = values(pay_status), pay_status = values(pay_status),
collection_account = values(collection_account), collection_account = values(collection_account),
platform_order_type = values(platform_order_type), platform_order_type = values(platform_order_type),
website = values(website), website = values(website),
create_time = values(create_time), create_time = values(create_time),
paid_time = values(paid_time), paid_time = values(paid_time),
refund_time = values(refund_time), refund_time = values(refund_time),
seller_id = values(seller_id), seller_id = values(seller_id),
bailun_account_id = values(bailun_account_id), bailun_account_id = values(bailun_account_id),
hq_account = values(hq_account), hq_account = values(hq_account),
seller_account = values(seller_account), seller_account = values(seller_account),
seller_order_id = values(seller_order_id), seller_order_id = values(seller_order_id),
seller_email = values(seller_email), seller_email = values(seller_email),
order_update_time = values(order_update_time), order_update_time = values(order_update_time),
seller_order_exchange_rate = values(seller_order_exchange_rate), seller_order_exchange_rate = values(seller_order_exchange_rate),
seller_other_exchange_rate = values(seller_other_exchange_rate), seller_other_exchange_rate = values(seller_other_exchange_rate),
finance_order_exchange_rate = values(finance_order_exchange_rate), finance_order_exchange_rate = values(finance_order_exchange_rate),
finance_other_exchange_rate = values(finance_other_exchange_rate), finance_other_exchange_rate = values(finance_other_exchange_rate),
cny_to_usd_exchange_rate = values(cny_to_usd_exchange_rate), cny_to_usd_exchange_rate = values(cny_to_usd_exchange_rate),
order_to_usd_exchange_rate = values(order_to_usd_exchange_rate), order_to_usd_exchange_rate = values(order_to_usd_exchange_rate),
other_to_usd_exchange_rate = values(other_to_usd_exchange_rate), other_to_usd_exchange_rate = values(other_to_usd_exchange_rate),
order_currency = values(order_currency), order_currency = values(order_currency),
other_currency = values(other_currency), other_currency = values(other_currency),
seller_name = values(seller_name), seller_name = values(seller_name),
bailun_order_id = values(bailun_order_id), bailun_order_id = values(bailun_order_id),
platform_order_status = values(platform_order_status), platform_order_status = values(platform_order_status),
bailun_order_status = values(bailun_order_status), bailun_order_status = values(bailun_order_status),
bailun_payment_status = values(bailun_payment_status), bailun_payment_status = values(bailun_payment_status),
bailun_interception_status = values(bailun_interception_status), bailun_interception_status = values(bailun_interception_status),
shipping_status = values(shipping_status), shipping_status = values(shipping_status),
bailun_sku = values(bailun_sku), bailun_sku = values(bailun_sku),
bailun_sku_title_en = values(bailun_sku_title_en), bailun_sku_title_en = values(bailun_sku_title_en),
bailun_sku_title_cn = values(bailun_sku_title_cn), bailun_sku_title_cn = values(bailun_sku_title_cn),
bailun_sku_quantity_ordered = values(bailun_sku_quantity_ordered), bailun_sku_quantity_ordered = values(bailun_sku_quantity_ordered),
bailun_sku_quantity_shipped = values(bailun_sku_quantity_shipped), bailun_sku_quantity_shipped = values(bailun_sku_quantity_shipped),
bailun_sku_quantity_refund = values(bailun_sku_quantity_refund), bailun_sku_quantity_refund = values(bailun_sku_quantity_refund),
bailun_sku_quantity_picked = values(bailun_sku_quantity_picked), bailun_sku_quantity_picked = values(bailun_sku_quantity_picked),
warehouse_name = values(warehouse_name), warehouse_name = values(warehouse_name),
warehouse_code_fba = values(warehouse_code_fba), warehouse_code_fba = values(warehouse_code_fba),
warehouse_code = values(warehouse_code), warehouse_code = values(warehouse_code),
bailun_sku_unit_price = values(bailun_sku_unit_price), bailun_sku_unit_price = values(bailun_sku_unit_price),
bailun_sku_weight = values(bailun_sku_weight), bailun_sku_weight = values(bailun_sku_weight),
bailun_sku_size = values(bailun_sku_size), bailun_sku_size = values(bailun_sku_size),
amount_sales = values(amount_sales), amount_sales = values(amount_sales),
amount_total = values(amount_total), amount_total = values(amount_total),
amount_shipping = values(amount_shipping), amount_shipping = values(amount_shipping),
amount_product = values(amount_product), amount_product = values(amount_product),
amount_tax = values(amount_tax), amount_tax = values(amount_tax),
amount_adjustment = values(amount_adjustment), amount_adjustment = values(amount_adjustment),
amount_gift_wrap = values(amount_gift_wrap), amount_gift_wrap = values(amount_gift_wrap),
amount_refund = values(amount_refund), amount_refund = values(amount_refund),
amount_prepaid = values(amount_prepaid), amount_prepaid = values(amount_prepaid),
cost_total = values(cost_total), cost_total = values(cost_total),
cost_promotion = values(cost_promotion), cost_promotion = values(cost_promotion),
cost_platform_fee = values(cost_platform_fee), cost_platform_fee = values(cost_platform_fee),
cost_product = values(cost_product), cost_product = values(cost_product),
cost_shipping = values(cost_shipping), cost_shipping = values(cost_shipping),
cost_package = values(cost_package), cost_package = values(cost_package),
cost_fba_fee = values(cost_fba_fee), cost_fba_fee = values(cost_fba_fee),
cost_paypal_fee = values(cost_paypal_fee), cost_paypal_fee = values(cost_paypal_fee),
cost_refund_commisson = values(cost_refund_commisson), cost_refund_commisson = values(cost_refund_commisson),
cost_handle_bailun = values(cost_handle_bailun), cost_handle_bailun = values(cost_handle_bailun),
cost_handle_platform = values(cost_handle_platform), cost_handle_platform = values(cost_handle_platform),
cost_tail = values(cost_tail), cost_tail = values(cost_tail),
cost_first = values(cost_first), cost_first = values(cost_first),
cost_logistics = values(cost_logistics), cost_logistics = values(cost_logistics),
profit_total = values(profit_total), profit_total = values(profit_total),
profit_rate = values(profit_rate), profit_rate = values(profit_rate),
receipt_country = values(receipt_country), receipt_country = values(receipt_country),
receipt_city = values(receipt_city), receipt_city = values(receipt_city),
receipt_area = values(receipt_area), receipt_area = values(receipt_area),
receipt_address = values(receipt_address), receipt_address = values(receipt_address),
receipt_address_2 = values(receipt_address_2), receipt_address_2 = values(receipt_address_2),
receipt_postal_code = values(receipt_postal_code), receipt_postal_code = values(receipt_postal_code),
receiver = values(receiver), receiver = values(receiver),
receiver_phone = values(receiver_phone), receiver_phone = values(receiver_phone),
buyer_id = values(buyer_id), buyer_id = values(buyer_id),
buyer_name = values(buyer_name), buyer_name = values(buyer_name),
buyer_email = values(buyer_email), buyer_email = values(buyer_email),
has_fba_exception = values(has_fba_exception), has_fba_exception = values(has_fba_exception),
has_platform_exception = values(has_platform_exception), has_platform_exception = values(has_platform_exception),
has_cancle = values(has_cancle), has_cancle = values(has_cancle),
area_id = values(area_id), area_id = values(area_id),
bailun_category_id = values(bailun_category_id), bailun_category_id = values(bailun_category_id),
bailun_category_name = values(bailun_category_name), bailun_category_name = values(bailun_category_name),
gmt_create = values(gmt_create), gmt_create = values(gmt_create),
gmt_modified = values(gmt_modified), gmt_modified = values(gmt_modified),
ratio_weight = values(ratio_weight), ratio_weight = values(ratio_weight),
ratio_price = values(ratio_price), ratio_price = values(ratio_price),
bailun_picking_status = values(bailun_picking_status), bailun_picking_status = values(bailun_picking_status),
bailun_require_logistics = values(bailun_require_logistics), bailun_require_logistics = values(bailun_require_logistics),
has_delete = values(has_delete), has_delete = values(has_delete),
has_scalp = values(has_scalp), has_scalp = values(has_scalp),
has_buyer_remark = values(has_buyer_remark), has_buyer_remark = values(has_buyer_remark),
has_platsku_remark = values(has_platsku_remark), has_platsku_remark = values(has_platsku_remark),
logistics_method_code = values(logistics_method_code), logistics_method_code = values(logistics_method_code),
logistics_method_name = values(logistics_method_name), logistics_method_name = values(logistics_method_name),
has_innersale = values(has_innersale), has_innersale = values(has_innersale),
company_id = values(company_id), company_id = values(company_id),
bailun_refund_status = values(bailun_refund_status), bailun_refund_status = values(bailun_refund_status),
refund_obj = values(refund_obj), refund_obj = values(refund_obj),
refund_type = values(refund_type), refund_type = values(refund_type),
refund_reference_id = values(refund_reference_id), refund_reference_id = values(refund_reference_id),
has_fba_s = values(has_fba_s), has_fba_s = values(has_fba_s),
bailun_sku_quantity_pushed = values(bailun_sku_quantity_pushed), bailun_sku_quantity_pushed = values(bailun_sku_quantity_pushed),
amount_general_cargo = values(amount_general_cargo), amount_general_cargo = values(amount_general_cargo),
has_transfer_order = values(has_transfer_order) has_transfer_order = values(has_transfer_order)
</update> </update>
<delete id="truncateTable">
delete from dc_base_oms_sku_30
</delete>
</mapper> </mapper>
...@@ -1387,7 +1387,8 @@ ...@@ -1387,7 +1387,8 @@
on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
where (t2.`status` = 0 or t2.`status` is null) where (t2.`status` = 0 or t2.`status` is null)
and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem} and t1.id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
order by t1.id desc order by t1.id
# desc
limit #{pageStart}, #{pageOffset}; limit #{pageStart}, #{pageOffset};
</select> </select>
......
package com.bailuntec.mapper; package com.bailuntec.mapper;
import com.bailuntec.domain.dto.SalesDetailItem;
import com.bailuntec.domain.entity.DcBaseWeekCoefficient; import com.bailuntec.domain.entity.DcBaseWeekCoefficient;
import com.bailuntec.domain.example.DcBaseWeekCoefficientExample; import com.bailuntec.domain.example.DcBaseWeekCoefficientExample;
import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcBaseWeekCoefficientMapper { public interface DcBaseWeekCoefficientMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
...@@ -120,4 +122,9 @@ public interface DcBaseWeekCoefficientMapper { ...@@ -120,4 +122,9 @@ public interface DcBaseWeekCoefficientMapper {
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
int upsertSelective(DcBaseWeekCoefficient record); int upsertSelective(DcBaseWeekCoefficient record);
List<DcBaseWeekCoefficient> selectByDays(@Param("salesDetailItemList") List<SalesDetailItem> salesDetailItemList,
@Param("bailunSku") String bailunSku,
@Param("warehouseCode") String warehouseCode);
} }
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
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="bailun_sku_warehouse_code" jdbcType="VARCHAR" property="bailunSkuWarehouseCode" /> <result column="bailun_sku_warehouse_code" jdbcType="VARCHAR" property="bailunSkuWarehouseCode"/>
<result column="week" jdbcType="INTEGER" property="week" /> <result column="week" jdbcType="INTEGER" property="week"/>
<result column="coefficient" jdbcType="VARCHAR" property="coefficient" /> <result column="coefficient" jdbcType="VARCHAR" property="coefficient"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="formula" jdbcType="VARCHAR" property="formula" /> <result column="formula" jdbcType="VARCHAR" property="formula"/>
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!-- <!--
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,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>
...@@ -70,7 +71,8 @@ ...@@ -70,7 +71,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>
...@@ -89,7 +91,8 @@ ...@@ -89,7 +91,8 @@
id, bailun_sku, warehouse_code, bailun_sku_warehouse_code, week, coefficient, update_date, id, bailun_sku, warehouse_code, bailun_sku_warehouse_code, week, coefficient, update_date,
formula formula
</sql> </sql>
<select id="selectByExample" parameterType="com.bailuntec.domain.example.DcBaseWeekCoefficientExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.bailuntec.domain.example.DcBaseWeekCoefficientExample"
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.
...@@ -98,10 +101,10 @@ ...@@ -98,10 +101,10 @@
<if test="distinct"> <if test="distinct">
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
from dc_base_week_coefficient from dc_base_week_coefficient
<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}
...@@ -121,7 +124,7 @@ ...@@ -121,7 +124,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_base_week_coefficient from dc_base_week_coefficient
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
...@@ -140,7 +143,7 @@ ...@@ -140,7 +143,7 @@
--> -->
delete from dc_base_week_coefficient delete from dc_base_week_coefficient
<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.DcBaseWeekCoefficient"> <insert id="insert" parameterType="com.bailuntec.domain.entity.DcBaseWeekCoefficient">
...@@ -214,14 +217,15 @@ ...@@ -214,14 +217,15 @@
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.bailuntec.domain.example.DcBaseWeekCoefficientExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.bailuntec.domain.example.DcBaseWeekCoefficientExample"
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_base_week_coefficient select count(*) from dc_base_week_coefficient
<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">
...@@ -257,7 +261,7 @@ ...@@ -257,7 +261,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">
...@@ -275,7 +279,7 @@ ...@@ -275,7 +279,7 @@
update_date = #{record.updateDate,jdbcType=TIMESTAMP}, update_date = #{record.updateDate,jdbcType=TIMESTAMP},
formula = #{record.formula,jdbcType=VARCHAR} formula = #{record.formula,jdbcType=VARCHAR}
<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.DcBaseWeekCoefficient"> <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcBaseWeekCoefficient">
...@@ -435,21 +439,32 @@ ...@@ -435,21 +439,32 @@
update_date = #{updateDate,jdbcType=TIMESTAMP}, update_date = #{updateDate,jdbcType=TIMESTAMP},
formula = #{formula,jdbcType=VARCHAR} formula = #{formula,jdbcType=VARCHAR}
</insert> </insert>
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcBaseWeekCoefficientExample" resultMap="BaseResultMap"> <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcBaseWeekCoefficientExample"
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_base_week_coefficient from dc_base_week_coefficient
<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}
</if> </if>
limit 1 limit 1
</select> </select>
<select id="selectByDays" resultType="com.bailuntec.domain.entity.DcBaseWeekCoefficient">
SELECT t2.*,t1.week_date from week_config t1
LEFT JOIN dc_base_week_coefficient t2
on t1.`week` = t2.`week` and t2.bailun_sku = #{bailunSku} and t2.warehouse_code = #{warehouseCode}
and t1.week_date in
<foreach close=")" collection="salesDetailItemList" item="item" open="(" separator=",">
#{item.date}
</foreach>
</select>
</mapper> </mapper>
...@@ -860,7 +860,7 @@ ...@@ -860,7 +860,7 @@
price, price,
transport_type transport_type
FROM dc_base_purchase FROM dc_base_purchase
WHERE buy_status IN (0, 1, 2, 3) WHERE buy_status IN (0, 1, 2, 3,9)
AND has_delete = 0 AND has_delete = 0
GROUP BY bailun_sku, GROUP BY bailun_sku,
parent_id parent_id
......
package com.bailuntec.mapper; package com.bailuntec.mapper;
import com.bailuntec.domain.dto.SalesDetailItem;
import com.bailuntec.domain.entity.SalesDayConfig; import com.bailuntec.domain.entity.SalesDayConfig;
import com.bailuntec.domain.example.SalesDayConfigExample; import com.bailuntec.domain.example.SalesDayConfigExample;
import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SalesDayConfigMapper { public interface SalesDayConfigMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
...@@ -120,4 +122,9 @@ public interface SalesDayConfigMapper { ...@@ -120,4 +122,9 @@ public interface SalesDayConfigMapper {
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
int upsertSelective(SalesDayConfig record); int upsertSelective(SalesDayConfig record);
List<SalesDayConfig> selectByDays(@Param("salesDetailItemList") List<SalesDetailItem> salesDetailItemList,
@Param("bailunSku") String bailunSku,
@Param("warehouseCode") String warehouseCode);
} }
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
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="bailun_sku_warehouse_code" jdbcType="VARCHAR" property="bailunSkuWarehouseCode" /> <result column="bailun_sku_warehouse_code" jdbcType="VARCHAR" property="bailunSkuWarehouseCode"/>
<result column="date" jdbcType="TIMESTAMP" property="date" /> <result column="date" jdbcType="TIMESTAMP" property="date"/>
<result column="date_str" jdbcType="VARCHAR" property="dateStr" /> <result column="date_str" jdbcType="VARCHAR" property="dateStr"/>
<result column="sales" jdbcType="DECIMAL" property="sales" /> <result column="sales" jdbcType="DECIMAL" property="sales"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="create_user" jdbcType="VARCHAR" property="createUser" /> <result column="create_user" jdbcType="VARCHAR" property="createUser"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="update_user" jdbcType="VARCHAR" property="updateUser" /> <result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!-- <!--
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,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>
...@@ -73,7 +74,8 @@ ...@@ -73,7 +74,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>
...@@ -92,7 +94,8 @@ ...@@ -92,7 +94,8 @@
id, bailun_sku, warehouse_code, bailun_sku_warehouse_code, date, date_str, sales, id, bailun_sku, warehouse_code, bailun_sku_warehouse_code, date, date_str, sales,
create_date, create_user, update_date, update_user create_date, create_user, update_date, update_user
</sql> </sql>
<select id="selectByExample" parameterType="com.bailuntec.domain.example.SalesDayConfigExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.bailuntec.domain.example.SalesDayConfigExample"
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.
...@@ -101,10 +104,10 @@ ...@@ -101,10 +104,10 @@
<if test="distinct"> <if test="distinct">
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List"/>
from sales_day_config from sales_day_config
<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}
...@@ -124,7 +127,7 @@ ...@@ -124,7 +127,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 sales_day_config from sales_day_config
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
...@@ -143,7 +146,7 @@ ...@@ -143,7 +146,7 @@
--> -->
delete from sales_day_config delete from sales_day_config
<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.SalesDayConfig"> <insert id="insert" parameterType="com.bailuntec.domain.entity.SalesDayConfig">
...@@ -237,14 +240,15 @@ ...@@ -237,14 +240,15 @@
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.bailuntec.domain.example.SalesDayConfigExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.bailuntec.domain.example.SalesDayConfigExample"
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 sales_day_config select count(*) from sales_day_config
<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">
...@@ -289,7 +293,7 @@ ...@@ -289,7 +293,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">
...@@ -310,7 +314,7 @@ ...@@ -310,7 +314,7 @@
update_date = #{record.updateDate,jdbcType=TIMESTAMP}, update_date = #{record.updateDate,jdbcType=TIMESTAMP},
update_user = #{record.updateUser,jdbcType=VARCHAR} update_user = #{record.updateUser,jdbcType=VARCHAR}
<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.SalesDayConfig"> <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.SalesDayConfig">
...@@ -513,21 +517,34 @@ ...@@ -513,21 +517,34 @@
update_date = #{updateDate,jdbcType=TIMESTAMP}, update_date = #{updateDate,jdbcType=TIMESTAMP},
update_user = #{updateUser,jdbcType=VARCHAR} update_user = #{updateUser,jdbcType=VARCHAR}
</insert> </insert>
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.SalesDayConfigExample" resultMap="BaseResultMap">
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.SalesDayConfigExample"
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 sales_day_config from sales_day_config
<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}
</if> </if>
limit 1 limit 1
</select> </select>
<select id="selectByDays" resultType="com.bailuntec.domain.entity.SalesDayConfig">
SELECT * from week_config t1
LEFT JOIN sales_day_config t2
on t1.`week_date` = t2.date and t2.bailun_sku = #{bailunSku} and t2.warehouse_code = #{warehouseCode}
and t1.week_date in
<foreach close=")" collection="salesDetailItemList" item="item" open="(" separator=",">
#{item.date}
</foreach>
</select>
</mapper> </mapper>
...@@ -98,6 +98,17 @@ ...@@ -98,6 +98,17 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
<!--测试用例插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- 跳过测试-->
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -104,8 +104,8 @@ public class BalanceSheetServiceTest { ...@@ -104,8 +104,8 @@ public class BalanceSheetServiceTest {
@Test @Test
public void generateBalanceSheet() { public void generateBalanceSheet() {
Date startDate = DateTimeUtil.stringToDate("2020-10-19", DateTimeUtil.DATE_FORMAT); Date startDate = DateTimeUtil.stringToDate("2020-11-26", DateTimeUtil.DATE_FORMAT);
Date endDate = DateTimeUtil.stringToDate("2020-11-02", DateTimeUtil.DATE_FORMAT); Date endDate = DateTimeUtil.stringToDate("2020-11-26", DateTimeUtil.DATE_FORMAT);
while (startDate.compareTo(endDate) == -1) { while (startDate.compareTo(endDate) == -1) {
balanceSheetService.generateBalanceSheet(0, "百伦供应链", startDate); balanceSheetService.generateBalanceSheet(0, "百伦供应链", startDate);
startDate = DateTimeUtil.addDays(startDate, 1); // 日期增加一天 startDate = DateTimeUtil.addDays(startDate, 1); // 日期增加一天
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
<version>2.1.1</version> <version>2.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
...@@ -45,8 +44,8 @@ ...@@ -45,8 +44,8 @@
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
...@@ -89,7 +88,8 @@ ...@@ -89,7 +88,8 @@
<!--镜像名称:镜像版本--> <!--镜像名称:镜像版本-->
<skipDockerBuild>false</skipDockerBuild> <skipDockerBuild>false</skipDockerBuild>
<imageName>ccr.ccs.tencentyun.com/blt.data.center/dc-show-auto-turnover:${maven.build.timestamp}</imageName> <imageName>ccr.ccs.tencentyun.com/blt.data.center/dc-show-auto-turnover:${maven.build.timestamp}
</imageName>
<dockerDirectory>src/main/docker</dockerDirectory> <dockerDirectory>src/main/docker</dockerDirectory>
<resources> <resources>
<resource> <resource>
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.bailuntec.domain.constant.CommonConstant; import com.bailuntec.domain.constant.CommonConstant;
import com.bailuntec.domain.constant.Constant; import com.bailuntec.domain.constant.Constant;
import com.bailuntec.domain.dto.SalesDetailItem;
import com.bailuntec.domain.dto.SalesVolumeAvgDTO; import com.bailuntec.domain.dto.SalesVolumeAvgDTO;
import com.bailuntec.domain.dto.SalesVolumeDTO; import com.bailuntec.domain.dto.SalesVolumeDTO;
import com.bailuntec.domain.entity.*; import com.bailuntec.domain.entity.*;
...@@ -21,6 +22,7 @@ import com.bailuntec.utils.OkHttpUtil; ...@@ -21,6 +22,7 @@ import com.bailuntec.utils.OkHttpUtil;
import com.bailuntec.utils.PropertiesUtil; import com.bailuntec.utils.PropertiesUtil;
import com.bailuntec.utils.SessionUtil; import com.bailuntec.utils.SessionUtil;
import com.dangdang.ddframe.job.api.ShardingContext; import com.dangdang.ddframe.job.api.ShardingContext;
import com.google.common.collect.Lists;
import com.google.gson.Gson; import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
...@@ -40,6 +42,8 @@ import java.time.format.DateTimeFormatter; ...@@ -40,6 +42,8 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Slf4j @Slf4j
public class AutoTurnoverJob extends PointJob { public class AutoTurnoverJob extends PointJob {
...@@ -218,7 +222,6 @@ public class AutoTurnoverJob extends PointJob { ...@@ -218,7 +222,6 @@ public class AutoTurnoverJob extends PointJob {
//库存对应的仓库 //库存对应的仓库
dcBaseWarehouse = baseWarehouseMapper.selectOneByExample(DcBaseWarehouseExample.newAndCreateCriteria().andWarehouseCodeEqualTo(warehouseCode).example()); dcBaseWarehouse = baseWarehouseMapper.selectOneByExample(DcBaseWarehouseExample.newAndCreateCriteria().andWarehouseCodeEqualTo(warehouseCode).example());
BigDecimal incrementalRatio = BigDecimal.ONE; BigDecimal incrementalRatio = BigDecimal.ONE;
int compareSales = 0; int compareSales = 0;
//销量 //销量
DcAutoSalesMapper autoSalesMapper; DcAutoSalesMapper autoSalesMapper;
...@@ -267,7 +270,11 @@ public class AutoTurnoverJob extends PointJob { ...@@ -267,7 +270,11 @@ public class AutoTurnoverJob extends PointJob {
} finally { } finally {
SessionUtil.closeSession(); SessionUtil.closeSession();
} }
autoTurnoverUseDcAutoSales(bailunSku, warehouseCode, dcAutoSales, dcBaseStock, dcBaseWarehouse, dcAutoWarehouseweekSales); autoTurnoverUseDcAutoSales(bailunSku,
warehouseCode,
dcAutoSales,
dcBaseStock,
dcBaseWarehouse);
} }
/** /**
...@@ -283,14 +290,12 @@ public class AutoTurnoverJob extends PointJob { ...@@ -283,14 +290,12 @@ public class AutoTurnoverJob extends PointJob {
* @param dcAutoSales 销量 * @param dcAutoSales 销量
* @param dcBaseStock 库存 * @param dcBaseStock 库存
* @param dcBaseWarehouse 仓库 * @param dcBaseWarehouse 仓库
* @param dcAutoWarehouseweekSales 自动周转系数
*/ */
private void autoTurnoverUseDcAutoSales(String bailunSku, private void autoTurnoverUseDcAutoSales(String bailunSku,
String warehouseCode, String warehouseCode,
DcAutoSales dcAutoSales, DcAutoSales dcAutoSales,
DcBaseStock dcBaseStock, DcBaseStock dcBaseStock,
DcBaseWarehouse dcBaseWarehouse, DcBaseWarehouse dcBaseWarehouse) throws Exception {
DcAutoWarehouseweekSales dcAutoWarehouseweekSales) throws Exception {
//记录时间 //记录时间
LocalDate recordTime = LocalDate.now(); LocalDate recordTime = LocalDate.now();
...@@ -778,6 +783,50 @@ public class AutoTurnoverJob extends PointJob { ...@@ -778,6 +783,50 @@ public class AutoTurnoverJob extends PointJob {
dcAutoTurnover.setIsOutStock(0); dcAutoTurnover.setIsOutStock(0);
dcAutoTurnover.setGmtModified(LocalDateTime.now()); dcAutoTurnover.setGmtModified(LocalDateTime.now());
/*周系数*/
List<String> param = new ArrayList<>(Lists.newArrayList(dcAutoTurnover.getSalesDetails()
.trim()
.substring(1)
.substring(0, dcAutoTurnover.getSalesDetails().length() - 2)
.split(",")));
List<BigDecimal> salesDetails = param.stream().map(var -> {
try {
String ss= var.trim();
return new BigDecimal(ss);
} catch (Exception ex) {
throw ex;
}
}).collect(Collectors.toList());
AtomicReference<LocalDate> localDate = new AtomicReference<>(LocalDate.now().minusDays(7));
List<SalesDetailItem> salesDetailItemList = salesDetails.stream().map(salesDetail -> {
SalesDetailItem salesDetailItem = new SalesDetailItem();
salesDetailItem.setSales(salesDetail);
salesDetailItem.setDate(localDate.get());
localDate.set(localDate.get().plusDays(1));
return salesDetailItem;
}).collect(Collectors.toList());
DcBaseWeekCoefficientMapper dcBaseWeekCoefficientMapper = SessionUtil.getSession().getMapper(DcBaseWeekCoefficientMapper.class);
SalesDayConfigMapper salesDayConfigMapper = SessionUtil.getSession().getMapper(SalesDayConfigMapper.class);
List<DcBaseWeekCoefficient> dcBaseWeekCoefficientList = dcBaseWeekCoefficientMapper.selectByDays(salesDetailItemList, dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
List<SalesDayConfig> salesDayConfigMapperList = salesDayConfigMapper.selectByDays(salesDetailItemList, dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
Map<LocalDate, DcBaseWeekCoefficient> weekCoefficientMap = dcBaseWeekCoefficientList.stream().collect(Collectors.toMap(DcBaseWeekCoefficient::getWeekDate, dcBaseWeekCoefficient -> dcBaseWeekCoefficient));
Map<LocalDate, SalesDayConfig> salesDayConfigMap = salesDayConfigMapperList.stream().collect(Collectors.toMap(salesDayConfig -> salesDayConfig.getDate().toLocalDate(), salesDayConfig -> salesDayConfig));
salesDetailItemList.stream().peek(salesDetailItem -> {
salesDetailItem.setSalesDayConfig(salesDayConfigMap.get(salesDetailItem.getDate()).getSales());
salesDetailItem.setWeekCoefficient(new BigDecimal(weekCoefficientMap.get(salesDetailItem.getDate()).getCoefficient()));
})
.forEach(SalesDetailItem::calcShowSales);
dcAutoTurnover.setSalesDetails(salesDetailItemList.stream().map(SalesDetailItem::getShowSales).map(BigDecimal::toString).collect(Collectors.joining(",")));
int i = autoTurnoverMapper.updateByExampleSelective(dcAutoTurnover, DcAutoTurnoverExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoTurnover.getBailunSku()).andWarehouseCodeEqualTo(dcAutoTurnover.getWarehouseCode()).example()); int i = autoTurnoverMapper.updateByExampleSelective(dcAutoTurnover, DcAutoTurnoverExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoTurnover.getBailunSku()).andWarehouseCodeEqualTo(dcAutoTurnover.getWarehouseCode()).example());
if (i == 0) { if (i == 0) {
...@@ -793,6 +842,7 @@ public class AutoTurnoverJob extends PointJob { ...@@ -793,6 +842,7 @@ public class AutoTurnoverJob extends PointJob {
} }
private void caculatePlatformAvgSales(DcAutoTurnoverWithBLOBs dcAutoTurnover) { private void caculatePlatformAvgSales(DcAutoTurnoverWithBLOBs dcAutoTurnover) {
try { try {
DcAutoSalesMapper mapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class); DcAutoSalesMapper mapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class);
...@@ -1471,10 +1521,17 @@ public class AutoTurnoverJob extends PointJob { ...@@ -1471,10 +1521,17 @@ public class AutoTurnoverJob extends PointJob {
* @param forecastShortSupplyList 预测断货 * @param forecastShortSupplyList 预测断货
* @param autoForecastDay 周转倍数 * @param autoForecastDay 周转倍数
*/ */
private void initForecaseList private void initForecaseList(List<String> forecastInboundRelationList,
(List<String> forecastInboundRelationList, List<BigDecimal> forecastInventoryList, List<Integer> forecastPurchaseInboundList, List<Integer> forecastTransferInboundList, List<Integer> forecastInboundList, List<BigDecimal> forecastSalesList, List<BigDecimal> forecastShortSupplyList, Integer List<BigDecimal> forecastInventoryList,
autoForecastDay, List<String> forecastSalesExplainList) { List<Integer> forecastPurchaseInboundList,
List<Integer> forecastTransferInboundList,
List<Integer> forecastInboundList,
List<BigDecimal> forecastSalesList,
List<BigDecimal> forecastShortSupplyList,
Integer autoForecastDay,
List<String> forecastSalesExplainList) {
for (int i1 = 0; i1 < autoForecastDay; i1++) { for (int i1 = 0; i1 < autoForecastDay; i1++) {
forecastInboundList.add(0); forecastInboundList.add(0);
forecastInventoryList.add(BigDecimal.ZERO); forecastInventoryList.add(BigDecimal.ZERO);
forecastSalesList.add(BigDecimal.ZERO); forecastSalesList.add(BigDecimal.ZERO);
......
...@@ -10,8 +10,9 @@ EVENT_RDB_STORAGE_PASSWORD=#7kfnymAM$Y9-Ntf ...@@ -10,8 +10,9 @@ EVENT_RDB_STORAGE_PASSWORD=#7kfnymAM$Y9-Ntf
ZOOKEEPER_SERVER=172.31.255.120:2181 ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE=data-center NAME_SPACE=data-center
JOB_NAME=show-auto-turnover8 JOB_NAME=show-auto-turnover12
JOB_CRON=0 0 3 * * ? JOB_CRON=0 0 3 * * ?
#JOB_CRON=0 50 9 * * ?
SHARDING_TOTAL_COUNT=8 SHARDING_TOTAL_COUNT=8
......
...@@ -137,8 +137,8 @@ public class AutoTurnoverTest { ...@@ -137,8 +137,8 @@ public class AutoTurnoverTest {
public void testXX() { public void testXX() {
DcBaseStock dcBaseStock = SessionUtil.getSession().getMapper(DcBaseStockMapper.class) DcBaseStock dcBaseStock = SessionUtil.getSession().getMapper(DcBaseStockMapper.class)
.selectOneByExample(DcBaseStockExample.newAndCreateCriteria() .selectOneByExample(DcBaseStockExample.newAndCreateCriteria()
.andBailunSkuEqualTo("950093401") .andBailunSkuEqualTo("LM-EO-007")
.andWarehouseCodeEqualTo("GZBLWH") .andWarehouseCodeEqualTo("MMDUSFBA")
.example()); .example());
try { try {
......
...@@ -57,7 +57,7 @@ public class AutoTurnoverJobTest { ...@@ -57,7 +57,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 0), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 0),
jobPointLog); jobPointLog);
} }
...@@ -68,7 +68,7 @@ public class AutoTurnoverJobTest { ...@@ -68,7 +68,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 1), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 1),
jobPointLog); jobPointLog);
} }
...@@ -79,7 +79,7 @@ public class AutoTurnoverJobTest { ...@@ -79,7 +79,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 2), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 2),
jobPointLog); jobPointLog);
} }
...@@ -90,7 +90,7 @@ public class AutoTurnoverJobTest { ...@@ -90,7 +90,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 3), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 3),
jobPointLog); jobPointLog);
} }
...@@ -101,7 +101,7 @@ public class AutoTurnoverJobTest { ...@@ -101,7 +101,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 4), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 4),
jobPointLog); jobPointLog);
} }
...@@ -112,7 +112,7 @@ public class AutoTurnoverJobTest { ...@@ -112,7 +112,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 5), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 5),
jobPointLog); jobPointLog);
} }
...@@ -123,7 +123,7 @@ public class AutoTurnoverJobTest { ...@@ -123,7 +123,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 6), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 6),
jobPointLog); jobPointLog);
} }
...@@ -134,7 +134,7 @@ public class AutoTurnoverJobTest { ...@@ -134,7 +134,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "INCREMENT", new HashMap<>()), 7), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 8, "NORMAL", new HashMap<>()), 7),
jobPointLog); jobPointLog);
} }
...@@ -145,9 +145,8 @@ public class AutoTurnoverJobTest { ...@@ -145,9 +145,8 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageIndex(1); jobPointLog.setPageIndex(1);
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", "show-auto-turnover3", 1, "INCREMENT", new HashMap<>()), 0), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", "show-auto-turnover3", 1, "NORMAL", new HashMap<>()), 0),
jobPointLog); jobPointLog);
} }
...@@ -159,7 +158,7 @@ public class AutoTurnoverJobTest { ...@@ -159,7 +158,7 @@ public class AutoTurnoverJobTest {
jobPointLog.setPageSize(1000); jobPointLog.setPageSize(1000);
AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob(); AutoTurnoverJob autoTurnoverJob = new AutoTurnoverJob();
autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 1, "INCREMENT", new HashMap<>()), 0), autoTurnoverJob.executeJob(new ShardingContext(new ShardingContexts("x", null, 1, "NORMAL", new HashMap<>()), 0),
jobPointLog); jobPointLog);
} }
......
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