理财申购单新增两个功能按钮

This commit is contained in:
李贵强 2025-07-17 19:30:45 +08:00
parent aaa92f87da
commit a719a19cff
2 changed files with 172 additions and 128 deletions

View File

@ -24,6 +24,7 @@ import java.util.EventObject;
/** /**
* 动态表单插件-SAP应收未清 shjh_sapyswq * 动态表单插件-SAP应收未清 shjh_sapyswq
*
* @author yuxueliang * @author yuxueliang
*/ */
public class ASParbillFormPlugin extends AbstractFormPlugin { public class ASParbillFormPlugin extends AbstractFormPlugin {
@ -60,7 +61,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
super.afterBindData(e); super.afterBindData(e);
FormShowParameter showParam = this.getView().getFormShowParameter(); FormShowParameter showParam = this.getView().getFormShowParameter();
//如果是清账单过来的只能进行查询不能确认勾选 //如果是清账单过来的只能进行查询不能确认勾选
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);
} }
@ -73,12 +74,12 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
public void afterCreateNewData(EventObject e) { public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e); super.afterCreateNewData(e);
FormShowParameter showParam = this.getView().getFormShowParameter(); FormShowParameter showParam = this.getView().getFormShowParameter();
if(showParam.getCustomParam("billorg") != null){ if (showParam.getCustomParam("billorg") != null) {
IFormView parentView = this.getView().getParentView();//获取父表单 IFormView parentView = this.getView().getParentView();//获取父表单
IDataModel model = parentView.getModel();//获取父表单模型 IDataModel model = parentView.getModel();//获取父表单模型
this.getModel().setValue("shjh_org",model.getDataEntity().get("org"));//公司从父页面带过来 this.getModel().setValue("shjh_org", model.getDataEntity().get("org"));//公司从父页面带过来
this.getModel().setValue("shjh_customer",model.getDataEntity().get("shjh_customer"));//客户从父页面带过来 this.getModel().setValue("shjh_customer", model.getDataEntity().get("shjh_customer"));//客户从父页面带过来
this.getModel().setValue("shjh_currency",model.getDataEntity().get("shjh_currency"));//币别从父页面带过来 this.getModel().setValue("shjh_currency", model.getDataEntity().get("shjh_currency"));//币别从父页面带过来
} }
} }
@ -113,22 +114,22 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
} }
String orgrCode = org.getString("number"); String orgrCode = org.getString("number");
// 点击查询按钮 // 点击查询按钮
handleQueryButtonClick(orgrCode,customerCode); 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_pzh",null);//SAP应收凭证号 this.getModel().setValue("shjh_pzh", null);//SAP应收凭证号
this.getModel().setValue("shjh_kmbh",null);//总账科目编号 this.getModel().setValue("shjh_kmbh", null);//总账科目编号
this.getModel().setValue("shjh_fph",null);//发票号 this.getModel().setValue("shjh_fph", null);//发票号
this.getModel().setValue("shjh_year",null);//会计年度 this.getModel().setValue("shjh_year", null);//会计年度
this.getModel().setValue("shjh_gzrq_startdate",null);//SAP应收凭过账日期 this.getModel().setValue("shjh_gzrq_startdate", null);//SAP应收凭过账日期
this.getModel().setValue("shjh_gzrq_enddate",null);//SAP应收凭过账日期 this.getModel().setValue("shjh_gzrq_enddate", null);//SAP应收凭过账日期
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("按钮处理异常:"+e.getMessage()); logger.error("按钮处理异常:" + e.getMessage());
this.getView().showMessage("按钮处理异常"+e.getMessage()); this.getView().showMessage("按钮处理异常" + e.getMessage());
} }
} }
@ -145,8 +146,9 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
/** /**
* 点击查询按钮 * 点击查询按钮
* @param companyCode 公司编码 *
* @param customerCode 客户编码 * @param companyCode 公司编码
* @param customerCode 客户编码
*/ */
private void handleQueryButtonClick(String companyCode, String customerCode) { private void handleQueryButtonClick(String companyCode, String customerCode) {
try { try {
@ -172,7 +174,9 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
// 添加SAP应收凭证号过滤条件 // 添加SAP应收凭证号过滤条件
if (StringUtils.isNotEmpty(shjh_pzh)) { if (StringUtils.isNotEmpty(shjh_pzh)) {
addFilterCondition(IT_LIST, "BELNR", shjh_pzh, shjh_pzh); //解析多行凭证号用于批量查询
parseQueryNumber(IT_LIST, "BELNR", shjh_pzh);
//addFilterCondition(IT_LIST, "BELNR", shjh_pzh, shjh_pzh);
} }
// 添加会计科目编号过滤条件 // 添加会计科目编号过滤条件
if (StringUtils.isNotEmpty(shjh_kmbh)) { if (StringUtils.isNotEmpty(shjh_kmbh)) {
@ -188,9 +192,9 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
String postingdate_enddas = postingdate_endda == null ? "" : sdf.format(postingdate_endda); String postingdate_enddas = postingdate_endda == null ? "" : sdf.format(postingdate_endda);
addFilterCondition(IT_LIST, "BUDAT", postingdate_starts, postingdate_enddas); addFilterCondition(IT_LIST, "BUDAT", postingdate_starts, postingdate_enddas);
} }
JSONObject sapReturnData = SapUtils.sapArAPI(IT_LIST,billNumber); JSONObject sapReturnData = SapUtils.sapArAPI(IT_LIST, billNumber);
//sap返回的结果不为空且正确执行分录插入数据 //sap返回的结果不为空且正确执行分录插入数据
if(sapReturnData != null && parseResponse(sapReturnData)){ if (sapReturnData != null && parseResponse(sapReturnData)) {
JSONObject data = sapReturnData.getJSONObject("data"); JSONObject data = sapReturnData.getJSONObject("data");
JSONArray rows = data.getJSONArray("IT_ITEM"); JSONArray rows = data.getJSONArray("IT_ITEM");
DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID); DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID);
@ -208,7 +212,28 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
} 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 void parseQueryNumber(JSONArray IT_LIST, String field, String queryText) {
// 1. 清理输入去除空格中文逗号统一用英文逗号分隔
String cleanedText = queryText.replaceAll("\\s+", "") // 去空格
.replace("", ","); // 中文逗号转英文
// 2. 按空格拆分
String[] numbers = cleanedText.split(",");
// 3. 遍历处理每个凭证号
for (String number : numbers) {
if (number.isEmpty()) continue;
JSONObject eqQuery = new JSONObject();
eqQuery.put("FIELD", field);
eqQuery.put("SIGN", "I");
eqQuery.put("OPTION", "EQ");
eqQuery.put("LOW", number);
eqQuery.put("HIGH", number);
IT_LIST.add(eqQuery);
} }
} }
@ -221,16 +246,16 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
success = true; success = true;
break; break;
case "1": case "1":
this.getView().showMessage("服务异常:"+msg); this.getView().showMessage("服务异常:" + msg);
break; break;
case "2": case "2":
this.getView().showMessage("三方服务异常:"+msg); this.getView().showMessage("三方服务异常:" + msg);
break; break;
case "3": case "3":
this.getView().showMessage("业务异常:"+msg); this.getView().showMessage("业务异常:" + msg);
break; break;
default: default:
this.getView().showMessage("未知异常:"+msg); this.getView().showMessage("未知异常:" + msg);
break; break;
} }
return success; return success;
@ -238,30 +263,31 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
/** /**
* 应收未清分录赋值 * 应收未清分录赋值
*
* @param detail sap接口返回json分录参数 * @param detail sap接口返回json分录参数
* @param i 分录行号 * @param i 分录行号
*/ */
private void setEntityRowValues(JSONObject detail, int i) { private void setEntityRowValues(JSONObject detail, int i) {
//与sap沟通确认字段对应 //与sap沟通确认字段对应
try { try {
this.getModel().setValue("shjh_e_pzh",detail.getString("BELNR"), i);//凭证号 this.getModel().setValue("shjh_e_pzh", detail.getString("BELNR"), i);//凭证号
this.getModel().setValue("shjh_e_pzlx",detail.getString("BLART"), i);//凭证类型 this.getModel().setValue("shjh_e_pzlx", detail.getString("BLART"), i);//凭证类型
this.getModel().setValue("shjh_e_pzhh",detail.getString("BUZEI"), i);//凭证行项目号 this.getModel().setValue("shjh_e_pzhh", detail.getString("BUZEI"), i);//凭证行项目号
this.getModel().setValue("shjh_e_fph",detail.getString("AWKEY"), i);//发票号 this.getModel().setValue("shjh_e_fph", detail.getString("AWKEY"), i);//发票号
// this.getModel().setValue("shjh_e_fpdate",detail.getDate(""), i);//发票日期 // this.getModel().setValue("shjh_e_fpdate",detail.getDate(""), i);//发票日期
this.getModel().setValue("shjh_e_account",detail.getString("HKONT"), i);// 总账科目 this.getModel().setValue("shjh_e_account", detail.getString("HKONT"), i);// 总账科目
// this.getModel().setValue("shjh_e_fenpei",detail.getString(""), i);// 分配 // this.getModel().setValue("shjh_e_fenpei",detail.getString(""), i);// 分配
this.getModel().setValue("shjh_e_canzhao",detail.getString("XBLNR"), i);// 参照 this.getModel().setValue("shjh_e_canzhao", detail.getString("XBLNR"), i);// 参照
//20250707 原参考代码1 XREF1 按照要求取sap新增的字段 凭证标题的内部参考码 XREF1_HD //20250707 原参考代码1 XREF1 按照要求取sap新增的字段 凭证标题的内部参考码 XREF1_HD
this.getModel().setValue("shjh_e_ckdm1",detail.getString("XREF1_HD"), i);//参考代码1 this.getModel().setValue("shjh_e_ckdm1", detail.getString("XREF1_HD"), i);//参考代码1
this.getModel().setValue("shjh_e_ckdm2",detail.getString("XREF2"), i);// 参考代码2 this.getModel().setValue("shjh_e_ckdm2", detail.getString("XREF2"), i);// 参考代码2
// this.getModel().setValue("shjh_e_text",detail.getString(""), i);// 文本 // this.getModel().setValue("shjh_e_text",detail.getString(""), i);// 文本
this.getModel().setValue("shjh_e_gzdate",detail.getDate("BUDAT"), i);// 过账日期 this.getModel().setValue("shjh_e_gzdate", detail.getDate("BUDAT"), i);// 过账日期
this.getModel().setValue("shjh_e_unsettle",detail.getBigDecimal("DMBTR"), i);//未核销金额 this.getModel().setValue("shjh_e_unsettle", detail.getBigDecimal("DMBTR"), i);//未核销金额
this.getModel().setValue("shjh_e_year",detail.getString("GJAHR"), i);//会计年度 this.getModel().setValue("shjh_e_year", detail.getString("GJAHR"), 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());
} }
} }
@ -287,7 +313,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin {
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("传递参数异常: " + e.getMessage()); logger.error("传递参数异常: " + e.getMessage());
this.getView().showMessage("传递参数异常!"+e.getMessage()); this.getView().showMessage("传递参数异常!" + e.getMessage());
} }
} }

