sap应收未清优化

This commit is contained in:
yuxueliang0813 2025-03-15 18:07:41 +08:00
parent c094710ceb
commit ab05e6bae9
6 changed files with 198 additions and 170 deletions

View File

@ -15,12 +15,11 @@ import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.ApiUtils; import shjh.jhzj7.fi.fi.utils.SapUtils;
import shjh.jhzj7.fi.fi.utils.EsbUtils;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.EventObject; import java.util.EventObject;
import java.util.HashMap;
/** /**
* 动态表单插件-SAP应收未清 shjh_sapyswq * 动态表单插件-SAP应收未清 shjh_sapyswq
@ -29,8 +28,7 @@ import java.util.HashMap;
public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin { public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
private final static Log logger = LogFactory.getLog(ASParbillFormPlugin.class); private final static Log logger = LogFactory.getLog(ASParbillFormPlugin.class);
private final static String entryID = "shjh_details";//分录标识 private final static String entryID = "shjh_entryentity";//分录标识
private final static String apiurl = "shjh_details";//接口地址
private static final String QUERY_BUTTON_KEY = "shjh_btnquery";//查询按钮 private static final String QUERY_BUTTON_KEY = "shjh_btnquery";//查询按钮
private static final String SELECTED_BUTTON_KEY = "shjh_btnok";//确认勾选按钮 private static final String SELECTED_BUTTON_KEY = "shjh_btnok";//确认勾选按钮
private static final String RESET_BUTTON_KEY = "shjh_btnreset";//重置按钮 private static final String RESET_BUTTON_KEY = "shjh_btnreset";//重置按钮
@ -64,6 +62,8 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
if("clearBillForm".equals(showParam.getCustomParam("Apikey"))){ if("clearBillForm".equals(showParam.getCustomParam("Apikey"))){
this.getView().setVisible(false, SELECTED_BUTTON_KEY); this.getView().setVisible(false, SELECTED_BUTTON_KEY);
} }
this.getModel().setValue("shjh_org",((JSONObject)showParam.getCustomParam("billorg")).getLong("id"));//公司从父页面带过来
this.getModel().setValue("shjh_customer",((JSONObject)showParam.getCustomParam("billcustomer")).getLong("id"));//客户从父页面带过来
} }
/** /**
@ -84,33 +84,31 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
String key = source.getKey(); String key = source.getKey();
if (StringUtils.equals(QUERY_BUTTON_KEY, key)) { if (StringUtils.equals(QUERY_BUTTON_KEY, key)) {
// 校验和获取过滤条件 // 校验和获取过滤条件
DynamicObject org = (DynamicObject) this.getModel().getValue("shjh_orgfield"); DynamicObject customer = (DynamicObject) this.getModel().getValue("shjh_customer");
if (customer == null) {
this.getView().showMessage("请选择一个客户!");
return;
}
String customerCode = customer.getString("number");
DynamicObject org = (DynamicObject) this.getModel().getValue("shjh_org");
if (org == null) { if (org == null) {
this.getView().showMessage("请选择公司!"); this.getView().showMessage("请选择一个公司!");
return; return;
} }
String orgrCode = org.getString("number");
Date startDate = (Date) this.getModel().getValue("shjh_startdate");
if (startDate == null) {
this.getView().showMessage("请选择开始日期!");
return;
}
Date endDate = (Date) this.getModel().getValue("shjh_enddate");
if (endDate == null) {
this.getView().showMessage("请选择结束日期!");
return;
}
String companyCode = org.getString("number");
// 点击查询按钮 // 点击查询按钮
handleQueryButtonClick(companyCode, startDate, endDate); handleQueryButtonClick(orgrCode,customerCode);
} else if (StringUtils.equals(SELECTED_BUTTON_KEY, key)) { } else if (StringUtils.equals(SELECTED_BUTTON_KEY, key)) {
// 点击选择按钮 // 点击选择按钮
handleSelectedButton(); handleSelectedButton();
} else if (StringUtils.equals(RESET_BUTTON_KEY, key)) { } else if (StringUtils.equals(RESET_BUTTON_KEY, key)) {
// 点击重置按钮 // 点击重置按钮
this.getModel().setValue("shjh_textfield",null); this.getModel().setValue("shjh_pzh",null);//SAP应收凭证号
this.getModel().setValue("shjh_kmbh",null);//总账科目编号
this.getModel().setValue("shjh_fph",null);//发票号
this.getModel().setValue("shjh_year",null);//会计年度
this.getModel().setValue("shjh_gzrq_startdate",null);//SAP应收凭过账日期
this.getModel().setValue("shjh_gzrq_enddate",null);//SAP应收凭过账日期
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("按钮处理异常:"+e.getMessage()); logger.error("按钮处理异常:"+e.getMessage());
@ -118,144 +116,124 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
} }
} }
// 添加过滤条件到IT_LIST的方法
public void addFilterCondition(JSONArray IT_LIST, String field, String low, String high) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("FIELD", field); // 字段
jsonObject.put("SIGN", "I"); // I:包含 E排除
jsonObject.put("LOW", low); // LOW 枚举字段所代表值的区间开始值
jsonObject.put("HIGH", high); // HIGH枚举字段所代表值的区间结束值
jsonObject.put("OPTION", "BT"); // 默认BT
IT_LIST.add(jsonObject);
}
/** /**
* 点击查询按钮 * 点击查询按钮
* @param companyCode 公司编码 * @param companyCode 公司编码
* @param startDate 开始日期 * @param customerCode 客户编码
* @param endDate 结束日期
*/ */
private void handleQueryButtonClick(String companyCode, Date startDate, Date endDate) { private void handleQueryButtonClick(String companyCode, String customerCode) {
try { try {
FormShowParameter showParameter = this.getView().getFormShowParameter(); FormShowParameter showParameter = this.getView().getFormShowParameter();
String apiKey = showParameter.getCustomParam("Apikey");
String billNumber = showParameter.getCustomParam("billNumber"); String billNumber = showParameter.getCustomParam("billNumber");
//组装入参调用SAP接口处理返回值 //组装查询入参 日期格式
handleSAPApi(companyCode, startDate, endDate, billNumber); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String shjh_pzh = (String) this.getModel().getValue("shjh_pzh");//SAP应收凭证号
String shjh_kmbh = (String) this.getModel().getValue("shjh_kmbh");//会计科目编号
String shjh_year = (String) this.getModel().getValue("shjh_year");//会计年度
Date postingdate_start = (Date) this.getModel().getValue("shjh_gzrq_startdate");//SAP应收凭过账日期(开始)
Date postingdate_endda = (Date) this.getModel().getValue("shjh_gzrq_enddate");//SAP应收凭过账日期(结束)
JSONArray IT_LIST = new JSONArray();
// 添加公司过滤条件
addFilterCondition(IT_LIST, "BUKRS", companyCode, companyCode);
// 添加客户过滤条件
addFilterCondition(IT_LIST, "KUNNR", customerCode, customerCode);
// 添加SAP应收凭证号过滤条件
if (StringUtils.isNotEmpty(shjh_pzh)) {
addFilterCondition(IT_LIST, "BELNR", shjh_pzh, shjh_pzh);
}
// 添加会计科目编号过滤条件
if (StringUtils.isNotEmpty(shjh_kmbh)) {
addFilterCondition(IT_LIST, "HKONT", shjh_kmbh, shjh_kmbh);
}
// 会计年度
if (StringUtils.isNotEmpty(shjh_year)) {
addFilterCondition(IT_LIST, "GJAHR", shjh_year, shjh_year);
}
// 添加SAP应收凭过账日期过滤条件
if (postingdate_start != null || postingdate_endda != null) {
String postingdate_starts = postingdate_start == null ? "" : sdf.format(postingdate_start);
String postingdate_enddas = postingdate_endda == null ? "" : sdf.format(postingdate_endda);
addFilterCondition(IT_LIST, "BUDAT", postingdate_starts, postingdate_enddas);
}
JSONObject sapReturnData = SapUtils.sapArAPI(IT_LIST,billNumber);
//sap返回的结果不为空且正确执行分录插入数据
if(sapReturnData != null && parseResponse(sapReturnData)){
JSONObject data = sapReturnData.getJSONObject("data");
JSONArray rows = data.getJSONArray("IT_ITEMS");
DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID);
entry.clear();
JSONObject detail;
for (int i = 0; i < rows.size(); i++) {
detail = (JSONObject) rows.get(i);
entry.addNew();
setEntityRowValues(detail, i);
}
this.getView().updateView(entryID); this.getView().updateView(entryID);
}
} catch (Exception e) { } catch (Exception e) {
logger.error("查询操作失败: " + e.getMessage()); logger.error("查询操作失败: " + e.getMessage());
this.getView().showMessage("查询操作失败"+e.getMessage()); this.getView().showMessage("查询操作失败"+e.getMessage());
} }
} }
/** private boolean parseResponse(JSONObject result) {
* 调用SAP接口
* @param companyCode 公司编码
* @param startDate 开始日期
* @param endDate 结束日期
* @param billNumber 本单单号日志记录用
*/
private void handleSAPApi(String companyCode, Date startDate, Date endDate, String billNumber) {
try {
DynamicObject supplier = (DynamicObject) this.getModel().getValue("shjh_supplier");
if (supplier == null) {
this.getView().showMessage("请选择供应商!");
return;
}
String supplierCode = supplier.getString("number");
String interfaceID="FMGetJahYFKList";
HashMap<String, String> head = ApiUtils.buildHead(interfaceID);
HashMap<String, Object> body = ApiUtils.buildBody(companyCode, null, startDate, endDate);
HashMap<String, Object> data = (HashMap<String, Object>) body.get("data");
// 添加额外的参数
data.put("SupplierCode", supplierCode);
data.put("IsWriteOffDetail", true);
String response = ApiUtils.sendPost(head, body, apiurl);
if (response != null) {
Boolean result = parseResponse(response, billNumber, String.valueOf(body), "预付款单清单查询接口");
if (result) {
handleAspApiResponse(response);
}
}
} catch (Exception e) {
logger.error("处理SAP应收未清接口时发生错误: "+e.getMessage());
this.getView().showMessage("处理SAP应收未清接口时发生错误"+e.getMessage());
}
}
/**
* 日志记录
* @param response 响应参数
* @param billNumber 本单单号
* @param body 请求体
* @param apiName 接口名
*/
private Boolean parseResponse(String response, String billNumber, String body, String apiName) {
JSONObject result = JSONObject.parseObject(response);
boolean success = false; boolean success = false;
if (null != result) {
String code = result.getString("code"); String code = result.getString("code");
String msg = result.getString("msg");
switch (code) { switch (code) {
case "0": case "0":
success = true; success = true;
EsbUtils.saveLog(billNumber, apiName, body, response, true, "ESBQueryApi", "查询成功");
break; break;
case "1": case "1":
this.getView().showMessage("服务异常"); this.getView().showMessage("服务异常:"+msg);
EsbUtils.saveLog(billNumber, apiName, body, response, false, "ESBQueryApi", "服务异常");
break; break;
case "2": case "2":
this.getView().showMessage("三方服务异常"); this.getView().showMessage("三方服务异常:"+msg);
EsbUtils.saveLog(billNumber, apiName, body, response, false, "ESBQueryApi", "三方服务异常");
break; break;
case "3": case "3":
this.getView().showMessage("业务异常"); this.getView().showMessage("业务异常:"+msg);
EsbUtils.saveLog(billNumber, apiName, body, response, false, "ESBQueryApi", "业务异常");
break; break;
default: default:
this.getView().showMessage("未知异常"); this.getView().showMessage("未知异常:"+msg);
EsbUtils.saveLog(billNumber, apiName, body, response, false, "ESBQueryApi", "未知异常");
break; break;
} }
}
return success; return success;
} }
/** /**
* sap接口数据解析 * 应收未清分录赋值
* @param response 响应参数 * @param detail sap接口返回json分录参数
* @param i 分录行号
*/ */
private void handleAspApiResponse(String response) { private void setEntityRowValues(JSONObject detail, int i) {
//TODO 与sap沟通确认字段对应
try { try {
JSONObject root = JSONObject.parseObject(response); this.getModel().setValue("shjh_e_pzh",detail.getString("BELNR"), i);//凭证号
JSONObject data = root.getJSONObject("data"); this.getModel().setValue("shjh_e_pzlx",detail.getString("BLART"), i);//凭证类型
JSONArray rows = data.getJSONArray("rows"); this.getModel().setValue("shjh_e_pzhh",detail.getString("BUZEI"), i);//凭证行项目号
DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID); this.getModel().setValue("shjh_e_fph",detail.getString("XREF1"), i);//发票号
entry.clear(); // this.getModel().setValue("shjh_e_fpdate",detail.getDate(""), i);//发票日期
for (int i = 0; i < rows.size(); i++) { this.getModel().setValue("shjh_e_account",detail.getString("HKONT"), i);// 总账科目
JSONObject top = (JSONObject) rows.get(i); // this.getModel().setValue("shjh_e_fenpei",detail.getString(""), i);// 分配
JSONArray loanDetailInfo = top.getJSONArray("LoanDetailInfo"); this.getModel().setValue("shjh_e_canzhao",detail.getString("AWKEY"), i);// 参照
JSONObject detail = (JSONObject) loanDetailInfo.get(0); this.getModel().setValue("shjh_e_ckdm1",detail.getString("XREF2"), i);//参考代码1
entry.addNew(); this.getModel().setValue("shjh_e_ckdm2",detail.getString("XREF3"), i);// 参考代码2
setPaymentApiValues(top, detail, i); // this.getModel().setValue("shjh_e_text",detail.getString(""), i);// 文本
} this.getModel().setValue("shjh_e_gzdate",detail.getDate("BUDAT"), i);// 过账日期
} catch (Exception e) { this.getModel().setValue("shjh_e_unsettle",detail.getBigDecimal("DMBTR"), i);//未核销金额
logger.error("SAP应收未清数据解析异常: " + e.getMessage()); this.getModel().setValue("shjh_e_year",detail.getString("GJAHR"), i);//会计年度
this.getView().showMessage("SAP应收未清数据解析异常"+e.getMessage());
}
}
/**
* 预付单赋值
*
* @param top json头参数
* @param detail json分录参数
* @param i
*/
private void setPaymentApiValues(JSONObject top, JSONObject detail, int i) {
try {
this.getModel().setValue("shjh_billno", top.getString("CompanyCode"), i);
this.getModel().setValue("shjh_prepaymentnum", top.getString("RequestCode"), i);
this.getModel().setValue("shjh_purchasenum", detail.getString("PoOrderNo"), i);
this.getModel().setValue("shjh_purchaselinenum", detail.getString("PoOrderColNo"), i);
this.getModel().setValue("shjh_billsubject", detail.getString("RequestName"), i);
this.getModel().setValue("shjh_prepaymentdate", detail.getDate("CreatedDate"), i);
this.getModel().setValue("shjh_paymentamount", top.getBigDecimal("RequestAmt"), i);
this.getModel().setValue("shjh_documentamount", top.getBigDecimal("AvailableAmt"), i);
this.getModel().setValue("shjh_verificationnum", top.getString("StrColumn20"), i);
this.getModel().setValue("shjh_fiscalyear", top.getString("GLDate").substring(0, 4), i);
} catch (Exception e) { } catch (Exception e) {
logger.error("分录赋值异常: " + e.getMessage()); logger.error("分录赋值异常: " + e.getMessage());
this.getView().showMessage("分录赋值异常!"+e.getMessage()); this.getView().showMessage("分录赋值异常!"+e.getMessage());
@ -267,19 +245,20 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
*/ */
private void handleSelectedButton() { private void handleSelectedButton() {
try { try {
//清空 EntryGrid entryGrid = this.getView().getControl(entryID);//获得分录的控件对象
PARAM_LIST.clear();
EntryGrid entryGrid = this.getControl(entryID);
int[] selectRows = entryGrid.getSelectRows(); int[] selectRows = entryGrid.getSelectRows();
DynamicObjectCollection entity = this.getModel().getEntryEntity(entryID);
if (selectRows != null && selectRows.length > 0) { if (selectRows != null && selectRows.length > 0) {
DynamicObjectCollection docolls = this.getModel().getEntryEntity(entryID);
//清空返回数据包
PARAM_LIST.clear();
DynamicObject doinfo;
for (int selectRow : selectRows) { for (int selectRow : selectRows) {
DynamicObject dynamicObject = entity.get(selectRow); doinfo = docolls.get(selectRow);
PARAM_LIST.add(dynamicObject); PARAM_LIST.add(doinfo);
} }
this.getView().close(); this.getView().close();
} else { } else {
this.getView().showMessage("请选中一条数据!"); this.getView().showMessage("请选择一条明细数据!");
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("传递参数异常: " + e.getMessage()); logger.error("传递参数异常: " + e.getMessage());

View File

@ -71,11 +71,13 @@ public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin {
* @param apiKey 按钮来源的区分标识 * @param apiKey 按钮来源的区分标识
*/ */
private FormShowParameter createASPParam(String apiKey) { private FormShowParameter createASPParam(String apiKey) {
HashMap<String, Object> map = new HashMap<>(2); HashMap<String, Object> map = new HashMap<>(4);
//按钮区分标识 //按钮区分标识
map.put("Apikey",apiKey); map.put("Apikey",apiKey);
//清账明细单单号 //清账单单号
map.put("billNumber",this.getModel().getValue("billno")); map.put("billNumber",this.getModel().getValue("billno"));
map.put("billorg",this.getModel().getValue("org"));//清账单公司
map.put("billcustomer",this.getModel().getValue("shjh_customer"));//清账单客户
FormShowParameter showParameter = new FormShowParameter(); FormShowParameter showParameter = new FormShowParameter();
//需要打开单据的标识 //需要打开单据的标识
showParameter.setFormId(SAPFormID); showParameter.setFormId(SAPFormID);
@ -89,6 +91,7 @@ public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin {
} }
private BillShowParameter createDetailBillParam(String detailBillid) { private BillShowParameter createDetailBillParam(String detailBillid) {
//组装打开清账明细单的界面参数
// HashMap<String, Object> map = new HashMap<>(2); // HashMap<String, Object> map = new HashMap<>(2);
// //按钮区分标识 // //按钮区分标识
// map.put("Apikey",apiKey); // map.put("Apikey",apiKey);
@ -106,7 +109,7 @@ public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin {
//pageid //pageid
// showParameter.setPageId(); // showParameter.setPageId();
//传到目标页面的自定义参数 //传到目标页面的自定义参数
showParameter.setCustomParam("Apikey","viewDetailFromClear"); showParameter.setCustomParam("parentFromCustomParam","viewDetailFromClear");
//回调方法 //回调方法
// showParameter.setCloseCallBack(); // showParameter.setCloseCallBack();
return showParameter; return showParameter;

View File

@ -30,20 +30,20 @@ public class ClearBillListPlugin extends AbstractListPlugin implements Plugin {
@Override @Override
public void itemClick(ItemClickEvent evt) { public void itemClick(ItemClickEvent evt) {
super.itemClick(evt); super.itemClick(evt);
try { // try {
if ("shjh_unclearacctount".equals(evt.getItemKey())) { // if ("shjh_unclearacctount".equals(evt.getItemKey())) {
//点击反清账按钮 // //点击反清账按钮
// FormShowParameter showParameter = createParam(evt.getItemKey(),unClearFormID); // FormShowParameter showParameter = createParam(evt.getItemKey(),unClearFormID);
// this.getView().showForm(showParameter); // this.getView().showForm(showParameter);
}else if("shjh_changestatus".equals(evt.getItemKey())){ // }else if("shjh_changestatus".equals(evt.getItemKey())){
//点击修改清账单状态按钮 // //点击修改清账单状态按钮
// FormShowParameter showParameter = createParam(evt.getItemKey(),updateStatusFormID); // FormShowParameter showParameter = createParam(evt.getItemKey(),updateStatusFormID);
// this.getView().showForm(showParameter); // this.getView().showForm(showParameter);
} // }
} catch (Exception e) { // } catch (Exception e) {
logger.error("按钮处理异常:"+e.getMessage()); // logger.error("按钮处理异常:"+e.getMessage());
this.getView().showMessage("按钮处理异常"+e.getMessage()); // this.getView().showMessage("按钮处理异常"+e.getMessage());
} // }
} }
@Override @Override

View File

@ -53,18 +53,21 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
* 构建表单之间的传参 弹框展示SAP应收未清列表 * 构建表单之间的传参 弹框展示SAP应收未清列表
*/ */
private FormShowParameter createFormParameter() { private FormShowParameter createFormParameter() {
HashMap<String, Object> map = new HashMap<>(2); // HashMap<String, Object> map = new HashMap<>(2);
//按钮区分标识 //按钮区分标识
// map.put("Apikey",SAP_BUTTON_KEY); // map.put("Apikey",SAP_BUTTON_KEY);
//清账明细单单号
map.put("billNumber",this.getModel().getValue("billno"));
FormShowParameter showParameter = new FormShowParameter(); FormShowParameter showParameter = new FormShowParameter();
//需要打开单据的标识 //需要打开单据的标识
showParameter.setFormId(destFormID); showParameter.setFormId(destFormID);
//打开方式 //打开方式
showParameter.getOpenStyle().setShowType(ShowType.Modal); showParameter.getOpenStyle().setShowType(ShowType.Modal);
//传到子页面参数 //传到子页面参数
showParameter.setCustomParams(map); // showParameter.setCustomParams(map);
showParameter.setCustomParam("billNumber",this.getModel().getValue("billno"));//清账明细单单号
showParameter.setCustomParam("billorg",this.getModel().getValue("org"));//清账明细单公司
showParameter.setCustomParam("billcustomer",this.getModel().getValue("shjh_customer"));//清账明细单客户
// map.put("billorg",(DynamicObject)this.getModel().getValue("org"));
// map.put("billcustomer",(DynamicObject)this.getModel().getValue("shjh_customer"));
//回调方法 //回调方法
showParameter.setCloseCallBack(new CloseCallBack(this, SAP_BUTTON_KEY)); showParameter.setCloseCallBack(new CloseCallBack(this, SAP_BUTTON_KEY));
return showParameter; return showParameter;
@ -144,7 +147,7 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
this.getModel().setValue("shjh_e_text",returnInfo.getString("shjh_e_text"), i);// 文本 this.getModel().setValue("shjh_e_text",returnInfo.getString("shjh_e_text"), i);// 文本
this.getModel().setValue("shjh_e_gzdate",returnInfo.getDate("shjh_e_gzdate"), i);// 过账日期 this.getModel().setValue("shjh_e_gzdate",returnInfo.getDate("shjh_e_gzdate"), i);// 过账日期
this.getModel().setValue("shjh_e_unsettle",returnInfo.getBigDecimal("shjh_e_unsettle"), i);//未核销金额 this.getModel().setValue("shjh_e_unsettle",returnInfo.getBigDecimal("shjh_e_unsettle"), i);//未核销金额
this.getModel().setValue("shjh_e_cursettle",returnInfo.getBigDecimal("shjh_e_cursettle"), i);//本次核销金额 // this.getModel().setValue("shjh_e_cursettle",returnInfo.getBigDecimal("shjh_e_cursettle"), i);//本次核销金额
this.getModel().setValue("shjh_e_year",returnInfo.getString("shjh_e_year"), i);//会计年度 this.getModel().setValue("shjh_e_year",returnInfo.getString("shjh_e_year"), i);//会计年度
this.getModel().setValue("shjh_e_qzpztext",returnInfo.getString("shjh_e_qzpztext"), i);// 清账凭证文本 this.getModel().setValue("shjh_e_qzpztext",returnInfo.getString("shjh_e_qzpztext"), i);// 清账凭证文本
} }
@ -157,7 +160,7 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
super.afterBindData(e); super.afterBindData(e);
FormShowParameter showParam = this.getView().getFormShowParameter(); FormShowParameter showParam = this.getView().getFormShowParameter();
//如果是清账单过来的只能进行查看 //如果是清账单过来的只能进行查看
if("viewDetailFromClear".equals(showParam.getCustomParam("Apikey"))){ if("viewDetailFromClear".equals(showParam.getCustomParam("parentFromCustomParam"))){
this.getView().setVisible(false, "tbmain"); this.getView().setVisible(false, "tbmain");
} }
} }

View File

@ -63,7 +63,7 @@ public class SappzFormPlugin extends AbstractFormPlugin {
Boolean isselfprocurement = (Boolean) this.getModel().getValue("shjh_isselfprocurement");//是否自行采购 Boolean isselfprocurement = (Boolean) this.getModel().getValue("shjh_isselfprocurement");//是否自行采购
// 日期格式 // 日期格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
JSONArray IT_LIST = new JSONArray(); JSONArray IT_LIST = new JSONArray();
// 添加公司过滤条件 // 添加公司过滤条件
if (shjhOrgfield != null) { if (shjhOrgfield != null) {

View File

@ -2,7 +2,6 @@ package shjh.jhzj7.fi.fi.utils;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
@ -17,7 +16,6 @@ import org.apache.http.util.EntityUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -45,6 +43,11 @@ public class SapUtils {
// public static final String withholdingUrl = "https://hipint.jahwa.com.cn:6443/gateway//HIP_ReceiveFromFM/1.0/fm/send";//正式环境 // public static final String withholdingUrl = "https://hipint.jahwa.com.cn:6443/gateway//HIP_ReceiveFromFM/1.0/fm/send";//正式环境
public static final String receiverID2 = "FeiKong";//定义的发送者 public static final String receiverID2 = "FeiKong";//定义的发送者
private static final String interfaceID5 = "AccountsReceivableVoucherList";//识别被调接口并进行路由
private static final String Apimenthod5 = "SAP应收凭证清单";
public static final String sapArUrl = "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//测试环境(SAP应收凭证清单)
// public static final String sapArUrl = "https://hipint.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//正式环境
/** /**
* SAP应付凭证锁定解锁状态回写 * SAP应付凭证锁定解锁状态回写
*/ */
@ -83,6 +86,46 @@ public class SapUtils {
return pendingsBody; return pendingsBody;
} }
/**
* SAP应收凭证清单接口
* @param IT_LIST 过滤条件入参
* @param billno 单据编号
* @author yuxueliang
*/
public static JSONObject sapArAPI(JSONArray IT_LIST,String billno){
Map<String, Object> thirdPartyMap = new HashMap<>();
thirdPartyMap.put("interfaceID",interfaceID5);
thirdPartyMap.put("receiverID",receiverID1);
thirdPartyMap.put("URL",sapArUrl);
thirdPartyMap.put("billno",billno);
// 组装请求体
JSONObject arBody = sapArBody(IT_LIST);
// 发送请求并处理响应
return processRequest(arBody, thirdPartyMap, Apimenthod5);
}
/**
* SAP应收凭证清单接口组装请求体
* @param IT_LIST 过滤条件入参
* @author yuxueliang
*/
private static JSONObject sapArBody(JSONArray IT_LIST) {
// 获取当前日期和时间
LocalDateTime date = LocalDateTime.now();
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
// 格式化当前日期和时间
String dates = date.format(formatter);
//组装请求体
JSONObject pendingsBody = new JSONObject();
pendingsBody.put("rootContextID",""+System.currentTimeMillis());//唯一事务ID采用UUID或其他强唯一性ID
pendingsBody.put("requestTime",dates);//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
JSONObject data = new JSONObject();
data.put("IT_INPUT",IT_LIST);
pendingsBody.put("data", data);
return pendingsBody;
}
/** /**
* SAP应付凭证清单接口 * SAP应付凭证清单接口