| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.business.BpmBusinessFormMapper">
- <!--
- 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
- 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
- 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
- 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
- -->
- <select id="getElderlyInfoByInstanceId" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.ElderlyLogRecordVO">
- SELECT
- ei.id AS elderlyId,
- ei.elder_name,
- bbf.id,
- bbf.type
- FROM
- bpm_business_form bbf
- INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
- WHERE
- bbf.process_instance_id = #{processInstanceId}
- </select>
- <select id="selectMyBpmPage" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
- SELECT
- ecr.id,
- ecr.change_date,
- snm.create_time,
- ecr.current_flag,
- bbf.process_instance_id,
- bbf.type,
- bbf.`status`,
- snm.id AS messageId,
- snm.notify_type,
- snm.template_content,
- snm.completed_status,
- snm.read_status
- FROM
- elderly_change_record ecr
- 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)
- INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
- WHERE
- snm.user_id = #{loginUserId} AND snm.deleted = 0 AND bbf.deleted = 0 AND ecr.deleted = 0
- <if test="pageVO.status != null and pageVO.queryType != 0">
- and bbf.`status` = #{pageVO.status}
- </if>
- <if test="pageVO.queryType == 0">
- and (bbf.`status` = #{pageVO.status} OR (bbf.`status` IN (3,4) AND snm.read_status = 0))
- </if>
- <if test="pageVO.completedStatus != null">
- and snm.completed_status = #{pageVO.completedStatus}
- </if>
- <if test="pageVO.notifyType == null">
- and snm.notify_type in (0, 1)
- </if>
- <if test="pageVO.notifyType != null">
- and snm.notify_type = #{pageVO.notifyType}
- </if>
- <if test="pageVO.businessType != null">
- and snm.business_type = #{pageVO.businessType}
- </if>
- <if test="pageVO.templateContent != null">
- and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
- </if>
- <if test="pageVO.startUserId != null">
- AND ecr.creator = #{pageVO.loginNickname}
- AND bbf.creator = #{loginUserId}
- </if>
- UNION
- SELECT
- err.id,
- err.retreat_date,
- snm.create_time,
- err.current_flag,
- bbf.process_instance_id,
- bbf.type,
- bbf.`status`,
- snm.id AS messageId,
- snm.notify_type,
- snm.template_content,
- snm.completed_status,
- snm.read_status
- FROM
- elderly_retreat_record err
- INNER JOIN bpm_business_form bbf ON err.id = bbf.business_id AND err.current_flag = 0 AND bbf.type IN (1,2)
- INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
- WHERE
- snm.user_id = #{loginUserId} AND snm.deleted = 0 AND bbf.deleted = 0 AND err.deleted = 0
- <if test="pageVO.status != null and pageVO.queryType != 0">
- and bbf.`status` = #{pageVO.status}
- </if>
- <if test="pageVO.queryType == 0">
- and (bbf.`status` = #{pageVO.status} OR (bbf.`status` IN (3,4) AND snm.read_status = 0))
- </if>
- <if test="pageVO.completedStatus != null">
- and snm.completed_status = #{pageVO.completedStatus}
- </if>
- <if test="pageVO.notifyType == null">
- and snm.notify_type in (0, 1)
- </if>
- <if test="pageVO.notifyType != null">
- and snm.notify_type = #{pageVO.notifyType}
- </if>
- <if test="pageVO.businessType != null">
- and snm.business_type = #{pageVO.businessType}
- </if>
- <if test="pageVO.templateContent != null">
- and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
- </if>
- <if test="pageVO.startUserId != null">
- AND err.creator = #{loginUserId}
- AND bbf.creator = #{loginUserId}
- </if>
- ORDER BY create_time DESC
- </select>
- <select id="selectMyBpmPagTest" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
- SELECT
- ecr.id,
- ecr.change_date,
- ecr.create_time,
- ecr.current_flag,
- bbf.process_instance_id,
- bbf.type,
- bbf.`status`,
- snm.id AS messageId,
- snm.notify_type,
- snm.template_content,
- snm.completed_status
- FROM
- elderly_change_record ecr
- INNER JOIN bpm_business_form bbf ON ecr.id = bbf.business_id AND bbf.type IN (4,5,6,7,8)
- INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
- WHERE
- snm.user_id = #{loginUserId}
- <if test="pageVO.status != null">
- and bbf.`status` = #{pageVO.status}
- </if>
- <if test="pageVO.completedStatus != null">
- and snm.completed_status = #{pageVO.completedStatus}
- </if>
- <if test="pageVO.notifyType != null">
- and snm.notify_type = #{pageVO.notifyType}
- </if>
- <if test="pageVO.businessType != null">
- and snm.business_type = #{pageVO.businessType}
- </if>
- <if test="pageVO.templateContent != null">
- and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
- </if>
- <if test="pageVO.startUserId != null">
- AND ecr.creator = #{loginUserId}
- AND bbf.creator = #{loginUserId}
- </if>
- UNION
- SELECT
- err.id,
- err.retreat_date,
- err.create_time,
- err.current_flag,
- bbf.process_instance_id,
- bbf.type,
- bbf.`status`,
- snm.id AS messageId,
- snm.notify_type,
- snm.template_content,
- snm.completed_status
- FROM
- elderly_retreat_record err
- INNER JOIN bpm_business_form bbf ON err.id = bbf.business_id AND bbf.type IN (1,2)
- INNER JOIN system_notify_message snm ON bbf.process_instance_id = snm.pk_message
- WHERE
- snm.user_id = #{loginUserId}
- <if test="pageVO.status != null">
- and bbf.`status` = #{pageVO.status}
- </if>
- <if test="pageVO.completedStatus != null">
- and snm.completed_status = #{pageVO.completedStatus}
- </if>
- <if test="pageVO.notifyType != null">
- and snm.notify_type = #{pageVO.notifyType}
- </if>
- <if test="pageVO.businessType != null">
- and snm.business_type = #{pageVO.businessType}
- </if>
- <if test="pageVO.templateContent != null">
- and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
- </if>
- <if test="pageVO.startUserId != null">
- AND err.creator = #{loginUserId}
- AND bbf.creator = #{loginUserId}
- </if>
- ORDER BY create_time DESC
- </select>
- <select id="getElderMapByBusinessKey" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
- SELECT
- CONCAT(bbf.id, '') AS id,
- ei.elder_name,
- st.name AS tenantName
- FROM
- bpm_business_form bbf
- INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
- INNER JOIN system_tenant st ON bbf.start_tenant_id = st.id
- WHERE
- bbf.id IN
- <foreach collection="businessKeys" item="businessKey" open="(" separator="," close=")">
- #{businessKey}
- </foreach>
- </select>
- <select id="getElderMapByProcessInstanceId" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
- SELECT
- process_instance_id AS id,
- ei.elder_name,
- bbf.type,
- bbf.status
- FROM
- bpm_business_form bbf
- INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
- WHERE
- bbf.process_instance_id IN
- <foreach collection="processInstanceIds" item="processInstanceId" open="(" separator="," close=")">
- #{processInstanceId}
- </foreach>
- </select>
- <select id="selectCopyPage" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
- SELECT
- bpic.id,
- bpic.create_time,
- bbf.process_instance_id,
- bbf.type,
- bbf.`status`,
- snm.id AS messageId,
- snm.notify_type,
- snm.template_content,
- snm.completed_status,
- snm.read_status,
- snm.business_sub_type,
- snm.buginess_name
- FROM
- bpm_process_instance_copy bpic
- INNER JOIN bpm_business_form bbf ON bpic.process_instance_id = bbf.process_instance_id
- INNER JOIN system_notify_message snm ON bpic.user_id = snm.user_id AND bbf.process_instance_id = snm.pk_message
- WHERE
- bpic.user_id = #{loginUserId} AND snm.deleted = 0 AND bbf.deleted = 0 AND bpic.deleted = 0
- <if test="pageVO.status != null">
- and bbf.`status` = #{pageVO.status}
- </if>
- <if test="pageVO.completedStatus != null">
- and snm.completed_status = #{pageVO.completedStatus}
- </if>
- <if test="pageVO.notifyType != null">
- and snm.notify_type = #{pageVO.notifyType}
- </if>
- <if test="pageVO.businessType != null">
- and snm.business_type = #{pageVO.businessType}
- </if>
- <if test="pageVO.templateContent != null">
- and snm.template_content LIKE CONCAT('%', #{pageVO.templateContent}, '%')
- </if>
- ORDER BY create_time DESC
- </select>
- <select id="selectMyMessagePage" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
- SELECT * FROM system_notify_message
- WHERE user_id = #{loginUserId}
- AND completed_status = 0
- AND deleted = 0
- <if test="pageVO.businessType != null">
- AND business_type = #{pageVO.businessType}
- </if>
- <if test="pageVO.notifyType != null">
- AND notify_type = #{pageVO.notifyType}
- </if>
- order by create_time DESC
- </select>
- <select id="getTenantNameList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO">
- SELECT
- CONCAT(st.id, '') AS tenantId,
- st.name AS tenantName,
- ei.elder_name,
- bbf.process_instance_id
- FROM
- bpm_business_form bbf
- INNER JOIN elderly_info ei ON bbf.business_id2 = ei.id
- INNER JOIN system_tenant st ON ei.tenant_id = st.id
- WHERE
- bbf.process_instance_id IN
- <foreach collection="processInstanceIds" item="processInstanceId" open="(" separator="," close=")">
- #{processInstanceId}
- </foreach>
- UNION ALL
- SELECT
- CONCAT(st.id, '') AS tenantId,
- st.name AS tenantName,
- ciw.elder_name,
- bbf.process_instance_id
- FROM
- bpm_business_form bbf
- INNER JOIN elderly_check_in_wait ciw ON bbf.business_id2 = ciw.id
- INNER JOIN system_tenant st ON ciw.tenant_id = st.id
- WHERE
- bbf.process_instance_id IN
- <foreach collection="processInstanceIds" item="processInstanceId" open="(" separator="," close=")">
- #{processInstanceId}
- </foreach>
- </select>
- <select id="getReadList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.task.vo.elderly.BpmElderlyInfoVO">
- SELECT
- bbf.process_instance_id AS id,
- bbf.read_status
- FROM
- bpm_business_form bbf
- WHERE
- bbf.read_status = 0
- AND bbf.process_instance_id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- GROUP BY bbf.process_instance_id, bbf.read_status
- </select>
- </mapper>
|