Browse Source

代码合并

hejq 7 years ago
parent
commit
8fb5bc859a

+ 16 - 6
src/main/java/com/uas/platform/b2b/dao/PurchaseNoticeDao.java

@@ -68,14 +68,15 @@ public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNoti
 	@Query("select count(n) from PurchaseNotice n where n.vendUU = :vendUU and n.status = :status and n.waiting = 0")
 	int getCountByVendUUAndStatus(@Param("vendUU") long vendUU, @Param("status") short status);
 
-	/**
-	 * 按发货单更新通知单的发货数
-	 * @param id 发货单id
-	 */
+    /**
+     * 按发货单更新通知单的发货数
+     * @param id 发货单id
+     * @param sendQty 已发货数量
+     */
 	@Modifying(clearAutomatically = true)
     @Transactional(rollbackFor = SQLException.class)
-	@Query("update PurchaseNotice n set n.endQty=(select sum(s.qty) from SaleSendItem s where s.notice=n) where n.id= :id")
-	void updateBySend(@Param("id") long id);
+	@Query("update PurchaseNotice n set n.endQty= :sendQty where n.id= :id")
+	void updateBySend(@Param("id") long id, @Param("sendQty") Double sendQty);
 	
 	/**
 	 * 根据截止日期获取(交货日期)
@@ -179,4 +180,13 @@ public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNoti
 	 */
 	@Query("select p.id from PurchaseNotice p where  p.date >= :date")
 	List<Long> findByDate( @Param("date") Date date);
+
+    /**
+     * 根据采购明细Id查询已发货的数量
+     *
+     * @param itemId 采购明细id
+     * @return
+     */
+    @Query("select sum(p.endQty) from PurchaseNotice p where p.orderItemId = :itemId")
+	Double getSendQtyByItemId(@Param("itemId") Long itemId);
 }

+ 16 - 7
src/main/java/com/uas/platform/b2b/dao/SaleSendItemDao.java

@@ -1,7 +1,6 @@
 package com.uas.platform.b2b.dao;
 
-import java.util.List;
-
+import com.uas.platform.b2b.model.SaleSendItem;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
@@ -10,10 +9,10 @@ import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.uas.platform.b2b.model.SaleSendItem;
+import java.sql.SQLException;
+import java.util.List;
 
 @Repository
-@Transactional
 public interface SaleSendItemDao extends JpaSpecificationExecutor<SaleSendItem>, JpaRepository<SaleSendItem, Long> {
 
 	/**
@@ -40,6 +39,7 @@ public interface SaleSendItemDao extends JpaSpecificationExecutor<SaleSendItem>,
 	 */
 	@Modifying(clearAutomatically = true)
 	@Query("update SaleSendItem s set s.qty = :qty,s.replyRemark = :remark where s.id= :id")
+	@Transactional(rollbackFor = SQLException.class)
 	public void updateByReply(@Param("id") long id, @Param("qty") double qty, @Param("remark") String remark);
 	
 	/**
@@ -50,6 +50,7 @@ public interface SaleSendItemDao extends JpaSpecificationExecutor<SaleSendItem>,
 	@Modifying(clearAutomatically = true)
 	@Query(nativeQuery = true,
 		value = "update sale$senditem si set si_verifyqty = (select sum(siv_qty) from SALE$SENDITEMVERIFY siv where siv.SIV_SENDITEMID = si.SI_ID ), si_okqty = (select sum(siv_okqty) from SALE$SENDITEMVERIFY siv where siv.SIV_SENDITEMID = si.SI_ID ), si_notokqty = (select sum(siv_notokqty) from SALE$SENDITEMVERIFY siv where siv.SIV_SENDITEMID = si.SI_ID ) where si.si_id= :id")
+	@Transactional(rollbackFor = SQLException.class)
 	public void updateByVerify(@Param("id") long id);
 	
 	/**
@@ -76,8 +77,16 @@ public interface SaleSendItemDao extends JpaSpecificationExecutor<SaleSendItem>,
 	 */
 	@Modifying
 	@Query("update SaleSendItem s set s.packageQty = :packageQty,s.outBoxQty = :outBoxQty where s.id= :id")
-	public void updatePackageQty(@Param("id") long id, @Param("packageQty") Double packageQty, @Param("outBoxQty") Double outBoxQty);
-	
-	
+	@Transactional(rollbackFor = SQLException.class)
+	void updatePackageQty(@Param("id") long id, @Param("packageQty") Double packageQty, @Param("outBoxQty") Double outBoxQty);
+
+    /**
+     * 根据发货提醒id获取已发货数量
+     *
+     * @param noticeId 发货提醒id
+     * @return 该发货提醒已发货的数量
+     */
+	@Query("select sum(s.qty) from SaleSendItem s where s.noticeId= :noticeId")
+	Double getSendQtyByNoticeId(@Param("noticeId") Long noticeId);
 
 }

