O
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.

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