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.

1051 lines
41 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.spring.modules.change.mapper.ChangeManagementMapper">
  4. <!-- 技术参数卡列表 -->
  5. <select id="technicalSpecificationSearch" parameterType="TechnicalSpecificationData" resultType="TechnicalSpecificationData">
  6. SELECT
  7. a.site,
  8. b.bu_no,
  9. a.test_part_no as partNo,
  10. dbo.get_part_name(a.site, a.test_part_no) as partDesc,
  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.rev_no,
  17. case when a.ECN_flag = 'Y' then '变更中' else '未发起' end as ecnFlag,
  18. a.ECN_no,
  19. a.ECN_address
  20. FROM plm_technical_specification_sheet a
  21. LEFT JOIN view_Project_Part b ON a.site = b.site AND a.test_part_no = b.final_part_no AND a.project_id = b.project_id
  22. LEFT JOIN plm_project_info c ON a.site = c.site AND a.project_id = c.project_id
  23. LEFT JOIN plm_customer_information j ON j.site = c.site and j.customer_no = c.customer_id
  24. <where>
  25. a.site = #{query.site} AND (a.ECN_flag is null or a.ECN_flag = 'N')
  26. <if test = "query.buNo != null and query.buNo != ''">
  27. AND b.bu_no = #{query.buNo}
  28. </if>
  29. <if test = "query.partNo != null and query.partNo != ''">
  30. AND a.test_part_no like #{query.partNo}
  31. </if>
  32. <if test = "query.partDesc != null and query.partDesc != ''">
  33. AND dbo.get_part_name(a.site, a.test_part_no) like #{query.partDesc}
  34. </if>
  35. <if test = "query.customerId != null and query.customerId != ''">
  36. AND c.customer_id like #{query.customerId}
  37. </if>
  38. <if test = "query.customerDesc != null and query.customerDesc != ''">
  39. AND j.customer_desc like #{query.customerDesc}
  40. </if>
  41. <if test = "query.projectId != null and query.projectId != ''">
  42. AND a.project_id like #{query.projectId}
  43. </if>
  44. <if test = "query.projectDesc != null and query.projectDesc != ''">
  45. AND c.project_name like #{query.projectDesc}
  46. </if>
  47. <if test = "query.codeNo != null and query.codeNo != ''">
  48. AND a.code_no like #{query.codeNo}
  49. </if>
  50. </where>
  51. </select>
  52. <!-- 根据用户编码获得用户部门 -->
  53. <select id="getDepartmentByUserName" resultType="com.spring.modules.change.vo.SysUserVo" parameterType="com.spring.modules.change.vo.SysUserVo">
  54. SELECT
  55. a.site,
  56. a.user_id,
  57. a.username,
  58. a.password,
  59. a.salt,
  60. a.email,
  61. a.mobile,
  62. a.status,
  63. a.create_user_id,
  64. a.create_time,
  65. a.language_default,
  66. a.user_display,
  67. a.bu_no,
  68. a.post_no,
  69. a.department_no,
  70. b.department_name
  71. FROM sys_user as a
  72. LEFT JOIN department as b on a.site = b.site and a.department_no = b.department_no
  73. WHERE a.site = #{site} and a.username = #{username}
  74. </select>
  75. <!-- 根据变更单号删除文件 -->
  76. <delete id="deleteChangeFiles" parameterType="ChangeRequestEntity">
  77. delete from sys_oss
  78. where order_ref1 = #{site} and order_ref2 = #{changeNo}
  79. </delete>
  80. <!-- 新增变更详情 -->
  81. <insert id="saveChangeRequestDetail">
  82. insert into plm_change_request_detail
  83. (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
  84. <foreach collection="list" item="item" index="index" separator=",">
  85. (#{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})
  86. </foreach>
  87. </insert>
  88. <!-- 修改技术参数卡的ECN状态 -->
  89. <update id="updateTechnicalSpecificationSheet">
  90. update plm_technical_specification_sheet
  91. set ECN_flag = 'Y',
  92. ECN_no = #{changeNo},
  93. update_date = getDate(),
  94. update_by = #{createBy}
  95. where site = #{site}
  96. AND code_no in (
  97. <foreach collection="ids" item="item" separator=",">
  98. #{item}
  99. </foreach>
  100. )
  101. </update>
  102. <!-- =============================================================================================================== -->
  103. <!-- 工程变更记录列表 -->
  104. <select id="changeRecordSearch" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="com.spring.modules.change.vo.ChangeRequestVo">
  105. SELECT
  106. a.site,
  107. a.change_no,
  108. a.applicant_id,
  109. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  110. b.department_no as applicationDepartmentId,
  111. dbo.get_department_name(a.site, b.department_no) as applicationDepartmentName,
  112. a.apply_date,
  113. a.ecn_type,
  114. a.change_impact,
  115. a.change_impact_desc,
  116. a.ecn_stage,
  117. a.change_type,
  118. a.tp_engineer_id,
  119. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  120. a.change_phase_in_date,
  121. a.df_is_product,
  122. a.printing,
  123. a.manufacturing_cost_is_change,
  124. a.change_request_desc,
  125. a.is_re_quote,
  126. a.ul_certification_requirements,
  127. a.ul_continue_to_meet_demand,
  128. a.gp_certification_requirements,
  129. a.gp_continue_to_meet_demand,
  130. a.create_date,
  131. a.create_by,
  132. a.update_date,
  133. a.update_by,
  134. a.industrial_engineer_id,
  135. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  136. a.change_status,
  137. a.cqc_operator_id,
  138. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  139. a.fai_operator_id,
  140. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  141. a.step_id,
  142. a.reject_flag,
  143. a.reject_step_id,
  144. d.is_reject,
  145. d.node_id,
  146. d.node_name
  147. FROM plm_change_request a
  148. LEFT JOIN sys_user as b on a.site = b.site and a.applicant_id = b.username
  149. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{query.menuId}
  150. 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
  151. <where>
  152. a.site = #{query.site}
  153. <if test = "query.changeNo != null and query.changeNo != ''">
  154. AND a.change_no like #{query.changeNo}
  155. </if>
  156. </where>
  157. </select>
  158. <!-- 变更单详情的列表 -->
  159. <select id="changeDetailSearch" parameterType="com.spring.modules.change.vo.ChangeRequestDetailVo" resultType="com.spring.modules.change.vo.ChangeRequestDetailVo">
  160. SELECT
  161. a.site,
  162. a.change_no,
  163. a.code_no,
  164. a.rev_no,
  165. a.part_no,
  166. a.part_desc,
  167. a.drawing_no,
  168. a.draft_no,
  169. a.new_part_no,
  170. a.new_drawing_no,
  171. a.new_draft_no,
  172. a.create_date,
  173. a.create_by,
  174. a.update_date,
  175. a.update_by
  176. FROM plm_change_request_detail a
  177. where a.site = #{site} and a.change_no = #{changeNo}
  178. </select>
  179. <!-- 查询库存成本影响 -->
  180. <select id="costImpactSearch" parameterType="ChangeRequestEntity" resultType="com.spring.modules.change.vo.ChangeCostImpactVo">
  181. SELECT
  182. site,
  183. change_no,
  184. production_product_flag,
  185. inventory_product_flag,
  186. new_order_flag,
  187. affected_flag,
  188. production_product_number,
  189. production_product_opinions,
  190. production_product_scrap_amount,
  191. production_product_remark,
  192. production_product_executor,
  193. dbo.plm_get_user_display(site, production_product_executor) as productionProductExecutorName,
  194. inventory_product_number,
  195. inventory_product_opinions,
  196. inventory_product_scrap_amount,
  197. inventory_product_remark,
  198. inventory_product_executor,
  199. dbo.plm_get_user_display(site, inventory_product_executor) as inventoryProductExecutorName,
  200. new_order_number,
  201. affected_number,
  202. affected_opinions,
  203. affected_scrap_amount,
  204. affected_remark,
  205. affected_executor,
  206. dbo.plm_get_user_display(site, affected_executor) as affectedExecutorName,
  207. change_total_cost,
  208. remark,
  209. create_date,
  210. create_by,
  211. update_date,
  212. update_by
  213. FROM plm_change_cost_impact
  214. where site = #{site} and change_no = #{changeNo}
  215. </select>
  216. <!-- 库存成本影响新增 -->
  217. <insert id="costImpactSave" parameterType="ChangeCostImpactEntity">
  218. INSERT INTO plm_change_cost_impact
  219. (site, change_no, production_product_flag, inventory_product_flag, new_order_flag, affected_flag, production_product_number, production_product_opinions,
  220. production_product_remark, production_product_executor, inventory_product_number, inventory_product_opinions, inventory_product_remark, inventory_product_executor,
  221. new_order_number, affected_number, affected_opinions, affected_remark, affected_executor, change_total_cost, remark, create_date, create_by,
  222. production_product_scrap_amount, inventory_product_scrap_amount, affected_scrap_amount)
  223. VALUES
  224. (#{site}, #{changeNo}, #{productionProductFlag}, #{inventoryProductFlag}, #{newOrderFlag}, #{affectedFlag}, #{productionProductNumber}, #{productionProductOpinions},
  225. #{productionProductRemark}, #{productionProductExecutor}, #{inventoryProductNumber}, #{inventoryProductOpinions}, #{inventoryProductRemark}, #{inventoryProductExecutor},
  226. #{newOrderNumber}, #{affectedNumber}, #{affectedOpinions}, #{affectedRemark}, #{affectedExecutor}, #{changeTotalCost}, #{remark}, getDate(), #{createBy},
  227. #{productionProductScrapAmount}, #{inventoryProductScrapAmount}, #{affectedScrapAmount})
  228. </insert>
  229. <!-- 查询执行信息 -->
  230. <select id="queryChangeExecutionInfo" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo" resultType="ChangeExecutionInfoEntity">
  231. SELECT
  232. site,
  233. change_no,
  234. original_film_no,
  235. new_film_no,
  236. original_die_cutting_rule_no,
  237. new_die_cutting_rule_no,
  238. original_stencil_no,
  239. new_stencil_no,
  240. execution_date,
  241. create_date,
  242. create_by,
  243. update_date,
  244. update_by
  245. FROM plm_change_execution_info
  246. where site = #{site} and change_no = #{changeNo}
  247. </select>
  248. <!-- 执行信息新增 -->
  249. <insert id="executionSave" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo">
  250. INSERT INTO plm_change_execution_info
  251. (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)
  252. VALUES
  253. (#{site}, #{changeNo}, #{originalFilmNo}, #{newFilmNo}, #{originalDieCuttingRuleNo}, #{newDieCuttingRuleNo}, #{originalStencilNo}, #{newStencilNo}, #{executionDate}, getDate(), #{createBy})
  254. </insert>
  255. <!-- 判断所选技术参数卡状态 -->
  256. <select id="queryTechnicalSpecificationSheet" resultType="TechnicalSpecificationData">
  257. SELECT
  258. site,
  259. code_no,
  260. ECN_flag,
  261. ECN_no
  262. FROM plm_technical_specification_sheet
  263. where site = #{site}
  264. AND code_no in (
  265. <foreach collection="ids" item="item" separator=",">
  266. #{item}
  267. </foreach>
  268. )
  269. </select>
  270. <!-- 编辑库存成本影响 -->
  271. <update id="costImpactUpdate" parameterType="ChangeCostImpactEntity">
  272. update plm_change_cost_impact
  273. set production_product_flag = #{productionProductFlag},
  274. inventory_product_flag = #{inventoryProductFlag},
  275. new_order_flag = #{newOrderFlag},
  276. affected_flag = #{affectedFlag},
  277. production_product_number = #{productionProductNumber},
  278. production_product_opinions = #{productionProductOpinions},
  279. production_product_remark = #{productionProductRemark},
  280. production_product_executor = #{productionProductExecutor},
  281. inventory_product_number = #{inventoryProductNumber},
  282. inventory_product_opinions = #{inventoryProductOpinions},
  283. inventory_product_remark = #{inventoryProductRemark},
  284. inventory_product_executor = #{inventoryProductExecutor},
  285. new_order_number = #{newOrderNumber},
  286. affected_number = #{affectedNumber},
  287. affected_opinions = #{affectedOpinions},
  288. affected_remark = #{affectedRemark},
  289. affected_executor = #{affectedExecutor},
  290. change_total_cost = #{changeTotalCost},
  291. remark = #{remark},
  292. update_date = getDate(),
  293. update_by = #{createBy},
  294. production_product_scrap_amount = #{productionProductScrapAmount},
  295. inventory_product_scrap_amount = #{inventoryProductScrapAmount},
  296. affected_scrap_amount = #{affectedScrapAmount}
  297. where site = #{site} and change_no = #{changeNo}
  298. </update>
  299. <!-- 查询ECN种类数据 -->
  300. <select id="getEcnTypeHeader" parameterType="EcnTypeHeaderData" resultType="EcnTypeHeaderData">
  301. SELECT
  302. site,
  303. dict_id,
  304. dict_name,
  305. dict_type as value
  306. FROM sys_dict_type
  307. where site = #{site} and dict_type like 'change_ecn_type_%' and status = 'Y'
  308. </select>
  309. <!-- 查询ECN种类数据 -->
  310. <select id="getEcnTypeDetail" parameterType="EcnTypeHeaderData" resultType="EcnTypeDetailData">
  311. SELECT
  312. site,
  313. dict_value as value
  314. FROM sys_dict_data
  315. where site = #{site} and dict_type = #{value} and status = 'Y'
  316. </select>
  317. <!-- 新增ECN种类header -->
  318. <insert id="saveEcnTypeHeader">
  319. insert into plm_change_ecn_type_header
  320. (site, change_no, header_value, flag) VALUES
  321. <foreach collection="list" item="item" index="index" separator=",">
  322. (#{item.site}, #{item.changeNo}, #{item.value}, #{item.flag})
  323. </foreach>
  324. </insert>
  325. <!-- 新增ECN种类detail -->
  326. <insert id="saveEcnTypeDetail">
  327. insert into plm_change_ecn_type_detail
  328. (site, change_no, header_value, value, flag) VALUES
  329. <foreach collection="list" item="item" index="index" separator=",">
  330. (#{item.site}, #{item.changeNo}, #{item.headerValue}, #{item.value}, #{item.flag})
  331. </foreach>
  332. </insert>
  333. <!-- 查询ECN的模板 -->
  334. <select id="getEcnModel" parameterType="PlmPropertiesModelHeaderData" resultType="PlmPropertiesModelHeaderData">
  335. SELECT
  336. site,
  337. function_type,
  338. code_no,
  339. code_desc
  340. FROM plm_properties_model_header
  341. <where>
  342. site = #{site} and function_type = #{functionType} and code_no = #{codeNo}
  343. </where>
  344. </select>
  345. <!-- 查询模板属性 -->
  346. <select id="getItemList" parameterType="PlmPropertiesModelHeaderData" resultType="ChangeItemData">
  347. SELECT
  348. a.site,
  349. a.properties_item_no as itemNo,
  350. b.ItemDesc as itemDesc,
  351. a.code_no,
  352. b.ValueChooseFlag,
  353. a.function_type
  354. FROM plm_properties_model_detail as a
  355. 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
  356. <where>
  357. a.site = #{site} and a.function_type = #{functionType} and a.code_no = #{codeNo}
  358. <if test="itemNo != null and itemNo != ''">
  359. AND a.properties_item_no like #{itemNo}
  360. </if>
  361. <if test="itemDesc != null and itemDesc != ''">
  362. AND b.ItemDesc like #{itemDesc}
  363. </if>
  364. </where>
  365. </select>
  366. <!-- 获取属性可选值 -->
  367. <select id="getAvailableValueList" parameterType="ChangeItemData" resultType="PlmPropertiesItemAvailableData">
  368. select
  369. ItemNo,
  370. ValueNo,
  371. AvailableValue
  372. from plm_properties_item_available
  373. where itemNo = #{itemNo} and site = #{site} and ItemType = #{functionType}
  374. </select>
  375. <!-- 获取属性可选值 -->
  376. <select id="getAvailableValueList2" parameterType="ChangeItemEntity" resultType="PlmPropertiesItemAvailableData">
  377. select
  378. ItemNo,
  379. ValueNo,
  380. AvailableValue
  381. from plm_properties_item_available
  382. where itemNo = #{itemNo} and site = #{site} and ItemType = 'ECN'
  383. </select>
  384. <!-- 新增变更单属性 -->
  385. <insert id="chooseItemSave">
  386. insert into plm_change_item
  387. (site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no) VALUES
  388. <foreach collection="list" item="item" index="index" separator=",">
  389. (#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=DATE}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
  390. </foreach>
  391. </insert>
  392. <!-- 新增可行性属性 -->
  393. <insert id="chooseItemSave2">
  394. insert into plm_change_FA_item
  395. (site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no, choose_value) VALUES
  396. <foreach collection="list" item="item" index="index" separator=",">
  397. (#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=DATE}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo}, #{item.chooseValue})
  398. </foreach>
  399. </insert>
  400. <!-- 查询执行对象 -->
  401. <select id="executionInfoSearch" parameterType="ChangeRequestEntity" resultType="ChangeExecutionInfoEntity">
  402. SELECT
  403. site,
  404. change_no,
  405. original_film_no,
  406. new_film_no,
  407. original_die_cutting_rule_no,
  408. new_die_cutting_rule_no,
  409. original_stencil_no,
  410. new_stencil_no,
  411. execution_date,
  412. create_date,
  413. create_by,
  414. update_date,
  415. update_by
  416. FROM plm_change_execution_info
  417. where site = #{site} and change_no = #{changeNo}
  418. </select>
  419. <!-- 查询变更单属性 -->
  420. <select id="changeItemSearch" parameterType="ChangeRequestEntity" resultType="ChangeItemEntity">
  421. SELECT
  422. site,
  423. change_no,
  424. item_no,
  425. item_desc,
  426. execute_flag,
  427. executor,
  428. item_execution_date,
  429. item_remark,
  430. create_date,
  431. create_by,
  432. update_date,
  433. update_by,
  434. code_no
  435. FROM plm_change_item
  436. where site = #{site} and change_no = #{changeNo}
  437. </select>
  438. <!-- 查询变更单属性 -->
  439. <select id="changeItemSearch2" parameterType="ChangeRequestEntity" resultType="ChangeItemEntity">
  440. SELECT
  441. a.site,
  442. a.change_no,
  443. a.item_no,
  444. a.item_desc,
  445. a.execute_flag,
  446. a.executor,
  447. a.item_execution_date,
  448. a.item_remark,
  449. a.create_date,
  450. a.create_by,
  451. a.update_date,
  452. a.update_by,
  453. a.code_no,
  454. a.choose_value,
  455. b.ValueChooseFlag
  456. FROM plm_change_FA_item as a
  457. left join plm_properties_item as b on a.site = b.site and a.item_no = b.ItemNo and b.ItemType = 'ECN'
  458. where a.site = #{site} and a.change_no = #{changeNo}
  459. </select>
  460. <!-- 查询变更单会签属性 -->
  461. <select id="changeCSItemSearch" parameterType="ChangeRequestEntity" resultType="ChangeCountersignatureItemEntity">
  462. SELECT
  463. site,
  464. change_no,
  465. item_no,
  466. item_desc,
  467. execute_flag,
  468. executor,
  469. item_execution_date,
  470. item_remark,
  471. create_date,
  472. create_by,
  473. update_date,
  474. update_by,
  475. code_no
  476. FROM plm_change_countersignature_item
  477. where site = #{site} and change_no = #{changeNo}
  478. </select>
  479. <!-- 查询变更明细 -->
  480. <select id="requestDetailSearch" parameterType="ChangeRequestEntity" resultType="ChangeRequestDetailEntity">
  481. SELECT
  482. site,
  483. change_no,
  484. code_no,
  485. rev_no,
  486. part_no,
  487. part_desc,
  488. drawing_no,
  489. draft_no,
  490. new_part_no,
  491. new_drawing_no,
  492. new_draft_no,
  493. create_date,
  494. create_by,
  495. update_date,
  496. update_by
  497. FROM plm_change_request_detail
  498. where site = #{site} and change_no = #{changeNo}
  499. </select>
  500. <!-- 删除变更明细 -->
  501. <delete id="deleteChangeDetail" parameterType="ChangeRequestDetailEntity">
  502. delete from plm_change_request_detail
  503. where site = #{site} and change_no = #{changeNo} and code_no = #{codeNo}
  504. </delete>
  505. <!-- 查询所选ECN种类Header -->
  506. <select id="getChooseEcnTypeHeader" parameterType="ChangeRequestEntity" resultType="EcnTypeHeaderData">
  507. SELECT
  508. site,
  509. change_no,
  510. header_value as value,
  511. flag
  512. FROM plm_change_ecn_type_header
  513. where site = #{site} and change_no = #{changeNo}
  514. </select>
  515. <!-- 查询所选ECN种类Detail -->
  516. <select id="getChooseEcnTypeDetail" parameterType="EcnTypeHeaderData" resultType="EcnTypeDetailData">
  517. SELECT
  518. site,
  519. change_no,
  520. header_value,
  521. value,
  522. flag
  523. FROM plm_change_ecn_type_detail
  524. where site = #{site} and change_no = #{changeNo} and header_value = #{value}
  525. </select>
  526. <!-- 删除变更明细 -->
  527. <delete id="deleteChangeDetails" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  528. delete from plm_change_request_detail
  529. where site = #{site} and change_no = #{changeNo}
  530. </delete>
  531. <!-- 删除种类Header -->
  532. <delete id="deleteEcnTypeHeaderByChangeNo" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  533. delete from plm_change_ecn_type_header
  534. where site = #{site} and change_no = #{changeNo}
  535. </delete>
  536. <!-- 删除种类Detail -->
  537. <delete id="deleteEcnTypeDetailByChangeNo" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  538. delete from plm_change_ecn_type_detail
  539. where site = #{site} and change_no = #{changeNo}
  540. </delete>
  541. <!-- 查询工程变更记录 -->
  542. <select id="selectChangeRequest" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="com.spring.modules.change.vo.ChangeRequestVo">
  543. SELECT
  544. a.site,
  545. a.change_no,
  546. a.applicant_id,
  547. dbo.get_userDisPlay(a.applicant_id) as applicantName,
  548. b.department_no as applicationDepartmentId,
  549. dbo.get_department_name(a.site, b.department_no) as applicationDepartmentName,
  550. a.apply_date,
  551. a.ecn_type,
  552. a.change_impact,
  553. a.change_impact_desc,
  554. a.ecn_stage,
  555. a.change_type,
  556. a.tp_engineer_id,
  557. dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
  558. a.change_phase_in_date,
  559. a.df_is_product,
  560. a.printing,
  561. a.manufacturing_cost_is_change,
  562. a.change_request_desc,
  563. a.is_re_quote,
  564. a.ul_certification_requirements,
  565. a.ul_continue_to_meet_demand,
  566. a.gp_certification_requirements,
  567. a.gp_continue_to_meet_demand,
  568. a.create_date,
  569. a.create_by,
  570. a.update_date,
  571. a.update_by,
  572. a.industrial_engineer_id,
  573. dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
  574. a.change_status,
  575. a.cqc_operator_id,
  576. dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
  577. a.fai_operator_id,
  578. dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName,
  579. a.step_id,
  580. a.reject_flag,
  581. a.reject_step_id,
  582. d.is_Reject
  583. FROM plm_change_request a
  584. LEFT JOIN sys_user as b on a.site = b.site and a.applicant_id = b.username
  585. left join plm_request_header as prh on a.site = prh.site and prh.menu_id = #{menuId}
  586. 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
  587. where a.site = #{site} and a.change_no = #{changeNo}
  588. </select>
  589. <!-- 编辑库存成本影响 -->
  590. <update id="executionUpdate" parameterType="com.spring.modules.change.vo.ChangeExecutionInfoVo">
  591. update plm_change_execution_info
  592. set original_film_no = #{originalFilmNo},
  593. new_film_no = #{newFilmNo},
  594. original_die_cutting_rule_no = #{originalDieCuttingRuleNo},
  595. new_die_cutting_rule_no = #{newDieCuttingRuleNo},
  596. original_stencil_no = #{originalStencilNo},
  597. new_stencil_no = #{newStencilNo},
  598. execution_date = #{executionDate},
  599. update_date = getDate(),
  600. update_by = #{createBy}
  601. where site = #{site} and change_no = #{changeNo}
  602. </update>
  603. <!-- 编辑变更单属性 -->
  604. <update id="chooseItemUpdate" parameterType="ChangeItemEntity">
  605. update plm_change_item
  606. set execute_flag = #{executeFlag},
  607. executor = #{executor},
  608. item_execution_date = #{itemExecutionDate},
  609. item_remark = #{itemRemark},
  610. update_date = getDate(),
  611. update_by = #{createBy}
  612. where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
  613. </update>
  614. <!-- 编辑变更单属性 -->
  615. <update id="chooseItemUpdate2" parameterType="ChangeItemEntity">
  616. update plm_change_FA_item
  617. set execute_flag = #{executeFlag},
  618. executor = #{executor},
  619. item_execution_date = #{itemExecutionDate},
  620. item_remark = #{itemRemark},
  621. update_date = getDate(),
  622. update_by = #{createBy},
  623. choose_value = #{chooseValue}
  624. where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
  625. </update>
  626. <!-- 编辑变更单属性 -->
  627. <update id="chooseCSItemUpdate" parameterType="ChangeCountersignatureItemEntity">
  628. update plm_change_countersignature_item
  629. set execute_flag = #{executeFlag},
  630. executor = #{executor},
  631. item_execution_date = #{itemExecutionDate},
  632. item_remark = #{itemRemark},
  633. update_date = getDate(),
  634. update_by = #{createBy}
  635. where site = #{site} and change_no = #{changeNo} and item_no = #{itemNo}
  636. </update>
  637. <!-- 新增会签属性 -->
  638. <insert id="chooseCSItemSave">
  639. insert into plm_change_countersignature_item
  640. (site, change_no, item_no, item_desc, execute_flag, executor, item_execution_date, item_remark, create_date, create_by, code_no) VALUES
  641. <foreach collection="list" item="item" index="index" separator=",">
  642. (#{item.site}, #{item.changeNo}, #{item.itemNo}, #{item.itemDesc}, #{item.executeFlag}, #{item.executor}, #{item.itemExecutionDate,jdbcType=DATE}, #{item.itemRemark}, getDate(), #{item.createBy}, #{item.codeNo})
  643. </foreach>
  644. </insert>
  645. <select id="queryRequestHeader" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestHeaderVo">
  646. SELECT
  647. a.site,
  648. a.bu,
  649. a.classification_no,
  650. a.classification_name,
  651. a.menu_id,
  652. a.workflow_id,
  653. b.workflowname,
  654. a.status,
  655. a.remark,
  656. a.create_by,
  657. a.create_date,
  658. a.update_by,
  659. a.update_date,
  660. c.url
  661. FROM plm_request_header a
  662. LEFT JOIN [VIEW_Process_management_OA_PLM] b ON a.workflow_id = b.workflowid
  663. left join sys_menu as c on a.menu_id = c.menu_id
  664. WHERE a.site = #{site} and a.menu_id = #{menuId} and a.status = 'Y'
  665. </select>
  666. <select id="queryNodeDetailFirst" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  667. SELECT
  668. a.id,
  669. a.site,
  670. a.bu,
  671. a.classification_no,
  672. b.node_id,
  673. a.node_name,
  674. a.create_date,
  675. a.create_by,
  676. a.update_date,
  677. a.update_by,
  678. a.remark,
  679. a.plm_field,
  680. a.oa_field,
  681. a.field_value,
  682. a.order_ref1,
  683. a.order_ref2,
  684. a.order_ref3,
  685. a.order_ref4,
  686. a.field_desc,
  687. a.workflow_id,
  688. a.plm_table,
  689. a.field_type,
  690. b.step_id
  691. FROM plm_request_header as c
  692. left join plm_request_node as b on c.site = b.site and c.bu = b.bu and c.classification_no = b.classification_no
  693. LEFT JOIN plm_request_node_detail as a on a.classification_no = b.classification_no and a.node_id = b.node_id
  694. WHERE b.site = #{site} and b.workflow_id = #{workflowId} and c.menu_id = #{menuId}
  695. and b.node_id = (select top 1 node_id from plm_request_node where site = #{site} and workflow_id = #{workflowId} order by seq_no)
  696. </select>
  697. <select id="getSeqNo" parameterType="ProcessFormEntity" resultType="int">
  698. SELECT
  699. case when max(seq_no) is null THEN 1 ELSE max(seq_no) + 1 end
  700. FROM plm_process_form
  701. WHERE site = #{site} and bu = #{bu} and request_id = #{requestId}
  702. </select>
  703. <insert id="saveProcessForm" parameterType="ProcessFormEntity">
  704. INSERT INTO plm_process_form
  705. (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)
  706. VALUES
  707. (#{site}, #{bu}, #{requestId}, #{workflowId}, #{nodeId}, #{domainControlAccount}, #{documentNo}, #{documentType}, #{seqNo}, #{rejectFlag}, #{rejectNodeId}, #{nodeConclusion}, #{submitDate}, #{submittedBy}, getDate(), #{createBy}, #{isRemark}, #{classificationNo}, #{stepId}, #{menuId})
  708. </insert>
  709. <!-- 编辑变更单属性 -->
  710. <update id="updateChangeStatus" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  711. update plm_change_request
  712. set change_status = #{changeStatus},
  713. update_date = getDate(),
  714. update_by = #{userName}
  715. where site = #{site} and change_no = #{changeNo}
  716. </update>
  717. <select id="queryRequestId" parameterType="string" resultType="ProcessFormEntity">
  718. SELECT
  719. a.id,
  720. a.site,
  721. a.bu,
  722. a.request_id,
  723. a.workflow_id,
  724. b.workflowname,
  725. a.node_id,
  726. a.domain_control_account,
  727. a.document_no,
  728. a.document_type,
  729. a.seq_no,
  730. a.reject_flag,
  731. a.reject_node_id,
  732. a.node_conclusion,
  733. a.submit_date,
  734. a.submitted_by,
  735. a.is_remark,
  736. a.classification_no,
  737. a.menu_id,
  738. c.url
  739. FROM plm_process_form as a
  740. LEFT JOIN [VIEW_Process_management_OA_PLM] as b ON a.workflow_id = b.workflowid and a.node_id = b.nodeid
  741. left join sys_menu as c on a.menu_id = c.menu_id
  742. WHERE a.site = #{site} and a.bu = #{bu} and a.document_no = #{documentNo} and a.is_remark = 0
  743. </select>
  744. <select id="queryNodeDetails" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  745. SELECT
  746. id,
  747. site,
  748. bu,
  749. classification_no,
  750. node_id,
  751. node_name,
  752. create_date,
  753. create_by,
  754. update_date,
  755. update_by,
  756. remark,
  757. plm_field,
  758. oa_field,
  759. field_value,
  760. order_ref1,
  761. order_ref2,
  762. order_ref3,
  763. order_ref4,
  764. field_desc,
  765. workflow_id,
  766. plm_table,
  767. field_type
  768. FROM plm_request_node_detail
  769. WHERE site = #{site} and workflow_id = #{workflowId} and node_id = #{nodeId} and classification_no = #{classificationNo}
  770. </select>
  771. <!-- 编辑变更单属性 -->
  772. <update id="updateProcessForm" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  773. update plm_process_form
  774. set is_remark = 1,
  775. update_date = getDate(),
  776. update_by = #{userName}
  777. where site = #{site} and document_no = #{changeNo} and is_remark = 0
  778. </update>
  779. <!-- 编辑变更单属性 -->
  780. <update id="updateStepId" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  781. update plm_change_request
  782. set step_id = #{stepId}
  783. <if test='rejectFlag == "Y"'>
  784. reject_flag = 'Y',
  785. </if>
  786. where site = #{site} and change_no = #{changeNo}
  787. </update>
  788. <select id="getStepId" parameterType="string" resultType="int">
  789. SELECT step_id
  790. FROM plm_request_node
  791. WHERE classification_no = #{classificationNo} and node_id = #{nodeId}
  792. </select>
  793. <!-- 编辑变更单的驳回标识 -->
  794. <update id="updateChangeReject" parameterType="com.spring.modules.change.vo.ChangeRequestVo">
  795. update plm_change_request
  796. set reject_flag = 'Y',
  797. reject_step_id = #{rejectStepId}
  798. where site = #{site} and change_no = #{changeNo}
  799. </update>
  800. <!-- 编辑流程记录的驳回标识 -->
  801. <update id="updateProcessReject" parameterType="string">
  802. update plm_process_form
  803. set reject_flag = 'Y'
  804. where site = #{site} and bu = #{bu} and request_id = #{requestId} and domain_control_account = #{domainControlAccount} and is_remark = 0
  805. </update>
  806. <select id="getProcessNodeId" parameterType="string" resultType="ProcessFormEntity">
  807. SELECT
  808. id,
  809. site,
  810. bu,
  811. request_id,
  812. workflow_id,
  813. node_id,
  814. domain_control_account,
  815. document_no,
  816. document_type,
  817. seq_no,
  818. reject_flag,
  819. reject_node_id,
  820. is_remark,
  821. classification_no,
  822. step_id
  823. FROM plm_process_form
  824. WHERE site = #{site} and bu = #{bu} and request_id = #{requestId} and domain_control_account = #{domainControlAccount} and is_remark = 0
  825. </select>
  826. <select id="getNodeName" parameterType="string" resultType="string">
  827. select
  828. node_name
  829. from plm_request_node
  830. where site = #{site} and classification_no = #{classificationNo} and node_id = #{nodeId}
  831. </select>
  832. <select id="getNodeInformation" parameterType="com.spring.modules.change.vo.ChangeRequestVo" resultType="PlmRequestDetailEntity">
  833. select
  834. b.id,
  835. b.site,
  836. b.bu,
  837. b.classification_no,
  838. b.node_id,
  839. b.node_name,
  840. b.node_type,
  841. b.remark,
  842. b.workflow_id,
  843. b.seq_no,
  844. b.step_id
  845. from plm_request_header as a
  846. 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
  847. where a.site = #{site} and a.menu_id = #{menuId} and a.status = 'Y' and b.step_id = #{stepId}
  848. </select>
  849. <select id="getNodeAuthority" parameterType="PlmRequestDetailEntity" resultType="RequestNodeAuthorityEntity">
  850. select
  851. a.site,
  852. a.bu,
  853. a.classification_no,
  854. a.node_id,
  855. a.node_name,
  856. a.field_id,
  857. a.update_flag,
  858. a.table_id,
  859. a.required,
  860. b.fieldName
  861. from plm_request_node_authority as a
  862. left join (SELECT
  863. col.name AS fieldId,
  864. CONVERT(varchar(50), comm.value) AS fieldName,
  865. tbl.name as tableId
  866. FROM
  867. sys.columns AS col
  868. INNER JOIN
  869. sys.tables AS tbl ON col.object_id = tbl.object_id
  870. INNER JOIN
  871. sys.types AS typ ON col.user_type_id = typ.user_type_id
  872. LEFT JOIN
  873. sys.extended_properties AS comm ON col.object_id = comm.major_id AND col.column_id = comm.minor_id) as b
  874. on a.table_id = b.tableId and a.field_id = b.fieldId
  875. where a.site = #{site} and a.bu = #{bu} and a.classification_no = #{classificationNo} and a.node_id = #{nodeId}
  876. </select>
  877. <!-- 编辑变更单属性 -->
  878. <update id="updateStepId2" parameterType="ParamData">
  879. update ${tableName}
  880. set step_id = #{stepId}
  881. <if test='rejectFlag == "Y"'>
  882. ,reject_flag = 'Y'
  883. </if>
  884. where site = #{site} and ${fieldName1} = #{docNo}
  885. </update>
  886. <!-- 编辑变更单属性 -->
  887. <update id="updateProcessForm2" parameterType="ParamData">
  888. update plm_process_form
  889. set is_remark = 1,
  890. update_date = getDate(),
  891. update_by = #{userName}
  892. where site = #{site} and document_no = #{docNo} and is_remark = 0
  893. </update>
  894. <!-- 编辑变更单属性 -->
  895. <update id="updateChangeStatus2" parameterType="ParamData">
  896. update ${tableName}
  897. set ${fieldName2} = #{status},
  898. update_date = getDate(),
  899. update_by = #{userName},
  900. step_id = #{stepId}
  901. where site = #{site} and ${fieldName1} = #{docNo}
  902. </update>
  903. <!-- 编辑变更单的驳回标识 -->
  904. <update id="updateChangeReject2" parameterType="ParamData">
  905. update ${tableName}
  906. set reject_flag = 'Y',
  907. reject_step_id = #{rejectStepId}
  908. where site = #{site} and ${fieldName1} = #{docNo}
  909. </update>
  910. <select id="queryNodeDetailLast" parameterType="string" resultType="com.spring.modules.request.vo.PlmRequestDetailVo">
  911. SELECT
  912. step_id
  913. FROM plm_request_node
  914. where site = #{site} and classification_no = #{classificationNo} and workflow_id = #{workflowId}
  915. order by seq_no desc
  916. </select>
  917. <delete id="chooseItemDel">
  918. delete from plm_change_item
  919. where site = #{site} and change_no = #{changeNo}
  920. </delete>
  921. <delete id="chooseItemDel2">
  922. delete from plm_change_FA_item
  923. where site = #{site} and change_no = #{changeNo}
  924. </delete>
  925. <delete id="chooseItemCSDel">
  926. delete from plm_change_countersignature_item
  927. where site = #{site} and change_no = #{changeNo}
  928. </delete>
  929. <update id="updateProcessNode">
  930. update plm_process_form
  931. set node_conclusion = #{nodeConclusion},
  932. reject_opinion = #{rejectOpinion}
  933. where site = #{site} and bu = #{bu} and request_id = #{requestId} and classification_no = #{classificationNo} and node_id = #{nodeId}
  934. </update>
  935. <select id="getApprovalList" parameterType="com.spring.modules.change.vo.ProcessFormVo" resultType="com.spring.modules.change.vo.ProcessFormVo">
  936. select
  937. a.classification_no,
  938. b.node_id,
  939. b.node_name,
  940. c.reject_flag,
  941. case when c.reject_flag = 'Y' then '是' else '否' end as rejectFlagDesc,
  942. c.reject_node_id,
  943. dbo.plm_get_nodeName(a.site, c.reject_node_id, a.classification_no) as rejectNodeName,
  944. c.node_conclusion,
  945. case when c.node_conclusion = 'Y' then '同意' when c.node_conclusion = 'N' then '驳回' else '' end as nodeConclusionDesc,
  946. c.create_date,
  947. c.create_by,
  948. c.reject_opinion
  949. from plm_request_header a
  950. LEFT JOIN plm_request_node b ON a.SITE = b.SITE AND a.classification_no = b.classification_no AND a.workflow_id = b.workflow_id
  951. LEFT JOIN plm_process_form c ON b.SITE = b.SITE AND b.classification_no = c.classification_no AND b.workflow_id = c.workflow_id AND b.node_id = c.node_id and c.document_no = #{documentNo}
  952. WHERE a.site = #{site} AND a.menu_id = #{menuId}
  953. ORDER BY b.step_id ASC
  954. </select>
  955. <select id="getTechnicalSpecification" resultType="PlmTechnicalSpecificationSheetData">
  956. SELECT
  957. id,
  958. site,
  959. code_no,
  960. rev_no,
  961. ori_code_no
  962. FROM plm_technical_specification_sheet
  963. where site = #{site} and code_no = #{codeNo}
  964. </select>
  965. <update id="updatePartActive">
  966. update part
  967. set active = 'N'
  968. where site = #{site} and part_no = #{partNo}
  969. </update>
  970. <select id="getBuBySite" parameterType="Bu" resultType="Bu">
  971. SELECT
  972. id,
  973. site,
  974. bu_no,
  975. bu_desc,
  976. remark
  977. FROM BU
  978. where site = #{site} and active = 'Y'
  979. </select>
  980. </mapper>