diff --git a/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java b/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java index 1aea50fd..7d665a97 100644 --- a/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java +++ b/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java @@ -284,11 +284,11 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService private void syncAllGoods(DataBaseInfo dataBaseInfo, CommentModel commentModel){ String where="where 1=1"; Integer total =0; + String parentId=getAndCacheTree(dataBaseInfo,dataBaseInfo.getCategoryName());//加载缓存用的 if(DicEnum.SYNCTYPE_02.getCode().equals(dataBaseInfo.getSyncType())){ if (StringUtils.isNotEmpty(dataBaseInfo.getCategoryName())) { - String parentId=getAndCacheTree(dataBaseInfo,dataBaseInfo.getCategoryName()); - String childrens= commonCache.get(CommonCache.CACHE_CATEGROY+parentId); //syncGoodsSearchModel.setItemClsno(childrens); + String childrens= commonCache.get(CommonCache.CACHE_CATEGROY+parentId); where += " and b.item_clsno in ('" + childrens + "')"; } if(StringUtils.isNotEmpty(commentModel.getSyncTime())){ @@ -336,7 +336,6 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService folders.add(String.valueOf(i)); syncCount+=sxSyncGoods.size(); } - // folders.add(String.valueOf(2)); //folders.add(String.valueOf(4)); //folders.add(String.valueOf(5)); log.info("商品分类总共有{}条数据,同步完成{}条",total,syncCount); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/ShopBaseProductCategoryService.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/ShopBaseProductCategoryService.java index b50f1792..ffd983e1 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/ShopBaseProductCategoryService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/ShopBaseProductCategoryService.java @@ -149,4 +149,6 @@ public interface ShopBaseProductCategoryService extends IBaseService baseWrapper=new QueryWrapper<>(); baseWrapper.select("MAX(product_id) as product_id"); ShopProductBase shopProductBase= shopProductBaseServiceImpl.getOne(baseWrapper); - Long productId= shopProductBase.getProduct_id()+1; + Long productId= shopProductBase.getProduct_id(); //QueryWrapper baseSeWrapper=new QueryWrapper(); //baseSeWrapper.eq("prefix", "product_id"); ShopNumberSeq shopNumberSeqBase= new ShopNumberSeq(); @@ -679,7 +680,7 @@ public abstract class SyncBaseThirdSxAbstract{ QueryWrapper itemQuery=new QueryWrapper<>(); itemQuery.select("MAX(item_id) as item_id"); ShopProductItem shopProductItem= shopProductItemServiceImpl.getOne(itemQuery); - Long itemtId= shopProductItem.getItem_id()+1; + Long itemtId= shopProductItem.getItem_id(); // QueryWrapper itemWrapper=new QueryWrapper(); //itemWrapper.eq("prefix", "item_id"); ShopNumberSeq shopNumberSeqItem= new ShopNumberSeq(); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java index 08fb43bc..987cea9f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java @@ -43,6 +43,7 @@ import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.common.utils.StringUtils; import com.suisung.mall.core.web.service.RedisService; +import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService; import com.suisung.mall.shop.number.service.ShopNumberSeqService; import com.suisung.mall.shop.page.service.OssService; import com.suisung.mall.shop.sixun.dao.SxDataDao; @@ -72,6 +73,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.File; @@ -122,7 +124,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements private final static String CLIENTFILEPATH="sxclient/"; - + @Autowired + private ShopBaseProductCategoryService shopBaseProductCategoryService; /** * 批量保存商品的分类 @@ -452,6 +455,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements * @param folders */ @Override + @Async public void SyncReadSxFileData(String appKey, String sign, String syncType, List folders) { SyncApp syncApp = syncAppService.getOne(new LambdaQueryWrapper() .select(SyncApp::getApp_key, SyncApp::getApp_secret,SyncApp::getStore_id) @@ -473,6 +477,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements }); syncPrimaryKey(); shopNumberSeqService.clearKey(); + shopBaseProductCategoryService.clearCategoryCache(storeId); ExecutorService executor = Executors.newFixedThreadPool(6); List> futures = new ArrayList<>(); // 提交任务 @@ -488,7 +493,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements while (true){ count++; String taskName=newFolders.get(taskId); - String fileName="good_"+taskId+".txt"; + String fileName="good_"+(taskId+1)+".txt"; JSONArray jsonArray=new ThreadFileUtils().processFolder(taskName,newFolders.get(taskId)); try { baseSaveOrUpdateGoodsBatch(jsonArray,storeId); @@ -497,6 +502,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements return "成功" + taskId; }catch (Exception e){ if(count<2){ + //Thread.sleep(100); continue; } fails.getAndIncrement(); @@ -519,6 +525,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements //记录到数据库 syncPrimaryKey(); shopNumberSeqService.clearKey(); + shopBaseProductCategoryService.clearCategoryCache(storeId); List syncFileLogs=new ArrayList<>(); for (int i = 0; i < failFolders.size(); i++) { String path=failFolders.get(i);