|
|
@@ -1,12 +1,12 @@
|
|
|
package com.uas.platform.b2b.service.impl;
|
|
|
|
|
|
-import com.uas.sso.util.FlexJsonUtil;
|
|
|
import com.uas.platform.b2b.dao.PurchaseOrderAllDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseOrderAllItemDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseOrderCartDao;
|
|
|
import com.uas.platform.b2b.dao.VendorDao;
|
|
|
import com.uas.platform.b2b.model.*;
|
|
|
import com.uas.platform.b2b.service.CartService;
|
|
|
+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.exception.NotFoundException;
|
|
|
@@ -16,8 +16,8 @@ import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.platform.core.model.Status;
|
|
|
import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.search.b2b.model.SPage;
|
|
|
+import com.uas.sso.util.FlexJsonUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
-import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
@@ -53,26 +53,22 @@ public class CartServiceImpl implements CartService {
|
|
|
@Override
|
|
|
public SPage<PurchaseOrderAll> getCartList(PageParams params, String searchFilter) {
|
|
|
SearchFilter filter = FlexJsonUtil.fromJson(searchFilter, SearchFilter.class);
|
|
|
- SPage<PurchaseOrderAll> orders = new SPage<PurchaseOrderAll>();
|
|
|
final PageInfo pageInfo = new PageInfo(params);
|
|
|
pageInfo.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
pageInfo.filter("status", Status.UNAUDIT.value());
|
|
|
pageInfo.filter("userUU", SystemSession.getUser().getUserUU());
|
|
|
- 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));
|
|
|
+ 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<PurchaseOrderAll> ordersInfos = purchaseOrderAllDao.findAll(new Specification<PurchaseOrderAll>() {
|
|
|
public Predicate toPredicate(Root<PurchaseOrderAll> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
}
|
|
|
}, pageInfo);
|
|
|
- orders.setContent(ordersInfos.getContent());
|
|
|
- orders.setPage(ordersInfos.getNumber());
|
|
|
- orders.setTotalElement(ordersInfos.getTotalElements());
|
|
|
- orders.setSize(ordersInfos.getSize());
|
|
|
- orders.setTotalPage(ordersInfos.getTotalPages());
|
|
|
- return orders;
|
|
|
+ return SPageUtils.covertSPage(ordersInfos);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -84,8 +80,6 @@ public class CartServiceImpl implements CartService {
|
|
|
purcOrder.setStatus((short) Status.NOT_REPLY.value());
|
|
|
purcOrder.setAuditor(SystemSession.getUser().getUserName());
|
|
|
purchaseOrderAllDao.save(purcOrder);
|
|
|
- // ContextUtils.publishEvent(new
|
|
|
- // PurchaseOrderSaveReleaseEvent(PurchaseOrderAllItem.distinct(purcOrder.getOrderItems())));
|
|
|
logger.log("平台新增采购单", "新增了一张采购单(" + id + ")",
|
|
|
SystemSession.getUser().getUserUU(), SystemSession.getUser().getIp());
|
|
|
map.put("id", id);
|
|
|
@@ -113,8 +107,12 @@ public class CartServiceImpl implements CartService {
|
|
|
if (detail == null) {
|
|
|
map.put("error", "该条明细不存在,可能已被删除");
|
|
|
} else {
|
|
|
- purchaseOrderAllItemDao.delete(id);
|
|
|
- map.put("success", "该条明细已删除");
|
|
|
+ try {
|
|
|
+ purchaseOrderAllItemDao.delete(id);
|
|
|
+ map.put("success", "该条明细已删除");
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
return map;
|
|
|
}
|