新增统计查询
This commit is contained in:
parent
fac29d5e2e
commit
7ae10a84d3
@ -42,7 +42,7 @@ public class StateCode {
|
|||||||
public static final int PRODUCT_STATE_NORMAL = 1001; //正常
|
public static final int PRODUCT_STATE_NORMAL = 1001; //正常
|
||||||
public static final int PRODUCT_STATE_OFF_THE_SHELF = 1002; //下架
|
public static final int PRODUCT_STATE_OFF_THE_SHELF = 1002; //下架
|
||||||
|
|
||||||
public static final int PRODUCT_STATE_OFF_THE_SHELF_UNCHECK = 1003; //同步数据的状态,下架未分配商品
|
public static final int PRODUCT_STATE_OFF_THE_SHELF_UNCHECK = 1003; //同步数据的状态,下架未分配商品,也叫待审核
|
||||||
|
|
||||||
public static final int DEMAND_STATE_CONDUCT = 1000; //采购中
|
public static final int DEMAND_STATE_CONDUCT = 1000; //采购中
|
||||||
public static final int DEMAND_STATE_REJECT = 1030; //被驳回
|
public static final int DEMAND_STATE_REJECT = 1030; //被驳回
|
||||||
|
|||||||
@ -64,11 +64,11 @@ import com.suisung.mall.shop.product.pojo.vo.ProductVo;
|
|||||||
import com.suisung.mall.shop.product.service.*;
|
import com.suisung.mall.shop.product.service.*;
|
||||||
import com.suisung.mall.shop.sixun.service.SxSyncGoodsService;
|
import com.suisung.mall.shop.sixun.service.SxSyncGoodsService;
|
||||||
import com.suisung.mall.shop.store.service.*;
|
import com.suisung.mall.shop.store.service.*;
|
||||||
import com.suisung.mall.shop.sync.keymanage.RedisKey;
|
|
||||||
import com.suisung.mall.shop.sync.service.ProductMappingService;
|
import com.suisung.mall.shop.sync.service.ProductMappingService;
|
||||||
import com.suisung.mall.shop.sync.service.StoreDbConfigService;
|
import com.suisung.mall.shop.sync.service.StoreDbConfigService;
|
||||||
import com.suisung.mall.shop.user.service.*;
|
import com.suisung.mall.shop.user.service.*;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.http.client.utils.CloneUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -87,7 +87,10 @@ import java.math.BigDecimal;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
@ -2973,6 +2976,18 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
boolean openCount=getParameter("openCount",false);//1是开启,0是不开启
|
||||||
|
if(openCount){
|
||||||
|
ShopProductIndex shopProductIndex=new ShopProductIndex();
|
||||||
|
shopProductIndex.setCategory_id(category_id);
|
||||||
|
shopProductIndex.setStore_id(store_id);
|
||||||
|
Integer[] countArrays= countShopIndex(shopProductIndex);
|
||||||
|
data.put("allRecords",countArrays[0]);//全部
|
||||||
|
data.put("normalRecords",countArrays[1]);//销售中
|
||||||
|
data.put("offRecords",countArrays[2]);//仓库中
|
||||||
|
data.put("illegalRecords",countArrays[3]);//违规禁售
|
||||||
|
data.put("unCheckedRecords",countArrays[4]);//未分配或者待审核
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6129,5 +6144,77 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//计算全部,销售中,仓库中,违规禁销,未分配商品的数量
|
||||||
|
public Integer[] countShopIndex(ShopProductIndex shopProductIndex) {
|
||||||
|
//商品状态:1001-正常;1002-下架仓库中;1003-待审核; 1000-违规禁售,1003
|
||||||
|
int taskCount = 5;
|
||||||
|
CompletableFuture<Integer> count1 = CompletableFuture.supplyAsync(() -> {
|
||||||
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
|
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||||
|
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||||
|
}
|
||||||
|
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||||
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
|
});
|
||||||
|
CompletableFuture<Integer> count2 = CompletableFuture.supplyAsync(() -> {
|
||||||
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
|
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||||
|
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||||
|
}
|
||||||
|
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||||
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_NORMAL);
|
||||||
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
|
});
|
||||||
|
CompletableFuture<Integer> count3 = CompletableFuture.supplyAsync(() -> {
|
||||||
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
|
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||||
|
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||||
|
}
|
||||||
|
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||||
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF);
|
||||||
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
|
});
|
||||||
|
CompletableFuture<Integer> count4 = CompletableFuture.supplyAsync(() -> {
|
||||||
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
|
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||||
|
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||||
|
}
|
||||||
|
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||||
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_ILLEGAL);
|
||||||
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
|
});
|
||||||
|
CompletableFuture<Integer> count5 = CompletableFuture.supplyAsync(() -> {
|
||||||
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
|
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||||
|
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||||
|
}
|
||||||
|
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||||
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||||
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
|
});
|
||||||
|
|
||||||
|
// 等待所有任务完成
|
||||||
|
CompletableFuture<Void> allFutures = CompletableFuture.allOf(count1, count2, count3,count4,count5);
|
||||||
|
allFutures.thenRun(() -> {
|
||||||
|
logger.info("所有统计任务完成");
|
||||||
|
});
|
||||||
|
Integer[] resultInt=new Integer[taskCount];
|
||||||
|
try {
|
||||||
|
resultInt[0]=count1.get();
|
||||||
|
resultInt[1]=count2.get();
|
||||||
|
resultInt[2]=count3.get();
|
||||||
|
resultInt[3]=count4.get();
|
||||||
|
resultInt[4]=count5.get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return resultInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
AtomicInteger count1=new AtomicInteger(0);//全部
|
||||||
|
System.out.println(count1.addAndGet(10));
|
||||||
|
System.out.println(count1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -382,7 +382,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
|||||||
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
||||||
storeDbConfigQueryWrapper.select("priority_mode");
|
storeDbConfigQueryWrapper.select("priority_mode");
|
||||||
storeDbConfigQueryWrapper.eq("store_id", storeId);
|
storeDbConfigQueryWrapper.eq("store_id", storeId);
|
||||||
StoreDbConfig storeDbConfig= storeDbConfigService.getOne(storeDbConfigQueryWrapper);
|
StoreDbConfig storeDbConfig= storeDbConfigService.findOne(storeDbConfigQueryWrapper);
|
||||||
if(null==storeDbConfig){
|
if(null==storeDbConfig){
|
||||||
return CommonResult.failed("同步数据库配置不能为空");
|
return CommonResult.failed("同步数据库配置不能为空");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user