理财申购单新增两个功能按钮
This commit is contained in:
		
							parent
							
								
									aaa92f87da
								
							
						
					
					
						commit
						a719a19cff
					
				|  | @ -24,6 +24,7 @@ import java.util.EventObject; | |||
| 
 | ||||
| /** | ||||
|  * 动态表单插件-【SAP应收未清】 shjh_sapyswq | ||||
|  * | ||||
|  * @author yuxueliang | ||||
|  */ | ||||
| public class ASParbillFormPlugin extends AbstractFormPlugin { | ||||
|  | @ -60,7 +61,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin { | |||
|         super.afterBindData(e); | ||||
|         FormShowParameter showParam = this.getView().getFormShowParameter(); | ||||
|         //如果是清账单过来的,只能进行查询不能确认勾选 | ||||
|         if("clearBillForm".equals(showParam.getCustomParam("Apikey"))){ | ||||
|         if ("clearBillForm".equals(showParam.getCustomParam("Apikey"))) { | ||||
|             this.getView().setVisible(false, SELECTED_BUTTON_KEY); | ||||
|         } | ||||
| 
 | ||||
|  | @ -73,12 +74,12 @@ public class ASParbillFormPlugin extends AbstractFormPlugin { | |||
|     public void afterCreateNewData(EventObject e) { | ||||
|         super.afterCreateNewData(e); | ||||
|         FormShowParameter showParam = this.getView().getFormShowParameter(); | ||||
|         if(showParam.getCustomParam("billorg") != null){ | ||||
|         if (showParam.getCustomParam("billorg") != null) { | ||||
|             IFormView parentView = this.getView().getParentView();//获取父表单 | ||||
|             IDataModel model = parentView.getModel();//获取父表单模型 | ||||
|             this.getModel().setValue("shjh_org",model.getDataEntity().get("org"));//公司从父页面带过来 | ||||
|             this.getModel().setValue("shjh_customer",model.getDataEntity().get("shjh_customer"));//客户从父页面带过来 | ||||
|             this.getModel().setValue("shjh_currency",model.getDataEntity().get("shjh_currency"));//币别从父页面带过来 | ||||
|             this.getModel().setValue("shjh_org", model.getDataEntity().get("org"));//公司从父页面带过来 | ||||
|             this.getModel().setValue("shjh_customer", model.getDataEntity().get("shjh_customer"));//客户从父页面带过来 | ||||
|             this.getModel().setValue("shjh_currency", model.getDataEntity().get("shjh_currency"));//币别从父页面带过来 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -113,22 +114,22 @@ public class ASParbillFormPlugin extends AbstractFormPlugin { | |||
|                 } | ||||
|                 String orgrCode = org.getString("number"); | ||||
|                 // 点击查询按钮 | ||||
|                 handleQueryButtonClick(orgrCode,customerCode); | ||||
|                 handleQueryButtonClick(orgrCode, customerCode); | ||||
|             } else if (StringUtils.equals(SELECTED_BUTTON_KEY, key)) { | ||||
|                 // 点击选择按钮 | ||||
|                 handleSelectedButton(); | ||||
|             } else if (StringUtils.equals(RESET_BUTTON_KEY, key)) { | ||||
|                 // 点击重置按钮 | ||||
|                 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应收凭过账日期 | ||||
|                 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) { | ||||
|             logger.error("按钮处理异常:"+e.getMessage()); | ||||
|             this.getView().showMessage("按钮处理异常"+e.getMessage()); | ||||
|             logger.error("按钮处理异常:" + 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) { | ||||
|         try { | ||||
|  | @ -172,7 +174,9 @@ public class ASParbillFormPlugin extends AbstractFormPlugin { | |||
| 
 | ||||
|             // 添加SAP应收凭证号过滤条件 | ||||
|             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)) { | ||||
|  | @ -188,9 +192,9 @@ public class ASParbillFormPlugin extends AbstractFormPlugin { | |||
|                 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); | ||||
|             JSONObject sapReturnData = SapUtils.sapArAPI(IT_LIST, billNumber); | ||||
|             //sap返回的结果不为空且正确,执行分录插入数据 | ||||
|             if(sapReturnData != null && parseResponse(sapReturnData)){ | ||||
|             if (sapReturnData != null && parseResponse(sapReturnData)) { | ||||
|                 JSONObject data = sapReturnData.getJSONObject("data"); | ||||
|                 JSONArray rows = data.getJSONArray("IT_ITEM"); | ||||
|                 DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID); | ||||
|  | @ -208,7 +212,28 @@ public class ASParbillFormPlugin extends AbstractFormPlugin { | |||
| 
 | ||||
|         } catch (Exception e) { | ||||
|             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; | ||||
|                 break; | ||||
|             case "1": | ||||
|                 this.getView().showMessage("服务异常:"+msg); | ||||
|                 this.getView().showMessage("服务异常:" + msg); | ||||
|                 break; | ||||
|             case "2": | ||||
|                 this.getView().showMessage("三方服务异常:"+msg); | ||||
|                 this.getView().showMessage("三方服务异常:" + msg); | ||||
|                 break; | ||||
|             case "3": | ||||
|                 this.getView().showMessage("业务异常:"+msg); | ||||
|                 this.getView().showMessage("业务异常:" + msg); | ||||
|                 break; | ||||
|             default: | ||||
|                 this.getView().showMessage("未知异常:"+msg); | ||||
|                 this.getView().showMessage("未知异常:" + msg); | ||||
|                 break; | ||||
|         } | ||||
|         return success; | ||||
|  | @ -238,30 +263,31 @@ public class ASParbillFormPlugin extends AbstractFormPlugin { | |||
| 
 | ||||
|     /** | ||||
|      * 应收未清分录赋值 | ||||
|      * | ||||
|      * @param detail sap接口返回json分录参数 | ||||
|      * @param i 分录行号 | ||||
|      * @param i      分录行号 | ||||
|      */ | ||||
|     private void setEntityRowValues(JSONObject detail, int i) { | ||||
|         //与sap沟通确认字段对应 | ||||
|         try { | ||||
|             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_pzhh",detail.getString("BUZEI"), i);//凭证行项目号 | ||||
|             this.getModel().setValue("shjh_e_fph",detail.getString("AWKEY"), 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_pzhh", detail.getString("BUZEI"), 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_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_canzhao",detail.getString("XBLNR"), i);// 参照 | ||||
|             this.getModel().setValue("shjh_e_canzhao", detail.getString("XBLNR"), i);// 参照 | ||||
|             //20250707 原参考代码1 XREF1 按照要求取sap新增的字段 凭证标题的内部参考码 XREF1_HD | ||||
|             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_ckdm1", detail.getString("XREF1_HD"), i);//参考代码1 | ||||
|             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_gzdate",detail.getDate("BUDAT"), 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_gzdate", detail.getDate("BUDAT"), i);// 过账日期 | ||||
|             this.getModel().setValue("shjh_e_unsettle", detail.getBigDecimal("DMBTR"), i);//未核销金额 | ||||
|             this.getModel().setValue("shjh_e_year", detail.getString("GJAHR"), i);//会计年度 | ||||
|         } catch (Exception e) { | ||||
|             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) { | ||||
|             logger.error("传递参数异常: " + e.getMessage()); | ||||
|             this.getView().showMessage("传递参数异常!"+e.getMessage()); | ||||
|             this.getView().showMessage("传递参数异常!" + e.getMessage()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -34,24 +34,24 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|             if (!"cas_recbill".equals(name)) { | ||||
|                 return; | ||||
|             } | ||||
|             bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(),"cas_recbill"); | ||||
|             bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(), "cas_recbill"); | ||||
| 
 | ||||
| //            DynamicObject planClass = bill.getDynamicObject("shjh_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); | ||||
|             } | ||||
|             SaveServiceHelper.save(new DynamicObject[]{bill}); | ||||
| 
 | ||||
|             //若源单为收款处理 认领通知单,清空单据头.是否已推送SAP;单据头.SAP凭证号;单据头.SAP会计年度任保留方便后续推红冲凭证 cas_recbill | ||||
|             String sourcebilltype = bill.getString("sourcebilltype"); | ||||
|             if ("cas_recbill".equals(sourcebilltype) ||"收款单".equals(sourcebilltype) ) { | ||||
|             if ("cas_recbill".equals(sourcebilltype) || "收款单".equals(sourcebilltype)) { | ||||
|                 long sourcebillid = bill.getLong("sourcebillid"); | ||||
|                 QFilter q1 = new QFilter("id", QCP.equals, sourcebillid); | ||||
|                 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"); | ||||
|                 QFilter q1 = new QFilter("sourcebillid", QCP.equals, sourcebillid); | ||||
|                 QFilter q2 = new QFilter("actrecamt", QCP.less_than, 0); | ||||
|  | @ -103,8 +103,8 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|             DynamicObject org = bill.getDynamicObject("org"); | ||||
|             if (null != org) { | ||||
|                 long orgid = org.getLong("id"); | ||||
|                 QFilter q4 = new QFilter("org_entry.u_org.id", QCP.equals,orgid ); | ||||
|                 q2  = q2.and(q4); | ||||
|                 QFilter q4 = new QFilter("org_entry.u_org.id", QCP.equals, orgid); | ||||
|                 q2 = q2.and(q4); | ||||
|             } | ||||
|             DynamicObject rule = BusinessDataServiceHelper.loadSingle("cas_recpayrule", q2.toArray()); | ||||
|             if (null != rule) { | ||||
|  | @ -124,12 +124,13 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|                          */ | ||||
|                         String oppunit = beiIntelpay.getString("oppunit");//收款入账中心的对方户名 | ||||
|                         Long companyId = beiIntelpay.getLong("company.id");//收款入账中心的资金组织id | ||||
|                         String companyNumber = beiIntelpay.getString("company.number");//收款入账中心的资金组织编码 | ||||
|                         bill.set("shjh_dfhm", oppunit);//收款单备注字段 | ||||
|                         bill.set("payertype", "bd_customer");//付款人类型:客户 | ||||
|                         // 2025/6/18 优化: 先根据规则指定的付款人赋值 | ||||
|                         //判断收款单是否从规则和客户映射表取过数据,如果取过了,则设置为true;没取过,则取值 | ||||
|                         if (!bill.getBoolean("shjh_xdgzkh")) { | ||||
|                             carryCustomerRule(entry,bill,oppunit,companyId); | ||||
|                             carryCustomerRule(entry, bill, oppunit, companyId, companyNumber); | ||||
| //                            DynamicObject ePayerid = entry.getDynamicObject("e_payerid"); | ||||
| //                            if (null != ePayerid) { | ||||
| //                                bill.set("payer", ePayerid.getPkValue()); //付款人id | ||||
|  | @ -187,7 +188,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|                                 DynamicObject entryss = entrys.get(0);//首行(被动) | ||||
|                                 DynamicObject shjhYym = entryss.getDynamicObject("shjh_yym");//若收款单分录原因码为空,则从业务小类中携带 | ||||
|                                 if (null != shjhEBizsmall) { | ||||
|                                     shjhEBizsmall = BusinessDataServiceHelper.loadSingle(shjhEBizsmall.getPkValue(),"shjh_bizsmalltype"); | ||||
|                                     shjhEBizsmall = BusinessDataServiceHelper.loadSingle(shjhEBizsmall.getPkValue(), "shjh_bizsmalltype"); | ||||
|                                     if (null == shjhYym) { | ||||
|                                         entryss.set("shjh_yym", shjhEBizsmall.getDynamicObject("shjh_yym"));//规则--小类--原因码 | ||||
|                                     } | ||||
|  | @ -196,30 +197,30 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|                                         //【业务小类】清账方式字段=全部金蝶清账,再判断是否为结构性清账客户 | ||||
|                                         //判断客户是否拆分,客户拆分为否时,以表头付款人来判断,否则以分录上的客户来判断 | ||||
|                                         boolean customerSplit = bill.getBoolean("shjh_customersplit"); | ||||
|                                         if(customerSplit){ | ||||
|                                         if (customerSplit) { | ||||
|                                             //以分录上客户来判断的话,先设置成不下推,由人为操作单子后系统判断 | ||||
|                                             entryss.set("shjh_needpushbill", false);//不需要下推清账单 | ||||
|                                             entryss.set("shjh_closingstatus", "A");//无需金蝶清账 | ||||
|                                             bill.set("shjh_qzzt", "A");//无需金蝶清账 | ||||
|                                         }else{ | ||||
|                                         } else { | ||||
|                                             //根据收款单付款人id判断,此时的付款类型是客户 | ||||
|                                             QFilter mapnumber = new QFilter("shjh_customer.id", QCP.equals, bill.getLong("payer"));//客户 | ||||
|                                             mapnumber.and("enable", QCP.equals, "1");//是否可用 | ||||
|                                             mapnumber.and("shjh_org.id", QCP.equals, org.getLong("id"));//公司 | ||||
|                                             DynamicObject mappingObj = BusinessDataServiceHelper.loadSingle("shjh_jgqzcust", mapnumber.toArray()); | ||||
|                                             if(mappingObj != null){ | ||||
|                                             if (mappingObj != null) { | ||||
|                                                 //结构性清账客户映射表中有值 | ||||
|                                                 entryss.set("shjh_needpushbill", true);//需要下推清账单 | ||||
|                                                 entryss.set("shjh_closingstatus", "B");//待清账 | ||||
|                                                 bill.set("shjh_qzzt", "B");//待清账 | ||||
|                                             }else{ | ||||
|                                             } else { | ||||
|                                                 entryss.set("shjh_needpushbill", false);//不需要下推清账单 | ||||
|                                                 entryss.set("shjh_closingstatus", "A");//无需金蝶清账 | ||||
|                                                 bill.set("shjh_qzzt", "A");//无需金蝶清账 | ||||
|                                             } | ||||
|                                         } | ||||
| 
 | ||||
|                                     }else{ | ||||
|                                     } else { | ||||
|                                         entryss.set("shjh_needpushbill", false);//不需要下推清账单 | ||||
|                                         entryss.set("shjh_closingstatus", "A");//无需金蝶清账 | ||||
|                                         bill.set("shjh_qzzt", "A");//无需金蝶清账 | ||||
|  | @ -248,7 +249,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|         Date bizDate = bill.getDate("bizdate"); | ||||
|         QFilter qFilter = new QFilter("shjh_biztype", QCP.equals, "B"); // 业务类型:收款 | ||||
|         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_enddate", QCP.large_equals, bizDate)); | ||||
| 
 | ||||
|  | @ -329,7 +330,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
| 
 | ||||
|             //付款人类型 | ||||
|             String payerType = bill.getString("payertype"); | ||||
|             if (null!=payerType) { | ||||
|             if (null != payerType) { | ||||
|                 switch (payerType) { | ||||
|                     case "bd_customer": | ||||
|                         // 10_1. 检查客户(包含) | ||||
|  | @ -382,16 +383,16 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 包含某个多选基础资料-收款单表头取数 | ||||
|      * @param accountBill 资金计划科目表 | ||||
|      * @param recBill 收款处理 | ||||
|      * | ||||
|      * @param accountBill  资金计划科目表 | ||||
|      * @param recBill      收款处理 | ||||
|      * @param accountField 被匹配基础资料标识 | ||||
|      * @param recField 提供基础资料标识 | ||||
|      * @param recField     提供基础资料标识 | ||||
|      * @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); | ||||
|         if (dynamicObjectCollection.isEmpty()) { | ||||
|             return false; // 无限制-通过 | ||||
|  | @ -413,14 +414,15 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
| 
 | ||||
|     /** | ||||
|      * 包含某个多选基础资料-收款单分录取数 | ||||
|      * @param accountBill 资金计划科目表 | ||||
|      * @param recBill 收款处理 | ||||
|      * @param entryName 分录标识 | ||||
|      * | ||||
|      * @param accountBill  资金计划科目表 | ||||
|      * @param recBill      收款处理 | ||||
|      * @param entryName    分录标识 | ||||
|      * @param accountField 被匹配基础资料标识 | ||||
|      * @param recField 提供基础资料标识 | ||||
|      * @param recField     提供基础资料标识 | ||||
|      * @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); | ||||
|         if (dynamicObjectCollection.isEmpty()) { | ||||
|             return false; // 无限制则通过 | ||||
|  | @ -432,7 +434,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|         } | ||||
| 
 | ||||
|         DynamicObject dynamicObject = entry.get(0).getDynamicObject(recField); | ||||
|         if (dynamicObject==null){ | ||||
|         if (dynamicObject == null) { | ||||
|             return true;//放行 | ||||
|         } | ||||
|         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 recField 提供基础资料标识 | ||||
|      * @param recField     提供基础资料标识 | ||||
|      * @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); | ||||
|         if (dynamicObjectCollection.isEmpty()) { | ||||
|             return false; // 无排除限制则通过 | ||||
|  | @ -475,13 +478,14 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
| 
 | ||||
|     /** | ||||
|      * 针对包含客户||供应商 | ||||
|      * | ||||
|      * @param accountBill | ||||
|      * @param recBill | ||||
|      * @param accountField | ||||
|      * @param recField | ||||
|      * @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); | ||||
|         if (dynamicObjectCollection.isEmpty()) { | ||||
|             return false; // 无限制则通过 | ||||
|  | @ -502,13 +506,14 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
| 
 | ||||
|     /** | ||||
|      * 针对不包含客户||供应商 | ||||
|      * | ||||
|      * @param accountBill | ||||
|      * @param recBill | ||||
|      * @param accountField | ||||
|      * @param recField | ||||
|      * @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); | ||||
|         if (dynamicObjectCollection.isEmpty()) { | ||||
|             return false; // 无限制则通过 | ||||
|  | @ -529,8 +534,9 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
| 
 | ||||
|     /** | ||||
|      * 针对客户检查客户组,客户组为必填项 | ||||
|      * | ||||
|      * @param accountBill 资金计划科目表 | ||||
|      * @param recBill 收款处理 | ||||
|      * @param recBill     收款处理 | ||||
|      * @return | ||||
|      */ | ||||
|     private boolean checkCustomerGroup(DynamicObject accountBill, DynamicObject recBill) { | ||||
|  | @ -583,7 +589,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
| 
 | ||||
|             for (DynamicObject allowedGroup : allowedGroups) { | ||||
|                 DynamicObject baseDataObj = allowedGroup.getDynamicObject("fbasedataid"); | ||||
|                 String number=baseDataObj.getString("number"); | ||||
|                 String number = baseDataObj.getString("number"); | ||||
|                 if (customerGroupNumber.equals(number)) { | ||||
|                     return false; // 匹配到允许的客户组 | ||||
|                 } | ||||
|  | @ -600,70 +606,82 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|      * 3.规则生单未配置客户——>取收款入账中心客户 | ||||
|      * 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.先看取映射表按钮是否打开,打开——>取映射表中客户 | ||||
|         //20250704 经过和建彪沟通先注释根据标记来判断的代码 | ||||
| //        boolean shjhEGetcustomer = entry.getBoolean("shjh_e_getcustomer"); //取规则得映射表客户标记 | ||||
| //        if (shjhEGetcustomer) { | ||||
|             QFilter qFilter = new QFilter("shjh_dfhm", QCP.equals, oppunit); | ||||
|             //新增收款入账中心-资金组织&&映射表组织过滤 | ||||
|             qFilter.and(new QFilter("shjh_org.id", QCP.equals, companyId)); | ||||
|             //对方户名与客户名称映射表 shjh_dfhmcust | ||||
|             DynamicObject shjhDfhmcust = BusinessDataServiceHelper.loadSingle("shjh_dfhmcust", qFilter.toArray()); | ||||
|             if (null != shjhDfhmcust) { | ||||
|                 DynamicObject shjhCustomer = shjhDfhmcust.getDynamicObject("shjh_customer"); | ||||
|                 if (null != shjhCustomer) { | ||||
|                     bill.set("payer", shjhCustomer.getPkValue()); //付款人id | ||||
|                     bill.set("payernumber", shjhCustomer.getString("number")); //付款人编码 | ||||
|                     bill.set("payername", shjhCustomer.getString("name")); //付款人名称 | ||||
|                 } | ||||
|         QFilter qFilter = new QFilter("shjh_dfhm", QCP.equals, oppunit); | ||||
|         //新增收款入账中心-资金组织&&映射表组织过滤 | ||||
|         qFilter.and(new QFilter("shjh_org.id", QCP.equals, companyId)); | ||||
|         //对方户名与客户名称映射表 shjh_dfhmcust | ||||
|         DynamicObject shjhDfhmcust = BusinessDataServiceHelper.loadSingle("shjh_dfhmcust", qFilter.toArray()); | ||||
|         if (null != shjhDfhmcust) { | ||||
|             DynamicObject shjhCustomer = shjhDfhmcust.getDynamicObject("shjh_customer"); | ||||
|             if (null != shjhCustomer) { | ||||
|                 bill.set("payer", shjhCustomer.getPkValue()); //付款人id | ||||
|                 bill.set("payernumber", shjhCustomer.getString("number")); //付款人编码 | ||||
|                 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 { | ||||
|                 //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 { | ||||
|                     //3.规则生单未配置客户——>取收款入账中心客户 | ||||
|                     QFilter customerFilter = new QFilter("name", QCP.equals, oppunit); | ||||
|                     //可用状态 | ||||
|                     customerFilter.and(new QFilter("enable",QCP.equals,"1")); | ||||
|                     DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name",customerFilter.toArray()); | ||||
|                     boolean exitCustomerArray = false; | ||||
|                     if (null != bd_customer  ) { | ||||
|                         if (bd_customer.length!=0){ | ||||
|                             bill.set("payer", bd_customer[0].getPkValue()); //付款人id | ||||
|                             bill.set("payernumber", bd_customer[0].getString("number")); //付款人编码 | ||||
|                             bill.set("payername", bd_customer[0].getString("name")); //付款人名称 | ||||
|                             exitCustomerArray=true; | ||||
|                 //3.规则生单未配置客户——>取收款入账中心客户 | ||||
|                 QFilter customerFilter = new QFilter("name", QCP.equals, oppunit); | ||||
|                 //可用状态 | ||||
|                 customerFilter.and(new QFilter("enable", QCP.equals, "1")); | ||||
|                 DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name", customerFilter.toArray()); | ||||
|                 boolean exitCustomerArray = false; | ||||
|                 if (null != bd_customer && bd_customer.length != 0) { | ||||
|                     if (bd_customer.length == 1) { | ||||
|                         bill.set("payer", bd_customer[0].getPkValue()); //付款人id | ||||
|                         bill.set("payernumber", bd_customer[0].getString("number")); //付款人编码 | ||||
|                         bill.set("payername", bd_customer[0].getString("name")); //付款人名称 | ||||
|                         exitCustomerArray = true; | ||||
|                     } else { | ||||
|                         //存在多个客户,判断组织编码companyNumber是否在客户基础资料客户组5分录中的销售公司编码中配置 | ||||
|                         for (int i = 0; i < bd_customer.length; i++) { | ||||
|                             Set<String> numberSet = new HashSet<>(); | ||||
|                             DynamicObject customer = BusinessDataServiceHelper.loadSingle(bd_customer[i].getPkValue(), "bd_customer"); | ||||
|                             if (customer!=null){ | ||||
|                                 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.规则生单未配置客户——>默认不确定客户 | ||||
|                         QFilter qFilter1 = new QFilter("number", QCP.equals, "1042086"); //4000042 | ||||
|                         DynamicObject bdCustomer = BusinessDataServiceHelper.loadSingle("bd_customer", qFilter1.toArray()); | ||||
|                         if (null != bdCustomer) { | ||||
|                             bill.set("payer", bdCustomer.getPkValue()); //付款人id | ||||
|                             bill.set("payernumber", bdCustomer.getString("number")); //付款人编码 | ||||
|                             bill.set("payername", bdCustomer.getString("name")); //付款人名称 | ||||
|                         } | ||||
|                 } | ||||
|                 if (!exitCustomerArray) { | ||||
|                     //4.规则生单未配置客户——>默认不确定客户 | ||||
|                     QFilter qFilter1 = new QFilter("number", QCP.equals, "1042086"); //4000042 | ||||
|                     DynamicObject bdCustomer = BusinessDataServiceHelper.loadSingle("bd_customer", qFilter1.toArray()); | ||||
|                     if (null != bdCustomer) { | ||||
|                         bill.set("payer", bdCustomer.getPkValue()); //付款人id | ||||
|                         bill.set("payernumber", bdCustomer.getString("number")); //付款人编码 | ||||
|                         bill.set("payername", bdCustomer.getString("name")); //付款人名称 | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             bill.set("shjh_xdgzkh", true);//设置收款单标记位 从规则携带客户等信息 为true | ||||
|         } | ||||
|         bill.set("shjh_xdgzkh", true);//设置收款单标记位 从规则携带客户等信息 为true | ||||
| //        } | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue