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.

952 lines
39 KiB

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