Browse Source

邮件消息推送方法更新,增加从企业物料到我的产品库转入的方法

hejq 8 years ago
parent
commit
9aa5969f18

+ 23 - 4
src/main/java/com/uas/platform/b2b/controller/ProductUsersController.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2b.controller;
 package com.uas.platform.b2b.controller;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2b.model.FileUpload;
 import com.uas.platform.b2b.model.FileUpload;
 import com.uas.platform.b2b.model.Product;
 import com.uas.platform.b2b.model.Product;
 import com.uas.platform.b2b.model.ProductUsers;
 import com.uas.platform.b2b.model.ProductUsers;
@@ -20,10 +21,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.ui.ModelMap;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.ModelAndView;
 
 
 import java.io.IOException;
 import java.io.IOException;
@@ -151,4 +149,25 @@ public class ProductUsersController {
         }
         }
         return map;
         return map;
     }
     }
+
+    /**
+     * 批量转入我的物料
+     *
+     * @param ids
+     */
+    @RequestMapping(value = "/coverToUserByIds", method = RequestMethod.POST)
+    public ModelMap coverToUserByIds(String ids) {
+       return productUsersService.coverToUserProd(ids);
+    }
+
+    /**
+     * 单个转入我的物料
+     *
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "/covertToUser/{id}", method = RequestMethod.POST)
+    public void coverToUserById(@PathVariable Long id) {
+        productUsersService.coverToUserProd(id);
+    }
 }
 }

+ 19 - 0
src/main/java/com/uas/platform/b2b/dao/ProductUsersDao.java

@@ -4,6 +4,7 @@ import com.uas.platform.b2b.model.ProductUsers;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.query.Procedure;
 import org.springframework.data.repository.query.Param;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
@@ -27,4 +28,22 @@ public interface ProductUsersDao extends JpaSpecificationExecutor<ProductUsers>,
      */
      */
     @Query("select p from ProductUsers p where p.enuu = :enuu and p.useruu = :useruu and p.product.title = :title and p.product.spec = :spec and p.product.brand = :brand")
     @Query("select p from ProductUsers p where p.enuu = :enuu and p.useruu = :useruu and p.product.title = :title and p.product.spec = :spec and p.product.brand = :brand")
     List<ProductUsers> findByEnuuAndUseruuAndTitleAndSpecAndBrand(@Param("enuu") Long enuu, @Param("useruu") Long useruu, @Param("title") String title, @Param("spec") String spec, @Param("brand") String brand);
     List<ProductUsers> findByEnuuAndUseruuAndTitleAndSpecAndBrand(@Param("enuu") Long enuu, @Param("useruu") Long useruu, @Param("title") String title, @Param("spec") String spec, @Param("brand") String brand);
+
+    /**
+     * 通过选择的id批量转入我的物料
+     *
+     * @param ids
+     */
+    @Procedure(procedureName = "product_coverto_user")
+    Integer coverToUserProd(String ids, Long useruu, Long enuu);
+
+    /**
+     * 通过企业UU,个人uu和物料id查询我的产品库物料信息
+     *
+     * @param enuu
+     * @param useruu
+     * @param prid
+     * @return
+     */
+    List<ProductUsers> findByEnuuAndUseruuAndAndPrid(Long enuu, Long useruu, Long prid);
 }
 }

+ 2 - 4
src/main/java/com/uas/platform/b2b/listener/MessageListener.java

@@ -128,10 +128,8 @@ public class MessageListener implements ApplicationListener<SaveReleaseEvent<?,
                                             useruus.add(uu);
                                             useruus.add(uu);
                                     }
                                     }
                                 }
                                 }