View File

@ -34,24 +34,24 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
if (!"cas_recbill".equals(name)) { if (!"cas_recbill".equals(name)) {
return; return;
} }
bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(),"cas_recbill"); bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(), "cas_recbill");
// DynamicObject planClass = bill.getDynamicObject("shjh_planclass"); // DynamicObject planClass = bill.getDynamicObject("shjh_planclass");
// if (null == planClass) { // if (null == planClass) {
//根据配置表携带资金计划科目 //根据配置表携带资金计划科目
bill.set("shjh_planclass", xdMembersubject(bill)); bill.set("shjh_planclass", xdMembersubject(bill));
// } // }
//二次修改不进入该方法 //二次修改不进入该方法
//携带生单规则分录的业务大类,业务小类,成本中心,利润中心到收款处理单头, //携带生单规则分录的业务大类,业务小类,成本中心,利润中心到收款处理单头,
if (!bill.getBoolean("shjh_xdgzkh")){ if (!bill.getBoolean("shjh_xdgzkh")) {
carryCustomer(bill); carryCustomer(bill);
} }
SaveServiceHelper.save(new DynamicObject[]{bill}); SaveServiceHelper.save(new DynamicObject[]{bill});
//若源单为收款处理 认领通知单,清空单据头.是否已推送SAP;单据头.SAP凭证号;单据头.SAP会计年度任保留方便后续推红冲凭证 cas_recbill //若源单为收款处理 认领通知单,清空单据头.是否已推送SAP;单据头.SAP凭证号;单据头.SAP会计年度任保留方便后续推红冲凭证 cas_recbill
String sourcebilltype = bill.getString("sourcebilltype"); String sourcebilltype = bill.getString("sourcebilltype");
if ("cas_recbill".equals(sourcebilltype) ||"收款单".equals(sourcebilltype) ) { if ("cas_recbill".equals(sourcebilltype) || "收款单".equals(sourcebilltype)) {
long sourcebillid = bill.getLong("sourcebillid"); long sourcebillid = bill.getLong("sourcebillid");
QFilter q1 = new QFilter("id", QCP.equals, sourcebillid); QFilter q1 = new QFilter("id", QCP.equals, sourcebillid);
DynamicObject[] load = BusinessDataServiceHelper.load("cas_recbill", DynamicObject[] load = BusinessDataServiceHelper.load("cas_recbill",
@ -66,7 +66,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
} }
} }
if ("cas_claimcenterbill".equals(sourcebilltype) ||"认领通知单".equals(sourcebilltype)) { if ("cas_claimcenterbill".equals(sourcebilltype) || "认领通知单".equals(sourcebilltype)) {
long sourcebillid = bill.getLong("sourcebillid"); long sourcebillid = bill.getLong("sourcebillid");
QFilter q1 = new QFilter("sourcebillid", QCP.equals, sourcebillid); QFilter q1 = new QFilter("sourcebillid", QCP.equals, sourcebillid);
QFilter q2 = new QFilter("actrecamt", QCP.less_than, 0); QFilter q2 = new QFilter("actrecamt", QCP.less_than, 0);
@ -103,8 +103,8 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
DynamicObject org = bill.getDynamicObject("org"); DynamicObject org = bill.getDynamicObject("org");
if (null != org) { if (null != org) {
long orgid = org.getLong("id"); long orgid = org.getLong("id");
QFilter q4 = new QFilter("org_entry.u_org.id", QCP.equals,orgid ); QFilter q4 = new QFilter("org_entry.u_org.id", QCP.equals, orgid);
q2 = q2.and(q4); q2 = q2.and(q4);
} }
DynamicObject rule = BusinessDataServiceHelper.loadSingle("cas_recpayrule", q2.toArray()); DynamicObject rule = BusinessDataServiceHelper.loadSingle("cas_recpayrule", q2.toArray());
if (null != rule) { if (null != rule) {
@ -124,12 +124,13 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
*/ */
String oppunit = beiIntelpay.getString("oppunit");//收款入账中心的对方户名 String oppunit = beiIntelpay.getString("oppunit");//收款入账中心的对方户名
Long companyId = beiIntelpay.getLong("company.id");//收款入账中心的资金组织id Long companyId = beiIntelpay.getLong("company.id");//收款入账中心的资金组织id
String companyNumber = beiIntelpay.getString("company.number");//收款入账中心的资金组织编码
bill.set("shjh_dfhm", oppunit);//收款单备注字段 bill.set("shjh_dfhm", oppunit);//收款单备注字段
bill.set("payertype", "bd_customer");//付款人类型:客户 bill.set("payertype", "bd_customer");//付款人类型:客户
// 2025/6/18 优化 先根据规则指定的付款人赋值 // 2025/6/18 优化 先根据规则指定的付款人赋值
//判断收款单是否从规则和客户映射表取过数据如果取过了则设置为true;没取过则取值 //判断收款单是否从规则和客户映射表取过数据如果取过了则设置为true;没取过则取值
if (!bill.getBoolean("shjh_xdgzkh")) { if (!bill.getBoolean("shjh_xdgzkh")) {
carryCustomerRule(entry,bill,oppunit,companyId); carryCustomerRule(entry, bill, oppunit, companyId, companyNumber);
// DynamicObject ePayerid = entry.getDynamicObject("e_payerid"); // DynamicObject ePayerid = entry.getDynamicObject("e_payerid");
// if (null != ePayerid) { // if (null != ePayerid) {
// bill.set("payer", ePayerid.getPkValue()); //付款人id // bill.set("payer", ePayerid.getPkValue()); //付款人id
@ -187,7 +188,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
DynamicObject entryss = entrys.get(0);//首行(被动) DynamicObject entryss = entrys.get(0);//首行(被动)
DynamicObject shjhYym = entryss.getDynamicObject("shjh_yym");//若收款单分录原因码为空则从业务小类中携带 DynamicObject shjhYym = entryss.getDynamicObject("shjh_yym");//若收款单分录原因码为空则从业务小类中携带
if (null != shjhEBizsmall) { if (null != shjhEBizsmall) {
shjhEBizsmall = BusinessDataServiceHelper.loadSingle(shjhEBizsmall.getPkValue(),"shjh_bizsmalltype"); shjhEBizsmall = BusinessDataServiceHelper.loadSingle(shjhEBizsmall.getPkValue(), "shjh_bizsmalltype");
if (null == shjhYym) { if (null == shjhYym) {
entryss.set("shjh_yym", shjhEBizsmall.getDynamicObject("shjh_yym"));//规则--小类--原因码 entryss.set("shjh_yym", shjhEBizsmall.getDynamicObject("shjh_yym"));//规则--小类--原因码
} }
@ -196,30 +197,30 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
//业务小类清账方式字段=全部金蝶清账再判断是否为结构性清账客户 //业务小类清账方式字段=全部金蝶清账再判断是否为结构性清账客户
//判断客户是否拆分,客户拆分为否时以表头付款人来判断否则以分录上的客户来判断 //判断客户是否拆分,客户拆分为否时以表头付款人来判断否则以分录上的客户来判断
boolean customerSplit = bill.getBoolean("shjh_customersplit"); boolean customerSplit = bill.getBoolean("shjh_customersplit");
if(customerSplit){ if (customerSplit) {
//以分录上客户来判断的话先设置成不下推由人为操作单子后系统判断 //以分录上客户来判断的话先设置成不下推由人为操作单子后系统判断
entryss.set("shjh_needpushbill", false);//不需要下推清账单 entryss.set("shjh_needpushbill", false);//不需要下推清账单
entryss.set("shjh_closingstatus", "A");//无需金蝶清账 entryss.set("shjh_closingstatus", "A");//无需金蝶清账
bill.set("shjh_qzzt", "A");//无需金蝶清账 bill.set("shjh_qzzt", "A");//无需金蝶清账
}else{ } else {
//根据收款单付款人id判断此时的付款类型是客户 //根据收款单付款人id判断此时的付款类型是客户
QFilter mapnumber = new QFilter("shjh_customer.id", QCP.equals, bill.getLong("payer"));//客户 QFilter mapnumber = new QFilter("shjh_customer.id", QCP.equals, bill.getLong("payer"));//客户
mapnumber.and("enable", QCP.equals, "1");//是否可用 mapnumber.and("enable", QCP.equals, "1");//是否可用
mapnumber.and("shjh_org.id", QCP.equals, org.getLong("id"));//公司 mapnumber.and("shjh_org.id", QCP.equals, org.getLong("id"));//公司
DynamicObject mappingObj = BusinessDataServiceHelper.loadSingle("shjh_jgqzcust", mapnumber.toArray()); DynamicObject mappingObj = BusinessDataServiceHelper.loadSingle("shjh_jgqzcust", mapnumber.toArray());
if(mappingObj != null){ if (mappingObj != null) {
//结构性清账客户映射表中有值 //结构性清账客户映射表中有值
entryss.set("shjh_needpushbill", true);//需要下推清账单 entryss.set("shjh_needpushbill", true);//需要下推清账单
entryss.set("shjh_closingstatus", "B");//待清账 entryss.set("shjh_closingstatus", "B");//待清账
bill.set("shjh_qzzt", "B");//待清账 bill.set("shjh_qzzt", "B");//待清账
}else{ } else {
entryss.set("shjh_needpushbill", false);//不需要下推清账单 entryss.set("shjh_needpushbill", false);//不需要下推清账单
entryss.set("shjh_closingstatus", "A");//无需金蝶清账 entryss.set("shjh_closingstatus", "A");//无需金蝶清账
bill.set("shjh_qzzt", "A");//无需金蝶清账 bill.set("shjh_qzzt", "A");//无需金蝶清账
} }
} }
}else{ } else {
entryss.set("shjh_needpushbill", false);//不需要下推清账单 entryss.set("shjh_needpushbill", false);//不需要下推清账单
entryss.set("shjh_closingstatus", "A");//无需金蝶清账 entryss.set("shjh_closingstatus", "A");//无需金蝶清账
bill.set("shjh_qzzt", "A");//无需金蝶清账 bill.set("shjh_qzzt", "A");//无需金蝶清账
@ -248,7 +249,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
Date bizDate = bill.getDate("bizdate"); Date bizDate = bill.getDate("bizdate");
QFilter qFilter = new QFilter("shjh_biztype", QCP.equals, "B"); // 业务类型:收款 QFilter qFilter = new QFilter("shjh_biztype", QCP.equals, "B"); // 业务类型:收款
qFilter.and(new QFilter("status", QCP.equals, "C")); // 审核状态 qFilter.and(new QFilter("status", QCP.equals, "C")); // 审核状态
qFilter.and(new QFilter("enable",QCP.equals,"1"));//启用状态 qFilter.and(new QFilter("enable", QCP.equals, "1"));//启用状态
qFilter.and(new QFilter("shjh_begindate", QCP.less_equals, bizDate)); qFilter.and(new QFilter("shjh_begindate", QCP.less_equals, bizDate));
qFilter.and(new QFilter("shjh_enddate", QCP.large_equals, bizDate)); qFilter.and(new QFilter("shjh_enddate", QCP.large_equals, bizDate));
@ -329,7 +330,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
//付款人类型 //付款人类型
String payerType = bill.getString("payertype"); String payerType = bill.getString("payertype");
if (null!=payerType) { if (null != payerType) {
switch (payerType) { switch (payerType) {
case "bd_customer": case "bd_customer":
// 10_1. 检查客户包含 // 10_1. 检查客户包含
@ -382,16 +383,16 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
} }
/** /**
* 包含某个多选基础资料-收款单表头取数 * 包含某个多选基础资料-收款单表头取数
* @param accountBill 资金计划科目表 *
* @param recBill 收款处理 * @param accountBill 资金计划科目表
* @param recBill 收款处理
* @param accountField 被匹配基础资料标识 * @param accountField 被匹配基础资料标识
* @param recField 提供基础资料标识 * @param recField 提供基础资料标识
* @return 是否符合 * @return 是否符合
*/ */
private boolean checkDynamicDataMatch(DynamicObject accountBill, DynamicObject recBill ,String accountField,String recField){ private boolean checkDynamicDataMatch(DynamicObject accountBill, DynamicObject recBill, String accountField, String recField) {
DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField); DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField);
if (dynamicObjectCollection.isEmpty()) { if (dynamicObjectCollection.isEmpty()) {
return false; // 无限制-通过 return false; // 无限制-通过
@ -413,14 +414,15 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
/** /**
* 包含某个多选基础资料-收款单分录取数 * 包含某个多选基础资料-收款单分录取数
* @param accountBill 资金计划科目表 *
* @param recBill 收款处理 * @param accountBill 资金计划科目表
* @param entryName 分录标识 * @param recBill 收款处理
* @param entryName 分录标识
* @param accountField 被匹配基础资料标识 * @param accountField 被匹配基础资料标识
* @param recField 提供基础资料标识 * @param recField 提供基础资料标识
* @return 是否符合 * @return 是否符合
*/ */
private boolean checkDynamicDataMatch(DynamicObject accountBill, DynamicObject recBill ,String entryName,String accountField,String recField){ private boolean checkDynamicDataMatch(DynamicObject accountBill, DynamicObject recBill, String entryName, String accountField, String recField) {
DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField); DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField);
if (dynamicObjectCollection.isEmpty()) { if (dynamicObjectCollection.isEmpty()) {
return false; // 无限制则通过 return false; // 无限制则通过
@ -432,7 +434,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
} }
DynamicObject dynamicObject = entry.get(0).getDynamicObject(recField); DynamicObject dynamicObject = entry.get(0).getDynamicObject(recField);
if (dynamicObject==null){ if (dynamicObject == null) {
return true;//放行 return true;//放行
} }
Long orgId = dynamicObject.getLong("id"); Long orgId = dynamicObject.getLong("id");
@ -447,13 +449,14 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
/** /**
* 不包含某个多选基础资料 * 不包含某个多选基础资料
* @param accountBill 资金计划科目表 *
* @param recBill 收款处理 * @param accountBill 资金计划科目表
* @param recBill 收款处理
* @param accountField 被匹配基础资料标识 * @param accountField 被匹配基础资料标识
* @param recField 提供基础资料标识 * @param recField 提供基础资料标识
* @return 是否符合 * @return 是否符合
*/ */
private boolean checkNotDynamicMatch(DynamicObject accountBill, DynamicObject recBill ,String accountField,String recField) { private boolean checkNotDynamicMatch(DynamicObject accountBill, DynamicObject recBill, String accountField, String recField) {
DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField); DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField);
if (dynamicObjectCollection.isEmpty()) { if (dynamicObjectCollection.isEmpty()) {
return false; // 无排除限制则通过 return false; // 无排除限制则通过
@ -475,13 +478,14 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
/** /**
* 针对包含客户||供应商 * 针对包含客户||供应商
*
* @param accountBill * @param accountBill
* @param recBill * @param recBill
* @param accountField * @param accountField
* @param recField * @param recField
* @return * @return
*/ */
private boolean checkCustomerOrSupplierMatch(DynamicObject accountBill, DynamicObject recBill ,String accountField,String recField){ private boolean checkCustomerOrSupplierMatch(DynamicObject accountBill, DynamicObject recBill, String accountField, String recField) {
DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField); DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField);
if (dynamicObjectCollection.isEmpty()) { if (dynamicObjectCollection.isEmpty()) {
return false; // 无限制则通过 return false; // 无限制则通过
@ -502,13 +506,14 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
/** /**
* 针对不包含客户||供应商 * 针对不包含客户||供应商
*
* @param accountBill * @param accountBill
* @param recBill * @param recBill
* @param accountField * @param accountField
* @param recField * @param recField
* @return * @return
*/ */
private boolean checkNotCustomerOrSupplierMatch(DynamicObject accountBill, DynamicObject recBill ,String accountField,String recField){ private boolean checkNotCustomerOrSupplierMatch(DynamicObject accountBill, DynamicObject recBill, String accountField, String recField) {
DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField); DynamicObjectCollection dynamicObjectCollection = accountBill.getDynamicObjectCollection(accountField);
if (dynamicObjectCollection.isEmpty()) { if (dynamicObjectCollection.isEmpty()) {
return false; // 无限制则通过 return false; // 无限制则通过
@ -529,8 +534,9 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
/** /**
* 针对客户检查客户组客户组为必填项 * 针对客户检查客户组客户组为必填项
*
* @param accountBill 资金计划科目表 * @param accountBill 资金计划科目表
* @param recBill 收款处理 * @param recBill 收款处理
* @return * @return
*/ */
private boolean checkCustomerGroup(DynamicObject accountBill, DynamicObject recBill) { private boolean checkCustomerGroup(DynamicObject accountBill, DynamicObject recBill) {
@ -583,7 +589,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
for (DynamicObject allowedGroup : allowedGroups) { for (DynamicObject allowedGroup : allowedGroups) {
DynamicObject baseDataObj = allowedGroup.getDynamicObject("fbasedataid"); DynamicObject baseDataObj = allowedGroup.getDynamicObject("fbasedataid");
String number=baseDataObj.getString("number"); String number = baseDataObj.getString("number");
if (customerGroupNumber.equals(number)) { if (customerGroupNumber.equals(number)) {
return false; // 匹配到允许的客户组 return false; // 匹配到允许的客户组
} }
@ -600,70 +606,82 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
* 3.规则生单未配置客户>取收款入账中心客户 * 3.规则生单未配置客户>取收款入账中心客户
* 4.以上都未配置>不确定客户 * 4.以上都未配置>不确定客户
*/ */
private void carryCustomerRule(DynamicObject entry,DynamicObject bill,String oppunit,Long companyId){ private void carryCustomerRule(DynamicObject entry, DynamicObject bill, String oppunit, Long companyId, String companyNumber) {
//1.先看取映射表按钮是否打开打开>取映射表中客户 //1.先看取映射表按钮是否打开打开>取映射表中客户
//20250704 经过和建彪沟通先注释根据标记来判断的代码 //20250704 经过和建彪沟通先注释根据标记来判断的代码
// boolean shjhEGetcustomer = entry.getBoolean("shjh_e_getcustomer"); //取规则得映射表客户标记 // boolean shjhEGetcustomer = entry.getBoolean("shjh_e_getcustomer"); //取规则得映射表客户标记
// if (shjhEGetcustomer) { // if (shjhEGetcustomer) {
QFilter qFilter = new QFilter("shjh_dfhm", QCP.equals, oppunit); QFilter qFilter = new QFilter("shjh_dfhm", QCP.equals, oppunit);
//新增收款入账中心-资金组织&&映射表组织过滤 //新增收款入账中心-资金组织&&映射表组织过滤
qFilter.and(new QFilter("shjh_org.id", QCP.equals, companyId)); qFilter.and(new QFilter("shjh_org.id", QCP.equals, companyId));
//对方户名与客户名称映射表 shjh_dfhmcust //对方户名与客户名称映射表 shjh_dfhmcust
DynamicObject shjhDfhmcust = BusinessDataServiceHelper.loadSingle("shjh_dfhmcust", qFilter.toArray()); DynamicObject shjhDfhmcust = BusinessDataServiceHelper.loadSingle("shjh_dfhmcust", qFilter.toArray());
if (null != shjhDfhmcust) { if (null != shjhDfhmcust) {
DynamicObject shjhCustomer = shjhDfhmcust.getDynamicObject("shjh_customer"); DynamicObject shjhCustomer = shjhDfhmcust.getDynamicObject("shjh_customer");
if (null != shjhCustomer) { if (null != shjhCustomer) {
bill.set("payer", shjhCustomer.getPkValue()); //付款人id bill.set("payer", shjhCustomer.getPkValue()); //付款人id
bill.set("payernumber", shjhCustomer.getString("number")); //付款人编码 bill.set("payernumber", shjhCustomer.getString("number")); //付款人编码
bill.set("payername", shjhCustomer.getString("name")); //付款人名称 bill.set("payername", shjhCustomer.getString("name")); //付款人名称
} }
} else {
//2.映射表中未配置客户>取规则生单中客户
DynamicObject ePayerid = entry.getDynamicObject("e_payerid");
if (null != ePayerid) {
bill.set("payer", ePayerid.getPkValue()); //付款人id
bill.set("payernumber", ePayerid.getString("number")); //付款人编码
bill.set("payername", ePayerid.getString("name")); //付款人名称
} else { } else {
//2.映射表中未配置客户>取规则生单中客户 //3.规则生单未配置客户>取收款入账中心客户
DynamicObject ePayerid = entry.getDynamicObject("e_payerid"); QFilter customerFilter = new QFilter("name", QCP.equals, oppunit);
if (null != ePayerid) { //可用状态
bill.set("payer", ePayerid.getPkValue()); //付款人id customerFilter.and(new QFilter("enable", QCP.equals, "1"));
bill.set("payernumber", ePayerid.getString("number")); //付款人编码 DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name", customerFilter.toArray());
bill.set("payername", ePayerid.getString("name")); //付款人名称 boolean exitCustomerArray = false;
} else { if (null != bd_customer && bd_customer.length != 0) {
//3.规则生单未配置客户>取收款入账中心客户 if (bd_customer.length == 1) {
QFilter customerFilter = new QFilter("name", QCP.equals, oppunit); bill.set("payer", bd_customer[0].getPkValue()); //付款人id
//可用状态 bill.set("payernumber", bd_customer[0].getString("number")); //付款人编码
customerFilter.and(new QFilter("enable",QCP.equals,"1")); bill.set("payername", bd_customer[0].getString("name")); //付款人名称
DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name",customerFilter.toArray()); exitCustomerArray = true;
boolean exitCustomerArray = false; } else {
if (null != bd_customer ) { //存在多个客户判断组织编码companyNumber是否在客户基础资料客户组5分录中的销售公司编码中配置
if (bd_customer.length!=0){ for (int i = 0; i < bd_customer.length; i++) {
bill.set("payer", bd_customer[0].getPkValue()); //付款人id Set<String> numberSet = new HashSet<>();
bill.set("payernumber", bd_customer[0].getString("number")); //付款人编码 DynamicObject customer = BusinessDataServiceHelper.loadSingle(bd_customer[i].getPkValue(), "bd_customer");
bill.set("payername", bd_customer[0].getString("name")); //付款人名称 if (customer!=null){
exitCustomerArray=true; DynamicObjectCollection dynamicObjectCollection = customer.getDynamicObjectCollection("shjh_entry_five");
if (dynamicObjectCollection != null && dynamicObjectCollection.size() != 0) {
for (DynamicObject item : dynamicObjectCollection) {
String saleCompanyNum = item.getString("shjh_salecompanynum");
if (saleCompanyNum!=null && !"".equals(saleCompanyNum)){
numberSet.add(saleCompanyNum);
}
}
if (numberSet.contains(companyNumber)){
bill.set("payer", bd_customer[i].getPkValue()); //付款人id
bill.set("payernumber", bd_customer[i].getString("number")); //付款人编码
bill.set("payername", bd_customer[i].getString("name")); //付款人名称
exitCustomerArray = true;
break;
}
}
}
} }
//else if (bd_customer.length>1){
//for (int i = 0; i < bd_customer.length; i++) {
//DynamicObjectCollection dynamicObjectCollection = bd_customer[i].getDynamicObjectCollection("shjh_entry_five");
// if (dynamicObjectCollection.size()!=0){
// bill.set("payer", bd_customer[i].getPkValue()); //付款人id
// bill.set("payernumber", bd_customer[i].getString("number")); //付款人编码
// bill.set("payername", bd_customer[i].getString("name")); //付款人名称
// exitCustomerArray=true;
// break;
// }
//}
// }
} }
if (!exitCustomerArray){ }
//4.规则生单未配置客户>默认不确定客户 if (!exitCustomerArray) {
QFilter qFilter1 = new QFilter("number", QCP.equals, "1042086"); //4000042 //4.规则生单未配置客户>默认不确定客户
DynamicObject bdCustomer = BusinessDataServiceHelper.loadSingle("bd_customer", qFilter1.toArray()); QFilter qFilter1 = new QFilter("number", QCP.equals, "1042086"); //4000042
if (null != bdCustomer) { DynamicObject bdCustomer = BusinessDataServiceHelper.loadSingle("bd_customer", qFilter1.toArray());
bill.set("payer", bdCustomer.getPkValue()); //付款人id if (null != bdCustomer) {
bill.set("payernumber", bdCustomer.getString("number")); //付款人编码 bill.set("payer", bdCustomer.getPkValue()); //付款人id
bill.set("payername", bdCustomer.getString("name")); //付款人名称 bill.set("payernumber", bdCustomer.getString("number")); //付款人编码
} bill.set("payername", bdCustomer.getString("name")); //付款人名称
} }
} }
} }
bill.set("shjh_xdgzkh", true);//设置收款单标记位 从规则携带客户等信息 为true }
bill.set("shjh_xdgzkh", true);//设置收款单标记位 从规则携带客户等信息 为true
// } // }
} }
} }