Browse Source

app采购单、询价单筛选接口修改;回复接口增加判空。

dongbw 8 years ago
parent
commit
904ac5936e

+ 22 - 7
src/main/java/com/uas/platform/b2b/mobile/controller/AppInquiryController.java

@@ -1,7 +1,6 @@
 package com.uas.platform.b2b.mobile.controller;
 
 import com.uas.account.support.Page;
-import com.uas.platform.b2b.model.PurchaseInquiry;
 import com.uas.platform.b2b.model.PurchaseInquiryItem;
 import com.uas.platform.b2b.model.PurchaseInquiryReply;
 import com.uas.platform.b2b.model.SearchFilter;
@@ -24,7 +23,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -81,6 +83,7 @@ public class AppInquiryController {
                 pageParams.getFilters().put("id_inid", new MultiValue(list, true));
             }
             List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("id_status", true, Sort.Type.LONG, new Long(1)));
             sortList.add(new Sort("id_id", false, Sort.Type.LONG, new Long(1)));
             pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
             Page<PurchaseInquiryItem> purchaseInquiryItemPage = searchService.searchPurchaseInquiryItemIdsForApp(keyword, pageParams);
@@ -90,6 +93,12 @@ public class AppInquiryController {
         } else {
             PageInfo pageInfo = new PageInfo(page, size);
             pageInfo.filter("vendUU", SystemSession.getUser().getEnterprise().getUu());
+            org.springframework.data.domain.Sort.Order statusOrder = new org.springframework.data.domain.Sort.Order(org.springframework.data.domain.Sort.Direction.ASC, "status");
+            org.springframework.data.domain.Sort.Order idOrder = new org.springframework.data.domain.Sort.Order(org.springframework.data.domain.Sort.Direction.DESC, "id");
+            List<org.springframework.data.domain.Sort.Order> orders = new ArrayList<>();
+            orders.add(statusOrder);
+            orders.add(idOrder);
+            pageInfo.setSort(new org.springframework.data.domain.Sort(orders));
             SearchFilter filter = new SearchFilter();
             SearchFilter distribute = userService.distribute();
             if (distribute != null && distribute.getDistribute() == null) {
@@ -457,9 +466,9 @@ public class AppInquiryController {
     }
 
     /**
-     * 作为卖家,根据询价单ID查找询价单(含明细)
+     * 作为卖家,根据询价单明细ID查找询价单(含明细)
      *
-     * @param id 询价单id
+     * @param itemId 询价单明细id
      * @return
      */
     @RequestMapping(value = "/{itemId}/info", method = RequestMethod.GET)
@@ -497,9 +506,15 @@ public class AppInquiryController {
     private PurchaseInquiryItem toItem(Long inquiryItemId, String replies, Long leadtime, Double minOrderQty, Double minPackQty) {
         List<PurchaseInquiryReply> replyList = FlexJsonUtils.fromJsonArray(replies, PurchaseInquiryReply.class);
         PurchaseInquiryItem item = purchaseInquiryService.findItemByItemId(inquiryItemId);
-        item.setLeadtime(leadtime);
-        item.setMinPackQty(minPackQty);
-        item.setMinOrderQty(minOrderQty);
+        if (null != leadtime) {
+            item.setLeadtime(leadtime);
+        }
+        if (null != minPackQty) {
+            item.setMinPackQty(minPackQty);
+        }
+        if (null != minOrderQty) {
+            item.setMinOrderQty(minOrderQty);
+        }
         HashSet<PurchaseInquiryReply> replyHashSet = new HashSet<>(replyList);
         item.setReplies(replyHashSet);
         return item;

+ 7 - 0
src/main/java/com/uas/platform/b2b/mobile/controller/SaleController.java

@@ -160,6 +160,7 @@ public class SaleController {
 			}
 			// TODO 其他过滤条件
 			List<Sort> sortList = new ArrayList<>();
+			sortList.add(new Sort("pu_status", true, Sort.Type.LONG, 1L));
 			sortList.add(new Sort("pu_id", false, Sort.Type.LONG, 1L));
 			pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
 			Map<String, Object> map = new HashMap<String, Object>();
@@ -174,6 +175,12 @@ public class SaleController {
 					SystemSession.getUser().getEnterprise().getUu(), OrderType.sale.name());
 			PageInfo pageInfo = new PageInfo(page, size);
 			pageInfo.filter("vendUU", SystemSession.getUser().getEnterprise().getUu());
+			org.springframework.data.domain.Sort.Order statusOrder = new org.springframework.data.domain.Sort.Order(org.springframework.data.domain.Sort.Direction.ASC, "status");
+			org.springframework.data.domain.Sort.Order idOrder = new org.springframework.data.domain.Sort.Order(org.springframework.data.domain.Sort.Direction.DESC, "id");
+			List<org.springframework.data.domain.Sort.Order> orders = new ArrayList<>();
+			orders.add(statusOrder);
+			orders.add(idOrder);
+			pageInfo.setSort(new org.springframework.data.domain.Sort(orders));
 			SearchFilter filter = new SearchFilter();
 			SearchFilter distribute = userService.distribute();
 			if (distribute != null && distribute.getDistribute() == null) {

+ 3 - 1
src/main/java/com/uas/platform/b2b/mobile/model/OrderReply.java

@@ -67,7 +67,9 @@ public class OrderReply {
         PurchaseOrderReply reply = new PurchaseOrderReply();
         reply.setDelivery(this.delivery);
         reply.setQty(this.qty);
-        reply.setRemark(this.remark);
+        if (null != this.remark) {
+            reply.setRemark(this.remark);
+        }
         return reply;
     }
 }

+ 1 - 1
src/main/java/com/uas/platform/b2b/service/ProductService.java

@@ -193,7 +193,7 @@ public interface ProductService {
 	 * 禁用物料
 	 * @param code
 	 */
-	public int updateB2bEnabled(String code, Short b2benabled);
+	public int updateB2bEnabled(String code, Short b2bDisabled);
 
 	/**
 	 * ERP个人物料同步到平台

+ 1 - 1
src/main/java/com/uas/platform/b2b/service/impl/ProductServiceImpl.java

@@ -465,7 +465,7 @@ public class ProductServiceImpl implements ProductService {
 			public Predicate toPredicate(Root<Product> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
 				pageInfo.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
 				pageInfo.expression(
-						PredicateUtils.or(PredicateUtils.isNull("b2benabled"), PredicateUtils.eq("b2benabled", Constant.NO, false)));
+						PredicateUtils.or(PredicateUtils.isNull("productStatus.b2bDisabled"), PredicateUtils.eq("productStatus.b2bDisabled", Constant.NO, false)));
 				query.where(pageInfo.getPredicates(root, query, builder));
 				return null;
 			}

+ 5 - 3
src/main/java/com/uas/platform/b2b/service/impl/SaleQuotationServiceImpl.java

@@ -80,9 +80,11 @@ public class SaleQuotationServiceImpl implements SaleQuotationService {
 
 	@Override
 	public void onReplyDecide(List<SaleQuotationItem> quotationItems) {
-		saleQuotationItemDao.save(quotationItems);
-		saleQuotationDao.save(quotationItems.get(0).getQuotation());
-		ContextUtils.publishEvent(new SaleQuotationDecideReleaseEvent(quotationItems));
+		if (!CollectionUtils.isEmpty(quotationItems)) {
+			saleQuotationItemDao.save(quotationItems);
+			saleQuotationDao.save(quotationItems.get(0).getQuotation());
+			ContextUtils.publishEvent(new SaleQuotationDecideReleaseEvent(quotationItems));
+		}
 	}
 
 	@Override

+ 6 - 4
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -379,21 +379,23 @@ public class VendorsServiceImpl implements VendorService {
 					User admin = userDao.findOne(vendor.getEnAdminuu());
 					vendor.setAdmin(admin);
 				}
+				PageInfo pageInfo = new PageInfo(1, 5);
 				final PredicateFactory<Product> factory = new PredicateFactory<>();
 				factory.add(PredicateUtils.eq("enUU", enUU, false));
 				factory.add(PredicateUtils.in("cmpCode", cmpCodes, false));
-				List<Product> hitsProducts = productDao.findAll(new Specification<Product>() {
+				// 获取前五条匹配物料
+				Page<Product> hitsProducts = productDao.findAll(new Specification<Product>() {
 					@Override
 					public Predicate toPredicate(Root<Product> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
 						query.where(factory.toPredicate(root, query, cb));
 						query.orderBy(cb.desc(root.get("id").as(Long.class)));
 						return null;
 					}
-				});
+				}, pageInfo);
 				VendorRecommend vendorRecommend = new VendorRecommend();
 				vendorRecommend.setEnterprise(vendor);
-				vendorRecommend.setHitProds(hitsProducts);
-				vendorRecommend.setHitNums(hitsProducts.size());
+				vendorRecommend.setHitProds(hitsProducts.getContent());
+				vendorRecommend.setHitNums(hitsProducts.getNumberOfElements());
 				content.add(vendorRecommend);
 			}
 		}