Procházet zdrojové kódy

20220527_sun优化信息查询页面sql

15143018065 před 2 roky
rodič
revize
caf337689a

+ 15 - 6
ruoyi-modules/mz-business/src/main/java/com/ruoyi/business/controller/DjpdSqController.java

@@ -309,18 +309,27 @@ public class DjpdSqController extends BaseController
     @GetMapping("/jgqy/list")
     public TableDataInfo jgqyList(YljgKhHtxx htxx)
     {
+        List<YljgKhHtxx> list = new ArrayList<>();
         PageDomain pageDomain = TableSupport.buildPageRequest();
         htxx.getParams().put("pageSize", pageDomain.getPageSize());
         htxx.getParams().put("pageNum", (pageDomain.getPageNum() - 1) * pageDomain.getPageSize());
         htxx.setCreateUnit(SecurityUtils.getUserUnitId());
         long count = htxxMapper.selectYljgKhHtxxByQyCount(htxx);
-        List<YljgKhHtxx> list = htxxMapper.selectYljgKhHtxxByQy(htxx);
+        List<String> pageIdList = htxxMapper.selectYljgKhHtxxByQyIdList(htxx);
+        if (CollectionUtils.isNotEmpty(pageIdList)) {
+            list = htxxMapper.selectYljgKhHtxxByQy(pageIdList);
+        }
         list.forEach(l -> {
-            if (StringUtils.isNotEmpty(l.getSzxzqh())) {
-                Map<String, Object> qh = sysDeptJlMapper.selectJlDeptByParams(null, l.getSzxzqh());
-                if (ObjectUtils.isNotEmpty(qh)) {
-                    if (qh.containsKey(SysDeptJlStatus.NAME.getCode())) {
-                        l.setSzxzqh(qh.get(SysDeptJlStatus.NAME.getCode()).toString());
+            if (StringUtils.isNotEmpty(l.getJgmc())) {
+                String jgmc = l.getJgmc().substring(0, l.getJgmc().indexOf("%%"));
+                String szxzqh = l.getJgmc().substring(l.getJgmc().indexOf("%%") + 2);
+                l.setJgmc(jgmc);
+                if (StringUtils.isNotEmpty(szxzqh)) {
+                    Map<String, Object> qh = sysDeptJlMapper.selectJlDeptByParams(null, szxzqh);
+                    if (ObjectUtils.isNotEmpty(qh)) {
+                        if (qh.containsKey(SysDeptJlStatus.NAME.getCode())) {
+                            l.setSzxzqh(qh.get(SysDeptJlStatus.NAME.getCode()).toString());
+                        }
                     }
                 }
             }

+ 5 - 6
ruoyi-modules/mz-business/src/main/java/com/ruoyi/business/controller/YljgKhJbxxController.java

@@ -3,12 +3,15 @@ package com.ruoyi.business.controller;
 import com.ruoyi.business.domain.YljgKhChxxx;
 import com.ruoyi.business.domain.YljgKhJbxx;
 import com.ruoyi.business.domain.YljgKhJtxx;
+import com.ruoyi.business.mapper.YljgKhJbxxMapper;
 import com.ruoyi.business.service.IYljgKhJbxxService;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.PageDomain;
 import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.core.web.page.TableSupport;
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.security.annotation.RequiresPermissions;
@@ -39,9 +42,7 @@ public class YljgKhJbxxController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(YljgKhJbxx yljgKhJbxx)
     {
-        startPage();
-        List<YljgKhJbxx> list = yljgKhJbxxService.selectYljgKhJbxxList(yljgKhJbxx);
-        return getDataTable(list);
+        return yljgKhJbxxService.selectYljgKhJbxxPage(yljgKhJbxx, TableSupport.buildPageRequest());
     }
 
     /**
@@ -51,9 +52,7 @@ public class YljgKhJbxxController extends BaseController
     @GetMapping("/sq/list")
     public TableDataInfo sqList(YljgKhJbxx yljgKhJbxx)
     {
-        startPage();
-        List<YljgKhJbxx> list = yljgKhJbxxService.selectYljgKhJbxxSqList(yljgKhJbxx);
-        return getDataTable(list);
+        return yljgKhJbxxService.selectYljgKhJbxxSqPage(yljgKhJbxx, TableSupport.buildPageRequest());
     }
 
     /**

+ 3 - 3
ruoyi-modules/mz-business/src/main/java/com/ruoyi/business/mapper/YljgKhHtxxMapper.java

@@ -20,9 +20,9 @@ import java.util.List;
 })
 public interface YljgKhHtxxMapper extends BaseMapperPlus<YljgKhHtxx>
 {
-    @InterceptorIgnore(tenantLine = "true")
-    public List<YljgKhHtxx> selectYljgKhHtxxByQy(YljgKhHtxx yljgKhHtxx);
+    public List<YljgKhHtxx> selectYljgKhHtxxByQy(List<String> idList);
+
+    public List<String> selectYljgKhHtxxByQyIdList(YljgKhHtxx yljgKhHtxx);
 
-    @InterceptorIgnore(tenantLine = "true")
     public long selectYljgKhHtxxByQyCount(YljgKhHtxx yljgKhHtxx);
 }

+ 12 - 0
ruoyi-modules/mz-business/src/main/java/com/ruoyi/business/mapper/YljgKhJbxxMapper.java

@@ -47,4 +47,16 @@ public interface YljgKhJbxxMapper extends BaseMapperPlus<YljgKhJbxx>
     public List<YljgKhChxxx> selectChxxxList(YljgKhChxxx chxxx);
 
     public List<YljgKhNlpg> selectNlpgList(YljgKhNlpg nlpg);
+
+    public long selectYljgKhJbxxCount(YljgKhJbxx yljgKhJbxx);
+
+    public long selectYljgKhJbxxSqCount(YljgKhJbxx yljgKhJbxx);
+
+    public List<String> selectYljgKhJbxxPageIdList(YljgKhJbxx yljgKhJbxx);
+
+    public List<String> selectYljgKhJbxxSqPageIdList(YljgKhJbxx yljgKhJbxx);
+
+    public List<YljgKhJbxx> selectYljgKhJbxxPage(List<String> pageIdList);
+
+    public List<YljgKhJbxx> selectYljgKhJbxxSqPage(List<String> pageIdList);
 }

+ 6 - 0
ruoyi-modules/mz-business/src/main/java/com/ruoyi/business/service/IYljgKhJbxxService.java

@@ -3,6 +3,8 @@ package com.ruoyi.business.service;
 import com.ruoyi.business.domain.YljgKhChxxx;
 import com.ruoyi.business.domain.YljgKhJbxx;
 import com.ruoyi.business.domain.YljgKhJtxx;
+import com.ruoyi.common.core.web.page.PageDomain;
+import com.ruoyi.common.core.web.page.TableDataInfo;
 
 import java.util.List;
 
@@ -30,6 +32,10 @@ public interface IYljgKhJbxxService
      */
     public List<YljgKhJbxx> selectYljgKhJbxxList(YljgKhJbxx yljgKhJbxx);
 
+    public TableDataInfo selectYljgKhJbxxPage(YljgKhJbxx yljgKhJbxx, PageDomain pageDomain);
+
+    public TableDataInfo selectYljgKhJbxxSqPage(YljgKhJbxx yljgKhJbxx, PageDomain pageDomain);
+
     public List<YljgKhJbxx> selectYljgKhJbxxSqList(YljgKhJbxx yljgKhJbxx);
 
     public List<YljgKhJtxx> selectJtxxList(YljgKhJtxx jtxx);

+ 74 - 0
ruoyi-modules/mz-business/src/main/java/com/ruoyi/business/service/impl/YljgKhJbxxServiceImpl.java

@@ -7,9 +7,13 @@ import com.ruoyi.business.mapper.YljgKhHtxxMapper;
 import com.ruoyi.business.mapper.YljgKhJbxxMapper;
 import com.ruoyi.business.mapper.YljgKhRztzxxMapper;
 import com.ruoyi.business.service.IYljgKhJbxxService;
+import com.ruoyi.common.core.constant.HttpStatus;
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.web.page.PageDomain;
+import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.ruoyi.ext.api.enums.SysDeptJlStatus;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -132,6 +136,76 @@ public class YljgKhJbxxServiceImpl implements IYljgKhJbxxService
         return res;
     }
 
+    @Override
+    public TableDataInfo selectYljgKhJbxxPage(YljgKhJbxx yljgKhJbxx, PageDomain pageDomain) {
+        List<YljgKhJbxx> res = new ArrayList<>();
+        yljgKhJbxx.getParams().put("pageSize", pageDomain.getPageSize());
+        yljgKhJbxx.getParams().put("pageNum", (pageDomain.getPageNum() - 1) * pageDomain.getPageSize());
+        long count = yljgKhJbxxMapper.selectYljgKhJbxxCount(yljgKhJbxx);
+        List<String> pageIdList = yljgKhJbxxMapper.selectYljgKhJbxxPageIdList(yljgKhJbxx);
+        if (CollectionUtils.isNotEmpty(pageIdList)) {
+            res = yljgKhJbxxMapper.selectYljgKhJbxxPage(pageIdList);
+        }
+        res.forEach(r -> {
+            r.setAge(String.valueOf(DateUtils.getCurrentAge(
+                    DateUtils.dateTime(YYYYMMDD, r.getCsrq()))) + "岁");
+            if (StringUtils.isNotEmpty(r.getJgmc())) {
+                String jgmc = r.getJgmc().substring(0, r.getJgmc().indexOf("%%"));
+                String szxzqh = r.getJgmc().substring(r.getJgmc().indexOf("%%") + 2);
+                r.setJgmc(jgmc);
+                if (StringUtils.isNotEmpty(szxzqh)) {
+                    Map<String, Object> map = sysDeptJlMapper.selectJlDeptByParams(null, szxzqh);
+                    if (ObjectUtils.isNotEmpty(map)) {
+                        if (map.containsKey(SysDeptJlStatus.NAME.getCode())) {
+                            r.setXzqhId(map.get(SysDeptJlStatus.NAME.getCode()).toString());
+                        }
+                    }
+                }
+            }
+        });
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setRows(res);
+        rspData.setMsg("查询成功");
+        rspData.setTotal(count);
+        return rspData;
+    }
+
+    @Override
+    public TableDataInfo selectYljgKhJbxxSqPage(YljgKhJbxx yljgKhJbxx, PageDomain pageDomain) {
+        List<YljgKhJbxx> res = new ArrayList<>();
+        yljgKhJbxx.getParams().put("pageSize", pageDomain.getPageSize());
+        yljgKhJbxx.getParams().put("pageNum", (pageDomain.getPageNum() - 1) * pageDomain.getPageSize());
+        long count = yljgKhJbxxMapper.selectYljgKhJbxxSqCount(yljgKhJbxx);
+        List<String> pageIdList = yljgKhJbxxMapper.selectYljgKhJbxxSqPageIdList(yljgKhJbxx);
+        if (CollectionUtils.isNotEmpty(pageIdList)) {
+            res = yljgKhJbxxMapper.selectYljgKhJbxxSqPage(pageIdList);
+        }
+        res.forEach(r -> {
+            r.setAge(String.valueOf(DateUtils.getCurrentAge(
+                    DateUtils.dateTime(YYYYMMDD, r.getCsrq()))) + "岁");
+            if (StringUtils.isNotEmpty(r.getJgmc())) {
+                String jgmc = r.getJgmc().substring(0, r.getJgmc().indexOf("%%"));
+                String szxzqh = r.getJgmc().substring(r.getJgmc().indexOf("%%") + 2);
+                r.setJgmc(jgmc);
+                if (StringUtils.isNotEmpty(szxzqh)) {
+                    Map<String, Object> map = sysDeptJlMapper.selectJlDeptByParams(null, szxzqh);
+                    if (ObjectUtils.isNotEmpty(map)) {
+                        if (map.containsKey(SysDeptJlStatus.NAME.getCode())) {
+                            r.setXzqhId(map.get(SysDeptJlStatus.NAME.getCode()).toString());
+                        }
+                    }
+                }
+            }
+        });
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setRows(res);
+        rspData.setMsg("查询成功");
+        rspData.setTotal(count);
+        return rspData;
+    }
+
     /**
      * 查询养老机构_客户_基本信息列表
      *

+ 26 - 23
ruoyi-modules/mz-business/src/main/resources/mapper/business/YljgKhHtxxMapper.xml

@@ -55,40 +55,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="szxzqh"    column="szxzqh"    />
     </resultMap>
 
-    <select id="selectYljgKhHtxxByQy" parameterType="YljgKhHtxx" resultMap="YljgKhHtxxResult">
+    <select id="selectYljgKhHtxxByQy" parameterType="java.util.List" resultMap="YljgKhHtxxResult">
         SELECT id, xm, zjhm, cwh, fjh, hldj, htksrq, htjsrq, yjrzrq, htqdrq, rzzt,
-        (select yljg_jcxx.jgmc from yljg_jcxx where yljg_kh_htxx.jg_id = yljg_jcxx.id) as jgmc,
-        (select yljg_jcxx.szxzqh from yljg_jcxx where yljg_kh_htxx.jg_id = yljg_jcxx.id) as szxzqh
+        (select CONCAT_WS('%%', jgmc, szxzqh) from yljg_jcxx where yljg_kh_htxx.jg_id = yljg_jcxx.id) as jgmc
         FROM yljg_kh_htxx
-        INNER JOIN (
-            SELECT
-                id
-            FROM
-                yljg_kh_htxx
-            <where>
-                state = '0'
-                <if test="createUnit != null and createUnit != ''"> and (create_unit BETWEEN #{createUnit} and (select max(dept_id) FROM sys_dept WHERE find_in_set(#{createUnit}, ancestors)))</if>
-                <if test="xm != null  and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
-                <if test="zjhm != null  and zjhm != ''"> and zjhm = #{zjhm}</if>
-                <if test="(jgmc != null and jgmc != '') and (szxzqh != null  and szxzqh != '')">
-                    AND jg_id IN (select id from yljg_jcxx where szxzqh = #{szxzqh} and jgmc like concat('%', #{jgmc}, '%'))
-                </if>
-                <if test="(jgmc != null and jgmc != '') and (szxzqh == null or szxzqh == '')"> AND jg_id IN (select id from yljg_jcxx where jgmc like concat('%', #{jgmc}, '%'))</if>
-                <if test="(jgmc == null or jgmc == '') and (szxzqh != null and szxzqh != '')"> AND jg_id IN (select id from yljg_jcxx where szxzqh = #{szxzqh})</if>
-            </where>
-            LIMIT #{params.pageNum}, #{params.pageSize}
-        ) AS page USING(id)
+        <where>
+            id in
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
 
+    <select id="selectYljgKhHtxxByQyIdList" parameterType="YljgKhHtxx" resultType="String">
+        SELECT
+            id
+        FROM
+            yljg_kh_htxx FORCE INDEX (idx_jgqy)
+        <where>
+            state = '0'
+            <if test="xm != null  and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
+            <if test="zjhm != null  and zjhm != ''"> and zjhm = #{zjhm}</if>
+            <if test="(jgmc != null and jgmc != '') and (szxzqh != null  and szxzqh != '')">
+                AND jg_id IN (select id from yljg_jcxx where szxzqh = #{szxzqh} and jgmc like concat('%', #{jgmc}, '%'))
+            </if>
+            <if test="(jgmc != null and jgmc != '') and (szxzqh == null or szxzqh == '')"> AND jg_id IN (select id from yljg_jcxx where jgmc like concat('%', #{jgmc}, '%'))</if>
+            <if test="(jgmc == null or jgmc == '') and (szxzqh != null and szxzqh != '')"> AND jg_id IN (select id from yljg_jcxx where szxzqh = #{szxzqh})</if>
+        </where>
+        LIMIT #{params.pageNum}, #{params.pageSize}
     </select>
 
     <select id="selectYljgKhHtxxByQyCount" parameterType="YljgKhHtxx" resultType="Long">
         select
         count(0)
         from
-        yljg_kh_htxx
+        yljg_kh_htxx FORCE INDEX (idx_jgqy)
         <where>
             state = '0'
-            <if test="createUnit != null and createUnit != ''"> and (create_unit BETWEEN #{createUnit} and (select max(dept_id) FROM sys_dept WHERE find_in_set(#{createUnit}, ancestors)))</if>
             <if test="xm != null  and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
             <if test="zjhm != null  and zjhm != ''"> and zjhm = #{zjhm}</if>
             <if test="(jgmc != null and jgmc != '') and (szxzqh != null  and szxzqh != '')">

+ 175 - 4
ruoyi-modules/mz-business/src/main/resources/mapper/business/YljgKhJbxxMapper.xml

@@ -131,8 +131,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <sql id="selectYljgKhJbxxVo">
         select a.id, a.jg_id, a.xm, a.xb, a.zjhm, a.csrq, a.nlpg, a.is_cj, b.jgmc as jgmc,
          b.szxzqh as xjdxzqy
-         from yljg_kh_jbxx a
-         left join yljg_jcxx b on a.jg_id = b.id and b.state = '0'
+         from yljg_kh_jbxx a FORCE INDEX (idx_rzjg)
+         left join yljg_jcxx b on a.jg_id = b.id
     </sql>
 
     <select id="selectYljgKhJbxxList" parameterType="YljgKhJbxx" resultMap="YljgKhJbxxResult">
@@ -153,8 +153,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <sql id="selectYljgKhJbxxSqVo">
         select a.id, a.jg_id, a.xm, a.xb, a.zjhm, a.csrq, a.nlpg, a.is_cj, b.jgmc as jgmc,
          b.szxzqh as xjdxzqy
-         from yljg_kh_jbxx a
-         left join yljgsq_jcxx b on a.jg_id = b.id and b.state = '0'
+         from yljg_kh_jbxx a FORCE INDEX (idx_sqfw)
+         left join yljgsq_jcxx b on a.jg_id = b.id
     </sql>
 
     <select id="selectYljgKhJbxxSqList" parameterType="YljgKhJbxx" resultMap="YljgKhJbxxResult">
@@ -250,4 +250,175 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             id = #{id}
         AND state = '0'
     </select>
+
+
+    <select id="selectYljgKhJbxxCount" parameterType="YljgKhJbxx" resultType="Long">
+        SELECT
+            count(0)
+        FROM
+            yljg_kh_jbxx FORCE INDEX (idx_rzjg)
+        <where>
+            state = '0'
+            AND is_rz = '1'
+            AND create_user_type = '01'
+            <if test="xm != null  and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
+            <if test="zjhm != null  and zjhm != ''"> and zjhm = #{zjhm}</if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId != null  and xzqhId != '')">
+                AND jg_id IN (select id from yljg_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ) and jgmc like concat('%', #{jgmc}, '%'))
+            </if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId == null or xzqhId == '')"> AND jg_id IN (select id from yljg_jcxx where jgmc like concat('%', #{jgmc}, '%'))</if>
+            <if test="(jgmc == null or jgmc == '') and (xzqhId != null and xzqhId != '')"> AND jg_id IN (select id from yljg_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ))</if>
+            <if test="nlpg != null  and nlpg != ''"> and nlpg = #{nlpg}</if>
+            <if test="isCj != null  and isCj != ''"> and is_cj = #{isCj}</if>
+        </where>
+    </select>
+
+    <select id="selectYljgKhJbxxSqCount" parameterType="YljgKhJbxx" resultType="Long">
+        SELECT
+        count(0)
+        FROM
+        yljg_kh_jbxx FORCE INDEX (idx_sqfw)
+        <where>
+            state = '0'
+            AND create_user_type = '02'
+            <if test="xm != null  and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
+            <if test="zjhm != null  and zjhm != ''"> and zjhm = #{zjhm}</if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId != null  and xzqhId != '')">
+                AND jg_id IN (select id from yljgsq_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ) and jgmc like concat('%', #{jgmc}, '%'))
+            </if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId == null or xzqhId == '')"> AND jg_id IN (select id from yljgsq_jcxx where jgmc like concat('%', #{jgmc}, '%'))</if>
+            <if test="(jgmc == null or jgmc == '') and (xzqhId != null and xzqhId != '')"> AND jg_id IN (select id from yljgsq_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ))</if>
+            <if test="nlpg != null  and nlpg != ''"> and nlpg = #{nlpg}</if>
+            <if test="isCj != null  and isCj != ''"> and is_cj = #{isCj}</if>
+        </where>
+    </select>
+
+    <select id="selectYljgKhJbxxPageIdList" parameterType="YljgKhJbxx" resultType="String">
+        SELECT
+         id
+        FROM
+        yljg_kh_jbxx FORCE INDEX (idx_rzjg)
+        <where>
+            state = '0'
+            AND is_rz = '1'
+            AND create_user_type = '01'
+            <if test="xm != null  and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
+            <if test="zjhm != null  and zjhm != ''"> and zjhm = #{zjhm}</if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId != null  and xzqhId != '')">
+                AND jg_id IN (select id from yljg_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ) and jgmc like concat('%', #{jgmc}, '%'))
+            </if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId == null or xzqhId == '')"> AND jg_id IN (select id from yljg_jcxx where jgmc like concat('%', #{jgmc}, '%'))</if>
+            <if test="(jgmc == null or jgmc == '') and (xzqhId != null and xzqhId != '')"> AND jg_id IN (select id from yljg_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ))</if>
+            <if test="nlpg != null  and nlpg != ''"> and nlpg = #{nlpg}</if>
+            <if test="isCj != null  and isCj != ''"> and is_cj = #{isCj}</if>
+        </where>
+        LIMIT #{params.pageNum}, #{params.pageSize}
+    </select>
+
+    <select id="selectYljgKhJbxxSqPageIdList" parameterType="YljgKhJbxx" resultType="String">
+        SELECT
+        id
+        FROM
+        yljg_kh_jbxx FORCE INDEX (idx_sqfw)
+        <where>
+            state = '0'
+            AND create_user_type = '02'
+            <if test="xm != null  and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
+            <if test="zjhm != null  and zjhm != ''"> and zjhm = #{zjhm}</if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId != null  and xzqhId != '')">
+                AND jg_id IN (select id from yljgsq_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ) and jgmc like concat('%', #{jgmc}, '%'))
+            </if>
+            <if test="(jgmc != null and jgmc != '') and (xzqhId == null or xzqhId == '')"> AND jg_id IN (select id from yljgsq_jcxx where jgmc like concat('%', #{jgmc}, '%'))</if>
+            <if test="(jgmc == null or jgmc == '') and (xzqhId != null and xzqhId != '')"> AND jg_id IN (select id from yljgsq_jcxx where szxzqh IN (
+                SELECT
+                dept_id
+                FROM
+                sys_dept
+                WHERE
+                dept_id = #{xzqhId}
+                OR find_in_set(#{xzqhId}, ancestors)
+                ))</if>
+            <if test="nlpg != null  and nlpg != ''"> and nlpg = #{nlpg}</if>
+            <if test="isCj != null  and isCj != ''"> and is_cj = #{isCj}</if>
+        </where>
+        LIMIT #{params.pageNum}, #{params.pageSize}
+    </select>
+
+    <select id="selectYljgKhJbxxPage" parameterType="java.util.List" resultMap="YljgKhJbxxResult">
+        select id, jg_id, xm, xb, zjhm, csrq, nlpg, is_cj, (select CONCAT_WS('%%', jgmc, szxzqh) from yljg_jcxx where yljg_jcxx.id = yljg_kh_jbxx.jg_id) AS jgmc
+        from yljg_kh_jbxx
+        <where>
+            id in
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
+    <select id="selectYljgKhJbxxSqPage" parameterType="java.util.List" resultMap="YljgKhJbxxResult">
+        select id, jg_id, xm, xb, zjhm, csrq, nlpg, is_cj, (select CONCAT_WS('%%', jgmc, szxzqh) from yljgsq_jcxx where yljgsq_jcxx.id = yljg_kh_jbxx.jg_id) AS jgmc
+        from yljg_kh_jbxx
+        <where>
+            id in
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
 </mapper>

+ 0 - 3
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptJlController.java

@@ -57,9 +57,6 @@ public class SysDeptJlController extends BaseController
     @GetMapping("/tree")
     public AjaxResult tree(SysDeptJl sysDeptJl)
     {
-        if(StringUtils.isEmpty(sysDeptJl.getParentId()) && StringUtils.isEmpty(sysDeptJl.getId())){
-            sysDeptJl.setParentId("479a446fce894740b373f9c4b356daac");
-        }
         List<SysDeptJl> list = sysDeptJlService.selectSysDeptJlTree(sysDeptJl);
         return AjaxResult.success(list);
     }

+ 1 - 2
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptJlMapper.xml

@@ -47,9 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectSysDeptJlTree" parameterType="SysDeptJl" resultMap="SysDeptJlResult">
         select * from (select id, code, code as dept_id, name, parent_id, level
-        from sys_dept_jl) as a
+        from sys_dept_jl where level &lt; 4) as a
         <where>
-            a.level &lt; 4
             <if test="id != null  and id != ''"> and a.id = #{id}</if>
             <if test="code != null  and code != ''"> and a.code = #{code}</if>
             <if test="name != null  and name != ''"> and a.name like concat('%', #{name}, '%')</if>

+ 10 - 2
ruoyi-ui/src/views/business/xxcx/lrxx/rzjg/index.vue

@@ -165,7 +165,7 @@
         </template>
       </el-table-column>
       <el-table-column label="入住机构名称" align="center" prop="jgmc" />
-      <el-table-column label="机构所在区划" align="center" prop="xjdxzqy">
+      <el-table-column label="机构所在区划" align="center" prop="xzqhId">
       </el-table-column>
       <el-table-column
         label="操作"
@@ -627,6 +627,11 @@ export default {
     };
   },
   created() {
+    if (this.user.userData.dept.parentId == '0') {
+this.queryParams.xzqhId = '220000000000';
+    } else {
+this.queryParams.xzqhId = this.user.userData.dept.deptId;
+    }
     this.getList();
   },
   computed: {
@@ -671,7 +676,10 @@ export default {
       this.handleQuery();
     },
     async loadNode(node, resolve) {
-      const parentId = node.level == 0? this.user.userData.dept.parentId :node.data.code;
+      let parentId = node.level == 0? this.user.userData.dept.parentId :node.data.code;
+      if (parentId == '0') {
+        parentId = '000000000000';
+      }
       let {code, data} = await treeDeptJlList({
         parentId
       });

+ 11 - 2
ruoyi-ui/src/views/business/xxcx/lrxx/sqfw/index.vue

@@ -165,7 +165,7 @@
         </template>
       </el-table-column>
       <el-table-column label="入住机构名称" align="center" prop="jgmc" />
-      <el-table-column label="机构所在区划" align="center" prop="xjdxzqy">
+      <el-table-column label="机构所在区划" align="center" prop="xzqhId">
       </el-table-column>
       <el-table-column
         label="操作"
@@ -627,6 +627,12 @@ export default {
     };
   },
   created() {
+        if (this.user.userData.dept.parentId == '0') {
+this.queryParams.xzqhId = '220000000000';
+    } else {
+this.queryParams.xzqhId = this.user.userData.dept.deptId;
+    }
+    
     this.getList();
   },
   computed: {
@@ -671,7 +677,10 @@ export default {
       this.handleQuery();
     },
     async loadNode(node, resolve) {
-      const parentId = node.level == 0? this.user.userData.dept.parentId :node.data.code;
+      let parentId = node.level == 0? this.user.userData.dept.parentId :node.data.code;
+      if (parentId == '0') {
+        parentId = '000000000000';
+      }
       let {code, data} = await treeDeptJlList({
         parentId
       });