|
@@ -0,0 +1,237 @@
|
|
|
+package com.ygj.yuemum.component;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicCyDto;
|
|
|
+import com.ygj.yuemum.domain.customer.dto.CustomerInfoFeedbackCyDto;
|
|
|
+import com.ygj.yuemum.domain.customer.dto.CustomerInfoFollowCyDto;
|
|
|
+import com.ygj.yuemum.service.customer.CustomerInfoBasicService;
|
|
|
+import com.ygj.yuemum.service.customer.CustomerInfoFeedbackService;
|
|
|
+import com.ygj.yuemum.service.customer.CustomerInfoFollowService;
|
|
|
+import com.ygj.yuemum.service.scheduled.CYScheduledService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 氚云返回数据格式, ReturnData 没有数据时时会为 null
|
|
|
+ * {
|
|
|
+ * "ReturnData":{
|
|
|
+ * "BizObjectArray":[
|
|
|
+ * {}
|
|
|
+ * ]
|
|
|
+ * },
|
|
|
+ * "Logined":false,
|
|
|
+ * "DataType":0,
|
|
|
+ * "Successful":true
|
|
|
+ * }
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class CyScheduled {
|
|
|
+
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(CyScheduled.class);
|
|
|
+
|
|
|
+ private static final String ENPTYDATE= "2000-01-01 01:01:10";
|
|
|
+
|
|
|
+ private static final String CIFBSchemaCode = "e3i1ixenjat08xho5hy3zp2c4";
|
|
|
+
|
|
|
+ private static final String CIBSchemaCode = "twjff2zg1n2lwdrfkwbqnqne5";
|
|
|
+
|
|
|
+ private static final String CIFSchemaCode = "ajxhpu8n5e3n2272xda8k38o3";
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CYScheduledService cyScheduledService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CustomerInfoFeedbackService customerInfoFeedbackService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CustomerInfoBasicService customerInfoBasicService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CustomerInfoFollowService customerInfoFollowService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 信息反馈表,
|
|
|
+ */
|
|
|
+ public void initCustomerInfoFeedback(int fromRowNum, int toRowNum) {
|
|
|
+ JSONObject jsonObject;
|
|
|
+ try {
|
|
|
+ jsonObject = cyScheduledService.listFormData(CIFBSchemaCode, fromRowNum, toRowNum);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("信息反馈表数据导入有问题" + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject jsonObject1 = jsonObject.getJSONObject("ReturnData");
|
|
|
+ if (jsonObject1 == null) {
|
|
|
+ logger.info("没有返回值,可能数据导完了");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = jsonObject1.getJSONArray("BizObjectArray");
|
|
|
+ List<CustomerInfoFeedbackCyDto> list = convertRtData2CIFBList(jsonArray);
|
|
|
+ customerInfoFeedbackService.insertInfoFeedbackList(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户信息表
|
|
|
+ */
|
|
|
+ public void initCustomerInfoBasic(int fromRowNum, int toRowNum) {
|
|
|
+ JSONObject jsonObject;
|
|
|
+ try {
|
|
|
+ jsonObject = cyScheduledService.listFormData(CIBSchemaCode, fromRowNum, toRowNum);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("信息基础表数据导入有问题" + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject jsonObject1 = jsonObject.getJSONObject("ReturnData");
|
|
|
+ if (jsonObject1 == null) {
|
|
|
+ logger.info("没有返回值,可能数据导完了");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = jsonObject1.getJSONArray("BizObjectArray");
|
|
|
+ List<CustomerInfoBasicCyDto> list = convertRtData2CIBList(jsonArray);
|
|
|
+ customerInfoBasicService.insertInfoBasicList(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initCustomerInfoFollow(int fromRowNum, int toRowNum) {
|
|
|
+ JSONObject jsonObject;
|
|
|
+ try {
|
|
|
+ jsonObject = cyScheduledService.listFormData(CIFSchemaCode, fromRowNum, toRowNum);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("信息跟进表数据导入有问题" + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject jsonObject1 = jsonObject.getJSONObject("ReturnData");
|
|
|
+ if (jsonObject1 == null) {
|
|
|
+ logger.info("没有返回值,可能数据导完了");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = jsonObject1.getJSONArray("BizObjectArray");
|
|
|
+ List<CustomerInfoFollowCyDto> list = convertRtData2CIFList(jsonArray);
|
|
|
+ customerInfoFollowService.insertInfoFollowList(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<CustomerInfoFeedbackCyDto> convertRtData2CIFBList(JSONArray jsonArray) {
|
|
|
+ List<CustomerInfoFeedbackCyDto> customerInfoFeedbacks = new ArrayList<>(jsonArray.size() * 2);
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject jObj = jsonArray.getJSONObject(i);
|
|
|
+ CustomerInfoFeedbackCyDto customerInfoFeedback = new CustomerInfoFeedbackCyDto();
|
|
|
+ customerInfoFeedback.setFb_date(jObj.getString("Fd70b7fe2c26543b7a0dc5e842f01505a"));
|
|
|
+ customerInfoFeedback.setSource_channel(jObj.getString("F65c267199c244ab781911ae917c19e23"));
|
|
|
+ customerInfoFeedback.setFb_customer_phone(jObj.getString("F2eaf0b5866324133ae25469e15bfcbeb"));
|
|
|
+ customerInfoFeedback.setBranche_name(jObj.getString("F0000001"));
|
|
|
+ customerInfoFeedback.setFb_type(jObj.getString("F69ae33f6130a456bb49d9c3eda150924"));
|
|
|
+ customerInfoFeedback.setCreate_person(jObj.getString("CreatedBy"));
|
|
|
+ customerInfoFeedback.setIn_charge_person(jObj.getString("F0000005"));
|
|
|
+ customerInfoFeedback.setCustomer_manager(jObj.getString("OwnerId"));
|
|
|
+ customerInfoFeedback.setEntry_date(jObj.getString("CreatedTime"));
|
|
|
+ customerInfoFeedback.setP_code(jObj.getString("F0000012"));
|
|
|
+ customerInfoFeedback.setFb_customer_name(jObj.getString("Feee971d2c7744512951911969636b29a"));
|
|
|
+ customerInfoFeedback.setFb_wechat_number(jObj.getString("F0000010"));
|
|
|
+ customerInfoFeedback.setEdc_date(jObj.getString("F6d79882ffa4145f797ae2d7463087f05"));
|
|
|
+ customerInfoFeedback.setFb_remarks(jObj.getString("fb_remarks"));
|
|
|
+ customerInfoFeedback.setStore(jObj.getString("Fa8590df8fe8546458f799d71e3514a71"));
|
|
|
+ JSONArray jsonArray1 = jObj.getJSONArray("Fe568775265f74579a6f6d54cfabba349");
|
|
|
+ if (jsonArray1 != null && jsonArray1.size() > 0) {
|
|
|
+ JSONObject jsonObject1 = jsonArray1.getJSONObject(0);
|
|
|
+ if (jsonObject1.getString("F6016dc1446df4ce0b9c6ef3fc19bb89a") != null) {
|
|
|
+ customerInfoFeedback.setIt_on(jsonObject1.getString("F6016dc1446df4ce0b9c6ef3fc19bb89a"));
|
|
|
+ } else {
|
|
|
+ customerInfoFeedback.setIt_on("");
|
|
|
+ }
|
|
|
+ if (jsonObject1.getString("F0000008") != null) {
|
|
|
+ customerInfoFeedback.setCommunication_content(jsonObject1.getString("F0000008"));
|
|
|
+ } else {
|
|
|
+ customerInfoFeedback.setCommunication_content("");
|
|
|
+ }
|
|
|
+ if (jsonObject1.getDate("") != null) {
|
|
|
+ customerInfoFeedback.setConvenient_time(jObj.getString(""));
|
|
|
+ } else {
|
|
|
+ customerInfoFeedback.setConvenient_time(ENPTYDATE);
|
|
|
+ }
|
|
|
+ if (jsonObject1.getString("") != null) {
|
|
|
+ customerInfoFeedback.setUser_feedback(jsonObject1.getString(""));
|
|
|
+ } else {
|
|
|
+ customerInfoFeedback.setUser_feedback("");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ customerInfoFeedback.setIt_on("");
|
|
|
+ customerInfoFeedback.setCommunication_content("");
|
|
|
+ customerInfoFeedback.setConvenient_time(ENPTYDATE);
|
|
|
+ customerInfoFeedback.setUser_feedback("");
|
|
|
+ }
|
|
|
+ customerInfoFeedbacks.add(customerInfoFeedback);
|
|
|
+ }
|
|
|
+
|
|
|
+ return customerInfoFeedbacks;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param jsonArray
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<CustomerInfoBasicCyDto> convertRtData2CIBList(JSONArray jsonArray) {
|
|
|
+ List<CustomerInfoBasicCyDto> list = new ArrayList<>(jsonArray.size() * 2);
|
|
|
+ for (int i = 0;i < jsonArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+ CustomerInfoBasicCyDto customerInfoBasicCyDto = new CustomerInfoBasicCyDto();
|
|
|
+ customerInfoBasicCyDto.setBranche_name(jsonObject.getString("F0000002"));
|
|
|
+ customerInfoBasicCyDto.setFb_customer_name(jsonObject.getString("F0000004"));
|
|
|
+ customerInfoBasicCyDto.setFb_customer_phone(jsonObject.getString("F0000005"));
|
|
|
+ customerInfoBasicCyDto.setP_code(jsonObject.getString("F0000029"));
|
|
|
+ customerInfoBasicCyDto.setFb_wechat_number(jsonObject.getString("F0000007"));
|
|
|
+ customerInfoBasicCyDto.setSource_channel(jsonObject.getString("F0000014"));
|
|
|
+ customerInfoBasicCyDto.setCustomer_state(jsonObject.getString("F0000013"));
|
|
|
+ customerInfoBasicCyDto.setEdc_date(jsonObject.getString("F0000009"));
|
|
|
+ customerInfoBasicCyDto.setPregnancy_way(jsonObject.getString("F0000038"));
|
|
|
+
|
|
|
+ JSONObject jsonObject1 = jsonObject.getJSONObject("F0000010");
|
|
|
+ if (jsonObject1 != null) {
|
|
|
+ customerInfoBasicCyDto.setAddress_basic(jsonObject1.getString("adcode"));
|
|
|
+ customerInfoBasicCyDto.setAddress_detail(jsonObject1.getString("Detail"));
|
|
|
+ }
|
|
|
+
|
|
|
+ customerInfoBasicCyDto.setFb_remarks(jsonObject.getString("F0000011"));
|
|
|
+ customerInfoBasicCyDto.setEntry_date(jsonObject.getString("CreatedTime"));
|
|
|
+ customerInfoBasicCyDto.setCreate_person(jsonObject.getString("CreatedBy"));
|
|
|
+ customerInfoBasicCyDto.setFb_date(jsonObject.getString("F0000024"));
|
|
|
+ list.add(customerInfoBasicCyDto);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param jsonArray
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<CustomerInfoFollowCyDto> convertRtData2CIFList(JSONArray jsonArray) {
|
|
|
+ List<CustomerInfoFollowCyDto> list = new ArrayList<>(jsonArray.size() * 2);
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+ CustomerInfoFollowCyDto customerInfoFollowCyDto = new CustomerInfoFollowCyDto();
|
|
|
+ customerInfoFollowCyDto.setCreate_date(jsonObject.getString("CreatedTime"));
|
|
|
+ customerInfoFollowCyDto.setFollow_mehtod(jsonObject.getString("F0000006"));
|
|
|
+ customerInfoFollowCyDto.setFb_customer_name(jsonObject.getString("F0000021"));
|
|
|
+ customerInfoFollowCyDto.setFb_customer_phone(jsonObject.getString("F0000016"));
|
|
|
+ customerInfoFollowCyDto.setSource_channel(jsonObject.getString("F0000017"));
|
|
|
+ customerInfoFollowCyDto.setEdc_date(jsonObject.getString("F0000022"));
|
|
|
+ customerInfoFollowCyDto.setFollow_state(jsonObject.getString("F0000007"));
|
|
|
+ customerInfoFollowCyDto.setAddress(jsonObject.getString("F0000008"));
|
|
|
+ customerInfoFollowCyDto.setFollow_desc(jsonObject.getString("F0000009"));
|
|
|
+ customerInfoFollowCyDto.setPhotos("");
|
|
|
+ customerInfoFollowCyDto.setNext_follow_date(jsonObject.getString("F0000011"));
|
|
|
+ customerInfoFollowCyDto.setCreate_person(jsonObject.getString("CreatedBy"));
|
|
|
+ customerInfoFollowCyDto.setFb_date(jsonObject.getString("F0000023"));
|
|
|
+ list.add(customerInfoFollowCyDto);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|