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.

727 lines
39 KiB

2 weeks ago
2 weeks ago
2 weeks ago
10 months ago
2 weeks ago
3 months ago
3 months ago
3 months ago
3 months ago
2 weeks ago
2 weeks ago
2 weeks ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 weeks ago
10 months ago
2 weeks ago
10 months ago
2 weeks ago
6 months ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!-- namespace = 接口的全限定符 -->
  4. <mapper namespace="com.xujie.sys.modules.pms.mapper.EamProjectMapper">
  5. <insert id="saveNeweamProject">
  6. INSERT INTO plm_project_info
  7. (site,bu_no,project_no,ori_project_id,project_category,project_name,project_desc,status,project_source,customer_no,final_customer_id,priority,remark,need_date,c_project_region,project_manager,project_owner,engineer,c_quality_engineer1,c_quality_engineer2,c_quality_engineer3,c_quality_engineer4,c_quality_engineer5,c_quality_engineer6,c_manufacture_engineer,doc_engineer,ipqc_hard_tag,c_quality_engineer7,qc_engineer,pe_engineer,ee_engineer,doc_engineer2,project_creation_date,create_date,create_by)
  8. VALUES
  9. (#{site},#{buNo},#{projectNo},#{oriProjectId},#{projectCategory},#{projectName},#{projectDesc},#{status},#{projectSource},#{customerNo},#{finalCustomerId},#{priority},#{remark},#{needDate},#{cProjectRegion},#{projectManager},#{projectOwner},#{engineer},#{cQualityEngineer1},#{cQualityEngineer2},#{cQualityEngineer3},#{cQualityEngineer4},#{cQualityEngineer5},#{cQualityEngineer6},#{cManufactureEngineer},#{docEngineer},#{ipqcHardTag},#{cQualityEngineer7},#{qcEngineer},#{peEngineer},#{eeEngineer},#{docEngineer2},#{projectCreationDate},GetDATE(),#{createBy})
  10. </insert>
  11. <insert id="saveProductionValidationDocument">
  12. INSERT INTO plm_project_document_confirm_file_list
  13. (site,Order_Ref1,Order_Ref2,Item_No,document_type,document_id,Order_Ref3)
  14. VALUES
  15. (#{site},#{orderRef1},#{orderRef2},#{itemNo},#{documentType},#{documentId},#{orderRef3})
  16. </insert>
  17. <insert id="saveProductionValidationDocumentConfirmator">
  18. INSERT INTO plm_project_document_confirm
  19. (site,Order_Ref1,Order_Ref2,Item_No,document_type,userid,wanted_confirm_date,confirm_flag,confirmed_by,confirmed_date,create_date,create_by)
  20. VALUES
  21. (#{site},#{orderRef1},#{orderRef2},#{itemNo},'产品文档',#{userid},#{wantedConfirmDate},'N',#{confirmedBy},#{confirmedDate},GETDATE(),#{createBy})
  22. </insert>
  23. <update id="eamProjectEdit">
  24. UPDATE plm_project_info
  25. SET project_no = #{projectNo},project_category = #{projectCategory},project_name =
  26. #{projectName},project_desc = #{projectDesc},status = #{status},project_source =
  27. #{projectSource},customer_no = #{customerNo},priority = #{priority},remark = #{remark},need_date =
  28. #{needDate},c_project_region = #{cProjectRegion},project_manager = #{projectManager},project_owner =
  29. #{projectOwner},engineer = #{engineer},c_quality_engineer1 = #{cQualityEngineer1},c_quality_engineer2 =
  30. #{cQualityEngineer2},c_quality_engineer3 = #{cQualityEngineer3},c_quality_engineer4 =
  31. #{cQualityEngineer4},c_quality_engineer5 = #{cQualityEngineer5},c_quality_engineer6 =
  32. #{cQualityEngineer6},c_manufacture_engineer = #{cManufactureEngineer},doc_engineer =
  33. #{docEngineer},ipqc_hard_tag = #{ipqcHardTag},c_quality_engineer7 = #{cQualityEngineer7},qc_engineer = #{qcEngineer},pe_engineer = #{peEngineer},ee_engineer = #{eeEngineer},update_date =
  34. GETDATE(),update_by = #{updateBy},project_creation_date = #{projectCreationDate},doc_engineer2 = #{docEngineer2}
  35. ,project_close_date =
  36. CASE
  37. WHEN #{projectCloseDate} IS NOT NULL THEN CONVERT(date, #{projectCloseDate})
  38. ELSE project_close_date
  39. END
  40. WHERE site = #{site} and id = #{projectId}
  41. </update>
  42. <update id="saveFormalPartNo">
  43. UPDATE plm_project_part
  44. SET final_part_no = #{finalPartNo} ,final_part_desc = #{finalPartDesc}
  45. WHERE site = #{site} and project_id = #{projectId} and id = #{projectPartId}
  46. </update>
  47. <update id="updateProjectDocumentConfirm">
  48. UPDATE plm_project_document_confirm
  49. SET confirm_flag = 'Y',confirmed_by = #{confirmedBy},confirmed_date = #{confirmedDate},remark = #{remark}
  50. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2} and document_type = '产品文档' and Item_No = #{itemNo} and userid = #{userid}
  51. </update>
  52. <select id="countNotConfirmedProjectDocument" resultType="java.lang.Integer">
  53. SELECT COUNT(1)
  54. FROM plm_project_document_confirm
  55. WHERE site = #{site}
  56. and Order_Ref1 = #{orderRef1}
  57. and Order_Ref2 = #{orderRef2}
  58. and document_type = '产品文档'
  59. and ISNULL(confirm_flag, 'N') &lt;&gt; 'Y'
  60. </select>
  61. <update id="updateProjectPartStatusToFormal">
  62. UPDATE plm_project_part
  63. SET status = N'正式量产',
  64. update_date = GETDATE()
  65. WHERE site = #{site}
  66. and project_id = #{orderRef1}
  67. and id = #{orderRef2}
  68. </update>
  69. <delete id="eamProjectDelete">
  70. DELETE FROM plm_project_info
  71. WHERE id = #{projectId}
  72. </delete>
  73. <delete id="eamProjectPartDelete">
  74. DELETE FROM plm_project_part
  75. WHERE site = #{site} and project_id = #{projectId} and test_part_no = #{testPartNo}
  76. </delete>
  77. <delete id="deleteDocumentInformation">
  78. DELETE FROM plm_project_document_confirm_file_list
  79. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
  80. </delete>
  81. <delete id="deleteConfirmationRecord">
  82. DELETE FROM plm_project_document_confirm
  83. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and document_type = '产品文档' and Order_Ref2 = #{orderRef2}
  84. </delete>
  85. <delete id="deleteSysoss">
  86. delete from CKT_MES_II_REAL.dbo.sys_oss
  87. where order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2} and order_ref4 = #{orderRef4} and order_ref5 = #{orderRef5}
  88. </delete>
  89. <delete id="eamProjectPartInfoDelete">
  90. DELETE FROM plm_project_part
  91. WHERE id = #{projectPartId}
  92. </delete>
  93. <delete id="deleteConfirmatory">
  94. DELETE FROM plm_document_toconfirm_user
  95. WHERE site = #{site} and BU = #{buNo} and document_type = '产品文档' and userid = #{userid}
  96. </delete>
  97. <select id="eamProjectSearch" parameterType="com.xujie.sys.modules.pms.data.EamProjectInfoData" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  98. SELECT
  99. a.id as project_id,a.site,a.bu_no,d.bu_desc,a.project_no,a.project_category,a.project_name, a.project_desc,a.status, a.project_source, a.customer_no, a.final_customer_id, a.priority,a.engineer,
  100. a.remark,a.need_date,a.c_project_region,a.project_manager,a.project_owner,a.c_project_build_date,a.c_quality_engineer1,a.c_quality_engineer2,a.c_quality_engineer3,a.c_quality_engineer4,a.c_quality_engineer5,a.c_quality_engineer6,
  101. a.c_manufacture_engineer,a.doc_engineer,a.doc_engineer2,a.ipqc_hard_tag,A.c_quality_engineer7,a.qc_engineer,a.pe_engineer,a.ee_engineer,a.project_close_date,a.project_creation_date,a.create_date,a.create_by,a.update_date,a.update_by,c.customer_desc, CKT_MES_II_REAL.dbo.plm_get_customer_desc(a.site,a.final_customer_id) as final_customer_name
  102. FROM plm_project_info as a
  103. LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and a.site = c.site
  104. left join CKT_MES_II_REAL.dbo.BU as d on a.site = d.site and a.bu_no = d.bu_no
  105. <where>
  106. a.site in (select site from eam_access_site where username = #{query.userName})
  107. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  108. <if test="query.projectId != null and query.projectId != ''">
  109. AND (
  110. a.id = #{query.projectId}
  111. OR a.id IN (
  112. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectId}, ',')
  113. )
  114. )
  115. </if>
  116. <if test="query.projectNo != null and query.projectNo != ''">
  117. AND (
  118. UPPER(a.project_no) LIKE '%' + UPPER(#{query.projectNo}) + '%'
  119. OR a.project_no IN (
  120. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  121. )
  122. )
  123. </if>
  124. <if test="query.projectDesc != null and query.projectDesc != ''">
  125. and UPPER(a.project_desc) like '%' + UPPER(#{query.projectDesc}) + '%'
  126. </if>
  127. <if test="query.customerNo != null and query.customerNo != ''">
  128. and UPPER(a.customer_no) like '%' + UPPER(#{query.customerNo}) + '%'
  129. </if>
  130. <if test="query.customerDesc != null and query.customerDesc != ''">
  131. and UPPER(c.customer_desc) like '%' + UPPER(#{query.customerDesc}) + '%'
  132. </if>
  133. <if test="query.buDesc != null and query.buDesc != ''">
  134. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  135. </if>
  136. <if test="query.projectCategory != null and query.projectCategory != ''">
  137. and a.project_category = #{query.projectCategory}
  138. </if>
  139. <if test="query.status != null and query.status != ''">
  140. and a.status = #{query.status}
  141. </if>
  142. <if test="query.projectManager != null and query.projectManager != ''">
  143. and a.project_manager = #{query.projectManager}
  144. </if>
  145. <if test="query.projectOwner != null and query.projectOwner != ''">
  146. and a.project_owner = #{query.projectOwner}
  147. </if>
  148. <if test="query.engineer != null and query.engineer != ''">
  149. and a.engineer = #{query.engineer}
  150. </if>
  151. <if test="query.cProjectRegion != null and query.cProjectRegion != ''">
  152. and a.c_project_region = #{query.cProjectRegion}
  153. </if>
  154. <if test="query.startDate != null ">
  155. AND a.project_creation_date >= #{query.startDate}
  156. </if>
  157. <if test="query.endDate != null ">
  158. AND #{query.endDate} >= a.project_creation_date
  159. </if>
  160. </where>
  161. order by a.id desc
  162. </select>
  163. <select id="queryEamProjectInfo" parameterType="com.xujie.sys.modules.pms.data.EamProjectInfoData" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  164. SELECT
  165. a.id as project_id,a.site,a.bu_no,d.bu_desc,a.project_no,a.project_category,a.project_name, a.project_desc,a.status, a.project_source, a.customer_no, a.final_customer_id, a.priority,a.engineer,
  166. a.remark,a.need_date,a.c_project_region,a.project_manager,a.project_owner,a.c_project_build_date,a.c_quality_engineer1,a.c_quality_engineer2,a.c_quality_engineer3,a.c_quality_engineer4,a.c_quality_engineer5,a.c_quality_engineer6,
  167. a.c_manufacture_engineer,a.doc_engineer,a.doc_engineer2,a.ipqc_hard_tag,a.c_quality_engineer7,a.qc_engineer,a.pe_engineer,a.ee_engineer,a.project_close_date,a.project_creation_date,a.create_date,a.create_by,a.update_date,a.update_by,c.customer_desc, CKT_MES_II_REAL.dbo.plm_get_customer_desc(a.site,a.final_customer_id) as final_customer_name
  168. FROM plm_project_info as a
  169. LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and a.site = c.site
  170. left join CKT_MES_II_REAL.dbo.BU as d on a.site = d.site and a.bu_no = d.bu_no
  171. <where>
  172. a.site in (select site from eam_access_site where username = #{params.userName})
  173. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{params.userName}))
  174. <if test="params.sql != null and params.sql != ''">
  175. ${params.sql}
  176. </if>
  177. </where>
  178. order by a.id desc
  179. </select>
  180. <select id="checkeamProject" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  181. SELECT
  182. a.site,a.bu_no,a.id as project_id,a.project_category, a.project_name, a.project_desc,a.status, a.project_source, a.customer_no, a.priority,
  183. a.remark,a.need_date,a.c_project_region,a.project_manager,a.project_owner,a.c_project_build_date,a.c_quality_engineer1,a.c_quality_engineer2,a.c_quality_engineer3,a.c_quality_engineer4,a.c_quality_engineer5,a.c_quality_engineer6,
  184. a.c_manufacture_engineer,a.doc_engineer,a.doc_engineer2,a.ipqc_hard_tag,a.c_quality_engineer7,a.qc_engineer,a.pe_engineer,a.ee_engineer,a.project_close_date,a.project_creation_date,a.create_date,a.create_by,a.update_date,a.update_by,b.test_part_no,b.part_desc
  185. FROM plm_project_info as a
  186. LEFT JOIN plm_project_part as b ON a.id = b.project_id
  187. WHERE a.project_no = #{projectNo} and a.site = #{site} and a.bu_no = #{buNo}
  188. </select>
  189. <select id="getCustomerNo" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  190. SELECT
  191. customer_no,
  192. customer_desc,
  193. active
  194. FROM
  195. plm_customer_information AS a
  196. where site = #{site} and active = 'Y'
  197. ORDER BY customer_no DESC
  198. </select>
  199. <insert id="saveNewCustomer">
  200. INSERT INTO plm_customer_information
  201. (site,customer_no,customer_desc,create_date,create_by,active)
  202. VALUES
  203. (#{site},#{customerNo},#{customerDesc},GETDATE(),#{createBy},'Y')
  204. </insert>
  205. <select id="checkProjectDelete" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  206. SELECT
  207. a.project_id,
  208. a.id as project_part_id,
  209. a.test_part_no
  210. FROM plm_project_part as a
  211. LEFT JOIN plm_project_info as b ON a.project_id = b.id
  212. WHERE a.project_id = #{projectId}
  213. </select>
  214. <select id="searchConfirmatorList" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  215. SELECT
  216. a.userid,
  217. b.username,
  218. b.user_display
  219. FROM plm_document_toconfirm_user as a
  220. LEFT JOIN CKT_MES_II_REAL.dbo.sys_user as b ON a.userid = b.user_id
  221. WHERE a.BU = #{query.buNo} and a.Site = #{query.site} and a.document_type = '产品文档'
  222. </select>
  223. <select id="searchNotConfirmatorList" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  224. SELECT
  225. a.site,
  226. a.bu_no,
  227. a.username,
  228. s.user_id,
  229. s.user_display
  230. FROM
  231. AccessBu a
  232. LEFT JOIN sys_user s ON a.username = s.username
  233. AND a.site = s.site
  234. LEFT JOIN plm_document_toconfirm_user b ON s.user_id = b.userid
  235. AND b.Site = s.site
  236. AND b.BU = a.bu_no
  237. AND b.document_type = '产品文档'
  238. <where>
  239. AND s.user_id IS NOT NULL
  240. AND b.userid IS NULL
  241. <if test="query.username != null and query.username != ''">
  242. AND s.username like #{query.username}
  243. </if>
  244. <if test="query.userDisplay != null and query.userDisplay != ''">
  245. AND s.user_display like #{query.userDisplay}
  246. </if>
  247. </where>
  248. </select>
  249. <select id="checkProductionValidationDocument"
  250. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  251. SELECT *
  252. FROM plm_project_document_confirm_file_list
  253. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
  254. </select>
  255. <select id="checkProductionValidationDocumentAll"
  256. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  257. SELECT *
  258. FROM plm_project_document_confirm_file_list
  259. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
  260. </select>
  261. <select id="checkProductionValidationDocumentConfirmator"
  262. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  263. SELECT *
  264. FROM plm_project_document_confirm
  265. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2} and document_type = '产品文档' and Item_No = #{itemNo} and userid = #{userid}
  266. </select>
  267. <select id="searchConfirmProgressDocumentList"
  268. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  269. SELECT a.Item_No,
  270. a.document_type,
  271. (case when a.order_ref3 = '-2' then c.sop_name ELSE b.file_name END) as file_name,
  272. a.document_id,
  273. a.site,
  274. a.Order_Ref1 AS project_id,
  275. a.order_ref3 AS document_definition_list_id,
  276. b.created_by
  277. FROM
  278. plm_project_document_confirm_file_list AS a
  279. LEFT JOIN sys_oss AS b ON a.document_id = b.id
  280. LEFT JOIN part_sop AS c ON a.document_id = c.id
  281. WHERE a.Site = #{query.site} and a.Order_Ref1 = #{query.orderRef1} and a.Order_Ref2 = #{query.orderRef2}
  282. ORDER BY a.Item_No
  283. </select>
  284. <select id="searchConfirmProgressPusherList"
  285. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  286. SELECT a.*,b.user_display,b.username
  287. FROM plm_project_document_confirm as a
  288. LEFT JOIN sys_user as b ON a.userid = b.user_id
  289. WHERE a.site = #{query.site} and a.Order_Ref1 = #{query.orderRef1} and a.document_type = '产品文档' and a.Order_Ref2 = #{query.orderRef2}
  290. </select>
  291. <select id="searchProjectConfirmatorFileList"
  292. resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
  293. SELECT a.*
  294. FROM sys_oss as a
  295. <where>
  296. <if test="query.id != null and query.id != ''">
  297. a.id = CAST(#{query.id} AS INT)
  298. </if>
  299. <if test="query.id == null or query.id == ''">
  300. a.order_ref1 = #{query.orderRef1} and a.order_ref4 = #{query.orderRef4} and a.order_ref2 = #{query.orderRef2} and a.order_ref3 = #{query.orderRef3} and a.order_ref5 = #{query.orderRef5}
  301. <if test="query.createdBy != null and query.createdBy != ''">
  302. and a.created_by = #{query.createdBy}
  303. </if>
  304. <if test="query.cAdditionalInfo != null and query.cAdditionalInfo != ''">
  305. and a.c_additional_info = #{query.cAdditionalInfo}
  306. </if>
  307. <if test="query.fileName != null and query.fileName != ''">
  308. and a.file_name = #{query.fileName}
  309. </if>
  310. </if>
  311. </where>
  312. </select>
  313. <select id="getMaxItemNo2" resultType="java.lang.Integer">
  314. SELECT COALESCE(MAX(Item_No), 0) AS maxItemNo
  315. FROM plm_project_document_confirm_file_list
  316. WHERE site = #{site} AND Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
  317. </select>
  318. <select id="checkConfirmationRecord"
  319. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  320. SELECT a.*
  321. FROM plm_project_document_confirm as a
  322. WHERE a.site = #{site} and a.Order_Ref1 = #{orderRef1} and a.document_type = '产品文档' and a.Order_Ref2 = #{orderRef2}
  323. </select>
  324. <!-- SELECT-->
  325. <!-- (SELECT TOP 1 proofing_no FROM plm_proofing_information WHERE project_id = ppi.project_id and test_part_id = ppi.id) AS proofing_no,-->
  326. <!-- ppi.id AS project_part_id,-->
  327. <!-- ppi.project_id,-->
  328. <!-- STUFF(-->
  329. <!-- COALESCE(-->
  330. <!-- CASE WHEN pu1.email IS NOT NULL AND pu1.email != '' THEN ';' + pu1.email ELSE '' END +-->
  331. <!-- CASE WHEN pu2.email IS NOT NULL AND pu2.email != '' THEN ';' + pu2.email ELSE '' END +-->
  332. <!-- CASE WHEN pu3.email IS NOT NULL AND pu3.email != '' THEN ';' + pu3.email ELSE '' END +-->
  333. <!-- CASE WHEN pu4.email IS NOT NULL AND pu4.email != '' THEN ';' + pu4.email ELSE '' END +-->
  334. <!-- CASE WHEN pu5.email IS NOT NULL AND pu5.email != '' THEN ';' + pu5.email ELSE '' END +-->
  335. <!-- CASE WHEN pu6.email IS NOT NULL AND pu6.email != '' THEN ';' + pu6.email ELSE '' END,-->
  336. <!-- ''-->
  337. <!-- ),-->
  338. <!-- 1, 1, ''-->
  339. <!-- ) AS email-->
  340. <!-- FROM-->
  341. <!-- plm_project_part ppi-->
  342. <!-- LEFT JOIN sys_user pu1 ON LEFT ( ppi.c_quality_engineer1, CHARINDEX( '-', ppi.c_quality_engineer1 ) - 1 ) = pu1.username-->
  343. <!-- LEFT JOIN sys_user pu2 ON LEFT ( ppi.c_quality_engineer2, CHARINDEX( '-', ppi.c_quality_engineer2 ) - 1 ) = pu2.username-->
  344. <!-- LEFT JOIN sys_user pu3 ON LEFT ( ppi.c_quality_engineer3, CHARINDEX( '-', ppi.c_quality_engineer3 ) - 1 ) = pu3.username-->
  345. <!-- LEFT JOIN sys_user pu7 ON LEFT ( ppi.c_quality_engineer4, CHARINDEX( '-', ppi.c_quality_engineer4 ) - 1 ) = pu7.username-->
  346. <!-- LEFT JOIN sys_user pu4 ON LEFT ( ppi.c_manufacture_engineer, CHARINDEX( '-', ppi.c_manufacture_engineer ) - 1 ) = pu4.username-->
  347. <!-- LEFT JOIN sys_user pu5 ON LEFT ( ppi.engineer, CHARINDEX( '-', ppi.engineer ) - 1 ) = pu5.username-->
  348. <!-- LEFT JOIN sys_user pu6 ON LEFT ( ppi.doc_engineer, CHARINDEX( '-', ppi.doc_engineer ) - 1 ) = pu6.username-->
  349. <!-- WHERE-->
  350. <!-- ppi.id = #{projectPartId}-->
  351. <select id="getSendMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  352. {call plm_get_to_email_list_proofing(
  353. #{site, mode=IN, jdbcType=VARCHAR},
  354. #{projectId, mode=IN, jdbcType=INTEGER},
  355. #{projectPartId, mode=IN, jdbcType=INTEGER},
  356. #{proofingId, mode=IN, jdbcType=INTEGER})}
  357. </select>
  358. <select id="getSendMassProductionMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  359. {call plm_get_to_email_list_MassProd(
  360. #{site, mode=IN, jdbcType=VARCHAR},
  361. #{projectId, mode=IN, jdbcType=INTEGER},
  362. #{projectPartId, mode=IN, jdbcType=INTEGER})}
  363. </select>
  364. <select id="getAutoSendMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  365. {call plm_get_to_email_list_AlertMessage(
  366. #{site, mode=IN, jdbcType=VARCHAR})}
  367. </select>
  368. <select id="getRoleDescByNo" resultType="com.xujie.sys.modules.factory.entity.vo.BusinessRoleVo">
  369. SELECT
  370. role_desc
  371. FROM business_role
  372. WHERE role_no = #{roleNo}
  373. </select>
  374. <select id="getWarnSendMailAddress" parameterType="map" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  375. SELECT
  376. ppp.project_id,
  377. ppp.test_part_no,
  378. pu.email
  379. FROM
  380. plm_project_part ppp
  381. LEFT JOIN sys_user pu ON LEFT ( ppp.${type}, CHARINDEX( '-', ppp.${type} ) - 1 ) = pu.username
  382. WHERE
  383. ppp.project_id = #{query.projectId} and ppp.site = #{query.site} and ppp.id = #{query.projectPartId}
  384. </select>
  385. <select id="getConfirmatorSendMailAddress" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  386. SELECT DISTINCT
  387. a.Order_Ref1 as project_id,
  388. a.Order_Ref2 as project_part_id,
  389. STUFF((SELECT DISTINCT '; ' + b.email
  390. FROM plm_project_document_confirm as c
  391. LEFT JOIN sys_user as b ON c.userid = b.user_id
  392. WHERE c.Site = #{site} and c.Order_Ref1 = #{projectId} and c.Order_Ref2 = #{projectPartId}
  393. FOR XML PATH('')), 1, 2, '') as email
  394. FROM plm_project_document_confirm as a
  395. WHERE a.Site = #{site} and a.Order_Ref1 = #{projectId} and a.Order_Ref2 = #{projectPartId}
  396. </select>
  397. <select id="searchProjectAllDocumentTask" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  398. {call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{projectPartId,mode=IN}, #{proofingId, mode=IN})}
  399. </select>
  400. <select id="queryEmailByCreateUser" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  401. SELECT
  402. a.project_id,
  403. a.proofing_no,
  404. a.create_by,
  405. b.email
  406. FROM plm_proofing_information as a
  407. LEFT JOIN sys_user as b ON a.create_by = b.username
  408. WHERE a.site = #{site} and a.project_id = #{projectId} and a.id = #{proofingId} and a.test_part_id = #{projectPartId}
  409. </select>
  410. <select id="checkProjectPartInfo" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  411. SELECT
  412. *
  413. from plm_project_part
  414. WHERE project_id = #{projectId}
  415. </select>
  416. <select id="checkeamProjectId" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  417. SELECT
  418. a.project_no
  419. FROM plm_project_info as a
  420. WHERE a.id = #{projectId}
  421. </select>
  422. <select id="eamProjectPartSearch" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  423. SELECT
  424. a.*,
  425. a.id as projectPartId,
  426. b.project_no,
  427. b.project_desc,
  428. b.bu_no,
  429. b.c_project_region,
  430. c.customer_desc,
  431. d.bu_desc
  432. FROM plm_project_part as a
  433. LEFT JOIN plm_project_info as b ON a.project_id = b.id
  434. LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and a.site = c.site
  435. left join CKT_MES_II_REAL.dbo.BU as d on b.site = d.site and b.bu_no = d.bu_no
  436. <where>
  437. b.site in (select site from eam_access_site where username = #{query.userName})
  438. and (b.site + '-' + b.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  439. <if test="query.projectId != null and query.projectId != ''">
  440. AND (
  441. a.project_id = #{query.projectId}
  442. OR a.project_id IN (
  443. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectId}, ',')
  444. )
  445. )
  446. </if>
  447. <if test="query.feedingFlag != null and query.feedingFlag == 1 ">
  448. and (
  449. select count(*) from plm_proofing_information ppi
  450. where ppi.project_id = a.project_id and ppi.test_part_id = a.id
  451. ) > 0
  452. </if>
  453. <if test="query.feedingFlag != null and query.feedingFlag == 2 ">
  454. and (
  455. select count(*) from plm_proofing_information ppi
  456. where ppi.project_id = a.project_id and ppi.test_part_id = a.id
  457. ) = 0
  458. </if>
  459. <if test="query.projectNo != null and query.projectNo != ''">
  460. AND
  461. (UPPER(b.project_no) like '%' + UPPER(#{query.projectNo}) + '%' OR b.project_no IN (SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')))
  462. </if>
  463. <if test="query.projectDesc != null and query.projectDesc != ''">
  464. and UPPER(b.project_desc) like '%' + UPPER(#{query.projectDesc}) + '%'
  465. </if>
  466. <if test="query.projectPartId != null and query.projectPartId != ''">
  467. and a.id = #{query.projectPartId}
  468. </if>
  469. <if test="query.testPartNo != null and query.testPartNo != ''">
  470. AND (
  471. UPPER(a.test_part_no) like '%' + UPPER(#{query.testPartNo}) + '%'
  472. OR a.test_part_no IN (
  473. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  474. )
  475. )
  476. </if>
  477. <if test="query.partDesc != null and query.partDesc != ''">
  478. and UPPER(a.part_desc) like '%' + UPPER(#{query.partDesc}) + '%'
  479. </if>
  480. <if test="query.customerNo != null and query.customerNo != ''">
  481. and UPPER(a.customer_no) like '%' + UPPER(#{query.customerNo}) + '%'
  482. </if>
  483. <if test="query.customerDesc != null and query.customerDesc != ''">
  484. and UPPER(c.customer_desc) like '%' + UPPER(#{query.customerDesc}) + '%'
  485. </if>
  486. <if test="query.buDesc != null and query.buDesc != ''">
  487. AND dbo.get_bu_desc ( b.site, b.bu_no ) = #{query.buDesc}
  488. </if>
  489. <if test="query.projectCategory != null and query.projectCategory != ''">
  490. and a.project_category = #{query.projectCategory}
  491. </if>
  492. <if test="query.status != null and query.status != ''">
  493. and a.status = #{query.status}
  494. </if>
  495. <if test="query.projectManager != null and query.projectManager != ''">
  496. and a.project_manager = #{query.projectManager}
  497. </if>
  498. <if test="query.projectOwner != null and query.projectOwner != ''">
  499. and a.project_owner = #{query.projectOwner}
  500. </if>
  501. <if test="query.engineer != null and query.engineer != ''">
  502. and a.engineer = #{query.engineer}
  503. </if>
  504. <if test="query.cProjectRegion != null and query.cProjectRegion != ''">
  505. and b.c_project_region = #{query.cProjectRegion}
  506. </if>
  507. <if test="query.finalPartNo != null and query.finalPartNo != ''">
  508. and a.final_part_no = #{query.finalPartNo}
  509. </if>
  510. <if test="query.startDate != null ">
  511. AND a.build_date >= #{query.startDate}
  512. </if>
  513. <if test="query.endDate != null ">
  514. AND #{query.endDate} >= a.build_date
  515. </if>
  516. <if test="query.massProductionStartDate != null ">
  517. AND a.close_date >= #{query.massProductionStartDate}
  518. </if>
  519. <if test="query.massProductionEndDate != null ">
  520. AND #{query.massProductionEndDate} >= a.close_date
  521. </if>
  522. </where>
  523. order by a.id desc
  524. </select>
  525. <select id="queryEamProjectPart" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  526. SELECT
  527. a.*,
  528. a.id as projectPartId,
  529. b.project_no,
  530. b.project_desc,
  531. b.bu_no,
  532. a.customer_no,
  533. b.c_project_region,
  534. c.customer_desc,
  535. d.bu_desc
  536. FROM plm_project_part as a
  537. LEFT JOIN plm_project_info as b ON a.project_id = b.id
  538. LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and b.site = c.site
  539. left join CKT_MES_II_REAL.dbo.BU as d on b.site = d.site and b.bu_no = d.bu_no
  540. <where>
  541. <if test="params.sql != null and params.sql != ''">
  542. ${params.sql}
  543. </if>
  544. </where>
  545. order by a.id desc
  546. </select>
  547. <select id="checkProjectPartNo" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  548. SELECT
  549. a.test_part_no
  550. FROM plm_project_part as a
  551. WHERE a.site = #{site} and a.project_id = #{projectId} and a.test_part_no = #{testPartNo} and a.id != (case when #{projectPartId} is null then '' else #{projectPartId} end)
  552. </select>
  553. <select id="checkProjectPartProofing" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  554. SELECT * from plm_proofing_information
  555. WHERE project_id = #{projectId} and test_part_id = #{projectPartId}
  556. </select>
  557. <select id="getSiteByBu" resultType="String">
  558. select top 1 site from BU where bu_no=#{buNo}
  559. </select>
  560. <select id="getFinalPartDesc" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  561. EXEC dbo.sp_plm_get_final_part_desc #{site}, #{buNo}, #{finalPartNo}
  562. </select>
  563. <select id="getEmailAddressByUsername" resultType="string">
  564. SELECT
  565. email
  566. FROM
  567. sys_user
  568. WHERE
  569. username = #{username}
  570. </select>
  571. <select id="checkConfirmatory" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  572. SELECT
  573. *
  574. FROM plm_document_toconfirm_user as a
  575. WHERE a.BU = #{buNo} and a.Site = #{site} and a.document_type = '产品文档' and a.userid = #{userid}
  576. </select>
  577. <select id="searchSopFileList" resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
  578. SELECT a.sop_name + '.' + SUBSTRING(sop_url, CHARINDEX('.', sop_url) + 1, LEN(sop_url)) as file_name,
  579. a.creation_date as create_date,
  580. a.created_by as created_by,
  581. a.sop_url as url,
  582. a.id,
  583. '-2' as order_ref3,
  584. SUBSTRING(a.sop_url, CHARINDEX('.', a.sop_url) + 1, LEN(a.sop_url)) as file_type
  585. FROM part_sop as a
  586. <where>
  587. <if test="query.id != null and query.id != ''">
  588. a.id = CAST(#{query.id} AS INT)
  589. </if>
  590. <if test="query.id == null or query.id == ''">
  591. a.order_ref1 = #{query.orderRef1} and a.order_ref4 = #{query.orderRef4} and a.order_ref2 = #{query.orderRef2} and a.order_ref3 = #{query.orderRef3} and a.order_ref5 = #{query.orderRef5}
  592. <if test="query.createdBy != null and query.createdBy != ''">
  593. and a.created_by = #{query.createdBy}
  594. </if>
  595. <if test="query.cAdditionalInfo != null and query.cAdditionalInfo != ''">
  596. and a.c_additional_info = #{query.cAdditionalInfo}
  597. </if>
  598. <if test="query.fileName != null and query.fileName != ''">
  599. and a.file_name = #{query.fileName}
  600. </if>
  601. </if>
  602. </where>
  603. </select>
  604. <select id="getEmailsByUsernames" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  605. SELECT email
  606. FROM sys_user
  607. WHERE site = #{site}
  608. AND username IN
  609. <foreach item="username" collection="usernames" open="(" separator="," close=")">
  610. #{username}
  611. </foreach>
  612. </select>
  613. <select id="searchMassProductionBomList"
  614. resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  615. {call dbo.plm_get_part_fullBOM(#{data.site, mode=IN}, #{data.projectId, mode=IN}, #{data.projectPartId, mode=IN})}
  616. </select>
  617. <select id="searchRoutingList" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  618. {call dbo.rfq_get_fullRouting(#{data.site, mode=IN}, #{data.partNo, mode=IN})}
  619. </select>
  620. <select id="searchMassProductionBomListTX"
  621. resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  622. {call dbo.plm_get_part_fullBOM_TX(#{data.site, mode=IN}, #{data.projectId, mode=IN}, #{data.projectPartId, mode=IN})}
  623. </select>
  624. <select id="searchRoutingListTX" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  625. {call dbo.rfq_get_fullRouting_TX(#{data.site, mode=IN}, #{data.partNo, mode=IN})}
  626. </select>
  627. <select id="searchSysOssFileList" resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
  628. select * from sys_oss where file_name = #{fileName}
  629. </select>
  630. <insert id="saveNewProjectPart" useGeneratedKeys="true" keyProperty="projectPartId">
  631. INSERT INTO plm_project_part (
  632. site,
  633. project_id,
  634. test_part_no,
  635. part_desc,
  636. create_date,
  637. create_by,
  638. final_part_no,
  639. project_manager,
  640. project_owner,
  641. build_date,
  642. c_quality_engineer1,
  643. c_quality_engineer2,
  644. c_quality_engineer3,
  645. c_quality_engineer4,
  646. c_quality_engineer5,
  647. c_quality_engineer6,
  648. c_manufacture_engineer,
  649. doc_engineer,
  650. doc_engineer2,
  651. engineer,
  652. ipqc_hard_tag,
  653. c_quality_engineer7,
  654. qc_engineer,
  655. pe_engineer,
  656. ee_engineer,
  657. status,
  658. part_type,
  659. priority,
  660. project_category,
  661. need_date,
  662. customer_no,
  663. remark
  664. ) VALUES (
  665. #{site},
  666. #{projectId},
  667. #{testPartNo},
  668. #{partDesc},
  669. getdate(),
  670. #{createBy},
  671. #{finalPartNo},
  672. #{projectManager},
  673. #{projectOwner},
  674. #{buildDate},
  675. #{cQualityEngineer1},
  676. #{cQualityEngineer2},
  677. #{cQualityEngineer3},
  678. #{cQualityEngineer4},
  679. #{cQualityEngineer5},
  680. #{cQualityEngineer6},
  681. #{cManufactureEngineer},
  682. #{docEngineer},
  683. #{docEngineer2},
  684. #{engineer},
  685. #{ipqcHardTag},
  686. #{cQualityEngineer7},
  687. #{qcEngineer},
  688. #{peEngineer},
  689. #{eeEngineer},
  690. #{status},
  691. #{partType},
  692. #{priority},
  693. #{projectCategory},
  694. #{needDate},
  695. #{customerNo},
  696. #{remark}
  697. );
  698. </insert>
  699. <insert id="addConfirmatory">
  700. INSERT INTO plm_document_toconfirm_user
  701. (site,BU,document_type,userid,create_date,create_by)
  702. VALUES
  703. (#{site},#{buNo},'产品文档',#{userid},GETDATE(),#{createBy})
  704. </insert>
  705. <update id="eamProjectPartInfoEdit">
  706. UPDATE plm_project_part
  707. SET test_part_no = #{testPartNo},part_desc = #{partDesc},update_date = GETDATE(),update_by = #{updateBy},
  708. build_date = #{buildDate}, priority = #{priority}, project_category = #{projectCategory}, need_date =
  709. #{needDate}, project_manager = #{projectManager}, project_owner = #{projectOwner}, engineer = #{engineer}, c_quality_engineer1 = #{cQualityEngineer1}, c_quality_engineer2 = #{cQualityEngineer2}, c_quality_engineer3 = #{cQualityEngineer3}, c_quality_engineer4 = #{cQualityEngineer4}, c_quality_engineer5 = #{cQualityEngineer5}, c_quality_engineer6 = #{cQualityEngineer6}, c_manufacture_engineer = #{cManufactureEngineer},doc_engineer = #{docEngineer},doc_engineer2 = #{docEngineer2},ipqc_hard_tag = #{ipqcHardTag},
  710. c_quality_engineer7 = #{cQualityEngineer7},qc_engineer = #{qcEngineer},pe_engineer = #{peEngineer},ee_engineer = #{eeEngineer},remark = #{remark},
  711. status = CASE WHEN #{status} IS NOT NULL THEN #{status} ELSE status END,customer_no = #{customerNo},
  712. part_type = CASE WHEN #{partType} IS NOT NULL THEN #{partType} ELSE part_type END,
  713. close_date = (CASE
  714. WHEN #{closeDate} IS NULL THEN ISNULL(close_date, NULL)
  715. ELSE CONVERT(DATE, #{closeDate})
  716. END)
  717. WHERE id = #{projectPartId}
  718. </update>
  719. </mapper>