Browse Source

处理导入重复的显示问题

hulh 8 years ago
parent
commit
2d26bbecf5

+ 2 - 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列:产品型号不能为空"),
@@ -23,7 +23,7 @@ public enum  ErrorInfoConstant {
     DELIVERY_VALUE_INFO("G-H列:交期只能填写1-31之间的整数值"),
     PRICE_INFO("K列:单价必须是小于1万的正数"),
     MIN_PACKAGE_INFO("I列:最小包数量包含非数字字符"),
-    REPEAT_IN_EXCEL("");
+    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();
         }

+ 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获取一组产品的信息

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

@@ -123,13 +123,17 @@ 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();
 		// 获取第一个工作表
 		Sheet sheet = workbook.getSheetAt(0);
@@ -202,7 +206,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			}
 		}
 		if (!isAPerson) {
-			resetRepeatData(releaseProductByBatchs);
+			resetRepeatData(releaseProductByBatchs, isImport);
 		}
 		commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
 		Long userUU = SystemSession.getUser().getUserUU();
@@ -234,14 +238,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 
 	/**
 	 * 判断是否重复,重复则重设状态
-	 * @param data
+	 * @param 	data
+	 * @param 	isImport
 	 */
-	private void resetRepeatData(List<ReleaseProductByBatch> data) {
+	private void resetRepeatData(List<ReleaseProductByBatch> data, Boolean isImport) {
 		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());
@@ -250,6 +258,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			List<Product> productList = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(enuu, each.getB2cCode(), each.getB2cBranden(), IntegerConstant.YES_SHORT);
 			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 (!isImport) {
+					each.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
+					each.setReleaseCode(ReleaseStatus.had_exists.value());
+					each.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+					continue;
+				}
 				if (!CollectionUtils.isEmpty(goodsList)) {
 					for (Goods goods1 : goodsList) {
 						if (GoodsUtil.compareWithQtyPrice(each.getPrices(), goods1.getPrices(), each.getCurrency())) {