|
|
@@ -1,5 +1,6 @@
|
|
|
package com.xunmei.iot.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -22,7 +23,7 @@ import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author test
|
|
|
@@ -39,28 +40,55 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo<SensorPageVo> selectSensorDataPage(SensorPageDto request) {
|
|
|
- final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
|
|
|
+ dealPageParam(request);
|
|
|
|
|
|
- if (ObjectUtil.equal(Boolean.TRUE,request.getCheckSub())){
|
|
|
- request.setOrgPath(sysOrg.getPath());
|
|
|
- request.setOrgId(null);
|
|
|
+ Page<SensorPageVo> page = sensorMapper.selectPageData(request.getPageRequest(), request);
|
|
|
+ for (SensorPageVo record : page.getRecords()) {
|
|
|
+ final String info = record.getInfo();
|
|
|
+ record.setInfo(dealInfoData(info));
|
|
|
}
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String dealInfoData(String info) {
|
|
|
+ final List<Map> list = JSON.parseArray(info, Map.class);
|
|
|
+ List<String> dataList = new ArrayList<>();
|
|
|
+ for (Map map : list) {
|
|
|
+ final String name = (String) map.get("name");
|
|
|
+ final String res = (String) map.get("res");
|
|
|
+ if (ObjectUtil.hasEmpty(name, res)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dataList.add(name + ":" + res);
|
|
|
+ }
|
|
|
+ return String.join(";", dataList);
|
|
|
+ }
|
|
|
|
|
|
- Page<SensorPageVo> page= sensorMapper.selectPageData(request.getPageRequest(),request);
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<SensorPageVo> selectSensorLogDataPage(SensorPageDto request) {
|
|
|
+ dealPageParam(request);
|
|
|
+ if (ObjectUtil.isEmpty(request.getDeviceCode())) {
|
|
|
+ throw new RuntimeException("设备编码不能为空!");
|
|
|
+ }
|
|
|
+ Page<SensorPageVo> page = sensorMapper.selectSensorLogDataPage(request.getPageRequest(), request);
|
|
|
for (SensorPageVo record : page.getRecords()) {
|
|
|
final String info = record.getInfo();
|
|
|
- final List<Map> list = JSON.parseArray(info, Map.class);
|
|
|
- List<String> dataList = new ArrayList<>();
|
|
|
- for (Map map : list) {
|
|
|
- final String name = (String) map.get("name");
|
|
|
- final String res = (String) map.get("res");
|
|
|
- if (ObjectUtil.hasEmpty(name,res)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- dataList.add(name+":"+res);
|
|
|
- }
|
|
|
- record.setInfo(String.join(";",dataList));
|
|
|
+ record.setInfo(dealInfoData(info));
|
|
|
}
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void dealPageParam(SensorPageDto request) {
|
|
|
+ final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
|
|
|
+ if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
|
|
|
+ request.setOrgPath(sysOrg.getPath());
|
|
|
+ request.setOrgId(null);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(request.getDateRange())) {
|
|
|
+ //web的查询
|
|
|
+ request.setStartTime(DateUtil.beginOfDay(request.getDateRange()[0]));
|
|
|
+ request.setEndTime(DateUtil.endOfDay(request.getDateRange()[1]));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|