Przeglądaj źródła

物料工具类匹配单个物料方法修改;物料删除改为禁用该物料;

dongbw 8 lat temu
rodzic
commit
7434662d58

+ 0 - 4
src/main/java/com/uas/platform/b2b/erp/service/impl/PurchaseProdInOutServiceImpl.java

@@ -97,9 +97,7 @@ public class PurchaseProdInOutServiceImpl implements PurchaseProdInOutService {
 							Product product = new Product();
 							product.setCode(item.getProdcode());
 							product.setEnUU(enUU);
-							// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 							Long proId = ProductUtils.updateOne(product);
-//							product = productDao.save(product);
 							item.setProduct(product);
 							item.setProdId(proId);
 						}
@@ -147,9 +145,7 @@ public class PurchaseProdInOutServiceImpl implements PurchaseProdInOutService {
 							Product product = new Product();
 							product.setCode(returnItem.getProdCode());
 							product.setEnUU(enUU);
-							// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 							Long proId = ProductUtils.updateOne(product);
-//							product = productDao.save(product);
 							returnItem.setProduct(product);
 							returnItem.setProdId(proId);
 						}

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

@@ -221,11 +221,8 @@ public class ProductUtils {
      * @param idList 需要匹配的物料id List
      */
     public static void matchChoose(Long enUU, List<Long > idList) throws Exception {
-        HashMap<String, Object> params = new HashMap<>();
-        params.put("enUU", enUU);
-        params.put("idList", idList);
-        Response res = HttpUtil.sendPostRequest(PRODUCT_PUBLIC_SERVICE_URL + "/product/match/selected", params);
-        if (HttpStatus.OK.value() != res.getStatusCode()) {
+        String res = HttpUtil.doPost(PRODUCT_PUBLIC_SERVICE_URL + "/product/match/selected?enUU=" + enUU, FlexJsonUtils.toJsonDeep(idList));
+        if (null == res) {
             throw new RuntimeException("匹配所选失败");
         }
     }

+ 21 - 18
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -23,7 +23,7 @@ import com.uas.platform.b2b.model.Enterprise;
 import com.uas.platform.b2b.model.EnterpriseInfo;
 import com.uas.platform.b2b.model.FileUpload;
 import com.uas.platform.b2b.model.Product;
-import com.uas.platform.b2b.model.ProductMatchResult;
+import com.uas.platform.b2b.model.ProductStatus;
 import com.uas.platform.b2b.model.PurchaseOrderAll;
 import com.uas.platform.b2b.model.PurchaseOrderAllItem;
 import com.uas.platform.b2b.model.Role;
@@ -223,9 +223,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 						Product oldProd = prods.get(0);
 						if (oldProd.getIsSale() == null) {
 							oldProd.setIsSale(Constant.YES);
-                            // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
-                            ProductUtils.updateOne(product);
-//							productDao.save(oldProd);
+                            ProductUtils.updateOne(oldProd);
 						}
 						alters.add(product.getCode());
 						product.setCode(null);
@@ -256,7 +254,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 			}
 			if (!CollectionUtils.isEmpty(products)) {
 				try {
-					products = productDao.save(products);
+					ProductUtils.update(products);
 //					saveUserOrders(products);
 					modelMap.put("success", products.size());
 				} catch (Exception e) {
@@ -342,7 +340,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 			prodInfo.setStandard(Constant.NO);
 		}
 		prodInfo.setErpDate(new Date());
-		prodInfo = productDao.save(prodInfo);
+		ProductUtils.updateOne(prodInfo);
 //		saveUserOrders(prodInfo);
 		map.put("success", "更新成功");
 		return map;
@@ -399,9 +397,8 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 			prodInfo.setEnUU(SystemSession.getUser().getEnterprise().getUu());
 			prodInfo.setSourceApp("B2B");
 			prodInfo.setErpDate(new Date());
-			prodInfo = productDao.save(prodInfo);
-//			saveUserOrders(prodInfo);
-			map.put("id", prodInfo.getId());
+			Long prId = ProductUtils.updateOne(prodInfo);
+			map.put("id", prId);
 			map.put("success", "物料添加成功");
 		}
 		return map;
@@ -439,17 +436,23 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 		return product;
 	}
 
