设备操作相关接口,以及用户充值卡相关接口修改
This commit is contained in:
parent
788bfb100a
commit
593f3d3faa
@ -85,7 +85,7 @@ public class AjaxResult extends HashMap<String, Object>
|
||||
*/
|
||||
public static AjaxResult success()
|
||||
{
|
||||
return AjaxResult.success("操作成功");
|
||||
return AjaxResult.success("操作成功",null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ public class DeviceOtherMsgConsumer {
|
||||
public void consume(DeviceReportBo bo){
|
||||
try {
|
||||
//处理emq订阅的非 property/post 属性上报的消息 ,因为其他消息量小,放在一起处理
|
||||
String serialNumber=bo.getSerialNumber();//设备序列号
|
||||
|
||||
Long productId;//产品id
|
||||
|
||||
Long packetId;//包号
|
||||
@ -41,7 +41,10 @@ public class DeviceOtherMsgConsumer {
|
||||
//从主题中解析出产品id
|
||||
String[] split = topic.split("/");
|
||||
productId= Long.valueOf(split[1]);
|
||||
System.err.println("主题:"+topic+"产品id:"+productId+"设备序列号:"+serialNumber);
|
||||
//从主题中解析出设备序列号
|
||||
String serialNumber= split[2];//设备序列号
|
||||
|
||||
System.err.println("主题:"+topic+"--产品id:"+productId+"--设备序列号:"+serialNumber);
|
||||
//设备上报数据消息
|
||||
if(topic.endsWith("/info/up")){
|
||||
deviceDataReportHandler(new String(data));
|
||||
|
@ -42,11 +42,12 @@ public class DeviceOtherMsgHandler {
|
||||
* @param bo
|
||||
*/
|
||||
public void messageHandler(DeviceReportBo bo) {
|
||||
System.err.println("进入消息处理入口:"+bo);
|
||||
|
||||
String type = "";
|
||||
String name = topicsUtils.parseTopicName(bo.getTopicName());
|
||||
if (StringUtils.isEmpty(name) || name.endsWith(TopicType.FUNCTION_GET.getTopicSuffix())) return;
|
||||
ReportDataBo data = this.buildReportData(bo);
|
||||
System.err.println("进入消息处理入口:"+data);
|
||||
TopicType topicType = TopicType.getType(name);
|
||||
switch (topicType) {
|
||||
case INFO_POST:
|
||||
@ -77,7 +78,7 @@ public class DeviceOtherMsgHandler {
|
||||
String message = new String(bo.getData());
|
||||
// log.info("收到设备信息[{}]", message);
|
||||
Long productId = topicsUtils.parseProductId(bo.getTopicName());
|
||||
System.err.println("主题路径解析出产品id:"+productId);
|
||||
// System.err.println("主题路径解析出产品id:"+productId);
|
||||
String serialNumber = topicsUtils.parseSerialNumber(bo.getTopicName());
|
||||
ReportDataBo dataBo = new ReportDataBo();
|
||||
dataBo.setMessage(message);
|
||||
|
@ -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])));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.fastbee.iot.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceOperationDTO {
|
||||
|
||||
private Long productId;
|
||||
|
||||
private String deviceNumber;
|
||||
|
||||
private String operationType;
|
||||
|
||||
private String operationCode;
|
||||
}
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.iot.domain.Device;
|
||||
import com.fastbee.iot.mapper.DeviceMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.iot.mapper.DeviceReportInfoMapper;
|
||||
@ -24,6 +26,10 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
|
||||
private DeviceReportInfoMapper deviceReportInfoMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备上电审核前上报的基础信息
|
||||
*
|
||||
@ -81,7 +87,26 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
|
||||
if(deviceReportInfo.getAutoReview()!=null&&deviceReportInfo.getAutoReview()){
|
||||
deviceReportInfo.setStatus(2);//修改状态为已审核
|
||||
}
|
||||
return deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo);
|
||||
int inserted = deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo);
|
||||
|
||||
if(inserted<1){
|
||||
throw new ServiceException("插入设备上报信息失败!");
|
||||
}
|
||||
// //插入成功后,插入设备信息
|
||||
// Device device= new Device();
|
||||
// device.setDeviceName(deviceReportInfo.getName());
|
||||
// device.setSerialNumber(deviceReportInfo.getSerialNumber());
|
||||
// //TODO 弄成活的
|
||||
// device.setProductId(146L);
|
||||
// device.setStatus(1);//未激活
|
||||
// device.setCreateTime(deviceReportInfo.getPowersTime());
|
||||
// device.setTenantId(1L);//默认总管理员
|
||||
// int inserted1 = deviceMapper.insert(device);
|
||||
// if(inserted1<1){
|
||||
// throw new ServiceException("插入设备信息失败!");
|
||||
// }
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userName", unless = "#result == null")
|
||||
// @Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userName", unless = "#result == null")
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String userName)
|
||||
{
|
||||
@ -136,7 +136,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userId", unless = "#result == null")
|
||||
// @Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userId", unless = "#result == null")
|
||||
@Override
|
||||
public SysUser selectUserById(Long userId)
|
||||
{
|
||||
@ -149,7 +149,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
@Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userName", unless = "#result == null")
|
||||
// @Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userName", unless = "#result == null")
|
||||
@Override
|
||||
public String selectUserRoleGroup(String userName)
|
||||
{
|
||||
@ -167,7 +167,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
@Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userName", unless = "#result == null")
|
||||
// @Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userName", unless = "#result == null")
|
||||
@Override
|
||||
public String selectUserPostGroup(String userName)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user