-                                if (CollectionUtils.isEmpty(useruus)) {// 如果分配的业务员没有相关物料的信息,再分配给企业的业务员
-                                    useruus = commonDao.query(
-                                            "select distinct user_uu useruu from sec$userrole u left join sec$roles r on u.role_id = r.role_id where r.role_desc = '业务员' and r.role_enuu = " + enter.getEnuu(),
-                                            UserAndEnterprise.class);
+                                if (CollectionUtils.isEmpty(useruus)) {// 如果分配的业务员没有相关物料的信息,再分配给企业的分配客户的业务员
+                                    useruus = uus;
                                     if (CollectionUtils.isEmpty(useruus)) {// 以上两种情况都没有直接发送给管理员
                                     if (CollectionUtils.isEmpty(useruus)) {// 以上两种情况都没有直接发送给管理员
                                         useruus = commonDao.query(
                                         useruus = commonDao.query(
                                                 "select distinct user_uu useruu from sec$userrole u left join sec$roles r on u.role_id = r.role_id where r.role_desc = '管理员' and r.role_enuu = " + enter.getEnuu(),
                                                 "select distinct user_uu useruu from sec$userrole u left join sec$roles r on u.role_id = r.role_id where r.role_desc = '管理员' and r.role_enuu = " + enter.getEnuu(),

+ 16 - 0
src/main/java/com/uas/platform/b2b/service/ProductUsersService.java

@@ -7,6 +7,8 @@ import com.uas.search.b2b.model.SPage;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.ui.ModelMap;
 import org.springframework.ui.ModelMap;
 
 
+import java.util.List;
+
 /**
 /**
  * Created by hejq on 2017-11-08.
  * Created by hejq on 2017-11-08.
  */
  */
@@ -43,4 +45,18 @@ public interface ProductUsersService {
      * @return
      * @return
      */
      */
     ModelMap releaseByWorkbook(Workbook workbook);
     ModelMap releaseByWorkbook(Workbook workbook);
+
+    /**
+     * 批量转入我的产品库
+     *
+     * @param ids
+     */
+    ModelMap coverToUserProd(String ids);
+
+    /**
+     * 单个转入我的物料
+     *
+     * @param id
+     */
+    void coverToUserProd(Long id);
 }
 }

+ 1 - 1
src/main/java/com/uas/platform/b2b/service/PurchaseOrderService.java

@@ -397,5 +397,5 @@ public interface PurchaseOrderService {
      */
      */
     public void replyByBatch(String idString, String username, String userip, Long enuu, Long useruu);
     public void replyByBatch(String idString, String username, String userip, Long enuu, Long useruu);
 
 
-//    SPage<SaleOrderForProd> findOrderItemsByPageInfo(PageInfo pageInfo, SearchFilter filter);
+    SPage<SaleOrderForProd> findOrderItemsByPageInfo(PageInfo pageInfo, SearchFilter filter);
 }
 }

+ 25 - 0
src/main/java/com/uas/platform/b2b/service/impl/ProductUsersServiceImpl.java

@@ -298,4 +298,29 @@ public class ProductUsersServiceImpl implements ProductUsersService {
         }
         }
         return modelMap;
         return modelMap;
     }
     }
+
+    @Override
+    public ModelMap coverToUserProd(String ids) {
+        ids.replace("["," ");
+        ids.replace("]"," ");
+        Integer count = productUsersDao.coverToUserProd(ids, SystemSession.getUser().getUserUU(), SystemSession.getUser().getEnterprise().getUu());
+        logger.log("我的产品库", "新增了我产品信息", "size:" + count);
+        return new ModelMap("count", count);
+    }
+
+    @Override
+    public void coverToUserProd(Long id) {
+        Long useruu = SystemSession.getUser().getUserUU();
+        Long enuu = SystemSession.getUser().getEnterprise().getUu();
+        List<ProductUsers> prods = productUsersDao.findByEnuuAndUseruuAndAndPrid(enuu, useruu, id);
+        if(CollectionUtils.isEmpty(prods)) {
+            ProductUsers prod = new ProductUsers();
+            prod.setUseruu(useruu);
+            prod.setEnuu(enuu);
+            prod.setPrid(id);
+            prod.setDate(new Date());
+            prod = productUsersDao.save(prod);
+            logger.log("我的产品库", "新增了我产品信息", "id:" + prod.getId());
+        }
+    }
 }
 }

+ 103 - 2
src/main/webapp/resources/js/index/app.js

@@ -20612,8 +20612,9 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     }]);
     }]);
 
 
     // 当前企业所有的物料信息
     // 当前企业所有的物料信息
