|
|
@@ -1,37 +1,23 @@
|
|
|
package com.uas.platform.b2b.service.impl;
|
|
|
|
|
|
-import com.uas.platform.b2b.dao.*;
|
|
|
-import com.uas.platform.b2b.erp.support.ErpBufferedLogger;
|
|
|
+import com.uas.platform.b2b.dao.UserOrderDao;
|
|
|
import com.uas.platform.b2b.model.Product;
|
|
|
import com.uas.platform.b2b.model.ProductMatchResult;
|
|
|
-import com.uas.platform.b2b.model.ProductStatus;
|
|
|
import com.uas.platform.b2b.ps.ProductUtils;
|
|
|
-import com.uas.platform.b2b.search.SearchService;
|
|
|
import com.uas.platform.b2b.service.ProductService;
|
|
|
import com.uas.platform.b2b.support.SPageUtils;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
-import com.uas.platform.b2b.support.UsageBufferedLogger;
|
|
|
-import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.Status;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.search.b2b.model.SPage;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -41,57 +27,18 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ProductServiceImpl implements ProductService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private ProductDao productDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SearchService searchService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private CommonDao commonDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ProductMatchResultDao productMatchResultDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private UserOrderDao userOrderDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ProductStatusDao productStatusDao;
|
|
|
-
|
|
|
- private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
-
|
|
|
- private final static ErpBufferedLogger erpLogger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
|
|
|
-
|
|
|
@Override
|
|
|
public void save(List<Product> products) throws Exception {
|
|
|
ProductUtils.paginationUpdate(products);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Page<Product> findAllByPageInfo(final PageInfo pageInfo, final String keyword) {
|
|
|
- return productDao.findAll(new Specification<Product>() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public Predicate toPredicate(Root<Product> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
- if (StringUtils.hasText(keyword)) {
|
|
|
- List<Object> lists = new ArrayList<>();
|
|
|
- List<Product> prodList = searchService.searchProductsCheckIds(keyword, null).getContent();
|
|
|
- for (Product list : prodList) {
|
|
|
- lists.add(list.getId());
|
|
|
- }
|
|
|
- pageInfo.expression(PredicateUtils.in("id", lists, false));
|
|
|
- }
|
|
|
- query.where(pageInfo.getPredicates(root, query, builder));
|
|
|
- return null;
|
|
|
- }
|
|
|
- }, pageInfo);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void unlock(Long id) {
|
|
|
try {
|
|
|
- Product prod = productDao.findOne(id);
|
|
|
+ Product prod = ProductUtils.findById(id);
|
|
|
prod.setIsSale(Constant.YES);
|
|
|
ProductUtils.switchProduct(id, "sale", Constant.YES);
|
|
|
} catch (Exception e) {
|
|
|
@@ -103,7 +50,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Override
|
|
|
public void lock(Long id) {
|
|
|
try {
|
|
|
- Product prod = productDao.findOne(id);
|
|
|
+ Product prod = ProductUtils.findById(id);
|
|
|
prod.setIsSale(Constant.YES);
|
|
|
ProductUtils.switchProduct(id, "sale", Constant.NO);
|
|
|
} catch (Exception e) {
|
|
|
@@ -114,7 +61,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Override
|
|
|
public void unlockPurc(Long id) {
|
|
|
try {
|
|
|
- Product prod = productDao.findOne(id);
|
|
|
+ Product prod = ProductUtils.findById(id);
|
|
|
prod.setIsPurchase(Constant.YES);
|
|
|
ProductUtils.switchProduct(id, "purc", Constant.YES);
|
|
|
} catch (Exception e) {
|
|
|
@@ -125,7 +72,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
@Override
|
|
|
public void lockPurc(Long id) {
|
|
|
try {
|
|
|
- Product prod = productDao.findOne(id);
|
|
|
+ Product prod = ProductUtils.findById(id);
|
|
|
prod.setIsPurchase(Constant.NO);
|
|
|
ProductUtils.switchProduct(id, "purc", Constant.NO);
|
|
|
} catch (Exception e) {
|
|
|
@@ -133,43 +80,6 @@ public class ProductServiceImpl implements ProductService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ModelMap refreshproduct(Long id) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- ProductMatchResult re = productMatchResultDao.findOne(id);
|
|
|
- if (null != re) {
|
|
|
- Product prod = productDao.findOne(re.getPrid());
|
|
|
- prod.setPbrand(re.getBrandcn());
|
|
|
- prod.setPbranden(re.getBranden());
|
|
|
- prod.setPcmpcode(re.getCmpcode());
|
|
|
- prod.setKind(re.getKindcn());
|
|
|
- prod.setKinden(re.getKinden());
|
|
|
- prod.setCmpUuId(re.getUuid());
|
|
|
- prod.setImg(re.getImg());
|
|
|
- prod.setEncapsulation(re.getEncapsulation());
|
|
|
- prod.setStandard(Constant.YES);
|
|
|
- prod.setMatchstatus(Status.FINISH.value());
|
|
|
- prod.setTostandard(new Date());
|
|
|
- List<Product> prods = productDao.findByEnUUAndPcmpcodeAndPbrand(
|
|
|
- SystemSession.getUser().getEnterprise().getUu(), prod.getPcmpcode(), prod.getPbrand());
|
|
|
- // 新增物料状态
|
|
|
- ProductStatus productStatus = new ProductStatus(prod.getId(), Constant.NO);
|
|
|
- if (prods.size() == 0) {
|
|
|
- productStatus.setB2bDisabled(Constant.YES);
|
|
|
- }
|
|
|
- try {
|
|
|
- // 保存物料禁用状态信息
|
|
|
- productStatusDao.save(productStatus);
|
|
|
- ProductUtils.updateOne(prod);
|
|
|
- } catch (Exception e) {
|
|
|
- map.put("error", "更新失败");
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- map.put("success", "更新成功");
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public List<ProductMatchResult> matchaone(Long id) throws Exception {
|
|
|
List<Long> ids = new ArrayList<>();
|