设备操作相关接口,以及用户充值卡相关接口修改
This commit is contained in:
@ -505,4 +505,16 @@ public class DeviceController extends BaseController {
|
||||
return AjaxResult.success(deviceService.getDeviceActivationList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备编号判断设备是否激活
|
||||
*/
|
||||
@GetMapping("/getDeviceIsActivation")
|
||||
@ApiOperation("根据设备编号判断设备是否激活")
|
||||
public AjaxResult getDeviceActivation(String serialNumber) {
|
||||
Device device = deviceService.selectDeviceBySerialNumber(serialNumber);
|
||||
if(device.getStatus().toString().equals("1")){
|
||||
return AjaxResult.success(false);
|
||||
}
|
||||
return AjaxResult.success(true);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.fastbee.data.controller;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.dtflys.forest.annotation.Post;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.iot.model.dto.DeviceOperationDTO;
|
||||
import com.fastbee.mqttclient.PubMqttCallBack;
|
||||
import com.fastbee.mqttclient.PubMqttClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 下发指令操作设备
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/device/operation")
|
||||
public class DeviceOperationController {
|
||||
|
||||
@Autowired
|
||||
private PubMqttClient pubMqttClient;
|
||||
|
||||
@Autowired
|
||||
private PubMqttCallBack pubMqttCallBack;
|
||||
|
||||
/**
|
||||
* 下发指令控制设备
|
||||
*/
|
||||
@PostMapping("/control")
|
||||
public AjaxResult control(@RequestBody DeviceOperationDTO deviceOperationDTO){
|
||||
|
||||
//构建主题
|
||||
String topic ="/"+deviceOperationDTO.getProductId()+"/"+deviceOperationDTO.getDeviceNumber()+"/cmd/down";
|
||||
//构建消息
|
||||
Map<String,Object> param = new HashMap<>();
|
||||
//远程阀控
|
||||
if(deviceOperationDTO.getOperationType().equals("700")){
|
||||
param.put("cmd",700);
|
||||
Map<String,Object> data = new HashMap<>();
|
||||
data.put("status",deviceOperationDTO.getOperationCode());
|
||||
param.put("data",data);
|
||||
pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(param));
|
||||
return AjaxResult.success();
|
||||
//设备重启
|
||||
} else if (deviceOperationDTO.getOperationType().equals("100")) {
|
||||
param.put("cmd",100);
|
||||
Map<String,Object> data = new HashMap<>();
|
||||
data.put("status",deviceOperationDTO.getOperationCode());
|
||||
param.put("data",data);
|
||||
}
|
||||
return AjaxResult.error("未知命令!");
|
||||
}
|
||||
|
||||
}
|
@ -41,7 +41,7 @@ public class DeviceReportInfoController extends BaseController
|
||||
/**
|
||||
* 查询设备上电审核前上报的基础信息列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:info:list')")
|
||||
// @PreAuthorize("@ss.hasPermi('iot:info:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询设备上电审核前上报的基础信息列表")
|
||||
public TableDataInfo list(DeviceReportInfo deviceReportInfo)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fastbee.data.controller.gis.mqtt;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fastbee.mqttclient.PubMqttCallBack;
|
||||
import com.fastbee.mqttclient.PubMqttClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -7,6 +8,9 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/mqtt")
|
||||
public class MqttTest {
|
||||
@ -18,12 +22,17 @@ public class MqttTest {
|
||||
private PubMqttCallBack pubMqttCallBack;
|
||||
|
||||
/**
|
||||
* 测试平台mqtt发布消息
|
||||
* 测试平台mqtt下发指令
|
||||
*/
|
||||
@GetMapping("/publish")
|
||||
public String test(){
|
||||
pubMqttClient.publish(1,true,"/10086/155/cmd/down","mqtt测试主题发布消息!");
|
||||
return "test";
|
||||
Map<String,Object> param = new HashMap<>();
|
||||
param.put("cmd",700);
|
||||
Map<String,Object> data = new HashMap<>();
|
||||
data.put("status",0);
|
||||
param.put("data",data);
|
||||
pubMqttClient.publish(1,true,"/10086/155/cmd/down", JSONUtil.toJsonStr(param));
|
||||
return "ok";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.fastbee.data.controller.userRecharge;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@ -112,10 +114,10 @@ public class UserRechargeCardsController extends BaseController
|
||||
* 删除用户充值卡
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:cards:remove')")
|
||||
@DeleteMapping("/{ids}")
|
||||
@DeleteMapping("/{id}")
|
||||
@ApiOperation("删除用户充值卡")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
public AjaxResult remove(@PathVariable Long id)
|
||||
{
|
||||
return toAjax(userRechargeCardsService.deleteUserRechargeCardsByIds(ids));
|
||||
return toAjax(userRechargeCardsService.deleteUserRechargeCardsByIds(Collections.singletonList(id).toArray(new Long[0])));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user