Просмотр исходного кода

供应商分配和转移先进行权限判断

hejq 7 лет назад
Родитель
Сommit
16c1d2fa89

+ 26 - 0
src/main/java/com/uas/platform/b2b/core/util/DateUtils.java

@@ -1,5 +1,7 @@
 package com.uas.platform.b2b.core.util;
 
+import org.apache.commons.lang3.time.FastDateFormat;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -22,6 +24,30 @@ public class DateUtils {
 	static final SimpleDateFormat YM = new SimpleDateFormat("yyyy-MM");
 	static final SimpleDateFormat YMD = new SimpleDateFormat("yyyy-MM-dd");
 	static final SimpleDateFormat YMD_HMS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    static final FastDateFormat MM = FastDateFormat.getInstance("MM");
+    static final FastDateFormat YYYY = FastDateFormat.getInstance("yyyy");
+    static final FastDateFormat DD = FastDateFormat.getInstance("dd");
+
+    /**
+     * 获取月份
+     */
+    public static Integer getMonth(Date date) {
+        return Integer.valueOf(MM.format(date));
+    }
+
+    /**
+     * 获取年份
+     */
+    public static Integer getYear(Date date) {
+        return Integer.valueOf(YYYY.format(date));
+    }
+
+    /**
+     * 获取天数
+     */
+    public static Integer getDay(Date date) {
+        return Integer.valueOf(DD.format(date));
+    }
 
 	/**
 	 * 获取月份起始日期

+ 3 - 2
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -27,6 +27,7 @@ import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
+import com.uas.ps.core.page.exception.IllegalOperatorException;
 import com.uas.search.b2b.model.MultiValue;
 import com.uas.search.b2b.model.SPage;
 import com.uas.search.b2b.model.Sort;
@@ -636,10 +637,10 @@ public class VendorsServiceImpl implements VendorService {
                 if (Constant.NO == distribute.getIsTransfer()) {
                     throw new IllegalAccessException("当前用户没有分配或转移的权限");
                 }
+            } else {
+                throw new IllegalAccessException("当前用户没有分配或转移的权限");
             }
-
         }
-
     }
 
     /**

+ 29 - 0
src/main/java/com/uas/platform/b2b/task/SendNoticeTask.java

@@ -1,9 +1,11 @@
 package com.uas.platform.b2b.task;
 
+import com.uas.platform.b2b.core.util.DateUtils;
 import com.uas.platform.b2b.dao.CommunalLogDao;
 import com.uas.platform.b2b.dao.PurchaseNoticeDao;
 import com.uas.platform.b2b.dao.PurchaseOrderDao;
 import com.uas.platform.b2b.model.CommunalLog;
+import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.util.HttpUtil;
 import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.log4j.Logger;
@@ -20,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 每天定时更新发货提醒异常的数据
@@ -127,4 +130,30 @@ public class SendNoticeTask {
             }
         }
     }
+
+    private Short checkNoticeWaitStaus(Date delivery, Integer stock) {
+        Integer nowYear = DateUtils.getYear(new Date());
+        Integer delYear = DateUtils.getYear(delivery);
+        if (Objects.equals(nowYear, delYear)) {
+            if (stock == -1) {
+                Integer nowMonth = DateUtils.getMonth(new Date());
+                Integer delMonth = DateUtils.getMonth(delivery);
+                if (nowMonth >= delMonth) {
+                    return Constant.NO;
+                } else if (nowMonth + 1 == delMonth) {
+                    Integer nowDay = DateUtils.getDay(new Date());
+                    // 本月临界值
+                    Integer maxDay = 25;
+                    if (nowDay > maxDay) {
+                        return Constant.NO;
+                    } else {
+                        return Constant.YES;
+                    }
+                } else {
+                    return Constant.YES;
+                }
+            }
+        }
+        return Constant.NO;
+    }
 }

+ 7 - 0
src/main/webapp/resources/js/index/app.js

@@ -2174,6 +2174,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                 } else {
                     toaster.pop('error', '您没有为当前客户分配用户的权限!');
                 }
+            }, function (res) {
+                toaster.pop('error', res.data);
             });
         };
 
@@ -2511,6 +2513,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             $scope.distribute = distribute;
             $scope.havedone = angular.copy($scope.distribute);
             $scope.loading = false;
+        }, function (res) {
+            $scope.loading = false;
+            toaster.pop('error', res.data);
         });
 
         var checkStatus = function (userinfos) {
@@ -2627,6 +2632,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             $scope.transfer = transfer;
             $scope.havedone = angular.copy($scope.transfer);
             $scope.loading = false;
+        }, function (res) {
+            toaster.pop('error', res.data);
         });
 
         var checkStatus = function (userinfos) {