| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 | <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.care.bigscreen.mapper.BigSreenMapper">    <!--查询-->    <select id="selectBigScreenStatisticsByOp" resultType="com.care.bigscreen.vo.OpBigScreenStatisticsVO">        SELECT        sum(older_amount) olderAmount,        sum(older_60_80_amount) older6080Amount,        convert(sum(older_60_80_amount)/sum(older_amount),decimal(20,2)) older6080Rate,        sum(older_80_above_amount) older80AboveAmount,        convert(sum(older_80_above_amount)/sum(older_amount),decimal(20,2)) older80AboveRate,        sum(alone_living_amount) aloneLivingAmount,        convert(sum(alone_living_amount)/sum(older_amount),decimal(20,2)) aloneLivingRate,        sum(no_alone_living_amount) noAloneLivingAmount,        convert(sum(no_alone_living_amount)/sum(older_amount),decimal(20,2)) noAloneLivingRate,        sum(concentrate_living_amount) concentrateLivingAmount,        convert(sum(concentrate_living_amount)/sum(older_amount),decimal(20,2)) concentrateLivingRate,        sum(other_living_amount) otherLivingAmount,        convert(sum(other_living_amount)/sum(older_amount),decimal(20,2)) otherLivingRate,        sum(one_level_amount) oneLevelAmount,        sum(two_level_amount) twoLevelAmount,        sum(three_level_amount) threeLevelAmount,        sum(chamberlain_amount) chamberlainAmount,        convert(sum(older_amount)/sum(chamberlain_amount),decimal(20,2)) serveAmountAvg,        sum(serve_amount) serveAmount,        sum(device_amount) deviceAmount,        convert(sum(indoor_online_amount)/(sum(indoor_online_amount) + sum(indoor_offline_amount)),decimal(20,2)) indoorOnlineRate,        sum(indoor_online_amount) indoorOnlineAmount,        sum(indoor_offline_amount) indoorOfflineAmount,        convert(sum(outdoor_online_amount)/(sum(outdoor_online_amount) + sum(outdoor_offline_amount)),decimal(20,2)) outdoorOnlineRate,        sum(outdoor_online_amount) outdoorOnlineAmount,        sum(outdoor_offline_amount) outdoorOfflineAmount,        sum(rt_event_amount) rtEventAmount,        sum(rt_fall_amount) rtFallAmount,        sum(rt_stagnation_amount) rtStagnationAmount,        sum(rt_falling_bed_amount) rtFallingBedAmount,        sum(rt_active_call_amount) rtActiveCallAmount,        sum(rt_outdoors_call_amount) rtOutdoorsCallAmount,        sum(his_event_amount) hisEventAmount,        sum(his_fall_amount) hisFallAmount,        sum(his_stagnation_amount) hisStagnationAmount,        sum(his_falling_bed_amount) hisFallingBedAmount,        sum(his_active_call_amount) hisActiveCallAmount,        sum(his_outdoors_call_amount) hisOutdoorsCallAmount        FROM st_station t        <where>            1 = 1            <if test="stationId != null and stationId != ''">                AND t.station_id = #{stationId}            </if>        </where>    </select>    <!--机构统计表查询-->    <select id="selectBigScreenOrgStatistics" resultType="com.care.bigscreen.vo.BigScreenOrgVO">        SELECT        sum(station_amount) stationAmount,        sum(seats_amount) seatsAmount,        convert(sum(seats_online_duration)/3600,decimal(20,2)) seatsOnlineDuration        FROM st_organization t        <where>            1 = 1            <if test="orgId != null and orgId != ''">                AND t.org_id = #{orgId}            </if>        </where>    </select>    <!--运营商大屏根据经纬度查询-->    <select id="selectOpBigScreenStatisticsByLongitudeLatitude" resultType="com.care.bigscreen.vo.OpBigScreenStatisticsVO">        SELECT        sum(older_amount) olderAmount,        sum(older_60_80_amount) older6080Amount,        convert(sum(older_60_80_amount)/sum(older_amount),decimal(20,2)) older6080Rate,        sum(older_80_above_amount) older80AboveAmount,        convert(sum(older_80_above_amount)/sum(older_amount),decimal(20,2)) older80AboveRate        FROM st_station t        <where>            t.longitude >= #{longitudeLeftUp} and t.longitude <= #{longitudeRightDown}            AND t.latitude <= #{latitudeLeftUp} and t.longitude >= #{latitudeRightDown}        </where>    </select>    <!--机构大屏查询统计-->    <select id="selectBigScreenStatisticsByOrg" resultType="com.care.bigscreen.vo.OrgBigScreenStatisticsVO">        SELECT        sum(chamberlain_amount) chamberlainAmount,        sum(chamberlain_in_service_amount) chamberlainInServiceAmount,        sum(serve_amount) serveAmount,        sum(device_amount) deviceAmount,        sum(indoor_online_amount + outdoor_online_amount) deviceOnlineAmount,        sum(indoor_offline_amount + outdoor_offline_amount) deviceOfflineAmount,        sum(rt_event_amount) rtEventAmount,        sum(rt_fall_amount + his_fall_amount) fallAmount,        convert(sum(rt_fall_amount + his_fall_amount)/sum(rt_event_amount + his_event_amount),decimal(20,2)) fallRate,        sum(rt_stagnation_amount + his_stagnation_amount) stagnationAmount,        convert(sum(rt_stagnation_amount + his_stagnation_amount)/sum(rt_event_amount + his_event_amount),decimal(20,2)) stagnationRate,        sum(rt_falling_bed_amount + his_falling_bed_amount) fallingBedAmount,        convert(sum(rt_falling_bed_amount + his_falling_bed_amount)/sum(rt_event_amount + his_event_amount),decimal(20,2)) fallingBedRate,        sum(rt_active_call_amount + his_active_call_amount) activeCallAmount,        convert(sum(rt_active_call_amount + his_active_call_amount)/sum(rt_event_amount + his_event_amount),decimal(20,2)) activeCallRate,        sum(rt_outdoors_call_amount + his_outdoors_call_amount) outdoorsCallAmount,        convert(sum(rt_outdoors_call_amount + his_outdoors_call_amount)/sum(rt_event_amount + his_event_amount),decimal(20,2)) outdoorsCallRate        FROM st_station t        <where>            1 = 1            <if test="orgId != null and orgId != ''">                AND t.org_id = #{orgId}            </if>            <if test="stationId != null and stationId != ''">                AND t.station_id = #{stationId}            </if>        </where>    </select>    <!--机构大屏根据经纬度查询-->    <select id="selectOrgBigScreenStatisticsByLongitudeLatitude" resultType="com.care.bigscreen.vo.OrgBigScreenStatisticsVO">        SELECT        (select station_amount from st_organization where org_id = t.org_id) stationAmount,        sum(device_amount) deviceAmount,        sum(indoor_online_amount + outdoor_online_amount) deviceOnlineAmount        FROM st_station t        <where>            t.longitude >= #{longitudeLeftUp} and t.longitude <= #{longitudeRightDown}            AND t.latitude <= #{latitudeLeftUp} and t.longitude >= #{latitudeRightDown}            AND t.org_id = #{orgId}        </where>    </select>    <select id="selectBigScreenStationList" resultType="com.care.bigscreen.vo.BigScreenStationVO">        SELECT        a.station_id stationId,        a.station_name stationName,        a.org_id orgId,        a.longitude,        a.latitude,        b.director,        b.phone,        b.addr,        a.chamberlain_amount chamberlainAmount,        a.device_amount deviceAmount,        (a.rt_event_amount + a.his_event_amount) eventAmount        FROM st_station a INNER JOIN care_station b ON a.station_id = b.id        <where>           1 = 1            <if test="orgId != null and orgId != ''">                AND a.org_id = #{orgId}            </if>        </where>    </select>    <select id="selectOrgBigScreenDeviceList" resultType="com.care.bigscreen.vo.BigScreenDeviceVO">        SELECT        a.dev_name deviceName,        (case when a.longitude is null then        (select b.longitude from care_house b where b.id = a.house_id)        else a.longitude  end ) longitude,        (case when a.longitude is null then        (select b.latitude from care_house b where b.id = a.house_id)        else a.latitude  end ) latitude,        a.status,        (select b.addr from care_house b where b.id = a.house_id) deviceAddr        FROM care_device a        <where>            1 = 1            <if test="orgId != null and orgId != ''">                AND a.org_id = #{orgId}            </if>            <if test="stationId != null and stationId != ''">                AND a.station_id = #{stationId}            </if>            <if test="status != null and status != ''">                AND a.status = #{status}            </if>        </where>    </select>    <select id="selectStationBigScreenStatisticsByStation" resultType="com.care.bigscreen.vo.StationBigScreenStatisticsVO">        SELECT        a.station_id stationId,        a.station_name stationName,        a.older_amount olderAmount,        a.chamberlain_amount chamberlainAmount,        a.serve_amount serveAmount,        a.serve_today_amount serveTodayAmount,        (select b.seats_amount from st_organization b where b.org_id=a.org_id) seatsAmount,        (select b.seats_curr_online_amount from st_organization b where b.org_id=a.org_id) seatsCurrOnlineAmount,        (select b.seats_call_min_amount from st_organization b where b.org_id=a.org_id) seatsCallMinAmount        FROM st_station a        where a.station_id = #{stationId}    </select>    <select id="selectBigScreenAlarmOlderList" resultType="com.care.bigscreen.vo.BigScreenAlarmOlderVO">      SELECT a.older_id olderId,         CONCAT((select b.name from care_older b where b.id = a.older_id),'--', (select sdc.name from sys_dim_code sdc where sdc.dim_code = (select b.status from care_older b where b.id = a.older_id) and sdc.type_code='older_status')) nameOlderStatus,         a.status eventStatus,        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.status and sdc.type_code='event_order_status') eventStatusName         FROM care_event_order a        where a.station_id = #{stationId} and a.status in ('0','1')        <if test="olderName != null and olderName != ''">            AND (select b.name from care_older b where b.id = a.older_id) like CONCAT('%',#{olderName},'%')        </if>        and a.modify_time  in (            SELECT modify_time from (SELECT MAX(modify_time) modify_time FROM care_event_order GROUP BY older_id) a        )        order by a.status,a.modify_time desc    </select>    <resultMap id="BigScreenOlderDetailVOMap" type="com.care.bigscreen.vo.BigScreenOlderDetailVO">        <id column="id" property="olderId"/>        <result column="name" property="name"/>        <result column="gender" property="gender"/>        <result column="age" property="age"/>        <result column="live_type" property="liveType"/>        <result column="bed_number" property="bedNumber"/>        <result column="safe_level" property="safeLevel"/>        <result column="key_escrow_type" property="keyEscrowType"/>        <result column="addr" property="addr"/>        <result column="phone" property="phone"/>        <result column="older_status" property="olderStatus"/>        <result column="older_event_status" property="olderEventStatus"/>        <collection property="olderContactList" ofType="com.care.bigscreen.vo.BigSreenOlderContactVO">            <id column="contact_id" property="contactId"/>            <result column="contact_name" property="contactName"/>            <result column="contact_phone" property="contactPhone"/>            <result column="relation_type" property="relationType"/>        </collection>    </resultMap>    <select id="selectStationBigScreenOlderDetail" resultMap="BigScreenOlderDetailVOMap">        SELECT        a.id,        a.name,        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.gender and sdc.type_code='gender') gender,        ROUND(DATEDIFF(CURDATE(), a.birthday)/365.2422) age,        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.live_type and sdc.type_code='older_live_type') live_type,         a.bed_number,         a.safe_level,         ch.key_escrow_type,         <!-- a.breath_rate,          a.heart_rate,-->          ch.addr,          a.phone,         <!-- (case when (select count(1) from care_device b where b.dev_type='2' and b.id in (select c.dev_id from care_older_device_rel c where c.older_id = a.id)) > 0 then 'Y' else 'N' end)  has_our_door_device,-->          (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.status and sdc.type_code='older_status') older_status,          (select c.status from care_event_order c where c.older_id = a.id order by c.create_time desc limit 1) older_event_status,           d.id contact_id,          d.contact_name contact_name,          d.contact_phone contact_phone,          (select sdc.name from sys_dim_code sdc where sdc.dim_code = d.relation_type and sdc.type_code='older_contact_relation_type') relation_type        FROM care_older a left join care_house_older_rel chor on chor.older_id = a.id        left join care_house_contact_rel chcr on chcr.house_id=chor.house_id        left join care_house_contact d on d.id = chcr.contact_id        left join care_house ch on ch.id=chcr.house_id        where a.id = #{olderId}        order by a.id,d.contact_level    </select>    <select id="selectStationBigScreenEventTotal" resultType="com.care.bigscreen.vo.BigScreenEventTotalVO">        SELECT        (select count(1) from care_event_order  where station_id = #{stationId} and status in ('0','1') ) rtEventAmount,        (select count(1) from care_event_order  where station_id = #{stationId} and status not in ('0','1') )  hisEventAmount         from dual    </select>    <select id="selectBigScreenRtEventList" resultType="com.care.bigscreen.vo.BigScreenEventVO">        SELECT        a.title,        a.create_time createTime,        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.status and sdc.type_code='event_order_status') status,        '告警' eventType        FROM care_event_order a        where a.status in ('0','1')        <if test="orgId != null and orgId != ''">            and a.org_id = #{orgId}        </if>        <if test="stationId != null and stationId != ''">            and a.station_id = #{stationId}        </if>        order by a.status,a.create_time    </select>    <select id="selectBigScreenHisEventListByCount" resultType="int" >        SELECT         count(1)        FROM care_event_order a        where a.station_id = #{stationId} and a.status not in ('0','1')    </select>    <select id="selectBigScreenHisEventListByPage" resultType="com.care.bigscreen.vo.BigScreenEventVO">        SELECT        a.title,        a.create_time createTime,        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.status and sdc.type_code='event_order_status') status,        '告警' eventType        FROM care_event_order a        where a.station_id = #{stationId} and a.status not in ('0','1')        order by a.create_time desc        LIMIT #{pageUtil.start}, #{pageUtil.pageSize}    </select>    <select id="selectStationBigScreenOlderCardTotal" resultType="com.care.bigscreen.vo.BigScreenOlderCardTotalVO">        SELECT        (select count(1) from care_older  where station_id = #{stationId}        <if test="olderName != null and olderName != ''">            AND name like CONCAT('%',#{olderName},'%')        </if>         ) allOlderAmount,        (select count(1) from care_older  where station_id = #{stationId} and status not in ('0','1')        <if test="olderName != null and olderName != ''">            AND name like CONCAT('%',#{olderName},'%')        </if>        )  alarmOlderAmount        from dual    </select>    <select id="selectBigScreenOlderCardListByCount" resultType="int" >        SELECT        count(1)        FROM care_older a        where a.station_id = #{stationId}        <if test="olderName != null and olderName != ''">        AND a.name like CONCAT('%',#{olderName},'%')        </if>        <if test="isAlarm == '1'.toString()">            AND a.status not in ('1','2')        </if>    </select>    <select id="selectBigScreenOlderCardListByPage" resultType="com.care.bigscreen.vo.BigScreenOlderDetailVO">        SELECT        a.id older_id,        a.name,        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.gender and sdc.type_code='gender') gender,        ROUND(DATEDIFF(CURDATE(), a.birthday)/365.2422) age,        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.live_type and sdc.type_code='older_live_type') live_type,        a.bed_number,        a.safe_level,        ch.key_escrow_type,        ch.addr,        a.phone,        <!--(case when (select count(1) from care_device b where b.dev_type='2' and b.id in (select c.dev_id from care_older_device_rel c where c.older_id = a.id)) > 0 then 'Y' else 'N' end)  has_our_door_device,-->        (select sdc.name from sys_dim_code sdc where sdc.dim_code = a.status and sdc.type_code='older_status') olderStatus,        (select c.status from care_event_order c where c.older_id = a.id order by c.create_time desc limit 1) olderEventStatus        FROM care_older a left join care_house_older_rel rel on a.id=older_id        left join care_house ch on ch.id=rel.house_id        where a.station_id = #{stationId}        <if test="olderName != null and olderName != ''">            AND a.name like CONCAT('%',#{olderName},'%')        </if>        <if test="isAlarm == '1'.toString()">            AND a.status not in ('1','2')        </if>        order by ifnull((select c.status from care_event_order c where c.older_id = a.id order by c.create_time desc limit 1),99), a.modify_time desc        LIMIT #{pageUtil.start}, #{pageUtil.pageSize}    </select></mapper>
 |