校验:排除时间段应在返利时间范围之内!

This commit is contained in:
pan-houxiang 2025-11-24 16:10:36 +08:00
parent b79b1b15a2
commit e3efcd14c4
1 changed files with 47 additions and 22 deletions

View File

@ -7,6 +7,7 @@ import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.FormShowParameter;
import kd.bos.form.events.AfterDoOperationEventArgs;
@ -110,6 +111,9 @@ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements BeforeF
String name = e.getProperty().getName();
DynamicObject dataEntity = this.getModel().getDataEntity();
String tqq9_rebatesub = dataEntity.getString("tqq9_rebatesub");
ChangeData[] changeSet = e.getChangeSet();
Object newValueObj = changeSet[0].getNewValue();
Object oldValueObj = changeSet[0].getOldValue();
if (StringUtils.equals("0", tqq9_rebatesub)) {
if (StringUtils.equals("tqq9_shanghailici", name)) {
StringBuilder companyBulider = new StringBuilder();
@ -331,31 +335,52 @@ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements BeforeF
}
getModel().setValue("name", newName.toString());
}
// 比较时间段
if (StringUtils.equals("tqq9_date", name) || StringUtils.equals("tqq9_exclusiondate", name)) {
Date tqq9_startdate = (Date) dataEntity.get("tqq9_startdate"); // 返利开始时间
Date tqq9_enddate = (Date) dataEntity.get("tqq9_enddate"); // 返利结束时间
Date tqq9_startexcludate = (Date) dataEntity.get("tqq9_startexcludate"); // 排除开始时间
Date tqq9_endexcludate = (Date) dataEntity.get("tqq9_endexcludate"); // 排除结束时间
// 首先判断返利时间范围是否填写
if (tqq9_startdate == null || tqq9_enddate == null) {
this.getView().showErrorNotification("返利时间范围未填写");
return;
}
// 判断排除时间范围是否填写
if (tqq9_startexcludate != null || tqq9_endexcludate != null) {
if (tqq9_startexcludate == null || tqq9_endexcludate == null) {
this.getView().showErrorNotification("排除时间范围需完整填写");
return;
}
// 判断返利时间范围是否大于等于排除时间范围
if (tqq9_startdate.compareTo(tqq9_startexcludate) > 0 || tqq9_enddate.compareTo(tqq9_endexcludate) < 0) {
this.getView().showErrorNotification("返利时间范围应大于等于排除时间范围");
return;
// 校验排除时间段的开始时间应大于返利时间范围的结束时间
if (StringUtils.equals("tqq9_startexcludate", name) ||
StringUtils.equals("tqq9_startdate", name)) {
Date tqq9_startdate = dataEntity.getDate("tqq9_startdate");
Date tqq9_startexcludate = dataEntity.getDate("tqq9_startexcludate");
// 修改返利开始时间的时候触发
if (tqq9_startexcludate != null) {
if (tqq9_startdate != null) {
if (tqq9_startdate.compareTo(tqq9_startexcludate) > 0) {
this.getView().showErrorNotification("排除时间段的开始时间应大于等于返利时间范围的结束时间!");
//清空排除时间
if ("tqq9_startdate".equals(name)) {
this.getModel().setValue("tqq9_startdate", oldValueObj);
} else {
this.getModel().setValue("tqq9_startexcludate", oldValueObj);
}
}
} else {
this.getView().showErrorNotification("请先填写返利时间范围的开始时间!");
this.getModel().setValue("tqq9_startexcludate", null);
}
}
}
//校验排除时间段的结束时间应小于等于返利时间范围的结束时间
if (StringUtils.equals("tqq9_endexcludate", name) ||
StringUtils.equals("tqq9_enddate", name)) {
Date tqq9_enddate = dataEntity.getDate("tqq9_enddate");
Date tqq9_endexcludate = dataEntity.getDate("tqq9_endexcludate");
// 修改返利开始时间的时候触发
if (tqq9_endexcludate != null) {
if (tqq9_enddate != null) {
if (tqq9_endexcludate.compareTo(tqq9_enddate) > 0) {
this.getView().showErrorNotification("排除时间段的结束时间应小于等于返利时间范围的结束时间!");
//清空排除时间
if ("tqq9_enddate".equals(name)) {
this.getModel().setValue("tqq9_enddate", oldValueObj);
} else {
this.getModel().setValue("tqq9_endexcludate", oldValueObj);
}
}
} else {
this.getView().showErrorNotification("请先填写返利时间范围的结束时间!");
this.getModel().setValue("tqq9_endexcludate", null);
}
}
}
}