123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532 |
- <?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.huaxu.dao.HomePageReportMapper">
- <select id="getDeviceWaterForSixMonth" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
- select
- r.year,r.month,
- sum(r.SUM_VALUE)/10000 as "amount"
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.id
- left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
- left join sms_year_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
- where dp.`STATUS`=1 and s.ENABLE_STATE = 1 and dp.TENANT_ID=#{tenantId}
- <if test="companyOrgId != null">
- and s.COMPANY_ORG_ID = #{companyOrgId}
- </if>
- and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}
- and r.year*12 + r.month >= year(CURDATE())*12 + month(CURDATE()) - 5
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by r.year,r.month
- order by r.year desc,r.month desc
- </select>
- <select id="countSceneByType" resultType="com.huaxu.dto.homePage.CompanyCount">
- select
- sum(if(SCENE_TYPE_NAME = "水源",1,0)) as "waterSource"
- ,sum(if(SCENE_TYPE_NAME = "水厂",1,0)) as "waterFactory"
- ,sum(if(SCENE_TYPE_NAME = "管网",1,0)) as "pipeNetwork"
- ,sum(if(SCENE_TYPE_NAME = "泵站",1,0)) as "pumpingStation"
- ,0 as "waterMeter"
- from sms_scene s
- left join sms_scene_type st on s.SCENE_TYPE_ID =st.ID
- where s.PARENT_SCENE_ID= 0 and s.`STATUS` = 1 and st.`STATUS` = 1
- and st.SCENE_TYPE_NAME in ('水源','水厂','管网','泵站')
- <if test="companyOrgId != null">
- and s.COMPANY_ORG_ID = #{companyOrgId}
- </if>
- and s.TENANT_ID=#{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- </select>
- <select id="getWaterSalesDetails" resultType="com.huaxu.dto.homePage.CompanyProduce">
- select
- sum(RECEIVABLE_TOTAL_AMOUNT) AS "receivableAmount",
- sum(RECEIVED_TOTAL_AMOUNT) AS "receivedAmount",
- sum(METER_READING_USAGE) AS "waterSale"
- from sms_month_revenue r
- where r.TENANT_ID = #{tenantId}
- <if test="companyOrgId != null">
- and r.COMPANY_ORG_ID = #{companyOrgId}
- </if>
- and year(r.COLLECT_DATE) =year(CURDATE()) and month(r.COLLECT_DATE) = month(CURDATE())
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- and r.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- </select>
- <select id="getPipeNetworkQualification" resultType="com.huaxu.dto.homePage.WaterQualityRate">
- select
- sum(alarmNumber ) as "abnormal",
- ROUND(sum(if(alarmNumber > 0 ,0,1))/if(count(1) != 0, count(1),1) * 100,2) as "averageQuality"
- from
- (
- select
- s.id as "sceneId"
- ,dp.DEVICE_ID as "deviceId"
- ,count(ad.id) as "alarmNumber"
- from sms_scene_type pst
- left join sms_scene ps on ps.SCENE_TYPE_ID =pst.ID
- left join sms_scene s on s.PARENT_SCENE_ID =ps.ID
- left join sms_scene_type st on s.SCENE_TYPE_ID =st.ID
- left join sms_device_parm dp on dp.PARENT_SCENE_ID =ps.ID and dp.SCENE_ID =s.ID
- left join sms_alarm_details ad on dp.SCENE_ID =ad.SCENE_ID and dp.DEVICE_ID =ad.DEVICE_ID and dp.attribute_id = ad.attribute_id
- and ad.STATE = 1 and ad.`STATUS` =1 and ad.ALARM_TYPE = '参数报警'
- where pst.`STATUS` = 1 and st.`STATUS` = 1 and ps.`STATUS` = 1 and s.`STATUS` = 1 and dp.`STATUS` = 1
- and pst.SCENE_TYPE_NAME ='管网' and st.SCENE_TYPE_NAME ='水质'
- <if test="companyOrgId != null">
- and ps.COMPANY_ORG_ID = #{companyOrgId}
- </if>
- and ps.TENANT_ID=#{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by s.id,dp.DEVICE_ID
- ) a
- </select>
- <select id="getWaterQualification" resultType="com.huaxu.dto.homePage.WaterQualityRate">
- select
- sum(alarmNumber ) as "abnormal",
- ROUND(sum(if(alarmNumber > 0 ,0,1))/if(count(1) != 0, count(1),1) * 100,2) as "averageQuality"
- from (
- select
- s.id as "sceneId"
- ,sum( if(dp.PARM_TYPE IN
- <foreach collection="parmTypes" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- and ad.id is not null,1,0) ) AS "alarmNumber"
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.id and PARENT_SCENE_ID ='0'
- left join sms_device_parm dp on dp.PARENT_SCENE_ID =s.ID
- left join sms_alarm_details ad on ad.STATE = 1 and ad.PARENT_SCENE_ID=dp.PARENT_SCENE_ID and ad.DEVICE_ID =dp.DEVICE_ID and ad.ATTRIBUTE_ID =dp.ATTRIBUTE_ID
- where s.`STATUS`=1 and s.ENABLE_STATE = 1 and dp.`STATUS` = 1 and st.SCENE_TYPE_NAME = #{sceneType}
- <if test="companyOrgId != null">
- and s.COMPANY_ORG_ID = #{companyOrgId}
- </if>
- and s.TENANT_ID =#{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by s.id
- ) a
- </select>
- <select id="getMonitorDataFifteenDays" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
- select
- r.year,r.month,r.day,
- sum(r.SUM_VALUE) as "amount"
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.id
- left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
- left join sms_month_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
- where st.`STATUS`=1 and dp.`STATUS`=1 and s.ENABLE_STATE = 1
- and s.id = #{sceneId}
- and st.SCENE_TYPE_NAME = #{sceneType}
- and dp.PARM_TYPE = #{parmType}
- and dp.TENANT_ID=#{tenantId}
- and r.COLLECT_DATE >= DATE_SUB(CURDATE(),INTERVAL 14 day)
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by r.year,r.month,r.day
- order by r.year desc,r.month desc,r.day desc
- </select>
- <select id="getWaterQualificationForScene" resultType="java.math.BigDecimal">
- select
- ROUND(sum(if(alarmNumber > 0 ,0,1))/if(count(1) != 0, count(1),1) * 100,2)
- from
- (
- select
- s.id as "sceneId"
- ,d.id as "deviceId"
- ,count(ad.id) as "alarmNumber"
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.ID
- left join sms_device_scene ds on ds.PARENT_SCENE_ID = s.ID
- left join sms_device d on d.id=ds.DEVICE_ID
- left join sms_device_parm dp on dp.SCENE_ID =ds.SCENE_ID and dp.DEVICE_ID =ds.DEVICE_ID and dp.PARM_TYPE =#{parmType}
- left join sms_alarm_details ad on dp.SCENE_ID =ad.SCENE_ID and dp.DEVICE_ID =ad.DEVICE_ID and dp.ATTRIBUTE_ID =ad.ATTRIBUTE_ID
- and ad.STATE = 1 and ad.`STATUS` =1
- where st.`STATUS` = 1 and s.`STATUS` = 1 and ds.`STATUS` = 1 and d.`STATUS` = 1 and dp.`STATUS` = 1
- and s.id= #{sceneId}
- and st.SCENE_TYPE_NAME = #{sceneType}
- and s.TENANT_ID=#{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by s.id,d.id
- ) a
- </select>
- <select id="getWaterQualificationByMonth" resultType="java.math.BigDecimal">
- select
- ROUND(if(count(1) >0 ,1-((sum(alarmNumber) /count(1))/timestampdiff(MINUTE,#{monthDate},now())),1)* 100,2) as amount
- from
- (
- select
- ifnull(sum(
- if(ad.state = 1,
- timestampdiff(MINUTE,if(ad.ALARM_START_TIME > #{monthDate},ad.ALARM_START_TIME ,#{monthDate}),now())
- ,if(ad.ALARM_START_TIME > #{monthDate} ,timestampdiff(MINUTE,ad.ALARM_START_TIME,ad.alarm_end_time), timestampdiff(MINUTE,#{monthDate},ad.alarm_end_time))
- )),0) alarmNumber
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.ID
- left join sms_device_scene ds on ds.PARENT_SCENE_ID = s.ID
- left join sms_device d on d.id=ds.DEVICE_ID
- left join sms_device_parm dp on dp.SCENE_ID =ds.SCENE_ID and dp.DEVICE_ID =ds.DEVICE_ID and dp.PARM_TYPE =#{parmType}
- left join sms_alarm_details ad on dp.SCENE_ID =ad.SCENE_ID and dp.DEVICE_ID =ad.DEVICE_ID and dp.ATTRIBUTE_ID =ad.ATTRIBUTE_ID
- and ad.`STATUS` =1 and (ad.alarm_end_time > #{monthDate} or ad.state = 1)
- where st.`STATUS` = 1 and s.`STATUS` = 1 and ds.`STATUS` = 1 and d.`STATUS` = 1 and dp.`STATUS` = 1
- and s.id= #{sceneId}
- and st.SCENE_TYPE_NAME = #{sceneType}
- and s.TENANT_ID=#{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- <if test="item.orgId != null">
- #{item.orgId}
- </if>
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- <if test="item.orgId != null">
- #{item.orgId}
- </if>
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- <if test="item.orgId != null">
- #{item.orgId}
- </if>
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- <if test="item.orgId != null">
- #{item.orgId}
- </if>
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by s.id,d.id,dp.ATTRIBUTE_ID
- ) a
- </select>
- <select id="getWaterSupplyData" resultType="com.huaxu.dto.generalView.WaterSupplyData">
- select
- r.year
- ,r.month
- ,r.day
- ,dp.PARM_TYPE as "parmType"
- ,sum(r.SUM_VALUE) as "amount"
- ,da.UNIT as "unit"
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.id
- left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
- left join sms_device_attribute da on dp.ATTRIBUTE_ID =da.ID
- left join sms_month_report r on r.DEVICE_ID =dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
- where dp.`STATUS`=1 and st.`STATUS`=1 and s.`STATUS`=1 and s.ENABLE_STATE = 1
- and r.COLLECT_DATE >= date_add(curdate(), interval - day(curdate()) + 1 day)
- and dp.PARM_TYPE in (3,4,5,6,12)
- and s.id= #{sceneId}
- and st.SCENE_TYPE_NAME = #{sceneType}
- and dp.TENANT_ID=#{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by r.year,r.month,r.day,dp.PARM_TYPE,da.UNIT
- </select>
- <!--查询前N个月的取水量供水量-->
- <select id="getDeviceWaterForMonth" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
- select
- r.year,r.month,
- sum(r.SUM_VALUE)/10000 as "amount"
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.id
- left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
- left join sms_year_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
- where dp.`STATUS`=1 and s.ENABLE_STATE = 1 and dp.TENANT_ID=#{tenantId}
- <if test="companyOrgId != null">
- and s.COMPANY_ORG_ID = #{companyOrgId}
- </if>
- and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}
- and r.year*12 + r.month >= year(CURDATE())*12 + month(CURDATE()) + 1 - #{month}
- and r.year*12 + r.month < year(CURDATE())*12 + month(CURDATE()) + 1
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by r.year,r.month
- order by r.year desc,r.month desc
- </select>
- <!--查询时间段内的取水量供水量-->
- <select id="getDeviceWaterForMonth" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
- select
- r.year,r.month,r.day,
- sum(r.SUM_VALUE)/10000 as "amount"
- from sms_scene_type st
- left join sms_scene s on s.SCENE_TYPE_ID =st.id
- left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
- left join sms_year_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
- where dp.`STATUS`=1 and s.ENABLE_STATE = 1 and dp.TENANT_ID=#{tenantId}
- <if test="companyOrgId != null">
- and s.COMPANY_ORG_ID = #{companyOrgId}
- </if>
- and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}
- and r.year*12 + r.month >= #{startYear}*12 + #{startMonth}
- and r.year*12 + r.month <= #{endYear}*12 + #{endMonth}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- group by r.year,r.month,r.day
- order by r.year desc,r.month desc,r.day desc
- </select>
- </mapper>
|