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.

1253 lines
60 KiB

4 months ago
4 months ago
4 months ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
3 months ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
3 months ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
3 months ago
9 hours ago
3 months ago
9 hours ago
9 hours ago
3 months ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
9 hours ago
7 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.ProofingInformationMapper">
  5. <insert id="proofingInformationSave" useGeneratedKeys="true" keyProperty="proofingId">
  6. INSERT INTO plm_proofing_information
  7. (site,proofing_no,project_id,test_part_id,customer_no,tracker,engineer,priority_level,proofing_number,plan_start_date,required_delivery_date,remark,technical_considerations,is_need_to_send_samples,send_samples_address,consignee,consignee_contact,proofing_result_information,actuality_send_samples_date,send_samples_method,deliver_goods_information,deliver_goods_remark,actuality_reply_date,confirm_results,confirm_by,confirm_information,proofing_status,proofing_result_status,next_to_do,create_date,create_by,approver,step_id,reject_flag,reject_step_id,c_project_type_db,project_phase)
  8. VALUES
  9. (#{site},#{proofingNo},#{projectId},#{projectPartId},#{customerNo},#{tracker},#{engineer},#{priorityLevel},#{proofingNumber},#{planStartDate},#{requiredDeliveryDate},#{remark},#{technicalConsiderations},#{isNeedToSendSamples},#{sendSamplesAddress},#{consignee},#{consigneeContact},#{proofingResultInformation},#{actualitySendSamplesDate},#{sendSamplesMethod},#{deliverGoodsInformation},#{deliverGoodsRemark},#{actualityReplyDate},#{confirmResults},#{confirmBy},#{confirmInformation},#{proofingStatus},#{proofingResultStatus},#{nextToDo},getDate(),#{createBy},#{approver},#{stepId},#{rejectFlag},#{rejectStepId},#{cProjectTypeDb},#{projectPhase})
  10. </insert>
  11. <update id="updateProofingInfoById">
  12. UPDATE plm_proofing_information
  13. SET
  14. proofing_no = #{proofingNo},
  15. proofing_number = #{proofingNumber},
  16. plan_start_date = #{planStartDate},
  17. required_delivery_date = #{requiredDeliveryDate},
  18. actuality_delivery_date = #{actualityDeliveryDate},
  19. update_date = getDate(),
  20. update_by = #{updateBy},
  21. c_project_type_db = #{cProjectTypeDb},
  22. project_phase = #{projectPhase},
  23. proofing_status = #{proofingStatus},
  24. proofing_result_status = #{proofingResultStatus},
  25. remark = #{remark}
  26. WHERE id = #{proofingId}
  27. </update>
  28. <update id="updateProofingInfoById1">
  29. UPDATE plm_proofing_information
  30. SET proofing_no = #{proofingNo},
  31. proofing_number = #{proofingNumber},
  32. plan_start_date = #{planStartDate},
  33. required_delivery_date = #{requiredDeliveryDate},
  34. update_date = getDate(),
  35. update_by = #{updateBy},
  36. c_project_type_db = #{cProjectTypeDb},
  37. project_phase = #{projectPhase},
  38. proofing_status = #{proofingStatus},
  39. proofing_result_status = #{proofingResultStatus},
  40. remark = #{remark}
  41. WHERE id = #{proofingId}
  42. </update>
  43. <update id="updateDocumentListUploadedFlag">
  44. UPDATE plm_document_list_definition
  45. SET uploaded_flag = 'N'
  46. WHERE site = #{site} AND proofing_id = #{proofingId} AND project_id = #{projectId} AND test_part_id = #{projectPartId} and id = #{documentDefinitionListId}
  47. </update>
  48. <select id="proofingInformationSearch" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  49. SELECT
  50. a.id as proofing_id,
  51. a.site,
  52. a.proofing_no,
  53. a.project_id,
  54. b.project_no,
  55. a.test_part_id as project_part_id,
  56. d.test_part_no,
  57. a.customer_no,
  58. a.tracker,
  59. a.engineer,
  60. a.priority_level,
  61. a.proofing_number,
  62. a.plan_start_date,
  63. a.required_delivery_date,
  64. a.remark,
  65. a.technical_considerations,
  66. a.is_need_to_send_samples,
  67. a.send_samples_address,
  68. a.consignee,
  69. a.consignee_contact,
  70. a.actuality_delivery_date,
  71. a.proofing_result_information,
  72. a.actuality_send_samples_date,
  73. a.send_samples_method,
  74. a.deliver_goods_information,
  75. a.deliver_goods_remark,
  76. a.actuality_reply_date,
  77. a.confirm_results,
  78. a.confirm_by,
  79. a.confirm_information,
  80. a.proofing_status,
  81. a.proofing_result_status,
  82. a.next_to_do,
  83. a.create_date,
  84. a.create_by,
  85. a.update_date,
  86. a.update_by,
  87. a.approver,
  88. a.step_id,
  89. a.reject_flag,
  90. a.reject_step_id,
  91. a.c_project_type_db,
  92. a.project_phase,
  93. b.project_category,
  94. b.bu_no,
  95. b.project_desc,
  96. c.customer_desc,
  97. d.part_desc
  98. FROM plm_proofing_information as a
  99. LEFT JOIN plm_project_info as b ON a.project_id = b.id and a.site = b.site
  100. LEFT JOIN plm_customer_information AS c ON c.customer_no = b.customer_no and c.site = b.site
  101. LEFT JOIN plm_project_part AS d ON d.project_id = a.project_id and d.id = a.test_part_id
  102. where
  103. a.project_id = #{query.projectId}
  104. and a.test_part_id = #{query.projectPartId}
  105. order by a.create_date desc
  106. </select>
  107. <select id="getProofDocument" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  108. {call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{projectPartId,mode=IN}, #{proofingId, mode=IN})}
  109. </select>
  110. <delete id="deleteDocumentType">
  111. DELETE FROM plm_document_list_definition WHERE id = #{documentDefinitionListId}
  112. </delete>
  113. <select id="countUploadedDocumentByIds" resultType="java.lang.Integer">
  114. SELECT COUNT(1)
  115. FROM CKT_MES_II_REAL.dbo.sys_oss AS a
  116. INNER JOIN plm_document_list_definition AS b ON CAST(b.id AS VARCHAR(50)) = a.order_ref3
  117. WHERE b.id IN
  118. <foreach collection="documentDefinitionListIds" item="id" open="(" separator="," close=")">
  119. #{id}
  120. </foreach>
  121. </select>
  122. <delete id="batchDeleteDocumentType">
  123. DELETE FROM plm_document_list_definition
  124. WHERE id IN
  125. <foreach collection="documentDefinitionListIds" item="id" open="(" separator="," close=")">
  126. #{id}
  127. </foreach>
  128. </delete>
  129. <delete id="deleteProofingDocument">
  130. DELETE a
  131. FROM
  132. plm_document_list_definition as a
  133. INNER join bu_document_list_definition as b on a.document_type_id = b.document_type_id and a.site = b.site
  134. WHERE a.proofing_id = #{proofingId} and b.project_category = #{cProjectTypeDb}
  135. </delete>
  136. <delete id="deleteProofingDocument1">
  137. DELETE FROM CKT_MES_II_REAL.dbo.sys_oss WHERE id = #{documentId}
  138. </delete>
  139. <delete id="deleteProjectDocument">
  140. DELETE a
  141. FROM
  142. plm_document_list_definition as a
  143. INNER join bu_document_list_definition as b on a.document_type_id = b.document_type_id and a.site = b.site
  144. WHERE a.proofing_id = -1 and b.project_category = #{projectCategory} and a.project_id = #{projectId} and a.test_part_id = #{projectPartId}
  145. </delete>
  146. <delete id="proofingInformationDelete">
  147. DELETE FROM plm_proofing_information WHERE id = #{proofingId}
  148. </delete>
  149. <delete id="deleteDocumentDefinitionById">
  150. DELETE FROM plm_document_list_definition WHERE id = #{documentDefinitionListId}
  151. </delete>
  152. <select id="selecProofingOne" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  153. SELECT *,id as proofing_id FROM plm_proofing_information WHERE id = #{proofingId}
  154. </select>
  155. <!-- 查询documentTypeId列表 -->
  156. <select id="getDocumentTypeIds" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData" parameterType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  157. SELECT a.document_type_id, b.responsible_department ,c.role_desc
  158. FROM bu_document_list_definition as a
  159. left join document_type_definition as b on a.document_type_id = b.document_type_id and a.site = b.site
  160. left join business_role as c on b.responsible_department = c.role_no and b.Site = c.site
  161. WHERE a.site = #{site}
  162. AND a.bu_no = #{buNo}
  163. AND a.project_category = #{cProjectTypeDb}
  164. AND a.project_phase = 'Sample'
  165. </select>
  166. <!-- 查询documentTypeId列表 -->
  167. <select id="getProjectDocumentTypeIds" resultType="string" parameterType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  168. SELECT document_type_id
  169. FROM bu_document_list_definition
  170. WHERE site = #{site}
  171. AND bu_no = #{buNo}
  172. AND project_category = #{projectCategory}
  173. AND project_phase = 'Mass production'
  174. </select>
  175. <!-- 检查文档是否存在 -->
  176. <select id="documentExists" resultType="boolean" parameterType="map">
  177. SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
  178. FROM plm_document_list_definition
  179. WHERE site = #{data.site}
  180. AND proofing_id = #{data.proofingId}
  181. AND project_id = #{data.projectId}
  182. AND document_type_id = #{documentTypeId}
  183. </select>
  184. <!-- 检查文档是否存在 -->
  185. <select id="projectDocumentExists" resultType="boolean" parameterType="map">
  186. SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
  187. FROM plm_document_list_definition
  188. WHERE site = #{data.site}
  189. AND proofing_id = #{data.proofingId}
  190. AND project_id = #{data.projectId}
  191. AND test_part_id = #{data.projectPartId}
  192. AND document_type_id = #{documentTypeId}
  193. </select>
  194. <select id="getExtraDocumentList" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  195. SELECT
  196. a.document_type_id,
  197. a.document_type,
  198. (SELECT role_desc FROM business_role WHERE role_no = a.responsible_department and site = #{query.site}) AS
  199. responsible_department,
  200. a.estimated_completion_days
  201. FROM document_type_definition as a
  202. where
  203. a.site = #{query.site}
  204. AND a.document_type_id NOT IN (
  205. SELECT document_type_id
  206. FROM plm_document_list_definition
  207. WHERE site = #{query.site}
  208. AND proofing_id = #{query.proofingId}
  209. AND project_id = #{query.projectId}
  210. )
  211. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  212. AND UPPER(a.document_type_id) like '%' + UPPER(#{query.documentTypeId}) + '%'
  213. </if>
  214. <if test="query.documentType != null and query.documentType != ''">
  215. AND UPPER(a.document_type) like '%' + UPPER(#{query.documentType}) + '%'
  216. </if>
  217. <if test="query.responsibleDepartment != null and query.responsibleDepartment != ''">
  218. AND UPPER(a.responsible_department) like '%' + UPPER(#{query.responsibleDepartment}) + '%'
  219. </if>
  220. </select>
  221. <select id="documentExists1" resultType="java.lang.Boolean">
  222. SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
  223. FROM plm_document_list_definition
  224. WHERE site = #{data.site}
  225. AND proofing_id = #{data.proofingId}
  226. and test_part_id = #{data.projectPartId}
  227. AND project_id = #{data.projectId}
  228. AND document_type_id = #{documentTypeId}
  229. </select>
  230. <select id="selectProjectList" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  231. SELECT a.*,b.project_category FROM plm_document_list_definition as a
  232. left join plm_project_info as b on a.project_id = b.id
  233. left join bu_document_list_definition as c on a.document_type_id = c.document_type_id
  234. WHERE a.project_id = #{projectId} and a.proofing_id = -1 and c.project_phase = 'Mass Production'
  235. </select>
  236. <select id="searchProjectAllDocument" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  237. {call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{projectPartId,mode=IN}, #{proofingId, mode=IN})}
  238. </select>
  239. <select id="queryProofingNo" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  240. SELECT * FROM plm_proofing_information WHERE site = #{site} and project_id = #{projectId} and id = #{proofingId}
  241. </select>
  242. <select id="selectProofingDocument" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  243. SELECT
  244. c.id
  245. FROM
  246. sys_oss AS a
  247. LEFT JOIN plm_document_list_definition AS b ON CAST ( b.id AS VARCHAR ) = a.order_ref3
  248. LEFT JOIN bu_document_list_definition AS c ON b.document_type_id = c.document_type_id
  249. WHERE b.proofing_id = #{proofingId} and c.project_category = #{cProjectTypeDb} and c.project_phase = 'Sample'
  250. </select>
  251. <select id="checkProductionConfirmationDocument" resultType="boolean">
  252. SELECT
  253. CASE
  254. WHEN EXISTS (
  255. SELECT 1
  256. FROM plm_project_document_confirm_file_list AS a
  257. WHERE Site = #{site} AND document_type = #{documentType} AND Order_Ref1 = #{OrderRef1} AND document_id = #{documentId} and Order_Ref2 = #{OrderRef2}
  258. ) THEN 1
  259. ELSE 0
  260. END AS exists_flag
  261. </select>
  262. <select id="getPendingUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  263. SELECT * FROM view_plm_toupload_list_byUser
  264. <where>
  265. status != '草稿' AND RelatedPerson = #{userId}
  266. <if test="query.projectNo != null and query.projectNo != ''">
  267. AND (
  268. project_no like '%' + #{query.projectNo} + '%'
  269. OR project_no IN (
  270. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  271. )
  272. )
  273. </if>
  274. <if test="query.projectDesc != null and query.projectDesc != ''">
  275. and project_desc like '%' + #{query.projectDesc} + '%'
  276. </if>
  277. <if test="query.uploadedFlag != null and query.uploadedFlag != ''">
  278. <choose>
  279. <when test="query.uploadedFlag == '已上传'">
  280. <![CDATA[
  281. AND uploaded_flag = '已上传'
  282. ]]>
  283. </when>
  284. <when test="query.uploadedFlag == '未上传'">
  285. <![CDATA[
  286. AND uploaded_flag != '已上传'
  287. ]]>
  288. </when>
  289. <otherwise>
  290. <![CDATA[
  291. AND uploaded_flag = #{query.uploadedFlag, jdbcType=VARCHAR}
  292. ]]>
  293. </otherwise>
  294. </choose>
  295. </if>
  296. <if test="query.testPartNo != null and query.testPartNo != ''">
  297. AND (
  298. test_part_no like '%' + #{query.testPartNo} + '%'
  299. OR test_part_no IN (
  300. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  301. )
  302. )
  303. </if>
  304. <if test="query.partDesc != null and query.partDesc != ''">
  305. and part_desc like '%' + #{query.partDesc} + '%'
  306. </if>
  307. <if test="query.proofingNo != null and query.proofingNo != ''">
  308. and proofing_no like '%' + #{query.proofingNo} + '%'
  309. </if>
  310. <if test="query.customerNo != null and query.customerNo != ''">
  311. and customer_no like '%' + #{query.customerNo} + '%'
  312. </if>
  313. <if test="query.customerDesc != null and query.customerDesc != ''">
  314. and customer_desc like '%' + #{query.customerDesc} + '%'
  315. </if>
  316. <if test="query.buDesc != null and query.buDesc != ''">
  317. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  318. </if>
  319. <if test="query.projectCategory != null and query.projectCategory != ''">
  320. and project_category = #{query.projectCategory}
  321. </if>
  322. <if test="query.status != null and query.status != ''">
  323. and status = #{query.status}
  324. </if>
  325. <if test="query.projectManager != null and query.projectManager != ''">
  326. and project_manager = #{query.projectManager}
  327. </if>
  328. <if test="query.projectOwner != null and query.projectOwner != ''">
  329. and project_owner = #{query.projectOwner}
  330. </if>
  331. <if test="query.engineer != null and query.engineer != ''">
  332. and engineer = #{query.engineer}
  333. </if>
  334. <if test="query.projectLeader != null and query.projectLeader != ''">
  335. AND (
  336. CASE
  337. WHEN responsible_department = 'R001' AND CHARINDEX('-', ISNULL(project_manager, '')) > 0 THEN SUBSTRING(project_manager, CHARINDEX('-', project_manager) + 1, LEN(project_manager))
  338. WHEN responsible_department = 'R002' AND CHARINDEX('-', ISNULL(project_owner, '')) > 0 THEN SUBSTRING(project_owner, CHARINDEX('-', project_owner) + 1, LEN(project_owner))
  339. WHEN responsible_department = 'R004' AND CHARINDEX('-', ISNULL(engineer, '')) > 0 THEN SUBSTRING(engineer, CHARINDEX('-', engineer) + 1, LEN(engineer))
  340. WHEN responsible_department = 'R005' AND CHARINDEX('-', ISNULL(c_quality_engineer1, '')) > 0 THEN SUBSTRING(c_quality_engineer1, CHARINDEX('-', c_quality_engineer1) + 1, LEN(c_quality_engineer1))
  341. WHEN responsible_department = 'R007' AND CHARINDEX('-', ISNULL(c_quality_engineer2, '')) > 0 THEN SUBSTRING(c_quality_engineer2, CHARINDEX('-', c_quality_engineer2) + 1, LEN(c_quality_engineer2))
  342. WHEN responsible_department = 'R008' AND CHARINDEX('-', ISNULL(c_quality_engineer3, '')) > 0 THEN SUBSTRING(c_quality_engineer3, CHARINDEX('-', c_quality_engineer3) + 1, LEN(c_quality_engineer3))
  343. WHEN responsible_department = 'R009' AND CHARINDEX('-', ISNULL(c_manufacture_engineer, '')) > 0 THEN SUBSTRING(c_manufacture_engineer, CHARINDEX('-', c_manufacture_engineer) + 1, LEN(c_manufacture_engineer))
  344. WHEN responsible_department = 'R011' AND CHARINDEX('-', ISNULL(c_quality_engineer4, '')) > 0 THEN SUBSTRING(c_quality_engineer4, CHARINDEX('-', c_quality_engineer4) + 1, LEN(c_quality_engineer4))
  345. WHEN responsible_department = 'R012' AND CHARINDEX('-', ISNULL(doc_engineer, '')) > 0 THEN SUBSTRING(doc_engineer, CHARINDEX('-', doc_engineer) + 1, LEN(doc_engineer))
  346. WHEN responsible_department = 'R013' AND CHARINDEX('-', ISNULL(c_quality_engineer5, '')) > 0 THEN SUBSTRING(c_quality_engineer5, CHARINDEX('-', c_quality_engineer5) + 1, LEN(c_quality_engineer5))
  347. WHEN responsible_department = 'R014' AND CHARINDEX('-', ISNULL(c_quality_engineer6, '')) > 0 THEN SUBSTRING(c_quality_engineer6, CHARINDEX('-', c_quality_engineer6) + 1, LEN(c_quality_engineer6))
  348. WHEN responsible_department = 'R015' AND CHARINDEX('-', ISNULL(ipqc_hard_tag, '')) > 0 THEN SUBSTRING(ipqc_hard_tag, CHARINDEX('-', ipqc_hard_tag) + 1, LEN(ipqc_hard_tag))
  349. WHEN responsible_department = 'R016' AND CHARINDEX('-', ISNULL(c_quality_engineer7, '')) > 0 THEN SUBSTRING(c_quality_engineer7, CHARINDEX('-', c_quality_engineer7) + 1, LEN(c_quality_engineer7))
  350. WHEN responsible_department = 'R017' AND CHARINDEX('-', ISNULL(doc_engineer2, '')) > 0 THEN SUBSTRING(doc_engineer2, CHARINDEX('-', doc_engineer2) + 1, LEN(doc_engineer2))
  351. ELSE ''
  352. END
  353. ) = #{query.projectLeader}
  354. </if>
  355. <if test="query.finalPartNo != null and query.finalPartNo != ''">
  356. and final_part_no = #{query.finalPartNo}
  357. </if>
  358. <if test="query.massProductionStartDate != null ">
  359. AND close_date >= #{query.massProductionStartDate}
  360. </if>
  361. <if test="query.massProductionEndDate != null ">
  362. AND #{query.massProductionEndDate} >= close_date
  363. </if>
  364. <if test="query.startDate != null ">
  365. AND build_date >= #{query.startDate}
  366. </if>
  367. <if test="query.endDate != null ">
  368. AND #{query.endDate} >= build_date
  369. </if>
  370. <if test="query.documentDefinitionListId != null and query.documentDefinitionListId != ''">
  371. AND documentDefinitionListId = #{query.documentDefinitionListId}
  372. </if>
  373. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  374. AND document_type_id like '%' + #{query.documentTypeId} + '%'
  375. </if>
  376. <if test="query.documentType != null and query.documentType != ''">
  377. AND document_type like '%' + #{query.documentType} + '%'
  378. </if>
  379. </where>
  380. order by project_id
  381. </select>
  382. <select id="getOverdueUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  383. <![CDATA[
  384. SELECT * FROM view_plm_toupload_list_byUser
  385. WHERE status != '草稿'
  386. AND Request_date < GETDATE()
  387. AND RelatedPerson = #{userId}
  388. ]]>
  389. <if test="query.projectNo != null and query.projectNo != ''">
  390. <![CDATA[
  391. AND (
  392. project_no like '%' + #{query.projectNo} + '%'
  393. OR project_no IN (
  394. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  395. )
  396. )
  397. ]]>
  398. </if>
  399. <if test="query.projectDesc != null and query.projectDesc != ''">
  400. <![CDATA[
  401. and project_desc like '%' + #{query.projectDesc} + '%'
  402. ]]>
  403. </if>
  404. <if test="query.uploadedFlag != null and query.uploadedFlag != ''">
  405. <choose>
  406. <when test="query.uploadedFlag == '已上传'">
  407. <![CDATA[
  408. AND uploaded_flag = '已上传'
  409. ]]>
  410. </when>
  411. <when test="query.uploadedFlag == '未上传'">
  412. <![CDATA[
  413. AND uploaded_flag != '已上传'
  414. ]]>
  415. </when>
  416. <otherwise>
  417. <![CDATA[
  418. AND uploaded_flag = #{query.uploadedFlag, jdbcType=VARCHAR}
  419. ]]>
  420. </otherwise>
  421. </choose>
  422. </if>
  423. <if test="query.testPartNo != null and query.testPartNo != ''">
  424. <![CDATA[
  425. AND (
  426. test_part_no like '%' + #{query.testPartNo} + '%'
  427. OR test_part_no IN (
  428. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  429. )
  430. )
  431. ]]>
  432. </if>
  433. <if test="query.partDesc != null and query.partDesc != ''">
  434. <![CDATA[
  435. AND part_desc like '%' + #{query.partDesc} + '%'
  436. ]]>
  437. </if>
  438. <if test="query.proofingNo != null and query.proofingNo != ''">
  439. <![CDATA[
  440. AND proofing_no like '%' + #{query.proofingNo} + '%'
  441. ]]>
  442. </if>
  443. <if test="query.customerNo != null and query.customerNo != ''">
  444. <![CDATA[
  445. AND customer_no LIKE '%' + #{query.customerNo} + '%'
  446. ]]>
  447. </if>
  448. <if test="query.customerDesc != null and query.customerDesc != ''">
  449. <![CDATA[
  450. AND customer_desc LIKE '%' + #{query.customerDesc} + '%'
  451. ]]>
  452. </if>
  453. <if test="query.buDesc != null and query.buDesc != ''">
  454. <![CDATA[
  455. AND dbo.get_bu_desc(site, bu_no) = #{query.buDesc}
  456. ]]>
  457. </if>
  458. <if test="query.projectCategory != null and query.projectCategory != ''">
  459. <![CDATA[
  460. AND project_category = #{query.projectCategory}
  461. ]]>
  462. </if>
  463. <if test="query.status != null and query.status != ''">
  464. <![CDATA[
  465. AND status = #{query.status}
  466. ]]>
  467. </if>
  468. <if test="query.projectManager != null and query.projectManager != ''">
  469. <![CDATA[
  470. AND project_manager = #{query.projectManager}
  471. ]]>
  472. </if>
  473. <if test="query.projectOwner != null and query.projectOwner != ''">
  474. <![CDATA[
  475. AND project_owner = #{query.projectOwner}
  476. ]]>
  477. </if>
  478. <if test="query.engineer != null and query.engineer != ''">
  479. <![CDATA[
  480. AND engineer = #{query.engineer}
  481. ]]>
  482. </if>
  483. <if test="query.projectLeader != null and query.projectLeader != ''">
  484. <![CDATA[
  485. AND (
  486. CASE
  487. WHEN responsible_department = 'R001' AND CHARINDEX('-', ISNULL(project_manager, '')) > 0 THEN SUBSTRING(project_manager, CHARINDEX('-', project_manager) + 1, LEN(project_manager))
  488. WHEN responsible_department = 'R002' AND CHARINDEX('-', ISNULL(project_owner, '')) > 0 THEN SUBSTRING(project_owner, CHARINDEX('-', project_owner) + 1, LEN(project_owner))
  489. WHEN responsible_department = 'R004' AND CHARINDEX('-', ISNULL(engineer, '')) > 0 THEN SUBSTRING(engineer, CHARINDEX('-', engineer) + 1, LEN(engineer))
  490. WHEN responsible_department = 'R005' AND CHARINDEX('-', ISNULL(c_quality_engineer1, '')) > 0 THEN SUBSTRING(c_quality_engineer1, CHARINDEX('-', c_quality_engineer1) + 1, LEN(c_quality_engineer1))
  491. WHEN responsible_department = 'R007' AND CHARINDEX('-', ISNULL(c_quality_engineer2, '')) > 0 THEN SUBSTRING(c_quality_engineer2, CHARINDEX('-', c_quality_engineer2) + 1, LEN(c_quality_engineer2))
  492. WHEN responsible_department = 'R008' AND CHARINDEX('-', ISNULL(c_quality_engineer3, '')) > 0 THEN SUBSTRING(c_quality_engineer3, CHARINDEX('-', c_quality_engineer3) + 1, LEN(c_quality_engineer3))
  493. WHEN responsible_department = 'R009' AND CHARINDEX('-', ISNULL(c_manufacture_engineer, '')) > 0 THEN SUBSTRING(c_manufacture_engineer, CHARINDEX('-', c_manufacture_engineer) + 1, LEN(c_manufacture_engineer))
  494. WHEN responsible_department = 'R011' AND CHARINDEX('-', ISNULL(c_quality_engineer4, '')) > 0 THEN SUBSTRING(c_quality_engineer4, CHARINDEX('-', c_quality_engineer4) + 1, LEN(c_quality_engineer4))
  495. WHEN responsible_department = 'R012' AND CHARINDEX('-', ISNULL(doc_engineer, '')) > 0 THEN SUBSTRING(doc_engineer, CHARINDEX('-', doc_engineer) + 1, LEN(doc_engineer))
  496. WHEN responsible_department = 'R013' AND CHARINDEX('-', ISNULL(c_quality_engineer5, '')) > 0 THEN SUBSTRING(c_quality_engineer5, CHARINDEX('-', c_quality_engineer5) + 1, LEN(c_quality_engineer5))
  497. WHEN responsible_department = 'R014' AND CHARINDEX('-', ISNULL(c_quality_engineer6, '')) > 0 THEN SUBSTRING(c_quality_engineer6, CHARINDEX('-', c_quality_engineer6) + 1, LEN(c_quality_engineer6))
  498. WHEN responsible_department = 'R015' AND CHARINDEX('-', ISNULL(ipqc_hard_tag, '')) > 0 THEN SUBSTRING(ipqc_hard_tag, CHARINDEX('-', ipqc_hard_tag) + 1, LEN(ipqc_hard_tag))
  499. WHEN responsible_department = 'R016' AND CHARINDEX('-', ISNULL(c_quality_engineer7, '')) > 0 THEN SUBSTRING(c_quality_engineer7, CHARINDEX('-', c_quality_engineer7) + 1, LEN(c_quality_engineer7))
  500. WHEN responsible_department = 'R017' AND CHARINDEX('-', ISNULL(doc_engineer2, '')) > 0 THEN SUBSTRING(doc_engineer2, CHARINDEX('-', doc_engineer2) + 1, LEN(doc_engineer2))
  501. ELSE ''
  502. END
  503. ) = #{query.projectLeader}
  504. ]]>
  505. </if>
  506. <if test="query.finalPartNo != null and query.finalPartNo != ''">
  507. <![CDATA[
  508. and final_part_no = #{query.finalPartNo}
  509. ]]>
  510. </if>
  511. <if test="query.massProductionStartDate != null ">
  512. <![CDATA[
  513. AND close_date >= #{query.massProductionStartDate}
  514. ]]>
  515. </if>
  516. <if test="query.massProductionEndDate != null ">
  517. <![CDATA[
  518. AND #{query.massProductionEndDate} >= close_date
  519. ]]>
  520. </if>
  521. <if test="query.startDate != null">
  522. <![CDATA[
  523. AND build_date >= #{query.startDate}
  524. ]]>
  525. </if>
  526. <if test="query.endDate != null">
  527. <![CDATA[
  528. AND #{query.endDate} >= build_date
  529. ]]>
  530. </if>
  531. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  532. <![CDATA[
  533. AND document_type_id like '%' + #{query.documentTypeId} + '%'
  534. ]]>
  535. </if>
  536. <if test="query.documentType != null and query.documentType != ''">
  537. <![CDATA[
  538. AND document_type like '%' + #{query.documentType} + '%'
  539. ]]>
  540. </if>
  541. <![CDATA[
  542. ORDER BY project_id
  543. ]]>
  544. </select>
  545. <select id="getAllUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  546. SELECT * FROM view_plm_toupload_list_byUser
  547. <where>
  548. status != '草稿'
  549. <if test="query.projectNo != null and query.projectNo != ''">
  550. AND (
  551. project_no like '%' + #{query.projectNo} + '%'
  552. OR project_no IN (
  553. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  554. )
  555. )
  556. </if>
  557. <if test="query.uploadedFlag != null and query.uploadedFlag != ''">
  558. <choose>
  559. <when test="query.uploadedFlag == '已上传'">
  560. AND uploaded_flag = '已上传'
  561. </when>
  562. <when test="query.uploadedFlag == '未上传'">
  563. AND uploaded_flag != '已上传'
  564. </when>
  565. <otherwise>
  566. AND uploaded_flag = #{query.uploadedFlag, jdbcType=VARCHAR}
  567. </otherwise>
  568. </choose>
  569. </if>
  570. <if test="query.projectDesc != null and query.projectDesc != ''">
  571. and project_desc like '%' + #{query.projectDesc} + '%'
  572. </if>
  573. <if test="query.testPartNo != null and query.testPartNo != ''">
  574. AND (
  575. test_part_no like '%' + #{query.testPartNo} + '%'
  576. OR test_part_no IN (
  577. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  578. )
  579. )
  580. </if>
  581. <if test="query.partDesc != null and query.partDesc != ''">
  582. and part_desc like '%' + #{query.partDesc} + '%'
  583. </if>
  584. <if test="query.proofingNo != null and query.proofingNo != ''">
  585. <![CDATA[
  586. AND proofing_no like '%' + #{query.proofingNo} + '%'
  587. ]]>
  588. </if>
  589. <if test="query.customerNo != null and query.customerNo != ''">
  590. and customer_no like '%' + #{query.customerNo} + '%'
  591. </if>
  592. <if test="query.customerDesc != null and query.customerDesc != ''">
  593. and customer_desc like '%' + #{query.customerDesc} + '%'
  594. </if>
  595. <if test="query.buDesc != null and query.buDesc != ''">
  596. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  597. </if>
  598. <if test="query.projectCategory != null and query.projectCategory != ''">
  599. and project_category = #{query.projectCategory}
  600. </if>
  601. <if test="query.status != null and query.status != ''">
  602. and status = #{query.status}
  603. </if>
  604. <if test="query.projectManager != null and query.projectManager != ''">
  605. and project_manager = #{query.projectManager}
  606. </if>
  607. <if test="query.projectOwner != null and query.projectOwner != ''">
  608. and project_owner = #{query.projectOwner}
  609. </if>
  610. <if test="query.engineer != null and query.engineer != ''">
  611. and engineer = #{query.engineer}
  612. </if>
  613. <if test="query.projectLeader != null and query.projectLeader != ''">
  614. AND (
  615. CASE
  616. WHEN responsible_department = 'R001' AND CHARINDEX('-', ISNULL(project_manager, '')) > 0 THEN SUBSTRING(project_manager, CHARINDEX('-', project_manager) + 1, LEN(project_manager))
  617. WHEN responsible_department = 'R002' AND CHARINDEX('-', ISNULL(project_owner, '')) > 0 THEN SUBSTRING(project_owner, CHARINDEX('-', project_owner) + 1, LEN(project_owner))
  618. WHEN responsible_department = 'R004' AND CHARINDEX('-', ISNULL(engineer, '')) > 0 THEN SUBSTRING(engineer, CHARINDEX('-', engineer) + 1, LEN(engineer))
  619. WHEN responsible_department = 'R005' AND CHARINDEX('-', ISNULL(c_quality_engineer1, '')) > 0 THEN SUBSTRING(c_quality_engineer1, CHARINDEX('-', c_quality_engineer1) + 1, LEN(c_quality_engineer1))
  620. WHEN responsible_department = 'R007' AND CHARINDEX('-', ISNULL(c_quality_engineer2, '')) > 0 THEN SUBSTRING(c_quality_engineer2, CHARINDEX('-', c_quality_engineer2) + 1, LEN(c_quality_engineer2))
  621. WHEN responsible_department = 'R008' AND CHARINDEX('-', ISNULL(c_quality_engineer3, '')) > 0 THEN SUBSTRING(c_quality_engineer3, CHARINDEX('-', c_quality_engineer3) + 1, LEN(c_quality_engineer3))
  622. WHEN responsible_department = 'R009' AND CHARINDEX('-', ISNULL(c_manufacture_engineer, '')) > 0 THEN SUBSTRING(c_manufacture_engineer, CHARINDEX('-', c_manufacture_engineer) + 1, LEN(c_manufacture_engineer))
  623. WHEN responsible_department = 'R011' AND CHARINDEX('-', ISNULL(c_quality_engineer4, '')) > 0 THEN SUBSTRING(c_quality_engineer4, CHARINDEX('-', c_quality_engineer4) + 1, LEN(c_quality_engineer4))
  624. WHEN responsible_department = 'R012' AND CHARINDEX('-', ISNULL(doc_engineer, '')) > 0 THEN SUBSTRING(doc_engineer, CHARINDEX('-', doc_engineer) + 1, LEN(doc_engineer))
  625. WHEN responsible_department = 'R013' AND CHARINDEX('-', ISNULL(c_quality_engineer5, '')) > 0 THEN SUBSTRING(c_quality_engineer5, CHARINDEX('-', c_quality_engineer5) + 1, LEN(c_quality_engineer5))
  626. WHEN responsible_department = 'R014' AND CHARINDEX('-', ISNULL(c_quality_engineer6, '')) > 0 THEN SUBSTRING(c_quality_engineer6, CHARINDEX('-', c_quality_engineer6) + 1, LEN(c_quality_engineer6))
  627. WHEN responsible_department = 'R015' AND CHARINDEX('-', ISNULL(ipqc_hard_tag, '')) > 0 THEN SUBSTRING(ipqc_hard_tag, CHARINDEX('-', ipqc_hard_tag) + 1, LEN(ipqc_hard_tag))
  628. WHEN responsible_department = 'R016' AND CHARINDEX('-', ISNULL(c_quality_engineer7, '')) > 0 THEN SUBSTRING(c_quality_engineer7, CHARINDEX('-', c_quality_engineer7) + 1, LEN(c_quality_engineer7))
  629. WHEN responsible_department = 'R017' AND CHARINDEX('-', ISNULL(doc_engineer2, '')) > 0 THEN SUBSTRING(doc_engineer2, CHARINDEX('-', doc_engineer2) + 1, LEN(doc_engineer2))
  630. ELSE ''
  631. END
  632. ) = #{query.projectLeader}
  633. </if>
  634. <if test="query.finalPartNo != null and query.finalPartNo != ''">
  635. and final_part_no = #{query.finalPartNo}
  636. </if>
  637. <if test="query.massProductionStartDate != null ">
  638. AND close_date >= #{query.massProductionStartDate}
  639. </if>
  640. <if test="query.massProductionEndDate != null ">
  641. AND #{query.massProductionEndDate} >= close_date
  642. </if>
  643. <if test="query.startDate != null ">
  644. AND build_date >= #{query.startDate}
  645. </if>
  646. <if test="query.endDate != null ">
  647. AND #{query.endDate} >= build_date
  648. </if>
  649. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  650. AND document_type_id like '%' + #{query.documentTypeId} + '%'
  651. </if>
  652. <if test="query.documentType != null and query.documentType != ''">
  653. AND document_type like '%' + #{query.documentType} + '%'
  654. </if>
  655. </where>
  656. order by project_id
  657. </select>
  658. <select id="queryPendingUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  659. SELECT * FROM view_plm_toupload_list_byUser
  660. <where>
  661. status != '草稿' AND RelatedPerson = #{user.userId}
  662. <if test="params.sql != null and params.sql != ''">
  663. ${params.sql}
  664. </if>
  665. </where>
  666. order by project_id
  667. </select>
  668. <select id="queryOverdueUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  669. <![CDATA[
  670. SELECT * FROM view_plm_toupload_list_byUser
  671. WHERE status != '草稿'
  672. AND Request_date < GETDATE()
  673. AND RelatedPerson = #{user.userId}
  674. ]]>
  675. <if test="params.sql != null and params.sql != ''">
  676. <![CDATA[
  677. ${params.sql}
  678. ]]>
  679. </if>
  680. <![CDATA[
  681. ORDER BY project_id
  682. ]]>
  683. </select>
  684. <select id="queryAllUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  685. SELECT * FROM view_plm_toupload_list_byUser
  686. <where>
  687. status != '草稿'
  688. <if test="params.sql != null and params.sql != ''">
  689. ${params.sql}
  690. </if>
  691. </where>
  692. order by project_id
  693. </select>
  694. <select id="getPendingConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  695. SELECT * FROM view_plm_toproconfirm_list_byUser
  696. <where>
  697. status != '草稿' AND RelatedPerson = #{userId}
  698. <if test="query.projectNo != null and query.projectNo != ''">
  699. AND (
  700. project_no like '%' + #{query.projectNo} + '%'
  701. OR project_no IN (
  702. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  703. )
  704. )
  705. </if>
  706. <if test="query.projectDesc != null and query.projectDesc != ''">
  707. and project_desc like '%' + #{query.projectDesc} + '%'
  708. </if>
  709. <if test="query.confirmFlag != null and query.confirmFlag != ''">
  710. and confirm_flag like #{query.confirmFlag}
  711. </if>
  712. <if test="query.testPartNo != null and query.testPartNo != ''">
  713. AND (
  714. test_part_no like '%' + #{query.testPartNo} + '%'
  715. OR test_part_no IN (
  716. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  717. )
  718. )
  719. </if>
  720. <if test="query.partDesc != null and query.partDesc != ''">
  721. and part_desc like '%' + #{query.partDesc} + '%'
  722. </if>
  723. <if test="query.customerNo != null and query.customerNo != ''">
  724. and customer_no like '%' + #{query.customerNo} + '%'
  725. </if>
  726. <if test="query.customerDesc != null and query.customerDesc != ''">
  727. and customer_desc like '%' + #{query.customerDesc} + '%'
  728. </if>
  729. <if test="query.buDesc != null and query.buDesc != ''">
  730. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  731. </if>
  732. <if test="query.projectCategory != null and query.projectCategory != ''">
  733. and project_category = #{query.projectCategory}
  734. </if>
  735. <if test="query.status != null and query.status != ''">
  736. and status = #{query.status}
  737. </if>
  738. <if test="query.projectManager != null and query.projectManager != ''">
  739. and project_manager = #{query.projectManager}
  740. </if>
  741. <if test="query.projectOwner != null and query.projectOwner != ''">
  742. and project_owner = #{query.projectOwner}
  743. </if>
  744. <if test="query.engineer != null and query.engineer != ''">
  745. and engineer = #{query.engineer}
  746. </if>
  747. <if test="query.startDate != null ">
  748. AND build_date >= #{query.startDate}
  749. </if>
  750. <if test="query.endDate != null ">
  751. AND #{query.endDate} >= build_date
  752. </if>
  753. </where>
  754. order by project_id
  755. </select>
  756. <select id="getOverdueConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  757. <![CDATA[
  758. SELECT * FROM view_plm_toproconfirm_list_byUser
  759. WHERE status != '草稿' AND confirm_flag = 'N' AND wanted_confirm_date < GETDATE() AND RelatedPerson = #{userId}
  760. ]]>
  761. <if test="query.projectNo != null and query.projectNo != ''">
  762. <![CDATA[
  763. AND (
  764. project_no like '%' + #{query.projectNo} + '%'
  765. OR project_no IN (
  766. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  767. )
  768. )
  769. ]]>
  770. </if>
  771. <if test="query.projectDesc != null and query.projectDesc != ''">
  772. <![CDATA[
  773. and project_desc like '%' + #{query.projectDesc} + '%'
  774. ]]>
  775. </if>
  776. <if test="query.confirmFlag != null and query.confirmFlag != ''">
  777. <![CDATA[
  778. and confirm_flag = #{query.confirmFlag}
  779. ]]>
  780. </if>
  781. <if test="query.testPartNo != null and query.testPartNo != ''">
  782. <![CDATA[
  783. AND (
  784. test_part_no like '%' + #{query.testPartNo} + '%'
  785. OR test_part_no IN (
  786. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  787. )
  788. )
  789. ]]>
  790. </if>
  791. <if test="query.partDesc != null and query.partDesc != ''">
  792. <![CDATA[
  793. and part_desc like '%' + #{query.partDesc} + '%'
  794. ]]>
  795. </if>
  796. <if test="query.customerNo != null and query.customerNo != ''">
  797. <![CDATA[
  798. AND customer_no LIKE '%' + #{query.customerNo} + '%'
  799. ]]>
  800. </if>
  801. <if test="query.customerDesc != null and query.customerDesc != ''">
  802. <![CDATA[
  803. AND customer_desc LIKE '%' + #{query.customerDesc} + '%'
  804. ]]>
  805. </if>
  806. <if test="query.buDesc != null and query.buDesc != ''">
  807. <![CDATA[
  808. AND dbo.get_bu_desc(site, bu_no) = #{query.buDesc}
  809. ]]>
  810. </if>
  811. <if test="query.projectCategory != null and query.projectCategory != ''">
  812. <![CDATA[
  813. AND project_category = #{query.projectCategory}
  814. ]]>
  815. </if>
  816. <if test="query.status != null and query.status != ''">
  817. <![CDATA[
  818. AND status = #{query.status}
  819. ]]>
  820. </if>
  821. <if test="query.projectManager != null and query.projectManager != ''">
  822. <![CDATA[
  823. AND project_manager = #{query.projectManager}
  824. ]]>
  825. </if>
  826. <if test="query.startDate != null">
  827. <![CDATA[
  828. AND build_date >= #{query.startDate}
  829. ]]>
  830. </if>
  831. <if test="query.endDate != null">
  832. <![CDATA[
  833. AND #{query.endDate} >= build_date
  834. ]]>
  835. </if>
  836. <![CDATA[
  837. ORDER BY project_id
  838. ]]>
  839. </select>
  840. <select id="getAllConfirmations"
  841. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  842. SELECT * FROM view_plm_toproconfirm_list_byUser
  843. <where>
  844. status != '草稿'
  845. <if test="query.projectNo != null and query.projectNo != ''">
  846. AND (
  847. project_no like '%' + #{query.projectNo} + '%'
  848. OR project_no IN (
  849. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  850. )
  851. )
  852. </if>
  853. <if test="query.projectDesc != null and query.projectDesc != ''">
  854. and project_desc like '%' + #{query.projectDesc} + '%'
  855. </if>
  856. <if test="query.confirmFlag != null and query.confirmFlag != ''">
  857. and confirm_flag = #{query.confirmFlag}
  858. </if>
  859. <if test="query.testPartNo != null and query.testPartNo != ''">
  860. AND (
  861. test_part_no like '%' + #{query.testPartNo} + '%'
  862. OR test_part_no IN (
  863. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  864. )
  865. )
  866. </if>
  867. <if test="query.partDesc != null and query.partDesc != ''">
  868. and part_desc like '%' + #{query.partDesc} + '%'
  869. </if>
  870. <if test="query.customerNo != null and query.customerNo != ''">
  871. and customer_no like '%' + #{query.customerNo} + '%'
  872. </if>
  873. <if test="query.customerDesc != null and query.customerDesc != ''">
  874. and customer_desc like '%' + #{query.customerDesc} + '%'
  875. </if>
  876. <if test="query.buDesc != null and query.buDesc != ''">
  877. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  878. </if>
  879. <if test="query.projectCategory != null and query.projectCategory != ''">
  880. and project_category = #{query.projectCategory}
  881. </if>
  882. <if test="query.status != null and query.status != ''">
  883. and status = #{query.status}
  884. </if>
  885. <if test="query.projectManager != null and query.projectManager != ''">
  886. and project_manager = #{query.projectManager}
  887. </if>
  888. <if test="query.projectOwner != null and query.projectOwner != ''">
  889. and project_owner = #{query.projectOwner}
  890. </if>
  891. <if test="query.engineer != null and query.engineer != ''">
  892. and engineer = #{query.engineer}
  893. </if>
  894. <if test="query.startDate != null ">
  895. AND build_date >= #{query.startDate}
  896. </if>
  897. <if test="query.endDate != null ">
  898. AND #{query.endDate} >= build_date
  899. </if>
  900. </where>
  901. </select>
  902. <select id="queryPendingConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  903. SELECT * FROM view_plm_toproconfirm_list_byUser
  904. <where>
  905. status != '草稿' AND RelatedPerson = #{user.userId}
  906. <if test="params.sql != null and params.sql != ''">
  907. ${params.sql}
  908. </if>
  909. </where>
  910. order by project_id
  911. </select>
  912. <select id="queryOverdueConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  913. <![CDATA[
  914. SELECT * FROM view_plm_toproconfirm_list_byUser
  915. WHERE status != '草稿' AND confirm_flag = 'N' AND wanted_confirm_date < GETDATE() AND RelatedPerson = #{userId}
  916. ]]>
  917. <if test="params.sql != null and params.sql != ''">
  918. <![CDATA[
  919. ${params.sql}
  920. ]]>
  921. </if>
  922. <![CDATA[
  923. ORDER BY project_id
  924. ]]>
  925. </select>
  926. <select id="queryAllConfirmProgressList" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  927. SELECT * FROM view_plm_toproconfirm_list_byUser
  928. <where>
  929. status != '草稿'
  930. <if test="params.sql != null and params.sql != ''">
  931. ${params.sql}
  932. </if>
  933. </where>
  934. order by project_id
  935. </select>
  936. <select id="getDocumentOwnerEmail">
  937. SELECT b.username FROM view_plm_toupload_list_byUser as a
  938. left join sys_user as b on a.RelatedPerson = b.user_id
  939. WHERE a.project_part_id = #{projectPartId}
  940. </select>
  941. <select id="getAllUploadsList" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  942. SELECT * FROM view_plm_toupload_list_byUser
  943. order by project_id
  944. </select>
  945. <select id="getAllConfirmationsList"
  946. resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  947. SELECT * FROM view_plm_toproconfirm_list_byUser
  948. </select>
  949. <!-- 插入文档 -->
  950. <insert id="insertDocument" parameterType="map">
  951. INSERT INTO plm_document_list_definition
  952. (site, proofing_id, test_part_id, project_id, created_by, manual_flag, uploaded_flag, create_date, document_type_id)
  953. VALUES
  954. (#{data.site}, #{data.proofingId}, #{data.projectPartId}, #{data.projectId}, #{data.createBy}, 'N', 'N', getDate(), #{documentTypeId})
  955. </insert>
  956. <!-- 插入文档 -->
  957. <insert id="insertProjectDocument" parameterType="map">
  958. INSERT INTO plm_document_list_definition
  959. (site, proofing_id, test_part_id, project_id, created_by, manual_flag, uploaded_flag, create_date, document_type_id)
  960. VALUES
  961. (#{data.site}, #{data.proofingId}, #{data.projectPartId}, #{data.projectId}, #{data.createBy}, 'N', 'N', getDate(), #{documentTypeId})
  962. </insert>
  963. <insert id="proofingDocumentNEWSave">
  964. INSERT INTO plm_document_list_definition
  965. (site,proofing_id, test_part_id, project_id,document_type_id,created_by,manual_flag,uploaded_flag,create_date)
  966. VALUES
  967. (#{site},#{proofingId}, #{projectPartId}, #{projectId},#{documentTypeId},#{createBy},'Y','N',GETDATE())
  968. </insert>
  969. <!-- 查询所有打样记录 -->
  970. <select id="queryAllProofing" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  971. SELECT b.id as project_id,
  972. ppp.id AS project_part_id,
  973. ppp.test_part_no,
  974. ppp.part_desc,
  975. b.project_no,
  976. b.ori_project_id,
  977. ppp.project_category,
  978. b.project_name,
  979. ppp.status,
  980. b.project_source,
  981. b.customer_no,
  982. b.priority,
  983. ppp.site,
  984. b.project_desc,
  985. b.customer_remark,
  986. ppp.need_date,
  987. b.bu_no,
  988. b.parent_project_no,
  989. b.final_customer_id,
  990. b.c_project_region,
  991. ppp.project_manager,
  992. ppp.project_owner,
  993. b.c_project_build_date,
  994. ppp.c_quality_engineer1,
  995. ppp.c_quality_engineer2,
  996. ppp.c_quality_engineer3,
  997. ppp.c_quality_engineer4,
  998. ppp.c_quality_engineer5,
  999. ppp.c_quality_engineer6,
  1000. ppp.c_manufacture_engineer,
  1001. ppp.doc_engineer,
  1002. ppp.doc_engineer2,
  1003. ppp.ipqc_hard_tag,
  1004. ppp.c_quality_engineer7,
  1005. ppp.close_date,
  1006. ppp.final_part_no,
  1007. ppp.build_date,
  1008. ppp.engineer,
  1009. ppi.id AS proofing_id,
  1010. ppi.proofing_no,
  1011. ppi.tracker,
  1012. ppi.priority_level,
  1013. ppi.proofing_number,
  1014. ppi.plan_start_date,
  1015. ppi.required_delivery_date,
  1016. ppi.remark,
  1017. ppi.technical_considerations,
  1018. ppi.is_need_to_send_samples,
  1019. ppi.send_samples_address,
  1020. ppi.consignee,
  1021. ppi.consignee_contact,
  1022. ppi.actuality_delivery_date,
  1023. ppi.proofing_result_information,
  1024. ppi.actuality_send_samples_date,
  1025. ppi.send_samples_method,
  1026. ppi.deliver_goods_information,
  1027. ppi.deliver_goods_remark,
  1028. ppi.actuality_reply_date,
  1029. ppi.confirm_results,
  1030. ppi.confirm_by,
  1031. ppi.confirm_information,
  1032. ppi.proofing_status,
  1033. ppi.proofing_result_status,
  1034. ppi.next_to_do,
  1035. ppi.approver,
  1036. ppi.step_id,
  1037. ppi.reject_flag,
  1038. ppi.reject_step_id,
  1039. ppi.c_project_type_db,
  1040. dbo.plm_get_customer_desc(b.site,b.customer_no) as customer_desc,
  1041. dbo.get_bu_desc(b.site,b.bu_no) as bu_desc,
  1042. ppi.create_by,
  1043. ppi.create_date,
  1044. ppi.update_by,
  1045. ppi.update_date,
  1046. ppi.project_phase
  1047. FROM plm_proofing_information as ppi
  1048. left join plm_project_info as b on ppi.project_id = b.id
  1049. left join plm_project_part as ppp on ppi.test_part_id = ppp.id
  1050. <where> ppp.status != '草稿'
  1051. <if test="query.projectNo != null and query.projectNo != ''">
  1052. AND (
  1053. b.project_no like '%' + #{query.projectNo} + '%'
  1054. OR b.project_no IN (
  1055. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.projectNo}, ',')
  1056. )
  1057. )
  1058. </if>
  1059. <if test="query.projectDesc != null and query.projectDesc != ''">
  1060. and b.project_desc like '%' + #{query.projectDesc} + '%'
  1061. </if>
  1062. <if test="query.testPartNo != null and query.testPartNo != ''">
  1063. AND (
  1064. ppp.test_part_no like '%' + #{query.testPartNo} + '%'
  1065. OR ppp.test_part_no IN (
  1066. SELECT Value FROM CKT_MES_II_REAL.dbo.SplitString(#{query.testPartNo}, ',')
  1067. )
  1068. )
  1069. </if>
  1070. <if test="query.partDesc != null and query.partDesc != ''">
  1071. and ppp.part_desc like '%' + #{query.partDesc} + '%'
  1072. </if>
  1073. <if test="query.proofingNo != null and query.proofingNo != ''">
  1074. and ppi.proofing_no like '%' + #{query.proofingNo} + '%'
  1075. </if>
  1076. <if test="query.projectManager != null and query.projectManager != ''">
  1077. and ppp.project_manager = #{query.projectManager}
  1078. </if>
  1079. <if test="query.projectOwner != null and query.projectOwner != ''">
  1080. and ppp.project_owner = #{query.projectOwner}
  1081. </if>
  1082. <if test="query.engineer != null and query.engineer != ''">
  1083. and ppp.engineer = #{query.engineer}
  1084. </if>
  1085. <if test="query.customerNo != null and query.customerNo != ''">
  1086. and b.customer_no like '%' + #{query.customerNo} + '%'
  1087. </if>
  1088. <if test="query.customerDesc != null and query.customerDesc != ''">
  1089. and dbo.plm_get_customer_desc(b.site,b.customer_no) like '%' + #{query.customerDesc} + '%'
  1090. </if>
  1091. <if test="query.buDesc != null and query.buDesc != ''">
  1092. AND dbo.get_bu_desc ( b.site,b.bu_no ) = #{query.buDesc}
  1093. </if>
  1094. <if test="query.cProjectTypeDb != null and query.cProjectTypeDb != ''">
  1095. and ppi.c_project_type_db = #{query.cProjectTypeDb}
  1096. </if>
  1097. <if test="query.status != null and query.status != ''">
  1098. and ppp.status = #{query.status}
  1099. </if>
  1100. <if test="query.startDate != null ">
  1101. AND ppp.build_date >= #{query.startDate}
  1102. </if>
  1103. <if test="query.endDate != null ">
  1104. AND #{query.endDate} >= ppp.build_date
  1105. </if>
  1106. <if test="query.proofingStatus != null and query.proofingStatus != ''">
  1107. and ppi.proofing_status = #{query.proofingStatus}
  1108. </if>
  1109. <if test="query.proofingResultStatus != null and query.proofingResultStatus != ''">
  1110. and ppi.proofing_result_status = #{query.proofingResultStatus}
  1111. </if>
  1112. </where>
  1113. </select>
  1114. <select id="queryAllProofing2" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  1115. SELECT b.id as project_id,
  1116. ppp.id AS project_part_id,
  1117. ppp.test_part_no,
  1118. ppp.part_desc,
  1119. b.project_no,
  1120. b.ori_project_id,
  1121. ppp.project_category,
  1122. b.project_name,
  1123. ppp.status,
  1124. b.project_source,
  1125. b.customer_no,
  1126. b.priority,
  1127. ppp.site,
  1128. b.project_desc,
  1129. b.customer_remark,
  1130. ppp.need_date,
  1131. b.bu_no,
  1132. b.parent_project_no,
  1133. b.final_customer_id,
  1134. b.c_project_region,
  1135. ppp.project_manager,
  1136. ppp.project_owner,
  1137. b.c_project_build_date,
  1138. ppp.c_quality_engineer1,
  1139. ppp.c_quality_engineer2,
  1140. ppp.c_quality_engineer3,
  1141. ppp.c_quality_engineer4,
  1142. ppp.c_quality_engineer5,
  1143. ppp.c_quality_engineer6,
  1144. ppp.c_manufacture_engineer,
  1145. ppp.doc_engineer,
  1146. ppp.doc_engineer2,
  1147. ppp.ipqc_hard_tag,
  1148. ppp.c_quality_engineer7,
  1149. ppp.close_date,
  1150. ppp.final_part_no,
  1151. ppp.build_date,
  1152. ppp.engineer,
  1153. ppi.id AS proofing_id,
  1154. ppi.proofing_no,
  1155. ppi.tracker,
  1156. ppi.priority_level,
  1157. ppi.proofing_number,
  1158. ppi.plan_start_date,
  1159. ppi.required_delivery_date,
  1160. ppi.remark,
  1161. ppi.technical_considerations,
  1162. ppi.is_need_to_send_samples,
  1163. ppi.send_samples_address,
  1164. ppi.consignee,
  1165. ppi.consignee_contact,
  1166. ppi.actuality_delivery_date,
  1167. ppi.proofing_result_information,
  1168. ppi.actuality_send_samples_date,
  1169. ppi.send_samples_method,
  1170. ppi.deliver_goods_information,
  1171. ppi.deliver_goods_remark,
  1172. ppi.actuality_reply_date,
  1173. ppi.confirm_results,
  1174. ppi.confirm_by,
  1175. ppi.confirm_information,
  1176. ppi.proofing_status,
  1177. ppi.proofing_result_status,
  1178. ppi.next_to_do,
  1179. ppi.approver,
  1180. ppi.step_id,
  1181. ppi.reject_flag,
  1182. ppi.reject_step_id,
  1183. ppi.c_project_type_db,
  1184. dbo.plm_get_customer_desc(b.site,b.customer_no) as customer_desc,
  1185. dbo.get_bu_desc(b.site,b.bu_no) as bu_desc,
  1186. ppi.create_by,
  1187. ppi.create_date,
  1188. ppi.update_by,
  1189. ppi.update_date
  1190. FROM plm_proofing_information as ppi
  1191. left join plm_project_info as b on ppi.project_id = b.id
  1192. left join plm_project_part as ppp on ppi.test_part_id = ppp.id
  1193. <where> ppp.status != '草稿'
  1194. <if test="params.sql != null and params.sql != ''">
  1195. ${params.sql}
  1196. </if>
  1197. </where>
  1198. </select>
  1199. <select id="queryPlmUser"
  1200. resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  1201. Select a.username, a.user_display, a.user_id from sys_user as a left join access_role as b on a.username = b.username where b.role_no = 'R002' and a.site = #{site}
  1202. </select>
  1203. <select id="selecProofingOneByNo" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  1204. SELECT * FROM plm_proofing_information WHERE proofing_no = #{proofingNo}
  1205. </select>
  1206. <!-- 试验申请单附件同步至打样文档:文档类型为「试验申请单+三方签字」(与前端 document_type + document_desc 展示一致) -->
  1207. <select id="selectDocumentListIdForErfProofCopy" resultType="java.lang.Integer">
  1208. SELECT TOP 1 p.id
  1209. FROM plm_document_list_definition AS p
  1210. INNER JOIN document_type_definition AS dtd
  1211. ON p.document_type_id = dtd.document_type_id AND p.site = dtd.Site
  1212. WHERE p.site = #{site}
  1213. AND p.proofing_id = #{proofingId}
  1214. AND p.project_id = #{projectId}
  1215. AND p.test_part_id = #{projectPartId}
  1216. AND dtd.document_type LIKE N'%试验申请单%'
  1217. AND dtd.document_type LIKE N'%三方签字%'
  1218. </select>
  1219. <select id="getCopyDocumentFileList" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  1220. Select t.site,t.project_id,pi.project_no,pi.project_desc,t.test_part_id,ppp.test_part_no,ppp.part_desc,t.proofing_id,isnull(ppi.proofing_no,'*') as proofing_no,t.id,t.document_type_id,dtd.document_type,dtd.estimated_completion_days,(SELECT role_desc FROM business_role WHERE role_no = dtd.responsible_department AND site = '2') AS responsible_department
  1221. ,t.uploaded_flag,d.file_name,d.create_date,d.created_by,d.id as oss_id,d.conclusion,d.url
  1222. from plm_document_list_definition as t
  1223. left join sys_oss as d on convert(varchar(50),t.site)=d.order_ref1
  1224. and convert(varchar(50),t.project_id)=d.order_ref4
  1225. and convert(varchar(50),t.test_part_id)=d.order_ref5
  1226. and convert(varchar(50),t.proofing_id)=d.order_ref2
  1227. and convert(varchar(50),t.id)=d.order_ref3
  1228. and d.order_reftype='项目文档' --固定代码
  1229. LEFT JOIN plm_project_info as pi on t.site = pi.site and t.project_id = pi.id
  1230. LEFT JOIN plm_project_part as ppp on t.test_part_id = ppp.id and t.site = ppp.site
  1231. left join plm_proofing_information as ppi on t.site=ppi.site and t.proofing_id=ppi.id
  1232. ,document_type_definition as dtd
  1233. where t.document_type_id=dtd.document_type_id
  1234. and t.uploaded_flag = 'Y'
  1235. AND d.order_reftype = '项目文档'
  1236. and t.site= #{site}
  1237. and t.project_id= #{projectId}
  1238. and t.document_type_id = #{documentTypeId}
  1239. ORDER BY t.test_part_id , t.proofing_id
  1240. </select>
  1241. </mapper>