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.

652 lines
35 KiB

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