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.

1242 lines
51 KiB

2 years ago
6 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
8 months ago
8 months ago
8 months ago
6 months ago
8 months ago
8 months ago
8 months ago
6 months ago
8 months ago
2 years ago
8 months ago
8 months ago
8 months ago
2 years ago
2 years ago
6 months ago
2 years ago
2 years ago
6 months ago
2 years ago
6 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
6 months ago
2 years ago
1 year ago
2 years ago
6 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
7 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. <!-- 判断 Recipe 是否存在子料 -->
  656. <select id="queryComponentPart" parameterType="RecipeHeaderEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  657. SELECT
  658. site,
  659. part_no,
  660. eng_chg_level,
  661. bom_type,
  662. alternative_no,
  663. component_part
  664. FROM plm_recipe_component
  665. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  666. </select>
  667. <!-- 判断 Recipe 是否存在子料 -->
  668. <select id="queryComponentPart2" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  669. SELECT
  670. site,
  671. part_no,
  672. eng_chg_level,
  673. bom_type,
  674. alternative_no,
  675. component_part
  676. FROM plm_recipe_component
  677. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  678. </select>
  679. <!-- 获取ifs header 对象-->
  680. <select id="getRecipeHeader" parameterType="RecipeDetailEntity" resultType="RecipeIfsHeader">
  681. SELECT
  682. site as contract,
  683. part_no,
  684. eng_chg_level,
  685. bom_type,
  686. eff_phase_in_date,
  687. eff_phase_out_date,
  688. note_text,
  689. create_date,
  690. 'add' as histType
  691. FROM plm_recipe_header
  692. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  693. </select>
  694. <!-- 获取ifs component 对象-->
  695. <select id="getRecipeComponent" parameterType="RecipeDetailEntity" resultType="RecipeIfsItem">
  696. SELECT
  697. site as contract,
  698. part_no,
  699. eng_chg_level,
  700. bom_type,
  701. alternative_no,
  702. line_item_no,
  703. line_sequence,
  704. component_part,
  705. qty_per_assembly,
  706. issue_type,
  707. component_scrap,
  708. shrinkage_factor,
  709. note_text,
  710. consumption_item,
  711. operation_no,
  712. parts_by_weight,
  713. qty_uom,
  714. issue_planned_scrap_db,
  715. issue_overreported_qty_db,
  716. fixed_qty_flag,
  717. promise_planned,
  718. phantom_consume,
  719. oper_cost_distribution,
  720. gen_oh_cost_distribution,
  721. qty_kg,
  722. by_prod_as_supply_in_mrp_db,
  723. leadtime_offset,
  724. std_planned_item,
  725. charged_item,
  726. last_activity_date,
  727. exclude_from_calculations_db,
  728. exclude_from_as_built_db,
  729. lot_batch_origin_db,
  730. weight_share
  731. FROM plm_recipe_component
  732. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  733. </select>
  734. <!-- 获取recipe header 对象-->
  735. <select id="queryRecipeHeader" parameterType="RecipeHeaderEntity" resultType="RecipeHeaderEntity">
  736. SELECT
  737. site,
  738. part_no,
  739. eng_chg_level,
  740. bom_type,
  741. note_text,
  742. eff_phase_in_date,
  743. eff_phase_out_date,
  744. eng_revision,
  745. row_version,
  746. row_key,
  747. type_flag,
  748. net_weight
  749. FROM plm_recipe_header
  750. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  751. </select>
  752. <!-- recipe主表编辑 -->
  753. <update id="updateInDate" parameterType="RecipeHeaderEntity">
  754. update plm_recipe_header
  755. set eff_phase_out_date = #{effPhaseOutDate},
  756. update_date = getDate(),
  757. update_by = #{createBy}
  758. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  759. </update>
  760. <!-- 校验物料版本是否存在-->
  761. <select id="queryPartRevision" parameterType="RecipeHeaderEntity" resultType="PartRevisionEntity">
  762. SELECT
  763. site,
  764. part_no,
  765. eng_chg_level,
  766. eff_phase_in_date,
  767. eff_phase_out_date,
  768. revision_text,
  769. product_status,
  770. repair_status,
  771. eng_revision,
  772. create_date,
  773. create_by,
  774. update_date,
  775. update_by
  776. FROM part_revision
  777. WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  778. </select>
  779. <!-- 新增物料版本 -->
  780. <insert id="savePartRevision" parameterType="RecipeHeaderEntity">
  781. 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)
  782. values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{noteText}, 'Not In Effect', 'Not In Effect', #{engRevision}, getDate(), #{createBy})
  783. </insert>
  784. <select id="queryRecipeDetailOfficialFlag" parameterType="RecipeComponentEntity" resultType="RecipeDetailEntity">
  785. SELECT
  786. site,
  787. part_no,
  788. bom_type,
  789. eng_chg_level,
  790. alternative_no,
  791. alternative_description,
  792. min_lot_qty,
  793. default_flag,
  794. note_text as detailNoteText,
  795. status,
  796. official_flag,
  797. display_weight_uom,
  798. display_volume_uom,
  799. reg_unit
  800. FROM plm_recipe_detail
  801. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  802. </select>
  803. <!-- 获取 component 对象-->
  804. <select id="queryComponentPartFlag" parameterType="RecipeDetailEntity" resultType="PartInformationEntity">
  805. SELECT
  806. a.site,
  807. a.part_no,
  808. b.status
  809. FROM plm_recipe_component as a
  810. LEFT JOIN part as b on a.site = b.site and a.component_part = b.part_no
  811. 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}
  812. </select>
  813. <select id="queryRecipeDetailEntityList" resultType="com.spring.modules.part.entity.RecipeDetailEntity">
  814. SELECT
  815. site,
  816. part_no,
  817. bom_type,
  818. eng_chg_level,
  819. alternative_no,
  820. alternative_description,
  821. status,
  822. min_lot_qty,
  823. default_flag,
  824. note_text as detailNoteText,
  825. official_flag,
  826. display_weight_uom,
  827. display_volume_uom,
  828. reg_unit
  829. FROM plm_recipe_detail
  830. where site = #{site} and part_no = #{partNo}
  831. order by eng_chg_level desc
  832. </select>
  833. <!-- 查询库位 -->
  834. <select id="selectLocation" parameterType="RecipeComponentEntity" resultType="LocationInformationEntity">
  835. SELECT
  836. site,
  837. location_id,
  838. location_name
  839. FROM view_location
  840. <where>
  841. site = #{site} AND location_id = #{issueToLoc}
  842. </where>
  843. </select>
  844. <!-- 查询part revision -->
  845. <select id="selectPartRevision" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.PartRevisionVo">
  846. SELECT
  847. site,
  848. part_no,
  849. eng_chg_level,
  850. eff_phase_in_date,
  851. eff_phase_out_date,
  852. revision_text,
  853. product_status,
  854. repair_status,
  855. eng_revision
  856. FROM part_revision
  857. where site = #{site} AND part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  858. </select>
  859. <!-- 修改revision状态 -->
  860. <update id="updatePartRevisionProductStatus" parameterType="com.spring.modules.part.vo.PartRevisionVo">
  861. update part_revision
  862. set product_status = #{productStatus},
  863. <if test = "bomType == 'Repair'">
  864. repair_status = 'In Effect',
  865. </if>
  866. update_date = getDate(),
  867. update_by = #{updateBy}
  868. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
  869. </update>
  870. <!-- 新增副产品成本分配数据 -->
  871. <insert id="saveRecipeManufStructCostDistrib">
  872. insert into plm_recipe_manuf_struct_cost_distrib
  873. (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
  874. <foreach collection="list" item="item" index="index" separator=",">
  875. (#{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})
  876. </foreach>
  877. </insert>
  878. <!-- 查recipe副产品成本分配 -->
  879. <select id="queryRecipeManufStructCostDistrib" parameterType="RecipeDetailEntity" resultType="com.spring.modules.part.vo.RecipeManufStructCostDistribVo">
  880. SELECT
  881. site,
  882. part_no,
  883. bom_type,
  884. eng_chg_level,
  885. alternative_no,
  886. by_prod_line_item_no,
  887. component_line_item_no,
  888. item_cost_distribution,
  889. component_part_no,
  890. dbo.get_part_name(site, component_part_no) as componentPartDesc,
  891. by_prod_part_no,
  892. dbo.get_part_name(site, by_prod_part_no) as byProdPartDesc
  893. FROM plm_recipe_manuf_struct_cost_distrib
  894. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  895. </select>
  896. <delete id="deletemanufStructCostDistribByProductPartNo" parameterType="RecipeComponentEntity">
  897. delete from plm_recipe_manuf_struct_cost_distrib
  898. 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}
  899. </delete>
  900. <delete id="deletemanufStructCostDistribByComponentPartNo" parameterType="RecipeComponentEntity">
  901. delete from plm_recipe_manuf_struct_cost_distrib
  902. 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}
  903. </delete>
  904. <!-- 编辑副产品成本分配 -->
  905. <update id="updateManufStructCostDistrib" parameterType="com.spring.modules.part.vo.RecipeManufStructCostDistribVo">
  906. update plm_recipe_manuf_struct_cost_distrib
  907. set item_cost_distribution = #{itemCostDistribution,jdbcType=FLOAT},
  908. update_date = getDate(),
  909. update_by = #{updateBy}
  910. 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}
  911. </update>
  912. <!-- 查recipe子明细 -->
  913. <select id="queryRecipeMultiLevelStructureList" parameterType="RecipeDetailEntity" resultType="RecipeMultiLevelStructureData">
  914. SELECT
  915. a.site,
  916. a.part_no,
  917. dbo.get_part_name(a.site, a.part_no) as partDesc,
  918. a.bom_type,
  919. a.eng_chg_level,
  920. a.alternative_no,
  921. b.alternative_description,
  922. a.component_part,
  923. dbo.get_part_name(a.site, a.component_part) as componentPartDesc,
  924. a.qty_per_assembly,
  925. a.print_unit,
  926. dbo.get_um_name(a.print_unit) as printUnitName,
  927. c.product_group_id4,
  928. dbo.get_product_group_name(c.site, c.product_group_id4, '4') as productGroupName4,
  929. c.min_order_qty,
  930. c.mul_order_qty,
  931. c.planning_method,
  932. c.cum_lead_time,
  933. c.unprotected_lead_time,
  934. dbo.get_cum_lead_time(a.site, a.component_part) as componentCumLeadTime,
  935. dbo.get_unprotected_lead_time(a.site, a.component_part) as componentUnprotectedLeadTime
  936. FROM plm_recipe_component as a
  937. 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
  938. LEFT JOIN part as c on a.site = c.site and a.part_no = c.part_no
  939. 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}
  940. </select>
  941. <!-- 新增Recipe子明细表内容 -->
  942. <insert id="saveRecipeComponents">
  943. insert into plm_recipe_component
  944. (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,
  945. 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,
  946. 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,
  947. charged_item, last_activity_date, exclude_from_calculations_db, exclude_from_as_built_db, lot_batch_origin_db, weight_share)
  948. VALUES
  949. <foreach collection="list" item="item" index="index" separator=",">
  950. (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.componentPart}, #{item.lineItemNo}, #{item.printUnit}, #{item.qtyPerAssembly}, #{item.componentScrap}, #{item.shrinkageFactor}, #{item.issueType},
  951. #{item.issueToLoc}, #{item.operationNo}, #{item.noteText}, getDate(), #{item.createBy}, #{item.lineSequence}, #{item.consumptionItem}, #{item.partsByWeight}, #{item.qtyUom}, #{item.issuePlannedScrapDb}, #{item.issueOverreportedQtyDb},
  952. #{item.fixedQtyFlag}, #{item.promisePlanned}, #{item.phantomConsume}, #{item.operCostDistribution}, #{item.genOhCostDistribution}, #{item.qtyKg}, #{item.byProdAsSupplyInMrpDb}, #{item.leadtimeOffset}, #{item.stdPlannedItem},
  953. #{item.chargedItem}, getDate(), #{item.excludeFromCalculationsDb}, #{item.excludeFromAsBuiltDb}, #{item.lotBatchOriginDb}, #{item.weightShare})
  954. </foreach>
  955. </insert>
  956. <update id="updateRecipeHeaderOfficialFlag" parameterType="com.spring.modules.part.vo.RecipeDetailVo">
  957. update plm_recipe_header
  958. set official_flag = 'Y'
  959. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
  960. </update>
  961. <update id="updateRecipeDetailOfficialFlag" parameterType="com.spring.modules.part.vo.RecipeDetailVo">
  962. update plm_recipe_detail
  963. set official_flag = 'Y'
  964. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  965. </update>
  966. <!-- 查recipe副产品成本分配 -->
  967. <select id="queryRecipeManufStructCostDistribToIfs" resultType="RecipeIfsManufStructCostDistrib">
  968. SELECT
  969. site as contract,
  970. part_no,
  971. bom_type,
  972. eng_chg_level,
  973. alternative_no,
  974. by_prod_line_item_no,
  975. component_line_item_no,
  976. item_cost_distribution,
  977. component_part_no,
  978. by_prod_part_no as byProductPartNo,
  979. FROM plm_recipe_manuf_struct_cost_distrib
  980. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  981. </select>
  982. <delete id="deleteManufStructCostDistribByAlternative" parameterType="RecipeDetailEntity">
  983. delete from plm_recipe_manuf_struct_cost_distrib
  984. where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
  985. </delete>
  986. <select id="selectRecipeHeaderByPartNo" resultType="com.spring.modules.part.vo.RecipeHeaderVo">
  987. SELECT
  988. a.site,
  989. a.part_no,
  990. a.bom_type,
  991. a.eng_chg_level,
  992. a.note_text,
  993. a.eff_phase_in_date,
  994. a.eff_phase_out_date,
  995. a.eng_revision,
  996. a.type_flag,
  997. a.net_weight,
  998. a.official_flag
  999. FROM plm_recipe_header as a
  1000. 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
  1001. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1002. </select>
  1003. <select id="selectRecipeDetailByPartNo" resultType="com.spring.modules.part.vo.RecipeDetailVo">
  1004. SELECT
  1005. a.site,
  1006. a.part_no,
  1007. a.bom_type,
  1008. a.eng_chg_level,
  1009. a.alternative_no,
  1010. a.alternative_description,
  1011. a.status,
  1012. a.min_lot_qty,
  1013. a.default_flag,
  1014. a.note_text as detailNoteText,
  1015. a.official_flag,
  1016. a.display_weight_uom,
  1017. a.display_volume_uom,
  1018. a.reg_unit
  1019. FROM plm_recipe_detail as a
  1020. 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
  1021. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1022. </select>
  1023. <!-- recipe明细查重 -->
  1024. <select id="selectRecipeComponentByPartNo" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  1025. SELECT
  1026. a.site,
  1027. a.part_no,
  1028. a.bom_type,
  1029. a.eng_chg_level,
  1030. a.alternative_no,
  1031. a.component_part,
  1032. a.print_unit,
  1033. a.qty_per_assembly,
  1034. a.component_scrap,
  1035. a.issue_type,
  1036. a.shrinkage_factor,
  1037. a.line_item_no,
  1038. a.operation_no,
  1039. a.issue_to_loc,
  1040. a.note_text,
  1041. a.line_sequence,
  1042. a.consumption_item,
  1043. a.parts_by_weight,
  1044. a.qty_uom,
  1045. a.issue_planned_scrap_db,
  1046. a.issue_overreported_qty_db,
  1047. a.fixed_qty_flag,
  1048. a.promise_planned,
  1049. a.phantom_consume,
  1050. a.oper_cost_distribution,
  1051. a.gen_oh_cost_distribution,
  1052. a.qty_kg,
  1053. a.by_prod_as_supply_in_mrp_db,
  1054. a.leadtime_offset,
  1055. a.std_planned_item,
  1056. a.charged_item,
  1057. a.last_activity_date,
  1058. a.exclude_from_calculations_db,
  1059. a.exclude_from_as_built_db,
  1060. a.lot_batch_origin_db,
  1061. a.weight_share
  1062. FROM plm_recipe_component as a
  1063. 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
  1064. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1065. </select>
  1066. <!-- 查recipe副产品成本分配 -->
  1067. <select id="selectRecipeManufStructCostDistribByPartNo" resultType="com.spring.modules.part.vo.RecipeManufStructCostDistribVo">
  1068. SELECT
  1069. a.site,
  1070. a.part_no,
  1071. a.bom_type,
  1072. a.eng_chg_level,
  1073. a.alternative_no,
  1074. a.by_prod_line_item_no,
  1075. a.component_line_item_no,
  1076. a.item_cost_distribution,
  1077. a.component_part_no,
  1078. a.by_prod_part_no
  1079. FROM plm_recipe_manuf_struct_cost_distrib as a
  1080. 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
  1081. where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null
  1082. </select>
  1083. <!-- 查recipe子明细 -->
  1084. <select id="queryRecipeComponentList" parameterType="RecipeComponentEntity" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  1085. SELECT
  1086. site,
  1087. part_no,
  1088. bom_type,
  1089. eng_chg_level,
  1090. alternative_no,
  1091. component_part,
  1092. print_unit,
  1093. qty_per_assembly,
  1094. component_scrap,
  1095. issue_type,
  1096. shrinkage_factor,
  1097. line_item_no,
  1098. operation_no,
  1099. issue_to_loc,
  1100. note_text,
  1101. line_sequence,
  1102. consumption_item,
  1103. parts_by_weight,
  1104. qty_uom,
  1105. issue_planned_scrap_db,
  1106. issue_overreported_qty_db,
  1107. fixed_qty_flag,
  1108. promise_planned,
  1109. phantom_consume,
  1110. oper_cost_distribution,
  1111. gen_oh_cost_distribution,
  1112. qty_kg,
  1113. by_prod_as_supply_in_mrp_db,
  1114. leadtime_offset,
  1115. std_planned_item,
  1116. charged_item,
  1117. last_activity_date,
  1118. exclude_from_calculations_db,
  1119. exclude_from_as_built_db,
  1120. lot_batch_origin_db,
  1121. weight_share
  1122. FROM plm_recipe_component
  1123. where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo}
  1124. </select>
  1125. <select id="queryComponentPartRecipeList" resultType="com.spring.modules.part.vo.RecipeComponentVo">
  1126. SELECT
  1127. a.site,
  1128. a.part_no,
  1129. a.bom_type,
  1130. a.eng_chg_level,
  1131. a.alternative_no,
  1132. b.alternative_description,
  1133. a.component_part,
  1134. d.part_desc as componentPartDesc,
  1135. a.qty_per_assembly,
  1136. a.print_unit,
  1137. dbo.get_um_name(a.print_unit) as printUnitName
  1138. FROM plm_recipe_component as a
  1139. 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
  1140. LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no
  1141. where a.site = #{site} and a.part_no = #{partNo}
  1142. </select>
  1143. <select id="recipeManagementSearchAny" resultType="com.spring.modules.part.vo.RecipeHeaderVo">
  1144. SELECT
  1145. a.site,
  1146. a.part_no,
  1147. b.part_desc,
  1148. a.eng_chg_level,
  1149. a.bom_type,
  1150. a.note_text,
  1151. a.eff_phase_in_date,
  1152. a.eff_phase_out_date,
  1153. a.eng_revision,
  1154. a.type_flag,
  1155. a.net_weight,
  1156. a.create_date,
  1157. a.create_by,
  1158. a.update_date,
  1159. a.update_by,
  1160. b.um_id as printUnit,
  1161. c.um_name as printUnitName,
  1162. a.official_flag,
  1163. b.ifs_part_no,
  1164. b.plm_part_no
  1165. FROM plm_recipe_header as a
  1166. left join part as b on a.site = b.site and a.part_no = b.part_no
  1167. left join um as c on b.um_id = c.um_id
  1168. <if test="query.whereClause != null and query.whereClause != ''">
  1169. WHERE ${query.whereClause}
  1170. </if>
  1171. <if test="query.orderClause != null and query.orderClause != ''">
  1172. ORDER BY ${query.orderClause}
  1173. </if>
  1174. <if test="query.orderClause == null or query.orderClause == ''">
  1175. order by a.part_no
  1176. </if>
  1177. </select>
  1178. </mapper>