BpmBusinessFormMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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="cn.iocoder.yudao.module.bpm.dal.mysql.business.BpmBusinessFormMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="getElderlyInfoByInstanceId" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.ElderlyLogRecordVO">
  11. SELECT
  12. ei.id AS elderlyId,
  13. ei.elder_name,
  14. bbf.id,
  15. bbf.type
  16. FROM
  17. bpm_business_form bbf
  18. INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
  19. WHERE
  20. bbf.process_instance_id = #{processInstanceId}
  21. </select>
  22. <select id="selectMyBpmPage" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
  23. SELECT
  24. ecr.id,
  25. ecr.change_date,
  26. snm.create_time,
  27. ecr.current_flag,
  28. bbf.process_instance_id,
  29. bbf.type,
  30. bbf.`status`,
  31. snm.id AS messageId,
  32. snm.notify_type,
  33. snm.template_content,
  34. snm.completed_status,
  35. snm.read_status
  36. FROM
  37. elderly_change_record ecr
  38. INNER JOIN bpm_business_form bbf ON ecr.id = bbf.business_id AND ecr.current_flag = 0 AND bbf.type IN (4,5,6,7,8,9)
  39. INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
  40. WHERE
  41. snm.user_id = #{loginUserId} AND snm.deleted = 0 AND bbf.deleted = 0 AND ecr.deleted = 0
  42. <if test="pageVO.status != null and pageVO.queryType != 0">
  43. and bbf.`status` = #{pageVO.status}
  44. </if>
  45. <if test="pageVO.queryType == 0">
  46. and (bbf.`status` = #{pageVO.status} OR (bbf.`status` IN (3,4) AND snm.read_status = 0))
  47. </if>
  48. <if test="pageVO.completedStatus != null">
  49. and snm.completed_status = #{pageVO.completedStatus}
  50. </if>
  51. <if test="pageVO.notifyType == null">
  52. and snm.notify_type in (0, 1)
  53. </if>
  54. <if test="pageVO.notifyType != null">
  55. and snm.notify_type = #{pageVO.notifyType}
  56. </if>
  57. <if test="pageVO.businessType != null">
  58. and snm.business_type = #{pageVO.businessType}
  59. </if>
  60. <if test="pageVO.templateContent != null">
  61. and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
  62. </if>
  63. <if test="pageVO.startUserId != null">
  64. AND ecr.creator = #{pageVO.loginNickname}
  65. AND bbf.creator = #{loginUserId}
  66. </if>
  67. UNION
  68. SELECT
  69. err.id,
  70. err.retreat_date,
  71. snm.create_time,
  72. err.current_flag,
  73. bbf.process_instance_id,
  74. bbf.type,
  75. bbf.`status`,
  76. snm.id AS messageId,
  77. snm.notify_type,
  78. snm.template_content,
  79. snm.completed_status,
  80. snm.read_status
  81. FROM
  82. elderly_retreat_record err
  83. INNER JOIN bpm_business_form bbf ON err.id = bbf.business_id AND err.current_flag = 0 AND bbf.type IN (1,2)
  84. INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
  85. WHERE
  86. snm.user_id = #{loginUserId} AND snm.deleted = 0 AND bbf.deleted = 0 AND err.deleted = 0
  87. <if test="pageVO.status != null and pageVO.queryType != 0">
  88. and bbf.`status` = #{pageVO.status}
  89. </if>
  90. <if test="pageVO.queryType == 0">
  91. and (bbf.`status` = #{pageVO.status} OR (bbf.`status` IN (3,4) AND snm.read_status = 0))
  92. </if>
  93. <if test="pageVO.completedStatus != null">
  94. and snm.completed_status = #{pageVO.completedStatus}
  95. </if>
  96. <if test="pageVO.notifyType == null">
  97. and snm.notify_type in (0, 1)
  98. </if>
  99. <if test="pageVO.notifyType != null">
  100. and snm.notify_type = #{pageVO.notifyType}
  101. </if>
  102. <if test="pageVO.businessType != null">
  103. and snm.business_type = #{pageVO.businessType}
  104. </if>
  105. <if test="pageVO.templateContent != null">
  106. and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
  107. </if>
  108. <if test="pageVO.startUserId != null">
  109. AND err.creator = #{loginUserId}
  110. AND bbf.creator = #{loginUserId}
  111. </if>
  112. ORDER BY create_time DESC
  113. </select>
  114. <select id="selectMyBpmPagTest" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
  115. SELECT
  116. ecr.id,
  117. ecr.change_date,
  118. ecr.create_time,
  119. ecr.current_flag,
  120. bbf.process_instance_id,
  121. bbf.type,
  122. bbf.`status`,
  123. snm.id AS messageId,
  124. snm.notify_type,
  125. snm.template_content,
  126. snm.completed_status
  127. FROM
  128. elderly_change_record ecr
  129. INNER JOIN bpm_business_form bbf ON ecr.id = bbf.business_id AND bbf.type IN (4,5,6,7,8)
  130. INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
  131. WHERE
  132. snm.user_id = #{loginUserId}
  133. <if test="pageVO.status != null">
  134. and bbf.`status` = #{pageVO.status}
  135. </if>
  136. <if test="pageVO.completedStatus != null">
  137. and snm.completed_status = #{pageVO.completedStatus}
  138. </if>
  139. <if test="pageVO.notifyType != null">
  140. and snm.notify_type = #{pageVO.notifyType}
  141. </if>
  142. <if test="pageVO.businessType != null">
  143. and snm.business_type = #{pageVO.businessType}
  144. </if>
  145. <if test="pageVO.templateContent != null">
  146. and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
  147. </if>
  148. <if test="pageVO.startUserId != null">
  149. AND ecr.creator = #{loginUserId}
  150. AND bbf.creator = #{loginUserId}
  151. </if>
  152. UNION
  153. SELECT
  154. err.id,
  155. err.retreat_date,
  156. err.create_time,
  157. err.current_flag,
  158. bbf.process_instance_id,
  159. bbf.type,
  160. bbf.`status`,
  161. snm.id AS messageId,
  162. snm.notify_type,
  163. snm.template_content,
  164. snm.completed_status
  165. FROM
  166. elderly_retreat_record err
  167. INNER JOIN bpm_business_form bbf ON err.id = bbf.business_id AND bbf.type IN (1,2)
  168. INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
  169. WHERE
  170. snm.user_id = #{loginUserId}
  171. <if test="pageVO.status != null">
  172. and bbf.`status` = #{pageVO.status}
  173. </if>
  174. <if test="pageVO.completedStatus != null">
  175. and snm.completed_status = #{pageVO.completedStatus}
  176. </if>
  177. <if test="pageVO.notifyType != null">
  178. and snm.notify_type = #{pageVO.notifyType}
  179. </if>
  180. <if test="pageVO.businessType != null">
  181. and snm.business_type = #{pageVO.businessType}
  182. </if>
  183. <if test="pageVO.templateContent != null">
  184. and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
  185. </if>
  186. <if test="pageVO.startUserId != null">
  187. AND err.creator = #{loginUserId}
  188. AND bbf.creator = #{loginUserId}
  189. </if>
  190. ORDER BY create_time DESC
  191. </select>
  192. <select id="getElderMapByBusinessKey" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
  193. SELECT
  194. CONCAT(bbf.id, '') AS id,
  195. ei.elder_name,
  196. st.name AS tenantName
  197. FROM
  198. bpm_business_form bbf
  199. INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
  200. INNER JOIN system_tenant st ON bbf.start_tenant_id = st.id
  201. WHERE
  202. bbf.id IN
  203. <foreach collection="businessKeys" item="businessKey" open="(" separator="," close=")">
  204. #{businessKey}
  205. </foreach>
  206. </select>
  207. <select id="getElderMapByProcessInstanceId" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
  208. SELECT
  209. process_instance_id AS id,
  210. ei.elder_name,
  211. bbf.type,
  212. bbf.status
  213. FROM
  214. bpm_business_form bbf
  215. INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
  216. WHERE
  217. bbf.process_instance_id IN
  218. <foreach collection="processInstanceIds" item="processInstanceId" open="(" separator="," close=")">
  219. #{processInstanceId}
  220. </foreach>
  221. </select>
  222. <select id="selectCopyPage" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
  223. SELECT
  224. bpic.id,
  225. bpic.create_time,
  226. bbf.process_instance_id,
  227. bbf.type,
  228. bbf.`status`,
  229. snm.id AS messageId,
  230. snm.notify_type,
  231. snm.template_content,
  232. snm.completed_status,
  233. snm.read_status,
  234. snm.business_sub_type,
  235. snm.buginess_name
  236. FROM
  237. bpm_process_instance_copy bpic
  238. INNER JOIN bpm_business_form bbf ON bpic.process_instance_id = bbf.process_instance_id
  239. INNER JOIN system_notify_message snm ON bpic.user_id = snm.user_id AND bbf.process_instance_id = snm.pk_message
  240. WHERE
  241. bpic.user_id = #{loginUserId} AND snm.deleted = 0 AND bbf.deleted = 0 AND bpic.deleted = 0
  242. <if test="pageVO.status != null">
  243. and bbf.`status` = #{pageVO.status}
  244. </if>
  245. <if test="pageVO.completedStatus != null">
  246. and snm.completed_status = #{pageVO.completedStatus}
  247. </if>
  248. <if test="pageVO.notifyType != null">
  249. and snm.notify_type = #{pageVO.notifyType}
  250. </if>
  251. <if test="pageVO.businessType != null">
  252. and snm.business_type = #{pageVO.businessType}
  253. </if>
  254. <if test="pageVO.templateContent != null">
  255. and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
  256. </if>
  257. ORDER BY create_time DESC
  258. </select>
  259. <select id="selectMyMessagePage" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
  260. SELECT * FROM system_notify_message
  261. WHERE user_id = #{loginUserId}
  262. AND completed_status = 0
  263. AND deleted = 0
  264. <if test="pageVO.businessType != null">
  265. AND business_type = #{pageVO.businessType}
  266. </if>
  267. <if test="pageVO.notifyType != null">
  268. AND notify_type = #{pageVO.notifyType}
  269. </if>
  270. order by create_time DESC
  271. </select>
  272. <select id="getTenantNameList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO">
  273. SELECT
  274. CONCAT(st.id, '') AS tenantId,
  275. st.name AS tenantName,
  276. ei.elder_name,
  277. bbf.process_instance_id
  278. FROM
  279. bpm_business_form bbf
  280. INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
  281. INNER JOIN system_tenant st ON ei.tenant_id = st.id
  282. WHERE
  283. bbf.process_instance_id IN
  284. <foreach collection="processInstanceIds" item="processInstanceId" open="(" separator="," close=")">
  285. #{processInstanceId}
  286. </foreach>
  287. UNION ALL
  288. SELECT
  289. CONCAT(st.id, '') AS tenantId,
  290. st.name AS tenantName,
  291. ciw.elder_name,
  292. bbf.process_instance_id
  293. FROM
  294. bpm_business_form bbf
  295. INNER JOIN elderly_check_in_wait ciw ON bbf.business_id2 = ciw.id
  296. INNER JOIN system_tenant st ON ciw.tenant_id = st.id
  297. WHERE
  298. bbf.process_instance_id IN
  299. <foreach collection="processInstanceIds" item="processInstanceId" open="(" separator="," close=")">
  300. #{processInstanceId}
  301. </foreach>
  302. </select>
  303. <select id="getReadList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
  304. SELECT
  305. bbf.process_instance_id AS id,
  306. bbf.read_status
  307. FROM
  308. bpm_business_form bbf
  309. WHERE
  310. bbf.read_status = 0
  311. AND bbf.process_instance_id IN
  312. <foreach collection="ids" item="id" open="(" separator="," close=")">
  313. #{id}
  314. </foreach>
  315. GROUP BY bbf.process_instance_id, bbf.read_status
  316. </select>
  317. </mapper>