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.

616 lines
25 KiB

1 year 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.xujie.sys.modules.part.mapper.BomManagementMapper">
  4. <!-- 材料信息列表 -->
  5. <select id="bomManagementSearch" parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo">
  6. SELECT
  7. a.site,
  8. a.bu_no,
  9. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  10. a.part_no,
  11. dbo.qc_get_part_desc(a.site, a.bu_no, a.part_no) as partDesc,
  12. a.eng_chg_level,
  13. a.bom_type,
  14. a.note_text,
  15. a.eff_phase_in_date,
  16. a.eff_phase_out_date,
  17. a.eng_revision,
  18. a.type_flag,
  19. a.net_weight,
  20. a.create_date,
  21. a.create_by,
  22. a.update_date,
  23. a.update_by,
  24. b.umid as printUnit,
  25. dbo.qc_get_um_name(a.site, b.umid) as printUnitName
  26. FROM plm_bom_header as a
  27. left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
  28. <where>
  29. a.site in (select site from eam_access_site where username = #{query.userName})
  30. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  31. <if test="query.buNo != null and query.buNo != ''">
  32. AND a.bu_no = #{query.buNo}
  33. </if>
  34. <if test = "query.partNo != null and query.partNo != ''">
  35. AND a.part_no like '%' + #{query.partNo} + '%'
  36. </if>
  37. <if test = "query.partDesc != null and query.partDesc != ''">
  38. AND dbo.qc_get_part_desc(a.site, a.bu_no, a.part_no) like '%' + #{query.partDesc} + '%'
  39. </if>
  40. <if test = "query.bomType != null and query.bomType != ''">
  41. AND a.bom_type = #{query.bomType}
  42. </if>
  43. <if test = "query.engChgLevel != null and query.engChgLevel != ''">
  44. AND a.eng_chg_level like '%' + #{query.engChgLevel} + '%'
  45. </if>
  46. </where>
  47. </select>
  48. <!-- 查询物料清单 -->
  49. <select id="queryPartList" parameterType="ComponentPartData" resultType="BomAllFieldEntity">
  50. SELECT
  51. site,
  52. sourceBu as buNo,
  53. part_no,
  54. part_desc,
  55. spec,
  56. umid as printUnit,
  57. dbo.qc_get_um_name(site, umid) as printUnitName,
  58. part_type,
  59. FamilyID,
  60. dbo.get_family_name(site, sourceBu, FamilyID) as familyName
  61. FROM part
  62. <where>
  63. site = #{query.site}
  64. and sourceBu = #{query.buNo}
  65. and part_type <![CDATA[<>]]> 'Purchased (raw)'
  66. and active = 'Y'
  67. <if test = "query.partNo != null and query.partNo != ''">
  68. AND part_no like '%' + #{query.partNo} + '%'
  69. </if>
  70. <if test = "query.partDesc != null and query.partDesc != ''">
  71. AND part_desc like '%' + #{query.partDesc} + '%'
  72. </if>
  73. </where>
  74. </select>
  75. <!-- 查出可创建BOM的物料 -->
  76. <select id="queryPartListBom" parameterType="ComponentPartData" resultType="BomAllFieldEntity">
  77. SELECT
  78. site,
  79. sourceBu as buNo,
  80. part_no,
  81. part_desc,
  82. spec,
  83. umid as printUnit,
  84. dbo.qc_get_um_name(site, umid) as printUnitName,
  85. part_type,
  86. FamilyID,
  87. dbo.get_family_name(site, sourceBu, FamilyID) as familyName
  88. FROM part
  89. <where>
  90. site = #{query.site}
  91. and sourceBu = #{query.buNo}
  92. and active = 'Y'
  93. and part_type <![CDATA[<>]]> 'Purchased (raw)'
  94. <if test = "query.partNo != null and query.partNo != ''">
  95. AND part_no like '%' + #{query.partNo} + '%'
  96. </if>
  97. <if test = "query.partDesc != null and query.partDesc != ''">
  98. AND part_desc like '%' + #{query.partDesc} + '%'
  99. </if>
  100. </where>
  101. </select>
  102. <!-- 新增BOM主表内容 -->
  103. <insert id="saveBomHeader" parameterType="BomHeaderEntity">
  104. INSERT INTO plm_bom_header
  105. (site, bu_no, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight, create_date, create_by)
  106. VALUES
  107. (#{site}, #{buNo}, #{partNo}, #{engChgLevel}, #{bomType}, #{noteText}, #{effPhaseInDate}, #{effPhaseOutDate}, #{engRevision}, #{typeFlag}, #{netWeight}, getDate(), #{createBy})
  108. </insert>
  109. <!-- bom明细新增 -->
  110. <insert id="bomDetailSave" parameterType="BomDetailEntity">
  111. INSERT INTO plm_bom_detail
  112. (site, bu_no, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by)
  113. VALUES
  114. (#{site}, #{buNo}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{alternativeDescription}, #{status}, #{minLotQty}, #{defaultFlag}, #{detailNoteText}, getDate(), #{createBy})
  115. </insert>
  116. <!-- 新增BOM子明细表内容 -->
  117. <insert id="saveBomComponent" parameterType="BomComponentEntity">
  118. INSERT INTO plm_bom_component
  119. (site, bu_no, 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_id, note_text, create_date, create_by, line_sequence, consumption_item)
  120. VALUES
  121. (#{site}, #{buNo}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{componentPart}, #{lineItemNo}, #{printUnit}, #{qtyPerAssembly}, #{componentScrap}, #{shrinkageFactor}, #{issueType}, #{issueToLoc}, #{operationId}, #{noteText}, getDate(), #{createBy}, #{lineSequence}, #{consumptionItem})
  122. </insert>
  123. <!-- 查bom明细 -->
  124. <select id="queryBomDetail" parameterType="BomHeaderEntity" resultType="BomDetailEntity">
  125. SELECT
  126. site,
  127. bu_no,
  128. part_no,
  129. bom_type,
  130. eng_chg_level,
  131. alternative_no,
  132. alternative_description,
  133. status,
  134. min_lot_qty,
  135. default_flag,
  136. note_text as detailNoteText
  137. FROM plm_bom_detail
  138. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel}
  139. </select>
  140. <!-- 查bom明细对象 -->
  141. <select id="queryDetailDataByNo" parameterType="BomDetailEntity" resultType="BomDetailEntity">
  142. SELECT
  143. site,
  144. bu_no,
  145. part_no,
  146. bom_type,
  147. eng_chg_level,
  148. alternative_no,
  149. alternative_description,
  150. status,
  151. min_lot_qty,
  152. default_flag,
  153. note_text as detailNoteText
  154. FROM plm_bom_detail
  155. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  156. </select>
  157. <!-- 查bom子明细 -->
  158. <select id="queryBomComponent" parameterType="BomDetailEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo">
  159. SELECT
  160. site,
  161. bu_no,
  162. part_no,
  163. bom_type,
  164. eng_chg_level,
  165. alternative_no,
  166. component_part,
  167. dbo.qc_get_part_desc(site, bu_no, component_part) as componentPartDesc,
  168. print_unit,
  169. dbo.qc_get_um_name(site, print_unit) as printUnitName,
  170. qty_per_assembly,
  171. component_scrap,
  172. issue_type,
  173. shrinkage_factor,
  174. line_item_no,
  175. operation_id,
  176. dbo.plm_get_operation_no(operation_id) as operationNo,
  177. issue_to_loc,
  178. dbo.get_location_name(site, bu_no, issue_to_loc) as issueToLocName,
  179. note_text,
  180. line_sequence,
  181. consumption_item
  182. FROM plm_bom_component
  183. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} and qty_per_assembly <![CDATA[ >= ]]> 0
  184. order by line_sequence
  185. </select>
  186. <!-- 查bom子明细 -->
  187. <select id="queryBomByProducts" parameterType="BomDetailEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo">
  188. SELECT
  189. site,
  190. bu_no,
  191. part_no,
  192. bom_type,
  193. eng_chg_level,
  194. alternative_no,
  195. component_part,
  196. dbo.qc_get_part_desc(site, bu_no, component_part) as componentPartDesc,
  197. print_unit,
  198. dbo.qc_get_um_name(site, print_unit) as printUnitName,
  199. abs(qty_per_assembly) as qtyPerAssembly,
  200. component_scrap,
  201. issue_type,
  202. shrinkage_factor,
  203. line_item_no,
  204. operation_id,
  205. issue_to_loc,
  206. dbo.get_location_name(site, bu_no, issue_to_loc) as issueToLocName,
  207. note_text,
  208. line_sequence,
  209. consumption_item
  210. FROM plm_bom_component
  211. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} and qty_per_assembly <![CDATA[ < ]]> 0
  212. order by line_sequence
  213. </select>
  214. <!-- 查bom子明细 -->
  215. <select id="queryBomComponentAll" parameterType="BomDetailEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo">
  216. SELECT
  217. site,
  218. bu_no,
  219. part_no,
  220. bom_type,
  221. eng_chg_level,
  222. alternative_no,
  223. component_part,
  224. dbo.qc_get_part_desc(site, bu_no, component_part) as componentPartDesc,
  225. print_unit,
  226. dbo.qc_get_um_name(site, print_unit) as printUnitName,
  227. qty_per_assembly,
  228. component_scrap,
  229. issue_type,
  230. shrinkage_factor,
  231. line_item_no,
  232. operation_id,
  233. issue_to_loc,
  234. dbo.get_location_name(site, bu_no, issue_to_loc) as issueToLocName,
  235. note_text,
  236. line_sequence,
  237. consumption_item
  238. FROM plm_bom_component
  239. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  240. order by line_sequence
  241. </select>
  242. <!-- bom主表编辑 -->
  243. <update id="updateBomHeader" parameterType="BomAllFieldEntity">
  244. update plm_bom_header
  245. set eff_phase_in_date = #{effPhaseInDate},
  246. eff_phase_out_date = #{effPhaseOutDate},
  247. eng_revision = #{engRevision},
  248. type_flag = #{typeFlag},
  249. net_weight = #{netWeight},
  250. note_text = #{noteText},
  251. update_date = getDate(),
  252. update_by = #{updateBy}
  253. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  254. </update>
  255. <!-- bom明细表编辑 -->
  256. <update id="updateBomDetail" parameterType="BomDetailEntity">
  257. update plm_bom_detail
  258. set alternative_description = #{alternativeDescription},
  259. min_lot_qty = #{minLotQty},
  260. note_text = #{detailNoteText},
  261. status = #{status},
  262. update_date = getDate(),
  263. update_by = #{updateBy}
  264. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  265. </update>
  266. <!-- 删除bom子明细 -->
  267. <delete id="deleteBomComponent" parameterType="BomAllFieldEntity">
  268. delete from plm_bom_component
  269. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  270. </delete>
  271. <!-- 删除替代 -->
  272. <delete id="bomDetailDelete" parameterType="BomDetailEntity">
  273. delete from plm_bom_detail
  274. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  275. </delete>
  276. <!-- bom主表查重 -->
  277. <select id="checkBomOnlyOne" parameterType="BomAllFieldEntity" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo">
  278. SELECT
  279. site,
  280. bu_no,
  281. part_no,
  282. dbo.qc_get_part_desc(site, bu_no, part_no) as partDesc,
  283. bom_type,
  284. eng_chg_level,
  285. eff_phase_in_date,
  286. eff_phase_out_date,
  287. eng_revision,
  288. type_flag,
  289. net_weight,
  290. note_text
  291. FROM plm_bom_header
  292. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel}
  293. </select>
  294. <!-- bom明细查重 -->
  295. <select id="checkBomDetailOnlyOne" parameterType="BomDetailEntity" resultType="BomDetailEntity">
  296. SELECT
  297. site,
  298. bu_no,
  299. part_no,
  300. bom_type,
  301. eng_chg_level,
  302. alternative_no,
  303. alternative_description,
  304. bom_type,
  305. eng_chg_level,
  306. min_lot_qty,
  307. default_flag,
  308. note_text as detailNoteText,
  309. status
  310. FROM plm_bom_detail
  311. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  312. </select>
  313. <!-- 批量删除子明细物料 -->
  314. <delete id="deleteBomComponents" parameterType="BomComponentEntity">
  315. delete from plm_bom_component
  316. where site = #{site}
  317. and bu_no = #{buNo}
  318. and part_no = #{partNo}
  319. and eng_chg_level = #{engChgLevel}
  320. and bom_type = #{bomType}
  321. and alternative_no = #{alternativeNo}
  322. and line_item_no = #{lineItemNo}
  323. </delete>
  324. <!-- 删除bom子明细 -->
  325. <delete id="deleteBomComponentByPartNo" parameterType="BomHeaderEntity">
  326. delete from plm_bom_component
  327. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  328. </delete>
  329. <!-- 删除bom明细 -->
  330. <delete id="deleteBomDetailByPartNo" parameterType="BomHeaderEntity">
  331. delete from plm_bom_detail
  332. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  333. </delete>
  334. <!-- 删除bom主记录 -->
  335. <delete id="deleteBomHeaderByPartNo" parameterType="BomHeaderEntity">
  336. delete from plm_bom_header
  337. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  338. </delete>
  339. <!-- 修改bom子明细 -->
  340. <update id="updateBomComponent" parameterType="BomComponentEntity">
  341. update plm_bom_component
  342. set qty_per_assembly = #{qtyPerAssembly},
  343. component_scrap = #{componentScrap},
  344. issue_type = #{issueType},
  345. shrinkage_factor = #{shrinkageFactor},
  346. operation_id = #{operationId},
  347. issue_to_loc = #{issueToLoc},
  348. note_text = #{noteText},
  349. line_sequence = #{lineSequence},
  350. consumption_item = #{consumptionItem},
  351. update_date = getDate(),
  352. update_by = #{updateBy}
  353. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = #{lineItemNo}
  354. </update>
  355. <!-- 查bom明细对象 -->
  356. <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity">
  357. select
  358. a.site,
  359. a.bu_no,
  360. a.part_no,
  361. a.routing_revision,
  362. a.routing_type,
  363. a.alternative_no,
  364. b.alternative_description,
  365. b.status,
  366. a.operation_id,
  367. a.operation_no,
  368. a.operation_name
  369. from plm_routing_component as a
  370. left join plm_routing_detail as b on a.site = b.site and a.bu_no = b.bu_no 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
  371. <where>
  372. a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
  373. <if test = "routingRevision != null and routingRevision != ''">
  374. AND a.routing_revision = #{routingRevision}
  375. </if>
  376. <if test = "routingType != null and routingType != ''">
  377. AND a.routing_type = #{routingType}
  378. </if>
  379. <if test = "alternativeNo != null and alternativeNo != ''">
  380. AND a.alternative_no = #{alternativeNo}
  381. </if>
  382. <if test = "operationNo != null and operationNo != ''">
  383. AND a.operation_no = #{operationNo}
  384. </if>
  385. <if test = "operationName != null and operationName != ''">
  386. AND a.operation_name like #{operationName}
  387. </if>
  388. <if test = "operationId != null and operationId != ''">
  389. AND a.operation_id = #{operationId}
  390. </if>
  391. </where>
  392. </select>
  393. <!-- 查 max line_item_no -->
  394. <select id="selectMaxLineItemNo" parameterType="BomComponentEntity" resultType="BomComponentEntity">
  395. SELECT
  396. site,
  397. bu_no,
  398. part_no,
  399. eng_chg_level,
  400. bom_type,
  401. alternative_no,
  402. component_part,
  403. line_item_no
  404. FROM plm_bom_component
  405. WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = (
  406. SELECT MAX(line_item_no)
  407. FROM plm_bom_component
  408. WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo})
  409. </select>
  410. <!-- 判断是否已有该物料的 bom -->
  411. <select id="queryPartBom" parameterType="BomAllFieldEntity" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo">
  412. SELECT top 1
  413. site,
  414. bu_no,
  415. part_no,
  416. bom_type,
  417. eng_chg_level,
  418. note_text,
  419. eff_phase_in_date,
  420. eff_phase_out_date,
  421. eng_revision,
  422. net_weight
  423. FROM plm_bom_header
  424. WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} order by eng_chg_level desc
  425. </select>
  426. <!-- 获取子料的序号 -->
  427. <select id="getComponentLineSequence" parameterType="BomAllFieldEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo">
  428. SELECT top 1
  429. site,
  430. bu_no,
  431. part_no,
  432. eng_chg_level,
  433. bom_type,
  434. alternative_no,
  435. line_sequence
  436. FROM plm_bom_component
  437. WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} order by line_sequence desc
  438. </select>
  439. <!-- 判断该 bom 是否有 Buildable Obsolete 状态的替代 -->
  440. <select id="queryAlternativeStatus" parameterType="BomHeaderEntity" resultType="com.xujie.sys.modules.part.vo.BomDetailVo">
  441. SELECT
  442. site,
  443. part_no,
  444. eng_chg_level,
  445. bom_type,
  446. alternative_no,
  447. status
  448. FROM plm_bom_detail
  449. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and (status = 'Buildable' or status = 'Obsolete')
  450. </select>
  451. <!-- 判断 BOM 是否存在子料 -->
  452. <select id="queryComponentPart" parameterType="BomHeaderEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo">
  453. SELECT
  454. site,
  455. part_no,
  456. eng_chg_level,
  457. bom_type,
  458. alternative_no,
  459. component_part
  460. FROM plm_bom_component
  461. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  462. </select>
  463. <!-- 获取bom header 对象-->
  464. <select id="queryBomHeader" parameterType="BomHeaderEntity" resultType="BomHeaderEntity">
  465. SELECT
  466. site,
  467. bu_no,
  468. part_no,
  469. eng_chg_level,
  470. bom_type,
  471. note_text,
  472. eff_phase_in_date,
  473. eff_phase_out_date,
  474. eng_revision,
  475. type_flag,
  476. net_weight
  477. FROM plm_bom_header
  478. WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  479. </select>
  480. <!-- 新增BOM子明细表内容 -->
  481. <insert id="saveBomComponents">
  482. insert into plm_bom_component
  483. (site, bu_no, 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_id, note_text, create_date, create_by, line_sequence, consumption_item) VALUES
  484. <foreach collection="list" item="item" index="index" separator=",">
  485. (#{item.site}, #{item.buNo}, #{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.operationId}, #{item.noteText}, getDate(), #{item.createBy}, #{item.lineSequence}, #{item.consumptionItem})
  486. </foreach>
  487. </insert>
  488. <!-- 判断 BOM 是否存在子料 -->
  489. <select id="queryComponentPart2" parameterType="BomDetailEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo">
  490. SELECT
  491. site,
  492. bu_no,
  493. part_no,
  494. eng_chg_level,
  495. bom_type,
  496. alternative_no,
  497. component_part
  498. FROM plm_bom_component
  499. WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  500. </select>
  501. <!-- 修改替代状态 -->
  502. <update id="updateAlternativeStatus" parameterType="BomDetailEntity">
  503. update plm_bom_detail
  504. set status = #{status},
  505. update_date = getDate(),
  506. update_by = #{updateBy}
  507. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  508. </update>
  509. <select id="getComponentByLineSequenceNo" parameterType="BomComponentEntity" resultType="BomComponentEntity">
  510. SELECT
  511. site,
  512. bu_no,
  513. part_no,
  514. eng_chg_level,
  515. bom_type,
  516. alternative_no,
  517. component_part,
  518. line_sequence
  519. FROM plm_bom_component
  520. WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_sequence = #{lineSequence}
  521. </select>
  522. <!-- bom主表编辑 -->
  523. <update id="updateInDate" parameterType="BomHeaderEntity">
  524. update plm_bom_header
  525. set eff_phase_out_date = #{effPhaseOutDate},
  526. update_date = getDate(),
  527. update_by = #{createBy}
  528. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  529. </update>
  530. <!-- 查出所有类型的物料 -->
  531. <select id="queryPartListAll" parameterType="ComponentPartData" resultType="BomAllFieldEntity">
  532. SELECT
  533. site,
  534. sourceBu as buNo,
  535. part_no,
  536. part_desc,
  537. spec,
  538. umid as printUnit,
  539. dbo.qc_get_um_name(site, umid) as printUnitName,
  540. part_type,
  541. FamilyID,
  542. dbo.get_family_name(site, sourceBu, FamilyID) as familyName
  543. FROM part
  544. <where>
  545. site = #{query.site}
  546. and sourceBu = #{query.buNo}
  547. and active = 'Y'
  548. <!-- and part_type <![CDATA[<>]]> 'Purchased (raw)' -->
  549. <if test = "query.partNo != null and query.partNo != ''">
  550. AND part_no like '%' + #{query.partNo} + '%'
  551. </if>
  552. <if test = "query.partDesc != null and query.partDesc != ''">
  553. AND part_desc like '%' + #{query.partDesc} + '%'
  554. </if>
  555. </where>
  556. </select>
  557. <!-- 校验日期是否冲突-->
  558. <select id="queryHeaderPhaseDate" parameterType="BomHeaderEntity" resultType="BomHeaderEntity">
  559. SELECT
  560. site,
  561. bu_no,
  562. part_no,
  563. eng_chg_level,
  564. bom_type,
  565. note_text,
  566. eff_phase_in_date,
  567. eff_phase_out_date
  568. FROM plm_bom_header
  569. <where>
  570. site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType}
  571. <if test = "effPhaseInDate == null">
  572. and eff_phase_in_date = #{effPhaseInDate}
  573. </if>
  574. <if test = "effPhaseOutDate != null">
  575. and #{effPhaseInDate} >= eff_phase_in_date and eff_phase_out_date >= #{effPhaseOutDate}
  576. </if>
  577. </where>
  578. </select>
  579. </mapper>