Browse Source

上架临时表增加序号字段
保存物料时将物料主键设置到上架临时表

yujia 7 years ago
parent
commit
04d257cf0e

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

@@ -414,13 +414,13 @@ public class ReleaseProductByBatchController {
         ModelAndView modelAndView = new ModelAndView();
         logger.log("商品批次", "下载批量上架商品的Excel模板");
         if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
-            modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releaseByBatch-person", "个人产品导入模板-优软商城"));
+            modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releaseByBatch-person", "导入产品-优软商城"));
             return modelAndView;
         }
         if (Currency.USD.equals(currency)) {
-            modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releasebyBatch-usd", "产品导入模板-优软商城"));
+            modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releasebyBatch-usd", "导入产品并上架-优软商城"));
         } else {
-            modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releaseByBatch-rmb", "产品导入模板-优软商城"));
+            modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/trade/releaseByBatch-rmb", "导入产品并上架-优软商城"));
         }
         return modelAndView;
     }

+ 15 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java

@@ -566,6 +566,12 @@ public class ReleaseProductByBatch implements Serializable {
 	@Column(name = "rel_goods_count")
 	private Integer goodsCount = 0;
 
+	/**
+	 *  第几条
+	 */
+	@Column(name = "rel_num")
+	private Integer num;
+
 //	private Short repeat;
 
 	@Override
@@ -1855,6 +1861,15 @@ public class ReleaseProductByBatch implements Serializable {
 		return this;
 	}
 
+	public Integer getNum() {
+		return num;
+	}
+
+	public ReleaseProductByBatch setNum(Integer num) {
+		this.num = num;
+		return this;
+	}
+
 	@Override
 	public String toString() {
 		return "ReleaseProductByBatch{" +

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

@@ -1054,7 +1054,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	private int convertValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isAPerson, boolean isPcb) {
 		// 统计为空的个数
 		int result = 0;
-
+		aProduct.setNum(rowNum - 2);
 		Object brandValue = readWorkBookCell(row.getCell(UploadConstant.BRAND_ENGLISH), Cell.CELL_TYPE_STRING,
 				rowNum, UploadConstant.BRAND_ENGLISH);
 		if (StringUtils.isEmpty(brandValue)) {
@@ -1829,6 +1829,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 					// releaseProductByBatch.getCode(); 在公有库生成
 					prodNum = "PNUM" + time + CreateNumberServiceImpl.formatIntToStr(++num, 8);
 					product.setProdNum(prodNum);
+					releaseProductByBatch.setProductNum(prodNum);
 					products.add(product);
 				} else {
 					//对于已经存在于物料库的信息,如果规格信息已存在,则做更新,如果是
@@ -1863,6 +1864,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 
             }
 		}
+		List<ReleaseProductByBatch> reList = new ArrayList<>();
 		if (products.size() != 0) {
 			List<Product> productes = productDao.save(products);
 			for (Product producte : productes) {
@@ -1873,8 +1875,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				productPrivates.add(productPrivate);
 
 				prIds.add(producte.getId());
+
+				for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchList) {
+					if (StringUtilB2C.equals(releaseProductByBatch.getProductNum(), producte.getProdNum())) {
+						releaseProductByBatch.setProductid(producte.getId());
+						reList.add(releaseProductByBatch);
+					}
+				}
 			}
 		}
+		if (CollectionUtils.isNotEmpty(reList)) {
+			releaseProductByBatchDao.save(reList);
+		}
 		if (CollectionUtils.isNotEmpty(productPrivates)) {
 			productPrivateService.saveProductPrivate(productPrivates);
 		}