+ 19 - 19
src/main/java/com/uas/platform/b2b/erp/service/impl/PurchaseNotifyServiceImpl.java

@@ -70,25 +70,25 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
 					remark = existNotice.getRemark() + "; ";
 				}
 				// 对卖家传输状态 // 待上传
-                existNotice.setSendStatus((short) Status.NOT_UPLOAD.value());
+				existNotice.setSendStatus((short) Status.NOT_UPLOAD.value());
 				if (existNotice.getQty() != null && !existNotice.getQty().equals(notice.getQty())) {
-					if (existNotice.getEndQty() > notice.getQty()) {
-						// 已发货数大于新的需求数,修改平台上的需求数为已发货数,将已发货数量传回买家ERP修改发货提醒的数量
-						existNotice.setRemark(remark + dateString + "修改需求数量:" + existNotice.getQty() + " -> "
-								+ existNotice.getEndQty());
-						// 需求数量
-						existNotice.setQty(existNotice.getEndQty());
-						// 状态  已回复
-						existNotice.setStatus((short) Status.REPLIED.value());
-						notices.add(existNotice);
-					} else {
-						// 已发货数小于或等于新的需求数,修改平台上的需求数为新的需求数
-						existNotice.setRemark(
-								remark + dateString + "修改需求数量:" + existNotice.getQty() + " -> " + notice.getQty());
-						existNotice.setQty(notice.getQty());
-						existNotice.setDelivery(notice.getDelivery());
-						notices.add(existNotice);
-					}
+                    if (existNotice.getEndQty() > notice.getQty()) {
+                        // 已发货数大于新的需求数,修改平台上的需求数为已发货数,将已发货数量传回买家ERP修改发货提醒的数量
+                        existNotice.setRemark(remark + dateString + "修改需求数量," + existNotice.getQty() + " -> "
+                                + existNotice.getEndQty());
+                        // 需求数量
+                        existNotice.setQty(existNotice.getEndQty());
+                        // 状态  已回复
+                        existNotice.setStatus((short) Status.REPLIED.value());
+                        notices.add(existNotice);
+                    } else {
+                        // 已发货数小于或等于新的需求数,修改平台上的需求数为新的需求数
+                        existNotice.setRemark(
+                                remark + dateString + "修改需求数量," + existNotice.getQty() + " -> " + notice.getQty());
+                        existNotice.setQty(notice.getQty());
+                        existNotice.setDelivery(notice.getDelivery());
+                        notices.add(existNotice);
+                    }
 				} else {
 					String existDeliveryStr = "空";
 					String deliveryStr = "空";
@@ -99,7 +99,7 @@ public class PurchaseNotifyServiceImpl implements PurchaseNotifyService {
 						deliveryStr = dateFormat.format(notice.getDelivery());
 					}
 					if (!existDeliveryStr.equals(deliveryStr)) {
-						existNotice.setRemark(remark + dateString + "修改交期: " + existDeliveryStr + " -> " + deliveryStr);
+						existNotice.setRemark(remark + dateString + "修改交期" + existDeliveryStr + " -> " + deliveryStr);
                         mergeWaitingStatus(existNotice.getId(), SqlDateFormdateUtils.DATE_FORMAT.format(notice.getDelivery()));
 					}
 					existNotice.setDelivery(notice.getDelivery());

+ 0 - 5
src/main/java/com/uas/platform/b2b/model/Product.java

@@ -513,11 +513,6 @@ public class Product {
 		this.cmpUuId = cmpUuId;
 	}
 
-	@Override
-	public String toString() {
-		return "编号:" + getCode() + ",标题:" + getTitle() + ",规格型号:" + getSpec();
-	}
-
 	public String getSourceApp() {
 		return sourceApp;
 	}

+ 15 - 0
src/main/java/com/uas/platform/b2b/ps/ProductUtils.java

@@ -10,6 +10,7 @@ import com.uas.platform.b2b.model.Product;
 import com.uas.platform.b2b.model.ProductInfo;
 import com.uas.platform.b2b.model.ProductUsers;
 import com.uas.platform.b2b.support.SysConf;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.util.HttpUtil;
 import com.uas.platform.core.util.HttpUtil.Response;
@@ -628,4 +629,18 @@ public class ProductUtils {
         return null;
     }
 
+    /**
+     * 针对导入的物料信息批量验证
+     *
+     * @param productList 导入物料信息
+     */
+    public static Map<String, Object> checkImportProductList(List<com.uas.platform.b2b.temporary.model.ProductInfo> productList) throws Exception {
+        String res = HttpUtil.doPost(PRODUCT_PUBLIC_SERVICE_URL + "/product/checkImportProductList", FlexJsonUtils.toJsonDeep(productList));
+        if (null != res) {
+            Map<String, Object> map = JSON.parseObject(res);
+            return map;
+        } else {
+            throw new IllegalOperatorException("物料导入失败");
+        }
+    }
 }

