- [x] 优化收款单携带资金计划科目的逻辑
- [x] 优化付款申请单携带资金计划科目的逻辑(不包含单据类型) --s
This commit is contained in:
		
							parent
							
								
									5f7a0885a4
								
							
						
					
					
						commit
						1197af0625
					
				|  | @ -15,14 +15,12 @@ import kd.bos.orm.query.QCP; | |||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.bos.servicehelper.operation.SaveServiceHelper; | ||||
| import kd.bos.util.StringUtils; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import shjh.jhzj7.fi.fi.utils.JhzjUtils; | ||||
| 
 | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.*; | ||||
| 
 | ||||
| import static shjh.jhzj7.fi.fi.utils.SapUtils.unlocked_status; | ||||
| 
 | ||||
|  | @ -255,22 +253,6 @@ public class PayApplySaveOperation extends AbstractOperationServicePlugIn implem | |||
|         JhzjUtils.saveLog(bill.getString("billno"), "付款申请携带资金计划科目(供应商/客户)","" | ||||
|                 ,queryDyobj(qFilter), true, String.valueOf(BusinessDataServiceHelper.load("shjh_request_account", | ||||
|                         "id,shjh_membersubject", qFilter.toArray()).length)); | ||||
| 
 | ||||
|         //外部系统单据类型_多选下拉 && 不包含单据类型 | ||||
|         String shjhExternalsystemdocume = bill.getString("shjh_externalsystemdocume"); | ||||
|         if (StringUtil.isNotEmpty(shjhExternalsystemdocume)) { | ||||
|             QFilter q4 = new QFilter("shjh_billtype", QCP.like, "%"+shjhExternalsystemdocume+"%"); | ||||
|             QFilter q5 = new QFilter("shjh_billtype", QCP.like, "%"+"%"); | ||||
|             QFilter q6 = new QFilter("shjh_bbhdjlx" , QCP.like, "%"+shjhExternalsystemdocume+"%"); | ||||
|             QFilter q7 = new QFilter("shjh_bbhdjlx" , QCP.like, "%"+"%"); | ||||
|             qFilter = qFilter.and(q4.or(q5)).and(q6.or(q7)); | ||||
|         }else { | ||||
|             QFilter q5 = new QFilter("shjh_billtype", QCP.like, "%"+"%"); | ||||
|             qFilter = qFilter.and(q5); | ||||
|         } | ||||
|         JhzjUtils.saveLog(bill.getString("billno"), "付款申请携带资金计划科目(外部系统单据类型)","" | ||||
|                 ,queryDyobj(qFilter), true, String.valueOf(BusinessDataServiceHelper.load("shjh_request_account", | ||||
|                         "id,shjh_membersubject", qFilter.toArray()).length)); | ||||
|         //不包含币种 currency | ||||
|         DynamicObject currency = bill.getDynamicObject("paycurrency"); | ||||
|         if (null != currency) { | ||||
|  | @ -299,7 +281,8 @@ public class PayApplySaveOperation extends AbstractOperationServicePlugIn implem | |||
|                 ,queryDyobj(qFilter), true, String.valueOf(BusinessDataServiceHelper.load("shjh_request_account", | ||||
|                         "id,shjh_membersubject", qFilter.toArray()).length)); | ||||
| 
 | ||||
|         DynamicObject[] accounts = BusinessDataServiceHelper.load("shjh_request_account", "id,shjh_membersubject,shjh_cgz,shjh_bbhcgz", qFilter.toArray()); | ||||
|         DynamicObject[] accounts = BusinessDataServiceHelper.load("shjh_request_account", "id," + | ||||
|                 "shjh_membersubject,shjh_cgz,shjh_bbhcgz,shjh_billtype,shjh_bbhdjlx", qFilter.toArray()); | ||||
| 
 | ||||
| 
 | ||||
|         if (accounts.length > 1) { | ||||
|  | @ -313,40 +296,65 @@ public class PayApplySaveOperation extends AbstractOperationServicePlugIn implem | |||
|         } | ||||
|         // 转换为 List 以便支持 remove 操作 | ||||
|         List<DynamicObject> configList = new ArrayList<>(Arrays.asList(accounts)); | ||||
|         //采购组shjh_procurementteam && 不包含采购组 | ||||
| 
 | ||||
|         // 采购组shjh_procurementteam && 不包含采购组 | ||||
|         String shjhBhcgz = bill.getString("shjh_procurementteam"); | ||||
|         QFilter filter = new QFilter("number", QCP.equals, shjhBhcgz); | ||||
|         DynamicObject shjh_cgz = BusinessDataServiceHelper.loadSingle("shjh_cgz", filter.toArray()); | ||||
|         if (null != shjh_cgz) { | ||||
|             boolean isbh = false; | ||||
|             Long cgzid = shjh_cgz.getLong("id"); | ||||
|             for (DynamicObject account : accounts) { | ||||
|                 DynamicObjectCollection shjh_cgzs = account.getDynamicObjectCollection("shjh_cgz");//采购组 | ||||
| 
 | ||||
|         if (shjh_cgz != null) { | ||||
|             long cgzid = shjh_cgz.getLong("id"); | ||||
|             Iterator<DynamicObject> iterator = configList.iterator(); | ||||
|             while (iterator.hasNext()) { | ||||
|                 DynamicObject account = iterator.next(); | ||||
|                 // 检查采购组 | ||||
|                 boolean isbh = false; | ||||
|                 DynamicObjectCollection shjh_cgzs = account.getDynamicObjectCollection("shjh_cgz"); | ||||
|                 for (DynamicObject shjhCgz : shjh_cgzs) { | ||||
|                     DynamicObject fbasedataid = shjhCgz.getDynamicObject("fbasedataid"); | ||||
|                     if (null != fbasedataid) { | ||||
|                         long id = fbasedataid.getLong("id"); | ||||
|                         if (id == cgzid) { | ||||
|                             isbh = true; | ||||
|                         } | ||||
|                     if (fbasedataid != null && fbasedataid.getLong("id") == cgzid) { | ||||
|                         isbh = true; | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 if (!isbh && !shjh_cgzs.isEmpty()) { | ||||
|                     configList.remove(account); | ||||
|                     iterator.remove(); | ||||
|                     continue; | ||||
|                 } | ||||
|                 DynamicObjectCollection shjh_bbhcgzs = account.getDynamicObjectCollection("shjh_bbhcgz");//不包含采购组 | ||||
| 
 | ||||
|                 // 检查不包含采购组 | ||||
|                 DynamicObjectCollection shjh_bbhcgzs = account.getDynamicObjectCollection("shjh_bbhcgz"); | ||||
|                 for (DynamicObject shjhBbhcgz : shjh_bbhcgzs) { | ||||
|                     DynamicObject fbasedataid = shjhBbhcgz.getDynamicObject("fbasedataid"); | ||||
|                     if (null != fbasedataid) { | ||||
|                         long id = fbasedataid.getLong("id"); | ||||
|                         if (id == cgzid) { | ||||
|                             configList.remove(account); | ||||
|                         } | ||||
|                     if (fbasedataid != null && fbasedataid.getLong("id") == cgzid) { | ||||
|                         iterator.remove(); | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // 外部系统单据类型_多选下拉 && 不包含单据类型 | ||||
|         String shjhExternalsystemdocume = bill.getString("shjh_externalsystemdocume"); | ||||
|         // 使用迭代器遍历以安全删除元素 | ||||
|         Iterator<DynamicObject> iterator = configList.iterator(); | ||||
|         while (iterator.hasNext()) { | ||||
|             DynamicObject account = iterator.next(); | ||||
|             account = BusinessDataServiceHelper.loadSingle(account.getPkValue(), "shjh_request_account"); | ||||
|             String bhdjlx = account.getString("shjh_billtype"); | ||||
|             // 外部系统单据类型_不包含剔除 | ||||
|             if (!bhdjlx.contains(shjhExternalsystemdocume) && StringUtils.isNotEmpty(bhdjlx)) { | ||||
|                 iterator.remove(); | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
|             String bbhdjlx = account.getString("shjh_bbhdjlx"); | ||||
|             // 不包含单据类型_包含剔除 | ||||
|             if (bbhdjlx.contains(shjhExternalsystemdocume)) { | ||||
|                 iterator.remove(); | ||||
|             } | ||||
|         } | ||||
|         if (!configList.isEmpty()) { | ||||
|             // 处理找到符合条件的账户 | ||||
|             DynamicObject account = configList.get(0); | ||||
|  |  | |||
|  | @ -496,6 +496,13 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|             return false; // 配置未限制客户组,默认通过 | ||||
|         } | ||||
| 
 | ||||
|         //获取收款单组织 | ||||
|         DynamicObject openorg = recBill.getDynamicObject("openorg"); | ||||
|         String orgNumber = ""; | ||||
|         if (null != openorg) { | ||||
|             orgNumber = openorg.getString("number"); | ||||
|         } | ||||
| 
 | ||||
|         // 5. 检查客户是否属于配置允许的客户组 | ||||
|         for (DynamicObject customerGroup : customerGroups) { | ||||
|             String customerGroupNumber = customerGroup.getString("shjh_entryfive_number"); | ||||
|  | @ -503,6 +510,15 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|                 continue; // 跳过无编号的客户组 | ||||
|             } | ||||
| 
 | ||||
|             String salecompanynum = customerGroup.getString("shjh_salecompanynum"); | ||||
|             if (salecompanynum == null) { | ||||
|                 continue; // 跳过无销售公司编号的客户组 | ||||
|             } | ||||
| 
 | ||||
|             if (!salecompanynum.equals(orgNumber)) { | ||||
|                 continue; // 跳过销售公司编号与收款单核算组织不匹配的客户组 | ||||
|             } | ||||
| 
 | ||||
|             for (DynamicObject allowedGroup : allowedGroups) { | ||||
|                 DynamicObject baseDataObj = allowedGroup.getDynamicObject("fbasedataid"); | ||||
|                 String number=baseDataObj.getString("number"); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue