BusinessDeclareMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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,namespace的值习惯上设置成包名+sql映射文件名,这样就能够保证namespace的值是唯一的,例如namespace="me.gacl.mapping.userMapper"就是me.gacl.mapping(包名)+userMapper(userMapper.xml文件去除后缀)
  4. -->
  5. <mapper namespace="com.fuzamei.mapperInterface.BusinessDeclareMapper">
  6. <!-- 支行业务申请,将新的数据插入到数据库中的业务申请表中 -->
  7. <insert id="insertBusinessDeclareInformationToDaoByBranchBank">
  8. insert into
  9. business_declare(business_id,
  10. bank_id,
  11. business_name,
  12. business_approval_id,
  13. responsible_investigation_id,
  14. product_approval_id,
  15. basic_data_id,
  16. declare_time,
  17. status_id,
  18. hash)
  19. values(#{businessId},
  20. #{bank},
  21. #{businessName},
  22. #{busineeApprovalId},
  23. #{responsibleInvestigationId},
  24. #{productApprovalId},
  25. #{basicDataId},
  26. #{declareTime},
  27. #{statusId},
  28. #{hash})
  29. </insert>
  30. <!-- 将附件信息插入附件表中 -->
  31. <insert id="insertAttachmentInformationToDaoByBranchBank">
  32. insert into
  33. attachment(attachment_id,
  34. attachment_name,
  35. url,
  36. upload_person_id,
  37. create_time)
  38. values(#{attachmentId},
  39. #{attachmentName},
  40. #{url},
  41. #{userId},
  42. #{createTime})
  43. </insert>
  44. <!-- 当经办支行进行业务申报的时候往操作记录表中插入一条数据 -->
  45. <insert id="insertOperationHistoryInformationToDaoByBranchBank">
  46. insert into
  47. operation_history(operator_type_id,
  48. operator_account,
  49. operator_role,
  50. operator_person,
  51. operator_time,
  52. hash)
  53. values(#{operatorTypeId},
  54. #{operatorAccount},
  55. #{operatorRole},
  56. #{operatorPerson},
  57. #{operatorTime},
  58. #{hash})
  59. </insert>
  60. <!-- 返回总页数 -->
  61. <select id="findAllInfromations" resultType="int">
  62. select
  63. count(*)
  64. from
  65. business_declare
  66. <where>
  67. <if test="businessName!='' and businessName!=null">
  68. business_name=#{businessName}
  69. </if>
  70. <if test="startTime!=null and endTime!=null">
  71. and declare_time between #{startTime} and #{endTime}
  72. </if>
  73. </where>
  74. </select>
  75. <!-- 根据条件或不根据条件查询业务申请信息,并返回给前端,需要进行6表关联查询,1张业务申请表,4张附件表,1张状态表 -->
  76. <select id="queryBusinessDeclareInformation" resultType="com.fuzamei.entity.BusinessDeclare">
  77. select
  78. bd.business_id,
  79. bd.bank_id,
  80. bd.business_name,
  81. a1.attachment_name as business_approval_name,
  82. a1.url as business_approval_url,
  83. a2.attachment_name as responsible_investigation_name,
  84. a2.url as responsible_investigation_url,
  85. a3.attachment_name as product_approval_name,
  86. a3.url as product_approval_url,
  87. a4.attachment_name as basic_data_name,
  88. a4.url as basic_data_url,
  89. bd.declare_time,
  90. s.status_name,
  91. bd.hash
  92. from
  93. business_declare bd
  94. left join
  95. attachment a1
  96. on
  97. a1.attachment_id=bd.business_approval_id
  98. left join
  99. attachment a2
  100. on
  101. a2.attachment_id=bd.responsible_investigation_id
  102. left join
  103. attachment a3
  104. on
  105. a3.attachment_id=bd.product_approval_id
  106. left join
  107. attachment a4
  108. on
  109. a4.attachment_id=bd.basic_data_id
  110. left join
  111. status s
  112. on
  113. s.status_id=bd.status_id
  114. <where>
  115. <if test="businessName!='' and businessName!=null">
  116. bd.business_name=#{businessName}
  117. </if>
  118. <if test="startTime!=null and endTime!=null">
  119. and bd.declare_time between #{startTime} and #{endTime}
  120. </if>
  121. </where>
  122. order by
  123. bd.declare_time desc
  124. limit
  125. #{startPage},#{rowNum}
  126. </select>
  127. <!-- 返回省分行查询时的总条数 -->
  128. <select id="findAllInfromationsByPBB" resultType="int">
  129. select
  130. count(*)
  131. from
  132. business_declare
  133. <where>
  134. <!-- 省分行能看到的要排除待二级分行审核和二级分行审核不通过的业务 -->
  135. status_id not in (1,2)
  136. <if test="businessName!='' and businessName!=null">
  137. and business_name=#{businessName}
  138. </if>
  139. <if test="startTime!=null and endTime!=null">
  140. and declare_time between #{startTime} and #{endTime}
  141. </if>
  142. </where>
  143. </select>
  144. <!-- 当省分行来查看业务申报表的时候给展现的数据,要除去状态1和状态2【分别对应待二级分行审核和二级分行审核不通过】 -->
  145. <select id="queryBusinessDeclareInformationByPBB" resultType="com.fuzamei.entity.BusinessDeclare">
  146. select
  147. bd.business_id,
  148. bd.bank_id,
  149. bd.business_name,
  150. a1.attachment_name as business_approval_name,
  151. a1.url as business_approval_url,
  152. a2.attachment_name as responsible_investigation_name,
  153. a2.url as responsible_investigation_url,
  154. a3.attachment_name as product_approval_name,
  155. a3.url as product_approval_url,
  156. a4.attachment_name as basic_data_name,
  157. a4.url as basic_data_url,
  158. bd.declare_time,
  159. s.status_name,
  160. bd.hash
  161. from
  162. business_declare bd
  163. left join
  164. attachment a1
  165. on
  166. a1.attachment_id=bd.business_approval_id
  167. left join
  168. attachment a2
  169. on
  170. a2.attachment_id=bd.responsible_investigation_id
  171. left join
  172. attachment a3
  173. on
  174. a3.attachment_id=bd.product_approval_id
  175. left join
  176. attachment a4
  177. on
  178. a4.attachment_id=bd.basic_data_id
  179. left join
  180. status s
  181. on
  182. s.status_id=bd.status_id
  183. <where>
  184. <!-- 省分行能看到的要排除待二级分行审核和二级分行审核不通过的业务 -->
  185. bd.status_id not in (1,2)
  186. <if test="businessName!='' and businessName!=null">
  187. and bd.business_name=#{businessName}
  188. </if>
  189. <if test="startTime!=null and endTime!=null">
  190. and bd.declare_time between #{startTime} and #{endTime}
  191. </if>
  192. </where>
  193. order by
  194. bd.declare_time desc
  195. limit
  196. #{startPage},#{rowNum}
  197. </select>
  198. <!-- 查看审核记录的sql语句 -->
  199. <select id="queryBusinessCheckInformation" resultType="com.fuzamei.entity.BusinessCheck">
  200. select
  201. bc.check_department,
  202. bc.check_person,
  203. bc.check_business_id,
  204. bc.check_opinion,
  205. bc.check_time,
  206. bc.result,
  207. s.status_name as task
  208. from
  209. (select
  210. bc.check_department,
  211. bc.check_person,
  212. bc.check_business_id,
  213. bc.check_opinion,
  214. bc.check_time,
  215. s.status_name as result,
  216. bc.task
  217. from
  218. business_check bc
  219. left join
  220. status s
  221. on
  222. bc.check_result=s.status_id) bc
  223. left join
  224. status s
  225. on
  226. bc.task=s.status_id
  227. where
  228. bc.check_business_id=#{businessId}
  229. order by
  230. bc.check_time desc
  231. </select>
  232. <!-- 将审核意见插入业务审核表中去 -->
  233. <insert id="businessDeclareCheckedBy">
  234. insert into
  235. business_check(check_department,
  236. check_person,
  237. check_business_id,
  238. check_opinion,
  239. check_time,
  240. check_result,
  241. task)
  242. values(#{organizationName},
  243. #{checkPerson},
  244. #{businessId},
  245. #{checkOpinion},
  246. #{checkTime},
  247. #{checkResult},
  248. #{task})
  249. </insert>
  250. <!-- 将审核结果意见在插入审核表的同时,也将审核结果更新到业务申报表中去,根据业务id(business_id)修改指定的业务 -->
  251. <update id="updateBusinessDeclareStatus">
  252. update
  253. business_declare
  254. set
  255. status_id=#{statusId}
  256. where
  257. business_id=#{businessId}
  258. </update>
  259. <!-- 省分行业务部门第一次上传合同文件到合同提交记录表中去 -->
  260. <insert id="insertContractInformationToContractRecord">
  261. insert into
  262. contract_record(business_id,
  263. contract_id,
  264. contract_name,
  265. version,
  266. contract_party,
  267. upload_department,
  268. upload_person,
  269. modify_opinion,
  270. unconfirm_department,
  271. status_id,
  272. commit_time,
  273. hash)
  274. values(#{businessId},
  275. #{contractId},
  276. #{contractName},
  277. #{version},
  278. #{contractParty},
  279. #{uploadDepartment},
  280. #{uploadPerson},
  281. #{modifyOpinion},
  282. #{uncomfirmDepartment},
  283. #{statusId}
  284. #{commitTime},
  285. #{hash})
  286. </insert>
  287. <!-- 省分行业务部门第一次上传合同文件到合同状态跟踪表中去 -->
  288. <insert id="insertContractInformationToContractStatusTracking">
  289. insert into
  290. contract_status_tracking(business_id,
  291. contract_id,
  292. contract_party,
  293. update_time,
  294. status_id)
  295. values(#{businessId},
  296. #{contractId},
  297. #{contractParty},
  298. #{updateTime},
  299. #{statusId})
  300. </insert>
  301. <!-- 将上传的合同文件信息插入到附件表中 -->
  302. <insert id="insertContractInformationToAttachment">
  303. insert into
  304. attachment(attachment_id,
  305. attachment_name,
  306. url,
  307. upload_person_id,
  308. create_time)
  309. values(#{attachmentId},
  310. #{attachmentName},
  311. #{url},
  312. #{userId},
  313. #{createTime})
  314. </insert>
  315. <!-- 对业务id进行查重 -->
  316. <select id="queryIfHasTheSameBusinessId" resultType="int">
  317. select count(*) from business_declare where business_id=#{businessId}
  318. </select>
  319. <!-- 根据业务id查询状态id值 -->
  320. <select id="getStatusIdByBusinessId" resultType="int">
  321. select status_id from business_declare where business_id=#{businessId}
  322. </select>
  323. </mapper>