浩赛已迁移能传正式环境的方法和功能
This commit is contained in:
parent
6b92670afc
commit
719d42f177
@ -4,15 +4,18 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public enum ProductClassEnum {
|
public enum ProductClassEnum {
|
||||||
核算提取("1"),
|
核酸提取系列("1"),
|
||||||
PCR("2"),
|
PCR系列("2"),
|
||||||
克隆及电泳("3"),
|
克隆及电泳系列("3"),
|
||||||
免疫学("4"),
|
免疫学("4"),
|
||||||
细胞生物学("5"),
|
细胞生物学("5"),
|
||||||
小分子化学物("6"),
|
小分子化学物("6"),
|
||||||
耗材("7"),
|
耗材("7"),
|
||||||
仪器设备("8"),
|
仪器设备("8"),
|
||||||
医疗器械("9");
|
医疗器械("9"),
|
||||||
|
WG实验服务("10"),
|
||||||
|
实验服务("11"),
|
||||||
|
Thermo赛默飞("12");
|
||||||
|
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
@ -79,6 +79,72 @@ public class CustomerController {
|
|||||||
String customerName = customerData.getString("name");
|
String customerName = customerData.getString("name");
|
||||||
String modifyTime = customerData.getString("last_modified_time");
|
String modifyTime = customerData.getString("last_modified_time");
|
||||||
|
|
||||||
|
//根据客户名称查询ERP中是否已经存在重名数据
|
||||||
|
Map getYSCustomerMap = new HashMap();
|
||||||
|
getYSCustomerMap.put("name", customerName);
|
||||||
|
getYSCustomerMap.put("pageSize", 10);
|
||||||
|
getYSCustomerMap.put("pageIndex", 1);
|
||||||
|
|
||||||
|
//开始获取token
|
||||||
|
String ysToken = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
ysToken = new YSSignUtils().getYSToken();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
String getCustomerByNameURL = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/merchant/newlist?access_token=" + ysToken;
|
||||||
|
|
||||||
|
JSONObject erpCustomerRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
erpCustomerRes = restTemplate.postForObject(getCustomerByNameURL, getYSCustomerMap, JSONObject.class);
|
||||||
|
} catch (HttpStatusCodeException e) {
|
||||||
|
// 获取响应体的错误信息
|
||||||
|
String errorBody = e.getResponseBodyAsString();
|
||||||
|
System.out.println("调用接口失败,状态码:" + e.getStatusCode());
|
||||||
|
System.out.println("错误响应:" + errorBody);
|
||||||
|
|
||||||
|
// 将错误响应封装为 JSONObject(可选)
|
||||||
|
erpCustomerRes = JSONObject.parseObject(errorBody);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
System.out.println("调用接口失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("200".equals(erpCustomerRes.getString("code")) && !erpCustomerRes.getJSONArray("data").isEmpty()) {
|
||||||
|
log.info("ERP中已经存在重名数据,将不再继续向下执行");
|
||||||
|
|
||||||
|
JSONObject erpCustomerData = erpCustomerRes.getJSONArray("data").getJSONObject(0);
|
||||||
|
|
||||||
|
String erpCustomerId = erpCustomerData.getString("id");
|
||||||
|
|
||||||
|
String erpCustomerCode = erpCustomerData.getString("code");
|
||||||
|
|
||||||
|
//开始封装回写数据
|
||||||
|
Map backReqMap = new HashMap();
|
||||||
|
backReqMap.put("_id", customerId);
|
||||||
|
backReqMap.put("dataObjectApiName", "AccountObj");
|
||||||
|
backReqMap.put("customer_code__c", erpCustomerCode);
|
||||||
|
backReqMap.put("ERP_ID__c", erpCustomerId);
|
||||||
|
backReqMap.put("response_status__c", "同步成功");
|
||||||
|
backReqMap.put("sync_status__c", "option_sync_success__c");
|
||||||
|
|
||||||
|
JSONObject updateCustomerReq = crmRequestUtil.updateCRM(backReqMap);
|
||||||
|
|
||||||
|
JSONObject updateCustomerRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
updateCustomerRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_MAIN, updateCustomerReq, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("客户更新状态为:" + updateCustomerRes);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//开始判断是否存在当前数据
|
//开始判断是否存在当前数据
|
||||||
JSONObject isLogRes = new JSONObject();
|
JSONObject isLogRes = new JSONObject();
|
||||||
|
|
||||||
@ -93,7 +159,6 @@ public class CustomerController {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("日志不存在,将继续向下执行");
|
|
||||||
log.info("日志不存在,将继续向下执行");
|
log.info("日志不存在,将继续向下执行");
|
||||||
|
|
||||||
//开始封装和处理数据
|
//开始封装和处理数据
|
||||||
@ -123,20 +188,23 @@ public class CustomerController {
|
|||||||
//营销伙伴-默认 是
|
//营销伙伴-默认 是
|
||||||
customerReq.put("merchantRole.merchantOptions", true);
|
customerReq.put("merchantRole.merchantOptions", true);
|
||||||
//管理组织
|
//管理组织
|
||||||
String orgCode = customerData.getString("management_organization__c") != null ? customerData.getString("management_organization__c") : "";
|
// String orgCode = customerData.getString("management_organization__c") != null ? customerData.getString("management_organization__c") : "";
|
||||||
|
//
|
||||||
|
// if (orgCode.equals("")) {
|
||||||
|
// log.info("管理组织为空,将不再继续向下执行");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
if (orgCode.equals("")) {
|
customerReq.put("createOrgCode", "HSJT");
|
||||||
log.info("管理组织为空,将不再继续向下执行");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
customerReq.put("createOrgCode", orgCode);
|
|
||||||
//客户编码
|
//客户编码
|
||||||
customerReq.put("code", customerData.getString("account_no"));
|
customerReq.put("code", customerData.getString("account_no"));
|
||||||
//客户名称
|
//客户名称
|
||||||
customerReq.put("name", Maps.of("simplifiedName", customerName));
|
Map simplifiedName = new HashMap<>();
|
||||||
|
simplifiedName.put("simplifiedName", customerName);
|
||||||
|
|
||||||
|
customerReq.put("name", simplifiedName);
|
||||||
//客户简称
|
//客户简称
|
||||||
customerReq.put("shortname", Maps.of("simplifiedName", customerData.getString("client_short_name__c") != null ? customerData.getString("client_short_name__c") : customerName));
|
customerReq.put("shortname", simplifiedName);
|
||||||
//地址信息
|
//地址信息
|
||||||
//截取CRM中的详细地址
|
//截取CRM中的详细地址
|
||||||
String province = customerData.getString("province") != null ? customerData.getString("province") : "";
|
String province = customerData.getString("province") != null ? customerData.getString("province") : "";
|
||||||
@ -146,30 +214,46 @@ public class CustomerController {
|
|||||||
|
|
||||||
String addressStr = province + city + district + address;
|
String addressStr = province + city + district + address;
|
||||||
|
|
||||||
customerReq.put("address", Maps.of("simplifiedName", addressStr));
|
Map addressMap = new HashMap<>();
|
||||||
|
addressMap.put("address", addressStr);
|
||||||
|
addressMap.put("addressCode", customerData.getString("postal_code__c") != null ? customerData.getString("postal_code__c") : "250000");
|
||||||
|
addressMap.put("isDefault", true);
|
||||||
|
|
||||||
|
customerReq.put("merchantAddressInfos", Arrays.asList(addressMap));
|
||||||
|
|
||||||
|
//联系人信息
|
||||||
|
Map merchantContactInfos = new HashMap<>();
|
||||||
|
|
||||||
|
Map fullName = new HashMap<>();
|
||||||
|
fullName.put("simplifiedName", customerName);
|
||||||
|
|
||||||
|
merchantContactInfos.put("fullName", fullName);
|
||||||
|
merchantContactInfos.put("isDefault", true);
|
||||||
|
merchantContactInfos.put("mobile", customerData.getString("tel") != null ? customerData.getString("tel") : "");
|
||||||
|
merchantContactInfos.put("areaCodeMobile", "+86-" + customerData.getString("tel") != null ? customerData.getString("tel") : "");
|
||||||
|
merchantContactInfos.put("email", customerData.getString("email") != null ? customerData.getString("email") : "");
|
||||||
|
|
||||||
|
customerReq.put("merchantContactInfos", Arrays.asList(merchantContactInfos));
|
||||||
|
|
||||||
//发票信息
|
//发票信息
|
||||||
Map invoiceMap = new HashMap<>();
|
Map invoiceMap = new HashMap<>();
|
||||||
invoiceMap.put("title", "11233221121");//发票抬头
|
invoiceMap.put("title", "11233221121");//发票抬头
|
||||||
invoiceMap.put("taxNo", "");//发票信息
|
invoiceMap.put("taxNo", "");//发票信息
|
||||||
invoiceMap.put("address", "");//发票地址
|
|
||||||
|
Map invoiceAddress = new HashMap<>();
|
||||||
|
invoiceAddress.put("simplifiedName", "");
|
||||||
|
|
||||||
|
invoiceMap.put("address", invoiceAddress);//发票地址
|
||||||
invoiceMap.put("bankName_Name", "");//银行网点
|
invoiceMap.put("bankName_Name", "");//银行网点
|
||||||
invoiceMap.put("bankAccount", "");//银行账号
|
invoiceMap.put("bankAccount", "");//银行账号
|
||||||
invoiceMap.put("isDefault", true);//默认
|
invoiceMap.put("isDefault", true);//默认
|
||||||
|
|
||||||
customerReq.put("invoice", invoiceMap);
|
customerReq.put("merchantAgentInvoiceInfos", Arrays.asList(invoiceMap));
|
||||||
|
|
||||||
Map customerMap = new HashMap<>();
|
Map customerMap = new HashMap<>();
|
||||||
customerMap.put("data", Arrays.asList(customerReq));
|
customerMap.put("data", Arrays.asList(customerReq));
|
||||||
|
|
||||||
//开始获取token
|
System.out.println(JSON.parse(JSON.toJSONString(customerMap)));
|
||||||
String ysToken = "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
ysToken = new YSSignUtils().getYSToken();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//开始封装请求url
|
//开始封装请求url
|
||||||
String url = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/merchant/integration/newbatchsave?access_token=" + ysToken;
|
String url = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/merchant/integration/newbatchsave?access_token=" + ysToken;
|
||||||
@ -210,7 +294,7 @@ public class CustomerController {
|
|||||||
logMap.put("tableName", "send_log_khxx");
|
logMap.put("tableName", "send_log_khxx");
|
||||||
|
|
||||||
//判断是否执行成功
|
//判断是否执行成功
|
||||||
if ("200".equals(customerYSRes.getString("code"))) {
|
if ("200".equals(customerYSRes.getString("code")) && customerYSRes.getJSONArray("data").getJSONObject(0).getInteger("successCount") > 0) {
|
||||||
log.info("同步成功");
|
log.info("同步成功");
|
||||||
logMap.put("log_status", "0");
|
logMap.put("log_status", "0");
|
||||||
logMap.put("res_body", "同步成功");
|
logMap.put("res_body", "同步成功");
|
||||||
@ -225,6 +309,7 @@ public class CustomerController {
|
|||||||
logMap.put("log_status", "1");
|
logMap.put("log_status", "1");
|
||||||
logMap.put("res_body", "同步失败:" + customerYSRes.getString("message") != null ? customerYSRes.getString("message") : "同步失败,未知原因");
|
logMap.put("res_body", "同步失败:" + customerYSRes.getString("message") != null ? customerYSRes.getString("message") : "同步失败,未知原因");
|
||||||
backReqMap.put("sync_status__c", "option_sync_failed__c");
|
backReqMap.put("sync_status__c", "option_sync_failed__c");
|
||||||
|
|
||||||
backReqMap.put("response_status__c", customerYSRes.getString("message") != null ? customerYSRes.getString("message") : "同步失败,未知原因");
|
backReqMap.put("response_status__c", customerYSRes.getString("message") != null ? customerYSRes.getString("message") : "同步失败,未知原因");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,6 +398,73 @@ public class CustomerController {
|
|||||||
String customerId = customerData.getString("_id");
|
String customerId = customerData.getString("_id");
|
||||||
String customerName = customerData.getString("name");
|
String customerName = customerData.getString("name");
|
||||||
String modifyTime = customerData.getString("last_modified_time");
|
String modifyTime = customerData.getString("last_modified_time");
|
||||||
|
String customerCode = customerData.getString("contact_id__c");
|
||||||
|
|
||||||
|
//根据客户名称查询ERP中是否已经存在重名数据
|
||||||
|
Map getYSCustomerMap = new HashMap();
|
||||||
|
getYSCustomerMap.put("name", customerName);
|
||||||
|
getYSCustomerMap.put("pageSize", 10);
|
||||||
|
getYSCustomerMap.put("pageIndex", 1);
|
||||||
|
|
||||||
|
//开始获取token
|
||||||
|
String ysToken = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
ysToken = new YSSignUtils().getYSToken();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
String getCustomerByNameURL = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/merchant/newlist?access_token=" + ysToken;
|
||||||
|
|
||||||
|
JSONObject erpCustomerRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
erpCustomerRes = restTemplate.postForObject(getCustomerByNameURL, getYSCustomerMap, JSONObject.class);
|
||||||
|
} catch (HttpStatusCodeException e) {
|
||||||
|
// 获取响应体的错误信息
|
||||||
|
String errorBody = e.getResponseBodyAsString();
|
||||||
|
System.out.println("调用接口失败,状态码:" + e.getStatusCode());
|
||||||
|
System.out.println("错误响应:" + errorBody);
|
||||||
|
|
||||||
|
// 将错误响应封装为 JSONObject(可选)
|
||||||
|
erpCustomerRes = JSONObject.parseObject(errorBody);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
System.out.println("调用接口失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("200".equals(erpCustomerRes.getString("code")) && !erpCustomerRes.getJSONArray("data").isEmpty()) {
|
||||||
|
log.info("ERP中已经存在重名数据,将不再继续向下执行");
|
||||||
|
|
||||||
|
JSONObject erpCustomerData = erpCustomerRes.getJSONArray("data").getJSONObject(0);
|
||||||
|
|
||||||
|
String erpCustomerId = erpCustomerData.getString("id");
|
||||||
|
|
||||||
|
String erpCustomerCode = erpCustomerData.getString("code");
|
||||||
|
|
||||||
|
//开始封装回写数据
|
||||||
|
Map backReqMap = new HashMap();
|
||||||
|
backReqMap.put("_id", customerId);
|
||||||
|
backReqMap.put("dataObjectApiName", "ContactObj");
|
||||||
|
backReqMap.put("contact_code__c", erpCustomerCode);
|
||||||
|
backReqMap.put("erp_id__c", erpCustomerId);
|
||||||
|
backReqMap.put("response_status__c", "同步成功");
|
||||||
|
backReqMap.put("sync_status__c", "option_sync_success__c");
|
||||||
|
|
||||||
|
JSONObject updateCustomerReq = crmRequestUtil.updateCRM(backReqMap);
|
||||||
|
|
||||||
|
JSONObject updateCustomerRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
updateCustomerRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_MAIN, updateCustomerReq, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("客户更新状态为:" + updateCustomerRes);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//开始查询当前数据是否已经同步过
|
//开始查询当前数据是否已经同步过
|
||||||
JSONObject isLogRes = new JSONObject();
|
JSONObject isLogRes = new JSONObject();
|
||||||
@ -332,8 +484,8 @@ public class CustomerController {
|
|||||||
|
|
||||||
//开始封装数据
|
//开始封装数据
|
||||||
Map contactMap = new HashMap<>();
|
Map contactMap = new HashMap<>();
|
||||||
|
contactMap.put("sourceUnique", customerCode);
|
||||||
contactMap.put("enterpriseNature", 0);
|
contactMap.put("enterpriseNature", 0);
|
||||||
contactMap.put("sourceUnique", customerData.getString("contact_id__c"));
|
|
||||||
contactMap.put("transTypeCode", "SYCSR001");//客户类型-通用
|
contactMap.put("transTypeCode", "SYCSR001");//客户类型-通用
|
||||||
|
|
||||||
//开始获取客户分类
|
//开始获取客户分类
|
||||||
@ -347,8 +499,8 @@ public class CustomerController {
|
|||||||
//枚举类获取客户分类编码
|
//枚举类获取客户分类编码
|
||||||
String customerCategoryName = AccountCategoryEnum.getValueByName(contactCategory);
|
String customerCategoryName = AccountCategoryEnum.getValueByName(contactCategory);
|
||||||
|
|
||||||
contactMap.put("customerClass_Name", customerCategoryName);//客户分类
|
contactMap.put("customerClass_Name", "KH09");//客户分类
|
||||||
contactMap.put("customerClassCode", customerCategoryName);//客户分类
|
contactMap.put("customerClassCode", "KH09");//客户分类
|
||||||
|
|
||||||
//纳税类别
|
//纳税类别
|
||||||
contactMap.put("taxPayingCategories", 0);
|
contactMap.put("taxPayingCategories", 0);
|
||||||
@ -358,13 +510,17 @@ public class CustomerController {
|
|||||||
contactMap.put("merchantRole.merchantOptions", true);
|
contactMap.put("merchantRole.merchantOptions", true);
|
||||||
|
|
||||||
//管理组织
|
//管理组织
|
||||||
contactMap.put("createOrgCode", customerData.getString("management_organization__c") != null ? customerData.getString("management_organization__c") : "");
|
contactMap.put("createOrgCode", "HSJT");
|
||||||
//客户编码
|
//客户编码
|
||||||
contactMap.put("code", customerData.getString("contact_id__c"));
|
contactMap.put("code", customerCode);
|
||||||
//客户名称
|
//客户名称
|
||||||
contactMap.put("name", customerData.getString("name"));
|
Map nameMap = new HashMap<>();
|
||||||
|
nameMap.put("simplifiedName", customerData.getString("name"));
|
||||||
|
contactMap.put("name", nameMap);
|
||||||
//客户简称
|
//客户简称
|
||||||
contactMap.put("shortname", customerData.getString("name"));
|
Map shortnameMap = new HashMap<>();
|
||||||
|
shortnameMap.put("simplifiedName", customerData.getString("name"));
|
||||||
|
contactMap.put("shortname", shortnameMap);
|
||||||
//上级客户
|
//上级客户
|
||||||
contactMap.put("parentCustomerCode", customerData.getString("parent_customer_code__c") != null ? customerData.getString("parent_customer_code__c") : "");
|
contactMap.put("parentCustomerCode", customerData.getString("parent_customer_code__c") != null ? customerData.getString("parent_customer_code__c") : "");
|
||||||
//todo 专营业务员(还没有集成)
|
//todo 专营业务员(还没有集成)
|
||||||
@ -388,80 +544,62 @@ public class CustomerController {
|
|||||||
|
|
||||||
if ("success".equals(salesManRes.getString("errorDescription")) && !salesManRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if ("success".equals(salesManRes.getString("errorDescription")) && !salesManRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
JSONObject salesManData = salesManRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
JSONObject salesManData = salesManRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||||
salesManId = salesManData.getString("erp_code__c") != null ? salesManData.getString("erp_code__c") : "";
|
salesManId = salesManData.getString("erp_id__c") != null ? salesManData.getString("erp_id__c") : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map saleManMap = new HashMap<>();
|
||||||
|
saleManMap.put("professSalesmanId", salesManId);
|
||||||
|
saleManMap.put("isDefault", true);
|
||||||
|
|
||||||
//专管业务员
|
//专管业务员
|
||||||
contactMap.put("professSalesmanCode", salesManId);
|
contactMap.put("principals", Arrays.asList(saleManMap));
|
||||||
|
|
||||||
//todo 科室名(暂未集成)
|
//科室名
|
||||||
String departmentName = customerData.getString("institute_department__c") != null ? customerData.getString("institute_department__c") : "";
|
Map merchantCharacter = new HashMap<>();
|
||||||
|
|
||||||
JSONObject getDepartment = crmRequestUtil.getCRMList(Arrays.asList(
|
String departmentId = customerData.getString("department_institution_erp__c") != null ? customerData.getString("department_institution_erp__c") : "";
|
||||||
new Filter("EQ", "_id", Arrays.asList(departmentName))
|
|
||||||
), "department_institute__c");
|
|
||||||
|
|
||||||
JSONObject departmentRes = new JSONObject();
|
|
||||||
|
|
||||||
try {
|
|
||||||
departmentRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getDepartment, JSONObject.class);
|
|
||||||
} catch (RestClientException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
String departmentCode = "";
|
|
||||||
|
|
||||||
if ("success".equals(departmentRes.getString("errorDescription")) && !departmentRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
|
||||||
JSONObject departmentData = departmentRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
|
||||||
departmentCode = departmentData.getString("erp_code__c") != null ? departmentData.getString("erp_code__c") : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//科室
|
//科室
|
||||||
contactMap.put("merchantCharacter__Y005", departmentCode);
|
merchantCharacter.put("KSYS01", departmentId);
|
||||||
//课题组
|
//课题组
|
||||||
String projectGroupName = customerData.getString("research_group_name__c") != null ? customerData.getString("research_group_name__c") : "";
|
String projectGroupId = customerData.getString("topic_group_erpid__c") != null ? customerData.getString("topic_group_erpid__c") : "";
|
||||||
|
|
||||||
JSONObject getProjectGroup = crmRequestUtil.getCRMList(Arrays.asList(
|
|
||||||
new Filter("EQ", "_id", Arrays.asList(projectGroupName))
|
|
||||||
), "topic_group__c");
|
|
||||||
|
|
||||||
JSONObject projectGroupRes = new JSONObject();
|
|
||||||
|
|
||||||
try {
|
|
||||||
projectGroupRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getProjectGroup, JSONObject.class);
|
|
||||||
} catch (RestClientException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
String projectGroupCode = "";
|
|
||||||
|
|
||||||
if ("success".equals(projectGroupRes.getString("errorDescription")) && !projectGroupRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
|
||||||
JSONObject projectGroupData = projectGroupRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
|
||||||
projectGroupCode = projectGroupData.getString("erp_code__c") != null ? projectGroupData.getString("erp_code__c") : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//课题组
|
//课题组
|
||||||
contactMap.put("merchantCharacter__K0003", projectGroupCode);
|
merchantCharacter.put("KTZ001", projectGroupId);
|
||||||
|
|
||||||
|
contactMap.put("merchantCharacter", merchantCharacter);
|
||||||
//联系人信息
|
//联系人信息
|
||||||
|
Map merchantContactInfos = new HashMap<>();
|
||||||
|
|
||||||
Map fullName = new HashMap<>();
|
Map fullName = new HashMap<>();
|
||||||
fullName.put("simplifiedName", customerName);
|
fullName.put("simplifiedName", customerName);
|
||||||
contactMap.put("fullName", fullName);
|
|
||||||
contactMap.put("mobile", customerData.getString("mobile1") != null ? customerData.getString("mobile1") : "");
|
merchantContactInfos.put("fullName", fullName);
|
||||||
|
merchantContactInfos.put("isDefault", true);
|
||||||
|
merchantContactInfos.put("areaCodeMobile", "+86-" + customerData.getString("mobile1") != null ? customerData.getString("mobile1") : "");
|
||||||
|
merchantContactInfos.put("mobile", customerData.getString("mobile1") != null ? customerData.getString("mobile1") : "");
|
||||||
|
|
||||||
|
contactMap.put("merchantContactInfos", Arrays.asList(merchantContactInfos));
|
||||||
|
//发票信息
|
||||||
|
Map invoiceMap = new HashMap<>();
|
||||||
|
invoiceMap.put("title", "11233221121");//发票抬头
|
||||||
|
invoiceMap.put("taxNo", "");//发票信息
|
||||||
|
|
||||||
|
Map invoiceAddress = new HashMap<>();
|
||||||
|
invoiceAddress.put("simplifiedName", "");//发票地址
|
||||||
|
|
||||||
|
invoiceMap.put("address", invoiceAddress);
|
||||||
|
invoiceMap.put("bankName", "");//银行网点
|
||||||
|
invoiceMap.put("bankAccount", "");//银行账号
|
||||||
|
invoiceMap.put("isDefault", true);//默认
|
||||||
|
|
||||||
|
contactMap.put("merchantAgentInvoiceInfos", Arrays.asList(invoiceMap));
|
||||||
|
|
||||||
Map customerMap = new HashMap<>();
|
Map customerMap = new HashMap<>();
|
||||||
customerMap.put("data", Arrays.asList(contactMap));
|
customerMap.put("data", Arrays.asList(contactMap));
|
||||||
|
|
||||||
System.out.println(JSON.parseObject(JSON.toJSONString(customerMap)));
|
System.out.println(JSON.parseObject(JSON.toJSONString(customerMap)));
|
||||||
|
|
||||||
//开始获取token
|
|
||||||
String ysToken = "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
ysToken = new YSSignUtils().getYSToken();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//开始封装请求url
|
//开始封装请求url
|
||||||
String url = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/merchant/integration/newbatchsave?access_token=" + ysToken;
|
String url = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/merchant/integration/newbatchsave?access_token=" + ysToken;
|
||||||
|
|
||||||
|
@ -14,10 +14,7 @@ import org.ssssssss.magicboot.entity.Filter;
|
|||||||
import org.ssssssss.magicboot.utils.CrmRequestUtil;
|
import org.ssssssss.magicboot.utils.CrmRequestUtil;
|
||||||
import org.ssssssss.magicboot.utils.YSSignUtils;
|
import org.ssssssss.magicboot.utils.YSSignUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门
|
* 部门
|
||||||
@ -51,12 +48,12 @@ public class DeptController {
|
|||||||
log.info("开始同步部门");
|
log.info("开始同步部门");
|
||||||
|
|
||||||
Map getDeptReq = new HashMap();
|
Map getDeptReq = new HashMap();
|
||||||
getDeptReq.put("parentId", "2132046702701969413");
|
getDeptReq.put("parentId", "2163138383273525256");
|
||||||
getDeptReq.put("pageSize", 100);
|
getDeptReq.put("pageSize", 100);
|
||||||
getDeptReq.put("pageIndex", 1);
|
getDeptReq.put("pageIndex", 1);
|
||||||
getDeptReq.put("externalOrg", 0);
|
getDeptReq.put("externalOrg", 0);
|
||||||
getDeptReq.put("sourceType", 1);
|
getDeptReq.put("sourceType", 1);
|
||||||
getDeptReq.put("codes", Arrays.asList("SKJ-BM04"));
|
getDeptReq.put("codes", Arrays.asList("SKJ-BM12.03"));
|
||||||
getDeptReq.put("dr", 0);
|
getDeptReq.put("dr", 0);
|
||||||
getDeptReq.put("funcTypeCode", "orgunit");
|
getDeptReq.put("funcTypeCode", "orgunit");
|
||||||
|
|
||||||
@ -130,7 +127,7 @@ public class DeptController {
|
|||||||
//开始封装请求
|
//开始封装请求
|
||||||
Map deptMapReq = new HashMap<>();
|
Map deptMapReq = new HashMap<>();
|
||||||
//部门编码
|
//部门编码
|
||||||
deptMapReq.put("dept_code", deptData.getString("code"));
|
deptMapReq.put("dept_code", deptData.getString("code").replace("SKJ-", ""));
|
||||||
//部门名称
|
//部门名称
|
||||||
deptMapReq.put("name", deptData.getString("name"));
|
deptMapReq.put("name", deptData.getString("name"));
|
||||||
//部门简称
|
//部门简称
|
||||||
@ -144,9 +141,15 @@ public class DeptController {
|
|||||||
//获取当前处理单据地等级
|
//获取当前处理单据地等级
|
||||||
String pid = "999999";
|
String pid = "999999";
|
||||||
String parentId = "";
|
String parentId = "";
|
||||||
|
String departmentOwner = "";
|
||||||
|
|
||||||
|
if ("2163138383273525256".equals(deptId)){
|
||||||
|
log.info("当前处理部门为最上级部门");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//判断级别,如果是2,则是思科捷最上级,如果不是2则是下级
|
//判断级别,如果是2,则是思科捷最上级,如果不是2则是下级
|
||||||
if (!deptId.equals("2132046702701969413")) {
|
if (!deptId.equals("2163138383273525256")) {
|
||||||
//级别小于2,则获取上级部门
|
//级别小于2,则获取上级部门
|
||||||
//需要获取一下详情以拿到上级部门ID
|
//需要获取一下详情以拿到上级部门ID
|
||||||
JSONObject getDeptSuperior = new JSONObject();
|
JSONObject getDeptSuperior = new JSONObject();
|
||||||
@ -176,6 +179,11 @@ public class DeptController {
|
|||||||
|
|
||||||
parentId = getDeptSuperior.getJSONObject("data").getString("parent");
|
parentId = getDeptSuperior.getJSONObject("data").getString("parent");
|
||||||
|
|
||||||
|
departmentOwner = getDeptSuperior.getJSONObject("data").getString("principal_name");
|
||||||
|
|
||||||
|
if (parentId.equals("2163138383273525256")) {
|
||||||
|
pid = "999999";
|
||||||
|
} else {
|
||||||
JSONObject getPid = crmRequestUtil.getCRMList(Arrays.asList(
|
JSONObject getPid = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
new Filter("EQ", "erp_id__c", Arrays.asList(parentId)),
|
new Filter("EQ", "erp_id__c", Arrays.asList(parentId)),
|
||||||
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
@ -195,14 +203,42 @@ public class DeptController {
|
|||||||
}
|
}
|
||||||
pid = getPidRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("_id");
|
pid = getPidRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("_id");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deptMapReq.put("parent_id", Arrays.asList(pid));
|
deptMapReq.put("parent_id", Arrays.asList(pid));
|
||||||
deptMapReq.put("field_1aF2M__c", parentId);
|
deptMapReq.put("field_1aF2M__c", parentId);
|
||||||
|
|
||||||
|
//开始查询部门负责人
|
||||||
|
JSONObject getOwner = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
|
new Filter("EQ", "name", Arrays.asList(departmentOwner)),
|
||||||
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
|
), "PersonnelObj");
|
||||||
|
|
||||||
|
JSONObject getOwnerRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
getOwnerRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getOwner, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
List ownerList = new ArrayList();
|
||||||
|
|
||||||
|
if ("success".equals(getOwnerRes.getString("errorDescription")) && !getOwnerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
|
JSONObject ownerData = getOwnerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||||
|
|
||||||
|
String ownerUserId = ownerData.getString("user_id");
|
||||||
|
|
||||||
|
ownerList = Arrays.asList(ownerUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
deptMapReq.put("manager_id", ownerList);
|
||||||
|
|
||||||
deptMapReq.put("dataObjectApiName", "DepartmentObj");
|
deptMapReq.put("dataObjectApiName", "DepartmentObj");
|
||||||
|
|
||||||
//开始查询是否已经存在重名部门
|
//开始查询是否已经存在重名部门
|
||||||
JSONObject getDept = crmRequestUtil.getCRMList(Arrays.asList(
|
JSONObject getDept = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
new Filter("EQ", "name", Arrays.asList(deptName)),
|
new Filter("EQ", "erp_id__c", Arrays.asList(deptId)),
|
||||||
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
), "DepartmentObj");
|
), "DepartmentObj");
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ public class InstituteController {
|
|||||||
|
|
||||||
//开始封装数据
|
//开始封装数据
|
||||||
Map institute = new HashMap<>();
|
Map institute = new HashMap<>();
|
||||||
institute.put("sourceUnique", "2267063578082148361");
|
institute.put("sourceUnique", "2173701348530847754");
|
||||||
institute.put("custdocdefid", "2157208682701520904");
|
institute.put("custdocdefid", "2163884255875694593");
|
||||||
institute.put("code", instituteData.getString("department_institution_id__c"));
|
institute.put("code", instituteData.getString("department_institution_id__c"));
|
||||||
|
|
||||||
//名称
|
//名称
|
||||||
@ -138,6 +138,8 @@ public class InstituteController {
|
|||||||
request.put("unmatchedStrategy", "add");
|
request.put("unmatchedStrategy", "add");
|
||||||
request.put("data", Arrays.asList(institute));
|
request.put("data", Arrays.asList(institute));
|
||||||
|
|
||||||
|
System.out.println(JSON.parseObject(JSON.toJSONString(request)));
|
||||||
|
|
||||||
//开始获取token
|
//开始获取token
|
||||||
String ysToken = "";
|
String ysToken = "";
|
||||||
|
|
||||||
@ -186,13 +188,54 @@ public class InstituteController {
|
|||||||
logMap.put("tableName", "send_log_khxx");
|
logMap.put("tableName", "send_log_khxx");
|
||||||
|
|
||||||
//判断是否执行成功
|
//判断是否执行成功
|
||||||
if ("200".equals(instituteYSRes.getString("code"))) {
|
if ("200".equals(instituteYSRes.getString("code")) && instituteYSRes.getJSONObject("data").getInteger("successCount") > 0) {
|
||||||
log.info("同步成功");
|
log.info("同步成功");
|
||||||
logMap.put("log_status", "0");
|
logMap.put("log_status", "0");
|
||||||
logMap.put("res_body", "同步成功");
|
logMap.put("res_body", "同步成功");
|
||||||
|
|
||||||
//获取ERPID
|
//获取ERPID
|
||||||
JSONObject erpMap = instituteYSRes.getJSONObject("data").getJSONArray("infos").getJSONObject(0);
|
JSONObject erpMap = instituteYSRes.getJSONObject("data").getJSONArray("infos").getJSONObject(0);
|
||||||
|
|
||||||
|
//获取ERPID
|
||||||
|
String erpId = erpMap.getString("id");
|
||||||
|
|
||||||
|
//根据erpId查询erp编码
|
||||||
|
Map erpCodeMap = new HashMap<>();
|
||||||
|
erpCodeMap.put("ids", Arrays.asList(erpId));
|
||||||
|
erpCodeMap.put("custdocdefid", "2163884255875694593");
|
||||||
|
erpCodeMap.put("pageIndex", 1);
|
||||||
|
erpCodeMap.put("pageSize", 10);
|
||||||
|
|
||||||
|
System.out.println(JSON.parse(JSON.toJSONString(erpCodeMap)));
|
||||||
|
|
||||||
|
//开始发起请求
|
||||||
|
String getCodeUrl = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/customerdoc/batchQueryDetail?access_token=" + ysToken;
|
||||||
|
|
||||||
|
JSONObject erpCodeRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
erpCodeRes = restTemplate.postForObject(getCodeUrl, erpCodeMap, JSONObject.class);
|
||||||
|
} catch (HttpStatusCodeException e) {
|
||||||
|
// 获取响应体的错误信息
|
||||||
|
String errorBody = e.getResponseBodyAsString();
|
||||||
|
System.out.println("调用接口失败,状态码:" + e.getStatusCode());
|
||||||
|
System.out.println("错误响应:" + errorBody);
|
||||||
|
|
||||||
|
// 将错误响应封装为 JSONObject(可选)
|
||||||
|
erpCodeRes = JSONObject.parseObject(errorBody);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
System.out.println("调用接口失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(erpCodeRes);
|
||||||
|
|
||||||
|
if ("200".equals(erpCodeRes.getString("code")) && !erpCodeRes.getJSONObject("data").getJSONArray("recordList").isEmpty()) {
|
||||||
|
//开始获取当前单据的编码
|
||||||
|
JSONObject erpCodeData = erpCodeRes.getJSONObject("data").getJSONArray("recordList").getJSONObject(0);
|
||||||
|
|
||||||
|
backReqMap.put("field_h57mR__c", erpCodeData.getString("code"));
|
||||||
|
}
|
||||||
|
|
||||||
backReqMap.put("field_eO8gK__c", erpMap.getString("id"));
|
backReqMap.put("field_eO8gK__c", erpMap.getString("id"));
|
||||||
backReqMap.put("sync_status__c", "option_sync_success__c");
|
backReqMap.put("sync_status__c", "option_sync_success__c");
|
||||||
backReqMap.put("response_status__c", "同步成功");
|
backReqMap.put("response_status__c", "同步成功");
|
||||||
|
@ -50,14 +50,15 @@ public class PersonController {
|
|||||||
//开始封装请求参数
|
//开始封装请求参数
|
||||||
LinkedHashMap getPersonReq = new LinkedHashMap<>();
|
LinkedHashMap getPersonReq = new LinkedHashMap<>();
|
||||||
getPersonReq.put("pageIndex", 1);
|
getPersonReq.put("pageIndex", 1);
|
||||||
getPersonReq.put("pageSize", 1);
|
getPersonReq.put("pageSize", 300);
|
||||||
getPersonReq.put("objid", "");
|
getPersonReq.put("objid", "");
|
||||||
getPersonReq.put("name", "");
|
getPersonReq.put("name", "");
|
||||||
getPersonReq.put("mobile", "");
|
getPersonReq.put("mobile", "");
|
||||||
getPersonReq.put("email", "");
|
getPersonReq.put("email", "");
|
||||||
getPersonReq.put("orgIds", Arrays.asList("2132046702701969413"));
|
getPersonReq.put("orgIds", Arrays.asList());
|
||||||
getPersonReq.put("userId", "");
|
getPersonReq.put("userId", "");
|
||||||
getPersonReq.put("pubts", "");
|
getPersonReq.put("pubts", "");
|
||||||
|
getPersonReq.put("unit_id", "2163138383273525256");
|
||||||
//getPersonReq.put("enable", Arrays.asList(0));
|
//getPersonReq.put("enable", Arrays.asList(0));
|
||||||
|
|
||||||
System.out.println("人员列表请求参数为:" + JSON.toJSONString(getPersonReq));
|
System.out.println("人员列表请求参数为:" + JSON.toJSONString(getPersonReq));
|
||||||
@ -92,7 +93,7 @@ public class PersonController {
|
|||||||
System.out.println("调用接口失败:" + e.getMessage());
|
System.out.println("调用接口失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(personRes);
|
//System.out.println(personRes);
|
||||||
|
|
||||||
if (!"200".equals(personRes.getString("code")) || personRes.getJSONObject("data").getJSONArray("recordList").isEmpty()) {
|
if (!"200".equals(personRes.getString("code")) || personRes.getJSONObject("data").getJSONArray("recordList").isEmpty()) {
|
||||||
log.info("erp请求产品失败或者没有符合条件的数据");
|
log.info("erp请求产品失败或者没有符合条件的数据");
|
||||||
@ -111,9 +112,10 @@ public class PersonController {
|
|||||||
String personName = personData.getString("name");
|
String personName = personData.getString("name");
|
||||||
String modifyTime = personData.getString("modifiedtime");
|
String modifyTime = personData.getString("modifiedtime");
|
||||||
|
|
||||||
Integer dr = personData.getInteger("dr");
|
String orgId = personData.getString("unit_id") != null ? personData.getString("unit_id") : "";
|
||||||
|
|
||||||
if (dr == 1) {
|
if (!"2163138383273525256".equals(orgId)) {
|
||||||
|
log.info("当前人员不是思科捷组织的员工");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +140,8 @@ public class PersonController {
|
|||||||
personMapReq.put("dataObjectApiName", "PersonnelObj");
|
personMapReq.put("dataObjectApiName", "PersonnelObj");
|
||||||
//erp编码
|
//erp编码
|
||||||
personMapReq.put("erp_code__c", personData.getString("code"));
|
personMapReq.put("erp_code__c", personData.getString("code"));
|
||||||
|
//员工编号
|
||||||
|
personMapReq.put("employee_number", personData.getString("code"));
|
||||||
//erpId
|
//erpId
|
||||||
personMapReq.put("erp_id__c", personId);
|
personMapReq.put("erp_id__c", personId);
|
||||||
//系统名
|
//系统名
|
||||||
@ -165,6 +169,20 @@ public class PersonController {
|
|||||||
|
|
||||||
personMapReq.put("sex", crmSex);
|
personMapReq.put("sex", crmSex);
|
||||||
|
|
||||||
|
//员工状态
|
||||||
|
String personStatus = personData.getString("enable");
|
||||||
|
|
||||||
|
//1是正常,0是禁用
|
||||||
|
switch (personStatus) {
|
||||||
|
case "1":
|
||||||
|
personMapReq.put("status", "0");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "2":
|
||||||
|
personMapReq.put("status", "1");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//生日
|
//生日
|
||||||
String birthday = personData.getString("birthdate") != null ? personData.getString("birthdate") : "";
|
String birthday = personData.getString("birthdate") != null ? personData.getString("birthdate") : "";
|
||||||
|
|
||||||
@ -202,8 +220,11 @@ public class PersonController {
|
|||||||
personMapReq.put("note__c", personData.getString("remark") != null ? personData.getString("remark") : "");
|
personMapReq.put("note__c", personData.getString("remark") != null ? personData.getString("remark") : "");
|
||||||
//todo 组织
|
//todo 组织
|
||||||
|
|
||||||
|
//获取主职信息
|
||||||
|
JSONObject mainJob = personData.getJSONArray("mainJobList").getJSONObject(0);
|
||||||
|
|
||||||
//主属部门
|
//主属部门
|
||||||
String dept = personData.getString("dept_id") != null ? personData.getString("dept_id") : "";
|
String dept = mainJob.getString("dept_id") != null ? mainJob.getString("dept_id") : "";
|
||||||
|
|
||||||
if ("".equals(dept)) {
|
if ("".equals(dept)) {
|
||||||
log.info("部门为空");
|
log.info("部门为空");
|
||||||
@ -239,9 +260,6 @@ public class PersonController {
|
|||||||
|
|
||||||
personMapReq.put("main_department", Arrays.asList(dept_id));
|
personMapReq.put("main_department", Arrays.asList(dept_id));
|
||||||
|
|
||||||
//获取主职信息
|
|
||||||
JSONObject mainJob = personData.getJSONArray("mainJobList").getJSONObject(0);
|
|
||||||
|
|
||||||
//职务
|
//职务
|
||||||
String jobStr = mainJob.getString("job_id") != null ? mainJob.getString("job_id") : "";
|
String jobStr = mainJob.getString("job_id") != null ? mainJob.getString("job_id") : "";
|
||||||
|
|
||||||
@ -289,9 +307,9 @@ public class PersonController {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("success".equals(getLeaderRes.getString("errorDescription")) && getLeaderRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if ("success".equals(getLeaderRes.getString("errorDescription")) && !getLeaderRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
log.info("主管存在");
|
log.info("主管存在");
|
||||||
String leader_id = getLeaderRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("_id");
|
String leader_id = getLeaderRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("user_id");
|
||||||
|
|
||||||
personMapReq.put("leader", Arrays.asList(leader_id));
|
personMapReq.put("leader", Arrays.asList(leader_id));
|
||||||
}
|
}
|
||||||
@ -333,9 +351,11 @@ public class PersonController {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("人员数据为:" + getPersonFromCRMRes);
|
||||||
|
|
||||||
Boolean isExist = true;
|
Boolean isExist = true;
|
||||||
|
|
||||||
if ("success".equals(getPersonFromCRMRes.getString("errorDescription")) && getPersonFromCRMRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if ("success".equals(getPersonFromCRMRes.getString("errorDescription")) && !getPersonFromCRMRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
log.info("该人员已经存在");
|
log.info("该人员已经存在");
|
||||||
|
|
||||||
JSONObject personMainReq = getPersonFromCRMRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
JSONObject personMainReq = getPersonFromCRMRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||||
|
@ -66,12 +66,12 @@ public class ProductCategoryController {
|
|||||||
//开始封装请求
|
//开始封装请求
|
||||||
Map getCategoryReq = new HashMap<>();
|
Map getCategoryReq = new HashMap<>();
|
||||||
getCategoryReq.put("pageIndex", 1);
|
getCategoryReq.put("pageIndex", 1);
|
||||||
getCategoryReq.put("pageSize", 100);
|
getCategoryReq.put("pageSize", 500);
|
||||||
|
|
||||||
//getCategoryReq.put("code", "000007");
|
//getCategoryReq.put("code", "000007");
|
||||||
|
|
||||||
getCategoryReq.put("endTime", nowStr);
|
// getCategoryReq.put("endTime", nowStr);
|
||||||
getCategoryReq.put("beginTime", twoDaysAgoStr);
|
// getCategoryReq.put("beginTime", twoDaysAgoStr);
|
||||||
|
|
||||||
System.out.println(JSONObject.parseObject(JSON.toJSONString(getCategoryReq)));
|
System.out.println(JSONObject.parseObject(JSON.toJSONString(getCategoryReq)));
|
||||||
|
|
||||||
@ -123,6 +123,18 @@ public class ProductCategoryController {
|
|||||||
String categoryCode = categoryData.getString("code");
|
String categoryCode = categoryData.getString("code");
|
||||||
String categoryName = categoryData.getJSONObject("name").getString("simplifiedName");
|
String categoryName = categoryData.getJSONObject("name").getString("simplifiedName");
|
||||||
|
|
||||||
|
if (categoryCode.length() < 3) {
|
||||||
|
log.info("产品分类长度小于3,将不再处理");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String categoryCodeStr = categoryCode.substring(0, 3);
|
||||||
|
|
||||||
|
if (!categoryCodeStr.equals("A01") && !categoryCodeStr.equals("A02") && !categoryCodeStr.equals("A03") && !categoryCodeStr.equals("B03")) {
|
||||||
|
log.info("产品分类不符合要求,将不再处理");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//开始查询是否已经执行过了
|
//开始查询是否已经执行过了
|
||||||
JSONObject isLogRes = new JSONObject();
|
JSONObject isLogRes = new JSONObject();
|
||||||
|
|
||||||
@ -152,13 +164,16 @@ public class ProductCategoryController {
|
|||||||
categoryReq.put("category_describe", remark);
|
categoryReq.put("category_describe", remark);
|
||||||
|
|
||||||
//判断是否存在上级部门
|
//判断是否存在上级部门
|
||||||
String parentCode = categoryData.getString("parent") != null ? categoryData.getString("parent") : "";
|
String parentCode = categoryData.getString("parentCode") != null ? categoryData.getString("parentCode") : "";
|
||||||
|
String level = categoryData.getString("level") != null ? categoryData.getString("level") : "";
|
||||||
|
|
||||||
|
if (!"1".equals(level)) {
|
||||||
|
|
||||||
if (!"".equals(parentCode)) {
|
if (!"".equals(parentCode)) {
|
||||||
log.info("上级部门存在,将查询上级部门");
|
log.info("上级部门存在,将查询上级部门");
|
||||||
|
|
||||||
JSONObject parentCategoryReq = crmRequestUtil.getCRMList(Arrays.asList(
|
JSONObject parentCategoryReq = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
new Filter("EQ", "erp_id__c", Arrays.asList(parentCode)),
|
new Filter("EQ", "category_code", Arrays.asList(parentCode)),
|
||||||
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
), "ProductCategoryObj");
|
), "ProductCategoryObj");
|
||||||
|
|
||||||
@ -176,14 +191,16 @@ public class ProductCategoryController {
|
|||||||
|
|
||||||
categoryReq.put("pid", parentCategoryData.getString("_id"));
|
categoryReq.put("pid", parentCategoryData.getString("_id"));
|
||||||
} else {
|
} else {
|
||||||
log.info("上级分类不存在,不再向下执行");
|
log.info("上级分类不存在,pid直接传空值");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//查询是否已存在当前单据
|
//查询是否已存在当前单据
|
||||||
JSONObject isExist = crmRequestUtil.getCRMList(Arrays.asList(
|
JSONObject isExist = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
new Filter("EQ", "erp_id__c", Arrays.asList(categoryId)),
|
new Filter("EQ", "category_code", Arrays.asList(categoryCode)),
|
||||||
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
), "ProductCategoryObj");
|
), "ProductCategoryObj");
|
||||||
|
|
||||||
|
@ -77,12 +77,12 @@ public class ProductController {
|
|||||||
//开始封装请求
|
//开始封装请求
|
||||||
Map getProductReq = new HashMap<>();
|
Map getProductReq = new HashMap<>();
|
||||||
getProductReq.put("pageIndex", 1);
|
getProductReq.put("pageIndex", 1);
|
||||||
getProductReq.put("pageSize", 100);
|
getProductReq.put("pageSize", 10);
|
||||||
|
|
||||||
getProductReq.put("code", "000008");
|
//getProductReq.put("code", "000008");
|
||||||
|
|
||||||
getProductReq.put("endTime", nowStr);
|
// getProductReq.put("endTime", nowStr);
|
||||||
getProductReq.put("beginTime", twoDaysAgoStr);
|
// getProductReq.put("beginTime", twoDaysAgoStr);
|
||||||
|
|
||||||
System.out.println(JSONObject.parseObject(JSON.toJSONString(getProductReq)));
|
System.out.println(JSONObject.parseObject(JSON.toJSONString(getProductReq)));
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ public class ProductController {
|
|||||||
product.put("product_category_id", categoryData.getString("_id"));
|
product.put("product_category_id", categoryData.getString("_id"));
|
||||||
|
|
||||||
//todo 产品线
|
//todo 产品线
|
||||||
String productLineStr = "";
|
String productLineStr = productData.getString("productLineName") != null ? productData.getString("productLineName") : "";
|
||||||
String productLine = "";
|
String productLine = "";
|
||||||
|
|
||||||
if (!productLineStr.equals("")) {
|
if (!productLineStr.equals("")) {
|
||||||
@ -202,12 +202,11 @@ public class ProductController {
|
|||||||
product.put("product_line", productLine);
|
product.put("product_line", productLine);
|
||||||
//品牌
|
//品牌
|
||||||
JSONObject productBrand = productData.getJSONObject("productCharacterDef");
|
JSONObject productBrand = productData.getJSONObject("productCharacterDef");
|
||||||
|
|
||||||
//品牌封装
|
//品牌封装
|
||||||
product.put("brand_name__c", productBrand.getString("PP0001") != null ? productBrand.getString("PP0001") : "");
|
product.put("brand_name__c", productBrand.getString("PP01") != null ? productBrand.getString("PP01") : "");
|
||||||
|
|
||||||
//todo 产品大类
|
//todo 产品大类
|
||||||
String productBigClassStr = "";
|
String productBigClassStr = productBrand.getString("CPDL_name") != null ? productBrand.getString("CPDL_name") : "";
|
||||||
String productBigClass = "";
|
String productBigClass = "";
|
||||||
|
|
||||||
if (!productBigClassStr.equals("")) {
|
if (!productBigClassStr.equals("")) {
|
||||||
@ -216,7 +215,7 @@ public class ProductController {
|
|||||||
|
|
||||||
product.put("product_category__c", productBigClass);
|
product.put("product_category__c", productBigClass);
|
||||||
//产品标准价格
|
//产品标准价格
|
||||||
product.put("price", productBrand.getBigDecimal("MLJ01") != null ? productBrand.getBigDecimal("MLJ01") : BigDecimal.ZERO);
|
product.put("price", productBrand.getBigDecimal("MLJ") != null ? productBrand.getBigDecimal("MLJ") : BigDecimal.ZERO);
|
||||||
|
|
||||||
//单位
|
//单位
|
||||||
String unitStr = productData.getString("unitName") != null ? productData.getString("unitName") : "";
|
String unitStr = productData.getString("unitName") != null ? productData.getString("unitName") : "";
|
||||||
|
@ -50,7 +50,7 @@ public class ResearchGroupController {
|
|||||||
log.info("开始同步课题组");
|
log.info("开始同步课题组");
|
||||||
|
|
||||||
JSONObject getResearch = crmRequestUtil.getCRMList(Arrays.asList(
|
JSONObject getResearch = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
new Filter("EQ", "name", Arrays.asList("保护伞课题组"))
|
new Filter("EQ", "name", Arrays.asList("保护伞T病毒课题组"))
|
||||||
), "topic_group__c");
|
), "topic_group__c");
|
||||||
|
|
||||||
JSONObject researchRes = new JSONObject();
|
JSONObject researchRes = new JSONObject();
|
||||||
@ -95,8 +95,8 @@ public class ResearchGroupController {
|
|||||||
|
|
||||||
//开始封装
|
//开始封装
|
||||||
Map researchMap = new HashMap();
|
Map researchMap = new HashMap();
|
||||||
researchMap.put("sourceUnique", "2141608528251453447");
|
researchMap.put("sourceUnique", "2171495625126313995");
|
||||||
researchMap.put("custdocdefid", "2137219552709181445");
|
researchMap.put("custdocdefid", "2163852876860358656");
|
||||||
|
|
||||||
//编码
|
//编码
|
||||||
researchMap.put("code", researchData.getString("topic_group_code__c") != null ? researchData.getString("topic_group_code__c") : "");
|
researchMap.put("code", researchData.getString("topic_group_code__c") != null ? researchData.getString("topic_group_code__c") : "");
|
||||||
@ -182,13 +182,54 @@ public class ResearchGroupController {
|
|||||||
logMap.put("tableName", "send_log_khxx");
|
logMap.put("tableName", "send_log_khxx");
|
||||||
|
|
||||||
//判断是否执行成功
|
//判断是否执行成功
|
||||||
if ("200".equals(researchYSRes.getString("code"))) {
|
if ("200".equals(researchYSRes.getString("code")) && researchYSRes.getJSONObject("data").getInteger("successCount") > 0) {
|
||||||
log.info("同步成功");
|
log.info("同步成功");
|
||||||
logMap.put("log_status", "0");
|
logMap.put("log_status", "0");
|
||||||
logMap.put("res_body", "同步成功");
|
logMap.put("res_body", "同步成功");
|
||||||
|
|
||||||
//获取ERPID
|
//获取ERPID
|
||||||
JSONObject erpMap = researchYSRes.getJSONObject("data").getJSONArray("infos").getJSONObject(0);
|
JSONObject erpMap = researchYSRes.getJSONObject("data").getJSONArray("infos").getJSONObject(0);
|
||||||
|
|
||||||
|
//获取ERPID
|
||||||
|
String erpId = erpMap.getString("id");
|
||||||
|
|
||||||
|
//根据erpId查询erp编码
|
||||||
|
Map erpCodeMap = new HashMap<>();
|
||||||
|
erpCodeMap.put("ids", Arrays.asList(erpId));
|
||||||
|
erpCodeMap.put("custdocdefid", "2163852876860358656");
|
||||||
|
erpCodeMap.put("pageIndex", 1);
|
||||||
|
erpCodeMap.put("pageSize", 10);
|
||||||
|
|
||||||
|
System.out.println(JSON.parse(JSON.toJSONString(erpCodeMap)));
|
||||||
|
|
||||||
|
//开始发起请求
|
||||||
|
String getCodeUrl = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/digitalModel/customerdoc/batchQueryDetail?access_token=" + ysToken;
|
||||||
|
|
||||||
|
JSONObject erpCodeRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
erpCodeRes = restTemplate.postForObject(getCodeUrl, erpCodeMap, JSONObject.class);
|
||||||
|
} catch (HttpStatusCodeException e) {
|
||||||
|
// 获取响应体的错误信息
|
||||||
|
String errorBody = e.getResponseBodyAsString();
|
||||||
|
System.out.println("调用接口失败,状态码:" + e.getStatusCode());
|
||||||
|
System.out.println("错误响应:" + errorBody);
|
||||||
|
|
||||||
|
// 将错误响应封装为 JSONObject(可选)
|
||||||
|
erpCodeRes = JSONObject.parseObject(errorBody);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
System.out.println("调用接口失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(erpCodeRes);
|
||||||
|
|
||||||
|
if ("200".equals(erpCodeRes.getString("code")) && !erpCodeRes.getJSONObject("data").getJSONArray("recordList").isEmpty()) {
|
||||||
|
//开始获取当前单据的编码
|
||||||
|
JSONObject erpCodeData = erpCodeRes.getJSONObject("data").getJSONArray("recordList").getJSONObject(0);
|
||||||
|
|
||||||
|
backReqMap.put("topic_group_code__c", erpCodeData.getString("code"));
|
||||||
|
}
|
||||||
|
|
||||||
backReqMap.put("erp_id__c", erpMap.getString("id"));
|
backReqMap.put("erp_id__c", erpMap.getString("id"));
|
||||||
backReqMap.put("sync_status__c", "option_sync_success__c");
|
backReqMap.put("sync_status__c", "option_sync_success__c");
|
||||||
backReqMap.put("response_status__c", "同步成功");
|
backReqMap.put("response_status__c", "同步成功");
|
||||||
|
@ -24,7 +24,8 @@ public class YSSignUtils {
|
|||||||
|
|
||||||
private RestTemplate restTemplate = new RestTemplate();
|
private RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
private static final String appSecret = "9e14a58b43975fc735adf16cd3570a2e297cf12e";
|
//private static final String appSecret = "9e14a58b43975fc735adf16cd3570a2e297cf12e";
|
||||||
|
private static final String appSecret = "41978857c894f5ca5e975a6bd0f577f4b0030e05";//正式环境
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用友生成签名方法
|
* 用友生成签名方法
|
||||||
@ -34,7 +35,8 @@ public class YSSignUtils {
|
|||||||
*/
|
*/
|
||||||
public String sign(long timestamp) throws Exception {
|
public String sign(long timestamp) throws Exception {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("appKey", "9f874bdd564543ea96206398c7d07cbf");
|
// params.put("appKey", "9f874bdd564543ea96206398c7d07cbf");//测试
|
||||||
|
params.put("appKey", "15371aac60ed4feaa7192ba0ab7a2098");//正式
|
||||||
params.put("timestamp", String.valueOf(timestamp));
|
params.put("timestamp", String.valueOf(timestamp));
|
||||||
|
|
||||||
//排序并拼接参数
|
//排序并拼接参数
|
||||||
@ -64,6 +66,7 @@ public class YSSignUtils {
|
|||||||
/**
|
/**
|
||||||
* token获取方法
|
* token获取方法
|
||||||
* 单独构造url防止spring自动编码
|
* 单独构造url防止spring自动编码
|
||||||
|
*
|
||||||
* @return null
|
* @return null
|
||||||
* @Author weiloong_zhang
|
* @Author weiloong_zhang
|
||||||
*/
|
*/
|
||||||
@ -94,7 +97,7 @@ public class YSSignUtils {
|
|||||||
//构造URL,确保signature不被Spring编码
|
//构造URL,确保signature不被Spring编码
|
||||||
String ysGetTokenUrl = UriComponentsBuilder
|
String ysGetTokenUrl = UriComponentsBuilder
|
||||||
.fromHttpUrl("https://c1.yonyoucloud.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken")
|
.fromHttpUrl("https://c1.yonyoucloud.com/iuap-api-auth/open-auth/selfAppAuth/getAccessToken")
|
||||||
.queryParam("appKey", "9f874bdd564543ea96206398c7d07cbf")
|
.queryParam("appKey", "15371aac60ed4feaa7192ba0ab7a2098")
|
||||||
.queryParam("timestamp", timestamp)
|
.queryParam("timestamp", timestamp)
|
||||||
.queryParam("signature", "{signature}")//用模板方式绕过自动编码
|
.queryParam("signature", "{signature}")//用模板方式绕过自动编码
|
||||||
.build(false)
|
.build(false)
|
||||||
@ -125,6 +128,7 @@ public class YSSignUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 防止token失效
|
* 防止token失效
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @Author weiloong_zhang
|
* @Author weiloong_zhang
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user