Procházet zdrojové kódy

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

wangdy před 8 roky
rodič
revize
718889bb6a

+ 3 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/constant/ErrorInfoConstant.java

@@ -6,7 +6,7 @@ package com.uas.platform.b2c.prod.commodity.constant;
  * @author hulh
  */
 public enum  ErrorInfoConstant {
-    REPEAT_INFO("产品库已存在产品"),
+    REPEAT_INFO("产品库已存在相同的产品"),
     CODE_PATTERN_INFO("A列:请勿输入中文或中文特殊字符"),
     CODE_LENGTH_INFO("A列:产品型号不能超过100字符"),
     CODE_EMPTY_INFO("A列:产品型号不能为空"),
@@ -22,7 +22,8 @@ public enum  ErrorInfoConstant {
     DELIVERY_EMPTY_INFO("G-H列:存在交期的信息为空"),
     DELIVERY_VALUE_INFO("G-H列:交期只能填写1-31之间的整数值"),
     PRICE_INFO("K列:单价必须是小于1万的正数"),
-    MIN_PACKAGE_INFO("I列:最小包数量包含非数字字符");
+    MIN_PACKAGE_INFO("I列:最小包数量包含非数字字符"),
+    REPEAT_IN_EXCEL("表格中已存在相同的产品");
 
     /**
      * 错误提示

+ 2 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ReleaseProductByBatchController.java

@@ -203,7 +203,7 @@ public class ReleaseProductByBatchController {
      * @return model map
      */
     @RequestMapping(value = "/release/excel", method = RequestMethod.POST)
-    public ModelMap releaseByExcel(FileUpload uploadItem, @RequestParam("selfSale") Boolean selfSale, String currency, Integer isPerson) {
+    public ModelMap releaseByExcel(FileUpload uploadItem, @RequestParam("selfSale") Boolean selfSale, String currency, Integer isPerson, Integer repeatImport) {
         ModelMap map = new ModelMap();
         String fileName = uploadItem.getFile().getOriginalFilename();
         String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
@@ -218,7 +218,7 @@ public class ReleaseProductByBatchController {
             } else {
                 throw new IllegalOperatorException("文件格式不正确!请上传.xls或.xlsx格式的文件");
             }
-            map = releaseProductByBatchService.releaseByWorkbook(workbook, selfSale, currency, isPerson);
+            map = releaseProductByBatchService.releaseByWorkbook(workbook, selfSale, currency, isPerson, repeatImport);
         } catch (IOException e) {
             e.printStackTrace();
         }

+ 5 - 3
src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java

@@ -473,6 +473,8 @@ public class ReleaseProductByBatch implements Serializable {
 	@Column(name = "rel_storename")
 	private String storeName;
 
+//	private Short repeat;
+
 	@Override
 	public boolean equals(Object o) {
 		if (this == o) return true;
@@ -487,9 +489,9 @@ public class ReleaseProductByBatch implements Serializable {
 		if (!minPackageStr.equals(that.minPackageStr)) return false;
 		if (!packaging.equals(that.packaging)) return false;
 		if (!selfMaxDeliveryStr.equals(that.selfMaxDeliveryStr)) return false;
-		if (!selfMinDeliveryStr.equals(that.selfMinDeliveryStr)) return false;
-		return GoodsUtil.compareWithQtyPrice(prices, that.getPrices(), that.getCurrency());
-
+//		if (!selfMinDeliveryStr.equals(that.selfMinDeliveryStr)) return false;
+//		return GoodsUtil.compareWithQtyPrice(prices, that.getPrices(), that.getCurrency());
+		return selfMinDeliveryStr.equals(that.selfMinDeliveryStr);
 	}
 
 	public void setBrandEnByExcel(Object value) {

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/ReleaseProductByBatchService.java

@@ -33,7 +33,7 @@ public interface ReleaseProductByBatchService {
      * @param currency
      * @return model map
      */
-    public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson);
+    public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport);
 
     /**
      * 根据发布者UU获取一组产品的信息

+ 55 - 9
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -2,7 +2,6 @@ package com.uas.platform.b2c.prod.commodity.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.uas.platform.b2c.common.account.model.Enterprise;
-import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.common.base.dao.CommonDao;
 import com.uas.platform.b2c.core.config.SysConf;
@@ -16,7 +15,11 @@ import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
 import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
 import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
-import com.uas.platform.b2c.prod.commodity.dao.*;
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
+import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
+import com.uas.platform.b2c.prod.commodity.dao.ProductPersonDao;
+import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
+import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
 import com.uas.platform.b2c.prod.commodity.model.*;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
 import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
@@ -26,7 +29,6 @@ import com.uas.platform.b2c.prod.store.model.StoreIn;
 import com.uas.platform.b2c.prod.store.model.StoreStatus;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.order.StringConstant.Currency;
-import com.uas.platform.b2c.trade.presale.model.Collection;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
@@ -123,15 +125,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	 * @author hejq
 	 */
 	@Override
-	public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson) {
+	public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport) {
 		// 是否上传个人物料
 		boolean isAPerson = false;
+		boolean isImport = false;
 		if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
 			isAPerson = true;
 			selfSale = false;
 		}
+		if (null != repeatImport && IntegerConstant.YES_SHORT.equals(repeatImport)) {
+			isImport = true;
+		}
 		ModelMap modelMap = new ModelMap();
-		Set<ReleaseProductByBatch> releaseProductByBatchs = new HashSet<>();
 		// 获取第一个工作表
 		Sheet sheet = workbook.getSheetAt(0);
 		int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
@@ -149,6 +154,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			throw new IllegalOperatorException
 					("您上传的信息超过2000条,请拆分成2000以再在上传");
 		}
+		List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
 		String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
 		StoreIn storeIn = getStoreInfo(selfSale);
 		Row headerRow = sheet.getRow(0);
@@ -191,6 +197,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 								releaseProductByBatch.setTag(null);
 							}
 						}
+						validateRepeatInExcel(releaseProductByBatchs, releaseProductByBatch, isImport);
 					}
 					// 简单验证数据,防止空行保存的情况
 					if (blankNum != 3) {
@@ -204,7 +211,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		Long enUU = SystemSession.getUser().getEnterprise().getUu();
 		List<ReleaseProductByBatch> addList = new ArrayList<>(releaseProductByBatchs.size());
 		addList.addAll(releaseProductByBatchs);
-		resetRepeatData(addList, isAPerson);
+		resetRepeatData(addList, isImport, isAPerson);
 		if (isAPerson) {
 			for (ReleaseProductByBatch releaseProductByBatch : addList) {
 				List<Product> productList = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(enUU,releaseProductByBatch.getB2cCode(),
@@ -234,16 +241,49 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		return modelMap;
 	}
 
+	/**
+	 * 验证Excel中数据是否重复
+	 *
+	 * @param 	batchList
+	 * @param 	aBatch
+	 * @param 	isImport
+	 */
+	private void validateRepeatInExcel(List<ReleaseProductByBatch> batchList, ReleaseProductByBatch aBatch, Boolean isImport) {
+		if (CollectionUtils.isEmpty(batchList) || !StringUtils.isEmpty(aBatch.getErrmsg()))
+			return ;
+		for (ReleaseProductByBatch each : batchList) {
+			if (StringUtils.isEmpty(each.getErrmsg()) && each.equals(aBatch)) {
+				if (!isImport) {
+					aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
+					aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
+					aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+					break;
+				} else {
+					if (GoodsUtil.compareWithQtyPrice(each.getPrices(), aBatch.getPrices(), each.getCurrency())) {
+						aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
+						aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
+						aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+						break;
+					}
+				}
+			}
+		}
+	}
+
 	/**
 	 * 判断是否重复,重复则重设状态
-	 * @param data
+	 * @param 	data
+	 * @param 	isImport
 	 */
-	private void resetRepeatData(List<ReleaseProductByBatch> data, boolean isAPerson) {
+	private void resetRepeatData(List<ReleaseProductByBatch> data, Boolean isImport, boolean isAPerson) {
 		Long enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
 		if (enuu == null) {
 			throw new IllegalOperatorException("企业enuu丢失");
 		}
 		for (ReleaseProductByBatch each : data) {
+			if (StringUtils.hasText(each.getErrmsg())) {
+				continue;
+			}
 			List<Product> standardList = productDao.findMatchStandard(enuu, each.getBrandNameEn(), each.getCode(), IntegerConstant.YES_SHORT);
 			if (!CollectionUtils.isEmpty(standardList)) {
 				each.setB2cBranden(standardList.get(0).getPbranden());
@@ -256,6 +296,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			if (!CollectionUtils.isEmpty(productList)) {
 				List<Goods> goodsList = goodsDao.findRepeatGoodsInProductId(productList.get(0).getId(), each.getProductDate(), each.getPackaging(), each.getMinPackage(), each.getMinBuyQty(), each.getSelfMaxDelivery(), each.getSelfMinDelivery(), each.getUnit());
 				if (!CollectionUtils.isEmpty(goodsList)) {
+					if (!isImport) {
+						each.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
+						each.setReleaseCode(ReleaseStatus.had_exists.value());
+						each.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+						continue;
+					}
 					for (Goods goods1 : goodsList) {
 						if (GoodsUtil.compareWithQtyPrice(each.getPrices(), goods1.getPrices(), each.getCurrency())) {
 							each.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
@@ -274,7 +320,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	 * @param aProduct 单个产品
 	 * @param productSet 产品列表
 	 */
-	private Boolean validateTagInfo(ReleaseProductByBatch aProduct, Set<ReleaseProductByBatch> productSet) {
+	private Boolean validateTagInfo(ReleaseProductByBatch aProduct, List<ReleaseProductByBatch> productSet) {
 		for (ReleaseProductByBatch each : productSet) {
 			if (aProduct.getBrandNameEn().equals(each.getBrandNameEn()) && aProduct.getCode().equals(each.getCode())
 					&& aProduct.getTag().equals(each.getTag())) {

+ 56 - 50
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_upload_ctrl.js

@@ -38,6 +38,12 @@ define([ 'app/app' ], function(app) {
         //批量发布的类型
         $scope.batch.sellType = null;
 
+
+        $scope.repeatImport = 0;
+		$scope.switchImport = function (type) {
+			$scope.repeatImport = type;
+		};
+
         //翻页的信息
         $scope.pageParams = {};
 
@@ -199,56 +205,56 @@ define([ 'app/app' ], function(app) {
             }
         };
 
-        // 上传Excel批量发布(大量)
-        $scope.upload = function() {
-            if(($scope.batch.myFiles == null) || ($scope.batch.myFiles.length == 0)) {
-                return ;
-            }
-            var file = $scope.batch.myFiles[0];
-            if(!file) {
-                toaster.pop('info', '请选择需要上传的文件');
-                return;
-            }
-            if ($rootScope.$$productOn.tab === 'bathOnPerson') {
-                var param = {selfSale : $scope.batch.sellType == 'self', currency : $scope.batch.currency, isPerson : 1};
-            } else {
-                var param = {selfSale : $scope.batch.sellType == 'self', currency : $scope.batch.currency};
-            }
-            $upload.upload({
-                url: 'release/product/release/excel',
-                file: file,
-                method: 'POST',
-                params : param
-            }).success(function(data) {
-                $scope.selectFile(' ');
-                $scope.batch.myFiles = [];
-                $scope.proInfo = data.info;
-                $scope.result = data;
-                $scope.hadImport = false;
-                // var message = "";
-                // if($scope.result.success) {
-                // 	message = '标准产品' + $scope.result.success + '个';
-                // }
-                // if($scope.result.failure) {
-                // 	if(message) {
-                // 		message = message + ',非标产品' + $scope.result.failure +  '个';
-                // 	}else {
-                // 		message = '非标产品' + $scope.result.failure +  '个';
-                // 	}
-                // }
-                // if($scope.result.filter) {
-                // 	if(message) {
-                // 		message = message + ',过滤' + $scope.result.filter +  '条';
-                // 	}else {
-                // 		message = '过滤' + $scope.result.filter +  '条';
-                // 	}
-                // }
-                // if(!message) {
-                // 	message = '没有提交任何信息'
-                // }
-                toaster.pop('info', '提示', '上传完成');
-                $scope.relTableParams.page(1);
-                $scope.relTableParams.reload();
+		// 上传Excel批量发布(大量)
+		$scope.upload = function() {
+			if(($scope.batch.myFiles == null) || ($scope.batch.myFiles.length == 0)) {
+				return ;
+			}
+			var file = $scope.batch.myFiles[0];
+			if(!file) {
+				toaster.pop('info', '请选择需要上传的文件');
+				return;
+			}
+			if ($rootScope.$$productOn.tab === 'bathOnPerson') {
+				var param = {selfSale : $scope.batch.sellType == 'self', currency : $scope.batch.currency, isPerson : 1};
+			} else {
+                var param = {selfSale : $scope.batch.sellType == 'self', currency : $scope.batch.currency, repeatImport : $scope.repeatImport};
+			}
+			$upload.upload({
+				url: 'release/product/release/excel',
+				file: file,
+				method: 'POST',
+				params : param
+			}).success(function(data) {
+				$scope.selectFile(' ');
+				$scope.batch.myFiles = [];
+				$scope.proInfo = data.info;
+				$scope.result = data;
+				$scope.hadImport = false;
+				// var message = "";
+				// if($scope.result.success) {
+				// 	message = '标准产品' + $scope.result.success + '个';
+				// }
+				// if($scope.result.failure) {
+				// 	if(message) {
+				// 		message = message + ',非标产品' + $scope.result.failure +  '个';
+				// 	}else {
+				// 		message = '非标产品' + $scope.result.failure +  '个';
+				// 	}
+				// }
+				// if($scope.result.filter) {
+				// 	if(message) {
+				// 		message = message + ',过滤' + $scope.result.filter +  '条';
+				// 	}else {
+				// 		message = '过滤' + $scope.result.filter +  '条';
+				// 	}
+				// }
+				// if(!message) {
+				// 	message = '没有提交任何信息'
+				// }
+				toaster.pop('info', '提示', '上传完成');
+				$scope.relTableParams.page(1);
+				$scope.relTableParams.reload();
                 if ($rootScope.$$productOn.tab === 'bathOnPerson') {
                     publicPersonProduct();
                 }

+ 14 - 1
src/main/webapp/resources/view/vendor/forstore/vendor_upload.html

@@ -510,7 +510,20 @@
                                 <img ng-hide="batch.sellType == 'UAS'" src="static/img/upload/ziying-active.png" alt="">
                             </span>
                         </div>
-                        <div><span ng-if="$$productOn.tab == 'bathOn'">2、</span>请上传已经编辑好的库存表格,选择好上传的文件之后,点击确认上传</div>
+                        <div ng-if="$$productOn.tab == 'bathOn'">2、若存在属性完全相同但价格不一致的产品:</div>
+                        <div class="sale-label" style="margin-top: -10px;" ng-if="$$productOn.tab == 'bathOn'">
+                            <label class="sellType">
+                                <input type="radio" name="import" id="forIgnore" ng-model="repeatImport" value="0" ng-click="switchImport(0)">
+                                <label for="forIgnore"></label>
+                                <span>忽略不导入</span>
+                            </label>
+                            <label class="sellType">
+                                <input type="radio" name="import" id="forImport" ng-model="repeatImport" value="1" ng-click="switchImport(1)">
+                                <label for="forImport"></label>
+                                <span>作为新产品继续导入</span>
+                            </label>
+                        </div>
+                        <div><span ng-if="$$productOn.tab == 'bathOn'">3、</span>请上传已经编辑好的库存表格,选择好上传的文件之后,点击确认上传</div>
                         <div class="upload">
                             <div class="upload-content">
                                 <input type="text" name="txt" id="upload_text" />