Merge branch 'master' of http://47.109.37.87:3000/by2025/SmartParks
All checks were successful
Build and Push to Target Registry / 构建并推送镜像到目标仓库 (push) Successful in 13m46s
All checks were successful
Build and Push to Target Registry / 构建并推送镜像到目标仓库 (push) Successful in 13m46s
This commit is contained in:
@@ -28,7 +28,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|||||||
* 前端访问路由地址为:/property/meterInfo
|
* 前端访问路由地址为:/property/meterInfo
|
||||||
*
|
*
|
||||||
* @author lsm
|
* @author lsm
|
||||||
* @date 2025-07-19
|
* @since 2025-07-19
|
||||||
*/
|
*/
|
||||||
@Validated
|
@Validated
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -109,20 +109,23 @@ public class TbMeterInfoController extends BaseController {
|
|||||||
* 生成 社区/建组/单元/楼栋/(水电气表)树结构
|
* 生成 社区/建组/单元/楼栋/(水电气表)树结构
|
||||||
*
|
*
|
||||||
* @param meterType 水电气类型
|
* @param meterType 水电气类型
|
||||||
*
|
* @param isMeter 是否返回仪表
|
||||||
* @return (水电气表)树结构
|
* @return (水电气表)树结构
|
||||||
*/
|
*/
|
||||||
@GetMapping("/tree/{meterType}")
|
@GetMapping("/tree")
|
||||||
public R<List<TreeNode<Long>>> queryMeterInfoTree(@PathVariable("meterType") Long meterType) {
|
public R<List<TreeNode<Long>>> queryMeterInfoTree(@RequestParam Long meterType, @RequestParam Boolean isMeter) {
|
||||||
return R.ok(tbMeterInfoService.queryMeterInfoTree(meterType));
|
return R.ok(tbMeterInfoService.queryMeterInfoTree(meterType, isMeter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取水/电/气表当前读数
|
* 获取水/电/气表当前读数/状态
|
||||||
|
*
|
||||||
|
* @param meterType 水电气类型
|
||||||
|
* @param floorId 楼栋id
|
||||||
*/
|
*/
|
||||||
@GetMapping("/currentReading/{floorId}")
|
@GetMapping("/currentReading")
|
||||||
public R<List<TbMeterInfoVo>> currentReading(@PathVariable("floorId") Long floorId) {
|
public R<List<TbMeterInfoVo>> currentReading(@RequestParam Long meterType, @RequestParam Long floorId) {
|
||||||
return R.ok(tbMeterInfoService.getMeterStatus(floorId));
|
return R.ok(tbMeterInfoService.getMeterStatus(meterType, floorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -179,10 +179,11 @@ public class TbMeterInfoServiceImpl implements ITbMeterInfoService {
|
|||||||
* 查询水电气树结构
|
* 查询水电气树结构
|
||||||
*
|
*
|
||||||
* @param meterType 水电气类型
|
* @param meterType 水电气类型
|
||||||
|
* @param isMeter 是否返回仪表
|
||||||
* @return 水电气树结构
|
* @return 水电气树结构
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<TreeNode<Long>> queryMeterInfoTree(Long meterType) {
|
public List<TreeNode<Long>> queryMeterInfoTree(Long meterType, Boolean isMeter) {
|
||||||
// 默认加载社区树
|
// 默认加载社区树
|
||||||
List<TreeNode<Long>> treeList = new ArrayList<>();
|
List<TreeNode<Long>> treeList = new ArrayList<>();
|
||||||
List<TbCommunityVo> tbCommunityVos = communityService.queryAll();
|
List<TbCommunityVo> tbCommunityVos = communityService.queryAll();
|
||||||
@@ -225,6 +226,7 @@ public class TbMeterInfoServiceImpl implements ITbMeterInfoService {
|
|||||||
}).toList();
|
}).toList();
|
||||||
treeList.addAll(l3);
|
treeList.addAll(l3);
|
||||||
|
|
||||||
|
if (isMeter){
|
||||||
TbMeterInfoBo bo = new TbMeterInfoBo();
|
TbMeterInfoBo bo = new TbMeterInfoBo();
|
||||||
bo.setMeterType(meterType);
|
bo.setMeterType(meterType);
|
||||||
List<TbMeterInfoVo> meterInfoVos = this.queryList(bo);
|
List<TbMeterInfoVo> meterInfoVos = this.queryList(bo);
|
||||||
@@ -239,16 +241,21 @@ public class TbMeterInfoServiceImpl implements ITbMeterInfoService {
|
|||||||
}).toList();
|
}).toList();
|
||||||
treeList.addAll(l4);
|
treeList.addAll(l4);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return TreeUtils.build(treeList, 0L);
|
return TreeUtils.build(treeList, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取水/电/气表当前读数/状态
|
* 获取水/电/气表当前读数/状态
|
||||||
|
*
|
||||||
|
* @param meterType 水电气类型
|
||||||
|
* @param floorId 楼栋id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<TbMeterInfoVo> getMeterStatus(Long floorId) {
|
public List<TbMeterInfoVo> getMeterStatus(Long meterType, Long floorId) {
|
||||||
TbMeterInfoBo meterInfoBo = new TbMeterInfoBo();
|
TbMeterInfoBo meterInfoBo = new TbMeterInfoBo();
|
||||||
meterInfoBo.setFloorId(floorId);
|
meterInfoBo.setFloorId(floorId);
|
||||||
|
meterInfoBo.setMeterType(meterType);
|
||||||
List<TbMeterInfoVo> meterInfoVoList = this.queryList(meterInfoBo);
|
List<TbMeterInfoVo> meterInfoVoList = this.queryList(meterInfoBo);
|
||||||
if (meterInfoVoList.isEmpty()) return null;
|
if (meterInfoVoList.isEmpty()) return null;
|
||||||
|
|
||||||
@@ -257,8 +264,16 @@ public class TbMeterInfoServiceImpl implements ITbMeterInfoService {
|
|||||||
for (String ip : hostIpArr) {
|
for (String ip : hostIpArr) {
|
||||||
ipCountMap.put(ip, baseMapper.selectCount(new LambdaQueryWrapper<TbMeterInfo>().eq(TbMeterInfo::getHostIp, ip)));
|
ipCountMap.put(ip, baseMapper.selectCount(new LambdaQueryWrapper<TbMeterInfo>().eq(TbMeterInfo::getHostIp, ip)));
|
||||||
}
|
}
|
||||||
List<MeterResult> meterResults = meterRecordUtil.getMeterStatus(ipCountMap, hostIpArr);
|
List<MeterResult> meterResults;
|
||||||
log.info("获取仪表状态结果={}", meterResults);
|
try{
|
||||||
|
meterResults = meterRecordUtil.getMeterStatus(ipCountMap, hostIpArr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 获取数据失败,返回所有数据,设置通信状态为0
|
||||||
|
for (TbMeterInfoVo item : meterInfoVoList) {
|
||||||
|
item.setCommunicationState(0L);
|
||||||
|
}
|
||||||
|
return meterInfoVoList;
|
||||||
|
}
|
||||||
|
|
||||||
for (TbMeterInfoVo item : meterInfoVoList) {
|
for (TbMeterInfoVo item : meterInfoVoList) {
|
||||||
MeterResult meterResult = meterResults.stream().filter(o -> o.getIp().equals(item.getHostIp())).findFirst().orElse(null);
|
MeterResult meterResult = meterResults.stream().filter(o -> o.getIp().equals(item.getHostIp())).findFirst().orElse(null);
|
||||||
@@ -266,7 +281,7 @@ public class TbMeterInfoServiceImpl implements ITbMeterInfoService {
|
|||||||
|
|
||||||
BigDecimal initReading = BigDecimal.valueOf(meterResult.getCollectionValue().get(Integer.parseInt(item.getMeterCode())))
|
BigDecimal initReading = BigDecimal.valueOf(meterResult.getCollectionValue().get(Integer.parseInt(item.getMeterCode())))
|
||||||
.setScale(2, RoundingMode.HALF_UP);
|
.setScale(2, RoundingMode.HALF_UP);
|
||||||
if (initReading.equals(BigDecimal.ZERO)) {
|
if (initReading.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
item.setCommunicationState(0L);
|
item.setCommunicationState(0L);
|
||||||
} else {
|
} else {
|
||||||
item.setCommunicationState(1L);
|
item.setCommunicationState(1L);
|
||||||
|
@@ -71,13 +71,16 @@ public interface ITbMeterInfoService {
|
|||||||
* 查询水电气树结构
|
* 查询水电气树结构
|
||||||
*
|
*
|
||||||
* @param meterType 水电气类型
|
* @param meterType 水电气类型
|
||||||
*
|
* @param isMeter 是否返回仪表
|
||||||
* @return 水电气树结构
|
* @return 水电气树结构
|
||||||
*/
|
*/
|
||||||
List<TreeNode<Long>> queryMeterInfoTree(Long meterType);
|
List<TreeNode<Long>> queryMeterInfoTree(Long meterType, Boolean isMeter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取水/电/气表当前读数/状态
|
* 获取水/电/气表当前读数/状态
|
||||||
|
*
|
||||||
|
* @param meterType 水电气类型
|
||||||
|
* @param floorId 楼栋id
|
||||||
*/
|
*/
|
||||||
List<TbMeterInfoVo> getMeterStatus(Long floorId);
|
List<TbMeterInfoVo> getMeterStatus(Long meterType, Long floorId);
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@ public class MeterRecordUtil {
|
|||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.putOnce("ipMap", ipMap);
|
jsonObject.putOnce("ipMap", ipMap);
|
||||||
jsonObject.putOnce("ipArr", ipArr);
|
jsonObject.putOnce("ipArr", ipArr);
|
||||||
String post = HttpUtil.post(meterRecordUrl + READING_URL, jsonObject.toString());
|
String post = HttpUtil.post(meterRecordUrl + READING_URL, jsonObject.toString(), 3000);
|
||||||
Result<List<MeterResult>> result = JSONUtil.toBean(post, new TypeReference<Result<List<MeterResult>>>() {}, true);
|
Result<List<MeterResult>> result = JSONUtil.toBean(post, new TypeReference<Result<List<MeterResult>>>() {}, true);
|
||||||
return result.getData();
|
return result.getData();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user