优化了项目和销售订单,优化了仓库信息
This commit is contained in:
parent
719d42f177
commit
928bb59848
@ -6,8 +6,8 @@ import java.util.Map;
|
|||||||
public enum OrderTypeEnum {
|
public enum OrderTypeEnum {
|
||||||
普通销售("SO001"),
|
普通销售("SO001"),
|
||||||
直运销售("SO004"),
|
直运销售("SO004"),
|
||||||
实验服务销售("SO071"),
|
实验服务销售("SO005"),
|
||||||
其他服务销售("SO004");
|
其他服务销售("QT001");
|
||||||
|
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
@ -87,8 +87,10 @@ public class ProjectController {
|
|||||||
|
|
||||||
//开始封装请求
|
//开始封装请求
|
||||||
Map projectReqMap = new HashMap<>();
|
Map projectReqMap = new HashMap<>();
|
||||||
//todo 所属项目类别
|
//所属项目类别
|
||||||
projectReqMap.put("classifyid", "2143096107351670788");
|
String projectClassify = projectData.getString("project_category__c") != null ? projectData.getString("project_category__c") : "";
|
||||||
|
|
||||||
|
projectReqMap.put("classifyid___code", projectClassify);
|
||||||
//所属组织
|
//所属组织
|
||||||
Map orgMap = new HashMap<>();
|
Map orgMap = new HashMap<>();
|
||||||
orgMap.put("en_US", "Enterprise Account");
|
orgMap.put("en_US", "Enterprise Account");
|
||||||
@ -131,22 +133,22 @@ public class ProjectController {
|
|||||||
|
|
||||||
System.out.println("负责人数据为:" + ownerRes);
|
System.out.println("负责人数据为:" + ownerRes);
|
||||||
|
|
||||||
// if (!"success".equals(ownerRes.getString("errorDescription")) || ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if (!"success".equals(ownerRes.getString("errorDescription")) || ownerRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
// log.info("负责人不存在或者请求失败");
|
log.info("负责人不存在或者请求失败");
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
|
||||||
//
|
|
||||||
// String ownerUserId = ownerData.getString("erp_id__c") != null ? ownerData.getString("erp_id__c") : ownerData.getString("user_id");
|
|
||||||
//
|
|
||||||
// if (ownerUserId.equals("")) {
|
|
||||||
// log.info("负责人不存在或者请求失败");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//projectReqMap.put("person", ownerUserId);
|
JSONObject ownerData = ownerRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||||
projectReqMap.put("person", "2155571363863068673");
|
|
||||||
|
String ownerUserId = ownerData.getString("erp_id__c") != null ? ownerData.getString("erp_id__c") : "";
|
||||||
|
|
||||||
|
if (ownerUserId.equals("")) {
|
||||||
|
log.info("负责人不存在或者请求失败");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
projectReqMap.put("person", ownerUserId);
|
||||||
|
//projectReqMap.put("person", "2155571363863068673");
|
||||||
|
|
||||||
//查询部门
|
//查询部门
|
||||||
String deptId = projectData.getString("owner_department_id");
|
String deptId = projectData.getString("owner_department_id");
|
||||||
@ -166,25 +168,25 @@ public class ProjectController {
|
|||||||
|
|
||||||
System.out.println(getDeptRes);
|
System.out.println(getDeptRes);
|
||||||
|
|
||||||
// if (!"success".equals(getDeptRes.getString("errorDescription")) || getDeptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if (!"success".equals(getDeptRes.getString("errorDescription")) || getDeptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
// log.info("部门不存在,将不再继续向下执行");
|
log.info("部门不存在,将不再继续向下执行");
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// log.info("部门存在,将开始执行");
|
|
||||||
//
|
|
||||||
// JSONObject deptData = getDeptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
|
||||||
//
|
|
||||||
// String deptERPId = deptData.getString("erp_id__c") != null ? deptData.getString("erp_id__c") : "";
|
|
||||||
//
|
|
||||||
// if (deptERPId.equals("")) {
|
|
||||||
// log.info("部门不存在或者请求失败");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//projectReqMap.put("deptid", deptERPId);
|
log.info("部门存在,将开始执行");
|
||||||
projectReqMap.put("deptid", "2155557327902605316");
|
|
||||||
projectReqMap.put("sourceUnique", "2328679934822187269");
|
JSONObject deptData = getDeptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||||
|
|
||||||
|
String deptERPId = deptData.getString("erp_id__c") != null ? deptData.getString("erp_id__c") : "";
|
||||||
|
|
||||||
|
if (deptERPId.equals("")) {
|
||||||
|
log.info("部门不存在或者请求失败");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
projectReqMap.put("deptid", deptERPId);
|
||||||
|
//projectReqMap.put("deptid", "2155557327902605316");
|
||||||
|
projectReqMap.put("sourceUnique", projectId);
|
||||||
projectReqMap.put("orgid", "666666");
|
projectReqMap.put("orgid", "666666");
|
||||||
|
|
||||||
//开始封装请求体
|
//开始封装请求体
|
||||||
|
@ -16,6 +16,8 @@ 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.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@ -29,7 +31,7 @@ public class SalesOrderController {
|
|||||||
|
|
||||||
private RestTemplate restTemplate = new RestTemplate();
|
private RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
public static void main(String[] weiLoong) {
|
public static void main(String[] args) {
|
||||||
new SalesOrderController().syncSalesOrder();
|
new SalesOrderController().syncSalesOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ public class SalesOrderController {
|
|||||||
* @return void
|
* @return void
|
||||||
* @Author weiloong_zhang
|
* @Author weiloong_zhang
|
||||||
*/
|
*/
|
||||||
@PostMapping("/sync/sales-order")
|
@PostMapping("/sync/salesOrder")
|
||||||
public void syncSalesOrder() {
|
public void syncSalesOrder() {
|
||||||
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
CrmRequestUtil crmRequestUtil = new CrmRequestUtil();
|
||||||
|
|
||||||
@ -50,38 +52,36 @@ public class SalesOrderController {
|
|||||||
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
), "SalesOrderObj");
|
), "SalesOrderObj");
|
||||||
|
|
||||||
JSONObject getSalesOrderRes = new JSONObject();
|
JSONObject salesOrderRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getSalesOrderRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getSalesOrder, JSONObject.class);
|
salesOrderRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getSalesOrder, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("销售订单查询结果为:" + getSalesOrderRes);
|
if (!"success".equals(salesOrderRes.getString("errorDescription")) || salesOrderRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
|
log.info("销售订单不存在或者销售订单请求失败");
|
||||||
if (!"success".equals(getSalesOrderRes.getString("errorDescription")) || getSalesOrderRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
|
||||||
log.info("查询失败或者不存在符合条件数据");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("查询成功,继续向下执行");
|
log.info("销售订单请求成功且数据存在,将继续向下执行");
|
||||||
|
|
||||||
for (Object salesOrderObj : getSalesOrderRes.getJSONObject("data").getJSONArray("dataList")) {
|
for (Object salesOrderObj : salesOrderRes.getJSONObject("data").getJSONArray("dataList")) {
|
||||||
JSONObject salesOrderData = JSON.parseObject(JSON.toJSONString(salesOrderObj));
|
JSONObject salesOrderData = JSON.parseObject(JSON.toJSONString(salesOrderObj));
|
||||||
|
|
||||||
System.out.println("当前正在处理的数据为:" + salesOrderData);
|
System.out.println("当前正在处理的销售订单数据为:" + salesOrderData);
|
||||||
|
|
||||||
//开始截取关键数据
|
//开始截取关键数据
|
||||||
String salesOrderId = salesOrderData.getString("_id");
|
String salesOrderId = salesOrderData.getString("_id");
|
||||||
String salesOrderName = salesOrderData.getString("name");
|
String salesOrderCode = salesOrderData.getString("name");
|
||||||
String modifyTime = salesOrderData.getString("last_modified_time");
|
String modifyTime = salesOrderData.getString("last_modified_time");
|
||||||
|
|
||||||
//开始查询当前数据是否已经集成过了
|
//开始查询当前数据是否已经执行过了
|
||||||
JSONObject isLogRes = new JSONObject();
|
JSONObject isLogRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
isLogRes = restTemplate.getForObject("http://localhost:18080/Log/query/log_data?table=send_log_xsdd&log_type=KJHT&dataId=" + salesOrderId + "&mark=" + modifyTime, JSONObject.class);
|
isLogRes = restTemplate.getForObject("http://localhost:18080/Log/query/log_data?table=send_log_xsdd&log_type=XSDD&dataId=" + salesOrderId + "&mark=" + modifyTime, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -93,256 +93,303 @@ public class SalesOrderController {
|
|||||||
|
|
||||||
log.info("日志不存在,将继续向下执行");
|
log.info("日志不存在,将继续向下执行");
|
||||||
|
|
||||||
//开始封装数据
|
//开始封装主表相关数据
|
||||||
Map salesOrderMap = new HashMap();
|
Map salesOrderMap = new HashMap<>();
|
||||||
//交易类型
|
//币种
|
||||||
String orderType = salesOrderData.getString("order_type__c__r") != null ? salesOrderData.getString("order_type__c__r") : "";
|
salesOrderMap.put("orderPrices!currency", "2158013267526025386");
|
||||||
|
salesOrderMap.put("orderPrices!natCurrency", "2158013267526025386");
|
||||||
|
//汇率
|
||||||
|
salesOrderMap.put("orderPrices!exchRate", "13.0");
|
||||||
|
//汇率类型
|
||||||
|
salesOrderMap.put("orderPrices!exchangeRateType", "i3p6cwlm");
|
||||||
|
//单价含税
|
||||||
|
salesOrderMap.put("orderPrices!taxInclusive", true);
|
||||||
|
|
||||||
if ("".equals(orderType)) {
|
//开始获取交易类型
|
||||||
log.info("交易类型不存在");
|
String tradeType = salesOrderData.getString("order_type__c__r") != null ? salesOrderData.getString("order_type__c__r") : "";
|
||||||
continue;
|
|
||||||
|
String tradeTypeStr = "";
|
||||||
|
|
||||||
|
if (!tradeType.equals("")) {
|
||||||
|
tradeTypeStr = OrderTypeEnum.getValueByName(tradeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
String orderTypeName = OrderTypeEnum.getValueByName(orderType);
|
salesOrderMap.put("transactionTypeId", tradeTypeStr);
|
||||||
|
|
||||||
salesOrderMap.put("transactionTypeId_code", orderTypeName);
|
//todo 销售组织(思科捷)
|
||||||
|
salesOrderMap.put("salesOrgId", "2163138383273525256");
|
||||||
//销售组织
|
//销售组织
|
||||||
salesOrderMap.put("settlementOrgId_code", "SKJ");
|
salesOrderMap.put("settlementOrgId", "2163138383273525256");
|
||||||
salesOrderMap.put("settlementOrgId", "2132046702701969413");
|
|
||||||
salesOrderMap.put("salesOrgId", "2132046702701969413");
|
|
||||||
salesOrderMap.put("transTypeKeyField", "transTypeKeyField");
|
|
||||||
salesOrderMap.put("transactionTypeId", "2126101050633486643");
|
|
||||||
salesOrderMap.put("orderPrices!currency", "2126099298265333798");
|
|
||||||
salesOrderMap.put("orderPrices!exchRate", 1);
|
|
||||||
salesOrderMap.put("orderPrices!exchangeRateType", "j30ib0to");
|
|
||||||
salesOrderMap.put("orderPrices!natCurrency", "2126099298265333798");
|
|
||||||
salesOrderMap.put("orderPrices!taxInclusive", true);
|
|
||||||
salesOrderMap.put("payMoney", 500);
|
|
||||||
//单据编号
|
//单据编号
|
||||||
salesOrderMap.put("code", salesOrderName);
|
salesOrderMap.put("code", salesOrderCode);
|
||||||
|
//销售订单金额
|
||||||
|
BigDecimal orderAmount = salesOrderData.getBigDecimal("order_amount") != null ? salesOrderData.getBigDecimal("order_amount") : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
salesOrderMap.put("payMoney", orderAmount);
|
||||||
|
|
||||||
|
//转换时间方法
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
//单据日期
|
//单据日期
|
||||||
long orderTime = salesOrderData.getLong("order_time__c") != null ? salesOrderData.getLong("order_time__c") : 0;
|
long docDate = salesOrderData.getLong("order_time");
|
||||||
|
|
||||||
// 转换为 LocalDateTime
|
String docDateStr = sdf.format(new Date(docDate));
|
||||||
LocalDateTime dateTime = Instant.ofEpochMilli(orderTime)
|
|
||||||
.atZone(ZoneId.systemDefault())
|
|
||||||
.toLocalDateTime();
|
|
||||||
|
|
||||||
// 格式化
|
salesOrderMap.put("vouchdate", docDateStr);
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
String orderTimeStr = dateTime.format(formatter);
|
|
||||||
|
|
||||||
salesOrderMap.put("orderDate", orderTimeStr);
|
|
||||||
salesOrderMap.put("vouchdate", orderTimeStr);
|
|
||||||
|
|
||||||
//联系人
|
//联系人
|
||||||
String contactId = salesOrderData.getString("contact_erpid__c") != null ? salesOrderData.getString("contact_erpid__c") : "";
|
String contactId = salesOrderData.getString("contact_erpid__c") != null ? salesOrderData.getString("contact_erpid__c") : "";
|
||||||
|
|
||||||
salesOrderMap.put("agentId", contactId);
|
salesOrderMap.put("agentId", contactId);
|
||||||
|
salesOrderMap.put("invoiceAgentId", contactId);
|
||||||
|
|
||||||
//客户
|
//销售部门
|
||||||
String customerId = salesOrderData.getString("customer_erpid__c") != null ? salesOrderData.getString("customer_erpid__c") : "";
|
List ownerList = salesOrderData.getJSONArray("owner");
|
||||||
|
|
||||||
if ("".equals(customerId)) {
|
JSONObject getPerson = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
log.info("客户不存在");
|
new Filter("EQ", "user_id", ownerList),
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
salesOrderMap.put("orderDefineCharacter__KHDW01", customerId);
|
|
||||||
salesOrderMap.put("invoiceAgentId", customerId);
|
|
||||||
|
|
||||||
//课题组
|
|
||||||
String researchId = salesOrderData.getString("topic_group_erpid__c") != null ? salesOrderData.getString("topic_group_erpid__c") : "";
|
|
||||||
|
|
||||||
salesOrderMap.put("orderDefineCharacter__K0003", researchId);
|
|
||||||
|
|
||||||
//院所或科室
|
|
||||||
String instituteId = salesOrderData.getString("institutionr_department__c") != null ? salesOrderData.getString("institutionr_department__c") : "";
|
|
||||||
|
|
||||||
salesOrderMap.put("orderDefineCharacter__Y005", instituteId);
|
|
||||||
|
|
||||||
//业务员
|
|
||||||
// List ownerList = salesOrderData.getJSONArray("owner");
|
|
||||||
//
|
|
||||||
// JSONObject getSalesMan = crmRequestUtil.getCRMList(Arrays.asList(
|
|
||||||
// new Filter("EQ", "user_id", ownerList),
|
|
||||||
// new Filter("EQ", "life_status", Arrays.asList("normal"))
|
|
||||||
// ), "PersonnelObj");
|
|
||||||
//
|
|
||||||
// JSONObject getSalesManRes = new JSONObject();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// getSalesManRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getSalesMan, JSONObject.class);
|
|
||||||
// } catch (RestClientException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!"success".equals(getSalesManRes.getString("errorDescription")) || getSalesManRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
|
||||||
// log.info("业务员不存在");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// log.info("业务员存在,继续向下执行");
|
|
||||||
//
|
|
||||||
// JSONObject getSalesManData = getSalesManRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
|
||||||
|
|
||||||
//salesOrderMap.put("corpContact", getSalesManData.getString("erp_id__c") != null ? getSalesManData.getString("erp_id__c") : "");
|
|
||||||
salesOrderMap.put("corpContact", "2155571363863068673");
|
|
||||||
|
|
||||||
String departmentId = salesOrderData.getString("owner_department_id");
|
|
||||||
|
|
||||||
// JSONObject getDepartment = crmRequestUtil.getCRMList(Arrays.asList(
|
|
||||||
// new Filter("EQ", "department_id", Arrays.asList(departmentId)),
|
|
||||||
// new Filter("EQ", "life_status", Arrays.asList("normal"))
|
|
||||||
// ), "DepartmentObj");
|
|
||||||
//
|
|
||||||
// JSONObject getDepartmentRes = new JSONObject();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// getDepartmentRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getDepartment, JSONObject.class);
|
|
||||||
// } catch (RestClientException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!"success".equals(getDepartmentRes.getString("errorDescription")) || getDepartmentRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
|
||||||
// log.info("部门不存在");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// log.info("部门存在,继续向下执行");
|
|
||||||
//
|
|
||||||
// JSONObject getDepartmentData = getDepartmentRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
|
||||||
|
|
||||||
//salesOrderMap.put("saleDepartmentId", getDepartmentData.getString("erp_id__c") != null ? getDepartmentData.getString("erp_id__c") : "");
|
|
||||||
salesOrderMap.put("saleDepartmentId", "2155557327902605316");
|
|
||||||
|
|
||||||
//todo 实验项目名称
|
|
||||||
// String projectId = salesOrderData.getString("project_erpid__c") != null ? salesOrderData.getString("project_erpid__c") : "";
|
|
||||||
//
|
|
||||||
// salesOrderMap.put("orderDefineCharacter__X0001", projectId);
|
|
||||||
|
|
||||||
//合同编号
|
|
||||||
salesOrderMap.put("orderDefineCharacter__HTBH001", salesOrderData.getString("internal_contract_number__c") != null ? salesOrderData.getString("internal_contract_number__c") : "");
|
|
||||||
|
|
||||||
//付款方式
|
|
||||||
String paymentType = salesOrderData.getString("field_0f31k__c") != null ? salesOrderData.getString("field_0f31k__c") : "";
|
|
||||||
|
|
||||||
salesOrderMap.put("orderDefineCharacter__FKFS001", paymentType);
|
|
||||||
|
|
||||||
//终端客户
|
|
||||||
String terminalCustomer = salesOrderData.getString("terminal_customer_erid__c") != null ? salesOrderData.getString("terminal_customer_erid__c") : "";
|
|
||||||
|
|
||||||
salesOrderMap.put("orderDefineCharacter__ZDKH01", terminalCustomer);
|
|
||||||
|
|
||||||
//todo 核销备注
|
|
||||||
salesOrderMap.put("orderDefineCharacter__HXBZ001", salesOrderData.getString("field_0f31k__c") != null ? salesOrderData.getString("field_0f31k__c") : "");
|
|
||||||
|
|
||||||
//备注
|
|
||||||
salesOrderMap.put("memo", salesOrderData.getString("field_0f31k__c") != null ? salesOrderData.getString("field_0f31k__c") : "");
|
|
||||||
|
|
||||||
//收货地址
|
|
||||||
salesOrderMap.put("receiveAddress", salesOrderData.getString("delivery_address__c") != null ? salesOrderData.getString("delivery_address__c") : "");
|
|
||||||
salesOrderMap.put("receiver", salesOrderData.getString("contact_person__c__r") != null ? salesOrderData.getString("contact_person__c__r") : "");
|
|
||||||
|
|
||||||
//开始查询订单产品
|
|
||||||
JSONObject getOrderProduct = crmRequestUtil.getCRMList(Arrays.asList(
|
|
||||||
new Filter("EQ", "order_id", Arrays.asList(salesOrderId)),
|
|
||||||
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
), "SalesOrderProductObj");
|
), "PersonnelObj");
|
||||||
|
|
||||||
JSONObject getOrderProductRes = new JSONObject();
|
JSONObject personRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getOrderProductRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getOrderProduct, JSONObject.class);
|
personRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getPerson, JSONObject.class);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!"success".equals(getOrderProductRes.getString("errorDescription")) || getOrderProductRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
if ("success".equals(personRes.getString("errorDescription")) && !personRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
log.info("订单产品不存在");
|
JSONObject personData = personRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||||
|
|
||||||
|
String personERPId = personData.getString("erp_id__c") != null ? personData.getString("erp_id__c") : "";
|
||||||
|
|
||||||
|
salesOrderMap.put("corpContact", personERPId);
|
||||||
|
}
|
||||||
|
|
||||||
|
String ownerDepartmentId = salesOrderData.getString("owner_department_id");
|
||||||
|
|
||||||
|
JSONObject getDept = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
|
new Filter("EQ", "_id", Arrays.asList(ownerDepartmentId)),
|
||||||
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
|
), "DepartmentObj");
|
||||||
|
|
||||||
|
JSONObject deptRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
deptRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getDept, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("success".equals(deptRes.getString("errorDescription")) && !deptRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
|
JSONObject deptData = deptRes.getJSONObject("data").getJSONArray("dataList").getJSONObject(0);
|
||||||
|
|
||||||
|
String deptERPId = deptData.getString("erp_id__c") != null ? deptData.getString("erp_id__c") : "";
|
||||||
|
|
||||||
|
salesOrderMap.put("saleDepartmentId", deptERPId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//实验项目名称
|
||||||
|
String projectName = salesOrderData.getString("project_erpid__c") != null ? salesOrderData.getString("project_erpid__c") : "";
|
||||||
|
|
||||||
|
//todo salesOrderMap.put("projectName", projectName);
|
||||||
|
|
||||||
|
//备注
|
||||||
|
String remark = salesOrderData.getString("reconciliation_note__c") != null ? salesOrderData.getString("reconciliation_note__c") : "";
|
||||||
|
|
||||||
|
salesOrderMap.put("memo", remark);
|
||||||
|
|
||||||
|
//收货地址
|
||||||
|
String addressStr = salesOrderData.getString("delivery_address__c") != null ? salesOrderData.getString("delivery_address__c") : "";
|
||||||
|
|
||||||
|
salesOrderMap.put("receiveAddress", addressStr);
|
||||||
|
|
||||||
|
//开始封装自定义信息
|
||||||
|
Map orderDefineCharacter = new HashMap<>();
|
||||||
|
//课题组
|
||||||
|
String researchGroupId = salesOrderData.getString("topic_group_erpid__c") != null ? salesOrderData.getString("topic_group_erpid__c") : "";
|
||||||
|
|
||||||
|
orderDefineCharacter.put("KTZ001", researchGroupId);
|
||||||
|
|
||||||
|
//客户单位
|
||||||
|
String customerId = salesOrderData.getString("customer_erpid__c") != null ? salesOrderData.getString("customer_erpid__c") : "";
|
||||||
|
|
||||||
|
orderDefineCharacter.put("SJKH01", customerId);
|
||||||
|
//院所科室
|
||||||
|
String instituteId = salesOrderData.getString("institutionr_department__c") != null ? salesOrderData.getString("institutionr_department__c") : "";
|
||||||
|
|
||||||
|
orderDefineCharacter.put("KSYS01", instituteId);
|
||||||
|
|
||||||
|
//合同编号
|
||||||
|
String contractNum = salesOrderData.getString("internal_contract_number__c") != null ? salesOrderData.getString("internal_contract_number__c") : "";
|
||||||
|
|
||||||
|
orderDefineCharacter.put("HT01", contractNum);
|
||||||
|
|
||||||
|
//付款方式
|
||||||
|
String paymentMethod = salesOrderData.getString("field_0f31k__c") != null ? salesOrderData.getString("field_0f31k__c") : "";
|
||||||
|
|
||||||
|
orderDefineCharacter.put("FKFS01", paymentMethod);
|
||||||
|
|
||||||
|
//todo 终端客户
|
||||||
|
|
||||||
|
salesOrderMap.put("orderDefineCharacter", orderDefineCharacter);
|
||||||
|
|
||||||
|
//状态
|
||||||
|
salesOrderMap.put("_status", "Insert");
|
||||||
|
|
||||||
|
//开始封装明细数据
|
||||||
|
//根据主表查询明细表
|
||||||
|
JSONObject getSalesOrderDetail = crmRequestUtil.getCRMList(Arrays.asList(
|
||||||
|
new Filter("EQ", "order_id", Arrays.asList(salesOrderId)),
|
||||||
|
new Filter("EQ", "life_status", Arrays.asList("normal"))
|
||||||
|
), "SalesOrderProductObj");
|
||||||
|
|
||||||
|
JSONObject salesOrderDetailRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
salesOrderDetailRes = restTemplate.postForObject(URLConstant.GET_CUSTOMIZE_LIST_URL, getSalesOrderDetail, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!"success".equals(salesOrderDetailRes.getString("errorDescription")) || salesOrderDetailRes.getJSONObject("data").getJSONArray("dataList").isEmpty()) {
|
||||||
|
log.info("无销售订单详情,将不再继续向下执行");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("订单产品存在,继续向下执行");
|
log.info("查询到了销售订单,继续向下执行");
|
||||||
|
|
||||||
List orderDetails = new ArrayList();
|
//封装销售订单明细
|
||||||
|
List<Object> salesOrderDetails = new ArrayList<>();
|
||||||
|
|
||||||
for (Object orderDetailObj : getOrderProductRes.getJSONObject("data").getJSONArray("dataList")) {
|
for (Object salesDetailObj : salesOrderDetailRes.getJSONObject("data").getJSONArray("dataList")) {
|
||||||
JSONObject orderDetailData = JSON.parseObject(JSON.toJSONString(orderDetailObj));
|
JSONObject salesDetailData = JSON.parseObject(JSON.toJSONString(salesDetailObj));
|
||||||
|
|
||||||
System.out.println("当前正在处理数据为:" + orderDetailData);
|
System.out.println("当前正在处理的销售订单明细数据为:" + salesDetailData);
|
||||||
|
|
||||||
Map orderDetailMap = new HashMap();
|
//开始封装明细数据
|
||||||
|
Map salesDetail = new HashMap<>();
|
||||||
Map priceMap = new HashMap();
|
//todo 实验项目编码
|
||||||
|
String productId = salesDetailData.getString("product_erp_id__c");
|
||||||
//商品编码和名称
|
salesDetail.put("productId", productId);
|
||||||
String productCode = orderDetailData.getString("product_code__c__r") != null ? orderDetailData.getString("product_code__c__r") : "";
|
|
||||||
String productName = orderDetailData.getString("product_name__c") != null ? orderDetailData.getString("product_name__c") : "";
|
|
||||||
|
|
||||||
orderDetailMap.put("skuCode", productCode);
|
|
||||||
orderDetailMap.put("skuName", productName);
|
|
||||||
|
|
||||||
//数量
|
//数量
|
||||||
orderDetailMap.put("qty", orderDetailData.getBigDecimal("quantity") != null ? orderDetailData.getBigDecimal("quantity") : 0);
|
BigDecimal quantity = salesDetailData.getBigDecimal("quantity") != null ? salesDetailData.getBigDecimal("quantity") : BigDecimal.ZERO;
|
||||||
|
salesDetail.put("qty", quantity);
|
||||||
|
salesDetail.put("subQty", quantity);
|
||||||
|
|
||||||
|
//计价数量
|
||||||
|
BigDecimal priceQuantity = salesDetailData.getBigDecimal("pricing_quantity__c") != null ? salesDetailData.getBigDecimal("pricing_quantity__c") : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
salesDetail.put("priceQty", priceQuantity);
|
||||||
|
|
||||||
//含税成交价
|
//含税成交价
|
||||||
orderDetailMap.put("oriTaxUnitPrice", orderDetailData.getBigDecimal("tax_inclusive_deal_price__c") != null ? orderDetailData.getBigDecimal("tax_inclusive_deal_price__c") : 0);
|
BigDecimal taxInclusivePrice = salesDetailData.getBigDecimal("sales_price") != null ? salesDetailData.getBigDecimal("sales_price") : BigDecimal.ZERO;
|
||||||
|
|
||||||
//币种
|
salesDetail.put("oriTaxUnitPrice", taxInclusivePrice);
|
||||||
String currency = orderDetailData.getString("currency_type__c") != null ? orderDetailData.getString("currency_type__c") : "";
|
|
||||||
|
|
||||||
if (!"".equals(currency)) {
|
|
||||||
//orderDetailMap.put("currency", CurrencyEnum.getValueByName(currency));
|
|
||||||
orderDetailMap.put("currency", "2126099298265333798");
|
|
||||||
priceMap.put("currency", "2126099298265333798");
|
|
||||||
}
|
|
||||||
|
|
||||||
//todo 目录价
|
//todo 目录价
|
||||||
orderDetailMap.put("orderDetailDefineCharacter__MLJ01", orderDetailData.getBigDecimal("product_price") != null ? orderDetailData.getBigDecimal("product_price") : 0);
|
//todo BigDecimal catalogPrice = salesDetailData.getBigDecimal("product_price") != null ? salesDetailData.getBigDecimal("product_price") : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
//含税金额
|
//含税金额
|
||||||
orderDetailMap.put("oriSum", orderDetailData.getBigDecimal("subtotal") != null ? orderDetailData.getBigDecimal("subtotal") : 0);
|
BigDecimal hsaTaxPrice = salesDetailData.getBigDecimal("subtotal") != null ? salesDetailData.getBigDecimal("subtotal") : BigDecimal.ZERO;
|
||||||
//税率
|
|
||||||
orderDetailMap.put("taxRate", orderDetailData.getBigDecimal("tax_rate__c") != null ? orderDetailData.getBigDecimal("tax_rate__c") : 0);
|
salesDetail.put("oriSum", hsaTaxPrice);
|
||||||
|
//todo 税率
|
||||||
|
//todo BigDecimal taxRate = salesDetailData.getBigDecimal("tax_rate__c") != null ? salesDetailData.getBigDecimal("tax_rate__c") : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
salesDetail.put("taxId", "VATR1");
|
||||||
|
|
||||||
//税额
|
//税额
|
||||||
priceMap.put("oriTax", orderDetailData.getBigDecimal("field_11b7H__c") != null ? orderDetailData.getBigDecimal("field_11b7H__c") : 0);
|
BigDecimal taxAmount = salesDetailData.getBigDecimal("field_11b7H__c") != null ? salesDetailData.getBigDecimal("field_11b7H__c") : BigDecimal.ZERO;
|
||||||
priceMap.put("orderDetailPrices!natSum", orderDetailData.getBigDecimal("field_11b7H__c") != null ? orderDetailData.getBigDecimal("field_11b7H__c") : 0);
|
|
||||||
|
salesDetail.put("orderDetailPrices!oriTax", taxAmount);
|
||||||
|
salesDetail.put("orderDetailPrices!natTax", taxAmount);
|
||||||
|
|
||||||
//库存组织
|
//库存组织
|
||||||
orderDetailMap.put("settlementOrgId_code", "SKJ");
|
String kuCunOrg = salesDetailData.getString("inventory_organization__c") != null ? salesDetailData.getString("inventory_organization__c") : "";
|
||||||
//质保期
|
|
||||||
orderDetailMap.put("orderDetailDefineCharacter__ZBQ01", orderDetailData.getBigDecimal("field_jbN2r__c") != null ? orderDetailData.getBigDecimal("field_jbN2r__c") : 0);
|
salesDetail.put("stockOrgId", kuCunOrg);
|
||||||
//todo 市场活动备注
|
|
||||||
orderDetailMap.put("orderDetailDefineCharacter__SCHDBZ", "");
|
// //质保期
|
||||||
|
// long zhiBaoQi = salesDetailData.getLong("field_jbN2r__c") != null ? salesDetailData.getLong("field_jbN2r__c") : 0;
|
||||||
|
//
|
||||||
|
// String zhiBaoQiStr = sdf.format(new Date(zhiBaoQi));
|
||||||
|
//
|
||||||
|
// salesDetail.put("warrantyDate", zhiBaoQiStr);
|
||||||
|
|
||||||
|
long planDate = salesDetailData.getLong("acceptance_date__c") != null ? salesDetailData.getLong("acceptance_date__c") : 0;
|
||||||
|
|
||||||
|
salesDetail.put("consignTime", sdf.format(new Date(planDate)));
|
||||||
|
|
||||||
//行备注
|
//行备注
|
||||||
orderDetailMap.put("memo", orderDetailData.getString("remark") != null ? orderDetailData.getString("remark") : "");
|
String lineRemark = salesDetailData.getString("remark") != null ? salesDetailData.getString("remark") : "";
|
||||||
|
|
||||||
|
//暂时给行备注加上CRMID
|
||||||
|
salesDetail.put("memo", salesDetailData.getString("_id"));
|
||||||
|
|
||||||
|
//销售单位
|
||||||
|
String salesUnit = salesDetailData.getString("sales_unit__c") != null ? salesDetailData.getString("sales_unit__c") : "";
|
||||||
|
|
||||||
|
salesDetail.put("iProductAuxUnitId", salesUnit);
|
||||||
|
salesDetail.put("masterUnitId", salesUnit);
|
||||||
|
salesDetail.put("iProductUnitId", salesUnit);
|
||||||
|
|
||||||
|
//todo 销售费用
|
||||||
|
// BigDecimal salesFee = salesDetailData.getBigDecimal("sales_cost__c") != null ? salesDetailData.getBigDecimal("sales_cost__c") : BigDecimal.ZERO;
|
||||||
|
//
|
||||||
|
// salesDetail.put("iSalesFee", salesFee);
|
||||||
|
|
||||||
//无税金额
|
//无税金额
|
||||||
priceMap.put("oriMoney", orderDetailData.getString("field_dt212__c") != null ? orderDetailData.getString("field_dt212__c") : "");
|
BigDecimal taxFreeAmount = salesDetailData.getBigDecimal("field_dt212__c") != null ? salesDetailData.getBigDecimal("field_dt212__c") : BigDecimal.ZERO;
|
||||||
//含税单价
|
|
||||||
priceMap.put("natTaxUnitPrice", orderDetailData.getBigDecimal("sales_price") != null ? orderDetailData.getBigDecimal("sales_price") : 0);
|
|
||||||
//无税单价
|
|
||||||
priceMap.put("natUnitPrice", orderDetailData.getBigDecimal("field_jyqC3__c") != null ? orderDetailData.getBigDecimal("field_jyqC3__c") : 0);
|
|
||||||
|
|
||||||
orderDetailMap.put("orderDetailPrices", priceMap);
|
salesDetail.put("orderDetailPrices!natMoney", salesDetailData.getBigDecimal("field_dt212__c") != null ? salesDetailData.getBigDecimal("field_dt212__c") : BigDecimal.ZERO);
|
||||||
// orderDetailMap.put("orderPrices", priceMap);
|
salesDetail.put("orderDetailPrices!oriMoney", taxFreeAmount);
|
||||||
|
|
||||||
orderDetails.add(orderDetailMap);
|
//含税金额
|
||||||
|
BigDecimal noTaxAmount = salesDetailData.getBigDecimal("field_jyqC3__c") != null ? salesDetailData.getBigDecimal("field_jyqC3__c") : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
salesDetail.put("orderDetailPrices!natUnitPrice", noTaxAmount);
|
||||||
|
//无税成交价
|
||||||
|
salesDetail.put("orderDetailPrices!oriUnitPrice", noTaxAmount);
|
||||||
|
salesDetail.put("oriTaxUnitPrice", noTaxAmount);
|
||||||
|
salesDetail.put("orderDetailPrices!natTaxUnitPrice", noTaxAmount);
|
||||||
|
|
||||||
|
|
||||||
|
//含税金额
|
||||||
|
salesDetail.put("orderDetailPrices!natSum", salesDetailData.getBigDecimal("subtotal") != null ? salesDetailData.getBigDecimal("subtotal") : BigDecimal.ZERO);
|
||||||
|
|
||||||
|
//销售组织
|
||||||
|
salesDetail.put("settlementOrgId", "2163138383273525256");
|
||||||
|
|
||||||
|
//todo 销售换算率
|
||||||
|
salesDetail.put("invExchRate", 1);
|
||||||
|
|
||||||
|
//todo 计价单位是否浮动换算率
|
||||||
|
salesDetail.put("unitExchangeTypePrice", 0);
|
||||||
|
|
||||||
|
//todo 计价换算率
|
||||||
|
salesDetail.put("invPriceExchRate", 1);
|
||||||
|
|
||||||
|
//todo 商品售卖类型
|
||||||
|
salesDetail.put("orderProductType", "SALE");
|
||||||
|
|
||||||
|
//todo 销售单位是否浮动换算率
|
||||||
|
salesDetail.put("unitExchangeType", 0);
|
||||||
|
|
||||||
|
//状态
|
||||||
|
salesDetail.put("_status", "Insert");
|
||||||
|
|
||||||
|
salesOrderDetails.add(salesDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderDetails.isEmpty()){
|
salesOrderMap.put("orderDetails", salesOrderDetails);
|
||||||
log.info("无订单明细");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//开始封装明细
|
Map salesDataMap = new HashMap<>();
|
||||||
salesOrderMap.put("orderDetails", orderDetails);
|
salesDataMap.put("data", salesOrderMap);
|
||||||
|
|
||||||
Map dataMap = new HashMap();
|
|
||||||
dataMap.put("data", salesOrderMap);
|
|
||||||
|
|
||||||
System.out.println("开始封装数据为:" + JSON.parseObject(JSON.toJSONString(dataMap)));
|
|
||||||
|
|
||||||
//开始获取token
|
//开始获取token
|
||||||
String erpToken = "";
|
String erpToken = "";
|
||||||
@ -353,13 +400,13 @@ public class SalesOrderController {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
//url
|
//开始发起请求
|
||||||
String url = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/sd/voucherorder/singleSave" + "?access_token=" + erpToken;
|
String url = "https://c1.yonyoucloud.com/iuap-api-gateway/yonbip/sd/voucherorder/singleSave?access_token=" + erpToken;//url
|
||||||
|
|
||||||
JSONObject salesOrderERPRes = new JSONObject();
|
JSONObject salesOrderERPRes = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
salesOrderERPRes = restTemplate.postForObject(url, dataMap, JSONObject.class);
|
salesOrderERPRes = restTemplate.postForObject(url, salesDataMap, JSONObject.class);
|
||||||
} catch (HttpStatusCodeException e) {
|
} catch (HttpStatusCodeException e) {
|
||||||
//获取响应体的错误信息
|
//获取响应体的错误信息
|
||||||
String errorBody = e.getResponseBodyAsString();
|
String errorBody = e.getResponseBodyAsString();
|
||||||
@ -372,7 +419,88 @@ public class SalesOrderController {
|
|||||||
System.out.println("调用接口失败:" + e.getMessage());
|
System.out.println("调用接口失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(salesOrderERPRes);
|
System.out.println("销售订单创建结果为:" + salesOrderERPRes);
|
||||||
|
|
||||||
|
//开始封装回写程序
|
||||||
|
Map backReqMap = new HashMap();
|
||||||
|
backReqMap.put("_id", salesOrderId);
|
||||||
|
backReqMap.put("dataObjectApiName", "SalesOrderObj");
|
||||||
|
|
||||||
|
Map backDetailMap = new HashMap();
|
||||||
|
|
||||||
|
//开始封装日志
|
||||||
|
Map logMap = new HashMap<>();
|
||||||
|
logMap.put("log_id", UUID.randomUUID().toString().replace("-", ""));
|
||||||
|
logMap.put("log_type", "XSDD");
|
||||||
|
logMap.put("syn_type", "0");
|
||||||
|
logMap.put("data_name", salesOrderCode);
|
||||||
|
logMap.put("data_id", salesOrderId);
|
||||||
|
logMap.put("mark", modifyTime);
|
||||||
|
logMap.put("send_body", JSON.toJSONString(salesDataMap));
|
||||||
|
logMap.put("send_res", JSON.toJSONString(salesOrderERPRes));
|
||||||
|
logMap.put("tableName", "send_log_xsdd");
|
||||||
|
|
||||||
|
if ("200".equals(salesOrderERPRes.getString("code"))) {
|
||||||
|
//同步成功
|
||||||
|
log.info("销售订单同步成功");
|
||||||
|
logMap.put("log_status", "0");
|
||||||
|
logMap.put("res_body", "同步成功");
|
||||||
|
|
||||||
|
//erp返回全量数据
|
||||||
|
JSONObject erpResponse = salesOrderERPRes.getJSONObject("data");
|
||||||
|
//开始封装回写程序
|
||||||
|
backReqMap.put("erp_id__c", erpResponse.getString("id"));
|
||||||
|
backReqMap.put("sync_status__c", "option_sync_success__c");
|
||||||
|
backReqMap.put("response_status__c", "同步成功");
|
||||||
|
|
||||||
|
List backDetails = new ArrayList();
|
||||||
|
//开始封装明细数据
|
||||||
|
for (Object orderDetailObj : erpResponse.getJSONArray("orderDetails")) {
|
||||||
|
JSONObject orderDetail = JSON.parseObject(JSON.toJSONString(orderDetailObj));
|
||||||
|
|
||||||
|
Map backDetail = new HashMap();
|
||||||
|
backDetail.put("_id", orderDetail.getString("memo"));
|
||||||
|
backDetail.put("field_9b817__c", orderDetail.getString("id"));
|
||||||
|
|
||||||
|
backDetails.add(backDetail);
|
||||||
|
}
|
||||||
|
|
||||||
|
backDetailMap.put("SalesOrderProductObj", backDetails);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logMap.put("log_status", "1");
|
||||||
|
logMap.put("res_body", "同步失败:" + salesOrderERPRes.getString("message") != null ? salesOrderERPRes.getString("message") : "同步失败,未知原因");
|
||||||
|
backReqMap.put("sync_status__c", "option_sync_failed__c");
|
||||||
|
backReqMap.put("response_status__c", salesOrderERPRes.getString("message") != null ? salesOrderERPRes.getString("message") : "同步失败,未知原因");
|
||||||
|
|
||||||
|
backDetailMap.put("SalesOrderProductObj", Arrays.asList());
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("开始回写数据");
|
||||||
|
|
||||||
|
JSONObject backReq = crmRequestUtil.crmWithDetail(backReqMap, backDetailMap);
|
||||||
|
|
||||||
|
JSONObject backRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
backRes = restTemplate.postForObject(URLConstant.UPDATE_CRM_MAIN, backReq, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("回写结果为:" + backRes);
|
||||||
|
logMap.put("send_memo", JSON.toJSONString(backRes));
|
||||||
|
|
||||||
|
//开始记录日志
|
||||||
|
JSONObject logRes = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
logRes = restTemplate.postForObject("http://localhost:18080/Log/insert/log_data", logMap, JSONObject.class);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("日志记录结果为:" + logRes);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class WarehouseController {
|
|||||||
getWarehouseMap.put("pageSize", 10);
|
getWarehouseMap.put("pageSize", 10);
|
||||||
// getWarehouseMap.put("startTs", twoDaysAgoStr);
|
// getWarehouseMap.put("startTs", twoDaysAgoStr);
|
||||||
// getWarehouseMap.put("endTs", nowStr);
|
// getWarehouseMap.put("endTs", nowStr);
|
||||||
getWarehouseMap.put("code", "A.001");
|
getWarehouseMap.put("code", "BJ.002");
|
||||||
|
|
||||||
//开始获取erpToken
|
//开始获取erpToken
|
||||||
System.out.println("人员列表请求参数为:" + JSON.toJSONString(getWarehouseMap));
|
System.out.println("人员列表请求参数为:" + JSON.toJSONString(getWarehouseMap));
|
||||||
@ -134,8 +134,8 @@ public class WarehouseController {
|
|||||||
//开始封装请求
|
//开始封装请求
|
||||||
Map warehouseCrm = new HashMap<>();
|
Map warehouseCrm = new HashMap<>();
|
||||||
warehouseCrm.put("dataObjectApiName", "WarehouseObj");
|
warehouseCrm.put("dataObjectApiName", "WarehouseObj");
|
||||||
//是否默认仓
|
//todo 是否默认仓
|
||||||
warehouseCrm.put("is_default", true);
|
// warehouseCrm.put("is_default", true);
|
||||||
//仓库名称
|
//仓库名称
|
||||||
warehouseCrm.put("name", warehouseName);
|
warehouseCrm.put("name", warehouseName);
|
||||||
//仓库编码
|
//仓库编码
|
||||||
@ -247,7 +247,7 @@ public class WarehouseController {
|
|||||||
JSONObject createWarehouseRes = new JSONObject();
|
JSONObject createWarehouseRes = new JSONObject();
|
||||||
|
|
||||||
if (isExist) {
|
if (isExist) {
|
||||||
log.info("该产人员不存在,将执行创建");
|
log.info("该仓库不存在,将执行创建");
|
||||||
|
|
||||||
logMap.put("log_type", "CK");
|
logMap.put("log_type", "CK");
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ public class WarehouseController {
|
|||||||
|
|
||||||
System.out.println("创建结果为:" + JSON.parseObject(JSON.toJSONString(createWarehouseRes)));
|
System.out.println("创建结果为:" + JSON.parseObject(JSON.toJSONString(createWarehouseRes)));
|
||||||
} else {
|
} else {
|
||||||
log.info("该人员已存在,将执行更新");
|
log.info("该仓库已存在,将执行更新");
|
||||||
|
|
||||||
logMap.put("log_type", "CKUP");
|
logMap.put("log_type", "CKUP");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user