From 30dfb3b82976c7ef28dcf37d067fe5d8c8437470 Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Tue, 7 May 2024 17:24:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E4=BF=A1=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E4=BA=A4OA=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ABAP_AS_WITH_POOL.jcoDestination | 6 +- .../customer/CustomerController.java | 34 +++++++- .../web/utils/SapFunction/ConnectToSAP.java | 4 +- .../web/utils/SapFunction/SapRfcUtils.java | 81 ++++++++++++++++++- .../com/ruoyi/customer/domain/Customer.java | 6 ++ .../com/ruoyi/customer/domain/RfcResult.java | 31 +++++++ .../mapper/customer/CustomerMapper.xml | 8 +- ruoyi-ui/src/api/customer/customer.js | 9 +++ .../src/views/customer/customer/index.vue | 39 ++++++--- 9 files changed, 192 insertions(+), 26 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/customer/domain/RfcResult.java diff --git a/ABAP_AS_WITH_POOL.jcoDestination b/ABAP_AS_WITH_POOL.jcoDestination index d7275de..6316cd3 100644 --- a/ABAP_AS_WITH_POOL.jcoDestination +++ b/ABAP_AS_WITH_POOL.jcoDestination @@ -1,11 +1,11 @@ #for tests only ! -#Mon May 06 17:03:41 CST 2024 +#Tue May 07 17:18:59 CST 2024 jco.destination.pool_capacity=10 jco.client.lang=ZH -jco.client.ashost=172.19.0.125 +jco.client.ashost=172.19.0.120 jco.client.saprouter= jco.client.user=RFC jco.client.sysnr=00 jco.destination.peak_limit=10 jco.client.passwd=654321 -jco.client.client=800 +jco.client.client=300 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java index bfd4927..b8bb14a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java @@ -9,11 +9,13 @@ import com.ruoyi.common.constant.WebsocketConst; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.UUID; +import com.ruoyi.customer.domain.RfcResult; import com.ruoyi.customer.domain.qcc.FuzzySearch; import com.ruoyi.customer.domain.qcc.QccFuzzySearchJsonResult; import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.service.ISysNoticeService; import com.ruoyi.web.utils.IdUtils; +import com.ruoyi.web.utils.SapFunction.SapRfcUtils; import com.ruoyi.web.utils.SendNotice.NoticeUtil; import com.ruoyi.web.utils.qcc.HttpHelper; import com.ruoyi.web.utils.qcc.QiChaChaUtil; @@ -137,8 +139,6 @@ public class CustomerController extends BaseController customer.setUpdateBy(getUsername()); customer.setCusApprovalStatus("1");//客户提交 状态设置为 审核中 - //TODO 提交校验 - if(StringUtils.isEmpty(cus_id)){ customer.setCusId(UUID.fastUUID().toString()); customer.setCusCode(IdUtils.createNo("KH_",2)); @@ -153,6 +153,20 @@ public class CustomerController extends BaseController } } + /** + * 数据组驳回 + */ + @PreAuthorize("@ss.hasPermi('customer:customer:return')") + @Log(title = "客户信息驳回", businessType = BusinessType.OTHER) + @PostMapping("/returnCustomer") + public AjaxResult returnCustomer(@RequestBody Customer customer) + { + customer.setUpdateBy(getUsername()); + customer.setCusApprovalStatus("3");//客户提交 状态设置为 已驳回 + customerService.updateCustomer(customer); + return success(); + } + /** * 提交客户信息-SAP */ @@ -163,11 +177,23 @@ public class CustomerController extends BaseController { customer.setUpdateBy(getUsername()); customer.setCusApprovalStatus("2");//客户提交 状态设置为 已审核 - customerService.updateCustomer(customer); + //TODO 提交校验 调用SAP rfc接口 更新客户凭证号 - return success(); + RfcResult result = SapRfcUtils.sendSAP(customer); + String type = result.getType(); + if("S".equals(type)){ + customer.setCusSapCode(result.getPartner()); + customerService.updateCustomer(customer); + }else{ + return error(result.getMessage()); + } + return success(result.getMessage()); } + /** + * 发送信息-数据组审核 + * @param customer + */ private void sendNotice(Customer customer){ //推送消息 LoginUser loginUser = getLoginUser();//当前登陆者 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/ConnectToSAP.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/ConnectToSAP.java index 2033f94..8f14672 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/ConnectToSAP.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/ConnectToSAP.java @@ -19,11 +19,11 @@ public class ConnectToSAP { private static void initProperties() { Properties connectProperties = new Properties(); // SAP服务器 - connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "172.19.0.125"); + connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "172.19.0.120");//172.19.0.125 // SAP系统编号 connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00"); // SAP集团 - connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "800"); + connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "300");//800 // SAP用户名 connectProperties.setProperty(DestinationDataProvider.JCO_USER, "RFC"); // SAP密码 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/SapRfcUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/SapRfcUtils.java index 8aa6040..6e3f7d6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/SapRfcUtils.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/SapRfcUtils.java @@ -1,11 +1,10 @@ package com.ruoyi.web.utils.SapFunction; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.customer.domain.Bank; import com.ruoyi.customer.domain.BankCode; -import com.sap.conn.jco.JCoDestination; -import com.sap.conn.jco.JCoFunction; -import com.sap.conn.jco.JCoParameterList; -import com.sap.conn.jco.JCoTable; +import com.ruoyi.customer.domain.Customer; +import com.sap.conn.jco.*; import java.util.ArrayList; import java.util.List; @@ -365,5 +364,79 @@ public class SapRfcUtils { return countrys; } + /*=======================================客户新建推送SAP=================================================*/ + /** + * 客户新建推送SAP + * @param customer + * @return + */ + public static com.ruoyi.customer.domain.RfcResult sendSAP(Customer customer) { + JCoFunction function = null; + com.ruoyi.customer.domain.RfcResult res = new com.ruoyi.customer.domain.RfcResult(); + JCoDestination destination = ConnectToSAP.connect(); + try { + function = destination.getRepository().getFunctionTemplate("ZOA02_CUSTOMER_CREATE").getFunction(); + if (function == null) + throw new RuntimeException("RFC_SYSTEM_INFO not found in SAP."); + JCoParameterList input = function.getImportParameterList(); + + JCoStructure jCoStructure = input.getStructure("IS_CUSTOMER"); + jCoStructure.setValue("KTOKK",customer.getCusGroup());//客户账户组 + jCoStructure.setValue("TITLE_MEDI","0003");//称谓文本 + jCoStructure.setValue("NAME1",customer.getCusName());//客户名称 + jCoStructure.setValue("SORT1",customer.getCusName());//搜索项1 + jCoStructure.setValue("LANGU",customer.getCusLanguage());//SAP 语言代码 + jCoStructure.setValue("COUNTRY",customer.getCusCountry());//国家/地区代码 + jCoStructure.setValue("POST_CODE1","000000");//邮箱邮政编码 + jCoStructure.setValue("STREET",customer.getCusStreet());//街道/门牌号 + jCoStructure.setValue("STR_SUPPL1",customer.getCusQccStreet());//街道2 + jCoStructure.setValue("STR_SUPPL3",customer.getCusQccStreet());//街道3 + jCoStructure.setValue("STR_SUPPL4",customer.getCusQccStreet());//街道4 + jCoStructure.setValue("BAHNS",customer.getCusVatNo());//增值税号 + jCoStructure.setValue("TEL_NUMBER",customer.getCusPhoneNumber());//电话号码 + jCoStructure.setValue("BRAN1",customer.getCusIndustryCode());//行业代码 + jCoStructure.setValue("FLAG","审核通过");//审批通过 + + + JCoStructure jCoStructure2 = input.getStructure("IS_SALES"); + jCoStructure2.setValue("VKORG",customer.getCusSalesOrganization());//销售组织 + jCoStructure2.setValue("VTWEG",customer.getCusDistributionChannel());//分销渠道 + jCoStructure2.setValue("SPART","00");//产品组 + jCoStructure2.setValue("BZIRK",customer.getCusSalesTerritory());//销售地区 + jCoStructure2.setValue("VKBUR",customer.getCusSaleOffice());//销售部门 + jCoStructure2.setValue("WAERS",customer.getCusCurrency());//币种 + jCoStructure2.setValue("KALKS","1");//客户定价过程 + jCoStructure2.setValue("VSBED","01");//装运条件 + jCoStructure2.setValue("ZTERM",customer.getCusPaymentTerms());//付款条件 + jCoStructure2.setValue("KTGRD","01");//账户分配组 + jCoStructure2.setValue("TAXKD",customer.getCusTax());//客户税分类 + + JCoStructure jCoStructure3 = input.getStructure("IS_COMPANY"); + jCoStructure3.setValue("BUKRS","1100");//公司代码 + jCoStructure3.setValue("AKONT",customer.getCusReconciliationAccount());//统驭科目 + jCoStructure3.setValue("ZTERM",customer.getCusPaymentTerms());//付款条件 + jCoStructure3.setValue("TOGRU","1100");//容差组 + + JCoParameterList inputTable = function.getTableParameterList(); + JCoTable tableInfo4 = inputTable.getTable("IT_BANK"); + List banks = customer.getBankList(); + for(Bank bank:banks){ + tableInfo4.appendRow(); + tableInfo4.setValue("BANKS",bank.getBankCountry());//国家 + tableInfo4.setValue("BANKL",bank.getBankCode());//银行代码 + tableInfo4.setValue("KOINH",bank.getBankAccount());//银行账户 + } + + function.execute(destination); + JCoParameterList exportParam = function.getExportParameterList(); + res.setType(exportParam.getString("E_TYPE")); + res.setMessage(exportParam.getString("E_MESSAGE")); + res.setPartner(exportParam.getString("E_PARTNER")); + + }catch (Exception e) { + e.printStackTrace(); + } + return res; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java index 919ea70..c5ae78d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java @@ -95,6 +95,9 @@ public class Customer extends BaseEntity @Excel(name = "备注") private String cusRemark; + /** 驳回备注 */ + private String cusReturnRemark; + /** 客户禁用状态 */ @Excel(name = "客户禁用状态",dictType = "common_state") private String cusState; @@ -284,6 +287,9 @@ public class Customer extends BaseEntity { return cusRemark; } + public String getCusReturnRemark() { return cusReturnRemark; } + + public void setCusReturnRemark(String cusReturnRemark) { this.cusReturnRemark = cusReturnRemark; } public void setCusState(String cusState) { this.cusState = cusState; diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/RfcResult.java b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/RfcResult.java new file mode 100644 index 0000000..5ba17fe --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/RfcResult.java @@ -0,0 +1,31 @@ +package com.ruoyi.customer.domain; + +public class RfcResult { + private String type; + private String message; + private String partner; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getPartner() { + return partner; + } + + public void setPartner(String partner) { + this.partner = partner; + } +} diff --git a/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml b/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml index ffe34a6..2425b88 100644 --- a/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml @@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -63,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select a.cus_id, a.cus_code, a.cus_name, a.cus_sap_code, a.cus_street, a.cus_qcc_street,a.cus_payment_terms, a.cus_phone_number, a.cus_industry_code, a.cus_group, a.cus_vat_no, a.cus_type, a.cus_country, a.cus_language, a.cus_label, - a.cus_classification, a.cus_receiving_email, a.cus_recipient, a.cus_recipient_phone, a.cus_remark, + a.cus_classification, a.cus_receiving_email, a.cus_recipient, a.cus_recipient_phone, a.cus_remark,a.cus_return_remark, a.cus_state, a.cus_approval_status,a.create_time,u.nick_name create_name, a.cus_sales_organization,a.cus_distribution_channel,a.cus_sales_territory,a.cus_sale_office, @@ -88,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"