This commit is contained in:
李贵强 2025-08-08 16:28:06 +08:00
parent 21bf67c0ff
commit dd9d816ef8
6 changed files with 205 additions and 49 deletions

View File

@ -1,9 +1,13 @@
package shjh.jhzj7.fi.fi.plugin.form; package shjh.jhzj7.fi.fi.plugin.form;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.resource.ResManager; import kd.bos.dataentity.resource.ResManager;
import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.tmc.cim.common.enums.CimEntityEnum; import kd.tmc.cim.common.enums.CimEntityEnum;
import kd.tmc.cim.common.enums.RedeemWayEnum; import kd.tmc.cim.common.enums.RedeemWayEnum;
import kd.tmc.cim.common.helper.RevenueCalcHelper; import kd.tmc.cim.common.helper.RevenueCalcHelper;
@ -15,15 +19,17 @@ import kd.tmc.fbp.common.util.DateUtils;
import kd.tmc.fbp.common.util.EmptyUtil; import kd.tmc.fbp.common.util.EmptyUtil;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date; import java.util.Date;
public class RedeemBillExtendEditPlugin extends RedeemBillEdit { public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
private final static Log logger = LogFactory.getLog(RedeemBillExtendEditPlugin.class);
@Override @Override
public void propertyChanged(PropertyChangedArgs args) { public void propertyChanged(PropertyChangedArgs args) {
// 如果不是 "copies" 属性才调用父类逻辑 // 如果不是 "copies" 属性才调用父类逻辑
if (!"copies".equals(args.getProperty().getName())) { if (!"copies".equals(args.getProperty().getName()) && !"redeemdate".equals(args.getProperty().getName())) {
super.propertyChanged(args); super.propertyChanged(args);
} }
@ -32,6 +38,8 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
this.checkCopies(); this.checkCopies();
this.calAmount(); this.calAmount();
this.calRealRevenue(); this.calRealRevenue();
}else if ("redeemdate".equals(args.getProperty().getName())){
this.calRealRevenue();
} }
} }
@ -70,7 +78,7 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
DynamicObject finBillNoF7 = (DynamicObject)this.getModel().getValue("finbillno"); DynamicObject finBillNoF7 = (DynamicObject)this.getModel().getValue("finbillno");
if (!EmptyUtil.isEmpty(finBillNoF7)) { if (!EmptyUtil.isEmpty(finBillNoF7)) {
Long finBillId = (Long)finBillNoF7.getPkValue(); Long finBillId = (Long)finBillNoF7.getPkValue();
DynamicObject finBill = TmcDataServiceHelper.loadSingle(CimEntityEnum.cim_finsubscribe.getValue(), "endinstdate,iopv", new QFilter[]{new QFilter("id", "=", finBillId)}); DynamicObject finBill = TmcDataServiceHelper.loadSingle(CimEntityEnum.cim_finsubscribe.getValue(), new QFilter[]{new QFilter("id", "=", finBillId)});
if (RedeemWayEnum.amount_redeem.getValue().equals(redeemWay)) { if (RedeemWayEnum.amount_redeem.getValue().equals(redeemWay)) {
boolean isRevenue = (Boolean)this.getModel().getValue("isrevenue"); boolean isRevenue = (Boolean)this.getModel().getValue("isrevenue");
if (isRevenue) { if (isRevenue) {
@ -82,18 +90,36 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
} }
} }
} else { } else {
BigDecimal redeemAmount = (BigDecimal)this.getModel().getValue("amount"); BigDecimal redeemAmount = (BigDecimal) this.getModel().getValue("amount");
BigDecimal copies = (BigDecimal)this.getModel().getValue("copies"); BigDecimal copies = (BigDecimal) this.getModel().getValue("copies");
BigDecimal iopv = finBill.getBigDecimal("iopv"); BigDecimal iopv = finBill.getBigDecimal("iopv");
BigDecimal realRevenue = redeemAmount.subtract(iopv.multiply(copies)); BigDecimal shrsyfe = (BigDecimal) this.getView().getModel().getValue("shjh_shrsyfe");//赎回日剩余份数
String value = (String) this.getModel().getValue("shjh_xjglcp"); DynamicObjectCollection collection = finBill.getDynamicObjectCollection("valuationentry");
//非现金管理类计提日期前所有赎回单上的实际收益 BigDecimal realRevenue = BigDecimal.ZERO;
//赎回单实际收益赎回份数*赎回日净值-购买时净值 if (collection != null && collection.size() != 0) {
if ("0".equals(value)) { //判断现金管理类
BigDecimal shrjz = (BigDecimal) this.getModel().getValue("shjh_shrjz"); String value = (String) this.getModel().getValue("shjh_xjglcp");
realRevenue=copies.multiply(shrjz.subtract(iopv)); //现金管理类计提日期前所有赎回单的现金管理类收益
//赎回单理财实际收益赎回金额一购买金额*赎回比之积
if ("1".equals(value)) {
Date redeemDate = (Date) this.getModel().getValue("redeemdate");
if (redeemDate != null) {
//自身比
//BigDecimal selfRat = copies.divide(shrsyfe, 10, RoundingMode.HALF_UP);
BigDecimal amount = finBill.getBigDecimal("amount");
//赎回比之积
BigDecimal redProductAmount = this.getRedProductAmount(collection, redeemDate);
realRevenue = redeemAmount.subtract(copies.divide(shrsyfe,8, RoundingMode.HALF_UP).multiply(redProductAmount).multiply(amount));
}else {
//非现金管理类计提日期前所有赎回单上的实际收益
//赎回单实际收益赎回份数*赎回日净值-购买时净值
BigDecimal shrjz = (BigDecimal) this.getModel().getValue("shjh_shrjz");
realRevenue = copies.multiply(shrjz.subtract(iopv));
}
}
TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", realRevenue);
} }
TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", realRevenue);
} }
} }
@ -115,4 +141,75 @@ public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
return intBill; return intBill;
} }
/**
* 计提日最近估值记录获取赎回份额/赎回日剩余份额* 所有赎回单
*
* @param entry 输入数据集合
* @param date 目标日期
* @return 所有符合条件的赎回单的(赎回份额 / 剩余份额)的乘积
*/
private BigDecimal getRedProductAmount(DynamicObjectCollection entry, Date date) {
// 1. 按估值日期和赎回日期排序
DynamicObjectCollection sortedEntries = new DynamicObjectCollection();
sortedEntries.addAll(entry);
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. 累乘符合条件的差额初始值设为1
BigDecimal product = BigDecimal.ONE;
for (DynamicObject item : sortedEntries) {
try {
// 检查是否为赎回单跳过非赎回条目
DynamicObject shdh = item.getDynamicObject("shjh_shdh");
if (shdh == null) {
continue;
}
// 检查估值日期是否 目标日期
Date valDate = item.getDate("e_valuationdate");
if (valDate == null || valDate.compareTo(date) > 0) {
continue;
}
Object pkValue = shdh.getPkValue();
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(pkValue, "cim_redeem");
// 安全获取数值字段
BigDecimal copies = dynamicObject.getBigDecimal("copies"); // 赎回份额
BigDecimal remainderCopies = dynamicObject.getBigDecimal("shjh_shrsyfe"); // 赎回日剩余份额
if (copies == null || remainderCopies == null || remainderCopies.compareTo(BigDecimal.ZERO) == 0) {
continue; // 跳过无效数据
}
// 计算 (赎回份额/剩余日份额)
BigDecimal ratio = copies.divide(remainderCopies, 10, RoundingMode.HALF_UP);
// 累乘
product = product.multiply(ratio).setScale(10, RoundingMode.HALF_UP);
} catch (Exception e) {
// 记录错误并跳过当前条目
logger.error("处理赎回单数据出错: " + e.getMessage(), e);
}
}
return product;
}
} }

