PublicInquiryItemDao.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package com.uas.ps.inquiry.dao;
  2. import com.uas.ps.inquiry.model.PublicInquiryItem;
  3. import org.springframework.data.jpa.repository.JpaRepository;
  4. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  5. import org.springframework.data.jpa.repository.Modifying;
  6. import org.springframework.data.jpa.repository.Query;
  7. import org.springframework.data.repository.query.Param;
  8. import org.springframework.stereotype.Repository;
  9. import javax.transaction.Transactional;
  10. import java.util.List;
  11. import java.util.Set;
  12. /**
  13. * 公共询价报价信息表数据库操作
  14. *
  15. * Created by hejq on 2018-01-14.
  16. */
  17. @Repository
  18. public interface PublicInquiryItemDao extends JpaRepository<PublicInquiryItem, Long>, JpaSpecificationExecutor<PublicInquiryItem> {
  19. /**
  20. * 通过企业UU和下载状态查询已报价未传回ERP的单据
  21. *
  22. * @param enUU 企业UU
  23. * @param backStatus 未下载状态202
  24. * @author hejq
  25. * @date 2018-01-14 11:49
  26. * @return
  27. */
  28. @Query("from PublicInquiryItem d where d.inquiry.enUU = :enUU and d.backStatus = :backStatus and ifnull(d.source, ' ') = 'ERP'")
  29. List<PublicInquiryItem> findByEnUUAndBackStatus(@Param("enUU") Long enUU, @Param("backStatus") short backStatus);
  30. /**
  31. * 根据传回的id更新下载状态
  32. *
  33. * @param ids 询价明细idList
  34. * @author hejq
  35. * @date 2018-01-14 11:49
  36. */
  37. @Modifying
  38. @Transactional
  39. @Query("update PublicInquiryItem i set i.backStatus = 351 where i.id in (:ids)")
  40. void updateBackStatus(@Param("ids") Set<Long> ids);
  41. /**
  42. * 按询价单明细ID更新采纳结果
  43. * 新增将decideDownStatus设置为202 ,供报价方UAS获取
  44. *
  45. * @author hejq
  46. * @date 2018-01-14 15:03
  47. * @param agreed 采纳结果
  48. * @param decideStatus 采纳状态
  49. * @param id 询价id
  50. */
  51. @Modifying(clearAutomatically = true)
  52. @Query("update PublicInquiryItem p set p.agreed = :agreed, p.decideStatus = :decideStatus, p.decideDownStatus = 202 where p.id = :id")
  53. @Transactional
  54. void updateDecideStatusByID(@Param("agreed")Short agreed, @Param("decideStatus") Short decideStatus, @Param("id") Long id);
  55. /**
  56. * 通过供应商UU号和来源id查询单据明细
  57. *
  58. * @author hejq
  59. * @date 2018-01-14 14:53
  60. * @param enuu 供应商UU号
  61. * @param id 来源id
  62. * @return
  63. */
  64. PublicInquiryItem findByVendUUAndSourceId(Long enuu, Long id);
  65. /**
  66. * 通过主表id查询序号
  67. *
  68. * @param id 询价主表id
  69. * @return
  70. */
  71. @Query("select count(1) from PublicInquiryItem i where i.inquiry.id = :id")
  72. Integer countByInquiryId(@Param("id") Long id);
  73. /**
  74. * 通过来源id查询报价信息
  75. *
  76. * @param sourceId
  77. * @return
  78. */
  79. List<PublicInquiryItem> findBySourceId(Long sourceId);
  80. /**
  81. * 通过来源id查询报价信息 报价时间倒序
  82. *
  83. * @param sourceId
  84. * @return
  85. */
  86. List<PublicInquiryItem> findBySourceIdOrderByOfferTimeDesc(Long sourceId);
  87. /**
  88. * 根据enUU和上传状态获取报价明细
  89. * @param vendUU 企业UU
  90. * @param status 状态
  91. * @return 报价单list
  92. */
  93. List<PublicInquiryItem> findByVendUUAndDecideDownStatus(Long vendUU, short status);
  94. /**
  95. * 通过企业UU和回复下载状态查询已报价 未传到卖家ERP的单据
  96. *
  97. * @param vendUU 企业UU
  98. * @param replySendStatus 未下载状态202
  99. * @author dongbw
  100. * @return
  101. */
  102. @Query(value = "select * from public$inquiryitems d where d.id_venduu = :vendUU and d.id_replysendstatus = :replySendStatus limit 200", nativeQuery = true)
  103. List<PublicInquiryItem> findByVendUUAndReplySendStatus(@Param("vendUU")Long vendUU, @Param("replySendStatus") short replySendStatus);
  104. }