支付信息变更单-列表过滤锁定当前变更人
This commit is contained in:
		
							parent
							
								
									9361e4ec6e
								
							
						
					
					
						commit
						e12d9ed338
					
				|  | @ -3,6 +3,7 @@ package shjh.jhzj7.fi.fi.plugin.task; | ||||||
| import kd.bos.context.RequestContext; | import kd.bos.context.RequestContext; | ||||||
| import kd.bos.dataentity.OperateOption; | import kd.bos.dataentity.OperateOption; | ||||||
| import kd.bos.dataentity.entity.DynamicObject; | import kd.bos.dataentity.entity.DynamicObject; | ||||||
|  | import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||||
| import kd.bos.entity.operate.OperateOptionConst; | import kd.bos.entity.operate.OperateOptionConst; | ||||||
| import kd.bos.entity.operate.result.OperationResult; | import kd.bos.entity.operate.result.OperationResult; | ||||||
| import kd.bos.exception.KDException; | import kd.bos.exception.KDException; | ||||||
|  | @ -16,6 +17,8 @@ import kd.bos.servicehelper.operation.OperationServiceHelper; | ||||||
| import kd.sdk.plugin.Plugin; | import kd.sdk.plugin.Plugin; | ||||||
| 
 | 
 | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  | import java.util.Calendar; | ||||||
|  | import java.util.Date; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | @ -47,20 +50,69 @@ public class PayApplyFukuanTask extends AbstractTask implements Plugin { | ||||||
|             // 不显示交互提示,自动执行到底 |             // 不显示交互提示,自动执行到底 | ||||||
|             operateOption.setVariableValue(OperateOptionConst.IGNOREINTERACTION, String.valueOf(true)); |             operateOption.setVariableValue(OperateOptionConst.IGNOREINTERACTION, String.valueOf(true)); | ||||||
|             // 全部校验通过才保存 |             // 全部校验通过才保存 | ||||||
|             operateOption.setVariableValue(OperateOptionConst.STRICTVALIDATION, String.valueOf(true)); |             //operateOption.setVariableValue(OperateOptionConst.STRICTVALIDATION, String.valueOf(true)); | ||||||
|             //同一个用户在多个界面操作同一张,也不允许操作 |             //同一个用户在多个界面操作同一张,也不允许操作 | ||||||
|             operateOption.setVariableValue(OperateOptionConst.MUTEX_ISSTRICT, String.valueOf(true)); |             operateOption.setVariableValue(OperateOptionConst.MUTEX_ISSTRICT, String.valueOf(true)); | ||||||
|             for (DynamicObject dynamicObject : recBillMap.values()) { |             for (DynamicObject dynamicObject : recBillMap.values()) { | ||||||
|                 // 注意:executeOperate 需要一个数组形式的 DynamicObject[] |                 // 注意:executeOperate 需要一个数组形式的 DynamicObject[] | ||||||
|                 DynamicObject[] billArray = new DynamicObject[]{dynamicObject}; |                 DynamicObjectCollection entry = dynamicObject.getDynamicObjectCollection("entry"); | ||||||
|                 OperationResult operationResult = OperationServiceHelper.executeOperate("pushandsave", AP_PAYAPPLY, billArray, operateOption); |                 if (entry!=null && entry.size()!=0){ | ||||||
|                 // 可以根据需要处理 operationResult,例如检查是否成功、获取返回值等 |                     //判断是否集团内-境内外供应商 | ||||||
|                 if (operationResult.isSuccess()) { |                     DynamicObject dynamicObject1 = entry.get(0); | ||||||
|                     logger.info("执行 pay 成功,单据编号:" + dynamicObject.getPkValue()); |                     boolean supplierFilter = supplierFilter(dynamicObject1); | ||||||
|                 } else { |                     //判断是否存在数据在下推期间范围(到期日是当前月月底前) | ||||||
|                     logger.error(operationResult.getMessage()); |                     boolean expirationDateFilter = expirationDateFilter(entry); | ||||||
|  |                     if (!supplierFilter && expirationDateFilter){ | ||||||
|  |                         DynamicObject[] billArray = new DynamicObject[]{dynamicObject}; | ||||||
|  |                         OperationResult operationResult = OperationServiceHelper.executeOperate("pushandsave", AP_PAYAPPLY, billArray, operateOption); | ||||||
|  |                         // 可以根据需要处理 operationResult,例如检查是否成功、获取返回值等 | ||||||
|  |                         if (operationResult.isSuccess()) { | ||||||
|  |                             logger.info("执行 pay 成功,单据编号:" + dynamicObject.getPkValue()); | ||||||
|  |                         } else { | ||||||
|  |                             logger.error(operationResult.getMessage()); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     private boolean supplierFilter(DynamicObject dynamicObject){ | ||||||
|  |         boolean isFilterSupplier = false; | ||||||
|  |         String asstacttype = dynamicObject.getString("e_asstacttype"); | ||||||
|  |         if ("bd_supplier".equals(asstacttype)){ | ||||||
|  |             DynamicObject asstact = dynamicObject.getDynamicObject("e_asstact"); | ||||||
|  |             if (asstact!=null){ | ||||||
|  |                 //获取供应商分类映射 | ||||||
|  |                 QFilter qFilter1 = new QFilter("supplier.id", QCP.equals, asstact.getPkValue()); | ||||||
|  |                 DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle("bd_suppliergroupdetail", qFilter1.toArray()); | ||||||
|  |                 if (dynamicObject1!=null){ | ||||||
|  |                     String number = dynamicObject1.getString("group.number"); | ||||||
|  |                     if ("D200".equals(number) || "D201".equals(number)){ | ||||||
|  |                         isFilterSupplier=true; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return isFilterSupplier; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private boolean expirationDateFilter(DynamicObjectCollection entry){ | ||||||
|  |         boolean hasValidDueDate = false;  // 默认false,表示没有符合条件的数据 | ||||||
|  | 
 | ||||||
|  |         // 获取当前月的最后一天(月底) | ||||||
|  |         Calendar calendar = Calendar.getInstance(); | ||||||
|  |         calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); | ||||||
|  |         Date endOfCurrentMonth = calendar.getTime(); | ||||||
|  | 
 | ||||||
|  |         //遍历entry集合,检查是否有到期日小于等于当前月月底的数据 | ||||||
|  |         for (DynamicObject object : entry) { | ||||||
|  |             Date dueDate = object.getDate("e_duedate"); | ||||||
|  |             if (dueDate != null && dueDate.compareTo(endOfCurrentMonth) <= 0) { | ||||||
|  |                 hasValidDueDate = true;  // 找到符合条件的数据 | ||||||
|  |                 break;  // 只要有一条符合就退出循环 | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return hasValidDueDate; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue