Browse Source

匹配结果页,如果数据没加载完成,会一直加载

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@9417 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq 8 years ago
parent
commit
8c468bdc7e

+ 15 - 3
src/main/java/com/uas/platform/b2b/controller/ProductController.java

@@ -264,10 +264,22 @@ public class ProductController {
 	 * 
 	 * @return
 	 */
-	@RequestMapping(value = "/matchall", method = RequestMethod.GET)
+	@RequestMapping(value = "/matchbytype/{type}", method = RequestMethod.GET)
 	@ResponseBody
-	private ModelMap matchall() {
-		return productService.matchall();
+	private ModelMap matchall(@PathVariable String type) {
+		return productService.matchall(type);
+	}
+
+	/**
+	 * 得到匹配结果数量
+	 * 
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/matchsize/{type}", method = RequestMethod.GET)
+	@ResponseBody
+	private ModelMap matchsize(@PathVariable String type) {
+		return productService.matchsize(type);
 	}
 
 	/**

+ 26 - 0
src/main/java/com/uas/platform/b2b/dao/ProductDao.java

@@ -144,6 +144,24 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
 	@Procedure(procedureName = "PRODUCT$MATCHES")
 	public String upateResultByEnuu(Long enuu);
 
+	/**
+	 * 通过uu查询非标准器件进行存储
+	 * 
+	 * @param enuu
+	 * @return
+	 */
+	@Procedure(procedureName = "PRODUCT$MATCHES_SALE")
+	public String upateResultByEnuuForSale(Long enuu);
+
+	/**
+	 * 通过uu查询非标准器件进行存储
+	 * 
+	 * @param enuu
+	 * @return
+	 */
+	@Procedure(procedureName = "PRODUCT$MATCHES_PURC")
+	public String upateResultByEnuuForPurc(Long enuu);
+
 	/**
 	 * 根据状态更新数据
 	 * 
@@ -153,5 +171,13 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
 	 */
 	public List<Product> findByEnUUAndMatchstatus(Long uu, Integer status);
 
+	/**
+	 * 通过应用来源和下载状态查询物料信息
+	 * 
+	 * @param enuu
+	 * @param app
+	 * @param status
+	 * @return
+	 */
 	public List<Product> findByEnUUAndSourceAppAndDownloadstatus(Long enuu, String app, Integer status);
 }

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

@@ -97,7 +97,7 @@ public interface ProductService {
 	 * 
 	 * @return
 	 */
-	public ModelMap matchall();
+	public ModelMap matchall(String type);
 
 	/**
 	 * 通过型号匹配器件
@@ -152,4 +152,12 @@ public interface ProductService {
 	 * @param idArray
 	 */
 	public void onProductDownSuccess(String[] idArray);
+
+	/**
+	 * 获取匹配数量
+	 * 
+	 * @param type
+	 * @return
+	 */
+	public ModelMap matchsize(String type);
 }

+ 24 - 2
src/main/java/com/uas/platform/b2b/service/impl/ProductServiceImpl.java

@@ -230,7 +230,7 @@ public class ProductServiceImpl implements ProductService {
 	}
 
 	@Override
-	public ModelMap matchall() {
+	public ModelMap matchall(String matchtype) {
 		ModelMap map = new ModelMap();
 		// List<Product> products =
 		// productDao.findByEnUUAndStandard(SystemSession.getUser().getEnterprise().getUu(),
@@ -289,7 +289,14 @@ public class ProductServiceImpl implements ProductService {
 		// } else {
 		// map.put("error", "暂未查询到当前企业的非标准的物料信息");
 		// }
-		String num = productDao.upateResultByEnuu(SystemSession.getUser().getEnterprise().getUu());
+		String num = null;
+		if (matchtype.equals("sale")) {
+			num = productDao.upateResultByEnuuForSale(SystemSession.getUser().getEnterprise().getUu());
+		} else if (matchtype.equals("purc")) {
+			num = productDao.upateResultByEnuuForPurc(SystemSession.getUser().getEnterprise().getUu());
+		} else if (matchtype.equals("all")) {
+			num = productDao.upateResultByEnuu(SystemSession.getUser().getEnterprise().getUu());
+		}
 		if (null == num) {
 			map.put("size", 0);
 		} else {
@@ -400,6 +407,21 @@ public class ProductServiceImpl implements ProductService {
 		}
 	}
 
+	@Override
+	public ModelMap matchsize(String type) {
+		ModelMap map = new ModelMap();
+		String sql = "select count(*) from products where pr_matchstatus = 101 and pr_enuu = "
+				+ SystemSession.getUser().getEnterprise().getUu();
+		if (type.equals("sale")) {
+			sql = sql + "and pr_issale = 1";
+		} else if (type.equals("purc")) {
+			sql = sql + "and pr_ispurchase = 1";
+		}
+		Integer size = commonDao.queryForObject(sql, Integer.class);
+		map.put("size", size);
+		return map;
+	}
+
 	/*
 	 * @Override public ModelMap updateByEn() { ModelMap map = new ModelMap();
 	 * List<Product> products =

+ 38 - 11
src/main/webapp/resources/js/index/app.js

@@ -10196,8 +10196,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         
      // 一键匹配
 		$scope.matchall = function() {
-            $scope.loading = true;
-			Products.matchall({}, function(data) {
+			$scope.loading = true;
+			$scope.type = "sale";
+			Products.matchbytype({type: $scope.type}, {}, function(data) {
 				toaster.pop('info', '提示', '匹配成功'+data.size+'个标准器件');
 				window.location.href = "#/sale/productmatches";
 			}, function(response) {
@@ -16037,8 +16038,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 		
 		// 一键匹配
 		$scope.matchall = function() {
-            $scope.loading = true;
-			Products.matchall({}, function(data) {
+			$scope.type = "all";
+			$scope.loading = true;
+			Products.matchbytype({type: $scope.type}, {}, function(data) {
 				toaster.pop('info', '提示', '匹配成功'+data.size+'个标准器件');
 				window.location.href = "#/approvalFlow/productmatches";
 			}, function(response) {
@@ -16103,7 +16105,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				getService().call(null, BaseService.parseParams(pageParams), function(page){
 					$scope.loading = false;
 					if(page) {
-						console.log(page);
 						params.total(page.totalElement);
 						$defer.resolve(page.content);
 						$scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
@@ -16114,6 +16115,15 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 								product.checked = $scope.checks.checked;
 							}
 						});
+						$scope.total = page.totalElement;
+						Products.matchsize({type: 'all'}, {}, function(data) {
+							$scope.size = data.size;
+							if($scope.total < $scope.size) {
+								$scope.tableParams.reload();
+							}
+						}, function(response) {
+							toaster.pop('error', '提示', response.data);
+						});
 					}
 				}, function(response) {
 					$scope.loading = false;
@@ -16283,7 +16293,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				getService().call(null, BaseService.parseParams(pageParams), function(page){
 					$scope.loading = false;
 					if(page) {
-						console.log(page);
 						params.total(page.totalElement);
 						$defer.resolve(page.content);
 						$scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
@@ -16294,6 +16303,15 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 								product.checked = $scope.checks.checked;
 							}
 						});
+						$scope.total = page.totalElement;
+						Products.matchsize({type: 'sale'}, {}, function(data) {
+							$scope.size = data.size;
+							if($scope.total < $scope.size) {
+								$scope.tableParams.reload();
+							}
+						}, function(response) {
+							toaster.pop('error', '提示', response.data);
+						});
 					}
 				}, function(response) {
 					$scope.loading = false;
@@ -16463,7 +16481,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 				getService().call(null, BaseService.parseParams(pageParams), function(page){
 					$scope.loading = false;
 					if(page) {
-						console.log(page);
 						params.total(page.totalElement);
 						$defer.resolve(page.content);
 						$scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
@@ -16474,6 +16491,15 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 								product.checked = $scope.checks.checked;
 							}
 						});
+						$scope.total = page.totalElement;
+						Products.matchsize({type: 'purc'}, {}, function(data) {
+							$scope.size = data.size;
+							if($scope.total < $scope.size) {
+								$scope.tableParams.reload();
+							}
+						}, function(response) {
+							toaster.pop('error', '提示', response.data);
+						});
 					}
 				}, function(response) {
 					$scope.loading = false;
@@ -16752,8 +16778,9 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         
      // 一键匹配
 		$scope.matchall = function() {
-            $scope.loading = true;
-			Products.matchall({}, function(data) {
+			$scope.type = "purc";
+			$scope.loading = true;
+			Products.matchbytype({type: $scope.type}, {}, function(data) {
 				toaster.pop('info', '提示', '匹配成功'+data.size+'个标准器件');
 				window.location.href = "#/purc/productmatches";
 			}, function(response) {
@@ -16767,7 +16794,6 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 	 */
 	app.controller('UploadProductCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function($scope, $upload, toaster, BaseService) {
 		BaseService.scrollBackToTop();
-		
 		$scope.$watch('myFiles', function(){
 			if($scope.myFiles) {
 				var file = $scope.myFiles[0];
@@ -16781,12 +16807,13 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 			if($scope.myFiles) {
 				var file = $scope.myFiles[0];
 				if(file.name) {
+					$scope.loading = true;
 					$upload.upload({
 						url: 'purcProduct/release/excel',
 						file: file,
 						method: 'POST'
 					}).success(function(data) {
-                        $scope.loading = false;
+						$scope.loading = false;
 						if(data.error) {
 							toaster.pop('error', '提示', data.error);
 						}

+ 6 - 2
src/main/webapp/resources/js/index/services/Product.js

@@ -44,8 +44,8 @@ define([ 'ngResource'], function() {
 				methoe: 'GET',
 				isArray: true
 			},
-			matchall: {
-				url: 'product/matchall',
+			matchbytype: {
+				url: 'product/matchbytype/:type',
 				method: 'GET'
 			},
 			updateall: {
@@ -85,6 +85,10 @@ define([ 'ngResource'], function() {
 			updateByEn: {
 				url: 'product/updateByEn',
 				method: 'POST'
+			},
+			matchsize: {
+				url: 'product/matchsize/:type',
+				method: 'GET'
 			}
 		});
 	}]).factory('PurcProduct', ['$resource', function($resource) {

+ 6 - 0
src/main/webapp/resources/tpl/index/purc/uploadByBatch.html

@@ -295,9 +295,15 @@ table.table.table-striped  thead {
 </style>
 <!-- block start -->
 <div class="block">
+<<<<<<< .mine
+	<div class="loading in" ng-class="{'in': loading}">
+		<i></i>
+	</div>
+=======
 	<div class="loading" ng-class="{'in': loading}">
 		<i></i>
 	</div>
+>>>>>>> .r9416
 	<div class="headerline">
 		<div class="index"></div>
 		<div class="content f16 text-bold">第一步、下载Excel模板</div>