| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518 |
- <?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.daju.mix.dao.mapper.CimWorkingMapper">
- <resultMap id="BaseResultMap" type="com.daju.mix.dto.InspectorInfosDTO">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="context" jdbcType="VARCHAR" property="inspectContent"/>
- <result column="region" jdbcType="VARCHAR" property="inspectRegion"/>
- <result column="status" jdbcType="VARCHAR" property="status"/>
- </resultMap>
- <!-- 获取督查问题统计信息列表 -->
- <select id="getInspectorInfos" resultMap="BaseResultMap">
- select ci.id,
- ci.context,
- (
- SELECT
- type.typename
- FROM
- t_s_typegroup AS typeg
- LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
- WHERE
- typeg.typegroupcode = 'superivseArea'
- AND ci.area = type.typecode
- ) AS region,
- (
- SELECT
- type.typename
- FROM
- t_s_typegroup AS typeg
- LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
- WHERE
- typeg.typegroupcode = 'superivseStatus'
- AND ci.status = type.typecode
- ) AS state from t_b_schedule_superivse ci
- where TO_DAYS(ci.create_date) = TO_DAYS(NOW())
- <if test="scheduleType != null and scheduleType != '' ">
- and ci.type = #{scheduleType}
- </if>
- </select>
- <!-- 督查4.5 -->
- <select id="getCleInfos" resultType="com.daju.mix.dto.CleanInsDTO">
- select id, code serial, context inspectContent, type category, status state
- from t_b_schedule_superivse
- where TO_DAYS(create_date) = TO_DAYS(NOW())
- and type = '1'
- </select>
- <!--获取近5日预警统计信息-->
- <select id="getLast5daysWarningsOld" resultType="java.util.Map">
- SELECT
- (
- SELECT
- type.typename
- FROM
- t_s_typegroup AS typeg
- LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
- WHERE
- typeg.typegroupcode = 'assignmentStyle'
- AND a.schedule_type = type.typecode
- ) AS transportType,
- count(1) / (
- SELECT
- count(1)
- FROM
- t_b_alarm AS b
- <where>
- datediff(NOW(), b.alarm_time) <![CDATA[<]]> 5
- <if test="scheduleType != null and scheduleType != '' ">
- AND b.schedule_assignment_style = #{scheduleType}
- </if>
- </where>
- ) AS warningsRate
- FROM
- t_b_alarm AS a
- <where>
- datediff(NOW(), a.alarm_time) <![CDATA[<]]> 5
- <if test="scheduleType != null and scheduleType != '' ">
- AND a.schedule_assignment_style = #{scheduleType}
- </if>
- </where>
- GROUP BY
- a.schedule_type
- </select>
- <select id="getLast5daysWarnings" resultType="java.util.Map">
- select tst.typename alertType, ifnull(count(c.alertType), 0) num from
- (SELECT a.id,
- (
- SELECT type.typename
- FROM t_s_typegroup AS typeg
- LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
- WHERE typeg.typegroupcode = 'alarmFrom'
- AND a.alarm_from = type.typecode
- ) AS alertType,
- a.context AS alertContent,
- (
- SELECT u.realname
- FROM t_s_base_user AS u
- WHERE u.id = a.alarm_recevier
- ) AS leader,
- a.alarm_time AS alertTime
- FROM
- t_b_alarm AS a
- WHERE a.alarm_time <= date_format(NOW(), '%Y-%m-%d')
- AND a.alarm_time >= date_format(
- DATE_ADD(NOW(), INTERVAL - 5 DAY),
- '%Y-%m-%d'
- )) c
- RIGHT JOIN (select typecode, typename from t_s_type where typegroupid = 'ff8080817ae6b8cb017b0b62e8670023') tst
- ON tst.typename = c.alertType
- where
- 1 = 1
- <if test="id != null and id != ''">
- and tst.typecode = #{id}
- </if>
- group by tst.typename
- </select>
- <select id="getLast5daysWarningsC" resultType="java.util.Map">
- select tst.typename alertType, ifnull(count(c.alertType), 0) num from
- (SELECT a.id,
- (
- SELECT type.typename
- FROM t_s_typegroup AS typeg
- LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
- WHERE typeg.typegroupcode = 'alarmFrom'
- AND a.alarm_from = type.typecode
- ) AS alertType,
- a.context AS alertContent,
- (
- SELECT u.realname
- FROM t_s_base_user AS u
- WHERE u.id = a.alarm_recevier
- ) AS leader,
- a.alarm_time AS alertTime
- FROM
- t_b_alarm AS a
- WHERE a.alarm_time <= date_format(NOW(), '%Y-%m-%d')
- AND a.alarm_time >= date_format(
- DATE_ADD(NOW(), INTERVAL - 5 DAY),
- '%Y-%m-%d'
- )) c
- RIGHT JOIN (select typecode, typename from t_s_type where typegroupid = 'ff8080817ae6b8cb017b0b62e8670023') tst
- ON tst.typename = c.alertType
- where
- 1 = 1
- <if test="id != null and id != ''">
- and tst.typecode = #{id}
- </if>
- group by tst.typename
- </select>
- <!--获取近5日预警按元素类型统计信息-->
- <select id="getLast5daysWarningsByElementType" resultType="java.util.Map">
- SELECT
- DATE_FORMAT(
- last5Day.alarmDay,
- '%c.%e'
- ) AS alarmDay,
- (
- SELECT
- count(1)
- FROM
- t_b_alarm AS alarm
- WHERE
- EXISTS (
- SELECT
- csta.id
- FROM
- t_b_car_schedule_type AS csta
- WHERE
- alarm.schedule_assignment_style = csta.business_type
- <if test="elementType != null and elementType != '' ">
- AND csta.car_type = #{elementType}
- </if>
- )
- <if test="scheduleType != null and scheduleType != '' ">
- AND alarm.schedule_assignment_style = #{scheduleType}
- </if>
- AND DATEDIFF(
- alarm.alarm_time,
- last5Day.alarmDay
- ) = 0
- ) alarmCount
- FROM
- (
- SELECT
- i,
- DATE_FORMAT(
- ADDDATE(NOW(), INTERVAL - i DAY),
- '%Y-%m-%d'
- ) AS alarmDay
- FROM
- (
- SELECT
- 0 AS i
- UNION
- SELECT
- 1
- UNION
- SELECT
- 2
- UNION
- SELECT
- 3
- UNION
- SELECT
- 4
- ) lastDay
- ) last5Day
- ORDER BY
- last5Day.alarmDay DESC
- </select>
- <!-- 车辆作业获取实时预警信息-近5日-->
- <select id="getRealWarningsByElementType" resultType="com.daju.mix.dto.RealWarningDTO">
- SELECT
- a.id,
- (@i :=@i + 1) AS serial,
- a.context AS alertContent,
- (
- SELECT
- u.realname
- FROM
- t_s_base_user AS u
- WHERE
- u.id = a.alarm_recevier
- ) AS receiver
- FROM
- (SELECT @i := 0) t,
- t_b_car AS car
- RIGHT JOIN t_b_alarm AS a ON car.id = a.alarm_car
- WHERE
- DATEDIFF(NOW(), a.alarm_time) <![CDATA[<]]> 5
- <if test="scheduleType != null and scheduleType != '' ">
- AND a.schedule_assignment_style = #{scheduleType}
- </if>
- <if test="alarmFrom != null and alarmFrom != '' ">
- AND a.alarm_from = #{alarmFrom}
- </if>
- <if test="alarmType != null and alarmType != '' ">
- AND a.alarm_type = #{alarmType}
- </if>
- <if test="elementType != null and elementType != '' ">
- AND a.alarm_car = #{elementType}
- </if>
- ORDER BY
- a.alarm_time DESC
- </select>
- <select id="getRealWarningsByElementTypeC" resultType="com.daju.mix.dto.RealWarningCDTO">
- SELECT
- a.id,
- (@i :=@i + 1) AS serial,
- a.context AS Content,
- (
- SELECT
- u.realname
- FROM
- t_s_base_user AS u
- WHERE
- u.id = a.alarm_recevier
- ) AS receiver
- FROM
- (SELECT @i := 0) t,
- t_b_car AS car
- LEFT JOIN t_b_alarm AS a ON car.id = a.alarm_car
- WHERE
- datediff(NOW(), a.alarm_time) <![CDATA[<]]> 5
- <if test="id != null and id != '' ">
- AND a.alarm_user = #{id} OR a.alarm_car = #{id}
- </if>
- <if test="elementType != null and elementType = ''">
- AND a.alarm_from = #{elementType}
- </if>
- ORDER BY
- a.alarm_time DESC
- </select>
- <select id="getGWarning" resultType="com.daju.mix.dto.GcbWarningDTO">
- SELECT
- a.id id,
- (
- SELECT
- u.realname
- FROM
- t_s_base_user AS u
- WHERE
- u.id = a.alarm_user
- ) alarmUser,
- a.context AS alertContent,
- (
- SELECT
- u.realname
- FROM
- t_s_base_user AS u
- WHERE
- u.id = a.alarm_recevier
- ) AS receiver
- FROM
- t_b_car AS car
- LEFT JOIN t_b_alarm AS a ON car.id = a.alarm_car
- ${ew.customSqlSegment}
- </select>
- <select id="warningDetailsByCarId" resultType="java.util.Map">
- SELECT
- a.id,a.context, (
- SELECT
- u.realname
- FROM
- t_s_base_user AS u
- WHERE
- a.alarm_recevier = u.id
- ) AS username
- FROM
- t_b_alarm AS a
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND a.schedule_assignment_style = #{scheduleType}
- </if>
- <if test="carId != null and carId != '' ">
- AND a.alarm_car = #{carId}
- </if>
- </where>
- </select>
- <!-- 根据车辆查询今日预警数-->
- <select id="todayWarningCount" resultType="int">
- SELECT
- count(1)
- FROM
- t_b_alarm AS a
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND a.schedule_assignment_style = #{scheduleType}
- </if>
- <if test="carId != null and carId != '' ">
- AND a.alarm_car = #{carId}
- </if>
- <if test="archivesCode != null and archivesCode != '' ">
- AND a.archives_code = #{archivesCode}
- </if>
- <if test="alarmFrom != null and alarmFrom != '' ">
- AND a.alarm_from = #{alarmFrom}
- </if>
- <if test="alarmType != null and alarmType != '' ">
- AND a.alarm_type = #{alarmType}
- </if>
- AND DATEDIFF(now(), a.alarm_time) = 0
- </where>
- </select>
- <!-- 获取指定车辆的作业概况信息-->
- <select id="workingProfilesByCarId" resultType="java.util.Map">
- SELECT
- cst.id,
- cstd.username,
- cstd.user_id,
- cst.work_route_name AS workingLine,
- (
- SELECT
- type.typename
- FROM
- t_s_typegroup AS typeg
- LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
- WHERE
- typeg.typegroupcode = 'assignmentStyle'
- AND cst.type = type.typecode
- ) AS workingContent,
- (
- SELECT
- type.typename
- FROM
- t_s_typegroup AS typeg
- LEFT JOIN t_s_type AS type ON typeg.ID = type.typegroupid
- WHERE
- typeg.typegroupcode = 'workStatus'
- AND cst.`work_status` = type.typecode
- ) AS workingState
- FROM
- t_b_car_schedule_task_detail AS cstd
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = cstd.pid
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- <if test="carId != null and carId != '' ">
- AND cstd.carid = #{carId}
- </if>
- AND DATEDIFF(now(), concat(cstd.yearmonth , '-' ,cstd.code_day)) = 0
- </where>
- </select>
- <!-- 根据场所类型-查询场所数量-->
- <select id="selectPlaceCountByPlaceType" resultType="int">
- SELECT COUNT(1)
- FROM t_b_archives_place AS p
- WHERE p.type = #{placeType}
- </select>
- <!-- 根据人员职务类型-查询人员数量-->
- <select id="selectUserCountByUserDutiesId" resultType="int">
- select
- COUNT(id)
- from t_s_base_user
- where id in
- (SELECT
- userid
- FROM
- t_bus_user_personnel
- WHERE
- belong_dutiesid = #{dutiesid});
- </select>
- <select id="getUserTrend" resultType="java.lang.Integer">
- select ifnull(in_num, 0) num
- from t_public_toilet_ridership
- where TO_DAYS(NOW()) = TO_DAYS(update_time)
- and update_time <= #{date}
- and in_num != 0
- and code = #{id}
- order by
- update_time desc limit 1
- </select>
- <select id="getToiletWE" resultType="com.daju.mix.dto.ToiletWEDTO">
- SELECT DATE_FORMAT(last30Day.tempDay, '%c.%e') AS date,
- (
- select ifnull(sum(water_meter), 0) water from t_public_toilet_energy where DATEDIFF(last30Day.tempDay,
- count_date) = 0
- <if test="code != null and code != ''">
- and code = #{code}
- </if>
- ) AS water,
- (
- select ifnull(sum(watt_meter), 0) watt from t_public_toilet_energy where DATEDIFF(last30Day.tempDay, count_date)
- = 0
- <if test="code != null and code != ''">
- and code = #{code}
- </if>
- ) AS watt
- FROM (SELECT ADDDATE(NOW(), INTERVAL -i DAY) AS tempDay
- FROM (
- SELECT @xi := @xi + 1 AS i
- FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) xc1,
- (SELECT 1
- UNION
- SELECT 2
- UNION
- SELECT 3
- UNION
- SELECT 4
- UNION
- SELECT 5
- UNION
- SELECT 6) xc2,
- (SELECT 1
- UNION
- SELECT 2
- UNION
- SELECT 3
- UNION
- SELECT 4
- UNION
- SELECT 5
- UNION
- SELECT 6) xc3,
- (SELECT @xi := -1) xc0
- ) xc
- ORDER BY tempDay DESC
- LIMIT 5
- ) last30Day
- ORDER BY last30Day.tempDay ASC LIMIT 5
- </select>
- <select id="getTNum" resultType="java.lang.Integer">
- select in_num num
- from t_public_toilet_ridership
- where code = #{id}
- and in_num is not null
- order by update_time desc limit 1
- </select>
- <!-- 巡回保洁排班信息-电子围栏报警 -->
- <select id="getScheduleGps" resultType="com.daju.mix.dto.ElectronicFenceDto">
- select tpr.person_id userId,
- tpr.longitude_wgs84 longitude,
- tpr.latitude_wgs84 latitude,
- CONCAT(tcd.yearmonth, '-', tcd.code_day) date, tbt.`start`, CONCAT(tcd.yearmonth,'-',tcd.code_day,' ', tbt.`start`, ':00') beginTime, CONCAT(tcd.yearmonth,'-',tcd.code_day,' ', tbt.`end`, ':00') endTime
- from
- t_personnel_real_position tpr
- left join
- t_b_car_schedule_task_detail tcd on tcd.user_id = tpr.person_id
- left join
- t_b_car_schedule_task tbt on tbt.id = tcd.pid
- where
- TO_DAYS(NOW()) = TO_DAYS(tpr.gps_time)
- and
- TO_DAYS(NOW()) = TO_DAYS(CONCAT(tcd.yearmonth
- , '-'
- , tcd.code_day))
- and
- tbt.type = 24
- </select>
- </mapper>
|