diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java index e9107ff1..694c04c9 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java @@ -10,10 +10,10 @@ import com.suisung.mall.common.exception.ApiException; import com.suisung.mall.common.modules.base.ShopBaseProductSpec; import com.suisung.mall.common.modules.product.ShopProductSpecItem; import com.suisung.mall.common.utils.CheckUtil; -import com.suisung.mall.common.utils.ContextUtil; import com.suisung.mall.common.utils.FilterUtils; import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.shop.base.service.ShopBaseProductSpecService; +import com.suisung.mall.shop.number.service.ShopNumberSeqService; import com.suisung.mall.shop.product.service.ShopProductSpecItemService; import com.suisung.mall.shop.store.service.ShopStoreBaseService; import io.swagger.annotations.Api; @@ -49,7 +49,11 @@ public class ShopBaseProductSpecController { private ShopProductSpecItemService shopProductSpecItemService; @Autowired - ShopStoreBaseService shopStoreBaseService; + private ShopStoreBaseService shopStoreBaseService; + + @Autowired + private ShopNumberSeqService shopNumberSeqService; + /** * 分页列表查询 * @@ -105,6 +109,8 @@ public class ShopBaseProductSpecController { shopBaseProductSpec.setStore_id(oldSpec.getStore_id()); }else { Integer storeId = Integer.valueOf(userDto.getStore_id()); + List specIdList= shopNumberSeqService.getBatchSpecId(1); + shopBaseProductSpec.setSpec_id(specIdList.get(0)); shopBaseProductSpec.setStore_id(storeId); } shopBaseProductSpec.setSpec_id(spec_id); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductSpecServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductSpecServiceImpl.java index 4a41eac4..34c8608b 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductSpecServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductSpecServiceImpl.java @@ -3,11 +3,9 @@ package com.suisung.mall.shop.base.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.suisung.mall.common.domain.UserDto; import com.suisung.mall.common.modules.base.ShopBaseProductCategory; import com.suisung.mall.common.modules.base.ShopBaseProductSpec; import com.suisung.mall.common.modules.product.ShopProductSpecItem; -import com.suisung.mall.common.utils.ContextUtil; import com.suisung.mall.common.utils.FilterUtils; import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.core.web.service.RedisService; @@ -16,7 +14,6 @@ import com.suisung.mall.shop.base.mapper.ShopBaseProductSpecMapper; import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService; import com.suisung.mall.shop.base.service.ShopBaseProductSpecService; import com.suisung.mall.shop.product.service.ShopProductSpecItemService; -import com.suisung.mall.shop.sync.keymanage.RedisKey; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/number/service/ShopNumberSeqService.java b/mall-shop/src/main/java/com/suisung/mall/shop/number/service/ShopNumberSeqService.java index b79a1f1f..34128812 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/number/service/ShopNumberSeqService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/number/service/ShopNumberSeqService.java @@ -22,13 +22,11 @@ public interface ShopNumberSeqService extends IBaseService { List batchCreateNextNo(String seqName, int batchSize); void clearRelateGoodsId(); - void clearKey(); void batchUpdateSeq(List shopNumberSeqList); List getBatchSpecItemId(int batchSize); - void clearKeyStoreItemSepcId(); List getBatchUserAccountBaseId(int batchSize); @@ -36,8 +34,6 @@ public interface ShopNumberSeqService extends IBaseService { List getBatchSpecId(int batchSize); - void clearKeyStoreSepcId(); - List getBatchLibraryProductId(int batchSize); void clearKeyLibraryProductId(); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/number/service/impl/ShopNumberSeqServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/number/service/impl/ShopNumberSeqServiceImpl.java index b90426d0..ea6923ee 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/number/service/impl/ShopNumberSeqServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/number/service/impl/ShopNumberSeqServiceImpl.java @@ -6,6 +6,8 @@ import com.suisung.mall.common.feignService.AccountService; import com.suisung.mall.common.modules.base.ShopBaseProductSpec; import com.suisung.mall.common.modules.library.LibraryProduct; import com.suisung.mall.common.modules.number.ShopNumberSeq; +import com.suisung.mall.common.modules.product.ShopProductBase; +import com.suisung.mall.common.modules.product.ShopProductItem; import com.suisung.mall.common.modules.product.ShopProductSpecItem; import com.suisung.mall.core.web.service.RedisService; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; @@ -13,13 +15,17 @@ import com.suisung.mall.shop.base.service.ShopBaseProductSpecService; import com.suisung.mall.shop.library.service.LibraryProductService; import com.suisung.mall.shop.number.mapper.ShopNumberSeqMapper; import com.suisung.mall.shop.number.service.ShopNumberSeqService; +import com.suisung.mall.shop.product.service.ShopProductBaseService; +import com.suisung.mall.shop.product.service.ShopProductItemService; import com.suisung.mall.shop.product.service.ShopProductSpecItemService; import com.suisung.mall.shop.sync.keymanage.RedisKey; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; @@ -57,6 +63,15 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("prefix", seqName); @@ -207,24 +223,10 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl shopNumberSeqList=new ArrayList<>(); + QueryWrapper baseWrapper=new QueryWrapper<>(); + baseWrapper.select("MAX(product_id) as product_id"); + ShopProductBase shopProductBase= shopProductBaseService.getOne(baseWrapper); + Long productId= shopProductBase.getProduct_id(); + //QueryWrapper baseSeWrapper=new QueryWrapper(); + //baseSeWrapper.eq("prefix", "product_id"); + ShopNumberSeq shopNumberSeqBase= new ShopNumberSeq(); + shopNumberSeqBase.setPrefix("product_id"); + shopNumberSeqBase.setNumber(productId); + //shopNumberSeqServiceImpl.edit(shopNumberSeqBase,baseWrapper); + //查询产品item + QueryWrapper itemQuery=new QueryWrapper<>(); + itemQuery.select("MAX(item_id) as item_id"); + ShopProductItem shopProductItem= shopProductItemService.getOne(itemQuery); + Long itemtId=1L; + if(null!=shopProductItem){ + itemtId= shopProductItem.getItem_id(); + } + // QueryWrapper itemWrapper=new QueryWrapper(); + //itemWrapper.eq("prefix", "item_id"); + ShopNumberSeq shopNumberSeqItem= new ShopNumberSeq(); + shopNumberSeqItem.setNumber(itemtId); + shopNumberSeqItem.setPrefix("item_id"); + shopNumberSeqList.add(shopNumberSeqBase); + shopNumberSeqList.add(shopNumberSeqItem); + this.batchUpdateSeq(shopNumberSeqList); + this.clearRelateGoodsId(); + } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/product/controller/admin/ShopProductSpecItemController.java b/mall-shop/src/main/java/com/suisung/mall/shop/product/controller/admin/ShopProductSpecItemController.java index 63776c6b..2eb5d6c4 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/product/controller/admin/ShopProductSpecItemController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/product/controller/admin/ShopProductSpecItemController.java @@ -10,6 +10,7 @@ import com.suisung.mall.common.modules.product.ShopProductSpecItem; import com.suisung.mall.common.service.impl.BaseControllerImpl; import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.common.utils.ContextUtil; +import com.suisung.mall.shop.number.service.ShopNumberSeqService; import com.suisung.mall.shop.product.mapper.ShopProductItemMapper; import com.suisung.mall.shop.product.service.ShopProductItemService; import com.suisung.mall.shop.product.service.ShopProductSpecItemService; @@ -21,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** *

* 商品规格值表 前端控制器 @@ -43,6 +46,9 @@ public class ShopProductSpecItemController extends BaseControllerImpl { @Autowired private ShopProductItemMapper shopProductItemMapper; + @Autowired + private ShopNumberSeqService shopNumberSeqService; + /** * 分页列表查询 * @@ -88,6 +94,10 @@ public class ShopProductSpecItemController extends BaseControllerImpl { public CommonResult edit(ShopProductSpecItem shopProductSpecItem) { UserDto user = ContextUtil.getCurrentUser(); shopProductSpecItem.setStore_id(Integer.valueOf(user.getStore_id())); + if(ObjectUtil.isNull(shopProductSpecItem.getSpec_item_id())){ + List specItemIds= shopNumberSeqService.getBatchSpecItemId(1); + shopProductSpecItem.setSpec_item_id(specItemIds.get(0)); + } return CommonResult.success(shopProductSpecItemService.saveOrUpdate(shopProductSpecItem)); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductBaseServiceImpl.java index 54540f52..39a55e71 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductBaseServiceImpl.java @@ -737,7 +737,10 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl productIds= shopNumberSeqService.batchCreateNextNo("product_id",1); + productId=productIds.get(0); + // productId = shopNumberSeqService.createNextNo("product_id"); + if (null == productId) { return Pair.of(false, I18nUtil._("生成商品编号异常!")); } else { @@ -1032,7 +1035,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl itemIds= shopNumberSeqService.batchCreateNextNo("item_id",1); + item_id=itemIds.get(0); + // item_id = shopNumberSeqService.createNextNo("item_id"); if (null == item_id) { return Pair.of(false, I18nUtil._("生成商品 ItemId 异常!")); @@ -1209,8 +1214,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl productIds= shopNumberSeqService.batchCreateNextNo("product_id",1); + Long $product_id = productIds.get(0); + //Long $product_id = shopNumberSeqService.createNextNo("product_id"); if (null == $product_id) { throw new ApiException(I18nUtil._("生成商品编号异常!")); @@ -1383,7 +1389,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl itemIds= shopNumberSeqService.batchCreateNextNo("item_id",1); + item_id=itemIds.get(0); + //item_id = shopNumberSeqService.createNextNo("item_id"); if (null == item_id) { throw new ApiException(I18nUtil._("生成商品ItemId异常!")); @@ -4987,8 +4995,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl itemIds= shopNumberSeqService.batchCreateNextNo("item_id",1); + item_id=itemIds.get(0); if (null == item_id) { throw new ApiException(I18nUtil._("生成商品ItemId异常!")); } else { diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductItemServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductItemServiceImpl.java index 79ce3eff..3901ca5d 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductItemServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductItemServiceImpl.java @@ -1224,7 +1224,8 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl productIds= shopNumberSeqService.batchCreateNextNo("product_id",1); + shopProductBase.setProduct_id(productIds.get(0)); shopProductBase.setProduct_add_time(currentDate.getTime()); shopProductIndex.setProduct_add_time(currentDate.getTime()); } @@ -1295,7 +1296,8 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl itemIds= shopNumberSeqService.batchCreateNextNo("item_id",1); + shopProductItem.setItem_id(itemIds.get(0)); shopProductItem.setItem_number(IdUtil.simpleUUID()); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/keymanage/RedisKey.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/keymanage/RedisKey.java index 3080eea7..25ea1adb 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/keymanage/RedisKey.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/keymanage/RedisKey.java @@ -26,4 +26,6 @@ public class RedisKey { public static final String STOREDATALIBRARYID="storedata:libraryId"; + + public static final String STOREDATAGOODBATCHLOCK="store:data:goodsbatchLock"; } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ProductMappingServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ProductMappingServiceImpl.java index 50d40f3e..9bbe9b45 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ProductMappingServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ProductMappingServiceImpl.java @@ -537,7 +537,6 @@ public class ProductMappingServiceImpl extends BaseServiceImpl item_keys = redisService.keys(ConstantRedis.Cache_NameSpace +"shop_product_item"+ "*"); redisService.del(item_keys); Set base_keys = redisService.keys(ConstantRedis.Cache_NameSpace +"shop_product_base"+ "*"); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java index 0950fb2a..5f0e04e1 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/ShopSyncImportServiceImpl.java @@ -237,9 +237,7 @@ public class ShopSyncImportServiceImpl implements ShopSyncImportService { private void cleanCache(String storeId){ syncThirdDataService.syncPrimaryKey(); - shopNumberSeqService.clearKey(); shopBaseProductCategoryService.clearCategoryCache(storeId); - shopNumberSeqService.clearKeyStoreItemSepcId(); productBrandService.clearBrandMapByStoreId(storeId); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java index 500e5b66..36978a83 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java @@ -1059,9 +1059,10 @@ public abstract class SyncBaseThirdSxAbstract{ Map existIdMap= checkExistingShopBaseProductSpec(shopBaseProductSpecList); List insertShopBaseProductSpecList=new ArrayList<>(); List updateShopBaseProductSpecList=new ArrayList<>(); - QueryWrapper queryWrapper= new QueryWrapper<>(); - queryWrapper.select("max(spec_id) as spec_id"); - int spec_id=shopBaseProductSpecService.getOne(queryWrapper).getSpec_id()+1; +// QueryWrapper queryWrapper= new QueryWrapper<>(); +// queryWrapper.select("max(spec_id) as spec_id"); + // int spec_id=shopBaseProductSpecService.getOne(queryWrapper).getSpec_id()+1; + //int i=0; for(int i=0;i { +// if((shopBaseProductType.getType_name()+"规格").equals(shopBaseProductSpecList.get(finalI1).getSpec_name())){ +// shopBaseProductType.setType_spec_ids(String.valueOf(finalSpec_id)); +// } +// }); + insertShopBaseProductSpecList.add(shopBaseProductSpecList.get(i)); + } + // spec_id++; + } + + if(!insertShopBaseProductSpecList.isEmpty()){ + List specIdList=shopNumberSeqService.getBatchSpecId(insertShopBaseProductSpecList.size()); + for(int i=0;i { - if((shopBaseProductType.getType_name()+"规格").equals(shopBaseProductSpecList.get(finalI1).getSpec_name())){ + if((shopBaseProductType.getType_name()+"规格").equals(insertShopBaseProductSpecList.get(finalI).getSpec_name())){ shopBaseProductType.setType_spec_ids(String.valueOf(finalSpec_id)); } }); - insertShopBaseProductSpecList.add(shopBaseProductSpecList.get(i)); + insertShopBaseProductSpecList.get(i).setSpec_id(finalSpec_id); } - spec_id++; } + if(CollectionUtil.isNotEmpty(insertShopBaseProductSpecList)){ shopBaseProductSpecService.saveBatch(insertShopBaseProductSpecList,insertShopBaseProductSpecList.size()); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncStoreSpecsServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncStoreSpecsServiceImpl.java index dfb16664..0c268971 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncStoreSpecsServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncStoreSpecsServiceImpl.java @@ -83,7 +83,6 @@ public class SyncStoreSpecsServiceImpl extends ServiceImpl> futures = new ArrayList<>(); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("store_id", storeId); @@ -120,7 +119,6 @@ public class SyncStoreSpecsServiceImpl extends ServiceImpl folders) { + 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) .eq(SyncApp::getApp_key, appKey) @@ -574,7 +579,13 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements logger.info("没有商品数据"); return; } - + String key=RedisKey.STOREDATAGOODBATCHLOCK+":"+storeId; + // redisService.del(key); + if(!checkeckIsLock(storeId)){ + logger.info("批量同步商品等待时间异常结束"); + return; + } + setLock(storeId,"true"); List newFolders = new ArrayList<>(); folders.forEach(page -> { String newfolder = new FileUtils().getSyncTypeFlag(syncType, clientPath) + storeId + FileUtils.pathSeparator + page + FileUtils.pathSeparator; @@ -584,10 +595,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements //upLoadZipToOss(newFolders.get(0));//上传文件到cos // dowloadAndUnZip(newFolders.get(0));//读取cos文件回本地 syncPrimaryKey(); - shopNumberSeqService.clearKey(); shopBaseProductCategoryService.clearCategoryCache(storeId); // shopProductSpecItemService.clearExistItem(Integer.valueOf(storeId)); - shopNumberSeqService.clearKeyStoreItemSepcId(); ExecutorService executor = Executors.newFixedThreadPool(6); List> futures = new ArrayList<>(); // 提交任务 @@ -606,9 +615,18 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements // Map ShopBaseProductSpecMap = baseProductSpecService.getShopBaseProductSpecMap(Integer.valueOf(storeId));//切割商品缓存 // long seconds=System.currentTimeMillis(); // Date productSaleTime=Date.from(Instant.now().plusSeconds(seconds)); + + String fileIndex=folders.get(0); + String fileEndFix; + if (fileIndex.length()>1){ + fileEndFix=fileIndex.split("_")[1]; + } else { + fileEndFix = ""; + } + List fileNames=new ArrayList<>(); for(int i=0;i syncStoreDataQueryWrapper = new QueryWrapper<>(); @@ -630,7 +648,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements while (true) { count++; // String taskName = newFolders.get(taskId); - String fileName = "goods_" + (taskId + 1) + ".txt"; + String fileName = "goods_" + (taskId + 1) +"_"+fileEndFix+ ".txt"; String sycnDataId=DigestUtils.md5Hex(newFolders.get(taskId) + fileName); JSONArray jsonArray = getSyncDataContent(finalSyncDataMap,sycnDataId); try { @@ -662,8 +680,6 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements executor.shutdown(); //记录到数据库 syncPrimaryKey(); - shopNumberSeqService.clearKey(); - shopNumberSeqService.clearKeyStoreItemSepcId(); shopBaseProductCategoryService.clearCategoryCache(storeId); productBrandService.clearBrandMapByStoreId(storeId); List syncFileLogs = new ArrayList<>(); @@ -708,6 +724,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements if(ObjectUtil.isNull(storeDbConfig.getRefreshTime())){ syncShopImages(Integer.valueOf(storeId));//同时商品图库数据 } + + redisService.del(key); } @Override @@ -716,6 +734,39 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements syncShopImageService.syncMapingShopImages(storeId); } + /** + * 保证单线程执行同步数据 + * @param storeId + * @return + */ + public synchronized boolean checkeckIsLock(String storeId){ + logger.info("等待时间开始"); + String key=RedisKey.STOREDATAGOODBATCHLOCK+":"+storeId; + Map isLockMap= (Map) redisService.get(key); + if(isLockMap!=null){ + String result= (String) isLockMap.get("batchGoodIsLock"); + if("true".equals(result)){ + try { + logger.info("进入等待时间"); + Thread.sleep(1000 * 60 * 1);//五分钟 + return checkeckIsLock(storeId); + } catch (InterruptedException e) { + logger.info("等待异常:{}",e.getMessage()); + return false; + } + } + } + logger.info("等待时间结束"); + return true; + } + + public synchronized void setLock(String storeId,String value){ + String key=RedisKey.STOREDATAGOODBATCHLOCK+":"+storeId; + Map map= new HashMap<>(); + map.put("batchGoodIsLock",value); + redisService.set(key,map,600000); + } + @Override public ResponseEntity downloadToClient(String primaryKey, String clienVersionName) { diff --git a/sql/shop/dev/20251111_dml.sql b/sql/shop/dev/20251111_dml.sql new file mode 100644 index 00000000..6993b814 --- /dev/null +++ b/sql/shop/dev/20251111_dml.sql @@ -0,0 +1 @@ +alter table sycn_store_data change `file_path` `file_path` varchar(128) DEFAULT NULL COMMENT '文件全路径'; \ No newline at end of file