O
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

454 lines
18 KiB

12 months ago
10 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
7 months ago
11 months ago
1 year ago
12 months ago
11 months ago
1 year ago
10 months ago
10 months ago
10 months ago
1 year ago
12 months ago
1 year ago
11 months ago
10 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xujie.sys.modules.part.mapper.QuicklyCreateBomMapper">
  4. <!-- 获取所有节点 -->
  5. <select id="getNodeTree" resultType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity" parameterType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity">
  6. SELECT
  7. a.site,
  8. b.sourceBu as buNo,
  9. a.template_no,
  10. a.node_id,
  11. a.node_name,
  12. a.main_part,
  13. a.part_no,
  14. b.part_desc,
  15. a.id,
  16. a.p_id,
  17. a.create_date,
  18. a.create_by,
  19. a.update_date,
  20. a.update_by,
  21. b.umid2 as printUnit,
  22. dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
  23. a.eng_chg_level,
  24. a.routing_revision
  25. FROM plm_quickly_bom_Info as a
  26. left join part as b on a.site = b.site and a.part_no = b.part_no
  27. <where>
  28. a.site = #{site} AND a.main_part = #{mainPart}
  29. <if test="nodeId != null and nodeId != ''">
  30. AND a.node_id = #{nodeId}
  31. </if>
  32. </where>
  33. </select>
  34. <!-- 获得id -->
  35. <select id="getSonId" parameterType="BomNodeEntity" resultType="java.lang.String">
  36. SELECT MAX(
  37. CAST(
  38. RIGHT(id, LEN(id) - CHARINDEX('-', id, LEN(#{pId}) + 1)) AS INT
  39. )
  40. ) AS maxSubId
  41. FROM plm_quickly_bom_Info
  42. WHERE site = #{site}
  43. AND id LIKE #{pId} + '-%'
  44. AND CHARINDEX('-', id, LEN(#{pId}) + 2) = 0
  45. </select>
  46. <!-- 新增节点 -->
  47. <insert id="saveNewNode" parameterType="BomNodeEntity">
  48. INSERT INTO plm_bom_node (site, node_id, node_name, part_no, id, p_id, create_date, create_by)
  49. VALUES (#{site}, #{nodeId}, #{nodeName}, #{partNo}, #{id}, #{pId}, getDate(), #{createBy})
  50. </insert>
  51. <update id="nodeEdit" parameterType="BomNodeEntity">
  52. UPDATE plm_quickly_bom_Info
  53. SET node_name = #{nodeName},
  54. update_date = getDate(),
  55. update_by = #{updateBy}
  56. WHERE site = #{site} and main_part = #{mainPart} and node_id = #{nodeId}
  57. </update>
  58. <!-- 删除该节点以及其子节点-->
  59. <delete id="nodeDelete" parameterType="BomNodeEntity">
  60. DELETE FROM plm_quickly_bom_Info
  61. WHERE site = #{site} and main_part = #{mainPart}
  62. <if test="id != null and id != ''">
  63. and (id like #{id} + '-%' or id = #{id})
  64. </if>
  65. </delete>
  66. <select id="getBomInformationByPartNo" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo" parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo">
  67. SELECT top 1
  68. a.site,
  69. a.bu_no,
  70. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  71. a.part_no,
  72. b.part_desc,
  73. a.eng_chg_level,
  74. a.bom_type,
  75. a.note_text,
  76. a.eff_phase_in_date,
  77. a.eff_phase_out_date,
  78. a.eng_revision,
  79. a.type_flag,
  80. a.net_weight,
  81. a.create_date,
  82. a.create_by,
  83. a.update_date,
  84. a.update_by,
  85. b.umid2 as printUnit,
  86. dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
  87. isnull(dbo.get_yield_rate(a.site, a.bu_no, b.product_group_id2, '2'), 100) as yieldRate,
  88. a.process_unit,
  89. c.UMName as processUnitName
  90. FROM plm_bom_header as a
  91. left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
  92. left join plm_bom_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.eng_chg_level = d.eng_chg_level and a.bom_type = d.bom_type
  93. left join UM as c on a.site = c.site and a.process_unit = c.UMID
  94. <where>
  95. a.site = #{site}
  96. <if test="buNo != null and buNo != ''">
  97. and a.bu_no = #{buNo}
  98. </if>
  99. <if test="partNo != null and partNo != ''">
  100. and a.part_no = #{partNo}
  101. </if>
  102. <if test="bomType != null and bomType != ''">
  103. and a.bom_type = #{bomType}
  104. </if>
  105. </where>
  106. order by a.eng_chg_level desc
  107. </select>
  108. <update id="updateBomNodePart">
  109. UPDATE plm_quickly_bom_Info
  110. SET part_no = #{partNo}
  111. WHERE site = #{site} and main_part = #{mainPart} and node_id = #{nodeId}
  112. </update>
  113. <select id="getRoutingInformationByPartNo" resultType="com.xujie.sys.modules.part.vo.RoutingHeaderVo" parameterType="com.xujie.sys.modules.part.vo.RoutingHeaderVo">
  114. SELECT top 1
  115. a.site,
  116. a.bu_no,
  117. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  118. a.part_no,
  119. b.part_desc,
  120. a.routing_revision,
  121. a.routing_type,
  122. a.note_text,
  123. a.phase_in_date,
  124. a.phase_out_date,
  125. a.create_date,
  126. a.create_by,
  127. a.update_date,
  128. a.update_by,
  129. b.umid2 as printUnit,
  130. dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
  131. b.code_no
  132. FROM plm_routing_header as a
  133. left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
  134. left join plm_routing_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.routing_revision = d.routing_revision and a.routing_type = d.routing_type
  135. <where>
  136. a.site = #{site}
  137. <if test="buNo != null and buNo != ''">
  138. and a.bu_no = #{buNo}
  139. </if>
  140. <if test="partNo != null and partNo != ''">
  141. and a.part_no = #{partNo}
  142. </if>
  143. <if test="routingType != null and routingType != ''">
  144. and a.routing_type = #{routingType}
  145. </if>
  146. </where>
  147. order by a.routing_revision desc
  148. </select>
  149. <update id="resetNodePartInfo" >
  150. UPDATE plm_bom_node
  151. SET part_no = ''
  152. WHERE Site = #{site}
  153. </update>
  154. <select id="getBomTemplateDetail" resultType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity">
  155. SELECT
  156. pbtd.site,
  157. pbtd.template_no,
  158. pbtd.node_id,
  159. pbn.node_name,
  160. pbtd.id,
  161. pbtd.p_id,
  162. #{partNo} as mainPart,
  163. #{createBy} as createBy
  164. FROM plm_bom_template_detail as pbtd left join plm_bom_node as pbn on pbtd.site = pbn.site and pbtd.node_id = pbn.node_id
  165. where pbtd.site = #{site} and pbtd.template_no = #{templateNo}
  166. </select>
  167. <insert id="saveQuicklyBomInfo">
  168. insert into plm_quickly_bom_Info
  169. (site, template_no, node_id, main_part, part_no, id, p_id, create_date, create_by, node_name, eng_chg_level, routing_revision)
  170. VALUES
  171. <foreach collection="list" item="item" index="index" separator=",">
  172. (#{item.site}, #{item.templateNo}, #{item.nodeId}, #{item.mainPart},
  173. <choose>
  174. <when test='item.pId.toString() == "0"'>
  175. #{item.mainPart}
  176. </when>
  177. <otherwise>
  178. #{item.partNo}
  179. </otherwise>
  180. </choose>
  181. , #{item.id}, #{item.pId}, getDate(), #{item.createBy}, #{item.nodeName}, 1, 1)
  182. </foreach>
  183. </insert>
  184. <insert id="saveTemplateHeader" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
  185. insert into plm_template_header
  186. (site, bu_no, template_no, template_name) VALUES (#{site}, #{buNo}, #{templateNo}, #{templateName})
  187. </insert>
  188. <insert id="saveTemplateDetail" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
  189. insert into plm_template_detail
  190. (site, bu_no, template_no, um_id, family_id, product_group_id1, product_group_id2, product_group_id3, code_no, bom_template_no)
  191. VALUES (#{site}, #{buNo}, #{templateNo}, #{umId}, #{familyId}, #{productGroupId1}, #{productGroupId2}, #{productGroupId3}, #{codeNo}, #{bomTemplateNo})
  192. </insert>
  193. <update id="updateTemplateHeader" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
  194. UPDATE plm_template_header
  195. SET template_name = #{templateName}
  196. WHERE site = #{site} AND bu_no = #{buNo} AND template_no = #{templateNo}
  197. </update>
  198. <delete id="deleteTemplateDetail" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
  199. DELETE FROM plm_template_detail
  200. WHERE site = #{site} AND bu_no = #{buNo} AND template_no = #{templateNo}
  201. </delete>
  202. <delete id="deleteQuicklyBomInfo">
  203. DELETE FROM plm_quickly_bom_Info
  204. WHERE site = #{site} and main_part = #{partNo}
  205. </delete>
  206. <delete id="deletePartSubPropertiesValue"
  207. parameterType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
  208. delete from part_sub_properties_value
  209. WHERE site = #{site} and part_no = #{partNo} and bu_no = #{buNo} and record_type = #{recordType}
  210. </delete>
  211. <select id="getPartInfoByNo" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
  212. SELECT
  213. a.id,
  214. a.site,
  215. a.sourceBu as buNo,
  216. a.part_no,
  217. a.part_desc,
  218. a.umid2 as umId2,
  219. um.UMName as umName,
  220. a.spec,
  221. a.active,
  222. a.remark,
  223. a.part_type2,
  224. a.product_group_id1,
  225. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id1, '1') as productGroupName1,
  226. a.product_group_id2,
  227. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id2, '2') as productGroupName2,
  228. a.product_group_id3,
  229. dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id3, '3') as productGroupName3,
  230. a.FamilyID as familyID,
  231. pf.family_name as familyName,
  232. a.part_desce_en,
  233. a.code_no,
  234. dbo.get_code_desc(a.site, a.sourceBu, a.code_no, 'IP') as codeDesc,
  235. a.template_no,
  236. pbt.template_name
  237. FROM part as a
  238. LEFT JOIN UM as um on a.site = um.site and a.umid2 = um.UMID
  239. LEFT JOIN part_family as pf on a.site = pf.site and a.sourceBu = pf.bu_no and a.FamilyID = pf.family_id
  240. LEFT JOIN plm_bom_template as pbt on a.site = pbt.site and a.template_no = pbt.template_no
  241. where a.site = #{site} and a.part_no = #{partNo}
  242. </select>
  243. <select id="findNode" resultType="com.xujie.sys.modules.part.entity.BomNodeEntity"
  244. parameterType="com.xujie.sys.modules.part.entity.BomNodeEntity">
  245. select site,
  246. node_id,
  247. node_name,
  248. part_no,
  249. id,
  250. p_id
  251. from plm_bom_node
  252. where site = #{site} and node_id = #{nodeId} and id = #{id}
  253. </select>
  254. <select id="deletePartSubPropertiesValueHeader">
  255. delete from part_sub_properties_value_header
  256. where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and code_no = #{codeNo} and record_type = #{recordType} and sub_code_seq_no = 1
  257. </select>
  258. <select id="getTemplateList" resultType="com.xujie.sys.modules.part.vo.TemplateVo"
  259. parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
  260. select template_no,
  261. template_name
  262. from plm_template_header
  263. where site = #{site} and bu_no = #{buNo}
  264. </select>
  265. <select id="chooseTemplate" resultType="com.xujie.sys.modules.part.vo.TemplateVo"
  266. parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
  267. select ptd.*,
  268. um.UmName as umName,
  269. pf.family_name as familyName,
  270. dbo.get_product_group_name(ptd.site, ptd.bu_no, ptd.product_group_id1, '1') as productGroupName1,
  271. dbo.get_product_group_name(ptd.site, ptd.bu_no, ptd.product_group_id2, '2') as productGroupName2,
  272. dbo.get_product_group_name(ptd.site, ptd.bu_no, ptd.product_group_id3, '3') as productGroupName3,
  273. dbo.get_code_desc(ptd.site, ptd.bu_no, ptd.code_no, 'IP') as codeDesc,
  274. pbt.template_name as bomTemplateName
  275. from plm_template_detail as ptd
  276. left join UM as um on ptd.site = um.site and ptd.um_id = um.UMID
  277. left join part_family as pf on ptd.site = pf.site and ptd.bu_no = pf.bu_no and ptd.family_id = pf.family_id
  278. left join plm_bom_template as pbt on ptd.site = pbt.site and ptd.bom_template_no = pbt.template_no
  279. where ptd.site = #{site} and ptd.bu_no = #{buNo} and ptd.template_no = #{tempNo}
  280. </select>
  281. <select id="getBomInformationListByPartNo" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo"
  282. parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo">
  283. SELECT
  284. a.site,
  285. a.bu_no,
  286. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  287. a.part_no,
  288. b.part_desc,
  289. a.eng_chg_level,
  290. a.bom_type,
  291. a.note_text,
  292. a.eff_phase_in_date,
  293. a.eff_phase_out_date,
  294. a.eng_revision,
  295. a.type_flag,
  296. a.net_weight,
  297. a.create_date,
  298. a.create_by,
  299. a.update_date,
  300. a.update_by,
  301. b.umid2 as printUnit,
  302. dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
  303. isnull(dbo.get_yield_rate(a.site, a.bu_no, b.product_group_id2, '2'), 100) as yieldRate,
  304. a.process_unit,
  305. c.UMName as processUnitName
  306. FROM plm_bom_header as a
  307. left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
  308. left join plm_bom_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.eng_chg_level = d.eng_chg_level and a.bom_type = d.bom_type
  309. left join UM as c on a.site = c.site and a.process_unit = c.UMID
  310. <where>
  311. a.site = #{site}
  312. <if test="buNo != null and buNo != ''">
  313. and a.bu_no = #{buNo}
  314. </if>
  315. <if test="partNo != null and partNo != ''">
  316. and a.part_no = #{partNo}
  317. </if>
  318. <if test="bomType != null and bomType != ''">
  319. and a.bom_type = #{bomType}
  320. </if>
  321. </where>
  322. order by a.eng_chg_level
  323. </select>
  324. <select id="getRoutingInformationListByPartNo" resultType="com.xujie.sys.modules.part.vo.RoutingHeaderVo"
  325. parameterType="com.xujie.sys.modules.part.vo.RoutingHeaderVo">
  326. SELECT
  327. a.site,
  328. a.bu_no,
  329. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  330. a.part_no,
  331. b.part_desc,
  332. a.routing_revision,
  333. a.routing_type,
  334. a.note_text,
  335. a.phase_in_date,
  336. a.phase_out_date,
  337. a.create_date,
  338. a.create_by,
  339. a.update_date,
  340. a.update_by,
  341. b.umid2 as printUnit,
  342. dbo.qc_get_um_name(a.site, b.umid2) as printUnitName
  343. FROM plm_routing_header as a
  344. left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
  345. left join plm_routing_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.routing_revision = d.routing_revision and a.routing_type = d.routing_type
  346. <where>
  347. a.site = #{site}
  348. <if test="buNo != null and buNo != ''">
  349. and a.bu_no = #{buNo}
  350. </if>
  351. <if test="partNo != null and partNo != ''">
  352. and a.part_no = #{partNo}
  353. </if>
  354. <if test="routingType != null and routingType != ''">
  355. and a.routing_type = #{routingType}
  356. </if>
  357. </where>
  358. order by a.routing_revision
  359. </select>
  360. <select id="getEngChgLevelList" resultType="java.lang.Integer">
  361. SELECT
  362. a.eng_chg_level
  363. FROM plm_bom_header as a
  364. left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
  365. left join plm_bom_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.eng_chg_level = d.eng_chg_level and a.bom_type = d.bom_type
  366. left join UM as c on a.site = c.site and a.process_unit = c.UMID
  367. <where>
  368. a.site = #{site}
  369. <if test="buNo != null and buNo != ''">
  370. and a.bu_no = #{buNo}
  371. </if>
  372. <if test="partNo != null and partNo != ''">
  373. and a.part_no = #{partNo}
  374. </if>
  375. <if test="bomType != null and bomType != ''">
  376. and a.bom_type = #{bomType}
  377. </if>
  378. </where>
  379. order by a.eng_chg_level
  380. </select>
  381. <select id="getRoutingRevisionList" resultType="java.lang.Integer">
  382. SELECT
  383. a.routing_revision
  384. FROM plm_routing_header as a
  385. left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
  386. left join plm_routing_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.routing_revision = d.routing_revision and a.routing_type = d.routing_type
  387. <where>
  388. a.site = #{site}
  389. <if test="buNo != null and buNo != ''">
  390. and a.bu_no = #{buNo}
  391. </if>
  392. <if test="partNo != null and partNo != ''">
  393. and a.part_no = #{partNo}
  394. </if>
  395. <if test="routingType != null and routingType != ''">
  396. and a.routing_type = #{routingType}
  397. </if>
  398. </where>
  399. order by a.routing_revision desc
  400. </select>
  401. <update id="updateBomInfoId" parameterType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity">
  402. UPDATE plm_quickly_bom_info
  403. SET
  404. id = REPLACE(id, #{data.pId}, #{data.id}),
  405. p_id = REPLACE(p_id, #{data.pId}, #{data.id})
  406. WHERE site = #{data.site}
  407. AND main_part = #{data.mainPart}
  408. AND id LIKE #{data.id} + '%'
  409. AND (
  410. LEN(id) = LEN(#{data.id})
  411. OR
  412. (LEN(id) > LEN(#{data.id}) AND SUBSTRING(id, LEN(#{data.id}) + 1, 1) = '-')
  413. )
  414. </update>
  415. <update id="updatePartNoOfNode" parameterType="com.xujie.sys.modules.part.entity.PartNodeVo">
  416. update plm_quickly_bom_info
  417. set part_no = #{partNo}
  418. where site = #{site}
  419. and node_id = #{nodeId}
  420. and main_part = #{mainPart}
  421. </update>
  422. <update id="setRevision" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo">
  423. update plm_quickly_bom_info
  424. set eng_chg_level = #{engChgLevel},
  425. routing_revision = #{routingRevision}
  426. where site = #{site}
  427. and part_no = #{partNo}
  428. and main_part = #{mainPart}
  429. </update>
  430. </mapper>