|
|
@@ -9,37 +9,60 @@ import org.springframework.data.repository.query.Param;
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.sql.SQLException;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
+/**
|
|
|
+ * 发货提醒
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ * @date 2018-07-19 11:12
|
|
|
+ */
|
|
|
@Repository
|
|
|
-@Transactional
|
|
|
public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNotice>, JpaRepository<PurchaseNotice, Long> {
|
|
|
|
|
|
/**
|
|
|
- * 按买家企业ID和送货提醒来源ID查找送货提醒单
|
|
|
- *
|
|
|
+ * 通过enUU和来源id查询发货提醒
|
|
|
+ *
|
|
|
+ * @param enUU 企业UU
|
|
|
+ * @param sourceId 来源id
|
|
|
* @return
|
|
|
*/
|
|
|
List<PurchaseNotice> findByEnUUAndSourceId(long enUU, long sourceId);
|
|
|
|
|
|
- /**
|
|
|
- * 按供应商企业ID和传输状态查找送货提醒单
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * 通过企业UU和来源id查询发货提醒
|
|
|
+ *
|
|
|
+ * @param enUU 企业UU
|
|
|
+ * @param sourceIdList 来源ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Query("select n from PurchaseNotice n where n.enUU = :enUU and n.sourceId in (:sourceIdList)")
|
|
|
+ List<PurchaseNotice> findByEnUUAndSourceIdList(@Param("enUU") Long enUU, @Param("sourceIdList") List<Long> sourceIdList);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按供应商企业ID和传输状态查找送货提醒单
|
|
|
+ *
|
|
|
+ * @param vendUU 供应商UU
|
|
|
+ * @param sendStatus 发货状态
|
|
|
+ * @return
|
|
|
+ */
|
|
|
List<PurchaseNotice> findByVendUUAndSendStatus(long vendUU, Short sendStatus);
|
|
|
|
|
|
- /**
|
|
|
- * 按供应商企业ID、是否结案和结案状态查找送货提醒
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * 按供应商企业ID、是否结案和结案状态查找送货提醒
|
|
|
+ *
|
|
|
+ * @param vendUU 供应商UU
|
|
|
+ * @param endStatus 结案状态
|
|
|
+ * @return
|
|
|
+ */
|
|
|
List<PurchaseNotice> findByVendUUAndEndStatus(long vendUU, Short endStatus);
|
|
|
|
|
|
/**
|
|
|
* 按ID集合查找送货提醒
|
|
|
- *
|
|
|
+ *
|
|
|
+ * @param ids 发货提醒ID
|
|
|
* @return
|
|
|
*/
|
|
|
@Query("select n from PurchaseNotice n where n.id IN (:ids) and (n.endQty is null or n.endQty < n.qty)")
|
|
|
@@ -48,78 +71,69 @@ public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNoti
|
|
|
/**
|
|
|
* 按送货提醒单的供应商企业ID和送货提醒单状态来统计条数
|
|
|
*
|
|
|
- * @param vendUU
|
|
|
- * @param status
|
|
|
+ * @param vendUU 企业UU
|
|
|
+ * @param status 发货提醒状态
|
|
|
* @return
|
|
|
*/
|
|
|
@Query("select count(n) from PurchaseNotice n where n.vendUU = :vendUU and n.status = :status and n.waiting = 0")
|
|
|
- public int getCountByVendUUAndStatus(@Param("vendUU") long vendUU, @Param("status") short status);
|
|
|
+ int getCountByVendUUAndStatus(@Param("vendUU") long vendUU, @Param("status") short status);
|
|
|
|
|
|
/**
|
|
|
* 按发货单更新通知单的发货数
|
|
|
- *
|
|
|
+ * @param id 发货单id
|
|
|
*/
|
|
|
@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")
|
|
|
- public void updateBySend(@Param("id") long id);
|
|
|
+ void updateBySend(@Param("id") long id);
|
|
|
|
|
|
/**
|
|
|
* 根据截止日期获取(交货日期)
|
|
|
- * @param formDate
|
|
|
- * @param endDate
|
|
|
+ *
|
|
|
+ * @param vendUU 供应商UU
|
|
|
+ * @param endDate 截止日期
|
|
|
* @return
|
|
|
*/
|
|
|
@Query("select p.id from PurchaseNotice p where p.vendUU=:vendUU and p.delivery <= :endDate")
|
|
|
- public List<Long> findByEndDate(@Param("vendUU")Long vendUU, @Param("endDate")Date endDate);
|
|
|
+ List<Long> findByEndDate(@Param("vendUU") Long vendUU, @Param("endDate") Date endDate);
|
|
|
|
|
|
/**
|
|
|
* 根据起始日期获取(交货日期)
|
|
|
- * @param formDate
|
|
|
- * @param endDate
|
|
|
+ *
|
|
|
+ * @param formDate 起始日期
|
|
|
+ * @param vendUU 供应商UU
|
|
|
* @return
|
|
|
*/
|
|
|
@Query("select p.id from PurchaseNotice p where p.vendUU=:vendUU and p.delivery >= :fromDate")
|
|
|
- public List<Long> findByFromDate(@Param("vendUU")Long vendUU, @Param("fromDate")Date formDate);
|
|
|
+ List<Long> findByFromDate(@Param("vendUU") Long vendUU, @Param("fromDate") Date formDate);
|
|
|
|
|
|
/**
|
|
|
* 按送货提醒单的企业UU和送货提醒单状态来统计已发货条数
|
|
|
*
|
|
|
- * @param vendUU
|
|
|
- * @param status
|
|
|
+ * @param enUU 企业UU
|
|
|
+ * @param status 发货状态
|
|
|
* @return
|
|
|
*/
|
|
|
@Query("select count(n) from PurchaseNotice n where n.enUU = :enUU and n.status = :status and n.waiting = 0")
|
|
|
- public Long getCountByEnUUAndStatus(@Param("enUU") long enUU, @Param("status") short status);
|
|
|
-
|
|
|
- /**
|
|
|
- * 按送货提醒单的企业UU和送货提醒单状态来统计未发货条数
|
|
|
- *
|
|
|
- * @param vendUU
|
|
|
- * @param status
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Query("select count(n) from PurchaseNotice n where n.enUU = :enUU and n.status = :status and n.waiting = 0")
|
|
|
- public Long getTodoCountByEnUUAndStatus(@Param("enUU") long enUU, @Param("status") short status);
|
|
|
-
|
|
|
- /**
|
|
|
- * 按送货提醒单的企业UU来统计备货条数
|
|
|
- *
|
|
|
- * @param vendUU
|
|
|
- * @param status
|
|
|
- * @return
|
|
|
- */
|
|
|
+ Long getCountByEnUUAndStatus(@Param("enUU") long enUU, @Param("status") short status);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按送货提醒单的企业UU来统计备货条数
|
|
|
+ *
|
|
|
+ * @param enUU 企业UU
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Query("select count(n) from PurchaseNotice n where n.enUU = :enUU and n.waiting = 1")
|
|
|
- public Long getWatingCountByEnUUAndStatus(@Param("enUU") long enUU);
|
|
|
-
|
|
|
- /**
|
|
|
- * 按送货提醒单的企业UU来统计已取消条数
|
|
|
- *
|
|
|
- * @param vendUU
|
|
|
- * @param status
|
|
|
- * @return
|
|
|
- */
|
|
|
+ Long getWatingCountByEnUUAndStatus(@Param("enUU") long enUU);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按送货提醒单的企业UU来统计已取消条数
|
|
|
+ *
|
|
|
+ * @param enUU 企业UU
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Query("select count(n) from PurchaseNotice n where n.enUU = :enUU and n.end = 1")
|
|
|
- public Long getEndCountByEnUUAndStatus(@Param("enUU") long enUU);
|
|
|
+ Long getEndCountByEnUUAndStatus(@Param("enUU") long enUU);
|
|
|
|
|
|
/**
|
|
|
* 根据供应商UU号获取客户发发货提醒数量
|
|
|
@@ -127,14 +141,14 @@ public interface PurchaseNoticeDao extends JpaSpecificationExecutor<PurchaseNoti
|
|
|
* @return
|
|
|
*/
|
|
|
@Query("select count(p) from PurchaseNotice p where p.vendUU = :vendUU")
|
|
|
- public long countByVendUU(@Param("vendUU")Long vendUU);
|
|
|
+ Long countByVendUU(@Param("vendUU")Long vendUU);
|
|
|
|
|
|
- /**
|
|
|
- * 获得每种单据状态的未读数量
|
|
|
- *
|
|
|
- * @Param ids 未读单据id
|
|
|
- * @return
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * 获得每种单据状态的未读数量
|
|
|
+ *
|
|
|
+ * @Param ids 未读单据id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Query("select count(p), p.status from PurchaseNotice p where p.id in :ids and (p.end is null or p.end = 0) and p.waiting=0 group by p.status")
|
|
|
List<Object[]> getUnreadCountEveryStatus(@Param("ids") List<Long> ids);
|
|
|
|