|
@@ -1,29 +1,24 @@
|
|
|
package com.fjhx.iot.service.tda.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.iot.constants.RedisConstant;
|
|
|
-import com.fjhx.iot.entity.tda.dto.EbcDto;
|
|
|
import com.fjhx.iot.entity.tda.dto.TdaDeviceDto;
|
|
|
import com.fjhx.iot.entity.tda.dto.TdaDeviceSelectDto;
|
|
|
import com.fjhx.iot.entity.tda.po.TdaDevice;
|
|
|
import com.fjhx.iot.entity.tda.vo.TdaDeviceVo;
|
|
|
import com.fjhx.iot.mapper.tda.TdaDeviceMapper;
|
|
|
-import com.fjhx.iot.service.tda.TdaApplicationService;
|
|
|
import com.fjhx.iot.service.tda.TdaDeviceService;
|
|
|
-import com.fjhx.iot.service.tda.TdaProductService;
|
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
@@ -41,14 +36,6 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class TdaDeviceServiceImpl extends ServiceImpl<TdaDeviceMapper, TdaDevice> implements TdaDeviceService {
|
|
|
|
|
|
- @Lazy
|
|
|
- @Autowired
|
|
|
- private TdaProductService tdaProductService;
|
|
|
-
|
|
|
- @Lazy
|
|
|
- @Autowired
|
|
|
- private TdaApplicationService tdaApplicationService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
@@ -57,6 +44,15 @@ public class TdaDeviceServiceImpl extends ServiceImpl<TdaDeviceMapper, TdaDevice
|
|
|
IWrapper<TdaDevice> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("td", TdaDevice::getId);
|
|
|
wrapper.keyword(dto, new SqlField("td.device_name"));
|
|
|
+
|
|
|
+ //权限过滤:设备管理-子公司看自己的,总公司看全部
|
|
|
+ Long companyId = SecurityUtils.getCompanyId();
|
|
|
+ if (!Objects.equals(companyId, 100L)) {
|
|
|
+ wrapper.eq("td.company_id", companyId);
|
|
|
+ } else {
|
|
|
+ wrapper.eq("td.company_id", dto.getCompanyId());
|
|
|
+ }
|
|
|
+
|
|
|
Page<TdaDeviceVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
|
|
List<TdaDeviceVo> records = page.getRecords();
|
|
@@ -65,41 +61,41 @@ public class TdaDeviceServiceImpl extends ServiceImpl<TdaDeviceMapper, TdaDevice
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
- for (TdaDeviceVo record : records) {
|
|
|
-
|
|
|
- HashMap<String, Object> other = new HashMap<>();
|
|
|
- record.setOther(other);
|
|
|
-
|
|
|
- // 设备id
|
|
|
- String deviceId = record.getDeviceId();
|
|
|
-
|
|
|
- // 产品设备类型
|
|
|
- String deviceType = record.getDeviceType();
|
|
|
-
|
|
|
- if (StrUtil.isBlank(deviceId)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- Object obj = redisCache.getCacheObject(RedisConstant.DEVICE_PREFIX + deviceId);
|
|
|
- if (obj == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- switch (deviceType) {
|
|
|
- case "ebc":
|
|
|
- EbcDto ebcDto = (EbcDto) obj;
|
|
|
- EbcDto.Status status = ebcDto.getStatus();
|
|
|
- String sysSta = status.getSys_sta();
|
|
|
- record.setStatus(sysSta);
|
|
|
- record.setEventTime(ebcDto.getEventTime());
|
|
|
-
|
|
|
- other.put("ebc", "1");
|
|
|
- other.put("jiaka", status.getJiaka());
|
|
|
- other.put("hengyi", status.getHengyi());
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+// for (TdaDeviceVo record : records) {
|
|
|
+//
|
|
|
+// HashMap<String, Object> other = new HashMap<>();
|
|
|
+// record.setOther(other);
|
|
|
+//
|
|
|
+// // 设备id
|
|
|
+// String deviceId = record.getDeviceId();
|
|
|
+//
|
|
|
+// // 产品设备类型
|
|
|
+// String deviceType = record.getDeviceType();
|
|
|
+//
|
|
|
+// if (StrUtil.isBlank(deviceId)) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// Object obj = redisCache.getCacheObject(RedisConstant.DEVICE_PREFIX + deviceId);
|
|
|
+// if (obj == null) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// switch (deviceType) {
|
|
|
+// case "ebc":
|
|
|
+// EbcDto ebcDto = (EbcDto) obj;
|
|
|
+// EbcDto.Status status = ebcDto.getStatus();
|
|
|
+// String sysSta = status.getSys_sta();
|
|
|
+// record.setStatus(sysSta);
|
|
|
+// record.setEventTime(ebcDto.getEventTime());
|
|
|
+//
|
|
|
+// other.put("ebc", "1");
|
|
|
+// other.put("jiaka", status.getJiaka());
|
|
|
+// other.put("hengyi", status.getHengyi());
|
|
|
+// break;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
|
|
|
return page;
|
|
@@ -134,6 +130,9 @@ public class TdaDeviceServiceImpl extends ServiceImpl<TdaDeviceMapper, TdaDevice
|
|
|
|
|
|
// tdaDeviceDto.setSecret(deviceKey.getSecret());
|
|
|
|
|
|
+ //赋值归属公司Id
|
|
|
+ tdaDeviceDto.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
+
|
|
|
this.save(tdaDeviceDto);
|
|
|
}
|
|
|
|