+ 11 - 0
src/main/java/com/uas/platform/b2b/service/PurchaseNoticeService.java

@@ -344,4 +344,15 @@ public interface PurchaseNoticeService {
      * @return
      */
     SPage<PurchaseNotice> findAllNoticesByPageInfo(PageInfo pageInfo, String keyword, SearchFilter filter);
+
+	/**
+	 * 按条件查询发货提醒
+	 *
+	 * @param pageInfo 分页信息,过滤条件
+	 * @param keyword 搜索词
+	 * @param filter 过滤条件
+	 * @param state 状态
+	 * @return SPage封装的数据
+	 */
+    SPage<PurchaseNotice> findNoticesByPageInfo(PageInfo pageInfo, String keyword, SearchFilter filter, String state);
 }

+ 26 - 84
src/main/java/com/uas/platform/b2b/service/impl/PurcOrderServiceImpl.java

@@ -25,6 +25,7 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class PurcOrderServiceImpl implements PurcOrderService {
@@ -120,28 +121,27 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 	@Override
 	public ModelMap releaseByWorkbook(Workbook workbook) throws Exception {
 		ModelMap modelMap = new ModelMap();
-		List<String> alters = new ArrayList<String>();
-		List<ProductInfo> productInfos = new ArrayList<ProductInfo>();
+		List<String> alters = new ArrayList<>();
+		List<ProductInfo> productInfos = new ArrayList<>();
 		Sheet sheet = workbook.getSheetAt(0);
 		int rowNum = sheet.getLastRowNum();
 		Row headerRow = sheet.getRow(0);
+		int valueNum = 3;
 		int total = 0;
-		int success = 0;
 		if (headerRow != null) {
-			for (int r = 3; r <= rowNum; r++) {
+			for (int r = valueNum; r <= rowNum; r++) {
 			    int line = r + 1;
                 Row row = sheet.getRow(r);
 				if (row != null) {
 				    int failure =  0;
 					total++;
-					Product product = new Product();
 					ProductInfo productInfo = new ProductInfo();
 
 					// 商品名称
 					if (row.getCell(0) != null && row.getCell(0).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
 						try {
-							product.setTitle(row.getCell(0).getStringCellValue().trim());
+                            productInfo.setTitle(row.getCell(0).getStringCellValue().trim());
 						} catch (Exception e) {
                             alters.add("第" + line + "行第" + 1 + "列名称格式不正确;");
                             failure++;
@@ -155,7 +155,7 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 					if (row.getCell(1) != null) {
 						row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
 						try {
-							product.setCode(row.getCell(1).getStringCellValue().trim());
+                            productInfo.setCode(row.getCell(1).getStringCellValue().trim());
 						} catch (Exception e) {
                             alters.add("第" + line + "行第" + 2 + "列编号格式不正确;");
                             failure++;
@@ -166,7 +166,7 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 					if (row.getCell(2) != null && row.getCell(2).getCellType() != Cell.CELL_TYPE_BLANK) {
 						row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
 						try {
-							product.setSpec(row.getCell(2).getStringCellValue().trim());
+                            productInfo.setSpec(row.getCell(2).getStringCellValue().trim());
 						} catch (Exception e) {
                             alters.add("第" + line + "行第" + 3 + "规格型号格式不正确;");
                             failure++;
@@ -180,7 +180,7 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 					if (row.getCell(3) != null) {
 						row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
 						try {
-							product.setCmpCode(row.getCell(3).getStringCellValue().trim());
+                            productInfo.setCmpCode(row.getCell(3).getStringCellValue().trim());
 						} catch (Exception e) {
                             alters.add("第" + line + "行第" + 4 + "列原厂型号格式不正确;");
                             failure++;
@@ -242,16 +242,29 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 						productInfo.setRemark(row.getCell(8).getStringCellValue());
 					}
 					if (failure == 0) {
-					    // 录入数据符合要求,进行物料处理
-						List<ProductInfo> productInfoList = (List<ProductInfo>) musterdProduct(product, productInfo, success).get("productInfos");
-                        productInfos.addAll(productInfoList);
-                        success = (Integer) musterdProduct(product, productInfo, success).get("success");
+                        productInfo.setEnUU(SystemSession.getUser().getEnterprise().getUu());
+                        productInfo.setUserUU(SystemSession.getUser().getUserUU());
+                        productInfo.setSourceApp("B2B");
+                        productInfo.setIsSale(Constant.YES);
+                        //设置默认单位
+                        productInfo.setUnit("PCS");
+                        //为了同步商城数据标准,标准字段也赋值
+                        productInfo.setPcmpcode(productInfo.getCmpCode());
+                        productInfo.setPbranden(productInfo.getPbranden() == null ? productInfo.getBrand() : productInfo.getPbranden());
+                        // 新增数据时间
+                        productInfo.setErpDate(new Date(System.currentTimeMillis()));
+                        productInfo.setStandard(Constant.NO);
+                        productInfo.setIsPurchase(Constant.YES);
+                        productInfos.add(productInfo);
                     }
 				}
 			}
             if (alters.size() > 0) {
                 modelMap.put("alters", alters);
             } else {
+                Map<String, Object> map = ProductUtils.checkImportProductList(productInfos);
+                productInfos = (List<ProductInfo>) map.get("products");
+                Integer success = (Integer) map.get("success");
                 if (!CollectionUtils.isEmpty(productInfos)) {
                     modelMap.put("products", productInfos);
                 }
@@ -262,77 +275,6 @@ public class PurcOrderServiceImpl implements PurcOrderService {
 		return modelMap;
 	}
 
-    /**
-     * 输入数据符合要求,进行其他处理操作
-     *
-     * @param product
-     * @param productInfo
-     * @param success
-     * @return
-     */
-    private ModelMap musterdProduct(Product product, ProductInfo productInfo, int success) {
-        List<ProductInfo> productInfos = new ArrayList<>();
-        ModelMap map = new ModelMap();
-        product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
-        product.setUserUU(SystemSession.getUser().getUserUU());
-        product.setSourceApp("B2B");
-        product.setIsSale(Constant.YES);
-        if (product.getTitle() != null) {
-            //设置默认单位
-            product.setUnit("PCS");
-            //为了同步商城数据标准,标准字段也赋值
-            product.setPcmpcode(product.getCmpCode());
-            product.setPbranden(product.getPbranden() == null ? product.getBrand() : product.getPbranden());
-            // 新增数据时间
-            product.setErpDate(new Date(System.currentTimeMillis()));
-            product.setStandard(Constant.NO);
-            product.setIsPurchase(Constant.YES);
-            // 如果物料不存在,则进行存储
-            if (product.getCode() != null) {
-                List<Product> prods = ProductUtils.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), product.getCode());
-                if (CollectionUtils.isEmpty(prods)) {
-                    try {
-                        Long prId = ProductUtils.updateOne(product);
-                        product.setId(prId);
-                        success++;
-                    } catch (Exception e) {
-
-                    }
-                } else {
-                    product = prods.get(0);
-                    success++;
-                }
-            } else {// 物料编码不存在
-                List<Product> prods = ProductUtils.findByEnUUAndTitle(SystemSession.getUser().getEnterprise().getUu(), product.getTitle());
-                if (CollectionUtils.isEmpty(prods)) {
-                    //生成随机编码
-                    SimpleDateFormat sdf = new SimpleDateFormat("yymmddhhmm_sss");
-                    product.setCode("prod" + sdf.format(new Date()));
-                    try {
-                        Long prId = ProductUtils.updateOne(product);
-                        product.setId(prId);
-                        success++;
-                    } catch (Exception e) {
-
-                    }
-                } else {
-                    product = prods.get(0);
-                    success++;
-                }
-            }
-            productInfo.setId(product.getId());
-            productInfo.setTitle(product.getTitle());
-            productInfo.setCode(product.getCode());
-            productInfo.setSpec(product.getSpec());
-            productInfo.setPrice(productInfo.getRateprice());
-            productInfo.setTotalprice(productInfo.getPrice() * productInfo.getAmount());
-            productInfos.add(productInfo);
-        }
-        map.put("productInfos", productInfos);
-        map.put("success", success);
-        return map;
-    }
-
     @Override
 	public ModelMap copyorder(Long id) {
 		PurchaseOrderAll order = purchaseOrderAllDao.findOne(id);

+ 125 - 22
src/main/java/com/uas/platform/b2b/service/impl/PurchaseNoticeServiceImpl.java

@@ -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) {

+ 45 - 0
src/main/java/com/uas/platform/b2b/support/SearchUtils.java

@@ -0,0 +1,45 @@
+package com.uas.platform.b2b.support;
+
+/**
+ * 搜索相关
+ *
+ * @author hejq
+ * @date 2018-08-13 18:54
+ */
+public class SearchUtils {
+
+    /**
+     * UU号正则表达式
+     */
+    public static final String UU_REGEXP = "^\\d{4,}$";
+
+    /**
+     * 数字正则表达式
+     */
+    public static final String NUM_REGEXP= "^[0-9]*$";
+
+    /**
+     * 待处理
+     */
+    public static final String TODO_STATE = "todo";
+
+    /**
+     * 全部
+     */
+    public static final String ALL_STATE = "all";
+
+    /**
+     * 已处理
+     */
+    public static final String DONE_STATE = "done";
+
+    /**
+     * 已结案,已取消
+     */
+    public static final String END_STATE = "end";
+
+    /**
+     * 待发货
+     */
+    public static final String WAITING_STATE = "waiting";
+}

+ 17 - 68
src/main/java/com/uas/platform/b2b/temporary/model/ProductInfo.java

@@ -1,5 +1,7 @@
 package com.uas.platform.b2b.temporary.model;
 
+import com.uas.platform.b2b.model.Product;
+
 import java.util.Date;
 
 /**
@@ -8,33 +10,18 @@ import java.util.Date;
  * @author hejq
  * @time 创建时间:2017年5月17日
  */
-public class ProductInfo {
-
-	/**
-	 * id
-	 */
-	private Long id;
-
-	/**
-	 * 商品信息标题
-	 */
-	private String title;
-
-	/**
-	 * 产品编号
-	 */
-	private String code;
-
-	/**
-	 * 产品规格
-	 */
-	private String spec;
+public class ProductInfo extends Product {
 
 	/**
 	 * 数量
 	 */
 	private Double amount;
 
+    /**
+     * 不含税单价
+     */
+    private Double unitPrice;
+
 	/**
 	 * 税率
 	 */
@@ -45,11 +32,6 @@ public class ProductInfo {
 	 */
 	private Double rateprice;
 
-	/**
-	 * 不含税单价
-	 */
-	private Double price;
-
 	/**
 	 * 不含税总额
 	 */
@@ -65,38 +47,6 @@ public class ProductInfo {
 	 */
 	private String remark;
 
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getTitle() {
-		return title;
-	}
-
-	public void setTitle(String title) {
-		this.title = title;
-	}
-
-	public String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = code;
-	}
-
-	public String getSpec() {
-		return spec;
-	}
-
-	public void setSpec(String spec) {
-		this.spec = spec;
-	}
-
 	public Double getAmount() {
 		return amount;
 	}
@@ -113,7 +63,15 @@ public class ProductInfo {
 		this.rate = rate;
 	}
 
-	public Double getRateprice() {
+    public Double getUnitPrice() {
+        return unitPrice;
+    }
+
+    public void setUnitPrice(Double unitPrice) {
+        this.unitPrice = unitPrice;
+    }
+
+    public Double getRateprice() {
 		return rateprice;
 	}
 
@@ -121,14 +79,6 @@ public class ProductInfo {
 		this.rateprice = rateprice;
 	}
 
-	public Double getPrice() {
-		return price;
-	}
-
-	public void setPrice(Double price) {
-		this.price = price;
-	}
-
 	public Double getTotalprice() {
 		return totalprice;
 	}
@@ -152,5 +102,4 @@ public class ProductInfo {
 	public void setRemark(String remark) {
 		this.remark = remark;
 	}
-
 }

+ 0 - 76
src/main/java/com/uas/platform/b2b/temporary/model/UpdateByBatchParameter.java

@@ -1,76 +0,0 @@
-package com.uas.platform.b2b.temporary.model;
-
-/**
- * 批量修改传递的参数设置
- * 
- * @author hejq
- * @time 创建时间:2017年6月9日
- */
-public class UpdateByBatchParameter {
-
-	/**
-	 * 修改的字段类型
-	 */
-	private String updatetype;
-
-	/**
-	 * 需要修改的来源类型(销售、采购、总物料)
-	 */
-	private String type;
-
-	/**
-	 * 标准类型(all:全部; standard:标准; nonstandard: 非标准)
-	 */
-	private String standard;
-
-	/**
-	 * 原值
-	 */
-	private String oldvalue;
-
-	/**
-	 * 新值
-	 */
-	private String newvalue;
-
-	public String getUpdatetype() {
-		return updatetype;
-	}
-
-	public void setUpdatetype(String updatetype) {
-		this.updatetype = updatetype;
-	}
-
-	public String getType() {
-		return type;
-	}
-
-	public void setType(String type) {
-		this.type = type;
-	}
-
-	public String getStandard() {
-		return standard;
-	}
-
-	public void setStandard(String standard) {
-		this.standard = standard;
-	}
-
-	public String getOldvalue() {
-		return oldvalue;
-	}
-
-	public void setOldvalue(String oldvalue) {
-		this.oldvalue = oldvalue;
-	}
-
-	public String getNewvalue() {
-		return newvalue;
-	}
-
-	public void setNewvalue(String newvalue) {
-		this.newvalue = newvalue;
-	}
-
-}

+ 2 - 3
src/main/webapp/resources/js/index/app.js

@@ -14421,7 +14421,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         unit: 'PCS',
                         spec: prod.spec,
                         qty: prod.amount,
-                        price: prod.price,
+                        price: prod.rateprice,
                         remark: prod.remark,
                         delivery: prod.date,
                         prid: prod.id,
@@ -14429,7 +14429,6 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         prodsource: 'purchaser'
                     });
                 })
-
             }, function () {
 
             });
@@ -16149,7 +16148,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                         unit: 'PCS',
                         spec: prod.spec,
                         qty: prod.amount,
-                        price: prod.price,
+                        price: prod.rateprice,
                         remark: prod.remark,
                         delivery: prod.date,
                         prid: prod.id,