| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784 |
- <?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.TBCarScheduleTaskArrangeMapper">
- <!-- 根据作业类型、车辆类型、查询今日作业人数-->
- <select id="selectTodayWorkersCountByScheduleTypeAndCarType" resultType="String">
- SELECT
- csta.user_id as userCount
- FROM
- t_b_car_schedule_task_detail AS csta
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
- where
- TO_DAYS(NOW()) = TO_DAYS(CONCAT(csta.yearmonth,'-',csta.code_day))
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- <if test="elementType != null and elementType != '' ">
- AND csta.carid in (select id from t_b_car where type = #{elementType} )
- </if>
- GROUP BY
- csta.user_id
- </select>
- <!-- add-刘梦祥-2022年7月18日17:41:58(根据作业类型、场所类型、查询今日作业人数)-->
- <select id="selectTodayWorkersCountByScheduleTypeAndElementType" resultType="String">
- SELECT
- user_id as userId
- FROM
- t_b_car_schedule_task_detail
- WHERE
- concat(yearmonth, "-", code_day) = CURDATE()
- AND pid IN (
- SELECT
- id
- FROM
- T_b_car_schedule_task
- WHERE
- <if test="scheduleType != null and scheduleType != '' ">
- assignment_style = #{scheduleType}
- </if>
- <if test="elementType != null and elementType != '' ">
- AND work_route IN (
- SELECT
- route_id
- FROM
- t_b_work_route_list
- WHERE
- place_code IN (
- SELECT
- `code`
- FROM
- t_b_archives_area
- where area_type = #{elementType}
- )
- GROUP BY route_id
- )
- </if>
- )
- and user_id is not NULL;
- </select>
- <!-- 根据作业类型、元素类型、查询今日作业车辆数update:刘梦祥-2022年7月14日15:04:04(优化查询逻辑,并解决查询数据异常的问题)-->
- <select id="selectTodayVehiclesCountByScheduleTypeAndElementType" resultType="int">
- SELECT
- count(DISTINCT tbcstd.carid)
- FROM
- t_b_car_schedule_task_detail tbcstd
- RIGHT JOIN t_b_car_schedule_task tbcst ON tbcstd.pid = tbcst.id
- RIGHT JOIN t_b_car tbc ON tbcstd.carid = tbc.id
- WHERE
- CONCAT(tbcstd.code_year,"-",tbcstd.code_month,"-",tbcstd.code_day) = CURDATE()
- <if test="scheduleType != null and scheduleType != '' ">
- AND tbcst.assignment_style = #{scheduleType}
- </if>
- <if test="carType != null and carType != '' ">
- AND tbc.type = #{carType}
- </if>
- <if test="elementType != null and elementType != '' ">
- AND tbcstd.pid IN (
- SELECT
- id
- FROM
- T_b_car_schedule_task
- WHERE
- <if test="scheduleType != null and scheduleType != '' ">
- assignment_style = #{scheduleType}
- </if>
- AND work_route IN (
- SELECT
- route_id
- FROM
- t_b_work_route_list
- WHERE
- place_code IN (
- SELECT
- `code`
- FROM
- t_b_archives_place
- where type = #{elementType}
- )
- GROUP BY route_id
- )
- )
- </if>
- and tbcstd.carid is not NULL;
- </select>
- <!-- 查询今日区域作业人数-->
- <select id="selectTodayWorkersCountByRegionType" resultType="java.util.Map">
- SELECT
- tbwr.area_region areaRegion,
- count(DISTINCT tbcstd.user_id) userCount
- FROM
- t_b_car_schedule_task_detail tbcstd
- LEFT JOIN t_b_car_schedule_task tbcst ON tbcst.id = tbcstd.pid
- LEFT JOIN t_b_work_route tbwr ON tbwr.id = tbcst.work_route
- WHERE
- CONCAT(
- tbcstd.yearmonth,
- '-',
- tbcstd.code_day
- ) = CURRENT_DATE ()
- <if test="regionType != null and regionType != '' ">
- AND tbwr.area_region = #{regionType}
- </if>
- GROUP BY
- tbwr.area_region;
- </select>
- <!-- 进博 查询今日区域实际作业人数-->
- <select id="selectTodayWorkersCountByRegionTypeJinBo" resultType="java.util.Map">
- SELECT
- userCount.area_region AS areaRegion,
- count(*) AS userCount
- FROM
- (
- SELECT
- tu.area_region,
- tu.id
- FROM
- t_s_user AS tu
- where
- tu.device_id is not null
- and tu.area_region is not null
- AND tu.area_region = '3'
- GROUP BY
- tu.area_region,
- tu.id
- ) AS userCount
- GROUP BY
- userCount.area_region
- </select>
- <!-- 查询今日区域作业车辆数-->
- <select id="selectTodayVehiclesCountByRegionType" resultType="java.util.Map">
- SELECT
- areaCar.areaRegion areaRegion,
- COUNT(areaCar.carCount) carCount
- FROM
- (
- SELECT
- GROUP_CONCAT(DISTINCT tbwr.area_region) areaRegion,
- COUNT(tbcstd.carid) carCount
- FROM
- t_b_car_schedule_task_detail tbcstd
- LEFT JOIN t_b_car_schedule_task tbcst ON tbcst.id = tbcstd.pid
- LEFT JOIN t_b_work_route tbwr ON tbwr.id = tbcst.work_route
- WHERE
- CONCAT(
- tbcstd.yearmonth,
- '-',
- tbcstd.code_day
- ) = CURRENT_DATE ()
- GROUP BY
- tbcstd.carid
- ) AS areaCar
- <if test="regionType != null and regionType != '' ">
- where LEFT(areaCar.areaRegion,1) = #{regionType}
- </if>
- GROUP BY
- LEFT(areaCar.areaRegion,1);
- </select>
- <!-- 进博 查询今日区域实际作业车辆数-->
- <select id="selectTodayVehiclesCountByRegionTypeJinBo" resultType="java.util.Map">
- SELECT
- carcount.area_region AS areaRegion,
- count(*) AS carCount
- FROM
- (
- SELECT
- tc.area_region,
- tc.id
- FROM
- t_b_car AS tc
- where
- tc.area_region is not null
- and tc.gpssn is not null
- AND tc.area_region = '3'
- GROUP BY
- tc.area_region,
- tc.id
- ) AS carcount
- GROUP BY
- carcount.area_region
- </select>
- <!-- 根据作业类型、元素类型、车辆id,场所编码查询作业完成率-->
- <select id="selectWorkingCountByScheduleTypeAndElementType" resultType="java.util.Map">
- SELECT
- (
- SELECT
- SUM(tbcsc.done_count)/100
- FROM
- t_b_car_schedule_task_detail tbcstd
- left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
- WHERE
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) BETWEEN #{startDate} AND #{endDate} AND
- </if>
- tbcstd.pid IN (
- SELECT
- id
- FROM
- T_b_car_schedule_task
- WHERE
- work_route IN (
- SELECT
- route_id
- FROM
- t_b_work_route_list
- WHERE
- place_code IN (
- SELECT
- `code`
- FROM
- t_b_archives_area
- <where>
- <if test="placeType != null and placeType != '' ">
- AND area_type = #{placeType}
- </if>
- <if test="placeCode != null and placeCode != '' ">
- AND `code` = #{placeCode}
- </if>
- </where>
- )
- )
- <if test="scheduleType != null and scheduleType != '' ">
- AND assignment_style = #{scheduleType}
- </if>
- )
- <if test="carId != null and carId != '' ">
- AND tbcstd.carid = #{carId}
- </if>
- <if test="elementType != null and elementType != '' ">
- AND tbcstd.carid IN (
- select id from t_b_car where type = #{elementType}
- )
- </if>
- ) AS completeCount,
- (
- SELECT
- COUNT(DISTINCT CONCAT(yearmonth,code_day,carid))
- FROM
- t_b_car_schedule_task_detail
- WHERE
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- CONCAT(yearmonth,"-",code_day) BETWEEN #{startDate} AND #{endDate} and
- </if>
- pid IN (
- SELECT
- id
- FROM
- T_b_car_schedule_task
- WHERE
- work_route IN (
- SELECT
- route_id
- FROM
- t_b_work_route_list
- WHERE
- place_code IN (
- SELECT
- `code`
- FROM
- t_b_archives_area
- <where>
- <if test="placeType != null and placeType != '' ">
- AND area_type = #{placeType}
- </if>
- <if test="placeCode != null and placeCode != '' ">
- AND `code` = #{placeCode}
- </if>
- </where>
- )
- )
- <if test="scheduleType != null and scheduleType != '' ">
- AND assignment_style = #{scheduleType}
- </if>
- )
- <if test="carId != null and carId != '' ">
- AND carid = #{carId}
- </if>
- <if test="elementType != null and elementType != '' ">
- AND carid IN (
- select id from t_b_car where type = #{elementType}
- )
- </if>
- ) AS totalCount;
- </select>
- <!-- add-刘梦祥-2022年8月22日13:44:12(添加作业任务查询SQL,根据区域统计) -->
- <select id="selectJobsCountByRegionType" resultType="java.util.Map">
- SELECT
- COUNT(tbcstd.id) todayJobs,
- COUNT(
- tbcsc.schedule_count
- ) jobs
- FROM
- (
- SELECT
- *
- FROM
- t_b_car_schedule_task_detail
- WHERE
- CONCAT(yearmonth, "-", code_day) = CURRENT_DATE ()
- ) tbcstd
- LEFT JOIN T_b_car_schedule_task tbcst ON tbcst.id = tbcstd.pid
- LEFT JOIN t_b_car_schedule_count tbcsc ON tbcsc.car_id = tbcstd.carid
- AND tbcsc.schedule_date = CONCAT(
- tbcstd.yearmonth,
- "-",
- tbcstd.code_day
- )
- LEFT JOIN t_b_work_route tbr ON tbr.id = tbcst.work_route
- <if test="regionType != null and regionType != '' ">
- where tbr.area_region = #{regionType};
- </if>
- </select>
- <!-- 模拟·作业完成率 -->
- <select id="getMockRate" resultType="java.util.Map">
- select workingType workingTypeName, rateNum totalCount from cursor_working_rate where #{time} <![CDATA[<]]> rateTime group by workingType
- </select>
- <!-- 查询区域作业完成率-根据作业类型、元素类型、车辆id,场所编码-->
- <select id="selectWorkingCountByAreaRegion" resultType="java.util.Map">
- SELECT
- t1.area_region,completeCount,totalCount
- FROM
- (
- SELECT
- route.area_region,
- COUNT(tbcsc.id)
- FROM
- t_b_car_schedule_task_detail tbcstd
- left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
- RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) BETWEEN #{startDate} AND #{endDate}
- </if>
- and tbcsc.done_count = 100
- </where>
- GROUP BY route.area_region
- ) t1
- RIGHT JOIN (
- SELECT
- route.area_region,
- COUNT(csta.id) totalCount
- FROM
- t_b_car_schedule_task_detail AS csta
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
- LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND CONCAT(csta.yearmonth,"-",csta.code_day) BETWEEN #{startDate} AND #{endDate}
- </if>
- </where>
- GROUP BY route.area_region
- ) t2 ON t1.area_region = t2.area_region
- <where>
- <if test="areaRegion != null and areaRegion != ''">
- AND t1.area_region = #{areaRegion}
- </if>
- </where>
- </select>
- <!-- cim首页查询-查询区域作业类型完成情况 -->
- <select id="selectWorkingAreaRegionDetailByBusinessType" resultType="com.daju.mix.dto.CimRegionFinishDetailDto">
- SELECT
- cst.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 = 'areaRegion'
- AND route.area_region = type.typecode
- ) AS regionName,
- (
- 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 workingType,
- (
- SELECT
- COUNT(1) completeCount
- FROM
- t_b_car_schedule_task_arrange AS csta1
- LEFT JOIN t_b_car_schedule_task AS cst1 ON cst1.id = csta1.arrange_id
- LEFT JOIN t_b_work_route AS route1 ON route1.id = cst1.work_route
- <where>
- cst1. STATUS = '2'
- AND route1.area_region = route.area_region
- AND cst1.type = cst.type
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND csta1.date BETWEEN #{startDate} AND #{endDate}
- </if>
- </where>
- ) AS finishCount,
- (
- SELECT
- COUNT(1) totalCount
- FROM
- t_b_car_schedule_task_arrange AS csta2
- LEFT JOIN t_b_car_schedule_task AS cst2 ON cst2.id = csta2.arrange_id
- LEFT JOIN t_b_work_route AS route2 ON route2.id = cst2.work_route
- <where>
- route2.area_region = route.area_region
- AND cst2.type = cst.type
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND csta2.date BETWEEN #{startDate} AND #{endDate}
- </if>
- </where>
- ) AS workingCount
- FROM
- t_b_car_schedule_task_arrange AS csta
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
- LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- <if test="regionType != null and regionType != '' ">
- AND route.area_region = #{regionType}
- </if>
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND csta.date BETWEEN #{startDate} AND #{endDate}
- </if>
- </where>
- GROUP BY
- route.area_region,cst.type
- </select>
-
- <!-- 根据作业类型、元素类型、查询指定时间段的作业情况 返回作业类型-->
- <select id="selectTodayWorkingCountByScheduleTypeAndElementType" resultType="com.daju.mix.dto.todayWorkDto">
- SELECT
- cst.id,
- csta.username AS worker,
- (
- 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 type,
- GROUP_CONCAT(cst.work_route_name) workRouteName,
- IFNULL(tbsfar.num,0) AS completeCount,
- IFNULL(tbsfar.area_num,0) AS totalCount
- FROM
- t_b_car_schedule_task_detail AS csta
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.pid
- LEFT JOIN t_b_car AS cstype ON cstype.id = csta.carid
- LEFT JOIN t_b_car_schedule_finished_area_record tbsfar on tbsfar.schedule_date = CONCAT(csta.yearmonth,'-',csta.code_day) and (tbsfar.car_id = csta.carid or tbsfar.car_id = csta.user_id)
- where
- TO_DAYS(NOW()) = TO_DAYS(CONCAT(csta.yearmonth,'-',csta.code_day))
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- <if test="elementType != null and elementType != '' ">
- AND (cstype.type = #{elementType} OR cst.type = #{elementType})
- </if>
- <if test="isQueryUnfinished !=null and isQueryUnfinished != ''">
- AND csta.`status` != 2
- </if>
- GROUP BY
- csta.user_id
- </select>
- <!-- home-查询最近5日作业类别、作业数量-->
- <select id="selectLast5DayWorkingCount" 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 task.type = type.typecode
- ) AS workType,
- COUNT(1) AS workCount
- FROM
- t_b_car_schedule_task_arrange AS arr
- LEFT JOIN t_b_car_schedule_task AS task ON task.id = arr.arrange_id
- <if test="regionType != null and regionType != ''">
- RIGHT JOIN t_b_work_route AS route ON route.id = task.work_route
- </if>
- WHERE
- arr.date <![CDATA[<=]]> date_format(NOW(), '%Y-%m-%d')
- AND arr.date >= date_format(
- DATE_ADD(NOW(), INTERVAL - 5 DAY),
- '%Y-%m-%d'
- )
- <if test="scheduleType != null and scheduleType != ''">
- AND task.assignment_style = #{scheduleType}
- </if>
- <if test="regionType != null and regionType != ''">
- AND route.area_region = #{regionType}
- </if>
- GROUP BY
- task.type
- </select>
- <!-- home-查询今日清运作业完成率排名-->
- <select id="getTodayFinishRateRank" resultType="java.util.Map">
- SELECT
- cst.type,
- (
- 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 workingTypeName,
- SUM(tbcsc.done_count)/100 completeCount,
- COUNT(DISTINCT CONCAT(tbcstd.yearmonth,tbcstd.code_day,tbcstd.carid)) totalCount
- FROM
- t_b_car_schedule_task_detail AS tbcstd
- left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
- left join t_b_car_schedule_task_arrange as csta on csta.arrange_id = cst.id
- LEFT JOIN t_b_work_route AS route ON route.id = cst.work_route
- WHERE CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) = CURRENT_DATE()
- <if test="regionType != null and regionType != ''">
- AND route.area_region = #{regionType}
- </if>
- <!--<if test="regionType != null and regionType != '' ">
- RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
- </if>-->
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- GROUP BY
- cst.type
- </select>
- <!-- home-查询今日清运作业完成率排名明细-->
- <select id="getTodayFinishRateRankDetail" resultType="com.daju.mix.dto.CimWorkingReteDetailDto">
- SELECT
- cst.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 = 'assignmentStyle'
- AND cst.type = type.typecode
- ) AS workingType,
- cst.work_route_name AS workingLine,
- CONCAT(
- ROUND(
- (
- (
- SELECT
- COUNT(1)
- FROM
- t_b_car_schedule_task_arrange AS csta1
- LEFT JOIN t_b_car_schedule_task AS cst1 ON cst1.id = csta1.arrange_id
- LEFT JOIN t_b_car_schedule_type AS cstype1 ON cstype1.business_type = cst1.assignment_style
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst1.assignment_style = #{scheduleType}
- </if>
- AND DATEDIFF(NOW(), csta1.date) = 0
- AND cst1.type = cst.type
- AND cst1. STATUS = '2'
- </where>
- ) / (
- SELECT
- COUNT(1)
- FROM
- t_b_car_schedule_task_arrange AS csta1
- LEFT JOIN t_b_car_schedule_task AS cst1 ON cst1.id = csta1.arrange_id
- LEFT JOIN t_b_car_schedule_type AS cstype1 ON cstype1.business_type = cst1.assignment_style
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst1.assignment_style = #{scheduleType}
- </if>
- AND DATEDIFF(NOW(), csta1.date) = 0
- AND cst1.type = cst.type
- </where>
- )
- ) * 100,
- 2
- ),
- '%'
- ) AS rate
- FROM
- t_b_car_schedule_task_arrange AS csta
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- AND DATEDIFF(NOW(), csta.date) = 0
- </where>
- GROUP BY
- cst.type
- ORDER BY
- rate DESC
- </select>
- <!-- home-查询作业完成明细-->
- <select id="getTodayFinishDetailList" resultType="com.daju.mix.dto.CimWorkingFinishDetailDto">
- SELECT
- csta.id,
- cst.type,
- (
- 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 workingType,
- csta.user_name AS worker,
- CASE csta.archive_type
- WHEN '-1' THEN
- (
- SELECT
- r.`name`
- FROM
- t_b_archives_road_section AS r
- WHERE
- r.`code` = csta.archive_id
- )
- ELSE
- (
- SELECT
- p.`name`
- FROM
- t_b_archives_place AS p
- WHERE
- p.`code` = csta.archive_id
- )
- END AS pointName
- FROM
- t_b_car_schedule_task_arrange AS csta
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = csta.arrange_id
- RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
- <where>
- <if test="scheduleType != null and scheduleType != '' ">
- AND cst.assignment_style = #{scheduleType}
- </if>
- <if test="regionType != null and regionType != '' ">
- AND route.area_region = #{regionType}
- </if>
- AND DATEDIFF(NOW(), csta.date) = 0
- </where>
- </select>
- <!-- home-查询近5日区域业务类型完成情况-->
- <select id="getLast5DayBusinessCountByRegion" resultType="java.util.Map">
- SELECT
- t2.area_region,
- t2.assignment_style,
- completeCount,
- totalCount
- FROM
- (
- SELECT
- cst.assignment_style,
- route.area_region,
- SUM(tbcsc.done_count)/100 completeCount
- FROM t_b_car_schedule_task_detail AS tbcstd
- left join t_b_car_schedule_count tbcsc on tbcsc.schedule_date = CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) and tbcsc.car_id = tbcstd.carid
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
- RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
- WHERE
- CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) <![CDATA[<=]]> date_format(NOW(), '%Y-%m-%d')
- AND CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) >= date_format(
- DATE_ADD(NOW(), INTERVAL - 5 DAY),
- '%Y-%m-%d'
- )
- GROUP BY
- route.area_region,
- cst.assignment_style
- ) t1
- RIGHT JOIN (
- SELECT
- cst.assignment_style,
- route.area_region,
- COUNT(1) totalCount
- FROM
- t_b_car_schedule_task_detail AS tbcstd
- LEFT JOIN t_b_car_schedule_task AS cst ON cst.id = tbcstd.pid
- RIGHT JOIN t_b_work_route AS route ON route.id = cst.work_route
- WHERE
- CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) <![CDATA[<=]]> date_format(NOW(), '%Y-%m-%d')
- AND CONCAT(tbcstd.yearmonth,"-",tbcstd.code_day) >= date_format(
- DATE_ADD(NOW(), INTERVAL - 5 DAY),
- '%Y-%m-%d'
- )
- GROUP BY
- route.area_region,
- cst.assignment_style
- ) t2 ON t1.area_region = t2.area_region AND t1.assignment_style = t2.assignment_style
- <where>
- <if test="areaRegion != null and areaRegion != ''">
- AND t2.area_region = #{areaRegion}
- </if>
- </where>
- </select>
- <select id="getTypeCodeName" resultType="java.util.Map">
- select * from t_s_typegroup tg left join t_s_type t on t.typegroupid=tg.ID where tg.typegroupcode=#{typeGroupCode}
- </select>
- <select id="getGcbSchedule" resultType="com.daju.api.hardware.dto.GcbScheduleDTO">
- SELECT
- tc.plate plate,
- tsp2.typename type,
- tsp.typename brand,
- tc.framenumber framenumber,
- td.description company,
- tf.name fleetid,
- ta.date date,
- tt.work_route_name workRouteName
- FROM
- t_b_car_schedule_task_arrange ta
- LEFT JOIN t_b_car tc ON ta.car_id = tc.id
- LEFT JOIN t_b_car_schedule_task tt ON ta.arrange_id = tt.id
- LEFT JOIN t_s_depart td ON td.org_code = tc.sys_company_code
- LEFT JOIN t_b_car_fleet tf ON tf.id = tc.fleetid
- LEFT JOIN (select * from t_s_type where typegroupid = 'ff8080817a8af150017a9f84c7f8003d') tsp ON tsp.typecode = tc.brand
- LEFT JOIN (select * from t_s_type where typegroupid = '2c9358a86dbeda88016dbee52d0f0031') tsp2 ON tsp2.typecode = tc.type
- ${ew.customSqlSegment}
- </select>
- </mapper>
|