+	/**
+	 * 删除物料,设置成disabled
+	 * @param id 物料id
+	 */
 	@Override
 	public void deleteById(Long id) throws Exception {
-		if (productDao.exists(id)) {
-			// 先删除匹配结果的id
-			List<ProductMatchResult> results = productMatchResultDao.findByPrid(id);
-			if (!CollectionUtils.isEmpty(results)) {
-				productMatchResultDao.delete(results);
-			}
-			// 需要删除个人物料库的数据
-            deleteUserProduct(id);
-			productDao.delete(id);
+		Product product = productDao.findOne(id);
+		if (null != product) {
+			ProductUtils.deleteMatchResultAndProductUser(id);
+			// 物料禁用
+			ProductStatus productStatus = new ProductStatus();
+			productStatus.setProduct(product);
+			productStatus.setB2bDisabled(Constant.YES);
+			productStatusDao.save(productStatus);
+			product.setIsPurchase(Constant.NO);
+			product.setIsSale(Constant.NO);
+			ProductUtils.updateOne(product);
 		}
 	}
 

+ 1 - 19
src/main/java/com/uas/platform/b2b/service/impl/ProductServiceImpl.java

@@ -83,7 +83,6 @@ public class ProductServiceImpl implements ProductService {
 
 	@Override
 	public void save(List<Product> products) throws Exception {
-		// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 		ProductUtils.update(products);
 	}
 
@@ -108,12 +107,10 @@ public class ProductServiceImpl implements ProductService {
 
 	@Override
 	public void unlock(Long id) {
-		// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 		try {
             Product prod = productDao.findOne(id);
             prod.setIsSale(Constant.YES);
             ProductUtils.switchProduct(id, "sale", Constant.YES);
-//            productDao.save(prod);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -122,12 +119,10 @@ public class ProductServiceImpl implements ProductService {
 
 	@Override
 	public void lock(Long id) {
-		// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 		try {
             Product prod = productDao.findOne(id);
             prod.setIsSale(Constant.YES);
             ProductUtils.switchProduct(id, "sale", Constant.NO);
-//            productDao.save(prod);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -135,12 +130,10 @@ public class ProductServiceImpl implements ProductService {
 
 	@Override
 	public void unlockPurc(Long id) {
-		// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 		try {
 			Product prod = productDao.findOne(id);
 			prod.setIsPurchase(Constant.YES);
             ProductUtils.switchProduct(id, "purc", Constant.YES);
-//            productDao.save(prod);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -148,12 +141,10 @@ public class ProductServiceImpl implements ProductService {
 
 	@Override
 	public void lockPurc(Long id) {
-		// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 		try {
 			Product prod = productDao.findOne(id);
 			prod.setIsPurchase(Constant.NO);
             ProductUtils.switchProduct(id, "purc", Constant.NO);
-//            productDao.save(prod);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -166,21 +157,15 @@ public class ProductServiceImpl implements ProductService {
 			for (Product prod : products) {
 				if (updatetype.equals(UpdateType.BRANDUPDATE.getPhrase())) {
 					prod.setBrand(keyword);
-					// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 					ProductUtils.updateOne(prod);
-//					productDao.save(prod);
 				} else if (updatetype.equals(UpdateType.PRODSPECUPDATE.getPhrase())
 						|| updatetype.equals(UpdateType.MATERSPECUPDATE.getPhrase())) {
 					prod.setSpec(keyword);
 					prod.setCmpCode(keyword);
-					// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 					ProductUtils.updateOne(prod);
-//					productDao.save(prod);
 				} else if (updatetype.equals(UpdateType.TITLEUPDATE.getPhrase())) {
 					prod.setTitle(keyword);
-					// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 					ProductUtils.updateOne(prod);
-//					productDao.save(prod);
 				}
 			}
 			map.put("success", updatetype + "修改成功");
@@ -345,9 +330,9 @@ public class ProductServiceImpl implements ProductService {
                 productStatus.setB2bDisabled(Constant.NO);
 			}
 			try {
-				ProductUtils.updateOne(prod);
 				// 保存物料禁用状态信息
 				productStatusDao.save(productStatus);
+				ProductUtils.updateOne(prod);
 			} catch (Exception e) {
 				map.put("error", "更新失败");
 				e.printStackTrace();
@@ -410,9 +395,7 @@ public class ProductServiceImpl implements ProductService {
 			Product product = productDao.findOne(Long.parseLong(id));
 			if (product != null) {
 				product.setDownloadstatus(Status.DOWNLOADED.value());
-				// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 				ProductUtils.updateOne(product);
-//				productDao.save(product);
 			}
 		}
 	}
@@ -605,7 +588,6 @@ public class ProductServiceImpl implements ProductService {
         for (ProductSaler productSaler : productSalers) {
             ProductUsers prod = productUsersDao.findByEnuuAndUseruuAndErpid(enuu, productSaler.getEm_uu(), productSaler.getPs_id());
             if (null != prod) {
-				// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 				ProductUtils.deleteProductUser(prod.getId());
 //                productUsersDao.delete(prod);
 				erpLogger.log("ERP删除个人物料信息同步", "关联物料id: " + prod.getPrid(), 1);

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

@@ -94,7 +94,6 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                 prod.setEnuu(enuu);
                 prod.setPrid(productList.get(0).getId());
                 prod.setUseruu(useruu);
-                // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                 ProductUtils.updateProductUsersOne(prod);
 //                productUsersDao.save(prod);
                 logger.log("个人产品库增加产品", "关联:" + productList.get(0).getId());
@@ -129,15 +128,12 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                 prodInfo.setIsShow(Constant.NO);
                 prodInfo.setStandard(Constant.NO);
                 prodInfo.setErpDate(new Date());
-                // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                 Long proId = ProductUtils.updateOne(prodInfo);
-//                prodInfo = productDao.save(prodInfo);
                 ProductUsers prod = new ProductUsers();
                 prod.setDate(new Date());
                 prod.setEnuu(enuu);
                 prod.setPrid(proId);
                 prod.setUseruu(useruu);
-                // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                 ProductUtils.updateProductUsersOne(prod);
                 productUsersDao.save(prod);
                 logger.log("个人产品库增加产品", "关联:" + proId);
@@ -151,7 +147,6 @@ public class ProductUsersServiceImpl implements ProductUsersService {
 
     @Override
     public void deleteById(Long id) throws Exception {
-        // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
         ProductUtils.deleteProductUser(id);
 //        productUsersDao.delete(id);
     }
@@ -279,9 +274,7 @@ public class ProductUsersServiceImpl implements ProductUsersService {
                                     }
                                 }
                             }
-                            // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                             Long proId = ProductUtils.updateOne(product);
-//                            product = productDao.save(product);
                             prod.setDate(new Date());
                             prod.setEnuu(enuu);
                             prod.setPrid(proId);
@@ -302,7 +295,6 @@ public class ProductUsersServiceImpl implements ProductUsersService {
             modelMap.put("total", total);
             if (!CollectionUtils.isEmpty(productUsers)) {
                 try {
-                    // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                     ProductUtils.updateProductUsersByBatch(productUsers);
 //                    productUsers = productUsersDao.save(productUsers);
                     modelMap.put("success", productUsers.size());
@@ -346,16 +338,12 @@ public class ProductUsersServiceImpl implements ProductUsersService {
 			        if(role.getDesc().equals("业务员") || role.getDesc().equals("销售经理")) {
 			        	if(product.getIsSale() == null || product.getIsSale().equals(Constant.NO)) {
 					        product.setIsSale(Constant.YES);
-                            // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                             ProductUtils.updateOne(product);
-//					        productDao.save(product);
 				        }
 			        } else if(role.getDesc().equals("采购员")) {
 				        if(product.getIsPurchase() == null || product.getIsPurchase().equals(Constant.NO)) {
 					        product.setIsPurchase(Constant.YES);
-                            // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                             ProductUtils.updateOne(product);
-//					        productDao.save(product);
 				        }
 			        }
 		        }
@@ -365,7 +353,6 @@ public class ProductUsersServiceImpl implements ProductUsersService {
             prod.setEnuu(enuu);
             prod.setPrid(id);
             prod.setDate(new Date());
-            // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
             Long prId = ProductUtils.updateProductUsersOne(prod);
 //            prod = productUsersDao.save(prod);
             logger.log("我的产品库", "新增了我产品信息", "id:" + prId);
@@ -374,7 +361,6 @@ public class ProductUsersServiceImpl implements ProductUsersService {
 
     @Override
     public void deleteByBatch(List<Long> idList) throws Exception {
-        // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
         ProductUtils.deleteProductUserByBatch(idList);
 //        List<ProductUsers> prods = productUsersDao.findAll(idList);
 //        productUsersDao.delete(prods);

+ 0 - 2
src/main/java/com/uas/platform/b2b/service/impl/PurcInquiryServiceImpl.java

@@ -236,9 +236,7 @@ public class PurcInquiryServiceImpl implements PurcInquiryService {
 //										product.setShipAddr(SystemSession.getUser().getEnterprise().getEnAddress());
 										// 导入的物料这里没有填写规格
 										product.setSpec(purcitem.getProdTitle());
-										// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 										Long proId = ProductUtils.updateOne(product);
-//										product = productDao.save(product);
 										item.setProduct(product);
 										item.setProductId(proId);
 									}

+ 0 - 4
src/main/java/com/uas/platform/b2b/service/impl/PurcOrderServiceImpl.java

@@ -215,9 +215,7 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 						if(product.getCode() != null) {
 							List<Product> prods = productDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), product.getCode());
 							if (CollectionUtils.isEmpty(prods)) {
-							    // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 								ProductUtils.updateOne(product);
-//								product = productDao.save(product);
 							} else {
 								product = prods.get(0);
 							}
@@ -228,9 +226,7 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 								//生成随机编码
 								SimpleDateFormat sdf = new SimpleDateFormat("yymmddhhmm_sss");
 								product.setCode("prod" + sdf.format(new Date()));
-								// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 								ProductUtils.updateOne(product);
-//								product = productDao.save(product);
 							} else {
 								product = prods.get(0);
 							}

+ 0 - 6
src/main/java/com/uas/platform/b2b/service/impl/PurcProductServiceImpl.java

@@ -221,9 +221,7 @@ public class PurcProductServiceImpl implements PurcProductService {
 							// oldProd.setStandard(Constant.YES);
 							// }
 							oldProd.setIsPurchase(Constant.YES);
-							// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 							ProductUtils.updateOne(product);
-//							productDao.save(oldProd);
 						}
 						// else if (oldProd.getIsPurchase() != null) {
 						// if (!oldProd.getIsPurchase().equals(Constant.YES)) {
@@ -251,7 +249,6 @@ public class PurcProductServiceImpl implements PurcProductService {
 						// oldProd.setStandard(Constant.YES);
 						// }
 						// oldProd.setIsPurchase(Constant.YES);
-						// productDao.save(oldProd);
 						// }
 						// }
 						alters.add(product.getCode());
@@ -283,10 +280,7 @@ public class PurcProductServiceImpl implements PurcProductService {
 			}
 			if (!CollectionUtils.isEmpty(products)) {
 				try {
-					// TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
 					ProductUtils.update(products);
-//					products = productDao.save(products);
-//					saveUserOrders(products);
 					modelMap.put("success", products.size());
 				} catch (Exception e) {
 					modelMap.put("error", "存在编号相同的物料");

+ 0 - 4
src/main/java/com/uas/platform/b2b/service/impl/PurchaseTenderServiceImpl.java

@@ -240,9 +240,7 @@ public class PurchaseTenderServiceImpl implements PurchaseTenderService {
             List<Product> oldProducts = productDao.findByEnUUAndCode(currentEnUU, tenderProd.getProdCode());
             if (CollectionUtils.isEmpty(oldProducts)) {
                 Product newProduct = new Product(tenderProd, currentEnUU);
-                // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                 ProductUtils.updateOne(newProduct);
-//                productDao.save(newProduct);
             }
             tenderProd.setTender(tender);
             purchaseTenderProdDao.save(tenderProd);
@@ -296,9 +294,7 @@ public class PurchaseTenderServiceImpl implements PurchaseTenderService {
             List<Product> oldProducts = productDao.findByEnUUAndCode(currentEnUU, tenderProd.getProdCode());
             if (CollectionUtils.isEmpty(oldProducts)) {
                 Product newProduct = new Product(tenderProd, currentEnUU);
-                // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
                 ProductUtils.updateOne(newProduct);
-//                productDao.save(newProduct);
             }
             tenderProd.setTender(tender);
             purchaseTenderProdDao.save(tenderProd);