fix同步数据问题修改

This commit is contained in:
liyj 2025-05-29 16:59:47 +08:00
parent 03b34a858f
commit 214f568f94
7 changed files with 38 additions and 20 deletions

View File

@ -28,7 +28,7 @@ public class WebController {
@RequestMapping("/synBrand")
public void synBrand(){
log.info("synBrand");
sxDataService.getAppSign();
// sxDataService.getAppSign();
sxDataService.SyncBranchList(new DataBaseInfo(),sxDataService.getCommentModel());
}
@ -36,21 +36,21 @@ public class WebController {
@RequestMapping("/syncCategory")
public void syncCategory(){
log.info("syncCategory");
sxDataService.getAppSign();
//sxDataService.getAppSign();
sxDataService.SyncCategory(new DataBaseInfo(),sxDataService.getCommentModel());
}
@RequestMapping("/syncGoods")
public void syncGoods(){
log.info("syncGoods");
sxDataService.getAppSign();
//sxDataService.getAppSign();
sxDataService.SyncGoods(new DataBaseInfo(),sxDataService.getCommentModel());
}
@RequestMapping("/synvip")
public void synvip(){
log.info("synvip");
sxDataService.getAppSign();
// sxDataService.getAppSign();
sxDataService.SyncVipList(new DataBaseInfo(),sxDataService.getCommentModel());
}

View File

@ -81,16 +81,26 @@ public abstract class SxDataAbstService {
//寻找父级
if(null!=sxSyncCategory.getCls_parent()){
SxSyncCategory firstNode=getParentNode(allSxSyncCategories,sxSyncCategory.getCls_parent());
if(null==firstNode){
sxCategoryModel.setFirst_category_name("");
}
sxCategoryModel.setParent_name(firstNode.getItem_clsname());//todo 暂时无用
//如何存在上级的上级则上级为第二层上上及为第一层
if(null!=firstNode.getCls_parent()) {//还存在上级
SxSyncCategory secondNode=getParentNode(allSxSyncCategories,sxSyncCategory.getCls_parent());
if(null!=secondNode && secondNode.getItem_clsno().equals(firstNode.getCls_parent())){
sxCategoryModel.setFirst_category_name(secondNode.getItem_clsname());
sxCategoryModel.setSecond_category_name(firstNode.getItem_clsname());
}else {
sxCategoryModel.setFirst_category_name(firstNode.getItem_clsname());
}
}else {
sxCategoryModel.setFirst_category_name(firstNode.getItem_clsname());
}
}else {
sxCategoryModel.setFirst_category_name("");
}
sxCategoryModel.setProduct_type("食品生鲜");
sxCategoryModels.add(sxCategoryModel);
}
return sxCategoryModels;

View File

@ -120,8 +120,10 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl<ShopBasePro
@Override
public boolean saveOrUpdateBrand(ShopBaseProductBrand shopBaseProductBrand) {
shopBaseProductBrand.setBrand_name_pinyin(PinyinUtil.getPinyin(shopBaseProductBrand.getBrand_name()));
//shopBaseProductBrand.setBrand_name_pinyin("qi ta pin pai");
shopBaseProductBrand.setBrand_name_pinyin(PinyinUtil.getPinyin(shopBaseProductBrand.getBrand_name()," "));
shopBaseProductBrand.setBrand_initial(Convert.toStr(shopBaseProductBrand.getBrand_name_pinyin().charAt(0)));
//shopBaseProductBrand.setBrand_initial("q");
Integer store_id = shopBaseProductBrand.getStore_id();
boolean isPlatform = true;

View File

@ -1246,6 +1246,7 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
if (CollUtil.isEmpty(map)) {
QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", storeId);
queryWrapper.eq("data_source", 2);
List<ShopBaseProductCategory> categoryList = find(queryWrapper);
// 类似数据可以放到前端整理
List<Map> category_tmp_rows = Convert.toList(Map.class, categoryList);

View File

@ -98,29 +98,28 @@ public abstract class SyncBaseThirdSxAbstract{
if (StrUtil.isNotBlank(o.getStr("product_type"))) {
ShopBaseProductType productType = productTypeService.getProductTypeByName(o.getStr("product_type"));
if (productType != null) {
list.get(i).setType_id(productType.getType_id());
typeId = productType.getType_id();
} else {
// 新增一个类型
ShopBaseProductType newProductType = new ShopBaseProductType();
newProductType.setType_name(o.getStr("product_type"));
newProductType.setType_buildin(0);
if (productTypeService.save(newProductType)) {
typeId = newProductType.getType_id();
}
}
list.get(i).setType_id(typeId);
}
// 处理第一级父类字段 产品分类
Integer firstParentId = 0;
list.get(i).setCategory_parent_id(firstParentId);//设置默认值
if (StrUtil.isNotBlank(o.getStr("first_category_name"))) {
// TODO storeId 不判断一下吗
ShopBaseProductCategory cate = productCategoryService.getCategoryByName(o.getStr("first_category_name"));
if (cate != null) {
list.get(i).setParent_id(cate.getCategory_id());
list.get(i).setCategory_parent_id(cate.getCategory_id());
} else{
// 新增一个第一级父类
ShopBaseProductCategory firstCate = new ShopBaseProductCategory();
@ -132,11 +131,10 @@ public abstract class SyncBaseThirdSxAbstract{
if (productCategoryService.saveOrUpdate(firstCate)) {
// 当前子分类的父类id
firstParentId = firstCate.getId();
list.get(i).setParent_id(firstParentId);
list.get(i).setCategory_parent_id(firstParentId);
}
}
list.get(i).setParent_id(firstParentId);
}
// 处理第二级父类字段 产品分类
@ -144,25 +142,26 @@ public abstract class SyncBaseThirdSxAbstract{
// TODO storeId 不判断一下吗
ShopBaseProductCategory cate = productCategoryService.getCategoryByName(o.getStr("second_category_name"));
if (cate != null) {
list.get(i).setParent_id(cate.getCategory_id());
list.get(i).setCategory_parent_id(cate.getCategory_id());
} else {
// 新增一个第二级父类
ShopBaseProductCategory secondCate = new ShopBaseProductCategory();
secondCate.setCategory_name(o.getStr("second_category_name"));
secondCate.setParent_id(firstParentId);
secondCate.setCategory_parent_id(firstParentId);
secondCate.setStore_id(storeId);
secondCate.setType_id(typeId);
secondCate.setData_source(2);
if (productCategoryService.saveOrUpdate(secondCate)) {
// 当前子分类的第二级父类id
list.get(i).setParent_id(secondCate.getId());
list.get(i).setCategory_parent_id(secondCate.getId());
}
}
}
}
ShopBaseProductCategory productCategoryTemp = productCategoryService.getCategoryByName(list.get(i).getParent_id(), list.get(i).getCategory_name(), list.get(i).getStore_id());
ShopBaseProductCategory productCategoryTemp = productCategoryService.getCategoryByName(list.get(i).getCategory_parent_id(), list.get(i).getCategory_name(), list.get(i).getStore_id());
if (productCategoryTemp != null) {
// 更改记录
if (!productCategoryTemp.getCategory_image().equals(list.get(i).getCategory_image())
@ -575,10 +574,14 @@ public abstract class SyncBaseThirdSxAbstract{
shopProductIndex.setProduct_transport_id(String.valueOf(StateCode.DELIVERY_TYPE_SAME_CITY));
if(categoryId!=0){
Integer typeId = (Integer) categoryMap.get(categoryId);
Integer typeId = (Integer) categoryMap.get(categoryId.toString());
if (ObjectUtil.isNotEmpty(typeId)) {
shopProductIndex.setType_id(typeId);
}else {
logger.info("typeId-{}",typeId);
}
}else {
logger.info("cateGoryId-{}",cateGoryId);
}
// shop_product_data

View File

@ -130,6 +130,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
@Autowired
private FileUtils fileUtils;
/**
* 批量保存商品的分类
*
@ -488,6 +489,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
AtomicInteger fails= new AtomicInteger();
List<String> failFolders=new ArrayList<>();
List<String> failMessage=new ArrayList<>();
shopBaseProductCategoryService.getCategoryListByStoreId(storeId);
for (int i = 0; i < newFolders.size(); i++) {
final int taskId = i;
threadNum.incrementAndGet();