|
|
@@ -301,6 +301,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
}
|
|
|
userUU = SystemSession.getUser().getUserUU();
|
|
|
+ List<ProductAttachSubmit> productAttachSubmits = productAttachService.findByProductidsAndStatus(idList, Status.UNAUDIT.value());
|
|
|
List<Long> productIds = productPersonDao.findIdByEnuuAndUserUU(enUU, userUU);
|
|
|
for (V_ProductPrivate v_productPrivate : productList) {
|
|
|
for (Long productId : productIds) {
|
|
|
@@ -308,6 +309,13 @@ public class ProductServiceImpl implements ProductService {
|
|
|
v_productPrivate.setAddProductPerson(true);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ for (ProductAttachSubmit attachSubmit : productAttachSubmits) {
|
|
|
+ if ((attachSubmit.getProductId() != null) && attachSubmit.getProductId().longValue() == v_productPrivate.getId().longValue()) {
|
|
|
+ v_productPrivate.setProductAttachSubmit(attachSubmit);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return new PageImpl<V_ProductPrivate>(productList, page, ids.getTotalElement());
|
|
|
}
|
|
|
@@ -364,7 +372,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return null;
|
|
|
}
|
|
|
}, page);*/
|
|
|
-
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
List<V_ProductPerson> productList = productPage.getContent();
|
|
|
for (V_ProductPerson product : productList) {
|
|
|
if ("ERP".equals(product.getSourceApp())) {
|
|
|
@@ -375,6 +383,19 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
List<ProductReplace> productReplaceList = productReplaceDao.findByProductIdOrderByDetno(product.getId());
|
|
|
product.setProductReplaceList(productReplaceList);
|
|
|
+ list.add(product.getId());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ List<ProductAttachSubmit> submits = productAttachService.findByProductidsAndStatus(list, Status.UNAUDIT.value());
|
|
|
+ for (ProductAttachSubmit productAttachSubmit : submits) {
|
|
|
+ for (V_ProductPerson product : productList) {
|
|
|
+ if (product.getId().longValue() == productAttachSubmit.getProductId().longValue()) {
|
|
|
+ product.setProductAttachSubmit(productAttachSubmit);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return new PageImpl<V_ProductPerson>(productList, page, productPage.getTotalElements());
|
|
|
}
|
|
|
@@ -1864,56 +1885,40 @@ public class ProductServiceImpl implements ProductService {
|
|
|
if (persistProduct == null) {
|
|
|
return new ResultMap(CodeType.NOT_EXiST, "数据库找不到对应的信息,请重新操作");
|
|
|
}
|
|
|
- if (persistProduct.getB2cEnabled() != IntegerConstant.YES_SHORT) {
|
|
|
+ List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(id);
|
|
|
+ if ((CollectionUtils.isNotEmpty(productPrivates)) && productPrivates.get(0).getB2cEnabled() != IntegerConstant.YES_SHORT) {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT, "该物料商城未启用,不能操作");
|
|
|
}
|
|
|
+ if (!StringUtilB2C.equals(persistProduct.getSpec() , product.getSpec())) {
|
|
|
+ String spec = product.getSpec();
|
|
|
+ ResultMap resultMap = StringUtilB2C.validateSpec(spec);
|
|
|
+ if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
+ return resultMap;
|
|
|
+ } else {
|
|
|
+ spec = (String) resultMap.getData();
|
|
|
+ persistProduct.setSpec(spec);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (persistProduct.getStandard() == IntegerConstant.NO_SHORT) {
|
|
|
Component component = findBybrNameAndcmpCode(persistProduct.getPbranden(), persistProduct.getPcmpcode());
|
|
|
if (component != null) {
|
|
|
- persistProduct.setPcmpcode(component.getCode());
|
|
|
- persistProduct.setPbranden(component.getBrand().getNameEn());
|
|
|
- persistProduct.setPbrand(component.getBrand().getNameCn());
|
|
|
- persistProduct.setPbranduuid(component.getBrand().getUuid());
|
|
|
- persistProduct.setPbrandid(component.getBrandid());
|
|
|
- persistProduct.setCmpUuId(component.getUuid());
|
|
|
- persistProduct.setCmpImg(component.getImg());
|
|
|
- persistProduct.setKinden(component.getKind().getNameEn());
|
|
|
- persistProduct.setKind(component.getKind().getNameCn());
|
|
|
- persistProduct.setKindid(component.getKindid());
|
|
|
- String errorMsg = "该物料可以匹配为标准";
|
|
|
- if (!StringUtils.isEmpty(component.getAttach())) {
|
|
|
- List<ProductPrivate> privateList = productPrivateDao.findByPrId(persistProduct.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(privateList)) {
|
|
|
- ProductPrivate productPrivate = privateList.get(0);
|
|
|
- productPrivate.setAttach(component.getAttach());
|
|
|
- errorMsg = ",且规格书已存在,不能修改";
|
|
|
- }
|
|
|
+ //更新物料信息
|
|
|
+ updateProductByComponent(persistProduct, component);
|
|
|
+ if ((!StringUtils.isEmpty(component.getAttach())) && (!StringUtils.isEmpty(attachUrl))) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT, "该物料已匹配为标准,规格书已存在,规格书不能修改");
|
|
|
} else {
|
|
|
if (!StringUtils.isEmpty(attachUrl)) {
|
|
|
productAttachService.submit(persistProduct.getId(), attachUrl);
|
|
|
}
|
|
|
+ return new ResultMap(CodeType.OK.code(), "成功");
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(product.getSpec())) {
|
|
|
- //如果标准器件库存在规格信息,而用户又未填写,则需要填充对应的信息
|
|
|
- if (!StringUtils.isEmpty(component.getDescription())) {
|
|
|
- persistProduct.setSpec(component.getDescription());
|
|
|
- } else {
|
|
|
- persistProduct.setSpec(product.getSpec());
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!product.getSpec().equals(persistProduct.getSpec())) {
|
|
|
- persistProduct.setSpec(product.getSpec());
|
|
|
- }
|
|
|
- }
|
|
|
- productDao.save(persistProduct);
|
|
|
- //更新在售产品的信息
|
|
|
- goodsDao.updateGoodsByProduct(persistProduct.getPbrand(), persistProduct.getPbranden(), persistProduct.getPbrandid(), persistProduct.getPbranduuid(), persistProduct.getKind(), persistProduct.getKindid(), persistProduct.getCmpImg(), persistProduct.getCmpUuId(), persistProduct.getSpec(), persistProduct.getId());
|
|
|
- return ResultMap.success(errorMsg);
|
|
|
+
|
|
|
} else {
|
|
|
- String msg = "";
|
|
|
//非标且找不到标准信息
|
|
|
- String brand = "", code = "", kind = "", spec = "";
|
|
|
- ProductPrivate productPrivate = null;
|
|
|
+ String brand = "", code = "", kind = "";
|
|
|
+ if (!StringUtils.isEmpty(attachUrl)) {
|
|
|
+ productAttachService.submit(persistProduct.getId(), attachUrl);
|
|
|
+ }
|
|
|
if (!StringUtilB2C.equals(persistProduct.getPbranden() , product.getPbranden())) {
|
|
|
brand = product.getPbranden();
|
|
|
ResultMap resultMap = StringUtilB2C.validateBrand(brand);
|
|
|
@@ -1942,17 +1947,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
persistProduct.setKind(kind);
|
|
|
}
|
|
|
}
|
|
|
- if (!StringUtilB2C.equals(persistProduct.getSpec() , product.getSpec())) {
|
|
|
- spec = product.getSpec();
|
|
|
- ResultMap resultMap = StringUtilB2C.validateSpec(spec);
|
|
|
- if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
- return resultMap;
|
|
|
- } else {
|
|
|
- spec = (String) resultMap.getData();
|
|
|
- persistProduct.setSpec(spec);
|
|
|
- }
|
|
|
- }
|
|
|
- //如果修改了品牌、或者型号
|
|
|
+ //如果修改了品牌、或者型号,需要匹配看,是否为标准
|
|
|
if (!StringUtils.isEmpty(brand) || !StringUtils.isEmpty(code)) {
|
|
|
if (StringUtils.isEmpty(code)) {
|
|
|
code = persistProduct.getPcmpcode();
|
|
|
@@ -1962,33 +1957,31 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
List<Product> products = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(SystemSession.getUser().getEnterprise().getUu(), code, brand, IntegerConstant.YES_SHORT);
|
|
|
if (CollectionUtils.isNotEmpty(products)) {
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT, "该企业下已存在同品牌、同型号的企业。");
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT, "该企业下已存在同品牌、同型号的物料。");
|
|
|
} else {
|
|
|
Component component1 = findBybrNameAndcmpCode(brand, code);
|
|
|
if (component1 != null) {
|
|
|
- //TODO 转标准,规格信息设置、规格书设置
|
|
|
+ //根据器件更新物料信息
|
|
|
+ ResultMap resultMap = updateProductByComponent(persistProduct, component1);
|
|
|
+ return resultMap;
|
|
|
} else {
|
|
|
persistProduct.setPbranden(brand);
|
|
|
persistProduct.setPbrand(brand);
|
|
|
persistProduct.setPcmpcode(code);
|
|
|
+ Product product1 = productDao.save(persistProduct);
|
|
|
+ goodsService.updateGoodsByProduct(product1);
|
|
|
+ return ResultMap.success(product1);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- List<ProductPrivate> productPrivateList = productPrivateDao.findByPrId(persistProduct.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(productPrivateList)) {
|
|
|
- productPrivate = productPrivateList.get(0);
|
|
|
- if (!StringUtils.isEmpty(productPrivate.getAttach())) {
|
|
|
- msg = "规格书已存在";
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ //直接保存
|
|
|
+ Product product1 = productDao.save(persistProduct);
|
|
|
+ return ResultMap.success(product1);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
//标准的信息,只能修改规格书、规格信息
|
|
|
- String msg = "";
|
|
|
- String updateAttachUrl = "";
|
|
|
- String spec = "";
|
|
|
Component component = null;
|
|
|
- Product product1 = null;
|
|
|
if (!StringUtilB2C.equals(product.getPbranden(), persistProduct.getPbranden())) {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT, "标准物料,品牌不能修改");
|
|
|
}
|
|
|
@@ -1998,59 +1991,26 @@ public class ProductServiceImpl implements ProductService {
|
|
|
if (!StringUtilB2C.equals(product.getKind(), persistProduct.getKind())) {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT, "标准物料,类目不能修改");
|
|
|
}
|
|
|
+ if (!StringUtilB2C.equals(product.getSpec(), persistProduct.getSpec())) {
|
|
|
+ persistProduct.setSpec(product.getSpec());
|
|
|
+ }
|
|
|
if (persistProduct.getCmpUuId() != null) {
|
|
|
component = componentDao.findByUuid(persistProduct.getCmpUuId());
|
|
|
}
|
|
|
- if (!StringUtils.isEmpty(attachUrl)) {
|
|
|
- List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(persistProduct.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(productPrivates)) {
|
|
|
- if (StringUtils.isEmpty(productPrivates.get(0).getAttach())) {
|
|
|
- if (component != null) {
|
|
|
- if (StringUtils.isEmpty(component.getAttach())) {
|
|
|
- productAttachService.submit(persistProduct.getId(), attachUrl);
|
|
|
- } else {
|
|
|
- msg = "规格书已经存在,不能上传";
|
|
|
- updateAttachUrl = component.getAttach();
|
|
|
- productPrivates.get(0).setAttach(updateAttachUrl);
|
|
|
- productPrivateDao.save(productPrivates.get(0));
|
|
|
- }
|
|
|
- } else {
|
|
|
- productAttachService.submit(persistProduct.getId(), attachUrl);
|
|
|
- }
|
|
|
- } else {
|
|
|
- msg = "规格书已经存在,不能上传";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!StringUtilB2C.equals(product.getSpec(), persistProduct.getSpec())) {
|
|
|
- if (StringUtils.isEmpty(product.getSpec())) {
|
|
|
- if (!StringUtils.isEmpty(component.getSpec())) {
|
|
|
- spec = component.getSpec();
|
|
|
- persistProduct.setSpec(component.getSpec());
|
|
|
- } else {
|
|
|
- spec = product.getSpec();
|
|
|
- persistProduct.setSpec(product.getSpec());
|
|
|
- }
|
|
|
- } else {
|
|
|
- spec = product.getSpec();
|
|
|
- persistProduct.setSpec(product.getSpec());
|
|
|
+ updateProductByComponent(persistProduct, component);
|
|
|
+ if (!StringUtils.isEmpty(component.getAttach()) && !StringUtils.isEmpty(attachUrl)) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT, "规格书已经存在,不能重复上传。");
|
|
|
+ } else {
|
|
|
+ if (!StringUtils.isEmpty(attachUrl)) {
|
|
|
+ productAttachService.submit(persistProduct.getId(), attachUrl);
|
|
|
}
|
|
|
- product1 = productDao.save(persistProduct);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //更新在售产品信息
|
|
|
- goodsService.updateGoodsByProduct(product1);
|
|
|
- if (StringUtils.isEmpty(msg)) {
|
|
|
- msg = "修改成功";
|
|
|
+ return new ResultMap(CodeType.OK.code(), "成功");
|
|
|
}
|
|
|
- return new ResultMap(CodeType.OK.code(), msg, product1);
|
|
|
}
|
|
|
} else {
|
|
|
return new ResultMap(CodeType.NOT_COMPLETE_INFO, "物料信息丢失,请重新操作");
|
|
|
}
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2080,5 +2040,124 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新物料信息根据标准器件
|
|
|
+ *
|
|
|
+ * @param productid 物料id
|
|
|
+ * @param componentUuid 器件id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultMap updateProductByComponent(Long productid, String componentUuid) {
|
|
|
+ if (productid == null) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "物料主键缺失");
|
|
|
+ } else if(StringUtils.isEmpty(componentUuid)) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO, "标准器件uuid缺失");
|
|
|
+ } else {
|
|
|
+ Component component = componentDao.findByUuid(componentUuid);
|
|
|
+ if (component == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST, "找不到对应器件");
|
|
|
+ }
|
|
|
+ Product product = productDao.findOne(productid);
|
|
|
+ if (product == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST, "找不到对应物料");
|
|
|
+ }
|
|
|
+ ResultMap resultMap = updateProductByComponent(product, component);
|
|
|
+
|
|
|
+ updateProductByComponent(component);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新物料信息
|
|
|
+ *
|
|
|
+ * @param product 物料信息
|
|
|
+ * @param component 器件信息
|
|
|
+ * @return ResultMap
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultMap updateProductByComponent(Product product, Component component) {
|
|
|
+ if (product == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST, "物料缺失");
|
|
|
+ }
|
|
|
+ if (component == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST, "标准器件缺失");
|
|
|
+ } else {
|
|
|
+ //更新之前的标准器件
|
|
|
+ updateProductByComponent(component);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(product.getSpec())) {
|
|
|
+ product.setSpec(component.getDescription());
|
|
|
+ }
|
|
|
+ product.setKind(component.getKind().getNameCn());
|
|
|
+ product.setKinden(component.getKind().getNameEn());
|
|
|
+ product.setKindid(component.getKindid());
|
|
|
+ product.setPbrand(component.getBrand().getNameCn());
|
|
|
+ product.setPbranden(component.getBrand().getNameEn());
|
|
|
+ product.setPbrandid(component.getBrandid());
|
|
|
+ product.setPbranduuid(component.getBrand().getUuid());
|
|
|
+ product.setCmpCode(component.getCode());
|
|
|
+ product.setCmpImg(component.getImg());
|
|
|
+ product.setCmpUuId(component.getUuid());
|
|
|
+ if (!StringUtils.isEmpty(component.getAttach())) {
|
|
|
+ List<ProductPrivate> privates = productPrivateDao.findByPrId(product.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(privates)) {
|
|
|
+ ProductPrivate productPrivate = privates.get(0);
|
|
|
+ productPrivate.setAttach(component.getAttach());
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Product product1 = productDao.save(product);
|
|
|
+ goodsService.updateGoodsByProduct(product1);
|
|
|
+ return ResultMap.success(product1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新物料信息
|
|
|
+ *
|
|
|
+ * @param component 器件信息
|
|
|
+ * @return ResultMap
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultMap updateProductByComponent(Component component) {
|
|
|
+ if (component == null) {
|
|
|
+ return new ResultMap(CodeType.OK, "");
|
|
|
+ } else {
|
|
|
+ if ((!StringUtils.isEmpty(component.getSpec())) || (!StringUtils.isEmpty(component.getAttach()))) {
|
|
|
+ List<Product> productList = productDao.findByCmpUuId(component.getUuid());
|
|
|
+ List<ProductPrivate> productPrivatelist = new ArrayList<>();
|
|
|
+ List<Product> list = new ArrayList<>();
|
|
|
+ for (Product product : productList) {
|
|
|
+ if (!StringUtils.isEmpty(component.getAttach())) {
|
|
|
+ List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(product.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(productPrivates)) {
|
|
|
+ ProductPrivate productPrivate = productPrivates.get(0);
|
|
|
+ productPrivate.setAttach(component.getAttach());
|
|
|
+ productPrivatelist.add(productPrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(product.getSpec()) && !StringUtils.isEmpty(component.getSpec())) {
|
|
|
+ product.setSpec(component.getSpec());
|
|
|
+ list.add(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(productPrivatelist)) {
|
|
|
+ productPrivateDao.save(productPrivatelist);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ productDao.save(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsService.updateGoodsByComponent(component);
|
|
|
+ return ResultMap.success("");
|
|
|
+ } else {
|
|
|
+ return ResultMap.success("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|