Commit 0d463b4b by huluobin

# 更新

parent e2057286
......@@ -134,4 +134,13 @@ public interface SalesDayConfigMapper {
List<SalesDayConfig> selectByDays2(@Param("salesDetailItemList") List<DateTurnover> salesDetailItemList,
@Param("bailunSku") String bailunSku,
@Param("warehouseCode") String warehouseCode);
/**
* 查询时间最远的一个销量配置
*
* @param bailunSku bailun sku
* @param warehouseCode warehouse code
* @return 时间最远的一个销量配置
*/
SalesDayConfig selectFarthest(@Param("bailunSku") String bailunSku, @Param("warehouseCode") String warehouseCode);
}
......@@ -548,9 +548,19 @@
</select>
<select id="selectTarget" resultType="com.bailuntec.domain.entity.SalesDayConfig">
select DISTINCT bailun_sku,warehouse_code from sales_day_config
select DISTINCT bailun_sku, warehouse_code
from sales_day_config
where create_date &gt; '2020-12-15'
</select>
<select id="selectFarthest" resultType="com.bailuntec.domain.entity.SalesDayConfig">
select *
from sales_day_config
where bailun_sku = #{bailunSku}
and warehouse_code = #{warehouseCode}
order by date desc
limit 1
</select>
</mapper>
......@@ -38,6 +38,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static java.time.Period.between;
@Slf4j
public class AutoTurnoverJob extends PointJob {
private AutoSalesService autoSalesService = new AutoSalesServiceImpl();
......@@ -361,8 +363,15 @@ public class AutoTurnoverJob extends PointJob {
* 所以预测2倍周转期长度
* 2倍周转期长度 < 31 的, 默认算31天, 但是生成的采购建议不拿2倍周转期以外的
*/
SalesDayConfigMapper salesDayConfigMapper = SessionUtil.getSession().getMapper(SalesDayConfigMapper.class);
SalesDayConfig farthestSalesDayConfig = salesDayConfigMapper.selectFarthest(bailunSku, warehouseCode);
int autoForecastDay = turnoverDays * Constant.TURNOVER_MULTIPLE < Constant.MIN_AUTO_FORECAST_DAY ? Constant.MIN_AUTO_FORECAST_DAY : turnoverDays * 2;
if (farthestSalesDayConfig != null) {
int salesDayConfigDays = Period.between(LocalDate.now(), farthestSalesDayConfig.getDate().toLocalDate()).getDays();
autoForecastDay = Math.max(salesDayConfigDays, autoForecastDay);
}
/*
* 初始化预测容器, 用来存放预测销量, 库存等数据
* forecastInventoryList
......@@ -429,10 +438,11 @@ public class AutoTurnoverJob extends PointJob {
}).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());
SalesDayConfigMapper salesDayConfigMapper1 = SessionUtil.getSession().getMapper(SalesDayConfigMapper.class);
List<SalesDayConfig> salesDayConfigMapperList = salesDayConfigMapper1.selectByDays(salesDetailItemList, dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
if (ListUtil.isNotEmpty(dcBaseWeekCoefficientList)) {
Map<LocalDate, DcBaseWeekCoefficient> weekCoefficientMap = dcBaseWeekCoefficientList.stream().collect(Collectors.toMap(DcBaseWeekCoefficient::getWeekDate, dcBaseWeekCoefficient -> dcBaseWeekCoefficient));
......@@ -1165,7 +1175,7 @@ public class AutoTurnoverJob extends PointJob {
else {
finalEstimatedArrivalTime = dcBasePurchase.getEstimatedArrivalTime().plusDays(dcAutoTurnover.getInspectionDelivery());
}
int interval = Period.between(recordTime, finalEstimatedArrivalTime.toLocalDate()).getDays();
int interval = between(recordTime, finalEstimatedArrivalTime.toLocalDate()).getDays();
int index = Math.max(interval, 0);
forecastInboundRelationList.set(index, forecastInboundRelationList.get(index).equals(Constant.NAN_STRING) ? Constant.PURCHASE_SIGN + dcBasePurchase.getPurchaseId() + "_" + dcBasePurchase.getCount() : forecastInboundRelationList.get(index) + "*" + Constant.PURCHASE_SIGN + dcBasePurchase.getPurchaseId() + "_" + dcBasePurchase.getCount());
forecastPurchaseInboundList.set(index, forecastPurchaseInboundList.get(index) + dcBasePurchase.getCount());
......@@ -1198,7 +1208,7 @@ public class AutoTurnoverJob extends PointJob {
} else {
finalEstimatedArrivalTime = dcBaseTransferVerify.getCreateTime().plusDays(dcAutoConfigDelivery.getAbroadInbound()).plusDays(dcAutoConfigDelivery.getTranferBale()).plusDays(dcAutoConfigDelivery.getTranferHead());
}
int interval = Period.between(recordTime, finalEstimatedArrivalTime.toLocalDate()).getDays();
int interval = between(recordTime, finalEstimatedArrivalTime.toLocalDate()).getDays();
int index = Math.max(interval, 0);
//todo fba的调拨在途,切换读我做的一个新表(表结构构建中)
......@@ -1244,7 +1254,7 @@ public class AutoTurnoverJob extends PointJob {
Map<LocalDate, List<DcBaseTransExpectarrivaltime>> map = dcBaseTransExpectarrivaltimeList.stream().collect(Collectors.groupingBy(item -> item.getExpectarrivaltime().toLocalDate()));
map.forEach((localDate, dcBaseTransExpectarrivaltimes) -> {
int interval = Period.between(recordTime, localDate).getDays();
int interval = between(recordTime, localDate).getDays();
int index = Math.max(interval, 0);
forecastInboundRelationList.set(index, forecastInboundRelationList.get(index) + "*" + dcBaseTransExpectarrivaltimes.stream().map(dcBaseTransExpectarrivaltime -> Constant.TRANSFER_SIGN + dcBaseTransExpectarrivaltime.getTransferOrderId() + "_" + dcBaseTransExpectarrivaltime.getCount()).collect(Collectors.joining("*")));
......@@ -1285,7 +1295,7 @@ public class AutoTurnoverJob extends PointJob {
promotionsBuilder.append(dcAutoConfigPromotion.getId());
//看促销日期和recordTime相差多少天
int interval = Period.between(recordTime, dcAutoConfigPromotion.getPromotionTime()).getDays();
int interval = between(recordTime, dcAutoConfigPromotion.getPromotionTime()).getDays();
if (interval >= 0 && interval < autoForecastDay) {
promotionCount = promotionCount + dcAutoConfigPromotion.getCount();
forecastSalesList.set(interval, forecastSalesList.get(interval).add(BigDecimal.valueOf(dcAutoConfigPromotion.getCount())));
......@@ -1317,12 +1327,12 @@ public class AutoTurnoverJob extends PointJob {
if (configCorrectionList != null && configCorrectionList.size() > 0) {
for (DcAutoConfigCorrection dcAutoConfigCorrection : configCorrectionList) {
if (dcAutoConfigCorrection.getStartTime() != null && dcAutoConfigCorrection.getEndTime() == null) {
int interval = Period.between(recordTime, dcAutoConfigCorrection.getStartTime()).getDays();
int interval = between(recordTime, dcAutoConfigCorrection.getStartTime()).getDays();
BigDecimal param = dcAutoConfigCorrection.getParam();
forecastSalesList.set(interval, param.multiply(forecastSalesList.get(interval)).setScale(3, RoundingMode.HALF_EVEN));
} else if (dcAutoConfigCorrection.getStartTime() != null && dcAutoConfigCorrection.getEndTime() != null) {
int begin = Period.between(recordTime, dcAutoConfigCorrection.getStartTime()).getDays();
int end = Period.between(recordTime, dcAutoConfigCorrection.getEndTime()).getDays();
int begin = between(recordTime, dcAutoConfigCorrection.getStartTime()).getDays();
int end = between(recordTime, dcAutoConfigCorrection.getEndTime()).getDays();
end = Math.min(end, autoForecastDay);
for (int i = begin; i <= end; i++) {
forecastSalesList.set(i, dcAutoConfigCorrection.getParam().multiply(forecastSalesList.get(i)).setScale(3, RoundingMode.HALF_EVEN));
......
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