|
|
@@ -138,7 +138,7 @@ public class EquipmentParamServiceImpl implements IEquipmentParamService {
|
|
|
// TODO 根据设备id获取对应的主数据所在寄存器的唯一code(暂时只处理了传感器和阀门相关)
|
|
|
@Override
|
|
|
public String getCodeByParentId(Long parentId) {
|
|
|
- if(parentId == null) {
|
|
|
+ if (parentId == null) {
|
|
|
log.warn("parentId is null");
|
|
|
return null;
|
|
|
}
|
|
|
@@ -178,7 +178,7 @@ public class EquipmentParamServiceImpl implements IEquipmentParamService {
|
|
|
|
|
|
@Override
|
|
|
public Integer getSetCodeByParentId(Long parentId) {
|
|
|
- if(parentId == null) {
|
|
|
+ if (parentId == null) {
|
|
|
log.warn("parentId is null");
|
|
|
return null;
|
|
|
}
|
|
|
@@ -280,7 +280,7 @@ public class EquipmentParamServiceImpl implements IEquipmentParamService {
|
|
|
LambdaQueryWrapper<EquipmentParam> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.in(EquipmentParam::getDataType, dataTypes);
|
|
|
wrapper.in(EquipmentParam::getParamType, RegisterTypeEnum.MASTER_DATA.getCode(), RegisterTypeEnum.SLAVE_DATA.getCode());
|
|
|
- wrapper.eq(EquipmentParam::getStatus,GeneralStatus.ENABLE.getCode());
|
|
|
+ wrapper.eq(EquipmentParam::getStatus, GeneralStatus.ENABLE.getCode());
|
|
|
return equipmentParamMapper.selectList(wrapper);
|
|
|
}
|
|
|
|
|
|
@@ -288,17 +288,33 @@ public class EquipmentParamServiceImpl implements IEquipmentParamService {
|
|
|
public Map<String, Object> getRegisterQuantity() {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
//查询目前传感器数量
|
|
|
- int sensorNum_now= Math.toIntExact(equipmentParamMapper.selectCount(null));
|
|
|
- map.put("value",sensorNum_now);
|
|
|
+ int sensorNum_now = Math.toIntExact(equipmentParamMapper.selectCount(null));
|
|
|
+ map.put("value", sensorNum_now);
|
|
|
//昨日传感器数量
|
|
|
LocalDate today = LocalDate.now();
|
|
|
LocalDateTime startOfDay = today.atStartOfDay();
|
|
|
- LambdaQueryWrapper<EquipmentParam> w=new LambdaQueryWrapper<>();
|
|
|
+ LambdaQueryWrapper<EquipmentParam> w = new LambdaQueryWrapper<>();
|
|
|
w.lt(EquipmentParam::getCreateTime, startOfDay);
|
|
|
int sensorNum_yesterday = Math.toIntExact(equipmentParamMapper.selectCount(w));
|
|
|
//今日传感器数量变化
|
|
|
- map.put("trend",sensorNum_now-sensorNum_yesterday);
|
|
|
+ map.put("trend", sensorNum_now - sensorNum_yesterday);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<Long, String> getCodeMapByParentIds(List<Long> validEquipmentIds) {
|
|
|
+ if (CollectionUtils.isEmpty(validEquipmentIds)) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+ Map<Long, String> result = new HashMap<>();
|
|
|
+ for (Long id : validEquipmentIds) {
|
|
|
+ String code = getCodeByParentId(id);
|
|
|
+ if (code != null) {
|
|
|
+ result.put(id, code);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|