Browse Source

处理批量修改物料的接口

yujia 7 years ago
parent
commit
e050a465b9

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

@@ -1482,20 +1482,17 @@ public class ReleaseProductByBatch implements Serializable {
 
 	public Goods releaseProductByBatchConvertToGoods(ReleaseProductByBatch releaseProductByBatch) {
 		Goods goods = new Goods();
-		goods.setBrandNameCn(releaseProductByBatch.getBrandNameEn());
+		goods.setBrandNameEn(releaseProductByBatch.getBrandNameEn());
 		goods.setCurrencyName(releaseProductByBatch.getCurrency());
 		goods.setCode(releaseProductByBatch.getCode());
 		goods.setCreatedDate(new Date());
 		goods.setUpdateDate(new Date());
 		goods.setMinDelivery(releaseProductByBatch.getSelfMinDelivery());
 		goods.setMaxDelivery(releaseProductByBatch.getSelfMaxDelivery());
-//		goods.setSelfDeliveryDemMaxTime(releaseProductByBatch.getDeliveryDemMaxTime());
-//		goods.setSelfDeliveryDemMinTime(releaseProductByBatch.getDeliveryDemMinTime());
-//		goods.setSelfDeliveryHKMaxTime(releaseProductByBatch.getDeliveryHKMaxTime());
-//		goods.setSelfDeliveryHKMinTime(releaseProductByBatch.getDeliveryHKMinTime());
 		goods.setProduceDate(releaseProductByBatch.getProductDate());
 		goods.setPublisherUU(releaseProductByBatch.getPublisherUu());
 		goods.setPublisherName(releaseProductByBatch.getPublisherName());
+		goods.setPublishPhone(releaseProductByBatch.getPublisherTel());
 		goods.setMinBuyQty(releaseProductByBatch.getMinBuyQty());
 		goods.setMinPackQty(releaseProductByBatch.getMinPackage());
 		goods.setUuid(releaseProductByBatch.getComponentUuId());
@@ -1505,12 +1502,12 @@ public class ReleaseProductByBatch implements Serializable {
 		goods.setRmbTaxRate(releaseProductByBatch.getRmbTaxRate());
 		goods.setUsdTaxRate(releaseProductByBatch.getUsdTaxRate());
 		goods.setReserve(releaseProductByBatch.getReserve());
-		goods.setPublishPhone(releaseProductByBatch.getPublisherTel());
 		goods.setReturnInWeek(releaseProductByBatch.getReturnInWeek());
 		goods.setShipArea(releaseProductByBatch.getShipArea());
 		goods.setSampleQty(releaseProductByBatch.getSampleqty());
 		goods.setKindNameCn(releaseProductByBatch.getKindName());
 		goods.setImg(releaseProductByBatch.getImg());
+		goods.setProductid(releaseProductByBatch.getProductid());
 		return goods;
 	}
 

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

@@ -461,7 +461,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			batchList.add(aBatch);
 			total++;
 		}
-		int success = goodsFillDataToExcel(batchList);
+		int success = goodsFillDataToExcelAndUpdate(batchList);
 		Long userUU = SystemSession.getUser().getUserUU();
 //		Long enUU = SystemSession.getUser().getEnterprise().getUu();
 //		resetRepeatData(batchList, true, false);
@@ -480,7 +480,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	 * 根据批次号设置需要被修改的信息
 	 * @param batchList
 	 */
-	private Integer goodsFillDataToExcel(List<ReleaseProductByBatch> batchList) {
+	private Integer goodsFillDataToExcelAndUpdate(List<ReleaseProductByBatch> batchList) {
 		int result = 0;
 		if (CollectionUtils.isEmpty(batchList)) {
 			return result;
@@ -496,8 +496,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		if (CollectionUtils.isNotEmpty(batchCodes)) {
 			goodses = goodsService.findGoodsByBatchCodes(batchCodes);
 		}
-		for (Goods goods : goodses) {
-			for (ReleaseProductByBatch aBatch : batchList) {
+		Goods newGoods = null;
+		for (ReleaseProductByBatch aBatch : batchList) {
+			newGoods = null;
+			for (Goods goods : goodses) {
 				if (goods.getBatchCode().equals(aBatch.getBatchCode())) {
 					aBatch.setB2cBranden(goods.getBrandNameEn());
 					aBatch.setBrandNameEn(goods.getBrandNameEn());
@@ -510,30 +512,34 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 						aBatch.setReleaseStatus(ReleaseStatus.failure.getPhrase());
 					}
 					fillInGoods(goods, aBatch);
-					ResultMap resultMap = goodsService.updateGoods(goods);
-					if (resultMap.isSuccess()) {
-						Goods goods1 = (Goods) resultMap.getData();
-						if (Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
-							ResultMap offMap = goodsService.offShelfGoodsByProvider(goods.getBatchCode(), null, false);
-							if (offMap.isSuccess()) {
-								result++;
-							} else {
-								aBatch.setErrmsg(offMap.getMessage());
-								aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
-								aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
-							}
-						} else {
-							result++;
-						}
+					newGoods = goods;
+					break;
+				}
+			}
+			if (newGoods == null) {
+				newGoods = aBatch.releaseProductByBatchConvertToGoods(aBatch);
+			}
+			ResultMap resultMap = goodsService.updateGoods(newGoods);
+			if (resultMap.isSuccess()) {
+				Goods goods1 = (Goods) resultMap.getData();
+				if (Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
+					ResultMap offMap = goodsService.offShelfGoodsByProvider(newGoods.getBatchCode(), null, false);
+					if (offMap.isSuccess()) {
+						result++;
 					} else {
-						aBatch.setErrmsg(resultMap.getMessage());
+						aBatch.setErrmsg(offMap.getMessage());
 						aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
 						aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
 					}
+				} else {
+					result++;
 				}
+			} else {
+				aBatch.setErrmsg(resultMap.getMessage());
+				aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
+				aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
 			}
 		}
-
 		return result;
 	}
 
@@ -589,7 +595,27 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				continue;
 			}
 			Goods goods = goodsDao.findByBatchCode(aBatch.getBatchCode());
-
+			fillInGoods(goods, aBatch);
+			ResultMap resultMap = goodsService.updateGoods(goods);
+			if (resultMap.isSuccess()) {
+				Goods goods1 = (Goods) resultMap.getData();
+				if (Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
+					ResultMap offMap = goodsService.offShelfGoodsByProvider(goods.getBatchCode(), null, false);
+					if (offMap.isSuccess()) {
+						result++;
+					} else {
+						aBatch.setErrmsg(offMap.getMessage());
+						aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
+						aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
+					}
+				} else {
+					result++;
+				}
+			} else {
+				aBatch.setErrmsg(resultMap.getMessage());
+				aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
+				aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
+			}
 		}
 		return result;
 	}