|
@@ -13,9 +13,16 @@ import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
|
|
import kd.bos.entity.validate.AbstractValidator;
|
|
|
import kd.bos.logging.Log;
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
+import kd.fi.er.business.servicehelper.CommonServiceHelper;
|
|
|
+import kd.fi.er.business.trip.util.TripReqChangeUtil;
|
|
|
+import nckd.base.helper.CommonHelperUtils;
|
|
|
import nckd.jimin.jyyy.fi.common.FinanceCommonUtils;
|
|
|
|
|
|
/**
|
|
@@ -33,9 +40,18 @@ public class TripReqBillSubmitOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
List<String> fieldKeys = e.getFieldKeys();
|
|
|
|
|
|
// fieldKeys.add("tripentry");
|
|
|
+ fieldKeys.add("ischange");
|
|
|
fieldKeys.add("applier");
|
|
|
fieldKeys.add("tripentry.startdate");
|
|
|
fieldKeys.add("tripentry.enddate");
|
|
|
+
|
|
|
+ Iterator var3 = TripReqChangeUtil.getTriphistoryMappingresult().entrySet().iterator();
|
|
|
+
|
|
|
+ while(var3.hasNext()) {
|
|
|
+ Map.Entry<String, String> entry = (Map.Entry)var3.next();
|
|
|
+ fieldKeys.add(entry.getKey());
|
|
|
+ fieldKeys.add(entry.getValue());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -54,7 +70,9 @@ public class TripReqBillSubmitOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
|
|
|
DynamicObjectCollection tripentry = tripReqInfo.getDynamicObjectCollection("tripentry");
|
|
|
|
|
|
+ int index = 0;
|
|
|
for(DynamicObject entry : tripentry){
|
|
|
+ index++;
|
|
|
Date startDate = entry.getDate("startdate");
|
|
|
Date endDate = entry.getDate("enddate");
|
|
|
|
|
@@ -66,11 +84,41 @@ public class TripReqBillSubmitOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
Long billId = tripReqInfo.getLong("id");
|
|
|
Long userId = tripReqInfo.getDynamicObject("applier").getLong("id");
|
|
|
|
|
|
+ //校验是否有交叉重叠的时间
|
|
|
String checkMsg = FinanceCommonUtils.checkDateIsExists(billId, userId, startDate, endDate);
|
|
|
|
|
|
if(checkMsg.length() > 0) {
|
|
|
this.addErrorMessage(dataEntity, "存在开始时间、结束时间重叠的单据!" + checkMsg);
|
|
|
}
|
|
|
+
|
|
|
+ //如果是变更行程,需要与变更前的做校验
|
|
|
+ QFilter qFilter = new QFilter("id", QCP.equals, tripReqInfo.getLong("id"));
|
|
|
+ qFilter.and(new QFilter("tripchangehistoryentry.srcentryid", QCP.equals, entry.getLong("id")));
|
|
|
+
|
|
|
+ String selectFields = "tripchangehistoryentry.historystartdate, tripchangehistoryentry.historyenddate, tripchangehistoryentry.changetime";
|
|
|
+
|
|
|
+ DynamicObjectCollection historyEntities = QueryServiceHelper.query(tripReqInfo.getDataEntityType().getName(), selectFields, qFilter.toArray(), "tripchangehistoryentry.changetime desc");
|
|
|
+
|
|
|
+ if (tripReqInfo.getBoolean("ischange") && historyEntities.size() > 0) {
|
|
|
+ DynamicObject historyEntry = historyEntities.get(0);
|
|
|
+ Date now = new Date();
|
|
|
+ Date curStartDate = entry.getDate("startdate");
|
|
|
+ Date hisStartDate = historyEntry.getDate("tripchangehistoryentry.historystartdate");
|
|
|
+
|
|
|
+ String nowString = CommonHelperUtils.getDateFormatString(now, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String curStartDateString = CommonHelperUtils.getDateFormatString(curStartDate, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String hisStartDateString = CommonHelperUtils.getDateFormatString(hisStartDate, "yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ if(hisStartDate.compareTo(now) > 0){
|
|
|
+ if(curStartDate.compareTo(now) < 0){
|
|
|
+ this.addErrorMessage(dataEntity, "行程" + index + ", 出差前变更, 变更后的开始时间(" + curStartDateString + ")不能小于当前时间(" + nowString + ")");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(curStartDate.compareTo(hisStartDate) < 0){
|
|
|
+ this.addErrorMessage(dataEntity, "行程" + index + ", 出差后变更, 变更后的开始时间(" + curStartDateString + ")不能小于原开始时间(" + hisStartDateString + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|