更新
This commit is contained in:
parent
694970f18e
commit
6f708bbe8c
50
data/magic-api/api/B-传输日志/日志/保存销售预测同步日志.ms
Normal file
50
data/magic-api/api/B-传输日志/日志/保存销售预测同步日志.ms
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"properties" : { },
|
||||||
|
"id" : "copy1745905421038d65912",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
|
||||||
|
"name" : "保存销售预测同步日志",
|
||||||
|
"createTime" : null,
|
||||||
|
"updateTime" : 1745905450397,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/savesales_prediction",
|
||||||
|
"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_sales_prediction').primary('log_id',uuid()).save(data)
|
50
data/magic-api/api/B-传输日志/日志/保存项目同步日志.ms
Normal file
50
data/magic-api/api/B-传输日志/日志/保存项目同步日志.ms
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"properties" : { },
|
||||||
|
"id" : "copy1745808687043d87940",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
|
||||||
|
"name" : "保存项目同步日志",
|
||||||
|
"createTime" : null,
|
||||||
|
"updateTime" : 1745808707906,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/saveproject",
|
||||||
|
"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_project').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" : "copy1745905491097d61575",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||||
|
"name" : "修改销售预测同步",
|
||||||
|
"createTime" : null,
|
||||||
|
"updateTime" : 1745912331249,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/updatesales_prediction",
|
||||||
|
"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_sales_prediction").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" : "copy1745808609390d29375",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||||
|
"name" : "修改项目同步",
|
||||||
|
"createTime" : null,
|
||||||
|
"updateTime" : 1745808680843,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/updateProjcet",
|
||||||
|
"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_project").primary('send_id')
|
||||||
|
.update(data)
|
173
data/magic-api/api/B-同步日志/查询销售预测同步日志.ms
Normal file
173
data/magic-api/api/B-同步日志/查询销售预测同步日志.ms
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
{
|
||||||
|
"properties" : { },
|
||||||
|
"id" : "copy1745905454396d11136",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||||
|
"name" : "查询销售预测同步日志",
|
||||||
|
"createTime" : null,
|
||||||
|
"updateTime" : 1745905470230,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/querysales_prediction",
|
||||||
|
"method" : "GET",
|
||||||
|
"parameters" : [ {
|
||||||
|
"name" : "sendType",
|
||||||
|
"value" : "TuiHuo",
|
||||||
|
"description" : null,
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "String",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : null,
|
||||||
|
"error" : null,
|
||||||
|
"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",
|
||||||
|
"description" : null,
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "String",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : null,
|
||||||
|
"error" : null,
|
||||||
|
"expression" : null,
|
||||||
|
"children" : null
|
||||||
|
} ],
|
||||||
|
"options" : [ ],
|
||||||
|
"requestBody" : "",
|
||||||
|
"headers" : [ ],
|
||||||
|
"paths" : [ ],
|
||||||
|
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": [],\n \"timestamp\": 1716889610473,\n \"executeTime\": 8\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" : "",
|
||||||
|
"description" : "",
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "Array",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : "",
|
||||||
|
"error" : "",
|
||||||
|
"expression" : "",
|
||||||
|
"children" : [ ]
|
||||||
|
}, {
|
||||||
|
"name" : "timestamp",
|
||||||
|
"value" : "1716889610473",
|
||||||
|
"description" : "",
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "Long",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : "",
|
||||||
|
"error" : "",
|
||||||
|
"expression" : "",
|
||||||
|
"children" : [ ]
|
||||||
|
}, {
|
||||||
|
"name" : "executeTime",
|
||||||
|
"value" : "8",
|
||||||
|
"description" : "",
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "Integer",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : "",
|
||||||
|
"error" : "",
|
||||||
|
"expression" : "",
|
||||||
|
"children" : [ ]
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
================================
|
||||||
|
//查询本机mysql
|
||||||
|
return db.select(
|
||||||
|
"""
|
||||||
|
SELECT * FROM `send_syn_sales_prediction` where
|
||||||
|
send_type=#{sendType}
|
||||||
|
<if test="dataId != null">
|
||||||
|
and dsf_id=#{dataId}
|
||||||
|
</if>
|
||||||
|
<if test="datapId != null">
|
||||||
|
and dsfzhu_id=#{datapId}
|
||||||
|
</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}
|
||||||
|
</if>
|
||||||
|
order by create_time desc
|
||||||
|
|
||||||
|
""");
|
173
data/magic-api/api/B-同步日志/查询项目同步日志.ms
Normal file
173
data/magic-api/api/B-同步日志/查询项目同步日志.ms
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
{
|
||||||
|
"properties" : { },
|
||||||
|
"id" : "copy1745808556895d15952",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||||
|
"name" : "查询项目同步日志",
|
||||||
|
"createTime" : null,
|
||||||
|
"updateTime" : 1745808575698,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/queryProject",
|
||||||
|
"method" : "GET",
|
||||||
|
"parameters" : [ {
|
||||||
|
"name" : "sendType",
|
||||||
|
"value" : "TuiHuo",
|
||||||
|
"description" : null,
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "String",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : null,
|
||||||
|
"error" : null,
|
||||||
|
"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",
|
||||||
|
"description" : null,
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "String",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : null,
|
||||||
|
"error" : null,
|
||||||
|
"expression" : null,
|
||||||
|
"children" : null
|
||||||
|
} ],
|
||||||
|
"options" : [ ],
|
||||||
|
"requestBody" : "",
|
||||||
|
"headers" : [ ],
|
||||||
|
"paths" : [ ],
|
||||||
|
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": [],\n \"timestamp\": 1716889610473,\n \"executeTime\": 8\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" : "",
|
||||||
|
"description" : "",
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "Array",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : "",
|
||||||
|
"error" : "",
|
||||||
|
"expression" : "",
|
||||||
|
"children" : [ ]
|
||||||
|
}, {
|
||||||
|
"name" : "timestamp",
|
||||||
|
"value" : "1716889610473",
|
||||||
|
"description" : "",
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "Long",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : "",
|
||||||
|
"error" : "",
|
||||||
|
"expression" : "",
|
||||||
|
"children" : [ ]
|
||||||
|
}, {
|
||||||
|
"name" : "executeTime",
|
||||||
|
"value" : "8",
|
||||||
|
"description" : "",
|
||||||
|
"required" : false,
|
||||||
|
"dataType" : "Integer",
|
||||||
|
"type" : null,
|
||||||
|
"defaultValue" : null,
|
||||||
|
"validateType" : "",
|
||||||
|
"error" : "",
|
||||||
|
"expression" : "",
|
||||||
|
"children" : [ ]
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
================================
|
||||||
|
//查询本机mysql
|
||||||
|
return db.select(
|
||||||
|
"""
|
||||||
|
SELECT * FROM `send_syn_project` where
|
||||||
|
send_type=#{sendType}
|
||||||
|
<if test="dataId != null">
|
||||||
|
and dsf_id=#{dataId}
|
||||||
|
</if>
|
||||||
|
<if test="datapId != null">
|
||||||
|
and dsfzhu_id=#{datapId}
|
||||||
|
</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}
|
||||||
|
</if>
|
||||||
|
order by create_time desc
|
||||||
|
|
||||||
|
""");
|
126
data/magic-api/api/B-同步日志/销售预测待同步保存.ms
Normal file
126
data/magic-api/api/B-同步日志/销售预测待同步保存.ms
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
{
|
||||||
|
"properties" : { },
|
||||||
|
"id" : "copy1745905472523d55220",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||||
|
"name" : "销售预测待同步保存",
|
||||||
|
"createTime" : null,
|
||||||
|
"updateTime" : 1745905488288,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/savesales_prediction",
|
||||||
|
"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_sales_prediction").primary('send_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" : "copy1745808582300d24910",
|
||||||
|
"script" : null,
|
||||||
|
"groupId" : "4506c21162d24d4c81bad5bc8707672a",
|
||||||
|
"name" : "项目待同步保存",
|
||||||
|
"createTime" : 1745808599992,
|
||||||
|
"updateTime" : null,
|
||||||
|
"lock" : null,
|
||||||
|
"createBy" : null,
|
||||||
|
"updateBy" : null,
|
||||||
|
"path" : "/saveProject",
|
||||||
|
"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_project").primary('send_id', () => uuid())
|
||||||
|
.save(data)
|
@ -0,0 +1,438 @@
|
|||||||
|
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.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
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.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ProjectNewOpportunity")
|
||||||
|
public class ProjectNewOpportunityController {
|
||||||
|
static Logger log = LoggerFactory.getLogger("ProjectNewOpportunity");
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
new ProjectNewOpportunityController().getSynData();
|
||||||
|
new ProjectNewOpportunityController().saveSynData();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSynData() 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 = "NewOpportunityObj";
|
||||||
|
|
||||||
|
/* 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("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.getSendSYNDataProject("SJ", 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", "SJ"); //业务类型
|
||||||
|
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.saveSendSYNDataProject(jsonObjectData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveSynData() throws Exception {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||||
|
FXHTTP fxapi = new FXHTTP();
|
||||||
|
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryProject?sendType=SJ&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 number = GcjJson.getNodeValue(str, "JSON.opportunity_id__c") != null ? GcjJson.getNodeValue(str, "JSON.opportunity_id__c").toString() : "";
|
||||||
|
|
||||||
|
String strJson = "";
|
||||||
|
try{
|
||||||
|
JSONObject dataSyn = MagicApi.getSendSYNDataProject("SJ", 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("number",number);
|
||||||
|
datajson.put("group_number","01");//项目分类
|
||||||
|
datajson.put("name",nameData);//项目名称
|
||||||
|
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||||
|
datajson.put("enable","1");//使用状态
|
||||||
|
datajson.put("status","C");//数据状态
|
||||||
|
//创建组织
|
||||||
|
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_project/projectSave";
|
||||||
|
String res_param = obj;
|
||||||
|
String res = "";
|
||||||
|
try {
|
||||||
|
String accessToken = "2096108315279888384_hjuaG4aAhb6aY7DOaoUmDLzx4lBXY3q4q5n7PvEVsq740PNMWx1X1q4CD1wljgW33pj5Ie8lbXCG3a2CIDFgxqGrmo2TCg5ss6kY03";
|
||||||
|
// String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("accessToken", accessToken);//放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("", "NewOpportunityObj", 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("", "NewOpportunityObj", 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("", "NewOpportunityObj", dataId, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
|
||||||
|
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||||
|
|
||||||
|
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||||
|
MagicApi.updateSendSYUPDATEProject(sendData);
|
||||||
|
|
||||||
|
JSONObject logData = new JSONObject();
|
||||||
|
logData.put("log_type", "SJ"); //业务类型
|
||||||
|
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.saveProjectLog(logData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void getSynDataUP() 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 = "NewOpportunityObj";
|
||||||
|
|
||||||
|
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("EQ", "life_status", "invalid")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/* 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 = "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.getSendSYNDataProject("SJUP", 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", "SJUP"); //业务类型
|
||||||
|
jsonObjectData.put("send_syn", "1"); //同步类型 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.saveSendSYNDataProject(jsonObjectData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void updateSynData() throws Exception {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||||
|
FXHTTP fxapi = new FXHTTP();
|
||||||
|
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryProject?sendType=SJUP&sendStatus=3&sendSyn=1", "");
|
||||||
|
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 number = GcjJson.getNodeValue(str, "JSON.opportunity_id__c") != null ? GcjJson.getNodeValue(str, "JSON.opportunity_id__c").toString() : "";
|
||||||
|
|
||||||
|
String strJson = "";
|
||||||
|
try{
|
||||||
|
JSONObject dataSyn = MagicApi.getSendSYNDataProject("SJUP", 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("number",number);
|
||||||
|
datajson.put("group_number","01");//项目分类
|
||||||
|
datajson.put("name",nameData);//项目名称
|
||||||
|
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||||
|
datajson.put("enable","2");//使用状态 禁用
|
||||||
|
datajson.put("status","C");//数据状态
|
||||||
|
//创建组织
|
||||||
|
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_project/projectSave";
|
||||||
|
String res_param = obj;
|
||||||
|
String res = "";
|
||||||
|
try {
|
||||||
|
String accessToken = "2096108315279888384_hjuaG4aAhb6aY7DOaoUmDLzx4lBXY3q4q5n7PvEVsq740PNMWx1X1q4CD1wljgW33pj5Ie8lbXCG3a2CIDFgxqGrmo2TCg5ss6kY03";
|
||||||
|
// String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("accessToken", accessToken);//放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("sync_info__c", resjs.getString("message"));
|
||||||
|
//回写json
|
||||||
|
fxapi.upSynFieldParam("", "NewOpportunityObj", 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("", "NewOpportunityObj", 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("", "NewOpportunityObj", dataId, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
|
||||||
|
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||||
|
|
||||||
|
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||||
|
MagicApi.updateSendSYUPDATEProject(sendData);
|
||||||
|
|
||||||
|
JSONObject logData = new JSONObject();
|
||||||
|
logData.put("log_type", "SJUP"); //业务类型
|
||||||
|
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.saveProjectLog(logData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,438 @@
|
|||||||
|
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.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
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.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ProjectObj")
|
||||||
|
public class ProjectObjController {
|
||||||
|
static Logger log = LoggerFactory.getLogger("ProjectObj");
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
new ProjectObjController().getSynData();
|
||||||
|
new ProjectObjController().saveSynData();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSynData() 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 = "ProjectObj";
|
||||||
|
|
||||||
|
/* 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("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.getSendSYNDataProject("project", 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", "project"); //业务类型
|
||||||
|
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.saveSendSYNDataProject(jsonObjectData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveSynData() throws Exception {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||||
|
FXHTTP fxapi = new FXHTTP();
|
||||||
|
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryProject?sendType=project&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 number = GcjJson.getNodeValue(str, "JSON.project_no__c") != null ? GcjJson.getNodeValue(str, "JSON.project_no__c").toString() : "";
|
||||||
|
|
||||||
|
String strJson = "";
|
||||||
|
try{
|
||||||
|
JSONObject dataSyn = MagicApi.getSendSYNDataProject("project", 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("number",number);
|
||||||
|
datajson.put("group_number","02");//项目分类
|
||||||
|
datajson.put("name",nameData);//项目名称
|
||||||
|
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||||
|
datajson.put("enable","1");//使用状态
|
||||||
|
datajson.put("status","C");//数据状态
|
||||||
|
//创建组织
|
||||||
|
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_project/projectSave";
|
||||||
|
String res_param = obj;
|
||||||
|
String res = "";
|
||||||
|
try {
|
||||||
|
String accessToken = "2096108315279888384_sk2dyYgkHyM1NTWf3w6iZuCElVY8wY7OPRb27af3EAkuzbsSbQChg0AMt5hoLGUqHVkDmHsucRLvpyd8FoS77k46strtfebvRzp205";
|
||||||
|
// String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("accessToken", accessToken);//放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("", "NewOpportunityObj", 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("", "NewOpportunityObj", 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("", "NewOpportunityObj", dataId, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
|
||||||
|
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||||
|
|
||||||
|
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||||
|
MagicApi.updateSendSYUPDATEProject(sendData);
|
||||||
|
|
||||||
|
JSONObject logData = new JSONObject();
|
||||||
|
logData.put("log_type", "project"); //业务类型
|
||||||
|
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.saveProjectLog(logData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void getSynDataUP() 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 = "ProjectObj";
|
||||||
|
|
||||||
|
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("EQ", "life_status", "invalid")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/* 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 = "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.getSendSYNDataProject("projectup", 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", "projectup"); //业务类型
|
||||||
|
jsonObjectData.put("send_syn", "1"); //同步类型 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.saveSendSYNDataProject(jsonObjectData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void updateSynData() throws Exception {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||||
|
FXHTTP fxapi = new FXHTTP();
|
||||||
|
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryProject?sendType=projectup&sendStatus=3&sendSyn=1", "");
|
||||||
|
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 number = GcjJson.getNodeValue(str, "JSON.opportunity_id__c") != null ? GcjJson.getNodeValue(str, "JSON.opportunity_id__c").toString() : "";
|
||||||
|
|
||||||
|
String strJson = "";
|
||||||
|
try{
|
||||||
|
JSONObject dataSyn = MagicApi.getSendSYNDataProject("projectup", 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("number",number);
|
||||||
|
datajson.put("group_number","02");//项目分类
|
||||||
|
datajson.put("name",nameData);//项目名称
|
||||||
|
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||||
|
datajson.put("enable","2");//使用状态 禁用
|
||||||
|
datajson.put("status","C");//数据状态
|
||||||
|
//创建组织
|
||||||
|
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_project/projectSave";
|
||||||
|
String res_param = obj;
|
||||||
|
String res = "";
|
||||||
|
try {
|
||||||
|
String accessToken = "2096108315279888384_hjuaG4aAhb6aY7DOaoUmDLzx4lBXY3q4q5n7PvEVsq740PNMWx1X1q4CD1wljgW33pj5Ie8lbXCG3a2CIDFgxqGrmo2TCg5ss6kY03";
|
||||||
|
// String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("accessToken", accessToken);//放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("sync_info__c", resjs.getString("message"));
|
||||||
|
//回写json
|
||||||
|
fxapi.upSynFieldParam("", "NewOpportunityObj", 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("", "NewOpportunityObj", 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("", "NewOpportunityObj", dataId, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
|
||||||
|
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||||
|
|
||||||
|
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||||
|
MagicApi.updateSendSYUPDATEProject(sendData);
|
||||||
|
|
||||||
|
JSONObject logData = new JSONObject();
|
||||||
|
logData.put("log_type", "projectup"); //业务类型
|
||||||
|
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.saveProjectLog(logData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -44,7 +44,7 @@ public class UsceController {
|
|||||||
// time = "2024-05-01";
|
// time = "2024-05-01";
|
||||||
String sendUrl = "https://lxr2.zhydsp.cn:40448/ierp/kapi/v2/f9w5/base/bos_user/userQuery";
|
String sendUrl = "https://lxr2.zhydsp.cn:40448/ierp/kapi/v2/f9w5/base/bos_user/userQuery";
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
//String token = "2095350818281620480_38r7dCr7UfM45m43Givw964713GJgVwF2xS0uolYf9EvP6kgi8KeRegeih5L6qmyWCr5LjUCeEe8lVwMGsT3KLWz3PxgAwuBCuau01";
|
//String accessToken = "2096108315279888384_8elReBSzvx315JiLWiH82YKJGosF3G2kN688q05rHUritX9x3fWS3lmetalPeMe3HceZV7fK1GdSJsk1J46A3S0VkOxIUqf7wnS207";
|
||||||
String accessToken = new KDTokenController().getKDAccessToken();
|
String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
if (accessToken == null || accessToken.equals("")) {
|
if (accessToken == null || accessToken.equals("")) {
|
||||||
@ -59,7 +59,7 @@ public class UsceController {
|
|||||||
datajson.put("createtime", "2012-02-26 11:04:43");
|
datajson.put("createtime", "2012-02-26 11:04:43");
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
String[] strings = {
|
String[] strings = {
|
||||||
"ZHY003.009"
|
"王小龙"
|
||||||
};
|
};
|
||||||
|
|
||||||
// 将字符串添加到 JSONArray 中
|
// 将字符串添加到 JSONArray 中
|
||||||
@ -68,7 +68,7 @@ public class UsceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
datajson.put("dpt_number", arr);
|
datajson.put("name", arr);
|
||||||
|
|
||||||
|
|
||||||
params.put("data", datajson);
|
params.put("data", datajson);
|
||||||
|
@ -0,0 +1,258 @@
|
|||||||
|
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.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
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.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/Contact")
|
||||||
|
public class customerContactController {
|
||||||
|
static Logger log = LoggerFactory.getLogger("Contact");
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
new customerContactController().getSynDataAdd();
|
||||||
|
new customerContactController().SaveSyn();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = "ContactObj";
|
||||||
|
|
||||||
|
List<CrmFXApiParam> paramList = Arrays.asList(
|
||||||
|
new CrmFXApiParam("GT", "last_modified_time", System.currentTimeMillis() - (1000 * 60 * 60 * 24)),
|
||||||
|
new CrmFXApiParam("EQ", "sync_status__c", "option_pending_sync__c"),
|
||||||
|
new CrmFXApiParam("ISN", "field_7qGnx__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("LXR", 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", "LXR"); //业务类型
|
||||||
|
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 SaveSyn() 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=LXR&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 account_id = GcjJson.getNodeValue(str, "JSON.account_id") != null ? GcjJson.getNodeValue(str, "JSON.account_id").toString() : "";
|
||||||
|
String customer_code__c = GcjJson.getNodeValue(str, "JSON.customer_code__c") != null ? GcjJson.getNodeValue(str, "JSON.customer_code__c").toString() : "";
|
||||||
|
|
||||||
|
|
||||||
|
String strJson = "";
|
||||||
|
try{
|
||||||
|
JSONObject dataSyn = MagicApi.getSendSYNDataCustomer("LXR", 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("number",customer_code__c);
|
||||||
|
|
||||||
|
JSONArray groupstandardarr = new JSONArray();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject jsonjectZ = fxapi.getSynDataObj("客户下联系人", "ContactObj", "account_id", account_id);
|
||||||
|
JSONArray arrayZ = jsonjectZ.getJSONObject("data").getJSONArray("dataList");
|
||||||
|
for (int j = 0; j < arrayZ.size(); j++) {
|
||||||
|
JSONObject stra = arrayZ.getJSONObject(j);
|
||||||
|
|
||||||
|
JSONObject groupstandardjson = new JSONObject();
|
||||||
|
|
||||||
|
groupstandardjson.put("contactperson",GcjJson.getNodeValue(stra, "JSON.name"));
|
||||||
|
groupstandardjson.put("contactpersonpost",GcjJson.getNodeValue(stra, "JSON.job_title"));
|
||||||
|
groupstandardjson.put("dept",GcjJson.getNodeValue(stra, "JSON.department"));
|
||||||
|
groupstandardjson.put("email",GcjJson.getNodeValue(stra, "JSON.email"));
|
||||||
|
groupstandardjson.put("phone",GcjJson.getNodeValue(stra, "JSON.mobile1"));
|
||||||
|
groupstandardarr.add(groupstandardjson);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
datajson.put("entry_linkman",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";
|
||||||
|
String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("accessToken", accessToken);//放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);
|
||||||
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
paramMap.put("sync_status__c", "option_sync_success__c");
|
||||||
|
// paramMap.put("sync_info__c", resjs.getString("message"));
|
||||||
|
//回写json
|
||||||
|
fxapi.upSynFieldParam("", "ContactObj", 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("", "ContactObj", 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("", "ContactObj", 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", "LXR"); //业务类型
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -193,9 +193,12 @@ public class customerController {
|
|||||||
String res_param = obj;
|
String res_param = obj;
|
||||||
String res = "";
|
String res = "";
|
||||||
try {
|
try {
|
||||||
String token = "2096108315279888384_HJyMZK1Lco9gSZUKU1ipq85P5J32eQDdaz8WgChd1DvHrPZylIodiBmBYa8U2smKVC8MKAspXtjNQ2Fjw5MlWXDnkn5nPFPQWzSB03";
|
// String token = "2096108315279888384_HJyMZK1Lco9gSZUKU1ipq85P5J32eQDdaz8WgChd1DvHrPZylIodiBmBYa8U2smKVC8MKAspXtjNQ2Fjw5MlWXDnkn5nPFPQWzSB03";
|
||||||
|
String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("accessToken", token);//放token
|
headers.put("accessToken", accessToken);//放token
|
||||||
HttpClientResult rtn = HttpClientUtils.doPostJson(res_url, headers, obj);
|
HttpClientResult rtn = HttpClientUtils.doPostJson(res_url, headers, obj);
|
||||||
String resStr = rtn.getContent();
|
String resStr = rtn.getContent();
|
||||||
JSONObject resjs = JSONObject.parseObject(resStr);
|
JSONObject resjs = JSONObject.parseObject(resStr);
|
||||||
@ -310,7 +313,7 @@ public class customerController {
|
|||||||
log.info("客户待同步数据-" + i + " ------" + nameData);
|
log.info("客户待同步数据-" + i + " ------" + nameData);
|
||||||
JSONObject jsonObjectData = new JSONObject();
|
JSONObject jsonObjectData = new JSONObject();
|
||||||
jsonObjectData.put("send_type", "KH"); //业务类型
|
jsonObjectData.put("send_type", "KH"); //业务类型
|
||||||
jsonObjectData.put("send_syn", "0"); //同步类型 0新增 1修改 2删除
|
jsonObjectData.put("send_syn", "1"); //同步类型 0新增 1修改 2删除
|
||||||
jsonObjectData.put("crm_id", dataId);//数据id
|
jsonObjectData.put("crm_id", dataId);//数据id
|
||||||
jsonObjectData.put("crmzhu_id", dataId);//数据id
|
jsonObjectData.put("crmzhu_id", dataId);//数据id
|
||||||
jsonObjectData.put("send_status", 3);//同步状态 true同步成功 false同步失败 3待同步
|
jsonObjectData.put("send_status", 3);//同步状态 true同步成功 false同步失败 3待同步
|
||||||
@ -329,7 +332,7 @@ public class customerController {
|
|||||||
public void getSynKHUPdate() throws Exception {
|
public void getSynKHUPdate() throws Exception {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||||
FXHTTP fxapi = new FXHTTP();
|
FXHTTP fxapi = new FXHTTP();
|
||||||
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryCustomer?sendType=KH&sendStatus=3&sendSyn=0", "");
|
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/queryCustomer?sendType=KH&sendStatus=3&sendSyn=1", "");
|
||||||
JSONObject resJson = JSON.parseObject(resJsonStr);
|
JSONObject resJson = JSON.parseObject(resJsonStr);
|
||||||
if (resJson != null) {
|
if (resJson != null) {
|
||||||
log.info("待同步客户数" + resJson.getJSONArray("data").size());
|
log.info("待同步客户数" + resJson.getJSONArray("data").size());
|
||||||
@ -415,9 +418,13 @@ public class customerController {
|
|||||||
String res_param = obj;
|
String res_param = obj;
|
||||||
String res = "";
|
String res = "";
|
||||||
try {
|
try {
|
||||||
String token = "2096108315279888384_HJyMZK1Lco9gSZUKU1ipq85P5J32eQDdaz8WgChd1DvHrPZylIodiBmBYa8U2smKVC8MKAspXtjNQ2Fjw5MlWXDnkn5nPFPQWzSB03";
|
// String token = "2096108315279888384_HJyMZK1Lco9gSZUKU1ipq85P5J32eQDdaz8WgChd1DvHrPZylIodiBmBYa8U2smKVC8MKAspXtjNQ2Fjw5MlWXDnkn5nPFPQWzSB03";
|
||||||
|
String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("accessToken", token);//放token
|
headers.put("accessToken", accessToken);//放token
|
||||||
HttpClientResult rtn = HttpClientUtils.doPostJson(res_url, headers, obj);
|
HttpClientResult rtn = HttpClientUtils.doPostJson(res_url, headers, obj);
|
||||||
String resStr = rtn.getContent();
|
String resStr = rtn.getContent();
|
||||||
JSONObject resjs = JSONObject.parseObject(resStr);
|
JSONObject resjs = JSONObject.parseObject(resStr);
|
||||||
|
@ -62,9 +62,16 @@ public class customergroupController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String token = "2096108315279888384_Y8HeV0864EhPN9oPNs57p3B6tpFipZoQB6NMm1aczKr1QGotVhrr6FIpOfz4H67lNpol7NvBPXIb93t8U2UddG1SFKdXy5h78Sl502";
|
// String token = "2096108315279888384_Y8HeV0864EhPN9oPNs57p3B6tpFipZoQB6NMm1aczKr1QGotVhrr6FIpOfz4H67lNpol7NvBPXIb93t8U2UddG1SFKdXy5h78Sl502";
|
||||||
|
String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
if (accessToken == null || accessToken.equals("")) {
|
||||||
|
logger.info("金蝶token为空或不存在");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("accessToken", token);//放token
|
headers.put("accessToken", accessToken);//放token
|
||||||
|
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
|
|
||||||
|
@ -0,0 +1,549 @@
|
|||||||
|
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.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.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/salesPrediction")
|
||||||
|
public class salesPredictionController {
|
||||||
|
static Logger log = LoggerFactory.getLogger("salesPrediction");
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
new salesPredictionController().getSynDataAdd();
|
||||||
|
new salesPredictionController().SynSave();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = "sales_prediction__c";
|
||||||
|
|
||||||
|
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("EQ", "life_status", "normal")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// List<CrmFXApiParam> paramList = Arrays.asList(new CrmFXApiParam("EQ", "name", "XSYC-20250312-0001"));
|
||||||
|
|
||||||
|
JSONObject jsonject = fxapi.getSynNewDataObj(true, "销售预测", 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.getSendSYNDataSP("SP", 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", "SP"); //业务类型
|
||||||
|
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.saveSendSYNDataSP(jsonObjectData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SynSave() throws Exception {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
FXHTTP fxapi = new FXHTTP();
|
||||||
|
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/querysales_prediction?sendType=SP&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 remark = GcjJson.getNodeValue(str, "JSON.remark__c") != null ? GcjJson.getNodeValue(str, "JSON.remark__c").toString() : "";
|
||||||
|
|
||||||
|
|
||||||
|
String cemployeeid = "";
|
||||||
|
if (GcjJson.getNodeValue(str, "JSON.owner__r.id") != null) {
|
||||||
|
cemployeeid = GcjJson.getNodeValue(str, "JSON.owner__r.id").toString();
|
||||||
|
cemployeeid = fxapi.getDataBYID("PersonnelObj", "_id", cemployeeid, "JSON.data.dataList[0].field_T1xid__c");
|
||||||
|
}
|
||||||
|
/* if (StringUtils.isBlank(cemployeeid)) {
|
||||||
|
sendFlag = true;
|
||||||
|
stringBuffer.append("销售员不存在\n");
|
||||||
|
}*/
|
||||||
|
String cdeptid = "";
|
||||||
|
if (GcjJson.getNodeValue(str, "JSON.owner_department_id") != null) {
|
||||||
|
String dept_id = GcjJson.getNodeValue(str, "JSON.owner_department_id").toString();
|
||||||
|
cdeptid = fxapi.getDataBYID("DepartmentObj", "dept_id", dept_id, "JSON.data.dataList[0].field_Vj6sf__c");
|
||||||
|
}
|
||||||
|
// cdeptid = "zyierp";
|
||||||
|
String strJson = "";
|
||||||
|
try{
|
||||||
|
JSONObject dataSyn = MagicApi.getSendSYNDataSP("SP", 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("billno",nameData);
|
||||||
|
//简称
|
||||||
|
datajson.put("biztime",sdf.format(GcjJson.getNodeValue(str, "JSON.proposal_date__c")));
|
||||||
|
datajson.put("comment",remark);//备注
|
||||||
|
datajson.put("org_number",cdeptid);
|
||||||
|
datajson.put("dept_number",cdeptid);
|
||||||
|
datajson.put("user_number",cemployeeid);
|
||||||
|
|
||||||
|
datajson.put("billtype_number","f9w5_salespred_BT");//类型
|
||||||
|
|
||||||
|
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||||
|
// datajson.put("settlementtypeid_number","JSFS04");//结算方式
|
||||||
|
|
||||||
|
JSONArray billentry = new JSONArray();
|
||||||
|
|
||||||
|
|
||||||
|
String apiNameZ = "sales_prediction_details__c";
|
||||||
|
JSONObject jsonjectZ = fxapi.getSynDataZDYObj("销售预测明细", apiNameZ, "sales_prediction_id__c", dataId);
|
||||||
|
JSONArray arrayZ = jsonjectZ.getJSONObject("data").getJSONArray("dataList");
|
||||||
|
for (int j = 0; j < arrayZ.size(); j++) {
|
||||||
|
JSONObject stra = arrayZ.getJSONObject(j);
|
||||||
|
JSONObject billentryjson = new JSONObject();
|
||||||
|
billentryjson.put("qty", GcjJson.getNodeValue(stra, "JSON.quantity__c"));
|
||||||
|
billentryjson.put("f9w5_busopportunity", GcjJson.getNodeValue(stra, "JSON.opportunity_name_text__c"));
|
||||||
|
billentryjson.put("f9w5_tagname", GcjJson.getNodeValue(stra, "JSON.tag_name__c"));
|
||||||
|
billentryjson.put("f9w5_parameter",GcjJson.getNodeValue(stra, "JSON.parameter__c"));
|
||||||
|
|
||||||
|
billentryjson.put("f9w5_country",GcjJson.getNodeValue(stra, "JSON.field_4o10E__c__r"));
|
||||||
|
billentryjson.put("f9w5_province",GcjJson.getNodeValue(stra, "JSON.field_S0ue4__c__r"));
|
||||||
|
billentryjson.put("f9w5_city",GcjJson.getNodeValue(stra, "JSON.field_s6uUm__c__r"));
|
||||||
|
billentryjson.put("f9w5_area",GcjJson.getNodeValue(stra, "JSON.field_kq1O4__c__r"));
|
||||||
|
|
||||||
|
billentryjson.put("f9w5_siminfo",GcjJson.getNodeValue(stra, "JSON.sim_card_info__c"));
|
||||||
|
// billentryjson.put("f9w5_isurgent",GcjJson.getNodeValue(stra, "JSON.is_urgent__c"));
|
||||||
|
billentryjson.put("f9w5_isurgent","1");
|
||||||
|
billentryjson.put("f9w5_reqdelvytime",sdf.format(GcjJson.getNodeValue(stra, "JSON.required_delivery_time__c")));
|
||||||
|
billentryjson.put("f9w5_thirdpartyid",GcjJson.getNodeValue(stra, "JSON.third_party_id__c"));
|
||||||
|
billentryjson.put("f9w5_otherrequire",GcjJson.getNodeValue(stra, "JSON.other_requirements__c"));
|
||||||
|
billentryjson.put("entrycomment",GcjJson.getNodeValue(stra, "JSON.remark__c"));
|
||||||
|
billentryjson.put("material_number",GcjJson.getNodeValue(stra, "JSON.product_code_text__c"));
|
||||||
|
//billentryjson.put("material_number","10010020374");
|
||||||
|
billentry.add(billentryjson);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
datajson.put("billentry",billentry);//销售预测明细
|
||||||
|
|
||||||
|
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/sm/f9w5_salespred/salespredSave";
|
||||||
|
String res_param = obj;
|
||||||
|
String res = "";
|
||||||
|
try {
|
||||||
|
String accessToken = "2096108315279888384_8elReBSzvx315JiLWiH82YKJGosF3G2kN688q05rHUritX9x3fWS3lmetalPeMe3HceZV7fK1GdSJsk1J46A3S0VkOxIUqf7wnS207";
|
||||||
|
// String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("accessToken", accessToken);//放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.upSynZDYFieldParam("", "sales_prediction__c", 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.upSynZDYFieldParam("", "sales_prediction__c", 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.upSynZDYFieldParam("", "sales_prediction__c", dataId, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
|
||||||
|
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||||
|
|
||||||
|
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||||
|
MagicApi.updateSendSYUPDATESP(sendData);
|
||||||
|
|
||||||
|
JSONObject logData = new JSONObject();
|
||||||
|
logData.put("log_type", "SP"); //业务类型
|
||||||
|
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.saveSPLog(logData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void getSynDataUP() 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 = "sales_prediction__c";
|
||||||
|
|
||||||
|
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("EQ", "life_status", "normal")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// List<CrmFXApiParam> paramList = Arrays.asList(new CrmFXApiParam("EQ", "name", "XSYC-20250312-0001"));
|
||||||
|
|
||||||
|
JSONObject jsonject = fxapi.getSynNewDataObj(true, "销售预测", 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.getSendSYNDataSP("SPUP", 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", "SPUP"); //业务类型
|
||||||
|
jsonObjectData.put("send_syn", "1"); //同步类型 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.saveSendSYNDataSP(jsonObjectData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SynUpdate() throws Exception {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
FXHTTP fxapi = new FXHTTP();
|
||||||
|
String resJsonStr = MagicApi.getWNRES("http://localhost:18088/syn/querysales_prediction?sendType=SPUP&sendStatus=3&sendSyn=1", "");
|
||||||
|
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 remark = GcjJson.getNodeValue(str, "JSON.remark__c") != null ? GcjJson.getNodeValue(str, "JSON.remark__c").toString() : "";
|
||||||
|
|
||||||
|
|
||||||
|
String cemployeeid = "";
|
||||||
|
if (GcjJson.getNodeValue(str, "JSON.owner__r.id") != null) {
|
||||||
|
cemployeeid = GcjJson.getNodeValue(str, "JSON.owner__r.id").toString();
|
||||||
|
cemployeeid = fxapi.getDataBYID("PersonnelObj", "_id", cemployeeid, "JSON.data.dataList[0].field_T1xid__c");
|
||||||
|
}
|
||||||
|
/* if (StringUtils.isBlank(cemployeeid)) {
|
||||||
|
sendFlag = true;
|
||||||
|
stringBuffer.append("销售员不存在\n");
|
||||||
|
}*/
|
||||||
|
String cdeptid = "";
|
||||||
|
if (GcjJson.getNodeValue(str, "JSON.owner_department_id") != null) {
|
||||||
|
String dept_id = GcjJson.getNodeValue(str, "JSON.owner_department_id").toString();
|
||||||
|
cdeptid = fxapi.getDataBYID("DepartmentObj", "dept_id", dept_id, "JSON.data.dataList[0].field_Vj6sf__c");
|
||||||
|
}
|
||||||
|
// cdeptid = "zyierp";
|
||||||
|
String strJson = "";
|
||||||
|
try{
|
||||||
|
JSONObject dataSyn = MagicApi.getSendSYNDataSP("SP", 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("billno",nameData);
|
||||||
|
//简称
|
||||||
|
datajson.put("biztime",sdf.format(GcjJson.getNodeValue(str, "JSON.proposal_date__c")));
|
||||||
|
datajson.put("comment",remark);//备注
|
||||||
|
datajson.put("org_number",cdeptid);
|
||||||
|
datajson.put("dept_number",cdeptid);
|
||||||
|
datajson.put("user_number",cemployeeid);
|
||||||
|
|
||||||
|
datajson.put("billtype_number","f9w5_salespred_BT");//类型
|
||||||
|
|
||||||
|
datajson.put("f9w5_crmid",dataId);//CRMID
|
||||||
|
// datajson.put("settlementtypeid_number","JSFS04");//结算方式
|
||||||
|
|
||||||
|
JSONArray billentry = new JSONArray();
|
||||||
|
|
||||||
|
|
||||||
|
String apiNameZ = "sales_prediction_details__c";
|
||||||
|
JSONObject jsonjectZ = fxapi.getSynDataZDYObj("销售预测明细", apiNameZ, "sales_prediction_id__c", dataId);
|
||||||
|
JSONArray arrayZ = jsonjectZ.getJSONObject("data").getJSONArray("dataList");
|
||||||
|
for (int j = 0; j < arrayZ.size(); j++) {
|
||||||
|
JSONObject stra = arrayZ.getJSONObject(j);
|
||||||
|
JSONObject billentryjson = new JSONObject();
|
||||||
|
billentryjson.put("qty", GcjJson.getNodeValue(stra, "JSON.quantity__c"));
|
||||||
|
billentryjson.put("f9w5_busopportunity", GcjJson.getNodeValue(stra, "JSON.opportunity_name_text__c"));
|
||||||
|
billentryjson.put("f9w5_tagname", GcjJson.getNodeValue(stra, "JSON.tag_name__c"));
|
||||||
|
billentryjson.put("f9w5_parameter",GcjJson.getNodeValue(stra, "JSON.parameter__c"));
|
||||||
|
|
||||||
|
billentryjson.put("f9w5_country",GcjJson.getNodeValue(stra, "JSON.field_4o10E__c__r"));
|
||||||
|
billentryjson.put("f9w5_province",GcjJson.getNodeValue(stra, "JSON.field_S0ue4__c__r"));
|
||||||
|
billentryjson.put("f9w5_city",GcjJson.getNodeValue(stra, "JSON.field_s6uUm__c__r"));
|
||||||
|
billentryjson.put("f9w5_area",GcjJson.getNodeValue(stra, "JSON.field_kq1O4__c__r"));
|
||||||
|
|
||||||
|
billentryjson.put("f9w5_siminfo",GcjJson.getNodeValue(stra, "JSON.sim_card_info__c"));
|
||||||
|
// billentryjson.put("f9w5_isurgent",GcjJson.getNodeValue(stra, "JSON.is_urgent__c"));
|
||||||
|
billentryjson.put("f9w5_isurgent","1");
|
||||||
|
billentryjson.put("f9w5_reqdelvytime",sdf.format(GcjJson.getNodeValue(stra, "JSON.required_delivery_time__c")));
|
||||||
|
billentryjson.put("f9w5_thirdpartyid",GcjJson.getNodeValue(stra, "JSON.third_party_id__c"));
|
||||||
|
billentryjson.put("f9w5_otherrequire",GcjJson.getNodeValue(stra, "JSON.other_requirements__c"));
|
||||||
|
billentryjson.put("entrycomment",GcjJson.getNodeValue(stra, "JSON.remark__c"));
|
||||||
|
billentryjson.put("material_number",GcjJson.getNodeValue(stra, "JSON.product_code_text__c"));
|
||||||
|
//billentryjson.put("material_number","10010020374");
|
||||||
|
billentry.add(billentryjson);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
datajson.put("billentry",billentry);//销售预测明细
|
||||||
|
|
||||||
|
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/sm/f9w5_salespred/salespredSave";
|
||||||
|
String res_param = obj;
|
||||||
|
String res = "";
|
||||||
|
try {
|
||||||
|
String accessToken = "2096108315279888384_8elReBSzvx315JiLWiH82YKJGosF3G2kN688q05rHUritX9x3fWS3lmetalPeMe3HceZV7fK1GdSJsk1J46A3S0VkOxIUqf7wnS207";
|
||||||
|
// String accessToken = new KDTokenController().getKDAccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("accessToken", accessToken);//放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);
|
||||||
|
|
||||||
|
}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.upSynZDYFieldParam("", "sales_prediction__c", 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.upSynZDYFieldParam("", "sales_prediction__c", dataId, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
|
||||||
|
sendData.put("send_status", !sendFlag);//同步状态 true同步成功 false同步失败 3待同步
|
||||||
|
|
||||||
|
sendData.put("send_id", str.getString("sendId")); //send_id
|
||||||
|
MagicApi.updateSendSYUPDATESP(sendData);
|
||||||
|
|
||||||
|
JSONObject logData = new JSONObject();
|
||||||
|
logData.put("log_type", "SPUP"); //业务类型
|
||||||
|
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.saveSPLog(logData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -48,7 +48,26 @@ public class MagicApi {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void saveSPLog(JSONObject data) {
|
||||||
|
System.out.println(data);
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicPost(
|
||||||
|
"http://127.0.0.1:18088/send/log/savesales_prediction"
|
||||||
|
, data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void saveProjectLog(JSONObject data) {
|
||||||
|
System.out.println(data);
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicPost(
|
||||||
|
"http://127.0.0.1:18088/send/log/saveproject"
|
||||||
|
, data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void saveDataWLLog(JSONObject data) {
|
public static void saveDataWLLog(JSONObject data) {
|
||||||
//System.out.println(data.toJSONString());
|
//System.out.println(data.toJSONString());
|
||||||
try {
|
try {
|
||||||
@ -284,6 +303,26 @@ public class MagicApi {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void saveSendSYNDataSP(JSONObject data) {
|
||||||
|
System.out.println(data.toJSONString());
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicPost(
|
||||||
|
"http://127.0.0.1:18088/syn/savesales_prediction"
|
||||||
|
, data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void saveSendSYNDataProject(JSONObject data) {
|
||||||
|
System.out.println(data.toJSONString());
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicPost(
|
||||||
|
"http://127.0.0.1:18088/syn/saveProject"
|
||||||
|
, data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void saveSendSYNUser(JSONObject data) {
|
public static void saveSendSYNUser(JSONObject data) {
|
||||||
System.out.println(data.toJSONString());
|
System.out.println(data.toJSONString());
|
||||||
try {
|
try {
|
||||||
@ -314,6 +353,26 @@ public class MagicApi {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void updateSendSYUPDATESP(JSONObject data) {
|
||||||
|
System.out.println(data.toJSONString());
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicPost(
|
||||||
|
"http://127.0.0.1:18088/syn/updatesales_prediction"
|
||||||
|
, data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void updateSendSYUPDATEProject(JSONObject data) {
|
||||||
|
System.out.println(data.toJSONString());
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicPost(
|
||||||
|
"http://127.0.0.1:18088/syn/updateProjcet"
|
||||||
|
, data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void updateSendSYUPDATENUser(JSONObject data) {
|
public static void updateSendSYUPDATENUser(JSONObject data) {
|
||||||
System.out.println(data.toJSONString());
|
System.out.println(data.toJSONString());
|
||||||
try {
|
try {
|
||||||
@ -361,6 +420,61 @@ public class MagicApi {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public static JSONObject getSendSYNDataSP(String type, String syn, String dataId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicGet(
|
||||||
|
"http://127.0.0.1:18088/syn/querysales_prediction?sendType=" + URLEncoder.encode(type, "UTF-8")
|
||||||
|
+ "&crmId=" + URLEncoder.encode(dataId, "UTF-8")
|
||||||
|
+ "&sendSyn=" + URLEncoder.encode(syn, "UTF-8")
|
||||||
|
, "");
|
||||||
|
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 getSendSYNDataSP(String type, String syn, String dataId, String sendStatus3) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicGet(
|
||||||
|
"http://127.0.0.1:18088/syn/querysales_prediction?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 getSendSYNDataProject(String type, String syn, String dataId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicGet(
|
||||||
|
"http://127.0.0.1:18088/syn/queryProject?sendType=" + URLEncoder.encode(type, "UTF-8")
|
||||||
|
+ "&crmId=" + URLEncoder.encode(dataId, "UTF-8")
|
||||||
|
+ "&sendSyn=" + URLEncoder.encode(syn, "UTF-8")
|
||||||
|
, "");
|
||||||
|
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 getSendSYNDataCustomer(String type, String syn, String dataId, String sendStatus3) {
|
public static JSONObject getSendSYNDataCustomer(String type, String syn, String dataId, String sendStatus3) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -380,7 +494,25 @@ public class MagicApi {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public static JSONObject getSendSYNDataProject(String type, String syn, String dataId, String sendStatus3) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String res = HttpSend.sendMagicGet(
|
||||||
|
"http://127.0.0.1:18088/syn/queryProject?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) {
|
public static JSONObject getSendSYNDataCRM(String type, String syn, String dataId, String sendStatus3) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user