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.

286 lines
14 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.ProofingInformationMapper">
  5. <insert id="proofingInformationSave">
  6. INSERT INTO plm_proofing_information
  7. (site,proofing_no,project_id,test_part_no,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,update_date,update_by,approver,step_id,reject_flag,reject_step_id,c_project_type_db,project_phase)
  8. VALUES
  9. (#{site},#{proofingNo},#{projectId},#{testPartNo},#{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},getDate(),#{updateBy},#{approver},#{stepId},#{rejectFlag},#{rejectStepId},#{cProjectTypeDb},#{projectPhase})
  10. </insert>
  11. <update id="updateProofingInfoById">
  12. UPDATE plm_proofing_information
  13. SET
  14. proofing_number = #{proofingNumber},
  15. plan_start_date = #{planStartDate},
  16. required_delivery_date = #{requiredDeliveryDate},
  17. actuality_delivery_date = #{actualityDeliveryDate},
  18. update_date = getDate(),
  19. update_by = #{updateBy},
  20. c_project_type_db = #{cProjectTypeDb},
  21. project_phase = #{projectPhase}
  22. WHERE id = #{id}
  23. </update>
  24. <update id="updateProofingInfoById1">
  25. UPDATE plm_proofing_information
  26. SET
  27. proofing_number = #{proofingNumber},
  28. plan_start_date = #{planStartDate},
  29. required_delivery_date = #{requiredDeliveryDate},
  30. update_date = getDate(),
  31. update_by = #{updateBy},
  32. c_project_type_db = #{cProjectTypeDb},
  33. project_phase = #{projectPhase}
  34. WHERE id = #{id}
  35. </update>
  36. <update id="updateDocumentListUploadedFlag">
  37. UPDATE plm_document_list_definition
  38. SET uploaded_flag = 'N'
  39. WHERE site = #{site} AND proofing_id = #{proofingId} AND project_id = #{projectId}
  40. </update>
  41. <select id="proofingInformationSearch" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  42. SELECT
  43. a.id,
  44. a.site,
  45. a.proofing_no,
  46. a.project_id,
  47. a.test_part_no,
  48. a.customer_no,
  49. a.tracker,
  50. a.engineer,
  51. a.priority_level,
  52. a.proofing_number,
  53. a.plan_start_date,
  54. a.required_delivery_date,
  55. a.remark,
  56. a.technical_considerations,
  57. a.is_need_to_send_samples,
  58. a.send_samples_address,
  59. a.consignee,
  60. a.consignee_contact,
  61. a.actuality_delivery_date,
  62. a.proofing_result_information,
  63. a.actuality_send_samples_date,
  64. a.send_samples_method,
  65. a.deliver_goods_information,
  66. a.deliver_goods_remark,
  67. a.actuality_reply_date,
  68. a.confirm_results,
  69. a.confirm_by,
  70. a.confirm_information,
  71. a.proofing_status,
  72. a.proofing_result_status,
  73. a.next_to_do,
  74. a.create_date,
  75. a.create_by,
  76. a.update_date,
  77. a.update_by,
  78. a.approver,
  79. a.step_id,
  80. a.reject_flag,
  81. a.reject_step_id,
  82. a.c_project_type_db,
  83. a.project_phase,
  84. b.project_category,
  85. b.bu_no,
  86. b.project_desc,
  87. c.customer_desc,
  88. d.part_desc
  89. FROM plm_proofing_information as a
  90. LEFT JOIN plm_project_info as b ON a.project_id = b.project_id and a.site = b.site
  91. LEFT JOIN plm_customer_information AS c ON c.customer_no = b.customer_no and c.site = b.site
  92. LEFT JOIN plm_project_part AS d ON d.project_id = b.project_id
  93. <where>
  94. <if test="query.projectId != null and query.projectId != ''">
  95. and a.project_id = #{query.projectId}
  96. </if>
  97. </where>
  98. order by a.create_date desc
  99. </select>
  100. <select id="getProofDocument" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  101. {call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{testPartNo,mode=IN}, #{proofingNo, mode=IN})}
  102. </select>
  103. <delete id="deleteDocumentType">
  104. DELETE FROM plm_document_list_definition WHERE id = #{documentDefinitionListId}
  105. </delete>
  106. <delete id="deleteProofingDocument">
  107. DELETE a
  108. FROM
  109. plm_document_list_definition as a
  110. INNER join bu_document_list_definition as b on a.document_type_id = b.document_type_id and a.site = b.site
  111. WHERE a.proofing_id = #{proofingNo} and b.project_category = #{cProjectTypeDb}
  112. </delete>
  113. <delete id="deleteProofingDocument1">
  114. DELETE FROM CKT_MES_II_REAL.dbo.sys_oss WHERE id = #{documentId}
  115. </delete>
  116. <delete id="deleteProjectDocument">
  117. DELETE a
  118. FROM
  119. plm_document_list_definition as a
  120. INNER join bu_document_list_definition as b on a.document_type_id = b.document_type_id and a.site = b.site
  121. WHERE a.proofing_id = '*' and b.project_category = #{projectCategory} and project_id = #{projectId}
  122. </delete>
  123. <delete id="proofingInformationDelete">
  124. DELETE FROM plm_proofing_information WHERE proofing_no = #{proofingNo} and site = #{site} and project_id = #{projectId}
  125. </delete>
  126. <delete id="deleteDocumentDefinitionById">
  127. DELETE FROM plm_document_list_definition WHERE id = #{documentDefinitionListId}
  128. </delete>
  129. <select id="selecProofingOne" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  130. SELECT * FROM plm_proofing_information WHERE id = #{id}
  131. </select>
  132. <!-- 查询documentTypeId列表 -->
  133. <select id="getDocumentTypeIds" resultType="string" parameterType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  134. SELECT document_type_id
  135. FROM bu_document_list_definition
  136. WHERE site = #{site}
  137. AND bu_no = #{buNo}
  138. AND project_category = #{cProjectTypeDb}
  139. AND project_phase = 'Sample'
  140. </select>
  141. <!-- 查询documentTypeId列表 -->
  142. <select id="getProjectDocumentTypeIds" resultType="string" parameterType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  143. SELECT document_type_id
  144. FROM bu_document_list_definition
  145. WHERE site = #{site}
  146. AND bu_no = #{buNo}
  147. AND project_category = #{projectCategory}
  148. AND project_phase = 'Mass production'
  149. </select>
  150. <!-- 检查文档是否存在 -->
  151. <select id="documentExists" resultType="boolean" parameterType="map">
  152. SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
  153. FROM plm_document_list_definition
  154. WHERE site = #{data.site}
  155. AND proofing_id = #{data.proofingNo}
  156. AND project_id = #{data.projectId}
  157. AND document_type_id = #{documentTypeId}
  158. </select>
  159. <!-- 检查文档是否存在 -->
  160. <select id="projectDocumentExists" resultType="boolean" parameterType="map">
  161. SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
  162. FROM plm_document_list_definition
  163. WHERE site = #{data.site}
  164. AND proofing_id = #{data.proofingNo}
  165. AND project_id = #{data.projectId}
  166. AND document_type_id = #{documentTypeId}
  167. </select>
  168. <select id="getExtraDocumentList" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  169. SELECT
  170. a.document_type_id,
  171. a.document_type,
  172. (SELECT role_desc FROM business_role WHERE role_no = a.responsible_department) AS responsible_department,
  173. a.estimated_completion_days
  174. FROM document_type_definition as a
  175. where
  176. a.site = #{query.site}
  177. AND a.document_type_id NOT IN (
  178. SELECT document_type_id
  179. FROM plm_document_list_definition
  180. WHERE site = #{query.site}
  181. AND proofing_id = #{query.proofingNo}
  182. AND project_id = #{query.projectId}
  183. )
  184. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  185. AND a.document_type_id like '%' + #{query.documentTypeId} + '%'
  186. </if>
  187. <if test="query.documentType != null and query.documentType != ''">
  188. AND a.document_type like '%' + #{query.documentType} + '%'
  189. </if>
  190. <if test="query.responsibleDepartment != null and query.responsibleDepartment != ''">
  191. AND a.responsible_department like '%' + #{query.responsibleDepartment} + '%'
  192. </if>
  193. </select>
  194. <select id="documentExists1" resultType="java.lang.Boolean">
  195. SELECT CASE WHEN COUNT(1) > 0 THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END
  196. FROM plm_document_list_definition
  197. WHERE site = #{data.site}
  198. AND proofing_id = #{data.proofingNo}
  199. AND project_id = #{data.projectId}
  200. AND document_type_id = #{documentTypeId}
  201. </select>
  202. <select id="selectProjectList" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  203. SELECT a.*,b.project_category FROM plm_document_list_definition as a
  204. left join plm_project_info as b on a.project_id = b.project_id
  205. left join bu_document_list_definition as c on a.document_type_id = c.document_type_id
  206. WHERE a.project_id = #{projectId} and a.proofing_id = '*' and c.project_phase = 'Mass Production'
  207. </select>
  208. <select id="searchProjectAllDocument" parameterType="map" statementType="CALLABLE" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  209. {call plm_getdocumentlist(#{site, mode=IN}, #{projectId, mode=IN}, #{testPartNo,mode=IN}, #{proofingNo, mode=IN})}
  210. </select>
  211. <select id="queryProofingNo" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  212. SELECT * FROM plm_proofing_information WHERE site = #{site} and project_id = #{projectId} and proofing_no = #{proofingNo}
  213. </select>
  214. <select id="selectProofingDocument" resultType="com.xujie.sys.modules.pms.data.ProofingInformationData">
  215. SELECT
  216. c.id
  217. FROM
  218. sys_oss AS a
  219. LEFT JOIN plm_document_list_definition AS b ON CAST ( b.id AS VARCHAR ) = a.order_ref3
  220. LEFT JOIN bu_document_list_definition AS c ON b.document_type_id = c.document_type_id
  221. WHERE b.proofing_id = #{proofingNo} and c.project_category = #{cProjectTypeDb} and c.project_phase = 'Sample'
  222. </select>
  223. <select id="checkProductionConfirmationDocument" resultType="boolean">
  224. SELECT
  225. CASE
  226. WHEN EXISTS (
  227. SELECT 1
  228. FROM plm_project_document_confirm_file_list AS a
  229. WHERE Site = #{site} AND document_type = #{documentType} AND Order_Ref1 = #{OrderRef1} AND document_id = #{documentId}
  230. ) THEN 1
  231. ELSE 0
  232. END AS exists_flag
  233. </select>
  234. <select id="getPendingUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  235. SELECT * FROM view_plm_toupload_list_byUser
  236. WHERE status != '草稿' AND uploaded_flag = 'N' AND RelatedPerson = #{userId}
  237. order by project_id
  238. </select>
  239. <select id="getOverdueUploads" resultType="com.xujie.sys.modules.pms.data.ProofDocumentData">
  240. <![CDATA[
  241. SELECT * FROM view_plm_toupload_list_byUser
  242. WHERE status != '草稿' AND uploaded_flag = 'N' AND Request_date < GETDATE() AND RelatedPerson = #{userId}
  243. order by project_id
  244. ]]>
  245. </select>
  246. <select id="getPendingConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  247. SELECT * FROM view_plm_toproconfirm_list_byUser
  248. WHERE status != '草稿' AND confirm_flag = 'N' AND RelatedPerson = #{userId}
  249. order by project_id
  250. </select>
  251. <select id="getOverdueConfirmations" resultType="com.xujie.sys.modules.pms.data.ProjectProductionValidationDocumentData">
  252. <![CDATA[
  253. SELECT * FROM view_plm_toproconfirm_list_byUser
  254. WHERE status != '草稿' AND confirm_flag = 'N' AND wanted_confirm_date < GETDATE() AND RelatedPerson = #{userId}
  255. order by project_id
  256. ]]>
  257. </select>
  258. <!-- 插入文档 -->
  259. <insert id="insertDocument" parameterType="map">
  260. INSERT INTO plm_document_list_definition
  261. (site, proofing_id, project_id, created_by, manual_flag, uploaded_flag, create_date, document_type_id)
  262. VALUES
  263. (#{data.site}, #{data.proofingNo}, #{data.projectId}, #{data.createBy}, 'N', 'N', getDate(), #{documentTypeId})
  264. </insert>
  265. <!-- 插入文档 -->
  266. <insert id="insertProjectDocument" parameterType="map">
  267. INSERT INTO plm_document_list_definition
  268. (site, proofing_id, project_id, created_by, manual_flag, uploaded_flag, create_date, document_type_id)
  269. VALUES
  270. (#{data.site}, #{data.proofingNo}, #{data.projectId}, #{data.createBy}, 'N', 'N', getDate(), #{documentTypeId})
  271. </insert>
  272. <insert id="proofingDocumentNEWSave">
  273. INSERT INTO plm_document_list_definition
  274. (site,proofing_id,project_id,document_type_id,created_by,manual_flag,uploaded_flag,create_date)
  275. VALUES
  276. (#{site},#{proofingNo},#{projectId},#{documentTypeId},#{createBy},'Y','N',GETDATE())
  277. </insert>
  278. </mapper>