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.

1011 lines
42 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
3 years ago
3 years ago
3 years ago
1 year ago
1 year ago
1 year ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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="queryBomComponentByKg" parameterType="com.spring.modules.part.entity.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. a.print_unit,
  270. a.line_sequence
  271. FROM plm_bom_component as a
  272. where a.site = #{site} and a.part_no = #{partNo} and a.bom_type = #{bomType}
  273. and a.eng_chg_level = #{engChgLevel} and a.alternative_no = #{alternativeNo}
  274. and a.qty_per_assembly <![CDATA[ >= ]]> 0 and a.print_unit = 'kg'
  275. order by a.line_sequence
  276. </select>
  277. <!-- 查bom子明细 -->
  278. <select id="queryBomByProducts" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  279. SELECT
  280. a.site,
  281. a.part_no,
  282. a.bom_type,
  283. a.eng_chg_level,
  284. a.alternative_no,
  285. a.component_part,
  286. b.part_desc as componentPartDesc,
  287. a.print_unit,
  288. dbo.get_um_name(a.print_unit) as printUnitName,
  289. abs(a.qty_per_assembly) as qtyPerAssembly,
  290. a.component_scrap,
  291. a.issue_type,
  292. a.shrinkage_factor,
  293. a.line_item_no,
  294. a.operation_no,
  295. a.issue_to_loc,
  296. dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName,
  297. a.note_text,
  298. a.line_sequence,
  299. a.consumption_item,
  300. b.part_status,
  301. dbo.get_part_status_name(a.site, b.part_status) as partStatusDesc
  302. FROM plm_bom_component as a
  303. left join part as b on a.site = b.site and a.component_part = b.part_no
  304. 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
  305. order by a.line_sequence
  306. </select>
  307. <!-- 查bom子明细 -->
  308. <select id="queryBomComponentAll" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  309. SELECT
  310. site,
  311. part_no,
  312. bom_type,
  313. eng_chg_level,
  314. alternative_no,
  315. component_part,
  316. dbo.get_part_name(site, component_part) as componentPartDesc,
  317. print_unit,
  318. dbo.get_um_name(print_unit) as printUnitName,
  319. qty_per_assembly,
  320. component_scrap,
  321. issue_type,
  322. shrinkage_factor,
  323. line_item_no,
  324. operation_no,
  325. issue_to_loc,
  326. dbo.get_location_name(site, issue_to_loc) as issueToLocName,
  327. note_text,
  328. line_sequence,
  329. consumption_item
  330. FROM plm_bom_component
  331. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  332. order by line_sequence
  333. </select>
  334. <!-- bom主表编辑 -->
  335. <update id="updateBomHeader" parameterType="BomAllFieldEntity">
  336. update plm_bom_header
  337. set eff_phase_in_date = #{effPhaseInDate},
  338. eff_phase_out_date = #{effPhaseOutDate},
  339. eng_revision = #{engRevision},
  340. type_flag = #{typeFlag},
  341. net_weight = #{netWeight},
  342. note_text = #{noteText},
  343. update_date = getDate(),
  344. update_by = #{updateBy}
  345. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  346. </update>
  347. <!-- bom明细表编辑 -->
  348. <update id="updateBomDetail" parameterType="BomDetailEntity">
  349. update plm_bom_detail
  350. set alternative_description = #{alternativeDescription},
  351. min_lot_qty = #{minLotQty},
  352. note_text = #{detailNoteText},
  353. status = #{status},
  354. update_date = getDate(),
  355. update_by = #{updateBy}
  356. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  357. </update>
  358. <!-- 删除bom子明细 -->
  359. <delete id="deleteBomComponent" parameterType="BomAllFieldEntity">
  360. delete from plm_bom_component
  361. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  362. </delete>
  363. <!-- 删除替代 -->
  364. <delete id="bomDetailDelete" parameterType="BomDetailEntity">
  365. delete from plm_bom_detail
  366. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  367. </delete>
  368. <!-- bom主表查重 -->
  369. <select id="checkBomOnlyOne" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomHeaderVo">
  370. SELECT
  371. site,
  372. part_no,
  373. dbo.get_part_name(site, part_no) as partDesc,
  374. bom_type,
  375. eng_chg_level,
  376. eff_phase_in_date,
  377. eff_phase_out_date,
  378. eng_revision,
  379. type_flag,
  380. net_weight,
  381. note_text,
  382. official_flag
  383. FROM plm_bom_header
  384. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel}
  385. </select>
  386. <!-- bom明细查重 -->
  387. <select id="checkBomDetailOnlyOne" parameterType="BomDetailEntity" resultType="BomDetailEntity">
  388. SELECT
  389. site,
  390. part_no,
  391. bom_type,
  392. eng_chg_level,
  393. alternative_no,
  394. alternative_description,
  395. bom_type,
  396. eng_chg_level,
  397. min_lot_qty,
  398. default_flag,
  399. note_text as detailNoteText,
  400. status,
  401. official_flag
  402. FROM plm_bom_detail
  403. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  404. </select>
  405. <!-- 批量删除子明细物料 -->
  406. <delete id="deleteBomComponents" parameterType="BomComponentEntity">
  407. delete from plm_bom_component
  408. where site = #{site}
  409. and part_no = #{partNo}
  410. and eng_chg_level = #{engChgLevel}
  411. and bom_type = #{bomType}
  412. and alternative_no = #{alternativeNo}
  413. and line_item_no = #{lineItemNo}
  414. </delete>
  415. <!-- 删除bom子明细 -->
  416. <delete id="deleteBomComponentByPartNo" parameterType="BomHeaderEntity">
  417. delete from plm_bom_component
  418. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  419. </delete>
  420. <!-- 删除bom明细 -->
  421. <delete id="deleteBomDetailByPartNo" parameterType="BomHeaderEntity">
  422. delete from plm_bom_detail
  423. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  424. </delete>
  425. <!-- 删除bom主记录 -->
  426. <delete id="deleteBomHeaderByPartNo" parameterType="BomHeaderEntity">
  427. delete from plm_bom_header
  428. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  429. </delete>
  430. <!-- bom明细查重 -->
  431. <select id="checkBomComponentOnlyOne" parameterType="BomComponentEntity" resultType="BomComponentEntity">
  432. SELECT
  433. site,
  434. part_no,
  435. bom_type,
  436. eng_chg_level,
  437. alternative_no,
  438. component_part,
  439. line_item_no
  440. FROM plm_bom_component
  441. 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}
  442. </select>
  443. <!-- 修改bom子明细 -->
  444. <update id="updateBomComponent" parameterType="BomComponentEntity">
  445. update plm_bom_component
  446. set qty_per_assembly = #{qtyPerAssembly},
  447. component_scrap = #{componentScrap},
  448. issue_type = #{issueType},
  449. shrinkage_factor = #{shrinkageFactor},
  450. operation_no = #{operationNo},
  451. issue_to_loc = #{issueToLoc},
  452. note_text = #{noteText},
  453. line_sequence = #{lineSequence},
  454. consumption_item = #{consumptionItem},
  455. update_date = getDate(),
  456. update_by = #{updateBy}
  457. 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}
  458. </update>
  459. <!-- 修改替代状态 -->
  460. <update id="updateAlternativeStatus" parameterType="BomDetailEntity">
  461. update plm_bom_detail
  462. set status = #{status},
  463. update_date = getDate(),
  464. update_by = #{updateBy}
  465. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  466. </update>
  467. <!-- 查bom明细对象 -->
  468. <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity">
  469. select
  470. a.site,
  471. a.part_no,
  472. a.routing_revision,
  473. a.routing_type,
  474. a.alternative_no,
  475. b.alternative_description,
  476. b.status,
  477. a.operation_id,
  478. a.operation_no,
  479. a.operation_name
  480. from plm_routing_component as a
  481. 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
  482. <where>
  483. a.site = #{site} and a.part_no = #{partNo}
  484. <if test = "routingRevision != null and routingRevision != ''">
  485. AND a.routing_revision = #{routingRevision}
  486. </if>
  487. <if test = "routingType != null and routingType != ''">
  488. AND a.routing_type = #{routingType}
  489. </if>
  490. <if test = "alternativeNo != null and alternativeNo != ''">
  491. AND a.alternative_no = #{alternativeNo}
  492. </if>
  493. <if test = "operationNo != null and operationNo != ''">
  494. AND a.operation_no = #{operationNo}
  495. </if>
  496. <if test = "operationName != null and operationName != ''">
  497. AND a.operation_name like #{operationName}
  498. </if>
  499. <if test = "operationId != null and operationId != ''">
  500. AND a.operation_id = #{operationId}
  501. </if>
  502. </where>
  503. </select>
  504. <!-- 查 max line_item_no -->
  505. <select id="selectMaxLineItemNo" parameterType="BomComponentEntity" resultType="BomComponentEntity">
  506. SELECT
  507. site,
  508. part_no,
  509. eng_chg_level,
  510. bom_type,
  511. alternative_no,
  512. component_part,
  513. line_item_no
  514. FROM plm_bom_component
  515. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = (
  516. SELECT MAX(line_item_no)
  517. FROM plm_bom_component
  518. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo})
  519. </select>
  520. <!-- 判断是否已有该物料的 bom -->
  521. <select id="queryPartBom" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomHeaderVo">
  522. SELECT top 1
  523. site,
  524. part_no,
  525. bom_type,
  526. eng_chg_level,
  527. note_text,
  528. eff_phase_in_date,
  529. eff_phase_out_date,
  530. eng_revision,
  531. net_weight,
  532. official_flag
  533. FROM plm_bom_header
  534. WHERE site = #{site} and part_no = #{partNo} and bom_type = #{bomType} order by eng_chg_level desc
  535. </select>
  536. <!-- 获取子料的序号 -->
  537. <select id="getComponentLineSequence" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  538. SELECT top 1
  539. site,
  540. part_no,
  541. eng_chg_level,
  542. bom_type,
  543. alternative_no,
  544. line_sequence
  545. FROM plm_bom_component
  546. 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
  547. </select>
  548. <!-- 判断该 bom 是否有 Buildable Obsolete 状态的替代 -->
  549. <select id="queryAlternativeStatus" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomDetailVo">
  550. SELECT
  551. site,
  552. part_no,
  553. eng_chg_level,
  554. bom_type,
  555. alternative_no,
  556. status
  557. FROM plm_bom_detail
  558. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and (status = 'Buildable' or status = 'Obsolete')
  559. </select>
  560. <!-- 判断该 BOM 是否有正式的替代 -->
  561. <select id="queryOfficialBomDetail" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomDetailVo">
  562. SELECT
  563. site,
  564. part_no,
  565. eng_chg_level,
  566. bom_type,
  567. alternative_no,
  568. status,
  569. official_flag
  570. FROM plm_bom_detail
  571. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and official_flag = 'Y'
  572. </select>
  573. <!-- 判断 BOM 是否存在子料 -->
  574. <select id="queryComponentPart" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  575. SELECT
  576. site,
  577. part_no,
  578. eng_chg_level,
  579. bom_type,
  580. alternative_no,
  581. component_part
  582. FROM plm_bom_component
  583. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  584. </select>
  585. <!-- 判断 BOM 是否存在子料 -->
  586. <select id="queryComponentPart2" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo">
  587. SELECT
  588. site,
  589. part_no,
  590. eng_chg_level,
  591. bom_type,
  592. alternative_no,
  593. component_part
  594. FROM plm_bom_component
  595. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  596. </select>
  597. <!-- 获取ifs header 对象-->
  598. <select id="getBomHeader" parameterType="BomDetailEntity" resultType="BomIfsHeader">
  599. SELECT
  600. site as contract,
  601. part_no,
  602. eng_chg_level,
  603. bom_type,
  604. eff_phase_in_date,
  605. eff_phase_out_date,
  606. note_text,
  607. create_date,
  608. 'add' as histType
  609. FROM plm_bom_header
  610. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  611. </select>
  612. <!-- 获取ifs component 对象-->
  613. <select id="getBomComponent" parameterType="BomDetailEntity" resultType="BomIfsItem">
  614. SELECT
  615. site as contract,
  616. part_no,
  617. eng_chg_level,
  618. bom_type,
  619. alternative_no,
  620. line_item_no,
  621. line_sequence,
  622. component_part,
  623. qty_per_assembly,
  624. issue_type,
  625. component_scrap,
  626. shrinkage_factor,
  627. note_text,
  628. consumption_item,
  629. operation_no,
  630. case when qty_per_assembly <![CDATA[<]]> 0 then 'byProduct' else '' end as productFlag
  631. FROM plm_bom_component
  632. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  633. </select>
  634. <!-- 获取bom header 对象-->
  635. <select id="queryBomHeader" parameterType="BomHeaderEntity" resultType="BomHeaderEntity">
  636. SELECT
  637. site,
  638. part_no,
  639. eng_chg_level,
  640. bom_type,
  641. note_text,
  642. eff_phase_in_date,
  643. eff_phase_out_date,
  644. eng_revision,
  645. row_version,
  646. row_key,
  647. type_flag,
  648. net_weight
  649. FROM plm_bom_header
  650. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  651. </select>
  652. <!-- bom主表编辑 -->
  653. <update id="updateInDate" parameterType="BomHeaderEntity">
  654. update plm_bom_header
  655. set eff_phase_out_date = #{effPhaseOutDate},
  656. update_date = getDate(),
  657. update_by = #{createBy}
  658. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  659. </update>
  660. <!-- 校验物料版本是否存在-->
  661. <select id="queryPartRevision" parameterType="BomHeaderEntity" resultType="PartRevisionEntity">
  662. SELECT
  663. site,
  664. part_no,
  665. eng_chg_level,
  666. eff_phase_in_date,
  667. eff_phase_out_date,
  668. revision_text,
  669. product_status,
  670. repair_status,
  671. eng_revision,
  672. create_date,
  673. create_by,
  674. update_date,
  675. update_by
  676. FROM part_revision
  677. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  678. </select>
  679. <!-- 新增物料版本 -->
  680. <insert id="savePartRevision" parameterType="BomHeaderEntity">
  681. 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)
  682. values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{noteText}, 'Not In Effect', 'Not In Effect', #{engRevision}, getDate(), #{createBy})
  683. </insert>
  684. <select id="queryBomDetailOfficialFlag" parameterType="BomComponentEntity" resultType="BomDetailEntity">
  685. SELECT
  686. site,
  687. part_no,
  688. bom_type,
  689. eng_chg_level,
  690. alternative_no,
  691. alternative_description,
  692. min_lot_qty,
  693. default_flag,
  694. note_text as detailNoteText,
  695. status,
  696. official_flag
  697. FROM plm_bom_detail
  698. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  699. </select>
  700. <!-- 获取 component 对象-->
  701. <select id="queryComponentPartFlag" parameterType="BomDetailEntity" resultType="PartInformationEntity">
  702. SELECT
  703. a.site,
  704. a.part_no,
  705. b.status
  706. FROM plm_bom_component as a
  707. LEFT JOIN part as b on a.site = b.site and a.component_part = b.part_no
  708. 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}
  709. </select>
  710. <select id="queryBomDetailEntityList" resultType="com.spring.modules.part.entity.BomDetailEntity">
  711. SELECT
  712. site,
  713. part_no,
  714. bom_type,
  715. eng_chg_level,
  716. alternative_no,
  717. alternative_description,
  718. status,
  719. min_lot_qty,
  720. default_flag,
  721. note_text as detailNoteText,
  722. official_flag
  723. FROM plm_bom_detail
  724. where site = #{site} and part_no = #{partNo}
  725. order by eng_chg_level desc
  726. </select>
  727. <!-- 查询库位 -->
  728. <select id="selectLocation" parameterType="BomComponentEntity" resultType="LocationInformationEntity">
  729. SELECT
  730. site,
  731. location_id,
  732. location_name
  733. FROM view_location
  734. <where>
  735. site = #{site} AND location_id = #{issueToLoc}
  736. </where>
  737. </select>
  738. <!-- 查询part revision -->
  739. <select id="selectPartRevision" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.PartRevisionVo">
  740. SELECT
  741. site,
  742. part_no,
  743. eng_chg_level,
  744. eff_phase_in_date,
  745. eff_phase_out_date,
  746. revision_text,
  747. product_status,
  748. repair_status,
  749. eng_revision
  750. FROM part_revision
  751. where site = #{site} AND part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  752. </select>
  753. <!-- 修改revision状态 -->
  754. <update id="updatePartRevisionProductStatus" parameterType="com.spring.modules.part.vo.PartRevisionVo">
  755. update part_revision
  756. set product_status = #{productStatus},
  757. <if test = "bomType == 'Repair'">
  758. repair_status = 'In Effect',
  759. </if>
  760. update_date = getDate(),
  761. update_by = #{updateBy}
  762. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  763. </update>
  764. <!-- 新增副产品成本分配数据 -->
  765. <insert id="saveBomManufStructCostDistrib">
  766. insert into plm_bom_manuf_struct_cost_distrib
  767. (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
  768. <foreach collection="list" item="item" index="index" separator=",">
  769. (#{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})
  770. </foreach>
  771. </insert>
  772. <!-- 查bom副产品成本分配 -->
  773. <select id="queryBomManufStructCostDistrib" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomManufStructCostDistribVo">
  774. SELECT
  775. site,
  776. part_no,
  777. bom_type,
  778. eng_chg_level,
  779. alternative_no,
  780. by_prod_line_item_no,
  781. component_line_item_no,
  782. item_cost_distribution,
  783. component_part_no,
  784. dbo.get_part_name(site, component_part_no) as componentPartDesc,
  785. by_prod_part_no,
  786. dbo.get_part_name(site, by_prod_part_no) as byProdPartDesc
  787. FROM plm_bom_manuf_struct_cost_distrib
  788. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  789. </select>
  790. <delete id="deletemanufStructCostDistribByProductPartNo" parameterType="BomComponentEntity">
  791. delete from plm_bom_manuf_struct_cost_distrib
  792. 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}
  793. </delete>
  794. <delete id="deletemanufStructCostDistribByComponentPartNo" parameterType="BomComponentEntity">
  795. delete from plm_bom_manuf_struct_cost_distrib
  796. 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}
  797. </delete>
  798. <!-- 编辑副产品成本分配 -->
  799. <update id="updateManufStructCostDistrib" parameterType="com.spring.modules.part.vo.BomManufStructCostDistribVo">
  800. update plm_bom_manuf_struct_cost_distrib
  801. set item_cost_distribution = #{itemCostDistribution,jdbcType=FLOAT},
  802. update_date = getDate(),
  803. update_by = #{updateBy}
  804. 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}
  805. </update>
  806. <!-- 查bom子明细 -->
  807. <select id="queryBomMultiLevelStructureList" parameterType="BomDetailEntity" resultType="BomMultiLevelStructureData">
  808. SELECT
  809. a.site,
  810. a.part_no,
  811. dbo.get_part_name(a.site, a.part_no) as partDesc,
  812. a.bom_type,
  813. a.eng_chg_level,
  814. a.alternative_no,
  815. b.alternative_description,
  816. a.component_part,
  817. dbo.get_part_name(a.site, a.component_part) as componentPartDesc,
  818. a.qty_per_assembly,
  819. a.print_unit,
  820. dbo.get_um_name(a.print_unit) as printUnitName,
  821. c.product_group_id4,
  822. dbo.get_product_group_name(c.site, c.product_group_id4, '4') as productGroupName4,
  823. c.min_order_qty,
  824. c.mul_order_qty,
  825. c.planning_method,
  826. c.cum_lead_time,
  827. c.unprotected_lead_time,
  828. dbo.get_cum_lead_time(a.site, a.component_part) as componentCumLeadTime,
  829. dbo.get_unprotected_lead_time(a.site, a.component_part) as componentUnprotectedLeadTime
  830. FROM plm_bom_component as a
  831. 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
  832. LEFT JOIN part as c on a.site = c.site and a.part_no = c.part_no
  833. 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}
  834. </select>
  835. <!-- 新增BOM子明细表内容 -->
  836. <insert id="saveBomComponents">
  837. insert into plm_bom_component
  838. (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
  839. <foreach collection="list" item="item" index="index" separator=",">
  840. (#{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})
  841. </foreach>
  842. </insert>
  843. <update id="updateBomHeaderOfficialFlag" parameterType="com.spring.modules.part.vo.BomDetailVo">
  844. update plm_bom_header
  845. set official_flag = 'Y'
  846. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  847. </update>
  848. <update id="updateBomDetailOfficialFlag" parameterType="com.spring.modules.part.vo.BomDetailVo">
  849. update plm_bom_detail
  850. set official_flag = 'Y'
  851. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  852. </update>
  853. <!-- 查bom副产品成本分配 -->
  854. <select id="queryBomManufStructCostDistribToIfs" resultType="BomIfsManufStructCostDistrib">
  855. SELECT
  856. site as contract,
  857. part_no,
  858. bom_type,
  859. eng_chg_level,
  860. alternative_no,
  861. by_prod_line_item_no,
  862. component_line_item_no,
  863. item_cost_distribution,
  864. component_part_no,
  865. by_prod_part_no as byProductPartNo,
  866. FROM plm_bom_manuf_struct_cost_distrib
  867. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  868. </select>
  869. <delete id="deleteManufStructCostDistribByAlternative" parameterType="BomDetailEntity">
  870. delete from plm_bom_manuf_struct_cost_distrib
  871. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  872. </delete>
  873. <select id="selectBomHeaderByPartNo" resultType="com.spring.modules.part.vo.BomHeaderVo">
  874. SELECT
  875. a.site,
  876. a.part_no,
  877. a.bom_type,
  878. a.eng_chg_level,
  879. a.note_text,
  880. a.eff_phase_in_date,
  881. a.eff_phase_out_date,
  882. a.eng_revision,
  883. a.type_flag,
  884. a.net_weight,
  885. a.official_flag
  886. FROM plm_bom_header 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. <select id="selectBomDetailByPartNo" resultType="com.spring.modules.part.vo.BomDetailVo">
  891. SELECT
  892. a.site,
  893. a.part_no,
  894. a.bom_type,
  895. a.eng_chg_level,
  896. a.alternative_no,
  897. a.alternative_description,
  898. a.status,
  899. a.min_lot_qty,
  900. a.default_flag,
  901. a.note_text as detailNoteText,
  902. a.official_flag
  903. FROM plm_bom_detail as a
  904. 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
  905. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  906. </select>
  907. <!-- bom明细查重 -->
  908. <select id="selectBomComponentByPartNo" resultType="com.spring.modules.part.vo.BomComponentVo">
  909. SELECT
  910. a.site,
  911. a.part_no,
  912. a.bom_type,
  913. a.eng_chg_level,
  914. a.alternative_no,
  915. a.component_part,
  916. a.print_unit,
  917. a.qty_per_assembly,
  918. a.component_scrap,
  919. a.issue_type,
  920. a.shrinkage_factor,
  921. a.line_item_no,
  922. a.operation_no,
  923. a.issue_to_loc,
  924. a.note_text,
  925. a.line_sequence,
  926. a.consumption_item
  927. FROM plm_bom_component 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. <!-- 查bom副产品成本分配 -->
  932. <select id="selectBomManufStructCostDistribByPartNo" resultType="com.spring.modules.part.vo.BomManufStructCostDistribVo">
  933. SELECT
  934. a.site,
  935. a.part_no,
  936. a.bom_type,
  937. a.eng_chg_level,
  938. a.alternative_no,
  939. a.by_prod_line_item_no,
  940. a.component_line_item_no,
  941. 0 as itemCostDistribution,
  942. a.component_part_no,
  943. a.by_prod_part_no
  944. FROM plm_bom_manuf_struct_cost_distrib as a
  945. 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
  946. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  947. </select>
  948. </mapper>