commit f696d7758279018287cd2485c7133076e1b6805f
Author: itzhang <2019326567@qq.com>
Date: Wed Jun 11 13:58:36 2025 +0800
智洋张伟龙编写的代码
diff --git a/data/magic-api/api/B-传输日志/group.json b/data/magic-api/api/B-传输日志/group.json
new file mode 100644
index 0000000..1e24dca
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/group.json
@@ -0,0 +1,14 @@
+{
+ "properties" : { },
+ "id" : "1500ff0ba1a64b3796ec9114e568869e",
+ "name" : "B-传输日志",
+ "type" : "api",
+ "parentId" : "0",
+ "path" : "/send",
+ "createTime" : 1684243742014,
+ "updateTime" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/group.json b/data/magic-api/api/B-传输日志/日志/group.json
new file mode 100644
index 0000000..1bfd11e
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/group.json
@@ -0,0 +1,14 @@
+{
+ "properties" : { },
+ "id" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "传输日志",
+ "type" : "api",
+ "parentId" : "1500ff0ba1a64b3796ec9114e568869e",
+ "path" : "/log",
+ "createTime" : 1684243742032,
+ "updateTime" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存人员同步日志.ms b/data/magic-api/api/B-传输日志/日志/保存人员同步日志.ms
new file mode 100644
index 0000000..10028d0
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存人员同步日志.ms
@@ -0,0 +1,50 @@
+{
+ "properties" : { },
+ "id" : "copy1724404999212d47014",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "保存人员同步日志",
+ "createTime" : null,
+ "updateTime" : 1743054112942,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/saveuser",
+ "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_user').primary('log_id',uuid()).save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存客户.ms b/data/magic-api/api/B-传输日志/日志/保存客户.ms
new file mode 100644
index 0000000..432359c
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存客户.ms
@@ -0,0 +1,50 @@
+{
+ "properties" : { },
+ "id" : "copy1745307476745d27404",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "保存客户",
+ "createTime" : null,
+ "updateTime" : 1745307494790,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/savecustomer",
+ "method" : "POST",
+ "parameters" : [ ],
+ "options" : [ {
+ "name" : "wrap_request_parameter",
+ "value" : "data",
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "permission",
+ "value" : "send:log:save",
+ "description" : "允许拥有该权限的访问",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ],
+ "requestBody" : "",
+ "headers" : [ ],
+ "paths" : [ ],
+ "responseBody" : null,
+ "description" : null,
+ "requestBodyDefinition" : null,
+ "responseBodyDefinition" : null
+}
+================================
+ data.create_time = new Date()
+return db.table('send_log_customer').primary('log_id',uuid()).save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存客户分类.ms b/data/magic-api/api/B-传输日志/日志/保存客户分类.ms
new file mode 100644
index 0000000..56fc2a8
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存客户分类.ms
@@ -0,0 +1,50 @@
+{
+ "properties" : { },
+ "id" : "d0c872104e524be0862e004fe29771c3",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "保存客户分类",
+ "createTime" : null,
+ "updateTime" : 1745307472124,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/save",
+ "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_customergroup').primary('log_id',uuid()).save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存成本同步日志.ms b/data/magic-api/api/B-传输日志/日志/保存成本同步日志.ms
new file mode 100644
index 0000000..58bdc45
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存成本同步日志.ms
@@ -0,0 +1,50 @@
+{
+ "properties" : { },
+ "id" : "copy1749177616553d59101",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "保存成本同步日志",
+ "createTime" : null,
+ "updateTime" : 1749178315255,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/cost",
+ "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_costrecord').primary('log_id',uuid()).save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存报价询价同步日志.ms b/data/magic-api/api/B-传输日志/日志/保存报价询价同步日志.ms
new file mode 100644
index 0000000..8d4dcb2
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存报价询价同步日志.ms
@@ -0,0 +1,50 @@
+{
+ "properties" : { },
+ "id" : "copy1747380095360d17588",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "保存报价询价同步日志",
+ "createTime" : 1747380116583,
+ "updateTime" : null,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/savepriceapprova",
+ "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_priceapprova').primary('log_id',uuid()).save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存销售预测同步日志.ms b/data/magic-api/api/B-传输日志/日志/保存销售预测同步日志.ms
new file mode 100644
index 0000000..40f9377
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存销售预测同步日志.ms
@@ -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)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存项目同步日志.ms b/data/magic-api/api/B-传输日志/日志/保存项目同步日志.ms
new file mode 100644
index 0000000..62c6ba4
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存项目同步日志.ms
@@ -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)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/保存领料同步日志.ms b/data/magic-api/api/B-传输日志/日志/保存领料同步日志.ms
new file mode 100644
index 0000000..3f78e73
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/保存领料同步日志.ms
@@ -0,0 +1,50 @@
+{
+ "properties" : { },
+ "id" : "copy1747118188498d320",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "保存领料同步日志",
+ "createTime" : null,
+ "updateTime" : 1747118204682,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/savematerialreqbill",
+ "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_materialreqbill').primary('log_id',uuid()).save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/列表.ms b/data/magic-api/api/B-传输日志/日志/列表.ms
new file mode 100644
index 0000000..3dc7ef1
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/列表.ms
@@ -0,0 +1,47 @@
+{
+ "properties" : { },
+ "id" : "ed67a93b6ded41029fdb69f3f3420fb9",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "列表",
+ "createTime" : null,
+ "updateTime" : 1699275219305,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/list",
+ "method" : "POST",
+ "parameters" : [ ],
+ "options" : [ {
+ "name" : "permission",
+ "value" : "send:log:view",
+ "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
+}
+================================
+return db.page("""
+ select log_id,log_type,log_status,syn_type,data_id,create_time,data_name,mark,res_body,send_flag,send_memo from send_log_info where 1=1
+ ?{logType, and log_type = #{logType} }
+ ?{logStatus, and log_status = #{logStatus} }
+ ?{synType, and syn_type = #{synType} }
+ ?{dataId, and data_id = #{dataId} }
+ ?{dataName, and data_name = #{dataName} }
+ ?{createTime && createTime.split(',')[0], and create_time >= #{createTime.split(',')[0]}}
+ ?{createTime && createTime.split(',')[1], and create_time <= #{createTime.split(',')[1]}}
+ ?{sendFlag, and send_flag = #{sendFlag} } order by create_time desc
+""")
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/删除.ms b/data/magic-api/api/B-传输日志/日志/删除.ms
new file mode 100644
index 0000000..e51fb13
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/删除.ms
@@ -0,0 +1,37 @@
+{
+ "properties" : { },
+ "id" : "f2d89c16aa424d74b9d6e944ea138998",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "删除",
+ "createTime" : 1696953066814,
+ "updateTime" : null,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/delete",
+ "method" : "DELETE",
+ "parameters" : [ ],
+ "options" : [ {
+ "name" : "permission",
+ "value" : "send:log:delete",
+ "description" : "允许拥有该权限的访问",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ],
+ "requestBody" : null,
+ "headers" : [ ],
+ "paths" : [ ],
+ "responseBody" : null,
+ "description" : null,
+ "requestBodyDefinition" : null,
+ "responseBodyDefinition" : null
+}
+================================
+return db.table('send_log_info').where().eq('log_id', log_id).delete()
\ No newline at end of file
diff --git a/data/magic-api/api/B-传输日志/日志/详情.ms b/data/magic-api/api/B-传输日志/日志/详情.ms
new file mode 100644
index 0000000..0bc5478
--- /dev/null
+++ b/data/magic-api/api/B-传输日志/日志/详情.ms
@@ -0,0 +1,39 @@
+{
+ "properties" : { },
+ "id" : "33b0df7daae64483b6c7067755ca7b68",
+ "script" : null,
+ "groupId" : "6ee06a9b9fe04b85b70a9364ef324ab4",
+ "name" : "详情",
+ "createTime" : 1696953066831,
+ "updateTime" : null,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/get",
+ "method" : "GET",
+ "parameters" : [ ],
+ "options" : [ {
+ "name" : "permission",
+ "value" : "send:log:view",
+ "description" : "允许拥有该权限的访问",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ],
+ "requestBody" : null,
+ "headers" : [ ],
+ "paths" : [ ],
+ "responseBody" : null,
+ "description" : null,
+ "requestBodyDefinition" : null,
+ "responseBodyDefinition" : null
+}
+================================
+return db.selectOne("""
+ select log_id,log_type,log_status,syn_type,data_id,create_time,data_name,res_body,send_flag,send_memo from send_log_info where log_id = #{log_id}
+""")
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/group.json b/data/magic-api/api/B-同步日志/group.json
new file mode 100644
index 0000000..f07565c
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/group.json
@@ -0,0 +1,14 @@
+{
+ "properties" : { },
+ "id" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "B-同步日志",
+ "type" : "api",
+ "parentId" : "0",
+ "path" : "/syn",
+ "createTime" : 1701349598045,
+ "updateTime" : 1701349674007,
+ "createBy" : null,
+ "updateBy" : null,
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/人员待同步保存.ms b/data/magic-api/api/B-同步日志/人员待同步保存.ms
new file mode 100644
index 0000000..474cf54
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/人员待同步保存.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1701349941295d22163",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "人员待同步保存",
+ "createTime" : null,
+ "updateTime" : 1743047168232,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/saveuser",
+ "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_user").primary('send_id', () => uuid())
+ .save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/修改人员同步.ms b/data/magic-api/api/B-同步日志/修改人员同步.ms
new file mode 100644
index 0000000..51aafe2
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/修改人员同步.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1701349998399d81042",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "修改人员同步",
+ "createTime" : null,
+ "updateTime" : 1743047188007,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/updateuser",
+ "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_user").primary('send_id')
+ .update(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/修改客户同步.ms b/data/magic-api/api/B-同步日志/修改客户同步.ms
new file mode 100644
index 0000000..620655e
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/修改客户同步.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1745307450958d20455",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "修改客户同步",
+ "createTime" : null,
+ "updateTime" : 1745307461569,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/updatecustomer",
+ "method" : "POST",
+ "parameters" : [ ],
+ "options" : [ {
+ "name" : "wrap_request_parameter",
+ "value" : "data",
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "permission",
+ "value" : "send:log:save",
+ "description" : "允许拥有该权限的访问",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ],
+ "requestBody" : "",
+ "headers" : [ ],
+ "paths" : [ ],
+ "responseBody" : "{\n \"code\": 500,\n \"message\": \"系统内部出现错误\",\n \"data\": null,\n \"timestamp\": 1701350039104,\n \"executeTime\": 4\n}",
+ "description" : null,
+ "requestBodyDefinition" : null,
+ "responseBodyDefinition" : {
+ "name" : "",
+ "value" : "",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ {
+ "name" : "code",
+ "value" : "500",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Integer",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "message",
+ "value" : "系统内部出现错误",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "data",
+ "value" : "null",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "timestamp",
+ "value" : "1701350039104",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Long",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "executeTime",
+ "value" : "4",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Integer",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ } ]
+ }
+}
+================================
+
+
+
+ data.update_time = new Date()
+return db.table("send_syn_customer").primary('send_id')
+ .update(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/修改成本同步.ms b/data/magic-api/api/B-同步日志/修改成本同步.ms
new file mode 100644
index 0000000..69dbbc0
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/修改成本同步.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1749178271384d15677",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "修改成本同步",
+ "createTime" : null,
+ "updateTime" : 1749178284980,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/updatecost",
+ "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_costrecord").primary('send_id')
+ .update(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/修改报价同步.ms b/data/magic-api/api/B-同步日志/修改报价同步.ms
new file mode 100644
index 0000000..72c0bb6
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/修改报价同步.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1747380151826d80978",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "修改报价同步",
+ "createTime" : 1747380163630,
+ "updateTime" : null,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/updatepriceapprova",
+ "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_priceapprova").primary('send_id')
+ .update(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/修改销售预测同步.ms b/data/magic-api/api/B-同步日志/修改销售预测同步.ms
new file mode 100644
index 0000000..47aaed7
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/修改销售预测同步.ms
@@ -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)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/修改项目同步.ms b/data/magic-api/api/B-同步日志/修改项目同步.ms
new file mode 100644
index 0000000..e7880d7
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/修改项目同步.ms
@@ -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)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/修改领料同步.ms b/data/magic-api/api/B-同步日志/修改领料同步.ms
new file mode 100644
index 0000000..ba50596
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/修改领料同步.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1747118253162d84764",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "修改领料同步",
+ "createTime" : null,
+ "updateTime" : 1747129492177,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/updatematerialreqbill",
+ "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_materialreqbill").primary('send_id')
+ .update(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/客户待同步保存.ms b/data/magic-api/api/B-同步日志/客户待同步保存.ms
new file mode 100644
index 0000000..af8eb6f
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/客户待同步保存.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1745307427497d38560",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "客户待同步保存",
+ "createTime" : null,
+ "updateTime" : 1745307448992,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/savecustomer",
+ "method" : "POST",
+ "parameters" : [ ],
+ "options" : [ {
+ "name" : "wrap_request_parameter",
+ "value" : "data",
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "permission",
+ "value" : "send:log:save",
+ "description" : "允许拥有该权限的访问",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ],
+ "requestBody" : "",
+ "headers" : [ ],
+ "paths" : [ ],
+ "responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": \"17a8bc5553e2400badd36ea784255c01\",\n \"timestamp\": 1701350036264,\n \"executeTime\": 4\n}",
+ "description" : null,
+ "requestBodyDefinition" : null,
+ "responseBodyDefinition" : {
+ "name" : "",
+ "value" : "",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ {
+ "name" : "code",
+ "value" : "200",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Integer",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "message",
+ "value" : "success",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "data",
+ "value" : "17a8bc5553e2400badd36ea784255c01",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "timestamp",
+ "value" : "1701350036264",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Long",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "executeTime",
+ "value" : "4",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Integer",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ } ]
+ }
+}
+================================
+
+
+
+ data.create_time = new Date()
+return db.table("send_syn_customer").primary('send_id', () => uuid())
+ .save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/成本待同步保存.ms b/data/magic-api/api/B-同步日志/成本待同步保存.ms
new file mode 100644
index 0000000..9230037
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/成本待同步保存.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1749178229400d98909",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "成本待同步保存",
+ "createTime" : null,
+ "updateTime" : 1749178253225,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/savecost",
+ "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_costrecord").primary('send_id', () => uuid())
+ .save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/报价待同步保存.ms b/data/magic-api/api/B-同步日志/报价待同步保存.ms
new file mode 100644
index 0000000..f6c8a3f
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/报价待同步保存.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1747380139022d12449",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "报价待同步保存",
+ "createTime" : 1747380149469,
+ "updateTime" : null,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/savepriceapprova",
+ "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_priceapprova").primary('send_id', () => uuid())
+ .save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询人员同步.ms b/data/magic-api/api/B-同步日志/查询人员同步.ms
new file mode 100644
index 0000000..5d2e572
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询人员同步.ms
@@ -0,0 +1,173 @@
+{
+ "properties" : { },
+ "id" : "copy1743047080239d23438",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "查询人员同步",
+ "createTime" : null,
+ "updateTime" : 1743047414999,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/queryuser",
+ "method" : "GET",
+ "parameters" : [ {
+ "name" : "sendType",
+ "value" : "user",
+ "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_user` where
+ send_type=#{sendType}
+
+ and dsf_id=#{dataId}
+
+
+ and dsfzhu_id=#{datapId}
+
+
+ and send_syn=#{sendSyn}
+
+
+ and send_status=#{sendStatus}
+
+
+ and crm_id=#{crmId}
+
+
+ and dsf_id=#{dsfId}
+
+
+ and send_status!=#{sendStatus3}
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询客户分类同步.ms b/data/magic-api/api/B-同步日志/查询客户分类同步.ms
new file mode 100644
index 0000000..e313b5f
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询客户分类同步.ms
@@ -0,0 +1,135 @@
+{
+ "properties" : { },
+ "id" : "95d66a27a4794b8c8126ad131743da56",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "查询客户分类同步",
+ "createTime" : null,
+ "updateTime" : 1744339012019,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/querygroup",
+ "method" : "GET",
+ "parameters" : [ {
+ "name" : "sendType",
+ "value" : "group",
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "dataId",
+ "value" : "北京市",
+ "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\": 1744339010854,\n \"executeTime\": 91\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" : "1744339010854",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Long",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "executeTime",
+ "value" : "91",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Integer",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ } ]
+ }
+}
+================================
+//查询本机mysql
+return db.select(
+"""
+ SELECT * FROM `send_log_customergroup` where
+ log_type=#{sendType}
+
+ and data_id=#{dataId}
+
+
+ and syn_type=#{sendSyn}
+
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询客户同步日志.ms b/data/magic-api/api/B-同步日志/查询客户同步日志.ms
new file mode 100644
index 0000000..e8a4f53
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询客户同步日志.ms
@@ -0,0 +1,173 @@
+{
+ "properties" : { },
+ "id" : "copy1732497876949d77458",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "查询客户同步日志",
+ "createTime" : null,
+ "updateTime" : 1745307421060,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/queryCustomer",
+ "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_customer` where
+ send_type=#{sendType}
+
+ and dsf_id=#{dataId}
+
+
+ and dsfzhu_id=#{datapId}
+
+
+ and send_syn=#{sendSyn}
+
+
+ and send_status=#{sendStatus}
+
+
+ and crm_id=#{crmId}
+
+
+ and dsf_id=#{dsfId}
+
+
+ and send_status!=#{sendStatus3}
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询成本同步.ms b/data/magic-api/api/B-同步日志/查询成本同步.ms
new file mode 100644
index 0000000..ee9aa46
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询成本同步.ms
@@ -0,0 +1,173 @@
+{
+ "properties" : { },
+ "id" : "copy1749178288259d99831",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "查询成本同步",
+ "createTime" : null,
+ "updateTime" : 1749178301250,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/querycost",
+ "method" : "GET",
+ "parameters" : [ {
+ "name" : "sendType",
+ "value" : "user",
+ "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_costrecord` where
+ send_type=#{sendType}
+
+ and dsf_id=#{dataId}
+
+
+ and dsfzhu_id=#{datapId}
+
+
+ and send_syn=#{sendSyn}
+
+
+ and send_status=#{sendStatus}
+
+
+ and crm_id=#{crmId}
+
+
+ and dsf_id=#{dsfId}
+
+
+ and send_status!=#{sendStatus3}
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询报价同步日志.ms b/data/magic-api/api/B-同步日志/查询报价同步日志.ms
new file mode 100644
index 0000000..a82dd30
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询报价同步日志.ms
@@ -0,0 +1,173 @@
+{
+ "properties" : { },
+ "id" : "copy1747380121763d51481",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "查询报价同步日志",
+ "createTime" : null,
+ "updateTime" : 1747380132413,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/querypriceapprova",
+ "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_priceapprova` where
+ send_type=#{sendType}
+
+ and dsf_id=#{dataId}
+
+
+ and dsfzhu_id=#{datapId}
+
+
+ and send_syn=#{sendSyn}
+
+
+ and send_status=#{sendStatus}
+
+
+ and crm_id=#{crmId}
+
+
+ and dsf_id=#{dsfId}
+
+
+ and send_status!=#{sendStatus3}
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询销售预测同步日志.ms b/data/magic-api/api/B-同步日志/查询销售预测同步日志.ms
new file mode 100644
index 0000000..0db93b8
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询销售预测同步日志.ms
@@ -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}
+
+ and dsf_id=#{dataId}
+
+
+ and dsfzhu_id=#{datapId}
+
+
+ and send_syn=#{sendSyn}
+
+
+ and send_status=#{sendStatus}
+
+
+ and crm_id=#{crmId}
+
+
+ and dsf_id=#{dsfId}
+
+
+ and send_status!=#{sendStatus3}
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询项目同步日志.ms b/data/magic-api/api/B-同步日志/查询项目同步日志.ms
new file mode 100644
index 0000000..ce4fe0e
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询项目同步日志.ms
@@ -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}
+
+ and dsf_id=#{dataId}
+
+
+ and dsfzhu_id=#{datapId}
+
+
+ and send_syn=#{sendSyn}
+
+
+ and send_status=#{sendStatus}
+
+
+ and crm_id=#{crmId}
+
+
+ and dsf_id=#{dsfId}
+
+
+ and send_status!=#{sendStatus3}
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/查询领料同步日志.ms b/data/magic-api/api/B-同步日志/查询领料同步日志.ms
new file mode 100644
index 0000000..a759c69
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/查询领料同步日志.ms
@@ -0,0 +1,173 @@
+{
+ "properties" : { },
+ "id" : "copy1747118211168d30333",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "查询领料同步日志",
+ "createTime" : null,
+ "updateTime" : 1747118228927,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/querymaterialreqbill",
+ "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_materialreqbill` where
+ send_type=#{sendType}
+
+ and dsf_id=#{dataId}
+
+
+ and dsfzhu_id=#{datapId}
+
+
+ and send_syn=#{sendSyn}
+
+
+ and send_status=#{sendStatus}
+
+
+ and crm_id=#{crmId}
+
+
+ and dsf_id=#{dsfId}
+
+
+ and send_status!=#{sendStatus3}
+
+ order by create_time desc
+
+""");
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/销售预测待同步保存.ms b/data/magic-api/api/B-同步日志/销售预测待同步保存.ms
new file mode 100644
index 0000000..84f6299
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/销售预测待同步保存.ms
@@ -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)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/项目待同步保存.ms b/data/magic-api/api/B-同步日志/项目待同步保存.ms
new file mode 100644
index 0000000..816c26b
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/项目待同步保存.ms
@@ -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)
\ No newline at end of file
diff --git a/data/magic-api/api/B-同步日志/领料待同步保存.ms b/data/magic-api/api/B-同步日志/领料待同步保存.ms
new file mode 100644
index 0000000..e073683
--- /dev/null
+++ b/data/magic-api/api/B-同步日志/领料待同步保存.ms
@@ -0,0 +1,126 @@
+{
+ "properties" : { },
+ "id" : "copy1747118238121d79879",
+ "script" : null,
+ "groupId" : "4506c21162d24d4c81bad5bc8707672a",
+ "name" : "领料待同步保存",
+ "createTime" : null,
+ "updateTime" : 1747118249721,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/savematerialreqbill",
+ "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_materialreqbill").primary('send_id', () => uuid())
+ .save(data)
\ No newline at end of file
diff --git a/data/magic-api/api/日志/group.json b/data/magic-api/api/日志/group.json
new file mode 100644
index 0000000..2f2c423
--- /dev/null
+++ b/data/magic-api/api/日志/group.json
@@ -0,0 +1,14 @@
+{
+ "properties" : { },
+ "id" : "55b38df92caf40b99b60fcc88e5ce361",
+ "name" : "日志",
+ "type" : "api",
+ "parentId" : "0",
+ "path" : "Log",
+ "createTime" : 1742981192694,
+ "updateTime" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/api/日志/新增日志.ms b/data/magic-api/api/日志/新增日志.ms
new file mode 100644
index 0000000..c16a2d9
--- /dev/null
+++ b/data/magic-api/api/日志/新增日志.ms
@@ -0,0 +1,46 @@
+{
+ "properties" : { },
+ "id" : "0ed26502b95049db8e00316c785c24c3",
+ "script" : null,
+ "groupId" : "55b38df92caf40b99b60fcc88e5ce361",
+ "name" : "新增日志",
+ "createTime" : null,
+ "updateTime" : 1749432031009,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/insert/log_data",
+ "method" : "POST",
+ "parameters" : [ ],
+ "options" : [ ],
+ "requestBody" : "",
+ "headers" : [ ],
+ "paths" : [ ],
+ "responseBody" : null,
+ "description" : null,
+ "requestBodyDefinition" : null,
+ "responseBodyDefinition" : null
+}
+================================
+return db.Log.insert("""
+
+insert into ${body.tableName} (
+ log_id,
+ log_type,
+ log_status,
+ syn_type,
+ data_id,
+ data_name,
+ mark,
+ res_body,
+ mark_id,
+ send_url,
+ send_body,
+ send_res,
+ send_flag,
+ send_memo)
+values
+(#{body.log_id},#{body.log_type},#{body.log_status},#{body.syn_type},#{body.data_id},#{body.data_name},#{body.mark},#{body.res_body},#{body.mark_id},
+#{body.send_url},#{body.send_body},#{body.send_res},#{body.send_flag},#{body.send_memo})
+
+""")
\ No newline at end of file
diff --git a/data/magic-api/api/日志/查询日志.ms b/data/magic-api/api/日志/查询日志.ms
new file mode 100644
index 0000000..7287ca0
--- /dev/null
+++ b/data/magic-api/api/日志/查询日志.ms
@@ -0,0 +1,330 @@
+{
+ "properties" : { },
+ "id" : "89c69bcd049d47228b3298cf0e318756",
+ "script" : null,
+ "groupId" : "55b38df92caf40b99b60fcc88e5ce361",
+ "name" : "查询日志",
+ "createTime" : null,
+ "updateTime" : 1749615961240,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/query/log_data",
+ "method" : "GET",
+ "parameters" : [ {
+ "name" : "table",
+ "value" : "send_log_htxx",
+ "description" : null,
+ "required" : true,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "dataId",
+ "value" : "68402bae3bf7c10001a2df32",
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "mark",
+ "value" : "1749084392443",
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "log_type",
+ "value" : "XSHT",
+ "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 \"logId\": \"08380a4057b3489b8e7952503c73e33e\",\n \"logType\": \"XSHT\",\n \"logStatus\": \"0\",\n \"synType\": \"0\",\n \"dataId\": \"68402bae3bf7c10001a2df32\",\n \"dataName\": \"ZHY2506040011\",\n \"mark\": \"1749084392443\",\n \"resBody\": \"同步成功\",\n \"markId\": null,\n \"sendUrl\": null,\n \"sendBody\": \"{\\\"body\\\":{\\\"data\\\":[{\\\"billname\\\":\\\"20250415095820391422(20250604测试)\\\",\\\"customer_number\\\":\\\"K01430013\\\",\\\"installationmethod\\\":\\\"opt1\\\",\\\"city\\\":\\\"湖南省\\\",\\\"payingcustomer_number\\\":\\\"K01430013\\\",\\\"county\\\":\\\"2251\\\",\\\"type_number\\\":\\\"XSHT-QD01\\\",\\\"reccustomer_number\\\":\\\"K01430013\\\",\\\"zhybilltype\\\":\\\"opt1\\\",\\\"totalallamount\\\":0,\\\"projectsource\\\":\\\"opt3\\\",\\\"party1st\\\":\\\"湖南星航电力科技有限公司\\\",\\\"operator\\\":\\\"ZHY11191\\\",\\\"industrytype_number\\\":\\\"opt1\\\",\\\"bizmode\\\":\\\"C\\\",\\\"crmid\\\":\\\"68402bae3bf7c10001a2df32\\\",\\\"billtype_number\\\":\\\"conm_salcontract_BT_QD\\\",\\\"province\\\":\\\"湖南省\\\",\\\"currency_number\\\":\\\"CNY\\\",\\\"salesmethod\\\":\\\"opt2\\\",\\\"biztimeend\\\":1744646400000,\\\"station\\\":\\\"opt2\\\",\\\"warranty\\\":24,\\\"biztime\\\":1744646400000,\\\"customerpropert\\\":\\\"opt2\\\",\\\"party2nd\\\":\\\"智洋创新科技股份有限公司\\\",\\\"deviceqty\\\":0,\\\"delivery\\\":false,\\\"biztimebegin\\\":1744646400000,\\\"isbidding\\\":false,\\\"dept\\\":\\\"004\\\",\\\"createorg_number\\\":\\\"ZHY\\\",\\\"contparties_number\\\":\\\"ZHY\\\",\\\"productline_number\\\":\\\"opt1\\\",\\\"project_number\\\":\\\"SJ20250604-0480\\\",\\\"billentry\\\":[{\\\"unit1_number\\\":\\\"pcs\\\",\\\"f9w5_unit1_number\\\":\\\"pcs\\\",\\\"baseunit\\\":\\\"套\\\",\\\"taxrateid_number\\\":\\\"V13\\\",\\\"linetype_number\\\":\\\"020\\\",\\\"specification\\\":\\\"无\\\",\\\"baseqty\\\":2,\\\"goodsname\\\":\\\"线路在线监测装置, 视频在线监测装置\\\",\\\"crmentryid\\\":\\\"68402bae3bf7c10001a2df33\\\",\\\"unit_number\\\":\\\"pcs\\\",\\\"material_number\\\":\\\"TEST0001\\\",\\\"qty\\\":2,\\\"curamountandtax\\\":53000.00,\\\"priceandtax\\\":26500.00}],\\\"org_number\\\":\\\"ZHY\\\",\\\"settlecurrency_number\\\":\\\"CNY\\\",\\\"settlecustomer_number\\\":\\\"K01430013\\\",\\\"billno\\\":\\\"ZHY2506040011\\\"}]},\\\"headers\\\":{\\\"Content-Type\\\":[\\\"application/json\\\"],\\\"accessToken\\\":[\\\"2095345516136108032_1IUXws7URzEN2w5yui9HYbtRNXcmFDGZ42aUIqhyVV8dMfy7GV2EiEwAJq4JzGWhDKPzAVPgQwC5phRjGh6sid53qc88G6e9NmQS00\\\"],\\\"Idempotency-Key\\\":[\\\"96a5582c51984b479fad836c84f38d10\\\"]}}\",\n \"sendRes\": \"{\\\"data\\\":{\\\"failCount\\\":\\\"0\\\",\\\"result\\\":[{\\\"billIndex\\\":0,\\\"billStatus\\\":true,\\\"errors\\\":[],\\\"id\\\":\\\"2230400248864334848\\\",\\\"keys\\\":{\\\"f9w5_crmid\\\":\\\"68402bae3bf7c10001a2df32\\\"},\\\"number\\\":\\\"ZHY2506040011\\\",\\\"type\\\":\\\"Add\\\"}],\\\"successCount\\\":\\\"1\\\"},\\\"errorCode\\\":\\\"0\\\",\\\"status\\\":true}\",\n \"sendFlag\": null,\n \"sendMemo\": null\n }],\n \"timestamp\": 1749615949677,\n \"executeTime\": 67\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" : "",
+ "value" : "",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ {
+ "name" : "logId",
+ "value" : "08380a4057b3489b8e7952503c73e33e",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "logType",
+ "value" : "XSHT",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "logStatus",
+ "value" : "0",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "synType",
+ "value" : "0",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "dataId",
+ "value" : "68402bae3bf7c10001a2df32",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "dataName",
+ "value" : "ZHY2506040011",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "mark",
+ "value" : "1749084392443",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "resBody",
+ "value" : "同步成功",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "markId",
+ "value" : "null",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "sendUrl",
+ "value" : "null",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "sendBody",
+ "value" : "{\\\"body\\\":{\\\"data\\\":[{\\\"billname\\\":\\\"20250415095820391422(20250604测试)\\\",\\\"customer_number\\\":\\\"K01430013\\\",\\\"installationmethod\\\":\\\"opt1\\\",\\\"city\\\":\\\"湖南省\\\",\\\"payingcustomer_number\\\":\\\"K01430013\\\",\\\"county\\\":\\\"2251\\\",\\\"type_number\\\":\\\"XSHT-QD01\\\",\\\"reccustomer_number\\\":\\\"K01430013\\\",\\\"zhybilltype\\\":\\\"opt1\\\",\\\"totalallamount\\\":0,\\\"projectsource\\\":\\\"opt3\\\",\\\"party1st\\\":\\\"湖南星航电力科技有限公司\\\",\\\"operator\\\":\\\"ZHY11191\\\",\\\"industrytype_number\\\":\\\"opt1\\\",\\\"bizmode\\\":\\\"C\\\",\\\"crmid\\\":\\\"68402bae3bf7c10001a2df32\\\",\\\"billtype_number\\\":\\\"conm_salcontract_BT_QD\\\",\\\"province\\\":\\\"湖南省\\\",\\\"currency_number\\\":\\\"CNY\\\",\\\"salesmethod\\\":\\\"opt2\\\",\\\"biztimeend\\\":1744646400000,\\\"station\\\":\\\"opt2\\\",\\\"warranty\\\":24,\\\"biztime\\\":1744646400000,\\\"customerpropert\\\":\\\"opt2\\\",\\\"party2nd\\\":\\\"智洋创新科技股份有限公司\\\",\\\"deviceqty\\\":0,\\\"delivery\\\":false,\\\"biztimebegin\\\":1744646400000,\\\"isbidding\\\":false,\\\"dept\\\":\\\"004\\\",\\\"createorg_number\\\":\\\"ZHY\\\",\\\"contparties_number\\\":\\\"ZHY\\\",\\\"productline_number\\\":\\\"opt1\\\",\\\"project_number\\\":\\\"SJ20250604-0480\\\",\\\"billentry\\\":[{\\\"unit1_number\\\":\\\"pcs\\\",\\\"f9w5_unit1_number\\\":\\\"pcs\\\",\\\"baseunit\\\":\\\"套\\\",\\\"taxrateid_number\\\":\\\"V13\\\",\\\"linetype_number\\\":\\\"020\\\",\\\"specification\\\":\\\"无\\\",\\\"baseqty\\\":2,\\\"goodsname\\\":\\\"线路在线监测装置, 视频在线监测装置\\\",\\\"crmentryid\\\":\\\"68402bae3bf7c10001a2df33\\\",\\\"unit_number\\\":\\\"pcs\\\",\\\"material_number\\\":\\\"TEST0001\\\",\\\"qty\\\":2,\\\"curamountandtax\\\":53000.00,\\\"priceandtax\\\":26500.00}],\\\"org_number\\\":\\\"ZHY\\\",\\\"settlecurrency_number\\\":\\\"CNY\\\",\\\"settlecustomer_number\\\":\\\"K01430013\\\",\\\"billno\\\":\\\"ZHY2506040011\\\"}]},\\\"headers\\\":{\\\"Content-Type\\\":[\\\"application/json\\\"],\\\"accessToken\\\":[\\\"2095345516136108032_1IUXws7URzEN2w5yui9HYbtRNXcmFDGZ42aUIqhyVV8dMfy7GV2EiEwAJq4JzGWhDKPzAVPgQwC5phRjGh6sid53qc88G6e9NmQS00\\\"],\\\"Idempotency-Key\\\":[\\\"96a5582c51984b479fad836c84f38d10\\\"]}}",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "sendRes",
+ "value" : "{\\\"data\\\":{\\\"failCount\\\":\\\"0\\\",\\\"result\\\":[{\\\"billIndex\\\":0,\\\"billStatus\\\":true,\\\"errors\\\":[],\\\"id\\\":\\\"2230400248864334848\\\",\\\"keys\\\":{\\\"f9w5_crmid\\\":\\\"68402bae3bf7c10001a2df32\\\"},\\\"number\\\":\\\"ZHY2506040011\\\",\\\"type\\\":\\\"Add\\\"}],\\\"successCount\\\":\\\"1\\\"},\\\"errorCode\\\":\\\"0\\\",\\\"status\\\":true}",
+ "description" : "",
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "sendFlag",
+ "value" : "null",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "sendMemo",
+ "value" : "null",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Object",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ } ]
+ } ]
+ }, {
+ "name" : "timestamp",
+ "value" : "1749615949677",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Long",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ }, {
+ "name" : "executeTime",
+ "value" : "67",
+ "description" : "",
+ "required" : false,
+ "dataType" : "Integer",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : "",
+ "error" : "",
+ "expression" : "",
+ "children" : [ ]
+ } ]
+ }
+}
+================================
+return db.Log.select("""
+
+select log_id,log_type,log_status,syn_type,data_id,data_name,mark,res_body,mark_id,send_url,send_body,send_res,send_flag,send_memo from ${table}
+where log_type = #{log_type} and data_id = #{dataId} and mark = #{mark}
+
+""")
\ No newline at end of file
diff --git a/data/magic-api/component/传输日志/group.json b/data/magic-api/component/传输日志/group.json
new file mode 100644
index 0000000..d096a05
--- /dev/null
+++ b/data/magic-api/component/传输日志/group.json
@@ -0,0 +1,14 @@
+{
+ "properties" : { },
+ "id" : "710c9f13f48248a382e695af54270dd6",
+ "name" : "传输日志",
+ "type" : "component",
+ "parentId" : "0",
+ "path" : "/send",
+ "createTime" : 1684243742087,
+ "updateTime" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/component/传输日志/传输日志/group.json b/data/magic-api/component/传输日志/传输日志/group.json
new file mode 100644
index 0000000..0c0e7dd
--- /dev/null
+++ b/data/magic-api/component/传输日志/传输日志/group.json
@@ -0,0 +1,14 @@
+{
+ "properties" : { },
+ "id" : "24eb9e08fa46447db43eba7618df7cc7",
+ "name" : "传输日志",
+ "type" : "component",
+ "parentId" : "710c9f13f48248a382e695af54270dd6",
+ "path" : "/log",
+ "createTime" : 1684243742092,
+ "updateTime" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/component/传输日志/传输日志/列表.ms b/data/magic-api/component/传输日志/传输日志/列表.ms
new file mode 100644
index 0000000..2cae968
--- /dev/null
+++ b/data/magic-api/component/传输日志/传输日志/列表.ms
@@ -0,0 +1,238 @@
+{
+ "properties" : { },
+ "id" : "49575ce482694a50ab641e9835c64865",
+ "script" : null,
+ "groupId" : "24eb9e08fa46447db43eba7618df7cc7",
+ "name" : "列表",
+ "createTime" : 1684253377806,
+ "updateTime" : 1684253426051,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/list",
+ "description" : null
+}
+================================
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/magic-api/component/数据管理/group.json b/data/magic-api/component/数据管理/group.json
new file mode 100644
index 0000000..433a69c
--- /dev/null
+++ b/data/magic-api/component/数据管理/group.json
@@ -0,0 +1,10 @@
+{
+ "properties" : { },
+ "id" : "55ff62aa20144b7bb5c6dfb5d76c8139",
+ "name" : "数据管理",
+ "type" : "component",
+ "parentId" : "0",
+ "path" : "/data",
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/component/数据管理/测试生成/group.json b/data/magic-api/component/数据管理/测试生成/group.json
new file mode 100644
index 0000000..07320e8
--- /dev/null
+++ b/data/magic-api/component/数据管理/测试生成/group.json
@@ -0,0 +1,10 @@
+{
+ "properties" : { },
+ "id" : "eb5dbed949de4f50ba4bf59f483252a5",
+ "name" : "测试生成",
+ "type" : "component",
+ "parentId" : "55ff62aa20144b7bb5c6dfb5d76c8139",
+ "path" : "/test",
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/component/数据管理/测试生成/列表.ms b/data/magic-api/component/数据管理/测试生成/列表.ms
new file mode 100644
index 0000000..08695e8
--- /dev/null
+++ b/data/magic-api/component/数据管理/测试生成/列表.ms
@@ -0,0 +1,166 @@
+{
+ "properties" : { },
+ "id" : "5770db2417964e91a87544a3d3ceb807",
+ "script" : null,
+ "groupId" : "eb5dbed949de4f50ba4bf59f483252a5",
+ "name" : "列表",
+ "createTime" : 1702995342933,
+ "updateTime" : null,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/list",
+ "description" : null
+}
+================================
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/magic-api/datasource/日志.json b/data/magic-api/datasource/日志.json
new file mode 100644
index 0000000..20c71d6
--- /dev/null
+++ b/data/magic-api/datasource/日志.json
@@ -0,0 +1,19 @@
+{
+ "properties" : { },
+ "id" : "3e3ba03a77b943eb85e4c528916e3586",
+ "script" : null,
+ "groupId" : "datasource:0",
+ "name" : "日志",
+ "createTime" : 1742981169023,
+ "updateTime" : null,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "url" : "jdbc:mysql://116.204.34.35:13300/zycx",
+ "username" : "root",
+ "password" : "root",
+ "key" : "Log",
+ "maxRows" : -1,
+ "driverClassName" : "com.mysql.cj.jdbc.Driver",
+ "type" : "com.alibaba.druid.pool.DruidDataSource"
+}
\ No newline at end of file
diff --git a/data/magic-api/function/权限/group.json b/data/magic-api/function/权限/group.json
new file mode 100644
index 0000000..89aea2e
--- /dev/null
+++ b/data/magic-api/function/权限/group.json
@@ -0,0 +1,10 @@
+{
+ "properties" : { },
+ "id" : "41922e26ef57421f8819fe6c59f14d63",
+ "name" : "权限",
+ "type" : "function",
+ "parentId" : "0",
+ "path" : "/permission",
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/function/权限/组织机构.ms b/data/magic-api/function/权限/组织机构.ms
new file mode 100644
index 0000000..78ec679
--- /dev/null
+++ b/data/magic-api/function/权限/组织机构.ms
@@ -0,0 +1,54 @@
+{
+ "properties" : { },
+ "id" : "a5f80b11b7fb4f3c97252331c80bcf85",
+ "script" : null,
+ "groupId" : "41922e26ef57421f8819fe6c59f14d63",
+ "name" : "组织机构",
+ "createTime" : 1646490239535,
+ "updateTime" : 1642327198030,
+ "lock" : "0",
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/office",
+ "description" : null,
+ "returnType" : null,
+ "mappingPath" : "/permission/office",
+ "parameters" : [ ]
+}
+================================
+import 'cn.dev33.satoken.stp.StpUtil';
+
+var currentUserId = StpUtil.getLoginId()
+//查出当前用户有多少角色
+var roles = db.select("""
+ select permission from sys_role where is_del = 0 and id in (select role_id from sys_user_role where user_id = #{currentUserId})
+""")
+var userIds = []
+for(role in roles){
+ if(role.permission == '0'){
+ return []
+ }else if(role.permission == '1'){
+ userIds.addAll(db.select("""
+ select id from sys_user where is_del = 0 and office_id in (
+ select office_id from sys_role_office where role_id in (
+ select role_id from sys_user_role where user_id = #{currentUserId}
+ )
+ )
+ """).map(it => it.id))
+ }else{
+ var officeId = db.selectValue("select office_id from sys_user where id = #{currentUserId}")
+ var offices = []
+ offices.push(officeId)
+ var getOfficeId = (list,pid) => {
+ var ids = select t.id from list t where t.pid = pid;
+ for(it in ids){
+ offices.push(it.id)
+ getOfficeId(list,it.id)
+ }
+ }
+ getOfficeId(db.select('select id, pid from sys_office where is_del = 0 order by sort'),officeId)
+ userIds.addAll(db.select("select id from sys_user where office_id in (#{offices})").map(it => it.id))
+ }
+}
+
+return userIds
\ No newline at end of file
diff --git a/data/magic-api/function/配置中心/group.json b/data/magic-api/function/配置中心/group.json
new file mode 100644
index 0000000..b3fe8e2
--- /dev/null
+++ b/data/magic-api/function/配置中心/group.json
@@ -0,0 +1,14 @@
+{
+ "properties" : { },
+ "id" : "7e31035eb8d4471b9fc2923ea1d966c3",
+ "name" : "配置中心",
+ "type" : "function",
+ "parentId" : "0",
+ "path" : "configure",
+ "createTime" : 1653109451626,
+ "updateTime" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "paths" : [ ],
+ "options" : [ ]
+}
\ No newline at end of file
diff --git a/data/magic-api/function/配置中心/根据keyAndcondition获取数据值.ms b/data/magic-api/function/配置中心/根据keyAndcondition获取数据值.ms
new file mode 100644
index 0000000..49c4a3d
--- /dev/null
+++ b/data/magic-api/function/配置中心/根据keyAndcondition获取数据值.ms
@@ -0,0 +1,48 @@
+{
+ "properties" : { },
+ "id" : "copy1653111178446d65648",
+ "script" : null,
+ "groupId" : "7e31035eb8d4471b9fc2923ea1d966c3",
+ "name" : "根据keyAndcondition获取数据值",
+ "createTime" : null,
+ "updateTime" : 1653118303409,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/getBykeyCondition",
+ "description" : null,
+ "returnType" : null,
+ "mappingPath" : null,
+ "parameters" : [ {
+ "name" : "configureKey",
+ "value" : null,
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : "java.lang.String",
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "configureCondition",
+ "value" : null,
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : "java.lang.String",
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ]
+}
+================================
+var configure = db.cache(`configure:${configureKey}${configureCondition}`).selectOne("""
+ select configure_value from sys_configure where configure_key = #{configureKey}
+ ?{configureCondition, and configure_condition = #{configureCondition}}
+""")
+
+return configure == null ? "" : configure.get("configureValue")
\ No newline at end of file
diff --git a/data/magic-api/function/配置中心/根据keyLikeCondition获取数据值.ms b/data/magic-api/function/配置中心/根据keyLikeCondition获取数据值.ms
new file mode 100644
index 0000000..827cd68
--- /dev/null
+++ b/data/magic-api/function/配置中心/根据keyLikeCondition获取数据值.ms
@@ -0,0 +1,48 @@
+{
+ "properties" : { },
+ "id" : "copy1653112036134d44643",
+ "script" : null,
+ "groupId" : "7e31035eb8d4471b9fc2923ea1d966c3",
+ "name" : "根据keyLikeCondition获取数据值",
+ "createTime" : null,
+ "updateTime" : 1653118334978,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/getLikeCondition",
+ "description" : null,
+ "returnType" : null,
+ "mappingPath" : null,
+ "parameters" : [ {
+ "name" : "configureKey",
+ "value" : null,
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : "java.lang.String",
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ }, {
+ "name" : "configureCondition",
+ "value" : null,
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : null,
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ]
+}
+================================
+var configure = db.cache(`configure:${configureKey}${configureCondition}`).selectOne("""
+ select configure_value from sys_configure where configure_key = #{configureKey}
+ ?{configureCondition, and configure_condition like concat('%',#{configureCondition},'%')}
+""")
+
+return configure == null ? "" : configure.get("configureValue")
\ No newline at end of file
diff --git a/data/magic-api/function/配置中心/根据key获取数据值.ms b/data/magic-api/function/配置中心/根据key获取数据值.ms
new file mode 100644
index 0000000..ac068d4
--- /dev/null
+++ b/data/magic-api/function/配置中心/根据key获取数据值.ms
@@ -0,0 +1,34 @@
+{
+ "properties" : { },
+ "id" : "3a21cd5fcd9b4e96b870a2268088266d",
+ "script" : null,
+ "groupId" : "7e31035eb8d4471b9fc2923ea1d966c3",
+ "name" : "根据key获取数据值",
+ "createTime" : null,
+ "updateTime" : 1653119091752,
+ "lock" : null,
+ "createBy" : null,
+ "updateBy" : null,
+ "path" : "/getBykey",
+ "description" : null,
+ "returnType" : null,
+ "mappingPath" : null,
+ "parameters" : [ {
+ "name" : "configureKey",
+ "value" : null,
+ "description" : null,
+ "required" : false,
+ "dataType" : "String",
+ "type" : "java.lang.String",
+ "defaultValue" : null,
+ "validateType" : null,
+ "error" : null,
+ "expression" : null,
+ "children" : null
+ } ]
+}
+================================
+var configure = db.cache(`configure:${configureKey}`).selectOne("""
+ select configure_value from sys_configure where configure_key = #{configureKey}
+""")
+return configure == null ? "" : configure.get("configureValue")
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..504fe5e
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,114 @@
+
+
+ 4.0.0
+ com.example
+ zhyManagement
+ 0.0.1-SNAPSHOT
+ zhyManagement
+ zhyManagement
+
+ 1.8
+ UTF-8
+ UTF-8
+ 2.6.13
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.2.2
+
+
+ com.mysql
+ mysql-connector-j
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.ssssssss
+ magic-api-spring-boot-starter
+ 2.0.1
+
+
+ com.alibaba
+ fastjson
+ 2.0.31
+
+
+ com.alibaba
+ druid
+ 1.2.22
+
+
+
+ com.github.ben-manes.caffeine
+ caffeine
+ 2.9.1
+
+
+ org.projectlombok
+ lombok
+ 1.18.4
+ provided
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+ 2.13.4
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+ UTF-8
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot.version}
+
+ com.management.ZhyManagementApplication
+
+
+
+
+ repackage
+
+ repackage
+
+
+
+
+
+ zhyManagement
+
+
+
diff --git a/src/main/java/com/management/ZhyManagementApplication.java b/src/main/java/com/management/ZhyManagementApplication.java
new file mode 100644
index 0000000..9f1f00f
--- /dev/null
+++ b/src/main/java/com/management/ZhyManagementApplication.java
@@ -0,0 +1,16 @@
+package com.management;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@Slf4j
+public class ZhyManagementApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ZhyManagementApplication.class, args);
+ log.info("程序启动成功");
+ }
+
+}
diff --git a/src/main/java/com/management/config/MagicBootConfiguration.java b/src/main/java/com/management/config/MagicBootConfiguration.java
new file mode 100644
index 0000000..51b2b44
--- /dev/null
+++ b/src/main/java/com/management/config/MagicBootConfiguration.java
@@ -0,0 +1,19 @@
+package com.management.config;
+
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+@Configuration
+public class MagicBootConfiguration {
+
+ @Bean
+ public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
+ LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeSerializer);
+ }
+}
diff --git a/src/main/java/com/management/constant/CertificateConstant.java b/src/main/java/com/management/constant/CertificateConstant.java
new file mode 100644
index 0000000..64bc6e8
--- /dev/null
+++ b/src/main/java/com/management/constant/CertificateConstant.java
@@ -0,0 +1,22 @@
+package com.management.constant;
+
+/**
+ * 创宇CRM的证书常量
+ *
+ * @param
+ * @return null
+ * @Author weiloong_zhang
+ */
+public class CertificateConstant {
+ public static final String APP_ID = "FSAID_131f56a";//appId
+ public static final String PERMANENT_CODE = "1A49B50861909007935CAB5E33E52BAA";//永久授权码
+ public static final String APP_SECRET = "5bda722932a54e80a05d2cc9b1722fed";//appSecret
+ public static final String CORP_ID = "FSCID_11F505C980B5FE43D5D7230567802E09";//企业Id
+ public static final String CURRENT_OPEN_USERID = "FSUID_A9AD0C360309427B3F431487883B73B9";//当前登录用户id
+
+// public static final String APP_ID = "FSAID_131fa51";//appId
+// public static final String PERMANENT_CODE = "EF03533F6929B59934A7E1155221420B";//永久授权码
+// public static final String APP_SECRET = "1ce9804037ff4baf9d308bd32a4ec6ef";//appSecret
+// public static final String CORP_ID = "FSCID_EC935623350FB07DBF52F84F49874A81";//企业Id
+// public static final String CURRENT_OPEN_USERID = "FSUID_7B52D1CF1B01E5A2A143E250A5B60595";//当前登录用户id
+}
diff --git a/src/main/java/com/management/constant/ERPURLConstant.java b/src/main/java/com/management/constant/ERPURLConstant.java
new file mode 100644
index 0000000..e277502
--- /dev/null
+++ b/src/main/java/com/management/constant/ERPURLConstant.java
@@ -0,0 +1,6 @@
+package com.management.constant;
+
+public class ERPURLConstant {
+ public static final String ERP_URL = "http://192.168.31.233:8022";//erp地址
+ public static final String ACCOUNT_ID = "2095345516136108032";//erp地址
+}
diff --git a/src/main/java/com/management/constant/URLConstant.java b/src/main/java/com/management/constant/URLConstant.java
new file mode 100644
index 0000000..a270bfa
--- /dev/null
+++ b/src/main/java/com/management/constant/URLConstant.java
@@ -0,0 +1,22 @@
+package com.management.constant;
+
+/**
+ * 接口地址URL常量
+ *
+ * @param
+ * @return null
+ * @Author weiloong_zhang
+ */
+public class URLConstant {
+ public static final String GET_CORPACCESSTOKEN_URL = "https://open.fxiaoke.com/cgi/corpAccessToken/get/V2";//获取token的接口地址
+ public static final String GET_CRM_LIST_URL = "https://open.fxiaoke.com/cgi/crm/v2/data/query";//获取客户列表的接口地址
+ public static final String GET_CUSTOMIZE_LIST_URL = "https://open.fxiaoke.com/cgi/crm/custom/v2/data/query";//获取自定义对象列表的接口地址
+ public static final String UPDATE_CRM_MAIN = "https://open.fxiaoke.com/cgi/crm/v2/data/update";
+ public static final String CREATE_CRM_MAIN = "https://open.fxiaoke.com/cgi/crm/v2/data/create";
+ public static final String CREATE_CRM_CUSTOMER_MAIN = "https://open.fxiaoke.com/cgi/crm/custom/v2/data/create";
+ public static final String UNLOCK_CRM_URL = "https://open.fxiaoke.com/cgi/crm/v2/object/unlock";
+ public static final String LOCK_CRM_URL = "https://open.fxiaoke.com/cgi/crm/v2/object/lock";
+ public static final String UPDATE_CRM_CUSTOMIZE = "https://open.fxiaoke.com/cgi/crm/custom/v2/data/update";
+ public static final String UPLOAD_FILE_URL = "https://open.fxiaoke.com/media/upload";
+ public static final String UPLOAD_ANNEX_URL = "https://open.fxiaoke.com/cgi/crm/custom/v2/data/update";
+}
diff --git a/src/main/java/com/management/controller/BankInfoController.java b/src/main/java/com/management/controller/BankInfoController.java
new file mode 100644
index 0000000..00ae21a
--- /dev/null
+++ b/src/main/java/com/management/controller/BankInfoController.java
@@ -0,0 +1,439 @@
+package com.management.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.management.constant.ERPURLConstant;
+import com.management.constant.URLConstant;
+import com.management.entity.Filter;
+import com.management.utils.CrmRequestUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+@RestController
+@RequestMapping("/api/bank")
+@Slf4j
+public class BankInfoController {
+
+ private RestTemplate restTemplate = new RestTemplate();
+
+ public static void main(String[] args) {
+ new BankInfoController().updateBankInfo();
+ }
+
+ /**
+ * 银行信息同步接口
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/sync/bankInfo")
+ public void syncBankInfo() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+
+ log.info("开始同步银行信息");
+
+ //获取当前时间
+ LocalDateTime now = LocalDateTime.now();
+ log.info("当前时间:{}", now);
+ //获取两天前的时间
+ LocalDateTime twoDaysAgo = now.minusDays(1);
+
+ //将时间转换样式
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ String twoDaysAgoStr = twoDaysAgo.format(formatter);
+ String nowStr = now.format(formatter);
+
+ //开始查询部门(暂时使用固定值)
+ Map data = new HashMap<>();
+ data.put("startTime", twoDaysAgoStr);
+ data.put("endTime", nowStr);
+ //data.put("number", Arrays.asList("ZHY002.005.003.004"));
+// data.put("level", "3");
+
+ Map deptReq = new HashMap<>();
+ deptReq.put("data", data);
+ deptReq.put("pageNo", 1);
+ deptReq.put("pageSize", 1999);
+
+ //开始获取金蝶token
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+
+ HttpEntity bankReqEntity = new HttpEntity(deptReq, headers);
+
+ //开始发起请求
+ String bankInfoUrl = ERPURLConstant.ERP_URL +"/ierp/kapi/v2/f9w5/basedata/bd_bebank/bebankQuery";
+
+ String bankInfoResStr = "";
+
+ //开始发起请求
+ try {
+ bankInfoResStr = restTemplate.postForObject(bankInfoUrl, bankReqEntity, String.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ JSONObject bankInfoRes = JSONObject.parseObject(bankInfoResStr);
+
+ System.out.println("获取到金蝶银行信息");
+
+ if (!"0".equals(bankInfoRes.getString("errorCode")) || bankInfoRes.getJSONObject("data").isEmpty() || bankInfoRes.getJSONObject("data").getJSONArray("rows").isEmpty()) {
+ log.info("金蝶查询银行信息失败或者没有符合条件的数据");
+ return;
+ }
+
+ log.info("数据存在,将继续向下执行");
+
+ for (Object bankInfoObj : bankInfoRes.getJSONObject("data").getJSONArray("rows")) {
+ JSONObject bankInfoData = JSON.parseObject(JSON.toJSONString(bankInfoObj));
+
+ //开始截取关键数据
+ //银行名称
+ String bankName = bankInfoData.getString("name");
+ //行号
+ String bankNumber = bankInfoData.getString("number");
+ //todo 创建时间
+ String createTime = "2025-05-14 00:00:00";
+
+ //开始查询是否已经集成过了
+ JSONObject isLog = new JSONObject();
+
+ try {
+ isLog = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_bank&log_type=BANK&dataId=" + bankNumber + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!isLog.getJSONArray("data").isEmpty()) {
+ log.info("当前银行已经集成过了,将不再向下执行");
+ continue;
+ }
+
+ //开始封装数据
+ Map bankInfoMap = new HashMap<>();
+ bankInfoMap.put("name", bankNumber);//行号
+ bankInfoMap.put("bank_name__c", bankName);//银行名称
+ bankInfoMap.put("province__c", bankInfoData.getString("province_name") != null ? bankInfoData.getString("province_name") : "");//省份
+ bankInfoMap.put("city_banking__c", bankInfoData.getString("city_name") != null ? bankInfoData.getString("city_name") : "");//市
+ bankInfoMap.put("country_region__c", bankInfoData.getString("country_fullname") != null ? bankInfoData.getString("country_fullname") : "");//国家地区
+ bankInfoMap.put("branch_number__c", bankInfoData.getString("union_number") != null ? bankInfoData.getString("union_number") : "");//联行号
+ bankInfoMap.put("dataObjectApiName", "bank_info__c");
+
+ //发起请求前查询是否已存在该数据
+ JSONObject isCrmExist = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "name", Arrays.asList(bankNumber)),
+ new Filter("EQ", "bank_name__c", Arrays.asList(bankName))
+ ), "bank_info__c");
+
+ JSONObject isCrmExistRes = new JSONObject();
+
+ try {
+ isCrmExistRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, isCrmExist, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(isCrmExistRes.getString("errorDescription")) && !isCrmExistRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("数据已存在,将执行更新");
+ JSONObject isCrmExistData = isCrmExistRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ bankInfoMap.put("_id", isCrmExistData.getString("_id"));
+
+ //更新请求
+ JSONObject updateReq = crmRequestUtil.updateCRM(bankInfoMap);
+
+ JSONObject updateRes = new JSONObject();
+
+ try {
+ updateRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, updateReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("更新结果为:" + JSON.parseObject(JSON.toJSONString(updateRes)));
+
+ //记录日志
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "BANKUP");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", bankName);
+ logMap.put("data_id", bankNumber);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(updateReq));
+ logMap.put("send_res", JSON.toJSONString(updateRes));
+ logMap.put("tableName", "send_log_bank");
+
+ //判断
+ if ("success".equals(updateRes.getString("errorDescription"))) {
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ } else {
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败" + updateRes.getString("errorMessage"));
+ }
+
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ continue;
+ }
+
+ log.info("数据不存在,将执行创建");
+
+ JSONObject createReq = crmRequestUtil.createCRM(bankInfoMap);
+
+ JSONObject createRes = new JSONObject();
+
+ try {
+ createRes = restTemplate.postForObject(URLConstant.CREATE_CRM_CUSTOMER_MAIN, createReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("创建结果为:" + JSON.parseObject(JSON.toJSONString(createRes)));
+
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "BANK");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", bankName);
+ logMap.put("data_id", bankNumber);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(createReq));
+ logMap.put("send_res", JSON.toJSONString(createRes));
+ logMap.put("tableName", "send_log_bank");
+
+ //判断
+ if ("success".equals(createRes.getString("errorDescription"))) {
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ } else {
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败" + createRes.getString("errorMessage"));
+ }
+
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println(logRes);
+
+ }
+
+ }
+
+ /**
+ * 银行信息更新方法
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/update/bankInfo")
+ public void updateBankInfo() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+
+ log.info("开始同步银行信息");
+
+ //获取当前时间
+ LocalDateTime now = LocalDateTime.now();
+ log.info("当前时间:{}", now);
+ //获取两天前的时间
+ LocalDateTime twoDaysAgo = now.minusDays(2);
+
+ //将时间转换样式
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ String twoDaysAgoStr = twoDaysAgo.format(formatter);
+ String nowStr = now.format(formatter);
+
+ //开始查询部门(暂时使用固定值)
+ Map data = new HashMap<>();
+ data.put("startTime", twoDaysAgoStr);
+ data.put("endTime", nowStr);
+ //data.put("number", Arrays.asList("ZHY002.005.003.004"));
+// data.put("level", "3");
+
+ Map deptReq = new HashMap<>();
+ deptReq.put("data", data);
+ deptReq.put("pageNo", 1);
+ deptReq.put("pageSize", 1999);
+
+ //开始获取金蝶token
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+
+ HttpEntity bankReqEntity = new HttpEntity(deptReq, headers);
+
+ //开始发起请求
+ String bankInfoUrl = ERPURLConstant.ERP_URL+"/ierp/kapi/v2/f9w5/basedata/bd_bebank/bebankQuery";
+
+ String bankInfoResStr = "";
+
+ //开始发起请求
+ try {
+ bankInfoResStr = restTemplate.postForObject(bankInfoUrl, bankReqEntity, String.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ JSONObject bankInfoRes = JSONObject.parseObject(bankInfoResStr);
+
+ System.out.println("金蝶银行信息结果为:" + bankInfoRes);
+
+ if (!"0".equals(bankInfoRes.getString("errorCode")) || bankInfoRes.getJSONObject("data").isEmpty() || bankInfoRes.getJSONObject("data").getJSONArray("rows").isEmpty()) {
+ log.info("金蝶查询银行信息失败或者没有符合条件的数据");
+ return;
+ }
+
+ log.info("数据存在,将继续向下执行");
+
+ for (Object bankInfoObj : bankInfoRes.getJSONObject("data").getJSONArray("rows")) {
+ JSONObject bankInfoData = JSON.parseObject(JSON.toJSONString(bankInfoObj));
+
+ System.out.println("当前正在处理的银行信息数据为:" + bankInfoData);
+
+ //开始截取关键数据
+ //银行名称
+ String bankName = bankInfoData.getString("name");
+ //行号
+ String bankNumber = bankInfoData.getString("number");
+ //todo 最新更新时间
+ String modifyTime = "2025-05-14 00:00:00";
+
+ //开始查询是否已经集成过了
+ JSONObject isLog = new JSONObject();
+
+ try {
+ isLog = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_bank&log_type=BANKUP&dataId=" + bankNumber + "&mark=" + modifyTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!isLog.getJSONArray("data").isEmpty()) {
+ log.info("当前银行已经集成过了,将不再向下执行");
+ continue;
+ }
+
+ //开始封装数据
+ Map bankInfoMap = new HashMap<>();
+ bankInfoMap.put("name", bankNumber);//行号
+ bankInfoMap.put("bank_name__c", bankName);//银行名称
+ bankInfoMap.put("province__c", bankInfoData.getString("province_name") != null ? bankInfoData.getString("province_name") : "");//省份
+ bankInfoMap.put("city_banking__c", bankInfoData.getString("city_name") != null ? bankInfoData.getString("city_name") : "");//市
+ bankInfoMap.put("country_region__c", bankInfoData.getString("country_fullname") != null ? bankInfoData.getString("country_fullname") : "");//国家地区
+ bankInfoMap.put("branch_number__c", bankInfoData.getString("union_number") != null ? bankInfoData.getString("union_number") : "");//联行号
+ bankInfoMap.put("dataObjectApiName", "bank_info__c");
+
+ //发起请求前查询是否已存在该数据
+ JSONObject isCrmExist = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "name", Arrays.asList(bankNumber)),
+ new Filter("EQ", "bank_name__c", Arrays.asList(bankName))
+ ), "bank_info__c");
+
+ JSONObject isCrmExistRes = new JSONObject();
+
+ try {
+ isCrmExistRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, isCrmExist, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(isCrmExistRes.getString("errorDescription")) || isCrmExistRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("数据不存在或者查询失败,将不再继续向下执行");
+ continue;
+ }
+
+ JSONObject isCrmExistData = isCrmExistRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ bankInfoMap.put("_id", isCrmExistData.getString("_id"));
+
+ //更新请求
+ JSONObject updateReq = crmRequestUtil.updateCRM(bankInfoMap);
+
+ JSONObject updateRes = new JSONObject();
+
+ try {
+ updateRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, updateReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("更新结果为:" + JSON.parseObject(JSON.toJSONString(updateRes)));
+
+ //记录日志
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "BANKUP");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", bankName);
+ logMap.put("data_id", bankNumber);
+ logMap.put("mark", modifyTime);
+ logMap.put("send_body", JSON.toJSONString(updateReq));
+ logMap.put("send_res", JSON.toJSONString(updateRes));
+ logMap.put("tableName", "send_log_bank");
+
+ //判断
+ if ("success".equals(updateRes.getString("errorDescription"))) {
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ } else {
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败" + updateRes.getString("errorMessage"));
+ }
+
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("日志记录结果为:" + logRes);
+
+ }
+ }
+}
diff --git a/src/main/java/com/management/controller/CRMTokenController.java b/src/main/java/com/management/controller/CRMTokenController.java
new file mode 100644
index 0000000..0a65982
--- /dev/null
+++ b/src/main/java/com/management/controller/CRMTokenController.java
@@ -0,0 +1,53 @@
+package com.management.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.management.constant.CertificateConstant;
+import com.management.constant.URLConstant;
+import com.management.utils.CaffeineCacheUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/crm")
+@Slf4j
+public class CRMTokenController {
+
+ private RestTemplate restTemplate = new RestTemplate();
+
+ @PostMapping("/getToken")
+ public void getCRMToken() {
+ //封装请求
+ Map tokenParams = new HashMap<>();
+ tokenParams.put("appId", CertificateConstant.APP_ID);
+ tokenParams.put("appSecret", CertificateConstant.APP_SECRET);
+ tokenParams.put("permanentCode", CertificateConstant.PERMANENT_CODE);
+
+ JSONObject tokenResponse = new JSONObject();
+
+ try {
+ tokenResponse = restTemplate.postForObject(URLConstant.GET_CORPACCESSTOKEN_URL, tokenParams, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //判断是否成功
+ if ("success".equals(tokenResponse.getString("errorMessage"))) {
+ String corpAccessToken = tokenResponse.getString("corpAccessToken");
+
+ //移除
+ CaffeineCacheUtil.remove("corpAccessToken");
+
+ //存入新的
+ CaffeineCacheUtil.put("corpAccessToken", corpAccessToken);
+ } else {
+ log.info("获取纷享销客token失败{}", tokenResponse);
+ }
+ }
+}
diff --git a/src/main/java/com/management/controller/DeptController.java b/src/main/java/com/management/controller/DeptController.java
new file mode 100644
index 0000000..11f564a
--- /dev/null
+++ b/src/main/java/com/management/controller/DeptController.java
@@ -0,0 +1,698 @@
+package com.management.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.management.constant.CertificateConstant;
+import com.management.constant.URLConstant;
+import com.management.entity.Filter;
+import com.management.utils.CrmRequestUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * 部门集成
+ *
+ * @param
+ * @return null
+ * @Author weiloong_zhang
+ */
+@RestController
+@RequestMapping("/zy/api/dept")
+@Slf4j
+public class DeptController {
+
+ @Autowired
+ private KDTokenController kdTokenController;
+
+ private RestTemplate restTemplate = new RestTemplate();
+
+ public static void main(String[] args) {
+ // new DeptController().syncDept();
+ new DeptController().syncDeptUp();
+ }
+
+ /**
+ * 部门同步,新增接口
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/sync_create")
+ public void syncDept() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+ //获取当前时间
+ LocalDateTime now = LocalDateTime.now();
+ log.info("当前时间:{}", now);
+ //获取两天前的时间
+ LocalDateTime twoDaysAgo = now.minusDays(2);
+
+ //将时间转换样式
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ String twoDaysAgoStr = twoDaysAgo.format(formatter);
+
+ //开始查询部门(暂时使用固定值)
+ Map data = new HashMap<>();
+ data.put("createtime", "2025-06-01 00:00:00");
+ data.put("enable", "1");
+ // data.put("number", Arrays.asList("ZHY002.005.003.004"));
+// data.put("level", "3");
+
+ Map deptReq = new HashMap<>();
+ deptReq.put("data", data);
+ deptReq.put("pageNo", 1);
+ deptReq.put("pageSize", 1999);
+
+ String accessToken = new KDTokenController().getKDAccessToken();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity deptReqEntity = new HttpEntity(deptReq, headers);
+
+ //开始发起请求
+ //请求地址
+ String deptUrl = "https://lxr2.zhydsp.cn:40448/ierp/kapi/v2/f9w5/base/bos_adminorg/adminOrgQuery";
+ String deptRes = "";
+
+ try {
+ deptRes = restTemplate.postForObject(deptUrl, deptReqEntity, String.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //将请求到的数据转换为JSONObject
+ JSONObject deptResObj = JSON.parseObject(deptRes);
+
+ //开始执行判断
+ if (deptResObj.getBooleanValue("status") != true || deptResObj.getJSONObject("data").isEmpty() || deptResObj.getJSONObject("data").getJSONArray("rows").isEmpty()) {
+ log.info("金蝶部门数据请求失败或者为空");
+ return;
+ }
+
+ //数据不为空,开始遍历数据
+ JSONArray deptRows = deptResObj.getJSONObject("data").getJSONArray("rows");
+
+ for (Object deptObj : deptRows) {
+ JSONObject deptData = JSON.parseObject(JSON.toJSONString(deptObj));
+
+ log.info("当前正在操作的数据为:{}", deptData);
+
+ //获取部门数据
+ //部门id
+ String deptId = deptData.getString("id");
+
+ //获取最后更新时间
+ String createTime = deptData.getString("createtime");
+
+ //查询日志
+ JSONObject getLog = new JSONObject();
+
+ try {
+ getLog = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_bmxx&log_type=DEPT&dataId=" + deptId + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(getLog.getString("message")) && !getLog.getJSONArray("data").isEmpty()) {
+ log.info("当前部门已经新建过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("没有集成过,将继续向下执行");
+
+ //部门名称
+ String deptName = deptData.getString("name");
+
+ if (deptName.contains("、")) {
+ deptName = deptName.replace("、", "_");
+ }
+ //父部门编码
+ JSONObject structureObj = deptData.getJSONArray("structure").getJSONObject(0);
+ String parentDeptCode = structureObj.getString("viewparent_id");
+ String parentDeptName = structureObj.getString("viewparent_name");
+ //部门编码
+ String deptCode = deptData.getString("number");
+
+ //开始封装数据
+ Map deptSyncReq = new HashMap<>();
+ deptSyncReq.put("name", deptName);
+ deptSyncReq.put("erp_id__c", deptId);
+ deptSyncReq.put("field_Vj6sf__c", deptCode);
+ deptSyncReq.put("field_v711K__c", parentDeptName);
+ deptSyncReq.put("field_31u4r__c", parentDeptCode);
+ deptSyncReq.put("owner", Arrays.asList("FSUID_50D3C26809B163F663DC8557268A8D44"));
+ deptSyncReq.put("dataObjectApiName", "DepartmentObj");
+
+ //查找父编码
+ //根据金蝶部门父编码查询crm部门父编码
+ JSONObject parentDeptReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "erp_id__c", Arrays.asList(parentDeptCode))
+ ), "DepartmentObj");
+
+ JSONObject parentDeptRes = new JSONObject();
+
+ try {
+ parentDeptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, parentDeptReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println(parentDeptRes);
+
+ if (!"success".equals(parentDeptRes.getString("errorDescription"))) {
+ log.info("查询失败");
+ continue;
+ }
+
+ if (parentDeptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("父编码为空,将不再向下执行");
+ continue;
+ }
+
+ //获取父部门和父编码
+ JSONObject parentDeptData = parentDeptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ String parentDeptId = parentDeptData.getString("_id");
+
+ deptSyncReq.put("parent_id", Arrays.asList(parentDeptId));
+ //判断部门是否在crm中存在
+ //请求封装
+ JSONObject deptIsExistReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "name", Arrays.asList(deptName)),
+ new Filter("EQ", "field_v711K__c", Arrays.asList(parentDeptName)),
+ new Filter("EQ", "field_31u4r__c", Arrays.asList(parentDeptCode))
+ ), "DepartmentObj");
+
+ //开始发起请求
+ JSONObject deptIsExistRes = new JSONObject();
+
+ try {
+ deptIsExistRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptIsExistReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(deptIsExistRes.getString("errorDescription")) && !deptIsExistRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ //部门已经存在,将直接进行数据更新
+ log.info("部门已经存在,将直接进行数据更新");
+ String dept_id = deptIsExistRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("_id");
+
+ deptSyncReq.put("_id", dept_id);
+
+ //开始执行更新
+ JSONObject deptUpReq = crmRequestUtil.updateCRM(deptSyncReq);
+ JSONObject deptUpRes = new JSONObject();
+
+ try {
+ deptUpRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_MAIN, deptUpReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ log.info("部门更新状态为:{}", deptUpRes);
+ continue;
+ }
+
+ //crm中不存在该部门,继续进行新增
+ //开始执行新建
+ JSONObject deptCreateReq = crmRequestUtil.createCRM(deptSyncReq);
+
+ JSONObject deptCreateRes = new JSONObject();
+
+ try {
+ deptCreateRes = restTemplate.postForObject(URLConstant.CREATE_CRM_MAIN, deptCreateReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ log.info("部门创建状态为:{}", deptCreateRes);
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "DEPT");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", deptName);
+ logMap.put("data_id", deptId);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(deptCreateReq));
+ logMap.put("send_res", JSON.toJSONString(deptCreateRes));
+ logMap.put("tableName", "send_log_bmxx");
+
+ //判断
+ if ("success".equals(deptCreateRes.getString("errorDescription"))) {
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ } else {
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败" + deptCreateRes.getString("errorMessage"));
+ }
+
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ log.info("日志上传状态为:{}", logRes);
+
+ }
+
+ }
+
+
+ /**
+ * 部门更新接口
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/sync_up")
+ public void syncDeptUp() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+ //获取当前时间
+ LocalDateTime now = LocalDateTime.now();
+ log.info("当前时间:{}", now);
+ //获取两天前的时间
+ LocalDateTime twoDaysAgo = now.minusDays(2);
+
+ //将时间转换样式
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ String twoDaysAgoStr = twoDaysAgo.format(formatter);
+
+ //开始查询部门(暂时使用固定值)
+ Map data = new HashMap<>();
+ data.put("modifytime", "2025-06-01 00:00:00");
+ data.put("enable", "1");
+ // data.put("number", Arrays.asList("ZHY002.005.001.006"));
+// data.put("level", "3");
+
+ Map deptReq = new HashMap<>();
+ deptReq.put("data", data);
+ deptReq.put("pageNo", 1);
+ deptReq.put("pageSize", 1000);
+
+ String accessToken = new KDTokenController().getKDAccessToken();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+
+ HttpEntity deptReqEntity = new HttpEntity(deptReq, headers);
+
+ //开始发起请求
+ //请求地址
+ String deptUrl = "https://lxr2.zhydsp.cn:40448/ierp/kapi/v2/f9w5/base/bos_adminorg/adminOrgQuery";
+ String deptRes = "";
+
+ try {
+ deptRes = restTemplate.postForObject(deptUrl, deptReqEntity, String.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //将请求到的数据转换为JSONObject
+ JSONObject deptResObj = JSON.parseObject(deptRes);
+ System.out.println("请求结果为:" + deptRes);
+
+ //开始执行判断
+ if (deptResObj.getBooleanValue("status") != true || deptResObj.getJSONObject("data").isEmpty() || deptResObj.getJSONObject("data").getJSONArray("rows").isEmpty()) {
+ log.info("金蝶部门数据请求失败或者为空");
+ return;
+ }
+
+ //数据不为空,开始遍历数据
+ JSONArray deptRows = deptResObj.getJSONObject("data").getJSONArray("rows");
+
+ for (Object deptObj : deptRows) {
+ JSONObject deptData = JSON.parseObject(JSON.toJSONString(deptObj));
+
+ log.info("当前正在操作的数据为:{}", deptData);
+
+ //获取部门数据
+ //部门id
+ String deptId = deptData.getString("id");
+
+ //获取最后更新时间
+ String modifyTime = deptData.getString("modifytime");
+
+ //查询日志
+ JSONObject getLog = new JSONObject();
+
+ try {
+ getLog = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_bmxx&log_type=DEPTUP&dataId=" + deptId + "&mark=" + modifyTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(getLog.getString("message")) && !getLog.getJSONArray("data").isEmpty()) {
+ log.info("当前部门已经更新过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("没有集成过,将继续向下执行");
+
+ //部门名称
+ String deptName = deptData.getString("name");
+
+ if (deptName.contains("、")) {
+ deptName = deptName.replace("、", "_");
+ }
+ //父部门编码
+ JSONObject structureObj = deptData.getJSONArray("structure").getJSONObject(0);
+ String parentDeptCode = structureObj.getString("viewparent_id");
+ String parentDeptName = structureObj.getString("viewparent_name");
+ //部门编码
+ String deptCode = deptData.getString("number");
+
+ //开始封装数据
+ Map deptSyncReq = new HashMap<>();
+ deptSyncReq.put("name", deptName);
+ deptSyncReq.put("erp_id__c", deptId);
+ deptSyncReq.put("field_Vj6sf__c", deptCode);
+ deptSyncReq.put("field_v711K__c", parentDeptName);
+ deptSyncReq.put("field_31u4r__c", parentDeptCode);
+ deptSyncReq.put("owner", Arrays.asList("FSUID_50D3C26809B163F663DC8557268A8D44"));
+ deptSyncReq.put("dataObjectApiName", "DepartmentObj");
+
+ //查找父编码
+ //根据金蝶部门父编码查询crm部门父编码
+ JSONObject parentDeptReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "erp_id__c", Arrays.asList(parentDeptCode))
+ ), "DepartmentObj");
+
+ JSONObject parentDeptRes = new JSONObject();
+
+ try {
+ parentDeptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, parentDeptReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(parentDeptRes.getString("errorDescription")) || parentDeptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("父编码为空,将不再向下执行");
+ continue;
+ }
+
+ //获取父部门和父编码
+ JSONObject parentDeptData = parentDeptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ String parentDeptId = parentDeptData.getString("_id");
+
+ deptSyncReq.put("parent_id", Arrays.asList(parentDeptId));
+
+ //判断部门是否在crm中存在
+ //请求封装
+ JSONObject deptIsExistReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "name", Arrays.asList(deptName)),
+ new Filter("EQ", "field_v711K__c", Arrays.asList(parentDeptName)),
+ new Filter("EQ", "field_31u4r__c", Arrays.asList(parentDeptCode))
+ ), "DepartmentObj");
+
+ //开始发起请求
+ JSONObject deptIsExistRes = new JSONObject();
+
+ try {
+ deptIsExistRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptIsExistReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(deptIsExistRes.getString("errorDescription")) && deptIsExistRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ //数据不存在,将不再向下执行
+ log.info("部门不存在,将不再向下执行");
+ continue;
+ }
+
+ //数据存在,将继续向下执行更新
+ //部门已经存在,将直接进行数据更新
+ log.info("部门已经存在,将直接进行数据更新");
+ String dept_id = deptIsExistRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("_id");
+
+ deptSyncReq.put("_id", dept_id);
+
+ //开始执行更新
+ JSONObject deptUpReq = crmRequestUtil.updateCRM(deptSyncReq);
+ JSONObject deptUpRes = new JSONObject();
+
+ try {
+ deptUpRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_MAIN, deptUpReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "DEPTUP");
+ logMap.put("syn_type", "1");
+ logMap.put("data_name", deptName);
+ logMap.put("data_id", deptId);
+ logMap.put("mark", modifyTime);
+ logMap.put("send_body", JSON.toJSONString(deptUpReq));
+ logMap.put("send_res", JSON.toJSONString(deptUpRes));
+ logMap.put("tableName", "send_log_bmxx");
+
+ //判断
+ if ("success".equals(deptUpRes.getString("errorDescription"))) {
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ } else {
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败");
+ }
+
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ log.info("日志上传状态为:{}", logRes);
+
+ }
+ }
+
+ /**
+ * 部门删除同步
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/sync_delete")
+ public void syncDeptDel() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+ //获取当前时间
+ LocalDateTime now = LocalDateTime.now();
+ log.info("当前时间:{}", now);
+ //获取两天前的时间
+ LocalDateTime twoDaysAgo = now.minusDays(2);
+
+ //将时间转换样式
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ String twoDaysAgoStr = twoDaysAgo.format(formatter);
+
+ //开始查询部门(暂时使用固定值)
+ Map data = new HashMap<>();
+ data.put("modifytime", "2020-01-01 00:00:00");
+ data.put("enable", "2");
+ //data.put("number", Arrays.asList("ZHY003.002"));
+// data.put("level", "3");
+
+ Map deptReq = new HashMap<>();
+ deptReq.put("data", data);
+ deptReq.put("pageNo", 1);
+ deptReq.put("pageSize", 1000);
+
+ String accessToken = kdTokenController.getKDAccessToken();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+
+ HttpEntity deptReqEntity = new HttpEntity(deptReq, headers);
+
+ //开始发起请求
+ //请求地址
+ String deptUrl = "https://lxr2.zhydsp.cn:40448/ierp/kapi/v2/f9w5/base/bos_adminorg/adminOrgQuery";
+ String deptRes = "";
+
+ try {
+ deptRes = restTemplate.postForObject(deptUrl, deptReqEntity, String.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //将请求到的数据转换为JSONObject
+ JSONObject deptResObj = JSON.parseObject(deptRes);
+ System.out.println("请求结果为:" + deptRes);
+
+ //开始执行判断
+ if (deptResObj.getBooleanValue("status") != true || deptResObj.getJSONObject("data").isEmpty() || deptResObj.getJSONObject("data").getJSONArray("rows").isEmpty()) {
+ log.info("金蝶部门数据请求失败或者为空");
+ return;
+ }
+
+ //数据不为空,开始遍历数据
+ JSONArray deptRows = deptResObj.getJSONObject("data").getJSONArray("rows");
+
+ for (Object deptObj : deptRows) {
+ JSONObject deptData = JSON.parseObject(JSON.toJSONString(deptObj));
+
+ log.info("当前正在操作的数据为:{}", deptData);
+
+ //获取部门数据
+ //部门id
+ String deptId = deptData.getString("id");
+
+ //获取最后更新时间
+ String modifyTime = deptData.getString("modifytime");
+
+ //查询日志
+ JSONObject getLog = new JSONObject();
+
+ try {
+ getLog = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_bmxx&log_type=DEPTDEL&dataId=" + deptId + "&mark=" + modifyTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(getLog.getString("message")) && !getLog.getJSONArray("data").isEmpty()) {
+ log.info("当前部门已经执行过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("没有集成过,将继续向下执行");
+
+ //部门名称
+ String deptName = deptData.getString("name");
+ //父部门编码
+ JSONObject structureObj = deptData.getJSONArray("structure").getJSONObject(0);
+ //父级全称
+ String parentDeptName = structureObj.getString("viewparent_name");
+ String parentDeptCode = structureObj.getString("viewparent_id");
+
+ //开始查询CRM
+ JSONObject crmReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "name", Arrays.asList(deptName)),
+ new Filter("EQ", "field_v711K__c", Arrays.asList(parentDeptName)),
+ new Filter("EQ", "field_31u4r__c", Arrays.asList(parentDeptCode))
+ ), "DepartmentObj");
+
+ JSONObject crmRes = new JSONObject();
+
+ try {
+ crmRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, crmReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(crmRes.getString("errorDescription"))) {
+ log.info("请求失败");
+ continue;
+ }
+
+ if (crmRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("未查询到数据");
+ continue;
+ }
+
+ //数据存在,执行作废
+
+ JSONObject crmData = crmRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ String crmId = crmData.getString("_id");
+
+ //开始封装作废数据
+
+ Map delData = new HashMap<>();
+ delData.put("object_data_id", crmId);
+ delData.put("dataObjectApiName", "DepartmentObj");
+
+ Map delReq = new HashMap<>();
+ delReq.put("corpAccessToken", crmRequestUtil.getCRMToken());
+ delReq.put("currentOpenUserId", CertificateConstant.CURRENT_OPEN_USERID);
+ delReq.put("corpId", CertificateConstant.CORP_ID);
+ delReq.put("data", delData);
+
+ //开始请求作废接口
+ JSONObject delRes = new JSONObject();
+
+ try {
+ delRes = restTemplate.postForObject("https://open.fxiaoke.com/cgi/crm/custom/v2/data/invalid", delReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "DEPTDEL");
+ logMap.put("syn_type", "2");
+ logMap.put("data_name", deptName);
+ logMap.put("data_id", deptId);
+ logMap.put("mark", modifyTime);
+ logMap.put("send_body", JSON.toJSONString(delReq));
+ logMap.put("send_res", JSON.toJSONString(delRes));
+ logMap.put("tableName", "send_log_bmxx");
+
+ //判断
+ if ("success".equals(delRes.getString("errorDescription"))) {
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ } else {
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败" + delRes.getString("errorMessage"));
+ }
+
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ log.info("日志上传状态为:{}", logRes);
+
+ }
+ }
+}
diff --git a/src/main/java/com/management/controller/DesignController.java b/src/main/java/com/management/controller/DesignController.java
new file mode 100644
index 0000000..044edc6
--- /dev/null
+++ b/src/main/java/com/management/controller/DesignController.java
@@ -0,0 +1,652 @@
+package com.management.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.management.constant.ERPURLConstant;
+import com.management.constant.URLConstant;
+import com.management.entity.Filter;
+import com.management.utils.CrmRequestUtil;
+import com.management.utils.KingDeeUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.*;
+
+/**
+ * 设计文件
+ *
+ * @param
+ * @return null
+ * @Author weiloong_zhang
+ */
+@RestController
+@RequestMapping("/api/design")
+@Slf4j
+public class DesignController {
+
+ private RestTemplate restTemplate = new RestTemplate();
+
+ public static void main(String[] args) {
+ new DesignController().syncDesign();
+ }
+
+ /**
+ * 设计文件同步
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/sync/designDoc")
+ public void syncDesign() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+ log.info("开始同步设计文件");
+
+ String[] syncStatus = {"option_pending_sync__c", "option_resync__c"};
+
+ JSONObject getDesignDoc = crmRequestUtil.getCRMList(Arrays.asList(
+ //new Filter("IS", "erp_id__c", Arrays.asList("")),
+ new Filter("IN", "sync_status__c", Arrays.asList(syncStatus)),
+ //new Filter("EQ", "name", Arrays.asList("SJWJ250528-0022")),
+ new Filter("GT", "create_time", Arrays.asList("1748923200000")),
+ new Filter("EQ", "life_status", Arrays.asList("normal"))
+ ), "design_file__c");
+
+ JSONObject designDocRes = new JSONObject();
+
+ try {
+ designDocRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getDesignDoc, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(designDocRes.getString("errorDescription")) || designDocRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("查询失败或者不存在符合条件的数据");
+ return;
+ }
+
+ log.info("查询成功,继续向下执行");
+
+ for (Object designDocObj : designDocRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject designDocData = JSON.parseObject(JSON.toJSONString(designDocObj));
+
+ System.out.println("当前正在处理的设计文件数据为:" + designDocData);
+
+ //当前设计文件的唯一id
+ String designDocId = designDocData.getString("_id");
+
+ //当前单据的编号
+ String designDocName = designDocData.getString("name");
+
+ //当前单据的创建时间
+ //String createTime = designDocData.getString("create_time");
+ String createTime = designDocData.getString("last_modified_time");
+
+ //开始查询该单据是否已经集成过
+ JSONObject isLog = new JSONObject();
+
+ try {
+ isLog = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_sjwj&log_type=DF&dataId=" + designDocId + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //判断是否已经执行过
+ if (!isLog.getJSONArray("data").isEmpty()) {
+ log.info("当前单据已经集成过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("当前单据没有集成过,将开始向下执行");
+
+ //开始封装传输至ERP中的请求
+ Map erpDesignMap = new HashMap<>();
+ erpDesignMap.put("billno", designDocName);//设计文件编号
+
+ //判断组织编码
+ String orgCode = "";
+ if (designDocData.getString("erp_organization_sales_con__c__v") != null && !"".equals(designDocData.getString("erp_organization_sales_con__c__v"))) {
+ orgCode = designDocData.getString("erp_organization_sales_con__c__v");
+ } else if (designDocData.getString("erp_organization_pre_contr__c__v") != null && !"".equals(designDocData.getString("erp_organization_pre_contr__c__v"))) {
+ orgCode = designDocData.getString("erp_organization_pre_contr__c__v");
+ } else {
+ log.info("当前单据没有组织编码,将不再向下执行");
+ continue;
+ }
+
+ erpDesignMap.put("org_number", orgCode);//组织编码
+ erpDesignMap.put("billtype_number", "pm_requirapplybill_BT_sjwjxf");//单据类型
+ erpDesignMap.put("biztype_name", "物料类采购");//业务类型
+
+ //开始获取单据日期
+ long bizTime = designDocData.getLong("document_date__c");
+ Date date = new Date(bizTime);
+
+ erpDesignMap.put("biztime", date);//单据日期
+
+ //部门编码
+ String deptCode = "";
+
+ List deptIdList = designDocData.getJSONArray("data_own_department");
+
+ //开始查询部门编码
+ JSONObject deptReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", deptIdList)
+ ), "DepartmentObj");
+
+ JSONObject deptRes = new JSONObject();
+
+ try {
+ deptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(deptRes.getString("errorDescription")) && !deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject deptData = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ deptCode = deptData.getString("field_Vj6sf__c") != null ? deptData.getString("field_Vj6sf__c") : "";
+ }
+
+ //erpDesignMap.put("dept_number", "004");//部门编码
+ erpDesignMap.put("dept_number", deptCode);//部门编码
+
+ //获取负责人编码
+ String ownerCode = "";
+
+ List ownerIdList = designDocData.getJSONArray("owner");
+
+ System.out.println(ownerIdList);
+
+ JSONObject ownerReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "user_id", ownerIdList)
+ ), "PersonnelObj");
+
+ JSONObject ownerRes = new JSONObject();
+
+ try {
+ ownerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, ownerReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("查询负责人结果为:" + ownerRes);
+
+ if ("success".equals(ownerRes.getString("errorDescription")) && !ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ ownerCode = ownerData.getString("field_T1xid__c") != null ? ownerData.getString("field_T1xid__c") : "";
+ }
+
+ //erpDesignMap.put("bizuser_number", "ID-000011");//人员编码
+ erpDesignMap.put("bizuser_number", ownerCode);//人员编码
+ erpDesignMap.put("bizorg_number", orgCode);//采购组织
+ erpDesignMap.put("project_number", "SJ20250424-0033");//todo 项目号(商机)
+ erpDesignMap.put("contractno", designDocData.getString("sales_contract_number__c__r"));//合同号
+ erpDesignMap.put("crmid", designDocId);//crm唯一id
+ erpDesignMap.put("comment", designDocData.getString("remark__c") != null ? designDocData.getString("remark__c") : "");//备注
+
+
+ //开始获取设计文件明细
+ JSONObject getDesignDocDetail = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "design_file__c", Arrays.asList(designDocId))
+ ), "design_file_details__c");
+
+ JSONObject designDocDetailRes = new JSONObject();
+
+ try {
+ designDocDetailRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getDesignDocDetail, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(designDocDetailRes.getString("errorDescription")) || designDocDetailRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("查询失败或不存在当前设计文件明细");
+ continue;
+ }
+
+ List designDocList = new ArrayList<>();
+
+ for (Object designDocDetailObj : designDocDetailRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject designDocDetailData = JSON.parseObject(JSON.toJSONString(designDocDetailObj));
+
+ System.out.println("当前正在处理的设计文件明细数据为:" + designDocDetailData);
+
+ //开始封装设计文件明细
+ Map designDocDetailMap = new HashMap<>();
+ designDocDetailMap.put("materialmasterid_number", designDocDetailData.getString("material_name__c"));//设计文件明细
+ designDocDetailMap.put("qty", designDocDetailData.getBigDecimal("quantity__c") != null ? designDocDetailData.getBigDecimal("quantity__c") : 0);//数量
+ designDocDetailMap.put("materialtype", designDocDetailData.getString("customer_material_type__c"));//客指供应类型
+ designDocDetailMap.put("crmentryid", designDocDetailData.getString("_id"));//crm明细行id
+ designDocDetailMap.put("entrycomment", designDocDetailData.getString("remark__c") != null ? designDocDetailData.getString("remark__c") : "");//备注
+ designDocDetailMap.put("supplier_number", designDocDetailData.getString("supplier_code__c") != null ? designDocDetailData.getString("supplier_code__c") : "");//建议供应商
+
+ designDocList.add(designDocDetailMap);
+
+ }
+
+ erpDesignMap.put("billentry", designDocList);
+
+ Map erpContractData = new HashMap<>();
+ erpContractData.put("data", Arrays.asList(erpDesignMap));//请求体
+
+ System.out.println("erp请求为:" + JSON.parseObject(JSON.toJSONString(erpContractData)));
+
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity designDocReqEntity = new HttpEntity(erpContractData, headers);
+
+ System.out.println("请求为:" + JSON.parseObject(JSON.toJSONString(designDocReqEntity)));
+
+ //开始向金蝶发起请求
+ String designPlanUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/pssc/requirapplybillSave";
+
+ JSONObject erpDesignDocRes = new JSONObject();
+
+ try {
+ erpDesignDocRes = restTemplate.postForObject(designPlanUrl, designDocReqEntity, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("设计文件结果为:" + JSON.parseObject(JSON.toJSONString(erpDesignDocRes)));
+
+ //开始封装回写程序
+ Map backReqMap = new HashMap();
+ backReqMap.put("_id", designDocId);
+ backReqMap.put("dataObjectApiName", "design_file__c");
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "DF");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", designDocName);
+ logMap.put("data_id", designDocId);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(designDocReqEntity));
+ logMap.put("send_res", JSON.toJSONString(erpDesignDocRes));
+ logMap.put("tableName", "send_log_sjwj");
+
+ //判断是否执行成功
+ if ("0".equals(erpDesignDocRes.getString("errorCode"))) {
+ //同步成功
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ backReqMap.put("erp_id__c", erpDesignDocRes.getJSONObject("datas").getJSONArray("result").getJSONObject(0).getString("id"));
+ backReqMap.put("sync_status__c", "option_sync_success__c");
+ backReqMap.put("response_info__c", "同步成功");
+
+ //审核
+ KingDeeUtils kingDeeUtils = new KingDeeUtils();
+ kingDeeUtils.audit(erpDesignDocRes.getJSONObject("datas").getJSONArray("result").getJSONObject(0).getString("id"), "pm_requirapplybill");
+ } else {
+ //同步失败
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败:" + erpDesignDocRes.getString("message"));
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", erpDesignDocRes.getString("message"));
+ }
+
+ //开始回写
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ System.out.println("回写请求为:" + JSON.parseObject(JSON.toJSONString(backReq)));
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+
+ //开始记录日志
+ JSONObject logResMap = new JSONObject();
+ try {
+ logResMap = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("日志插入结果为:" + logResMap);
+
+ //判断一下设计文件的状态,没有成功就不传了
+ if (!"0".equals(erpDesignDocRes.getString("errorCode"))) {
+ continue;
+ }
+
+ //开始封装明细回写程序
+ for (Object resultObj : erpDesignDocRes.getJSONObject("datas").getJSONArray("result").getJSONObject(0).getJSONArray("entry")) {
+ JSONObject resultData = JSON.parseObject(JSON.toJSONString(resultObj));
+
+ String erpLineId = resultData.getString("entryid");
+ String crmLineId = resultData.getString("crmentryid");
+
+ //开始封装
+ Map backMap = new HashMap();
+ backMap.put("_id", crmLineId);
+ backMap.put("erp_line_id__c", erpLineId);
+ backMap.put("dataObjectApiName", "design_file_details__c");
+
+ JSONObject detailReq = crmRequestUtil.updateCRM(backMap);
+
+ JSONObject detailRes = new JSONObject();
+
+ try {
+ detailRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, detailReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("明细回写结果为:" + detailRes);
+ }
+
+ }
+ }
+
+
+ /**
+ * 设计文件更新接口
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/syncUp/designDoc")
+ public void upDesignDoc() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+ log.info("开始同步设计文件");
+
+ JSONObject getDesignDoc = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "name", Arrays.asList("SJWJ250509-0003"))
+ ), "design_file__c");
+
+ JSONObject designDocRes = new JSONObject();
+
+ try {
+ designDocRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getDesignDoc, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(designDocRes.getString("errorDescription")) || designDocRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("查询失败或者不存在符合条件的数据");
+ return;
+ }
+
+ log.info("查询成功,继续向下执行");
+
+ for (Object designDocObj : designDocRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject designDocData = JSON.parseObject(JSON.toJSONString(designDocObj));
+
+ System.out.println("当前正在处理的设计文件数据为:" + designDocData);
+
+ //当前设计文件的唯一id
+ String designDocId = designDocData.getString("_id");
+
+ //当前单据的编号
+ String designDocName = designDocData.getString("name");
+
+ //当前单据的创建时间
+ String createTime = designDocData.getString("create_time");
+
+ //开始查询该单据是否已经集成过
+ JSONObject isLog = new JSONObject();
+
+ try {
+ isLog = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_sjwj&log_type=DFUP&dataId=" + designDocId + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //判断是否已经执行过
+ if (!isLog.getJSONArray("data").isEmpty()) {
+ log.info("当前单据已经集成过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("当前单据没有集成过,将开始向下执行");
+
+ //开始封装传输至ERP中的请求
+ String erpId = designDocData.getString("erp_id__c") != null ? designDocData.getString("erp_id__c") : "";
+
+ if ("".equals(erpId)) {
+ log.info("当前单据erp_id__c为空,不再向下执行");
+ continue;
+ }
+
+ Map erpDesignMap = new HashMap<>();
+ erpDesignMap.put("id", erpId);//erpId
+ erpDesignMap.put("billno", designDocName);//设计文件编号
+
+ //判断组织编码
+ String orgCode = "";
+ if (designDocData.getString("erp_organization_sales_con__c__v") != null && !"".equals(designDocData.getString("erp_organization_sales_con__c__v"))) {
+ orgCode = designDocData.getString("erp_organization_sales_con__c__v");
+ } else if (designDocData.getString("erp_organization_pre_contr__c__v") != null && !"".equals(designDocData.getString("erp_organization_pre_contr__c__v"))) {
+ orgCode = designDocData.getString("erp_organization_pre_contr__c__v");
+ } else {
+ log.info("当前单据没有组织编码,将不再向下执行");
+ continue;
+ }
+
+ erpDesignMap.put("org_number", orgCode);//组织编码
+ erpDesignMap.put("billtype_number", "pm_requirapplybill_STD_BT_S");//单据类型
+ erpDesignMap.put("biztype_name", "物料类采购");//业务类型
+
+ //开始获取单据日期
+ long bizTime = designDocData.getLong("document_date__c");
+ Date date = new Date(bizTime);
+
+ erpDesignMap.put("biztime", date);//单据日期
+
+ //部门编码
+ String deptCode = "";
+
+ List deptIdList = designDocData.getJSONArray("data_own_department");
+
+ //开始查询部门编码
+ JSONObject deptReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", deptIdList)
+ ), "DepartmentObj");
+
+ JSONObject deptRes = new JSONObject();
+
+ try {
+ deptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(deptRes.getString("errorDescription")) && !deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject deptData = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ deptCode = deptData.getString("field_Vj6sf__c") != null ? deptData.getString("field_Vj6sf__c") : "";
+ }
+
+ //erpDesignMap.put("dept_number", "ZHY");//部门编码
+ erpDesignMap.put("dept_number", deptCode);//部门编码
+
+ //获取负责人编码
+ String ownerCode = "";
+
+ List ownerIdList = designDocData.getJSONArray("owner");
+
+ JSONObject ownerReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "user_id", ownerIdList)
+ ), "PersonnelObj");
+
+ JSONObject ownerRes = new JSONObject();
+
+ try {
+ ownerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, ownerReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(ownerRes.getString("errorDescription")) && !ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ ownerCode = ownerData.getString("field_T1xid__c") != null ? ownerData.getString("field_T1xid__c") : "";
+ }
+
+ //erpDesignMap.put("bizuser_number", "ID-000011");//人员编码
+ erpDesignMap.put("bizuser_number", ownerCode);//人员编码
+ erpDesignMap.put("bizorg_number", orgCode);//采购组织
+ erpDesignMap.put("project_number", designDocData.getString("project_id__c"));//todo 项目号(商机)
+ erpDesignMap.put("contractno", designDocData.getString("sales_contract_number__c__r"));//合同号
+ erpDesignMap.put("crmid", designDocId);//crm唯一id
+ erpDesignMap.put("comment", designDocData.getString("remark__c") != null ? designDocData.getString("remark__c") : "");//备注
+
+
+ //开始获取设计文件明细
+ JSONObject getDesignDocDetail = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "design_file__c", Arrays.asList(designDocId))
+ ), "design_file_details__c");
+
+ JSONObject designDocDetailRes = new JSONObject();
+
+ try {
+ designDocDetailRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getDesignDocDetail, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(designDocDetailRes.getString("errorDescription")) || designDocDetailRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("查询失败或不存在当前设计文件明细");
+ continue;
+ }
+
+ List designDocList = new ArrayList<>();
+
+ for (Object designDocDetailObj : designDocDetailRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject designDocDetailData = JSON.parseObject(JSON.toJSONString(designDocDetailObj));
+
+ System.out.println("当前正在处理的设计文件明细数据为:" + designDocDetailData);
+
+ //开始封装设计文件明细
+ Map designDocDetailMap = new HashMap<>();
+ designDocDetailMap.put("materialmasterid_number", designDocDetailData.getString("material_name__c"));//设计文件明细
+ designDocDetailMap.put("qty", designDocDetailData.getBigDecimal("quantity__c") != null ? designDocDetailData.getBigDecimal("quantity__c") : 0);//数量
+ designDocDetailMap.put("materialtype", designDocDetailData.getString("customer_material_type__c"));//客指供应类型
+ designDocDetailMap.put("crmentryid", designDocDetailData.getString("_id"));//crm明细行id
+ designDocDetailMap.put("entrycomment", designDocDetailData.getString("remark__c") != null ? designDocDetailData.getString("remark__c") : "");//备注
+ designDocDetailMap.put("supplier_number", "G08000001");//todo 建议供应商
+
+ designDocList.add(designDocDetailMap);
+
+ }
+
+ erpDesignMap.put("billentry", designDocList);
+
+ Map erpContractData = new HashMap<>();
+ erpContractData.put("data", Arrays.asList(erpDesignMap));//请求体
+
+ System.out.println("erp请求为:" + JSON.parseObject(JSON.toJSONString(erpContractData)));
+
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity designDocReqEntity = new HttpEntity(erpContractData, headers);
+
+ System.out.println("请求为:" + JSON.parseObject(JSON.toJSONString(designDocReqEntity)));
+
+ //开始向金蝶发起请求
+ String designPlanUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/pssc/pm_requirapplybill/requirapplybillSave";
+
+ JSONObject erpDesignDocRes = new JSONObject();
+
+ try {
+ erpDesignDocRes = restTemplate.postForObject(designPlanUrl, designDocReqEntity, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("设计文件结果为:" + JSON.parseObject(JSON.toJSONString(erpDesignDocRes)));
+
+ //开始封装回写程序
+ Map backReqMap = new HashMap();
+ backReqMap.put("_id", designDocId);
+ backReqMap.put("dataObjectApiName", "design_file__c");
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "DFUP");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", designDocName);
+ logMap.put("data_id", designDocId);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(designDocReqEntity));
+ logMap.put("send_res", JSON.toJSONString(erpDesignDocRes));
+ logMap.put("tableName", "send_log_sjwj");
+
+ //判断是否执行成功
+ if ("0".equals(erpDesignDocRes.getString("errorCode"))) {
+ //同步成功
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ backReqMap.put("erp_id__c", erpDesignDocRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"));
+ backReqMap.put("sync_status__c", "option_sync_success__c");
+ backReqMap.put("response_info__c", "同步成功");
+ } else {
+ //同步失败
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败:" + erpDesignDocRes.getString("message"));
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", erpDesignDocRes.getString("message"));
+ }
+
+ //开始回写
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ System.out.println("回写请求为:" + JSON.parseObject(JSON.toJSONString(backReq)));
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+
+ //开始记录日志
+ JSONObject logResMap = new JSONObject();
+ try {
+ logResMap = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("日志插入结果为:" + logResMap);
+
+ }
+ }
+}
diff --git a/src/main/java/com/management/controller/FrameContractController.java b/src/main/java/com/management/controller/FrameContractController.java
new file mode 100644
index 0000000..88e182c
--- /dev/null
+++ b/src/main/java/com/management/controller/FrameContractController.java
@@ -0,0 +1,340 @@
+package com.management.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.management.constant.ERPURLConstant;
+import com.management.constant.URLConstant;
+import com.management.entity.Filter;
+import com.management.utils.CrmRequestUtil;
+import com.management.utils.KingDeeUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.*;
+
+@RestController
+@RequestMapping("/api/frame")
+@Slf4j
+public class FrameContractController {
+
+ private RestTemplate restTemplate = new RestTemplate();
+
+ public static void main(String[] args) {
+ new FrameContractController().syncFrameContract();
+ }
+
+ /**
+ * 同步框架合同
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping
+ public void syncFrameContract() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+
+ String[] syncStatus = {"option_pending_sync__c", "option_resync__c"};
+
+ JSONObject frameContract = crmRequestUtil.getCRMList(Arrays.asList(
+ //new Filter("IS", "erp_id__c", Arrays.asList("")),
+ new Filter("EQ", "life_status", Arrays.asList("normal")),
+ new Filter("IN", "sync_status__c", Arrays.asList(syncStatus)),
+ //new Filter("EQ", "name", Arrays.asList("KJ2505200005")),
+ new Filter("GT", "create_time", Arrays.asList("1748923200000"))
+ ), "framework_contract__c");
+
+ JSONObject frameContractRes = new JSONObject();
+
+ try {
+ frameContractRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, frameContract, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(frameContractRes.getString("errorDescription")) || frameContractRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("查询失败或者不存在符合条件的数据");
+ return;
+ }
+
+ log.info("查询成功,继续向下执行");
+
+ for (Object frameContractObj : frameContractRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject frameContractData = JSON.parseObject(JSON.toJSONString(frameContractObj));
+
+ System.out.println("当前正在处理的框架合同数据为:" + frameContractData);
+
+ //开始截取关键数据
+ String frameContractId = frameContractData.getString("_id");
+ //合同名称
+ String frameContractName = frameContractData.getString("name");
+ //创建时间
+ //String createTime = frameContractData.getString("create_time");
+ String createTime = frameContractData.getString("last_modified_time");
+
+ //开始查询是否已经集成过该合同
+ JSONObject isLogRes = new JSONObject();
+
+ try {
+ isLogRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_htxx&log_type=KJHT&dataId=" + frameContractId + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!isLogRes.getJSONArray("data").isEmpty()) {
+ log.info("当前数据已经执行过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("日志不存在,将继续向下执行");
+
+ //开始封装数据
+ Map frameContractReqMap = new HashMap<>();
+ frameContractReqMap.put("billno", frameContractName);//合同编号
+ frameContractReqMap.put("crmid", frameContractId);//合同编号
+
+ //开始查询商机编号
+ String businessId = frameContractData.getString("business_opportunity__c") != null ? frameContractData.getString("business_opportunity__c") : "";
+
+ if (businessId == null || businessId.equals("")) {
+ log.info("当前数据没有商机编号,将不再向下执行");
+ continue;
+ }
+
+ JSONObject businessReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", Arrays.asList(businessId))
+ ), "NewOpportunityObj");
+
+ JSONObject businessRes = new JSONObject();
+
+ businessRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, businessReq, JSONObject.class);
+
+ String projectCode = "";
+ if ("success".equals(businessRes.getString("errorDescription")) && !businessRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject businessData = businessRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ projectCode = businessData.getString("opportunity_id__c");
+ }
+
+ //frameContractReqMap.put("project_number", "SJ20250424-0033");//todo 项目号(商机编号)
+ frameContractReqMap.put("project_number", projectCode);//todo 项目号(商机编号)
+ frameContractReqMap.put("billtype_number", "conm_salcontract_BT_QD");//erp单据类型
+ frameContractReqMap.put("zhybilltype", frameContractData.getString("contract_type__c") != null ? frameContractData.getString("contract_type__c") : "");//合同类型
+ frameContractReqMap.put("billname", frameContractData.getString("project_name__c") != null ? frameContractData.getString("project_name__c") : "");//合同名称
+ frameContractReqMap.put("type_number", "XSHT-QD03");//合同类型
+ frameContractReqMap.put("contparties_number", frameContractData.getString("our_company_name__c") != null ? frameContractData.getString("our_company_name__c") : "");//合同主体
+ frameContractReqMap.put("createorg_number", frameContractData.getString("our_company_name__c") != null ? frameContractData.getString("our_company_name__c") : "");//销售组织编码
+ frameContractReqMap.put("org_number", frameContractData.getString("our_company_name__c") != null ? frameContractData.getString("our_company_name__c") : "");//销售组织编码
+ frameContractReqMap.put("currency_number", "CNY");//本位币.货币代码
+ frameContractReqMap.put("settlecurrency_number", "CNY");//结算币别.货币代码
+
+ long signDate = frameContractData.getLong("signing_date__c");
+
+ frameContractReqMap.put("biztime", signDate);//签订日期,单据日期
+ frameContractReqMap.put("biztimebegin", signDate);//起始日期
+ frameContractReqMap.put("biztimeend", signDate);//截止日期
+ frameContractReqMap.put("party1st", frameContractData.getString("contract_unit_name__c__r") != null ? frameContractData.getString("contract_unit_name__c__r") : "");//甲方
+ frameContractReqMap.put("party2nd", frameContractData.getString("our_company_name__c__r") != null ? frameContractData.getString("our_company_name__c__r") : "");//乙方
+ frameContractReqMap.put("bizmode", "C");//业务模式 A:统谈统签, B:统谈分签,C:分谈分签
+
+ //部门编码
+ String deptCode = "";
+
+ List deptIdList = frameContractData.getJSONArray("data_own_department");
+
+ //开始查询部门编码
+ JSONObject deptReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", deptIdList)
+ ), "DepartmentObj");
+
+ JSONObject deptRes = new JSONObject();
+
+ try {
+ deptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(deptRes.getString("errorDescription")) && !deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject deptData = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ deptCode = deptData.getString("field_Vj6sf__c") != null ? deptData.getString("field_Vj6sf__c") : "";
+ }
+
+ frameContractReqMap.put("dept", deptCode);//归属部门
+
+ //获取负责人编码
+ String ownerCode = "";
+
+ List ownerIdList = frameContractData.getJSONArray("owner");
+
+ JSONObject ownerReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "user_id", ownerIdList)
+ ), "PersonnelObj");
+
+ JSONObject ownerRes = new JSONObject();
+
+ try {
+ ownerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, ownerReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(ownerRes.getString("errorDescription")) && !ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ ownerCode = ownerData.getString("field_T1xid__c") != null ? ownerData.getString("field_T1xid__c") : "";
+ }
+
+ //frameContractReqMap.put("operator", "ZHY12025");//todo 负责人
+ frameContractReqMap.put("operator", ownerCode);
+
+ //合同单位
+ String customerId = frameContractData.getString("contract_unit_name__c");
+
+ //根据客户唯一id查询客户名称
+ JSONObject customerReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", Arrays.asList(customerId))
+ ), "AccountObj");
+
+ JSONObject customerRes = new JSONObject();
+
+ try {
+ customerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, customerReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(customerRes.getString("errorDescription")) || customerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("客户名称查询失败或者不存在,直接跳过更新");
+ continue;
+ }
+
+ JSONObject customerData = customerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ frameContractReqMap.put("customer_number", customerData.getString("account_no"));//合同单位名称
+ frameContractReqMap.put("reccustomer_number", customerData.getString("account_no"));//收获客户单位名称
+ //frameContractReqMap.put("customer_number", "Cus-000007");//todo 合同单位名称
+ frameContractReqMap.put("settlecustomer_number", frameContractData.getString("billing_customer_code__c") != null ? frameContractData.getString("billing_customer_code__c") : "");//结算客户
+ frameContractReqMap.put("payingcustomer_number", frameContractData.getString("payment_customer_code__c") != null ? frameContractData.getString("payment_customer_code__c") : "");//付款客户
+
+ //获取产品线
+
+ frameContractReqMap.put("productline_number", frameContractData.getString("product_line__c"));//产品线
+
+ //获取具体安装方式
+
+ frameContractReqMap.put("installationmethod", frameContractData.getString("installation_method__c"));//安装方式
+
+ //行业类型
+ frameContractReqMap.put("industrytype_number", frameContractData.getString("industry_type__c"));//行业类型
+ frameContractReqMap.put("province", frameContractData.getString("field_t3fgo__c__r"));//省
+ frameContractReqMap.put("city", frameContractData.getString("field_ngwth__c__r"));//市
+ frameContractReqMap.put("county", frameContractData.getString("field_K5p2C__c__r"));//县
+ frameContractReqMap.put("station", frameContractData.getString("single_choice__c") != null ? frameContractData.getString("single_choice__c") : "");//局级
+ frameContractReqMap.put("delivery", frameContractData.getString("ship_on_payment_received__c") != null ? frameContractData.getString("ship_on_payment_received__c") : "");//款到发货
+ frameContractReqMap.put("projectsource", frameContractData.getString("project_source__c") != null ? frameContractData.getString("project_source__c") : "");//项目来源
+ frameContractReqMap.put("salesmethod", frameContractData.getString("sales_method__c") != null ? frameContractData.getString("sales_method__c") : "");//销售方式
+
+ Map erpFrameContractReqMap = new HashMap<>();
+ erpFrameContractReqMap.put("data", Arrays.asList(frameContractReqMap));//请求体
+
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity contractReqEntity = new HttpEntity(erpFrameContractReqMap, headers);
+
+ System.out.println(JSON.parseObject(JSON.toJSONString(contractReqEntity)));
+
+ //开始向金蝶发起请求
+ String contractUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/conm/conm_salcontract/savecontract";
+
+ JSONObject contractRes = new JSONObject();
+
+ try {
+ contractRes = restTemplate.postForObject(contractUrl, contractReqEntity, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //开始封装回写程序
+ Map backReqMap = new HashMap();
+ backReqMap.put("_id", frameContractId);
+ backReqMap.put("dataObjectApiName", "framework_contract__c");
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "KJHT");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", frameContractName);
+ logMap.put("data_id", frameContractId);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(contractReqEntity));
+ logMap.put("send_res", JSON.toJSONString(contractRes));
+ logMap.put("tableName", "send_log_htxx");
+
+ //判断是否执行成功
+ if ("0".equals(contractRes.getString("errorCode"))) {
+ //同步成功
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ backReqMap.put("erp_id__c", contractRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"));
+ backReqMap.put("sync_status__c", "option_sync_success__c");
+ backReqMap.put("response_info__c", "同步成功");
+
+ //审核
+ KingDeeUtils kingDeeUtils = new KingDeeUtils();
+ kingDeeUtils.audit(contractRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"), "conm_salcontract");
+ } else {
+ //同步失败
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败:" + contractRes.getString("message"));
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", contractRes.getString("message"));
+ }
+
+ //开始回写
+ //解锁
+ if ("1".equals(frameContractData.getString("lock_status"))) {
+ log.info("解锁");
+ crmRequestUtil.unlockCRM(frameContractId, "framework_contract__c");
+ }
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+
+ //开始记录日志
+ JSONObject logRes = new JSONObject();
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("日志插入结果为:" + logRes);
+
+ }
+ }
+}
diff --git a/src/main/java/com/management/controller/GoodsPlanController.java b/src/main/java/com/management/controller/GoodsPlanController.java
new file mode 100644
index 0000000..b70dc9e
--- /dev/null
+++ b/src/main/java/com/management/controller/GoodsPlanController.java
@@ -0,0 +1,1037 @@
+package com.management.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.management.constant.ERPURLConstant;
+import com.management.constant.URLConstant;
+import com.management.entity.Filter;
+import com.management.utils.CrmRequestUtil;
+import com.management.utils.KingDeeUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.*;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 要货计划
+ *
+ * @param
+ * @return null
+ * @Author weiloong_zhang
+ */
+@RestController
+@RequestMapping("/api/goods_plan")
+@Slf4j
+public class GoodsPlanController {
+
+ private RestTemplate restTemplate = new RestTemplate();
+
+ public static void main(String[] args) {
+ new GoodsPlanController().syncGoodsPlan();
+ //new GoodsPlanController().updateGoodsPlan();
+ //new GoodsPlanController().syncTrackingNum();
+ }
+
+ /**
+ * 同步新增要货计划
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/sync/goodsPlan")
+ public void syncGoodsPlan() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+ log.info("开始同步要货计划");
+
+ String[] syncStatus = {"option_pending_sync__c", "option_resync__c"};
+
+ //要货计划请求
+ JSONObject getGoodsPlan = crmRequestUtil.getCRMList(Arrays.asList(
+ //new Filter("IS", "erp_id__c", Arrays.asList("")),
+ new Filter("EQ", "business_status__c", Arrays.asList("option_normal__c")),
+ new Filter("IN", "sync_status__c", Arrays.asList(syncStatus)),
+ new Filter("GT", "create_time", Arrays.asList("1748923200000")),
+ //new Filter("EQ", "name", Arrays.asList("YHJH20250508-0002")),
+ new Filter("EQ", "life_status", Arrays.asList("normal"))
+ ), "purchase_plan__c");
+
+ JSONObject goodsPlanRes = new JSONObject();
+
+ //开始发起请求
+ try {
+ goodsPlanRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getGoodsPlan, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //判断是否请求成功
+ if (!"success".equals(goodsPlanRes.getString("errorDescription")) || goodsPlanRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("请求失败或数据不存在");
+ return;
+ }
+
+ //请求成功
+ for (Object goodsPlanObj : goodsPlanRes.getJSONObject("data").getJSONArray("dataList")) {
+ //将Obj转为JSONObject
+ JSONObject goodsPlanData = JSON.parseObject(JSON.toJSONString(goodsPlanObj));
+
+ System.out.println("当前正在处理的要货计划数据为:" + goodsPlanData);
+
+ //获取当前单据的唯一id
+ String goodsPlanId = goodsPlanData.getString("_id");
+
+ //获取当前单据名称
+ String goodsPlanName = goodsPlanData.getString("name");
+
+ //获取当前单据的创建时间
+ //String createTime = goodsPlanData.getString("create_time");
+ String createTime = goodsPlanData.getString("last_modified_time");
+
+ //开始查询该单据是否已经集成过
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_goodsplan&log_type=GP&dataId=" + goodsPlanId + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!logRes.getJSONArray("data").isEmpty()) {
+ log.info("当前单据已经集成过了");
+ continue;
+ }
+
+ log.info("当前单据没有集成过");
+
+ //开始封装传输至ERP的请求
+ log.info("开始封装请求");
+
+ Map erpGoodsPlanReq = new HashMap<>();
+ erpGoodsPlanReq.put("f9w5_crmid", goodsPlanId);
+ erpGoodsPlanReq.put("billno", goodsPlanName);//单据编号
+ erpGoodsPlanReq.put("billtype_number", "f9w5_sm_purchaseplan_BT");//单据类型
+
+ String orgNum = goodsPlanData.getString("erp_organization__c") != null ? goodsPlanData.getString("erp_organization__c") : "";
+
+ erpGoodsPlanReq.put("org_number", orgNum);//组织编码
+
+ String businessType = goodsPlanData.getString("business_status__c") != null ? goodsPlanData.getString("business_status__c") : "";
+
+ switch (businessType) {
+ case "option_normal__c":
+ erpGoodsPlanReq.put("f9w5_busstatus", "A");//业务状态
+ break;
+ case "option_close__c":
+ erpGoodsPlanReq.put("f9w5_busstatus", "B");//业务状态
+ break;
+ default:
+ erpGoodsPlanReq.put("f9w5_busstatus", "A");//业务状态
+ break;
+ }
+
+ //开始获取需求日期
+ long biztime = goodsPlanData.getLong("requirement_date__c");
+
+ Date date = new Date(biztime);
+ erpGoodsPlanReq.put("biztime", date);//需求日期
+
+ //部门编码
+ String deptCode = "";
+
+ List deptIdList = goodsPlanData.getJSONArray("data_own_department");
+
+ //开始查询部门编码
+ JSONObject deptReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", deptIdList)
+ ), "DepartmentObj");
+
+ JSONObject deptRes = new JSONObject();
+
+ try {
+ deptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(deptRes.getString("errorDescription")) && !deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject deptData = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ deptCode = deptData.getString("field_Vj6sf__c") != null ? deptData.getString("field_Vj6sf__c") : "";
+ }
+
+ //erpGoodsPlanReq.put("dept", "zyierp");//todo 归属部门
+ erpGoodsPlanReq.put("dept", deptCode);//todo 归属部门
+
+ //获取负责人编码
+ String ownerCode = "";
+
+ List ownerIdList = goodsPlanData.getJSONArray("owner");
+
+ JSONObject ownerReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "user_id", ownerIdList)
+ ), "PersonnelObj");
+
+ JSONObject ownerRes = new JSONObject();
+
+ try {
+ ownerRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, ownerReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(ownerRes.getString("errorDescription")) && !ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ ownerCode = ownerData.getString("field_T1xid__c") != null ? ownerData.getString("field_T1xid__c") : "";
+ }
+
+ //erpGoodsPlanReq.put("operator", "ID-000011");//todo 负责人
+ erpGoodsPlanReq.put("operator", ownerCode);//todo 负责人
+
+ //根据要货计划查询要货计划明细
+ JSONObject getGoodsPlanDetail = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "purchase_plan__c", Arrays.asList(goodsPlanId))
+ ), "purchase_plan_details__c");
+
+ JSONObject goodsPlanDetailRes = new JSONObject();
+
+ try {
+ goodsPlanDetailRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getGoodsPlanDetail, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("要货计划明细查询结果为:" + goodsPlanDetailRes);
+
+ if (!"success".equals(goodsPlanDetailRes.getString("errorDescription")) || goodsPlanDetailRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("要货计划明细查询失败不存在当前要货计划明细");
+ continue;
+ }
+
+ log.info("要货计划明细存在,继续向下执行");
+
+ //延时执行(非阻塞)
+ ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
+ executor.schedule(() -> {
+ System.out.println("延时任务执行");
+ }, 5, TimeUnit.SECONDS); // 5秒后执行
+ executor.shutdown(); // 关闭线程池
+
+ //明细列表
+ List goodsPlanDetailList = new ArrayList<>();
+
+ //用来判断跟踪号是否传输成功
+ JSONObject trackingNumReason = new JSONObject();
+
+ for (Object goodsPlanDetailObj : goodsPlanDetailRes.getJSONObject("data").getJSONArray("dataList")) {
+
+ if (!trackingNumReason.isEmpty()) {
+ log.info("已经存在执行错误的明细,将不再执行本条数据");
+ continue;
+ }
+
+ JSONObject goodsPlanDetailData = JSON.parseObject(JSON.toJSONString(goodsPlanDetailObj));
+
+ System.out.println("当前正在处理的要货计划明细数据为:" + goodsPlanDetailData);
+
+ String trackingNum = goodsPlanDetailData.getString("batch_number__c") != null ? goodsPlanDetailData.getString("batch_number__c") : "";
+
+ if (trackingNum.equals("")) {
+ log.info("跟踪号不存在,将不再向下执行");
+ trackingNumReason.put("status", "false");
+ trackingNumReason.put("reason", "跟踪号不存在,将不再向下执行");
+ continue;
+ }
+
+ //跟踪号存在,开始执行
+ JSONObject syncTrackingNum = syncTrackingNum(trackingNum);
+
+ //判断是否执行成功
+ if (!"success".equals(syncTrackingNum.getString("errorCode"))) {
+ trackingNumReason.put("status", "false");
+ trackingNumReason.put("reason", syncTrackingNum.getString("message"));
+ continue;
+ }
+
+ //开始封装要货计划明细数据
+ Map erpGoodsPlanDetailReq = new HashMap<>();
+ erpGoodsPlanDetailReq.put("f9w5_crmentryid", goodsPlanDetailData.getString("_id"));//crm明细id
+ erpGoodsPlanDetailReq.put("material_number", goodsPlanDetailData.getString("material_id__c__r"));//物料编号
+ erpGoodsPlanDetailReq.put("entryorg_number", orgNum);//组织编码
+ erpGoodsPlanDetailReq.put("qty", goodsPlanDetailData.getBigDecimal("quantity__c") != null ? goodsPlanDetailData.getBigDecimal("quantity__c") : 0);//数量
+ //erpGoodsPlanDetailReq.put("lot_number", goodsPlanDetailData.getString("batch_number__c") != null ? goodsPlanDetailData.getString("batch_number__c") : "");//批号
+ erpGoodsPlanDetailReq.put("entrycomment", goodsPlanDetailData.getString("remark__c") != null ? goodsPlanDetailData.getString("remark__c") : "");//备注
+ erpGoodsPlanDetailReq.put("f9w5_contractno", goodsPlanDetailData.getString("sales_contract_number__c__r") != null ? goodsPlanDetailData.getString("sales_contract_number__c__r") : "");//销售合同编号
+ erpGoodsPlanDetailReq.put("f9w5_tracknumber_number", trackingNum);//跟踪号
+ erpGoodsPlanDetailReq.put("f9w5_programversion_number", goodsPlanDetailData.getString("program_version_number__c"));//程序版本
+
+ //开始查询项目号
+ String projectId = goodsPlanDetailData.getString("project_name__c") != null ? goodsPlanDetailData.getString("project_name__c") : "";
+
+ //开始查询项目号
+ JSONObject getProjectReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", Arrays.asList(projectId))
+ ), "NewOpportunityObj");
+
+ JSONObject projectRes = new JSONObject();
+
+ try {
+ projectRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getProjectReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ String projectCode = "";
+
+ if ("success".equals(projectRes.getString("errorDescription")) && !projectRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject projectData = projectRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ projectCode = projectData.getString("opportunity_id__c") != null ? projectData.getString("opportunity_id__c") : "";
+ }
+
+ erpGoodsPlanDetailReq.put("f9w5_project_number", projectCode);//项目号
+
+ goodsPlanDetailList.add(erpGoodsPlanDetailReq);
+
+ }
+
+ //开始封装回写程序
+ Map backReqMap = new HashMap();
+ backReqMap.put("_id", goodsPlanId);
+ backReqMap.put("dataObjectApiName", "purchase_plan__c");
+
+ //开始判断
+ if (!trackingNumReason.isEmpty()) {
+ log.info("明细封装错误,将不再向下执行");
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", trackingNumReason.getString("reason"));
+
+ //开始回写
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+ continue;
+ }
+
+
+ erpGoodsPlanReq.put("billentry", goodsPlanDetailList);
+
+ //开始封装要货计划请求
+ System.out.println("erp请求为:" + JSON.parseObject(JSON.toJSONString(erpGoodsPlanReq)));
+
+ Map erpContractData = new HashMap<>();
+ erpContractData.put("data", Arrays.asList(erpGoodsPlanReq));//请求体
+
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity goodsPlanReqEntity = new HttpEntity(erpContractData, headers);
+
+ System.out.println(JSON.parseObject(JSON.toJSONString(goodsPlanReqEntity)));
+
+ //开始向金蝶发起请求
+ String goodsPlanUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/sm/f9w5_sm_purchaseplan/purchaseplanSave";
+
+ JSONObject erpGoodsPlanRes = new JSONObject();
+
+ try {
+ erpGoodsPlanRes = restTemplate.postForObject(goodsPlanUrl, goodsPlanReqEntity, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("要货计划结果为:" + JSON.parseObject(JSON.toJSONString(erpGoodsPlanRes)));
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "GP");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", goodsPlanName);
+ logMap.put("data_id", goodsPlanId);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(goodsPlanReqEntity));
+ logMap.put("send_res", JSON.toJSONString(erpGoodsPlanRes));
+ logMap.put("tableName", "send_log_goodsplan");
+
+ //判断是否执行成功
+ if ("0".equals(erpGoodsPlanRes.getString("errorCode"))) {
+ //同步成功
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ backReqMap.put("erp_id__c", erpGoodsPlanRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"));
+ backReqMap.put("sync_status__c", "option_sync_success__c");
+ backReqMap.put("response_info__c", "同步成功");
+
+ //审核
+ KingDeeUtils kingDeeUtils = new KingDeeUtils();
+ kingDeeUtils.audit(erpGoodsPlanRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"), "f9w5_sm_purchaseplan");
+ } else {
+ //同步失败
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败:" + erpGoodsPlanRes.getString("message"));
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", erpGoodsPlanRes.getString("message"));
+ }
+
+ //开始回写
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ System.out.println("回写请求为:" + JSON.parseObject(JSON.toJSONString(backReq)));
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+
+ //开始记录日志
+ JSONObject logResMap = new JSONObject();
+ try {
+ logResMap = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("日志插入结果为:" + logResMap);
+
+
+ }
+
+ }
+
+ /**
+ * 要货计划更新接口
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/update/goodsPlan")
+ public void updateGoodsPlan() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+ log.info("开始同步更新要货计划");
+
+ //要货计划请求
+ JSONObject getGoodsPlan = crmRequestUtil.getCRMList(Arrays.asList(
+ //new Filter("IS", "erp_id__c", Arrays.asList("")),
+ new Filter("EQ", "business_status__c", Arrays.asList("option_close__c")),
+ //new Filter("IN", "sync_status__c", Arrays.asList(syncStatus)),
+ new Filter("GT", "create_time", Arrays.asList("1748923200000")),
+ //new Filter("EQ", "name", Arrays.asList("YHJH20250508-0002")),
+ new Filter("EQ", "life_status", Arrays.asList("normal"))
+ ), "purchase_plan__c");
+
+ JSONObject goodsPlanRes = new JSONObject();
+
+ //开始发起请求
+ try {
+ goodsPlanRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getGoodsPlan, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ //判断是否请求成功
+ if (!"success".equals(goodsPlanRes.getString("errorDescription")) || goodsPlanRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("请求失败或数据不存在");
+ return;
+ }
+
+ //请求成功
+ for (Object goodsPlanObj : goodsPlanRes.getJSONObject("data").getJSONArray("dataList")) {
+ //将Obj转为JSONObject
+ JSONObject goodsPlanData = JSON.parseObject(JSON.toJSONString(goodsPlanObj));
+
+ System.out.println("当前正在处理的要货计划数据为:" + goodsPlanData);
+
+ //获取当前单据的唯一id
+ String goodsPlanId = goodsPlanData.getString("_id");
+
+ //获取当前单据名称
+ String goodsPlanName = goodsPlanData.getString("name");
+
+ //获取当前单据的最后修改时间
+ String lastModifyTime = goodsPlanData.getString("last_modified_time");
+
+ //开始查询该单据是否已经集成过
+ JSONObject logRes = new JSONObject();
+
+ try {
+ logRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_goodsplan&log_type=GPUP&dataId=" + goodsPlanId + "&mark=" + lastModifyTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!logRes.getJSONArray("data").isEmpty()) {
+ log.info("当前单据已经更新过了");
+ continue;
+ }
+
+ log.info("当前单据没有集成过");
+
+ //开始封装传输至ERP的请求
+ log.info("开始封装请求");
+
+ //获取ERPID
+ String erpId = goodsPlanData.getString("erp_id__c") != null ? goodsPlanData.getString("erp_id__c") : "";
+
+ if ("".equals(erpId)) {
+ log.info("当前单据erp_id__c为空,不再向下执行");
+ continue;
+ }
+
+ log.info("存在ERPID,继续向下执行!");
+
+ Map erpGoodsPlanReq = new HashMap<>();
+ erpGoodsPlanReq.put("id", erpId);
+ erpGoodsPlanReq.put("f9w5_crmid", goodsPlanId);
+ erpGoodsPlanReq.put("billno", goodsPlanName);//单据编号
+ erpGoodsPlanReq.put("billtype_number", "f9w5_sm_purchaseplan_BT");//单据类型
+
+ //组织编码
+ String orgNum = goodsPlanData.getString("erp_organization__c") != null ? goodsPlanData.getString("erp_organization__c") : "";
+
+ erpGoodsPlanReq.put("org_number", orgNum);//组织编码
+
+ String businessType = goodsPlanData.getString("business_status__c") != null ? goodsPlanData.getString("business_status__c") : "";
+
+ switch (businessType) {
+ case "option_normal__c":
+ erpGoodsPlanReq.put("f9w5_busstatus", "A");//业务状态
+ break;
+ case "option_close__c":
+ erpGoodsPlanReq.put("f9w5_busstatus", "B");//业务状态
+ break;
+ default:
+ erpGoodsPlanReq.put("f9w5_busstatus", "A");//业务状态
+ break;
+ }
+
+ //开始获取需求日期
+ long biztime = goodsPlanData.getLong("requirement_date__c");
+
+ Date date = new Date(biztime);
+ erpGoodsPlanReq.put("biztime", date);//需求日期
+
+ //部门编码
+ String deptCode = "";
+
+ List deptIdList = goodsPlanData.getJSONArray("data_own_department");
+
+ //开始查询部门编码
+ JSONObject deptReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", deptIdList)
+ ), "DepartmentObj");
+
+ JSONObject deptRes = new JSONObject();
+
+ try {
+ deptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(deptRes.getString("errorDescription")) && !deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject deptData = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ deptCode = deptData.getString("field_Vj6sf__c") != null ? deptData.getString("field_Vj6sf__c") : "";
+ }
+
+ erpGoodsPlanReq.put("dept", deptCode);//todo 归属部门
+
+ //获取负责人编码
+ String ownerCode = "";
+
+ List ownerIdList = goodsPlanData.getJSONArray("owner");
+
+ JSONObject ownerReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "user_id", ownerIdList)
+ ), "PersonnelObj");
+
+ JSONObject ownerRes = new JSONObject();
+
+ try {
+ ownerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, ownerReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if ("success".equals(ownerRes.getString("errorDescription")) && !ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ ownerCode = ownerData.getString("field_T1xid__c") != null ? ownerData.getString("field_T1xid__c") : "";
+ }
+
+ erpGoodsPlanReq.put("operator", ownerCode);//todo 负责人
+
+ //根据要货计划查询要货计划明细
+ JSONObject getGoodsPlanDetail = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "purchase_plan__c", Arrays.asList(goodsPlanId))
+ ), "purchase_plan_details__c");
+
+ JSONObject goodsPlanDetailRes = new JSONObject();
+
+ try {
+ goodsPlanDetailRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getGoodsPlanDetail, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("要货计划明细查询结果为:" + goodsPlanDetailRes);
+
+ if (!"success".equals(goodsPlanDetailRes.getString("errorDescription")) || goodsPlanDetailRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("要货计划明细查询失败不存在当前要货计划明细");
+ continue;
+ }
+
+ log.info("要货计划明细存在,继续向下执行");
+
+ //明细列表
+ List goodsPlanDetailList = new ArrayList<>();
+
+ //用来判断跟踪号是否传输成功
+ JSONObject trackingNumReason = new JSONObject();
+
+ for (Object goodsPlanDetailObj : goodsPlanDetailRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject goodsPlanDetailData = JSON.parseObject(JSON.toJSONString(goodsPlanDetailObj));
+
+ System.out.println("当前正在处理的要货计划明细数据为:" + goodsPlanDetailData);
+
+ String trackingNum = goodsPlanDetailData.getString("batch_number__c") != null ? goodsPlanDetailData.getString("batch_number__c") : "";
+
+ if (trackingNum.equals("")) {
+ log.info("跟踪号不存在,将不再向下执行");
+ trackingNumReason.put("status", "false");
+ trackingNumReason.put("reason", "跟踪号不存在,将不再向下执行");
+ continue;
+ }
+
+ //跟踪号存在,开始执行
+ JSONObject syncTrackingNum = syncTrackingNum(trackingNum);
+
+ //判断是否执行成功
+ if (!"success".equals(syncTrackingNum.getString("errorCode"))) {
+ trackingNumReason.put("status", "false");
+ trackingNumReason.put("reason", syncTrackingNum.getString("message"));
+ continue;
+ }
+
+ //开始封装要货计划明细数据
+ Map erpGoodsPlanDetailReq = new HashMap<>();
+ erpGoodsPlanDetailReq.put("f9w5_crmentryid", goodsPlanDetailData.getString("_id"));//crm明细id
+ erpGoodsPlanDetailReq.put("material_number", goodsPlanDetailData.getString("material_id__c__r"));//物料编号
+ erpGoodsPlanDetailReq.put("entryorg_number", orgNum);//组织编码
+ erpGoodsPlanDetailReq.put("qty", goodsPlanDetailData.getBigDecimal("quantity__c") != null ? goodsPlanDetailData.getBigDecimal("quantity__c") : 0);//数量
+ //erpGoodsPlanDetailReq.put("lot_number", goodsPlanDetailData.getString("batch_number__c") != null ? goodsPlanDetailData.getString("batch_number__c") : "");//批号
+ erpGoodsPlanDetailReq.put("entrycomment", goodsPlanDetailData.getString("remark__c") != null ? goodsPlanDetailData.getString("remark__c") : "");//备注
+ erpGoodsPlanDetailReq.put("f9w5_contractno", goodsPlanDetailData.getString("sales_contract_number__c__r") != null ? goodsPlanDetailData.getString("sales_contract_number__c__r") : "");//销售合同编号
+ erpGoodsPlanDetailReq.put("f9w5_tracknumber_number", trackingNum);//跟踪号
+
+ //开始查询项目号
+ String projectId = goodsPlanDetailData.getString("project_name__c") != null ? goodsPlanDetailData.getString("project_name__c") : "";
+
+ //开始查询项目号
+ JSONObject getProjectReq = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", Arrays.asList(projectId))
+ ), "NewOpportunityObj");
+
+ JSONObject projectRes = new JSONObject();
+
+ try {
+ projectRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getProjectReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ String projectCode = "";
+
+ if ("success".equals(projectRes.getString("errorDescription")) && !projectRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ JSONObject projectData = projectRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+ projectCode = projectData.getString("opportunity_id__c") != null ? projectData.getString("opportunity_id__c") : "";
+ }
+
+ erpGoodsPlanDetailReq.put("f9w5_project_number", projectCode);//项目号
+
+ goodsPlanDetailList.add(erpGoodsPlanDetailReq);
+
+ }
+
+ //开始封装回写程序
+ Map backReqMap = new HashMap();
+ backReqMap.put("_id", goodsPlanId);
+ backReqMap.put("dataObjectApiName", "purchase_plan__c");
+
+ //开始判断
+ if (!trackingNumReason.isEmpty()) {
+ log.info("明细封装错误,将不再向下执行");
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", trackingNumReason.getString("reason"));
+
+ //开始回写
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+ continue;
+ }
+
+ erpGoodsPlanReq.put("billentry", goodsPlanDetailList);
+
+ //开始封装要货计划请求
+ System.out.println("erp请求为:" + JSON.parseObject(JSON.toJSONString(erpGoodsPlanReq)));
+
+ Map erpContractData = new HashMap<>();
+ erpContractData.put("data", Arrays.asList(erpGoodsPlanReq));//请求体
+
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity goodsPlanReqEntity = new HttpEntity(erpContractData, headers);
+
+ System.out.println(JSON.parseObject(JSON.toJSONString(goodsPlanReqEntity)));
+
+ //开始向金蝶发起请求
+ String goodsPlanUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/sm/f9w5_sm_purchaseplan/purchaseplanSave";
+
+ JSONObject erpGoodsPlanRes = new JSONObject();
+
+ try {
+ erpGoodsPlanRes = restTemplate.postForObject(goodsPlanUrl, goodsPlanReqEntity, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("要货计划结果为:" + JSON.parseObject(JSON.toJSONString(erpGoodsPlanRes)));
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "GPUP");
+ logMap.put("syn_type", "1");
+ logMap.put("data_name", goodsPlanName);
+ logMap.put("data_id", goodsPlanId);
+ logMap.put("mark", lastModifyTime);
+ logMap.put("send_body", JSON.toJSONString(goodsPlanReqEntity));
+ logMap.put("send_res", JSON.toJSONString(erpGoodsPlanRes));
+ logMap.put("tableName", "send_log_goodsplan");
+
+ //判断是否执行成功
+ if ("0".equals(erpGoodsPlanRes.getString("errorCode"))) {
+ //同步成功
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ backReqMap.put("erp_id__c", erpGoodsPlanRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"));
+ backReqMap.put("sync_status__c", "option_sync_success__c");
+ backReqMap.put("response_info__c", "同步成功");
+ } else {
+ //同步失败
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败:" + erpGoodsPlanRes.getString("message"));
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", erpGoodsPlanRes.getString("message"));
+ }
+
+ //开始回写
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ System.out.println("回写请求为:" + JSON.parseObject(JSON.toJSONString(backReq)));
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+
+ //开始记录日志
+ JSONObject logResMap = new JSONObject();
+ try {
+ logResMap = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("日志插入结果为:" + logResMap);
+ }
+ }
+
+
+ /**
+ * 跟踪号同步方法
+ *
+ * @return java.lang.String
+ * @Author weiloong_zhang
+ */
+ public JSONObject syncTrackingNum(String trackingNum) {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+
+ //String trackingNum = "YHJH2505290005-1";
+
+ JSONObject res = new JSONObject();
+
+ JSONObject getTrackNum = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "name", Arrays.asList(trackingNum))
+ ), "tracking_number__c");
+
+ JSONObject trackingNumRes = new JSONObject();
+
+ try {
+ trackingNumRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getTrackNum, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("跟踪号查询结果为:" + trackingNumRes);
+
+ if (!"success".equals(trackingNumRes.getString("errorDescription")) || trackingNumRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("查询失败或者不存在符合条件数据");
+ res.put("errorCode", "error");
+ res.put("message", "跟踪号查询失败或者不存在符合条件数据");
+ return res;
+ }
+
+ log.info("跟踪号查询成功,继续向下执行");
+
+ JSONObject trackingNumData = trackingNumRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ System.out.println("当前正在处理的跟踪号为:" + trackingNumData);
+
+ String trackingNumStr = trackingNumData.getString("name");
+ //开始封装跟踪号数据
+ Map trackingNumMap = new HashMap();
+ trackingNumMap.put("number", trackingNumStr);//跟踪号
+ trackingNumMap.put("status", "C");//数据状态
+ trackingNumMap.put("sourcebillno", trackingNumData.getString("purchase_plan__c__r") != null ? trackingNumData.getString("purchase_plan__c__r") : "");//todo 来源单据编号
+ trackingNumMap.put("description", "C");//todo 描述
+
+ String lineStr = trackingNumStr.split("-")[1];
+
+ trackingNumMap.put("sourcebillentryseq", lineStr);//来源单据分录行号
+ trackingNumMap.put("f9w5_materialname", trackingNumData.getString("material_name__c") != null ? trackingNumData.getString("material_name__c") : "");//物料名称
+
+ String isNeedForProduction = trackingNumData.getString("is_need_for_production__c") != null ? trackingNumData.getString("is_need_for_production__c") : "";
+
+ switch (isNeedForProduction) {
+ case "yes":
+ trackingNumMap.put("f9w5_isuse", true);//是否需要生产使用该参数
+ break;
+ case "no":
+ trackingNumMap.put("f9w5_isuse", false);//是否需要生产使用该参数
+ break;
+ default:
+ trackingNumMap.put("f9w5_isuse", null);//是否需要生产使用该参数
+ break;
+ }
+
+ trackingNumMap.put("f9w5_deviceid", trackingNumData.getString("device_id_third__c") != null ? trackingNumData.getString("device_id_third__c") : "");//设备ID(第三方编号)
+ trackingNumMap.put("f9w5_apn", trackingNumData.getString("apn_parameters__c") != null ? trackingNumData.getString("apn_parameters__c") : "");//APN参数
+ trackingNumMap.put("f9w5_ip", trackingNumData.getString("ip_address__c") != null ? trackingNumData.getString("ip_address__c") : "");//ip
+ trackingNumMap.put("f9w5_port", trackingNumData.getString("port__c") != null ? trackingNumData.getString("port__c") : "");//端口
+
+ //是否插卡
+ String isCard = trackingNumData.getString("is_card_inserted__c") != null ? trackingNumData.getString("is_card_inserted__c") : "";
+
+ switch (isCard) {
+ case "yes":
+ trackingNumMap.put("f9w5_bindingcard", true);//是否插卡
+ break;
+ case "no":
+ trackingNumMap.put("f9w5_bindingcard", false);//是否插卡
+ break;
+ default:
+ trackingNumMap.put("f9w5_bindingcard", null);//是否插卡
+ break;
+ }
+
+ //快快拍模式
+ String snapShot = trackingNumData.getString("snap_mode__c") != null ? trackingNumData.getString("snap_mode__c") : "";
+
+ switch (snapShot) {
+ case "yes":
+ trackingNumMap.put("f9w5_snapshot", true);//是否插卡
+ break;
+ case "no":
+ trackingNumMap.put("f9w5_snapshot", false);//是否插卡
+ break;
+ default:
+ trackingNumMap.put("f9w5_snapshot", null);//是否插卡
+ break;
+ }
+
+ //前端智能识别
+ String isFront = trackingNumData.getString("front_end_intelligent_reco__c") != null ? trackingNumData.getString("front_end_intelligent_reco__c") : "";
+
+ switch (isFront) {
+ case "yes":
+ trackingNumMap.put("f9w5_frontir", true);//前端智能识别
+ break;
+ case "no":
+ trackingNumMap.put("f9w5_frontir", false);//前端智能识别
+ break;
+ default:
+ trackingNumMap.put("f9w5_frontir", null);//前端智能识别
+ break;
+ }
+
+ //运行模式修改
+ String runMode = trackingNumData.getString("operation_mode_update__c") != null ? trackingNumData.getString("operation_mode_update__c") : "";
+
+ trackingNumMap.put("f9w5_runmodification", runMode);
+ //通道拍照时间间隔
+ trackingNumMap.put("f9w5_channelinterval", trackingNumData.getString("channel_photo_interval__c__r") != null ? trackingNumData.getString("channel_photo_interval__c__r") : "");
+ //通道图片分辨率/像素
+ trackingNumMap.put("f9w5_channelpixel", trackingNumData.getString("channel_image_resolution__c__r") != null ? trackingNumData.getString("channel_image_resolution__c__r") : "");
+ //机芯图片分辨率/像素
+ trackingNumMap.put("f9w5_movementpixel", trackingNumData.getString("core_image_resolution__c__r") != null ? trackingNumData.getString("core_image_resolution__c__r") : "");
+ //副机通道号
+ String auxiliarychannel = trackingNumData.getString("secondary_channel_number__c") != null ? trackingNumData.getString("secondary_channel_number__c") : "";
+ if (auxiliarychannel.equals("") || auxiliarychannel.equals("option_none__c")) {
+ auxiliarychannel = "";
+ }
+
+ trackingNumMap.put("f9w5_auxiliarychannel", auxiliarychannel);
+ //机芯拍照时间间隔
+ trackingNumMap.put("f9w5_movementinterval", trackingNumData.getString("core_photo_interval__c__r") != null ? trackingNumData.getString("core_photo_interval__c__r") : "");
+ //副机绑定地址
+ trackingNumMap.put("f9w5_auxiliaryip", trackingNumData.getString("secondary_device_bound_add__c__r") != null ? trackingNumData.getString("secondary_device_bound_add__c__r") : "");
+ //副机通道类型
+ String auxiliarychanneltype = trackingNumData.getString("secondary_channel_type__c__r") != null ? trackingNumData.getString("secondary_channel_type__c__r") : "";
+
+ if (auxiliarychanneltype.equals("") || auxiliarychanneltype.equals("option_none__c")) {
+ auxiliarychanneltype = "";
+ }
+
+ trackingNumMap.put("f9w5_auxiliarytype", auxiliarychanneltype);
+ //维护时间段
+ trackingNumMap.put("f9w5_maintenancetime", trackingNumData.getString("maintenance_time_period__c") != null ? trackingNumData.getString("maintenance_time_period__c") : "");
+ //出厂内外卡选择
+ trackingNumMap.put("f9w5_inoutcard", trackingNumData.getString("factory_external_card_choi__c__r") != null ? trackingNumData.getString("factory_external_card_choi__c__r") : "");
+ //出厂平台选择
+ trackingNumMap.put("f9w5_outplatform", trackingNumData.getString("factory_platform_choice__c__r") != null ? trackingNumData.getString("factory_platform_choice__c__r") : "");
+ //铭牌
+ trackingNumMap.put("f9w5_nameplate", trackingNumData.getString("tag_name__c__r") != null ? trackingNumData.getString("tag_name__c__r") : "");
+ //流量卡
+ trackingNumMap.put("f9w5_flowcard", trackingNumData.getString("traffic_card__c__r") != null ? trackingNumData.getString("traffic_card__c__r") : "");
+ //联网模式配置
+ trackingNumMap.put("f9w5_confignetset", trackingNumData.getString("network_mode_config__c__r") != null ? trackingNumData.getString("network_mode_config__c__r") : "");
+ //是否开启维护模式
+ String isMaintenance = trackingNumData.getString("is_maintenance_mode_enable__c") != null ? trackingNumData.getString("is_maintenance_mode_enable__c") : "";
+
+ switch (isMaintenance) {
+ case "yes":
+ trackingNumMap.put("f9w5_ismaintenance", true);//前端智能识别
+ break;
+ case "no":
+ trackingNumMap.put("f9w5_ismaintenance", false);//前端智能识别
+ break;
+ default:
+ trackingNumMap.put("f9w5_ismaintenance", null);//前端智能识别
+ break;
+ }
+
+ //物料编码
+ trackingNumMap.put("f9w5_material_number", trackingNumData.getString("material_code__c__r") != null ? trackingNumData.getString("material_code__c__r") : "");
+ //平台
+ trackingNumMap.put("f9w5_smplatform_number", trackingNumData.getString("platform_name_code__c") != null ? trackingNumData.getString("platform_name_code__c") : "");
+ //todo 来源单据类型.编码
+ trackingNumMap.put("sourcebilltype_number", "f9w5_sm_purchaseplan_BT");
+
+ Map erpTrackReq = new HashMap<>();
+ erpTrackReq.put("data", Arrays.asList(trackingNumMap));
+
+ //开始获取token
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ res.put("errorCode", "error");
+ res.put("message", "跟踪号金蝶token为空或不存在");
+ return res;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity contractReqEntity = new HttpEntity(erpTrackReq, headers);
+
+ System.out.println(JSON.parseObject(JSON.toJSONString(contractReqEntity)));
+
+ String trackingNumUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/sbd/bd_tracknumber/bdTracknumberSave";
+
+ //开始调用金蝶接口
+ JSONObject trackingNumERPRes = new JSONObject();
+
+ try {
+ trackingNumERPRes = restTemplate.postForObject(trackingNumUrl, contractReqEntity, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ res.put("errorCode", "error");
+ res.put("message", "跟踪号新增或更新请求失败");
+ return res;
+ }
+
+ System.out.println(JSON.parseObject(JSON.toJSONString(trackingNumERPRes)));
+
+ if ("0".equals(trackingNumERPRes.getString("errorCode"))) {
+ log.info("金蝶接口返回成功");
+ String trackingNumId = trackingNumERPRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id");
+ res.put("errorCode", "success");
+ res.put("message", "请求成功");
+ } else {
+ log.info("金蝶接口返回失败");
+ res.put("errorCode", "error");
+ res.put("message", "跟踪号新增或更新请求失败" + trackingNumERPRes.getString("message"));
+ return res;
+ }
+ return res;
+ }
+}
diff --git a/src/main/java/com/management/controller/InvoiceController.java b/src/main/java/com/management/controller/InvoiceController.java
new file mode 100644
index 0000000..708eabd
--- /dev/null
+++ b/src/main/java/com/management/controller/InvoiceController.java
@@ -0,0 +1,709 @@
+package com.management.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.management.constant.ERPURLConstant;
+import com.management.constant.URLConstant;
+import com.management.entity.Filter;
+import com.management.utils.CrmRequestUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+@RestController
+@RequestMapping("/api/invoice")
+@Slf4j
+public class InvoiceController {
+
+ private RestTemplate restTemplate = new RestTemplate();
+
+ public static void main(String[] args) {
+ new InvoiceController().syncInvoice();
+ //new InvoiceController().syncRedInvoice();
+ }
+
+ /**
+ * 发票同步
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping("/sync_invoice")
+ public void syncInvoice() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+
+ String[] syncStatus = {"option_pending_sync__c", "option_resync__c"};
+
+ JSONObject getInvoice = crmRequestUtil.getCRMList(Arrays.asList(
+ //new Filter("IS", "erp_id__c", Arrays.asList("")),
+ new Filter("IN", "sync_status__c", Arrays.asList(syncStatus)),
+ new Filter("EQ", "life_status", Arrays.asList("normal")),
+ //new Filter("EQ", "name", Arrays.asList("20250527-000010"))
+ new Filter("GT", "create_time", Arrays.asList("1748923200000"))
+ ), "InvoiceApplicationObj");
+
+ log.info("开始同步创建发票");
+
+ JSONObject invoiceRes = new JSONObject();
+
+ try {
+ invoiceRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getInvoice, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(invoiceRes.getString("errorDescription")) || invoiceRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("发票查询失败或者不存在");
+ return;
+ }
+
+ log.info("单据存在,继续向下执行");
+
+ for (Object invoiceObj : invoiceRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject invoiceData = JSON.parseObject(JSON.toJSONString(invoiceObj));
+
+ System.out.println("当前正在处理的发票为:" + invoiceData);
+
+ //开始截取关键数据
+ //发票CRMID
+ String invoiceId = invoiceData.getString("_id");
+ //发票名称
+ String invoiceName = invoiceData.getString("name");
+ //开票创建时间
+ //String createTime = invoiceData.getString("create_time");
+ String createTime = invoiceData.getString("last_modified_time");
+
+ //开始判断数据库中是否存在数据
+ JSONObject isLogRes = new JSONObject();
+
+ try {
+ isLogRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_invoice&log_type=KP&dataId=" + invoiceId + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!isLogRes.getJSONArray("data").isEmpty()) {
+ log.info("当前数据已经执行过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("日志不存在,将继续向下执行");
+
+ //开始封装请求
+ Map invoiceMap = new HashMap();
+
+ String invoiceType = invoiceData.getString("record_type") != null ? invoiceData.getString("record_type") : "";
+ invoiceMap.put("billsourcetype", "blue");
+ invoiceMap.put("crmbillno", invoiceName);//单据编号
+
+ invoiceMap.put("crmid", invoiceData.getString("sales1_contract__c"));//销售合同CRMID
+
+ //是否国网
+ String isGWStr = invoiceData.getString("is_state_grid__c") != null ? invoiceData.getString("is_state_grid__c") : "";
+ Boolean isGW = null;
+ switch (isGWStr) {
+ case "ubaL12a0M":
+ isGW = true;
+ break;
+ case "tiVjNIMLU":
+ isGW = false;
+ break;
+ default:
+ isGW = null;
+ break;
+ }
+
+ invoiceMap.put("isgw", isGW);//是否国网
+
+ //是否设计建筑服务
+ String isJZStr = invoiceData.getString("is_involved_construction_s__c") != null ? invoiceData.getString("is_involved_construction_s__c") : "";
+ Boolean isJZ = null;
+ switch (isJZStr) {
+ case "option_is_yes__c":
+ isJZ = true;
+ break;
+ case "option_is_no__c":
+ isJZ = false;
+ break;
+ default:
+ isJZ = null;
+ break;
+ }
+
+ invoiceMap.put("isjzfw", isJZ);//是否设计建筑服务
+
+ //是否跨地市
+ String isCityStr = invoiceData.getString("is_cross_city__c") != null ? invoiceData.getString("is_cross_city__c") : "";
+ Boolean isCity = null;
+ switch (isCityStr) {
+ case "option_is_yes__c":
+ isCity = true;
+ break;
+ case "option_is_no__c":
+ isCity = false;
+ break;
+ default:
+ isCity = null;
+ break;
+ }
+
+ invoiceMap.put("iskds", isCity);//是否跨地市
+
+ invoiceMap.put("jzaddr", invoiceData.getString("field_b11hY__c") != null ? invoiceData.getString("field_b11hY__c") : "");//建筑服务发生地
+ invoiceMap.put("jzpjname", invoiceData.getString("field_6cxEV__c") != null ? invoiceData.getString("field_6cxEV__c") : "");//建筑服务项目名称
+
+ invoiceMap.put("crminvoiceid", invoiceId);//crm开票申请ID
+
+ //开票类型
+ String invoiceKinds = invoiceData.getString("invoice_type") != null ? invoiceData.getString("invoice_type") : "";
+
+ invoiceMap.put("invoicetype", invoiceKinds);
+
+ invoiceMap.put("comment", invoiceData.getString("remark") != null ? invoiceData.getString("remark") : "");//发票备注
+ invoiceMap.put("buyeremail", invoiceData.getString("invoice_delivery_email__c") != null ? invoiceData.getString("invoice_delivery_email__c") : "2019326567@qq.com");//发票推送邮箱
+
+
+ //开票单位编码
+ String customerId = invoiceData.getString("invoice_unit__c") != null ? invoiceData.getString("invoice_unit__c") : "TEST0001";
+
+ //根据客户唯一id查询客户编码
+ JSONObject getCustomer = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", Arrays.asList(customerId))
+ ), "AccountObj");
+
+ JSONObject customerRes = new JSONObject();
+
+ try {
+ customerRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getCustomer, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(customerRes.getString("errorDescription")) || customerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("未找到开票单位或者查询失败");
+ continue;
+ }
+
+ JSONObject customerData = customerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ String customerNumber = customerData.getString("account_no");
+
+ invoiceMap.put("asstact_number", customerNumber);//往来户(客户)
+ invoiceMap.put("buyertaxno", invoiceData.getString("tax_id") != null ? invoiceData.getString("tax_id") : "");//纳税人识别号
+ //开票地址
+ String invoice_add = invoiceData.getString("invoice_add") != null ? invoiceData.getString("invoice_add") : "";
+ invoiceMap.put("buyeraddr", invoice_add);//购方地址
+ //电话
+ String invoice_phone = invoiceData.getString("invoice_tel") != null ? invoiceData.getString("invoice_tel") : "";
+
+ invoiceMap.put("buyerphone", invoice_phone);//购方电话
+
+ //开户行
+ String account_bank = invoiceData.getString("account_bank") != null ? invoiceData.getString("account_bank") : "";
+ invoiceMap.put("buyerbank", account_bank);
+ //开户账号
+ String account_bank_no = invoiceData.getString("account_bank_no") != null ? invoiceData.getString("account_bank_no") : "";
+ invoiceMap.put("buyerbanknumber", account_bank_no);
+
+ //是否展示地址电话
+ Boolean isShowTel = invoiceData.getBoolean("show_address_phone__c");
+ invoiceMap.put("showbuyeraddresstel", isShowTel);
+
+ //是否展示明细
+ Boolean isShowDetail = invoiceData.getBoolean("invoice_details_complete__c");
+ invoiceMap.put("showdetails", isShowDetail);
+
+ //是否展示开户行及账号
+ Boolean isShowBank = invoiceData.getBoolean("show_bank_account__c");
+ invoiceMap.put("showbuyerbank", isShowBank);
+
+ //是否含软
+ String isHasSoft = invoiceData.getString("is_contain_soft__c");
+ Boolean isHasSoftBool = false;
+
+ switch (isHasSoft) {
+ case "v2j71Ak5p":
+ isHasSoftBool = true;
+ break;
+ case "YOZj917km":
+ isHasSoftBool = false;
+ break;
+ }
+
+ invoiceMap.put("issoftworks", isHasSoftBool);
+
+ //软著版本编码
+ invoiceMap.put("softworks_number", invoiceData.getString("positive_number__c") != null ? invoiceData.getString("positive_number__c") : "");
+
+ //开始查询明细
+ JSONObject getInvoiceDetail = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "invoice_id", Arrays.asList(invoiceId))
+ ), "InvoiceApplicationLinesObj");
+
+ JSONObject invoiceDetailRes = new JSONObject();
+
+ try {
+ invoiceDetailRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getInvoiceDetail, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(invoiceDetailRes.getString("errorDescription")) || invoiceDetailRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("发票明细查询失败或者不存在");
+ continue;
+ }
+
+ log.info("发票明细查询成功,将继续向下执行");
+
+ List entry = new ArrayList<>();
+
+ for (Object invoiceDetailObj : invoiceDetailRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject invoiceDetailData = JSON.parseObject(JSON.toJSONString(invoiceDetailObj));
+
+ System.out.println("当前正在处理的明细为:" + invoiceDetailData);
+ Map entryMap = new HashMap();
+
+ if (invoiceType.equals("default__c")) {
+ //blue传销售合同明细id
+ entryMap.put("crmentryid", invoiceDetailData.getString("sales_contract_details__c"));
+ } else if (invoiceType.equals("record_3pGf2__c")) {
+ //red传开票申请单明细id
+ entryMap.put("crmentryid", invoiceDetailData.getString("_id"));
+ }
+
+ entryMap.put("crminvoiceentryid", invoiceDetailData.getString("_id"));//开票申请明细id
+ entryMap.put("goodsname", invoiceDetailData.getString("invoice_product_name__c") != null ? invoiceDetailData.getString("invoice_product_name__c") : "");//商品名称
+ //entryMap.put("softworks_number", invoiceDetailData.getString("invoice_product_num__c") != null ? invoiceDetailData.getString("invoice_product_num__c") : "");//软著编码
+ entryMap.put("taxratecodeid_number", invoiceDetailData.getString("product_category__c") != null ? invoiceDetailData.getString("product_category__c") : "");//税收分类
+ entryMap.put("quantity", invoiceDetailData.getBigDecimal("field_9C0j7__c") != null ? invoiceDetailData.getBigDecimal("field_9C0j7__c") : 0);//数量
+ entryMap.put("taxunitprice", invoiceDetailData.getBigDecimal("tax_inclusive_unit_price__c") != null ? invoiceDetailData.getBigDecimal("tax_inclusive_unit_price__c") : 0);//含税单价
+ entryMap.put("recamount", invoiceDetailData.getBigDecimal("invoiced_amount") != null ? invoiceDetailData.getBigDecimal("invoiced_amount") : 0);//应收金额-开票小计
+ entryMap.put("taxrateid_number", invoiceDetailData.getString("tax_rate_code__c") != null ? invoiceDetailData.getString("tax_rate_code__c") : "");//税率编码
+ entryMap.put("measureunit_number", invoiceDetailData.getString("unit__c") != null ? invoiceDetailData.getString("unit__c") : "");//计量单位
+ entryMap.put("specification", invoiceDetailData.getString("specification_model__c") != null ? invoiceDetailData.getString("specification_model__c") : "");//规格型号
+
+ entry.add(entryMap);
+ }
+
+ invoiceMap.put("entry", entry);
+
+ //开始获取token
+ String accessToken = new KDTokenController().getKDAccessTokenTest();
+
+ if (accessToken == null || accessToken.equals("")) {
+ log.info("金蝶token为空或不存在");
+ return;
+ }
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ //开始封装请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("accessToken", accessToken);
+ headers.set("Idempotency-Key", uuid);
+
+ HttpEntity invoiceReqEntity = new HttpEntity(invoiceMap, headers);
+
+ System.out.println(JSON.parseObject(JSON.toJSONString(invoiceReqEntity)));
+
+ String invoiceUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/ar/arbusbill/createInvoice";
+
+ JSONObject erpInvoiceRes = new JSONObject();
+
+ try {
+ erpInvoiceRes = restTemplate.postForObject(invoiceUrl, invoiceReqEntity, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println(erpInvoiceRes);
+
+ //开始封装回写程序
+ Map backReqMap = new HashMap();
+ backReqMap.put("_id", invoiceId);
+ backReqMap.put("dataObjectApiName", "InvoiceApplicationObj");
+
+ //开始封装日志
+ Map logMap = new HashMap<>();
+ logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
+ logMap.put("log_type", "KP");
+ logMap.put("syn_type", "0");
+ logMap.put("data_name", invoiceName);
+ logMap.put("data_id", invoiceId);
+ logMap.put("mark", createTime);
+ logMap.put("send_body", JSON.toJSONString(invoiceReqEntity));
+ logMap.put("send_res", JSON.toJSONString(erpInvoiceRes));
+ logMap.put("tableName", "send_log_invoice");
+
+ //判断是否执行成功
+ if ("0".equals(erpInvoiceRes.getString("errorCode"))) {
+ //同步成功
+ logMap.put("log_status", "0");
+ logMap.put("res_body", "同步成功");
+ backReqMap.put("erp_id__c", erpInvoiceRes.getJSONObject("data").getString("pkId"));
+ backReqMap.put("sync_status__c", "option_sync_success__c");
+ backReqMap.put("response_info__c", "同步成功");
+ } else {
+ //同步失败
+ logMap.put("log_status", "1");
+ logMap.put("res_body", "同步失败:" + erpInvoiceRes.getString("message"));
+ backReqMap.put("sync_status__c", "option_sync_failure__c");
+ backReqMap.put("response_info__c", erpInvoiceRes.getString("message"));
+ }
+
+ //开始回写
+ JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
+
+ JSONObject backRes = new JSONObject();
+
+ try {
+ backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, backReq, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("回写结果为:" + backRes);
+
+ //开始记录日志
+ JSONObject logRes = new JSONObject();
+ try {
+ logRes = restTemplate.postForObject("http://localhost:18085/Log/insert/log_data", logMap, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("日志插入结果为:" + logRes);
+
+ }
+ }
+
+
+ /**
+ * 红冲发票同步
+ *
+ * @return void
+ * @Author weiloong_zhang
+ */
+ @PostMapping
+ public void syncRedInvoice() {
+ CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
+
+ String[] syncStatus = {"option_pending_sync__c", "option_resync__c"};
+
+ JSONObject getRedInvoice = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("IN", "sync_status__c", Arrays.asList(syncStatus)),
+ //new Filter("IS", "field_UB1hE__c", Arrays.asList("")),
+ //new Filter("EQ", "name", Arrays.asList("HCFP2505-0003")),
+ new Filter("GT", "create_time", Arrays.asList("1748923200000")),
+ new Filter("EQ", "life_status", Arrays.asList("normal"))
+ ), "custom_object_example1__c");
+
+ JSONObject redInvoiceRes = new JSONObject();
+
+ try {
+ redInvoiceRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getRedInvoice, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(redInvoiceRes.getString("errorDescription")) || redInvoiceRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("未找到红冲发票或者查询失败");
+ return;
+ }
+
+ for (Object redInvoiceObj : redInvoiceRes.getJSONObject("data").getJSONArray("dataList")) {
+ JSONObject redInvoiceData = JSON.parseObject(JSON.toJSONString(redInvoiceObj));
+
+ System.out.println("当前正在处理数据为:" + redInvoiceData);
+
+ //开始截取关键数据
+ //唯一性编码
+ String redInvoiceId = redInvoiceData.getString("_id");
+ //红冲单号
+ String redInvoiceName = redInvoiceData.getString("name");
+ //红冲单创建时间
+ String createTime = redInvoiceData.getString("create_time");
+
+ JSONObject isLogRes = new JSONObject();
+
+ try {
+ isLogRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_invoice&log_type=REDKP&dataId=" + redInvoiceId + "&mark=" + createTime, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("查询日志结果为:" + isLogRes);
+
+ if (!isLogRes.getJSONArray("data").isEmpty()) {
+ log.info("当前数据已经执行过了,将不再向下执行");
+ continue;
+ }
+
+ log.info("日志不存在,将继续向下执行");
+
+ Map invoiceMap = new HashMap();
+ invoiceMap.put("billsourcetype", "red");//单据类型
+ invoiceMap.put("crmbillno", redInvoiceName);//单据编号
+ invoiceMap.put("crmid", redInvoiceData.getString("blue_invoice_application__c"));//红冲开票CRMID
+ invoiceMap.put("crminvoiceid", redInvoiceId);//CRM红冲开票申请ID
+ invoiceMap.put("invoicetype", redInvoiceData.getString("invoice_type__c") != null ? redInvoiceData.getString("invoice_type__c") : "");//开票类型
+ invoiceMap.put("comment", redInvoiceData.getString("invoice_note__c") != null ? redInvoiceData.getString("invoice_note__c") : "");//备注
+ invoiceMap.put("buyeremail", redInvoiceData.getString("invoice_delivery_email__c") != null ? redInvoiceData.getString("invoice_delivery_email__c") : "2019326567@qq.com");//发票推送邮箱
+
+ //开票单位编码
+ String customerId = redInvoiceData.getString("customer_name__c") != null ? redInvoiceData.getString("customer_name__c") : "TEST0001";
+
+ //根据客户唯一id查询客户编码
+ JSONObject getCustomer = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "_id", Arrays.asList(customerId))
+ ), "AccountObj");
+
+ JSONObject customerRes = new JSONObject();
+
+ try {
+ customerRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getCustomer, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(customerRes.getString("errorDescription")) || customerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("未找到开票单位或者查询失败");
+ continue;
+ }
+
+ JSONObject customerData = customerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
+
+ String customerNumber = customerData.getString("account_no");
+
+ invoiceMap.put("asstact_number", customerNumber);//往来户(客户)
+ invoiceMap.put("buyertaxno", redInvoiceData.getString("tax_identification_number__c") != null ? redInvoiceData.getString("tax_identification_number__c") : "");//纳税识别号
+ invoiceMap.put("buyeraddr", redInvoiceData.getString("invoice_address__c") != null ? redInvoiceData.getString("invoice_address__c") : "");//地址
+ invoiceMap.put("buyerphone", redInvoiceData.getString("field_SM1Wc__c") != null ? redInvoiceData.getString("field_SM1Wc__c") : "");//电话
+ invoiceMap.put("showbuyeraddresstel", redInvoiceData.getBooleanValue("show_address_phone__c"));//是否展示地址电话
+ invoiceMap.put("buyerbank", redInvoiceData.getString("bank_branch__c") != null ? redInvoiceData.getString("bank_branch__c") : "");//开户行
+ invoiceMap.put("buyerbanknumber", redInvoiceData.getString("account_number__c") != null ? redInvoiceData.getString("account_number__c") : "");//开户行账号
+ invoiceMap.put("showbuyerbank", redInvoiceData.getBooleanValue("show_bank_account__c"));//是否展示开户行
+ invoiceMap.put("showdetails", redInvoiceData.getBooleanValue("is_display_invoice_details__c"));//是否展示发票明细(名称、数量、单价、单位、规格)
+
+ String isSoftWorks = redInvoiceData.getString("is_contain_soft__c");
+ Boolean isSoftWorksFlag = false;
+ switch (isSoftWorks) {
+ case "v2j71Ak5p":
+ isSoftWorksFlag = true;
+ break;
+ case "YOZj917km":
+ isSoftWorksFlag = false;
+ break;
+ }
+ invoiceMap.put("issoftworks", isSoftWorksFlag);//是否含软
+
+ //是否国网
+ String isGWStr = redInvoiceData.getString("is_state_grid__c") != null ? redInvoiceData.getString("is_state_grid__c") : "";
+ Boolean isGW = null;
+ switch (isGWStr) {
+ case "ubaL12a0M":
+ isGW = true;
+ break;
+ case "tiVjNIMLU":
+ isGW = false;
+ break;
+ default:
+ isGW = null;
+ break;
+ }
+
+ invoiceMap.put("isgw", isGW);//是否国网
+
+ //是否设计建筑服务
+ String isJZStr = redInvoiceData.getString("is_involved_construction__c") != null ? redInvoiceData.getString("is_involved_construction__c") : "";
+ Boolean isJZ = null;
+ switch (isJZStr) {
+ case "option_is_yes__c":
+ isJZ = true;
+ break;
+ case "option_is_no__c":
+ isJZ = false;
+ break;
+ default:
+ isJZ = null;
+ break;
+ }
+
+ invoiceMap.put("isjzfw", isJZ);//是否设计建筑服务
+
+ //是否跨地市
+ String isCityStr = redInvoiceData.getString("is_cross_city__c") != null ? redInvoiceData.getString("is_cross_city__c") : "";
+ Boolean isCity = null;
+ switch (isCityStr) {
+ case "option_is_yes__c":
+ isCity = true;
+ break;
+ case "option_is_no__c":
+ isCity = false;
+ break;
+ default:
+ isCity = null;
+ break;
+ }
+
+ invoiceMap.put("iskds", isCity);//是否跨地市
+
+ invoiceMap.put("jzaddr", redInvoiceData.getString("service_occurrence_locatio__c") != null ? redInvoiceData.getString("service_occurrence_locatio__c") : "");//建筑服务发生地
+ invoiceMap.put("jzpjname", redInvoiceData.getString("project_name__c") != null ? redInvoiceData.getString("project_name__c") : "");//建筑服务项目名称
+
+ invoiceMap.put("softworks_number", redInvoiceData.getString("registration_number__c") != null ? redInvoiceData.getString("registration_number__c") : "");//软著版本编码
+ invoiceMap.put("blueinvoiceno", redInvoiceData.getString("original_invoice_number__c") != null ? redInvoiceData.getString("original_invoice_number__c") : "");//待冲蓝字发票号码
+ invoiceMap.put("redreason", redInvoiceData.getString("redemption_reason__c") != null ? redInvoiceData.getString("redemption_reason__c") : "");//冲红原因
+
+ //开始查询明细数据
+ JSONObject getInvoiceDetail = crmRequestUtil.getCRMList(Arrays.asList(
+ new Filter("EQ", "red_invoice_application__c", Arrays.asList(redInvoiceId))
+ ), "red_invoice_details__c");
+
+ JSONObject invoiceDetailRes = new JSONObject();
+
+ try {
+ invoiceDetailRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getInvoiceDetail, JSONObject.class);
+ } catch (RestClientException e) {
+ e.printStackTrace();
+ }
+
+ if (!"success".equals(invoiceDetailRes.getString("errorDescription")) || invoiceDetailRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
+ log.info("请求失败或数据不存在");
+ continue;
+ }
+
+ log.info("查询明细数据成功,继续向下执行和封装");
+
+ List