理财批量预提计算逻辑修改
This commit is contained in:
		
							parent
							
								
									802a71815c
								
							
						
					
					
						commit
						b242e37fa2
					
				|  | @ -11,8 +11,10 @@ import shjh.jhzj7.fi.fi.plugin.report.FinancialFormReport; | |||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.EventObject; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * 理财批量预提表单插件 | ||||
|  | @ -45,10 +47,7 @@ public class CimIntBillBatchFormPlugin extends AbstractFormPlugin implements Plu | |||
|                                     DynamicObjectCollection valuationentry = finsubscribe.getDynamicObjectCollection("valuationentry"); | ||||
| 
 | ||||
|                                     if (valuationentry != null && valuationentry.size() != 0) { | ||||
| 
 | ||||
|                                         BigDecimal redProductAmount = this.getRedProductAmount(valuationentry, preintdate); | ||||
| 
 | ||||
| 
 | ||||
|                                         DynamicObject targetValuation = null; | ||||
| 
 | ||||
|                                         // 1. 如果只有一条估值数据,直接使用 | ||||
|  | @ -59,6 +58,7 @@ public class CimIntBillBatchFormPlugin extends AbstractFormPlugin implements Plu | |||
|                                         else { | ||||
|                                             // 初始化最近日期和最小时间差 | ||||
|                                             long minDiff = Long.MAX_VALUE; | ||||
|                                             List<DynamicObject> candidates = new ArrayList<>(); | ||||
| 
 | ||||
|                                             for (int j = 0; j < valuationentry.size(); j++) { | ||||
|                                                 DynamicObject valuation = valuationentry.get(j); | ||||
|  | @ -68,13 +68,54 @@ public class CimIntBillBatchFormPlugin extends AbstractFormPlugin implements Plu | |||
|                                                     // 计算时间差(绝对值) | ||||
|                                                     long diff = Math.abs(valuationDate.getTime() - preintdate.getTime()); | ||||
| 
 | ||||
|                                                     // 如果找到更接近的日期,更新目标数据 | ||||
|                                                     if (diff < minDiff) { | ||||
|                                                         minDiff = diff; | ||||
|                                                         targetValuation = valuation; | ||||
|                                                         candidates.clear(); | ||||
|                                                         candidates.add(valuation); | ||||
|                                                     } else if (diff == minDiff) { | ||||
|                                                         candidates.add(valuation); | ||||
|                                                     } | ||||
|                                                 } | ||||
|                                             } | ||||
| 
 | ||||
|                                             // 如果有多个候选记录,按照规则选择 | ||||
|                                             if (candidates.size() > 1) { | ||||
|                                                 candidates.sort((o1, o2) -> { | ||||
|                                                     // 1. 比较赎回日期 | ||||
|                                                     Date redDate1 = o1.getDate("shjh_shrq"); | ||||
|                                                     Date redDate2 = o2.getDate("shjh_shrq"); | ||||
| 
 | ||||
|                                                     if (redDate1 != null && redDate2 != null) { | ||||
|                                                         int compareRedDate = redDate2.compareTo(redDate1); // 赎回日期降序 | ||||
|                                                         if (compareRedDate != 0) { | ||||
|                                                             return compareRedDate; | ||||
|                                                         } | ||||
|                                                     } else if (redDate1 != null) { | ||||
|                                                         return -1; | ||||
|                                                     } else if (redDate2 != null) { | ||||
|                                                         return 1; | ||||
|                                                     } | ||||
| 
 | ||||
|                                                     // 2. 赎回日期都为null时,比较seq(假设有seq字段) | ||||
|                                                     Integer seq1 = o1.getInt("seq"); | ||||
|                                                     Integer seq2 = o2.getInt("seq"); | ||||
| 
 | ||||
|                                                     if (seq1 != null && seq2 != null) { | ||||
|                                                         return seq2.compareTo(seq1); // seq降序 | ||||
|                                                     } else if (seq1 != null) { | ||||
|                                                         return -1; | ||||
|                                                     } else if (seq2 != null) { | ||||
|                                                         return 1; | ||||
|                                                     } | ||||
| 
 | ||||
|                                                     return 0; | ||||
|                                                 }); | ||||
|                                             } | ||||
| 
 | ||||
|                                             // 选择排序后的第一个候选记录 | ||||
|                                             if (!candidates.isEmpty()) { | ||||
|                                                 targetValuation = candidates.get(0); | ||||
|                                             } | ||||
|                                         } | ||||
| 
 | ||||
|                                         // 3. 计算本次预算预提收益 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue