You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
11 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.spring.modules.quotation.mapper.QuotationHeaderMapper">
  5. <!-- 表字段 -->
  6. <sql id="allColumn">
  7. qh.quotation_header_id,
  8. qh.site,
  9. qh.quotation_no,
  10. qh.quotation_date,
  11. qh.customer_no,
  12. dbo.plm_get_customer_desc(qh.site, qh.customer_no) as customerName,
  13. qh.version_code,
  14. qh.project_id,
  15. dbo.plm_get_project_name(qh.site, qh.project_id) as projectName,
  16. dbo.plm_get_project_final_customer_id(qh.site, qh.project_id) as finalCustomerId,
  17. dbo.plm_get_customer_desc(qh.site, dbo.plm_get_project_final_customer_id(qh.site, qh.project_id)) as finalCustomerName,
  18. qh.tracker,
  19. dbo.plm_get_user_display(qh.site, qh.tracker) as trackerName,
  20. qh.quoter,
  21. dbo.plm_get_user_display(qh.site, qh.quoter) as quoterName,
  22. qh.currency,
  23. qh.quotation_status,
  24. qh.remark,
  25. qh.customer_inquiry_no,
  26. qh.internal_inquiry_no,
  27. qh.require_approval,
  28. qh.approval_status,
  29. qh.create_by,
  30. qh.create_time
  31. </sql>
  32. <!-- resultMap -->
  33. <resultMap id="BaseResultMap" type="com.spring.modules.quotation.entity.QuotationHeader">
  34. <id column="quotation_header_id" jdbcType="INTEGER" property="quotationHeaderId" />
  35. <result column="site" jdbcType="VARCHAR" property="site" />
  36. <result column="quotation_no" jdbcType="VARCHAR" property="quotationNo" />
  37. <result column="quotation_date" jdbcType="TIMESTAMP" property="quotationDate" />
  38. <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
  39. <result column="version_code" jdbcType="VARCHAR" property="versionCode" />
  40. <result column="project_id" jdbcType="VARCHAR" property="projectId" />
  41. <result column="tracker" jdbcType="INTEGER" property="tracker" />
  42. <result column="quoter" jdbcType="INTEGER" property="quoter" />
  43. <result column="currency" jdbcType="VARCHAR" property="currency" />
  44. <result column="quotation_status" jdbcType="VARCHAR" property="quotationStatus" />
  45. <result column="remark" jdbcType="VARCHAR" property="remark" />
  46. <result column="customer_inquiry_no" jdbcType="VARCHAR" property="customerInquiryNo" />
  47. <result column="internal_inquiry_no" jdbcType="VARCHAR" property="internalInquiryNo" />
  48. <result column="require_approval" jdbcType="VARCHAR" property="requireApproval" />
  49. <result column="approval_status" jdbcType="VARCHAR" property="approvalStatus" />
  50. <result column="create_by" jdbcType="INTEGER" property="createBy" />
  51. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  52. </resultMap>
  53. <select id="getQuotationHeaderByPage" resultType="com.spring.modules.quotation.vo.QuotationHeaderVo">
  54. select
  55. <include refid="allColumn">
  56. </include>
  57. from dbo.quotation_header qh
  58. <where>
  59. site = #{site} and qh.active = 'Y'
  60. <if test="customerNo != null and customerNo != ''">
  61. AND customer_no like #{customerNo}
  62. </if>
  63. <if test="quotationNo != null and quotationNo != ''">
  64. AND quotation_no like #{quotationNo}
  65. </if>
  66. <if test="customerInquiryNo != null and customerInquiryNo != ''">
  67. AND customer_inquiry_no like #{customerInquiryNo}
  68. </if>
  69. <if test="internalInquiryNo != null and internalInquiryNo != ''">
  70. AND internal_inquiry_no like #{internalInquiryNo}
  71. </if>
  72. <if test="quotationStatus != null and quotationStatus != ''">
  73. AND quotation_status like #{quotationStatus}
  74. </if>
  75. <if test="projectId != null and projectId != ''">
  76. AND project_id like #{projectId}
  77. </if>
  78. <if test="startDate != null and startDate != ''">
  79. AND quotation_date >= #{startDate}
  80. </if>
  81. <if test="endDate != null and endDate != ''">
  82. AND #{endDate} >= quotation_date
  83. </if>
  84. <if test="customerName != null and customerName != ''">
  85. AND dbo.plm_get_customer_desc(site, customer_no) like #{customerName}
  86. </if>
  87. <if test="trackerName != null and trackerName != ''">
  88. AND dbo.plm_get_user_display(site, tracker) like #{trackerName}
  89. </if>
  90. <if test="quoterName != null and quoterName != ''">
  91. AND dbo.plm_get_user_display(site, quoter) like #{quoterName}
  92. </if>
  93. <if test="projectName != null and projectName != ''">
  94. AND dbo.plm_get_project_name(site, project_id) like #{projectName}
  95. </if>
  96. <if test="ids != null">
  97. AND quotation_header_id in (
  98. <foreach collection="ids" item="item" separator=",">
  99. #{item}
  100. </foreach>
  101. )
  102. </if>
  103. order by quotation_header_id desc
  104. </where>
  105. </select>
  106. <select id="getQuotationHeaderForToolingInfo" resultType="com.spring.modules.quotation.vo.QuotationHeaderVo">
  107. select
  108. <include refid="allColumn">
  109. </include>
  110. from dbo.quotation_header qh
  111. <where>
  112. site = #{site} and qh.active = 'Y' and tool_require_flag='N'
  113. and quotation_status not in ('草稿')
  114. and dbo.get_QuotationHeader_ifCanTooling(qh.site,qh.quotation_header_id) ='Y'
  115. <if test="customerNo != null and customerNo != ''">
  116. AND customer_no like #{customerNo}
  117. </if>
  118. <if test="quotationNo != null and quotationNo != ''">
  119. AND quotation_no like #{quotationNo}
  120. </if>
  121. <if test="customerInquiryNo != null and customerInquiryNo != ''">
  122. AND customer_inquiry_no like #{customerInquiryNo}
  123. </if>
  124. <if test="internalInquiryNo != null and internalInquiryNo != ''">
  125. AND internal_inquiry_no like #{internalInquiryNo}
  126. </if>
  127. <if test="quotationStatus != null and quotationStatus != ''">
  128. AND quotation_status like #{quotationStatus}
  129. </if>·
  130. <if test="projectId != null and projectId != ''">
  131. AND project_id like #{projectId}
  132. </if>
  133. <if test="startDate != null and startDate != ''">
  134. AND quotation_date >= #{startDate}
  135. </if>
  136. <if test="endDate != null and endDate != ''">
  137. AND #{endDate} >= quotation_date
  138. </if>
  139. <if test="customerName != null and customerName != ''">
  140. AND dbo.plm_get_customer_desc(site, customer_no) like #{customerName}
  141. </if>
  142. <if test="trackerName != null and trackerName != ''">
  143. AND dbo.plm_get_user_display(site, tracker) like #{trackerName}
  144. </if>
  145. <if test="quoterName != null and quoterName != ''">
  146. AND dbo.plm_get_user_display(site, quoter) like #{quoterName}
  147. </if>
  148. <if test="projectName != null and projectName != ''">
  149. AND dbo.plm_get_project_name(site, project_id) like #{projectName}
  150. </if>
  151. <if test="ids != null">
  152. AND quotation_header_id in (
  153. <foreach collection="ids" item="item" separator=",">
  154. #{item}
  155. </foreach>
  156. )
  157. </if>
  158. order by quotation_header_id desc
  159. </where>
  160. </select>
  161. <!-- 获得报价单号 -->
  162. <select id="getQuotationNo" resultType="string">
  163. SELECT
  164. Right('0000000000' + convert(VARCHAR(10), isnull(max(convert(INT, SUBSTRING(quotation_no, 4, 10))), 0) + 1), 8)
  165. FROM quotation_header
  166. WHERE site = #{site}
  167. </select>
  168. <select id="getQuotationHeaderByPagePost" resultType="com.spring.modules.quotation.vo.QuotationHeaderVo">
  169. select
  170. <include refid="allColumn">
  171. </include>
  172. from dbo.quotation_header qh
  173. <where>
  174. site = #{params.site} and qh.active = 'Y'
  175. <if test="params.customerNo != null and params.customerNo != ''">
  176. AND customer_no like #{params.customerNo}
  177. </if>
  178. <if test="params.quotationNo != null and params.quotationNo != ''">
  179. AND quotation_no like #{params.quotationNo}
  180. </if>
  181. <if test="params.customerInquiryNo != null and params.customerInquiryNo != ''">
  182. AND customer_inquiry_no like #{params.customerInquiryNo}
  183. </if>
  184. <if test="params.internalInquiryNo != null and params.internalInquiryNo != ''">
  185. AND internal_inquiry_no like #{params.internalInquiryNo}
  186. </if>
  187. <if test="params.quotationStatus != null and params.quotationStatus != ''">
  188. AND quotation_status like #{params.quotationStatus}
  189. </if>
  190. <if test="params.projectId != null and params.projectId != ''">
  191. AND project_id like #{params.projectId}
  192. </if>
  193. <if test="params.startDate != null">
  194. AND quotation_date >= #{params.startDate}
  195. </if>
  196. <if test="params.endDate != null">
  197. AND #{params.endDate} >= quotation_date
  198. </if>
  199. <if test="params.customerName != null and params.customerName != ''">
  200. AND dbo.plm_get_customer_desc(site, customer_no) like #{params.customerName}
  201. </if>
  202. <if test="params.trackerName != null and params.trackerName != ''">
  203. AND dbo.plm_get_user_display(site, tracker) like #{params.trackerName}
  204. </if>
  205. <if test="params.quoterName != null and params.quoterName != ''">
  206. AND dbo.plm_get_user_display(site, quoter) like #{params.quoterName}
  207. </if>
  208. <if test="params.projectName != null and params.projectName != ''">
  209. AND dbo.plm_get_project_name(site, project_id) like #{params.projectName}
  210. </if>
  211. <if test="params.versionCode != null and params.versionCode != ''">
  212. AND version_code = #{params.versionCode}
  213. </if>
  214. <if test="params.ids != null and params.ids.size() > 0">
  215. AND quotation_header_id in (
  216. <foreach collection="params.ids" item="item" separator=",">
  217. #{item}
  218. </foreach>
  219. )
  220. </if>
  221. order by quotation_header_id desc
  222. </where>
  223. </select>
  224. </mapper>