浏览代码

1、数据处理

lqh 1 年之前
父节点
当前提交
46b9a73549

+ 25 - 0
hx-customer/src/main/java/com/fjhx/customer/controller/xiaoman/XiaomanCustomerController.java

@@ -10,6 +10,7 @@ import com.fjhx.customer.service.xiaoman.XiaomanCustomerService;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * <p>
@@ -23,6 +24,9 @@ import java.util.List;
 @RequestMapping("/xiaomanCustomer")
 public class XiaomanCustomerController {
 
+
+
+
     @Autowired
     private XiaomanCustomerService xiaomanCustomerService;
 
@@ -74,4 +78,25 @@ public class XiaomanCustomerController {
         xiaomanCustomerService.delete(dto.getId());
     }
 
+
+
+//    private static final AtomicBoolean isRunning = new AtomicBoolean(false);
+//    /**
+//     * 匹配小满客户数据
+//     * @param xiaomanCustomerDto
+//     */
+//    @PostMapping("/aatchingData")
+//    public synchronized void aatchingData(@RequestBody XiaomanCustomerDto xiaomanCustomerDto) {
+//        // 检查是否已有线程在执行此方法
+//        if (isRunning.compareAndSet(false, true)) {
+//            try {
+//                xiaomanCustomerService.add(xiaomanCustomerDto);
+//            } finally {
+//                // 在方法执行完毕后设置 isRunning 为 false
+//                isRunning.set(false);
+//            }
+//        } else {
+//            throw new IllegalStateException("Another request is currently being processed. Please try again later.");
+//        }
+//    }
 }

+ 3 - 3
hx-customer/src/main/java/com/fjhx/customer/handle/HandleXiaomanData.java

@@ -31,6 +31,7 @@ import java.util.List;
 public class HandleXiaomanData {
     private static final String ALL_CUSTOMER_API_URL = "https://api-sandbox.xiaoman.cn/v1/company/list";
     private static XiaomanConfigService xiaomanConfigService = SpringUtils.getBean(XiaomanConfigService.class);
+    private static XiaomanCustomerService xiaomanCustomerService = SpringUtils.getBean(XiaomanCustomerService.class);
 
     private static final int PAGE_SIZE = 20;
 
@@ -53,10 +54,9 @@ public class HandleXiaomanData {
     public static CustomerListApiVo handleAllCustomer(String res){
         CustomerListApiVo customerListApiVo = handleList(res, new TypeReference<R<CustomerListApiVo>>() { });
 
-        XiaomanCustomerServiceImpl xiaomanCustomerService = SpringUtils.getBean(XiaomanCustomerServiceImpl.class);
         if (!customerListApiVo.getList().isEmpty()){
-            List<XiaomanCustomer> xiaomanCustomerList = new ArrayList<>(customerListApiVo.getList());
-            xiaomanCustomerService.saveOrUpdateBatch(xiaomanCustomerList);
+
+            xiaomanCustomerService.handleSaveOrUpdate(customerListApiVo.getList());
         }
 
         return customerListApiVo;

+ 319 - 0
hx-customer/src/main/java/com/fjhx/customer/handle/bbb.json

@@ -0,0 +1,319 @@
+{
+  "code": 200,
+  "message": "success",
+  "now": "2024-04-06 11:23:22",
+  "data": {
+    "company_id": 18669166854018,
+    "short_name": "",
+    "name": "Thu Pham",
+    "category_ids": [],
+    "serial_id": "86776",
+    "archive_time": "2024-04-01 15:55:43",
+    "owner": [
+      {
+        "user_id": "56322072",
+        "avatar": "https://v4client.oss-cn-hangzhou.aliyuncs.com/other/img/56322072/600d4e6ddf7d5b6ee403f5c6f522e79ea773f6ccf548e9d03ccc9a96988987d1.png",
+        "name": "Jimmy",
+        "nickname": "Jimmy"
+      }
+    ],
+    "archive_type": 4,
+    "country": "VN",
+    "biz_type": "",
+    "last_owner_info": {
+      "nickname": "无",
+      "user_id": 0,
+      "avatar": ""
+    },
+    "private_time": "2024-04-01 15:55:47",
+    "public_time": "",
+    "intention_level": 0,
+    "annual_procurement": 0,
+    "province": "",
+    "city": "",
+    "timezone": "7",
+    "scale_id": 0,
+    "star": 0,
+    "group_id": 0,
+    "trail_status": {
+      "status_id": "0",
+      "status_name": "无",
+      "status_color": "#cccccc"
+    },
+    "origin": 4,
+    "origin_list": [
+      4
+    ],
+    "origin_name": "阿里巴巴(B2B平台)",
+    "homepage": "",
+    "fax": "",
+    "tel": [
+      "",
+      ""
+    ],
+    "tel_area_code": "",
+    "address": "",
+    "remark": "",
+    "image_list": [],
+    "next_follow_up_time": "",
+    "create_user": 56322072,
+    "create_time": "2024-04-01 15:55:47",
+    "last_edit_user": "56322072",
+    "update_time": "2024-04-06 11:12:47",
+    "tag": [],
+    "product_group_ids": [],
+    "release_count": 0,
+    "public_type": 0,
+    "edit_time": "2024-04-06 11:12:46",
+    "main_lead_id": 0,
+    "order_time": "2024-04-06 11:12:47",
+    "recent_follow_up_time": "2024-04-01 15:55:48",
+    "client_tag_list": [],
+    "pool_user_map": [],
+    "company": [
+      {
+        "group_id": 1,
+        "name": "基本信息",
+        "fields": [
+          {
+            "id": "name",
+            "name": "公司名称",
+            "field_type": "1",
+            "value": "Thu Pham"
+          },
+          {
+            "id": "short_name",
+            "name": "简称",
+            "field_type": "1",
+            "value": ""
+          },
+          {
+            "id": "origin_list",
+            "name": "客户来源",
+            "field_type": "7",
+            "value": [
+              "阿里巴巴(B2B平台)"
+            ]
+          },
+          {
+            "id": "origin",
+            "name": "客户来源",
+            "field_type": 3,
+            "value": "阿里巴巴(B2B平台)"
+          }
+        ]
+      },
+      {
+        "group_id": 2,
+        "name": "特征信息",
+        "fields": [
+          {
+            "id": "biz_type",
+            "name": "客户类型",
+            "field_type": "3",
+            "value": ""
+          },
+          {
+            "id": "annual_procurement",
+            "name": "年采购额",
+            "field_type": "3",
+            "value": 0
+          },
+          {
+            "id": "country",
+            "name": "国家地区",
+            "field_type": "3",
+            "value": "VN"
+          },
+          {
+            "id": "intention_level",
+            "name": "采购意向",
+            "field_type": "3",
+            "value": 0
+          },
+          {
+            "id": "province",
+            "name": "省份",
+            "field_type": "3",
+            "value": ""
+          },
+          {
+            "id": "timezone",
+            "name": "时区",
+            "field_type": "3",
+            "value": "7"
+          },
+          {
+            "id": "city",
+            "name": "城市",
+            "field_type": "3",
+            "value": ""
+          },
+          {
+            "id": "scale_id",
+            "name": "规模",
+            "field_type": "3",
+            "value": 0
+          }
+        ]
+      },
+      {
+        "group_id": 3,
+        "name": "管理信息",
+        "fields": [
+          {
+            "id": "trail_status",
+            "name": "客户阶段",
+            "field_type": "3",
+            "value": "无"
+          }
+        ]
+      },
+      {
+        "group_id": 4,
+        "name": "联系信息",
+        "fields": [
+          {
+            "id": "homepage",
+            "name": "公司网址",
+            "field_type": "1",
+            "value": ""
+          },
+          {
+            "id": "fax",
+            "name": "传真",
+            "field_type": "1",
+            "value": ""
+          },
+          {
+            "id": "tel",
+            "name": "座机",
+            "field_type": "1",
+            "value": {
+              "tel_area_code": "",
+              "tel": ""
+            }
+          },
+          {
+            "id": "address",
+            "name": "详细地址",
+            "field_type": "2",
+            "value": ""
+          }
+        ]
+      },
+      {
+        "group_id": 5,
+        "name": "其他信息",
+        "fields": [
+          {
+            "id": "remark",
+            "name": "公司备注",
+            "field_type": "2",
+            "value": ""
+          },
+          {
+            "id": "14200691088213",
+            "name": "餐厨用品",
+            "field_type": "3",
+            "value": ""
+          }
+        ]
+      }
+    ],
+    "lead": {
+      "main_lead_id": 0,
+      "lead_name": null
+    },
+    "customers": [
+      {
+        "customer_id": 18669166853969,
+        "company_id": 18669166854018,
+        "name": "Thu Pham",
+        "email": "thupham99vn@gmail.com",
+        "gender": 0,
+        "remark": "",
+        "birth": "",
+        "tel_list": [],
+        "post_grade": 1,
+        "post": "",
+        "image_list": "",
+        "contact": [],
+        "main_customer_flag": 1,
+        "external_field_data": []
+      }
+    ],
+    "alibaba_store_info": [
+      {
+        "store_id": "239374100",
+        "store_name": "福建尔泓时代家居用品有限公司",
+        "enable_flag": "1",
+        "oauth_flag": "1",
+        "sync_customer_flag": "1"
+      }
+    ],
+    "source_detail": {
+      "alibaba_store_info": [
+        {
+          "store_id": "239374100",
+          "store_name": "福建尔泓时代家居用品有限公司",
+          "enable_flag": "1",
+          "oauth_flag": "1",
+          "sync_customer_flag": "1"
+        }
+      ],
+      "site_info": []
+    },
+    "alibaba_relation_list": [
+      {
+        "store_id": 239374100,
+        "alibaba_company_name": "Thu Pham",
+        "owner_account_id": 251531563,
+        "detail_url": "https://alicrm.alibaba.com/#customerId=ba19b4a20a40ca9779ac57de5ab31a34",
+        "company_id": 18669166854018,
+        "owner_info": {
+          "seller_account_id": "251531563",
+          "seller_email": "sale5@bridge-style.cc",
+          "enable_flag": "1",
+          "login_id": "cn1541243301embs",
+          "first_name": "Jimmy",
+          "last_name": "Wang"
+        },
+        "last_owner_info": {
+          "seller_account_id": 0,
+          "seller_email": "",
+          "enable_flag": 0,
+          "first_name": "",
+          "last_name": "",
+          "login_id": ""
+        },
+        "company_info": {
+          "company_id": 18669166854018,
+          "name": "Thu Pham",
+          "serial_id": "86776",
+          "pool_id": 0,
+          "is_archive": 1,
+          "create_time": "2024-04-01 15:55:47",
+          "trail_status": 0,
+          "user_id": [
+            56322072
+          ],
+          "user_info": [
+            {
+              "user_id": "56322072",
+              "nickname": "Jimmy"
+            }
+          ]
+        },
+        "store_info": {
+          "store_id": "239374100",
+          "store_name": "福建尔泓时代家居用品有限公司",
+          "delete_flag": false,
+          "exception": 0
+        }
+      }
+    ],
+    "deal_time": "",
+    "country_name": "越南"
+  }
+}

+ 2 - 0
hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/XiaomanCustomerService.java

@@ -1,6 +1,7 @@
 package com.fjhx.customer.service.xiaoman;
 
 import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
+import com.fjhx.customer.entity.xiaoman.vo.CustomerApiVo;
 import com.ruoyi.common.core.service.BaseService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.customer.entity.xiaoman.vo.XiaomanCustomerVo;
@@ -49,4 +50,5 @@ public interface XiaomanCustomerService  {
      */
     void delete(Long id);
 
+    void handleSaveOrUpdate(List<CustomerApiVo> customerApiVoList);
 }

+ 9 - 0
hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/impl/XiaomanCustomerServiceImpl.java

@@ -1,6 +1,8 @@
 package com.fjhx.customer.service.xiaoman.impl;
 
 import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
+import com.fjhx.customer.entity.xiaoman.vo.CustomerApiVo;
+import com.fjhx.customer.entity.xiaoman.vo.CustomerListApiVo;
 import com.fjhx.customer.mapper.xiaoman.XiaomanCustomerMapper;
 import com.fjhx.customer.service.xiaoman.XiaomanCustomerService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -12,6 +14,7 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerDto;
 import cn.hutool.core.bean.BeanUtil;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import static com.ruoyi.common.utils.wrapper.IWrapper.getWrapper;
@@ -65,4 +68,10 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
         this.removeById(id);
     }
 
+    @Override
+    public void handleSaveOrUpdate(List<CustomerApiVo> customerApiVoList) {
+        List<XiaomanCustomer> xiaomanCustomerList = new ArrayList<>(customerApiVoList);
+        saveOrUpdateBatch(xiaomanCustomerList);
+
+    }
 }