parent
9a601e584b
commit
21743895d9
|
|
@ -0,0 +1,167 @@
|
||||||
|
package shkd.sys.sys.plugin.form;
|
||||||
|
|
||||||
|
import kd.bos.form.control.Button;
|
||||||
|
import kd.bos.form.control.events.BeforeItemClickEvent;
|
||||||
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||||
|
import kd.bos.form.events.BeforeClosedEvent;
|
||||||
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.EventObject;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @FileName GuaranteeConDateFormPlugin
|
||||||
|
* @Description
|
||||||
|
* @Author csx
|
||||||
|
* @date 2025-10-27
|
||||||
|
**/
|
||||||
|
public class GuaranteeConDateFormPlugin extends AbstractFormPlugin {
|
||||||
|
|
||||||
|
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeBindData(EventObject e) {
|
||||||
|
Object end = this.getView().getFormShowParameter().getCustomParam("end");
|
||||||
|
// Map<String, Object> paramMap = this.getView().getFormShowParameter().getCustomParam("paramMap");
|
||||||
|
// Object end = paramMap.get("end");
|
||||||
|
if (end!=null){
|
||||||
|
String enddateString = (String) end;//上次的结束日期
|
||||||
|
try {
|
||||||
|
Date enddate = sdf.parse(enddateString);
|
||||||
|
Date quarterEndDate = getQuarterEndDate(enddate);//获取季末最后一天
|
||||||
|
this.getModel().setValue("shkd_startdate", getNextDay(enddate));
|
||||||
|
this.getModel().setValue("shkd_enddate", quarterEndDate);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerListener(EventObject e) {
|
||||||
|
super.registerListener(e);
|
||||||
|
this.addClickListeners("btnok");
|
||||||
|
addItemClickListeners("btnok");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(EventObject evt) {
|
||||||
|
super.click(evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeItemClick(BeforeItemClickEvent evt) {
|
||||||
|
super.beforeItemClick(evt);
|
||||||
|
Button source = (Button) evt.getSource();
|
||||||
|
String key = source.getKey();
|
||||||
|
if (key.equals("btnok")) {
|
||||||
|
Date shkd_startdate = (Date) this.getModel().getValue("shkd_startdate");
|
||||||
|
Date shkd_enddate = (Date) this.getModel().getValue("shkd_enddate");
|
||||||
|
if (shkd_enddate.before(shkd_startdate)) {
|
||||||
|
this.getView().showTipNotification("结束日期不能在开始日期之前,请重新检查!");
|
||||||
|
evt.setCancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this.getView().close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
||||||
|
super.afterDoOperation(e);
|
||||||
|
String operateKey = e.getOperateKey();
|
||||||
|
if (operateKey.equals("do")) {
|
||||||
|
Date shkd_startdate = (Date) this.getModel().getValue("shkd_startdate");
|
||||||
|
Date shkd_enddate = (Date) this.getModel().getValue("shkd_enddate");
|
||||||
|
// 指定日期格式
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
// 转换成字符串
|
||||||
|
String startdate = sdf.format(shkd_startdate);
|
||||||
|
String enddate = sdf.format(shkd_enddate);
|
||||||
|
this.getPageCache().put("shkd_startdate", startdate);
|
||||||
|
this.getPageCache().put("shkd_enddate", enddate);
|
||||||
|
this.getPageCache().put("btnok", "true");
|
||||||
|
}
|
||||||
|
this.getView().close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeClosed(BeforeClosedEvent e) {
|
||||||
|
super.beforeClosed(e);
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
String btnok = this.getPageCache().get("btnok");
|
||||||
|
if ("true".equals(btnok)){
|
||||||
|
String shkd_startdate = this.getPageCache().get("shkd_startdate");
|
||||||
|
String shkd_enddate = this.getPageCache().get("shkd_enddate");
|
||||||
|
map.put("shkd_startdate",shkd_startdate);
|
||||||
|
map.put("shkd_enddate",shkd_enddate);
|
||||||
|
this.getView().returnDataToParent(map);
|
||||||
|
}else {
|
||||||
|
this.getView().returnDataToParent(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取季末最后一天方法
|
||||||
|
* */
|
||||||
|
public Date getQuarterEndDate(Date enddate) {
|
||||||
|
// 使用 Calendar 来处理日期
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(enddate); // 设置日期
|
||||||
|
|
||||||
|
// 获取月份 (0 - 11)
|
||||||
|
int month = calendar.get(Calendar.MONTH);
|
||||||
|
|
||||||
|
// 根据月份来确定季度的最后一天
|
||||||
|
switch (month) {
|
||||||
|
case Calendar.JANUARY: // 1月 -> 第一季度
|
||||||
|
case Calendar.FEBRUARY: // 2月 -> 第一季度
|
||||||
|
case Calendar.MARCH: // 3月 -> 第一季度
|
||||||
|
calendar.set(Calendar.MONTH, Calendar.MARCH); // 设置为 3 月
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 31); // 设置为 3 月 31 日
|
||||||
|
break;
|
||||||
|
case Calendar.APRIL: // 4月 -> 第二季度
|
||||||
|
case Calendar.MAY: // 5月 -> 第二季度
|
||||||
|
case Calendar.JUNE: // 6月 -> 第二季度
|
||||||
|
calendar.set(Calendar.MONTH, Calendar.JUNE); // 设置为 6 月
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 30); // 设置为 6 月 30 日
|
||||||
|
break;
|
||||||
|
case Calendar.JULY: // 7月 -> 第三季度
|
||||||
|
case Calendar.AUGUST: // 8月 -> 第三季度
|
||||||
|
case Calendar.SEPTEMBER:// 9月 -> 第三季度
|
||||||
|
calendar.set(Calendar.MONTH, Calendar.SEPTEMBER); // 设置为 9 月
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 30); // 设置为 9 月 30 日
|
||||||
|
break;
|
||||||
|
case Calendar.OCTOBER: // 10月 -> 第四季度
|
||||||
|
case Calendar.NOVEMBER:// 11月 -> 第四季度
|
||||||
|
case Calendar.DECEMBER:// 12月 -> 第四季度
|
||||||
|
calendar.set(Calendar.MONTH, Calendar.DECEMBER); // 设置为 12 月
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 31); // 设置为 12 月 31 日
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回计算出的季度末日期
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getNextDay(Date enddate) {
|
||||||
|
// 使用 Calendar 来处理日期
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(enddate); // 设置日期为 enddate
|
||||||
|
|
||||||
|
// 将日期加一天
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
|
// 返回加一天后的日期
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
package shkd.sys.sys.plugin.form;
|
||||||
|
|
||||||
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.form.CloseCallBack;
|
||||||
|
import kd.bos.form.FormShowParameter;
|
||||||
|
import kd.bos.form.ShowType;
|
||||||
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
|
import kd.bos.form.events.ClosedCallBackEvent;
|
||||||
|
import kd.bos.form.operate.AbstractOperate;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @FileName GuaranteeContractFeeDetailPlugin
|
||||||
|
* @Description 担保合同表单界面插件
|
||||||
|
* @Author csx
|
||||||
|
* @date 2025-10-23
|
||||||
|
**/
|
||||||
|
public class GuaranteeContractFeeDetailPlugin extends AbstractBillPlugIn {
|
||||||
|
|
||||||
|
// 指定日期格式
|
||||||
|
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerListener(EventObject e) {
|
||||||
|
super.registerListener(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||||
|
super.beforeDoOperation(args);
|
||||||
|
AbstractOperate operate = (AbstractOperate)args.getSource();
|
||||||
|
if("jt".equals(operate.getOperateKey())){
|
||||||
|
//计提
|
||||||
|
FormShowParameter ShowParameter = new FormShowParameter();
|
||||||
|
ShowParameter.setFormId("shkd_guaranteecondate");
|
||||||
|
ShowParameter.setCloseCallBack(new CloseCallBack(this, "jt"));
|
||||||
|
ShowParameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||||
|
DynamicObjectCollection shkd_jtentry = this.getModel().getEntryEntity("shkd_jtentry");
|
||||||
|
//获取最晚的日期
|
||||||
|
Date shkd_jtenddate = shkd_jtentry.stream()
|
||||||
|
// 提取每个条目的 shkd_jtenddate 字段并确保它不为 null
|
||||||
|
.map(entry -> (Date) entry.getDate("shkd_jtenddate"))
|
||||||
|
.filter(date -> date != null) // 过滤掉 null 日期
|
||||||
|
.max(Comparator.naturalOrder()) // 找到最大的日期
|
||||||
|
.orElse(null);// 如果没有有效日期,返回 null
|
||||||
|
ShowParameter.setCustomParam("end", shkd_jtenddate);
|
||||||
|
this.getView().showForm(ShowParameter);
|
||||||
|
} else if ("yt".equals(operate.getOperateKey())) {
|
||||||
|
FormShowParameter ShowParameter = new FormShowParameter();
|
||||||
|
ShowParameter.setFormId("shkd_guaranteecondate");
|
||||||
|
ShowParameter.setCloseCallBack(new CloseCallBack(this, "yt"));
|
||||||
|
ShowParameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||||
|
DynamicObjectCollection shkd_ytentry = this.getModel().getEntryEntity("shkd_ytentry");
|
||||||
|
//获取最晚的日期
|
||||||
|
Date shkd_ytenddate = shkd_ytentry.stream()
|
||||||
|
// 提取每个条目的 shkd_jtenddate 字段并确保它不为 null
|
||||||
|
.map(entry -> (Date) entry.getDate("shkd_jtenddate"))
|
||||||
|
.filter(date -> date != null) // 过滤掉 null 日期
|
||||||
|
.max(Comparator.naturalOrder()) // 找到最大的日期
|
||||||
|
.orElse(null);// 如果没有有效日期,返回 null
|
||||||
|
ShowParameter.setCustomParam("end", shkd_ytenddate);
|
||||||
|
this.getView().showForm(ShowParameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closedCallBack(ClosedCallBackEvent e){
|
||||||
|
String actionId = e.getActionId();
|
||||||
|
if ("jt".equals(actionId)){
|
||||||
|
Object returnData = e.getReturnData();
|
||||||
|
if (returnData == null) return;
|
||||||
|
System.out.println(returnData);
|
||||||
|
HashMap<String, Object> map=(HashMap<String, Object>)returnData;
|
||||||
|
DynamicObjectCollection guaranteedebt_entry = this.getModel().getEntryEntity("guaranteedebt_entry");//担保债务
|
||||||
|
List<DynamicObject> gstatus = guaranteedebt_entry.stream()
|
||||||
|
// 过滤出 gstatus 字段为 "A" 的条目
|
||||||
|
.filter(entry -> "A".equals(entry.getString("gstatus")))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
int index = this.getModel().createNewEntryRow("shkd_jtentry");
|
||||||
|
this.getModel().setValue("shkd_jtfeerate",this.getModel().getValue("generalfeerate"),index);//费率(%)
|
||||||
|
this.getModel().setValue("shkd_jtfeeamt", BigDecimal.valueOf(123),index);//费用金额
|
||||||
|
Date shkd_startdate;
|
||||||
|
Date shkd_enddate;
|
||||||
|
try {
|
||||||
|
shkd_startdate = sdf.parse((String) map.get("shkd_startdate"));
|
||||||
|
shkd_enddate = sdf.parse((String) map.get("shkd_enddate"));
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
this.getModel().setValue("shkd_jtstartdate",shkd_startdate,index);
|
||||||
|
this.getModel().setValue("shkd_jtenddate",shkd_enddate,index);
|
||||||
|
this.getModel().setValue("shkd_jtfeepaydate",getNextDay(shkd_enddate),index);
|
||||||
|
//计算金额
|
||||||
|
|
||||||
|
} else if ("yt".equals(actionId)) {
|
||||||
|
Object returnData = e.getReturnData();
|
||||||
|
if (returnData == null) return;
|
||||||
|
System.out.println(returnData);
|
||||||
|
HashMap<String, Object> map=(HashMap<String, Object>)returnData;
|
||||||
|
DynamicObjectCollection guaranteedebt_entry = this.getModel().getEntryEntity("guaranteedebt_entry");//担保债务
|
||||||
|
List<DynamicObject> gstatus = guaranteedebt_entry.stream()
|
||||||
|
// 过滤出 gstatus 字段为 "A" 的条目
|
||||||
|
.filter(entry -> "A".equals(entry.getString("gstatus")))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getNextDay(Date enddate) {
|
||||||
|
// 使用 Calendar 来处理日期
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(enddate); // 设置日期为 enddate
|
||||||
|
|
||||||
|
// 将日期加一天
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
|
// 返回加一天后的日期
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue