|
|
|
@ -2,6 +2,7 @@ package com.ms.api.task;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.ms.api.bo.MovePublishBufferRandShopIdAndPriorityBO;
|
|
|
|
|
import com.ms.api.common.E;
|
|
|
|
|
import com.ms.api.common.StrObjMap;
|
|
|
|
|
import com.ms.api.common.TaskBaseService;
|
|
|
|
|
import com.ms.api.consts.RedisKeyConst;
|
|
|
|
@ -104,8 +105,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
|
|
|
|
|
log.info("start moveProductPublishBufferToQueue");
|
|
|
|
|
Map<Long, Integer> shopBufferCountMap = moveProductPublishBufferToQueue(selectedShopMap);
|
|
|
|
|
if (ObjectUtil.isEmpty(shopBufferCountMap)) {
|
|
|
|
|
log.info("end moveProductPublishBufferToQueue for empty bufferRows cost times");
|
|
|
|
|
return null;
|
|
|
|
|
E.throwMSException("end moveProductPublishBufferToQueue for empty bufferRows cost times");
|
|
|
|
|
}
|
|
|
|
|
log.info("end moveProductPublishBufferToQueue ret: " + shopBufferCountMap.toString());
|
|
|
|
|
return shopBufferCountMap;
|
|
|
|
@ -119,8 +119,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
|
|
|
|
|
log.info("handle getMoveProductPublishBufferShopMap");
|
|
|
|
|
int queueCount = moveProductPublishQueueService.count();
|
|
|
|
|
if (queueCount >= maxQueueCount) {
|
|
|
|
|
log.info("queueCount " + queueCount + ", maxQueueCount " + maxQueueCount + ", end.");
|
|
|
|
|
return null;
|
|
|
|
|
E.throwMSException("queueCount " + queueCount + ", maxQueueCount " + maxQueueCount + ", end.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int leftCount = maxQueueCount - queueCount;
|
|
|
|
@ -174,8 +173,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
|
|
|
|
|
log.info("start getShopMonthQuotaMap");
|
|
|
|
|
Map<Long, MoveShopConfig> shopMoveQuotaMap = getShopMonthQuotaMap(shopIds);
|
|
|
|
|
if(ObjectUtil.isEmpty(shopMoveQuotaMap)){
|
|
|
|
|
log.info("getShopMonthQuotaMap is empty");
|
|
|
|
|
return null;
|
|
|
|
|
E.throwMSException("getShopMonthQuotaMap is empty");
|
|
|
|
|
}
|
|
|
|
|
log.info("end getShopMonthQuotaMap");
|
|
|
|
|
|
|
|
|
@ -195,21 +193,19 @@ public class MovePublishBufferTaskService extends TaskBaseService {
|
|
|
|
|
*/
|
|
|
|
|
private Map<Long, MoveShopConfig> getShopMonthQuotaMap(List<Long> shopIds) {
|
|
|
|
|
if (ObjectUtil.isEmpty(shopIds)) {
|
|
|
|
|
return null;
|
|
|
|
|
E.throwMSException("shopIds is empty");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取店铺的配置
|
|
|
|
|
String curMonth = CommonTool.getCurMonthLastTime();
|
|
|
|
|
List<MoveShopConfig> moveConfigList = moveShopConfigService.selectByShopIds(shopIds,curMonth);
|
|
|
|
|
if (ObjectUtil.isEmpty(moveConfigList)) {
|
|
|
|
|
log.info("getShopMonthQuotaMap moveConfigList is empty");
|
|
|
|
|
return null;
|
|
|
|
|
E.throwMSException("getShopMonthQuotaMap moveConfigList is empty");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<Long, MoveShopConfig> moveConfigMap = CommonTool.convertListToMap(moveConfigList, MoveShopConfig::getShopId);
|
|
|
|
|
if (ObjectUtil.isEmpty(moveConfigMap)) {
|
|
|
|
|
log.info("getShopMonthQuotaMap moveConfigMap is empty");
|
|
|
|
|
return null;
|
|
|
|
|
E.throwMSException("getShopMonthQuotaMap moveConfigMap is empty");
|
|
|
|
|
}
|
|
|
|
|
return moveConfigMap;
|
|
|
|
|
}
|
|
|
|
@ -360,8 +356,7 @@ public class MovePublishBufferTaskService extends TaskBaseService {
|
|
|
|
|
}
|
|
|
|
|
log.info("end process selectedShopMap");
|
|
|
|
|
if (allBufferRowList.isEmpty()) {
|
|
|
|
|
log.info("end moveShopBufferToQueue for empty bufferRows cost times");
|
|
|
|
|
return null;
|
|
|
|
|
E.throwMSException("end moveShopBufferToQueue for empty bufferRows cost times");
|
|
|
|
|
}
|
|
|
|
|
// 分批把删除buffer中的数据,放入到queue中,同时放入到redis中
|
|
|
|
|
List<Map<Integer, MoveProductPublishBuffer>> chunkBufferRowList = CommonTool.chunkMap(allBufferRowList, 50);
|
|
|
|
|