|
|
@@ -23,6 +23,7 @@ import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
@@ -256,7 +257,7 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
List<ProductUsers> existProds = productUsersDao.findByEnuuAndUseruuAndTitleAndCmpCodeAndBrand
|
|
|
(enuu, useruu, product.getTitle(), product.getCmpCode(), product.getBrand());
|
|
|
if(CollectionUtils.isEmpty(existProds)) {
|
|
|
- List<Product> prods = productDao.findByEnUUAndCode(product.getEnUU(), product.getCode());
|
|
|
+ List<Product> prods = productDao.findByEnUUAndCode(enuu, product.getCode());
|
|
|
if (CollectionUtils.isEmpty(prods)) {
|
|
|
prods = productDao.findByTitleAndCmpCodeAndBrandAndEnUU(
|
|
|
product.getTitle(), product.getCmpCode(), product.getBrand(), enuu);
|
|
|
@@ -272,7 +273,7 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
product.setIsPubsale(Constant.NO);
|
|
|
product.setIsShow(Constant.NO);
|
|
|
product.setStandard(Constant.NO);
|
|
|
- product.setErpDate(new Date());
|
|
|
+ product.setCreateTime(new Date());
|
|
|
List<Role> roles = roleService.findByEnUUAndUserUU(enuu, useruu);
|
|
|
if(!CollectionUtils.isEmpty(roles)) {
|
|
|
for(Role role : roles) {
|
|
|
@@ -415,8 +416,33 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
ProductUsers productUsers = productUsersDao.findByEnuuAndUseruuAndPrid(enuu, useruu, productId);
|
|
|
if (null == productUsers) {
|
|
|
try {
|
|
|
+ // 用来存供应商企业的对应物料id
|
|
|
+ Long prId;
|
|
|
+ Product product = productDao.findOne(productId);
|
|
|
+ // 复制到供应商企业的物料
|
|
|
+ Product newProduct = new Product();
|
|
|
+ BeanUtils.copyProperties(product, newProduct);
|
|
|
+ // 将客户物料转入到本企业
|
|
|
+ List<Product> products = productDao.findByEnUUAndCode(enuu, product.getCode());
|
|
|
+ if (CollectionUtils.isEmpty(products)) {
|
|
|
+ newProduct.setId(null);
|
|
|
+ newProduct.setEnUU(enuu);
|
|
|
+ prId = ProductUtils.updateOne(newProduct);
|
|
|
+ } else {
|
|
|
+ // 如果根据型号,title ,brand在供应商本企业找到一样的,确定是同一个,直接转,否则修改物料编号
|
|
|
+ List<Product> cmpProducts = productDao.findByTitleAndCmpCodeAndBrandAndEnUU(
|
|
|
+ product.getTitle(), product.getCmpCode(), product.getBrand(), enuu);
|
|
|
+ if (!CollectionUtils.isEmpty(cmpProducts)) {
|
|
|
+ prId = cmpProducts.get(0).getId();
|
|
|
+ } else {
|
|
|
+ //生成随机编码
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yymmddhhmm_sss");
|
|
|
+ newProduct.setCode("prod" + sdf.format(new Date()));
|
|
|
+ prId = ProductUtils.updateOne(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
List<Long> idList = new ArrayList<>();
|
|
|
- idList.add(productId);
|
|
|
+ idList.add(prId);
|
|
|
ProductUtils.coverToUserProd(idList, enuu, useruu);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -426,4 +452,4 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
}
|
|
|
}).run();
|
|
|
}
|
|
|
-}
|
|
|
+}
|