parent
21743895d9
commit
f007464332
|
|
@ -1,17 +1,19 @@
|
||||||
package shkd.sys.sys.plugin.form;
|
package shkd.sys.sys.plugin.form;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.LocaleString;
|
||||||
import kd.bos.form.control.Button;
|
import kd.bos.form.control.Button;
|
||||||
import kd.bos.form.control.events.BeforeItemClickEvent;
|
import kd.bos.form.control.events.BeforeItemClickEvent;
|
||||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||||
import kd.bos.form.events.BeforeClosedEvent;
|
import kd.bos.form.events.BeforeClosedEvent;
|
||||||
|
import kd.bos.form.field.ComboEdit;
|
||||||
|
import kd.bos.form.field.ComboItem;
|
||||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.EventObject;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @FileName GuaranteeConDateFormPlugin
|
* @FileName GuaranteeConDateFormPlugin
|
||||||
|
|
@ -32,7 +34,7 @@ public class GuaranteeConDateFormPlugin extends AbstractFormPlugin {
|
||||||
String enddateString = (String) end;//上次的结束日期
|
String enddateString = (String) end;//上次的结束日期
|
||||||
try {
|
try {
|
||||||
Date enddate = sdf.parse(enddateString);
|
Date enddate = sdf.parse(enddateString);
|
||||||
Date quarterEndDate = getQuarterEndDate(enddate);//获取季末最后一天
|
Date quarterEndDate = getQuarterEndDate(getNextDay(enddate));//获取季末最后一天
|
||||||
this.getModel().setValue("shkd_startdate", getNextDay(enddate));
|
this.getModel().setValue("shkd_startdate", getNextDay(enddate));
|
||||||
this.getModel().setValue("shkd_enddate", quarterEndDate);
|
this.getModel().setValue("shkd_enddate", quarterEndDate);
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
|
|
@ -78,6 +80,7 @@ public class GuaranteeConDateFormPlugin extends AbstractFormPlugin {
|
||||||
if (operateKey.equals("do")) {
|
if (operateKey.equals("do")) {
|
||||||
Date shkd_startdate = (Date) this.getModel().getValue("shkd_startdate");
|
Date shkd_startdate = (Date) this.getModel().getValue("shkd_startdate");
|
||||||
Date shkd_enddate = (Date) this.getModel().getValue("shkd_enddate");
|
Date shkd_enddate = (Date) this.getModel().getValue("shkd_enddate");
|
||||||
|
BigDecimal shkd_generalfeerate = (BigDecimal) this.getModel().getValue("shkd_generalfeerate");
|
||||||
// 指定日期格式
|
// 指定日期格式
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
// 转换成字符串
|
// 转换成字符串
|
||||||
|
|
@ -85,6 +88,7 @@ public class GuaranteeConDateFormPlugin extends AbstractFormPlugin {
|
||||||
String enddate = sdf.format(shkd_enddate);
|
String enddate = sdf.format(shkd_enddate);
|
||||||
this.getPageCache().put("shkd_startdate", startdate);
|
this.getPageCache().put("shkd_startdate", startdate);
|
||||||
this.getPageCache().put("shkd_enddate", enddate);
|
this.getPageCache().put("shkd_enddate", enddate);
|
||||||
|
this.getPageCache().put("shkd_jtfeerate", shkd_generalfeerate.toString());
|
||||||
this.getPageCache().put("btnok", "true");
|
this.getPageCache().put("btnok", "true");
|
||||||
}
|
}
|
||||||
this.getView().close();
|
this.getView().close();
|
||||||
|
|
@ -98,8 +102,10 @@ public class GuaranteeConDateFormPlugin extends AbstractFormPlugin {
|
||||||
if ("true".equals(btnok)){
|
if ("true".equals(btnok)){
|
||||||
String shkd_startdate = this.getPageCache().get("shkd_startdate");
|
String shkd_startdate = this.getPageCache().get("shkd_startdate");
|
||||||
String shkd_enddate = this.getPageCache().get("shkd_enddate");
|
String shkd_enddate = this.getPageCache().get("shkd_enddate");
|
||||||
|
String shkd_jtfeerate = this.getPageCache().get("shkd_jtfeerate");
|
||||||
map.put("shkd_startdate",shkd_startdate);
|
map.put("shkd_startdate",shkd_startdate);
|
||||||
map.put("shkd_enddate",shkd_enddate);
|
map.put("shkd_enddate",shkd_enddate);
|
||||||
|
map.put("shkd_jtfeerate",shkd_jtfeerate);
|
||||||
this.getView().returnDataToParent(map);
|
this.getView().returnDataToParent(map);
|
||||||
}else {
|
}else {
|
||||||
this.getView().returnDataToParent(null);
|
this.getView().returnDataToParent(null);
|
||||||
|
|
@ -109,8 +115,8 @@ public class GuaranteeConDateFormPlugin extends AbstractFormPlugin {
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 获取季末最后一天方法
|
* 获取季末最后一天方法
|
||||||
* */
|
* */
|
||||||
public Date getQuarterEndDate(Date enddate) {
|
public Date getQuarterEndDate(Date enddate) {
|
||||||
// 使用 Calendar 来处理日期
|
// 使用 Calendar 来处理日期
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,18 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.form.CloseCallBack;
|
import kd.bos.form.CloseCallBack;
|
||||||
import kd.bos.form.FormShowParameter;
|
import kd.bos.form.FormShowParameter;
|
||||||
import kd.bos.form.ShowType;
|
import kd.bos.form.ShowType;
|
||||||
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
import kd.bos.form.events.ClosedCallBackEvent;
|
import kd.bos.form.events.ClosedCallBackEvent;
|
||||||
import kd.bos.form.operate.AbstractOperate;
|
import kd.bos.form.operate.AbstractOperate;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -24,6 +28,8 @@ import java.util.stream.Collectors;
|
||||||
**/
|
**/
|
||||||
public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
||||||
|
|
||||||
|
public static final List<String> entryop = Arrays.asList("newentryjt", "deleteentryjt","newentryyt","deleteentryyt");
|
||||||
|
|
||||||
// 指定日期格式
|
// 指定日期格式
|
||||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
|
@ -70,11 +76,19 @@ public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
||||||
|
super.afterDoOperation(e);
|
||||||
|
String operateKey = e.getOperateKey();
|
||||||
|
if (Arrays.asList("deleteentryjt","deleteentryyt").contains(operateKey)){
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{this.getModel().getDataEntity(true)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closedCallBack(ClosedCallBackEvent e){
|
public void closedCallBack(ClosedCallBackEvent e){
|
||||||
String actionId = e.getActionId();
|
String actionId = e.getActionId();
|
||||||
if ("jt".equals(actionId)){
|
if ("jt".equals(actionId)){//计提
|
||||||
Object returnData = e.getReturnData();
|
Object returnData = e.getReturnData();
|
||||||
if (returnData == null) return;
|
if (returnData == null) return;
|
||||||
System.out.println(returnData);
|
System.out.println(returnData);
|
||||||
|
|
@ -86,7 +100,7 @@ public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
int index = this.getModel().createNewEntryRow("shkd_jtentry");
|
int index = this.getModel().createNewEntryRow("shkd_jtentry");
|
||||||
this.getModel().setValue("shkd_jtfeerate",this.getModel().getValue("generalfeerate"),index);//费率(%)
|
this.getModel().setValue("shkd_jtfeerate",this.getModel().getValue("generalfeerate"),index);//费率(%)
|
||||||
this.getModel().setValue("shkd_jtfeeamt", BigDecimal.valueOf(123),index);//费用金额
|
// this.getModel().setValue("shkd_jtfeeamt", BigDecimal.valueOf(123),index);//费用金额
|
||||||
Date shkd_startdate;
|
Date shkd_startdate;
|
||||||
Date shkd_enddate;
|
Date shkd_enddate;
|
||||||
try {
|
try {
|
||||||
|
|
@ -98,9 +112,14 @@ public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
||||||
this.getModel().setValue("shkd_jtstartdate",shkd_startdate,index);
|
this.getModel().setValue("shkd_jtstartdate",shkd_startdate,index);
|
||||||
this.getModel().setValue("shkd_jtenddate",shkd_enddate,index);
|
this.getModel().setValue("shkd_jtenddate",shkd_enddate,index);
|
||||||
this.getModel().setValue("shkd_jtfeepaydate",getNextDay(shkd_enddate),index);
|
this.getModel().setValue("shkd_jtfeepaydate",getNextDay(shkd_enddate),index);
|
||||||
|
String shkd_jtfeerate = (String) map.get("shkd_jtfeerate");
|
||||||
|
BigDecimal fl = BigDecimal.valueOf(Double.parseDouble(shkd_jtfeerate));
|
||||||
|
this.getModel().setValue("shkd_jtfeerate",fl,index);//费率
|
||||||
//计算金额
|
//计算金额
|
||||||
|
BigDecimal getbalance = getbalance(shkd_startdate, shkd_enddate, gstatus,fl);
|
||||||
} else if ("yt".equals(actionId)) {
|
this.getModel().setValue("shkd_jtcsfy",getbalance,index);
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{this.getModel().getDataEntity(true)});
|
||||||
|
} else if ("yt".equals(actionId)) {//预提
|
||||||
Object returnData = e.getReturnData();
|
Object returnData = e.getReturnData();
|
||||||
if (returnData == null) return;
|
if (returnData == null) return;
|
||||||
System.out.println(returnData);
|
System.out.println(returnData);
|
||||||
|
|
@ -114,6 +133,44 @@ public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BigDecimal getbalance(Date shkd_startdate, Date shkd_enddate, List<DynamicObject> gstatus, BigDecimal fl) {
|
||||||
|
BigDecimal zero = BigDecimal.ZERO;
|
||||||
|
for (DynamicObject dynamicObject : gstatus) {
|
||||||
|
Date gdebtstartdate = dynamicObject.getDate("gdebtstartdate");//债务开始日期
|
||||||
|
Date gdebtenddate = dynamicObject.getDate("gdebtenddate");//债务结束日期
|
||||||
|
// 获取最大开始日期和最小结束日期
|
||||||
|
Date overlapStartDate = (gdebtstartdate.after(shkd_startdate)) ? gdebtstartdate : shkd_startdate;
|
||||||
|
Date overlapEndDate = (gdebtenddate.before(shkd_enddate)) ? gdebtenddate : shkd_enddate;
|
||||||
|
long convert;
|
||||||
|
// 判断是否有重叠
|
||||||
|
if (overlapStartDate.before(overlapEndDate)) {
|
||||||
|
// 计算重叠的天数
|
||||||
|
long diffInMillis = overlapEndDate.getTime() - overlapStartDate.getTime();
|
||||||
|
convert = TimeUnit.DAYS.convert(diffInMillis, TimeUnit.MILLISECONDS);
|
||||||
|
}else {
|
||||||
|
convert=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算金额 责任金额(计息本金)*费率(利率)/360*计息天数
|
||||||
|
BigDecimal flBigDecimal=fl.divide(BigDecimal.valueOf(100),6,RoundingMode.HALF_UP);
|
||||||
|
if (convert==0){
|
||||||
|
continue;
|
||||||
|
}else {
|
||||||
|
BigDecimal gdebtbalance = dynamicObject.getBigDecimal("gdebtbalance");
|
||||||
|
BigDecimal divide = (gdebtbalance.multiply(flBigDecimal)).
|
||||||
|
divide(BigDecimal.valueOf(360), 6, RoundingMode.HALF_UP).
|
||||||
|
multiply(BigDecimal.valueOf(convert));
|
||||||
|
zero=zero.add(divide);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zero;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取第二天
|
||||||
|
* */
|
||||||
public Date getNextDay(Date enddate) {
|
public Date getNextDay(Date enddate) {
|
||||||
// 使用 Calendar 来处理日期
|
// 使用 Calendar 来处理日期
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
@ -125,4 +182,12 @@ public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
||||||
// 返回加一天后的日期
|
// 返回加一天后的日期
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取两个日期相差天数
|
||||||
|
* */
|
||||||
|
public static long calculateDebtDuration(Date gdebtstartdate, Date gdebtenddate) {
|
||||||
|
long diffInMillis = gdebtenddate.getTime() - gdebtstartdate.getTime();
|
||||||
|
return TimeUnit.DAYS.convert(diffInMillis, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue