|
@@ -2,18 +2,33 @@ package com.uas.ps.inquiry.service.impl;
|
|
|
|
|
|
|
|
import com.uas.ps.entity.Status;
|
|
import com.uas.ps.entity.Status;
|
|
|
import com.uas.ps.inquiry.dao.*;
|
|
import com.uas.ps.inquiry.dao.*;
|
|
|
|
|
+import com.uas.ps.inquiry.domain.IPage;
|
|
|
import com.uas.ps.inquiry.entity.Constant;
|
|
import com.uas.ps.inquiry.entity.Constant;
|
|
|
import com.uas.ps.inquiry.entity.InquirySource;
|
|
import com.uas.ps.inquiry.entity.InquirySource;
|
|
|
import com.uas.ps.inquiry.model.*;
|
|
import com.uas.ps.inquiry.model.*;
|
|
|
|
|
+import com.uas.ps.inquiry.page.PageInfo;
|
|
|
|
|
+import com.uas.ps.inquiry.page.SearchFilter;
|
|
|
|
|
+import com.uas.ps.inquiry.page.criteria.CriterionExpression;
|
|
|
|
|
+import com.uas.ps.inquiry.page.criteria.LogicalExpression;
|
|
|
|
|
+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.page.exception.IllegalOperatorException;
|
|
|
import com.uas.ps.inquiry.service.InquiryForSaleService;
|
|
import com.uas.ps.inquiry.service.InquiryForSaleService;
|
|
|
|
|
+import com.uas.ps.inquiry.util.IPageUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
import org.springframework.dao.DataAccessException;
|
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
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.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -45,6 +60,9 @@ public class InquiryForSaleServiceImpl implements InquiryForSaleService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PurcInquiryItemDao purcInquiryItemDao;
|
|
private PurcInquiryItemDao purcInquiryItemDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private InquiryRemindDao remindDao;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 通过明细查询询价详情
|
|
* 通过明细查询询价详情
|
|
|
*
|
|
*
|
|
@@ -309,4 +327,70 @@ public class InquiryForSaleServiceImpl implements InquiryForSaleService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 通过分页信息查询询价推荐信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param pageInfo 分页信息
|
|
|
|
|
+ * @param filter 过滤条件
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public IPage<InquiryRemind> findRemindByPageInfo(final PageInfo pageInfo, final SearchFilter filter) {
|
|
|
|
|
+ if (null != filter) {
|
|
|
|
|
+ if (StringUtils.hasText(filter.getKeyword())) {
|
|
|
|
|
+ SimpleExpression title = new SimpleExpression("title", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
|
|
+ SimpleExpression cmpCode = new SimpleExpression("cmpCode", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
|
|
+ SimpleExpression spec = new SimpleExpression("spec", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
|
|
+ SimpleExpression brand = new SimpleExpression("brand", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
|
|
+ SimpleExpression enName = new SimpleExpression("enName", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
|
|
+ SimpleExpression userName = new SimpleExpression("userName", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
|
|
|
|
|
+ SimpleExpression[] simpleExpressions = new SimpleExpression[]{title, brand, cmpCode, spec, enName, userName};
|
|
|
|
|
+ LogicalExpression logical = new LogicalExpression(simpleExpressions, CriterionExpression.Operator.OR);
|
|
|
|
|
+ pageInfo.expression(logical);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (filter.getFromDate() != null) {
|
|
|
|
|
+ pageInfo.expression(PredicateUtils.gte("reDate", new Date(filter.getFromDate()), false));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (filter.getEndDate() != null) {
|
|
|
|
|
+ pageInfo.expression(PredicateUtils.lte("reDate", new Date(filter.getEndDate()), false));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Page reminds = remindDao.findAll(new Specification<InquiryRemind>() {
|
|
|
|
|
+ public Predicate toPredicate(Root<InquiryRemind> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
|
|
+ query.where(pageInfo.getPredicates(root, query, builder));
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }, pageInfo);
|
|
|
|
|
+ return covert(reminds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将查询的分页信息封装成需要的数据
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param reminds 推荐询价信息
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private IPage<InquiryRemind> covert(Page reminds) {
|
|
|
|
|
+ IPage<InquiryRemind> remindIPage = IPageUtils.covertIgnoreContent(reminds);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(reminds.getContent())) {
|
|
|
|
|
+ List<InquiryRemind> remindList = reminds.getContent();
|
|
|
|
|
+ for (InquiryRemind remind : remindList) {
|
|
|
|
|
+ PublicInquiryItem item = infoDao.findByVendUUAndSourceId(remind.getVendUU(), remind.getItemId());
|
|
|
|
|
+ if (null != item) {
|
|
|
|
|
+ remind.setNewId(item.getId());
|
|
|
|
|
+ remind.setStatus(Status.SUBMITTED.value());
|
|
|
|
|
+ if (null != item.getAgreed()) {
|
|
|
|
|
+ if (item.getAgreed().equals(Constant.YES)) {
|
|
|
|
|
+ remind.setStatus(Status.ALLOW.value());
|
|
|
|
|
+ } else if (item.getAgreed().equals(Constant.NO)) {
|
|
|
|
|
+ remind.setStatus(Status.NOTALLOW.value());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ remindIPage.setContent(remindList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return remindIPage;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|