|
|
@@ -1,8 +1,11 @@
|
|
|
package com.uas.ps.product.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.ps.brand.entity.BrandInfo;
|
|
|
import com.uas.ps.entity.Product;
|
|
|
import com.uas.ps.entity.ProductUsers;
|
|
|
import com.uas.ps.entity.Status;
|
|
|
+import com.uas.ps.product.ProductConstant;
|
|
|
import com.uas.ps.product.entity.Constant;
|
|
|
import com.uas.ps.product.entity.Prod;
|
|
|
import com.uas.ps.product.entity.ProductSaler;
|
|
|
@@ -19,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -44,6 +48,9 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Autowired
|
|
|
private ProductStoreStatusDao productStoreStatusDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* 保存物料
|
|
|
*
|
|
|
@@ -127,6 +134,38 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 单个物料匹配
|
|
|
+ * @param product
|
|
|
+ */
|
|
|
+ private void matchOne(Product product) {
|
|
|
+ // 获取品牌
|
|
|
+ String brandUrl = "";
|
|
|
+ BrandInfo result = restTemplate.getForEntity(brandUrl, BrandInfo.class).getBody();
|
|
|
+ if (result.getUuid() != null) {
|
|
|
+ String componentUrl = "";
|
|
|
+ JSONObject component = restTemplate.getForEntity(componentUrl, JSONObject.class).getBody();
|
|
|
+ if (component != null) {
|
|
|
+ // 更新物料信息
|
|
|
+ updateProductByComponent(product, result, component);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateProductByComponent(Product product, BrandInfo brandInfo, JSONObject component) {
|
|
|
+ product.setCmpUuid(component.getString("uuid"));
|
|
|
+ product.setpBrandId(brandInfo.getId());
|
|
|
+ product.setpBrand(brandInfo.getNameCn());
|
|
|
+ product.setpBrandEn(brandInfo.getNameEn());
|
|
|
+ product.setpBrandUuid(brandInfo.getUuid());
|
|
|
+ product.setCmpImg(component.getString("img"));
|
|
|
+ product.setKind("");
|
|
|
+ product.setKindEn("");
|
|
|
+ product.setKindId(2L);
|
|
|
+ product.setpCmpCode("");
|
|
|
+ product.setStandard(ProductConstant.STANDARD);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ModelMap assignPersonalProduct(Long userUU, Long productId) {
|
|
|
ModelMap map = new ModelMap();
|