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

711 lines
38 KiB

7 months ago
10 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
10 months ago
10 months ago
10 months 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,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},#{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},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.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.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.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. a.site = #{query.site}
  240. AND a.bu_no = #{query.buNo}
  241. AND s.user_id IS NOT NULL
  242. AND b.userid IS NULL
  243. <if test="query.username != null and query.username != ''">
  244. AND s.username like #{query.username}
  245. </if>
  246. <if test="query.userDisplay != null and query.userDisplay != ''">
  247. AND s.user_display like #{query.userDisplay}
  248. </if>
  249. </where>
  250. </select>
  251. <select id="checkProductionValidationDocument"
  252. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  253. SELECT *
  254. FROM plm_project_document_confirm_file_list
  255. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
  256. </select>
  257. <select id="checkProductionValidationDocumentAll"
  258. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  259. SELECT *
  260. FROM plm_project_document_confirm_file_list
  261. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
  262. </select>
  263. <select id="checkProductionValidationDocumentConfirmator"
  264. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  265. SELECT *
  266. FROM plm_project_document_confirm
  267. WHERE site = #{site} and Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2} and document_type = '产品文档' and Item_No = #{itemNo} and userid = #{userid}
  268. </select>
  269. <select id="searchConfirmProgressDocumentList"
  270. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  271. SELECT a.Item_No,
  272. a.document_type,
  273. (case when a.order_ref3 = '-2' then c.sop_name ELSE b.file_name END) as file_name,
  274. a.document_id,
  275. a.site,
  276. a.Order_Ref1 AS project_id,
  277. a.order_ref3 AS document_definition_list_id,
  278. b.created_by
  279. FROM
  280. plm_project_document_confirm_file_list AS a
  281. LEFT JOIN sys_oss AS b ON a.document_id = b.id
  282. LEFT JOIN part_sop AS c ON a.document_id = c.id
  283. WHERE a.Site = #{query.site} and a.Order_Ref1 = #{query.orderRef1} and a.Order_Ref2 = #{query.orderRef2}
  284. ORDER BY a.Item_No
  285. </select>
  286. <select id="searchConfirmProgressPusherList"
  287. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  288. SELECT a.*,b.user_display,b.username
  289. FROM plm_project_document_confirm as a
  290. LEFT JOIN sys_user as b ON a.userid = b.user_id
  291. WHERE a.site = #{query.site} and a.Order_Ref1 = #{query.orderRef1} and a.document_type = '产品文档' and a.Order_Ref2 = #{query.orderRef2}
  292. </select>
  293. <select id="searchProjectConfirmatorFileList"
  294. resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
  295. SELECT a.*
  296. FROM sys_oss as a
  297. <where>
  298. <if test="query.id != null and query.id != ''">
  299. a.id = CAST(#{query.id} AS INT)
  300. </if>
  301. <if test="query.id == null or query.id == ''">
  302. 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}
  303. <if test="query.createdBy != null and query.createdBy != ''">
  304. and a.created_by = #{query.createdBy}
  305. </if>
  306. <if test="query.cAdditionalInfo != null and query.cAdditionalInfo != ''">
  307. and a.c_additional_info = #{query.cAdditionalInfo}
  308. </if>
  309. <if test="query.fileName != null and query.fileName != ''">
  310. and a.file_name = #{query.fileName}
  311. </if>
  312. </if>
  313. </where>
  314. </select>
  315. <select id="getMaxItemNo2" resultType="java.lang.Integer">
  316. SELECT COALESCE(MAX(Item_No), 0) AS maxItemNo
  317. FROM plm_project_document_confirm_file_list
  318. WHERE site = #{site} AND Order_Ref1 = #{orderRef1} and Order_Ref2 = #{orderRef2}
  319. </select>
  320. <select id="checkConfirmationRecord"
  321. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  322. SELECT a.*
  323. FROM plm_project_document_confirm as a
  324. WHERE a.site = #{site} and a.Order_Ref1 = #{orderRef1} and a.document_type = '产品文档' and a.Order_Ref2 = #{orderRef2}
  325. </select>
  326. <!-- SELECT-->
  327. <!-- (SELECT TOP 1 proofing_no FROM plm_proofing_information WHERE project_id = ppi.project_id and test_part_id = ppi.id) AS proofing_no,-->
  328. <!-- ppi.id AS project_part_id,-->
  329. <!-- ppi.project_id,-->
  330. <!-- STUFF(-->
  331. <!-- COALESCE(-->
  332. <!-- CASE WHEN pu1.email IS NOT NULL AND pu1.email != '' THEN ';' + pu1.email ELSE '' END +-->
  333. <!-- CASE WHEN pu2.email IS NOT NULL AND pu2.email != '' THEN ';' + pu2.email ELSE '' END +-->
  334. <!-- CASE WHEN pu3.email IS NOT NULL AND pu3.email != '' THEN ';' + pu3.email ELSE '' END +-->
  335. <!-- CASE WHEN pu4.email IS NOT NULL AND pu4.email != '' THEN ';' + pu4.email ELSE '' END +-->
  336. <!-- CASE WHEN pu5.email IS NOT NULL AND pu5.email != '' THEN ';' + pu5.email ELSE '' END +-->
  337. <!-- CASE WHEN pu6.email IS NOT NULL AND pu6.email != '' THEN ';' + pu6.email ELSE '' END,-->
  338. <!-- ''-->
  339. <!-- ),-->
  340. <!-- 1, 1, ''-->
  341. <!-- ) AS email-->
  342. <!-- FROM-->
  343. <!-- plm_project_part ppi-->
  344. <!-- LEFT JOIN sys_user pu1 ON LEFT ( ppi.c_quality_engineer1, CHARINDEX( '-', ppi.c_quality_engineer1 ) - 1 ) = pu1.username-->
  345. <!-- LEFT JOIN sys_user pu2 ON LEFT ( ppi.c_quality_engineer2, CHARINDEX( '-', ppi.c_quality_engineer2 ) - 1 ) = pu2.username-->
  346. <!-- LEFT JOIN sys_user pu3 ON LEFT ( ppi.c_quality_engineer3, CHARINDEX( '-', ppi.c_quality_engineer3 ) - 1 ) = pu3.username-->
  347. <!-- LEFT JOIN sys_user pu7 ON LEFT ( ppi.c_quality_engineer4, CHARINDEX( '-', ppi.c_quality_engineer4 ) - 1 ) = pu7.username-->
  348. <!-- LEFT JOIN sys_user pu4 ON LEFT ( ppi.c_manufacture_engineer, CHARINDEX( '-', ppi.c_manufacture_engineer ) - 1 ) = pu4.username-->
  349. <!-- LEFT JOIN sys_user pu5 ON LEFT ( ppi.engineer, CHARINDEX( '-', ppi.engineer ) - 1 ) = pu5.username-->
  350. <!-- LEFT JOIN sys_user pu6 ON LEFT ( ppi.doc_engineer, CHARINDEX( '-', ppi.doc_engineer ) - 1 ) = pu6.username-->
  351. <!-- WHERE-->
  352. <!-- ppi.id = #{projectPartId}-->
  353. <select id="getSendMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  354. {call plm_get_to_email_list_proofing(
  355. #{site, mode=IN, jdbcType=VARCHAR},
  356. #{projectId, mode=IN, jdbcType=INTEGER},
  357. #{projectPartId, mode=IN, jdbcType=INTEGER},
  358. #{proofingId, mode=IN, jdbcType=INTEGER})}
  359. </select>
  360. <select id="getSendMassProductionMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  361. {call plm_get_to_email_list_MassProd(
  362. #{site, mode=IN, jdbcType=VARCHAR},
  363. #{projectId, mode=IN, jdbcType=INTEGER},
  364. #{projectPartId, mode=IN, jdbcType=INTEGER})}
  365. </select>
  366. <select id="getAutoSendMailAddress" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  367. {call plm_get_to_email_list_AlertMessage(
  368. #{site, mode=IN, jdbcType=VARCHAR})}
  369. </select>
  370. <select id="getRoleDescByNo" resultType="com.xujie.sys.modules.factory.entity.vo.BusinessRoleVo">
  371. SELECT
  372. role_desc
  373. FROM business_role
  374. WHERE role_no = #{roleNo}
  375. </select>
  376. <select id="getWarnSendMailAddress" parameterType="map" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  377. SELECT
  378. ppp.project_id,
  379. ppp.test_part_no,
  380. pu.email
  381. FROM
  382. plm_project_part ppp
  383. LEFT JOIN sys_user pu ON LEFT ( ppp.${type}, CHARINDEX( '-', ppp.${type} ) - 1 ) = pu.username
  384. WHERE
  385. ppp.project_id = #{query.projectId} and ppp.site = #{query.site} and ppp.id = #{query.projectPartId}
  386. </select>
  387. <select id="getConfirmatorSendMailAddress" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  388. SELECT DISTINCT
  389. a.Order_Ref1 as project_id,
  390. a.Order_Ref2 as project_part_id,
  391. STUFF((SELECT DISTINCT '; ' + b.email
  392. FROM plm_project_document_confirm as c
  393. LEFT JOIN sys_user as b ON c.userid = b.user_id
  394. WHERE c.Site = #{site} and c.Order_Ref1 = #{projectId} and c.Order_Ref2 = #{projectPartId}
  395. FOR XML PATH('')), 1, 2, '') as email
  396. FROM plm_project_document_confirm as a
  397. WHERE a.Site = #{site} and a.Order_Ref1 = #{projectId} and a.Order_Ref2 = #{projectPartId}
  398. </select>
  399. <select id="searchProjectAllDocumentTask" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  400. {call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{projectPartId,mode=IN}, #{proofingId, mode=IN})}
  401. </select>
  402. <select id="queryEmailByCreateUser" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  403. SELECT
  404. a.project_id,
  405. a.proofing_no,
  406. a.create_by,
  407. b.email
  408. FROM plm_proofing_information as a
  409. LEFT JOIN sys_user as b ON a.create_by = b.username
  410. WHERE a.site = #{site} and a.project_id = #{projectId} and a.id = #{proofingId} and a.test_part_id = #{projectPartId}
  411. </select>
  412. <select id="checkProjectPartInfo" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  413. SELECT
  414. *
  415. from plm_project_part
  416. WHERE project_id = #{projectId}
  417. </select>
  418. <select id="checkeamProjectId" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  419. SELECT
  420. a.project_no
  421. FROM plm_project_info as a
  422. WHERE a.id = #{projectId}
  423. </select>
  424. <select id="eamProjectPartSearch" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  425. SELECT
  426. a.*,
  427. a.id as projectPartId,
  428. b.project_no,
  429. b.project_desc,
  430. b.bu_no,
  431. b.c_project_region,
  432. c.customer_desc,
  433. d.bu_desc
  434. FROM plm_project_part as a
  435. LEFT JOIN plm_project_info as b ON a.project_id = b.id
  436. LEFT JOIN plm_customer_information as c ON a.customer_no = c.customer_no and a.site = c.site
  437. left join CKT_MES_II_REAL.dbo.BU as d on b.site = d.site and b.bu_no = d.bu_no
  438. <where>
  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="getFinalPartDesc" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  558. SELECT
  559. part_no as final_part_no,
  560. part_desc as final_part_desc
  561. FROM part
  562. WHERE site = #{site} and part_no = #{finalPartNo}
  563. </select>
  564. <select id="getEmailAddressByUsername" resultType="string">
  565. SELECT
  566. email
  567. FROM
  568. sys_user
  569. WHERE
  570. username = #{username}
  571. </select>
  572. <select id="checkConfirmatory" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  573. SELECT
  574. *
  575. FROM plm_document_toconfirm_user as a
  576. WHERE a.BU = #{buNo} and a.Site = #{site} and a.document_type = '产品文档' and a.userid = #{userid}
  577. </select>
  578. <select id="searchSopFileList" resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
  579. SELECT a.sop_name + '.' + SUBSTRING(sop_url, CHARINDEX('.', sop_url) + 1, LEN(sop_url)) as file_name,
  580. a.creation_date as create_date,
  581. a.created_by as created_by,
  582. a.sop_url as url,
  583. a.id,
  584. '-2' as order_ref3,
  585. SUBSTRING(a.sop_url, CHARINDEX('.', a.sop_url) + 1, LEN(a.sop_url)) as file_type
  586. FROM part_sop as a
  587. <where>
  588. <if test="query.id != null and query.id != ''">
  589. a.id = CAST(#{query.id} AS INT)
  590. </if>
  591. <if test="query.id == null or query.id == ''">
  592. 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}
  593. <if test="query.createdBy != null and query.createdBy != ''">
  594. and a.created_by = #{query.createdBy}
  595. </if>
  596. <if test="query.cAdditionalInfo != null and query.cAdditionalInfo != ''">
  597. and a.c_additional_info = #{query.cAdditionalInfo}
  598. </if>
  599. <if test="query.fileName != null and query.fileName != ''">
  600. and a.file_name = #{query.fileName}
  601. </if>
  602. </if>
  603. </where>
  604. </select>
  605. <select id="getEmailsByUsernames" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  606. SELECT email
  607. FROM sys_user
  608. WHERE site = #{site}
  609. AND username IN
  610. <foreach item="username" collection="usernames" open="(" separator="," close=")">
  611. #{username}
  612. </foreach>
  613. </select>
  614. <select id="searchMassProductionBomList"
  615. resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  616. {call dbo.plm_get_part_fullBOM(#{data.site, mode=IN}, #{data.projectId, mode=IN}, #{data.projectPartId, mode=IN})}
  617. </select>
  618. <select id="searchRoutingList" resultType="com.xujie.sys.modules.pms.data.EamProjectPartInfoData">
  619. {call dbo.rfq_get_fullRouting(#{data.site, mode=IN}, #{data.partNo, mode=IN})}
  620. </select>
  621. <select id="searchSysOssFileList" resultType="com.xujie.sys.modules.oss.entity.SysOssEntity">
  622. select * from sys_oss where file_name = #{fileName}
  623. </select>
  624. <insert id="saveNewProjectPart" useGeneratedKeys="true" keyProperty="projectPartId">
  625. INSERT INTO plm_project_part (
  626. site,
  627. project_id,
  628. test_part_no,
  629. part_desc,
  630. create_date,
  631. create_by,
  632. final_part_no,
  633. project_manager,
  634. project_owner,
  635. build_date,
  636. c_quality_engineer1,
  637. c_quality_engineer2,
  638. c_quality_engineer3,
  639. c_quality_engineer4,
  640. c_quality_engineer5,
  641. c_quality_engineer6,
  642. c_manufacture_engineer,
  643. doc_engineer,
  644. doc_engineer2,
  645. engineer,
  646. ipqc_hard_tag,
  647. c_quality_engineer7,
  648. status,
  649. part_type,
  650. priority,
  651. project_category,
  652. need_date,
  653. customer_no,
  654. remark
  655. ) VALUES (
  656. #{site},
  657. #{projectId},
  658. #{testPartNo},
  659. #{partDesc},
  660. getdate(),
  661. #{createBy},
  662. #{finalPartNo},
  663. #{projectManager},
  664. #{projectOwner},
  665. #{buildDate},
  666. #{cQualityEngineer1},
  667. #{cQualityEngineer2},
  668. #{cQualityEngineer3},
  669. #{cQualityEngineer4},
  670. #{cQualityEngineer5},
  671. #{cQualityEngineer6},
  672. #{cManufactureEngineer},
  673. #{docEngineer},
  674. #{docEngineer2},
  675. #{engineer},
  676. #{ipqcHardTag},
  677. #{cQualityEngineer7},
  678. #{status},
  679. #{partType},
  680. #{priority},
  681. #{projectCategory},
  682. #{needDate},
  683. #{customerNo},
  684. #{remark}
  685. );
  686. </insert>
  687. <insert id="addConfirmatory">
  688. INSERT INTO plm_document_toconfirm_user
  689. (site,BU,document_type,userid,create_date,create_by)
  690. VALUES
  691. (#{site},#{buNo},'产品文档',#{userid},GETDATE(),#{createBy})
  692. </insert>
  693. <update id="eamProjectPartInfoEdit">
  694. UPDATE plm_project_part
  695. SET test_part_no = #{testPartNo},part_desc = #{partDesc},update_date = GETDATE(),update_by = #{updateBy},
  696. build_date = #{buildDate}, priority = #{priority}, project_category = #{projectCategory}, need_date =
  697. #{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},
  698. c_quality_engineer7 = #{cQualityEngineer7},remark = #{remark},
  699. status = CASE WHEN #{status} IS NOT NULL THEN #{status} ELSE status END,customer_no = #{customerNo},
  700. part_type = CASE WHEN #{partType} IS NOT NULL THEN #{partType} ELSE part_type END,
  701. close_date = (CASE
  702. WHEN #{closeDate} IS NULL THEN ISNULL(close_date, NULL)
  703. ELSE CONVERT(DATE, #{closeDate})
  704. END)
  705. WHERE id = #{projectPartId}
  706. </update>
  707. </mapper>