|
|
@@ -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);
|