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.

993 lines
41 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
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
2 years ago
2 years ago
2 years ago
8 months ago
8 months ago
8 months ago
8 months 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 year 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.spring.modules.part.mapper.BomManagementMapper">
  4. <!-- 材料信息列表 -->
  5. <select id="bomManagementSearch" parameterType="com.spring.modules.part.vo.BomHeaderVo" resultType="com.spring.modules.part.vo.BomHeaderVo">
  6. SELECT
  7. a.site,
  8. a.part_no,
  9. b.part_desc as partDesc,
  10. a.eng_chg_level,
  11. a.bom_type,
  12. a.note_text,
  13. a.eff_phase_in_date,
  14. a.eff_phase_out_date,
  15. a.eng_revision,
  16. a.type_flag,
  17. a.net_weight,
  18. a.create_date,
  19. a.create_by,
  20. a.update_date,
  21. a.update_by,
  22. b.um_id as printUnit,
  23. c.um_name as printUnitName,
  24. a.official_flag,
  25. b.ifs_part_no,
  26. b.plm_part_no
  27. FROM plm_bom_header as a
  28. left join part as b on a.site = b.site and a.part_no = b.part_no
  29. left join um as c on b.um_id = c.um_id
  30. <where>
  31. a.site = #{query.site}
  32. AND b.show_in_query_flag = 'Y'
  33. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  34. AND b.plm_part_no like #{query.plmPartNo}
  35. </if>
  36. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  37. AND b.ifs_part_no like #{query.ifsPartNo}
  38. </if>
  39. <if test = "query.partDesc != null and query.partDesc != ''">
  40. AND b.part_desc like #{query.partDesc}
  41. </if>
  42. <if test = "query.bomType != null and query.bomType != ''">
  43. AND a.bom_type = #{query.bomType}
  44. </if>
  45. <if test = "query.engChgLevel != null and query.engChgLevel != ''">
  46. AND a.eng_chg_level = #{query.engChgLevel}
  47. </if>
  48. </where>
  49. </select>
  50. <!-- 查询物料清单 -->
  51. <select id="queryPartList" parameterType="ComponentPartData" resultType="BomAllFieldEntity">
  52. SELECT
  53. a.site,
  54. a.part_no,
  55. a.part_desc,
  56. a.spec,
  57. a.um_id as printUnit,
  58. b.um_name as printUnitName,
  59. a.part_type,
  60. a.family_id,
  61. c.family_name,
  62. a.part_status,
  63. d.part_status_desc,
  64. a.plm_part_no,
  65. a.ifs_part_no
  66. FROM part as a
  67. left join um as b on a.um_id = b.um_id
  68. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  69. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  70. <where>
  71. a.site = #{query.site}
  72. and a.part_type in ('Manufactured', 'Manufactured Recipe', 'Purchased')
  73. and a.active = 'Y' and a.show_in_query_flag = 'Y'
  74. <if test = "query.partNo != null and query.partNo != ''">
  75. AND a.part_no like #{query.partNo}
  76. </if>
  77. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  78. AND a.plm_part_no like #{query.plmPartNo}
  79. </if>
  80. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  81. AND a.ifs_part_no like #{query.ifsPartNo}
  82. </if>
  83. <if test = "query.partDesc != null and query.partDesc != ''">
  84. AND a.part_desc like #{query.partDesc}
  85. </if>
  86. <if test = "query.status != null and query.status != ''">
  87. AND a.status = #{query.status}
  88. </if>
  89. </where>
  90. </select>
  91. <!-- 查出可创建BOM的物料 -->
  92. <select id="queryPartListBom" parameterType="ComponentPartData" resultType="BomAllFieldEntity">
  93. SELECT
  94. a.site,
  95. a.part_no,
  96. a.part_desc,
  97. a.spec,
  98. a.um_id as printUnit,
  99. b.um_name as printUnitName,
  100. a.part_type,
  101. a.family_id,
  102. c.family_name,
  103. a.part_status,
  104. d.part_status_desc,
  105. a.plm_part_no,
  106. a.ifs_part_no
  107. FROM part as a
  108. left join um as b on a.um_id = b.um_id
  109. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  110. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  111. <where>
  112. a.site = #{query.site}
  113. and a.active = 'Y' and a.show_in_query_flag = 'Y'
  114. and a.part_type <![CDATA[<>]]> 'Purchased (raw)'
  115. <if test = "query.partNo != null and query.partNo != ''">
  116. AND a.part_no like #{query.partNo}
  117. </if>
  118. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  119. AND a.plm_part_no like #{query.plmPartNo}
  120. </if>
  121. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  122. AND a.ifs_part_no like #{query.ifsPartNo}
  123. </if>
  124. <if test = "query.partDesc != null and query.partDesc != ''">
  125. AND a.part_desc like #{query.partDesc}
  126. </if>
  127. <if test = "query.status != null and query.status != ''">
  128. AND a.status = #{query.status}
  129. </if>
  130. </where>
  131. </select>
  132. <!-- 查出所有类型的物料 -->
  133. <select id="queryPartListAll" parameterType="ComponentPartData" resultType="BomAllFieldEntity">
  134. SELECT
  135. a.site,
  136. a.part_no,
  137. a.part_desc,
  138. a.spec,
  139. a.um_id as printUnit,
  140. b.um_name as printUnitName,
  141. a.part_type,
  142. a.family_id,
  143. c.family_name,
  144. a.part_status,
  145. d.part_status_desc,
  146. a.plm_part_no,
  147. a.ifs_part_no,
  148. a.product_group_id4,
  149. dbo.get_product_group_name(a.site, a.product_group_id4, '4') as productGroupName4
  150. FROM part as a
  151. left join um as b on a.um_id = b.um_id
  152. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  153. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  154. <where>
  155. a.site = #{query.site}
  156. and a.active = 'Y' and a.show_in_query_flag = 'Y'
  157. <if test = "query.partNo != null and query.partNo != ''">
  158. AND a.part_no like #{query.partNo}
  159. </if>
  160. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  161. AND a.plm_part_no like #{query.plmPartNo}
  162. </if>
  163. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  164. AND a.ifs_part_no like #{query.ifsPartNo}
  165. </if>
  166. <if test = "query.partDesc != null and query.partDesc != ''">
  167. AND a.part_desc like #{query.partDesc}
  168. </if>
  169. <if test = "query.status != null and query.status != ''">
  170. AND a.status = #{query.status}
  171. </if>
  172. </where>
  173. </select>
  174. <!-- 新增BOM主表内容 -->
  175. <insert id="saveBomHeader" parameterType="BomHeaderEntity">
  176. INSERT INTO plm_bom_header
  177. (site, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight, official_flag, create_date, create_by)
  178. VALUES
  179. (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{noteText}, #{effPhaseInDate}, #{effPhaseOutDate}, #{engRevision}, #{typeFlag}, #{netWeight}, #{officialFlag}, getDate(), #{createBy})
  180. </insert>
  181. <!-- bom明细新增 -->
  182. <insert id="bomDetailSave" parameterType="BomDetailEntity">
  183. INSERT INTO plm_bom_detail
  184. (site, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by, official_flag)
  185. VALUES
  186. (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{alternativeDescription}, #{status}, #{minLotQty}, #{defaultFlag}, #{detailNoteText}, getDate(), #{createBy}, #{officialFlag})
  187. </insert>
  188. <!-- 新增BOM子明细表内容 -->
  189. <insert id="saveBomComponent" parameterType="BomComponentEntity">
  190. INSERT INTO plm_bom_component
  191. (site, part_no, eng_chg_level, bom_type, alternative_no, component_part, line_item_no, print_unit, qty_per_assembly, component_scrap, shrinkage_factor, issue_type, issue_to_loc, operation_no, note_text, create_date, create_by, line_sequence, consumption_item)
  192. VALUES
  193. (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{componentPart}, #{lineItemNo}, #{printUnit}, #{qtyPerAssembly}, #{componentScrap}, #{shrinkageFactor}, #{issueType}, #{issueToLoc}, #{operationNo}, #{noteText}, getDate(), #{createBy}, #{lineSequence}, #{consumptionItem})
  194. </insert>
  195. <!-- 查bom明细 -->
  196. <select id="queryBomDetail" parameterType="BomHeaderEntity" resultType="BomDetailEntity">
  197. SELECT
  198. site,
  199. part_no,
  200. bom_type,
  201. eng_chg_level,
  202. alternative_no,
  203. alternative_description,
  204. status,
  205. min_lot_qty,
  206. default_flag,
  207. note_text as detailNoteText,
  208. official_flag
  209. FROM plm_bom_detail
  210. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel}
  211. </select>
  212. <!-- 查bom明细对象 -->
  213. <select id="queryDetailDataByNo" parameterType="BomDetailEntity" resultType="BomDetailEntity">
  214. SELECT
  215. site,
  216. part_no,
  217. bom_type,
  218. eng_chg_level,
  219. alternative_no,
  220. alternative_description,
  221. status,
  222. min_lot_qty,
  223. default_flag,
  224. note_text as detailNoteText,
  225. official_flag
  226. FROM plm_bom_detail
  227. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  228. </select>
  229. <!-- 查bom子明细 -->
  230. <select id="queryBomComponent" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  231. SELECT
  232. a.site,
  233. a.part_no,
  234. a.bom_type,
  235. a.eng_chg_level,
  236. a.alternative_no,
  237. a.component_part,
  238. b.part_desc as componentPartDesc,
  239. a.print_unit,
  240. dbo.get_um_name(a.print_unit) as printUnitName,
  241. a.qty_per_assembly,
  242. a.component_scrap,
  243. a.issue_type,
  244. a.shrinkage_factor,
  245. a.line_item_no,
  246. a.operation_no,
  247. a.issue_to_loc,
  248. dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName,
  249. a.note_text,
  250. a.line_sequence,
  251. a.consumption_item,
  252. b.part_status,
  253. dbo.get_part_status_name(a.site, b.part_status) as partStatusDesc,
  254. dbo.get_ifHas_peifang( a.site,a.component_part) as ifHasPeifang
  255. FROM plm_bom_component as a
  256. left join part as b on a.site = b.site and a.component_part = b.part_no
  257. where a.site = #{site} and a.part_no = #{partNo} and a.bom_type = #{bomType} and a.eng_chg_level = #{engChgLevel} and a.alternative_no = #{alternativeNo} and a.qty_per_assembly <![CDATA[ >= ]]> 0
  258. order by a.line_sequence
  259. </select>
  260. <!-- 查bom子明细 -->
  261. <select id="queryBomByProducts" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  262. SELECT
  263. a.site,
  264. a.part_no,
  265. a.bom_type,
  266. a.eng_chg_level,
  267. a.alternative_no,
  268. a.component_part,
  269. b.part_desc as componentPartDesc,
  270. a.print_unit,
  271. dbo.get_um_name(a.print_unit) as printUnitName,
  272. abs(a.qty_per_assembly) as qtyPerAssembly,
  273. a.component_scrap,
  274. a.issue_type,
  275. a.shrinkage_factor,
  276. a.line_item_no,
  277. a.operation_no,
  278. a.issue_to_loc,
  279. dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName,
  280. a.note_text,
  281. a.line_sequence,
  282. a.consumption_item,
  283. b.part_status,
  284. dbo.get_part_status_name(a.site, b.part_status) as partStatusDesc
  285. FROM plm_bom_component as a
  286. left join part as b on a.site = b.site and a.component_part = b.part_no
  287. where a.site = #{site} and a.part_no = #{partNo} and a.bom_type = #{bomType} and a.eng_chg_level = #{engChgLevel} and a.alternative_no = #{alternativeNo} and a.qty_per_assembly <![CDATA[ < ]]> 0
  288. order by a.line_sequence
  289. </select>
  290. <!-- 查bom子明细 -->
  291. <select id="queryBomComponentAll" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  292. SELECT
  293. site,
  294. part_no,
  295. bom_type,
  296. eng_chg_level,
  297. alternative_no,
  298. component_part,
  299. dbo.get_part_name(site, component_part) as componentPartDesc,
  300. print_unit,
  301. dbo.get_um_name(print_unit) as printUnitName,
  302. qty_per_assembly,
  303. component_scrap,
  304. issue_type,
  305. shrinkage_factor,
  306. line_item_no,
  307. operation_no,
  308. issue_to_loc,
  309. dbo.get_location_name(site, issue_to_loc) as issueToLocName,
  310. note_text,
  311. line_sequence,
  312. consumption_item
  313. FROM plm_bom_component
  314. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  315. order by line_sequence
  316. </select>
  317. <!-- bom主表编辑 -->
  318. <update id="updateBomHeader" parameterType="BomAllFieldEntity">
  319. update plm_bom_header
  320. set eff_phase_in_date = #{effPhaseInDate},
  321. eff_phase_out_date = #{effPhaseOutDate},
  322. eng_revision = #{engRevision},
  323. type_flag = #{typeFlag},
  324. net_weight = #{netWeight},
  325. note_text = #{noteText},
  326. update_date = getDate(),
  327. update_by = #{updateBy}
  328. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  329. </update>
  330. <!-- bom明细表编辑 -->
  331. <update id="updateBomDetail" parameterType="BomDetailEntity">
  332. update plm_bom_detail
  333. set alternative_description = #{alternativeDescription},
  334. min_lot_qty = #{minLotQty},
  335. note_text = #{detailNoteText},
  336. status = #{status},
  337. update_date = getDate(),
  338. update_by = #{updateBy}
  339. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  340. </update>
  341. <!-- 删除bom子明细 -->
  342. <delete id="deleteBomComponent" parameterType="BomAllFieldEntity">
  343. delete from plm_bom_component
  344. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  345. </delete>
  346. <!-- 删除替代 -->
  347. <delete id="bomDetailDelete" parameterType="BomDetailEntity">
  348. delete from plm_bom_detail
  349. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  350. </delete>
  351. <!-- bom主表查重 -->
  352. <select id="checkBomOnlyOne" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomHeaderVo">
  353. SELECT
  354. site,
  355. part_no,
  356. dbo.get_part_name(site, part_no) as partDesc,
  357. bom_type,
  358. eng_chg_level,
  359. eff_phase_in_date,
  360. eff_phase_out_date,
  361. eng_revision,
  362. type_flag,
  363. net_weight,
  364. note_text,
  365. official_flag
  366. FROM plm_bom_header
  367. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel}
  368. </select>
  369. <!-- bom明细查重 -->
  370. <select id="checkBomDetailOnlyOne" parameterType="BomDetailEntity" resultType="BomDetailEntity">
  371. SELECT
  372. site,
  373. part_no,
  374. bom_type,
  375. eng_chg_level,
  376. alternative_no,
  377. alternative_description,
  378. bom_type,
  379. eng_chg_level,
  380. min_lot_qty,
  381. default_flag,
  382. note_text as detailNoteText,
  383. status,
  384. official_flag
  385. FROM plm_bom_detail
  386. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  387. </select>
  388. <!-- 批量删除子明细物料 -->
  389. <delete id="deleteBomComponents" parameterType="BomComponentEntity">
  390. delete from plm_bom_component
  391. where site = #{site}
  392. and part_no = #{partNo}
  393. and eng_chg_level = #{engChgLevel}
  394. and bom_type = #{bomType}
  395. and alternative_no = #{alternativeNo}
  396. and line_item_no = #{lineItemNo}
  397. </delete>
  398. <!-- 删除bom子明细 -->
  399. <delete id="deleteBomComponentByPartNo" parameterType="BomHeaderEntity">
  400. delete from plm_bom_component
  401. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  402. </delete>
  403. <!-- 删除bom明细 -->
  404. <delete id="deleteBomDetailByPartNo" parameterType="BomHeaderEntity">
  405. delete from plm_bom_detail
  406. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  407. </delete>
  408. <!-- 删除bom主记录 -->
  409. <delete id="deleteBomHeaderByPartNo" parameterType="BomHeaderEntity">
  410. delete from plm_bom_header
  411. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  412. </delete>
  413. <!-- bom明细查重 -->
  414. <select id="checkBomComponentOnlyOne" parameterType="BomComponentEntity" resultType="BomComponentEntity">
  415. SELECT
  416. site,
  417. part_no,
  418. bom_type,
  419. eng_chg_level,
  420. alternative_no,
  421. component_part,
  422. line_item_no
  423. FROM plm_bom_component
  424. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} and line_item_no = #{lineItemNo}
  425. </select>
  426. <!-- 修改bom子明细 -->
  427. <update id="updateBomComponent" parameterType="BomComponentEntity">
  428. update plm_bom_component
  429. set qty_per_assembly = #{qtyPerAssembly},
  430. component_scrap = #{componentScrap},
  431. issue_type = #{issueType},
  432. shrinkage_factor = #{shrinkageFactor},
  433. operation_no = #{operationNo},
  434. issue_to_loc = #{issueToLoc},
  435. note_text = #{noteText},
  436. line_sequence = #{lineSequence},
  437. consumption_item = #{consumptionItem},
  438. update_date = getDate(),
  439. update_by = #{updateBy}
  440. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = #{lineItemNo}
  441. </update>
  442. <!-- 修改替代状态 -->
  443. <update id="updateAlternativeStatus" parameterType="BomDetailEntity">
  444. update plm_bom_detail
  445. set status = #{status},
  446. update_date = getDate(),
  447. update_by = #{updateBy}
  448. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  449. </update>
  450. <!-- 查bom明细对象 -->
  451. <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity">
  452. select
  453. a.site,
  454. a.part_no,
  455. a.routing_revision,
  456. a.routing_type,
  457. a.alternative_no,
  458. b.alternative_description,
  459. b.status,
  460. a.operation_id,
  461. a.operation_no,
  462. a.operation_name
  463. from plm_routing_component as a
  464. left join plm_routing_detail as b on a.site = b.site and a.part_no = b.part_no and a.routing_revision = b.routing_revision and a.routing_type = b.routing_type and a.alternative_no = b.alternative_no
  465. <where>
  466. a.site = #{site} and a.part_no = #{partNo}
  467. <if test = "routingRevision != null and routingRevision != ''">
  468. AND a.routing_revision = #{routingRevision}
  469. </if>
  470. <if test = "routingType != null and routingType != ''">
  471. AND a.routing_type = #{routingType}
  472. </if>
  473. <if test = "alternativeNo != null and alternativeNo != ''">
  474. AND a.alternative_no = #{alternativeNo}
  475. </if>
  476. <if test = "operationNo != null and operationNo != ''">
  477. AND a.operation_no = #{operationNo}
  478. </if>
  479. <if test = "operationName != null and operationName != ''">
  480. AND a.operation_name like #{operationName}
  481. </if>
  482. <if test = "operationId != null and operationId != ''">
  483. AND a.operation_id = #{operationId}
  484. </if>
  485. </where>
  486. </select>
  487. <!-- 查 max line_item_no -->
  488. <select id="selectMaxLineItemNo" parameterType="BomComponentEntity" resultType="BomComponentEntity">
  489. SELECT
  490. site,
  491. part_no,
  492. eng_chg_level,
  493. bom_type,
  494. alternative_no,
  495. component_part,
  496. line_item_no
  497. FROM plm_bom_component
  498. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = (
  499. SELECT MAX(line_item_no)
  500. FROM plm_bom_component
  501. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo})
  502. </select>
  503. <!-- 判断是否已有该物料的 bom -->
  504. <select id="queryPartBom" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomHeaderVo">
  505. SELECT top 1
  506. site,
  507. part_no,
  508. bom_type,
  509. eng_chg_level,
  510. note_text,
  511. eff_phase_in_date,
  512. eff_phase_out_date,
  513. eng_revision,
  514. net_weight,
  515. official_flag
  516. FROM plm_bom_header
  517. WHERE site = #{site} and part_no = #{partNo} and bom_type = #{bomType} order by eng_chg_level desc
  518. </select>
  519. <!-- 获取子料的序号 -->
  520. <select id="getComponentLineSequence" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  521. SELECT top 1
  522. site,
  523. part_no,
  524. eng_chg_level,
  525. bom_type,
  526. alternative_no,
  527. line_sequence
  528. FROM plm_bom_component
  529. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} order by line_sequence desc
  530. </select>
  531. <!-- 判断该 bom 是否有 Buildable Obsolete 状态的替代 -->
  532. <select id="queryAlternativeStatus" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomDetailVo">
  533. SELECT
  534. site,
  535. part_no,
  536. eng_chg_level,
  537. bom_type,
  538. alternative_no,
  539. status
  540. FROM plm_bom_detail
  541. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and (status = 'Buildable' or status = 'Obsolete')
  542. </select>
  543. <!-- 判断该 BOM 是否有正式的替代 -->
  544. <select id="queryOfficialBomDetail" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomDetailVo">
  545. SELECT
  546. site,
  547. part_no,
  548. eng_chg_level,
  549. bom_type,
  550. alternative_no,
  551. status,
  552. official_flag
  553. FROM plm_bom_detail
  554. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and official_flag = 'Y'
  555. </select>
  556. <!-- 判断 BOM 是否存在子料 -->
  557. <select id="queryComponentPart" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  558. SELECT
  559. site,
  560. part_no,
  561. eng_chg_level,
  562. bom_type,
  563. alternative_no,
  564. component_part
  565. FROM plm_bom_component
  566. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  567. </select>
  568. <!-- 判断 BOM 是否存在子料 -->
  569. <select id="queryComponentPart2" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  570. SELECT
  571. site,
  572. part_no,
  573. eng_chg_level,
  574. bom_type,
  575. alternative_no,
  576. component_part
  577. FROM plm_bom_component
  578. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  579. </select>
  580. <!-- 获取ifs header 对象-->
  581. <select id="getBomHeader" parameterType="BomDetailEntity" resultType="BomIfsHeader">
  582. SELECT
  583. site as contract,
  584. part_no,
  585. eng_chg_level,
  586. bom_type,
  587. eff_phase_in_date,
  588. eff_phase_out_date,
  589. note_text,
  590. create_date,
  591. 'add' as histType
  592. FROM plm_bom_header
  593. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  594. </select>
  595. <!-- 获取ifs component 对象-->
  596. <select id="getBomComponent" parameterType="BomDetailEntity" resultType="BomIfsItem">
  597. SELECT
  598. site as contract,
  599. part_no,
  600. eng_chg_level,
  601. bom_type,
  602. alternative_no,
  603. line_item_no,
  604. line_sequence,
  605. component_part,
  606. qty_per_assembly,
  607. issue_type,
  608. component_scrap,
  609. shrinkage_factor,
  610. note_text,
  611. consumption_item,
  612. operation_no,
  613. case when qty_per_assembly <![CDATA[<]]> 0 then 'byProduct' else '' end as productFlag
  614. FROM plm_bom_component
  615. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  616. </select>
  617. <!-- 获取bom header 对象-->
  618. <select id="queryBomHeader" parameterType="BomHeaderEntity" resultType="BomHeaderEntity">
  619. SELECT
  620. site,
  621. part_no,
  622. eng_chg_level,
  623. bom_type,
  624. note_text,
  625. eff_phase_in_date,
  626. eff_phase_out_date,
  627. eng_revision,
  628. row_version,
  629. row_key,
  630. type_flag,
  631. net_weight
  632. FROM plm_bom_header
  633. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  634. </select>
  635. <!-- bom主表编辑 -->
  636. <update id="updateInDate" parameterType="BomHeaderEntity">
  637. update plm_bom_header
  638. set eff_phase_out_date = #{effPhaseOutDate},
  639. update_date = getDate(),
  640. update_by = #{createBy}
  641. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  642. </update>
  643. <!-- 校验物料版本是否存在-->
  644. <select id="queryPartRevision" parameterType="BomHeaderEntity" resultType="PartRevisionEntity">
  645. SELECT
  646. site,
  647. part_no,
  648. eng_chg_level,
  649. eff_phase_in_date,
  650. eff_phase_out_date,
  651. revision_text,
  652. product_status,
  653. repair_status,
  654. eng_revision,
  655. create_date,
  656. create_by,
  657. update_date,
  658. update_by
  659. FROM part_revision
  660. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  661. </select>
  662. <!-- 新增物料版本 -->
  663. <insert id="savePartRevision" parameterType="BomHeaderEntity">
  664. insert into part_revision (site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by)
  665. values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{noteText}, 'Not In Effect', 'Not In Effect', #{engRevision}, getDate(), #{createBy})
  666. </insert>
  667. <select id="queryBomDetailOfficialFlag" parameterType="BomComponentEntity" resultType="BomDetailEntity">
  668. SELECT
  669. site,
  670. part_no,
  671. bom_type,
  672. eng_chg_level,
  673. alternative_no,
  674. alternative_description,
  675. min_lot_qty,
  676. default_flag,
  677. note_text as detailNoteText,
  678. status,
  679. official_flag
  680. FROM plm_bom_detail
  681. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  682. </select>
  683. <!-- 获取 component 对象-->
  684. <select id="queryComponentPartFlag" parameterType="BomDetailEntity" resultType="PartInformationEntity">
  685. SELECT
  686. a.site,
  687. a.part_no,
  688. b.status
  689. FROM plm_bom_component as a
  690. LEFT JOIN part as b on a.site = b.site and a.component_part = b.part_no
  691. WHERE a.site = #{site} and a.part_no = #{partNo} and a.eng_chg_level = #{engChgLevel} and a.bom_type = #{bomType} and a.alternative_no = #{alternativeNo}
  692. </select>
  693. <select id="queryBomDetailEntityList" resultType="com.spring.modules.part.entity.BomDetailEntity">
  694. SELECT
  695. site,
  696. part_no,
  697. bom_type,
  698. eng_chg_level,
  699. alternative_no,
  700. alternative_description,
  701. status,
  702. min_lot_qty,
  703. default_flag,
  704. note_text as detailNoteText,
  705. official_flag
  706. FROM plm_bom_detail
  707. where site = #{site} and part_no = #{partNo}
  708. order by eng_chg_level desc
  709. </select>
  710. <!-- 查询库位 -->
  711. <select id="selectLocation" parameterType="BomComponentEntity" resultType="LocationInformationEntity">
  712. SELECT
  713. site,
  714. location_id,
  715. location_name
  716. FROM view_location
  717. <where>
  718. site = #{site} AND location_id = #{issueToLoc}
  719. </where>
  720. </select>
  721. <!-- 查询part revision -->
  722. <select id="selectPartRevision" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.PartRevisionVo">
  723. SELECT
  724. site,
  725. part_no,
  726. eng_chg_level,
  727. eff_phase_in_date,
  728. eff_phase_out_date,
  729. revision_text,
  730. product_status,
  731. repair_status,
  732. eng_revision
  733. FROM part_revision
  734. where site = #{site} AND part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  735. </select>
  736. <!-- 修改revision状态 -->
  737. <update id="updatePartRevisionProductStatus" parameterType="com.spring.modules.part.vo.PartRevisionVo">
  738. update part_revision
  739. set product_status = #{productStatus},
  740. <if test = "bomType == 'Repair'">
  741. repair_status = 'In Effect',
  742. </if>
  743. update_date = getDate(),
  744. update_by = #{updateBy}
  745. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  746. </update>
  747. <!-- 新增副产品成本分配数据 -->
  748. <insert id="saveBomManufStructCostDistrib">
  749. insert into plm_bom_manuf_struct_cost_distrib
  750. (site, part_no, eng_chg_level, bom_type, alternative_no, by_prod_line_item_no, component_line_item_no, item_cost_distribution, component_part_no, by_prod_part_no, create_date, create_by) VALUES
  751. <foreach collection="list" item="item" index="index" separator=",">
  752. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.byProdLineItemNo}, #{item.componentLineItemNo}, #{item.itemCostDistribution,jdbcType=FLOAT}, #{item.componentPartNo}, #{item.byProdPartNo}, getDate(), #{item.createBy})
  753. </foreach>
  754. </insert>
  755. <!-- 查bom副产品成本分配 -->
  756. <select id="queryBomManufStructCostDistrib" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomManufStructCostDistribVo">
  757. SELECT
  758. site,
  759. part_no,
  760. bom_type,
  761. eng_chg_level,
  762. alternative_no,
  763. by_prod_line_item_no,
  764. component_line_item_no,
  765. item_cost_distribution,
  766. component_part_no,
  767. dbo.get_part_name(site, component_part_no) as componentPartDesc,
  768. by_prod_part_no,
  769. dbo.get_part_name(site, by_prod_part_no) as byProdPartDesc
  770. FROM plm_bom_manuf_struct_cost_distrib
  771. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  772. </select>
  773. <delete id="deletemanufStructCostDistribByProductPartNo" parameterType="BomComponentEntity">
  774. delete from plm_bom_manuf_struct_cost_distrib
  775. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and by_prod_line_item_no = #{lineItemNo}
  776. </delete>
  777. <delete id="deletemanufStructCostDistribByComponentPartNo" parameterType="BomComponentEntity">
  778. delete from plm_bom_manuf_struct_cost_distrib
  779. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and component_line_item_no = #{lineItemNo}
  780. </delete>
  781. <!-- 编辑副产品成本分配 -->
  782. <update id="updateManufStructCostDistrib" parameterType="com.spring.modules.part.vo.BomManufStructCostDistribVo">
  783. update plm_bom_manuf_struct_cost_distrib
  784. set item_cost_distribution = #{itemCostDistribution,jdbcType=FLOAT},
  785. update_date = getDate(),
  786. update_by = #{updateBy}
  787. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and by_prod_line_item_no = #{byProdLineItemNo} and component_line_item_no = #{componentLineItemNo}
  788. </update>
  789. <!-- 查bom子明细 -->
  790. <select id="queryBomMultiLevelStructureList" parameterType="BomDetailEntity" resultType="BomMultiLevelStructureData">
  791. SELECT
  792. a.site,
  793. a.part_no,
  794. dbo.get_part_name(a.site, a.part_no) as partDesc,
  795. a.bom_type,
  796. a.eng_chg_level,
  797. a.alternative_no,
  798. b.alternative_description,
  799. a.component_part,
  800. dbo.get_part_name(a.site, a.component_part) as componentPartDesc,
  801. a.qty_per_assembly,
  802. a.print_unit,
  803. dbo.get_um_name(a.print_unit) as printUnitName,
  804. c.product_group_id4,
  805. dbo.get_product_group_name(c.site, c.product_group_id4, '4') as productGroupName4,
  806. c.min_order_qty,
  807. c.mul_order_qty,
  808. c.planning_method,
  809. c.cum_lead_time,
  810. c.unprotected_lead_time,
  811. dbo.get_cum_lead_time(a.site, a.component_part) as componentCumLeadTime,
  812. dbo.get_unprotected_lead_time(a.site, a.component_part) as componentUnprotectedLeadTime
  813. FROM plm_bom_component as a
  814. LEFT JOIN plm_bom_detail as b on a.site = b.site and a.part_no = b.part_no and a.bom_type = b.bom_type and a.eng_chg_level = b.eng_chg_level and a.alternative_no = b.alternative_no
  815. LEFT JOIN part as c on a.site = c.site and a.part_no = c.part_no
  816. where a.site = #{site} and a.part_no = #{partNo} and a.bom_type = #{bomType} and a.eng_chg_level = #{engChgLevel} and a.alternative_no = #{alternativeNo}
  817. </select>
  818. <!-- 新增BOM子明细表内容 -->
  819. <insert id="saveBomComponents">
  820. insert into plm_bom_component
  821. (site, part_no, eng_chg_level, bom_type, alternative_no, component_part, line_item_no, print_unit, qty_per_assembly, component_scrap, shrinkage_factor, issue_type, issue_to_loc, operation_no, note_text, create_date, create_by, line_sequence, consumption_item) VALUES
  822. <foreach collection="list" item="item" index="index" separator=",">
  823. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.componentPart}, #{item.lineItemNo}, #{item.printUnit}, #{item.qtyPerAssembly}, #{item.componentScrap}, #{item.shrinkageFactor}, #{item.issueType}, #{item.issueToLoc}, #{item.operationNo}, #{item.noteText}, getDate(), #{item.createBy}, #{item.lineSequence}, #{item.consumptionItem})
  824. </foreach>
  825. </insert>
  826. <update id="updateBomHeaderOfficialFlag" parameterType="com.spring.modules.part.vo.BomDetailVo">
  827. update plm_bom_header
  828. set official_flag = 'Y'
  829. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  830. </update>
  831. <update id="updateBomDetailOfficialFlag" parameterType="com.spring.modules.part.vo.BomDetailVo">
  832. update plm_bom_detail
  833. set official_flag = 'Y'
  834. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  835. </update>
  836. <!-- 查bom副产品成本分配 -->
  837. <select id="queryBomManufStructCostDistribToIfs" resultType="BomIfsManufStructCostDistrib">
  838. SELECT
  839. site as contract,
  840. part_no,
  841. bom_type,
  842. eng_chg_level,
  843. alternative_no,
  844. by_prod_line_item_no,
  845. component_line_item_no,
  846. item_cost_distribution,
  847. component_part_no,
  848. by_prod_part_no as byProductPartNo,
  849. FROM plm_bom_manuf_struct_cost_distrib
  850. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  851. </select>
  852. <delete id="deleteManufStructCostDistribByAlternative" parameterType="BomDetailEntity">
  853. delete from plm_bom_manuf_struct_cost_distrib
  854. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  855. </delete>
  856. <select id="selectBomHeaderByPartNo" resultType="com.spring.modules.part.vo.BomHeaderVo">
  857. SELECT
  858. a.site,
  859. a.part_no,
  860. a.bom_type,
  861. a.eng_chg_level,
  862. a.note_text,
  863. a.eff_phase_in_date,
  864. a.eff_phase_out_date,
  865. a.eng_revision,
  866. a.type_flag,
  867. a.net_weight,
  868. a.official_flag
  869. FROM plm_bom_header as a
  870. left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level
  871. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  872. </select>
  873. <select id="selectBomDetailByPartNo" resultType="com.spring.modules.part.vo.BomDetailVo">
  874. SELECT
  875. a.site,
  876. a.part_no,
  877. a.bom_type,
  878. a.eng_chg_level,
  879. a.alternative_no,
  880. a.alternative_description,
  881. a.status,
  882. a.min_lot_qty,
  883. a.default_flag,
  884. a.note_text as detailNoteText,
  885. a.official_flag
  886. FROM plm_bom_detail as a
  887. left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level
  888. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  889. </select>
  890. <!-- bom明细查重 -->
  891. <select id="selectBomComponentByPartNo" resultType="com.spring.modules.part.vo.BomComponentVo">
  892. SELECT
  893. a.site,
  894. a.part_no,
  895. a.bom_type,
  896. a.eng_chg_level,
  897. a.alternative_no,
  898. a.component_part,
  899. a.print_unit,
  900. a.qty_per_assembly,
  901. a.component_scrap,
  902. a.issue_type,
  903. a.shrinkage_factor,
  904. a.line_item_no,
  905. a.operation_no,
  906. a.issue_to_loc,
  907. a.note_text,
  908. a.line_sequence,
  909. a.consumption_item
  910. FROM plm_bom_component as a
  911. left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level
  912. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  913. </select>
  914. <!-- 查bom副产品成本分配 -->
  915. <select id="selectBomManufStructCostDistribByPartNo" resultType="com.spring.modules.part.vo.BomManufStructCostDistribVo">
  916. SELECT
  917. a.site,
  918. a.part_no,
  919. a.bom_type,
  920. a.eng_chg_level,
  921. a.alternative_no,
  922. a.by_prod_line_item_no,
  923. a.component_line_item_no,
  924. 0 as itemCostDistribution,
  925. a.component_part_no,
  926. a.by_prod_part_no
  927. FROM plm_bom_manuf_struct_cost_distrib as a
  928. left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level
  929. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  930. </select>
  931. </mapper>