View File

@ -9,6 +9,7 @@ import kd.bos.logging.LogFactory;
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.tmc.fbp.common.helper.TmcViewInputHelper;
import shjh.jhzj7.fi.fi.plugin.report.FinancialFormReport; import shjh.jhzj7.fi.fi.plugin.report.FinancialFormReport;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -68,9 +69,11 @@ public class RedeemFormPlugin extends AbstractFormPlugin {
this.getView().updateView("shjh_shrjz"); this.getView().updateView("shjh_shrjz");
this.getView().getModel().setValue("shjh_shrsyfe", shrsyfe); this.getView().getModel().setValue("shjh_shrsyfe", shrsyfe);
this.getView().updateView("shjh_shrsyfe"); this.getView().updateView("shjh_shrsyfe");
this.getView().getModel().setValue("iopv", shrjz);
this.getView().updateView("iopv");
} }
} }
updateRevenue(cimFinsubscribe); //updateRevenue(cimFinsubscribe);
} }
} }
} }
@ -83,16 +86,17 @@ public class RedeemFormPlugin extends AbstractFormPlugin {
this.getView().showErrorNotification("【赎回日剩余份数】—【赎回份数】大于等于0"); this.getView().showErrorNotification("【赎回日剩余份数】—【赎回份数】大于等于0");
this.getView().getModel().setValue("copies", BigDecimal.ZERO); this.getView().getModel().setValue("copies", BigDecimal.ZERO);
this.getView().updateView("copies"); this.getView().updateView("copies");
} else {
//获取申购单
DynamicObject finSubscribeF7 = (DynamicObject) this.getModel().getValue("finbillno");
if (finSubscribeF7 != null) {
DynamicObject finSubscribe = BusinessDataServiceHelper.loadSingle(finSubscribeF7.getPkValue(), "cim_finsubscribe");
if (finSubscribe != null) {
updateRevenue(finSubscribe);
}
}
} }
// else {
// //获取申购单
// DynamicObject finSubscribeF7 = (DynamicObject) this.getModel().getValue("finbillno");
// if (finSubscribeF7 != null) {
// DynamicObject finSubscribe = BusinessDataServiceHelper.loadSingle(finSubscribeF7.getPkValue(), "cim_finsubscribe");
// if (finSubscribe != null) {
// updateRevenue(finSubscribe);
// }
// }
// }
} }
} }
@ -118,7 +122,10 @@ public class RedeemFormPlugin extends AbstractFormPlugin {
private void updateRevenue(DynamicObject finSubscribe) { private void updateRevenue(DynamicObject finSubscribe) {
BigDecimal copies = (BigDecimal) this.getView().getModel().getValue("copies");//赎回份数 BigDecimal copies = (BigDecimal) this.getView().getModel().getValue("copies");//赎回份数
BigDecimal shrsyfe = (BigDecimal) this.getView().getModel().getValue("copies");//赎回日剩余份数 if (copies.compareTo(BigDecimal.ZERO)==0){
return;
}
BigDecimal shrsyfe = (BigDecimal) this.getView().getModel().getValue("shjh_shrsyfe");//赎回日剩余份数
DynamicObjectCollection collection = finSubscribe.getDynamicObjectCollection("valuationentry"); DynamicObjectCollection collection = finSubscribe.getDynamicObjectCollection("valuationentry");
if (collection != null && collection.size() != 0) { if (collection != null && collection.size() != 0) {
@ -134,8 +141,8 @@ public class RedeemFormPlugin extends AbstractFormPlugin {
//赎回比之积 //赎回比之积
BigDecimal redProductAmount = this.getRedProductAmount(collection, redeemDate); BigDecimal redProductAmount = this.getRedProductAmount(collection, redeemDate);
BigDecimal amount = (BigDecimal) this.getModel().getValue("amount"); BigDecimal amount = (BigDecimal) this.getModel().getValue("amount");
this.getModel().setValue("shjh_realrevenue2", amount.subtract(finSubscribe.getBigDecimal("amount").multiply(redProductAmount).multiply(selfRat))); BigDecimal realRevenue = amount.subtract(copies.divide(shrsyfe,8, RoundingMode.HALF_UP).multiply(redProductAmount).multiply(selfRat));
this.getView().updateView("shjh_realrevenue2"); TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", realRevenue);
} }
} }
} }

View File

@ -634,6 +634,7 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme
} else { } else {
//3.规则生单未配置客户>取收款入账中心客户 //3.规则生单未配置客户>取收款入账中心客户
QFilter customerFilter = new QFilter("name", QCP.equals, oppunit); QFilter customerFilter = new QFilter("name", QCP.equals, oppunit);
customerFilter.and(new QFilter("group.name",QCP.not_equals,"员工"));
//可用状态 //可用状态
customerFilter.and(new QFilter("enable", QCP.equals, "1")); customerFilter.and(new QFilter("enable", QCP.equals, "1"));
DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name", customerFilter.toArray()); DynamicObject[] bd_customer = BusinessDataServiceHelper.load("bd_customer", "id,name", customerFilter.toArray());

View File

@ -498,9 +498,12 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu
Object pkValue = shdh.getPkValue(); Object pkValue = shdh.getPkValue();
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(pkValue, "cim_redeem"); DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(pkValue, "cim_redeem");
BigDecimal amount = dynamicObject.getBigDecimal("amount"); // 赎回金额字段名 BigDecimal amount = dynamicObject.getBigDecimal("amount"); // 赎回金额字段名
BigDecimal realrevenue = dynamicObject.getBigDecimal("realrevenue"); // 实际收益字段名 //BigDecimal realrevenue = dynamicObject.getBigDecimal("realrevenue"); // 实际收益字段名
// if (amount != null) {
// sum = sum.add(amount).add(realrevenue);
// }
if (amount != null) { if (amount != null) {
sum = sum.add(amount).add(realrevenue); sum = amount;
} }
} }
} }

View File

@ -8,18 +8,28 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask; import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.util.StringUtils; import kd.bos.util.StringUtils;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* 定时从付款单携带SAP付凭证单号至被动付款入账中心主要处理sap主动付款场景 * 定时从付款单携带SAP付凭证单号至被动付款入账中心主要处理sap主动付款场景
*/ */
public class BeiIntelpayBillTask extends AbstractTask implements Plugin { public class BeiIntelpayBillTask extends AbstractTask implements Plugin {
//付款处理
private static final String KEY_PAY="cas_paybill";
//下拨处理
private static final String KEY_TRANS="fca_transdownbill";
//收款处理
private static final String KEY_REC="cas_recbill";
@Override @Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException { public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
@ -32,26 +42,64 @@ public class BeiIntelpayBillTask extends AbstractTask implements Plugin {
DynamicObject[] beiIntelpays = BusinessDataServiceHelper.load("bei_intelpay", "id," + DynamicObject[] beiIntelpays = BusinessDataServiceHelper.load("bei_intelpay", "id," +
"billno,shjh_credentialnums,recedbillentry,recedbillentry.e_recedbillnumber", new QFilter[]{q1, q2}); "billno,shjh_credentialnums,recedbillentry,recedbillentry.e_recedbillnumber", new QFilter[]{q1, q2});
for (DynamicObject beiIntelpay : beiIntelpays) { for (DynamicObject beiIntelpay : beiIntelpays) {
//接收单据信息:recedbillentry //下查
DynamicObjectCollection recedbillentry = beiIntelpay.getDynamicObjectCollection("recedbillentry"); Map<String, HashSet<Long>> intelPayMap = BFTrackerServiceHelper.findTargetBills("bei_intelpay", new Long[]{(Long) beiIntelpay.getPkValue()});
if (!recedbillentry.isEmpty()) { //付款单
DynamicObject object = recedbillentry.get(0); if (intelPayMap.containsKey(KEY_PAY)){
if (null != object) { Set<Long> billIds = intelPayMap.get(KEY_PAY);
String recedbillnumber = object.getString("e_recedbillnumber");//接收单据编号 for (Long billId : billIds) {
if (null != recedbillnumber && !recedbillnumber.isEmpty()) { DynamicObject payBill = BusinessDataServiceHelper.loadSingle(billId, KEY_PAY);
//获取付款单 if (null != payBill) {
QFilter q3 = new QFilter("billno", QCP.equals, recedbillnumber);//单据编号 if (StringUtils.isNotEmpty(payBill.getString("shjh_credentialnum"))) {
DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", beiIntelpay.set("shjh_credentialnums",payBill.getString("shjh_credentialnum"));//SAP付款凭证号
"id,shjh_credentialnum", new QFilter[]{q3}); SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
if (null != paybill) { }
if (StringUtils.isNotEmpty(paybill.getString("shjh_credentialnum"))) { }
beiIntelpay.set("shjh_credentialnums",paybill.getString("shjh_credentialnum"));//SAP付款凭证号 }
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay}); }else if (intelPayMap.containsKey(KEY_TRANS)){
} Set<Long> billIds = intelPayMap.get(KEY_TRANS);
for (Long billId : billIds) {
DynamicObject payBill = BusinessDataServiceHelper.loadSingle(billId, KEY_TRANS);
if (null != payBill) {
if (StringUtils.isNotEmpty(payBill.getString("shjh_sappzh"))) {
beiIntelpay.set("shjh_credentialnums",payBill.getString("shjh_sappzh"));//SAP付款凭证号
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
}
}
}
}else if (intelPayMap.containsKey(KEY_REC)){
Set<Long> billIds = intelPayMap.get(KEY_REC);
for (Long billId : billIds) {
DynamicObject payBill = BusinessDataServiceHelper.loadSingle(billId, KEY_REC);
if (null != payBill) {
if (StringUtils.isNotEmpty(payBill.getString("shjh_vouchernum"))) {
beiIntelpay.set("shjh_credentialnums",payBill.getString("shjh_vouchernum"));//SAP付款凭证号
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
} }
} }
} }
} }
//接收单据信息:recedbillentry
// DynamicObjectCollection recedbillentry = beiIntelpay.getDynamicObjectCollection("recedbillentry");
// if (!recedbillentry.isEmpty()) {
// DynamicObject object = recedbillentry.get(0);
// if (null != object) {
// String recedbillnumber = object.getString("e_recedbillnumber");//接收单据编号
// if (null != recedbillnumber && !recedbillnumber.isEmpty()) {
// //获取付款单
// QFilter q3 = new QFilter("billno", QCP.equals, recedbillnumber);//单据编号
// DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill",
// "id,shjh_credentialnum", new QFilter[]{q3});
// if (null != paybill) {
// if (StringUtils.isNotEmpty(paybill.getString("shjh_credentialnum"))) {
// beiIntelpay.set("shjh_credentialnums",paybill.getString("shjh_credentialnum"));//SAP付款凭证号
// SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
// }
// }
// }
// }
// }
} }
} }
} }

View File

@ -42,12 +42,12 @@ public class UnclaimedNoticeTask extends AbstractTask implements Plugin {
logger.info("昨天"+yesterdayStr); logger.info("昨天"+yesterdayStr);
QFilter qFilter = new QFilter("businesstype", QCP.equals, "rec");//业务类型-收款 QFilter qFilter = new QFilter("businesstype", QCP.equals, "rec");//业务类型-收款
qFilter.and("claimstatus", QCP.equals, "0");//认领通知单状态-待认领 qFilter.and("claimstatus", QCP.equals, "0");//认领通知单状态-待认领
try { // try {
qFilter.and("createtime", QCP.less_equals, new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(yesterdayStr+" 23:59:59"));//截至到昨天之前的 // qFilter.and("createtime", QCP.less_equals, new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(yesterdayStr+" 23:59:59"));//截至到昨天之前的
} catch (ParseException e) { // } catch (ParseException e) {
logger.info("日期格式化异常"+e.getMessage()); // logger.info("日期格式化异常"+e.getMessage());
throw new RuntimeException(e); // throw new RuntimeException(e);
} // }
DynamicObject[] colls = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray()); DynamicObject[] colls = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray());
DynamicObjectCollection usercolls; DynamicObjectCollection usercolls;
Map<String, List<DynamicObject>> userBills = new HashMap<>();//缓存用户和认领单的关系 Map<String, List<DynamicObject>> userBills = new HashMap<>();//缓存用户和认领单的关系