|
@@ -317,47 +317,91 @@
|
|
|
</select>
|
|
|
<!--根据用户权限统计一级场景个数-->
|
|
|
<select id="findSceneAmount" resultType="map">
|
|
|
- select count(a.ID) amount,b.SCENE_TYPE_NAME sceneTypeName
|
|
|
- from sms_scene a INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
|
|
|
- <where>
|
|
|
- a.PARENT_SCENE_ID=0
|
|
|
- and a.STATUS=1
|
|
|
- <if test="months != null">
|
|
|
- and a.run_time>=date_sub(date_format(curdate(), '%y-%m-1' ), interval #{months}-1 month)
|
|
|
- </if>
|
|
|
- <if test="scene.tenantId != null and scene.tenantId != ''">
|
|
|
- and a.tenant_id = #{scene.tenantId}
|
|
|
- </if>
|
|
|
- <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
- <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
- and ( a.DEPT_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
- or
|
|
|
- a.COMPANY_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
- )
|
|
|
+ select a.sceneTypeName,amount,newAmount from
|
|
|
+ (
|
|
|
+ select count(a.ID) amount,b.SCENE_TYPE_NAME sceneTypeName
|
|
|
+ from sms_scene a INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
|
|
|
+ <where>
|
|
|
+ a.PARENT_SCENE_ID=0
|
|
|
+ and a.STATUS=1
|
|
|
+ <if test="scene.tenantId != null and scene.tenantId != ''">
|
|
|
+ and a.tenant_id = #{scene.tenantId}
|
|
|
</if>
|
|
|
- <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
- and a.DEPT_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
+ <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
+ <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
+ and ( a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ or
|
|
|
+ a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
+ and a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 1">
|
|
|
+ and a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ </if>
|
|
|
</if>
|
|
|
- <if test="scene.permissonType == 1">
|
|
|
- and a.COMPANY_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
- and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ and SCENE_TYPE_NAME in('水源','水厂','泵站')
|
|
|
+ </where>
|
|
|
+ group by b.SCENE_TYPE_NAME
|
|
|
+ ) a left join
|
|
|
+ (
|
|
|
+ select count(a.ID) newAmount,b.SCENE_TYPE_NAME sceneTypeName
|
|
|
+ from sms_scene a INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
|
|
|
+ <where>
|
|
|
+ a.PARENT_SCENE_ID=0
|
|
|
+ and a.STATUS=1
|
|
|
+ <if test="months != null">
|
|
|
+ and a.run_time>=date_sub(date_format(curdate(), '%y-%m-1' ), interval #{months}-1 month)
|
|
|
</if>
|
|
|
- </if>
|
|
|
- and SCENE_TYPE_NAME in('水源','水厂','泵站')
|
|
|
- </where>
|
|
|
- group by b.SCENE_TYPE_NAME;
|
|
|
+ <if test="scene.tenantId != null and scene.tenantId != ''">
|
|
|
+ and a.tenant_id = #{scene.tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
+ <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
+ and ( a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ or
|
|
|
+ a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
+ and a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 1">
|
|
|
+ and a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ and SCENE_TYPE_NAME in('水源','水厂','泵站')
|
|
|
+ </where>
|
|
|
+ group by b.SCENE_TYPE_NAME
|
|
|
+ ) b
|
|
|
+ on a.sceneTypeName = b.sceneTypeName
|
|
|
</select>
|
|
|
|
|
|
|