Browse Source

缓存命令记录

master
lijunjie 2 years ago
parent
commit
9628806449
  1. 9
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/OnenetEquipController.java
  2. 9
      ruoyi-admin/src/main/java/com/ruoyi/web/domain/dto/OnenetEquipDto.java
  3. 8
      ruoyi-admin/src/main/java/com/ruoyi/web/service/IOnenetEquipService.java
  4. 65
      ruoyi-admin/src/main/java/com/ruoyi/web/service/impl/OnenetEquipServiceImpl.java
  5. 9
      ruoyi-ui/src/api/device/equips.js
  6. 80
      ruoyi-ui/src/views/device/equips/index.vue

9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/device/OnenetEquipController.java

@ -96,6 +96,15 @@ public class OnenetEquipController extends BaseController
return success(onenetEquipService.writeCommand(InsertDto));
}
/**
* 缓存命令记录
*/
@PostMapping("/commandHistory")
public AjaxResult commandHistory(@RequestBody OnenetEquipDto.HistoryDto HistoryDto)
{
return success(onenetEquipService.commandHistory(HistoryDto));
}
/**
* 查询设备数据
*/

9
ruoyi-admin/src/main/java/com/ruoyi/web/domain/dto/OnenetEquipDto.java

@ -36,6 +36,15 @@ public class OnenetEquipDto {
private String command;
}
@ApiModel("OnenetEquipDto - HistoryDto")
@Data
public static class HistoryDto{
@ApiModelProperty("")
private String imei;
@ApiModelProperty("时间")
private String[] historyTime;
}
@ApiModel("OnenetEquipDto - QureyEquipParam")
@Data
public static class QureyEquipParam{

8
ruoyi-admin/src/main/java/com/ruoyi/web/service/IOnenetEquipService.java

@ -36,6 +36,14 @@ public interface IOnenetEquipService
*/
public boolean writeCommand(OnenetEquipDto.InsertDto InsertDto);
/**
* 缓存命令记录
* @param HistoryDto
* @return
*/
public String commandHistory(OnenetEquipDto.HistoryDto HistoryDto);
/**
* 查询设备数据
* @param equipDataParam

65
ruoyi-admin/src/main/java/com/ruoyi/web/service/impl/OnenetEquipServiceImpl.java

@ -160,10 +160,61 @@ public class OnenetEquipServiceImpl implements IOnenetEquipService {
}
}
return false;
}
/**
* 缓存命令记录
* @param HistoryDto
* @return
*/
@Override
public String commandHistory(OnenetEquipDto.HistoryDto HistoryDto) {
if (StrUtil.hasEmpty(HistoryDto.getImei())){
return null;
}
OnenetConfig onenetConfigExample = new OnenetConfig();
onenetConfigExample.setConfigKey("onenet_api_key");
List<OnenetConfig> onenetConfigs = onenetConfigMapper.selectOnenetConfigList(onenetConfigExample);
List<OnenetEquipVo.EquipList> list = new ArrayList<>();
if (onenetConfigs.size() > 0) {
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("imei", HistoryDto.getImei());
if (!StrUtil.hasEmpty(HistoryDto.getHistoryTime())){
paramMap.put("start", HistoryDto.getHistoryTime()[0]);
paramMap.put("end", HistoryDto.getHistoryTime()[1]);
}
if (paramMap.get("start") == null){
DateTime yesterday = DateUtil.yesterday();
paramMap.put("start", DateUtil.format(yesterday, "yyyy-MM-dd'T'HH:mm:ss"));
// paramMap.put("start", "2023-02-02T10:45:10");
}
String url = "http://api.heclouds.com/nbiot/offline/history";
OnenetConfig onenetConfig = onenetConfigs.get(0);
String response = HttpRequest.get(url).header("api-key", onenetConfig.getConfigValue()).form(paramMap).execute().body();
JSONObject responseJson = JSON.parseObject(response);
Integer errno = responseJson.getObject("errno", Integer.class);
if (errno == 0) {
String dataJson = responseJson.getString("data");
return dataJson;
}
}
return null;
}
/**
* 查询设备数据
* @param equipDataParam
@ -191,13 +242,13 @@ public class OnenetEquipServiceImpl implements IOnenetEquipService {
OnenetConfig onenetConfig = onenetConfigs.get(0);
// String response = HttpRequest.get(url).header("api-key", onenetConfig.getConfigValue()).form(paramMap).execute().body();
String response = HttpRequest.get(url).header("api-key", onenetConfig.getConfigValue()).form(paramMap).execute().body();
String response = "{\"errno\":0,\"data\":{\"count\":1,\"datastreams\":[{\"datapoints\":[" +
"{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " +
"{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " +
"{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}" +
"],\"id\":\"3200_0_5750\"}]},\"error\":\"succ\"}";
// String response = "{\"errno\":0,\"data\":{\"count\":1,\"datastreams\":[{\"datapoints\":[" +
// "{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " +
// "{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}, " +
// "{\"at\":\"2023-01-09 17:47:15.969\",\"value\":\"68C00866472059908495852F015100FFFE0A6464220901002310010014731641646400000065014E000000000000182301091747150503000002015116\"}" +
// "],\"id\":\"3200_0_5750\"}]},\"error\":\"succ\"}";
JSONObject responseJson = JSON.parseObject(response);

9
ruoyi-ui/src/api/device/equips.js

@ -26,6 +26,15 @@ export function listEquipDatas(query) {
})
}
// 缓存命令记录
export function listHistorys(query) {
return request({
url: '/device/equip/commandHistory',
method: 'post',
data: query
})
}
// 查询推送记录
export function listReceiveDatas(query) {
return request({

80
ruoyi-ui/src/views/device/equips/index.vue

@ -30,7 +30,7 @@
<el-table-column label="设备标签" align="center" prop="tags" />
<el-table-column label="接入协议 " align="center" prop="protocol" />
<el-table-column label="位置" align="center" prop="location" />
<el-table-column label="NBIOT设备" align="center" prop="authInfo" />
<el-table-column label="NBIOT设备" align="center" prop="authInfo" width="300"/>
<el-table-column label="其他信息" align="center" prop="otherInfo" />
<el-table-column label="写设备资源" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
@ -56,6 +56,18 @@
</template>
</el-table-column>
<el-table-column label="缓存命令记录" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="getHistory(scope.row)"
v-hasPermi="['device:equips:edit']"
>缓存命令记录</el-button>
</template>
</el-table-column>
<el-table-column label="onenet推送记录" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -226,6 +238,35 @@
</el-dialog>
<!-- 缓存命令记录-->
<el-dialog title="缓存命令记录" :visible.sync="historyOpen" width="80%">
<el-form :model="historyParam" ref="queryFormEquipData" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="时间" prop="otherInfo">
<el-date-picker
v-model="historyParam.historyTime"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期" @click="">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getHistory(null)">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetHistory">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="historyList">
<el-table-column label="命令" align="center">
<template slot-scope="scope">
{{scope.row}}
</template>
</el-table-column>
</el-table>
</el-dialog>
<!-- onenet推送记录-->
<el-dialog title="onenet推送记录" :visible.sync="receiveDataOpen" width="80%">
<el-table v-loading="loading" :data="receiveDataList">
@ -253,7 +294,7 @@ import {
addEquips,
updateEquips,
getApiKey,
writeCommand, listEquipDatas, listReceiveDatas
writeCommand, listEquipDatas, listReceiveDatas, listHistorys
} from "@/api/device/equips";
@ -293,6 +334,17 @@ export default {
obj_id:0,
equipDataTime:"",
},
//
historyOpen:false,
historyParam: {
pageNum: 1,
pageSize: 10,
imei:0,
historyTime:[],
},
historyList: [],
historyTotal: 0,
//onenet
receiveDataOpen:false,
receiveDataParam: {
@ -389,9 +441,26 @@ export default {
this.loading = false;
});
},
/** 查询设备数据点 */
getHistory(row) {
this.historyOpen = true;
this.title = "查询设备数据点";
this.loading = true;
if (row != null){
let authInfo = JSON.parse(row.authInfo)
this.historyParam.imei = Object.keys(authInfo)[0]
}
listHistorys(this.historyParam).then(response => {
if (response.code == 200){
let msg = JSON.parse(response.msg);
this.historyList = msg.items
this.historyTotal = msg.total_count
}
this.loading = false;
});
},
/** onenet推送记录 */
getReceiveDatas(row) {
console.log(row)
this.receiveDataOpen = true;
this.title = "onenet推送记录";
this.loading = true;
@ -411,6 +480,11 @@ export default {
this.getEquipDatas();
},
resetHistory() {
this.historyParam.historyTime = [];
this.getHistory();
},
//
cancel() {
this.open = false;

Loading…
Cancel
Save