Browse Source

管网查询设备接口

wangli 4 years ago
parent
commit
e1c8f4f521

+ 24 - 8
sms_water/src/main/java/com/huaxu/controller/AppReportMonitorController.java

@@ -6,6 +6,7 @@ import com.huaxu.dto.OrgBaseTreeInfoDto;
 import com.huaxu.dto.generalView.WaterSupplyChart;
 import com.huaxu.dto.homePage.WaterQualityRate;
 import com.huaxu.dto.homePage.WaterQualityRateForScene;
+import com.huaxu.entity.DeviceEntity;
 import com.huaxu.entity.SceneEntity;
 import com.huaxu.model.AjaxMessage;
 import com.huaxu.model.ResultStatus;
@@ -38,22 +39,39 @@ public class AppReportMonitorController {
     private AppReportMonitorService appReportMonitorService;
 
     @RequestMapping(value = "getSceneByCompany",method = RequestMethod.GET)
-    @ApiOperation(value = "App报表展示————公司查询(点击公司查询水厂)")
+    @ApiOperation(value = "App报表展示——公司场景查询(点击公司查询水厂)")
     public AjaxMessage<List<SceneEntity>> getSceneByCompany(
-            @ApiParam(value = "场景类型名称:水源、水厂、泵站、管网") @RequestParam String sceneTypeName,
+            @ApiParam(value = "场景类型名称:水源、水厂、泵站") @RequestParam String sceneTypeName,
             @ApiParam(value = "公司id") @RequestParam Integer companyOrgId){
         return new AjaxMessage<>(ResultStatus.OK,appReportMonitorService.getSceneByCompany(sceneTypeName,companyOrgId));
     }
 
-    @RequestMapping(value = "getSceneByCompanyBySearch",method = RequestMethod.GET)
-    @ApiOperation(value = "App报表展示————公司查询(条件查询)")
-    public AjaxMessage<CompanySceneInfoDto> getSceneByCompanyBySearch(
-            @ApiParam(value = "场景类型名称:水源、水厂、泵站、管网") @RequestParam String sceneTypeName,
+
+
+    @RequestMapping(value = "getSceneCompanyBySearch",method = RequestMethod.GET)
+    @ApiOperation(value = "App报表展示——公司场景查询(条件查询)")
+    public AjaxMessage<CompanySceneInfoDto> getSceneCompanyBySearch(
+            @ApiParam(value = "场景类型名称:水源、水厂、泵站") @RequestParam String sceneTypeName,
             @ApiParam(value = "查询条件") @RequestParam(required = false) String condition){
         return new AjaxMessage<>(ResultStatus.OK,appReportMonitorService.getSceneByCompanyBySearch(sceneTypeName,condition));
     }
 
 
+    @RequestMapping(value = "getDeviceCompanyBySearchForPipeNetwork",method = RequestMethod.GET)
+    @ApiOperation(value = "App报表展示——公司管网设备查询(条件查询)")
+    public AjaxMessage<CompanySceneInfoDto> getDeviceCompanyBySearchForPipeNetwork(
+
+            @ApiParam(value = "查询条件") @RequestParam(required = false) String condition){
+        return new AjaxMessage<>(ResultStatus.OK,appReportMonitorService.getDeviceByCompanyBySearch(condition));
+    }
+
+    @RequestMapping(value = "getDeviceByCompanyForPipeNetwork",method = RequestMethod.GET)
+    @ApiOperation(value = "App报表展示——公司管网设备查询(点击公司查询水厂)")
+    public AjaxMessage<List<DeviceEntity>> getDeviceByCompanyForPipeNetwork(
+            @ApiParam(value = "公司id") @RequestParam Integer companyOrgId){
+        return new AjaxMessage<>(ResultStatus.OK,appReportMonitorService.getDeviceByCompany(companyOrgId));
+    }
+
     @RequestMapping(value = "getWaterQualification",method = RequestMethod.GET)
     @ApiOperation(value = "App报表展示——综合水质情况")
     public AjaxMessage<WaterQualityRate> getWaterQualification(){
@@ -98,6 +116,4 @@ public class AppReportMonitorController {
         return new AjaxMessage<>(ResultStatus.OK,appReportMonitorService.getWaterLevelForWaterSource(sceneId));
     }
 
-
-
 }

+ 28 - 2
sms_water/src/main/java/com/huaxu/dao/AppReportMonitorMapper.java

@@ -1,6 +1,10 @@
 package com.huaxu.dao;
 
+import com.huaxu.dto.DeviceDataInfoDto;
+import com.huaxu.dto.OrgBaseTreeInfoDto;
+import com.huaxu.entity.DeviceEntity;
 import com.huaxu.entity.SceneEntity;
+import com.huaxu.model.ProgramItem;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -14,7 +18,29 @@ import java.util.List;
 @Mapper
 public interface AppReportMonitorMapper {
 
-    List<SceneEntity> getSceneByCompany(@Param("sceneType") String sceneType,@Param("companyOrgId") Integer companyOrgId );
+    List<SceneEntity> getSceneByCompany(@Param("sceneType") String sceneType,@Param("companyOrgId") Integer companyOrgId ,
+                                        @Param("tenantId")String tenantId, @Param("userType")String userType,
+                                        @Param("permissonType")Integer permissonType,
+                                        @Param("programItems")List<ProgramItem> programItems);
+
+    List<DeviceEntity> getDeviceByCompany(@Param("companyOrgId") Integer companyOrgId ,
+                                        @Param("tenantId")String tenantId, @Param("userType")String userType,
+                                        @Param("permissonType")Integer permissonType,
+                                        @Param("programItems")List<ProgramItem> programItems);
+
+    List<Integer> getCompanyBySceneCondition(@Param("sceneType") String sceneType,@Param("condition") String condition ,
+                                             @Param("tenantId")String tenantId, @Param("userType")String userType,
+                                             @Param("permissonType")Integer permissonType,
+                                             @Param("programItems")List<ProgramItem> programItems);
+
+    List<Integer> getCompanyByDeviceCondition(@Param("condition") String condition ,
+                                             @Param("tenantId")String tenantId, @Param("userType")String userType,
+                                             @Param("permissonType")Integer permissonType,
+                                             @Param("programItems")List<ProgramItem> programItems);
+
+
+
+
+
 
-    List<Integer> getCompanyBySceneCondition(@Param("sceneType") String sceneType,@Param("condition") String condition );
 }

+ 5 - 1
sms_water/src/main/java/com/huaxu/dto/CompanySceneInfoDto.java

@@ -1,5 +1,6 @@
 package com.huaxu.dto;
 
+import com.huaxu.entity.DeviceEntity;
 import com.huaxu.entity.SceneEntity;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -19,11 +20,14 @@ public class CompanySceneInfoDto implements Serializable {
     private List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos;
     @ApiModelProperty("第一个公司的场景信息")
     private List<SceneEntity> sceneEntities;
+    @ApiModelProperty("第一个公司的设备信息")
+    private List<DeviceEntity> deviceEntities;
 
     public CompanySceneInfoDto(){}
 
-    public CompanySceneInfoDto(List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos,List<SceneEntity> sceneEntities){
+    public CompanySceneInfoDto(List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos,List<SceneEntity> sceneEntities,List<DeviceEntity> deviceEntities){
         this.orgBaseTreeInfoDtos =orgBaseTreeInfoDtos;
         this.sceneEntities =sceneEntities;
+        this.deviceEntities =deviceEntities;
     }
 }

+ 8 - 0
sms_water/src/main/java/com/huaxu/service/AppReportMonitorService.java

@@ -1,8 +1,10 @@
 package com.huaxu.service;
 
 import com.huaxu.dto.CompanySceneInfoDto;
+import com.huaxu.dto.DeviceDataInfoDto;
 import com.huaxu.dto.generalView.WaterSupplyChart;
 import com.huaxu.dto.homePage.WaterQualityRate;
+import com.huaxu.entity.DeviceEntity;
 import com.huaxu.entity.SceneEntity;
 
 import java.util.List;
@@ -24,9 +26,15 @@ public interface AppReportMonitorService {
 
     CompanySceneInfoDto getSceneByCompanyBySearch(String sceneTypeName, String condition);
 
+    List<DeviceEntity> getDeviceByCompany(Integer companyOrgId);
+
+    CompanySceneInfoDto getDeviceByCompanyBySearch( String condition);
+
     List<WaterSupplyChart> waterEnergyConsumption(Integer sceneId );
 
     List<WaterSupplyChart> getWaterLevelForWaterSource(Integer sceneId );
 
 
+
+
 }

+ 33 - 15
sms_water/src/main/java/com/huaxu/service/impl/AppReportMonitorServiceImpl.java

@@ -8,6 +8,7 @@ import com.huaxu.dto.OrgBaseTreeInfoDto;
 import com.huaxu.dto.generalView.WaterSupplyChart;
 import com.huaxu.dto.generalView.WaterSupplyData;
 import com.huaxu.dto.homePage.WaterQualityRate;
+import com.huaxu.entity.DeviceEntity;
 import com.huaxu.entity.SceneEntity;
 import com.huaxu.model.LoginUser;
 import com.huaxu.service.AppReportMonitorService;
@@ -50,31 +51,46 @@ public class AppReportMonitorServiceImpl  implements AppReportMonitorService {
 
     @Override
     public List<SceneEntity> getSceneByCompany(String sceneTypeName,Integer companyOrgId) {
-
-        return appReportMonitorMapper.getSceneByCompany(sceneTypeName,companyOrgId);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return appReportMonitorMapper.getSceneByCompany(sceneTypeName,companyOrgId,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
     }
 
+    @Override
+    public List<DeviceEntity> getDeviceByCompany(Integer companyOrgId) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return appReportMonitorMapper.getDeviceByCompany(companyOrgId,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+    }
     @Override
     public CompanySceneInfoDto getSceneByCompanyBySearch(String sceneTypeName, String condition) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
         //先查询公司
-        List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser(condition,new ArrayList<>());
+        //模糊查询场景所属公司id
+        List<Integer> companyIds = appReportMonitorMapper.getCompanyBySceneCondition(sceneTypeName,condition,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        //根据公司id和输入条件查询公司
+        List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser(condition,companyIds);
         //有公司的展示第一个公司信息
         if(orgBaseTreeInfoDtos.size() > 0){
-            List<SceneEntity> sceneEntities = appReportMonitorMapper.getSceneByCompany(sceneTypeName,orgBaseTreeInfoDtos.get(0).getId());
-            return new CompanySceneInfoDto(orgBaseTreeInfoDtos,sceneEntities);
+            List<SceneEntity> sceneEntities = appReportMonitorMapper.getSceneByCompany(sceneTypeName,orgBaseTreeInfoDtos.get(0).getId(),loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+            return new CompanySceneInfoDto(orgBaseTreeInfoDtos,sceneEntities,null);
         }
-        //模糊查询场景所属公司id
-        List<Integer> companyIds = appReportMonitorMapper.getCompanyBySceneCondition(sceneTypeName,condition);
-        if(companyIds.size() > 0){
-            //根据场景的公司id查询公司
-            orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser("",companyIds);
-            //有公司的展示第一个公司信息
-            if(orgBaseTreeInfoDtos.size() > 0){
-                List<SceneEntity> sceneEntities = appReportMonitorMapper.getSceneByCompany(sceneTypeName,orgBaseTreeInfoDtos.get(0).getId());
-                return new CompanySceneInfoDto(orgBaseTreeInfoDtos,sceneEntities);
-            }
+
+        return new CompanySceneInfoDto();
+    }
+
+    @Override
+    public CompanySceneInfoDto getDeviceByCompanyBySearch( String condition) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        //模糊查询设备所属公司id
+        List<Integer> companyIds = appReportMonitorMapper.getCompanyByDeviceCondition(condition,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+        //先查询公司
+        List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser(condition,companyIds);
+        //有公司的展示第一个公司信息
+        if(orgBaseTreeInfoDtos.size() > 0){
+            List<DeviceEntity> deviceEntities = appReportMonitorMapper.getDeviceByCompany(orgBaseTreeInfoDtos.get(0).getId(),loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
+            return new CompanySceneInfoDto(orgBaseTreeInfoDtos,null,deviceEntities);
         }
 
+
         return new CompanySceneInfoDto();
     }
 
@@ -181,4 +197,6 @@ public class AppReportMonitorServiceImpl  implements AppReportMonitorService {
         }
         return waterSupplyCharts;
     }
+
+
 }

+ 146 - 3
sms_water/src/main/resources/mapper/AppReportMonitorMapper.xml

@@ -9,10 +9,81 @@
             s.PARENT_SCENE_ID as "parentSceneId"
         from sms_scene_type st
         left join sms_scene s on st.id=s.SCENE_TYPE_ID
-        where st.SCENE_TYPE_NAME =#{sceneType}
+        where st.STATUS = 1 and s.STATUS = 1
+        and st.SCENE_TYPE_NAME =#{sceneType}
         and  s.COMPANY_ORG_ID = #{companyOrgId}
+        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>
         order by s.SCENE_NAME
+    </select>
 
+    <select id="getDeviceByCompany" resultType="com.huaxu.entity.DeviceEntity">
+        select
+            d.id
+            ,d.DEVICE_CODE as "deviceCode"
+            ,d.DEVICE_NAME as "deviceName"
+        from sms_scene_type st
+        left join sms_scene s on st.id=s.SCENE_TYPE_ID
+        left join sms_device_scene ds on ds.SCENE_ID =s.id
+        left join sms_device d on d.id=ds.DEVICE_ID
+        where st.STATUS = 1 and s.STATUS = 1 and ds.`STATUS` =1 and d.`STATUS` =1 and d.ENABLE_STATE =1
+        and st.SCENE_TYPE_NAME = '管网'
+        and  s.COMPANY_ORG_ID = #{companyOrgId}
+        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>
+        order by s.SCENE_NAME
     </select>
 
     <select id="getCompanyBySceneCondition" resultType="java.lang.Integer">
@@ -21,11 +92,83 @@
          s.COMPANY_ORG_ID
         from sms_scene_type st
         left join sms_scene s on st.id=s.SCENE_TYPE_ID
-        where
-        st.SCENE_TYPE_NAME =#{sceneType}
+        where st.STATUS = 1 and s.STATUS = 1
+        and st.SCENE_TYPE_NAME =#{sceneType}
         <if test="condition != null and condition !=''">
             and s.SCENE_NAME like concat('%',#{condition},'%')
         </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="getCompanyByDeviceCondition" resultType="java.lang.Integer">
+        select
+        distinct
+        d.COMPANY_ORG_ID
+        from sms_scene_type st
+        left join sms_scene s on st.id=s.SCENE_TYPE_ID
+        left join sms_device_scene ds on ds.SCENE_ID =s.id
+        left join sms_device d on d.id=ds.DEVICE_ID
+        where st.STATUS = 1 and s.STATUS = 1 and ds.`STATUS` =1 and d.`STATUS` =1 and d.ENABLE_STATE =1
+        and st.SCENE_TYPE_NAME ='管网'
+        <if test="condition != null and condition !=''">
+            and d.DEVICE_NAME like concat('%',#{condition},'%')
+        </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>
 

+ 4 - 2
user_center/src/main/resources/mapper/OrgMapper.xml

@@ -327,15 +327,17 @@
         where p.`STATUS` = 1
         and p.ORG_TYPE = 'company'
         and p.TENANT_ID = #{tenantId}
+        and (1>2
         <if test="condition != null and condition != ''">
-            and p.org_name like concat('%', #{condition},'%')
+            or p.org_name like concat('%', #{condition},'%')
         </if>
         <if test="companyIds != null and companyIds.size() > 0">
-            and p.id in
+            or p.id in
             <foreach collection="companyIds" item="item" open="(" separator="," close=")">
                 #{item}
             </foreach>
         </if>
+        )
         <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0">
             and p.id in
             <foreach collection="programItems" item="item" open="(" close=")" separator=",">