Explorar el Código

Merge remote-tracking branch 'origin/dev' into dev

hejq hace 7 años
padre
commit
6cc83bef10

+ 1 - 1
src/main/java/com/uas/platform/b2b/ps/ProductUtils.java

@@ -31,7 +31,7 @@ public class ProductUtils {
     /**
      * 物料单次请求数据量大小
      */
-    private static final int ONE_TIME_DATA_SIZE = 1000;
+    private static final int ONE_TIME_DATA_SIZE = 5000;
 
     /**
      * 分页批量更新物料

+ 15 - 8
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -2,6 +2,8 @@ package com.uas.platform.b2b.service.impl;
 
 import com.uas.account.entity.RequsetStatus;
 import com.uas.account.util.AccountUtils;
+import com.uas.platform.b2b.core.util.DateUtils;
+import com.uas.platform.b2b.core.util.StringUtil;
 import com.uas.platform.b2b.core.util.ThreadTask;
 import com.uas.platform.b2b.dao.CommonDao;
 import com.uas.platform.b2b.dao.DistributeDao;
@@ -54,6 +56,7 @@ import com.uas.search.b2b.model.Sort;
 import com.uas.search.b2b.model.Sort.Type;
 import com.uas.search.b2b.util.SearchConstants;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -64,7 +67,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.ui.ModelMap;
 
 import javax.transaction.Transactional;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -126,6 +128,11 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 	@Autowired
 	private ProductStatusDao productStatusDao;
 
+	/**
+	 * 一次上传允许的最大数量 (前三行为标题  从0开始)
+	 */
+	private final static Integer MAX_ROWNUM = 5002;
+
 	
 	/**
 	 * 批量导入物料资料
@@ -138,13 +145,17 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 		List<Product> products = new ArrayList<Product>();
 		List<Product> productsInfo = new ArrayList<Product>();
 		Sheet sheet = workbook.getSheetAt(0);
+		String codePrefix = "PR" + DateUtils.format(new Date(), "yyMMddHHmmss") + StringUtil.getRandomNumber(3);
 		int rowNum = sheet.getLastRowNum();
+		if (rowNum > MAX_ROWNUM) {
+			throw new IllegalOperatorException("单次上传不超过5000条");
+		}
 		Row headerRow = sheet.getRow(0);
 		int total = 0;
 		if (headerRow != null) {
 			for (int r = 3; r <= rowNum; r++) {
 				Row row = sheet.getRow(r);
-				if (row != null) {
+				if (row != null && row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
 					total++;
 					Product product = new Product();
 
@@ -152,6 +163,8 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 					if (row.getCell(0) != null && row.getCell(0).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
 						product.setCode(row.getCell(0).getStringCellValue().trim());
+					} else {
+						product.setCode(codePrefix + StringUtils.leftPad(String.valueOf(r), 4, "0"));
 					}
 
 					// 物料名称
@@ -176,12 +189,6 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 					if (row.getCell(3) != null && row.getCell(3).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
 						product.setCmpCode(row.getCell(3).getStringCellValue().trim());
-						if (product.getCode() == null) {
-							// 生成随机物料编码
-							SimpleDateFormat sdf = new SimpleDateFormat("mmsssss");
-							String code = SystemSession.getUser().getEnterprise().getUu() + sdf.format(new Date());
-							product.setCode(code);
-						}
 					} else {
                         modelMap.put("error", "第" + (r + 1) + "行物料型号未填写");
                         return modelMap;

+ 14 - 2
src/main/java/com/uas/platform/b2b/service/impl/ProductUsersServiceImpl.java

@@ -8,12 +8,16 @@ import com.uas.platform.b2b.dao.ProductDao;
 import com.uas.platform.b2b.dao.ProductStatusDao;
 import com.uas.platform.b2b.dao.ProductTempDao;
 import com.uas.platform.b2b.dao.ProductUsersDao;
-import com.uas.platform.b2b.model.*;
+import com.uas.platform.b2b.model.Product;
+import com.uas.platform.b2b.model.ProductTemp;
+import com.uas.platform.b2b.model.ProductUsers;
+import com.uas.platform.b2b.model.Role;
 import com.uas.platform.b2b.ps.ProductUtils;
 import com.uas.platform.b2b.service.ProductUsersService;
 import com.uas.platform.b2b.service.RoleService;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.b2b.support.UsageBufferedLogger;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
@@ -63,6 +67,11 @@ public class ProductUsersServiceImpl implements ProductUsersService {
     @Autowired
     private ProductTempDao productTempDao;
 
+    /**
+     * 一次上传允许的最大数量 (前三行为标题 从0开始)
+     */
+    private final static Integer MAX_ROWNUM = 20002;
+
     @Override
     public SPage<ProductUsers> findProductInfoByPageInfo(PageInfo pageInfo) {
         Page<ProductUsers> products = findAllProudctByPageInfo(pageInfo);
@@ -169,9 +178,12 @@ public class ProductUsersServiceImpl implements ProductUsersService {
         Long enUU = SystemSession.getUser().getEnterprise().getUu();
         Long userUU = SystemSession.getUser().getUserUU();
         // 生成随机物料编码
-        String codePrefix = "PR" + DateUtils.format(new Date(), "yyMMddHHmmsssss") + StringUtil.getRandomNumber(3);
+        String codePrefix = "PR" + DateUtils.format(new Date(), "yyMMddHHmmss") + StringUtil.getRandomNumber(3);
         Sheet sheet = workbook.getSheetAt(0);
         int rowNum = sheet.getLastRowNum();
+        if (rowNum > MAX_ROWNUM) {
+            throw new IllegalOperatorException("单次上传不超过20000条");
+        }
         Row headerRow = sheet.getRow(0);
         int total = 0;
         short isSale = Constant.YES;

+ 16 - 8
src/main/java/com/uas/platform/b2b/service/impl/PurcProductServiceImpl.java

@@ -1,5 +1,7 @@
 package com.uas.platform.b2b.service.impl;
 
+import com.uas.platform.b2b.core.util.DateUtils;
+import com.uas.platform.b2b.core.util.StringUtil;
 import com.uas.platform.b2b.dao.EnterpriseDao;
 import com.uas.platform.b2b.dao.ProductDao;
 import com.uas.platform.b2b.dao.ProductStatusDao;
@@ -9,8 +11,10 @@ import com.uas.platform.b2b.model.ProductStatus;
 import com.uas.platform.b2b.ps.ProductUtils;
 import com.uas.platform.b2b.service.PurcProductService;
 import com.uas.platform.b2b.support.SystemSession;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.Constant;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -19,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.ModelMap;
 
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -36,6 +39,11 @@ public class PurcProductServiceImpl implements PurcProductService {
 	@Autowired
 	private ProductStatusDao productStatusDao;
 
+	/**
+	 * 一次上传允许的最大数量 (前三行为标题  从0开始)
+	 */
+	private final static Integer MAX_ROWNUM = 5002;
+
 	/**
 	 * 批量导入物料资料
 	 */
@@ -48,13 +56,17 @@ public class PurcProductServiceImpl implements PurcProductService {
 		List<Product> oldProducts = new ArrayList<>();
 		List<Product> productsInfo = new ArrayList<Product>();
 		Sheet sheet = workbook.getSheetAt(0);
+		String codePrefix = "PR" + DateUtils.format(new Date(), "yyMMddHHmmss") + StringUtil.getRandomNumber(3);
 		int rowNum = sheet.getLastRowNum();
+		if (rowNum > MAX_ROWNUM) {
+			throw new IllegalOperatorException("单次上传不超过5000条");
+		}
 		Row headerRow = sheet.getRow(0);
 		int total = 0;
 		if (headerRow != null) {
 			for (int r = 3; r <= rowNum; r++) {
 				Row row = sheet.getRow(r);
-				if (row != null) {
+				if (row != null && row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
 					total++;
 					Product product = new Product();
 					//TODO huangct 上传文件中存在必填信息缺失的情况处理
@@ -63,6 +75,8 @@ public class PurcProductServiceImpl implements PurcProductService {
 					if (row.getCell(0) != null) {
 						row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
 						product.setCode(row.getCell(0).getStringCellValue().trim());
+					} else {
+						product.setCode(codePrefix + StringUtils.leftPad(String.valueOf(r), 4, "0"));
 					}
 
 					// 物料名称
@@ -87,12 +101,6 @@ public class PurcProductServiceImpl implements PurcProductService {
 					if (row.getCell(3) != null && row.getCell(3).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
 						product.setCmpCode(row.getCell(3).getStringCellValue().trim());
-						if (product.getCode() == null) {
-							// 生成随机物料编码
-							SimpleDateFormat sdf = new SimpleDateFormat("mmsssss");
-							String code = SystemSession.getUser().getEnterprise().getUu() + sdf.format(new Date());
-							product.setCode(code);
-						}
 					} else {
                         modelMap.put("error", "第" + (r + 1) + "行物料型号未填写");
                         return modelMap;

+ 7 - 15
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -349,12 +349,10 @@ public class VendorsServiceImpl implements VendorService {
 		System.out.println("进入方法:" + System.currentTimeMillis());
 		final Long enUU = SystemSession.getUser().getEnterprise().getUu();
 		String cmpCodesSql = concatProductCondition(enUU, productMatchCondition, productCondition);
-		System.out.println("查找物料语句拼接完成:" + System.currentTimeMillis());
 //		// 根据标准料号找出对应的供应商UU
 //		String vendUUsSql = "select distinct(ve_vendenuu) from purc$vendors left join v$products on pr_enuu = ve_vendenuu" +
 //				" where ve_myenuu = " + enUU + " and pr_issale = 1 and pr_cmpcode in (" + cmpCodesSql + ")";
 		// 采购物料原厂型号
-		System.out.println(cmpCodesSql);
 //		final List<String> cmpCodes = commonDao.queryForList(cmpCodesSql.toString(), String.class);
 		// rownum 控制
 		String rownumSql = ") t where rownum <= " + page * size + ") where r1 > " + (page - 1) * size;
@@ -382,16 +380,14 @@ public class VendorsServiceImpl implements VendorService {
 				" select distinct(en_uu) from (").append(enUUSql).append(")) group by en_uu order by count(pr_issale) desc) b");
 		vendorRecommendUusSql.append(" union all ").append(enterpriseProdSaleSql);
 		vendorRecommendUusSql.append(rownumSql);
-		System.out.println("SQL:" + vendorRecommendUusSql.toString());
-		System.out.println("NUM_SQL:" + vendorRecommendUuNumSql.toString());
+//		System.out.println("SQL:" + vendorRecommendUusSql.toString());
+//		System.out.println("NUM_SQL:" + vendorRecommendUuNumSql.toString());
 		// 因为需求更改为所有有销售产品的企业都会被返回,所以total直接取除本企业外其他有销售产品的企业数即可,之前的匹配企业数不再返回
 		StringBuffer totalSql = new StringBuffer().append(" select count(1) from (select en_uu from sec$enterprises left join " +
 				" v$products on en_uu = pr_enuu where pr_issale = 1 and pr_b2bdisabled <> 1 and en_uu <> ")
 				.append(enUU).append(" group by en_uu)");
-		System.out.println("所有语句拼接完成:" + System.currentTimeMillis());
 		Integer total = commonDao.queryForObject(totalSql.toString(), Integer.class);
 		List<Long> vendUUs = commonDao.queryForList(vendorRecommendUusSql.toString(), Long.class);
-		System.out.println("查找出所有推荐企业UU:" + System.currentTimeMillis());
 		return getVendorRecommendByVendUUs(enUU, vendUUs, page, size, total);
 	}
 
@@ -449,10 +445,7 @@ public class VendorsServiceImpl implements VendorService {
 	 */
 	private com.uas.account.support.Page<VendorRecommend> getVendorRecommendByVendUUs(Long enUU, List<Long> vendUUs, int page, int size, Integer total) {
 		List<VendorRecommend> content = new ArrayList<>();
-		int i = 0;
 		for (final Long vendUU : vendUUs) {
-			i = i+ 1;
-			System.out.println("开始处理第" + i + "条数据:" + System.currentTimeMillis());
 			Enterprise vendor = enterPriseDao.findOne(vendUU);
 			if (null != vendor) {
 //				if (null != vendor.getEnAdminuu()) {
@@ -471,12 +464,8 @@ public class VendorsServiceImpl implements VendorService {
 								" where p1.pr_ispurchase = 1 and (p1.pr_issale is null or p1.pr_issale = 0) " +
 								" and p1.pr_b2bdisabled <> 1 and p1.pr_enuu = ")
 						.append(enUU).append(")");
-				System.out.println("第" + i + "条数据物料查找语句拼接完成:" + System.currentTimeMillis());
-				System.out.println(productIdsSql.toString());
-				System.out.println(productNumSql.toString());
 				List<Long> prodIds = commonDao.queryForList(productIdsSql.toString(), Long.class);
 				Integer hitNums = commonDao.queryForObject(productNumSql.toString(), Integer.class);
-				System.out.println("第" + i + "条数据匹配物料id及数量查找完成:" + System.currentTimeMillis());
 				// 获取前五条匹配物料
 				List<Product> hitsProducts = productDao.findAll(prodIds);
 				VendorRecommend vendorRecommend = new VendorRecommend();
@@ -489,10 +478,11 @@ public class VendorsServiceImpl implements VendorService {
 				} else {
 					vendorRecommend.setIsVendor(Constant.NO);
 				}
-				System.out.println("第" + i + "条数据处理完毕,添加到content:" + System.currentTimeMillis());
 				content.add(vendorRecommend);
 			}
+			System.out.println("处理完一条数据:" + System.currentTimeMillis());
 		}
+		System.out.println("处理完所有数据:" + System.currentTimeMillis());
 		// 返回分页信息
 		return new com.uas.account.support.Page<VendorRecommend>(page, size, content, total);
 	}
@@ -509,6 +499,7 @@ public class VendorsServiceImpl implements VendorService {
 	 */
 	@Override
 	public com.uas.account.support.Page<Product> getProductsByVendorRecommend(int page, int size, Long vendUU, String productMatchCondition, String whereCondition) {
+		System.out.println("进入方法:" + System.currentTimeMillis());
 		// UAS企业UU
 		Long enUU = SystemSession.getUser().getEnterprise().getUu();
 		// 先查询当前企业的采购物料(待购&&不在售)的标准物料标准料号
@@ -537,7 +528,7 @@ public class VendorsServiceImpl implements VendorService {
 		String rownumSql = " t where rownum <= " + page * size + ") where r1 > " + (page - 1) * size;
 		idSql.append("select pr_id from (select t.*,rownum as r1 from (").append(productsMatchSql).append(" union all ").append(notMatchProductsSql)
 				.append(")").append(rownumSql);
-		System.out.println(idSql.toString());
+//		System.out.println(idSql.toString());
 		Integer count = commonDao.queryForObject(countSql, Integer.class);
 		List<Long> ids = commonDao.queryForList(idSql.toString(), Long.class);
 		List<Product> products = new ArrayList<>();
@@ -545,6 +536,7 @@ public class VendorsServiceImpl implements VendorService {
 		    Product product = productDao.findOne(id);
 		    products.add(product);
         }
+		System.out.println("返回数据:" + System.currentTimeMillis());
 		return new com.uas.account.support.Page<>(page, size, products, count);
 	}
 

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

@@ -23080,6 +23080,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             var modalInstance = $modal.open({
                 templateUrl: 'static/tpl/index/approvalFlow/modal/uplodaByBatch.html',
                 controller: 'UserProdUploadCtrl',
+                backdrop: 'static',
+                keyboard: false,
                 size: 'lg',
                 resolve: {}
             });

+ 4 - 3
src/main/webapp/resources/tpl/index/approvalFlow/modal/uplodaByBatch.html

@@ -12,8 +12,9 @@
 	<i></i>
 </div>
 <div class="modal-header Deputy" style="min-height: 50px;">
-	<div class="content f16 text-bold">批量导入 
-		<a style="padding-left: 780px;" ng-click="cancel()"><i class="fa fa-close"></i></a>
+	<div class="content f16 text-bold">批量导入
+		<span class="f12" style="color:#55b6ff;"><i class="fa fa-info-circle"></i>单次上传不超过20000条</span>
+		<a style="float:right; padding-right: 30px;" ng-click="cancel()"><i class="fa fa-close"></i></a>
 	</div>
 </div>
 <div class="modal-body Deputy" style="min-height: 200px;">
@@ -58,7 +59,7 @@
 	</div>
 	<div class="content f14 text-bold">第三步、信息提示</div>
 	<div class="box-item">
-		<p ng-if="result.total">
+		<p ng-if="null != result.total && result.total > 0">
 			<span>总共上传{{result.total}}个,成功{{result.success}}个</span>
 		</p>
 		<p ng-if="result.existed.length > 0">

+ 4 - 2
src/main/webapp/resources/tpl/index/baseInfo/uploadByBatch.html

@@ -245,7 +245,9 @@ table.table.table-striped  thead {
 	</div>
 	<div class="headerline">
 		<div class="index"></div>
-		<div class="content f16 text-bold">第一步、下载Excel模板</div>
+		<div class="content f16 text-bold">第一步、下载Excel模板
+			<span class="f12" style="color:#55b6ff;"><i class="fa fa-info-circle"></i>单次上传不超过5000条</span>
+		</div>
 	</div>
 	<div class="box-item" ng-hide="box1Closed">
 		<p>
@@ -300,7 +302,7 @@ table.table.table-striped  thead {
 	</div>
 	<div class="box-item" ng-hide="box3Closed">
 		<p ng-if="result">
-		<div ng-if="result">
+		<div ng-if="null != result.total && result.total > 0">
 			总共上传物料<span class="text-inverse">{{result.total}}</span>个,上传成功<span class="text-inverse">{{result.success || 0}}</span>个
 		</div>
 		<div ng-repeat="alter in alters">

+ 14 - 0
src/main/webapp/resources/tpl/index/home/pagingRelease.html

@@ -170,6 +170,20 @@
                 <th width="80">阅读状态</th>
             </tr>
         </thead>
+        <tbody ng-if="tableParams.total() == 0">
+            <tr>
+                <td colspan="6">
+                    <div class="row text-muted info-container" style="padding: 50px 10px;">
+                        <div>
+                            <br>
+                            <br>
+                            <div><img src="static/img/all/info.png" width="130px" height="90px"></div>
+                            <div class="f16">当前没有对应的消息!</div>
+                        </div>
+                    </div>
+                </td>
+            </tr>
+        </tbody>
         <tbody>
         <tr ng-repeat="releaseDetail in $data | orderBy: 'isRead'">
             <td>

+ 1 - 1
src/main/webapp/resources/tpl/index/purc/modal/purc_uplodaByBatch.html

@@ -9,7 +9,7 @@
 }
 </style>
 <div class="modal-header Deputy" style="min-height: 50px;">
-	<div class="content f16 text-bold">批量导入 
+	<div class="content f16 text-bold">批量导入
 		<a style="padding-left: 780px;" ng-click="cancel()"><i class="fa fa-close"></i></a>
 	</div>
 </div>

+ 2 - 2
src/main/webapp/resources/tpl/index/purc/modal/uplodaByBatch.html

@@ -9,7 +9,7 @@
 }
 </style>
 <div class="modal-header Deputy" style="min-height: 50px;">
-	<div class="content f16 text-bold">批量导入 
+	<div class="content f16 text-bold">批量导入
 		<a style="padding-left: 780px;" ng-click="cancel()"><i class="fa fa-close"></i></a>
 	</div>
 </div>
@@ -46,7 +46,7 @@
 					<button ng-click="upload()" class="btn btn-success btn-sm">
 						确认上传 <i class="fa fa-upload"></i>
 					</button>
-				</div class="col-xs-4">
+				</div>
 			</div>
 			<div>
 			</div>

+ 4 - 2
src/main/webapp/resources/tpl/index/purc/uploadByBatch.html

@@ -245,7 +245,9 @@ table.table.table-striped  thead {
 	</div>
 	<div class="headerline">
 		<div class="index"></div>
-		<div class="content f16 text-bold">第一步、下载Excel模板</div>
+		<div class="content f16 text-bold">第一步、下载Excel模板
+			<span class="f12" style="color:#55b6ff;"><i class="fa fa-info-circle"></i>单次上传不超过5000条</span>
+		</div>
 	</div>
 	<div class="box-item" ng-hide="box1Closed">
 		<p>
@@ -315,7 +317,7 @@ table.table.table-striped  thead {
 	</div>
 	<div class="box-item" ng-hide="box3Closed">
 		<p ng-if="result">
-			<div ng-if="result">
+			<div ng-if="null != result.total && result.total > 0">
 				总共上传物料<span class="text-inverse">{{result.total}}</span>个,上传成功<span class="text-inverse">{{result.success || 0}}</span>个
 			</div>
 			<div ng-repeat="alter in alters">