1.(费控-SAP付款凭证号接口,自定义插件)
2.(付款单确认付款生成_银行日记账单携带SAP应付凭证号) --s
This commit is contained in:
parent
2358d450f0
commit
31be8eb1bd
|
|
@ -0,0 +1,34 @@
|
||||||
|
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||||
|
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.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 付款单_付款操作
|
||||||
|
* shjh_cas_paybill_ext
|
||||||
|
*/
|
||||||
|
public class PaybillPayOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||||
|
super.afterExecuteOperationTransaction(e);
|
||||||
|
//付款操作之后查询有无单号为该付款单(cas_paybill)的银行日记账单(cas_bankjournal)
|
||||||
|
DynamicObject[] dataEntities = e.getDataEntities();
|
||||||
|
for (DynamicObject bill : dataEntities) {
|
||||||
|
bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(),"cas_paybill");
|
||||||
|
|
||||||
|
DynamicObject bankjournal = BusinessDataServiceHelper.loadSingle("cas_bankjournal", new QFilter("billno",
|
||||||
|
QCP.equals, bill.getString("billno")).toArray());
|
||||||
|
if (null != bankjournal) {
|
||||||
|
bankjournal.set("shjh_credentialnum",bill.getString("shjh_credentialnum"));
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{bankjournal});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -141,7 +141,7 @@ public class SapUtils {
|
||||||
// 组装请求体
|
// 组装请求体
|
||||||
JSONObject withholdingBody = withholdingBody(data);
|
JSONObject withholdingBody = withholdingBody(data);
|
||||||
// 发送请求并处理响应
|
// 发送请求并处理响应
|
||||||
return processRequest(withholdingBody, thirdPartyMap, Apimenthod2);
|
return processRequest(withholdingBody, thirdPartyMap, Apimenthod3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -369,11 +369,10 @@ public class ApplyAdjustBillControler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据公司编号加载组织信息
|
* 根据公司编号加载组织信息
|
||||||
*
|
|
||||||
* @param companyNum 公司编号
|
* @param companyNum 公司编号
|
||||||
* @return 组织信息的动态对象
|
* @return 组织信息的动态对象
|
||||||
*/
|
*/
|
||||||
private DynamicObject loadOrgByCompanyNum(String companyNum) {
|
public static DynamicObject loadOrgByCompanyNum(String companyNum) {
|
||||||
QFilter Q1 = new QFilter("number", QCP.equals, companyNum);
|
QFilter Q1 = new QFilter("number", QCP.equals, companyNum);
|
||||||
return BusinessDataServiceHelper.loadSingle(orgEntName, new QFilter[]{Q1});
|
return BusinessDataServiceHelper.loadSingle(orgEntName, new QFilter[]{Q1});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
package shjh.jhzj7.fi.fi.webapi;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONException;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.drew.lang.annotations.NotNull;
|
||||||
|
import kd.bos.api.client.ApiResult;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
|
import kd.bos.openapi.common.custom.annotation.ApiController;
|
||||||
|
import kd.bos.openapi.common.custom.annotation.ApiPostMapping;
|
||||||
|
import kd.bos.openapi.common.custom.annotation.ApiRequestBody;
|
||||||
|
import kd.bos.openapi.common.result.CustomApiResult;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||||
|
import shjh.jhzj7.fi.fi.webapi.model.PaybillVoucherNumModel;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static shjh.jhzj7.fi.fi.webapi.ApplyAdjustBillControler.loadOrgByCompanyNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 费控-SAP付款凭证号接口
|
||||||
|
*/
|
||||||
|
@ApiController(value = "VouchernumControler", desc = "费控-SAP付款凭证号接口,自定义插件")
|
||||||
|
public class VouchernumControler {
|
||||||
|
private static final String Apimenthod = "费控-SAP付款凭证号接口";
|
||||||
|
private static final Log log = LogFactory.getLog(VouchernumControler.class);
|
||||||
|
private static final String apimenthod = "/paybill_vouchernum";
|
||||||
|
|
||||||
|
@ApiPostMapping(value = apimenthod, desc = "费控-SAP付款凭证号接口")
|
||||||
|
public CustomApiResult<ApiResult> paybill_vouchernum(@NotNull @Valid @ApiRequestBody(value = "入参json格式数据") PaybillVoucherNumModel paybillVouchertbill) {
|
||||||
|
|
||||||
|
//select fopenorgid from T_CAS_PaymentBill where fbillno = 'FKZJ2025030006';
|
||||||
|
//select * from t_org_org where fid = 2116753963226241024;
|
||||||
|
JSONObject json_body;
|
||||||
|
String jsonBodyString = null;
|
||||||
|
try {
|
||||||
|
// 解析入参,如果格式不正确,日志记录,并反馈esb7.4.1
|
||||||
|
json_body = (JSONObject) JSON.toJSON(paybillVouchertbill);
|
||||||
|
jsonBodyString = JSON.toJSONString(json_body);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return handleErrorAndReturn("费控-SAP付款凭证号接口入参异常:" + e.getMessage(), "费控-SAP付款凭证号接口", null);
|
||||||
|
}
|
||||||
|
List<PaybillVoucherNumModel.EntryBean> items = paybillVouchertbill.getItems();
|
||||||
|
for (PaybillVoucherNumModel.EntryBean item : items) {
|
||||||
|
String companyNum = item.getCompanyNum();//公司编号_对应金蝶财务组织
|
||||||
|
String fkBillID = item.getFkBillID();//费控单据主表ID
|
||||||
|
String fkEntryID = item.getFkEntryID();//费控单据分录ID
|
||||||
|
String voucherNum = item.getVoucherNum();//SAP凭证号_存
|
||||||
|
Date voucherDate = item.getVoucherDate();//SAP凭证过账日期_yyyy-MM-dd_存
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String formattedDate = sdf.format(voucherDate);
|
||||||
|
Date formattedDateAsDate = null;
|
||||||
|
try {
|
||||||
|
// 将字符串类型转换回 Date 类型
|
||||||
|
formattedDateAsDate = sdf.parse(formattedDate);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
// 处理解析异常
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject org = loadOrgByCompanyNum(companyNum);
|
||||||
|
if (org == null) {
|
||||||
|
return handleErrorAndReturn("同步失败,凭证号:" + voucherNum + "的组织编码不存在", voucherNum, jsonBodyString);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取付款单
|
||||||
|
QFilter q1 = new QFilter("openorg.number", QCP.equals, companyNum);
|
||||||
|
QFilter q2 = new QFilter("shjh_fkbillid", QCP.equals, fkBillID);
|
||||||
|
QFilter q3 = new QFilter("shjh_fkentryid", QCP.equals, fkEntryID);
|
||||||
|
DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{q1, q2, q3});
|
||||||
|
if (null == paybill) {
|
||||||
|
return handleErrorAndReturn("同步失败:"+companyNum+"_"+fkBillID+"_"+fkEntryID+",付款单不存在", fkEntryID, jsonBodyString);
|
||||||
|
}
|
||||||
|
DynamicObject bankjournal = BusinessDataServiceHelper.loadSingle("cas_bankjournal", new QFilter("billno",
|
||||||
|
QCP.equals, paybill.getString("billno")).toArray());
|
||||||
|
//同步更新银行日记账单(cas_bankjournal)的SAP付款凭证号,若没有下游单据,付款操作后执行携带(PaybillPayOperation)
|
||||||
|
if (null != bankjournal) {
|
||||||
|
bankjournal.set("shjh_credentialnum",voucherNum);
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{bankjournal});
|
||||||
|
}
|
||||||
|
|
||||||
|
paybill.set("shjh_credentialnum",voucherNum);//SAP付款凭证号
|
||||||
|
paybill.set("shjh_voucherdate",formattedDateAsDate);//SAP凭证过账日期
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{paybill});
|
||||||
|
}
|
||||||
|
return CustomApiResult.success(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理错误并返回失败结果
|
||||||
|
*
|
||||||
|
* @param errorMessage 错误信息
|
||||||
|
* @param fkBillNum 费控单据编号
|
||||||
|
* @param jsonBodyString 入参JSON字符串
|
||||||
|
* @return 失败的CustomApiResult对象
|
||||||
|
*/
|
||||||
|
public static CustomApiResult<ApiResult> handleErrorAndReturn(String errorMessage, String fkBillNum, String jsonBodyString) {
|
||||||
|
handleError(errorMessage, fkBillNum, jsonBodyString);
|
||||||
|
return CustomApiResult.fail("400", errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理错误日志
|
||||||
|
*
|
||||||
|
* @param errorMessage 错误信息
|
||||||
|
* @param fkBillNum 费控单据编号
|
||||||
|
* @param jsonBodyString 入参JSON字符串
|
||||||
|
*/
|
||||||
|
public static void handleError(String errorMessage, String fkBillNum, String jsonBodyString) {
|
||||||
|
log.error(errorMessage);
|
||||||
|
// 可以添加更多的错误处理逻辑,如记录到数据库等
|
||||||
|
JhzjUtils.saveLog(fkBillNum, Apimenthod, jsonBodyString, errorMessage, false, "API");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
package shjh.jhzj7.fi.fi.webapi.model;
|
||||||
|
|
||||||
|
import kd.bos.openapi.common.custom.annotation.ApiModel;
|
||||||
|
import kd.bos.openapi.common.custom.annotation.ApiParam;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel
|
||||||
|
public class PaybillVoucherNumModel {
|
||||||
|
|
||||||
|
@ApiParam(value="明细数据集合",required=false,position=1)
|
||||||
|
private List<PaybillVoucherNumModel.EntryBean> items;
|
||||||
|
@ApiModel
|
||||||
|
public static class EntryBean implements Serializable {
|
||||||
|
@ApiParam(value="公司编号",required=true,position=1)
|
||||||
|
private String companyNum;
|
||||||
|
@ApiParam(value="费控单据主表ID",required=true,position=2)
|
||||||
|
private String fkBillID;
|
||||||
|
@ApiParam(value="费控单据分录ID",required=true,position=3)
|
||||||
|
private String fkEntryID;
|
||||||
|
@ApiParam(value="SAP凭证号",required=true,position=4)
|
||||||
|
private String voucherNum;
|
||||||
|
@ApiParam(value="SAP凭证过账日期",required=true,position=5)
|
||||||
|
private Date voucherDate;
|
||||||
|
|
||||||
|
public String getCompanyNum() {
|
||||||
|
return companyNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompanyNum(String companyNum) {
|
||||||
|
this.companyNum = companyNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFkBillID() {
|
||||||
|
return fkBillID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFkBillID(String fkBillID) {
|
||||||
|
this.fkBillID = fkBillID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFkEntryID() {
|
||||||
|
return fkEntryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFkEntryID(String fkEntryID) {
|
||||||
|
this.fkEntryID = fkEntryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVoucherNum() {
|
||||||
|
return voucherNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoucherNum(String voucherNum) {
|
||||||
|
this.voucherNum = voucherNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getVoucherDate() {
|
||||||
|
return voucherDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVoucherDate(Date voucherDate) {
|
||||||
|
this.voucherDate = voucherDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EntryBean> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<EntryBean> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue