修复了一些问题,对部分代码做了字段上的优化
This commit is contained in:
parent
f696d77582
commit
940647ce7f
@ -14,9 +14,9 @@ public class CertificateConstant {
|
|||||||
public static final String CORP_ID = "FSCID_11F505C980B5FE43D5D7230567802E09";//企业Id
|
public static final String CORP_ID = "FSCID_11F505C980B5FE43D5D7230567802E09";//企业Id
|
||||||
public static final String CURRENT_OPEN_USERID = "FSUID_A9AD0C360309427B3F431487883B73B9";//当前登录用户id
|
public static final String CURRENT_OPEN_USERID = "FSUID_A9AD0C360309427B3F431487883B73B9";//当前登录用户id
|
||||||
|
|
||||||
// public static final String APP_ID = "FSAID_131fa51";//appId
|
// public static final String APP_ID = "FSAID_1320236";//appId
|
||||||
// public static final String PERMANENT_CODE = "EF03533F6929B59934A7E1155221420B";//永久授权码
|
// public static final String PERMANENT_CODE = "E228E8B46751EE10F6C7C8E4F481F72C";//永久授权码
|
||||||
// public static final String APP_SECRET = "1ce9804037ff4baf9d308bd32a4ec6ef";//appSecret
|
// public static final String APP_SECRET = "57d5425be6cf4e59b8811b4cf7dec1c4";//appSecret
|
||||||
// public static final String CORP_ID = "FSCID_EC935623350FB07DBF52F84F49874A81";//企业Id
|
// public static final String CORP_ID = "FSCID_FF5898FF873EBE3B7B1FC67B2AC9FEEE";//企业Id
|
||||||
// public static final String CURRENT_OPEN_USERID = "FSUID_7B52D1CF1B01E5A2A143E250A5B60595";//当前登录用户id
|
// public static final String CURRENT_OPEN_USERID = "FSUID_F142EFABF6B20EBD3EBB65B0ECE27E8C";//当前登录用户id
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package com.management.controller;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.management.constant.CertificateConstant;
|
import com.management.constant.CertificateConstant;
|
||||||
import com.management.constant.URLConstant;
|
import com.management.constant.URLConstant;
|
||||||
|
import com.management.entity.Filter;
|
||||||
import com.management.utils.CaffeineCacheUtil;
|
import com.management.utils.CaffeineCacheUtil;
|
||||||
|
import com.management.utils.CrmRequestUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -11,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -50,4 +53,35 @@ public class CRMTokenController {
|
|||||||
log.info("获取纷享销客token失败{}", tokenResponse);
|
log.info("获取纷享销客token失败{}", tokenResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时同步CRM的token
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @Author weiloong_zhang
|
||||||
|
*/
|
||||||
|
@PostMapping("/getToken")
|
||||||
|
public void tokenReSync() {
|
||||||
|
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||||
|
|
||||||
|
JSONObject getCustomer = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
|
new Filter("EQ", "name", Arrays.asList("test"))
|
||||||
|
), "AccountObj");
|
||||||
|
|
||||||
|
JSONObject customerRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
customerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, getCustomer, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("success".equals(customerRes.getString("errorDescription"))) {
|
||||||
|
log.info("token还能继续使用,将不再向下执行");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
log.info("token已失效,将重新获取");
|
||||||
|
getCRMToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ public class InvoiceController {
|
|||||||
invoiceMap.put("showbuyerbank", isShowBank);
|
invoiceMap.put("showbuyerbank", isShowBank);
|
||||||
|
|
||||||
//是否含软
|
//是否含软
|
||||||
String isHasSoft = invoiceData.getString("is_contain_soft__c");
|
String isHasSoft = invoiceData.getString("is_contain_soft__c") != null ? invoiceData.getString("is_contain_soft__c") : "";
|
||||||
Boolean isHasSoftBool = false;
|
Boolean isHasSoftBool = false;
|
||||||
|
|
||||||
switch (isHasSoft) {
|
switch (isHasSoft) {
|
||||||
|
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,8 +35,8 @@ public class PreContractController {
|
|||||||
private RestTemplate restTemplate = new RestTemplate();
|
private RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new PreContractController().syncContract();
|
//new PreContractController().syncContract();
|
||||||
//new PreContractController().bgPreContract();
|
new PreContractController().bgPreContract();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -111,8 +112,8 @@ public class PreContractController {
|
|||||||
Map erpContractReq = new HashMap<>();
|
Map erpContractReq = new HashMap<>();
|
||||||
erpContractReq.put("billno", preContractData.getString("name"));//预签合同编号
|
erpContractReq.put("billno", preContractData.getString("name"));//预签合同编号
|
||||||
erpContractReq.put("crmid", preContractData.getString("_id"));//CRM唯一性编码
|
erpContractReq.put("crmid", preContractData.getString("_id"));//CRM唯一性编码
|
||||||
//erpContractReq.put("project_number", preContractData.getString("opportunity_id__c"));//项目号
|
erpContractReq.put("project_number", preContractData.getString("opportunity_id__c"));//项目号
|
||||||
erpContractReq.put("project_number", "SJ20250424-0033");//项目号
|
//erpContractReq.put("project_number", "SJ20250424-0033");//项目号
|
||||||
erpContractReq.put("billtype_number", "conm_salcontract_BT_YQ");//单据类型
|
erpContractReq.put("billtype_number", "conm_salcontract_BT_YQ");//单据类型
|
||||||
erpContractReq.put("billname", preContractData.getString("project_name__c") != null ? preContractData.getString("project_name__c") : "预签合同");//合同名称
|
erpContractReq.put("billname", preContractData.getString("project_name__c") != null ? preContractData.getString("project_name__c") : "预签合同");//合同名称
|
||||||
erpContractReq.put("type_number", "XSHT-YQ01");//合同类型
|
erpContractReq.put("type_number", "XSHT-YQ01");//合同类型
|
||||||
@ -334,8 +335,8 @@ public class PreContractController {
|
|||||||
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||||
|
|
||||||
JSONObject preContractBGReq = crmRequestUtil.getCRMList(Arrays.asList(
|
JSONObject preContractBGReq = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
new Filter("EQ", "name", Arrays.asList("YQHTBG20250518-0002"))
|
new Filter("EQ", "name", Arrays.asList("2025-06-11-00002"))
|
||||||
), "pre_signed_contract_amendm__c");
|
), "pre_signed_contract__c__changeObj__c");
|
||||||
|
|
||||||
JSONObject preContractBGRes = new JSONObject();
|
JSONObject preContractBGRes = new JSONObject();
|
||||||
|
|
||||||
@ -345,8 +346,6 @@ public class PreContractController {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("预签合同变更查询结果为:" + preContractBGRes);
|
|
||||||
|
|
||||||
if (!"success".equals(preContractBGRes.getString("errorDescription")) || preContractBGRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if (!"success".equals(preContractBGRes.getString("errorDescription")) || preContractBGRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
log.info("不存在要变更的预签合同");
|
log.info("不存在要变更的预签合同");
|
||||||
return;
|
return;
|
||||||
@ -355,21 +354,19 @@ public class PreContractController {
|
|||||||
for (Object preContractBGObj : preContractBGRes.getJSONObject("data").getJSONArray("dataList")) {
|
for (Object preContractBGObj : preContractBGRes.getJSONObject("data").getJSONArray("dataList")) {
|
||||||
JSONObject preContractBGData = JSON.parseObject(JSON.toJSONString(preContractBGObj));
|
JSONObject preContractBGData = JSON.parseObject(JSON.toJSONString(preContractBGObj));
|
||||||
|
|
||||||
System.out.println("当前正在处理的单据为:" + preContractBGData);
|
System.out.println("当前预签合同变更数据为:" + preContractBGData);
|
||||||
|
|
||||||
//开始截取关键数据
|
//开始截取关键数据
|
||||||
//唯一ID
|
|
||||||
String preContractId = preContractBGData.getString("_id");
|
String preContractId = preContractBGData.getString("_id");
|
||||||
//单据名称
|
String modifyTime = preContractBGData.getString("last_modified_time");
|
||||||
String preContractName = preContractBGData.getString("name");
|
String YQHTName = preContractBGData.getString("name");
|
||||||
//创建时间
|
String originalName = preContractBGData.getString("original_data__r");
|
||||||
String createTime = preContractBGData.getString("create_time");
|
|
||||||
|
|
||||||
//开始查询是否已经集成过该单据
|
//开始判断是否已经执行过
|
||||||
JSONObject isLogRes = new JSONObject();
|
JSONObject isLogRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
isLogRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_htxx&log_type=YQHTBG&dataId=" + preContractId + "&mark=" + createTime, JSONObject.class);
|
isLogRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_htxx&log_type=YQHTBG&dataId=" + preContractId + "&mark=" + modifyTime, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -381,153 +378,107 @@ public class PreContractController {
|
|||||||
|
|
||||||
log.info("日志不存在,将继续向下执行");
|
log.info("日志不存在,将继续向下执行");
|
||||||
|
|
||||||
//开始封装数据
|
//开始封装请求数据
|
||||||
Map preContractBGMap = new HashMap<>();
|
Map YQBGMap = new HashMap<>();
|
||||||
//开始封装传输至ERP的请求
|
YQBGMap.put("billno", YQHTName);//合同编号
|
||||||
//preContractBGMap.put("billno", preContractBGData.getString("source_pre_signed_contract__c__r"));//原预签合同编号
|
|
||||||
preContractBGMap.put("crmid", preContractBGData.getString("source_pre_signed_contract__c"));//CRM唯一性编码
|
|
||||||
|
|
||||||
//开始查询项目号
|
//开始获取商机编号
|
||||||
String projectCode = "";
|
String businessId = preContractBGData.getString("change_business_opportunity__c") != null ? preContractBGData.getString("change_business_opportunity__c") : "";
|
||||||
|
|
||||||
if (preContractBGData.getString("business_opportunity__c") != null) {
|
//根据商机唯一性ID获取商机编号
|
||||||
projectCode = preContractBGData.getString("business_opportunity__c");
|
JSONObject getBusiness = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
}
|
new Filter("EQ", "_id", Arrays.asList(businessId))
|
||||||
|
|
||||||
JSONObject projectReq = crmRequestUtil.getCRMList(Arrays.asList(
|
|
||||||
new Filter("EQ", "_id", Arrays.asList(projectCode))
|
|
||||||
), "NewOpportunityObj");
|
), "NewOpportunityObj");
|
||||||
|
|
||||||
JSONObject projectRes = new JSONObject();
|
JSONObject businessRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
projectRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, projectReq, JSONObject.class);
|
businessRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getBusiness, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("项目号查询结果为:" + projectRes);
|
if (!"success".equals(businessRes.getString("errorDescription")) || businessRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
|
log.info("不存在该商机,将不再向下执行");
|
||||||
if (!"success".equals(projectRes.getString("errorDescription")) || projectRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
|
||||||
log.info("商机不存在,将不再向下执行");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
projectCode = projectRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("opportunity_id__c");
|
|
||||||
|
|
||||||
//preContractBGMap.put("project_number", projectCode);//项目号
|
String projectCode = businessRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("opportunity_id__c");
|
||||||
preContractBGMap.put("project_number", "SJ20250424-0033");//项目号
|
|
||||||
preContractBGMap.put("billtype_number", "conm_salcontract_BT_YQ");//单据类型
|
|
||||||
preContractBGMap.put("billname", preContractBGData.getString("contract_name__c") != null ? preContractBGData.getString("contract_name__c") : "测试");//todo 合同名称
|
|
||||||
preContractBGMap.put("type_number", "XSHT-YQ01");//合同类型
|
|
||||||
preContractBGMap.put("contparties_number", "BU-0002");//合同主体
|
|
||||||
preContractBGMap.put("createorg_number", "zyierp");//销售组织编码
|
|
||||||
preContractBGMap.put("org_number", "zyierp");//销售组织编码
|
|
||||||
preContractBGMap.put("currency_number", "CNY");//本位币.货币代码
|
|
||||||
preContractBGMap.put("settlecurrency_number", "CNY");//结算币别.货币代码
|
|
||||||
|
|
||||||
//日期格式化为Date
|
YQBGMap.put("project", projectCode);//项目号
|
||||||
long documentDate = preContractBGData.getLong("document_date__c");
|
YQBGMap.put("billname", preContractBGData.getString("change_project_name__c") != null ? preContractBGData.getString("change_project_name__c") : "");//合同名称
|
||||||
preContractBGMap.put("biztime", new Date(documentDate));//签订日期,单据日期
|
YQBGMap.put("srcbillnumber", originalName);//来源单单号
|
||||||
preContractBGMap.put("biztimebegin", new Date(documentDate));//起始日期
|
YQBGMap.put("srcsysbillid", preContractBGData.getString("original_data"));//来源单ID
|
||||||
preContractBGMap.put("biztimeend", new Date(documentDate));//截止日期
|
YQBGMap.put("crmid", preContractBGData.getString("original_data"));//CRMID
|
||||||
preContractBGMap.put("party1st", preContractBGData.getString("contract_unit_name__c__r"));//甲方
|
|
||||||
preContractBGMap.put("party2nd", preContractBGData.getString("our_company_name__c"));//乙方
|
|
||||||
preContractBGMap.put("bizmode", "C");//业务模式 A:统谈统签, B:统谈分签,C:分谈分签
|
|
||||||
|
|
||||||
//部门编码
|
//获取部门
|
||||||
String deptCode = "";
|
String ownerDept = preContractBGData.getString("owner_department_id") != null ? preContractBGData.getString("owner_department_id") : "";
|
||||||
|
|
||||||
List deptIdList = preContractBGData.getJSONArray("data_own_department");
|
JSONObject getDept = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
|
new Filter("EQ", "_id", Arrays.asList(ownerDept))
|
||||||
//开始查询部门编码
|
|
||||||
JSONObject deptReq = crmRequestUtil.getCRMList(Arrays.asList(
|
|
||||||
new Filter("EQ", "_id", deptIdList)
|
|
||||||
), "DepartmentObj");
|
), "DepartmentObj");
|
||||||
|
|
||||||
JSONObject deptRes = new JSONObject();
|
JSONObject deptRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, deptReq, JSONObject.class);
|
deptRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, getDept, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("success".equals(deptRes.getString("errorDescription")) && !deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if (!"success".equals(deptRes.getString("errorDescription")) || deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
JSONObject deptData = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
log.info("不存在该部门,将不再向下执行");
|
||||||
deptCode = deptData.getString("field_Vj6sf__c") != null ? deptData.getString("field_Vj6sf__c") : "";
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
preContractBGMap.put("dept", deptCode);//归属部门
|
String deptERPCode = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("field_Vj6sf__c");
|
||||||
preContractBGMap.put("dept_number", "004");//归属部门
|
//YQBGMap.put("dept", deptERPCode);//部门编码
|
||||||
|
YQBGMap.put("dept", "ZHY");//部门编码
|
||||||
|
|
||||||
//获取负责人编码
|
List ownerId = preContractBGData.getJSONArray("owner") != null ? preContractBGData.getJSONArray("owner") : new ArrayList<>();
|
||||||
String ownerCode = "";
|
|
||||||
|
|
||||||
List ownerIdList = preContractBGData.getJSONArray("owner");
|
JSONObject getOwner = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
|
new Filter("EQ", "user_id", ownerId)
|
||||||
JSONObject ownerReq = crmRequestUtil.getCRMList(Arrays.asList(
|
|
||||||
new Filter("EQ", "user_id", ownerIdList)
|
|
||||||
), "PersonnelObj");
|
), "PersonnelObj");
|
||||||
|
|
||||||
JSONObject ownerRes = new JSONObject();
|
JSONObject ownerRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ownerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, ownerReq, JSONObject.class);
|
ownerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, getOwner, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("success".equals(ownerRes.getString("errorDescription")) && !ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if (!"success".equals(ownerRes.getString("errorDescription")) || ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
log.info("负责人不存在或者请求失败");
|
||||||
ownerCode = ownerData.getString("field_T1xid__c") != null ? ownerData.getString("field_T1xid__c") : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
preContractBGMap.put("operator", "ID-000016");//todo 负责人
|
|
||||||
preContractBGMap.put("user_operatornumber", "ID-000016");//todo 负责人
|
|
||||||
|
|
||||||
//合同单位
|
|
||||||
String customerId = preContractBGData.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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject customerData = customerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
System.out.println("负责人数据为:" + ownerRes);
|
||||||
|
|
||||||
//preContractBGMap.put("customer_number", customerData.getString("account_no"));//合同单位名称
|
String ownerUserId = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("field_T1xid__c");
|
||||||
preContractBGMap.put("customer_number", "Cus-000007");//todo 合同单位名称
|
//YQBGMap.put("operator", ownerUserId);//负责人
|
||||||
|
YQBGMap.put("operator", "ID-000016");//负责人
|
||||||
|
|
||||||
//获取产品线
|
//质保期
|
||||||
|
YQBGMap.put("warranty", preContractBGData.getBigDecimal("change_warranty_period_months__c") != null ? preContractBGData.getBigDecimal("warranty_period") : BigDecimal.ZERO);
|
||||||
preContractBGMap.put("productline_number", preContractBGData.getString("product_line__c"));//产品线
|
//订货客户
|
||||||
|
YQBGMap.put("customer", preContractBGData.getString("change_billing_customer_code__c") != null ? preContractBGData.getString("change_billing_customer_code__c") : "");
|
||||||
//获取具体安装方式
|
|
||||||
|
|
||||||
preContractBGMap.put("installationmethod", preContractBGData.getString("installation_method__c"));//安装方式
|
|
||||||
|
|
||||||
|
//产品线
|
||||||
|
YQBGMap.put("productLine", preContractBGData.getString("change_product_line__c") != null ? preContractBGData.getString("change_product_line__c") : "");
|
||||||
|
//安装方式
|
||||||
|
YQBGMap.put("installationmethod", preContractBGData.getString("change_installation_method__c") != null ? preContractBGData.getString("change_installation_method__c") : "");
|
||||||
//行业类型
|
//行业类型
|
||||||
preContractBGMap.put("industrytype_number", preContractBGData.getString("industry_type__c"));//行业类型
|
YQBGMap.put("industrytype", preContractBGData.getString("change_industry_type__c") != null ? preContractBGData.getString("change_industry_type__c") : "");
|
||||||
preContractBGMap.put("deviceqty", preContractBGData.getBigDecimal("device_quantity__c") != null ? preContractBGData.getBigDecimal("device_quantity__c") : 0);//设备数量
|
//省
|
||||||
preContractBGMap.put("totalallamount", preContractBGData.getBigDecimal("pre_signed_amount__c") != null ? preContractBGData.getBigDecimal("pre_signed_amount__c") : 0);//预签金额
|
YQBGMap.put("province", preContractBGData.getString("change_field_t3fgo__c__r") != null ? preContractBGData.getString("change_field_t3fgo__c__r") : "");
|
||||||
preContractBGMap.put("warranty", preContractBGData.getBigDecimal("warranty_period_months__c") != null ? preContractBGData.getBigDecimal("warranty_period_months__c") : 0);//质保期
|
//市
|
||||||
|
YQBGMap.put("city", preContractBGData.getString("change_field_ngwth__c__r") != null ? preContractBGData.getString("change_field_ngwth__c__r") : "");
|
||||||
Map erpContractBGDataReq = new HashMap<>();
|
//区
|
||||||
erpContractBGDataReq.put("data", Arrays.asList(preContractBGMap));//请求体
|
YQBGMap.put("county", preContractBGData.getString("change_field_K5p2C__c__r") != null ? preContractBGData.getString("change_field_K5p2C__c__r") : "");
|
||||||
|
|
||||||
|
//开始获取token
|
||||||
String accessToken = new KDTokenController().getKDAccessTokenTest();
|
String accessToken = new KDTokenController().getKDAccessTokenTest();
|
||||||
|
|
||||||
if (accessToken == null || accessToken.equals("")) {
|
if (accessToken == null || accessToken.equals("")) {
|
||||||
@ -541,60 +492,57 @@ public class PreContractController {
|
|||||||
headers.set("accessToken", accessToken);
|
headers.set("accessToken", accessToken);
|
||||||
headers.set("Idempotency-Key", uuid);
|
headers.set("Idempotency-Key", uuid);
|
||||||
|
|
||||||
HttpEntity contractReqEntity = new HttpEntity(erpContractBGDataReq, headers);
|
HttpEntity contractReqEntity = new HttpEntity(YQBGMap, headers);
|
||||||
|
|
||||||
System.out.println(JSON.parseObject(JSON.toJSONString(contractReqEntity)));
|
System.out.println(JSON.parseObject(JSON.toJSONString(contractReqEntity)));
|
||||||
|
|
||||||
//开始向金蝶发起请求
|
|
||||||
String contractUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/conm/salcontract/change";
|
String contractUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/conm/salcontract/change";
|
||||||
|
|
||||||
String erpPreContractBGRes = "";
|
JSONObject contractRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
erpPreContractBGRes = restTemplate.postForObject(contractUrl, contractReqEntity, String.class);
|
contractRes = restTemplate.postForObject(contractUrl, contractReqEntity, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject erpPreContractBGResJson = JSON.parseObject(erpPreContractBGRes);
|
System.out.println(JSON.parseObject(JSON.toJSONString(contractRes)));
|
||||||
|
|
||||||
System.out.println("金蝶预签结果为:" + erpPreContractBGResJson);
|
|
||||||
|
|
||||||
//开始封装回写程序
|
//开始封装回写程序
|
||||||
Map backReqMap = new HashMap();
|
Map backReqMap = new HashMap();
|
||||||
backReqMap.put("_id", preContractId);
|
backReqMap.put("_id", preContractBGData.getString("original_data"));
|
||||||
backReqMap.put("dataObjectApiName", "pre_signed_contract_amendm__c");
|
backReqMap.put("dataObjectApiName", "pre_signed_contract__c");
|
||||||
|
|
||||||
//开始封装日志
|
//开始封装日志
|
||||||
Map logMap = new HashMap<>();
|
Map logMap = new HashMap<>();
|
||||||
logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
|
logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
|
||||||
logMap.put("log_type", "YQHTBG");
|
logMap.put("log_type", "YQHTBG");
|
||||||
logMap.put("syn_type", "0");
|
logMap.put("syn_type", "0");
|
||||||
logMap.put("data_name", preContractName);
|
logMap.put("data_name", YQHTName);
|
||||||
logMap.put("data_id", preContractId);
|
logMap.put("data_id", preContractId);
|
||||||
logMap.put("mark", createTime);
|
logMap.put("mark", modifyTime);
|
||||||
logMap.put("send_body", JSON.toJSONString(contractReqEntity));
|
logMap.put("send_body", JSON.toJSONString(contractReqEntity));
|
||||||
logMap.put("send_res", JSON.toJSONString(erpPreContractBGResJson));
|
logMap.put("send_res", JSON.toJSONString(contractRes));
|
||||||
logMap.put("tableName", "send_log_htxx");
|
logMap.put("tableName", "send_log_htxx");
|
||||||
|
|
||||||
//判断是否执行成功
|
//判断是否执行成功
|
||||||
if ("0".equals(erpPreContractBGResJson.getString("errorCode"))) {
|
if ("0".equals(contractRes.getString("errorCode"))) {
|
||||||
//同步成功
|
//同步成功
|
||||||
logMap.put("log_status", "0");
|
logMap.put("log_status", "0");
|
||||||
logMap.put("res_body", "同步成功");
|
logMap.put("res_body", "同步成功");
|
||||||
backReqMap.put("erp_id__c", erpPreContractBGResJson.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"));
|
backReqMap.put("updated_erp_id__c", contractRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"));
|
||||||
backReqMap.put("sync_status__c", "option_sync_success__c");
|
backReqMap.put("sync_status__c", "option_sync_success__c");
|
||||||
backReqMap.put("response_info__c", "同步成功");
|
backReqMap.put("response_info__c", "变更同步成功");
|
||||||
|
|
||||||
//审核
|
//开始审核
|
||||||
KingDeeUtils kingDeeUtils = new KingDeeUtils();
|
// KingDeeUtils kingDeeUtils = new KingDeeUtils();
|
||||||
kingDeeUtils.audit(erpPreContractBGResJson.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"), "conm_salcontract");
|
// kingDeeUtils.audit(contractRes.getJSONObject("data").getJSONArray("result").getJSONObject(0).getString("id"), "conm_salcontract");
|
||||||
} else {
|
} else {
|
||||||
//同步失败
|
//同步失败
|
||||||
logMap.put("log_status", "1");
|
logMap.put("log_status", "1");
|
||||||
logMap.put("res_body", "同步失败:" + erpPreContractBGResJson.getString("message"));
|
logMap.put("res_body", "同步失败:" + contractRes.getString("message"));
|
||||||
backReqMap.put("sync_status__c", "option_sync_failure__c");
|
backReqMap.put("sync_status__c", "option_sync_failure__c");
|
||||||
backReqMap.put("response_info__c", erpPreContractBGResJson.getString("message"));
|
backReqMap.put("response_info__c", "变更失败:" + contractRes.getString("message"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//开始回写
|
//开始回写
|
||||||
|
@ -100,8 +100,10 @@ public class TenderingController {
|
|||||||
|
|
||||||
//开始封装请求
|
//开始封装请求
|
||||||
Map tenderingMapReq = new HashMap<>();
|
Map tenderingMapReq = new HashMap<>();
|
||||||
tenderingMapReq.put("number", tenderingData.getString("field_31pd4__c"));//标书购买申请流水号
|
tenderingMapReq.put("number", tenderingName);//标书购买申请流水号
|
||||||
tenderingMapReq.put("f9w5_crmid", tenderingId);//标书购买申请ID
|
tenderingMapReq.put("f9w5_crmid", tenderingId);//标书购买申请ID
|
||||||
|
tenderingMapReq.put("f9w5_pronum", tenderingData.getString("field_31pd4__c"));//招投标项目编号
|
||||||
|
tenderingMapReq.put("f9w5_tendernum", tenderingData.getString("bidding_number__c") != null ? tenderingData.getString("bidding_number__c") : "");//招标编号
|
||||||
tenderingMapReq.put("name", tenderingData.getString("opportunity_name__c__r") != null ? tenderingData.getString("opportunity_name__c__r") : "");//商机名称
|
tenderingMapReq.put("name", tenderingData.getString("opportunity_name__c__r") != null ? tenderingData.getString("opportunity_name__c__r") : "");//商机名称
|
||||||
|
|
||||||
//申请类型
|
//申请类型
|
||||||
|
@ -57,6 +57,7 @@ public class CrmTask {
|
|||||||
// @Scheduled(cron = "0 0/1 * * * ?")
|
// @Scheduled(cron = "0 0/1 * * * ?")
|
||||||
// private void configureTasks() throws Exception {
|
// private void configureTasks() throws Exception {
|
||||||
// System.out.println("开始同步ERP数据");
|
// System.out.println("开始同步ERP数据");
|
||||||
|
// crmTokenController.tokenReSync();
|
||||||
// preContractController.syncContract();
|
// preContractController.syncContract();
|
||||||
// frameContractController.syncFrameContract();
|
// frameContractController.syncFrameContract();
|
||||||
// xshtController.syncXSHT();
|
// xshtController.syncXSHT();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user