-    app.controller('ProductAllCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', 'ProductAllNewest', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, ProductAllNewest) {
+    app.controller('ProductAllCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', 'ProductAllNewest', '$rootScope', 'prodUser', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, ProductAllNewest, $rootScope, prodUser) {
         BaseService.scrollBackToTop();
         BaseService.scrollBackToTop();
+        $rootScope.ids = [];// 用来记录已经选择的物料
         $scope.active = 'all';
         $scope.active = 'all';
         $scope.agreedText = '全部';
         $scope.agreedText = '全部';
         $scope.dateZoneText = '一个月内';
         $scope.dateZoneText = '一个月内';
@@ -20668,6 +20669,17 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         $defer.resolve(page.content);
                         $defer.resolve(page.content);
                         $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
                         $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
                         $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
                         $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
+                        $scope.checkall = true;
+                        angular.forEach(page.content, function (prod) {
+                            if ($rootScope.ids.indexOf(prod.id) > -1) {
+                                prod.$selected = true;
+                            } else {
+                                $scope.checkall = false;
+                            }
+                        });
+                        $scope.checkboxes = {
+                            checked: $scope.checkall
+                        };
                     }
                     }
                 }, function (response) {
                 }, function (response) {
                     $scope.loading = false;
                     $scope.loading = false;
@@ -20743,6 +20755,94 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                 toaster.pop('error', '提示', response.data);
                 toaster.pop('error', '提示', response.data);
             });
             });
         }
         }
+
+        $scope.checkboxes = {
+            checked: false
+        };
+        angular.forEach($scope.tableParams.data, function (item) {
+            $scope.checkboxes.checked = false;
+            if($rootScope.ids.in_array(item.id)) {
+                $rootScope.ids.remove(item.id);
+                $scope.checkboxes.checked = true;
+            }
+        });
+
+        // 点击勾选全部的复选框
+        $scope.checkAll = function () {
+            angular.forEach($scope.tableParams.data, function (item) {
+                if (!item.waiting) {
+                    item.$selected = $scope.checkboxes.checked;
+                    if(item.$selected) {
+                        if(!$rootScope.ids.in_array(item.id)) {
+                            $rootScope.ids.push(item.id);
+                        }
+                    } else {
+                        if($rootScope.ids.in_array(item.id)) {
+                            $rootScope.ids.remove(item.id);
+                        }
+                    }
+
+                }
+            });
+        };
+
+        // 判断数组中是否存在某个对象
+        Array.prototype.S = String.fromCharCode(2);
+        Array.prototype.in_array = function(e) {
+            var r = new RegExp(this.S + e + this.S);
+            return (r.test(this.S + this.join(this.S) + this.S));
+        }
+
+        // 从数组中移除某个对象
+        Array.prototype.remove = function(val) {
+            var index = this.indexOf(val);
+            if (index > -1) {
+                this.splice(index, 1);
+            }
+        };
+
+        // 点击其中一个明细的复选框
+        $scope.checkOne = function (product) {
+            var result = true;
+            angular.forEach($scope.tableParams.data, function (item) {
+                if (item.$selected != true) {
+                    result = false;
+                    return;
+                }
+            });
+            if(product.$selected) {
+                if(!$rootScope.ids.in_array(product.id)) {
+                    $rootScope.ids.push(product.id);
+                }
+            } else {
+                if($rootScope.ids.in_array(product.id)) {
+                    $rootScope.ids.remove(product.id);
+                }
+            }
+            $scope.checkboxes = {
+                checked: result
+            };
+        };
+
+        // 批量转入我的产品库
+        $scope.addtoUserByCheck = function() {
+            var ids = angular.toJson($rootScope.ids);
+            ids = ids.replace(/\[|]/g,'');
+            prodUser.coverToUserByIds({ids: ids}, {}, function(data) {
+                toaster.pop('success', '成功转入' + data.count);
+            }, function(res) {
+                toaster.pop('error', '转入失败');
+            });
+        }
+
+        // 转入我的产品库
+        $scope.addtoUser = function(id) {
+            prodUser.coverToUser({id: id}, {}, function(data) {
+                toaster.pop('success', '转入成功');
+            }, function(res) {
+                toaster.pop('error', '转入失败');
+            });
+        }
     }]);
     }]);
 
 
     // 当前企业匹配的标准物料信息
     // 当前企业匹配的标准物料信息
