|
@@ -1,16 +1,24 @@
|
|
|
package com.fjhx.customer.handle;
|
|
|
|
|
|
|
|
|
-import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.fjhx.customer.entity.xiaoman.vo.CustomerApiVo;
|
|
|
+import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
|
|
|
import com.fjhx.customer.entity.xiaoman.vo.CustomerListApiVo;
|
|
|
+import com.fjhx.customer.service.xiaoman.XiaomanCustomerService;
|
|
|
+import com.fjhx.customer.service.xiaoman.impl.XiaomanCustomerServiceImpl;
|
|
|
+import com.ruoyi.common.utils.spring.SpringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
+import javax.swing.*;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class HandleXiaomanData {
|
|
|
|
|
@@ -26,12 +34,26 @@ public class HandleXiaomanData {
|
|
|
jsonData += line;
|
|
|
}
|
|
|
|
|
|
- handleList(jsonData, new TypeReference<R<CustomerListApiVo>>() {});
|
|
|
+ handleAllCustomer(jsonData);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ return customerListApiVo;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public static <T> T handleList(String res, TypeReference<R<T>> typeReference) {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
try {
|