收款推送费控和sap操作,优化url,注释

This commit is contained in:
yuxueliang0813 2025-04-24 13:45:27 +08:00
parent 1223517501
commit f4f8a53743
7 changed files with 84 additions and 82 deletions

View File

@ -28,16 +28,19 @@ import java.text.SimpleDateFormat;
import java.util.*;
/**
* 单据操作插件-借款单推送费控系统
* 单据操作插件
* 智慧财务--借款单推送费控系统-生成员工还款单
* @author LiGuiQiang
*/
public class LoanPushSapOperation extends AbstractOperationServicePlugIn implements Plugin {
private final static Log logger = LogFactory.getLog(LoanPushSapOperation.class);
private static final String INTERFACE_ID ="GeneraRepayBill";//识别被调接口并进行路由-员工借款
private static final String INTERFACE_ID = "GeneraRepayBill";//识别被调接口并进行路由-员工借款
private static final String RECEIVER_ID ="FeiKong";//定义的发送者
private static final String RECEIVER_ID = "FeiKong";//定义的发送者
private static final String API_URL = System.getProperty("url_a");
/**
* 操作标识
@ -75,7 +78,7 @@ public class LoanPushSapOperation extends AbstractOperationServicePlugIn impleme
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
//TODO:调用SAP预付款单接口
//TODO:调用费控生成员工还款单接口
String operationKey = e.getOperationKey();
if (StringUtils.equals(KEY_PUSH_LOAN, operationKey)) {
DynamicObject[] dataEntities = e.getDataEntities();
@ -90,12 +93,13 @@ public class LoanPushSapOperation extends AbstractOperationServicePlugIn impleme
HashMap<String, String> responseHead = ApiUtils.buildHead(INTERFACE_ID,RECEIVER_ID);
HashMap<String, Object> responseBody = this.assembleRequest(INTERFACE_ID,billNumber, recBill,message);
try {
String response = ApiUtils.sendPost(responseHead, responseBody, "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send");
String response = ApiUtils.sendPost(responseHead, responseBody, API_URL);
if (!response.isEmpty()) {
this.parseResponse(recBill,response, billNumber, responseBody, INTERFACE_ID, message);
}
} catch (IOException ex) {
message.append("收款处理【").append(billNumber).append("】:").append(ex.getMessage()).append("\n");
logger.info("调用费控员工还款接口异常"+ message);
}
if (message.length()!=0){
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
@ -152,12 +156,12 @@ public class LoanPushSapOperation extends AbstractOperationServicePlugIn impleme
}
}
String voucherNumber = (String) rowDataModel.getValue(KEY_VOUCHER_NUM);
if (voucherNumber.isEmpty()) {
this.addErrorMessage(dataEntity, "" + billNo + "】SAP凭证不能为空!");
if (EsbUtils.isEmpty(voucherNumber)) {
this.addErrorMessage(dataEntity, "" + billNo + "】SAP凭证不能为空!");
}
boolean result = (boolean) rowDataModel.getValue(KEY_IS_PUSH_FI);
if (result) {
this.addErrorMessage(dataEntity, "" + billNo + "】已推送费控,请勿重复推送!");
this.addErrorMessage(dataEntity, "" + billNo + "】已推送费控,请勿重复推送!");
}
}
}
@ -202,12 +206,12 @@ public class LoanPushSapOperation extends AbstractOperationServicePlugIn impleme
//创建人工号
//header.put("FM_CreateUserCode", recBill.getString("creator.number"));
header.put("FM_CreateUserCode", "GH017994");
header.put("FM_CurrencyCode", "RMB");
header.put("FM_CurrencyCode", "RMB");//币别编号 默认为人民币
//单据主题
header.put("FM_RequestName", "员工还款推送测试");
header.put("FM_RequestName", "员工还款"+billNumber);
//附件URL地址
//HashMap<String, String> url = new HashMap<>(2);
header.put("FM_AttachUr", new ArrayList<>());
//header.put("FM_AttachUr", new ArrayList<>());
//事项描述
header.put("Remark", "测试");
List<Map<String, Object>> body = new ArrayList<>();

View File

@ -27,8 +27,8 @@ import java.text.SimpleDateFormat;
import java.util.*;
/**
* 单据操作插件-预付款退回推送费控系统
*
* 单据操作插件
* 智慧财务--预付款退回推送费控系统-生成预付款退回单
* @author LiGuiQiang
*/
public class PaymentPushSapOperation extends AbstractOperationServicePlugIn implements Plugin {
@ -38,6 +38,9 @@ public class PaymentPushSapOperation extends AbstractOperationServicePlugIn impl
private static final String INTERFACE_ID ="GeneraGTH";//识别被调接口并进行路由-员工借款
private static final String RECEIVER_ID ="FeiKong";//定义的发送者
private static final String API_URL = System.getProperty("url_a");
/**
* 操作标识
*/
@ -74,7 +77,7 @@ public class PaymentPushSapOperation extends AbstractOperationServicePlugIn impl
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
//TODO:调用SAP预付款单接口
//TODO:调用生成预付款退回单接口
String operationKey = e.getOperationKey();
if (StringUtils.equals(KEY_PUSH_PAYMENT, operationKey)) {
DynamicObject[] dataEntities = e.getDataEntities();
@ -89,12 +92,13 @@ public class PaymentPushSapOperation extends AbstractOperationServicePlugIn impl
HashMap<String, String> responseHead = ApiUtils.buildHead(INTERFACE_ID,RECEIVER_ID);
HashMap<String, Object> responseBody = this.assembleRequest(INTERFACE_ID,billNumber, recBill,message);
try {
String response = ApiUtils.sendPost(responseHead, responseBody, "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send");
String response = ApiUtils.sendPost(responseHead, responseBody, API_URL);
if (!response.isEmpty()) {
this.parseResponse(recBill,response, billNumber, responseBody, INTERFACE_ID, message);
}
} catch (IOException ex) {
message.append("收款处理【").append(billNumber).append("】:").append(ex.getMessage()).append("\n");
logger.info("调用费控预付款退回接口异常"+ message);
}
if (message.length()!=0){
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
@ -147,18 +151,18 @@ public class PaymentPushSapOperation extends AbstractOperationServicePlugIn impl
String number = type.getString("number");
if (null != number) {
if (!"103".equals(number)) {
// 校验不通过输出一条错误提示
//校验不通过输出一条错误提示
this.addErrorMessage(dataEntity, ""+billNo+"】收款类型不符!");
}
}
}
String voucherNumber = (String) rowDataModel.getValue(KEY_VOUCHER_NUM);
if (voucherNumber.isEmpty()) {
this.addErrorMessage(dataEntity, ""+billNo+"】SAP凭证不能为空!");
if (EsbUtils.isEmpty(voucherNumber)) {
this.addErrorMessage(dataEntity, ""+billNo+"】SAP凭证不能为空!");
}
boolean result = (boolean) rowDataModel.getValue(KEY_IS_PUSH_FI);
if (result){
this.addErrorMessage(dataEntity, ""+billNo+"】已推送费控,请勿重复推送!");
this.addErrorMessage(dataEntity, ""+billNo+"】已推送费控,请勿重复推送!");
}
}
}
@ -194,8 +198,8 @@ public class PaymentPushSapOperation extends AbstractOperationServicePlugIn impl
//部门编码
header.put("FM_DeptCode", recBill.getDynamicObjectCollection("entry").get(0).getString("shjh_deptcode"));
//供应商编码
//header.put("FM_SupplierCode", getSupOrCusNumber(recBill));
header.put("FM_SupplierCode", "6000003");
header.put("FM_SupplierCode", getSupOrCusNumber(recBill));
// header.put("FM_SupplierCode", "6000003");
//员工工号
header.put("FM_UserCode", recBill.getDynamicObjectCollection("entry").get(0).getString("shjh_usercode"));
//成本中心编码
@ -204,12 +208,12 @@ public class PaymentPushSapOperation extends AbstractOperationServicePlugIn impl
//创建人工号
header.put("FM_CreateUserCode", recBill.getString("creator.number"));
//header.put("FM_CreateUserCode", "GH017994");//测试用
header.put("FM_CurrencyCode", "RMB");
header.put("FM_CurrencyCode", "RMB");//币别编号 默认为人民币
//单据主题
header.put("FM_RequestName", "退预付款推送测试");
header.put("FM_RequestName", "预付款退回单"+billNumber);
//附件URL地址
//HashMap<String, String> url = new HashMap<>(2);
header.put("FM_AttachUr", new ArrayList<>());
//header.put("FM_AttachUr", new ArrayList<>());
//事项描述
header.put("Remark", "测试");
List<Map<String, Object>> body = new ArrayList<>();
@ -240,8 +244,6 @@ public class PaymentPushSapOperation extends AbstractOperationServicePlugIn impl
return responseBody;
}
/**
* 日志记录
*

View File

@ -1,9 +1,6 @@
package shjh.jhzj7.fi.fi.plugin.operate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.formula.RowDataModel;
@ -17,7 +14,6 @@ import kd.bos.entity.validate.ErrorLevel;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.ApiUtils;
import shjh.jhzj7.fi.fi.utils.EsbUtils;
@ -25,23 +21,27 @@ import shjh.jhzj7.fi.fi.utils.SysUtils;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
/**
* 单据操作插件
* 智慧财务-冲销接口
* 智慧财务-冲销接口--预付款退回单/员工还款单作废
* @author LiGuiQiang
*/
public class RebReversalFiOperation extends AbstractOperationServicePlugIn implements Plugin {
private final static Log logger = LogFactory.getLog(RebReversalFiOperation.class);
private static final String INTERFACE_ID ="BillInvalid";//识别被调接口并进行路由-员工借款
private static final String INTERFACE_ID = "BillInvalid";//识别被调接口并进行路由-员工借款
private static final String RECEIVER_ID ="FeiKong";//定义的发送者
private static final String RECEIVER_ID = "FeiKong";//定义的发送者
private static final String API_URL = System.getProperty("url_a");
/**
* 操作标识
* 冲销操作标识
*/
private static final String KEY_REVERSAL = "reversal";
@ -90,7 +90,7 @@ public class RebReversalFiOperation extends AbstractOperationServicePlugIn imple
/**
* 是否已推送费控
*/
public final static String KEY_IS_PUSH_FI ="shjh_ispushfc";
public final static String KEY_IS_PUSH_FI = "shjh_ispushfc";
@Override
public void validate() {
@ -106,7 +106,7 @@ public class RebReversalFiOperation extends AbstractOperationServicePlugIn imple
if (null != type) {
String number = type.getString("number");
if (null != number) {
if (!"109".equals(number)&&!"103".equals(number)) {
if (!"109".equals(number) && !"103".equals(number)) {
// 校验不通过输出一条错误提示
this.addErrorMessage(dataEntity, "" + billNo + "】收款类型不符!");
}
@ -114,7 +114,7 @@ public class RebReversalFiOperation extends AbstractOperationServicePlugIn imple
}
boolean result = (boolean) rowDataModel.getValue(KEY_IS_PUSH_FI);
if (!result) {
this.addErrorMessage(dataEntity, "" + billNo + "未推送费控,无法冲销!");
this.addErrorMessage(dataEntity, "" + billNo + "未推送费控,无法冲销!");
}
}
}
@ -124,7 +124,7 @@ public class RebReversalFiOperation extends AbstractOperationServicePlugIn imple
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
//TODO:调用SAP预付款单接口
//TODO:调用费控的预付款退回单/员工还款单作废接口
String operationKey = e.getOperationKey();
if (StringUtils.equals(KEY_REVERSAL, operationKey)) {
DynamicObject[] dataEntities = e.getDataEntities();
@ -139,15 +139,16 @@ public class RebReversalFiOperation extends AbstractOperationServicePlugIn imple
HashMap<String, String> responseHead = ApiUtils.buildHead(INTERFACE_ID,RECEIVER_ID);
HashMap<String, Object> responseBody = this.assembleRequest(INTERFACE_ID,billNumber, recBill,message);
try {
String response = ApiUtils.sendPost(responseHead, responseBody, "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send");
String response = ApiUtils.sendPost(responseHead, responseBody, API_URL);
if (!response.isEmpty()) {
ApiUtils.parseResponse(response, billNumber, responseBody, INTERFACE_ID, message);
}
} catch (IOException ex) {
message.append("收款处理【").append(billNumber).append("】:").append(ex.getMessage()).append("\n");
logger.info("调用费控作废接口异常"+ message);
}
//错误消息
if (message.length()!=0){
if (message.length() != 0){
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
operateErrorInfo.setMessage(String.valueOf(message));
operateErrorInfo.setErrorLevel(ErrorLevel.Error.name());

View File

@ -8,7 +8,6 @@ import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.formula.RowDataModel;
import kd.bos.entity.operate.result.OperateErrorInfo;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
@ -21,27 +20,22 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.fi.cas.helper.VoucherBookHelper;
import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.plugin.form.info.RecFieldsInfo;
import shjh.jhzj7.fi.fi.utils.ApiUtils;
import shjh.jhzj7.fi.fi.utils.EsbUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import shjh.jhzj7.fi.fi.utils.SysUtils;
import shjh.jhzj7.fi.fi.utils.domin.ResponseData;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import static shjh.jhzj7.fi.fi.utils.SapUtils.sap_accounVoucher;
/**
* 单据操作插件
* 收款单推送SAP凭证
* 收款单收款凭证推送SAP会计凭证接口
*/
public class RecPushVoucherOperation extends AbstractOperationServicePlugIn implements Plugin {
@ -136,7 +130,7 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
//TODO:调用SAP预付款单接口
//TODO:调用SAP会计凭证接口
String operationKey = e.getOperationKey();
if (StringUtils.equals(KEY_PUSH_VOUCHER, operationKey)) {
DynamicObject[] dataEntities = e.getDataEntities();
@ -149,7 +143,7 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl
data.put("IS_HEADER", getIS_HEADER(recBill));
//详细参考IT_ITEM
JSONArray itItem = getIT_ITEM(recBill);
if (itItem==null){
if (itItem == null){
this.getOperationResult().setSuccess(false);//成功true;失败false
this.getOperationResult().setMessage("凭证不存在或未审核"); // 提示内容
this.getOperationResult().setShowMessage(true); // 是否显示提示消息
@ -313,7 +307,7 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl
IT_ITEMS.put("HKONT", account.getString("number"));
//查找核算维度
DynamicObjectCollection checkItems = account.getDynamicObjectCollection("checkitementry");
if (checkItems!=null&&checkItems.size()!=0){
if (checkItems!=null && checkItems.size()!=0){
//是否已经反写
boolean isMark=false;
for (DynamicObject checkItem : checkItems) {
@ -321,7 +315,7 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl
String assTactItemName = checkItem.getString("asstactitem.name");
if (assTactItemName!=null){
switch (assTactItemName){
case "客户":
case "客户-获利段":
case "客户编码":
IT_ITEMS.put("KUNNR", cusOrSupNumber);
isMark=true;
@ -350,7 +344,7 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl
case "1": // 借方
amount = debitlocal;
break;
case "-1": // 贷方
case "-1": // 贷方 sap通过负数体现贷方
amount = creditlocal.negate();
break;
default:

View File

@ -30,7 +30,7 @@ import java.util.*;
/**
* 单据操作插件
* SAP反清账接口按钮
* SAP反清账接口按钮-红字收款单使用该操作推送sap
*/
public class RecRedPushOperation extends AbstractOperationServicePlugIn implements Plugin {
@ -39,6 +39,8 @@ public class RecRedPushOperation extends AbstractOperationServicePlugIn implemen
private static final String INTERFACE_ID ="ReversalVoucher";//识别被调接口并进行路由-SAP反清账
private static final String RECEIVER_ID ="SAP";//定义的发送者
private static final String API_URL = System.getProperty("url_a");//sap相关接口地址
/**
* 操作标识
*/
@ -87,11 +89,11 @@ public class RecRedPushOperation extends AbstractOperationServicePlugIn implemen
String billNum = (String) rowDataModel.getValue(KEY_BILL_NUM);
String hotAccount = (String) rowDataModel.getValue(KEY_HOT_ACCOUNT);
if (!"2".equals(hotAccount)) {
this.addErrorMessage(dataEntity, billNum+"所选单据不符合反清账要求。");
this.addErrorMessage(dataEntity, billNum+"所选单据不符合收款红冲要求。");
}
Boolean isPushSap = (Boolean) rowDataModel.getValue(IS_PUSH_SAP);
if (isPushSap){
this.addErrorMessage(dataEntity, billNum+"所选单据已反清账");
this.addErrorMessage(dataEntity, billNum+"所选红冲单据已推送至SAP");
}
}
}
@ -115,7 +117,7 @@ public class RecRedPushOperation extends AbstractOperationServicePlugIn implemen
HashMap<String, String> responseHead = ApiUtils.buildHead(INTERFACE_ID,RECEIVER_ID);
HashMap<String, Object> responseBody = this.assembleRequest(billNumber, recBill,message);
try {
String response = ApiUtils.sendPost(responseHead, responseBody, "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send");
String response = ApiUtils.sendPost(responseHead, responseBody, API_URL);
if (!response.isEmpty()) {
boolean success = ApiUtils.parseResponse(response, billNumber, responseBody, INTERFACE_ID, message);
if (success){
@ -125,6 +127,7 @@ public class RecRedPushOperation extends AbstractOperationServicePlugIn implemen
}
} catch (IOException ex) {
message.append("收款处理【").append(billNumber).append("】:").append(ex.getMessage()).append("\n");
logger.info("调用收款红冲凭证接口异常"+message);
}
if (message.length()!=0){
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();

View File

@ -121,33 +121,31 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
voucherFilters.toArray());
if (null != gl_voucher) {
DynamicObjectCollection entries = gl_voucher.getDynamicObjectCollection("entries");
if (!entries.isEmpty()) {
JSONObject item;
DynamicObject account;
BigDecimal creditlocal;
for (DynamicObject entry : entries) {
item = new JSONObject();
account = entry.getDynamicObject("account");//科目
if (null != account) {
item.put("HKONT", account.getString("number")); //总账科目_科目(凭证分录account)
}
//获取贷方金额
creditlocal = entry.getBigDecimal("creditlocal");//贷方
//获取分录借贷方向
String entrydc = (String) entry.get("entrydc");//分录方向(1.借方,-1.贷方)
if ("1".equals(entrydc)) {
//设置sap凭证借方金额
item.put("DMBTR", String.valueOf(entry.getBigDecimal("debitlocal")));
} else if ("-1".equals(entrydc)) {
//设置sap凭证贷方金额 sap通过负数体现贷方
item.put("DMBTR", String.valueOf(creditlocal.negate()));
}
JSONObject item;
DynamicObject account;
BigDecimal creditlocal;
for (DynamicObject entry : entries) {
item = new JSONObject();
account = entry.getDynamicObject("account");//科目
if (null != account) {
item.put("HKONT", account.getString("number")); //总账科目_科目(凭证分录account)
}
//获取贷方金额
creditlocal = entry.getBigDecimal("creditlocal");//贷方
//获取分录借贷方向
String entrydc = (String) entry.get("entrydc");//分录方向(1.借方,-1.贷方)
if ("1".equals(entrydc)) {
//设置sap凭证借方金额
item.put("DMBTR", String.valueOf(entry.getBigDecimal("debitlocal")));
} else if ("-1".equals(entrydc)) {
//设置sap凭证贷方金额 sap通过负数体现贷方
item.put("DMBTR", String.valueOf(creditlocal.negate()));
}
// item.put("RSTGR", "014");//原因代码_原因码
// item.put("SGTXT", SGTXT);//行项目文本_SAP会计科目行项目号
// item.put("KOSTL",KOSTL);//成本中心_成本中心
// item.put("PRCTR",PRCTR);//利润中心_利润中心
IT_ITEM.add(item);
}
IT_ITEM.add(item);
}
}else{
String billNo = prinfo.getString("billno");

View File

@ -27,11 +27,11 @@ import java.util.concurrent.TimeUnit;
*/
public class ApiUtils {
static Log logger = LogFactory.getLog(ApiUtils.class);
static Log logger = LogFactory.getLog(ApiUtils.class);
//接口地址-测试地址
// private static final String API_URL="https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";
private static final String API_URL = System.getProperty("url_a");//sap相关接口地址
private static final String API_URL = System.getProperty("url_a");//接口地址从MC获取
public static final String APIKey = System.getProperty("APIKey");//ESB提供的接口访问APIKey