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.

1581 lines
63 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
8 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
8 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
8 months ago
11 months ago
12 months ago
8 months ago
11 months ago
11 months ago
11 months ago
8 months ago
8 months ago
8 months ago
1 year ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months 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.change.mapper.ChangeManagementMapper">
  4. <!-- 技术参数卡列表 -->
  5. <select id="technicalSpecificationSearch" parameterType="TechnicalSpecificationData" resultType="TechnicalSpecificationData">
  6. SELECT
  7. a.site,
  8. b.bu_no,
  9. b.final_part_no as partNo,
  10. b.part_desc,
  11. a.project_id,
  12. c.project_name as project_desc,
  13. c.customer_id,
  14. j.customer_desc,
  15. a.code_no,
  16. a.ori_code_no,
  17. a.rev_no,
  18. case when a.ECN_flag = 'Y' then '变更中' else '未发起' end as ecnFlag,
  19. a.ECN_no,
  20. a.ECN_address,
  21. b.test_part_no
  22. FROM plm_technical_specification_sheet a
  23. LEFT JOIN plm_project_info c ON a.site = c.site AND a.project_id = c.project_id
  24. LEFT JOIN plm_customer_information j ON j.site = c.site and j.customer_no = c.customer_id
  25. left join view_Project_final_Part b on a.site = b.site and a.project_id = b.project_id and a.test_part_no = b.test_part_no
  26. <where>
  27. a.site = #{query.site} AND isnull(a.ECN_flag, 'N') = 'N' and a.status = '已完成' and isnull(a.show_in_query_flag, 'Y') = 'Y'
  28. <if test = "query.buNo != null and query.buNo != ''">
  29. AND b.bu_no = #{query.buNo}
  30. </if>
  31. <if test = "query.testPartNo != null and query.testPartNo != ''">
  32. AND b.test_part_no like #{query.testPartNo}
  33. </if>
  34. <if test = "query.partNo != null and query.partNo != ''">
  35. AND b.final_part_no like #{query.partNo}
  36. </if>
  37. <if test = "query.partDesc != null and query.partDesc != ''">
  38. AND b.part_desc like #{query.partDesc}
  39. </if>
  40. <if test = "query.customerId != null and query.customerId != ''">
  41. AND c.customer_id like #{query.customerId}
  42. </if>
  43. <if test = "query.customerDesc != null and query.customerDesc != ''">
  44. AND j.customer_desc like #{query.customerDesc}
  45. </if>
  46. <if test = "query.projectId != null and query.projectId != ''">
  47. AND a.project_id like #{query.projectId}
  48. </if>
  49. <if test = "query.projectDesc != null and query.projectDesc != ''">
  50. AND c.project_name like #{query.projectDesc}
  51. </if>
  52. <if test = "query.oriCodeNo != null and query.oriCodeNo != ''">
  53. AND a.ori_code_no like #{query.oriCodeNo}
  54. </if>
  55. </where>
  56. </select>
  57. <!-- 技术参数卡列表 -->
  58. <select id="technicalSpecificationSearch2" parameterType="TechnicalSpecificationData" resultType="TechnicalSpecificationData">
  59. SELECT
  60. a.site,
  61. b.bu_no,
  62. a.test_part_no as testPartNo,
  63. b.part_desc,
  64. a.project_id,
  65. c.project_name as project_desc,
  66. c.customer_id,
  67. j.customer_desc,
  68. a.code_no,
  69. a.ori_code_no,
  70. a.rev_no,
  71. case when a.ECN_flag = 'Y' then '变更中' else '未发起' end as ecnFlag,
  72. a.ECN_no,
  73. a.ECN_address ,
  74. b.final_part_no as partNo
  75. FROM plm_technical_specification_sheet a
  76. LEFT JOIN view_Project_final_Part b ON a.site = b.site AND a.project_id = b.project_id AND a.test_part_no = b.test_part_no
  77. LEFT JOIN plm_project_info c ON a.site = c.site AND a.project_id = c.project_id
  78. LEFT JOIN plm_customer_information j ON j.site = c.site and j.customer_no = c.customer_id
  79. <where>
  80. a.site = #{site} AND (a.ECN_flag is null or a.ECN_flag = 'N') and a.status = '已完成'
  81. <if test = "buNo != null and buNo != ''">
  82. AND b.bu_no = #{buNo}
  83. </if>
  84. <if test = "partNo != null and partNo != ''">
  85. AND b.final_part_no like #{partNo}
  86. </if>
  87. <if test = "testPartNo != null and testPartNo != ''">
  88. AND a.test_part_no like #{testPartNo}
  89. </if>
  90. <if test = "partDesc != null and partDesc != ''">
  91. AND b.part_desc like #{partDesc}
  92. </if>
  93. <if test = "customerId != null and customerId != ''">
  94. AND c.customer_id like #{customerId}
  95. </if>
  96. <if test = "customerDesc != null and customerDesc != ''">
  97. AND j.customer_desc like #{customerDesc}
  98. </if>
  99. <if test = "projectId != null and projectId != ''">
  100. AND a.project_id like #{projectId}
  101. </if>
  102. <if test = "projectDesc != null and projectDesc != ''">
  103. AND c.project_name like #{projectDesc}
  104. </if>
  105. <if test = "oriCodeNo != null and oriCodeNo != ''">
  106. AND a.ori_code_no like #{oriCodeNo}
  107. </if>
  108. </where>
  109. </select>
  110. <!-- 根据用户编码获得用户部门 -->
  111. <select id="getDepartmentByUserName" resultType="com.spring.modules.change.vo.SysUserVo" parameterType="com.spring.modules.change.vo.SysUserVo">
  112. SELECT
  113. a.site,
  114. a.user_id,
  115. a.username,
  116. a.password,
  117. a.salt,
  118. a.email,
  119. a.mobile,
  120. a.status,
  121. a.create_user_id,
  122. a.create_time,
  123. a.language_default,
  124. a.user_display,
  125. a.bu_no,
  126. a.post_no,
  127. a.department_no,
  128. b.department_name
  129. FROM sys_user as a
  130. LEFT JOIN department as b on a.site = b.site and a.department_no = b.department_no
  131. WHERE a.site = #{site} and a.username = #{username}
  132. </select>
  133. <!-- 根据变更单号删除文件 -->
  134. <delete id="deleteChangeFiles" parameterType="ChangeRequestEntity">
  135. delete from sys_oss
  136. where order_ref1 = #{site} and order_ref2 = #{changeNo}
  137. </delete>
  138. <!-- 新增变更详情 -->
  139. <insert id="saveChangeRequestDetail">
  140. insert into plm_change_request_detail
  141. (site, change_no, code_no, rev_no, part_no, part_desc, drawing_no, draft_no, new_part_no, new_drawing_no, new_draft_no, create_date, create_by) VALUES
  142. <foreach collection="list" item="item" index="index" separator=",">
  143. (#{item.site}, #{item.changeNo}, #{item.codeNo}, #{item.revNo}, #{item.partNo}, #{item.partDesc}, #{item.drawingNo}, #{item.draftNo}, #{item.newPartNo}, #{item.newDrawingNo}, #{item.newDraftNo}, getDate(), #{item.createBy})
  144. </foreach>
  145. </insert>
  146. <!-- 修改技术参数卡的ECN状态 -->
  147. <update id="updateTechnicalSpecificationSheet">
  148. update plm_technical_specification_sheet
  149. set ECN_flag = 'Y',
  150. ECN_no = #{changeNo},
  151. update_date = getDate(),
  152. update_by = #{createBy}
  153. where site = #{site}
  154. AND code_no in (
  155. <foreach collection="ids" item="item" separator=",">
  156. #{item}
  157. </foreach>
  158. )
  159. </update>
  160. <!-- =============================================================================================================== -->
  161. <!-- 工程变更记录列表 -->
  162. <select id="changeRecordSearch" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="com.spring.modules.change.vo.ChangeRequestVo">
  163. SELECT
  164. a.site,
  165. a.bu_no,
  166. a.change_no,
  167. a.applicant_id,
  168. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  169. b.department_no as applicationDepartmentId,
  170. dbo.get_department_name(a.site, b.department_no) as applicationDepartmentName,
  171. a.apply_date,
  172. a.ecn_type,
  173. a.change_impact,
  174. a.change_impact_desc,
  175. a.ecn_stage,
  176. a.change_type,
  177. a.tp_engineer_id,
  178. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  179. a.change_phase_in_date,
  180. a.df_is_product,
  181. a.printing,
  182. a.manufacturing_cost_is_change,
  183. a.change_request_desc,
  184. a.is_re_quote,
  185. a.ul_certification_requirements,
  186. a.ul_continue_to_meet_demand,
  187. a.gp_certification_requirements,
  188. a.gp_continue_to_meet_demand,
  189. a.create_date,
  190. a.create_by,
  191. a.update_date,
  192. a.update_by,
  193. a.industrial_engineer_id,
  194. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  195. a.change_status,
  196. a.cqc_operator_id,
  197. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  198. a.fai_operator_id,
  199. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  200. a.step_id,
  201. a.reject_flag,
  202. a.reject_step_id,
  203. d.is_reject,
  204. d.node_id,
  205. d.node_name,
  206. dbo.get_plm_Approval_username(a.site, prh.workflow_id, d.node_id, a.change_no) as createBy2,
  207. dbo.get_process_control(a.site, prh.workflow_id, d.node_id, 4) as tpProcessControl,
  208. dbo.get_process_control(a.site, prh.workflow_id, d.node_id, 5) as csProcessControl
  209. FROM plm_change_request a
  210. LEFT JOIN sys_user as b on a.site = b.site and a.applicant_id = b.username
  211. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{query.menuId}
  212. left join plm_request_node as d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id
  213. <where>
  214. a.site = #{query.site} and a.show_in_query_flag = 'Y'
  215. <if test = "query.buNo != null and query.buNo != ''">
  216. AND a.bu_no = #{query.buNo}
  217. </if>
  218. <if test = "query.changeNo != null and query.changeNo != ''">
  219. AND a.change_no like #{query.changeNo}
  220. </if>
  221. <if test = "query.changeStatus != null and query.changeStatus != ''">
  222. AND a.change_status = #{query.changeStatus}
  223. </if>
  224. <if test="query.nodeId != null and query.nodeId != ''">
  225. AND d.node_id = #{query.nodeId}
  226. </if>
  227. <if test="query.createBy2 != null and query.createBy2 != ''">
  228. AND dbo.get_plm_Approval_username(a.site, prh.workflow_id, d.node_id, a.change_no) like #{query.createBy2}
  229. </if>
  230. </where>
  231. order by a.change_no desc
  232. </select>
  233. <!-- 变更单详情的列表 -->
  234. <select id="changeDetailSearch" parameterType="com.spring.modules.change.vo.ChangeRequestDetailVo" resultType="com.spring.modules.change.vo.ChangeRequestDetailVo">
  235. SELECT
  236. a.site,
  237. a.change_no,
  238. a.code_no,
  239. a.rev_no,
  240. a.part_no,
  241. a.part_desc,
  242. a.drawing_no,
  243. a.draft_no,
  244. a.new_part_no,
  245. a.new_drawing_no,
  246. a.new_draft_no,
  247. a.create_date,
  248. a.create_by,
  249. a.update_date,
  250. a.update_by,
  251. b.ori_code_no,
  252. p.plm_part_no
  253. FROM plm_change_request_detail a
  254. left join plm_technical_specification_sheet as b on a.site = b.site and a.code_no = b.code_no
  255. left join part as p on a.site = p.site and a.part_no = p.ifs_part_no and p.show_in_query_flag = 'Y'
  256. where a.site = #{site} and a.change_no = #{changeNo}
  257. </select>
  258. <!-- 查询库存成本影响 -->
  259. <select id="costImpactSearch" parameterType="ChangeRequestEntity" resultType="com.spring.modules.change.vo.ChangeCostImpactVo">
  260. SELECT
  261. site,
  262. change_no,
  263. production_product_flag,
  264. inventory_product_flag,
  265. new_order_flag,
  266. affected_flag,
  267. production_product_number,
  268. production_product_opinions,
  269. production_product_scrap_amount,
  270. production_product_remark,
  271. production_product_executor,
  272. dbo.plm_get_user_display(site, production_product_executor) as productionProductExecutorName,
  273. inventory_product_number,
  274. inventory_product_opinions,
  275. inventory_product_scrap_amount,
  276. inventory_product_remark,
  277. inventory_product_executor,
  278. dbo.plm_get_user_display(site, inventory_product_executor) as inventoryProductExecutorName,
  279. new_order_number,
  280. affected_number,
  281. affected_opinions,
  282. affected_scrap_amount,
  283. affected_remark,
  284. affected_executor,
  285. dbo.plm_get_user_display(site, affected_executor) as affectedExecutorName,
  286. change_total_cost,
  287. remark,
  288. create_date,
  289. create_by,
  290. update_date,
  291. update_by
  292. FROM plm_change_cost_impact
  293. where site = #{site} and change_no = #{changeNo}
  294. </select>
  295. <!-- 库存成本影响新增 -->
  296. <insert id="costImpactSave" parameterType="ChangeCostImpactEntity">
  297. INSERT INTO plm_change_cost_impact
  298. (site, change_no, production_product_flag, inventory_product_flag, new_order_flag, affected_flag, production_product_number, production_product_opinions,
  299. production_product_remark, production_product_executor, inventory_product_number, inventory_product_opinions, inventory_product_remark, inventory_product_executor,
  300. new_order_number, affected_number, affected_opinions, affected_remark, affected_executor, change_total_cost, remark, create_date, create_by,
  301. production_product_scrap_amount, inventory_product_scrap_amount, affected_scrap_amount)
  302. VALUES
  303. (#{site}, #{changeNo}, #{productionProductFlag}, #{inventoryProductFlag}, #{newOrderFlag}, #{affectedFlag}, #{productionProductNumber}, #{productionProductOpinions},
  304. #{productionProductRemark}, #{productionProductExecutor}, #{inventoryProductNumber}, #{inventoryProductOpinions}, #{inventoryProductRemark}, #{inventoryProductExecutor},
  305. #{newOrderNumber}, #{affectedNumber}, #{affectedOpinions}, #{affectedRemark}, #{affectedExecutor}, #{changeTotalCost}, #{remark}, getDate(), #{createBy},
  306. #{productionProductScrapAmount}, #{inventoryProductScrapAmount}, #{affectedScrapAmount})
  307. </insert>
  308. <!-- 查询执行信息 -->
  309. <select id="queryChangeExecutionInfo" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo" resultType="ChangeExecutionInfoEntity">
  310. SELECT
  311. site,
  312. change_no,
  313. original_film_no,
  314. new_film_no,
  315. original_die_cutting_rule_no,
  316. new_die_cutting_rule_no,
  317. original_stencil_no,
  318. new_stencil_no,
  319. execution_date,
  320. create_date,
  321. create_by,
  322. update_date,
  323. update_by
  324. FROM plm_change_execution_info
  325. where site = #{site} and change_no = #{changeNo}
  326. </select>
  327. <!-- 执行信息新增 -->
  328. <insert id="executionSave" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo">
  329. INSERT INTO plm_change_execution_info
  330. (site, change_no, original_film_no, new_film_no, original_die_cutting_rule_no, new_die_cutting_rule_no, original_stencil_no, new_stencil_no, execution_date, create_date, create_by)
  331. VALUES
  332. (#{site}, #{changeNo}, #{originalFilmNo}, #{newFilmNo}, #{originalDieCuttingRuleNo}, #{newDieCuttingRuleNo}, #{originalStencilNo}, #{newStencilNo}, #{executionDate}, getDate(), #{createBy})
  333. </insert>
  334. <!-- 判断所选技术参数卡状态 -->
  335. <select id="queryTechnicalSpecificationSheet" resultType="TechnicalSpecificationData">
  336. SELECT
  337. site,
  338. code_no,
  339. ECN_flag,
  340. ECN_no
  341. FROM plm_technical_specification_sheet
  342. where site = #{site}
  343. AND code_no in (
  344. <foreach collection="ids" item="item" separator=",">
  345. #{item}
  346. </foreach>
  347. )
  348. </select>
  349. <!-- 编辑库存成本影响 -->
  350. <update id="costImpactUpdate" parameterType="ChangeCostImpactEntity">
  351. update plm_change_cost_impact
  352. set production_product_flag = #{productionProductFlag},
  353. inventory_product_flag = #{inventoryProductFlag},
  354. new_order_flag = #{newOrderFlag},
  355. affected_flag = #{affectedFlag},
  356. production_product_number = #{productionProductNumber},
  357. production_product_opinions = #{productionProductOpinions},
  358. production_product_remark = #{productionProductRemark},
  359. production_product_executor = #{productionProductExecutor},
  360. inventory_product_number = #{inventoryProductNumber},
  361. inventory_product_opinions = #{inventoryProductOpinions},
  362. inventory_product_remark = #{inventoryProductRemark},
  363. inventory_product_executor = #{inventoryProductExecutor},
  364. new_order_number = #{newOrderNumber},
  365. affected_number = #{affectedNumber},
  366. affected_opinions = #{affectedOpinions},
  367. affected_remark = #{affectedRemark},
  368. affected_executor = #{affectedExecutor},
  369. change_total_cost = #{changeTotalCost},
  370. remark = #{remark},
  371. update_date = getDate(),
  372. update_by = #{createBy},
  373. production_product_scrap_amount = #{productionProductScrapAmount},
  374. inventory_product_scrap_amount = #{inventoryProductScrapAmount},
  375. affected_scrap_amount = #{affectedScrapAmount}
  376. where site = #{site} and change_no = #{changeNo}
  377. </update>
  378. <!-- 查询ECN种类数据 -->
  379. <select id="getEcnTypeHeader" parameterType="EcnTypeHeaderData" resultType="EcnTypeHeaderData">
  380. SELECT
  381. site,
  382. dict_id,
  383. dict_name,
  384. dict_type as value
  385. FROM sys_dict_type
  386. where site = #{site} and dict_type like 'change_ecn_type_%' and status = 'Y'
  387. </select>
  388. <!-- 查询ECN种类数据 -->
  389. <select id="getEcnTypeDetail" parameterType="EcnTypeHeaderData" resultType="EcnTypeDetailData">
  390. SELECT
  391. site,
  392. dict_value as value
  393. FROM sys_dict_data
  394. where site = #{site} and dict_type = #{value} and status = 'Y'
  395. </select>
  396. <!-- 新增ECN种类header -->
  397. <insert id="saveEcnTypeHeader">
  398. insert into plm_change_ecn_type_header
  399. (site, change_no, header_value, flag) VALUES
  400. <foreach collection="list" item="item" index="index" separator=",">
  401. (#{item.site}, #{item.changeNo}, #{item.value}, #{item.flag})
  402. </foreach>
  403. </insert>
  404. <!-- 新增ECN种类detail -->
  405. <insert id="saveEcnTypeDetail">
  406. insert into plm_change_ecn_type_detail
  407. (site, change_no, header_value, value, flag) VALUES
  408. <foreach collection="list" item="item" index="index" separator=",">
  409. (#{item.site}, #{item.changeNo}, #{item.headerValue}, #{item.value}, #{item.flag})
  410. </foreach>
  411. </insert>
  412. <!-- 查询ECN的模板 -->
  413. <select id="getEcnModel" parameterType="PlmPropertiesModelHeaderData" resultType="PlmPropertiesModelHeaderData">
  414. SELECT
  415. site,
  416. function_type,
  417. code_no,
  418. code_desc
  419. FROM plm_properties_model_header
  420. <where>
  421. site = #{site} and function_type = #{functionType} and code_no = #{codeNo}
  422. </where>
  423. </select>
  424. <!-- 查询模板属性 -->
  425. <select id="getItemList" parameterType="PlmPropertiesModelHeaderData" resultType="ChangeItemData">
  426. SELECT
  427. a.site,
  428. a.properties_item_no as itemNo,
  429. b.ItemDesc as itemDesc,
  430. a.code_no,
  431. b.ValueChooseFlag,
  432. a.function_type
  433. FROM plm_properties_model_detail as a
  434. left join plm_properties_item as b on a.site = b.site and a.properties_item_no = b.ItemNo and a.function_type = b.ItemType
  435. <where>
  436. a.site = #{site} and a.function_type = #{functionType} and a.code_no = #{codeNo}
  437. <if test="itemNo != null and itemNo != ''">
  438. AND a.properties_item_no like #{itemNo}
  439. </if>
  440. <if test="itemDesc != null and itemDesc != ''">
  441. AND b.ItemDesc like #{itemDesc}
  442. </if>
  443. </where>
  444. </select>
  445. <!-- 获取属性可选值 -->
  446. <select id="getAvailableValueList" parameterType="ChangeItemData" resultType="PlmPropertiesItemAvailableData">
  447. select
  448. ItemNo,
  449. ValueNo,
  450. AvailableValue
  451. from plm_properties_item_available
  452. where itemNo = #{itemNo} and site = #{site} and ItemType = #{functionType}
  453. </select>
  454. <!-- 获取属性可选值 -->
  455. <select id="getAvailableValueList2" parameterType="ChangeItemEntity" resultType="PlmPropertiesItemAvailableData">
  456. select
  457. ItemNo,
  458. ValueNo,
  459. AvailableValue
  460. from plm_properties_item_available
  461. where itemNo = #{itemNo} and site = #{site} and ItemType = 'ECN'
  462. </select>
  463. <!-- 新增变更单属性 -->
  464. <insert id="chooseItemSave">
  465. insert into plm_change_item
  466. (site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no) VALUES
  467. <foreach collection="list" item="item" index="index" separator=",">
  468. (#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=TIMESTAMP}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
  469. </foreach>
  470. </insert>
  471. <!-- 新增可行性属性 -->
  472. <insert id="chooseItemSave2">
  473. insert into plm_change_FA_item
  474. (site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no, choose_value) VALUES
  475. <foreach collection="list" item="item" index="index" separator=",">
  476. (#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=TIMESTAMP}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo}, #{item.chooseValue})
  477. </foreach>
  478. </insert>
  479. <!-- 查询执行对象 -->
  480. <select id="executionInfoSearch" parameterType="ChangeRequestEntity" resultType="ChangeExecutionInfoEntity">
  481. SELECT
  482. site,
  483. change_no,
  484. original_film_no,
  485. new_film_no,
  486. original_die_cutting_rule_no,
  487. new_die_cutting_rule_no,
  488. original_stencil_no,
  489. new_stencil_no,
  490. execution_date,
  491. create_date,
  492. create_by,
  493. update_date,
  494. update_by
  495. FROM plm_change_execution_info
  496. where site = #{site} and change_no = #{changeNo}
  497. </select>
  498. <!-- 查询变更单属性 -->
  499. <select id="changeItemSearch" parameterType="ChangeRequestEntity" resultType="ChangeItemEntity">
  500. SELECT
  501. site,
  502. change_no,
  503. item_no,
  504. item_desc,
  505. execute_flag,
  506. executor,
  507. item_execution_date,
  508. item_remark,
  509. create_date,
  510. create_by,
  511. update_date,
  512. update_by,
  513. code_no
  514. FROM plm_change_item
  515. where site = #{site} and change_no = #{changeNo}
  516. </select>
  517. <!-- 查询变更单属性 -->
  518. <select id="changeItemSearch2" parameterType="ChangeRequestEntity" resultType="ChangeItemEntity">
  519. SELECT
  520. a.site,
  521. a.change_no,
  522. a.item_no,
  523. a.item_desc,
  524. a.execute_flag,
  525. a.executor,
  526. a.item_execution_date,
  527. a.item_remark,
  528. a.create_date,
  529. a.create_by,
  530. a.update_date,
  531. a.update_by,
  532. a.code_no,
  533. a.choose_value,
  534. b.ValueChooseFlag
  535. FROM plm_change_FA_item as a
  536. left join plm_properties_item as b on a.site = b.site and a.item_no = b.ItemNo and b.ItemType = 'ECN'
  537. where a.site = #{site} and a.change_no = #{changeNo}
  538. </select>
  539. <!-- 查询变更单会签属性 -->
  540. <select id="changeCSItemSearch" parameterType="ChangeRequestEntity" resultType="ChangeCountersignatureItemEntity">
  541. SELECT
  542. site,
  543. change_no,
  544. item_no,
  545. item_desc,
  546. execute_flag,
  547. executor,
  548. item_execution_date,
  549. item_remark,
  550. create_date,
  551. create_by,
  552. update_date,
  553. update_by,
  554. code_no
  555. FROM plm_change_countersignature_item
  556. where site = #{site} and change_no = #{changeNo}
  557. </select>
  558. <!-- 查询变更明细 -->
  559. <select id="requestDetailSearch" parameterType="ChangeRequestEntity" resultType="ChangeRequestDetailEntity">
  560. SELECT
  561. a.site,
  562. a.change_no,
  563. a.code_no,
  564. a.rev_no,
  565. a.part_no,
  566. a.part_desc,
  567. a.drawing_no,
  568. a.draft_no,
  569. a.new_part_no,
  570. a.new_drawing_no,
  571. a.new_draft_no,
  572. a.create_date,
  573. a.create_by,
  574. a.update_date,
  575. a.update_by,
  576. b.plm_part_no,
  577. b.ifs_part_no
  578. FROM plm_change_request_detail as a
  579. left join part as b on a.site = b.site and a.part_no = b.ifs_part_no and b.show_in_query_flag ='Y'
  580. where a.site = #{site} and a.change_no = #{changeNo}
  581. </select>
  582. <!-- 删除变更明细 -->
  583. <delete id="deleteChangeDetail" parameterType="ChangeRequestDetailEntity">
  584. delete from plm_change_request_detail
  585. where site = #{site} and change_no = #{changeNo} and code_no = #{codeNo}
  586. </delete>
  587. <!-- 查询所选ECN种类Header -->
  588. <select id="getChooseEcnTypeHeader" parameterType="ChangeRequestEntity" resultType="EcnTypeHeaderData">
  589. SELECT
  590. site,
  591. change_no,
  592. header_value as value,
  593. flag
  594. FROM plm_change_ecn_type_header
  595. where site = #{site} and change_no = #{changeNo}
  596. </select>
  597. <!-- 查询所选ECN种类Detail -->
  598. <select id="getChooseEcnTypeDetail" parameterType="EcnTypeHeaderData" resultType="EcnTypeDetailData">
  599. SELECT
  600. site,
  601. change_no,
  602. header_value,
  603. value,
  604. flag
  605. FROM plm_change_ecn_type_detail
  606. where site = #{site} and change_no = #{changeNo} and header_value = #{value}
  607. </select>
  608. <!-- 删除变更明细 -->
  609. <delete id="deleteChangeDetails" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  610. delete from plm_change_request_detail
  611. where site = #{site} and change_no = #{changeNo}
  612. </delete>
  613. <!-- 删除种类Header -->
  614. <delete id="deleteEcnTypeHeaderByChangeNo" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  615. delete from plm_change_ecn_type_header
  616. where site = #{site} and change_no = #{changeNo}
  617. </delete>
  618. <!-- 删除种类Detail -->
  619. <delete id="deleteEcnTypeDetailByChangeNo" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  620. delete from plm_change_ecn_type_detail
  621. where site = #{site} and change_no = #{changeNo}
  622. </delete>
  623. <!-- 查询工程变更记录 -->
  624. <select id="selectChangeRequest" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="com.spring.modules.change.vo.ChangeRequestVo">
  625. SELECT
  626. a.site,
  627. a.bu_no,
  628. a.change_no,
  629. a.applicant_id,
  630. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  631. b.department_no as applicationDepartmentId,
  632. dbo.get_department_name(a.site, b.department_no) as applicationDepartmentName,
  633. a.apply_date,
  634. a.ecn_type,
  635. a.change_impact,
  636. a.change_impact_desc,
  637. a.ecn_stage,
  638. a.change_type,
  639. a.tp_engineer_id,
  640. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  641. a.change_phase_in_date,
  642. a.df_is_product,
  643. a.printing,
  644. a.manufacturing_cost_is_change,
  645. a.change_request_desc,
  646. a.is_re_quote,
  647. a.ul_certification_requirements,
  648. a.ul_continue_to_meet_demand,
  649. a.gp_certification_requirements,
  650. a.gp_continue_to_meet_demand,
  651. a.create_date,
  652. a.create_by,
  653. a.update_date,
  654. a.update_by,
  655. a.industrial_engineer_id,
  656. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  657. a.change_status,
  658. a.cqc_operator_id,
  659. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  660. a.fai_operator_id,
  661. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  662. a.step_id,
  663. a.reject_flag,
  664. a.reject_step_id,
  665. d.is_Reject,
  666. d.node_id,
  667. d.node_name,
  668. dbo.get_plm_Approval_username(a.site, prh.workflow_id, d.node_id, a.change_no) as createBy2,
  669. dbo.get_process_control(a.site, prh.workflow_id, d.node_id, 4) as tpProcessControl,
  670. dbo.get_process_control(a.site, prh.workflow_id, d.node_id, 5) as csProcessControl,
  671. a.show_in_query_flag
  672. FROM plm_change_request a
  673. LEFT JOIN sys_user as b on a.site = b.site and a.applicant_id = b.username
  674. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{menuId}
  675. left join plm_request_node as d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id
  676. where a.site = #{site} and a.change_no = #{changeNo}
  677. </select>
  678. <!-- 编辑库存成本影响 -->
  679. <update id="executionUpdate" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo">
  680. update plm_change_execution_info
  681. set original_film_no = #{originalFilmNo},
  682. new_film_no = #{newFilmNo},
  683. original_die_cutting_rule_no = #{originalDieCuttingRuleNo},
  684. new_die_cutting_rule_no = #{newDieCuttingRuleNo},
  685. original_stencil_no = #{originalStencilNo},
  686. new_stencil_no = #{newStencilNo},
  687. execution_date = #{executionDate},
  688. update_date = getDate(),
  689. update_by = #{createBy}
  690. where site = #{site} and change_no = #{changeNo}
  691. </update>
  692. <!-- 编辑变更单属性 -->
  693. <update id="chooseItemUpdate" parameterType="ChangeItemEntity">
  694. update plm_change_item
  695. set execute_flag = #{executeFlag},
  696. executor = #{executor},
  697. item_execution_date = #{itemExecutionDate},
  698. item_remark = #{itemRemark},
  699. update_date = getDate(),
  700. update_by = #{createBy}
  701. where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
  702. </update>
  703. <!-- 编辑变更单属性 -->
  704. <update id="chooseItemUpdate2" parameterType="ChangeItemEntity">
  705. update plm_change_FA_item
  706. set execute_flag = #{executeFlag},
  707. executor = #{executor},
  708. item_execution_date = #{itemExecutionDate},
  709. item_remark = #{itemRemark},
  710. update_date = getDate(),
  711. update_by = #{createBy},
  712. choose_value = #{chooseValue}
  713. where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
  714. </update>
  715. <!-- 编辑变更单属性 -->
  716. <update id="chooseCSItemUpdate" parameterType="ChangeCountersignatureItemEntity">
  717. update plm_change_countersignature_item
  718. set execute_flag = #{executeFlag},
  719. executor = #{executor},
  720. item_execution_date = #{itemExecutionDate},
  721. item_remark = #{itemRemark},
  722. update_date = getDate(),
  723. update_by = #{createBy}
  724. where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
  725. </update>
  726. <!-- 新增会签属性 -->
  727. <insert id="chooseCSItemSave">
  728. insert into plm_change_countersignature_item
  729. (site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no) VALUES
  730. <foreach collection="list" item="item" index="index" separator=",">
  731. (#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=TIMESTAMP}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
  732. </foreach>
  733. </insert>
  734. <select id="queryRequestHeader" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestHeaderVo">
  735. SELECT
  736. a.site,
  737. a.bu,
  738. a.classification_no,
  739. a.classification_name,
  740. a.menu_id,
  741. a.workflow_id,
  742. b.workflowname,
  743. a.status,
  744. a.remark,
  745. a.create_by,
  746. a.create_date,
  747. a.update_by,
  748. a.update_date,
  749. c.url,
  750. c.name
  751. FROM plm_request_header a
  752. LEFT JOIN [VIEW_Process_management_OA_PLM] b ON a.workflow_id = b.workflowid
  753. left join sys_menu as c on a.menu_id = c.menu_id
  754. WHERE a.site = #{site} and a.menu_id = #{menuId} and a.status = 'Y'
  755. </select>
  756. <select id="queryNodeDetailFirst" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  757. SELECT
  758. a.id,
  759. a.site,
  760. a.bu,
  761. a.classification_no,
  762. b.node_id,
  763. a.node_name,
  764. a.create_date,
  765. a.create_by,
  766. a.update_date,
  767. a.update_by,
  768. a.remark,
  769. a.plm_field,
  770. a.oa_field,
  771. a.field_value,
  772. a.order_ref1,
  773. a.order_ref2,
  774. a.order_ref3,
  775. a.order_ref4,
  776. a.field_desc,
  777. a.workflow_id,
  778. a.plm_table,
  779. a.field_type,
  780. b.step_id,
  781. a.review
  782. FROM plm_request_header as c
  783. left join plm_request_node as b on c.site = b.site and c.bu = b.bu and c.classification_no = b.classification_no
  784. LEFT JOIN plm_request_node_detail as a on a.site = b.site and a.classification_no = b.classification_no and a.node_id = b.node_id
  785. WHERE b.site = #{site} and b.workflow_id = #{workflowId} and c.menu_id = #{menuId}
  786. and b.node_id = (select top 1 node_id from plm_request_node where site = #{site} and workflow_id = #{workflowId} order by seq_no)
  787. </select>
  788. <select id="getSeqNo" parameterType="ProcessFormEntity" resultType="int">
  789. SELECT
  790. case when max(seq_no) is null THEN 1 ELSE max(seq_no) + 1 end
  791. FROM plm_process_form
  792. WHERE site = #{site} and bu = #{bu} and request_id = #{requestId} and ISNULL(process_intervention_flag ,' ') <![CDATA[<>]]> 'Y'
  793. </select>
  794. <insert id="saveProcessForm" parameterType="ProcessFormEntity">
  795. INSERT INTO plm_process_form
  796. (site, bu, request_id, workflow_id, node_id, domain_control_account, document_no, document_type, seq_no, reject_flag, reject_node_id, node_conclusion, submit_date, submitted_by, create_date, create_by, is_remark, classification_no, step_id, menu_id, process_intervention_flag)
  797. VALUES
  798. (#{site}, #{bu}, #{requestId}, #{workflowId}, #{nodeId}, #{domainControlAccount}, #{documentNo}, #{documentType}, #{seqNo}, #{rejectFlag}, #{rejectNodeId}, #{nodeConclusion}, #{submitDate}, #{submittedBy}, getDate(), #{createBy}, #{isRemark}, #{classificationNo}, #{stepId}, #{menuId}, #{processInterventionFlag})
  799. </insert>
  800. <!-- 编辑变更单属性 -->
  801. <update id="updateChangeStatus" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  802. update plm_change_request
  803. set change_status = #{changeStatus},
  804. update_date = getDate(),
  805. update_by = #{userName}
  806. where site = #{site} and change_no = #{changeNo}
  807. </update>
  808. <select id="queryRequestId" parameterType="string" resultType="ProcessFormEntity">
  809. SELECT
  810. a.id,
  811. a.site,
  812. a.bu,
  813. a.request_id,
  814. a.workflow_id,
  815. b.workflowname,
  816. a.node_id,
  817. a.domain_control_account,
  818. a.document_no,
  819. a.document_type,
  820. a.seq_no,
  821. a.reject_flag,
  822. a.reject_node_id,
  823. a.node_conclusion,
  824. a.submit_date,
  825. a.submitted_by,
  826. a.is_remark,
  827. a.classification_no,
  828. a.menu_id,
  829. c.url,
  830. b.nodename as nodeName,
  831. c.name
  832. FROM plm_process_form as a
  833. LEFT JOIN [VIEW_Process_management_OA_PLM] as b ON a.workflow_id = b.workflowid and a.node_id = b.nodeid
  834. left join sys_menu as c on a.menu_id = c.menu_id
  835. WHERE a.site = #{site} and a.bu = #{bu} and a.document_no = #{documentNo} and a.is_remark = 0 and ISNULL(a.process_intervention_flag ,' ') <![CDATA[<>]]> 'Y'
  836. </select>
  837. <select id="queryNodeDetails" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  838. SELECT
  839. id,
  840. site,
  841. bu,
  842. classification_no,
  843. node_id,
  844. node_name,
  845. create_date,
  846. create_by,
  847. update_date,
  848. update_by,
  849. remark,
  850. plm_field,
  851. oa_field,
  852. field_value,
  853. order_ref1,
  854. order_ref2,
  855. order_ref3,
  856. order_ref4,
  857. field_desc,
  858. workflow_id,
  859. plm_table,
  860. field_type,
  861. review
  862. FROM plm_request_node_detail
  863. WHERE site = #{site} and workflow_id = #{workflowId} and node_id = #{nodeId} and classification_no = #{classificationNo}
  864. </select>
  865. <!-- 编辑变更单属性 -->
  866. <update id="updateProcessForm" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  867. update plm_process_form
  868. set is_remark = 1,
  869. update_date = getDate(),
  870. update_by = #{userName}
  871. where site = #{site} and document_no = #{changeNo} and is_remark = 0
  872. </update>
  873. <!-- 编辑变更单属性 -->
  874. <update id="updateStepId" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  875. update plm_change_request
  876. set step_id = #{stepId}
  877. <if test='rejectFlag == "Y"'>
  878. reject_flag = 'Y',
  879. </if>
  880. where site = #{site} and change_no = #{changeNo}
  881. </update>
  882. <select id="getStepId" parameterType="string" resultType="int">
  883. SELECT step_id
  884. FROM plm_request_node
  885. WHERE classification_no = #{classificationNo} and node_id = #{nodeId} and site = #{site}
  886. </select>
  887. <!-- 编辑变更单的驳回标识 -->
  888. <update id="updateChangeReject" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  889. update plm_change_request
  890. set reject_flag = 'Y',
  891. reject_step_id = #{rejectStepId}
  892. where site = #{site} and change_no = #{changeNo}
  893. </update>
  894. <!-- 编辑流程记录的驳回标识 -->
  895. <update id="updateProcessReject" parameterType="string">
  896. update plm_process_form
  897. set reject_flag = 'Y'
  898. where site = #{site} and bu = #{bu} and request_id = #{requestId} and is_remark = 0
  899. </update>
  900. <select id="getProcessNodeId" parameterType="string" resultType="ProcessFormEntity">
  901. SELECT
  902. id,
  903. site,
  904. bu,
  905. request_id,
  906. workflow_id,
  907. node_id,
  908. domain_control_account,
  909. document_no,
  910. document_type,
  911. seq_no,
  912. reject_flag,
  913. reject_node_id,
  914. is_remark,
  915. classification_no,
  916. step_id
  917. FROM plm_process_form
  918. WHERE site = #{site} and bu = #{bu} and request_id = #{requestId} and domain_control_account = #{domainControlAccount} and is_remark = 0
  919. </select>
  920. <select id="getNodeName" parameterType="string" resultType="string">
  921. select
  922. node_name
  923. from plm_request_node
  924. where site = #{site} and classification_no = #{classificationNo} and node_id = #{nodeId}
  925. </select>
  926. <select id="getNodeInformation" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="PlmRequestDetailEntity">
  927. select
  928. b.id,
  929. b.site,
  930. b.bu,
  931. b.classification_no,
  932. b.node_id,
  933. b.node_name,
  934. b.node_type,
  935. b.remark,
  936. b.workflow_id,
  937. b.seq_no,
  938. b.step_id
  939. from plm_request_header as a
  940. left join plm_request_node as b on a.site = b.site and a.bu = b.bu and a.classification_no = b.classification_no and a.workflow_id = b.workflow_id
  941. where a.site = #{site} and a.menu_id = #{menuId} and a.status = 'Y' and b.step_id = #{stepId}
  942. </select>
  943. <select id="getAllNodeAuthority" parameterType="PlmRequestDetailEntity" resultType="RequestNodeAuthorityEntity">
  944. select distinct
  945. a.site,
  946. a.bu,
  947. a.classification_no,
  948. a.field_id,
  949. a.update_flag,
  950. a.table_id,
  951. max( a.required) required,
  952. b.fieldName
  953. from plm_request_node_authority as a
  954. left join (SELECT
  955. col.name AS fieldId,
  956. CONVERT(varchar(50), comm.value) AS fieldName,
  957. tbl.name as tableId
  958. FROM
  959. sys.columns AS col
  960. INNER JOIN
  961. sys.tables AS tbl ON col.object_id = tbl.object_id
  962. INNER JOIN
  963. sys.types AS typ ON col.user_type_id = typ.user_type_id
  964. LEFT JOIN
  965. sys.extended_properties AS comm ON col.object_id = comm.major_id AND col.column_id = comm.minor_id) as b
  966. on a.table_id = b.tableId and a.field_id = b.fieldId
  967. where a.site = #{site} and a.bu = #{bu} and a.classification_no = #{classificationNo}
  968. group by a.site,
  969. a.bu,
  970. a.classification_no,
  971. a.field_id,
  972. a.update_flag,
  973. a.table_id, b.fieldName
  974. </select>
  975. <select id="getNodeAuthority" parameterType="PlmRequestDetailEntity" resultType="RequestNodeAuthorityEntity">
  976. select
  977. a.site,
  978. a.bu,
  979. a.classification_no,
  980. a.node_id,
  981. a.node_name,
  982. a.field_id,
  983. a.update_flag,
  984. a.table_id,
  985. a.required,
  986. b.fieldName
  987. from plm_request_node_authority as a
  988. left join (SELECT
  989. col.name AS fieldId,
  990. CONVERT(varchar(50), comm.value) AS fieldName,
  991. tbl.name as tableId
  992. FROM
  993. sys.columns AS col
  994. INNER JOIN
  995. sys.tables AS tbl ON col.object_id = tbl.object_id
  996. INNER JOIN
  997. sys.types AS typ ON col.user_type_id = typ.user_type_id
  998. LEFT JOIN
  999. sys.extended_properties AS comm ON col.object_id = comm.major_id AND col.column_id = comm.minor_id) as b
  1000. on a.table_id = b.tableId and a.field_id = b.fieldId
  1001. where a.site = #{site} and a.bu = #{bu} and a.classification_no = #{classificationNo} and a.node_id = #{nodeId}
  1002. </select>
  1003. <!-- 编辑变更单属性 -->
  1004. <update id="updateStepId2" parameterType="com.spring.modules.change.entity.ParamData">
  1005. update ${tableName}
  1006. set step_id = #{stepId}
  1007. <if test='rejectFlag == "Y"'>
  1008. ,reject_flag = 'Y'
  1009. </if>
  1010. <where>
  1011. site = #{site} and ${fieldName1} = #{docNo}
  1012. <if test="revisionNo != null and revisionNo != ''">
  1013. AND rev_no = #{revisionNo}
  1014. </if>
  1015. </where>
  1016. </update>
  1017. <!-- 编辑变更单属性 -->
  1018. <update id="updateStepId3" parameterType="com.spring.modules.change.entity.ParamData">
  1019. update ${tableName}
  1020. set
  1021. <choose>
  1022. <when test="tableName == 'plm_technical_specification_sheet'">
  1023. ${fieldName2} = 'spz'
  1024. </when>
  1025. <otherwise>
  1026. ${fieldName2} = '审批中'
  1027. </otherwise>
  1028. </choose>
  1029. <where>
  1030. site = #{site} and ${fieldName1} = #{docNo}
  1031. <if test="revisionNo != null and revisionNo != ''">
  1032. AND rev_no = #{revisionNo}
  1033. </if>
  1034. </where>
  1035. </update>
  1036. <!-- 编辑变更单属性 -->
  1037. <!-- <update id="updateProcessForm2" parameterType="ParamData">-->
  1038. <!-- update plm_process_form-->
  1039. <!-- set is_remark = 1,-->
  1040. <!-- update_date = getDate(),-->
  1041. <!-- update_by = #{userName}-->
  1042. <!-- where site = #{site} and document_no = #{docNo} and is_remark = 0-->
  1043. <!-- </update>-->
  1044. <update id="updateProcessForm2" parameterType="ParamData">
  1045. update a
  1046. set A.is_remark = 1,
  1047. A.update_date = getDate(),
  1048. A.update_by = #{userName}
  1049. from plm_process_form a
  1050. left join sys_user b on a.domain_control_account = B.domain_control_account
  1051. where A.site = #{site} and document_no = #{docNo} and is_remark = 0 AND B.username = #{userName}
  1052. </update>
  1053. <update id="updateProcessForm3" parameterType="ParamData">
  1054. update plm_process_form
  1055. set is_remark = 1,
  1056. update_date = getDate(),
  1057. update_by = #{userName}
  1058. where site = #{site} and document_no = #{docNo} and is_remark = 0
  1059. </update>
  1060. <!-- 编辑变更单属性 -->
  1061. <update id="updateChangeStatus2" parameterType="ParamData">
  1062. update ${tableName}
  1063. set ${fieldName2} = #{status},
  1064. update_date = getDate(),
  1065. update_by = #{userName},
  1066. step_id = #{stepId}
  1067. <where>
  1068. site = #{site} and ${fieldName1} = #{docNo}
  1069. <if test="revisionNo != null and revisionNo != ''">
  1070. AND rev_no = #{revisionNo}
  1071. </if>
  1072. </where>
  1073. </update>
  1074. <!-- 编辑变更单的驳回标识 -->
  1075. <update id="updateChangeReject2" parameterType="ParamData">
  1076. update ${tableName}
  1077. set reject_flag = 'Y',
  1078. reject_step_id = #{rejectStepId}
  1079. where site = #{site} and ${fieldName1} = #{docNo}
  1080. </update>
  1081. <select id="queryNodeDetailLast" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  1082. SELECT
  1083. step_id
  1084. FROM plm_request_node
  1085. where site = #{site} and classification_no = #{classificationNo} and workflow_id = #{workflowId}
  1086. order by seq_no desc
  1087. </select>
  1088. <delete id="chooseItemDel">
  1089. delete from plm_change_item
  1090. where site = #{site} and change_no = #{changeNo}
  1091. </delete>
  1092. <delete id="chooseItemDel2">
  1093. delete from plm_change_FA_item
  1094. where site = #{site} and change_no = #{changeNo}
  1095. </delete>
  1096. <delete id="chooseItemCSDel">
  1097. delete from plm_change_countersignature_item
  1098. where site = #{site} and change_no = #{changeNo}
  1099. </delete>
  1100. <delete id="deleteChangeCostImpact">
  1101. delete from plm_change_cost_impact
  1102. where site = #{site} and change_no = #{changeNo}
  1103. </delete>
  1104. <delete id="deleteChangeExecutionInfo">
  1105. delete from plm_change_execution_info
  1106. where site = #{site} and change_no = #{changeNo}
  1107. </delete>
  1108. <update id="updateProcessNode">
  1109. update plm_process_form
  1110. set node_conclusion = #{nodeConclusion},
  1111. reject_opinion = #{rejectOpinion}
  1112. where site = #{site} and bu = #{bu} and request_id = #{requestId}
  1113. and classification_no = #{classificationNo}
  1114. and node_id = #{nodeId}
  1115. and domain_control_account = #{domainControlAccount}
  1116. and (node_conclusion is null or node_conclusion = '')
  1117. </update>
  1118. <update id="updateProcessNodeForReject">
  1119. update plm_process_form
  1120. set node_conclusion = #{nodeConclusion},
  1121. reject_opinion = #{rejectOpinion}
  1122. where site = #{site} and bu = #{bu} and request_id = #{requestId}
  1123. and classification_no = #{classificationNo}
  1124. and node_id = #{nodeId}
  1125. and (node_conclusion is null or node_conclusion = '')
  1126. </update>
  1127. <select id="getApprovalList" parameterType="com.spring.modules.change.vo.ProcessFormVo" resultType="com.spring.modules.change.vo.ProcessFormVo">
  1128. <!-- WITH cte AS (-->
  1129. <!-- SELECT-->
  1130. <!-- a.classification_no,-->
  1131. <!-- b.node_id,-->
  1132. <!-- b.node_name,-->
  1133. <!-- c.reject_flag,-->
  1134. <!-- CASE WHEN c.reject_flag = 'Y' THEN '是' ELSE '否' END AS rejectFlagDesc,-->
  1135. <!-- CASE WHEN c.process_intervention_flag = 'Y' THEN '是' ELSE '否' END AS process_intervention_flag,-->
  1136. <!-- c.reject_node_id,-->
  1137. <!-- dbo.plm_get_nodeName(a.site, c.reject_node_id, a.classification_no) AS rejectNodeName,-->
  1138. <!-- c.node_conclusion,-->
  1139. <!-- CASE-->
  1140. <!-- WHEN c.node_conclusion = 'Y' THEN '同意'-->
  1141. <!-- WHEN c.node_conclusion = 'N' THEN '驳回'-->
  1142. <!-- ELSE ''-->
  1143. <!-- END AS nodeConclusionDesc,-->
  1144. <!-- CAST(c.update_date AS DATETIME2(0)) AS update_date,-->
  1145. <!-- d.username AS create_by,-->
  1146. <!-- c.reject_opinion,-->
  1147. <!-- ISNULL(c.update_by, d.username) AS updateBy,-->
  1148. <!-- CAST(c.create_date AS DATETIME2(0)) AS create_date-->
  1149. <!-- FROM plm_request_header a-->
  1150. <!-- LEFT JOIN plm_request_node b-->
  1151. <!-- ON a.site = b.site-->
  1152. <!-- AND a.classification_no = b.classification_no-->
  1153. <!-- AND a.workflow_id = b.workflow_id-->
  1154. <!-- LEFT JOIN plm_process_form c-->
  1155. <!-- ON b.site = c.site-->
  1156. <!-- AND b.classification_no = c.classification_no-->
  1157. <!-- AND b.workflow_id = c.workflow_id-->
  1158. <!-- AND b.node_id = c.node_id-->
  1159. <!-- AND c.document_no = #{documentNo}-->
  1160. <!-- LEFT JOIN sys_user d-->
  1161. <!-- ON c.domain_control_account = d.domain_control_account-->
  1162. <!-- WHERE-->
  1163. <!-- a.site = #{site} AND a.menu_id = #{menuId}-->
  1164. <!-- AND c.create_date IS NOT NULL-->
  1165. <!-- ),-->
  1166. <!-- cte_dedup AS (-->
  1167. <!-- SELECT *,-->
  1168. <!-- ROW_NUMBER() OVER (-->
  1169. <!-- PARTITION BY classification_no, node_id, update_date-->
  1170. <!-- ORDER BY create_date DESC &#45;&#45; 保留每组最新创建的那条-->
  1171. <!-- ) AS rn-->
  1172. <!-- FROM cte-->
  1173. <!-- )-->
  1174. <!-- SELECT-->
  1175. <!-- classification_no,-->
  1176. <!-- node_id,-->
  1177. <!-- node_name,-->
  1178. <!-- reject_flag,-->
  1179. <!-- rejectFlagDesc,-->
  1180. <!-- reject_node_id,-->
  1181. <!-- rejectNodeName,-->
  1182. <!-- node_conclusion,-->
  1183. <!-- nodeConclusionDesc,-->
  1184. <!-- update_date,-->
  1185. <!-- create_by,-->
  1186. <!-- reject_opinion,-->
  1187. <!-- updateBy,-->
  1188. <!-- process_intervention_flag-->
  1189. <!-- FROM cte_dedup-->
  1190. <!-- WHERE rn = 1-->
  1191. <!-- ORDER BY-->
  1192. <!-- CASE WHEN update_date IS NULL THEN 1 ELSE 0 END,-->
  1193. <!-- update_date-->
  1194. <!-- 2025-05-22 海波要求替换成存储过程-->
  1195. exec dbo.get_process_form #{site},#{menuId},#{documentNo}
  1196. </select>
  1197. <select id="getTechnicalSpecification" resultType="PlmTechnicalSpecificationSheetData">
  1198. SELECT
  1199. id,
  1200. site,
  1201. code_no,
  1202. rev_no,
  1203. ori_code_no
  1204. FROM plm_technical_specification_sheet
  1205. where site = #{site} and code_no = #{codeNo}
  1206. </select>
  1207. <update id="updatePartActive">
  1208. update part
  1209. set active = 'N'
  1210. where site = #{site} and part_no = #{partNo}
  1211. </update>
  1212. <select id="getBuBySite" parameterType="Bu" resultType="Bu">
  1213. SELECT
  1214. id,
  1215. site,
  1216. bu_no,
  1217. bu_desc,
  1218. remark
  1219. FROM BU
  1220. where site = #{site} and active = 'Y'
  1221. <if test = "buNo != null and buNo != ''">
  1222. AND bu_no like #{buNo}
  1223. </if>
  1224. </select>
  1225. <select id="getReviewByNodeId" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  1226. select
  1227. site,
  1228. bu,
  1229. classification_no,
  1230. node_id,
  1231. node_name,
  1232. create_date,
  1233. create_by,
  1234. update_date,
  1235. update_by,
  1236. remark,
  1237. plm_field,
  1238. oa_field,
  1239. field_value,
  1240. field_desc,
  1241. workflow_id,
  1242. order_ref1,
  1243. order_ref2,
  1244. order_ref3,
  1245. order_ref4,
  1246. plm_table,
  1247. field_type,
  1248. review
  1249. from plm_request_node_detail
  1250. where site = #{site}
  1251. AND classification_no = #{classificationNo}
  1252. AND workflow_id = #{workflowId}
  1253. AND node_id = #{reviewNodeId}
  1254. </select>
  1255. <!-- 编辑变更单属性 -->
  1256. <update id="updateProcessFormToAgree">
  1257. update plm_process_form
  1258. set node_conclusion = 'Y',
  1259. update_date = getDate(),
  1260. update_by = #{userName}
  1261. where site = #{site} and bu = #{bu} and menu_id = #{menuId} and document_no = #{docNo} and step_id = #{stepId}
  1262. </update>
  1263. <select id="getProcessFormByIsRemark" parameterType="string" resultType="com.spring.modules.change.vo.ProcessFormVo">
  1264. SELECT
  1265. a.id,
  1266. a.site,
  1267. a.bu,
  1268. a.request_id,
  1269. a.workflow_id,
  1270. b.workflowname as workflowName,
  1271. a.node_id,
  1272. b.nodename as nodeName,
  1273. a.domain_control_account,
  1274. a.document_no,
  1275. a.document_type,
  1276. a.seq_no,
  1277. a.reject_flag,
  1278. a.reject_node_id,
  1279. a.is_remark,
  1280. a.classification_no,
  1281. a.step_id
  1282. FROM plm_process_form as a
  1283. LEFT JOIN [VIEW_Process_management_OA_PLM] as b ON a.workflow_id = b.workflowid and a.node_id = b.nodeid
  1284. WHERE a.site = #{site} and a.bu = #{bu} and a.document_no = #{docNo} and a.is_remark = #{isRemark}
  1285. </select>
  1286. <select id="getRequestNameByFunction" parameterType="string" resultType="string">
  1287. SELECT dbo.get_Process_heading(#{site}, #{classificationNo}, #{workflowId}, #{workflowName}, #{nodeId}, #{nodeName}, #{documentNo}, #{nodeConclusion}, #{updateBy}, #{updateDate}, #{rejectOpinion}, #{menuName}, #{type})
  1288. </select>
  1289. <!-- 根据视图查物料 -->
  1290. <select id="choosePartNoList" parameterType="PlmProjectPartData" resultType="PlmProjectPartData">
  1291. SELECT
  1292. a.Final_Part_No,
  1293. a.Test_part_no,
  1294. a.Part_desc,
  1295. pcpi.customer_part_no,
  1296. a.bu_no,
  1297. a.site
  1298. FROM view_Project_final_Part as a
  1299. left join plm_project_info as c on a.site = c.site and a.project_id = c.project_id
  1300. left join plm_customer_part_info as pcpi on a.site = pcpi.site and a.test_part_no = pcpi.part_no and c.customer_id = pcpi.customer_no
  1301. left join plm_technical_specification_sheet d on a.site = d.site and a.test_part_no = d.test_part_no
  1302. left join plm_change_request_detail T ON A.SITE = T.SITE AND A.FINAL_PART_NO = T.PART_NO
  1303. <where>
  1304. a.site = #{query.site}
  1305. and d.test_part_no is null
  1306. and T.PART_NO is null
  1307. <if test="query.buNo != null and query.buNo != ''">
  1308. AND a.bu_no = #{query.buNo}
  1309. </if>
  1310. <if test="query.finalPartNo != null and query.finalPartNo != ''">
  1311. AND a.Final_Part_No like #{query.finalPartNo}
  1312. </if>
  1313. <if test="query.customerPartNo != null and query.customerPartNo != ''">
  1314. AND pcpi.customer_part_no like #{query.customerPartNo}
  1315. </if>
  1316. <if test="query.testPartNo != null and query.testPartNo != ''">
  1317. AND a.Test_part_no like #{query.testPartNo}
  1318. </if>
  1319. <if test="query.partDesc != null and query.partDesc != ''">
  1320. AND a.Part_desc like #{query.partDesc}
  1321. </if>
  1322. and a.RealFlag = 'Y'
  1323. </where>
  1324. </select>
  1325. <select id="getOaUserIdByIsRemark" resultType="com.spring.modules.base.data.OaUserData">
  1326. SELECT
  1327. b.id,
  1328. b.loginId
  1329. FROM plm_process_form as a
  1330. inner JOIN view_oa_HrmResource as b ON a.domain_control_account = b.loginid
  1331. WHERE a.site = #{site} and a.document_no = #{docNo} and (a.is_remark = #{isRemark} OR A.step_id = 10)
  1332. </select>
  1333. <select id="getRequestNodeByNodeId" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  1334. SELECT
  1335. site,
  1336. countersignature_item
  1337. FROM plm_request_node
  1338. where classification_no = #{classificationNo} and site = #{site} and node_id = #{nodeId}
  1339. </select>
  1340. <select id="technicalSpecificationSearchAny"
  1341. resultType="com.spring.modules.change.entity.TechnicalSpecificationData">
  1342. SELECT
  1343. a.site,
  1344. b.bu_no,
  1345. b.final_part_no as partNo,
  1346. b.part_desc,
  1347. a.project_id,
  1348. c.project_name as project_desc,
  1349. c.customer_id,
  1350. j.customer_desc,
  1351. a.code_no,
  1352. a.ori_code_no,
  1353. a.rev_no,
  1354. case when a.ECN_flag = 'Y' then '变更中' else '未发起' end as ecnFlag,
  1355. a.ECN_no,
  1356. a.ECN_address,
  1357. b.test_part_no
  1358. FROM plm_technical_specification_sheet a
  1359. LEFT JOIN plm_project_info c ON a.site = c.site AND a.project_id = c.project_id
  1360. LEFT JOIN plm_customer_information j ON j.site = c.site and j.customer_no = c.customer_id
  1361. left join view_Project_final_Part b on a.site = b.site and a.project_id = b.project_id and a.test_part_no = b.test_part_no
  1362. <if test="params.whereClause != null and params.whereClause != ''">
  1363. WHERE ${params.whereClause}
  1364. </if>
  1365. <if test="params.orderClause != null and params.orderClause != ''">
  1366. ORDER BY ${params.orderClause}
  1367. </if>
  1368. <if test="params.orderClause == null or params.orderClause == ''">
  1369. order by a.ori_code_no
  1370. </if>
  1371. </select>
  1372. <select id="changeRecordSearchAny" resultType="com.spring.modules.change.vo.ChangeRequestVo">
  1373. SELECT
  1374. a.site,
  1375. a.bu_no,
  1376. a.change_no,
  1377. a.applicant_id,
  1378. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  1379. b.department_no as applicationDepartmentId,
  1380. dbo.get_department_name(a.site, b.department_no) as applicationDepartmentName,
  1381. a.apply_date,
  1382. a.ecn_type,
  1383. a.change_impact,
  1384. a.change_impact_desc,
  1385. a.ecn_stage,
  1386. a.change_type,
  1387. a.tp_engineer_id,
  1388. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  1389. a.change_phase_in_date,
  1390. a.df_is_product,
  1391. a.printing,
  1392. a.manufacturing_cost_is_change,
  1393. a.change_request_desc,
  1394. a.is_re_quote,
  1395. a.ul_certification_requirements,
  1396. a.ul_continue_to_meet_demand,
  1397. a.gp_certification_requirements,
  1398. a.gp_continue_to_meet_demand,
  1399. a.create_date,
  1400. a.create_by,
  1401. a.update_date,
  1402. a.update_by,
  1403. a.industrial_engineer_id,
  1404. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  1405. a.change_status,
  1406. a.cqc_operator_id,
  1407. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  1408. a.fai_operator_id,
  1409. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  1410. a.step_id,
  1411. a.reject_flag,
  1412. a.reject_step_id,
  1413. d.is_reject,
  1414. d.node_id,
  1415. d.node_name,
  1416. dbo.get_plm_Approval_username(a.site, prh.workflow_id, d.node_id, a.change_no) as createBy2,
  1417. dbo.get_process_control(a.site, prh.workflow_id, d.node_id, 4) as tpProcessControl,
  1418. dbo.get_process_control(a.site, prh.workflow_id, d.node_id, 5) as csProcessControl
  1419. FROM plm_change_request a
  1420. LEFT JOIN sys_user as b on a.site = b.site and a.applicant_id = b.username
  1421. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{params.menuId}
  1422. left join plm_request_node as d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id
  1423. <if test="params.whereClause != null and params.whereClause != ''">
  1424. WHERE ${params.whereClause}
  1425. </if>
  1426. <if test="params.orderClause != null and params.orderClause != ''">
  1427. ORDER BY ${params.orderClause}
  1428. </if>
  1429. <if test="params.orderClause == null or params.orderClause == ''">
  1430. order by a.change_no desc
  1431. </if>
  1432. </select>
  1433. <insert id="saveProcessFormBySql">
  1434. insert into plm_process_form (site, bu, request_id, workflow_id, node_id, domain_control_account, document_no, document_type, classification_no,
  1435. seq_no, node_conclusion, is_remark, step_id, menu_id, create_by, create_date, update_by, update_date)
  1436. SELECT
  1437. TOP 1
  1438. a.site,
  1439. a.bu,
  1440. a.request_id,
  1441. a.workflow_id,
  1442. b.node_id,
  1443. domain_control_account,
  1444. document_no,
  1445. a.document_type,
  1446. A.classification_no,
  1447. a.seq_no + 10 AS seq_no,
  1448. 'Y' AS node_conclusion,
  1449. '1' AS is_remark,
  1450. b.step_id,
  1451. A.menu_id,
  1452. a.create_by,
  1453. a.create_date,
  1454. a.update_by,
  1455. a.update_date
  1456. FROM
  1457. plm_process_form A
  1458. LEFT JOIN (
  1459. SELECT
  1460. TOP 1
  1461. SITE,
  1462. classification_no,
  1463. node_id,
  1464. node_name,
  1465. step_id
  1466. FROM plm_request_node
  1467. WHERE SITE = #{site} AND classification_no = #{classificationNo}
  1468. ORDER BY step_id DESC
  1469. ) B ON A.site = B.site AND A.classification_no = B.classification_no
  1470. WHERE A.site = #{site} AND document_no = #{docNo} AND a.classification_no IS NOT NULL
  1471. ORDER BY A.ID DESC
  1472. </insert>
  1473. <update id="updateBMShowInQueryFlag">
  1474. update plm_technical_specification_sheet
  1475. set show_in_query_flag = #{showInQueryFlag}
  1476. where site = #{site} and code_no = #{codeNo}
  1477. </update>
  1478. <select id="getChangeRecordByPartNo" resultType="com.spring.modules.change.vo.ChangeRequestDetailVo">
  1479. select
  1480. a.site,
  1481. a.change_no,
  1482. b.plm_part_no,
  1483. b.ifs_part_no
  1484. from plm_change_request_detail a
  1485. left join part b on a.site = b.site and a.part_no = b.part_no
  1486. where a.site = #{site}
  1487. <if test="testPartNo != null and testPartNo != ''">
  1488. and b.plm_part_no = #{testPartNo}
  1489. </if>
  1490. <if test="finalPartNo != null and finalPartNo != ''">
  1491. and b.ifs_part_no = #{finalPartNo}
  1492. </if>
  1493. </select>
  1494. </mapper>