Commit 4304a011 by yinyong

周转销量大于过去7天 50%权重 14天50%权重取7、14平均销量加配置增量百分比

parent 1b9affdf
package com.bailuntec.domain.entity;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class DcAutoUprushConfig {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_uprush_config.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_uprush_config.warehouse_code
*
* @mbg.generated
*/
private String warehouseCode;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_uprush_config.percentage
*
* @mbg.generated
*/
private BigDecimal percentage;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @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(", warehouseCode=").append(warehouseCode);
sb.append(", percentage=").append(percentage);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
DcAutoUprushConfig other = (DcAutoUprushConfig) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getWarehouseCode() == null ? other.getWarehouseCode() == null : this.getWarehouseCode().equals(other.getWarehouseCode()))
&& (this.getPercentage() == null ? other.getPercentage() == null : this.getPercentage().equals(other.getPercentage()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getWarehouseCode() == null) ? 0 : getWarehouseCode().hashCode());
result = prime * result + ((getPercentage() == null) ? 0 : getPercentage().hashCode());
return result;
}
}
\ No newline at end of file
...@@ -7,7 +7,9 @@ import com.bailuntec.domain.entity.DcAutoTurnover; ...@@ -7,7 +7,9 @@ import com.bailuntec.domain.entity.DcAutoTurnover;
import com.bailuntec.domain.example.DcAutoSalesExample; import com.bailuntec.domain.example.DcAutoSalesExample;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map;
public interface DcAutoSalesMapper { public interface DcAutoSalesMapper {
/** /**
...@@ -125,7 +127,11 @@ public interface DcAutoSalesMapper { ...@@ -125,7 +127,11 @@ public interface DcAutoSalesMapper {
*/ */
int upsertSelective(DcAutoSales record); int upsertSelective(DcAutoSales record);
SalesVolumeDTO getSalesVolumeDTO(@Param("queryTime") String queryTime, @Param("bailunSku") String bailunSku, @Param("warehouseCode") String warehouseCode); Map<String, BigDecimal> getSalesAvg(@Param("queryTime") String queryTime, @Param("bailunSku") String bailunSku, @Param("warehouseCode") String warehouseCode);
SalesVolumeDTO getSalesVolumeDTONoCompare(@Param("queryTime") String queryTime, @Param("bailunSku") String bailunSku, @Param("warehouseCode") String warehouseCode);
SalesVolumeDTO getSalesVolumeDTO(@Param("queryTime") String queryTime, @Param("bailunSku") String bailunSku, @Param("warehouseCode") String warehouseCode, @Param("compareSales") BigDecimal compareSales);
SalesVolumeAvgDTO getPlatformHistorySales( @Param("bailunSku") String bailunSku,@Param("warehouseCode") String warehouseCode,@Param("platform") String platform); SalesVolumeAvgDTO getPlatformHistorySales( @Param("bailunSku") String bailunSku,@Param("warehouseCode") String warehouseCode,@Param("platform") String platform);
} }
\ No newline at end of file
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcAutoUprushConfig;
import com.bailuntec.domain.example.DcAutoUprushConfigExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcAutoUprushConfigMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
long countByExample(DcAutoUprushConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int deleteByExample(DcAutoUprushConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int insert(DcAutoUprushConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int insertSelective(DcAutoUprushConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcAutoUprushConfig selectOneByExample(DcAutoUprushConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
List<DcAutoUprushConfig> selectByExample(DcAutoUprushConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
DcAutoUprushConfig selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcAutoUprushConfig record, @Param("example") DcAutoUprushConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcAutoUprushConfig record, @Param("example") DcAutoUprushConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcAutoUprushConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
*/
int updateByPrimaryKey(DcAutoUprushConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcAutoUprushConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_uprush_config
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcAutoUprushConfig record);
}
\ No newline at end of file
...@@ -145,8 +145,25 @@ public class AutoTurnoverJob extends PointJob { ...@@ -145,8 +145,25 @@ public class AutoTurnoverJob extends PointJob {
String warehouseCode = dcBaseStock.getWarehouseCode(); String warehouseCode = dcBaseStock.getWarehouseCode();
DcAutoSales dcAutoSales = null; DcAutoSales dcAutoSales = null;
try { try {
DcAutoSalesMapper autoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class); BigDecimal incrementalRatio = BigDecimal.ONE;
SalesVolumeDTO salesVolumeDTO = autoSalesMapper.getSalesVolumeDTO(queryTime, bailunSku, warehouseCode); BigDecimal compareSales = BigDecimal.ZERO;
DcAutoSalesMapper autoSalesMapper = null;
SalesVolumeDTO salesVolumeDTO = null;
autoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class);
Map<String, BigDecimal> map = autoSalesMapper.getSalesAvg(queryTime, bailunSku, warehouseCode);
DcAutoUprushConfigMapper dcAutoUprushConfigMapper = SessionUtil.getSession().getMapper(DcAutoUprushConfigMapper.class);
DcAutoUprushConfig dcAutoUprushConfig = dcAutoUprushConfigMapper.selectOneByExample(DcAutoUprushConfigExample.newAndCreateCriteria().andWarehouseCodeEqualTo(warehouseCode).example());
if(dcAutoUprushConfig != null && map != null) {
incrementalRatio = incrementalRatio.add(dcAutoUprushConfig.getPercentage());
compareSales = (map.get("seven_sales").add(map.get("fourteen_sales"))).divide(BigDecimal.valueOf(2), RoundingMode.HALF_EVEN).multiply(incrementalRatio);
}
autoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class);
if(compareSales.compareTo(BigDecimal.ZERO) == 0) {
salesVolumeDTO = autoSalesMapper.getSalesVolumeDTONoCompare(queryTime, bailunSku, warehouseCode);
}else {
salesVolumeDTO = autoSalesMapper.getSalesVolumeDTO(queryTime, bailunSku, warehouseCode, compareSales);
}
if (StringUtils.isEmpty(salesVolumeDTO.getHistorySales().trim())) { if (StringUtils.isEmpty(salesVolumeDTO.getHistorySales().trim())) {
DcAutoSalesMapper dcAutoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class); DcAutoSalesMapper dcAutoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class);
dcAutoSales = new DcAutoSales(bailunSku, warehouseCode); dcAutoSales = new DcAutoSales(bailunSku, warehouseCode);
......
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