From 8490eb11583ffdc586436f165860de5cfc39f915 Mon Sep 17 00:00:00 2001 From: cjl <909710561@qq.com> Date: Mon, 06 Jan 2025 09:18:29 +0800 Subject: [PATCH] fix:sql查询时间调整 --- screen-api/src/main/resources/mapper/OrganizationMapper.xml | 79 +++++++++++++++++++++++++++++---------- 1 files changed, 58 insertions(+), 21 deletions(-) diff --git a/screen-api/src/main/resources/mapper/OrganizationMapper.xml b/screen-api/src/main/resources/mapper/OrganizationMapper.xml index de7e2ec..7b47b80 100644 --- a/screen-api/src/main/resources/mapper/OrganizationMapper.xml +++ b/screen-api/src/main/resources/mapper/OrganizationMapper.xml @@ -2,26 +2,63 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.moral.api.mapper.OrganizationMapper"> - <!-- ������������������������ --> - <resultMap id="BaseResultMap" type="com.moral.api.entity.Organization"> - <id column="id" property="id" /> - <result column="parent_id" property="parentId" /> - <result column="admin_user_id" property="adminUserId" /> - <result column="name" property="name" /> - <result column="province_code" property="provinceCode" /> - <result column="city_code" property="cityCode" /> - <result column="area_code" property="areaCode" /> - <result column="town_code" property="townCode" /> - <result column="village_code" property="villageCode" /> - <result column="location_level" property="locationLevel" /> - <result column="address" property="address" /> - <result column="phone" property="phone" /> - <result column="email" property="email" /> - <result column="wechat" property="wechat" /> - <result column="create_time" property="createTime" /> - <result column="update_time" property="updateTime" /> - <result column="expire_time" property="expireTime" /> - <result column="is_delete" property="isDelete" /> - </resultMap> + <!-- ������������������������ --> + <resultMap id="BaseResultMap" type="com.moral.api.entity.Organization"> + <id column="id" property="id"/> + <result column="parent_id" property="parentId"/> + <result column="admin_user_id" property="adminUserId"/> + <result column="name" property="name"/> + <result column="province_code" property="provinceCode"/> + <result column="province_name" property="provinceName"/> + <result column="city_code" property="cityCode"/> + <result column="city_name" property="cityName"/> + <result column="area_code" property="areaCode"/> + <result column="area_name" property="areaName"/> + <result column="location_level_code" property="locationLevelCode"/> + <result column="location_level_name" property="locationLevelName"/> + <result column="address" property="address"/> + <result column="phone" property="phone"/> + <result column="email" property="email"/> + <result column="wechat" property="wechat"/> + <result column="create_time" property="createTime"/> + <result column="update_time" property="updateTime"/> + <result column="expire_time" property="expireTime"/> + <result column="is_delete" property="isDelete"/> + </resultMap> + <select id="orgIdList" resultType="java.lang.Integer"> + SELECT id FROM ( + SELECT id, parent_id, name FROM organization WHERE id = #{organizationId} + UNION ALL + SELECT i.id, i.parent_id, i.name + FROM organization i + INNER JOIN ( + SELECT * FROM ( + SELECT id, parent_id, name FROM organization WHERE id = #{organizationId} + UNION ALL + SELECT id, parent_id, name FROM organization WHERE parent_id = #{organizationId} + ) t1 + ) t2 ON i.parent_id = t2.id + where i.is_delete = 0 + ) t3 + </select> + <select id="orgIdSpecialDevList" resultType="java.lang.Integer"> + select organization_id from special_device where organization_id in ( + SELECT id FROM ( + SELECT id, parent_id, name FROM organization WHERE id = #{organizationId} + UNION ALL + SELECT i.id, i.parent_id, i.name + FROM organization i + INNER JOIN ( + SELECT * FROM ( + SELECT id, parent_id, name FROM organization WHERE id = #{organizationId} + UNION ALL + SELECT id, parent_id, name FROM organization WHERE parent_id = #{organizationId} + ) t1 + ) t2 ON i.parent_id = t2.id + where i.is_delete = 0 + ) t3 ) and mac = #{mac} and is_delete = 0 + + + </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0