|
|
@@ -1,7 +1,9 @@
|
|
|
package com.uas.ps.inquiry.service.impl;
|
|
|
|
|
|
+import com.uas.ps.core.util.ContextUtils;
|
|
|
import com.uas.ps.entity.Product;
|
|
|
import com.uas.ps.entity.Status;
|
|
|
+import com.uas.ps.inquiry.AccessConfiguration;
|
|
|
import com.uas.ps.inquiry.dao.*;
|
|
|
import com.uas.ps.inquiry.domain.IPage;
|
|
|
import com.uas.ps.inquiry.entity.Constant;
|
|
|
@@ -15,7 +17,10 @@ import com.uas.ps.inquiry.page.criteria.PredicateUtils;
|
|
|
import com.uas.ps.inquiry.page.criteria.SimpleExpression;
|
|
|
import com.uas.ps.inquiry.page.exception.IllegalOperatorException;
|
|
|
import com.uas.ps.inquiry.service.InquiryForSaleService;
|
|
|
+import com.uas.ps.inquiry.util.FlexJsonUtils;
|
|
|
+import com.uas.ps.inquiry.util.HttpUtil;
|
|
|
import com.uas.ps.inquiry.util.IPageUtils;
|
|
|
+import com.uas.ps.inquiry.util.ThreadUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
@@ -29,6 +34,7 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -66,6 +72,11 @@ public class InquiryForSaleServiceImpl implements InquiryForSaleService {
|
|
|
@Autowired
|
|
|
private ProductDao productDao;
|
|
|
|
|
|
+ /**
|
|
|
+ * 公共物料访问地址
|
|
|
+ */
|
|
|
+ private final String PS_PRODUCT_URL = ContextUtils.getBean(AccessConfiguration.class).getPsProductUrl();
|
|
|
+
|
|
|
/**
|
|
|
* 通过明细查询询价详情
|
|
|
*
|
|
|
@@ -260,18 +271,57 @@ public class InquiryForSaleServiceImpl implements InquiryForSaleService {
|
|
|
inquiryItem.setDecideStatus((short) Status.UNAUDIT.value());
|
|
|
items.add(inquiryItem);
|
|
|
}
|
|
|
- List<PublicInquiryItem> purcitems = infoDao.save(items);
|
|
|
+ final List<PublicInquiryItem> publicInquiryItems = infoDao.save(items);
|
|
|
// 更新原表的报价条数
|
|
|
- purcInquiryItemDao.updateAmount(purcitems.get(0).getSourceId(), purcitems.size());
|
|
|
+ purcInquiryItemDao.updateAmount(publicInquiryItems.get(0).getSourceId(), publicInquiryItems.size());
|
|
|
// 更新推荐表中的相关信息
|
|
|
remindDao.updateStatus(inquiryItem.getSourceId(), Status.SUBMITTED.value(), inquiryItem.getVendUU());
|
|
|
- if (purcitems.get(0).getId() != null) {
|
|
|
- return purcitems.get(0);
|
|
|
+ ThreadUtils.task(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ // 同步物料信息
|
|
|
+ syscProduct(publicInquiryItems);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).run();
|
|
|
+ if (publicInquiryItems.get(0).getId() != null) {
|
|
|
+ return publicInquiryItems.get(0);
|
|
|
} else {
|
|
|
throw new Exception("转询价报价单失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 转报价后进行物料同步
|
|
|
+ *
|
|
|
+ * @param publicInquiryItems
|
|
|
+ */
|
|
|
+ private void syscProduct(List<PublicInquiryItem> publicInquiryItems) throws Exception {
|
|
|
+ for (PublicInquiryItem item : publicInquiryItems) {
|
|
|
+ List<Product> products = new ArrayList<>();
|
|
|
+ List<Product> productList = productDao.findByEnUUAndCmpCodeAndBrand(item.getVendUU(), item.getCmpCode(), item.getInbrand());
|
|
|
+ if (CollectionUtils.isEmpty(productList)) {
|
|
|
+ Product product = new Product();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyymmddsss");
|
|
|
+ product.setCode(sdf.format(new Date()) + item.getCmpCode());
|
|
|
+ product.setBrand(item.getInbrand());
|
|
|
+ product.setCmpCode(item.getCmpCode());
|
|
|
+ product.setTitle(item.getProdTitle());
|
|
|
+ product.setSpec(item.getSpec());
|
|
|
+ product.setEnUU(item.getVendUU());
|
|
|
+ product.setUserUU(item.getVendUserUU());
|
|
|
+ product.setIsSale(Constant.YES);
|
|
|
+ products.add(product);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(products)) {
|
|
|
+ HttpUtil.doPost(PS_PRODUCT_URL + "product/update/b2b", FlexJsonUtils.toJsonDeep(products));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过id查询公共询价详情
|
|
|
*
|