O
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.

298 lines
12 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xujie.sys.modules.quote.mapper.QuoteDetailMapper">
  4. <select id="queryQuoteDetail" resultType="com.xujie.sys.modules.quote.entity.QuoteDetail">
  5. select qd.id,
  6. qd.quote_id,
  7. qd.site,
  8. qd.bu_no,
  9. qd.quote_no,
  10. qd.version_no,
  11. qd.item_no,
  12. qd.part_id,
  13. pp.part_no,
  14. pp.part_desc,
  15. qd.internal_inquiry_no,
  16. qd.qty,
  17. qd.quote_count,
  18. qd.status,
  19. qd.part_cost,
  20. qd.adjust_part_cost,
  21. qd.labour_cost,
  22. qd.adjust_labour_cost,
  23. qd.fabricate_cost,
  24. qd.adjust_fabricate_cost,
  25. qd.tool_cost,
  26. qd.adjust_tool_cost,
  27. qd.machine_cost,
  28. qd.adjust_machine_cost,
  29. qd.other_cost,
  30. qd.manage_cost,
  31. qd.total_cost,
  32. qd.profit_rate,
  33. qd.profit_amount,
  34. qd.total_price,
  35. qd.unit_price,
  36. qd.tax_rate,
  37. qd.tax_total_price,
  38. qd.tax_unit_price,
  39. qd.remark,
  40. qd.active,
  41. qd.create_by,
  42. qd.create_date,
  43. qd.update_by,
  44. qd.update_date,
  45. qd.pack_cost,
  46. qd.shipping_cost,
  47. qd.process_time,
  48. qd.yield,
  49. qd.bom_un_yield,
  50. qd.bom_yield,
  51. qd.parent_attrition_rate,
  52. qd.child_attrition_rate,
  53. qd.adjust_bom_un_yield,
  54. qd.quote_cost,
  55. qd.adjust_quote_cost,
  56. qd.quote_total_cost,
  57. qd.quote_profit_rate,
  58. qd.quote_profit_amount,
  59. qd.quote_total_price,
  60. qd.quote_unit_price,
  61. qd.quote_tax_rate,
  62. qd.quote_tax_total_price,
  63. qd.quote_tax_unit_price
  64. from plm_quote_detail qd
  65. left join part pp on qd.part_id = pp.id
  66. <where>
  67. <if test="id != null">
  68. and qd.id = #{id}
  69. </if>
  70. <if test="quoteId != null">
  71. and qd.quote_id = #{quoteId}
  72. </if>
  73. <if test="quoteNo != null and quoteNo != ''">
  74. and qd.quote_no = #{quoteNo}
  75. </if>
  76. <if test="site != null and site != ''">
  77. and qd.site = #{site}
  78. </if>
  79. <if test="buNo != null and buNo != ''">
  80. and qd.bu_no = #{buNo}
  81. </if>
  82. <if test="versionNo != null and versionNo != ''">
  83. and qd.version_no = #{versionNo}
  84. </if>
  85. </where>
  86. order by qd.id desc
  87. </select>
  88. <select id="queryQuoteDetailByPage" resultType="com.xujie.sys.modules.quote.entity.QuoteDetail">
  89. select qd.id,
  90. qd.quote_id,
  91. qd.site,
  92. qd.bu_no,
  93. qd.quote_no,
  94. qd.version_no,
  95. qd.item_no,
  96. qd.part_id,
  97. pp.test_part_no as partNo,
  98. pp.part_desc,
  99. qd.internal_inquiry_no,
  100. qd.qty,
  101. qd.quote_count,
  102. qd.status,
  103. qd.part_cost,
  104. qd.adjust_part_cost,
  105. qd.labour_cost,
  106. qd.adjust_labour_cost,
  107. qd.fabricate_cost,
  108. qd.adjust_fabricate_cost,
  109. qd.tool_cost,
  110. qd.adjust_tool_cost,
  111. qd.machine_cost,
  112. qd.adjust_machine_cost,
  113. qd.other_cost,
  114. qd.manage_cost,
  115. qd.total_cost,
  116. qd.profit_rate,
  117. qd.profit_amount,
  118. qd.total_price,
  119. qd.unit_price,
  120. qd.tax_rate,
  121. qd.tax_total_price,
  122. qd.tax_unit_price,
  123. qd.remark,
  124. qd.active,
  125. qd.create_by,
  126. qd.create_date,
  127. qd.update_by,
  128. qd.update_date,
  129. qd.pack_cost,
  130. qd.shipping_cost,
  131. qd.process_time,
  132. qd.yield,
  133. qd.bom_un_yield,
  134. qd.bom_yield,
  135. qd.parent_attrition_rate,
  136. qd.child_attrition_rate,
  137. qd.adjust_bom_un_yield,
  138. qd.quote_cost,
  139. qd.adjust_quote_cost,
  140. qd.quote_total_cost,
  141. qd.quote_profit_rate,
  142. qd.quote_profit_amount,
  143. qd.quote_total_price,
  144. qd.quote_unit_price,
  145. qd.quote_tax_rate,
  146. qd.quote_tax_total_price,
  147. qd.quote_tax_unit_price
  148. from plm_quote_detail qd
  149. left join plm_project_part pp on qd.part_id = pp.id
  150. <where>
  151. <if test="params.quoteId != null">
  152. and qd.quote_id = #{params.quoteId}
  153. </if>
  154. <if test="params.quoteNo != null and params.quoteNo != ''">
  155. and qd.quote_no = #{params.quoteNo}
  156. </if>
  157. <if test="params.site != null and params.site != ''">
  158. and qd.site = #{params.site}
  159. </if>
  160. <if test="params.buNo != null and params.buNo != ''">
  161. and qd.bu_no = #{params.buNo}
  162. </if>
  163. <if test="params.versionNo != null and params.versionNo != ''">
  164. and qd.version_no = #{params.versionNo}
  165. </if>
  166. </where>
  167. order by qd.id desc
  168. </select>
  169. <select id="queryItemNo" resultType="java.lang.Integer">
  170. select ISNULL(max(item_no),0)+1 from plm_quote_detail where quote_id = #{quoteId}
  171. </select>
  172. <select id="getPartYield" resultType="java.math.BigDecimal">
  173. select dbo.get_part_yield(#{site},#{partNo})
  174. </select>
  175. <select id="queryQuoteDetailReport" resultType="com.xujie.sys.modules.quote.entity.QuoteDetail">
  176. select qd.id,
  177. qd.site,
  178. qd.bu_no,
  179. qd.quote_id,
  180. b.bu_desc,
  181. q.quote_version_no,
  182. q.customer_no,
  183. c.customer_desc,
  184. q.quote_date,
  185. q.customer_inquiry_no,
  186. qd.part_id,
  187. pp.part_no,
  188. pp.part_desc,
  189. qd.status,
  190. qd.create_by,
  191. qd.create_date,
  192. qd.update_by,
  193. qd.update_date,
  194. qd.remark,
  195. q.remark as quoteRemark,
  196. qd.internal_inquiry_no,
  197. rh.required_completion_date,
  198. rh.request_date,
  199. (case rh.status
  200. when 'C' then '草稿'
  201. when 'B' then '已下达'
  202. when 'A' then '已报价'
  203. else '其他' end) as rfqStatus,
  204. (case rh.status
  205. when 'A' then '普通'
  206. when 'B' then '重要'
  207. when 'C' then '紧急'
  208. else '其他' end) as priority_level,
  209. dbo.get_requester_name(qd.site, rh.requester) as requesterName,
  210. rh.remark as rfqRemark,
  211. rd.id as rfq_detail_id
  212. from plm_quote_detail qd
  213. left join plm_quote q on qd.quote_id = q.id
  214. left join plm_customer_information c on q.customer_no = c.customer_no and q.site = c.site
  215. left join BU b on qd.bu_no = b.bu_no and b.site = qd.site
  216. left join part pp on qd.part_id = pp.id
  217. left join plm_rfq_header rh
  218. on rh.site = qd.site and rh.bu_no = qd.bu_no and qd.internal_inquiry_no = rh.rfq_no
  219. left join plm_rfq_detail rd on rh.id = rd.rfq_id and rd.site = qd.site and rd.test_part_id = qd.part_id
  220. <where>
  221. <if test="params.buId != null">
  222. and b.id = #{params.buId}
  223. </if>
  224. <if test="params.quoteVersionNo != null and params.quoteVersionNo != ''">
  225. and q.quote_version_no like #{params.quoteVersionNo}
  226. </if>
  227. <if test="params.customerNo != null and params.customerNo != ''">
  228. and q.customer_no like #{params.customerNo}
  229. </if>
  230. <if test="params.customerDesc != null and params.customerDesc != ''">
  231. and c.customer_desc like #{params.customerDesc}
  232. </if>
  233. <if test="params.status != null and params.status != ''">
  234. and qd.status = #{params.status}
  235. </if>
  236. <if test="params.partNo != null and params.partNo != ''">
  237. and pp.part_no like #{params.partNo}
  238. </if>
  239. <if test="params.partDesc != null and params.partDesc != ''">
  240. and pp.part_desc like #{params.partDesc}
  241. </if>
  242. <if test="params.list != null and params.list.size() > 0">
  243. and pp.part_no in (SELECT distinct p.part_no
  244. FROM part p
  245. LEFT JOIN BU b ON p.sourceBu = b.bu_no AND p.site = b.site
  246. INNER JOIN part_sub_properties_value_header ph
  247. ON p.part_no = ph.part_no AND p.site = ph.site AND
  248. p.sourceBu = ph.bu_no
  249. AND p.code_no = ph.code_no AND ph.record_type = 'IP'
  250. inner join plm_properties_model_header pmh
  251. on ph.site = pmh.site and ph.bu_no = pmh.bu_no and
  252. ph.code_no = pmh.code_no and function_type = 'IP'
  253. WHERE b.id = 1018
  254. AND pmh.id = #{params.codeId}
  255. <foreach collection="params.list" item="item">
  256. AND EXISTS (
  257. SELECT 1
  258. FROM part_sub_properties_value pd
  259. WHERE pd.part_no = p.part_no
  260. AND pd.site = p.site
  261. AND pd.bu_no = p.sourceBu
  262. AND pd.code_no = p.code_no
  263. AND pd.record_type = 'IP'
  264. <if test="item.propertiesItemNo != null and item.propertiesItemNo != ''">
  265. and pd.properties_item_no = #{item.propertiesItemNo}
  266. </if>
  267. <if test="item.textValue != null and item.textValue != ''">
  268. and pd.text_value = #{item.textValue}
  269. </if>
  270. <if test="item.numValue != null">
  271. and pd.num_value = #{item.numValue}
  272. </if>
  273. )
  274. </foreach>
  275. )
  276. </if>
  277. </where>
  278. order by qd.id desc
  279. </select>
  280. <select id="queryQuoteDetailReportOverall" resultType="com.xujie.sys.modules.quote.entity.QuoteDetailOverall">
  281. exec dbo.plm_calculate_quote_cost_overall #{site},#{quoteId},#{id}
  282. </select>
  283. <select id="queryQuoteDetailReportRM" resultType="com.xujie.sys.modules.quote.entity.QuoteDetailOverall">
  284. exec dbo.plm_calculate_quote_cost_RM #{site},#{quoteId},#{id}
  285. </select>
  286. <select id="queryQuoteDetailReportTP" resultType="java.util.LinkedHashMap">
  287. exec dbo.plm_calculate_quote_detail_TP #{id}
  288. </select>
  289. </mapper>