From 0d08c351c31db926ba7505b3d8daf323cd5370b7 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Tue, 18 Mar 2025 15:20:18 +0800 Subject: [PATCH] =?UTF-8?q?=20=201.=E4=BC=98=E5=8C=96=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E5=9B=9E=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --s --- .../fi/webapi/PayreceiptQueryControler.java | 54 +++++---- .../fi/fi/webapi/model/ApiResultExt.java | 105 ++++++++++++++++++ .../fi/webapi/model/ApplyAdjustBillModel.java | 3 +- .../fi/fi/webapi/model/ApplyBillModel.java | 3 +- .../webapi/model/PaybillVoucherNumModel.java | 2 +- .../fi/webapi/model/PayreceiptQueryModel.java | 2 +- 6 files changed, 146 insertions(+), 23 deletions(-) create mode 100644 main/java/shjh/jhzj7/fi/fi/webapi/model/ApiResultExt.java diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java b/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java index 9dedf10..7d5e0b0 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java @@ -17,10 +17,12 @@ import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import shjh.jhzj7.fi.fi.utils.JhzjUtils; +import shjh.jhzj7.fi.fi.webapi.model.ApiResultExt; import shjh.jhzj7.fi.fi.webapi.model.PaybillVoucherNumModel; import shjh.jhzj7.fi.fi.webapi.model.PayreceiptQueryModel; import javax.validation.Valid; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -37,8 +39,9 @@ public class PayreceiptQueryControler { private static final String apimenthod = "/payreceipt_query"; @ApiPostMapping(value = apimenthod, desc = "付款电子回单查询接口") - public CustomApiResult paybill_vouchernum(@NotNull @Valid @ApiRequestBody(value = "入参json格式数据") PayreceiptQueryModel PayreceiptQuerybill) { - + public CustomApiResult paybill_vouchernum(@NotNull @Valid @ApiRequestBody(value = "入参json格式数据") PayreceiptQueryModel PayreceiptQuerybill) { + //返回值 + ApiResultExt apiResultExt = new ApiResultExt(); //select * from T_CAS_PaymentBill where fbillno = 'FKZJ2025030006'; 2168985504052162560 //select * from t_org_org where fid = 2116753963226241024; JSONObject json_body; @@ -48,12 +51,10 @@ public class PayreceiptQueryControler { json_body = (JSONObject) JSON.toJSON(PayreceiptQuerybill); jsonBodyString = JSON.toJSONString(json_body); } catch (JSONException e) { - return handleErrorAndReturn("付款电子回单查询接口入参异常:" + e.getMessage(), Apimenthod, null); + return handleErrorAndReturn("付款电子回单查询接口入参异常:" + e.getMessage(), Apimenthod, null,apiResultExt); } - //返回值 - ApiResult customApiResult = new ApiResult(""); - HashMap map = new HashMap<>(); + List entryBeans = new ArrayList<>(); List items = PayreceiptQuerybill.getItems(); for (PayreceiptQueryModel.EntryBean item : items) { String companyNum = item.getCompanyNum();//公司编号 @@ -64,7 +65,7 @@ public class PayreceiptQueryControler { DynamicObject org = loadOrgByCompanyNum(companyNum); if (org == null) { - return handleErrorAndReturn("同步失败,费控单据编号:" + fkBillNumber + "的组织编码不存在", fkBillNumber, jsonBodyString); + return handleErrorAndReturn("同步失败,费控单据编号:" + fkBillNumber + "的组织编码不存在", fkBillNumber, jsonBodyString,apiResultExt); } QFilter q1 = new QFilter("openorg.number", QCP.equals, companyNum); @@ -73,18 +74,17 @@ public class PayreceiptQueryControler { q1 = addFilterIfNotEmpty(q1, "shjh_fkentryid", fkEntryID); DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{q1}); if (null == paybill) { - return handleErrorAndReturn("同步失败:付款单不存在", fkEntryID, jsonBodyString); + return handleErrorAndReturn("同步失败:付款单不存在", fkEntryID, jsonBodyString,apiResultExt); } - - customApiResult.setHeaders(map); - customApiResult.getHeaders().put("companyNum",companyNum); - customApiResult.getHeaders().put("kdPayBillID", String.valueOf(paybill.getPkValue())); - customApiResult.getHeaders().put("fkBillID",paybill.getString("shjh_fkbillid")); - customApiResult.getHeaders().put("fkEntryID",paybill.getString("shjh_fkentryid")); - customApiResult.getHeaders().put("receipturl","https://fm-test.jahwa.com.cn/ierp/?formId=home_page"); + ApiResultExt.EntryBean entryBean = new ApiResultExt.EntryBean(); + entryBean.setCompanyNum(companyNum); + entryBean.setKdPayBillID(String.valueOf(paybill.getPkValue())); + entryBean.setFkBillID(paybill.getString("shjh_fkbillid")); + entryBean.setFkEntryID(paybill.getString("shjh_fkentryid")); + entryBean.setReceipturl("https://fm-test.jahwa.com.cn/ierp/?formId=home_page"); + entryBeans.add(entryBean); } - - return CustomApiResult.success(customApiResult); + return handleSuccessAndReturn(apiResultExt, entryBeans); } private static QFilter addFilterIfNotNull(QFilter baseFilter, String field, Long value) { @@ -111,9 +111,25 @@ public class PayreceiptQueryControler { * @param jsonBodyString 入参JSON字符串 * @return 失败的CustomApiResult对象 */ - public static CustomApiResult handleErrorAndReturn(String errorMessage, String fkBillNum, String jsonBodyString) { + public static CustomApiResult handleErrorAndReturn(String errorMessage, String fkBillNum, String jsonBodyString,ApiResultExt apiResultExt) { handleError(errorMessage, fkBillNum, jsonBodyString); - return CustomApiResult.fail("400", errorMessage); + apiResultExt.setErrorCode("400"); + apiResultExt.setStatus(false); + apiResultExt.setData(null); + apiResultExt.setMessage(errorMessage); + return CustomApiResult.success(apiResultExt); + } + + /** + * 处理成功并返回结果 + * @return 成功的CustomApiResult对象 + */ + public static CustomApiResult handleSuccessAndReturn(ApiResultExt apiResultExt, List entryBeans) { + apiResultExt.setErrorCode("0"); + apiResultExt.setStatus(true); + apiResultExt.setData(entryBeans); + apiResultExt.setMessage(null); + return CustomApiResult.success(apiResultExt); } /** diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/model/ApiResultExt.java b/main/java/shjh/jhzj7/fi/fi/webapi/model/ApiResultExt.java new file mode 100644 index 0000000..8a80bcc --- /dev/null +++ b/main/java/shjh/jhzj7/fi/fi/webapi/model/ApiResultExt.java @@ -0,0 +1,105 @@ +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.util.List; + +@ApiModel +public class ApiResultExt implements Serializable { + + @ApiParam("接口访问是否成功") + private Boolean status; + @ApiParam("错误码") + private String errorCode; + @ApiParam("接口调用错误信息") + private String message; + @ApiParam("明细数据集合") + private List data; + @ApiModel + public static class EntryBean implements Serializable { + @ApiParam("公司编号") + private String companyNum; + @ApiParam("金蝶付款单ID") + private String kdPayBillID; + @ApiParam("费控单据主表ID") + private String fkBillID; + @ApiParam("费控单据分录ID") + private String fkEntryID; + @ApiParam("电子回单的URL,有可能为空") + private String receipturl; + + public String getCompanyNum() { + return companyNum; + } + + public void setCompanyNum(String companyNum) { + this.companyNum = companyNum; + } + + public String getKdPayBillID() { + return kdPayBillID; + } + + public void setKdPayBillID(String kdPayBillID) { + this.kdPayBillID = kdPayBillID; + } + + 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 getReceipturl() { + return receipturl; + } + + public void setReceipturl(String receipturl) { + this.receipturl = receipturl; + } + } + + public Boolean getStatus() { + return status; + } + + public void setStatus(Boolean status) { + this.status = status; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } +} diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyAdjustBillModel.java b/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyAdjustBillModel.java index 9c30f96..780f1bf 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyAdjustBillModel.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyAdjustBillModel.java @@ -3,11 +3,12 @@ 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.math.BigDecimal; import java.util.Date; @ApiModel -public class ApplyAdjustBillModel { +public class ApplyAdjustBillModel implements Serializable { @ApiParam(value = "公司编号", required = true, position = 1) private String companyNum; diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyBillModel.java b/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyBillModel.java index eba97dc..342c19c 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyBillModel.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/model/ApplyBillModel.java @@ -2,9 +2,10 @@ 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.util.Date; @ApiModel -public class ApplyBillModel { +public class ApplyBillModel implements Serializable { @ApiParam(value="公司编号",required=true,position=1) private String companyNum; diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/model/PaybillVoucherNumModel.java b/main/java/shjh/jhzj7/fi/fi/webapi/model/PaybillVoucherNumModel.java index 08e36e7..c87cb86 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/model/PaybillVoucherNumModel.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/model/PaybillVoucherNumModel.java @@ -8,7 +8,7 @@ import java.sql.Date; import java.util.List; @ApiModel -public class PaybillVoucherNumModel { +public class PaybillVoucherNumModel implements Serializable{ @ApiParam(value="明细数据集合",required=true,position=1) private List items; diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/model/PayreceiptQueryModel.java b/main/java/shjh/jhzj7/fi/fi/webapi/model/PayreceiptQueryModel.java index 9bf4a53..eee7f1d 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/model/PayreceiptQueryModel.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/model/PayreceiptQueryModel.java @@ -8,7 +8,7 @@ import java.io.Serializable; import java.util.List; @ApiModel -public class PayreceiptQueryModel { +public class PayreceiptQueryModel implements Serializable{ @ApiParam(value="明细数据集合",required=true,position=1) private List items;