理财申购、赎回改动
This commit is contained in:
		
							parent
							
								
									c8b45040e4
								
							
						
					
					
						commit
						62b854f1a3
					
				|  | @ -11,6 +11,7 @@ import kd.bos.servicehelper.operation.SaveServiceHelper; | |||
| import kd.sdk.plugin.Plugin; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.util.Date; | ||||
| import java.util.EventObject; | ||||
| 
 | ||||
| /** | ||||
|  | @ -53,20 +54,24 @@ public class CimFinancialBillPlugin extends AbstractBillPlugIn implements Plugin | |||
|                 this.getView().showTipNotification("无可删除数据!"); | ||||
|                 return; | ||||
|             } | ||||
|             DynamicObject maxSeqItem = findMaxSeqItem(entryEntity); | ||||
|             DynamicObject maxSeqItem = findMaxDateItem(entryEntity); | ||||
|             if (maxSeqItem!=null){ | ||||
|                 DynamicObject redeemBill = maxSeqItem.getDynamicObject("shjh_shdh"); | ||||
|                 if (redeemBill!=null){ | ||||
|                     this.getView().showTipNotification("最新估值分录存在已审核赎回单!"); | ||||
|                 }else { | ||||
|                     entryEntity.remove(maxSeqItem); | ||||
|                     DynamicObject newMaxSeqItem = findMaxSeqItem(entryEntity); | ||||
|                     DynamicObject newMaxSeqItem = findMaxDateItem(entryEntity); | ||||
|                     if (newMaxSeqItem!=null){ | ||||
|                         BigDecimal e_surpcopies = newMaxSeqItem.getBigDecimal("e_surpcopies"); | ||||
|                         financialBill.set("surpluscopies",e_surpcopies); | ||||
|                         SaveServiceHelper.update(financialBill); | ||||
|                     } | ||||
|                     DB.update(DBRoute.of("fi"),DELETE,new Object[]{maxSeqItem.getPkValue()}); | ||||
|                     int update = DB.update(DBRoute.of("fi"), DELETE, new Object[]{maxSeqItem.getPkValue()}); | ||||
|                     if (update==1){ | ||||
|                         //重新排序 | ||||
|                         this.reorder(financialBill,entryEntity); | ||||
|                     } | ||||
|                     this.getView().invokeOperation("refresh"); | ||||
|                 } | ||||
|             } | ||||
|  | @ -74,6 +79,47 @@ public class CimFinancialBillPlugin extends AbstractBillPlugIn implements Plugin | |||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private void reorder(DynamicObject financialBill,DynamicObjectCollection entryEntity) { | ||||
|         if (entryEntity == null || entryEntity.isEmpty()) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         // 1. 按估值日期和赎回日期排序 | ||||
|         DynamicObjectCollection sortedEntries = new DynamicObjectCollection(); | ||||
|         sortedEntries.addAll(entryEntity); | ||||
| 
 | ||||
|         sortedEntries.sort((o1, o2) -> { | ||||
|             // 优先按估值日期排序(从小到大) | ||||
|             Date valDate1 = o1.getDate("e_valuationdate"); | ||||
|             Date valDate2 = o2.getDate("e_valuationdate"); | ||||
|             int compareValDate = valDate1.compareTo(valDate2); | ||||
|             if (compareValDate != 0) { | ||||
|                 return compareValDate; | ||||
|             } | ||||
| 
 | ||||
|             // 估值日期相同时,按赎回日期排序 | ||||
|             Date redDate1 = o1.getDate("shjh_shrq"); | ||||
|             Date redDate2 = o2.getDate("shjh_shrq"); | ||||
|             if (redDate1 == null && redDate2 == null) return 0; | ||||
|             if (redDate1 == null) return -1;  // null视为较小值 | ||||
|             if (redDate2 == null) return 1; | ||||
|             return redDate1.compareTo(redDate2); | ||||
|         }); | ||||
| 
 | ||||
|         // 2. 重新赋值seq从0开始 | ||||
|         int seq = 0; | ||||
|         for (DynamicObject item : sortedEntries) { | ||||
|             item.set("seq", seq++); | ||||
|         } | ||||
| 
 | ||||
|         // 3. 将排序后的结果重新设置回原集合 | ||||
|         entryEntity.clear(); | ||||
|         entryEntity.addAll(sortedEntries); | ||||
|         financialBill.set("valuationentry",entryEntity); | ||||
|         SaveServiceHelper.update(financialBill); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private void updateBillInfo() { | ||||
|         boolean dataChanged = this.getModel().getDataChanged(); | ||||
|         if (dataChanged){ | ||||
|  | @ -91,30 +137,64 @@ public class CimFinancialBillPlugin extends AbstractBillPlugIn implements Plugin | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 从分录中查找行号最大的记录 | ||||
|      * 从分录中查找日期最大的记录 | ||||
|      * @param entryEntity 分录集合 | ||||
|      * @return 行号最大的记录,如果没有记录则返回null | ||||
|      */ | ||||
|     private DynamicObject findMaxSeqItem(DynamicObjectCollection entryEntity) { | ||||
|     private DynamicObject findMaxDateItem(DynamicObjectCollection entryEntity) { | ||||
|         if (entryEntity == null || entryEntity.isEmpty()) { | ||||
|             return null; | ||||
|         } | ||||
|         // 检查初始行情况 | ||||
|         if (entryEntity.size() == 1) { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         DynamicObject maxSeqItem = null; | ||||
|         int maxSeq = -1; | ||||
|         DynamicObject maxDateItem = null; | ||||
|         Date maxValDate = null; | ||||
|         Date maxRedDate = null; | ||||
| 
 | ||||
|         for (DynamicObject item : entryEntity) { | ||||
|             int currentSeq = item.getInt("seq"); | ||||
|             if (currentSeq==0){ | ||||
|                 this.getView().showMessage("初始行不可删除!"); | ||||
|                 return null; | ||||
|             //估值日期 | ||||
|             Date currentValDate = item.getDate("e_valuationdate"); | ||||
|             //赎回日期 | ||||
|             Date currentRedDate = item.getDate("shjh_shrq"); | ||||
|             // 第一次循环直接赋值 | ||||
|             if (maxDateItem == null) { | ||||
|                 maxDateItem = item; | ||||
|                 maxValDate = currentValDate; | ||||
|                 maxRedDate = currentRedDate; | ||||
|                 continue; | ||||
|             } | ||||
|             if (currentSeq > maxSeq) { | ||||
|                 maxSeq = currentSeq; | ||||
|                 maxSeqItem = item; | ||||
| 
 | ||||
|             // 比较估值日期 | ||||
|             int valDateCompare = currentValDate.compareTo(maxValDate); | ||||
|             if (valDateCompare > 0) { | ||||
|                 // 当前估值日期更大 | ||||
|                 maxDateItem = item; | ||||
|                 maxValDate = currentValDate; | ||||
|                 maxRedDate = currentRedDate; | ||||
|             } else if (valDateCompare == 0) { | ||||
|                 // 估值日期相同,比较赎回日期 | ||||
|                 // 处理赎回日期为null的情况 | ||||
|                 if (currentRedDate == null && maxRedDate == null) { | ||||
|                     continue; // 都为空,保持原样 | ||||
|                 } else if (currentRedDate == null) { | ||||
|                     continue; // 当前赎回日期为空,保持原样 | ||||
|                 } else if (maxRedDate == null) { | ||||
|                     // 原赎回日期为空,当前不为空,更新 | ||||
|                     maxDateItem = item; | ||||
|                     maxRedDate = currentRedDate; | ||||
|                 } else { | ||||
|                     // 都不为空,比较日期 | ||||
|                     if (currentRedDate.compareTo(maxRedDate) > 0) { | ||||
|                         maxDateItem = item; | ||||
|                         maxRedDate = currentRedDate; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return maxSeqItem; | ||||
|         return maxDateItem; | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,62 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.form; | ||||
| 
 | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.entity.operate.result.OperationResult; | ||||
| import kd.bos.form.CloseCallBack; | ||||
| import kd.bos.form.FormShowParameter; | ||||
| import kd.bos.form.ShowType; | ||||
| import kd.bos.form.events.AfterDoOperationEventArgs; | ||||
| import kd.bos.form.operate.FormOperate; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.QueryServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import kd.tmc.cim.common.helper.FinSubscribeValuationHelper; | ||||
| import kd.tmc.cim.formplugin.finsubscribe.FinSubscribeList; | ||||
| import kd.tmc.cim.formplugin.resource.CimFormResourceEnum; | ||||
| import kd.tmc.fbp.common.util.EmptyUtil; | ||||
| 
 | ||||
| /** | ||||
|  * 请implements插件扩展点接口 | ||||
|  */ | ||||
| public class FinSubScribeExtList extends FinSubscribeList { | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs args) { | ||||
|         FormOperate formOperate = (FormOperate)args.getSource(); | ||||
|         String operateKey = formOperate.getOperateKey(); | ||||
|         OperationResult operationResult = args.getOperationResult(); | ||||
|         if (operationResult != null && operationResult.isSuccess()) { | ||||
|             if (!"valuateupdate".equals(operateKey)){ | ||||
|                 super.afterDoOperation(args); | ||||
|             }else { | ||||
|                 this.showValuationUpdate(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void showValuationUpdate() { | ||||
|         Long selectedId = this.getSelectedId(); | ||||
|         if (!EmptyUtil.isEmpty(selectedId)) { | ||||
|             if (FinSubscribeValuationHelper.isExistOngoingRedeemBill(selectedId)) { | ||||
|                 this.getView().showTipNotification(CimFormResourceEnum.FinSubscribeList_17.loadKDString()); | ||||
|             } else { | ||||
|                 DynamicObjectCollection finsubCols = QueryServiceHelper.query("cim_finsubscribe", "currency,redeemway,valuationentry,valuationentry.e_surpcopies as e_surpcopies,valuationentry.e_iopv as e_iopv,valuationentry.e_valuation as e_valuation,valuationentry.e_valuationdate as e_valuationdate,valuationentry.seq as seq", new QFilter[]{new QFilter("id", "=", selectedId)}, "valuationentry.seq desc", 1); | ||||
|                 if (!EmptyUtil.isEmpty(finsubCols)) { | ||||
|                     DynamicObject dynamicObject = (DynamicObject)finsubCols.get(0); | ||||
|                     FormShowParameter showParameter = new FormShowParameter(); | ||||
|                     showParameter.setFormId("cim_valuation_update"); | ||||
|                     showParameter.getOpenStyle().setShowType(ShowType.NonModal); | ||||
|                     showParameter.getCustomParams().put("currency", dynamicObject.getLong("currency")); | ||||
|                     showParameter.getCustomParams().put("redeemway", dynamicObject.getString("redeemway")); | ||||
|                     showParameter.getCustomParams().put("e_valuation", dynamicObject.getBigDecimal("e_valuation")); | ||||
|                     showParameter.getCustomParams().put("e_surpcopies", dynamicObject.getBigDecimal("e_surpcopies")); | ||||
|                     showParameter.getCustomParams().put("e_iopv", dynamicObject.getBigDecimal("e_iopv")); | ||||
|                     showParameter.getCustomParams().put("ids", selectedId); | ||||
|                     showParameter.setCloseCallBack(new CloseCallBack(this, "valuateupdate")); | ||||
|                     this.getView().showForm(showParameter); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -117,7 +117,6 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit { | |||
|                             realRevenue = copies.multiply(shrjz.subtract(iopv)); | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", realRevenue); | ||||
|                 } | ||||
|             } | ||||
|  | @ -203,7 +202,7 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit { | |||
|                 // 计算 (赎回份额/剩余日份额) | ||||
|                 BigDecimal ratio = copies.divide(remainderCopies, 10, RoundingMode.HALF_UP); | ||||
|                 // 累乘 | ||||
|                 product = product.multiply(ratio).setScale(10, RoundingMode.HALF_UP); | ||||
|                 product = product.multiply(BigDecimal.ONE.subtract(ratio)).setScale(10, RoundingMode.HALF_UP); | ||||
| 
 | ||||
|             } catch (Exception e) { | ||||
|                 // 记录错误并跳过当前条目 | ||||
|  |  | |||
|  | @ -1,13 +1,17 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.operate; | ||||
| 
 | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.entity.plugin.AbstractOperationServicePlugIn; | ||||
| import kd.bos.entity.plugin.args.BeforeOperationArgs; | ||||
| 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.sdk.plugin.Plugin; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 理财申购 | ||||
|  * cim_finsubscribe | ||||
|  | @ -24,6 +28,43 @@ public class ValuateUpdateOperation extends AbstractOperationServicePlugIn imple | |||
|             DynamicObject prinfo; | ||||
|             for (int i = 0; i < dos.length; i++) { | ||||
|                 prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName()); | ||||
|                 //重新排序 | ||||
|                 DynamicObjectCollection valuationentry = prinfo.getDynamicObjectCollection("valuationentry"); | ||||
|                 if (valuationentry!=null && valuationentry.size()>1){ | ||||
|                     // 1. 按估值日期和赎回日期排序 | ||||
|                     DynamicObjectCollection sortedEntries = new DynamicObjectCollection(); | ||||
|                     sortedEntries.addAll(valuationentry); | ||||
| 
 | ||||
|                     sortedEntries.sort((o1, o2) -> { | ||||
|                         // 优先按估值日期排序(从小到大) | ||||
|                         Date valDate1 = o1.getDate("e_valuationdate"); | ||||
|                         Date valDate2 = o2.getDate("e_valuationdate"); | ||||
|                         int compareValDate = valDate1.compareTo(valDate2); | ||||
|                         if (compareValDate != 0) { | ||||
|                             return compareValDate; | ||||
|                         } | ||||
| 
 | ||||
|                         // 估值日期相同时,按赎回日期排序 | ||||
|                         Date redDate1 = o1.getDate("shjh_shrq"); | ||||
|                         Date redDate2 = o2.getDate("shjh_shrq"); | ||||
|                         if (redDate1 == null && redDate2 == null) return 0; | ||||
|                         if (redDate1 == null) return -1;  // null视为较小值 | ||||
|                         if (redDate2 == null) return 1; | ||||
|                         return redDate1.compareTo(redDate2); | ||||
|                     }); | ||||
| 
 | ||||
|                     // 2. 重新赋值seq从0开始 | ||||
|                     int seq = 0; | ||||
|                     for (DynamicObject item : sortedEntries) { | ||||
|                         item.set("seq", seq++); | ||||
|                     } | ||||
| 
 | ||||
|                     // 3. 将排序后的结果重新设置回原集合 | ||||
|                     valuationentry.clear(); | ||||
|                     valuationentry.addAll(sortedEntries); | ||||
|                     prinfo.set("valuationentry",valuationentry); | ||||
|                     SaveServiceHelper.update(prinfo); | ||||
|                 } | ||||
|                 //1、点击【估值】时,若申购单下游存在暂存、已提交的赎回单,提醒报错:“下游存在待审批的赎回单据,请删除或审批后再进行估值”; | ||||
|                 //cim_redeem | ||||
|                 QFilter q1 = new QFilter("finbillno.id", QCP.equals, prinfo.getLong("id")); | ||||
|  |  | |||
|  | @ -2,6 +2,8 @@ package shjh.jhzj7.fi.fi.plugin.report; | |||
| 
 | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.entity.NumberFormatProvider; | ||||
| import kd.bos.entity.report.AbstractReportColumn; | ||||
| import kd.bos.entity.report.ReportColumn; | ||||
| import kd.bos.entity.report.ReportQueryParam; | ||||
| import kd.bos.logging.Log; | ||||
|  | @ -444,10 +446,10 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|         row.set(REPORT_FIELDS[5], buyCopies); | ||||
|         row.set(REPORT_FIELDS[11], monthIop); | ||||
|         row.set(REPORT_FIELDS[12], monthIopDate); | ||||
|         row.set(DYNAMICS_FIELDS[4], monthAmount); | ||||
|         row.set(DYNAMICS_FIELDS[5], monthAnnualizedRate); | ||||
|         row.set(DYNAMICS_FIELDS[6], yearAmount); | ||||
|         row.set(DYNAMICS_FIELDS[7], yearAnnualizedRate); | ||||
|         row.set(DYNAMICS_FIELDS[4], monthAmount.setScale(2, RoundingMode.HALF_UP)); | ||||
|         row.set(DYNAMICS_FIELDS[5], monthAnnualizedRate.setScale(2, RoundingMode.HALF_UP)); | ||||
|         row.set(DYNAMICS_FIELDS[6], yearAmount.setScale(2, RoundingMode.HALF_UP)); | ||||
|         row.set(DYNAMICS_FIELDS[7], yearAnnualizedRate.setScale(2, RoundingMode.HALF_UP)); | ||||
| 
 | ||||
|         return allRedProductAmount; | ||||
|     } | ||||
|  | @ -503,7 +505,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
| //                    sum = sum.add(amount).add(realrevenue); | ||||
| //                } | ||||
|                 if (amount != null) { | ||||
|                     sum = amount; | ||||
|                     sum = sum.add(amount); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | @ -758,7 +760,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|             projectRevenue = new BigDecimal(day).multiply(amount) | ||||
|                     .multiply(expectedRate.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP)) | ||||
|                     .divide(basisDay, 8, RoundingMode.HALF_UP); | ||||
|             row.set(DYNAMICS_FIELDS[0], projectRevenue); | ||||
|             row.set(DYNAMICS_FIELDS[0], projectRevenue.setScale(2, RoundingMode.HALF_UP)); | ||||
|         } | ||||
|         return projectRevenue; | ||||
|     } | ||||
|  | @ -795,7 +797,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu | |||
|             // 设置到表格行 | ||||
|             boolean isValidPeriod = !valueDate.after(accrualDate) && !accrualDate.after(expireDate); | ||||
|             if (isValidPeriod){ | ||||
|                 row.set(DYNAMICS_FIELDS[3], revenue); | ||||
|                 row.set(DYNAMICS_FIELDS[3], revenue.setScale(2, RoundingMode.HALF_UP)); | ||||
|             }else { | ||||
|                 row.set(DYNAMICS_FIELDS[3], BigDecimal.ZERO); | ||||
|                 return BigDecimal.ZERO; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue