Commit c7ce2a0e by yinyong

周系数

parent 4304a011
package com.bailuntec.domain.dto;
import lombok.Data;
@Data
public class SalesVolumeWeekDTO {
private String bailunSku;
private String warehouseCode;
private String warehouseName;
private Integer oneWeekRate;
private Integer twoWeekRate;
private Integer threeWeekRate;
private Integer fourthWeekRate;
private Integer fiveWeekRate;
private Integer sixWeekRate;
private Integer sevenWeekRate;
private Integer eightWeekRate;
private Integer nineWeekRate;
private Integer tenWeekRate;
private Integer elevenWeekRate;
private Integer twelveWeekRate;
private Integer thridteenWeekRate;
private Integer fourteenWeekRate;
private Integer fifteenWeekRate;
private Integer sixteenWeekRate;
private Integer seventeenWeekRate;
private Integer eighteenWeekRate;
private Integer nineteenWeekRate;
private Integer twentyWeekRate;
private Integer twentyOneWeekRate;
private Integer twentyTwoWeekRate;
private Integer twentyThreeWeekRate;
private Integer twentyFourthWeekRate;
private Integer twentyFiveWeekRate;
private Integer twentySixWeekRate;
private Integer twentySeveneWeekRate;
private Integer twentyEightWeekRate;
private Integer twentyNineWeekRate;
private Integer thirtyWeekRate;
private Integer thirtyOneWeekRate;
private Integer thirtyTwoWeekRate;
private Integer thirtyThreeWeekRate;
private Integer thirtyFourthWeekRate;
private Integer thirtyFiveWeekRate;
private Integer thirtySixWeekRate;
private Integer thirtySeveneWeekRate;
private Integer thirtyEightWeekRate;
private Integer thirtyNineWeekRate;
private Integer fortyWeekRate;
private Integer fortyOneWeekRate;
private Integer fortyTwoWeekRate;
private Integer fortyThreeWeekRate;
private Integer fortyFourthWeekRate;
private Integer fortyFiveWeekRate;
private Integer fortySixWeekRate;
private Integer fortySeveneWeekRate;
private Integer fortyEightWeekRate;
private Integer fortyNineWeekRate;
private Integer fiftyWeekRate;
private Integer fiftyOneWeekRate;
private Integer fiftyTwoWeekRate;
private String salesDetail;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,6 +2,7 @@ package com.bailuntec.mapper;
import com.bailuntec.domain.dto.SalesVolumeAvgDTO;
import com.bailuntec.domain.dto.SalesVolumeDTO;
import com.bailuntec.domain.dto.SalesVolumeWeekDTO;
import com.bailuntec.domain.entity.DcAutoSales;
import com.bailuntec.domain.entity.DcAutoTurnover;
import com.bailuntec.domain.example.DcAutoSalesExample;
......@@ -131,6 +132,8 @@ public interface DcAutoSalesMapper {
SalesVolumeDTO getSalesVolumeDTONoCompare(@Param("queryTime") String queryTime, @Param("bailunSku") String bailunSku, @Param("warehouseCode") String warehouseCode);
SalesVolumeWeekDTO getSalesVolumeWeekDTO(@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);
......
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcAutoWeekSales;
import com.bailuntec.domain.example.DcAutoWeekSalesExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcAutoWeekSalesMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
long countByExample(DcAutoWeekSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int deleteByExample(DcAutoWeekSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int insert(DcAutoWeekSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int insertSelective(DcAutoWeekSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcAutoWeekSales selectOneByExample(DcAutoWeekSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
List<DcAutoWeekSales> selectByExample(DcAutoWeekSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
DcAutoWeekSales selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcAutoWeekSales record, @Param("example") DcAutoWeekSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcAutoWeekSales record, @Param("example") DcAutoWeekSalesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcAutoWeekSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
*/
int updateByPrimaryKey(DcAutoWeekSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcAutoWeekSales record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_week_sales
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcAutoWeekSales record);
}
\ No newline at end of file
package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.bailuntec.domain.dto.SalesVolumeWeekDTO;
import com.bailuntec.domain.entity.DcAutoWeekSales;
import com.bailuntec.domain.entity.DcBaseStock;
import com.bailuntec.domain.example.DcBaseStockExample;
import com.bailuntec.mapper.DcAutoSalesMapper;
import com.bailuntec.mapper.DcAutoWeekSalesMapper;
import com.bailuntec.mapper.DcBaseStockMapper;
import com.bailuntec.utils.SessionUtil;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Calendar;
import java.util.List;
public class CalculateWeekService {
public void autoTurnoverFromStock() {
try{
int pageSize = 1000;
DcBaseStockMapper baseStockMapper = SessionUtil.getSession().getMapper(DcBaseStockMapper.class);
long count = baseStockMapper.countByExample(DcBaseStockExample.newAndCreateCriteria().andWarehouseCodeEqualTo("GZBLWH").example());
int totalPage = (int)(count % pageSize == 0 ? count/pageSize : count/pageSize + 1);
int page = 0;
do{
List<DcBaseStock> dcBaseStockList = null;//分页查SKU_仓库
try {
DcBaseStockMapper baseStockMapperFor = SessionUtil.getSession().getMapper(DcBaseStockMapper.class);
dcBaseStockList = baseStockMapperFor.listStockById(page*pageSize, pageSize);
DcAutoSalesMapper autoSalesMapper = null;
if (dcBaseStockList != null && dcBaseStockList.size() > 0) {
for (DcBaseStock dcBaseStock : dcBaseStockList) {
autoSalesMapper = SessionUtil.getSession().getMapper(DcAutoSalesMapper.class);
SalesVolumeWeekDTO salesVolumeWeekDTO = autoSalesMapper.getSalesVolumeWeekDTO(dcBaseStock.getBailunSku(), dcBaseStock.getWarehouseCode());
if(StringUtils.isNotEmpty(salesVolumeWeekDTO.getSalesDetail().trim())) {
calculateWeekRate(salesVolumeWeekDTO);
}
}
}
}catch (Exception e){
e.printStackTrace();
}finally {
SessionUtil.closeSession();
}
page++;
}while(page <= totalPage);
}catch (Exception e){
e.printStackTrace();
}finally {
SessionUtil.closeSession();
}
}
public void calculateWeekRate(SalesVolumeWeekDTO salesVolumeWeekDTO) {
try{
DcAutoWeekSales dcAutoWeekSales = new DcAutoWeekSales();
DcAutoWeekSalesMapper dcAutoWeekSalesMapper = SessionUtil.getSession().getMapper(DcAutoWeekSalesMapper.class);
BeanUtils.copyProperties(dcAutoWeekSales, salesVolumeWeekDTO);
dcAutoWeekSales.setSaleDetail(salesVolumeWeekDTO.getSalesDetail());
// dcAutoWeekSales.setRateDetail(salesVolumeWeekDTO.getSalesDetail());
dcAutoWeekSalesMapper.upsertSelective(dcAutoWeekSales);
}catch (Exception e){
e.printStackTrace();
}finally {
SessionUtil.closeSession();
}
}
private Calendar getCalendarFormYear(int year){
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.set(Calendar.YEAR, year);
return cal;
}
public String getEndDayOfWeekNo(int year,int weekNo){
Calendar cal = getCalendarFormYear(year);
cal.set(Calendar.WEEK_OF_YEAR, weekNo);
cal.add(Calendar.DAY_OF_WEEK, 6);
return cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH) + 1) + "-" +
cal.get(Calendar.DAY_OF_MONTH);
}
public String getStartDayOfWeekNo(int year,int weekNo){
Calendar cal = getCalendarFormYear(year);
cal.set(Calendar.WEEK_OF_YEAR, weekNo);
return cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH) + 1) + "-" +
cal.get(Calendar.DAY_OF_MONTH);
}
}
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