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.

276 lines
14 KiB

3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 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.QuotationDetailMapper">
  5. <resultMap id="quotationDetailVo" type="com.spring.modules.quotation.vo.QuotationDetailVo">
  6. <id column="quotation_detail_id" jdbcType="INTEGER" property="quotationDetailId" />
  7. <result column="quotation_header_id" jdbcType="INTEGER" property="quotationHeaderId" />
  8. <result column="quotation_no" jdbcType="VARCHAR" property="quotationNo" />
  9. <result column="site" jdbcType="VARCHAR" property="site" />
  10. <result column="product_no" jdbcType="VARCHAR" property="productNo" />
  11. <result column="product_desc" jdbcType="VARCHAR" property="productDesc" />
  12. <result column="internal_inquiry_no" jdbcType="VARCHAR" property="internalInquiryNo" />
  13. <result column="quotation_detail_quantity" jdbcType="DECIMAL" property="quotationDetailQuantity" />
  14. <result column="quotation_detail_count" jdbcType="INTEGER" property="quotationDetailCount" />
  15. <result column="quotation_detail_status" jdbcType="VARCHAR" property="quotationDetailStatus" />
  16. <result column="compute_part_cost" jdbcType="DECIMAL" property="computePartCost" />
  17. <result column="compute_labour_cost" jdbcType="DECIMAL" property="computeLabourCost" />
  18. <result column="compute_fabricate_cost" jdbcType="DECIMAL" property="computeFabricateCost" />
  19. <result column="compute_tool_cost" jdbcType="DECIMAL" property="computeToolCost" />
  20. <result column="adjust_part_cost" jdbcType="DECIMAL" property="adjustPartCost" />
  21. <result column="adjust_labour_cost" jdbcType="DECIMAL" property="adjustLabourCost" />
  22. <result column="adjust_fabricate_cost" jdbcType="DECIMAL" property="adjustFabricateCost" />
  23. <result column="adjust_tool_cost" jdbcType="DECIMAL" property="adjustToolCost" />
  24. <result column="detail_other_cost" jdbcType="DECIMAL" property="detailOtherCost" />
  25. <result column="detail_manage_cost" jdbcType="DECIMAL" property="detailManageCost" />
  26. <result column="detail_total_cost" jdbcType="DECIMAL" property="detailTotalCost" />
  27. <result column="detail_profit_rate" jdbcType="DECIMAL" property="detailProfitRate" />
  28. <result column="detail_profit_amount" jdbcType="DECIMAL" property="detailProfitAmount" />
  29. <result column="system_compute_amount" jdbcType="DECIMAL" property="systemComputeAmount" />
  30. <result column="system_compute_price" jdbcType="DECIMAL" property="systemComputePrice" />
  31. <result column="final_untaxed_price" jdbcType="DECIMAL" property="finalUntaxedPrice" />
  32. <result column="final_taxed_price" jdbcType="DECIMAL" property="finalTaxedPrice" />
  33. <result column="remark" jdbcType="VARCHAR" property="remark" />
  34. <result column="compute_machine_cost" jdbcType="DECIMAL" property="computeMachineCost" />
  35. <result column="adjust_machine_cost" jdbcType="DECIMAL" property="adjustMachineCost" />
  36. <result column="tax_rate" jdbcType="DECIMAL" property="taxRate" />
  37. <collection property="quotationPartList" column="quotation_detail_id"
  38. select="com.spring.modules.quotation.mapper.QuotationPartMapper.getQuotationPart"
  39. ofType="com.spring.modules.quotation.entity.QuotationPart" >
  40. </collection>
  41. <collection property="quotationRoutingVoList" column="quotation_detail_id"
  42. select="com.spring.modules.quotation.mapper.QuotationRoutingMapper.searchQuotationRoutingByDetailId"
  43. ofType="com.spring.modules.quotation.vo.QuotationRoutingVo">
  44. </collection>
  45. <collection property="quotationToolList" column="quotation_detail_id"
  46. select="com.spring.modules.quotation.mapper.QuotationToolMapper.getQuotationTool"
  47. ofType="com.spring.modules.quotation.entity.QuotationTool">
  48. </collection>
  49. </resultMap>
  50. <resultMap id="quotationDetail" type="com.spring.modules.quotation.vo.QuotationDetailVo">
  51. <id column="quotation_detail_id" jdbcType="INTEGER" property="quotationDetailId" />
  52. <result column="quotation_header_id" jdbcType="INTEGER" property="quotationHeaderId" />
  53. <result column="site" jdbcType="VARCHAR" property="site" />
  54. <result column="product_no" jdbcType="VARCHAR" property="productNo" />
  55. <result column="product_desc" jdbcType="VARCHAR" property="productDesc" />
  56. <result column="internal_inquiry_no" jdbcType="VARCHAR" property="internalInquiryNo" />
  57. <result column="quotation_detail_quantity" jdbcType="DECIMAL" property="quotationDetailQuantity" />
  58. <result column="quotation_detail_count" jdbcType="INTEGER" property="quotationDetailCount" />
  59. <result column="quotation_detail_status" jdbcType="VARCHAR" property="quotationDetailStatus" />
  60. <result column="compute_part_cost" jdbcType="DECIMAL" property="computePartCost" />
  61. <result column="compute_labour_cost" jdbcType="DECIMAL" property="computeLabourCost" />
  62. <result column="compute_fabricate_cost" jdbcType="DECIMAL" property="computeFabricateCost" />
  63. <result column="compute_tool_cost" jdbcType="DECIMAL" property="computeToolCost" />
  64. <result column="adjust_part_cost" jdbcType="DECIMAL" property="adjustPartCost" />
  65. <result column="adjust_labour_cost" jdbcType="DECIMAL" property="adjustLabourCost" />
  66. <result column="adjust_fabricate_cost" jdbcType="DECIMAL" property="adjustFabricateCost" />
  67. <result column="adjust_tool_cost" jdbcType="DECIMAL" property="adjustToolCost" />
  68. <result column="detail_other_cost" jdbcType="DECIMAL" property="detailOtherCost" />
  69. <result column="detail_manage_cost" jdbcType="DECIMAL" property="detailManageCost" />
  70. <result column="detail_total_cost" jdbcType="DECIMAL" property="detailTotalCost" />
  71. <result column="detail_profit_rate" jdbcType="DECIMAL" property="detailProfitRate" />
  72. <result column="detail_profit_amount" jdbcType="DECIMAL" property="detailProfitAmount" />
  73. <result column="system_compute_amount" jdbcType="DECIMAL" property="systemComputeAmount" />
  74. <result column="system_compute_price" jdbcType="DECIMAL" property="systemComputePrice" />
  75. <result column="final_untaxed_price" jdbcType="DECIMAL" property="finalUntaxedPrice" />
  76. <result column="final_taxed_price" jdbcType="DECIMAL" property="finalTaxedPrice" />
  77. <result column="remark" jdbcType="VARCHAR" property="remark" />
  78. <result column="compute_machine_cost" jdbcType="DECIMAL" property="computeMachineCost" />
  79. <result column="adjust_machine_cost" jdbcType="DECIMAL" property="adjustMachineCost" />
  80. <result column="tax_rate" jdbcType="DECIMAL" property="taxRate" />
  81. <result column="active" property="active" />
  82. </resultMap>
  83. <select id="getQuotationDetailVoList" resultMap="quotationDetailVo">
  84. select
  85. qd.quotation_detail_id,
  86. qd.quotation_header_id,
  87. qh.quotation_no,
  88. qd.site,
  89. qd.product_no,
  90. qd.product_desc,
  91. qd.internal_inquiry_no,
  92. qd.quotation_detail_quantity,
  93. qd.quotation_detail_count,
  94. qd.quotation_detail_status,
  95. qd.compute_part_cost,
  96. qd.compute_labour_cost,
  97. qd.compute_fabricate_cost,
  98. qd.compute_tool_cost,
  99. qd.adjust_part_cost,
  100. qd.adjust_labour_cost,
  101. qd.adjust_fabricate_cost,
  102. qd.adjust_tool_cost,
  103. qd.detail_other_cost,
  104. qd.detail_manage_cost,
  105. qd.detail_total_cost,
  106. qd.detail_profit_rate,
  107. qd.detail_profit_amount,
  108. qd.system_compute_amount,
  109. qd.system_compute_price,
  110. qd.final_untaxed_price,
  111. qd.final_taxed_price,
  112. qd.remark,
  113. qd.compute_machine_cost,
  114. qd.adjust_machine_cost,
  115. qd.tax_rate
  116. from dbo.quotation_detail qd
  117. left join dbo.quotation_header qh on qd.quotation_header_id = qh.quotation_header_id
  118. left join dbo.view_Project_Part ppp on qd.product_no = ppp.test_part_no and qd.site = ppp.site
  119. <where>
  120. qd.site = #{site} and qd.active = 'Y' and qh.active = 'Y'
  121. <if test="quotationDetailId != null">
  122. and qd.quotation_detail_id &lt;&gt; #{quotationDetailId}
  123. </if>
  124. <if test="quotationHeaderId != null">
  125. and qd.quotation_header_id &lt;&gt; #{quotationHeaderId}
  126. </if>
  127. <if test="quotationNo != null and quotationNo != ''">
  128. and qh.quotation_no like #{quotationNo}
  129. </if>
  130. <if test="productNo != null and productNo != ''">
  131. and qd.product_no like #{productNo}
  132. </if>
  133. <if test="internalInquiryNo != null and internalInquiryNo != ''">
  134. and qd.internal_inquiry_no like #{internalInquiryNo}
  135. </if>
  136. <if test="productDesc != null and productDesc != ''">
  137. and qd.product_desc like #{productDesc}
  138. </if>
  139. order by qh.quotation_no desc
  140. </where>
  141. </select>
  142. <select id="getQuotationDetailVoListByInternalInquiryNo" resultMap="quotationDetailVo">
  143. select
  144. qd.quotation_detail_id,
  145. qd.quotation_header_id,
  146. qh.quotation_no,
  147. qd.site,
  148. qd.product_no,
  149. qd.product_desc,
  150. qd.internal_inquiry_no,
  151. qd.quotation_detail_quantity,
  152. qd.quotation_detail_count,
  153. qd.quotation_detail_status,
  154. qd.compute_part_cost,
  155. qd.compute_labour_cost,
  156. qd.compute_fabricate_cost,
  157. qd.compute_tool_cost,
  158. qd.adjust_part_cost,
  159. qd.adjust_labour_cost,
  160. qd.adjust_fabricate_cost,
  161. qd.adjust_tool_cost,
  162. qd.detail_other_cost,
  163. qd.detail_manage_cost,
  164. qd.detail_total_cost,
  165. qd.detail_profit_rate,
  166. qd.detail_profit_amount,
  167. qd.system_compute_amount,
  168. qd.system_compute_price,
  169. qd.final_untaxed_price,
  170. qd.final_taxed_price,
  171. qd.remark,
  172. qd.compute_machine_cost,
  173. qd.adjust_machine_cost,
  174. qd.tax_rate
  175. from dbo.quotation_detail qd
  176. left join dbo.quotation_header qh on qd.quotation_header_id = qh.quotation_header_id
  177. left join dbo.view_Project_Part ppp on qd.product_no = ppp.test_part_no and qd.site = ppp.site
  178. where qd.internal_inquiry_no &lt;&gt; '' and qd.site = #{site} and qd.active = 'Y' and qh.active = 'Y'
  179. <if test="quotationNo != null and quotationNo != ''">
  180. and qh.quotation_no like #{quotationNo}
  181. </if>
  182. <if test="productNo != null and productNo != ''">
  183. and qd.product_no like #{productNo}
  184. </if>
  185. <if test="internalInquiryNo != null and internalInquiryNo != ''">
  186. and qd.internal_inquiry_no like #{internalInquiryNo}
  187. </if>
  188. <if test="productDesc != null and productDesc != ''">
  189. and qd.product_desc like #{productDesc}
  190. </if>
  191. order by qh.quotation_no desc
  192. </select>
  193. <select id="getQuotationDetailVoListByPage" resultMap="quotationDetail">
  194. select quotation_detail_id,
  195. quotation_header_id,
  196. site,
  197. product_no,
  198. dbo.get_part_name(site, product_no) as product_desc,
  199. internal_inquiry_no,
  200. quotation_detail_quantity,
  201. quotation_detail_count,
  202. quotation_detail_status,
  203. compute_part_cost,
  204. compute_labour_cost,
  205. compute_fabricate_cost,
  206. compute_tool_cost,
  207. adjust_part_cost,
  208. adjust_labour_cost,
  209. adjust_fabricate_cost,
  210. adjust_tool_cost,
  211. detail_other_cost,
  212. detail_manage_cost,
  213. detail_total_cost,
  214. detail_profit_rate,
  215. detail_profit_amount,
  216. system_compute_amount,
  217. system_compute_price,
  218. final_untaxed_price,
  219. final_taxed_price,
  220. remark,
  221. compute_machine_cost,
  222. adjust_machine_cost,
  223. tax_rate,
  224. active
  225. from quotation_detail qd
  226. <where>
  227. and active = 'Y'
  228. <if test="quotationHeaderId != null">
  229. and quotation_header_id = #{quotationHeaderId}
  230. </if>
  231. </where>
  232. order by quotation_detail_id
  233. </select>
  234. <insert id="handleSavePropertiesHeader">
  235. INSERT INTO PartSubPropertiesValueHeader
  236. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
  237. SELECT
  238. concat('BJ',#{quotationDetailId}),
  239. site,
  240. code_no,
  241. 1,
  242. code_desc,
  243. function_type
  244. FROM plm_properties_model_header
  245. WHERE function_type = 'BJ'
  246. AND code_no = 'BJ001'
  247. AND site = #{site}
  248. </insert>
  249. <insert id="handleSavePropertiesDetail">
  250. INSERT INTO PartSubPropertiesValue
  251. (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
  252. select concat('BJ',#{quotationDetailId}),ppmd.site,ppmd.code_no,1,ppmh.code_desc,seq_no,properties_item_no,'','',ppmd.function_type
  253. from plm_properties_model_detail ppmd
  254. left join plm_properties_model_header ppmh on ppmh.function_type = ppmd.function_type and ppmh.code_no = ppmd.code_no and ppmh.site = ppmd.site
  255. WHERE ppmd.function_type = 'BJ'
  256. AND ppmd.code_no = 'BJ001'
  257. AND ppmd.site = #{site}
  258. </insert>
  259. <delete id="removePropertiesHeader">
  260. delete from PartSubPropertiesValueHeader where PartNo = concat('BJ',#{quotationDetailId})
  261. </delete>
  262. <delete id="removePropertiesDetail">
  263. delete from PartSubPropertiesValue where PartNo = concat('BJ',#{quotationDetailId})
  264. </delete>
  265. </mapper>