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.

1261 lines
52 KiB

2 years ago
9 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
11 months ago
11 months ago
11 months ago
9 months ago
11 months ago
11 months ago
11 months ago
9 months ago
10 months ago
2 years ago
11 months ago
11 months ago
11 months ago
2 years ago
2 years ago
9 months ago
2 years ago
2 years ago
9 months ago
2 years ago
9 months ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
9 months ago
2 years ago
1 year ago
2 years ago
9 months ago
2 years ago
1 year 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
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months 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.RecipeManagementMapper">
  4. <!-- 材料信息列表 -->
  5. <select id="recipeManagementSearch" parameterType="com.spring.modules.part.vo.RecipeHeaderVo" resultType="com.spring.modules.part.vo.RecipeHeaderVo">
  6. SELECT
  7. a.site,
  8. a.part_no,
  9. b.part_desc,
  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_recipe_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.partNo != null and query.partNo != ''">
  34. AND a.part_no like #{query.partNo}
  35. </if>
  36. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  37. AND b.plm_part_no like #{query.plmPartNo}
  38. </if>
  39. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  40. AND b.ifs_part_no like #{query.ifsPartNo}
  41. </if>
  42. <if test = "query.partDesc != null and query.partDesc != ''">
  43. AND b.part_desc like #{query.partDesc}
  44. </if>
  45. <if test = "query.bomType != null and query.bomType != ''">
  46. AND a.bom_type = #{query.bomType}
  47. </if>
  48. <if test = "query.engChgLevel != null and query.engChgLevel != ''">
  49. AND a.eng_chg_level = #{query.engChgLevel}
  50. </if>
  51. </where>
  52. </select>
  53. <!-- 查询物料清单 -->
  54. <select id="queryPartList" parameterType="ComponentPartData" resultType="RecipeAllFieldEntity">
  55. SELECT
  56. a.site,
  57. a.part_no,
  58. a.part_desc,
  59. a.spec,
  60. a.um_id as printUnit,
  61. b.um_name as printUnitName,
  62. a.part_type,
  63. a.family_id,
  64. c.family_name,
  65. a.part_status,
  66. d.part_status_desc,
  67. a.plm_part_no,
  68. a.ifs_part_no
  69. FROM part as a
  70. left join um as b on a.um_id = b.um_id
  71. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  72. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  73. <where>
  74. a.site = #{query.site}
  75. and a.part_type in ('Manufactured', 'Manufactured Recipe', 'Purchased')
  76. and a.active = 'Y' and a.show_in_query_flag = 'Y'
  77. <if test = "query.partNo != null and query.partNo != ''">
  78. AND a.part_no like #{query.partNo}
  79. </if>
  80. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  81. AND a.plm_part_no like #{query.plmPartNo}
  82. </if>
  83. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  84. AND a.ifs_part_no like #{query.ifsPartNo}
  85. </if>
  86. <if test = "query.partDesc != null and query.partDesc != ''">
  87. AND a.part_desc like #{query.partDesc}
  88. </if>
  89. <if test = "query.status != null and query.status != ''">
  90. AND a.status = #{query.status}
  91. </if>
  92. </where>
  93. </select>
  94. <!-- 查出可创建Recipe的物料 -->
  95. <select id="queryPartListRecipe" parameterType="ComponentPartData" resultType="RecipeAllFieldEntity">
  96. SELECT
  97. a.site,
  98. a.part_no,
  99. a.part_desc,
  100. a.spec,
  101. a.um_id as printUnit,
  102. b.um_name as printUnitName,
  103. a.part_type,
  104. a.family_id,
  105. c.family_name,
  106. a.part_status,
  107. d.part_status_desc,
  108. a.plm_part_no,
  109. a.ifs_part_no,
  110. a.product_group_id4
  111. FROM part as a
  112. left join um as b on a.um_id = b.um_id
  113. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  114. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  115. <where>
  116. a.site = #{query.site}
  117. and a.active = 'Y' and a.show_in_query_flag = 'Y'
  118. and a.part_type <![CDATA[<>]]> 'Purchased (raw)'
  119. <if test = "query.partNo != null and query.partNo != ''">
  120. AND a.part_no like #{query.partNo}
  121. </if>
  122. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  123. AND a.plm_part_no like #{query.plmPartNo}
  124. </if>
  125. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  126. AND a.ifs_part_no like #{query.ifsPartNo}
  127. </if>
  128. <if test = "query.partDesc != null and query.partDesc != ''">
  129. AND a.part_desc like #{query.partDesc}
  130. </if>
  131. <if test = "query.status != null and query.status != ''">
  132. AND a.status = #{query.status}
  133. </if>
  134. <if test = "query.productGroupId4 != null and query.productGroupId4 != ''">
  135. AND a.product_group_id4 = #{query.productGroupId4}
  136. </if>
  137. <if test = "query.partStatus != null and query.partStatus == 'active'">
  138. AND a.part_status != 'D'
  139. </if>
  140. </where>
  141. </select>
  142. <!-- 查出所有类型的物料 -->
  143. <select id="queryPartListAll" parameterType="ComponentPartData" resultType="RecipeAllFieldEntity">
  144. SELECT
  145. a.site,
  146. a.part_no,
  147. a.part_desc,
  148. a.spec,
  149. a.um_id as printUnit,
  150. b.um_name as printUnitName,
  151. a.part_type,
  152. a.family_id,
  153. c.family_name,
  154. a.part_status,
  155. d.part_status_desc,
  156. a.plm_part_no,
  157. a.ifs_part_no,
  158. a.product_group_id4,
  159. dbo.get_product_group_name(a.site, a.product_group_id4, '4') as productGroupName4
  160. FROM part as a
  161. left join um as b on a.um_id = b.um_id
  162. left join part_family as c on a.site = c.site and a.family_id = c.family_id
  163. left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status
  164. <where>
  165. a.site = #{query.site}
  166. and a.active = 'Y' and a.show_in_query_flag = 'Y'
  167. <if test = "query.partNo != null and query.partNo != ''">
  168. AND a.part_no like #{query.partNo}
  169. </if>
  170. <if test = "query.plmPartNo != null and query.plmPartNo != ''">
  171. AND a.plm_part_no like #{query.plmPartNo}
  172. </if>
  173. <if test = "query.ifsPartNo != null and query.ifsPartNo != ''">
  174. AND a.ifs_part_no like #{query.ifsPartNo}
  175. </if>
  176. <if test = "query.partDesc != null and query.partDesc != ''">
  177. AND a.part_desc like #{query.partDesc}
  178. </if>
  179. <if test = "query.status != null and query.status != ''">
  180. AND a.status = #{query.status}
  181. </if>
  182. <if test = "query.productGroupId4 != null and query.productGroupId4 != ''">
  183. AND a.product_group_id4 = #{query.productGroupId4}
  184. </if>
  185. <if test = "query.partStatus != null and query.partStatus == 'active'">
  186. AND a.part_status != 'D'
  187. </if>
  188. </where>
  189. </select>
  190. <!-- 新增Recipe主表内容 -->
  191. <insert id="saveRecipeHeader" parameterType="RecipeHeaderEntity">
  192. INSERT INTO plm_recipe_header
  193. (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)
  194. VALUES
  195. (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{noteText}, #{effPhaseInDate}, #{effPhaseOutDate}, #{engRevision}, #{typeFlag}, #{netWeight}, #{officialFlag}, getDate(), #{createBy})
  196. </insert>
  197. <!-- recipe明细新增 -->
  198. <insert id="recipeDetailSave" parameterType="RecipeDetailEntity">
  199. INSERT INTO plm_recipe_detail
  200. (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, display_weight_uom, display_volume_uom, reg_unit)
  201. VALUES
  202. (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{alternativeDescription}, #{status}, #{minLotQty}, #{defaultFlag}, #{detailNoteText}, getDate(), #{createBy}, #{officialFlag}, #{displayWeightUom}, #{displayVolumeUom}, #{regUnit})
  203. </insert>
  204. <!-- 新增Recipe子明细表内容 -->
  205. <insert id="saveRecipeComponent" parameterType="RecipeComponentEntity">
  206. INSERT INTO plm_recipe_component
  207. (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,
  208. issue_to_loc, operation_no, note_text, create_date, create_by, line_sequence, consumption_item, parts_by_weight, qty_uom, issue_planned_scrap_db, issue_overreported_qty_db,
  209. fixed_qty_flag, promise_planned, phantom_consume, oper_cost_distribution, gen_oh_cost_distribution, qty_kg, by_prod_as_supply_in_mrp_db, leadtime_offset, std_planned_item,
  210. charged_item, last_activity_date, exclude_from_calculations_db, exclude_from_as_built_db, lot_batch_origin_db, weight_share)
  211. VALUES
  212. (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{componentPart}, #{lineItemNo}, #{printUnit}, #{qtyPerAssembly}, #{componentScrap}, #{shrinkageFactor}, #{issueType},
  213. #{issueToLoc}, #{operationNo}, #{noteText}, getDate(), #{createBy}, #{lineSequence}, #{consumptionItem}, #{partsByWeight}, #{qtyUom}, #{issuePlannedScrapDb}, #{issueOverreportedQtyDb},
  214. #{fixedQtyFlag}, #{promisePlanned}, #{phantomConsume}, #{operCostDistribution}, #{genOhCostDistribution}, #{qtyKg}, #{byProdAsSupplyInMrpDb}, #{leadtimeOffset}, #{stdPlannedItem},
  215. #{chargedItem}, getDate(), #{excludeFromCalculationsDb}, #{excludeFromAsBuiltDb}, #{lotBatchOriginDb}, #{weightShare})
  216. </insert>
  217. <!-- 查recipe明细 -->
  218. <select id="queryRecipeDetail" parameterType="RecipeHeaderEntity" resultType="RecipeDetailEntity">
  219. SELECT
  220. site,
  221. part_no,
  222. bom_type,
  223. eng_chg_level,
  224. alternative_no,
  225. alternative_description,
  226. status,
  227. min_lot_qty,
  228. default_flag,
  229. note_text as detailNoteText,
  230. official_flag,
  231. display_weight_uom,
  232. display_volume_uom,
  233. reg_unit
  234. FROM plm_recipe_detail
  235. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel}
  236. </select>
  237. <!-- 查recipe明细对象 -->
  238. <select id="queryDetailDataByNo" parameterType="RecipeDetailEntity" resultType="RecipeDetailEntity">
  239. SELECT
  240. site,
  241. part_no,
  242. bom_type,
  243. eng_chg_level,
  244. alternative_no,
  245. alternative_description,
  246. status,
  247. min_lot_qty,
  248. default_flag,
  249. note_text as detailNoteText,
  250. official_flag,
  251. display_weight_uom,
  252. display_volume_uom,
  253. reg_unit
  254. FROM plm_recipe_detail
  255. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  256. </select>
  257. <!-- 查recipe子明细 -->
  258. <select id="queryRecipeComponent" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  259. SELECT
  260. a.site,
  261. a.part_no,
  262. a.bom_type,
  263. a.eng_chg_level,
  264. a.alternative_no,
  265. a.component_part,
  266. b.part_desc as componentPartDesc,
  267. a.print_unit,
  268. dbo.get_um_name(a.print_unit) as printUnitName,
  269. a.qty_per_assembly,
  270. a.component_scrap,
  271. a.issue_type,
  272. a.shrinkage_factor,
  273. a.line_item_no,
  274. a.operation_no,
  275. a.issue_to_loc,
  276. dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName,
  277. a.note_text,
  278. a.line_sequence,
  279. a.consumption_item,
  280. b.part_status,
  281. dbo.get_part_status_name(a.site, b.part_status) as partStatusDesc,
  282. a.parts_by_weight,
  283. a.qty_uom,
  284. a.issue_planned_scrap_db,
  285. a.issue_overreported_qty_db,
  286. a.fixed_qty_flag,
  287. a.promise_planned,
  288. a.phantom_consume,
  289. a.oper_cost_distribution,
  290. a.gen_oh_cost_distribution,
  291. a.qty_kg,
  292. a.by_prod_as_supply_in_mrp_db,
  293. a.leadtime_offset,
  294. a.std_planned_item,
  295. a.charged_item,
  296. a.last_activity_date,
  297. a.exclude_from_calculations_db,
  298. a.exclude_from_as_built_db,
  299. a.lot_batch_origin_db,
  300. a.weight_share
  301. FROM plm_recipe_component as a
  302. left join part as b on a.site = b.site and a.component_part = b.part_no
  303. 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
  304. order by a.line_sequence
  305. </select>
  306. <!-- 查recipe子明细 -->
  307. <select id="queryRecipeByProducts" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  308. SELECT
  309. a.site,
  310. a.part_no,
  311. a.bom_type,
  312. a.eng_chg_level,
  313. a.alternative_no,
  314. a.component_part,
  315. b.part_desc as componentPartDesc,
  316. a.print_unit,
  317. dbo.get_um_name(a.print_unit) as printUnitName,
  318. abs(a.qty_per_assembly) as qtyPerAssembly,
  319. a.component_scrap,
  320. a.issue_type,
  321. a.shrinkage_factor,
  322. a.line_item_no,
  323. a.operation_no,
  324. a.issue_to_loc,
  325. dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName,
  326. a.note_text,
  327. a.line_sequence,
  328. a.consumption_item,
  329. b.part_status,
  330. dbo.get_part_status_name(a.site, b.part_status) as partStatusDesc,
  331. a.parts_by_weight,
  332. a.qty_uom,
  333. a.issue_planned_scrap_db,
  334. a.issue_overreported_qty_db,
  335. a.fixed_qty_flag,
  336. a.promise_planned,
  337. a.phantom_consume,
  338. a.oper_cost_distribution,
  339. a.gen_oh_cost_distribution,
  340. a.qty_kg,
  341. a.by_prod_as_supply_in_mrp_db,
  342. a.leadtime_offset,
  343. a.std_planned_item,
  344. a.charged_item,
  345. a.last_activity_date,
  346. a.exclude_from_calculations_db,
  347. a.exclude_from_as_built_db,
  348. a.lot_batch_origin_db,
  349. a.weight_share
  350. FROM plm_recipe_component as a
  351. left join part as b on a.site = b.site and a.component_part = b.part_no
  352. 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
  353. order by a.line_sequence
  354. </select>
  355. <!-- 查recipe子明细 -->
  356. <select id="queryRecipeComponentAll" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  357. SELECT
  358. site,
  359. part_no,
  360. bom_type,
  361. eng_chg_level,
  362. alternative_no,
  363. component_part,
  364. dbo.get_part_name(site, component_part) as componentPartDesc,
  365. print_unit,
  366. dbo.get_um_name(print_unit) as printUnitName,
  367. qty_per_assembly,
  368. component_scrap,
  369. issue_type,
  370. shrinkage_factor,
  371. line_item_no,
  372. operation_no,
  373. issue_to_loc,
  374. dbo.get_location_name(site, issue_to_loc) as issueToLocName,
  375. note_text,
  376. line_sequence,
  377. consumption_item,
  378. parts_by_weight,
  379. qty_uom,
  380. issue_planned_scrap_db,
  381. issue_overreported_qty_db,
  382. fixed_qty_flag,
  383. promise_planned,
  384. phantom_consume,
  385. oper_cost_distribution,
  386. gen_oh_cost_distribution,
  387. qty_kg,
  388. by_prod_as_supply_in_mrp_db,
  389. leadtime_offset,
  390. std_planned_item,
  391. charged_item,
  392. last_activity_date,
  393. exclude_from_calculations_db,
  394. exclude_from_as_built_db,
  395. lot_batch_origin_db,
  396. weight_share
  397. FROM plm_recipe_component
  398. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  399. order by line_sequence
  400. </select>
  401. <!-- recipe主表编辑 -->
  402. <update id="updateRecipeHeader" parameterType="RecipeAllFieldEntity">
  403. update plm_recipe_header
  404. set eff_phase_in_date = #{effPhaseInDate},
  405. eff_phase_out_date = #{effPhaseOutDate},
  406. eng_revision = #{engRevision},
  407. type_flag = #{typeFlag},
  408. net_weight = #{netWeight},
  409. note_text = #{noteText},
  410. update_date = getDate(),
  411. update_by = #{updateBy}
  412. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  413. </update>
  414. <!-- recipe明细表编辑 -->
  415. <update id="updateRecipeDetail" parameterType="RecipeDetailEntity">
  416. update plm_recipe_detail
  417. set alternative_description = #{alternativeDescription},
  418. min_lot_qty = #{minLotQty},
  419. note_text = #{detailNoteText},
  420. status = #{status},
  421. update_date = getDate(),
  422. update_by = #{updateBy},
  423. display_weight_uom = #{displayWeightUom},
  424. display_volume_uom = #{displayVolumeUom}
  425. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  426. </update>
  427. <!-- 删除recipe子明细 -->
  428. <delete id="deleteRecipeComponent" parameterType="RecipeAllFieldEntity">
  429. delete from plm_recipe_component
  430. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  431. </delete>
  432. <!-- 删除替代 -->
  433. <delete id="recipeDetailDelete" parameterType="RecipeDetailEntity">
  434. delete from plm_recipe_detail
  435. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  436. </delete>
  437. <!-- recipe主表查重 -->
  438. <select id="checkRecipeOnlyOne" parameterType="RecipeAllFieldEntity" resultType="com.spring.modules.part.vo.RecipeHeaderVo">
  439. SELECT
  440. site,
  441. part_no,
  442. dbo.get_part_name(site, part_no) as partDesc,
  443. bom_type,
  444. eng_chg_level,
  445. eff_phase_in_date,
  446. eff_phase_out_date,
  447. eng_revision,
  448. type_flag,
  449. net_weight,
  450. note_text,
  451. official_flag
  452. FROM plm_recipe_header
  453. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel}
  454. </select>
  455. <!-- recipe明细查重 -->
  456. <select id="checkRecipeDetailOnlyOne" parameterType="RecipeDetailEntity" resultType="RecipeDetailEntity">
  457. SELECT
  458. site,
  459. part_no,
  460. bom_type,
  461. eng_chg_level,
  462. alternative_no,
  463. alternative_description,
  464. bom_type,
  465. eng_chg_level,
  466. min_lot_qty,
  467. default_flag,
  468. note_text as detailNoteText,
  469. status,
  470. official_flag,
  471. display_weight_uom,
  472. display_volume_uom,
  473. reg_unit
  474. FROM plm_recipe_detail
  475. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  476. </select>
  477. <!-- 批量删除子明细物料 -->
  478. <delete id="deleteRecipeComponents" parameterType="RecipeComponentEntity">
  479. delete from plm_recipe_component
  480. where site = #{site}
  481. and part_no = #{partNo}
  482. and eng_chg_level = #{engChgLevel}
  483. and bom_type = #{bomType}
  484. and alternative_no = #{alternativeNo}
  485. and line_item_no = #{lineItemNo}
  486. </delete>
  487. <!-- 删除recipe子明细 -->
  488. <delete id="deleteRecipeComponentByPartNo" parameterType="RecipeHeaderEntity">
  489. delete from plm_recipe_component
  490. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  491. </delete>
  492. <!-- 删除recipe明细 -->
  493. <delete id="deleteRecipeDetailByPartNo" parameterType="RecipeHeaderEntity">
  494. delete from plm_recipe_detail
  495. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  496. </delete>
  497. <!-- 删除recipe主记录 -->
  498. <delete id="deleteRecipeHeaderByPartNo" parameterType="RecipeHeaderEntity">
  499. delete from plm_recipe_header
  500. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  501. </delete>
  502. <!-- recipe明细查重 -->
  503. <select id="checkRecipeComponentOnlyOne" parameterType="RecipeComponentEntity" resultType="RecipeComponentEntity">
  504. SELECT
  505. site,
  506. part_no,
  507. bom_type,
  508. eng_chg_level,
  509. alternative_no,
  510. component_part,
  511. line_item_no
  512. FROM plm_recipe_component
  513. 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}
  514. </select>
  515. <!-- 修改recipe子明细 -->
  516. <update id="updateRecipeComponent" parameterType="RecipeComponentEntity">
  517. update plm_recipe_component
  518. set qty_per_assembly = #{qtyPerAssembly},
  519. component_scrap = #{componentScrap},
  520. issue_type = #{issueType},
  521. shrinkage_factor = #{shrinkageFactor},
  522. operation_no = #{operationNo},
  523. issue_to_loc = #{issueToLoc},
  524. note_text = #{noteText},
  525. line_sequence = #{lineSequence},
  526. consumption_item = #{consumptionItem},
  527. update_date = getDate(),
  528. update_by = #{updateBy},
  529. weight_share = #{weightShare},
  530. parts_by_weight = #{partsByWeight},
  531. qty_uom = #{qtyUom},
  532. qty_kg = #{qtyKg}
  533. 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}
  534. </update>
  535. <!-- 修改替代状态 -->
  536. <update id="updateAlternativeStatus" parameterType="RecipeDetailEntity">
  537. update plm_recipe_detail
  538. set status = #{status},
  539. update_date = getDate(),
  540. update_by = #{updateBy}
  541. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  542. </update>
  543. <!-- 查recipe明细对象 -->
  544. <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity">
  545. select
  546. a.site,
  547. a.part_no,
  548. a.routing_revision,
  549. a.routing_type,
  550. a.alternative_no,
  551. b.alternative_description,
  552. b.status,
  553. a.operation_id,
  554. a.operation_no,
  555. a.operation_name
  556. from plm_routing_component as a
  557. 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
  558. <where>
  559. a.site = #{site} and a.part_no = #{partNo}
  560. <if test = "routingRevision != null and routingRevision != ''">
  561. AND a.routing_revision = #{routingRevision}
  562. </if>
  563. <if test = "routingType != null and routingType != ''">
  564. AND a.routing_type = #{routingType}
  565. </if>
  566. <if test = "alternativeNo != null and alternativeNo != ''">
  567. AND a.alternative_no = #{alternativeNo}
  568. </if>
  569. <if test = "operationNo != null and operationNo != ''">
  570. AND a.operation_no = #{operationNo}
  571. </if>
  572. <if test = "operationName != null and operationName != ''">
  573. AND a.operation_name like #{operationName}
  574. </if>
  575. <if test = "operationId != null and operationId != ''">
  576. AND a.operation_id = #{operationId}
  577. </if>
  578. </where>
  579. </select>
  580. <!-- 查 max line_item_no -->
  581. <select id="selectMaxLineItemNo" parameterType="RecipeComponentEntity" resultType="RecipeComponentEntity">
  582. SELECT
  583. site,
  584. part_no,
  585. eng_chg_level,
  586. bom_type,
  587. alternative_no,
  588. component_part,
  589. line_item_no
  590. FROM plm_recipe_component
  591. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = (
  592. SELECT MAX(line_item_no)
  593. FROM plm_recipe_component
  594. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo})
  595. </select>
  596. <!-- 判断是否已有该物料的 recipe -->
  597. <select id="queryPartRecipe" parameterType="RecipeAllFieldEntity" resultType="com.spring.modules.part.vo.RecipeHeaderVo">
  598. SELECT top 1
  599. site,
  600. part_no,
  601. bom_type,
  602. eng_chg_level,
  603. note_text,
  604. eff_phase_in_date,
  605. eff_phase_out_date,
  606. eng_revision,
  607. net_weight,
  608. official_flag
  609. FROM plm_recipe_header
  610. WHERE site = #{site} and part_no = #{partNo} and bom_type = #{bomType} order by eng_chg_level desc
  611. </select>
  612. <!-- 获取子料的序号 -->
  613. <select id="getComponentLineSequence" parameterType="RecipeAllFieldEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  614. SELECT top 1
  615. site,
  616. part_no,
  617. eng_chg_level,
  618. bom_type,
  619. alternative_no,
  620. line_sequence
  621. FROM plm_recipe_component
  622. 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
  623. </select>
  624. <!-- 判断该 recipe 是否有 Buildable Obsolete 状态的替代 -->
  625. <select id="queryAlternativeStatus" parameterType="RecipeHeaderEntity" resultType="com.spring.modules.part.vo.RecipeDetailVo">
  626. SELECT
  627. site,
  628. part_no,
  629. eng_chg_level,
  630. bom_type,
  631. alternative_no,
  632. status,
  633. display_weight_uom,
  634. display_volume_uom,
  635. reg_unit
  636. FROM plm_recipe_detail
  637. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and (status = 'Buildable' or status = 'Obsolete')
  638. </select>
  639. <!-- 判断该 Recipe 是否有正式的替代 -->
  640. <select id="queryOfficialRecipeDetail" parameterType="RecipeHeaderEntity" resultType="com.spring.modules.part.vo.RecipeDetailVo">
  641. SELECT
  642. site,
  643. part_no,
  644. eng_chg_level,
  645. bom_type,
  646. alternative_no,
  647. status,
  648. official_flag,
  649. display_weight_uom,
  650. display_volume_uom,
  651. reg_unit
  652. FROM plm_recipe_detail
  653. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and official_flag = 'Y'
  654. </select>
  655. <!-- 正式替代且状态非拟定:整单删除前校验用 -->
  656. <select id="queryOfficialNonTentativeRecipeDetail" parameterType="RecipeHeaderEntity" resultType="com.spring.modules.part.vo.RecipeDetailVo">
  657. SELECT
  658. site,
  659. part_no,
  660. eng_chg_level,
  661. bom_type,
  662. alternative_no,
  663. status,
  664. official_flag,
  665. display_weight_uom,
  666. display_volume_uom,
  667. reg_unit
  668. FROM plm_recipe_detail
  669. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  670. and official_flag = 'Y'
  671. and (status IS NULL OR status &lt;&gt; 'Tentative')
  672. </select>
  673. <!-- 判断 Recipe 是否存在子料 -->
  674. <select id="queryComponentPart" parameterType="RecipeHeaderEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  675. SELECT
  676. site,
  677. part_no,
  678. eng_chg_level,
  679. bom_type,
  680. alternative_no,
  681. component_part
  682. FROM plm_recipe_component
  683. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  684. </select>
  685. <!-- 判断 Recipe 是否存在子料 -->
  686. <select id="queryComponentPart2" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  687. SELECT
  688. site,
  689. part_no,
  690. eng_chg_level,
  691. bom_type,
  692. alternative_no,
  693. component_part
  694. FROM plm_recipe_component
  695. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  696. </select>
  697. <!-- 获取ifs header 对象-->
  698. <select id="getRecipeHeader" parameterType="RecipeDetailEntity" resultType="RecipeIfsHeader">
  699. SELECT
  700. site as contract,
  701. part_no,
  702. eng_chg_level,
  703. bom_type,
  704. eff_phase_in_date,
  705. eff_phase_out_date,
  706. note_text,
  707. create_date,
  708. 'add' as histType
  709. FROM plm_recipe_header
  710. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  711. </select>
  712. <!-- 获取ifs component 对象-->
  713. <select id="getRecipeComponent" parameterType="RecipeDetailEntity" resultType="RecipeIfsItem">
  714. SELECT
  715. site as contract,
  716. part_no,
  717. eng_chg_level,
  718. bom_type,
  719. alternative_no,
  720. line_item_no,
  721. line_sequence,
  722. component_part,
  723. qty_per_assembly,
  724. issue_type,
  725. component_scrap,
  726. shrinkage_factor,
  727. note_text,
  728. consumption_item,
  729. operation_no,
  730. parts_by_weight,
  731. qty_uom,
  732. issue_planned_scrap_db,
  733. issue_overreported_qty_db,
  734. fixed_qty_flag,
  735. promise_planned,
  736. phantom_consume,
  737. oper_cost_distribution,
  738. gen_oh_cost_distribution,
  739. qty_kg,
  740. by_prod_as_supply_in_mrp_db,
  741. leadtime_offset,
  742. std_planned_item,
  743. charged_item,
  744. last_activity_date,
  745. exclude_from_calculations_db,
  746. exclude_from_as_built_db,
  747. lot_batch_origin_db,
  748. weight_share
  749. FROM plm_recipe_component
  750. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  751. </select>
  752. <!-- 获取recipe header 对象-->
  753. <select id="queryRecipeHeader" parameterType="RecipeHeaderEntity" resultType="RecipeHeaderEntity">
  754. SELECT
  755. site,
  756. part_no,
  757. eng_chg_level,
  758. bom_type,
  759. note_text,
  760. eff_phase_in_date,
  761. eff_phase_out_date,
  762. eng_revision,
  763. row_version,
  764. row_key,
  765. type_flag,
  766. net_weight
  767. FROM plm_recipe_header
  768. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  769. </select>
  770. <!-- recipe主表编辑 -->
  771. <update id="updateInDate" parameterType="RecipeHeaderEntity">
  772. update plm_recipe_header
  773. set eff_phase_out_date = #{effPhaseOutDate},
  774. update_date = getDate(),
  775. update_by = #{createBy}
  776. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  777. </update>
  778. <!-- 校验物料版本是否存在-->
  779. <select id="queryPartRevision" parameterType="RecipeHeaderEntity" resultType="PartRevisionEntity">
  780. SELECT
  781. site,
  782. part_no,
  783. eng_chg_level,
  784. eff_phase_in_date,
  785. eff_phase_out_date,
  786. revision_text,
  787. product_status,
  788. repair_status,
  789. eng_revision,
  790. create_date,
  791. create_by,
  792. update_date,
  793. update_by
  794. FROM part_revision
  795. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  796. </select>
  797. <!-- 新增物料版本 -->
  798. <insert id="savePartRevision" parameterType="RecipeHeaderEntity">
  799. 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)
  800. values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{noteText}, 'Not In Effect', 'Not In Effect', #{engRevision}, getDate(), #{createBy})
  801. </insert>
  802. <select id="queryRecipeDetailOfficialFlag" parameterType="RecipeComponentEntity" resultType="RecipeDetailEntity">
  803. SELECT
  804. site,
  805. part_no,
  806. bom_type,
  807. eng_chg_level,
  808. alternative_no,
  809. alternative_description,
  810. min_lot_qty,
  811. default_flag,
  812. note_text as detailNoteText,
  813. status,
  814. official_flag,
  815. display_weight_uom,
  816. display_volume_uom,
  817. reg_unit
  818. FROM plm_recipe_detail
  819. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  820. </select>
  821. <!-- 获取 component 对象-->
  822. <select id="queryComponentPartFlag" parameterType="RecipeDetailEntity" resultType="PartInformationEntity">
  823. SELECT
  824. a.site,
  825. a.part_no,
  826. b.status
  827. FROM plm_recipe_component as a
  828. LEFT JOIN part as b on a.site = b.site and a.component_part = b.part_no
  829. 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}
  830. </select>
  831. <select id="queryRecipeDetailEntityList" resultType="com.spring.modules.part.entity.RecipeDetailEntity">
  832. SELECT
  833. site,
  834. part_no,
  835. bom_type,
  836. eng_chg_level,
  837. alternative_no,
  838. alternative_description,
  839. status,
  840. min_lot_qty,
  841. default_flag,
  842. note_text as detailNoteText,
  843. official_flag,
  844. display_weight_uom,
  845. display_volume_uom,
  846. reg_unit
  847. FROM plm_recipe_detail
  848. where site = #{site} and part_no = #{partNo}
  849. order by eng_chg_level desc
  850. </select>
  851. <!-- 查询库位 -->
  852. <select id="selectLocation" parameterType="RecipeComponentEntity" resultType="LocationInformationEntity">
  853. SELECT
  854. site,
  855. location_id,
  856. location_name
  857. FROM view_location
  858. <where>
  859. site = #{site} AND location_id = #{issueToLoc}
  860. </where>
  861. </select>
  862. <!-- 查询part revision -->
  863. <select id="selectPartRevision" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.PartRevisionVo">
  864. SELECT
  865. site,
  866. part_no,
  867. eng_chg_level,
  868. eff_phase_in_date,
  869. eff_phase_out_date,
  870. revision_text,
  871. product_status,
  872. repair_status,
  873. eng_revision
  874. FROM part_revision
  875. where site = #{site} AND part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  876. </select>
  877. <!-- 修改revision状态 -->
  878. <update id="updatePartRevisionProductStatus" parameterType="com.spring.modules.part.vo.PartRevisionVo">
  879. update part_revision
  880. set product_status = #{productStatus},
  881. <if test = "bomType == 'Repair'">
  882. repair_status = 'In Effect',
  883. </if>
  884. update_date = getDate(),
  885. update_by = #{updateBy}
  886. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  887. </update>
  888. <!-- 新增副产品成本分配数据 -->
  889. <insert id="saveRecipeManufStructCostDistrib">
  890. insert into plm_recipe_manuf_struct_cost_distrib
  891. (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
  892. <foreach collection="list" item="item" index="index" separator=",">
  893. (#{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})
  894. </foreach>
  895. </insert>
  896. <!-- 查recipe副产品成本分配 -->
  897. <select id="queryRecipeManufStructCostDistrib" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.RecipeManufStructCostDistribVo">
  898. SELECT
  899. site,
  900. part_no,
  901. bom_type,
  902. eng_chg_level,
  903. alternative_no,
  904. by_prod_line_item_no,
  905. component_line_item_no,
  906. item_cost_distribution,
  907. component_part_no,
  908. dbo.get_part_name(site, component_part_no) as componentPartDesc,
  909. by_prod_part_no,
  910. dbo.get_part_name(site, by_prod_part_no) as byProdPartDesc
  911. FROM plm_recipe_manuf_struct_cost_distrib
  912. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  913. </select>
  914. <delete id="deletemanufStructCostDistribByProductPartNo" parameterType="RecipeComponentEntity">
  915. delete from plm_recipe_manuf_struct_cost_distrib
  916. 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}
  917. </delete>
  918. <delete id="deletemanufStructCostDistribByComponentPartNo" parameterType="RecipeComponentEntity">
  919. delete from plm_recipe_manuf_struct_cost_distrib
  920. 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}
  921. </delete>
  922. <!-- 编辑副产品成本分配 -->
  923. <update id="updateManufStructCostDistrib" parameterType="com.spring.modules.part.vo.RecipeManufStructCostDistribVo">
  924. update plm_recipe_manuf_struct_cost_distrib
  925. set item_cost_distribution = #{itemCostDistribution,jdbcType=FLOAT},
  926. update_date = getDate(),
  927. update_by = #{updateBy}
  928. 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}
  929. </update>
  930. <!-- 查recipe子明细 -->
  931. <select id="queryRecipeMultiLevelStructureList" parameterType="RecipeDetailEntity" resultType="RecipeMultiLevelStructureData">
  932. SELECT
  933. a.site,
  934. a.part_no,
  935. dbo.get_part_name(a.site, a.part_no) as partDesc,
  936. a.bom_type,
  937. a.eng_chg_level,
  938. a.alternative_no,
  939. b.alternative_description,
  940. a.component_part,
  941. dbo.get_part_name(a.site, a.component_part) as componentPartDesc,
  942. a.qty_per_assembly,
  943. a.print_unit,
  944. dbo.get_um_name(a.print_unit) as printUnitName,
  945. c.product_group_id4,
  946. dbo.get_product_group_name(c.site, c.product_group_id4, '4') as productGroupName4,
  947. c.min_order_qty,
  948. c.mul_order_qty,
  949. c.planning_method,
  950. c.cum_lead_time,
  951. c.unprotected_lead_time,
  952. dbo.get_cum_lead_time(a.site, a.component_part) as componentCumLeadTime,
  953. dbo.get_unprotected_lead_time(a.site, a.component_part) as componentUnprotectedLeadTime
  954. FROM plm_recipe_component as a
  955. LEFT JOIN plm_recipe_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
  956. LEFT JOIN part as c on a.site = c.site and a.part_no = c.part_no
  957. 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}
  958. </select>
  959. <!-- 新增Recipe子明细表内容 -->
  960. <insert id="saveRecipeComponents">
  961. insert into plm_recipe_component
  962. (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,
  963. issue_to_loc, operation_no, note_text, create_date, create_by, line_sequence, consumption_item, parts_by_weight, qty_uom, issue_planned_scrap_db, issue_overreported_qty_db,
  964. fixed_qty_flag, promise_planned, phantom_consume, oper_cost_distribution, gen_oh_cost_distribution, qty_kg, by_prod_as_supply_in_mrp_db, leadtime_offset, std_planned_item,
  965. charged_item, last_activity_date, exclude_from_calculations_db, exclude_from_as_built_db, lot_batch_origin_db, weight_share)
  966. VALUES
  967. <foreach collection="list" item="item" index="index" separator=",">
  968. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.componentPart}, #{item.lineItemNo}, #{item.printUnit}, #{item.qtyPerAssembly}, #{item.componentScrap}, #{item.shrinkageFactor}, #{item.issueType},
  969. #{item.issueToLoc}, #{item.operationNo}, #{item.noteText}, getDate(), #{item.createBy}, #{item.lineSequence}, #{item.consumptionItem}, #{item.partsByWeight}, #{item.qtyUom}, #{item.issuePlannedScrapDb}, #{item.issueOverreportedQtyDb},
  970. #{item.fixedQtyFlag}, #{item.promisePlanned}, #{item.phantomConsume}, #{item.operCostDistribution}, #{item.genOhCostDistribution}, #{item.qtyKg}, #{item.byProdAsSupplyInMrpDb}, #{item.leadtimeOffset}, #{item.stdPlannedItem},
  971. #{item.chargedItem}, getDate(), #{item.excludeFromCalculationsDb}, #{item.excludeFromAsBuiltDb}, #{item.lotBatchOriginDb}, #{item.weightShare})
  972. </foreach>
  973. </insert>
  974. <update id="updateRecipeHeaderOfficialFlag" parameterType="com.spring.modules.part.vo.RecipeDetailVo">
  975. update plm_recipe_header
  976. set official_flag = 'Y'
  977. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  978. </update>
  979. <update id="updateRecipeDetailOfficialFlag" parameterType="com.spring.modules.part.vo.RecipeDetailVo">
  980. update plm_recipe_detail
  981. set official_flag = 'Y'
  982. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  983. </update>
  984. <!-- 查recipe副产品成本分配 -->
  985. <select id="queryRecipeManufStructCostDistribToIfs" resultType="RecipeIfsManufStructCostDistrib">
  986. SELECT
  987. site as contract,
  988. part_no,
  989. bom_type,
  990. eng_chg_level,
  991. alternative_no,
  992. by_prod_line_item_no,
  993. component_line_item_no,
  994. item_cost_distribution,
  995. component_part_no,
  996. by_prod_part_no as byProductPartNo,
  997. FROM plm_recipe_manuf_struct_cost_distrib
  998. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  999. </select>
  1000. <delete id="deleteManufStructCostDistribByAlternative" parameterType="RecipeDetailEntity">
  1001. delete from plm_recipe_manuf_struct_cost_distrib
  1002. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  1003. </delete>
  1004. <select id="selectRecipeHeaderByPartNo" resultType="com.spring.modules.part.vo.RecipeHeaderVo">
  1005. SELECT
  1006. a.site,
  1007. a.part_no,
  1008. a.bom_type,
  1009. a.eng_chg_level,
  1010. a.note_text,
  1011. a.eff_phase_in_date,
  1012. a.eff_phase_out_date,
  1013. a.eng_revision,
  1014. a.type_flag,
  1015. a.net_weight,
  1016. a.official_flag
  1017. FROM plm_recipe_header as a
  1018. 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
  1019. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1020. </select>
  1021. <select id="selectRecipeDetailByPartNo" resultType="com.spring.modules.part.vo.RecipeDetailVo">
  1022. SELECT
  1023. a.site,
  1024. a.part_no,
  1025. a.bom_type,
  1026. a.eng_chg_level,
  1027. a.alternative_no,
  1028. a.alternative_description,
  1029. a.status,
  1030. a.min_lot_qty,
  1031. a.default_flag,
  1032. a.note_text as detailNoteText,
  1033. a.official_flag,
  1034. a.display_weight_uom,
  1035. a.display_volume_uom,
  1036. a.reg_unit
  1037. FROM plm_recipe_detail as a
  1038. 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
  1039. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1040. </select>
  1041. <!-- recipe明细查重 -->
  1042. <select id="selectRecipeComponentByPartNo" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  1043. SELECT
  1044. a.site,
  1045. a.part_no,
  1046. a.bom_type,
  1047. a.eng_chg_level,
  1048. a.alternative_no,
  1049. a.component_part,
  1050. a.print_unit,
  1051. a.qty_per_assembly,
  1052. a.component_scrap,
  1053. a.issue_type,
  1054. a.shrinkage_factor,
  1055. a.line_item_no,
  1056. a.operation_no,
  1057. a.issue_to_loc,
  1058. a.note_text,
  1059. a.line_sequence,
  1060. a.consumption_item,
  1061. a.parts_by_weight,
  1062. a.qty_uom,
  1063. a.issue_planned_scrap_db,
  1064. a.issue_overreported_qty_db,
  1065. a.fixed_qty_flag,
  1066. a.promise_planned,
  1067. a.phantom_consume,
  1068. a.oper_cost_distribution,
  1069. a.gen_oh_cost_distribution,
  1070. a.qty_kg,
  1071. a.by_prod_as_supply_in_mrp_db,
  1072. a.leadtime_offset,
  1073. a.std_planned_item,
  1074. a.charged_item,
  1075. a.last_activity_date,
  1076. a.exclude_from_calculations_db,
  1077. a.exclude_from_as_built_db,
  1078. a.lot_batch_origin_db,
  1079. a.weight_share
  1080. FROM plm_recipe_component as a
  1081. 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
  1082. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1083. </select>
  1084. <!-- 查recipe副产品成本分配 -->
  1085. <select id="selectRecipeManufStructCostDistribByPartNo" resultType="com.spring.modules.part.vo.RecipeManufStructCostDistribVo">
  1086. SELECT
  1087. a.site,
  1088. a.part_no,
  1089. a.bom_type,
  1090. a.eng_chg_level,
  1091. a.alternative_no,
  1092. a.by_prod_line_item_no,
  1093. a.component_line_item_no,
  1094. a.item_cost_distribution,
  1095. a.component_part_no,
  1096. a.by_prod_part_no
  1097. FROM plm_recipe_manuf_struct_cost_distrib as a
  1098. 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
  1099. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1100. </select>
  1101. <!-- 查recipe子明细 -->
  1102. <select id="queryRecipeComponentList" parameterType="RecipeComponentEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  1103. SELECT
  1104. site,
  1105. part_no,
  1106. bom_type,
  1107. eng_chg_level,
  1108. alternative_no,
  1109. component_part,
  1110. print_unit,
  1111. qty_per_assembly,
  1112. component_scrap,
  1113. issue_type,
  1114. shrinkage_factor,
  1115. line_item_no,
  1116. operation_no,
  1117. issue_to_loc,
  1118. note_text,
  1119. line_sequence,
  1120. consumption_item,
  1121. parts_by_weight,
  1122. qty_uom,
  1123. issue_planned_scrap_db,
  1124. issue_overreported_qty_db,
  1125. fixed_qty_flag,
  1126. promise_planned,
  1127. phantom_consume,
  1128. oper_cost_distribution,
  1129. gen_oh_cost_distribution,
  1130. qty_kg,
  1131. by_prod_as_supply_in_mrp_db,
  1132. leadtime_offset,
  1133. std_planned_item,
  1134. charged_item,
  1135. last_activity_date,
  1136. exclude_from_calculations_db,
  1137. exclude_from_as_built_db,
  1138. lot_batch_origin_db,
  1139. weight_share
  1140. FROM plm_recipe_component
  1141. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  1142. </select>
  1143. <select id="queryComponentPartRecipeList" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  1144. SELECT
  1145. a.site,
  1146. a.part_no,
  1147. a.bom_type,
  1148. a.eng_chg_level,
  1149. a.alternative_no,
  1150. b.alternative_description,
  1151. a.component_part,
  1152. d.part_desc as componentPartDesc,
  1153. a.qty_per_assembly,
  1154. a.print_unit,
  1155. dbo.get_um_name(a.print_unit) as printUnitName
  1156. FROM plm_recipe_component as a
  1157. LEFT JOIN plm_recipe_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
  1158. LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no
  1159. where a.site = #{site} and a.part_no = #{partNo}
  1160. </select>
  1161. <select id="recipeManagementSearchAny" resultType="com.spring.modules.part.vo.RecipeHeaderVo">
  1162. SELECT
  1163. a.site,
  1164. a.part_no,
  1165. b.part_desc,
  1166. a.eng_chg_level,
  1167. a.bom_type,
  1168. a.note_text,
  1169. a.eff_phase_in_date,
  1170. a.eff_phase_out_date,
  1171. a.eng_revision,
  1172. a.type_flag,
  1173. a.net_weight,
  1174. a.create_date,
  1175. a.create_by,
  1176. a.update_date,
  1177. a.update_by,
  1178. b.um_id as printUnit,
  1179. c.um_name as printUnitName,
  1180. a.official_flag,
  1181. b.ifs_part_no,
  1182. b.plm_part_no
  1183. FROM plm_recipe_header as a
  1184. left join part as b on a.site = b.site and a.part_no = b.part_no
  1185. left join um as c on b.um_id = c.um_id
  1186. <if test="query.whereClause != null and query.whereClause != ''">
  1187. WHERE ${query.whereClause}
  1188. </if>
  1189. <if test="query.orderClause != null and query.orderClause != ''">
  1190. ORDER BY ${query.orderClause}
  1191. </if>
  1192. <if test="query.orderClause == null or query.orderClause == ''">
  1193. order by a.part_no
  1194. </if>
  1195. </select>
  1196. </mapper>