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.

300 lines
11 KiB

1 year ago
2 years ago
2 years ago
2 years 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.QuoteBomHeaderMapper">
  5. <insert id="saveBatchQuoteDetailBom">
  6. insert into quote_bom_detail (site, quote_detail_id, part_no, version, bom_type, alternative_no, component_part,
  7. print_unit, qty_per_assembly, component_scrap, issue_type, shrinkage_factor,
  8. line_item_no, operation_id, issue_to_loc, note_text, line_sequence)
  9. values
  10. <foreach collection="list" item="item" separator=",">
  11. (#{item.site}, #{item.quoteDetailId}, #{item.partNo}, #{item.version}, #{item.bomType}, #{item.alternativeNo},
  12. #{item.componentPart}, #{item.printUnit}, #{item.qtyPerAssembly}, #{item.componentScrap}, #{item.issueType},
  13. #{item.shrinkageFactor}, #{item.lineItemNo}, #{item.operationId}, #{item.issueToLoc}, #{item.noteText},
  14. #{item.lineSequence})
  15. </foreach>
  16. </insert>
  17. <select id="getProjectPart" resultType="com.spring.modules.project.entity.PlmProjectPart">
  18. select top 1 final_part_no from view_Project_Part where site = #{site} and test_part_no = #{testPartNo}
  19. </select>
  20. <select id="getBomComponentEntityList" resultType="com.spring.modules.quotation.entity.QuoteBomDetail">
  21. SELECT site,
  22. part_no,
  23. eng_chg_level as version,
  24. bom_type,
  25. alternative_no,
  26. component_part,
  27. print_unit,
  28. qty_per_assembly,
  29. component_scrap,
  30. issue_type,
  31. shrinkage_factor,
  32. line_item_no,
  33. operation_id,
  34. issue_to_loc,
  35. note_text,
  36. line_sequence
  37. FROM plm_bom_component
  38. where site = #{site}
  39. and part_no = #{partNo}
  40. and bom_type = #{bomType}
  41. and eng_chg_level = #{version}
  42. and alternative_no = #{alternativeNo}
  43. and qty_per_assembly > 0
  44. order by line_sequence
  45. </select>
  46. <select id="searchQuoteBomDetailList" resultType="com.spring.modules.quotation.vo.QuoteBomDetailVo">
  47. SELECT a.id,
  48. a.header_id,
  49. a.site,
  50. a.part_no,
  51. a.bom_type,
  52. a.version,
  53. a.alternative_no,
  54. a.component_part,
  55. p.part_desc as componentPartDesc,
  56. dbo.get_part_unitCost(a.site, a.part_no) as unitCost,
  57. a.print_unit,
  58. dbo.get_um_name(a.print_unit) as printUnitName,
  59. a.qty_per_assembly,
  60. a.component_scrap,
  61. a.issue_type,
  62. case
  63. when a.issue_type = 'A' then '领退料倒冲'
  64. when a.issue_type = 'B' then '工单倒冲'
  65. when a.issue_type = 'C' then '生产订单倒冲'
  66. when a.issue_type = 'D' then '投料倒冲'
  67. when a.issue_type = 'E' then '批次倒冲'
  68. when a.issue_type = 'F' then '销售订单倒冲'
  69. when a.issue_type = 'G' then '项目倒冲'
  70. else '' end as issueTypeName,
  71. a.shrinkage_factor,
  72. a.line_item_no,
  73. a.operation_id,
  74. a.issue_to_loc,
  75. dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName,
  76. a.note_text,
  77. a.line_sequence
  78. FROM quote_bom_detail a,
  79. part p
  80. where a.site = p.site
  81. and a.component_part = p.part_no
  82. and a.header_id in (
  83. <foreach collection="list" item="item" separator=",">
  84. #{item.id}
  85. </foreach>
  86. )
  87. order by a.header_id, a.line_sequence
  88. </select>
  89. <select id="searchQuoteBomDetailAllList" resultType="com.spring.modules.quotation.vo.QuoteBomDetailVo">
  90. SELECT a.site,
  91. a.part_no,
  92. a.bom_type,
  93. a.version,
  94. a.alternative_no,
  95. a.component_part,
  96. p.part_desc as componentPartDesc,
  97. dbo.get_part_unitCost(a.site, p.part_no) as unitCost,
  98. a.print_unit,
  99. dbo.get_um_name(a.print_unit) as printUnitName,
  100. a.qty_per_assembly,
  101. a.component_scrap,
  102. a.issue_type,
  103. case
  104. when a.issue_type = 'A' then '领退料倒冲'
  105. when a.issue_type = 'B' then '工单倒冲'
  106. when a.issue_type = 'C' then '生产订单倒冲'
  107. when a.issue_type = 'D' then '投料倒冲'
  108. when a.issue_type = 'E' then '批次倒冲'
  109. when a.issue_type = 'F' then '销售订单倒冲'
  110. when a.issue_type = 'G' then '项目倒冲'
  111. else '' end as issueTypeName,
  112. a.shrinkage_factor,
  113. a.line_item_no,
  114. a.operation_id,
  115. a.issue_to_loc,
  116. dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName,
  117. a.note_text,
  118. a.line_sequence
  119. FROM quote_bom_detail a,
  120. part p
  121. where a.site = #{site}
  122. and a.quote_detail_id = #{quoteDetailId}
  123. and a.header_id = #{id}
  124. and a.site = p.site
  125. and a.component_part = p.part_no
  126. order by a.line_sequence
  127. </select>
  128. <select id="selectBomHeader" resultType="com.spring.modules.part.entity.BomHeaderEntity">
  129. select top 1 site,
  130. part_no,
  131. eng_chg_level,
  132. bom_type,
  133. note_text,
  134. eff_phase_in_date,
  135. eff_phase_out_date,
  136. eng_revision,
  137. row_version,
  138. row_key,
  139. type_flag,
  140. net_weight,
  141. create_date,
  142. create_by,
  143. update_date,
  144. update_by,
  145. official_flag
  146. from plm_bom_header
  147. where site = #{site}
  148. and part_no = #{partNo}
  149. and eff_phase_out_date is null
  150. order by eff_phase_in_date
  151. </select>
  152. <select id="searchQuoteBOMVersion" resultType="com.spring.modules.quotation.vo.QuoteBomDetailVo">
  153. SELECT
  154. a.site,
  155. a.part_no,
  156. a.eng_chg_level as version,
  157. a.bom_type,
  158. p.part_desc as componentPartDesc,
  159. a.eff_phase_in_date,
  160. a.eff_phase_out_date
  161. FROM plm_bom_header a,
  162. part p
  163. where a.site = #{site}
  164. <if test="partNo != null and partNo != ''">
  165. and a.part_no = #{partNo}
  166. </if>
  167. <if test="testPartNo != null and testPartNo != '' and partNo == null or partNo == ''">
  168. and a.part_no = #{testPartNo}
  169. </if>
  170. and a.site = p.site
  171. and a.part_no = p.part_no
  172. order by a.eng_chg_level
  173. </select>
  174. <select id="searchQuoteBOMAlternativeNo" resultType="com.spring.modules.quotation.vo.QuoteBomDetailVo">
  175. SELECT a.site,
  176. a.part_no,
  177. a.eng_chg_level as version,
  178. a.bom_type,
  179. p.part_desc as componentPartDesc,
  180. a.alternative_no,
  181. a.alternative_description,
  182. a.status
  183. FROM plm_bom_detail a,
  184. part p
  185. where a.site = #{site}
  186. <if test="partNo != null and partNo != ''">
  187. and a.part_no = #{partNo}
  188. </if>
  189. <if test="version != null">
  190. and a.eng_chg_level = #{version}
  191. </if>
  192. <if test="bomType != null and bomType != ''">
  193. and a.bom_type = #{bomType}
  194. </if>
  195. and a.site = p.site
  196. and a.part_no = p.part_no
  197. order by a.eng_chg_level
  198. </select>
  199. <select id="selectBomHeaderList" resultType="com.spring.modules.quotation.entity.QuoteBomHeader">
  200. select
  201. site,
  202. part_no,
  203. eng_chg_level as version,
  204. bom_type
  205. from plm_bom_header
  206. where site = #{site}
  207. and part_no in (
  208. <foreach item="item" collection="list" separator=",">
  209. #{item}
  210. </foreach>
  211. )
  212. and eff_phase_out_date is null
  213. order by eff_phase_in_date
  214. </select>
  215. <select id="selectBomHeaderData" resultType="com.spring.modules.quotation.entity.QuoteBomHeader">
  216. select
  217. top 1
  218. site,
  219. part_no,
  220. eng_chg_level as version,
  221. bom_type
  222. from plm_bom_header
  223. where site = #{site}
  224. and part_no = #{partNo}
  225. and eff_phase_out_date is null
  226. order by case when bom_type='Manufacturing' then 1
  227. when bom_type='Purchase' then 2
  228. when bom_type='Repair' then 3 end
  229. </select>
  230. <select id="selectBomHeaderByPartNoAndVersionAndAlternative"
  231. resultType="com.spring.modules.quotation.vo.QuoteDetailBomHeaderVo">
  232. select top 1 b.site,
  233. b.part_no,
  234. b.alternative_no,
  235. b.eng_chg_level as version,
  236. b.bom_type,
  237. b.part_no as test_part_no
  238. from plm_bom_detail b
  239. left join plm_bom_header a on a.site = b.site and a.part_no = b.part_no and a.bom_type = b.bom_type and
  240. a.eng_chg_level = b.eng_chg_level
  241. <where>
  242. <if test="site != null and site != ''">
  243. and b.site = #{site}
  244. </if>
  245. <if test="partNo != null and partNo != ''">
  246. and b.part_no = #{partNo}
  247. </if>
  248. <if test="version != null">
  249. and b.eng_chg_level = #{version}
  250. </if>
  251. <if test="version == null">
  252. and a.eff_phase_out_date is null
  253. </if>
  254. <if test="alternativeNo != null and alternativeNo != ''">
  255. and b.alternative_no = #{alternativeNo}
  256. </if>
  257. </where>
  258. order by a.eff_phase_in_date
  259. </select>
  260. <select id="selectBomDetailByPartNoAndVersionAndAlternative"
  261. resultType="com.spring.modules.quotation.vo.QuoteDetailBomHeaderVo">
  262. select
  263. site,
  264. part_no,
  265. eng_chg_level as version,
  266. bom_type,
  267. alternative_no,
  268. component_part as part_no,
  269. component_part as test_part_no,
  270. from
  271. plm_bom_component
  272. <where>
  273. <if test="site != null and site != ''">
  274. and site = #{site}
  275. </if>
  276. <if test="partNo != null and partNo != ''">
  277. and part_no = #{partNo}
  278. </if>
  279. <if test="version != null">
  280. and eng_chg_level = #{version}
  281. </if>
  282. <if test="bomType != null and bomType != ''">
  283. and bom_type = #{bomType}
  284. </if>
  285. <if test="alternativeNo != null and alternativeNo != ''">
  286. and alternative_no = #{alternativeNo}
  287. </if>
  288. </where>
  289. </select>
  290. </mapper>