| | |
| | | <result property="recordid" column="recordid"/> |
| | | <result property="exrecallcount" column="exrecallcount"/> |
| | | <result property="pulltime" column="pulltime"/> |
| | | <result property="deptcode" column="deptcode"/> |
| | | <result property="leaveldeptcode" column="leaveldeptcode"/> |
| | | <result property="labelstatus" column="labelstatus"/> |
| | | <result property="delFlag" column="del_flag"/> |
| | | <result property="updateBy" column="update_by"/> |
| | |
| | | <result property="leaveicd10code" column="leaveicd10code"/> |
| | | <result property="leavediagname" column="leavediagname"/> |
| | | <result property="diagname" column="diagname"/> |
| | | <result property="leaveldeptname" column="leaveldeptname"/> |
| | | <!-- 2026-11:原 sendlimit* 四个空闲列复用为「在院维度」(hospitaldistrict* = 在院病区,deptcode/name = 在院科室) --> |
| | | <result property="hospitaldistrictcode" column="hospitaldistrictcode"/> |
| | | <result property="hospitaldistrictname" column="hospitaldistrictname"/> |
| | | <result property="deptcode" column="deptcode"/> |
| | | <result property="deptname" column="deptname"/> |
| | | <result property="admindate" column="admindate"/> |
| | | <result property="roomno" column="roomno"/> |
| | |
| | | recordid, |
| | | exrecallcount, |
| | | pulltime, |
| | | deptcode, |
| | | leaveldeptcode, |
| | | labelstatus, |
| | | del_flag, |
| | | update_by, |
| | |
| | | sendname, |
| | | roomno, |
| | | admindate, |
| | | leaveldeptname, |
| | | hospitaldistrictcode, |
| | | hospitaldistrictname, |
| | | deptcode, |
| | | deptname, |
| | | stop_state, |
| | | leavehospitaldistrictcode, |
| | |
| | | <if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if> |
| | | </select> |
| | | |
| | | <select id="selectServiceSubtaskList" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity" |
| | | resultMap="ServiceSubtaskResult"> |
| | | <include refid="selectServiceSubtaskVo"/> |
| | | <!-- ====================================================================== |
| | | 科室 / 病区筛选(2026-11 修订版) |
| | | 两组条件【各自独立】,互不牵连(在院病区与离院病区不会同时存在): |
| | | 离院组:leavehospitaldistrictcodes → leavehospitaldistrictcode |
| | | leaveldeptcodes → leaveldeptcode |
| | | 在院组:hospitaldistrictcodes → hospitaldistrictcode(在院病区) |
| | | deptcodes → deptcode(在院科室) |
| | | 组内组合方式由 deptOrDistrict 决定:'1' = AND,'2' = OR。 |
| | | ('3'/'4' 是「离院病区 + 随访科室 visit_dept_code」那套,单独分支,不走这里) |
| | | 两组之间是 AND:只传一组时另一组自动不拼。 |
| | | 空数组 [] 一律视为"没传",不会拼出 IN ()。 |
| | | ====================================================================== --> |
| | | <sql id="filterLeaveDimAnd"> |
| | | /* f-v3 */ |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")"> |
| | | #{lvWardCodeItem} |
| | | </foreach> |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | AND leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")"> |
| | | #{lvDeptCodeItem} |
| | | </foreach> |
| | | </if> |
| | | </sql> |
| | | |
| | | <sql id="filterLeaveDimOr"> |
| | | /* f-v3 */ |
| | | <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0) |
| | | or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)"> |
| | | AND ( |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="lvWardCodeItem" open="(" separator="," close=")"> |
| | | #{lvWardCodeItem} |
| | | </foreach> |
| | | </if> |
| | | <if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0) |
| | | and (leaveldeptcodes != null and leaveldeptcodes.size() > 0)"> |
| | | OR |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="lvDeptCodeItem" open="(" separator="," close=")"> |
| | | #{lvDeptCodeItem} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | </sql> |
| | | |
| | | <sql id="filterInhospDimAnd"> |
| | | /* f-v3 */ |
| | | <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | AND hospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="inWardCodeItem" open="(" separator="," close=")"> |
| | | #{inWardCodeItem} |
| | | </foreach> |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | <foreach collection="deptcodes" item="inDeptCodeItem" open="(" separator="," close=")"> |
| | | #{inDeptCodeItem} |
| | | </foreach> |
| | | </if> |
| | | </sql> |
| | | |
| | | <sql id="filterInhospDimOr"> |
| | | /* f-v3 */ |
| | | <if test="(hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0) |
| | | or (deptcodes != null and deptcodes.size() > 0)"> |
| | | AND ( |
| | | <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | hospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="inWardCodeItem" open="(" separator="," close=")"> |
| | | #{inWardCodeItem} |
| | | </foreach> |
| | | </if> |
| | | <if test="(hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0) |
| | | and (deptcodes != null and deptcodes.size() > 0)"> |
| | | OR |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | deptcode IN |
| | | <foreach collection="deptcodes" item="inDeptCodeItem" open="(" separator="," close=")"> |
| | | #{inDeptCodeItem} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | </sql> |
| | | |
| | | <!-- ================================================================== |
| | | service_subtask 列表查询的公共 where 片段 |
| | | ================================================================== |
| | | patItem 走「两阶段分页」: |
| | | ① selectServiceSubtaskIdsPage —— 只查 id,走覆盖索引,不为被 offset |
| | | 跳过的每一行回表读 100 列; |
| | | ② selectServiceSubtaskList + subIdList —— 按 id 回表,只读一页的量。 |
| | | 两条语句的 where 必须【逐字一致】,否则第②步会把第①步选出的行过滤掉, |
| | | 导致一页返回不足 pageSize 条。所以收成公共片段,杜绝两份口径漂移。 |
| | | ================================================================== --> |
| | | <sql id="serviceSubtaskWhere"> |
| | | where del_flag = 0 |
| | | <if test="subId != null ">and id = #{subId}</if> |
| | | <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if> |
| | |
| | | '%') |
| | | </if> |
| | | <if test="startOutHospTime != null"> |
| | | AND date_format(endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d') |
| | | AND endtime >= DATE(#{startOutHospTime}) |
| | | </if> |
| | | <if test="endOutHospTime != null"> |
| | | AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d') |
| | | AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="startSendDateTime != null"> |
| | | AND date_format(visit_time,'%y%m%d') >= date_format(#{startSendDateTime},'%y%m%d') |
| | | AND visit_time >= DATE(#{startSendDateTime}) |
| | | </if> |
| | | <if test="endSendDateTime != null"> |
| | | AND date_format(visit_time,'%y%m%d') <= date_format(#{endSendDateTime},'%y%m%d') |
| | | AND visit_time < DATE_ADD(DATE(#{endSendDateTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="finishtimeStart != null"> |
| | | AND date_format(finishtime,'%y%m%d') >= date_format(#{finishtimeStart},'%y%m%d') |
| | | AND finishtime >= DATE(#{finishtimeStart}) |
| | | </if> |
| | | <if test="finishtimeEnd != null"> |
| | | AND date_format(finishtime,'%y%m%d') <= date_format(#{finishtimeEnd},'%y%m%d') |
| | | AND finishtime < DATE_ADD(DATE(#{finishtimeEnd}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="longSendTime != null"> |
| | | AND date_format(long_send_time,'%y%m%d') <= date_format(#{longSendTime},'%y%m%d') |
| | | AND long_send_time < DATE_ADD(DATE(#{longSendTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="deptOrDistrict==1"> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" |
| | | separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | <!-- |
| | | 科室/病区筛选(2026-11 修订): |
| | | 离院组(leaveldeptcodes / leavehospitaldistrictcodes)保持原逻辑; |
| | | 在院组(deptcodes / hospitaldistrictcodes → deptcode / hospitaldistrictcode)是新增的一组; |
| | | 组内按 deptOrDistrict 取 AND('1') / OR('2'),两组之间 AND(只传一组时另一组不拼)。 |
| | | --> |
| | | <if test='deptOrDistrict == "1"'> |
| | | <include refid="filterLeaveDimAnd"/> |
| | | <include refid="filterInhospDimAnd"/> |
| | | </if> |
| | | <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0"> |
| | | AND deptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | <if test='deptOrDistrict == "2"'> |
| | | <include refid="filterLeaveDimOr"/> |
| | | <include refid="filterInhospDimOr"/> |
| | | </if> |
| | | </if> |
| | | <if test="deptOrDistrict==2"> |
| | | AND (1=1 |
| | | <if test="leavehospitaldistrictcodes != null"> |
| | | AND leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" |
| | | separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | </if> |
| | | <if test=" leaveldeptcodes != null"> |
| | | OR deptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | <if test="deptOrDistrict==3"> |
| | | <!-- ⚠️ deptOrDistrict 是 String:OGNL 里 '1'(单引号单字符)是 char,String != char 恒 false! |
| | | 必须写成双引号字符串(XML 属性用单引号包住),或直接和数字比(OGNL 会做 String→Number 转换)。 --> |
| | | <if test='deptOrDistrict == "3"'> |
| | | AND (1=1 |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | |
| | | </if> |
| | | ) |
| | | </if> |
| | | <if test="deptOrDistrict==4"> |
| | | <if test='deptOrDistrict == "4"'> |
| | | AND (1=1 |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | |
| | | ) |
| | | </if> |
| | | <if test="visitTime != null"> |
| | | AND date_format(visit_time,'%y%m%d') = date_format(#{visitTime},'%y%m%d') |
| | | AND visit_time >= DATE(#{visitTime}) |
| | | AND visit_time < DATE_ADD(DATE(#{visitTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="senddate != null ">and senddate = #{senddate}</if> |
| | | <if test="senduuid != null and senduuid != ''">and senduuid = #{senduuid}</if> |
| | |
| | | <if test="recordid != null ">and recordid = #{recordid}</if> |
| | | <if test="exrecallcount != null ">and exrecallcount = #{exrecallcount}</if> |
| | | <if test="pulltime != null ">and pulltime = #{pulltime}</if> |
| | | <if test="deptcode != null and deptcode != ''">and deptcode = #{deptcode}</if> |
| | | <if test="deptname != null and deptname != ''">and deptname = #{deptname}</if> |
| | | <if test="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if> |
| | | <if test="labelstatus != null ">and labelstatus = #{labelstatus}</if> |
| | | <if test="isupload != null ">and isupload = #{isupload}</if> |
| | | <if test="uploadTime != null ">and upload_time = #{uploadTime}</if> |
| | |
| | | #{visitDeptCode} |
| | | </foreach> |
| | | </if> |
| | | </sql> |
| | | |
| | | <!-- 排序片段:保持原语义,只在调用方显式传 sort 时才拼 order by |
| | | (导出等不分页的调用方行为完全不变) --> |
| | | <sql id="serviceSubtaskOrderBy"> |
| | | <if test="sort != null and sort==0">order by endtime asc</if> |
| | | <if test="sort != null and sort==1">order by endtime desc</if> |
| | | <if test="sort != null and sort==2">order by visit_time asc</if> |
| | |
| | | <if test="sort != null and sort==7">order by visit_time asc</if> |
| | | <if test="sort != null and sort==8">order by visit_time desc</if> |
| | | <if test="sort != null and sort==9">order by sendname asc</if> |
| | | </sql> |
| | | |
| | | <!-- 分页场景专用排序:sort 为空时兜底 order by id desc。 |
| | | 原来 sort 为空时整条 SQL 没有 order by,limit/offset 取到的是「不确定顺序」, |
| | | 翻页会重复或漏行;这里给一个稳定顺序(想改成 id asc 只改这一行)。 --> |
| | | <sql id="serviceSubtaskOrderByPaged"> |
| | | <include refid="serviceSubtaskOrderBy"/> |
| | | <if test="sort == null">order by id desc</if> |
| | | </sql> |
| | | |
| | | <select id="selectServiceSubtaskList" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity" |
| | | resultMap="ServiceSubtaskResult"> |
| | | <include refid="selectServiceSubtaskVo"/> |
| | | <include refid="serviceSubtaskWhere"/> |
| | | <include refid="serviceSubtaskOrderBy"/> |
| | | <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if> |
| | | </select> |
| | | |
| | | <!-- |
| | | 两阶段分页第 1 步:只取 id。 |
| | | select 列表只有 id,where/order 涉及的列都在 idx_ss_org_cam_del_* 上, |
| | | 因此能走「覆盖索引 + 提前截断」;被 offset 跳过的那几千行不再回表读 100 列。 |
| | | 第 2 步由调用方用 subIdList 回表取整行(见 ServiceSubtaskServiceImpl#selectServiceSubtaskPage)。 |
| | | --> |
| | | <select id="selectServiceSubtaskIdsPage" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity" |
| | | resultType="java.lang.Long"> |
| | | select id |
| | | from service_subtask |
| | | <include refid="serviceSubtaskWhere"/> |
| | | <include refid="serviceSubtaskOrderByPaged"/> |
| | | limit ${pageSize} OFFSET ${pageNum} |
| | | </select> |
| | | |
| | | <select id="getCompensateServiceSubtaskList" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity" |
| | |
| | | <if test="recordid != null ">and recordid = #{recordid}</if> |
| | | <if test="exrecallcount != null ">and exrecallcount = #{exrecallcount}</if> |
| | | <if test="pulltime != null ">and pulltime = #{pulltime}</if> |
| | | <if test="deptcode != null and deptcode != ''">and deptcode = #{deptcode}</if> |
| | | <if test="deptname != null and deptname != ''">and deptname = #{deptname}</if> |
| | | <if test="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if> |
| | | <if test="labelstatus != null ">and labelstatus = #{labelstatus}</if> |
| | | <if test="isupload != null ">and isupload = #{isupload}</if> |
| | | <if test="uploadTime != null ">and upload_time = #{uploadTime}</if> |
| | |
| | | <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if> |
| | | <if test="serviceType != null and serviceType != ''">and service_type = #{serviceType}</if> |
| | | <if test="serviceTypes != null and serviceTypes != ''">and service_type IN (#{serviceTypes})</if> |
| | | <if test="deptcode != null and deptcode != ''">and deptcode = #{deptcode}</if> |
| | | <if test="deptname != null and deptname != ''">and deptname = #{deptname}</if> |
| | | <if test="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if> |
| | | <if test="isabnormal != null">and isabnormal = #{isabnormal}</if> |
| | | <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">and |
| | | leavehospitaldistrictcode = #{leavehospitaldistrictcode} |
| | |
| | | <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if> |
| | | <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if> |
| | | <if test="startOutHospTime != null"> |
| | | AND date_format(endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d') |
| | | AND endtime >= DATE(#{startOutHospTime}) |
| | | </if> |
| | | <if test="endOutHospTime != null"> |
| | | AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d') |
| | | AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | ) a |
| | | </select> |
| | |
| | | </if> |
| | | <if test="orgid != null and orgid != ''">AND ss.orgid = #{orgid}</if> |
| | | <if test="campusid != null and campusid != ''">and ss.campusid = #{campusid}</if> |
| | | <if test="deptcode != null and deptcode != ''">and ss.deptcode = #{deptcode}</if> |
| | | <if test="deptname != null and deptname != ''">and ss.deptname = #{deptname}</if> |
| | | <if test="leaveldeptcode != null and leaveldeptcode != ''">and ss.leaveldeptcode = #{leaveldeptcode}</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">and ss.leaveldeptname = #{leaveldeptname}</if> |
| | | <if test="isabnormal != null">and ss.isabnormal = #{isabnormal}</if> |
| | | <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">and |
| | | ss.leavehospitaldistrictcode = #{leavehospitaldistrictcode} |
| | |
| | | AND date_format(ss.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d') |
| | | </if> |
| | | <if test="groupKey != null and groupKey != ''"> |
| | | AND ss.${groupKey} IN |
| | | AND IFNULL(ss.${groupKey}, 'Unknown') IN |
| | | <foreach collection="groupKeyList" item="key" open="(" separator="," |
| | | close=")"> |
| | | #{key} |
| | |
| | | <if test="serviceType != null and serviceType != ''">and service_type = #{serviceType}</if> |
| | | <if test="serviceTypes != null and serviceTypes != ''">and service_type IN (#{serviceTypes})</if> |
| | | <if test="isabnormal != null ">and isabnormal = #{isabnormal}</if> |
| | | <if test="deptcode != null and deptcode != ''">and deptcode = #{deptcode}</if> |
| | | <if test="deptname != null and deptname != ''">and deptname = #{deptname}</if> |
| | | <if test="leaveldeptcode != null and leaveldeptcode != ''">and leaveldeptcode = #{leaveldeptcode}</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">and leaveldeptname = #{leaveldeptname}</if> |
| | | <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">and |
| | | leavehospitaldistrictcode = #{leavehospitaldistrictcode} |
| | | </if> |
| | |
| | | <if test="continueCount != null ">and continue_count = #{continueCount}</if> |
| | | <if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if> |
| | | <if test="startOutHospTime != null"> |
| | | AND date_format(endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d') |
| | | AND endtime >= DATE(#{startOutHospTime}) |
| | | </if> |
| | | <if test="endOutHospTime != null"> |
| | | AND date_format(endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d') |
| | | AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | GROUP BY sendname,sendstate,starttime,endtime,nurse_name,phone,sex,task_name,leavediagname,visit_time |
| | | ORDER BY sendname,visit_time |
| | |
| | | <if test="recordid != null">recordid,</if> |
| | | <if test="exrecallcount != null">exrecallcount,</if> |
| | | <if test="pulltime != null">pulltime,</if> |
| | | <if test="deptcode != null">deptcode,</if> |
| | | <if test="leaveldeptcode != null">leaveldeptcode,</if> |
| | | <!-- 2026-11:原 sendlimit* 复用列(在院维度:在院病区/在院科室),仅出院随访会填值 --> |
| | | <if test="hospitaldistrictcode != null and hospitaldistrictcode != ''">hospitaldistrictcode,</if> |
| | | <if test="hospitaldistrictname != null and hospitaldistrictname != ''">hospitaldistrictname,</if> |
| | | <if test="deptcode != null and deptcode != ''">deptcode,</if> |
| | | <if test="deptname != null and deptname != ''">deptname,</if> |
| | | <if test="labelstatus != null">labelstatus,</if> |
| | | <if test="updateBy != null">update_by,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | |
| | | <if test="wechat != null and wechat != ''">wechat,</if> |
| | | <if test="roomno != null and roomno != ''">roomno,</if> |
| | | <if test="admindate != null">admindate,</if> |
| | | <if test="deptname != null and deptname != ''">deptname,</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname,</if> |
| | | <if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code,</if> |
| | | <if test="leavediagname != null and leavediagname != ''">leavediagname,</if> |
| | | <!-- diagname:入院诊断名称。原 insert 漏了这一列,而出院链路的 |
| | |
| | | <if test="recordid != null">#{recordid},</if> |
| | | <if test="exrecallcount != null">#{exrecallcount},</if> |
| | | <if test="pulltime != null">#{pulltime},</if> |
| | | <if test="deptcode != null">#{deptcode},</if> |
| | | <if test="leaveldeptcode != null">#{leaveldeptcode},</if> |
| | | <!-- 2026-11:原 sendlimit* 复用列(入院/在院维度),仅出院随访会填值 --> |
| | | <if test="hospitaldistrictcode != null and hospitaldistrictcode != ''">#{hospitaldistrictcode},</if> |
| | | <if test="hospitaldistrictname != null and hospitaldistrictname != ''">#{hospitaldistrictname},</if> |
| | | <if test="deptcode != null and deptcode != ''">#{deptcode},</if> |
| | | <if test="deptname != null and deptname != ''">#{deptname},</if> |
| | | <if test="labelstatus != null">#{labelstatus},</if> |
| | | <if test="updateBy != null">#{updateBy},</if> |
| | | <if test="updateTime != null">#{updateTime},</if> |
| | |
| | | <if test="wechat != null and wechat != ''">#{wechat},</if> |
| | | <if test="roomno != null and roomno != ''">#{roomno},</if> |
| | | <if test="admindate != null ">#{admindate},</if> |
| | | <if test="deptname != null and deptname != ''">#{deptname},</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">#{leaveldeptname},</if> |
| | | <if test="leaveicd10code != null and leaveicd10code != ''">#{leaveicd10code},</if> |
| | | <if test="leavediagname != null and leavediagname != ''">#{leavediagname},</if> |
| | | <if test="diagname != null and diagname != ''">#{diagname},</if> |
| | |
| | | <if test="recordid != null">recordid = #{recordid},</if> |
| | | <if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if> |
| | | <if test="pulltime != null">pulltime = #{pulltime},</if> |
| | | <if test="deptcode != null">deptcode = #{deptcode},</if> |
| | | <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if> |
| | | <if test="labelstatus != null">labelstatus = #{labelstatus},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | |
| | | <if test="wechat != null and wechat != ''">wechat = #{wechat},</if> |
| | | <if test="roomno != null and roomno != ''">roomno = #{roomno},</if> |
| | | <if test="admindate != null ">admindate = #{admindate},</if> |
| | | <if test="deptname != null and deptname != ''">deptname = #{deptname},</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if> |
| | | <if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if> |
| | | <if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if> |
| | | <if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if> |
| | |
| | | <if test="recordid != null">recordid = #{recordid},</if> |
| | | <if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if> |
| | | <if test="pulltime != null">pulltime = #{pulltime},</if> |
| | | <if test="deptcode != null">deptcode = #{deptcode},</if> |
| | | <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if> |
| | | <if test="labelstatus != null">labelstatus = #{labelstatus},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | |
| | | <if test="wechat != null and wechat != ''">wechat = #{wechat},</if> |
| | | <if test="roomno != null and roomno != ''">roomno = #{roomno},</if> |
| | | <if test="admindate != null">admindate = #{admindate},</if> |
| | | <if test="deptname != null and deptname != ''">deptname = #{deptname},</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if> |
| | | <if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if> |
| | | <if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if> |
| | | <if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if> |
| | |
| | | <if test="recordid != null">recordid = #{recordid},</if> |
| | | <if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if> |
| | | <if test="pulltime != null">pulltime = #{pulltime},</if> |
| | | <if test="deptcode != null">deptcode = #{deptcode},</if> |
| | | <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if> |
| | | <if test="labelstatus != null">labelstatus = #{labelstatus},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | |
| | | <if test="wechat != null and wechat != ''">wechat = #{wechat},</if> |
| | | <if test="roomno != null and roomno != ''">roomno = #{roomno},</if> |
| | | <if test="admindate != null">admindate = #{admindate},</if> |
| | | <if test="deptname != null and deptname != ''">deptname = #{deptname},</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if> |
| | | <if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if> |
| | | <if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if> |
| | | <if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if> |
| | |
| | | <if test="recordid != null">recordid = #{recordid},</if> |
| | | <if test="exrecallcount != null">exrecallcount = #{exrecallcount},</if> |
| | | <if test="pulltime != null">pulltime = #{pulltime},</if> |
| | | <if test="deptcode != null">deptcode = #{deptcode},</if> |
| | | <if test="leaveldeptcode != null">leaveldeptcode = #{leaveldeptcode},</if> |
| | | <if test="labelstatus != null">labelstatus = #{labelstatus},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | |
| | | <if test="admindate != null ">admindate = #{admindate},</if> |
| | | <if test="visitCount != null ">visit_count = #{visitCount},</if> |
| | | <if test="isVisitAgain != null ">is_visit_again = #{isVisitAgain},</if> |
| | | <if test="deptname != null and deptname != ''">deptname = #{deptname},</if> |
| | | <if test="leaveldeptname != null and leaveldeptname != ''">leaveldeptname = #{leaveldeptname},</if> |
| | | <if test="leaveicd10code != null and leaveicd10code != ''">leaveicd10code = #{leaveicd10code},</if> |
| | | <if test="leavediagname != null and leavediagname != ''">leavediagname = #{leavediagname},</if> |
| | | <if test="libtemplateid != null ">libtemplateid = #{libtemplateid},</if> |
| | |
| | | management_doctor, |
| | | leavehospitaldistrictcode, |
| | | leavehospitaldistrictname, |
| | | deptcode, |
| | | deptname, |
| | | leaveldeptcode, |
| | | leaveldeptname, |
| | | sendstate, |
| | | preachform, |
| | | current_preachform, |
| | |
| | | <if test="campusid != null and campusid != ''"> |
| | | and campusid = #{campusid} |
| | | </if> |
| | | <!-- 2026-10-21:病区为空时视为"不限" |
| | | 南华满意度子任务的 leavehospitaldistrictcode 有 83%(3236/3811)为 NULL, |
| | | 原来「科室 AND 病区」两个条件永远不可能同时成立 → 整张统计表空。 |
| | | 判空放行只影响病区为空的记录,有病区的数据行为不变。 --> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <!-- 2026-10-21:visit_time 为空(南华满意度 3811/3811 全为 NULL)时按完成/创建时间兜底 --> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND visit_time >= DATE(#{startTime}) |
| | | AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime}) |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="hospitalStartTime != null and hospitalEndTime!=null"> |
| | | AND endtime >= DATE(#{hospitalStartTime}) |
| | |
| | | AND visit_count > 1 |
| | | </if> |
| | | <if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0"> |
| | | AND ${groupKey} IN |
| | | AND IFNULL(${groupKey}, 'Unknown') IN |
| | | <foreach collection="groupKeyList" item="key" open="(" separator="," |
| | | close=")"> |
| | | #{key} |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND b.deptcode IN |
| | | AND b.leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | |
| | | <if test="campusid != null and campusid != ''"> |
| | | and campusid = #{campusid} |
| | | </if> |
| | | <!-- 2026-10-21:病区为空时视为"不限" |
| | | 南华满意度子任务的 leavehospitaldistrictcode 有 83%(3236/3811)为 NULL, |
| | | 原来「科室 AND 病区」两个条件永远不可能同时成立 → 整张统计表空。 |
| | | 判空放行只影响病区为空的记录,有病区的数据行为不变。 --> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | AND leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | AND (hospitaldistrictcode IS NULL OR hospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="serviceType != null and serviceType.size() > 0"> |
| | |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <!-- 2026-10-21:visit_time 为空(南华满意度 3811/3811 全为 NULL)时按完成/创建时间兜底 --> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND visit_time >= DATE(#{startTime}) |
| | | AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime}) |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="hospitalStartTime != null and hospitalEndTime!=null"> |
| | | AND endtime >= DATE(#{hospitalStartTime}) |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- |
| | | ================================================================== |
| | | 随访分类统计(/smartor/serviceSubtask/getSfStatisticsCount)性能优化 |
| | | ================================================================== |
| | | 改造前:getSfStatisticsScript 先把 service_subtask 命中的**全部明细行** |
| | | (getSfStatistics 共 select 39 个字段,含 continue_content / result / suggest 等大字段) |
| | | 捞回 JVM,再在内存里按 drcode/科室/病区 逐行 if 累加;此外还要把这次命中的 |
| | | **全部子任务 id** 灌进 getSfStatisticsCategory 的 IN 列表再查一遍。 |
| | | 命中几千行时,网络传输(远端的库尤其明显)+ 内存遍历 + 超大 IN 列表就是接口慢的主因。 |
| | | |
| | | 改造后:累加下推到数据库,一次 GROUP BY 只返回“分组数”(通常几十行)的统计结果; |
| | | 满意度题目量也同样按分组在库里聚合。统计口径与原来的 getStatisticCategory 逐条对齐。 |
| | | 这两个语句的 where 条件与 getSfStatistics 保持一致,保证结果集不变。 |
| | | |
| | | 分组列(2026-10 起): |
| | | 离院维度 —— groupKey = leaveldeptcode / leavehospitaldistrictcode; |
| | | 在院维度 —— groupKey = deptcode / hospitaldistrictcode; |
| | | 过滤与分组使用同一列(groupColumn = groupKey),避免分组键与聚合行口径不一致。 |
| | | ================================================================== |
| | | --> |
| | | <resultMap type="com.ruoyi.task.domain.ServiceSubtaskStatistic" id="ServiceSubtaskScriptStatisticResult"> |
| | | <result property="groupCode" column="group_code"/> |
| | | <result property="firstVisitCount" column="first_visit_count"/> |
| | | <result property="againVisitCount" column="again_visit_count"/> |
| | | <result property="drcode" column="drcode"/> |
| | | <result property="drname" column="drname"/> |
| | | <result property="deptcode" column="deptcode"/> |
| | | <result property="deptname" column="deptname"/> |
| | | <result property="leavehospitaldistrictcode" column="leavehospitaldistrictcode"/> |
| | | <result property="leavehospitaldistrictname" column="leavehospitaldistrictname"/> |
| | | <result property="hospitaldistrictcode" column="hospitaldistrictcode"/> |
| | | <result property="hospitaldistrictname" column="hospitaldistrictname"/> |
| | | <result property="hospitaldeptcode" column="hospitaldeptcode"/> |
| | | <result property="hospitaldeptname" column="hospitaldeptname"/> |
| | | <result property="nonFollowUp" column="non_follow_up"/> |
| | | <result property="followUpNeeded" column="follow_up_needed"/> |
| | | <result property="needFollowUp" column="need_follow_up"/> |
| | | <result property="pendingFollowUp" column="pending_follow_up"/> |
| | | <result property="followUpSuccess" column="follow_up_success"/> |
| | | <result property="followUpFail" column="follow_up_fail"/> |
| | | <result property="manual" column="manual"/> |
| | | <result property="voice" column="voice"/> |
| | | <result property="sms" column="sms"/> |
| | | <result property="weChat" column="we_chat"/> |
| | | <result property="abnormal" column="abnormal"/> |
| | | <result property="needFollowUpAgain" column="need_follow_up_again"/> |
| | | <result property="pendingFollowUpAgain" column="pending_follow_up_again"/> |
| | | <result property="followUpSuccessAgain" column="follow_up_success_again"/> |
| | | <result property="followUpFailAgain" column="follow_up_fail_again"/> |
| | | <result property="manualAgain" column="manual_again"/> |
| | | <result property="voiceAgain" column="voice_again"/> |
| | | <result property="smsAgain" column="sms_again"/> |
| | | <result property="weChatAgain" column="we_chat_again"/> |
| | | <result property="abnormalAgain" column="abnormal_again"/> |
| | | </resultMap> |
| | | |
| | | <!-- |
| | | 按分组聚合随访统计(替代“全量明细回内存再累加”)。 |
| | | 口径说明(与原 ServiceSubtaskServiceImpl.getStatisticCategory 完全一致): |
| | | * 无需随访:sendstate = 4 |
| | | * 应随访:sendstate 非空且 != 4 |
| | | * 首次(visit_count = 1) / 再次(visit_count > 1) 两个分支互斥,与原来的 if / else if 一致 |
| | | * 人工/语音/短信/微信:首次分支**不**排除 sendstate = 4(原代码如此),再次分支同样 |
| | | * 异常:excep = '1' 且 sendstate 非空 |
| | | * 首次随访率 / 再次随访率在 Java 里按原公式(含原来的分母判断)计算 |
| | | --> |
| | | <select id="getSfStatisticsScriptSum" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq" |
| | | resultMap="ServiceSubtaskScriptStatisticResult"> |
| | | select |
| | | IFNULL(${groupColumn}, 'Unknown') as group_code, |
| | | MAX(drcode) as drcode, |
| | | MAX(drname) as drname, |
| | | MAX(leaveldeptcode) as deptcode, |
| | | MAX(leaveldeptname) as deptname, |
| | | MAX(leavehospitaldistrictcode) as leavehospitaldistrictcode, |
| | | MAX(leavehospitaldistrictname) as leavehospitaldistrictname, |
| | | MAX(hospitaldistrictcode) as hospitaldistrictcode, |
| | | MAX(hospitaldistrictname) as hospitaldistrictname, |
| | | MAX(deptcode) as hospitaldeptcode, |
| | | MAX(deptname) as hospitaldeptname, |
| | | SUM(CASE WHEN visit_count = 1 THEN 1 ELSE 0 END) as first_visit_count, |
| | | SUM(CASE WHEN visit_count > 1 THEN 1 ELSE 0 END) as again_visit_count, |
| | | SUM(CASE WHEN sendstate = 4 THEN 1 ELSE 0 END) as non_follow_up, |
| | | SUM(CASE WHEN sendstate is not null and sendstate != 4 THEN 1 ELSE 0 END) as follow_up_needed, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate is not null and sendstate != 4 THEN 1 ELSE 0 END) as need_follow_up, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate = 2 THEN 1 ELSE 0 END) as pending_follow_up, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate = 6 THEN 1 ELSE 0 END) as follow_up_success, |
| | | SUM(CASE WHEN visit_count = 1 and (sendstate = 5 or sendstate = 7) THEN 1 ELSE 0 END) as follow_up_fail, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '1' THEN 1 ELSE 0 END) as manual, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '3' THEN 1 ELSE 0 END) as voice, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '4' THEN 1 ELSE 0 END) as sms, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate is not null and current_preachform = '5' THEN 1 ELSE 0 END) as we_chat, |
| | | SUM(CASE WHEN visit_count = 1 and sendstate is not null and excep = '1' THEN 1 ELSE 0 END) as abnormal, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate is not null and sendstate != 4 THEN 1 ELSE 0 END) as need_follow_up_again, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate = 2 THEN 1 ELSE 0 END) as pending_follow_up_again, |
| | | SUM(CASE WHEN visit_count > 1 and (sendstate = 1 or sendstate = 3 or sendstate = 6) THEN 1 ELSE 0 END) as follow_up_success_again, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate = 5 THEN 1 ELSE 0 END) as follow_up_fail_again, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '1' THEN 1 ELSE 0 END) as manual_again, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '3' THEN 1 ELSE 0 END) as voice_again, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '4' THEN 1 ELSE 0 END) as sms_again, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate is not null and current_preachform = '5' THEN 1 ELSE 0 END) as we_chat_again, |
| | | SUM(CASE WHEN visit_count > 1 and sendstate is not null and excep = '1' THEN 1 ELSE 0 END) as abnormal_again |
| | | from service_subtask |
| | | where 1=1 |
| | | and del_flag = 0 |
| | | <if test="orgid != null and orgid != ''"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | <if test="campusid != null and campusid != ''"> |
| | | and campusid = #{campusid} |
| | | </if> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | AND leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | AND (hospitaldistrictcode IS NULL OR hospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="serviceType != null and serviceType.size() > 0"> |
| | | AND service_type IN |
| | | <foreach collection="serviceType" item="serviceType" open="(" separator="," |
| | | close=")"> |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime}) |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="hospitalStartTime != null and hospitalEndTime!=null"> |
| | | AND endtime >= DATE(#{hospitalStartTime}) |
| | | AND endtime < DATE_ADD(DATE(#{hospitalEndTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if> |
| | | <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if> |
| | | <if test="isabnormal != null">and isabnormal = #{isabnormal}</if> |
| | | <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if> |
| | | <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if> |
| | | <if test="continueCount != null ">and continue_count = #{continueCount}</if> |
| | | <if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP}</if> |
| | | <if test="type != null"> |
| | | and type = #{type} |
| | | </if> |
| | | <if test="visitCount != null and visitCount == 1"> |
| | | AND visit_count = 1 |
| | | </if> |
| | | <if test="visitCount != null and visitCount > 1"> |
| | | AND visit_count > 1 |
| | | </if> |
| | | <if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0"> |
| | | AND IFNULL(${groupKey}, 'Unknown') IN |
| | | <foreach collection="groupKeyList" item="key" open="(" separator="," |
| | | close=")"> |
| | | #{key} |
| | | </foreach> |
| | | </if> |
| | | group by IFNULL(${groupColumn}, 'Unknown') |
| | | </select> |
| | | |
| | | <!-- |
| | | 按分组聚合满意度题目量(替代 getSfStatisticsCategory 的“逐子任务 IN 查询 + 内存 N*M 过滤”)。 |
| | | where 条件 = 上面聚合查询的条件 + 原 getSfStatisticsCategory 的明细条件, |
| | | 因此命中的明细集合与改造前(getSfStatisticsCategory 结果再按子任务与分组求交)完全一致。 |
| | | configValue 为空时不调用本语句(原实现在这种场景下题目量一律为 0)。 |
| | | --> |
| | | <select id="getSfStatisticsScriptJoySum" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq" |
| | | resultType="map"> |
| | | select |
| | | IFNULL(t.${groupColumn}, 'Unknown') as groupCode, |
| | | SUM(CASE WHEN a.categoryid IN(${configValue}) |
| | | THEN 1 ELSE 0 END) as joyAllCount, |
| | | SUM(CASE WHEN a.categoryid IN(${configValue}) |
| | | AND IFNULL(a.matchedtext,a.asrtext) is not null |
| | | AND IFNULL(a.matchedtext,a.asrtext) != '' |
| | | THEN 1 ELSE 0 END) as joyCount |
| | | from service_subtask_detail a |
| | | INNER JOIN service_subtask t on a.sub_id = t.id |
| | | where 1=1 |
| | | and a.del_flag = 0 |
| | | and t.del_flag = 0 |
| | | <if test="orgid != null and orgid != ''"> |
| | | and t.orgid = #{orgid} |
| | | </if> |
| | | <if test="campusid != null and campusid != ''"> |
| | | and t.campusid = #{campusid} |
| | | </if> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND (t.leavehospitaldistrictcode IS NULL OR t.leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND t.leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | AND t.leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | AND (t.hospitaldistrictcode IS NULL OR t.hospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0"> |
| | | AND t.deptcode IN |
| | | <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="serviceType != null and serviceType.size() > 0"> |
| | | AND t.service_type IN |
| | | <foreach collection="serviceType" item="serviceType" open="(" separator="," |
| | | close=")"> |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)) >= DATE(#{startTime}) |
| | | AND IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="hospitalStartTime != null and hospitalEndTime!=null"> |
| | | AND t.endtime >= DATE(#{hospitalStartTime}) |
| | | AND t.endtime < DATE_ADD(DATE(#{hospitalEndTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="visitDeptCode != null">and t.visit_dept_code = #{visitDeptCode}</if> |
| | | <if test="visitDeptName != null">and t.visit_dept_name = #{visitDeptName}</if> |
| | | <if test="isabnormal != null">and t.isabnormal = #{isabnormal}</if> |
| | | <if test="continueFlag != null ">and t.continue_flag = #{continueFlag}</if> |
| | | <if test="continueTimeNow != null ">and t.continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if> |
| | | <if test="continueCount != null ">and t.continue_count = #{continueCount}</if> |
| | | <if test="continueTimeNext != null ">and t.continue_time_next = #{continueTimeNext,jdbcType=TIMESTAMP}</if> |
| | | <if test="type != null"> |
| | | and t.type = #{type} |
| | | </if> |
| | | <if test="visitCount != null and visitCount == 1"> |
| | | AND t.visit_count = 1 |
| | | </if> |
| | | <if test="visitCount != null and visitCount > 1"> |
| | | AND t.visit_count > 1 |
| | | </if> |
| | | <if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0"> |
| | | AND IFNULL(t.${groupKey}, 'Unknown') IN |
| | | <foreach collection="groupKeyList" item="key" open="(" separator="," |
| | | close=")"> |
| | | #{key} |
| | | </foreach> |
| | | </if> |
| | | group by IFNULL(t.${groupColumn}, 'Unknown') |
| | | </select> |
| | | |
| | | <select id="getSfStatisticsHyperlink" parameterType="com.ruoyi.task.domain.ServiceSubtaskCountReq" |
| | | resultMap="ServiceSubtaskResult"> |
| | | select id, |
| | |
| | | drname, |
| | | leavehospitaldistrictcode, |
| | | leavehospitaldistrictname, |
| | | deptcode, |
| | | deptname, |
| | | leaveldeptcode, |
| | | leaveldeptname, |
| | | sendstate, |
| | | preachform, |
| | | current_preachform, |
| | |
| | | <if test="campusid != null and campusid != ''"> |
| | | and campusid = #{campusid} |
| | | </if> |
| | | <!-- 2026-10-21:病区为空时视为"不限"(南华满意度 83% 子任务无病区),有病区的数据行为不变 --> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <!-- 2026-10-21:visit_time 为空时按完成/创建时间兜底 --> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND visit_time >= DATE(#{startTime}) |
| | | AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) >= DATE(#{startTime}) |
| | | AND IFNULL(visit_time, IFNULL(finishtime, create_time)) < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if> |
| | | <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if> |
| | |
| | | AND visit_count > 1 |
| | | </if> |
| | | <if test="groupKey != null and groupKey != '' and groupKeyList != null and groupKeyList.size>0"> |
| | | AND ${groupKey} IN |
| | | AND IFNULL(${groupKey}, 'Unknown') IN |
| | | <foreach collection="groupKeyList" item="key" open="(" separator="," |
| | | close=")"> |
| | | #{key} |
| | |
| | | AND leavehospitaldistrictcode = #{leavehospitaldistrictcode} |
| | | </if> |
| | | <if test="deptcode != null and deptcode != ''"> |
| | | AND deptcode = #{deptcode} |
| | | AND leaveldeptcode = #{deptcode} |
| | | </if> |
| | | order by endtime desc |
| | | <if test="pageSize != null and pageNum != null"> |
| | |
| | | <if test="campusid != null and campusid != ''"> |
| | | and campusid = #{campusid} |
| | | </if> |
| | | <!-- 2026-10-21:病区为空时视为"不限"(南华满意度 83% 子任务无病区),有病区的数据行为不变 --> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND date_format(visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if> |
| | | <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if> |
| | |
| | | <if test="campusid != null and campusid != ''"> |
| | | and campusid = #{campusid} |
| | | </if> |
| | | <!-- 2026-10-21:病区为空时视为"不限"(南华满意度 83% 子任务无病区),有病区的数据行为不变 --> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | AND (leavehospitaldistrictcode IS NULL OR leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND date_format(visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | ) AND targetid=a.id) joyCount , (SELECT COUNT(*) from (select sub_id FROM service_subtask_detail |
| | | WHERE sub_id IN(SELECT id FROM service_subtask t |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND date_format(visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(IFNULL(visit_time, IFNULL(finishtime, create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | GROUP BY sub_id ) ) ta ) joyAllCount |
| | | FROM ivr_liba_target a |
| | |
| | | <if test="campusid != null and campusid != ''"> |
| | | and t.campusid = #{campusid} |
| | | </if> |
| | | <!-- 2026-10-21:病区为空时视为"不限" |
| | | 南华满意度子任务的 leavehospitaldistrictcode 有 83%(3236/3811)为 NULL, |
| | | 原来「科室 AND 病区」两个条件永远不可能同时成立 → 整张统计表空。 |
| | | 判空放行只影响病区为空的记录,有病区的数据行为不变。 --> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND t.leavehospitaldistrictcode IN |
| | | AND (t.leavehospitaldistrictcode IS NULL OR t.leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND t.deptcode IN |
| | | AND t.leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <!-- 2026-10-21:visit_time 为空时按完成/创建时间兜底 --> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND date_format(t.visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(t.visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | AND date_format(IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(IFNULL(t.visit_time, IFNULL(t.finishtime, t.create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | <if test="visitDeptCode != null"> |
| | | and t.visit_dept_code = #{visitDeptCode} |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND ss.deptcode IN |
| | | AND ss.leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | AND ss.leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | AND ss.hospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldistrictcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0"> |
| | | AND ss.deptcode IN |
| | | <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="serviceType != null and serviceType.size() > 0"> |
| | |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <!-- 2026-10-21:visit_time 为空(南华满意度 3811/3811 全为 NULL)时按完成/创建时间兜底 --> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND date_format(ss.visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(ss.visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | <!-- 目前只统计语音和问卷 --> |
| | | <if test="type != null"> |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND ss.deptcode IN |
| | | AND ss.leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | AND ss.leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | AND ss.hospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldistrictcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="hospitaldeptcodes != null and hospitaldeptcodes.size() > 0"> |
| | | AND ss.deptcode IN |
| | | <foreach collection="hospitaldeptcodes" item="hospitaldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{hospitaldeptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="serviceType != null and serviceType.size() > 0"> |
| | |
| | | #{serviceType} |
| | | </foreach> |
| | | </if> |
| | | <!-- 2026-10-21:visit_time 为空(南华满意度 3811/3811 全为 NULL)时按完成/创建时间兜底 --> |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND date_format(ss.visit_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(ss.visit_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') >= date_format(#{startTime},'%y%m%d') |
| | | AND date_format(IFNULL(ss.visit_time, IFNULL(ss.finishtime, ss.create_time)),'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | <!-- 目前只统计语音和问卷 --> |
| | | <if test="type != null"> |
| | |
| | | recordid, |
| | | exrecallcount, |
| | | pulltime, |
| | | deptcode, |
| | | leaveldeptcode, |
| | | labelstatus, |
| | | del_flag, |
| | | upid, |
| | |
| | | admindate, |
| | | patid, |
| | | service_type, |
| | | deptname, |
| | | leaveldeptname, |
| | | score, |
| | | drname, |
| | | drcode, |
| | |
| | | </select> |
| | | |
| | | <select id="getDeptRanking" parameterType="com.ruoyi.common.core.service.dto.PatMedReq" resultType="com.ruoyi.common.core.service.dto.PatMedRes"> |
| | | SELECT deptname, |
| | | SELECT leaveldeptname AS deptname, |
| | | count(1) AS rc |
| | | FROM service_subtask |
| | | WHERE DATE_FORMAT(visit_time, '%Y-%m-%d') >= #{startDate} |
| | |
| | | <if test="campusid != null and campusid != ''"> |
| | | AND campusid = #{campusid} |
| | | </if> |
| | | GROUP BY deptname |
| | | GROUP BY leaveldeptname |
| | | </select> |
| | | |
| | | <!-- 服务统计查询 - 按时间维度统计出院/门诊随访数据 --> |
| | |
| | | AND campusid = #{campusid} |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | |
| | | AND phone = #{phone} |
| | | </if> |
| | | <if test="finishtimeStart != null"> |
| | | AND date_format(finishtime,'%y%m%d') >= date_format(#{finishtimeStart},'%y%m%d') |
| | | AND finishtime >= DATE(#{finishtimeStart}) |
| | | </if> |
| | | <if test="finishtimeEnd != null"> |
| | | AND date_format(finishtime,'%y%m%d') <= date_format(#{finishtimeEnd},'%y%m%d') |
| | | AND finishtime < DATE_ADD(DATE(#{finishtimeEnd}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="deptOrDistrict==1"> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" |
| | | separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | <!-- |
| | | 科室/病区筛选(2026-11 修订): |
| | | 离院组(leaveldeptcodes / leavehospitaldistrictcodes)保持原逻辑; |
| | | 在院组(deptcodes / hospitaldistrictcodes → deptcode / hospitaldistrictcode)是新增的一组; |
| | | 组内按 deptOrDistrict 取 AND('1') / OR('2'),两组之间 AND(只传一组时另一组不拼)。 |
| | | --> |
| | | <if test='deptOrDistrict == "1"'> |
| | | <include refid="filterLeaveDimAnd"/> |
| | | <include refid="filterInhospDimAnd"/> |
| | | </if> |
| | | <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0"> |
| | | AND deptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | </if> |
| | | <if test="deptOrDistrict==2"> |
| | | AND (1=1 |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" |
| | | separator="," |
| | | close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | </if> |
| | | <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0"> |
| | | OR deptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | <if test='deptOrDistrict == "2"'> |
| | | <include refid="filterLeaveDimOr"/> |
| | | <include refid="filterInhospDimOr"/> |
| | | </if> |
| | | <if test="visitCount != null and visitCount > 1 and visitDeptCodes != null and visitDeptCodes.size() > 0"> |
| | | AND visit_dept_code IN |
| | |
| | | AND templatename LIKE CONCAT('%', #{templatename}, '%') |
| | | </if> |
| | | <if test="startOutHospTime != null"> |
| | | AND DATE_FORMAT(endtime,'%y%m%d') >= DATE_FORMAT(#{startOutHospTime},'%y%m%d') |
| | | AND endtime >= DATE(#{startOutHospTime}) |
| | | </if> |
| | | <if test="endOutHospTime != null"> |
| | | AND DATE_FORMAT(endtime,'%y%m%d') <= DATE_FORMAT(#{endOutHospTime},'%y%m%d') |
| | | AND endtime < DATE_ADD(DATE(#{endOutHospTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="startSendDateTime != null"> |
| | | AND DATE_FORMAT(visit_time,'%y%m%d') >= DATE_FORMAT(#{startSendDateTime},'%y%m%d') |
| | | AND visit_time >= DATE(#{startSendDateTime}) |
| | | </if> |
| | | <if test="endSendDateTime != null"> |
| | | AND DATE_FORMAT(visit_time,'%y%m%d') <= DATE_FORMAT(#{endSendDateTime},'%y%m%d') |
| | | AND visit_time < DATE_ADD(DATE(#{endSendDateTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="longSendTime != null"> |
| | | AND DATE_FORMAT(long_send_time,'%y%m%d') <= DATE_FORMAT(#{longSendTime},'%y%m%d') |
| | | AND long_send_time < DATE_ADD(DATE(#{longSendTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="deptOrDistrict == 1"> |
| | | <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" |
| | | separator="," close=")"> |
| | | #{leavehospitaldistrictcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close=")"> |
| | | #{leaveldeptcode} |
| | | </foreach> |
| | | </if> |
| | | </if> |
| | | <if test="deptcode != null and deptcode != ''"> |
| | | AND deptcode = #{deptcode} |
| | | <!-- 2026-11:这里原本还有一份与上方 deptOrDistrict==1 完全重复的病区/科室条件, |
| | | 已删除(条件改用 filterSubtaskWardDim / filterSubtaskDeptDim 片段,避免两份口径不一致) --> |
| | | <if test="leaveldeptcode != null and leaveldeptcode != ''"> |
| | | AND leaveldeptcode = #{leaveldeptcode} |
| | | </if> |
| | | <if test="sendstate != null"> |
| | | AND sendstate = #{sendstate} |
| | |
| | | AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d') |
| | | </if> |
| | | <if test="deptcodeList != null and deptcodeList.size()>0"> |
| | | and deptcode in |
| | | and leaveldeptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," |
| | | close=")"> |
| | | #{leaveldeptcode} |
| | |
| | | parameterType="com.ruoyi.task.domain.VO.ServiceSubtaskCotinueCountVO" |
| | | resultType="java.util.Map"> |
| | | SELECT |
| | | deptcode AS groupCode, |
| | | deptname AS groupName, |
| | | leaveldeptcode AS groupCode, |
| | | leaveldeptname AS groupName, |
| | | SUM(CASE WHEN continue_flag = 1 THEN 1 ELSE 0 END) AS noContinueCnt, |
| | | SUM(CASE WHEN continue_flag = 2 THEN 1 ELSE 0 END) AS continueCnt |
| | | FROM service_subtask |
| | | WHERE del_flag = 0 |
| | | AND continue_flag IN (1, 2) |
| | | AND deptcode IS NOT NULL AND deptcode != '' |
| | | AND leaveldeptcode IS NOT NULL AND leaveldeptcode != '' |
| | | <if test="orgid != null and orgid != ''"> |
| | | AND orgid = #{orgid} |
| | | </if> |
| | |
| | | AND campusid = #{campusid} |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="code" open="(" separator="," close=")"> |
| | | #{code} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY deptcode, deptname |
| | | GROUP BY leaveldeptcode, leaveldeptname |
| | | ORDER BY groupCode |
| | | </select> |
| | | |
| | |
| | | leavehospitaldistrictname AS groupName, |
| | | </when> |
| | | <otherwise> |
| | | deptcode AS groupCode, |
| | | deptname AS groupName, |
| | | leaveldeptcode AS groupCode, |
| | | leaveldeptname AS groupName, |
| | | </otherwise> |
| | | </choose> |
| | | COUNT(*) AS totalCount, |
| | |
| | | </when> |
| | | <otherwise> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="code" open="(" separator="," close=")"> |
| | | #{code} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY deptcode, deptname |
| | | GROUP BY leaveldeptcode, leaveldeptname |
| | | ORDER BY groupCode |
| | | </otherwise> |
| | | </choose> |
| | |
| | | drname, |
| | | leavehospitaldistrictcode, |
| | | leavehospitaldistrictname, |
| | | deptcode, |
| | | deptname, |
| | | leaveldeptcode, |
| | | leaveldeptname, |
| | | sendstate, |
| | | preachform, |
| | | current_preachform, |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | AND leaveldeptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |