Browse Source

新增物料时自动匹配标准信息

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@9832 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
hejq 8 years ago
parent
commit
8473500944

+ 148 - 102
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -189,113 +189,133 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 					List<Product> prods = productDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(),
 							product.getCode());
 					if (CollectionUtils.isEmpty(prods)) {
-						product.setCode(product.getCode());
-						List<Component> components = componentDao.findByCode(product.getCmpCode());
-						if (components.size() == 1) {
-							Component cmp = components.get(0);
-							if (cmp.getBrand().getNameEn().equals(product.getBrand())
-									&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 先匹配英文文
-								product.setPbranden(cmp.getBrand().getNameEn());
-								product.setPbrand(cmp.getBrand().getNameCn());
-								product.setCmpUuId(cmp.getUuid());
-								product.setPcmpcode(cmp.getCode());
-								product.setKind(cmp.getKind().getNameCn());
-								product.setKinden(cmp.getKind().getNameEn());
-								product.setStandard(Constant.YES);
-								product.setMessage("success");
-							} else if (!cmp.getBrand().getNameEn().equals(product.getBrand())
-									&& cmp.getBrand().getNameCn().equals(product.getBrand())
-									&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 再匹配中文
-								product.setPbranden(cmp.getBrand().getNameEn());
-								product.setPbrand(cmp.getBrand().getNameCn());
-								product.setCmpUuId(cmp.getUuid());
-								product.setPcmpcode(cmp.getCode());
-								product.setKind(cmp.getKind().getNameCn());
-								product.setKinden(cmp.getKind().getNameEn());
-								product.setStandard(Constant.YES);
-								product.setMessage("success");
-							}
-						} else if (components.size() > 1) {
-							for (Component cmp : components) {// 器件有多个,先匹配品牌
-								if (cmp.getBrand().getNameEn().equals(product.getBrand())
-										&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 先匹配英文文
-									product.setPbranden(cmp.getBrand().getNameEn());
-									product.setPbrand(cmp.getBrand().getNameCn());
-									product.setCmpUuId(cmp.getUuid());
-									product.setPcmpcode(cmp.getCode());
-									product.setKind(cmp.getKind().getNameCn());
-									product.setKinden(cmp.getKind().getNameEn());
-									product.setStandard(Constant.YES);
-									product.setMessage("success");
-								} else if (!cmp.getBrand().getNameEn().equals(product.getBrand())
-										&& cmp.getBrand().getNameCn().equals(product.getBrand())
-										&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 再匹配中文
-									product.setPbranden(cmp.getBrand().getNameEn());
-									product.setPbrand(cmp.getBrand().getNameCn());
-									product.setCmpUuId(cmp.getUuid());
-									product.setPcmpcode(cmp.getCode());
-									product.setKind(cmp.getKind().getNameCn());
-									product.setKinden(cmp.getKind().getNameEn());
-									product.setStandard(Constant.YES);
-									product.setMessage("success");
-								} else {// 给出提示
-									product.setMessage(product.getCode() + "存在多个品牌,需要手动选择匹配");
-								}
-							}
-						}
+						// product.setCode(product.getCode());
+						// List<Component> components =
+						// componentDao.findByCode(product.getCmpCode());
+						// if (components.size() == 1) {
+						// Component cmp = components.get(0);
+						// if
+						// (cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 先匹配英文文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// } else if
+						// (!cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getBrand().getNameCn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 再匹配中文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// }
+						// } else if (components.size() > 1) {
+						// for (Component cmp : components) {// 器件有多个,先匹配品牌
+						// if
+						// (cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 先匹配英文文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// } else if
+						// (!cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getBrand().getNameCn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 再匹配中文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// } else {// 给出提示
+						// product.setMessage(product.getCode() +
+						// "存在多个品牌,需要手动选择匹配");
+						// }
+						// }
+						// }
 					} else {
 						Product oldProd = prods.get(0);
 						if (oldProd.getIsSale() == null) {
 							oldProd.setIsSale(Constant.YES);
-							if (oldProd.getCmpUuId() == null) {
-								List<Component> components = componentDao.findByCode(product.getCmpCode());
-								if (components.size() == 1) {
-									oldProd.setPbranden(components.get(0).getBrand().getNameEn());
-									oldProd.setPbrand(components.get(0).getBrand().getNameCn());
-									oldProd.setCmpUuId(components.get(0).getUuid());
-									oldProd.setPcmpcode(components.get(0).getCode());
-									oldProd.setKind(components.get(0).getKind().getNameCn());
-									oldProd.setKinden(components.get(0).getKind().getNameEn());
-									oldProd.setStandard(Constant.YES);
-								} else {
-									oldProd.setStandard(Constant.NO);
-								}
-							} else {
-								Component component = componentDao.findByUuid(oldProd.getCmpUuId());
-								oldProd.setPbrand(component.getBrand().getNameCn());
-								oldProd.setPbranden(component.getBrand().getNameEn());
-								oldProd.setKind(component.getKind().getNameCn());
-								oldProd.setKinden(component.getKind().getNameEn());
-								oldProd.setStandard(Constant.YES);
-							}
-							oldProd.setIsSale(Constant.YES);
+							// if (oldProd.getCmpUuId() == null) {
+							// List<Component> components =
+							// componentDao.findByCode(product.getCmpCode());
+							// if (components.size() == 1) {
+							// oldProd.setPbranden(components.get(0).getBrand().getNameEn());
+							// oldProd.setPbrand(components.get(0).getBrand().getNameCn());
+							// oldProd.setCmpUuId(components.get(0).getUuid());
+							// oldProd.setPcmpcode(components.get(0).getCode());
+							// oldProd.setKind(components.get(0).getKind().getNameCn());
+							// oldProd.setKinden(components.get(0).getKind().getNameEn());
+							// oldProd.setStandard(Constant.YES);
+							// } else {
+							// oldProd.setStandard(Constant.NO);
+							// }
+							// } else {
+							// Component component =
+							// componentDao.findByUuid(oldProd.getCmpUuId());
+							// oldProd.setPbrand(component.getBrand().getNameCn());
+							// oldProd.setPbranden(component.getBrand().getNameEn());
+							// oldProd.setKind(component.getKind().getNameCn());
+							// oldProd.setKinden(component.getKind().getNameEn());
+							// oldProd.setStandard(Constant.YES);
+							// }
+//							oldProd.setIsSale(Constant.YES);
 							productDao.save(oldProd);
-						} else if (oldProd.getIsSale() != null) {
-							if (!oldProd.getIsSale().equals(Constant.YES)) {
-								if (oldProd.getCmpUuId() == null) {
-									List<Component> components = componentDao.findByCode(product.getCmpCode());
-									if (components.size() == 1) {
-										oldProd.setPbranden(components.get(0).getBrand().getNameEn());
-										oldProd.setPbrand(components.get(0).getBrand().getNameCn());
-										oldProd.setCmpUuId(components.get(0).getUuid());
-										oldProd.setPcmpcode(components.get(0).getCode());
-										oldProd.setKind(components.get(0).getKind().getNameCn());
-										oldProd.setKinden(components.get(0).getKind().getNameEn());
-										oldProd.setStandard(Constant.YES);
-									} else {
-										oldProd.setStandard(Constant.NO);
-									}
-								} else {
-									Component component = componentDao.findByUuid(oldProd.getCmpUuId());
-									oldProd.setPbrand(component.getBrand().getNameCn());
-									oldProd.setPbranden(component.getBrand().getNameEn());
-									oldProd.setKind(component.getKind().getNameCn());
-									oldProd.setKinden(component.getKind().getNameEn());
-									oldProd.setStandard(Constant.YES);
-								}
-								oldProd.setIsSale(Constant.YES);
-								productDao.save(oldProd);
-							}
+//						} else if (oldProd.getIsSale() != null) {
+							// if (!oldProd.getIsSale().equals(Constant.YES)) {
+							// if (oldProd.getCmpUuId() == null) {
+							// List<Component> components =
+							// componentDao.findByCode(product.getCmpCode());
+							// if (components.size() == 1) {
+							// oldProd.setPbranden(components.get(0).getBrand().getNameEn());
+							// oldProd.setPbrand(components.get(0).getBrand().getNameCn());
+							// oldProd.setCmpUuId(components.get(0).getUuid());
+							// oldProd.setPcmpcode(components.get(0).getCode());
+							// oldProd.setKind(components.get(0).getKind().getNameCn());
+							// oldProd.setKinden(components.get(0).getKind().getNameEn());
+							// oldProd.setStandard(Constant.YES);
+							// } else {
+							// oldProd.setStandard(Constant.NO);
+							// }
+							// } else {
+							// Component component =
+							// componentDao.findByUuid(oldProd.getCmpUuId());
+							// oldProd.setPbrand(component.getBrand().getNameCn());
+							// oldProd.setPbranden(component.getBrand().getNameEn());
+							// oldProd.setKind(component.getKind().getNameCn());
+							// oldProd.setKinden(component.getKind().getNameEn());
+							// oldProd.setStandard(Constant.YES);
+							// }
+							// oldProd.setIsSale(Constant.YES);
+							// productDao.save(oldProd);
+							// }
 						}
 						alters.add(product.getCode());
 						product.setCode(null);
@@ -432,6 +452,32 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 			map.put("error", "物料已存在");
 			map.put("id", products.get(0).getId());
 		} else {
+			if (prodInfo.getCmpCode() != null && prodInfo.getBrand() != null && prodInfo.getTitle() != null) {
+				List<Component> cmps = componentDao.findByCode(prodInfo.getCmpCode());
+				if (!CollectionUtils.isEmpty(cmps)) {
+					for (Component cmp : cmps) {
+						if (cmp.getBrand().getNameEn().equals(prodInfo.getBrand())
+								&& cmp.getKind().getNameCn().equals(prodInfo.getTitle())) {// 匹配标准
+							prodInfo.setPbrand(cmp.getBrand().getNameCn());
+							prodInfo.setKinden(cmp.getKind().getNameEn());
+							prodInfo.setCmpUuId(cmp.getUuid());
+							prodInfo.setPbranden(cmp.getBrand().getNameEn());
+							prodInfo.setKind(cmp.getKind().getNameCn());
+							prodInfo.setStandard(Constant.YES);
+							break;
+						} else {
+							prodInfo.setCmpUuId(null);
+							prodInfo.setStandard(Constant.NO);
+						}
+					}
+				} else {
+					prodInfo.setCmpUuId(null);
+					prodInfo.setStandard(Constant.NO);
+				}
+			} else {
+				prodInfo.setCmpUuId(null);
+				prodInfo.setStandard(Constant.NO);
+			}
 			prodInfo.setEnUU(SystemSession.getUser().getEnterprise().getUu());
 			prodInfo.setStandard(Constant.NO);
 			prodInfo = productDao.save(prodInfo);

+ 123 - 103
src/main/java/com/uas/platform/b2b/service/impl/PurcProductServiceImpl.java

@@ -16,7 +16,6 @@ import org.springframework.ui.ModelMap;
 
 import com.uas.platform.b2b.dao.ComponentDao;
 import com.uas.platform.b2b.dao.ProductDao;
-import com.uas.platform.b2b.model.Component;
 import com.uas.platform.b2b.model.Product;
 import com.uas.platform.b2b.service.PurcProductService;
 import com.uas.platform.b2b.support.SystemSession;
@@ -119,114 +118,135 @@ public class PurcProductServiceImpl implements PurcProductService {
 					List<Product> prods = productDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(),
 							product.getCode());
 					if (CollectionUtils.isEmpty(prods)) {
-						product.setCode(product.getCode());
-						List<Component> components = componentDao.findByCode(product.getCmpCode());
-						if (components.size() == 1) {
-							Component cmp = components.get(0);
-							if (cmp.getBrand().getNameEn().equals(product.getBrand())
-									&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 先匹配英文文
-								product.setPbranden(cmp.getBrand().getNameEn());
-								product.setPbrand(cmp.getBrand().getNameCn());
-								product.setCmpUuId(cmp.getUuid());
-								product.setPcmpcode(cmp.getCode());
-								product.setKind(cmp.getKind().getNameCn());
-								product.setKinden(cmp.getKind().getNameEn());
-								product.setStandard(Constant.YES);
-								product.setMessage("success");
-							} else if (!cmp.getBrand().getNameEn().equals(product.getBrand())
-									&& cmp.getBrand().getNameCn().equals(product.getBrand())
-									&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 再匹配中文
-								product.setPbranden(cmp.getBrand().getNameEn());
-								product.setPbrand(cmp.getBrand().getNameCn());
-								product.setCmpUuId(cmp.getUuid());
-								product.setPcmpcode(cmp.getCode());
-								product.setKind(cmp.getKind().getNameCn());
-								product.setKinden(cmp.getKind().getNameEn());
-								product.setStandard(Constant.YES);
-								product.setMessage("success");
-							}
-						} else if (components.size() > 1) {
-							for (Component cmp : components) {// 器件有多个,先匹配品牌
-								if (cmp.getBrand().getNameEn().equals(product.getBrand())
-										&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 先匹配英文文
-									product.setPbranden(cmp.getBrand().getNameEn());
-									product.setPbrand(cmp.getBrand().getNameCn());
-									product.setCmpUuId(cmp.getUuid());
-									product.setPcmpcode(cmp.getCode());
-									product.setKind(cmp.getKind().getNameCn());
-									product.setKinden(cmp.getKind().getNameEn());
-									product.setStandard(Constant.YES);
-									product.setMessage("success");
-								} else if (!cmp.getBrand().getNameEn().equals(product.getBrand())
-										&& cmp.getBrand().getNameCn().equals(product.getBrand())
-										&& cmp.getKind().getNameCn().equals(product.getTitle())) {// 再匹配中文
-									product.setPbranden(cmp.getBrand().getNameEn());
-									product.setPbrand(cmp.getBrand().getNameCn());
-									product.setCmpUuId(cmp.getUuid());
-									product.setPcmpcode(cmp.getCode());
-									product.setKind(cmp.getKind().getNameCn());
-									product.setKinden(cmp.getKind().getNameEn());
-									product.setStandard(Constant.YES);
-									product.setMessage("success");
-								} else {// 给出提示
-									product.setMessage(product.getCode() + "存在多个品牌,需要手动选择匹配");
-								}
-							}
-						}
+						// product.setCode(product.getCode());
+						// List<Component> components =
+						// componentDao.findByCode(product.getCmpCode());
+						// if (components.size() == 1) {
+						// Component cmp = components.get(0);
+						// if
+						// (cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 先匹配英文文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// } else if
+						// (!cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getBrand().getNameCn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 再匹配中文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// }
+						// } else if (components.size() > 1) {
+						// for (Component cmp : components) {// 器件有多个,先匹配品牌
+						// if
+						// (cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 先匹配英文文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// } else if
+						// (!cmp.getBrand().getNameEn().equals(product.getBrand())
+						// &&
+						// cmp.getBrand().getNameCn().equals(product.getBrand())
+						// &&
+						// cmp.getKind().getNameCn().equals(product.getTitle()))
+						// {// 再匹配中文
+						// product.setPbranden(cmp.getBrand().getNameEn());
+						// product.setPbrand(cmp.getBrand().getNameCn());
+						// product.setCmpUuId(cmp.getUuid());
+						// product.setPcmpcode(cmp.getCode());
+						// product.setKind(cmp.getKind().getNameCn());
+						// product.setKinden(cmp.getKind().getNameEn());
+						// product.setStandard(Constant.YES);
+						// product.setMessage("success");
+						// } else {// 给出提示
+						// product.setMessage(product.getCode() +
+						// "存在多个品牌,需要手动选择匹配");
+						// }
+						// }
+						// }
 					} else {
 						Product oldProd = prods.get(0);
 						if (oldProd.getIsPubsale() == null) {
-							oldProd.setIsPurchase(Constant.YES);
-							if (oldProd.getCmpUuId() == null) {
-								List<Component> components = componentDao.findByCode(product.getCmpCode());
-								if (components.size() == 1) {
-									oldProd.setPbranden(components.get(0).getBrand().getNameEn());
-									oldProd.setPbrand(components.get(0).getBrand().getNameCn());
-									oldProd.setCmpUuId(components.get(0).getUuid());
-									oldProd.setPcmpcode(components.get(0).getCode());
-									oldProd.setKind(components.get(0).getKind().getNameCn());
-									oldProd.setKinden(components.get(0).getKind().getNameEn());
-									oldProd.setStandard(Constant.YES);
-								} else {
-									oldProd.setStandard(Constant.NO);
-								}
-							} else {
-								Component component = componentDao.findByUuid(oldProd.getCmpUuId());
-								oldProd.setPbrand(component.getBrand().getNameCn());
-								oldProd.setPbranden(component.getBrand().getNameEn());
-								oldProd.setKind(component.getKind().getNameCn());
-								oldProd.setKinden(component.getKind().getNameEn());
-								oldProd.setStandard(Constant.YES);
-							}
+							// oldProd.setIsPurchase(Constant.YES);
+							// if (oldProd.getCmpUuId() == null) {
+							// List<Component> components =
+							// componentDao.findByCode(product.getCmpCode());
+							// if (components.size() == 1) {
+							// oldProd.setPbranden(components.get(0).getBrand().getNameEn());
+							// oldProd.setPbrand(components.get(0).getBrand().getNameCn());
+							// oldProd.setCmpUuId(components.get(0).getUuid());
+							// oldProd.setPcmpcode(components.get(0).getCode());
+							// oldProd.setKind(components.get(0).getKind().getNameCn());
+							// oldProd.setKinden(components.get(0).getKind().getNameEn());
+							// oldProd.setStandard(Constant.YES);
+							// } else {
+							// oldProd.setStandard(Constant.NO);
+							// }
+							// } else {
+							// Component component =
+							// componentDao.findByUuid(oldProd.getCmpUuId());
+							// oldProd.setPbrand(component.getBrand().getNameCn());
+							// oldProd.setPbranden(component.getBrand().getNameEn());
+							// oldProd.setKind(component.getKind().getNameCn());
+							// oldProd.setKinden(component.getKind().getNameEn());
+							// oldProd.setStandard(Constant.YES);
+							// }
 							oldProd.setIsPurchase(Constant.YES);
 							productDao.save(oldProd);
-						} else if (oldProd.getIsPurchase() != null) {
-							if (!oldProd.getIsPurchase().equals(Constant.YES)) {
-								if (oldProd.getCmpUuId() == null) {
-									List<Component> components = componentDao.findByCode(product.getCmpCode());
-									if (components.size() == 1) {
-										oldProd.setPbranden(components.get(0).getBrand().getNameEn());
-										oldProd.setPbrand(components.get(0).getBrand().getNameCn());
-										oldProd.setCmpUuId(components.get(0).getUuid());
-										oldProd.setPcmpcode(components.get(0).getCode());
-										oldProd.setKind(components.get(0).getKind().getNameCn());
-										oldProd.setKinden(components.get(0).getKind().getNameEn());
-										oldProd.setStandard(Constant.YES);
-									} else {
-										oldProd.setStandard(Constant.NO);
-									}
-								} else {
-									Component component = componentDao.findByUuid(oldProd.getCmpUuId());
-									oldProd.setPbrand(component.getBrand().getNameCn());
-									oldProd.setPbranden(component.getBrand().getNameEn());
-									oldProd.setKind(component.getKind().getNameCn());
-									oldProd.setKinden(component.getKind().getNameEn());
-									oldProd.setStandard(Constant.YES);
-								}
-								oldProd.setIsPurchase(Constant.YES);
-								productDao.save(oldProd);
-							}
 						}
+						// else if (oldProd.getIsPurchase() != null) {
+						// if (!oldProd.getIsPurchase().equals(Constant.YES)) {
+						// if (oldProd.getCmpUuId() == null) {
+						// List<Component> components =
+						// componentDao.findByCode(product.getCmpCode());
+						// if (components.size() == 1) {
+						// oldProd.setPbranden(components.get(0).getBrand().getNameEn());
+						// oldProd.setPbrand(components.get(0).getBrand().getNameCn());
+						// oldProd.setCmpUuId(components.get(0).getUuid());
+						// oldProd.setPcmpcode(components.get(0).getCode());
+						// oldProd.setKind(components.get(0).getKind().getNameCn());
+						// oldProd.setKinden(components.get(0).getKind().getNameEn());
+						// oldProd.setStandard(Constant.YES);
+						// } else {
+						// oldProd.setStandard(Constant.NO);
+						// }
+						// } else {
+						// Component component =
+						// componentDao.findByUuid(oldProd.getCmpUuId());
+						// oldProd.setPbrand(component.getBrand().getNameCn());
+						// oldProd.setPbranden(component.getBrand().getNameEn());
+						// oldProd.setKind(component.getKind().getNameCn());
+						// oldProd.setKinden(component.getKind().getNameEn());
+						// oldProd.setStandard(Constant.YES);
+						// }
+						// oldProd.setIsPurchase(Constant.YES);
+						// productDao.save(oldProd);
+						// }
+						// }
 						alters.add(product.getCode());
 						product.setCode(null);
 					}