Commit 6e07ebbd by wutong

自动周转新增一个表放冗余数据

parent 78483484
package com.bailuntec.domain.entity;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
public class DcAutoDailyRedundance {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.bailun_sku
*
* @mbg.generated
*/
private String bailunSku;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.warehouse_code
*
* @mbg.generated
*/
private String warehouseCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.warehouse_name
*
* @mbg.generated
*/
private String warehouseName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.record_time
*
* @mbg.generated
*/
private LocalDate recordTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.quantity
*
* @mbg.generated
*/
private Integer quantity;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.gmt_create
*
* @mbg.generated
*/
private LocalDateTime gmtCreate;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_daily_redundance.gmt_modified
*
* @mbg.generated
*/
private LocalDateTime gmtModified;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @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(", warehouseName=").append(warehouseName);
sb.append(", recordTime=").append(recordTime);
sb.append(", quantity=").append(quantity);
sb.append(", gmtCreate=").append(gmtCreate);
sb.append(", gmtModified=").append(gmtModified);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
DcAutoDailyRedundance other = (DcAutoDailyRedundance) 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.getWarehouseName() == null ? other.getWarehouseName() == null : this.getWarehouseName().equals(other.getWarehouseName()))
&& (this.getRecordTime() == null ? other.getRecordTime() == null : this.getRecordTime().equals(other.getRecordTime()))
&& (this.getQuantity() == null ? other.getQuantity() == null : this.getQuantity().equals(other.getQuantity()))
&& (this.getGmtCreate() == null ? other.getGmtCreate() == null : this.getGmtCreate().equals(other.getGmtCreate()))
&& (this.getGmtModified() == null ? other.getGmtModified() == null : this.getGmtModified().equals(other.getGmtModified()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @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 + ((getWarehouseName() == null) ? 0 : getWarehouseName().hashCode());
result = prime * result + ((getRecordTime() == null) ? 0 : getRecordTime().hashCode());
result = prime * result + ((getQuantity() == null) ? 0 : getQuantity().hashCode());
result = prime * result + ((getGmtCreate() == null) ? 0 : getGmtCreate().hashCode());
result = prime * result + ((getGmtModified() == null) ? 0 : getGmtModified().hashCode());
return result;
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--<properties resource="db-tj.properties"/>-->
<!--<properties resource="db-test.properties"/>-->
<!-- <properties resource="db-test.properties"/>-->
<!-- <properties resource="db-dev.properties"/>-->
<properties resource="db-prod.properties"/>
<settings>
......
......@@ -350,7 +350,7 @@ public class AutoTurnoverJob extends PointJob {
*/
List<DcAutoForecastFluctuation> forecastFluctuationList = new ArrayList<>(turnoverDays);
DcAutoConfigSkuWarehouse dcAutoConfigSkuWarehouse = getAutoConfigSkuWarehouse(bailunSku, warehouseCode);
boolean hasMonitorFluctuation = actualForecastFluctuations(recordTime, forecastSalesList, realInventory, totalSafeInventory, outStock, dcAutoConfigSkuWarehouse, avgHistoryFourteendaySales, avgHistoryThreedaySales, forecastFluctuationList);
boolean hasMonitorFluctuation = actualForecastFluctuations(dcAutoTurnover,recordTime, forecastSalesList, realInventory, totalSafeInventory, outStock, dcAutoConfigSkuWarehouse, avgHistoryFourteendaySales, avgHistoryThreedaySales, forecastFluctuationList);
/*
* 获取采购建议-FBA仓库
......@@ -542,9 +542,32 @@ public class AutoTurnoverJob extends PointJob {
}
}
private boolean actualForecastFluctuations(LocalDate recordTime, List<BigDecimal> forecastSalesList, Integer realInventory, BigDecimal totalSafeInventory, Integer outStock, DcAutoConfigSkuWarehouse dcAutoConfigSkuWarehouse, BigDecimal avgHistoryFourteendaySales, BigDecimal avgHistoryThreedaySales, List<DcAutoForecastFluctuation> forecastFluctuationList) {
private boolean actualForecastFluctuations(DcAutoTurnover dcAutoTurnover,LocalDate recordTime, List<BigDecimal> forecastSalesList, Integer realInventory, BigDecimal totalSafeInventory, Integer outStock, DcAutoConfigSkuWarehouse dcAutoConfigSkuWarehouse, BigDecimal avgHistoryFourteendaySales, BigDecimal avgHistoryThreedaySales, List<DcAutoForecastFluctuation> forecastFluctuationList) {
boolean hasMonitorFluctuation = false;//默认是停止了监控波动功能的
/*
* 这个if判断单纯是为了判断实际冗余,然后存一个表给别人用
*/
if (realInventory > forecastSalesList.get(0).add(totalSafeInventory).doubleValue()) {
DcAutoDailyRedundance dcAutoDailyRedundance = new DcAutoDailyRedundance();
float v = realInventory - forecastSalesList.get(0).add(totalSafeInventory).floatValue();
dcAutoDailyRedundance.setQuantity(Math.round(v));
dcAutoDailyRedundance.setBailunSku(dcAutoTurnover.getBailunSku());
dcAutoDailyRedundance.setWarehouseCode(dcAutoTurnover.getWarehouseCode());
dcAutoDailyRedundance.setWarehouseName(dcAutoTurnover.getWarehouseName());
dcAutoDailyRedundance.setRecordTime(LocalDate.now());
try {
DcAutoDailyRedundanceMapper mapper = SessionUtil.getSession().getMapper(DcAutoDailyRedundanceMapper.class);
int i = mapper.updateByExampleSelective(dcAutoDailyRedundance,DcAutoDailyRedundanceExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoDailyRedundance.getBailunSku()).andWarehouseCodeEqualTo(dcAutoDailyRedundance.getWarehouseCode()).andRecordTimeEqualTo(dcAutoDailyRedundance.getRecordTime()).example());
if (i == 0) {
mapper.insertSelective(dcAutoDailyRedundance);
}
} catch (Exception e) {
throw new RuntimeException("MYBATIS操作dcAutoDailyRedundance失败",e);
} finally {
SessionUtil.closeSession();
}
}
/*
* 如果没有配置停止监控
* 库存大于0或者平均销量大于0
* 那就要监控波动
......
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcAutoDailyRedundance;
import com.bailuntec.domain.example.DcAutoDailyRedundanceExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcAutoDailyRedundanceMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
long countByExample(DcAutoDailyRedundanceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int deleteByExample(DcAutoDailyRedundanceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int insert(DcAutoDailyRedundance record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int insertSelective(DcAutoDailyRedundance record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcAutoDailyRedundance selectOneByExample(DcAutoDailyRedundanceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
List<DcAutoDailyRedundance> selectByExample(DcAutoDailyRedundanceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
DcAutoDailyRedundance selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcAutoDailyRedundance record, @Param("example") DcAutoDailyRedundanceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcAutoDailyRedundance record, @Param("example") DcAutoDailyRedundanceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcAutoDailyRedundance record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
*/
int updateByPrimaryKey(DcAutoDailyRedundance record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcAutoDailyRedundance record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_daily_redundance
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcAutoDailyRedundance record);
}
\ No newline at end of file
......@@ -52,7 +52,7 @@ public class AutoTurnoverTest {
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("322572421").andWarehouseCodeEqualTo("QYBLZZ").example());
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("232232601").andWarehouseCodeEqualTo("CHUKFBA").example());
// dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("213789601").andWarehouseCodeEqualTo("GZBLWH").example());
dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("406585310").andWarehouseCodeEqualTo("QYBLZZ").example());
dcBaseStock = mapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria().andBailunSkuEqualTo("LM-EO-007").andWarehouseCodeEqualTo("MMDUSFBA").example());
} catch (Exception e) {
e.printStackTrace();
} finally {
......
table-name=dc_auto_forecast_fluctuation
table-name=dc_auto_daily_redundance
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