|
|
@@ -6,15 +6,12 @@ import com.uas.platform.b2b.core.util.ThreadTask;
|
|
|
import com.uas.platform.b2b.dao.*;
|
|
|
import com.uas.platform.b2b.erp.model.PurchaseNotify;
|
|
|
import com.uas.platform.b2b.event.SaleSendAcceptReleaseEvent;
|
|
|
-import com.uas.platform.b2b.event.SaleSendRefuseReleaseEvent;
|
|
|
import com.uas.platform.b2b.model.*;
|
|
|
import com.uas.platform.b2b.ps.service.PersonalProductService;
|
|
|
import com.uas.platform.b2b.search.SearchService;
|
|
|
import com.uas.platform.b2b.service.PurchaseNoticeService;
|
|
|
-import com.uas.platform.b2b.support.CollectionUtil;
|
|
|
-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.b2b.service.UserService;
|
|
|
+import com.uas.platform.b2b.support.*;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
@@ -47,6 +44,7 @@ import java.util.*;
|
|
|
public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
|
|
|
private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private PurchaseNoticeDao purchaseNoticeDao;
|
|
|
|
|
|
@@ -104,6 +102,9 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Autowired
|
|
|
private PurchaseNoticeEndDao noticeEndDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
/**
|
|
|
* 最多数量
|
|
|
*/
|
|
|
@@ -241,7 +242,10 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
saleSendItemDao.save(sendItems);
|
|
|
for (SaleSendItem item : sendItems) {
|
|
|
if (item.getNoticeId() != null) {
|
|
|
- purchaseNoticeDao.updateBySend(item.getNoticeId());
|
|
|
+ Double sendQty = saleSendItemDao.getSendQtyByNoticeId(item.getNoticeId());
|
|
|
+ purchaseNoticeDao.updateBySend(item.getNoticeId(), sendQty);
|
|
|
+ logger.log("更新发货提醒发货数量", "ERP主动收料通知单/上传发货单更新发货提醒已发货数量",
|
|
|
+ "发货单: " + item.getNoticeId() + ",更新数量: " + sendQty);
|
|
|
// 更新发货状态
|
|
|
updateNoticeStatus(item.getNoticeId());
|
|
|
}
|
|
|
@@ -472,18 +476,16 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
|
|
|
@Override
|
|
|
public void onSaleSendChange(List<SaleSendItem> sendItems) {
|
|
|
- List<Long> ids = new ArrayList<>();
|
|
|
for (SaleSendItem item : sendItems) {
|
|
|
saleSendItemDao.updateByReply(item.getId(), item.getQty(), item.getReplyRemark());
|
|
|
if (item.getNoticeId() != null) {
|
|
|
- purchaseNoticeDao.updateBySend(item.getNoticeId());
|
|
|
+ Double sendQty = saleSendItemDao.getSendQtyByNoticeId(item.getNoticeId());
|
|
|
+ purchaseNoticeDao.updateBySend(item.getNoticeId(), sendQty);
|
|
|
+ logger.log("更新发货提醒发货数量", "ERP上传收料通知的确认数量更新发货提醒已发货数量",
|
|
|
+ "发货单: " + item.getNoticeId() + ",更新数量: " + sendQty);
|
|
|
updateNoticeStatus(item.getNoticeId());
|
|
|
- ids.add(item.getNoticeId());
|
|
|
}
|
|
|
}
|
|
|
- List<PurchaseNotice> notices = purchaseNoticeDao.findAll(ids);
|
|
|
- // 买家拒收之后给卖家发消息
|
|
|
- ContextUtils.publishEvent(new SaleSendRefuseReleaseEvent(SaleSendItem.distinct(sendItems)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1060,27 +1062,128 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
*/
|
|
|
@Override
|
|
|
public SPage<PurchaseNotice> findAllNoticesByPageInfo(final PageInfo pageInfo, String keyword, final SearchFilter filter) {
|
|
|
+ if (filter != null) {
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
+ }
|
|
|
+ if (filter.getFromDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
|
|
|
+ }
|
|
|
+ if (filter.getEndDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pageInfo.expression(PredicateUtils.isNull("end"));
|
|
|
Page<PurchaseNotice> notices = purchaseNoticeDao.findAll(new Specification<PurchaseNotice>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
- if (filter != null) {
|
|
|
- if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
- pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
+ List<Predicate> predicatesList = new ArrayList<Predicate>();
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ Predicate custName = builder.like(root.get("orderItem").get("order").get("enterprise").get("enName"), "%" + keyword+ "%");
|
|
|
+ if (keyword.matches(SearchUtils.UU_REGEXP)) {
|
|
|
+ Predicate custUU = builder.like(root.get("orderItem").get("order").get("enterprise").get("uu"), "%" + keyword+ "%");
|
|
|
+ builder.or(custUU);
|
|
|
}
|
|
|
- if (filter.getFromDate() != null) {
|
|
|
- pageInfo.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
|
|
|
- }
|
|
|
- if (filter.getEndDate() != null) {
|
|
|
- pageInfo.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
|
|
|
+ Predicate productCode = builder.like(root.get("orderItem").get("productCode"), "%" + keyword+ "%");
|
|
|
+ Predicate productTitle = builder.like(root.get("orderItem").get("productTitle"), "%" + keyword+ "%");
|
|
|
+ Predicate productSpec = builder.like(root.get("orderItem").get("productSpec"), "%" + keyword+ "%");
|
|
|
+ Predicate orderCode = builder.like(root.get("orderItem").get("order").get("code"), "%" + keyword+ "%");
|
|
|
+ predicatesList.add(builder.or(custName, productCode, productTitle, productSpec, orderCode));
|
|
|
+ }
|
|
|
+ Predicate[] predicates = pageInfo.getPredicates(root, query, builder);
|
|
|
+ Arrays.stream(predicates).forEach(predicate -> {
|
|
|
+ predicatesList.add(predicate);
|
|
|
+ });
|
|
|
+ return builder.and(predicatesList.toArray(new Predicate[predicatesList.size()]));
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
+ return SPageUtils.covertSPage(notices);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按条件查询发货提醒
|
|
|
+ *
|
|
|
+ * @param pageInfo 分页信息,过滤条件
|
|
|
+ * @param keyword 搜索词
|
|
|
+ * @param filter 过滤条件
|
|
|
+ * @param state 状态
|
|
|
+ * @return SPage封装的数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public SPage<PurchaseNotice> findNoticesByPageInfo(PageInfo pageInfo, String keyword, SearchFilter filter, String state) {
|
|
|
+ // 根据状态设置其他条件
|
|
|
+ setState(pageInfo, state, filter);
|
|
|
+ if (filter != null) {
|
|
|
+ if (!CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ pageInfo.expression(PredicateUtils.in("enUU", filter.getDistribute(), false));
|
|
|
+ }
|
|
|
+ if (filter.getFromDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
|
|
|
+ }
|
|
|
+ if (filter.getEndDate() != null) {
|
|
|
+ pageInfo.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Page<PurchaseNotice> notices = purchaseNoticeDao.findAll(new Specification<PurchaseNotice>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<PurchaseNotice> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
+ List<Predicate> predicatesList = new ArrayList<Predicate>();
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ Predicate custName = builder.like(root.get("orderItem").get("order").get("enterprise").get("enName"), "%" + keyword+ "%");
|
|
|
+ if (keyword.matches(SearchUtils.UU_REGEXP)) {
|
|
|
+ Predicate custUU = builder.like(root.get("orderItem").get("order").get("enterprise").get("uu"), "%" + keyword+ "%");
|
|
|
+ builder.or(custUU);
|
|
|
}
|
|
|
+ Predicate productCode = builder.like(root.get("orderItem").get("productCode"), "%" + keyword+ "%");
|
|
|
+ Predicate productTitle = builder.like(root.get("orderItem").get("productTitle"), "%" + keyword+ "%");
|
|
|
+ Predicate productSpec = builder.like(root.get("orderItem").get("productSpec"), "%" + keyword+ "%");
|
|
|
+ Predicate orderCode = builder.like(root.get("orderItem").get("order").get("code"), "%" + keyword+ "%");
|
|
|
+ predicatesList.add(builder.or(custName, productCode, productTitle, productSpec, orderCode));
|
|
|
}
|
|
|
- pageInfo.expression(PredicateUtils.isNull("end"));
|
|
|
- return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
+ Predicate[] predicates = pageInfo.getPredicates(root, query, builder);
|
|
|
+ Arrays.stream(predicates).forEach(predicate -> {
|
|
|
+ predicatesList.add(predicate);
|
|
|
+ });
|
|
|
+ return builder.and(predicatesList.toArray(new Predicate[predicatesList.size()]));
|
|
|
}
|
|
|
}, pageInfo);
|
|
|
return SPageUtils.covertSPage(notices);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 封装相关查询条件
|
|
|
+ *
|
|
|
+ * @param pageInfo 分页参数
|
|
|
+ * @param state 状态
|
|
|
+ * <pre>
|
|
|
+ * _todo : 待发货
|
|
|
+ * done: 已发货
|
|
|
+ * end: 已取消
|
|
|
+ * </pre>
|
|
|
+ * @param filter 过滤条件
|
|
|
+ */
|
|
|
+ private void setState(PageInfo pageInfo, String state, SearchFilter filter) {
|
|
|
+ pageInfo.filter("vendUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SearchFilter distribute = userService.distribute();
|
|
|
+ if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ list.addAll(distribute.getDistribute());
|
|
|
+ filter.setDistribute(list);
|
|
|
+ }
|
|
|
+ if (SearchUtils.TODO_STATE.equals(state)) {
|
|
|
+ pageInfo.expression(PredicateUtils.or(PredicateUtils.isNull("end"), PredicateUtils.eq("end", Constant.NO, false)));
|
|
|
+ pageInfo.filter("status", (short)Status.NOT_REPLY.value());
|
|
|
+ pageInfo.filter("waiting", Constant.NO);
|
|
|
+ } else if (SearchUtils.DONE_STATE.equals(state)) {
|
|
|
+ pageInfo.expression(PredicateUtils.or(PredicateUtils.isNull("end"), PredicateUtils.eq("end", Constant.NO, false)));
|
|
|
+ pageInfo.filter("status", (short)Status.REPLIED.value());
|
|
|
+ } else if (SearchUtils.END_STATE.equals(state)) {
|
|
|
+ pageInfo.filter("end", Constant.YES);
|
|
|
+ } else if (SearchUtils.WAITING_STATE.equals(state)) {
|
|
|
+ pageInfo.filter("waiting", Constant.YES);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void setReadByOrder(String category, Long[] sourceId) {
|