wanghaiwu 5 өдөр өмнө
parent
commit
88543398af

+ 43 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/operate/DailyVehicleBillSubmitOpPlugin.java

@@ -1,6 +1,7 @@
 package nckd.jimin.jyyy.fi.plugin.operate;
 
 import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.entity.ExtendedDataEntity;
 import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 import kd.bos.entity.plugin.AddValidatorsEventArgs;
@@ -12,6 +13,10 @@ import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
 import kd.bos.entity.validate.AbstractValidator;
 import kd.bos.logging.Log;
 import kd.bos.logging.LogFactory;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.QueryServiceHelper;
+import nckd.base.helper.CommonHelperUtils;
 import nckd.jimin.jyyy.fi.common.FinanceCommonUtils;
 
 import java.util.Date;
@@ -34,6 +39,7 @@ public class DailyVehicleBillSubmitOpPlugin extends AbstractOperationServicePlug
         fieldKeys.add("applier");
         fieldKeys.add("startdate");
         fieldKeys.add("enddate");
+        fieldKeys.add("nckd_ischange");
     }
 
     @Override
@@ -65,6 +71,43 @@ public class DailyVehicleBillSubmitOpPlugin extends AbstractOperationServicePlug
                     if(checkMsg.length() > 0) {
                         this.addErrorMessage(dataEntity, "存在开始时间、结束时间重叠的单据!" + checkMsg);
                     }
+
+                    //如果是变更行程,需要与变更前的做校验
+                    QFilter qFilter = new QFilter("id", QCP.equals, vehicleReqBillInfo.getLong("id"));
+
+                    String selectFields = "nckd_historyentry.nckd_historystartdate, nckd_historyentry.nckd_historyenddate, nckd_historyentry.nckd_changetime";
+
+                    DynamicObjectCollection historyEntities = QueryServiceHelper.query(vehicleReqBillInfo.getDataEntityType().getName(), selectFields, qFilter.toArray(), "nckd_historyentry.nckd_changetime desc");
+
+                    if (vehicleReqBillInfo.getBoolean("nckd_ischange") && historyEntities.size() > 0) {
+                        DynamicObject historyEntry = historyEntities.get(0);
+                        Date now = new Date();
+                        Date curStartDate = vehicleReqBillInfo.getDate("startdate");
+                        Date hisStartDate = historyEntry.getDate("nckd_historyentry.nckd_historystartdate");
+
+                        Date curEndDate = vehicleReqBillInfo.getDate("enddate");
+                        Date hisEndDate = historyEntry.getDate("nckd_historyentry.nckd_historyenddate");
+
+                        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");
+                        String curEndDateString = CommonHelperUtils.getDateFormatString(curEndDate, "yyyy-MM-dd HH:mm:ss");
+                        String hisEndDateString = CommonHelperUtils.getDateFormatString(hisEndDate, "yyyy-MM-dd HH:mm:ss");
+
+                        if(hisStartDate.compareTo(now) > 0){
+                            if(curStartDate.compareTo(now) < 0){
+                                this.addErrorMessage(dataEntity, "出差前变更, 变更后的开始时间(" + curStartDateString + ")不能小于当前时间(" + nowString + ")");
+                            }
+                        } else {
+                            if(curStartDate.compareTo(hisStartDate) < 0){
+                                this.addErrorMessage(dataEntity, "出差后变更, 变更后的开始时间(" + curStartDateString + ")不能小于原开始时间(" + hisStartDateString + ")");
+                            }
+                        }
+
+                        if(curEndDate.compareTo(hisEndDate) > 0){
+                            this.addErrorMessage(dataEntity, "变更后的结束时间(" + curEndDateString + ")不能大于原结束时间(" + hisEndDateString + ")");
+                        }
+                    }
                 }
             }
         });

+ 9 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/operate/TripReqBillSubmitOpPlugin.java

@@ -105,9 +105,14 @@ public class TripReqBillSubmitOpPlugin extends AbstractOperationServicePlugIn {
                             Date curStartDate = entry.getDate("startdate");
                             Date hisStartDate = historyEntry.getDate("tripchangehistoryentry.historystartdate");
 
+                            Date curEndDate = entry.getDate("enddate");
+                            Date hisEndDate = historyEntry.getDate("tripchangehistoryentry.historyenddate");
+
                             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");
+                            String curEndDateString = CommonHelperUtils.getDateFormatString(curEndDate, "yyyy-MM-dd HH:mm:ss");
+                            String hisEndDateString = CommonHelperUtils.getDateFormatString(hisEndDate, "yyyy-MM-dd HH:mm:ss");
 
                             if(hisStartDate.compareTo(now) > 0){
                                 if(curStartDate.compareTo(now) < 0){
@@ -118,6 +123,10 @@ public class TripReqBillSubmitOpPlugin extends AbstractOperationServicePlugIn {
                                     this.addErrorMessage(dataEntity, "行程" + index + ", 出差后变更, 变更后的开始时间(" + curStartDateString + ")不能小于原开始时间(" + hisStartDateString + ")");
                                 }
                             }
+
+                            if(curEndDate.compareTo(hisEndDate) > 0){
+                                this.addErrorMessage(dataEntity, "行程" + index + ", 变更后的结束时间(" + curEndDateString + ")不能大于原结束时间(" + hisEndDateString + ")");
+                            }
                         }
                     }
                 }