理财申购、赎回改动

This commit is contained in:
李贵强 2025-08-13 17:01:04 +08:00
parent c8b45040e4
commit 62b854f1a3
5 changed files with 208 additions and 24 deletions

View File

@ -11,6 +11,7 @@ import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.EventObject; import java.util.EventObject;
/** /**
@ -53,20 +54,24 @@ public class CimFinancialBillPlugin extends AbstractBillPlugIn implements Plugin
this.getView().showTipNotification("无可删除数据!"); this.getView().showTipNotification("无可删除数据!");
return; return;
} }
DynamicObject maxSeqItem = findMaxSeqItem(entryEntity); DynamicObject maxSeqItem = findMaxDateItem(entryEntity);
if (maxSeqItem!=null){ if (maxSeqItem!=null){
DynamicObject redeemBill = maxSeqItem.getDynamicObject("shjh_shdh"); DynamicObject redeemBill = maxSeqItem.getDynamicObject("shjh_shdh");
if (redeemBill!=null){ if (redeemBill!=null){
this.getView().showTipNotification("最新估值分录存在已审核赎回单!"); this.getView().showTipNotification("最新估值分录存在已审核赎回单!");
}else { }else {
entryEntity.remove(maxSeqItem); entryEntity.remove(maxSeqItem);
DynamicObject newMaxSeqItem = findMaxSeqItem(entryEntity); DynamicObject newMaxSeqItem = findMaxDateItem(entryEntity);
if (newMaxSeqItem!=null){ if (newMaxSeqItem!=null){
BigDecimal e_surpcopies = newMaxSeqItem.getBigDecimal("e_surpcopies"); BigDecimal e_surpcopies = newMaxSeqItem.getBigDecimal("e_surpcopies");
financialBill.set("surpluscopies",e_surpcopies); financialBill.set("surpluscopies",e_surpcopies);
SaveServiceHelper.update(financialBill); 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"); 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() { private void updateBillInfo() {
boolean dataChanged = this.getModel().getDataChanged(); boolean dataChanged = this.getModel().getDataChanged();
if (dataChanged){ if (dataChanged){
@ -91,30 +137,64 @@ public class CimFinancialBillPlugin extends AbstractBillPlugIn implements Plugin
} }
/** /**
* 从分录中查找行号最大的记录 * 从分录中查找日期最大的记录
* @param entryEntity 分录集合 * @param entryEntity 分录集合
* @return 行号最大的记录如果没有记录则返回null * @return 行号最大的记录如果没有记录则返回null
*/ */
private DynamicObject findMaxSeqItem(DynamicObjectCollection entryEntity) { private DynamicObject findMaxDateItem(DynamicObjectCollection entryEntity) {
if (entryEntity == null || entryEntity.isEmpty()) { if (entryEntity == null || entryEntity.isEmpty()) {
return null; return null;
} }
// 检查初始行情况
if (entryEntity.size() == 1) {
return null;
}
DynamicObject maxSeqItem = null; DynamicObject maxDateItem = null;
int maxSeq = -1; Date maxValDate = null;
Date maxRedDate = null;
for (DynamicObject item : entryEntity) { for (DynamicObject item : entryEntity) {
int currentSeq = item.getInt("seq"); //估值日期
if (currentSeq==0){ Date currentValDate = item.getDate("e_valuationdate");
this.getView().showMessage("初始行不可删除!"); //赎回日期
return null; 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;
} }
} }

View File

@ -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);
}
}
}
}
}

View File

@ -117,7 +117,6 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
realRevenue = copies.multiply(shrjz.subtract(iopv)); realRevenue = copies.multiply(shrjz.subtract(iopv));
} }
} }
TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", realRevenue); TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", realRevenue);
} }
} }
@ -203,7 +202,7 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
// 计算 (赎回份额/剩余日份额) // 计算 (赎回份额/剩余日份额)
BigDecimal ratio = copies.divide(remainderCopies, 10, RoundingMode.HALF_UP); 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) { } catch (Exception e) {
// 记录错误并跳过当前条目 // 记录错误并跳过当前条目

View File

@ -1,13 +1,17 @@
package shjh.jhzj7.fi.fi.plugin.operate; package shjh.jhzj7.fi.fi.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.BeforeOperationArgs; import kd.bos.entity.plugin.args.BeforeOperationArgs;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import java.util.Date;
/** /**
* 理财申购 * 理财申购
* cim_finsubscribe * cim_finsubscribe
@ -24,6 +28,43 @@ public class ValuateUpdateOperation extends AbstractOperationServicePlugIn imple
DynamicObject prinfo; DynamicObject prinfo;
for (int i = 0; i < dos.length; i++) { for (int i = 0; i < dos.length; i++) {
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName()); 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点击估值若申购单下游存在暂存已提交的赎回单提醒报错:下游存在待审批的赎回单据请删除或审批后再进行估值 //1点击估值若申购单下游存在暂存已提交的赎回单提醒报错:下游存在待审批的赎回单据请删除或审批后再进行估值
//cim_redeem //cim_redeem
QFilter q1 = new QFilter("finbillno.id", QCP.equals, prinfo.getLong("id")); QFilter q1 = new QFilter("finbillno.id", QCP.equals, prinfo.getLong("id"));

View File

@ -2,6 +2,8 @@ package shjh.jhzj7.fi.fi.plugin.report;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; 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.ReportColumn;
import kd.bos.entity.report.ReportQueryParam; import kd.bos.entity.report.ReportQueryParam;
import kd.bos.logging.Log; 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[5], buyCopies);
row.set(REPORT_FIELDS[11], monthIop); row.set(REPORT_FIELDS[11], monthIop);
row.set(REPORT_FIELDS[12], monthIopDate); row.set(REPORT_FIELDS[12], monthIopDate);
row.set(DYNAMICS_FIELDS[4], monthAmount); row.set(DYNAMICS_FIELDS[4], monthAmount.setScale(2, RoundingMode.HALF_UP));
row.set(DYNAMICS_FIELDS[5], monthAnnualizedRate); row.set(DYNAMICS_FIELDS[5], monthAnnualizedRate.setScale(2, RoundingMode.HALF_UP));
row.set(DYNAMICS_FIELDS[6], yearAmount); row.set(DYNAMICS_FIELDS[6], yearAmount.setScale(2, RoundingMode.HALF_UP));
row.set(DYNAMICS_FIELDS[7], yearAnnualizedRate); row.set(DYNAMICS_FIELDS[7], yearAnnualizedRate.setScale(2, RoundingMode.HALF_UP));
return allRedProductAmount; return allRedProductAmount;
} }
@ -503,7 +505,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
// sum = sum.add(amount).add(realrevenue); // sum = sum.add(amount).add(realrevenue);
// } // }
if (amount != null) { 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) projectRevenue = new BigDecimal(day).multiply(amount)
.multiply(expectedRate.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP)) .multiply(expectedRate.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP))
.divide(basisDay, 8, 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; return projectRevenue;
} }
@ -795,7 +797,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
// 设置到表格行 // 设置到表格行
boolean isValidPeriod = !valueDate.after(accrualDate) && !accrualDate.after(expireDate); boolean isValidPeriod = !valueDate.after(accrualDate) && !accrualDate.after(expireDate);
if (isValidPeriod){ if (isValidPeriod){
row.set(DYNAMICS_FIELDS[3], revenue); row.set(DYNAMICS_FIELDS[3], revenue.setScale(2, RoundingMode.HALF_UP));
}else { }else {
row.set(DYNAMICS_FIELDS[3], BigDecimal.ZERO); row.set(DYNAMICS_FIELDS[3], BigDecimal.ZERO);
return BigDecimal.ZERO; return BigDecimal.ZERO;