Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
282c8f64a1
|
@ -96,11 +96,10 @@ public class TradefinanceSelectPlugin extends AbstractTmcTreeReportDataPlugin {
|
|||
DataSet interestRateDS = TradeFinanceFilterHelper.interestRateDS(loanBillIds, this.cutoffdate, clazz);
|
||||
rows = rows.leftJoin(interestRateDS).on("loanbillid", "loanbillid").select(rows.getRowMeta().getFieldNames(), new String[]{"intrate"}).finish();
|
||||
rows = this.addFeeAmtDs(rows, loanBillIds);
|
||||
rows = this.addCalIntAmtDs(rows, loanBillIds);
|
||||
// DynamicObjectCollection rowData = ORM.create().toPlainDynamicObjectCollection(rows);
|
||||
return rows;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +142,8 @@ public class TradefinanceSelectPlugin extends AbstractTmcTreeReportDataPlugin {
|
|||
}
|
||||
|
||||
protected List<String> orinalAmountField() {
|
||||
return Arrays.asList("contractamt", "drawamount", "unpaidamt", "unpaidintamt", "paidamt", "estinterestamt", "paidintamt", "feeamt", "compamt" );
|
||||
return Arrays.asList("contractamt", "drawamount", "unpaidamt", "unpaidintamt", "paidamt", "estinterestamt", "paidintamt", "feeamt", "compamt" ,"shkd_contractamt","shkd_drawamount_statccy","shkd_remainingamount","shkd_paidamt");
|
||||
|
||||
}
|
||||
|
||||
protected String getReportField(String field) {
|
||||
|
@ -287,7 +287,7 @@ public class TradefinanceSelectPlugin extends AbstractTmcTreeReportDataPlugin {
|
|||
|
||||
//剩余提款金额:合同份额金额 - 剩余提款金额
|
||||
DataSet copy = main_balanceDataSet2.copy();
|
||||
DataSet main_balanceDataSet3 = copy.addField("shkd_contractamt - shkd_drawamount_statccy", "shkd_drawamount");
|
||||
DataSet main_balanceDataSet3 = copy.addField("shkd_contractamt - shkd_drawamount_statccy", "shkd_remainingamount");
|
||||
|
||||
//本年还款金额
|
||||
MainEntityType dataEntityType3 = MetadataServiceHelper.getDataEntityType("cfm_loancontractbill");
|
||||
|
@ -441,14 +441,22 @@ public class TradefinanceSelectPlugin extends AbstractTmcTreeReportDataPlugin {
|
|||
"unpaidamt_statccy",
|
||||
"estinterestamt_statccy",
|
||||
"paidintamt_statccy",
|
||||
"unpaidintamt_statccy"
|
||||
"unpaidintamt_statccy",
|
||||
"shkd_contractamt",
|
||||
"shkd_drawamount_statccy",
|
||||
"shkd_remainingamount",
|
||||
"shkd_paidamt"
|
||||
},
|
||||
new String[]{String.format("round(drawamount_statccy, %s)", amtPrecision),
|
||||
String.format("round(paidamt_statccy, %s)", amtPrecision),
|
||||
String.format("round(unpaidamt_statccy, %s)", amtPrecision),
|
||||
String.format("round(estinterestamt_statccy, %s)", amtPrecision),
|
||||
String.format("round(paidintamt_statccy, %s)", amtPrecision),
|
||||
String.format("round(unpaidintamt_statccy, %s)", amtPrecision)
|
||||
String.format("round(unpaidintamt_statccy, %s)", amtPrecision),
|
||||
String.format("round(shkd_contractamt, %s)", amtPrecision),
|
||||
String.format("round(shkd_drawamount_statccy, %s)", amtPrecision),
|
||||
String.format("round(shkd_remainingamount, %s)", amtPrecision),
|
||||
String.format("round(shkd_paidamt, %s)", amtPrecision)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -593,78 +601,12 @@ public class TradefinanceSelectPlugin extends AbstractTmcTreeReportDataPlugin {
|
|||
return loanBillDS.addField("estinterestamt + feeamt", "compamt");
|
||||
}
|
||||
|
||||
protected DataSet addCalIntAmtDs(DataSet loanBillDS, List<Long> loanBillIds) {
|
||||
List<Field> field = new ArrayList(2);
|
||||
field.add(new Field("loanbillid", DataType.LongType));
|
||||
field.add(new Field("calintamt", DataType.BigDecimalType));
|
||||
RowMeta rowMeta = new RowMeta((Field[])field.toArray(new Field[0]));
|
||||
DataSetBuilder datasetBuilder = Algo.create("calIntAmt").createDataSetBuilder(rowMeta);
|
||||
loanBillIds = (List)loanBillIds.stream().distinct().collect(Collectors.toList());
|
||||
List<List<Long>> loanBillIdLists = ListUtils.splitList(loanBillIds, 100L);
|
||||
StringBuilder noRateLoanBillSB = new StringBuilder();
|
||||
Iterator var8 = loanBillIdLists.iterator();
|
||||
|
||||
label43:
|
||||
while(var8.hasNext()) {
|
||||
List<Long> loanBillIdList = (List)var8.next();
|
||||
List<DynamicObject> loanBills = InterestCalcHelper.getLoanBills(loanBillIdList);
|
||||
Iterator var11 = loanBills.iterator();
|
||||
|
||||
while(true) {
|
||||
while(true) {
|
||||
if (!var11.hasNext()) {
|
||||
continue label43;
|
||||
}
|
||||
|
||||
DynamicObject loanBill = (DynamicObject)var11.next();
|
||||
long loanBillId = loanBill.getLong("id");
|
||||
if (RepaymentWayEnum.isHbfx(loanBill.getString("repaymentway"))) {
|
||||
loanBill.set("repaymentway", RepaymentWayEnum.bqhblsbq.getValue());
|
||||
}
|
||||
|
||||
DynamicObjectCollection rateadjust_entry = loanBill.getDynamicObjectCollection("rateadjust_entry");
|
||||
if (rateadjust_entry.size() > 0) {
|
||||
rateadjust_entry.sort(Comparator.comparing((r) -> {
|
||||
return r.getDate("ra_effectdate");
|
||||
}));
|
||||
Date startIntDate = loanBill.getDate("startintdate");
|
||||
if (startIntDate.compareTo(((DynamicObject)rateadjust_entry.get(0)).getDate("ra_effectdate")) < 0) {
|
||||
noRateLoanBillSB.append(loanBill.getString("billno")).append(",");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
IntBillExtInfo intBill;
|
||||
try {
|
||||
intBill = InterestCalcHelper.callInt(loanBill);
|
||||
} catch (TmcBizException var18) {
|
||||
TmcBizException e = var18;
|
||||
logger.error("计算利息失败: loanBillId={}, error: {}", loanBillId, e.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (EmptyUtil.isNoEmpty(intBill) && EmptyUtil.isNoEmpty(intBill.getDetails())) {
|
||||
Object[] row = new Object[]{loanBillId, intBill.getAmount()};
|
||||
datasetBuilder.append(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String LoanBills = noRateLoanBillSB.toString();
|
||||
logger.error("利息计算开始日必须要有可用利率: " + LoanBills);
|
||||
DataSet calIntAmtDs = datasetBuilder.build();
|
||||
loanBillDS = loanBillDS.leftJoin(calIntAmtDs).on("loanbillid", "loanbillid").select(loanBillDS.getRowMeta().getFieldNames(), new String[]{"calintamt"}).finish().updateField("calintamt", "case when calintamt is null then 0 else calintamt end");
|
||||
loanBillDS = loanBillDS.updateField("calintamt", "case when loantype in ('sl', 'bond') then calintamt*(drawamount/drawamount1) + feeamt else calintamt + feeamt end");
|
||||
return loanBillDS;
|
||||
}
|
||||
|
||||
public DataSet reDealResultDataSet(DataSet dataSet, ReportQueryParam queryParam) {
|
||||
if (dataSet != null && !dataSet.isEmpty()) {
|
||||
dataSet = dataSet.addField("case when unpaidamt=0 and cleardate is not null then cleardate else expiredate end", "comprateenddate");
|
||||
DataSet compDs = this.buildCompCalcDs(dataSet.copy());
|
||||
dataSet = dataSet.leftJoin(compDs).on("loanbillid", "compid").select(dataSet.getRowMeta().getFieldNames(), new String[]{"compyearday", "compdays"}).finish();
|
||||
dataSet = dataSet.addField("case when drawamount=0 or compdays=0 then 0 else calintamt * 100 * compyearday /(drawamount * compdays) end", "comprate_statccy");
|
||||
dataSet = dataSet.addField("case when drawamount_statccy=0 or compdays=0 then 0 else compamt_statccy * 100 * compyearday /(drawamount_statccy * compdays) end", "comprate_statccy");
|
||||
DataSet totalDs = dataSet.filter("sumlevel=2");
|
||||
dataSet = dataSet.filter("sumlevel!=2");
|
||||
dataSet = dataSet.orderBy((String[])this.orderByFields().toArray(new String[0]));
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package shkd.sys.sys.plugin.tmc;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.events.BeforePackageDataEvent;
|
||||
import kd.bos.form.events.BeforeCreateListDataProviderArgs;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.mvc.list.ListDataProvider;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.plugin.sample.bill.list.template.BeforeCreateListDataProvider;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 银行借款合同————给字段’提款金额‘赋值
|
||||
* 标准单据列表插件
|
||||
*/
|
||||
public class BankContractGetDataPlugin extends AbstractListPlugin implements Plugin {
|
||||
@Override
|
||||
public void beforePackageData(BeforePackageDataEvent e) {
|
||||
super.beforePackageData(e);
|
||||
DynamicObjectCollection pageData = e.getPageData();
|
||||
// 1. 收集所有合同号
|
||||
Set<String> billnoSet = new HashSet<>();
|
||||
for (DynamicObject demoObj : pageData) {
|
||||
billnoSet.add(demoObj.getString("billno"));
|
||||
}
|
||||
// 2. 一次性查出所有下游单据
|
||||
QFilter billnoFilter = new QFilter("loancontractbill.number", QCP.in, billnoSet.toArray());
|
||||
QFilter statusFilter = new QFilter("billstatus", QCP.equals, "C");
|
||||
DynamicObject[] sourceDyobjs = BusinessDataServiceHelper.load("cfm_loanbill",
|
||||
"id,loancontractbill.number,banksyndicate_entry,banksyndicate_entry.e_bank,banksyndicate_entry.e_shareamount",
|
||||
billnoFilter.and(statusFilter).toArray());
|
||||
// 3. 建立Map<合同号, List<下游单据>>
|
||||
Map<String, List<DynamicObject>> billnoToLoanbills = new HashMap<>();
|
||||
for (DynamicObject obj : sourceDyobjs) {
|
||||
String billno = obj.getDynamicObject("loancontractbill").getString("number");
|
||||
billnoToLoanbills.computeIfAbsent(billno, k -> new ArrayList<>()).add(obj);
|
||||
}
|
||||
// 4. 主循环
|
||||
for (DynamicObject demoObj : pageData) {
|
||||
DynamicObject bank = demoObj.getDynamicObject("banksyndicate_entry.e_bank");
|
||||
if (bank == null) continue;
|
||||
Long bankId = (Long)bank.getPkValue();
|
||||
String contraciBillno = demoObj.getString("billno");
|
||||
BigDecimal resultAmount = BigDecimal.ZERO;
|
||||
List<DynamicObject> loanbills = billnoToLoanbills.get(contraciBillno);
|
||||
if (loanbills != null) {
|
||||
for (DynamicObject loanbill : loanbills) {
|
||||
DynamicObjectCollection bankentrys = loanbill.getDynamicObjectCollection("banksyndicate_entry");
|
||||
for (DynamicObject bankentry : bankentrys) {
|
||||
if (bankId.equals(bankentry.getDynamicObject("e_bank").getLong("id"))) {
|
||||
resultAmount = resultAmount.add(bankentry.getBigDecimal("e_shareamount"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
demoObj.set("banksyndicate_entry.e_loanamount", resultAmount);
|
||||
}
|
||||
e.setPageData(pageData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
|
||||
super.beforeCreateListDataProvider(args);
|
||||
// ListDataProvider listDataProvider = new ListDataProvider(){
|
||||
// @Override
|
||||
// public DynamicObjectCollection getData(int start,int limit){
|
||||
// DynamicObjectCollection rows = super.getData(start, limit);
|
||||
// if(rows.isEmpty()){
|
||||
// return rows;
|
||||
// }
|
||||
// for (DynamicObject row : rows) {
|
||||
// row.set("e_loanamount","11111");
|
||||
// }
|
||||
// return rows;
|
||||
// }
|
||||
// };
|
||||
// args.setListDataProvider(listDataProvider);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import kd.bos.form.field.events.BeforeF7SelectListener;
|
|||
import kd.bos.list.ListShowParameter;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
|
||||
import kd.bos.servicehelper.org.OrgViewType;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
@ -68,9 +69,37 @@ public class BondSelectEntryOrgPlugin extends AbstractBillPlugIn implements Plug
|
|||
dataFilter.add(accountQFilter.and(accountQFilter2));
|
||||
}
|
||||
if("shkd_enryborrower".equals(name)){
|
||||
List<Long> allSubordinateOrgs = OrgUnitServiceHelper.getAllSubordinateOrgs(OrgViewType.BDControl, Collections.singletonList(orgId), true);
|
||||
QFilter accountQFilter = new QFilter("id", QCP.in, allSubordinateOrgs);
|
||||
dataFilter.add(accountQFilter);
|
||||
String number = org.getString("number");
|
||||
List<Long> allSubordinateOrgs = new ArrayList<>();
|
||||
//编码为SIG0010000的组织要找到SIG0000000的所有子集
|
||||
if("SIG0010000".equals(number)){
|
||||
QFilter qFilter = new QFilter("number", "=", "SIG0000000");
|
||||
DynamicObject bos_org = BusinessDataServiceHelper.loadSingle("bos_org","id",qFilter.toArray());
|
||||
allSubordinateOrgs = OrgUnitServiceHelper.getAllSubordinateOrgs(OrgViewType.BDControl, Collections.singletonList((Long)bos_org.getPkValue()), false);
|
||||
QFilter accountQFilter = new QFilter("id", QCP.in, allSubordinateOrgs);
|
||||
dataFilter.add(accountQFilter);
|
||||
}else{
|
||||
QFilter qFilter = new QFilter("number", "=", number+"-uatierp");
|
||||
DynamicObject bos_org = BusinessDataServiceHelper.loadSingle("bos_org","id",qFilter.toArray());
|
||||
if(bos_org == null){
|
||||
//未找到后缀为uatierp的合并层 正常拿下级
|
||||
allSubordinateOrgs = OrgUnitServiceHelper.getAllSubordinateOrgs(OrgViewType.BDControl, Collections.singletonList(orgId), true);
|
||||
QFilter accountQFilter = new QFilter("id", QCP.in, allSubordinateOrgs);
|
||||
dataFilter.add(accountQFilter);
|
||||
}else {
|
||||
//找到了后缀为uatierp的合并层 用其当上级找所有下级 然后过滤掉所有后缀为uatierp的值
|
||||
allSubordinateOrgs = OrgUnitServiceHelper.getAllSubordinateOrgs(OrgViewType.BDControl, Collections.singletonList((Long)bos_org.getPkValue()), false);
|
||||
List<Long> demoArr = new ArrayList<>();
|
||||
for (Long subId : allSubordinateOrgs) {
|
||||
QFilter qFilter1 = new QFilter("id", "=", subId);
|
||||
DynamicObject tempOrg = BusinessDataServiceHelper.loadSingle("bos_org","id,number",qFilter1.toArray());
|
||||
if(tempOrg.getString("number").contains("uatierp"))continue;
|
||||
demoArr.add((Long)tempOrg.getPkValue());
|
||||
}
|
||||
QFilter accountQFilter = new QFilter("id", QCP.in, demoArr);
|
||||
dataFilter.add(accountQFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
formShowParameter.getListFilterParameter().getQFilters().addAll(dataFilter);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue