| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- <?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.yt.zhylplat.dao.TWoWorkorderbaseMapper">
- <select id="selectWorkOrderPage" resultType="com.yt.zhylplat.vo.TWoWorkOrderBaseVO">
- select
- wob.F_WorkOrderId as workOrderId,
- wob.F_YHDeptName as yhDeptName,
- wob.F_WorkOrderType as workOrderType,
- '绿化' as workOrderLine,
- wob.F_Code as code,
- wob.F_CategoryName1 as categoryName1,
- wob.F_CategoryName2 as categoryName2,
- wob.F_CreateDate as createDate,
- wob.pushtime as pushTime,
- wob.checktime as checkTime,
- wot.F_CreateDate as finishTime,
- wob.F_Content as content,
- wob.F_Address as address,
- wob.checkdept as checkDept,
- wob.checkusername as checkUserName,
- wob.disposeresultdesc as disposeResultDesc,
- pre.file_url as preDisposeUrl,
- after.file_url as afterDisposeUrl,
- wob.F_State as state,
- wob.F_X as longitude,
- wob.F_Y as latitude
- from
- T_WO_WorkOrderBase wob
- left join
- (
- select
- F_WorkOrderId,
- F_CreateDate
- from
- T_WO_WorkOrderTask
- where
- F_StateId = 4
- limit 1
- ) wot ON wot.F_WorkOrderId = wob.F_WorkOrderId
- left join (
- select
- F_WorkOrderId,
- GROUP_CONCAT(F_FileUrl SEPARATOR ',') as file_url
- from
- T_WO_FileInfo
- where
- F_StateId = 1
- group by
- F_WorkOrderId
- ) pre on pre.F_WorkOrderId = wob.F_WorkOrderId
- left join (
- select
- F_WorkOrderId,
- GROUP_CONCAT(F_FileUrl SEPARATOR ',') as file_url
- from
- T_WO_FileInfo
- where
- F_StateId = 4
- group by
- F_WorkOrderId
- ) after on after.F_WorkOrderId = wob.F_WorkOrderId
- where
- wob.F_DeleteFlag = 0
- and
- wob.F_StateId = 4
- <if test="workOrderBaseVO.yhDeptName != null and workOrderBaseVO.yhDeptName != ''">
- and wob.F_YHDeptName like concat('%', #{workOrderBaseVO.yhDeptName}, '%')
- </if>
- <if test="workOrderBaseVO.code != null and workOrderBaseVO.code != ''">
- and wob.F_Code like concat('%', #{workOrderBaseVO.code}, '%')
- </if>
- order by wob.F_CreateDate desc
- </select>
- <select id="getWorkOrderBaseComplaintCount"
- resultType="com.yt.zhylplat.moduleLhgy.dto.LhzxWorkOrderBaseDto">
- select
- count(1) as complaintCount
- from
- T_WO_WorkOrderBase
- where
- F_YHDeptId = #{yhCompanyId}
- and
- section_id = #{sectionId}
- and
- DATE_FORMAT(F_CreateDate, '%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{lastMonthStartDate}, '%Y-%m-%d')
- and
- DATE_FORMAT(F_CreateDate, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{lastMonthEndDate}, '%Y-%m-%d')
- and
- F_WorkOrderTypeId = 5
- and
- F_DeleteFlag = 0
- </select>
- <select id="getWorkOrderBaseMaintenanceCount"
- resultType="com.yt.zhylplat.moduleLhgy.dto.LhzxWorkOrderBaseDto">
- select
- count(1) as dailyMaintenanceCount,
- sum(IF(wob.patrol_type = 1, 1, 0)) as streetTreeCount,
- sum(IF(wob.patrol_type = 2, 1, 0)) as greenSpaceCount,
- sum(IF(wob.patrol_type = 3, 1, 0)) as flowersCount,
- sum(IF(wob.patrol_type = 4, 1, 0)) as pestCount,
- sum(IF(wob.patrol_type is null, 1, 0)) as otherCount
- from
- T_WO_WorkOrderBase wob
- left join
- (
- select
- id,
- object_id
- from
- T_Lhgy_Patrol_Track
- where
- delete_flag = 0
- ) pt on wob.patrol_id = pt.id
- where
- wob.F_YHDeptId = #{yhCompanyId}
- and
- pt.object_id = #{sectionId}
- and
- DATE_FORMAT(wob.F_CreateDate, '%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{currentMonthStartDate}, '%Y-%m-%d')
- and
- DATE_FORMAT(wob.F_CreateDate, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{currentMonthEndDate}, '%Y-%m-%d')
- and
- wob.F_WorkOrderTypeId = 3
- and
- wob.F_DeleteFlag = 0
- </select>
- <select id="selectWorkOrderBasePageBySection"
- resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
- SELECT
- temp.*
- FROM
- (<include refid="WorkOrderBasePageBySectionSql"/>) temp
- </select>
- <select id="getWorkOrderBaseCountBySection" resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
- SELECT
- sum(if(temp.dailyMaintenanceCount is null, 0, temp.dailyMaintenanceCount)) as dailyMaintenanceCount,
- sum(if(temp.streetTreeCount is null, 0, temp.streetTreeCount)) as streetTreeCount,
- sum(if(temp.greenSpaceCount is null, 0, temp.greenSpaceCount)) as greenSpaceCount,
- sum(if(temp.flowersCount is null, 0, temp.flowersCount)) as flowersCount,
- sum(if(temp.pestCount is null, 0, temp.pestCount)) as pestCount,
- sum(if(temp.otherCount is null, 0, temp.otherCount)) as otherCount,
- sum(if(temp.complaintCount is null, 0, temp.complaintCount)) as complaintCount
- FROM
- (<include refid="WorkOrderBasePageBySectionSql"/>) temp
- </select>
- <select id="selectWorkOrderBaseListBySection"
- resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
- select
- temp.*
- from
- (<include refid="workOrderBaseListSql"/>) temp
- </select>
- <select id="getWorkOrderBaseSumCount" resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
- select
- sum(if(temp.workOrderCount is null, 0, temp.workOrderCount)) as workOrderCount,
- sum(if(temp.untreatedCount is null, 0, temp.untreatedCount)) as untreatedCount,
- sum(if(temp.untreatedCount is null, 0, temp.untreatedCount)) as untreatedCount,
- sum(if(temp.processingCount is null, 0, temp.processingCount)) as processingCount,
- sum(if(temp.withdrawnCount is null, 0, temp.withdrawnCount)) as withdrawnCount
- from
- (<include refid="workOrderBaseListSql"/>) temp
- </select>
- <sql id="WorkOrderBasePageBySectionSql">
- SELECT
- rsmc.maintenance_company_id,
- mc.old_maintenance_company_id,
- mc.maintenance_company_name,
- rsmc.section_id,
- s.old_section_id,
- s.section_name,
- IF(wo.dailyMaintenanceCount is null, 0, wo.dailyMaintenanceCount) as dailyMaintenanceCount,
- IF(wo.streetTreeCount is null, 0, wo.streetTreeCount) as streetTreeCount,
- IF(wo.greenSpaceCount is null, 0, wo.greenSpaceCount) as greenSpaceCount,
- IF(wo.flowersCount is null, 0, wo.flowersCount) as flowersCount,
- IF(wo.pestCount is null, 0, wo.pestCount) as pestCount,
- IF(wo.otherCount is null, 0, wo.otherCount) as otherCount,
- IF(com.complaintCount is null, 0, com.complaintCount) as complaintCount
- /*15 as complaintCount*/
- FROM
- (
- select DISTINCT
- maintenance_company_id,
- section_id,
- del_flg
- from
- T_Lhzx_Road_Section_Maintenance_Company
- WHERE
- del_flg = 0
- ) rsmc
- LEFT JOIN
- T_Lhzx_Maintenance_Company mc on mc.id = rsmc.maintenance_company_id
- LEFT JOIN
- T_Lhzx_Section s on s.id = rsmc.section_id
- LEFT JOIN
- (
- select
- wob.F_YHDeptId,
- wob.F_SGUserId,
- count(1) as dailyMaintenanceCount,
- sum(IF(wob.patrol_type = 1, 1, 0)) as streetTreeCount,
- sum(IF(wob.patrol_type = 2, 1, 0)) as greenSpaceCount,
- sum(IF(wob.patrol_type = 3, 1, 0)) as flowersCount,
- sum(IF(wob.patrol_type = 4, 1, 0)) as pestCount,
- sum(IF(wob.patrol_type is null, 1, 0)) as otherCount
- from
- T_WO_WorkOrderBase wob
- where
- wob.F_WorkOrderTypeId = 3
- and
- wob.F_DeleteFlag = 0
- and
- DATE_FORMAT(wob.F_CreateDate, '%Y-%m') = #{workOrderBaseVO.currentMonth}
- and
- wob.dept_type = 2
- GROUP BY
- wob.F_YHDeptId,
- wob.F_SGUserId
- ) wo on wo.F_YHDeptId = mc.old_maintenance_company_id and wo.F_SGUserId = s.old_section_id
- LEFT JOIN (
- select
- F_YHDeptId,
- F_SGUserId,
- count(1) as complaintCount
- from
- T_WO_WorkOrderBase
- where
- F_WorkOrderTypeId = 5
- and
- F_DeleteFlag = 0
- and
- DATE_FORMAT(F_CreateDate, '%Y-%m') = #{workOrderBaseVO.lastMonth}
- and
- dept_type = 2
- group by
- F_YHDeptId,
- F_SGUserId
- ) com on com.F_YHDeptId = mc.old_maintenance_company_id and com.F_SGUserId = s.old_section_id
- WHERE
- rsmc.del_flg = 0
- <if test="workOrderBaseVO.sectionId != null">
- and rsmc.section_id = #{workOrderBaseVO.sectionId}
- </if>
- <if test="workOrderBaseVO.maintenanceCompanyId != null">
- and rsmc.maintenance_company_id = #{workOrderBaseVO.maintenanceCompanyId}
- </if>
- ORDER BY
- rsmc.section_id, rsmc.maintenance_company_id
- </sql>
- <sql id="workOrderBaseListSql">
- select
- rsmc.maintenance_company_id,
- mc.old_maintenance_company_id,
- mc.maintenance_company_name,
- rsmc.section_id,
- s.old_section_id,
- s.section_name,
- wo.workOrderCount,
- wo.untreatedCount,
- wo.processingCount,
- wo.finishedCount,
- wo.withdrawnCount
- from (
- select DISTINCT
- maintenance_company_id,
- section_id,
- del_flg
- from
- T_Lhzx_Road_Section_Maintenance_Company
- WHERE
- del_flg = 0
- ) rsmc
- LEFT JOIN
- T_Lhzx_Maintenance_Company mc on mc.id = rsmc.maintenance_company_id
- LEFT JOIN
- T_Lhzx_Section s on s.id = rsmc.section_id
- LEFT JOIN
- (
- select
- wob.F_YHDeptId,
- wob.F_SGUserId,
- count(1) as workOrderCount,
- sum(IF(wob.F_StateId = 2, 1, 0)) as untreatedCount,
- sum(IF(wob.F_StateId = 3, 1, 0)) as processingCount,
- sum(IF(wob.F_StateId = 4, 1, 0)) as finishedCount,
- sum(IF(wob.F_StateId = 5, 1, 0)) as withdrawnCount
- from
- T_WO_WorkOrderBase wob
- where
- wob.is_center = 1
- and
- wob.F_DeleteFlag = 0
- and
- wob.dept_type = 2
- <if test="currentMonth != null and currentMonth != ''">
- and DATE_FORMAT(wob.F_CreateDate, '%Y-%m') = #{currentMonth}
- </if>
- GROUP BY
- wob.F_YHDeptId,
- wob.F_SGUserId
- ) wo on wo.F_YHDeptId = mc.old_maintenance_company_id and wo.F_SGUserId = s.old_section_id
- WHERE
- rsmc.del_flg = 0
- <if test="sectionId != null">
- and rsmc.section_id = #{sectionId}
- </if>
- <if test="maintenanceCompanyId != null">
- and rsmc.maintenance_company_id = #{maintenanceCompanyId}
- </if>
- ORDER BY
- rsmc.section_id,
- rsmc.maintenance_company_id
- </sql>
- </mapper>
|