|
|
@@ -1,9 +1,11 @@
|
|
|
package com.uas.ps.inquiry.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.ps.core.util.ContextUtils;
|
|
|
import com.uas.ps.entity.Product;
|
|
|
import com.uas.ps.entity.ProductUsers;
|
|
|
import com.uas.ps.entity.Status;
|
|
|
+import com.uas.ps.inquiry.AccessConfiguration;
|
|
|
import com.uas.ps.inquiry.dao.*;
|
|
|
import com.uas.ps.inquiry.entity.*;
|
|
|
import com.uas.ps.inquiry.model.*;
|
|
|
@@ -30,10 +32,7 @@ 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 javax.persistence.criteria.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@@ -118,6 +117,16 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
*/
|
|
|
private final String CONSUMERAPP = "B2B,MALL,ERP";
|
|
|
|
|
|
+ /**
|
|
|
+ * 公共物料访问地址
|
|
|
+ */
|
|
|
+ private final String PS_PRODUCT_URL = ContextUtils.getBean(AccessConfiguration.class).getPsProductUrl();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公共消息访问地址
|
|
|
+ */
|
|
|
+ private final String PS_MESSAGE_URL = ContextUtils.getBean(AccessConfiguration.class).getPsMessageUrl();
|
|
|
+
|
|
|
/**
|
|
|
* 保存公共询价信息
|
|
|
*
|
|
|
@@ -160,7 +169,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
*/
|
|
|
private void notify(List<PurcInquiryItem> inquiryItems) {
|
|
|
for (PurcInquiryItem item : inquiryItems) {
|
|
|
- String url = "http://192.168.253.12:24000/productuser/getProductUsersByEnUUAndCmpCode";
|
|
|
+ String url = PS_PRODUCT_URL + "/productuser/getProductUsersByEnUUAndCmpCode";
|
|
|
JSONObject formData = new JSONObject();
|
|
|
formData.put("enUU", item.getInquiry().getEnUU());
|
|
|
formData.put("cmpCode", item.getCmpCode());
|
|
|
@@ -173,7 +182,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
for (ProductUsers user : users) {
|
|
|
User u = userDao.findOne(user.getUseruu());
|
|
|
Enterprise e = enterpriseDao.findOne(user.getEnuu());
|
|
|
- String content = "发布公共询价信息,邀请您参与报价";
|
|
|
+ String content = "发布关于“" + item.getProduct().getTitle() + "”的公共询价信息,邀请您参与报价";
|
|
|
if (null != e) {
|
|
|
u.setEnterprise(e);
|
|
|
content = e.getEnName() + content;
|
|
|
@@ -216,7 +225,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
try {
|
|
|
- HttpUtil.doPost("http://192.168.253.131:8080", FlexJsonUtils.toJsonDeep(models));
|
|
|
+ HttpUtil.doPost(PS_MESSAGE_URL, FlexJsonUtils.toJsonDeep(models));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -236,15 +245,15 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
public List<PurcInquiry> covert(List<BatchInquiry> inquiries, Long enuu, String address) throws NotFoundException {
|
|
|
List<PurcInquiry> purcInquiries = new ArrayList<PurcInquiry>();
|
|
|
if (!CollectionUtils.isEmpty(inquiries)) {
|
|
|
- for(BatchInquiry inquiry : inquiries) {
|
|
|
+ for (BatchInquiry inquiry : inquiries) {
|
|
|
PurcInquiry old = purcInquiryDao.findByCodeAndEnUU(inquiry.getBi_code(), enuu);
|
|
|
//先判断是否已经存在,不存在才进行存储
|
|
|
- if(null == old) {
|
|
|
+ if (null == old) {
|
|
|
PurcInquiry purcInquiry = inquiry.covert();
|
|
|
purcInquiry.setEnUU(enuu);
|
|
|
purcInquiry.setShip(address);
|
|
|
Set<PurcInquiryItem> purcInquiryItems = new HashSet<PurcInquiryItem>();
|
|
|
- if(!CollectionUtils.isEmpty(inquiry.getInProducts())) {
|
|
|
+ if (!CollectionUtils.isEmpty(inquiry.getInProducts())) {
|
|
|
for(BatchInProduct batch : inquiry.getInProducts()) {
|
|
|
PurcInquiryItem item = new PurcInquiryItem();
|
|
|
item.setIsOpen(Constant.YES);
|
|
|
@@ -268,15 +277,16 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
item.setSource("ERP");
|
|
|
item.setSourceid(batch.getBip_id());
|
|
|
item.setCurrency(batch.getBip_currency());
|
|
|
- item.setUserName(batch.getEm_name());
|
|
|
+ item.setUserName(batch.getBip_buyername());
|
|
|
item.setUserTel(batch.getBip_mobile());
|
|
|
item.setUserCode(batch.getBip_buyercode());
|
|
|
- if(null != inquiry.getBi_date()) {
|
|
|
+ item.setOfferAmount(0);
|
|
|
+ if (null != inquiry.getBi_date()) {
|
|
|
item.setDate(inquiry.getBi_date());
|
|
|
} else {
|
|
|
- item.setDate(new Date());
|
|
|
+ item.setDate(new Date(System.currentTimeMillis()));
|
|
|
}
|
|
|
- if(item.getCurrency() == null) {
|
|
|
+ if (item.getCurrency() == null) {
|
|
|
item.setCurrency("RMB");
|
|
|
}
|
|
|
purcInquiryItems.add(item);
|
|
|
@@ -632,14 +642,13 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
@Override
|
|
|
public Page<PublicInquiryItemInfo> findByPageInfo(final PageInfo info, final SearchFilter filter) {
|
|
|
if (null != filter) {
|
|
|
- int k = 0;
|
|
|
- SimpleExpression[] simpArrs = new SimpleExpression[4];
|
|
|
if (StringUtils.hasText(filter.getKeyword())) {
|
|
|
- simpArrs[k] = new SimpleExpression("product.title", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
- simpArrs[k + 1] = new SimpleExpression("product.code", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
- simpArrs[k + 2] = new SimpleExpression("product.spec", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
- simpArrs[k + 3] = new SimpleExpression("product.brand", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
- LogicalExpression logical = new LogicalExpression(simpArrs, CriterionExpression.Operator.OR);
|
|
|
+ SimpleExpression title = new SimpleExpression("product.title", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
+ SimpleExpression code = new SimpleExpression("product.code", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
+ SimpleExpression spec = new SimpleExpression("product.spec", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
+ SimpleExpression brand = new SimpleExpression("product.brand", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
+ SimpleExpression[] simpleExpressions = new SimpleExpression[]{title, brand, code, spec};
|
|
|
+ LogicalExpression logical = new LogicalExpression(simpleExpressions, CriterionExpression.Operator.OR);
|
|
|
info.expression(logical);
|
|
|
}
|
|
|
if (filter.getFromDate() != null) {
|
|
|
@@ -676,9 +685,10 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
|
|
|
info.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(filter.getKeyword())) {
|
|
|
- SimpleExpression code = new SimpleExpression("cmpCode", filter.getKeyword(), CriterionExpression.Operator.LIKE);
|
|
|
+ SimpleExpression cmpCode = new SimpleExpression("cmpCode", filter.getKeyword(), CriterionExpression.Operator.LIKE);
|
|
|
SimpleExpression brand = new SimpleExpression("inbrand", filter.getKeyword(), CriterionExpression.Operator.LIKE);
|
|
|
- SimpleExpression[] simpleExpressions = new SimpleExpression[]{code, brand};
|
|
|
+ SimpleExpression code = new SimpleExpression("product.cmpCode", filter.getKeyword(), CriterionExpression.Operator.LIKE);
|
|
|
+ SimpleExpression[] simpleExpressions = new SimpleExpression[]{cmpCode, brand, code};
|
|
|
LogicalExpression logicalExpression = PredicateUtils.or(simpleExpressions);
|
|
|
info.expression(logicalExpression);
|
|
|
}
|