ContractManagementMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. <mapper namespace="com.fuzamei.mapperInterface.ContractManagementMapper">
  4. <!-- 根据条件查询所有符合条件的合同状态跟踪(contract_status_tracking)信息 -->
  5. <select id="queryContractStatusTracking" resultType="com.fuzamei.entity.ContractStatusTracking">
  6. select
  7. sct.id,
  8. sct.business_id,
  9. sct.contract_id,
  10. att.attachment_name as contract_name,
  11. att.url as url,
  12. sct.contract_party,
  13. sct.update_time,
  14. sct.status_id,
  15. s.status_name
  16. from
  17. contract_status_tracking sct
  18. left join
  19. status s
  20. on
  21. sct.status_id=s.status_id
  22. left join
  23. attachment att
  24. on
  25. sct.contract_id=att.attachment_id
  26. <where>
  27. <if test="businessId!=null">
  28. sct.business_id=#{businessId}
  29. </if>
  30. <if test="contractParty!='' and contractParty!=null">
  31. and sct.contract_party=#{contractParty}
  32. </if>
  33. <if test="startTime!=null and endTime!=null">
  34. and sct.update_time between #{startTime} and #{endTime}
  35. </if>
  36. </where>
  37. order by
  38. sct.update_time desc
  39. limit
  40. #{startPage},#{rowNum}
  41. </select>
  42. <!-- 根据条件查询所有符合条件的合同状态跟踪信息(contract_status_tracking)条数 -->
  43. <select id="findAllContractStatusTrackingInformation" resultType="int">
  44. select
  45. count(*)
  46. from
  47. contract_status_tracking
  48. <where>
  49. <if test="businessId!=null">
  50. business_id=#{businessId}
  51. </if>
  52. <if test="contractParty!='' and contractParty!=null">
  53. and contract_party=#{contractParty}
  54. </if>
  55. <if test="startTime!=null and endTime!=null">
  56. and update_time between #{startTime} and #{endTime}
  57. </if>
  58. </where>
  59. </select>
  60. <!-- 根据条件查询所有符合条件的合同记录表(contract_record)表信息 -->
  61. <select id="queryContractRecord" resultType="com.fuzamei.entity.ContractRecord">
  62. select
  63. cr.id,
  64. cr.business_id,
  65. cr.contract_id,
  66. cr.contract_name,
  67. cr.version,
  68. cr.contract_party,
  69. cr.upload_department,
  70. cr.upload_person,
  71. cr.modify_opinion,
  72. cr.unconfirm_department,
  73. s.status_name,
  74. cr.status_id,
  75. cr.commit_time,
  76. cr.hash
  77. from
  78. contract_record cr
  79. left join
  80. status s
  81. on
  82. s.status_id=cr.status_id
  83. where
  84. cr.business_id=#{businessId}
  85. order by
  86. cr.commit_time desc
  87. limit
  88. #{startPage},#{rowNum}
  89. </select>
  90. <!-- 根据条件查询所有符合条件的合同记录表(contract_record)信息条数 -->
  91. <select id="findAllContractRecordInformation" resultType="int">
  92. select
  93. count(*)
  94. from
  95. contract_record
  96. where
  97. business_id=#{businessId}
  98. </select>
  99. <!-- 根据业务id查询ContractStatusTracking的详细信息 -->
  100. <select id="getContractStatusTrackingByBusinessId" resultType="com.fuzamei.entity.ContractStatusTracking">
  101. select
  102. sct.id,
  103. sct.business_id,
  104. sct.contract_id,
  105. att.attachment_name as contract_name,
  106. att.url as url,
  107. sct.contract_party,
  108. sct.update_time,
  109. sct.status_id,
  110. s.status_name
  111. from
  112. contract_status_tracking sct
  113. left join
  114. status s
  115. on
  116. sct.status_id=s.status_id
  117. left join
  118. attachment att
  119. on
  120. sct.contract_id=att.attachment_id
  121. where
  122. sct.business_id=#{businessId}
  123. </select>
  124. <!-- 将数据插入附件表中 -->
  125. <insert id="insertInformationToAttachment">
  126. insert into
  127. attachment(attachment_id,
  128. attachment_name,
  129. url,
  130. upload_person_id,
  131. create_time)
  132. values(#{attachmentId},
  133. #{attachmentName},
  134. #{url},
  135. #{userId},
  136. #{createTime})
  137. </insert>
  138. <!-- 将信息插入到操作记录表中 -->
  139. <insert id="insertInformationToOperationHistory">
  140. insert into
  141. operation_history(operator_type_id,
  142. operator_account,
  143. operator_role,
  144. operator_person,
  145. operator_time,
  146. hash)
  147. values(#{operatorTypeId},
  148. #{operatorAccount},
  149. #{operatorRole},
  150. #{operatorPerson},
  151. #{operatorTime},
  152. #{hash})
  153. </insert>
  154. <!-- 根据业务id号获取最新的合同记录表中的一条信息 -->
  155. <select id="getLatestContractRecordByBusinessId" resultType="com.fuzamei.entity.ContractRecord">
  156. select
  157. cr.id,
  158. cr.business_id,
  159. cr.contract_id,
  160. cr.contract_name,
  161. cr.version,
  162. cr.contract_party,
  163. cr.upload_department,
  164. cr.upload_person,
  165. cr.modify_opinion,
  166. cr.unconfirm_department,
  167. s.status_name,
  168. cr.status_id,
  169. cr.commit_time,
  170. cr.hash
  171. from
  172. contract_record cr
  173. left join
  174. status s
  175. on
  176. s.status_id=cr.status_id
  177. where
  178. cr.business_id=#{businessId}
  179. order by
  180. cr.version desc
  181. limit 1
  182. </select>
  183. <!-- 将合同记录信息插入到合同记录表中 -->
  184. <insert id="insertInformationToContractRecord">
  185. insert into
  186. contract_record(business_id,
  187. contract_id,
  188. contract_name,
  189. version,
  190. contract_party,
  191. upload_department,
  192. upload_person,
  193. modify_opinion,
  194. unconfirm_department,
  195. status_id,
  196. commit_time,
  197. hash)
  198. values(#{businessId},
  199. #{contractId},
  200. #{contractName},
  201. #{version},
  202. #{contractParty},
  203. #{uploadDepartment},
  204. #{uploadPerson},
  205. #{modifyOpinion},
  206. #{uncomfirmDepartment},
  207. #{statusId}
  208. #{commitTime},
  209. #{hash})
  210. </insert>
  211. <!-- 对合同状态跟踪表中的更新时间和合同id号进行修改 -->
  212. <update id="updateContractStatusTracking">
  213. update
  214. contract_status_tracking
  215. set
  216. contract_id=#{contractId},
  217. update_time=#{updateTime}
  218. where
  219. business_id=#{businessId}
  220. </update>
  221. <!-- 根据业务id和版本号获取当前的一条合同记录详细信息 -->
  222. <select id="getCurrentContractRecordByBusinessId" resultType="com.fuzamei.entity.ContractRecord">
  223. select
  224. cr.id,
  225. cr.business_id,
  226. cr.contract_id,
  227. cr.contract_name,
  228. cr.version,
  229. cr.contract_party,
  230. cr.upload_department,
  231. cr.upload_person,
  232. cr.modify_opinion,
  233. cr.unconfirm_department,
  234. s.status_name,
  235. cr.status_id,
  236. cr.commit_time,
  237. cr.hash
  238. from
  239. contract_record cr
  240. left join
  241. status s
  242. on
  243. s.status_id=cr.status_id
  244. where
  245. cr.business_id=#{businessId}
  246. and cr.version=#{version}
  247. </select>
  248. <!-- 更新合同记录表的信息 -->
  249. <update id="updateContractRecord">
  250. update
  251. contract_record
  252. set
  253. commit_time=#{commitTime},
  254. unconfirm_department=#{unconfirmed},
  255. status_id=#{statusId}
  256. where
  257. business_id=#{businessId}
  258. and version=#{version}
  259. </update>
  260. <!-- 在指定业务id下将除了目标version以外的所有信息全部置为作废 -->
  261. <update id="updateOtherContractRecord">
  262. update
  263. contract_record
  264. set
  265. status_id=#{statusId},
  266. commit_time=#{commitTime}
  267. where
  268. business_id=#{businessId}
  269. and version not in(#{version})
  270. </update>
  271. <!-- 当整个合同被确认以后,更新合同状态跟踪表中的状态,时间和合同id号 -->
  272. <update id="updateContractStatusTrackingStatusAndContractId">
  273. update
  274. contract_status_tracking
  275. set
  276. contract_id=#{contractId},
  277. update_time=#{updateTime},
  278. status_id=#{statusId}
  279. where
  280. business_id=#{businessId}
  281. </update>
  282. </mapper>