@@ -21358,7 +21458,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
      */
      */
     app.controller('PurcProductCtrl', ['$scope', 'PurcProduct', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$modal', 'GetProductInfo', '$rootScope', 'PurcProductNewest', 'AccountEnterprise', function ($scope, PurcProduct, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $modal, GetProductInfo, $rootScope, PurcProductNewest, AccountEnterprise) {
     app.controller('PurcProductCtrl', ['$scope', 'PurcProduct', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$modal', 'GetProductInfo', '$rootScope', 'PurcProductNewest', 'AccountEnterprise', function ($scope, PurcProduct, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $modal, GetProductInfo, $rootScope, PurcProductNewest, AccountEnterprise) {
         BaseService.scrollBackToTop();
         BaseService.scrollBackToTop();
-
+        // 用来记录已经选择的id
+        $rootScope.ids = [];
         var loadAccount = function () {
         var loadAccount = function () {
             AccountEnterprise.get({}, function (data) {
             AccountEnterprise.get({}, function (data) {
                 $scope.enterprise = data;
                 $scope.enterprise = data;

+ 14 - 0
src/main/webapp/resources/js/index/services/ProductUsers.js

@@ -31,6 +31,20 @@ define([ 'ngResource'], function() {
             deleteById: {
             deleteById: {
                 url: 'productuser/edit/delete',
                 url: 'productuser/edit/delete',
                 method: 'POST'
                 method: 'POST'
+            },
+            /**
+             * 批量转入我的产品库
+             */
+            coverToUserByIds: {
+                url: 'productuser/coverToUserByIds',
+                method: 'POST'
+            },
+            /**
+             * 转入我的产品库
+             */
+            coverToUser: {
+                url: 'productuser/covertToUser/:id',
+                method: 'POST'
             }
             }
         })
         })
     }])
     }])

+ 8 - 2
src/main/webapp/resources/tpl/index/approvalFlow/prodList.html

@@ -187,8 +187,8 @@
         <span>产品库</span>
         <span>产品库</span>
         <div class="p-right">
         <div class="p-right">
             <a href="product/xls?keyword={{keywordXls}}" target="_self" class="text-simple" title="导出Excel表格">导出</a>
             <a href="product/xls?keyword={{keywordXls}}" target="_self" class="text-simple" title="导出Excel表格">导出</a>
-          <!--   <a ui-sref="sale.newProdInfo">新增</a>
-            <a ui-sref="sale.uploadByBatch" title="批量导入">批量导入</a> -->
+            <a ng-click="addtoUserByCheck()">批量转入</a>
+            <!--<a ui-sref="sale.uploadByBatch" title="批量导入">批量导入</a> -->
         </div>
         </div>
     </div>
     </div>
     <div class="condition block" style="padding: 10px 15px;">
     <div class="condition block" style="padding: 10px 15px;">
@@ -239,6 +239,9 @@
         <table class="order-table block " ng-table="tableParams">
         <table class="order-table block " ng-table="tableParams">
             <thead>
             <thead>
             <tr class="header">
             <tr class="header">
+                <th width="50px"><input type="checkbox" class="selector select_all"
+                           ng-model="checkboxes.checked" ng-click="checkAll()" title="点击选择后可以批量转入我的产品库">
+                </th>
                 <th width="140">产品编号</th>
                 <th width="140">产品编号</th>
                 <th>产品名称(类目)</th>
                 <th>产品名称(类目)</th>
                 <th width="160">产品型号</th>
                 <th width="160">产品型号</th>
@@ -249,6 +252,8 @@
             </thead>
             </thead>
             <tbody ng-repeat="product in $data">
             <tbody ng-repeat="product in $data">
             <tr class="order-hd">
             <tr class="order-hd">
+                <td class="text-center"><input type="checkbox" class="selector"
+                           ng-model="product.$selected" ng-click="checkOne(product)"></td>
                 <td class="text-center" title="{{product.code}}" ng-bind="::product.code"></td>
                 <td class="text-center" title="{{product.code}}" ng-bind="::product.code"></td>
                 <td class="line-h20 first text-center">
                 <td class="line-h20 first text-center">
                     <div class="order-main">
                     <div class="order-main">
@@ -274,6 +279,7 @@
                         <span class="" title="已关闭" ng-click="unlockPurc(product.id)" ng-if="::product.isPurchase!=1"></span>
                         <span class="" title="已关闭" ng-click="unlockPurc(product.id)" ng-if="::product.isPurchase!=1"></span>
                         <span class="off" title="已开启" ng-click="lockPurc(product.id)" ng-if="::product.isPurchase==1"></span>
                         <span class="off" title="已开启" ng-click="lockPurc(product.id)" ng-if="::product.isPurchase==1"></span>
                     </span>
                     </span>
+                    <span><a class="btn btn-success btn-sm" ng-click="addtoUser(product.id)">转我的产品</a></span>
                 </td>
                 </td>
             </tr>
             </tr>
             </tbody>
             </tbody>