Commit 02f9474b by huluobin

# 更新

parent 75b6df89
......@@ -1067,63 +1067,67 @@ public class AutoTurnoverJob extends PointJob {
//status` '监控状态, 默认0监控, 停止监控1',
try {
DcAutoForecastFluctuationMapper mapper = SessionUtil.getSession().getMapper(DcAutoForecastFluctuationMapper.class);
//JIT的 可以不做 冗余 和 缺货预测 实际冗余和实际缺货也不用提醒
//如果仓库是广州01 且 是这三个销售员, 就不提醒
if (!warehouseCode.equals(Constant.WAREHOUSE_JIT)
|| !turnoverSku.getBuyerName().equals(Constant.BUYER_JIT_1)
&& !turnoverSku.getBuyerName().equals(Constant.BUYER_JIT_2)
&& !turnoverSku.getBuyerName().equals(Constant.BUYER_JIT_3)) {
if (dcAutoConfigSkuWarehouse == null || dcAutoConfigSkuWarehouse.getStatus().equals(0)) {
if (forecastFluctuationList != null && forecastFluctuationList.size() > 0) {
//拿最早的时间 + 最晚的时间, SKU-仓库维度只放一条
DcAutoForecastFluctuation dcAutoForecastFluctuation = forecastFluctuationList.get(0);
dcAutoForecastFluctuation.setStartTime(forecastFluctuationList.get(0).getStartTime());
dcAutoForecastFluctuation.setEndTime(forecastFluctuationList.get(0).getEndTime());
dcAutoForecastFluctuation.setBailunSku(turnoverSku.getBailunSku());
dcAutoForecastFluctuation.setWarehouseCode(warehouseCode);
dcAutoForecastFluctuation.setWarehouseName(dcAutoTurnover.getWarehouseName());
dcAutoForecastFluctuation.setAvgSalesThree(avgHistoryThreedaySales);
/*
* 增加是否断货计算
* Add by Allan at 2020-07-23 10:58
* 断货=前一天还有库存,但是今天库存为0了则是已经断货
* */
if (forecastFluctuationList.get(0).getType() != 1 && dcBaseStock.getUsableStock() == 0) {
//获取前一天库存
Integer yesterdayStock = mapper.yesterdayStock(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
if (yesterdayStock != null && yesterdayStock > 0) {
dcAutoForecastFluctuation.setType(5); //实际断货
dcAutoForecastFluctuation.setStartTime(LocalDate.now()); //保存当天日期
dcAutoForecastFluctuation.setEndTime(LocalDate.now()); //保存当天日期
if (StringUtils.isBlank(transferStrategy.get())) {
try {
DcAutoForecastFluctuationMapper mapper = SessionUtil.getSession().getMapper(DcAutoForecastFluctuationMapper.class);
//JIT的 可以不做 冗余 和 缺货预测 实际冗余和实际缺货也不用提醒
//如果仓库是广州01 且 是这三个销售员, 就不提醒
if (!warehouseCode.equals(Constant.WAREHOUSE_JIT)
|| !turnoverSku.getBuyerName().equals(Constant.BUYER_JIT_1)
&& !turnoverSku.getBuyerName().equals(Constant.BUYER_JIT_2)
&& !turnoverSku.getBuyerName().equals(Constant.BUYER_JIT_3)) {
if (dcAutoConfigSkuWarehouse == null || dcAutoConfigSkuWarehouse.getStatus().equals(0)) {
if (forecastFluctuationList != null && forecastFluctuationList.size() > 0) {
//拿最早的时间 + 最晚的时间, SKU-仓库维度只放一条
DcAutoForecastFluctuation dcAutoForecastFluctuation = forecastFluctuationList.get(0);
dcAutoForecastFluctuation.setStartTime(forecastFluctuationList.get(0).getStartTime());
dcAutoForecastFluctuation.setEndTime(forecastFluctuationList.get(0).getEndTime());
dcAutoForecastFluctuation.setBailunSku(turnoverSku.getBailunSku());
dcAutoForecastFluctuation.setWarehouseCode(warehouseCode);
dcAutoForecastFluctuation.setWarehouseName(dcAutoTurnover.getWarehouseName());
dcAutoForecastFluctuation.setAvgSalesThree(avgHistoryThreedaySales);
/*
* 增加是否断货计算
* Add by Allan at 2020-07-23 10:58
* 断货=前一天还有库存,但是今天库存为0了则是已经断货
* */
if (forecastFluctuationList.get(0).getType() != 1 && dcBaseStock.getUsableStock() == 0) {
//获取前一天库存
Integer yesterdayStock = mapper.yesterdayStock(dcAutoTurnover.getBailunSku(), dcAutoTurnover.getWarehouseCode());
if (yesterdayStock != null && yesterdayStock > 0) {
dcAutoForecastFluctuation.setType(5); //实际断货
dcAutoForecastFluctuation.setStartTime(LocalDate.now()); //保存当天日期
dcAutoForecastFluctuation.setEndTime(LocalDate.now()); //保存当天日期
}
}
}
//End Add
//End Add
int i = mapper.updateByExampleSelective(dcAutoForecastFluctuation, DcAutoForecastFluctuationExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoForecastFluctuation.getBailunSku()).andWarehouseCodeEqualTo(dcAutoForecastFluctuation.getWarehouseCode()).example());
if (i == 0) {
mapper.insertSelective(dcAutoForecastFluctuation);
int i = mapper.updateByExampleSelective(dcAutoForecastFluctuation, DcAutoForecastFluctuationExample.newAndCreateCriteria().andBailunSkuEqualTo(dcAutoForecastFluctuation.getBailunSku()).andWarehouseCodeEqualTo(dcAutoForecastFluctuation.getWarehouseCode()).example());
if (i == 0) {
mapper.insertSelective(dcAutoForecastFluctuation);
}
} else {
mapper.deleteByExample(DcAutoForecastFluctuationExample.newAndCreateCriteria()
.andBailunSkuEqualTo(turnoverSku.getBailunSku())
.andWarehouseCodeEqualTo(warehouseCode).example());
}
} else {
} else if (dcAutoConfigSkuWarehouse.getStatus().equals(1)) {
mapper.deleteByExample(DcAutoForecastFluctuationExample.newAndCreateCriteria()
.andBailunSkuEqualTo(turnoverSku.getBailunSku())
.andWarehouseCodeEqualTo(warehouseCode).example());
}
} else if (dcAutoConfigSkuWarehouse.getStatus().equals(1)) {
mapper.deleteByExample(DcAutoForecastFluctuationExample.newAndCreateCriteria()
.andBailunSkuEqualTo(turnoverSku.getBailunSku())
.andWarehouseCodeEqualTo(warehouseCode).example());
}
} catch (Exception e) {
throw new RuntimeException("MYBATIS操作DB存DcAutoForecastFluctuation失败", e);
} finally {
SessionUtil.closeSession();
}
} catch (Exception e) {
throw new RuntimeException("MYBATIS操作DB存DcAutoForecastFluctuation失败", e);
} finally {
SessionUtil.closeSession();
}
}
......
......@@ -30,12 +30,12 @@ public class QueueConsumerJob implements SimpleJob {
@Data
public static class BaseQueueMessage {
@JSONField(name = "bailun_sku")
private String bailunSku;
@JSONField(name = "warehouse_code")
private String warehouseCode;
}
public static class BaseQueueMessage {
@JSONField(name = "bailun_sku")
private String bailunSku;
@JSONField(name = "warehouse_code")
private String warehouseCode;
}
@Override
public void execute(ShardingContext shardingContext) {
......@@ -53,7 +53,7 @@ public class QueueConsumerJob implements SimpleJob {
DcBaseStock dcBaseStock = dcBaseStockMapper.selectOneByExample(DcBaseStockExample.newAndCreateCriteria()
.andBailunSkuEqualTo(baseQueueMessage.getBailunSku())
.andWarehouseCodeEqualTo(baseQueueMessage.getWarehouseCode())
.example());
.example());
try {
autoTurnoverJob.autoTurnoverFromStock(dcBaseStock);
......
......@@ -256,7 +256,7 @@ public class AutoTurnoverTest {
public void testXX2() {
DcBaseStock dcBaseStock = SessionUtil.getSession().getMapper(DcBaseStockMapper.class)
.selectOneByExample(DcBaseStockExample.newAndCreateCriteria()
.andBailunSkuEqualTo("217632401")
.andBailunSkuEqualTo("LM-EO-007")
.andWarehouseCodeEqualTo("MMDUSFBA")
.example());
try {
......
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