新增的模块和部分内容
This commit is contained in:
parent
721e888b73
commit
ad6334df78
@ -239,6 +239,28 @@ public class DesignController {
|
||||
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") : "");//建议供应商
|
||||
|
||||
//是否直发
|
||||
String isDirectDeliveryStr = designDocDetailData.getString("is_direct_delivery__c") != null ? designDocDetailData.getString("is_direct_delivery__c") : "";
|
||||
|
||||
switch (isDirectDeliveryStr) {
|
||||
case "yes":
|
||||
designDocDetailMap.put("isdirectdelivery", "YES");//是否直发
|
||||
break;
|
||||
case "no":
|
||||
designDocDetailMap.put("isdirectdelivery", "NO");//是否直发
|
||||
break;
|
||||
default:
|
||||
designDocDetailMap.put("isdirectdelivery", "");//是否直发
|
||||
}
|
||||
|
||||
//直发现场时间
|
||||
long directDeliveryTime = designDocDetailData.getLong("direct_delivery_time__c") != null ? designDocDetailData.getLong("direct_delivery_time__c") : 0;
|
||||
|
||||
designDocDetailMap.put("deliverytime", new Date(directDeliveryTime));
|
||||
|
||||
//直发现场地址
|
||||
designDocDetailMap.put("deliverylocation", designDocDetailData.getString("direct_delivery_location__c") != null ? designDocDetailData.getString("direct_delivery_location__c") : "");
|
||||
|
||||
designDocList.add(designDocDetailMap);
|
||||
|
||||
}
|
||||
@ -388,7 +410,7 @@ public class DesignController {
|
||||
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||
|
||||
JSONObject getDesignBGDoc = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "name", Arrays.asList("2025-06-13-00007"))
|
||||
new Filter("EQ", "name", Arrays.asList("2025-06-20-00015"))
|
||||
), "design_file__c__changeObj__c");
|
||||
|
||||
System.out.println("设计文件变更接口请求为:" + JSON.parseObject(JSON.toJSONString(getDesignBGDoc)));
|
||||
@ -564,7 +586,31 @@ public class DesignController {
|
||||
Date reqDateDate = new Date(reqDate);
|
||||
designDocDetailMap.put("reqdate", reqDateDate);
|
||||
//CRM行ID
|
||||
designDocDetailMap.put("crmEntryId", designDocDetailData.getString("original_detail_data"));
|
||||
//判断变更类型
|
||||
String changeType = designDocDetailData.getString("changed_type") != null ? designDocDetailData.getString("changed_type") : "";
|
||||
|
||||
if (changeType.equals("add")) {
|
||||
//变更类型为新增,获取当前的行ID
|
||||
//行ID
|
||||
log.info("新增行");
|
||||
designDocDetailMap.put("changeType", "add");
|
||||
designDocDetailMap.put("crmEntryId", designDocDetailData.getString("_id"));
|
||||
designDocDetailMap.put("lineType", "010");
|
||||
} else if (changeType.equals("update")) {
|
||||
//变更类型为删除或者修改,获取源单的行id
|
||||
log.info("更新行");
|
||||
designDocDetailMap.put("changeType", "modify");
|
||||
designDocDetailMap.put("crmEntryId", designDocDetailData.getString("original_detail_data"));
|
||||
} else if (changeType.equals("deleted")) {
|
||||
//变更类型为删除或者修改,获取源单的行id
|
||||
log.info("删除行");
|
||||
designDocDetailMap.put("changeType", "delete");
|
||||
designDocDetailMap.put("crmEntryId", designDocDetailData.getString("original_detail_data"));
|
||||
} else {
|
||||
log.info("变更类型不存在");
|
||||
continue;
|
||||
}
|
||||
|
||||
//ERP行明细
|
||||
designDocDetailMap.put("entryId", designDocDetailData.getString("change_erp_line_id__c") != null ? designDocDetailData.getString("change_erp_line_id__c") : "");
|
||||
|
||||
|
@ -17,6 +17,8 @@ import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@ -706,4 +708,133 @@ public class InvoiceController {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除开票申请接口
|
||||
*
|
||||
* @return void
|
||||
* @Author weiloong_zhang
|
||||
*/
|
||||
@PostMapping("/sync/delete/invoice")
|
||||
public void deleteInvoice() {
|
||||
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||
|
||||
long twoDaysAgo = LocalDateTime.now()
|
||||
.minusDays(2)
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toInstant()
|
||||
.toEpochMilli();
|
||||
|
||||
JSONObject getInvoice = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
//new Filter("EQ", "name", Arrays.asList("2025-06-14-0005")),
|
||||
new Filter("GT", "last_modified_time", Arrays.asList(String.valueOf(twoDaysAgo))),
|
||||
new Filter("EQ", "life_status", Arrays.asList("invalid"))
|
||||
), "ExpenseClaimFormObj");
|
||||
|
||||
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);
|
||||
|
||||
//开始截取关键数据
|
||||
String invoiceId = invoiceData.getString("_id");
|
||||
String invoiceName = invoiceData.getString("name");
|
||||
String modifyTime = 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=KPZF&dataId=" + invoiceId + "&mark=" + modifyTime, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!isLogRes.getJSONArray("data").isEmpty()) {
|
||||
log.info("日志已存在,将不再向下执行");
|
||||
continue;
|
||||
}
|
||||
|
||||
log.info("日志不存在,继续向下执行");
|
||||
|
||||
Map invoiceDelMap = new HashMap<>();
|
||||
invoiceDelMap.put("crmInvoiceId", invoiceId);
|
||||
|
||||
//开始获取金蝶的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(invoiceDelMap, headers);
|
||||
|
||||
String invoiceUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/ar/arbusbill/deleteInvoice";
|
||||
|
||||
JSONObject delInvoiceRes = new JSONObject();
|
||||
|
||||
try {
|
||||
delInvoiceRes = restTemplate.postForObject(invoiceUrl, invoiceReqEntity, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("金蝶删除开票申请结果为:" + delInvoiceRes);
|
||||
|
||||
//开始封装日志
|
||||
Map logMap = new HashMap<>();
|
||||
logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
|
||||
logMap.put("log_type", "KPZF");
|
||||
logMap.put("syn_type", "2");
|
||||
logMap.put("data_name", invoiceName);
|
||||
logMap.put("data_id", invoiceId);
|
||||
logMap.put("mark", modifyTime);
|
||||
logMap.put("send_body", JSON.toJSONString(invoiceReqEntity));
|
||||
logMap.put("send_res", JSON.toJSONString(delInvoiceRes));
|
||||
logMap.put("tableName", "send_log_invoice");
|
||||
|
||||
if ("0".equals(delInvoiceRes.getString("errorCode"))) {
|
||||
log.info("金蝶删除开票申请成功");
|
||||
logMap.put("log_status", "0");
|
||||
logMap.put("res_body", "同步成功");
|
||||
} else {
|
||||
log.info("金蝶删除开票申请失败");
|
||||
logMap.put("log_status", "1");
|
||||
logMap.put("res_body", "同步失败:" + (delInvoiceRes.getString("message") != null ? delInvoiceRes.getString("message") : "未知错误"));
|
||||
}
|
||||
|
||||
JSONObject logRes = new JSONObject();
|
||||
|
||||
try {
|
||||
logRes = restTemplate.postForObject("http://localhost:18088/Log/insert/log_data", logMap, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("日志插入结果为:" + logRes);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ public class ReimbursementController {
|
||||
public static void main(String[] args) {
|
||||
new ReimbursementController().syncReimbursement();
|
||||
//new ReimbursementController().syncPublicExpenses();
|
||||
new ReimbursementController().syncTravelExpenses();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,7 +44,7 @@ public class ReimbursementController {
|
||||
public void syncReimbursement() {
|
||||
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||
|
||||
log.info("开始同步银行信息");
|
||||
log.info("开始同步费用信息");
|
||||
|
||||
//获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
@ -149,10 +150,11 @@ public class ReimbursementController {
|
||||
expensesMapReq.put("application_date", timestamp);//申请日期
|
||||
|
||||
//获取负责人信息
|
||||
String ownerCode = "ID-000016";//todo 负责人编码
|
||||
String ownerCode = expensesData.getString("applier_id") != null ? expensesData.getString("applier_id") : "";//todo 负责人编码
|
||||
//String ownerCode = "ID-000016";//todo 负责人编码
|
||||
|
||||
JSONObject getOwner = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "field_T1xid__c", Arrays.asList(ownerCode))
|
||||
new Filter("EQ", "erp_id__c", Arrays.asList(ownerCode))
|
||||
), "PersonnelObj");
|
||||
|
||||
JSONObject ownerRes = new JSONObject();
|
||||
@ -362,7 +364,7 @@ public class ReimbursementController {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
log.info("当前时间:{}", now);
|
||||
//获取两天前的时间
|
||||
LocalDateTime twoDaysAgo = now.minusDays(5);
|
||||
LocalDateTime twoDaysAgo = now.minusDays(3);
|
||||
|
||||
//将时间转换样式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
@ -463,10 +465,10 @@ public class ReimbursementController {
|
||||
expensesMainReq.put("application_date", timestamp);//申请日期
|
||||
|
||||
//获取负责人信息
|
||||
String ownerCode = "ID-000016";//todo 负责人编码
|
||||
String ownerCode = expensesData.getString("applier_id") != null ? expensesData.getString("applier_id") : "";//todo 负责人编码
|
||||
|
||||
JSONObject getOwner = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "field_T1xid__c", Arrays.asList(ownerCode))
|
||||
new Filter("EQ", "erp_id__c", Arrays.asList(ownerCode))
|
||||
), "PersonnelObj");
|
||||
|
||||
JSONObject ownerRes = new JSONObject();
|
||||
@ -649,4 +651,310 @@ public class ReimbursementController {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 差旅报销
|
||||
*
|
||||
* @return void
|
||||
* @Author weiloong_zhang
|
||||
*/
|
||||
@PostMapping("/sync/travel/expenses")
|
||||
public void syncTravelExpenses() {
|
||||
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||
|
||||
log.info("开始进行差旅报销同步");
|
||||
|
||||
//获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
log.info("当前时间:{}", now);
|
||||
//获取两天前的时间
|
||||
LocalDateTime twoDaysAgo = now.minusDays(5);
|
||||
|
||||
//将时间转换样式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String twoDaysAgoStr = twoDaysAgo.format(formatter);
|
||||
String nowStr = now.format(formatter);
|
||||
|
||||
//开始查询f费用报销单
|
||||
Map data = new HashMap<>();
|
||||
data.put("startTime", twoDaysAgoStr);
|
||||
data.put("endTime", nowStr);
|
||||
|
||||
Map expensesMap = new HashMap<>();
|
||||
expensesMap.put("data", data);
|
||||
expensesMap.put("pageNo", 1);
|
||||
expensesMap.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 expensesEntity = new HttpEntity(expensesMap, headers);
|
||||
|
||||
String expensesUrl = ERPURLConstant.ERP_URL + "/ierp/kapi/v2/f9w5/em/er_tripreimbursebill/query";
|
||||
|
||||
JSONObject expensesRes = new JSONObject();
|
||||
|
||||
try {
|
||||
expensesRes = restTemplate.postForObject(expensesUrl, expensesEntity, JSONObject.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println(expensesRes);
|
||||
|
||||
if (!"0".equals(expensesRes.getString("errorCode")) || expensesRes.getJSONObject("data").getJSONArray("rows").isEmpty()) {
|
||||
log.info("金蝶查询差旅报销单失败或者没有符合条件数据");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("金蝶查询差旅报销单成功,开始进行数据处理");
|
||||
|
||||
for (Object expensesObj : expensesRes.getJSONObject("data").getJSONArray("rows")) {
|
||||
JSONObject expensesData = JSON.parseObject(JSON.toJSONString(expensesObj));
|
||||
|
||||
System.out.println("当前正在处理的数据为:" + expensesData);
|
||||
|
||||
//开始截取关键数据
|
||||
String billNo = expensesData.getString("billno");
|
||||
String erpId = expensesData.getString("id");
|
||||
String bizDate = expensesData.getString("bizdate");
|
||||
|
||||
//开始查询当前数据是否以及执行过了
|
||||
JSONObject isLogRes = new JSONObject();
|
||||
|
||||
try {
|
||||
isLogRes = restTemplate.getForObject("http://localhost:18085/Log/query/log_data?table=send_log_fybx&log_type=CL&dataId=" + erpId + "&mark=" + bizDate, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!isLogRes.getJSONArray("data").isEmpty()) {
|
||||
log.info("当前数据已经执行过了,将不再向下执行");
|
||||
continue;
|
||||
}
|
||||
|
||||
log.info("日志不存在,将继续向下执行");
|
||||
|
||||
//开始封装主表数据
|
||||
Map expensesMain = new HashMap<>();
|
||||
expensesMain.put("erp_document_number__c", billNo);//单据编号
|
||||
expensesMain.put("erp_id__c", erpId);//单据ERPID
|
||||
expensesMain.put("record_type", "default__c");//业务类型
|
||||
expensesMain.put("dataObjectApiName", "ExpenseClaimFormObj");//对象名称
|
||||
|
||||
//开始获取时间数据并转换为字符串
|
||||
// 定义时间格式
|
||||
DateTimeFormatter formatterB = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// 解析字符串为 LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(bizDate, formatterB);
|
||||
|
||||
// 转换为时间戳(毫秒)
|
||||
long timestamp = localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
expensesMain.put("application_date", timestamp);//申请日期
|
||||
|
||||
//获取负责人信息
|
||||
String ownerCode = expensesData.getString("applier_id") != null ? expensesData.getString("applier_id") : "";//todo 负责人编码
|
||||
//String ownerCode = "ID-000016";//todo 负责人编码
|
||||
|
||||
JSONObject getOwner = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "erp_id__c", Arrays.asList(ownerCode))
|
||||
), "PersonnelObj");
|
||||
|
||||
JSONObject ownerRes = new JSONObject();
|
||||
|
||||
try {
|
||||
ownerRes = restTemplate.postForObject(URLConstant.GET_CRM_LIST_URL, getOwner, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!"success".equals(ownerRes.getString("errorDescription")) || ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||
log.info("负责人不存在或者请求失败");
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println("负责人数据为:" + ownerRes);
|
||||
|
||||
//开始截取负责人user_id
|
||||
String ownerUserId = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("user_id");
|
||||
expensesMain.put("owner", Arrays.asList(ownerUserId));
|
||||
expensesMain.put("applicant", Arrays.asList(ownerUserId));
|
||||
|
||||
//事由
|
||||
String description = expensesData.getString("description") != null ? expensesData.getString("description") : "";
|
||||
expensesMain.put("reason_for_event__c", description);//事由
|
||||
|
||||
//开始判断CRM里面是否已经存在该单据
|
||||
Boolean isExist = false;
|
||||
|
||||
JSONObject getExpenses = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "erp_id__c", Arrays.asList(erpId)),
|
||||
new Filter("EQ", "erp_document_number__c", Arrays.asList(billNo))
|
||||
), "ExpenseClaimFormObj");
|
||||
|
||||
JSONObject expensesCRMRes = new JSONObject();
|
||||
|
||||
try {
|
||||
expensesCRMRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getExpenses, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if ("success".equals(expensesCRMRes.getString("errorDescription")) && !expensesCRMRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||
log.info("该报销单已经存在");
|
||||
isExist = true;
|
||||
expensesMain.put("_id", expensesCRMRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("_id"));
|
||||
}
|
||||
|
||||
//开始封装明细数据
|
||||
List expensesDetails = new ArrayList<>();
|
||||
|
||||
for (Object expensesDetailObj : expensesData.getJSONArray("tripentry")) {
|
||||
JSONObject expensesDetailData = JSON.parseObject(JSON.toJSONString(expensesDetailObj));
|
||||
System.out.println("当前正在处理的报销单明细数据为:" + expensesDetailData);
|
||||
|
||||
//开始封装明细数据
|
||||
Map expensesDetailMap = new HashMap<>();
|
||||
expensesDetailMap.put("record_type", "record_P1mpZ__c");
|
||||
|
||||
String costProject = expensesDetailData.getString("std_project_number");
|
||||
|
||||
//项目号
|
||||
if (costProject.contains("SJ")) {
|
||||
//商机编号
|
||||
JSONObject getBusiness = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "opportunity_id__c", Arrays.asList(costProject))
|
||||
), "NewOpportunityObj");
|
||||
|
||||
JSONObject businessRes = new JSONObject();
|
||||
|
||||
try {
|
||||
businessRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getBusiness, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if ("success".equals(businessRes.getString("errorDescription")) && !businessRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||
JSONObject businessData = businessRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||
expensesDetailMap.put("", businessData.getString("_id"));
|
||||
}
|
||||
} else if (costProject.contains("XM")) {
|
||||
//项目编号
|
||||
JSONObject getProject = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "project_no__c", Arrays.asList(costProject))
|
||||
), "ProjectObj");
|
||||
|
||||
JSONObject projectRes = new JSONObject();
|
||||
|
||||
try {
|
||||
projectRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getProject, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if ("success".equals(projectRes.getString("errorDescription")) && !projectRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||
JSONObject projectData = projectRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||
expensesDetailMap.put("project_id", projectData.getString("_id"));
|
||||
}
|
||||
}
|
||||
|
||||
//todo 成本中心
|
||||
//String costCenter = expensesDetailData.getString("expensesDetailData") != null ? expensesDetailData.getString("expensesDetailData") : "";
|
||||
|
||||
expensesDetailMap.put("amount", expensesDetailData.getBigDecimal("triporiamount"));//金额(价税合计)
|
||||
expensesDetailMap.put("erp_row_id__c", expensesDetailData.getString("id"));//ERP行ID
|
||||
|
||||
//开始根据ERP行ID判断是否已经集成过该单据
|
||||
JSONObject getExpensesDetail = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "_id", Arrays.asList(expensesDetailData.getString("id")))
|
||||
), "ExpenseClaimFormDetailObj");
|
||||
|
||||
JSONObject expensesDetailCRMRes = new JSONObject();
|
||||
try {
|
||||
expensesDetailCRMRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getExpensesDetail, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if ("success".equals(expensesDetailCRMRes.getString("errorDescription")) && !expensesDetailCRMRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||
log.info("该报销单明细已经存在");
|
||||
expensesDetailMap.put("_id", expensesDetailCRMRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("_id"));
|
||||
}
|
||||
|
||||
expensesDetails.add(expensesDetailMap);
|
||||
|
||||
}
|
||||
|
||||
Map detailsMap = new HashMap<>();
|
||||
detailsMap.put("ExpenseClaimFormDetailObj", expensesDetails);
|
||||
|
||||
JSONObject expensesReq = crmRequestUtil.crmWithDetail(expensesMain, detailsMap);
|
||||
|
||||
System.out.println("费用报销请求结果为:" + expensesReq);
|
||||
|
||||
//开始封装日志
|
||||
Map logMap = new HashMap<>();
|
||||
logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
|
||||
logMap.put("log_type", "FY");
|
||||
logMap.put("data_name", billNo);
|
||||
logMap.put("data_id", erpId);
|
||||
logMap.put("mark", bizDate);
|
||||
logMap.put("send_body", JSON.toJSONString(expensesReq));
|
||||
logMap.put("tableName", "send_log_fybx");
|
||||
|
||||
JSONObject expensesCRMReq = new JSONObject();
|
||||
|
||||
if (isExist) {
|
||||
//已存在该单据,将进行更新
|
||||
logMap.put("syn_type", "1");
|
||||
|
||||
try {
|
||||
expensesCRMReq = restTemplate.postForObject(URLConstant.UPDATE_CRM_CUSTOMIZE, expensesReq, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("费用报销更新请求结果为:" + expensesCRMReq);
|
||||
} else {
|
||||
logMap.put("syn_type", "0");
|
||||
|
||||
try {
|
||||
expensesCRMReq = restTemplate.postForObject(URLConstant.CREATE_CRM_CUSTOMER_MAIN, expensesReq, JSONObject.class);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("费用报销创建请求结果为:" + expensesCRMReq);
|
||||
}
|
||||
|
||||
if ("success".equals(expensesCRMReq.getString("errorDescription"))) {
|
||||
logMap.put("log_status", "0");
|
||||
logMap.put("res_body", "同步成功");
|
||||
} else {
|
||||
logMap.put("log_status", "1");
|
||||
logMap.put("res_body", "同步失败" + expensesCRMReq.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ public class XSHTController {
|
||||
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||
|
||||
JSONObject getContract = crmRequestUtil.getCRMList(Arrays.asList(
|
||||
new Filter("EQ", "name", Arrays.asList("2025-06-13-00004"))
|
||||
new Filter("EQ", "name", Arrays.asList("2025-06-18-00007"))
|
||||
), "SaleContractChangeObj");
|
||||
|
||||
JSONObject contractBGRes = new JSONObject();
|
||||
@ -623,7 +623,7 @@ public class XSHTController {
|
||||
//开始获取部门
|
||||
String deptERPCode = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0).getString("field_Vj6sf__c");
|
||||
//contractBGMap.put("dept", deptERPCode);//部门编码
|
||||
contractBGMap.put("dept", "ZHY");//部门编码
|
||||
contractBGMap.put("dept", "zyierp");//部门编码
|
||||
|
||||
List ownerId = contractBGData.getJSONArray("owner") != null ? contractBGData.getJSONArray("owner") : new ArrayList<>();
|
||||
|
||||
@ -748,8 +748,40 @@ public class XSHTController {
|
||||
contractBGDetailMap.put("priceandtax", contractBGDetailData.getBigDecimal("change_sales_price") != null ? contractBGDetailData.getBigDecimal("change_sales_price") : BigDecimal.ZERO);
|
||||
//税率
|
||||
contractBGDetailMap.put("taxrateid", contractBGDetailData.getString("change_tax_rate_code__c") != null ? contractBGDetailData.getString("change_tax_rate_code__c") : "");
|
||||
//行ID
|
||||
contractBGDetailMap.put("crmentryid", contractBGDetailData.getString("original_detail_data"));
|
||||
|
||||
//开始获取变更类型
|
||||
String changeType = contractBGDetailData.getString("changed_type") != null ? contractBGDetailData.getString("changed_type") : "";
|
||||
|
||||
if (changeType.equals("add")) {
|
||||
log.info("删除行");
|
||||
//变更类型为新增,获取当前的行ID
|
||||
contractBGDetailMap.put("changeType", "add");
|
||||
//行ID
|
||||
contractBGDetailMap.put("crmentryid", contractBGDetailData.getString("_id"));
|
||||
//物料编码
|
||||
String material = contractBGDetailData.getString("change_product_id") != null ? contractBGDetailData.getString("change_product_id") : "";
|
||||
|
||||
if (material.equals("")) {
|
||||
log.info("物料编码不存在");
|
||||
continue;
|
||||
}
|
||||
|
||||
contractBGDetailMap.put("material", material);
|
||||
//行类型
|
||||
contractBGDetailMap.put("lineType", "010");
|
||||
} else if (changeType.equals("update")) {
|
||||
log.info("更新行");
|
||||
//变更类型为删除或者修改,获取当源单的行id
|
||||
contractBGDetailMap.put("changeType", "modify");
|
||||
contractBGDetailMap.put("crmentryid", contractBGDetailData.getString("original_detail_data"));
|
||||
} else if (changeType.equals("deleted")) {
|
||||
log.info("删除行");
|
||||
contractBGDetailMap.put("changeType", "delete");
|
||||
contractBGDetailMap.put("crmentryid", contractBGDetailData.getString("original_detail_data"));
|
||||
} else {
|
||||
log.info("变更类型不存在");
|
||||
continue;
|
||||
}
|
||||
|
||||
contractBGDetailList.add(contractBGDetailMap);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user