更新
This commit is contained in:
parent
728df54510
commit
bf0de882b4
50
data/magic-api/api/B-传输日志/日志/保存客户.ms
Normal file
50
data/magic-api/api/B-传输日志/日志/保存客户.ms
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"properties" : { },
|
||||
"id" : "copy1745307476745d27404",
|
||||
"script" : null,
|
||||
"groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
|
||||
"name" : "保存客户",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1745307494790,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : null,
|
||||
"path" : "/savecustomer",
|
||||
"method" : "POST",
|
||||
"parameters" : [ ],
|
||||
"options" : [ {
|
||||
"name" : "wrap_request_parameter",
|
||||
"value" : "data",
|
||||
"description" : null,
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
}, {
|
||||
"name" : "permission",
|
||||
"value" : "send:log:save",
|
||||
"description" : "允许拥有该权限的访问",
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
} ],
|
||||
"requestBody" : "",
|
||||
"headers" : [ ],
|
||||
"paths" : [ ],
|
||||
"responseBody" : null,
|
||||
"description" : null,
|
||||
"requestBodyDefinition" : null,
|
||||
"responseBodyDefinition" : null
|
||||
}
|
||||
================================
|
||||
data.create_time = new Date()
|
||||
return db.table('send_log_customer').primary('log_id',uuid()).save(data)
|
@ -3,9 +3,9 @@
|
||||
"id" : "d0c872104e524be0862e004fe29771c3",
|
||||
"script" : null,
|
||||
"groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
|
||||
"name" : "保存",
|
||||
"name" : "保存客户分类",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1740193136821,
|
||||
"updateTime" : 1745307472124,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : null,
|
||||
@ -47,4 +47,4 @@
|
||||
}
|
||||
================================
|
||||
data.create_time = new Date()
|
||||
return db.table('send_log_plmbom').primary('log_id',uuid()).save(data)
|
||||
return db.table('send_log_customergroup').primary('log_id',uuid()).save(data)
|
126
data/magic-api/api/B-同步日志/修改客户同步.ms
Normal file
126
data/magic-api/api/B-同步日志/修改客户同步.ms
Normal file
@ -0,0 +1,126 @@
|
||||
{
|
||||
"properties" : { },
|
||||
"id" : "copy1745307450958d20455",
|
||||
"script" : null,
|
||||
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||
"name" : "修改客户同步",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1745307461569,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : null,
|
||||
"path" : "/updatecustomer",
|
||||
"method" : "POST",
|
||||
"parameters" : [ ],
|
||||
"options" : [ {
|
||||
"name" : "wrap_request_parameter",
|
||||
"value" : "data",
|
||||
"description" : null,
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
}, {
|
||||
"name" : "permission",
|
||||
"value" : "send:log:save",
|
||||
"description" : "允许拥有该权限的访问",
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
} ],
|
||||
"requestBody" : "",
|
||||
"headers" : [ ],
|
||||
"paths" : [ ],
|
||||
"responseBody" : "{\n \"code\": 500,\n \"message\": \"系统内部出现错误\",\n \"data\": null,\n \"timestamp\": 1701350039104,\n \"executeTime\": 4\n}",
|
||||
"description" : null,
|
||||
"requestBodyDefinition" : null,
|
||||
"responseBodyDefinition" : {
|
||||
"name" : "",
|
||||
"value" : "",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Object",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ {
|
||||
"name" : "code",
|
||||
"value" : "500",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Integer",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "message",
|
||||
"value" : "系统内部出现错误",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "data",
|
||||
"value" : "null",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Object",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "timestamp",
|
||||
"value" : "1701350039104",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Long",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "executeTime",
|
||||
"value" : "4",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Integer",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
} ]
|
||||
}
|
||||
}
|
||||
================================
|
||||
|
||||
|
||||
|
||||
data.update_time = new Date()
|
||||
return db.table("send_syn_customer").primary('send_id')
|
||||
.update(data)
|
126
data/magic-api/api/B-同步日志/客户待同步保存.ms
Normal file
126
data/magic-api/api/B-同步日志/客户待同步保存.ms
Normal file
@ -0,0 +1,126 @@
|
||||
{
|
||||
"properties" : { },
|
||||
"id" : "copy1745307427497d38560",
|
||||
"script" : null,
|
||||
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||
"name" : "客户待同步保存",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1745307448992,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : null,
|
||||
"path" : "/savecustomer",
|
||||
"method" : "POST",
|
||||
"parameters" : [ ],
|
||||
"options" : [ {
|
||||
"name" : "wrap_request_parameter",
|
||||
"value" : "data",
|
||||
"description" : null,
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
}, {
|
||||
"name" : "permission",
|
||||
"value" : "send:log:save",
|
||||
"description" : "允许拥有该权限的访问",
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
} ],
|
||||
"requestBody" : "",
|
||||
"headers" : [ ],
|
||||
"paths" : [ ],
|
||||
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": \"17a8bc5553e2400badd36ea784255c01\",\n \"timestamp\": 1701350036264,\n \"executeTime\": 4\n}",
|
||||
"description" : null,
|
||||
"requestBodyDefinition" : null,
|
||||
"responseBodyDefinition" : {
|
||||
"name" : "",
|
||||
"value" : "",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Object",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ {
|
||||
"name" : "code",
|
||||
"value" : "200",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Integer",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "message",
|
||||
"value" : "success",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "data",
|
||||
"value" : "17a8bc5553e2400badd36ea784255c01",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "timestamp",
|
||||
"value" : "1701350036264",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Long",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "executeTime",
|
||||
"value" : "4",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Integer",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : "",
|
||||
"error" : "",
|
||||
"expression" : "",
|
||||
"children" : [ ]
|
||||
} ]
|
||||
}
|
||||
}
|
||||
================================
|
||||
|
||||
|
||||
|
||||
data.create_time = new Date()
|
||||
return db.table("send_syn_customer").primary('send_id', () => uuid())
|
||||
.save(data)
|
@ -3,17 +3,17 @@
|
||||
"id" : "95d66a27a4794b8c8126ad131743da56",
|
||||
"script" : null,
|
||||
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||
"name" : "查询",
|
||||
"name" : "查询客户分类同步",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1742968099755,
|
||||
"updateTime" : 1744339012019,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : null,
|
||||
"path" : "/query",
|
||||
"path" : "/querygroup",
|
||||
"method" : "GET",
|
||||
"parameters" : [ {
|
||||
"name" : "sendType",
|
||||
"value" : "TuiHuo",
|
||||
"value" : "group",
|
||||
"description" : null,
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
@ -24,32 +24,8 @@
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
}, {
|
||||
"name" : "sendStatus3",
|
||||
"value" : "3",
|
||||
"description" : null,
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
}, {
|
||||
"name" : "crmId",
|
||||
"value" : "665532391d23d0000111cab9",
|
||||
"description" : null,
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
"type" : null,
|
||||
"defaultValue" : null,
|
||||
"validateType" : null,
|
||||
"error" : null,
|
||||
"expression" : null,
|
||||
"children" : null
|
||||
}, {
|
||||
"name" : "sendSyn",
|
||||
"value" : "0",
|
||||
"name" : "dataId",
|
||||
"value" : "北京市",
|
||||
"description" : null,
|
||||
"required" : false,
|
||||
"dataType" : "String",
|
||||
@ -64,7 +40,7 @@
|
||||
"requestBody" : "",
|
||||
"headers" : [ ],
|
||||
"paths" : [ ],
|
||||
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": [],\n \"timestamp\": 1716889610473,\n \"executeTime\": 8\n}",
|
||||
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": [],\n \"timestamp\": 1744339010854,\n \"executeTime\": 91\n}",
|
||||
"description" : null,
|
||||
"requestBodyDefinition" : null,
|
||||
"responseBodyDefinition" : {
|
||||
@ -116,7 +92,7 @@
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "timestamp",
|
||||
"value" : "1716889610473",
|
||||
"value" : "1744339010854",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Long",
|
||||
@ -128,7 +104,7 @@
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "executeTime",
|
||||
"value" : "8",
|
||||
"value" : "91",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Integer",
|
||||
@ -145,29 +121,15 @@
|
||||
//查询本机mysql
|
||||
return db.select(
|
||||
"""
|
||||
SELECT * FROM `send_syn_plmbom` where
|
||||
send_type=#{sendType}
|
||||
SELECT * FROM `send_log_customergroup` where
|
||||
log_type=#{sendType}
|
||||
<if test="dataId != null">
|
||||
and dsf_id=#{dataId}
|
||||
</if>
|
||||
<if test="datapId != null">
|
||||
and dsfzhu_id=#{datapId}
|
||||
and data_id=#{dataId}
|
||||
</if>
|
||||
<if test="sendSyn != null">
|
||||
and send_syn=#{sendSyn}
|
||||
</if>
|
||||
<if test="sendStatus != null">
|
||||
and send_status=#{sendStatus}
|
||||
</if>
|
||||
<if test="crmId != null">
|
||||
and crm_id=#{crmId}
|
||||
</if>
|
||||
<if test="dsfId != null">
|
||||
and dsf_id=#{dsfId}
|
||||
</if>
|
||||
<if test="sendStatus3 != null">
|
||||
and send_status!=#{sendStatus3}
|
||||
and syn_type=#{sendSyn}
|
||||
</if>
|
||||
|
||||
order by create_time desc
|
||||
|
||||
""");
|
@ -3,13 +3,13 @@
|
||||
"id" : "copy1732497876949d77458",
|
||||
"script" : null,
|
||||
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||
"name" : "查询new",
|
||||
"name" : "查询客户同步日志",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1732497893388,
|
||||
"updateTime" : 1745307421060,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : null,
|
||||
"path" : "/querynew",
|
||||
"path" : "/queryCustomer",
|
||||
"method" : "GET",
|
||||
"parameters" : [ {
|
||||
"name" : "sendType",
|
||||
@ -145,7 +145,7 @@
|
||||
//查询本机mysql
|
||||
return db.select(
|
||||
"""
|
||||
SELECT crm_json,send_id FROM `send_syn_info` where
|
||||
SELECT * FROM `send_syn_customer` where
|
||||
send_type=#{sendType}
|
||||
<if test="dataId != null">
|
||||
and dsf_id=#{dataId}
|
@ -32,7 +32,7 @@ public class UsceController {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new UsceController().getUserData();
|
||||
// new UsceController().saveSynUser();
|
||||
new UsceController().saveSynUser();
|
||||
}
|
||||
|
||||
@PostMapping("/getUserData")
|
||||
@ -51,7 +51,7 @@ public class UsceController {
|
||||
datajson.put("createtime","2012-02-26 11:04:43");
|
||||
JSONArray arr = new JSONArray();
|
||||
String[] strings = {
|
||||
"ZHY005.001.004"
|
||||
"ZHY003.009"
|
||||
};
|
||||
|
||||
// 将字符串添加到 JSONArray 中
|
||||
|
@ -0,0 +1,474 @@
|
||||
package org.ssssssss.magicboot.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.ssssssss.magicboot.fxapi.HttpClientResult;
|
||||
import org.ssssssss.magicboot.fxapi.HttpClientUtils;
|
||||
import org.ssssssss.magicboot.fxapi.XKTokenAccess;
|
||||
import org.ssssssss.magicboot.fxapi.model.CrmFXApiParam;
|
||||
import org.ssssssss.magicboot.zdyutils.FXHTTP;
|
||||
import org.ssssssss.magicboot.zdyutils.FXTIC;
|
||||
import org.ssssssss.magicboot.zdyutils.GcjJson;
|
||||
import org.ssssssss.magicboot.zdyutils.MagicApi;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/customer")
|
||||
public class customerController {
|
||||
static Logger log = LoggerFactory.getLogger("customer");
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new customerController().getSynDataUpdate();
|
||||
new customerController().getSynKHUPdate();
|
||||
|
||||
}
|
||||
|
||||
public void getSynDataAdd() throws Exception {
|
||||
FXHTTP fxapi = new FXHTTP();
|
||||
XKTokenAccess xktonken = new XKTokenAccess();
|
||||
// 查询magic接口
|
||||
//获取时间戳
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String time = sdf.format(System.currentTimeMillis() - (1000 * 60 * 60));
|
||||
|
||||
String apiName = "AccountObj";
|
||||
|
||||
List<CrmFXApiParam> paramList = Arrays.asList(
|
||||
new CrmFXApiParam("GT", "last_modified_time", System.currentTimeMillis() - (1000 * 60 * 60 * 24)),
|
||||
new CrmFXApiParam("IS", "erp_id__c", ""),
|
||||
new CrmFXApiParam("ISN", "erp_category__c", ""),
|
||||
new CrmFXApiParam("EQ", "life_status", "normal")
|
||||
);
|
||||
|
||||
|
||||
/* List<CrmFXApiParam> paramList = Arrays.asList(new CrmFXApiParam("EQ", "name", "河北省水利行业协会"));*/
|
||||
|
||||
JSONObject jsonject = fxapi.getSynNewDataObj(false, "客户", apiName, paramList);
|
||||
JSONArray array = jsonject.getJSONObject("data").getJSONArray("dataList");
|
||||
|
||||
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject str = array.getJSONObject(i);
|
||||
String dataId = GcjJson.getNodeValue(str, "JSON._id") != null ? GcjJson.getNodeValue(str, "JSON._id").toString() : "";
|
||||
String nameData = GcjJson.getNodeValue(str, "JSON.name") != null ? GcjJson.getNodeValue(str, "JSON.name").toString() : "";
|
||||
|
||||
String syn_type = "0";//同步类型 0新增 1修改 2删除
|
||||
log.info("-------------------开始执行客户" + i + " -------------------" + nameData);
|
||||
XxlJobHelper.log("-------------------开始执行客户" + i + " -------------------" + nameData);
|
||||
|
||||
Boolean sendFlag = false;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
|
||||
try {
|
||||
boolean tbflag = false;
|
||||
//验证数据是否已存在
|
||||
JSONObject dataSyn = MagicApi.getSendSYNDataCustomer("KH", syn_type, dataId);
|
||||
|
||||
if (dataSyn != null && dataId.equals(dataSyn.getString("crmId"))) {
|
||||
log.info("数据已存在-" + nameData);
|
||||
XxlJobHelper.log("--数据已存在---" + nameData);
|
||||
tbflag = true;
|
||||
}
|
||||
if (tbflag) {
|
||||
continue;
|
||||
}
|
||||
log.info("客户待同步数据-" + i + " ------" + nameData);
|
||||
JSONObject jsonObjectData = new JSONObject();
|
||||
jsonObjectData.put("send_type", "KH"); //业务类型
|
||||
jsonObjectData.put("send_syn", "0"); //同步类型 0新增 1修改 2删除
|
||||
jsonObjectData.put("crm_id", dataId);//数据id
|
||||
jsonObjectData.put("crmzhu_id", dataId);//数据id
|
||||
jsonObjectData.put("send_status", 3);//同步状态 true同步成功 false同步失败 3待同步
|
||||
jsonObjectData.put("crm_code", nameData);//数据名称
|
||||
jsonObjectData.put("mark", nameData);//标识
|
||||
jsonObjectData.put("crm_json", str.toJSONString());//标识
|
||||
|
||||
MagicApi.saveSendSYNDatacustomer(jsonObjectData);
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void getSynKH() throws Exception {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
FXHTTP fxapi = new FXHTTP();
|
||||
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryCustomer?sendType=KH&sendStatus=3&sendSyn=0", "");
|
||||
JSONObject resJson = JSON.parseObject(resJsonStr);
|
||||
if (resJson != null) {
|
||||
log.info("待同步客户数" + resJson.getJSONArray("data").size());
|
||||
for (int i = 0; i < resJson.getJSONArray("data").size(); i++) {
|
||||
|
||||
JSONObject getData = resJson.getJSONArray("data").getJSONObject(i);
|
||||
JSONObject str = getData.getJSONObject("crmJson");
|
||||
String syn_type = "0";//同步类型 0新增 1修改 2删除
|
||||
Boolean sendFlag = false;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
boolean tbflag = false;
|
||||
// 构建json
|
||||
|
||||
String dataId = GcjJson.getNodeValue(str, "JSON._id") != null ? GcjJson.getNodeValue(str, "JSON._id").toString() : "";
|
||||
String nameData = GcjJson.getNodeValue(str, "JSON.name") != null ? GcjJson.getNodeValue(str, "JSON.name").toString() : "";
|
||||
String societycreditcode = GcjJson.getNodeValue(str, "JSON.uniform_social_credit_code") != null ? GcjJson.getNodeValue(str, "JSON.uniform_social_credit_code").toString() : "";
|
||||
String simplename = GcjJson.getNodeValue(str, "JSON.abbreviation__c") != null ? GcjJson.getNodeValue(str, "JSON.abbreviation__c").toString() : "";
|
||||
|
||||
String account_no = GcjJson.getNodeValue(str, "JSON.account_no") != null ? GcjJson.getNodeValue(str, "JSON.account_no").toString() : "";
|
||||
String erp_category__c = GcjJson.getNodeValue(str, "JSON.erp_category__c") != null ? GcjJson.getNodeValue(str, "JSON.erp_category__c").toString() : "";
|
||||
|
||||
|
||||
String strJson = "";
|
||||
try{
|
||||
JSONObject dataSyn = MagicApi.getSendSYNDataCustomer("KH", syn_type, dataId,"3");
|
||||
if (dataSyn != null && dataId.equals(dataSyn.getString("crmId"))) {
|
||||
log.info("数据已存在-" + nameData);
|
||||
XxlJobHelper.log("--数据已存在---" + nameData);
|
||||
tbflag = true;
|
||||
}
|
||||
if (tbflag) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject params = new JSONObject();
|
||||
|
||||
JSONArray dataarr = new JSONArray();
|
||||
JSONObject datajson = new JSONObject();
|
||||
//统一社会信用代码
|
||||
datajson.put("societycreditcode",societycreditcode);
|
||||
//简称
|
||||
datajson.put("simplename",simplename);
|
||||
datajson.put("taxrate_number","V13");//税率
|
||||
datajson.put("settlementcyid_number","CNY");//交易币.货币代码
|
||||
//纳税人识别号
|
||||
datajson.put("tx_register_no",societycreditcode);
|
||||
//编码
|
||||
datajson.put("number",account_no);
|
||||
datajson.put("paymentcurrency_number","CNY");//付款币种.货币代码
|
||||
datajson.put("name",nameData);//客户名称
|
||||
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||
// datajson.put("settlementtypeid_number","JSFS04");//结算方式
|
||||
|
||||
JSONArray groupstandardarr = new JSONArray();
|
||||
JSONObject groupstandardjson = new JSONObject();
|
||||
groupstandardjson.put("groupid_number",erp_category__c);
|
||||
groupstandardjson.put("standardid_number","JBFLBZ");
|
||||
groupstandardarr.add(groupstandardjson);
|
||||
datajson.put("entry_groupstandard",groupstandardarr);//分类标准
|
||||
|
||||
//创建组织
|
||||
datajson.put("createorg_number","zycxjtpoc.test");
|
||||
dataarr.add(datajson);
|
||||
params.put("data",dataarr);
|
||||
log.info("--请求json---" + params.toJSONString());
|
||||
System.out.println("--请求json:---" +params.toJSONString());
|
||||
strJson = params.toJSONString();
|
||||
|
||||
}catch (Exception e) {
|
||||
sendFlag = true;
|
||||
stringBuffer.append("参数解析错误,请联系开发人员");
|
||||
e.printStackTrace();
|
||||
}
|
||||
getSynDataSave(stringBuffer,sendFlag,fxapi,dataId,nameData,strJson,getData);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 写数据
|
||||
*/
|
||||
public void getSynDataSave(StringBuffer stringBuffer,Boolean sendFlag,FXHTTP fxapi,String dataId,String nameData,String obj,JSONObject str) {
|
||||
String syn_type = "0";//同步类型 0新增 1修改 2删除
|
||||
String res_url = "http://192.168.31.158:8022/ierp/kapi/v2/f9w5/basedata/bd_customer/customerSave";
|
||||
String res_param = obj;
|
||||
String res = "";
|
||||
try {
|
||||
String token = "2096108315279888384_HJyMZK1Lco9gSZUKU1ipq85P5J32eQDdaz8WgChd1DvHrPZylIodiBmBYa8U2smKVC8MKAspXtjNQ2Fjw5MlWXDnkn5nPFPQWzSB03";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("accessToken", token);//放token
|
||||
HttpClientResult rtn = HttpClientUtils.doPostJson(res_url, headers, obj);
|
||||
String resStr = rtn.getContent();
|
||||
JSONObject resjs = JSONObject.parseObject(resStr);
|
||||
res = resStr;
|
||||
if (resjs != null && resjs.getBoolean("status")) {
|
||||
JSONObject successdata = resjs.getJSONObject("data");
|
||||
JSONArray result = successdata.getJSONArray("result");
|
||||
JSONObject erpdata = (JSONObject) result.get(0);
|
||||
String erpid = erpdata.getString("id");
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("erp_id__c", erpid);//数据ID
|
||||
paramMap.put("sync_status__c", "option_sync_success__c");
|
||||
paramMap.put("sync_info__c", resjs.getString("message"));
|
||||
//回写json
|
||||
fxapi.upSynFieldParam("", "AccountObj", dataId, paramMap);
|
||||
}else{
|
||||
sendFlag=true;
|
||||
stringBuffer.append("客户创建接口调用失败:"+resjs.getString("message"));
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("sync_status__c", "option_sync_failure__c");
|
||||
paramMap.put("sync_info__c", stringBuffer);
|
||||
//回写json
|
||||
fxapi.upSynFieldParam("", "AccountObj", dataId, paramMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sendFlag = true;
|
||||
stringBuffer.append("客户创建接口调用失败,请检查网络配置");
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("sync_status__c", "option_sync_failure__c");
|
||||
paramMap.put("sync_info__c", stringBuffer);
|
||||
//回写json
|
||||
fxapi.upSynFieldParam("", "AccountObj", dataId, paramMap);
|
||||
}
|
||||
|
||||
JSONObject sendData = new JSONObject();
|
||||
|
||||
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||
|
||||
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||
MagicApi.updateSendSYUPDATEcustomer(sendData);
|
||||
|
||||
JSONObject logData = new JSONObject();
|
||||
logData.put("log_type", "KH"); //业务类型
|
||||
logData.put("log_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||
logData.put("syn_type", syn_type);//同步类型 0新增 1修改 2删除
|
||||
logData.put("data_id", dataId);//数据id
|
||||
logData.put("data_name", nameData);//数据名称
|
||||
logData.put("res_body", "同步成功");//返回值
|
||||
logData.put("res_url", res_url);//
|
||||
logData.put("res_param", res_param);//
|
||||
logData.put("res_res", res);//
|
||||
if (sendFlag) {
|
||||
logData.put("res_body", stringBuffer.toString());//返回值
|
||||
}
|
||||
//写入传输日志
|
||||
MagicApi.saveCustomerLog(logData);
|
||||
}
|
||||
|
||||
|
||||
public void getSynDataUpdate() throws Exception {
|
||||
FXHTTP fxapi = new FXHTTP();
|
||||
XKTokenAccess xktonken = new XKTokenAccess();
|
||||
// 查询magic接口
|
||||
//获取时间戳
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String time = sdf.format(System.currentTimeMillis() - (1000 * 60 * 60));
|
||||
|
||||
String apiName = "AccountObj";
|
||||
|
||||
/* List<CrmFXApiParam> paramList = Arrays.asList(
|
||||
new CrmFXApiParam("GT", "last_modified_time", System.currentTimeMillis() - (1000 * 60 * 60 * 24)),
|
||||
new CrmFXApiParam("ISN", "erp_id__c", ""),
|
||||
new CrmFXApiParam("ISN", "erp_category__c", ""),
|
||||
new CrmFXApiParam("EQ", "sync_status__c", "option_sync_success__c"),
|
||||
new CrmFXApiParam("EQ", "life_status", "normal")
|
||||
);*/
|
||||
|
||||
|
||||
List<CrmFXApiParam> paramList = Arrays.asList(new CrmFXApiParam("EQ", "name", "河北省水利行业协会"));
|
||||
|
||||
JSONObject jsonject = fxapi.getSynNewDataObj(false, "客户", apiName, paramList);
|
||||
JSONArray array = jsonject.getJSONObject("data").getJSONArray("dataList");
|
||||
|
||||
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject str = array.getJSONObject(i);
|
||||
String dataId = GcjJson.getNodeValue(str, "JSON._id") != null ? GcjJson.getNodeValue(str, "JSON._id").toString() : "";
|
||||
String nameData = GcjJson.getNodeValue(str, "JSON.name") != null ? GcjJson.getNodeValue(str, "JSON.name").toString() : "";
|
||||
String endtime = GcjJson.getNodeValue(str, "JSON.last_modified_time") != null ? GcjJson.getNodeValue(str, "JSON.last_modified_time").toString() : "";
|
||||
|
||||
String syn_type = "1";//同步类型 0新增 1修改 2删除
|
||||
log.info("-------------------开始执行客户" + i + " -------------------" + nameData);
|
||||
XxlJobHelper.log("-------------------开始执行客户" + i + " -------------------" + nameData);
|
||||
|
||||
Boolean sendFlag = false;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
|
||||
try {
|
||||
boolean tbflag = false;
|
||||
//验证数据是否已存在
|
||||
JSONObject dataSyn = MagicApi.getSendSYNDataCustomer("KH", syn_type, dataId);
|
||||
|
||||
if (dataSyn != null && dataId.equals(dataSyn.getString("crmId")) && endtime.equals(dataSyn.getString("mark")) ) {
|
||||
log.info("数据已存在-" + nameData);
|
||||
XxlJobHelper.log("--数据已存在---" + nameData);
|
||||
tbflag = true;
|
||||
}
|
||||
if (tbflag) {
|
||||
continue;
|
||||
}
|
||||
log.info("客户待同步数据-" + i + " ------" + nameData);
|
||||
JSONObject jsonObjectData = new JSONObject();
|
||||
jsonObjectData.put("send_type", "KH"); //业务类型
|
||||
jsonObjectData.put("send_syn", "0"); //同步类型 0新增 1修改 2删除
|
||||
jsonObjectData.put("crm_id", dataId);//数据id
|
||||
jsonObjectData.put("crmzhu_id", dataId);//数据id
|
||||
jsonObjectData.put("send_status", 3);//同步状态 true同步成功 false同步失败 3待同步
|
||||
jsonObjectData.put("crm_code", nameData);//数据名称
|
||||
jsonObjectData.put("mark", endtime);//标识
|
||||
jsonObjectData.put("crm_json", str.toJSONString());//标识
|
||||
|
||||
MagicApi.saveSendSYNDatacustomer(jsonObjectData);
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void getSynKHUPdate() throws Exception {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
FXHTTP fxapi = new FXHTTP();
|
||||
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryCustomer?sendType=KH&sendStatus=3&sendSyn=0", "");
|
||||
JSONObject resJson = JSON.parseObject(resJsonStr);
|
||||
if (resJson != null) {
|
||||
log.info("待同步客户数" + resJson.getJSONArray("data").size());
|
||||
for (int i = 0; i < resJson.getJSONArray("data").size(); i++) {
|
||||
|
||||
JSONObject getData = resJson.getJSONArray("data").getJSONObject(i);
|
||||
JSONObject str = getData.getJSONObject("crmJson");
|
||||
String syn_type = "1";//同步类型 0新增 1修改 2删除
|
||||
Boolean sendFlag = false;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
boolean tbflag = false;
|
||||
// 构建json
|
||||
|
||||
String dataId = GcjJson.getNodeValue(str, "JSON._id") != null ? GcjJson.getNodeValue(str, "JSON._id").toString() : "";
|
||||
String nameData = GcjJson.getNodeValue(str, "JSON.name") != null ? GcjJson.getNodeValue(str, "JSON.name").toString() : "";
|
||||
String societycreditcode = GcjJson.getNodeValue(str, "JSON.uniform_social_credit_code") != null ? GcjJson.getNodeValue(str, "JSON.uniform_social_credit_code").toString() : "";
|
||||
String simplename = GcjJson.getNodeValue(str, "JSON.abbreviation__c") != null ? GcjJson.getNodeValue(str, "JSON.abbreviation__c").toString() : "";
|
||||
|
||||
String account_no = GcjJson.getNodeValue(str, "JSON.account_no") != null ? GcjJson.getNodeValue(str, "JSON.account_no").toString() : "";
|
||||
String erp_category__c = GcjJson.getNodeValue(str, "JSON.erp_category__c") != null ? GcjJson.getNodeValue(str, "JSON.erp_category__c").toString() : "";
|
||||
|
||||
|
||||
String strJson = "";
|
||||
try{
|
||||
JSONObject dataSyn = MagicApi.getSendSYNDataCustomer("KH", syn_type, dataId,"3");
|
||||
if (dataSyn != null && dataId.equals(dataSyn.getString("crmId"))) {
|
||||
log.info("数据已存在-" + nameData);
|
||||
XxlJobHelper.log("--数据已存在---" + nameData);
|
||||
tbflag = true;
|
||||
}
|
||||
if (tbflag) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject params = new JSONObject();
|
||||
|
||||
JSONArray dataarr = new JSONArray();
|
||||
JSONObject datajson = new JSONObject();
|
||||
//统一社会信用代码
|
||||
datajson.put("societycreditcode",societycreditcode);
|
||||
//简称
|
||||
datajson.put("simplename",simplename);
|
||||
datajson.put("taxrate_number","V13");//税率
|
||||
datajson.put("settlementcyid_number","CNY");//交易币.货币代码
|
||||
//纳税人识别号
|
||||
datajson.put("tx_register_no",societycreditcode);
|
||||
//编码
|
||||
datajson.put("number",account_no);
|
||||
datajson.put("paymentcurrency_number","CNY");//付款币种.货币代码
|
||||
datajson.put("name",nameData);//客户名称
|
||||
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||
// datajson.put("settlementtypeid_number","JSFS04");//结算方式
|
||||
|
||||
JSONArray groupstandardarr = new JSONArray();
|
||||
JSONObject groupstandardjson = new JSONObject();
|
||||
groupstandardjson.put("groupid_number",erp_category__c);
|
||||
groupstandardjson.put("standardid_number","JBFLBZ");
|
||||
groupstandardarr.add(groupstandardjson);
|
||||
datajson.put("entry_groupstandard",groupstandardarr);//分类标准
|
||||
|
||||
//创建组织
|
||||
datajson.put("createorg_number","zycxjtpoc.test");
|
||||
dataarr.add(datajson);
|
||||
params.put("data",dataarr);
|
||||
log.info("--请求json---" + params.toJSONString());
|
||||
System.out.println("--请求json:---" +params.toJSONString());
|
||||
strJson = params.toJSONString();
|
||||
|
||||
}catch (Exception e) {
|
||||
sendFlag = true;
|
||||
stringBuffer.append("参数解析错误,请联系开发人员");
|
||||
e.printStackTrace();
|
||||
}
|
||||
getSynDataSaveup(stringBuffer,sendFlag,fxapi,dataId,nameData,strJson,getData);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getSynDataSaveup(StringBuffer stringBuffer,Boolean sendFlag,FXHTTP fxapi,String dataId,String nameData,String obj,JSONObject str) {
|
||||
String syn_type = "1";//同步类型 0新增 1修改 2删除
|
||||
String res_url = "http://192.168.31.158:8022/ierp/kapi/v2/f9w5/basedata/bd_customer/customerSave";
|
||||
String res_param = obj;
|
||||
String res = "";
|
||||
try {
|
||||
String token = "2096108315279888384_HJyMZK1Lco9gSZUKU1ipq85P5J32eQDdaz8WgChd1DvHrPZylIodiBmBYa8U2smKVC8MKAspXtjNQ2Fjw5MlWXDnkn5nPFPQWzSB03";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("accessToken", token);//放token
|
||||
HttpClientResult rtn = HttpClientUtils.doPostJson(res_url, headers, obj);
|
||||
String resStr = rtn.getContent();
|
||||
JSONObject resjs = JSONObject.parseObject(resStr);
|
||||
res = resStr;
|
||||
if (resjs != null && resjs.getBoolean("status")) {
|
||||
JSONObject successdata = resjs.getJSONObject("data");
|
||||
JSONArray result = successdata.getJSONArray("result");
|
||||
JSONObject erpdata = (JSONObject) result.get(0);
|
||||
String erpid = erpdata.getString("id");
|
||||
|
||||
|
||||
}else{
|
||||
sendFlag=true;
|
||||
stringBuffer.append("客户修改接口调用失败:"+resjs.getString("message"));
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("sync_status__c", "option_sync_failure__c");
|
||||
paramMap.put("sync_info__c", stringBuffer);
|
||||
//回写json
|
||||
fxapi.upSynFieldParam("", "AccountObj", dataId, paramMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sendFlag = true;
|
||||
stringBuffer.append("客户修改接口调用失败,请检查网络配置");
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("sync_status__c", "option_sync_failure__c");
|
||||
paramMap.put("sync_info__c", stringBuffer);
|
||||
//回写json
|
||||
fxapi.upSynFieldParam("", "AccountObj", dataId, paramMap);
|
||||
}
|
||||
|
||||
JSONObject sendData = new JSONObject();
|
||||
|
||||
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||
|
||||
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||
MagicApi.updateSendSYUPDATEcustomer(sendData);
|
||||
|
||||
JSONObject logData = new JSONObject();
|
||||
logData.put("log_type", "KH"); //业务类型
|
||||
logData.put("log_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||
logData.put("syn_type", syn_type);//同步类型 0新增 1修改 2删除
|
||||
logData.put("data_id", dataId);//数据id
|
||||
logData.put("data_name", nameData);//数据名称
|
||||
logData.put("res_body", "同步成功");//返回值
|
||||
logData.put("res_url", res_url);//
|
||||
logData.put("res_param", res_param);//
|
||||
logData.put("res_res", res);//
|
||||
if (sendFlag) {
|
||||
logData.put("res_body", stringBuffer.toString());//返回值
|
||||
}
|
||||
//写入传输日志
|
||||
MagicApi.saveCustomerLog(logData);
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package org.ssssssss.magicboot.controller;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.ssssssss.magicboot.fxapi.HttpClientResult;
|
||||
import org.ssssssss.magicboot.fxapi.HttpClientUtils;
|
||||
import org.ssssssss.magicboot.fxapi.XKTokenAccess;
|
||||
import org.ssssssss.magicboot.fxapi.model.CrmFXApiParam;
|
||||
import org.ssssssss.magicboot.zdyutils.FXHTTP;
|
||||
import org.ssssssss.magicboot.zdyutils.GcjJson;
|
||||
import org.ssssssss.magicboot.zdyutils.MagicApi;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/group")
|
||||
public class customergroupController {
|
||||
static Logger logger = LoggerFactory.getLogger("customergroup");
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new customergroupController().getSynData();
|
||||
|
||||
}
|
||||
@PostMapping("/getSynData")
|
||||
public void getSynData() throws Exception {
|
||||
|
||||
FXHTTP fxapi = new FXHTTP();
|
||||
JSONObject jsonject = fxapi.getXKName("AccountObj");
|
||||
JSONArray array = jsonject.getJSONObject("data").getJSONObject("describe").getJSONObject("fields")
|
||||
.getJSONObject("erp_category__c").getJSONArray("options");
|
||||
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject str = array.getJSONObject(i);
|
||||
Boolean sendFlag = false;//是否阻断
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
|
||||
String sendUrl = "http://192.168.31.158:8022/ierp/kapi/v2/f9w5/basedata/bd_customergroup/customergroupSave";
|
||||
String sendBody = "";
|
||||
String sendRes = "";
|
||||
|
||||
String label = GcjJson.getNodeValue(str, "JSON.label") != null ? GcjJson.getNodeValue(str, "JSON.label").toString() : "";
|
||||
String value = GcjJson.getNodeValue(str, "JSON.value") != null ? GcjJson.getNodeValue(str, "JSON.value").toString() : "";
|
||||
|
||||
|
||||
Boolean tbflag = false;
|
||||
|
||||
JSONObject ataLog = MagicApi.getDataLog("group", label);
|
||||
if (ataLog != null && label.equals(ataLog.getString("dataId"))) {
|
||||
tbflag = true;
|
||||
}
|
||||
if (tbflag) {
|
||||
System.out.println("数据已存在" + label);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
String token = "2096108315279888384_Y8HeV0864EhPN9oPNs57p3B6tpFipZoQB6NMm1aczKr1QGotVhrr6FIpOfz4H67lNpol7NvBPXIb93t8U2UddG1SFKdXy5h78Sl502";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("accessToken", token);//放token
|
||||
|
||||
JSONObject params = new JSONObject();
|
||||
|
||||
JSONArray dataarr = new JSONArray();
|
||||
JSONObject datajson = new JSONObject();
|
||||
|
||||
datajson.put("number",value);
|
||||
datajson.put("name",label);
|
||||
datajson.put("parent_number","01");//上级是中国
|
||||
|
||||
dataarr.add(datajson);
|
||||
params.put("data",dataarr);
|
||||
logger.info("--请求json---" + params.toJSONString());
|
||||
System.out.println("--请求json:---" +params.toJSONString());
|
||||
sendBody = params.toJSONString();
|
||||
String erpid= "";
|
||||
try {
|
||||
HttpClientResult rtn = HttpClientUtils.doPostJson(sendUrl, headers, params.toJSONString());
|
||||
String resStr = rtn.getContent();
|
||||
JSONObject resjs = JSONObject.parseObject(resStr);
|
||||
System.out.println(resjs);
|
||||
sendRes = resStr;
|
||||
|
||||
if (resjs != null ) {
|
||||
if(resjs.getBoolean("status")){
|
||||
JSONObject successdata = resjs.getJSONObject("data");
|
||||
JSONArray result = successdata.getJSONArray("result");
|
||||
JSONObject erpdata = (JSONObject) result.get(0);
|
||||
erpid = erpdata.getString("id");
|
||||
}else {
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
sendFlag = true;
|
||||
stringBuffer.append("接口调用失败:" + resjs.toString());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
sendFlag = true;
|
||||
stringBuffer.append("接口调用失败");
|
||||
}
|
||||
|
||||
|
||||
//结束
|
||||
JSONObject jsonObjectData = new JSONObject();
|
||||
jsonObjectData.put("log_type", "group"); //业务类型
|
||||
jsonObjectData.put("log_status", !sendFlag);//同步状态 0同步成功 1同步失败
|
||||
jsonObjectData.put("syn_type", "0");//同步类型 0新增 1修改 2删除
|
||||
jsonObjectData.put("data_id", label);//数据id
|
||||
jsonObjectData.put("data_name", label);//数据名称
|
||||
jsonObjectData.put("mark", value);//标识
|
||||
jsonObjectData.put("mark_id", erpid);//标识
|
||||
jsonObjectData.put("res_body", "同步成功");//返回值
|
||||
jsonObjectData.put("send_url", sendUrl);//返回值
|
||||
jsonObjectData.put("send_body", sendBody);//返回值
|
||||
jsonObjectData.put("send_res", sendRes);//返回值
|
||||
if (sendFlag) {
|
||||
jsonObjectData.put("res_body", stringBuffer.toString());//返回值
|
||||
}
|
||||
// 回写
|
||||
MagicApi.saveDataLog(jsonObjectData);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -463,14 +463,11 @@ public class FXHTTP {
|
||||
map.put("body.data.search_query_info.limit", 999);
|
||||
map.put("body.data.search_query_info.orders[0].fieldName", "create_time");
|
||||
map.put("body.data.search_query_info.orders[0].isAsc", "true");
|
||||
|
||||
for (int i = 0; i < CrmFXApiParam.size(); i++) {
|
||||
map.put("body.data.search_query_info.filters["+i+"].operator", CrmFXApiParam.get(i).getOperator());
|
||||
map.put("body.data.search_query_info.filters["+i+"].field_name", CrmFXApiParam.get(i).getFieldKey());
|
||||
map.put("body.data.search_query_info.filters["+i+"].field_values", CrmFXApiParam.get(i).getFieldValue());
|
||||
}
|
||||
|
||||
|
||||
map.put("body.data.dataObjectApiName", apiName);
|
||||
|
||||
try {
|
||||
|
@ -6,17 +6,7 @@ import java.net.URLEncoder;
|
||||
|
||||
public class MagicApi {
|
||||
public static void main(String[] args) {
|
||||
// JSONObject data= new JSONObject();
|
||||
// data.put("log_type","0");
|
||||
// data.put("log_status","0");
|
||||
// data.put("syn_type","0");
|
||||
// data.put("data_id","12312");
|
||||
// data.put("data_name","测试同步");
|
||||
// data.put("mark","21312312");
|
||||
// data.put("res_body","同步成功");
|
||||
//
|
||||
// saveDataLog(data);
|
||||
System.out.println(getkhzinfo("1001S3100000004DW7BE"));
|
||||
|
||||
}
|
||||
|
||||
public static void saveApiDataLog(JSONObject data) {
|
||||
@ -48,6 +38,17 @@ public class MagicApi {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void saveCustomerLog(JSONObject data) {
|
||||
System.out.println(data);
|
||||
try {
|
||||
String res = HttpSend.sendMagicPost(
|
||||
"http://127.0.0.1:18088/send/log/savecustomer"
|
||||
, data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveDataWLLog(JSONObject data) {
|
||||
//System.out.println(data.toJSONString());
|
||||
try {
|
||||
@ -119,7 +120,7 @@ public class MagicApi {
|
||||
|
||||
try {
|
||||
String res = HttpSend.sendMagicGet(
|
||||
"http://127.0.0.1:18088/SYNCLOG/GELOGDATA?type=" + URLEncoder.encode(type, "UTF-8") + "&dataId=" + URLEncoder.encode(dataId, "UTF-8")
|
||||
"http://127.0.0.1:18088/syn/querygroup?sendType=" + URLEncoder.encode(type, "UTF-8") + "&dataId=" + URLEncoder.encode(dataId, "UTF-8")
|
||||
, "");
|
||||
JSONObject resJson = JSONObject.parseObject(res);
|
||||
|
||||
@ -273,6 +274,16 @@ public class MagicApi {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void saveSendSYNDatacustomer(JSONObject data) {
|
||||
System.out.println(data.toJSONString());
|
||||
try {
|
||||
String res = HttpSend.sendMagicPost(
|
||||
"http://127.0.0.1:18088/syn/savecustomer"
|
||||
, data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void saveSendSYNUser(JSONObject data) {
|
||||
System.out.println(data.toJSONString());
|
||||
try {
|
||||
@ -293,6 +304,16 @@ public class MagicApi {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void updateSendSYUPDATEcustomer(JSONObject data) {
|
||||
System.out.println(data.toJSONString());
|
||||
try {
|
||||
String res = HttpSend.sendMagicPost(
|
||||
"http://127.0.0.1:18088/syn/updatecustomer"
|
||||
, data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void updateSendSYUPDATENUser(JSONObject data) {
|
||||
System.out.println(data.toJSONString());
|
||||
try {
|
||||
@ -322,11 +343,11 @@ public class MagicApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getSendSYNDataSBBom(String type, String syn, String dataId) {
|
||||
public static JSONObject getSendSYNDataCustomer(String type, String syn, String dataId) {
|
||||
|
||||
try {
|
||||
String res = HttpSend.sendMagicGet(
|
||||
"http://127.0.0.1:18088/syn/querysbbom?sendType=" + URLEncoder.encode(type, "UTF-8")
|
||||
"http://127.0.0.1:18088/syn/queryCustomer?sendType=" + URLEncoder.encode(type, "UTF-8")
|
||||
+ "&crmId=" + URLEncoder.encode(dataId, "UTF-8")
|
||||
+ "&sendSyn=" + URLEncoder.encode(syn, "UTF-8")
|
||||
, "");
|
||||
@ -340,7 +361,25 @@ public class MagicApi {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static JSONObject getSendSYNDataCustomer(String type, String syn, String dataId, String sendStatus3) {
|
||||
|
||||
try {
|
||||
String res = HttpSend.sendMagicGet(
|
||||
"http://127.0.0.1:18088/syn/queryCustomer?sendType=" + URLEncoder.encode(type, "UTF-8")
|
||||
+ "&crmId=" + URLEncoder.encode(dataId, "UTF-8")
|
||||
+ "&sendSyn=" + URLEncoder.encode(syn, "UTF-8")
|
||||
+ "&sendStatus3="+sendStatus3
|
||||
, "");
|
||||
JSONObject resJson = JSONObject.parseObject(res);
|
||||
|
||||
if (resJson.getJSONArray("data").size() > 0) {
|
||||
return resJson.getJSONArray("data").getJSONObject(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getSendSYNDataCRM(String type, String syn, String dataId, String sendStatus3) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user