|
|
@@ -17,46 +17,12 @@ import com.uas.platform.b2c.core.constant.Status;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
+import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.MatchModelDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductDetailDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductMatchResultDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductModifyHistoryDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductPersonDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductReplaceDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductStandardPutOnInfoDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.ProductStoreStatusDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.StockInOutHistDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.V_ProductPersonDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.GoodsHistory;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.MatchModel;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductDetail;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductMatchResult;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductModifyHistory;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductPerson;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductReplace;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductStandardPutOnInfo;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.ProductStoreStatus;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.StockInOutHist;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.UASBatchPutOnProperty;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.V_ProductPerson;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
|
|
|
-import com.uas.platform.b2c.prod.commodity.service.GoodsHistoryService;
|
|
|
-import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
-import com.uas.platform.b2c.prod.commodity.service.ProductService;
|
|
|
-import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
-import com.uas.platform.b2c.prod.commodity.service.UASBatchPutOnPropertyService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
|
import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
|
|
|
@@ -93,24 +59,7 @@ import com.uas.platform.core.model.Type;
|
|
|
import com.uas.platform.core.persistence.criteria.LogicalExpression;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.platform.core.persistence.criteria.SimpleExpression;
|
|
|
-import java.lang.reflect.Field;
|
|
|
-import java.sql.ResultSet;
|
|
|
-import java.sql.SQLException;
|
|
|
-import java.sql.Statement;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
import org.apache.commons.beanutils.ConvertUtils;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.log4j.Logger;
|
|
|
@@ -129,6 +78,17 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.sql.Statement;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+
|
|
|
/**
|
|
|
* Created by wangyc on 2017/5/26.
|
|
|
*/
|
|
|
@@ -257,6 +217,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Autowired
|
|
|
private SearchService searchService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductAttachService productAttachService;
|
|
|
+
|
|
|
@Value("#{sys.productServiceIp}")
|
|
|
private String productServiceIp;
|
|
|
|
|
|
@@ -338,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) {
|
|
|
@@ -345,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());
|
|
|
}
|
|
|
@@ -401,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())) {
|
|
|
@@ -412,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());
|
|
|
}
|
|
|
@@ -1875,5 +1859,305 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改非标物料的品牌、物料名称、型号、规格、规格书等信息
|
|
|
+ *
|
|
|
+ * @param json 修改的物料信息
|
|
|
+ * @param attachUrl 规格书的地址
|
|
|
+ * @return the string
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public ResultMap updateProduct(String json, String attachUrl) {
|
|
|
+ if (StringUtils.isEmpty(json)) {
|
|
|
+ return new ResultMap(CodeType.NOT_COMPLETE_INFO, "信息不完善");
|
|
|
+ } else {
|
|
|
+ Product product = FlexJsonUtils.fromJson(json, Product.class);
|
|
|
+ //第一步 判断此产品是为非标
|
|
|
+ if (product != null) {
|
|
|
+ Long id = product.getId();
|
|
|
+ if (id == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_COMPLETE_INFO, "物料主键信息丢失");
|
|
|
+ }
|
|
|
+ Product persistProduct = productDao.findOne(id);
|
|
|
+ if (persistProduct == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST, "数据库找不到对应的信息,请重新操作");
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ //更新物料信息
|
|
|
+ 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(), "成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //非标且找不到标准信息
|
|
|
+ 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);
|
|
|
+ if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
+ return resultMap;
|
|
|
+ } else {
|
|
|
+ brand = (String) resultMap.getData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtilB2C.equals(persistProduct.getPcmpcode() , product.getPcmpcode())) {
|
|
|
+ code = product.getPcmpcode();
|
|
|
+ ResultMap resultMap = StringUtilB2C.validateCmpCode(code);
|
|
|
+ if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
+ return resultMap;
|
|
|
+ } else {
|
|
|
+ code = (String) resultMap.getData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtilB2C.equals(persistProduct.getKind() , product.getKind())) {
|
|
|
+ kind = product.getKind();
|
|
|
+ ResultMap resultMap = StringUtilB2C.validateKind(kind);
|
|
|
+ if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
+ return resultMap;
|
|
|
+ } else {
|
|
|
+ kind = (String) resultMap.getData();
|
|
|
+ persistProduct.setKind(kind);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果修改了品牌、或者型号,需要匹配看,是否为标准
|
|
|
+ if (!StringUtils.isEmpty(brand) || !StringUtils.isEmpty(code)) {
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
+ code = persistProduct.getPcmpcode();
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(brand)) {
|
|
|
+ brand = persistProduct.getPbranden();
|
|
|
+ }
|
|
|
+ List<Product> products = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(SystemSession.getUser().getEnterprise().getUu(), code, brand, IntegerConstant.YES_SHORT);
|
|
|
+ if (CollectionUtils.isNotEmpty(products)) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT, "该企业下已存在同品牌、同型号的物料。");
|
|
|
+ } else {
|
|
|
+ Component component1 = findBybrNameAndcmpCode(brand, code);
|
|
|
+ if (component1 != null) {
|
|
|
+ //根据器件更新物料信息
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //直接保存
|
|
|
+ Product product1 = productDao.save(persistProduct);
|
|
|
+ return ResultMap.success(product1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //标准的信息,只能修改规格书、规格信息
|
|
|
+ Component component = null;
|
|
|
+ if (!StringUtilB2C.equals(product.getPbranden(), persistProduct.getPbranden())) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT, "标准物料,品牌不能修改");
|
|
|
+ }
|
|
|
+ if (!StringUtilB2C.equals(product.getPcmpcode(), persistProduct.getPcmpcode())) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT, "标准物料,型号不能修改");
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ 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(), "成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return new ResultMap(CodeType.NOT_COMPLETE_INFO, "物料信息丢失,请重新操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据品牌和型号找标准器件
|
|
|
+ *
|
|
|
+ * @param brName
|
|
|
+ * @param cmpCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Component findBybrNameAndcmpCode(String brName, String cmpCode) {
|
|
|
+ if (StringUtils.isEmpty(brName) || StringUtils.isEmpty(cmpCode)) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ List<Brand> brands = brandDao.findByName(brName);
|
|
|
+ if (CollectionUtils.isEmpty(brands)) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ Brand brand = brands.get(0);
|
|
|
+ List<Component> componentList = componentDao.findByCodeAndBrandid(cmpCode, brand.getId());
|
|
|
+ if (CollectionUtils.isEmpty(componentList)) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ return componentList.get(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新物料信息根据标准器件
|
|
|
+ *
|
|
|
+ * @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("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|