Browse Source

优化

master
blank 2 years ago
parent
commit
1ee59d5b4e
  1. 5
      ruoyi-api/src/main/java/com/ruoyi/api/app/DapingController.java
  2. 16
      ruoyi-api/src/main/java/com/ruoyi/api/mapper/DapingMapper.java
  3. 5
      ruoyi-api/src/main/java/com/ruoyi/api/service/DapingService.java
  4. 27
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/DapingServiceImpl.java
  5. 14
      ruoyi-api/src/main/resources/mapper/api/DapingMapper.xml

5
ruoyi-api/src/main/java/com/ruoyi/api/app/DapingController.java

@ -41,4 +41,9 @@ public class DapingController { @@ -41,4 +41,9 @@ public class DapingController {
return dapingService.getStationByStatus();
}
@RequestMapping("/station/count")
public R getCount(){
return dapingService.getCount();
}
}

16
ruoyi-api/src/main/java/com/ruoyi/api/mapper/DapingMapper.java

@ -48,4 +48,20 @@ public interface DapingMapper extends BaseMapper<WaterPhotoInfo> { @@ -48,4 +48,20 @@ public interface DapingMapper extends BaseMapper<WaterPhotoInfo> {
* @return
*/
Map<String,Object> selectStationByOfflineStatus();
/**
* 查询所有的区域
* @return
*/
List<Map<String,Object>> selectAllAlea();
/**
* 查询某个区域的所有在线或者离线的设备数量
* 1 在线
* 0 离线
* @param status
* @param aleaId
* @return
*/
Integer selectZXAndLXCount(@Param("status") Integer status,@Param("aleaId") Integer aleaId);
}

5
ruoyi-api/src/main/java/com/ruoyi/api/service/DapingService.java

@ -29,4 +29,9 @@ public interface DapingService extends IService<WaterPhotoInfo> { @@ -29,4 +29,9 @@ public interface DapingService extends IService<WaterPhotoInfo> {
* @return
*/
R getStationByStatus();
/**
* 水位计分布
*/
R getCount();
}

27
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/DapingServiceImpl.java

@ -85,4 +85,31 @@ public class DapingServiceImpl extends ServiceImpl<DapingMapper, WaterPhotoInfo> @@ -85,4 +85,31 @@ public class DapingServiceImpl extends ServiceImpl<DapingMapper, WaterPhotoInfo>
return R.ok().put("data",resultList);
}
@Override
public R getCount() {
List<Map<String, Object>> map = baseMapper.selectAllAlea();
Map<String, Object> result = new HashMap<>();
// 区域名称
List<String> stnms = new ArrayList<>();
// 各个区域在线的设备
List<Integer> zx = new ArrayList<>();
// 各个区域离线的设备
List<Integer> lx = new ArrayList<>();
for (Map<String, Object> m : map) {
Integer aleaId = (Integer)m.get("alea_id");
// 查询各个区域在线的设备
Integer zxCount = baseMapper.selectZXAndLXCount(1,aleaId);
// 查询各个区域离线的设备
Integer lxCount = baseMapper.selectZXAndLXCount(0,aleaId);
zx.add(zxCount);
lx.add(lxCount);
stnms.add((String) m.get("alea_name"));
}
result.put("stnms",stnms);
result.put("zx",zx);
result.put("lx",lx);
return R.ok().put("data",result);
}
}

14
ruoyi-api/src/main/resources/mapper/api/DapingMapper.xml

@ -77,4 +77,18 @@ @@ -77,4 +77,18 @@
<select id="selectStationByOfflineStatus" resultType="java.util.Map">
select count(1) as value , '不在线' as name from camera where status = '0' and first_time is not null
</select>
<select id="selectAllAlea" resultType="java.util.Map">
select * from sc_station_alea
</select>
<select id="selectZXAndLXCount" resultType="java.lang.Integer">
SELECT
count( 1 )
FROM
camera
WHERE
`status` = #{status}
AND devsn IN ( SELECT camera_sn FROM sc_station_info WHERE del_flag = '0' AND alea_id = #{aleaId} )
</select>
</mapper>

Loading…
Cancel
Save