瀏覽代碼

feat: 增加送样申请数量统计接口

suntg 6 年之前
父節點
當前提交
10eaca24dc

+ 20 - 0
src/main/java/com/uas/platform/b2b/dao/PurchaseProofingItemDao.java

@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.Collection;
 import java.util.List;
 
 @Repository
@@ -73,4 +74,23 @@ public interface PurchaseProofingItemDao extends JpaSpecificationExecutor<Purcha
      */
     @Query("select count(1) from PurchaseProofingItem p where p.id in :ids and p.status = :status")
     Integer findReadCount(@Param("ids") List<Long> ids, @Param("status") Short status);
+
+	/**
+	 * 根据卖方UU号和单据状态统计数量
+	 * @param vendUU
+	 * @param status
+	 * @return
+	 */
+	@Query("select count(1) from PurchaseProofingItem p where p.vendUU=:vendUU and p.status = :status")
+	int countByVendUUAndStatus(@Param("vendUU") Long vendUU, @Param("status") short status);
+
+	/**
+	 * 根据卖方UU号和买方UU号、单据状态获取统计数量
+	 * @param vendUU
+	 * @param enUUs
+	 * @param status
+	 * @return
+	 */
+	@Query("select count(1) from PurchaseProofingItem p where p.vendUU=:vendUU and p.proofing.enUU in :enUUs and p.status = :status")
+	int countByVendUUAndEnUUsAndStatus(@Param("vendUU") Long vendUU, @Param("enUUs") Collection enUUs, @Param("status") short status);
 }

+ 10 - 5
src/main/java/com/uas/platform/b2b/mall2/controller/SaleSampleController.java

@@ -52,7 +52,7 @@ public class SaleSampleController {
 	private PurchaseProofingService purchaseProofingService;
 
 	@Autowired
-	private AttachService attachService;
+	private UserService userService;
 
 	private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
 
@@ -92,10 +92,15 @@ public class SaleSampleController {
 	@ResponseBody
 	public ModelMap getCounts() {
 		ModelMap modelMap = new ModelMap();
-		// TODO
-		modelMap.put("todo", 0);
-		modelMap.put("done", 0);
-		modelMap.put("invalid", 0);
+		Long vendUU = SystemSession.getUser().getEnterprise().getUu();
+		SearchFilter distribute = userService.distribute();
+		Collection enUUs = null;
+		if (distribute != null && distribute.getDistribute() != null) {
+			enUUs = distribute.getDistribute();
+		}
+		modelMap.put("todo", purchaseProofingService.countTodoProofing(vendUU, enUUs));
+		modelMap.put("done", purchaseProofingService.countDoneProofing(vendUU, enUUs));
+		modelMap.put("invalid", purchaseProofingService.countInvalidProofing(vendUU, enUUs));
 		return modelMap;
 	}
 

+ 24 - 0
src/main/java/com/uas/platform/b2b/service/PurchaseProofingService.java

@@ -11,6 +11,7 @@ import com.uas.platform.core.model.PageInfo;
 import com.uas.search.b2b.model.SPage;
 import org.springframework.data.domain.Page;
 
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -222,4 +223,27 @@ public interface PurchaseProofingService {
 	 */
     void invalidateProductSample(String[] ids);
 
+	/**
+	 * 获取待送样单据数量
+	 * @param vendUU
+	 * @param enUUs
+	 * @return
+	 */
+    int countTodoProofing(Long vendUU, Collection enUUs);
+
+	/**
+	 * 获取已送样单据数量
+	 * @param vendUU
+	 * @param enUUs
+	 * @return
+	 */
+	int countDoneProofing(Long vendUU, Collection enUUs);
+
+	/**
+	 * 获取已作废单据数量
+	 * @param vendUU
+	 * @param enUUs
+	 * @return
+	 */
+	int countInvalidProofing(Long vendUU, Collection enUUs);
 }

+ 51 - 5
src/main/java/com/uas/platform/b2b/service/impl/PurchaseProofingServiceImpl.java

@@ -48,11 +48,7 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 打样申请单
@@ -565,4 +561,54 @@ public class PurchaseProofingServiceImpl implements PurchaseProofingService {
 		purchaseProofingItemDao.save(saveItems);
     }
 
+	/**
+	 * 获取待送样单据数量
+	 *
+	 * @param vendUU
+	 * @param enUUs
+	 * @return
+	 */
+	@Override
+	public int countTodoProofing(Long vendUU, Collection enUUs) {
+		return getCountByVenduuAndEnuuAndStatus(vendUU, enUUs, (short) Status.UNSEND.value());
+	}
+
+	/**
+	 * 获取已送样单据数量
+	 *
+	 * @param vendUU
+	 * @param enUUs
+	 * @return
+	 */
+	@Override
+	public int countDoneProofing(Long vendUU, Collection enUUs) {
+		return getCountByVenduuAndEnuuAndStatus(vendUU, enUUs, (short) Status.SEND.value());
+	}
+
+	/**
+	 * 获取已作废单据数量
+	 *
+	 * @param vendUU
+	 * @param enUUs
+	 * @return
+	 */
+	@Override
+	public int countInvalidProofing(Long vendUU, Collection enUUs) {
+		return getCountByVenduuAndEnuuAndStatus(vendUU, enUUs, (short) Status.CANCELLED.value());
+	}
+
+	/**
+	 * 根据供应商UU号和买方UU号、状态来获取统计数量
+	 * @param vendUU
+	 * @param enUUs
+	 * @param status
+	 * @return
+	 */
+	private int getCountByVenduuAndEnuuAndStatus(Long vendUU, Collection enUUs, short status) {
+		if (CollectionUtils.isEmpty(enUUs)) {
+			return purchaseProofingItemDao.countByVendUUAndStatus(vendUU, status);
+		}
+		return purchaseProofingItemDao.countByVendUUAndEnUUsAndStatus(vendUU, enUUs, status);
+	}
+
 }