1. 修改设备名称
This commit is contained in:
parent
c6dd7eb02b
commit
7ae96df488
|
@ -28,6 +28,8 @@ import java.net.URLEncoder;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static sun.audio.AudioDevice.device;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
|
@ -123,6 +125,17 @@ public class AppController extends BaseController
|
|||
return AjaxResult.success(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备名称
|
||||
*/
|
||||
@PutMapping("/editDeviceName")
|
||||
public AjaxResult editDeviceName(Long deviceId, String deviceName)
|
||||
{
|
||||
logger.info("接收到修改设备名称请求:deviceId=【{}】,deviceName=【{}】",deviceId,deviceName);
|
||||
int i = asDeviceService.updateAsDevice(AsDevice.builder().deviceId(deviceId).deviceName(deviceName).build());
|
||||
return AjaxResult.success(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 切换默认展示设备
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.ruoyi.common.constant.HttpStatus;
|
|||
import com.ruoyi.common.constant.IotConstants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.onenet.*;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
|
@ -275,6 +274,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
asDevice.setModel(model.getModel());
|
||||
AsDeviceVersion asDeviceVersion = versionMapper.selectAsDeviceVersionByVersionId(asDevice.getVersionId());
|
||||
asDevice.setVersion(asDeviceVersion.getVersion());
|
||||
asDevice.setIsDefault("1");
|
||||
return asDeviceMapper.insertAsDevice(asDevice);
|
||||
}
|
||||
|
||||
|
@ -289,28 +289,28 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
public int updateAsDevice(AsDevice asDevice)
|
||||
{
|
||||
asDevice.setUpdateTime(DateUtils.getNowDate());
|
||||
/** 请求iot设备参数*/
|
||||
/** 1.获取参数*/
|
||||
String command = getCommand(asDevice);
|
||||
logger.info("IOT获取到下发命令:【{}】",command);
|
||||
|
||||
/** 2.发送请求*/
|
||||
String deviceName = asDevice.getMac();//mac地址就是产品名称
|
||||
String param = "device_name=" + deviceName + "&product_id=" + productId +"&timeout=" + timeout;
|
||||
String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param;
|
||||
|
||||
String token = Token.getToken();
|
||||
logger.info("IOT获取到Authorization:【{}】",token);
|
||||
|
||||
String result = HttpUtils.sendPostWithToken(sendUrl, command, token);
|
||||
|
||||
JSONObject paramsObj = JSON.parseObject(result);
|
||||
String code = paramsObj.getString("code");
|
||||
if (!HttpStatus.IOT_SUCCESS.equals(code))
|
||||
{
|
||||
throw new ServiceException(code+"-----"+ IotUtil.formatMsg(code));
|
||||
}
|
||||
logger.info("IOT请求调用结果:【{}】",result);
|
||||
// /** 请求iot设备参数*/
|
||||
// /** 1.获取参数*/
|
||||
// String command = getCommand(asDevice);
|
||||
// logger.info("IOT获取到下发命令:【{}】",command);
|
||||
//
|
||||
// /** 2.发送请求*/
|
||||
// String deviceName = asDevice.getMac();//mac地址就是产品名称
|
||||
// String param = "device_name=" + deviceName + "&product_id=" + productId +"&timeout=" + timeout;
|
||||
// String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param;
|
||||
//
|
||||
// String token = Token.getToken();
|
||||
// logger.info("IOT获取到Authorization:【{}】",token);
|
||||
//
|
||||
// String result = HttpUtils.sendPostWithToken(sendUrl, command, token);
|
||||
//
|
||||
// JSONObject paramsObj = JSON.parseObject(result);
|
||||
// String code = paramsObj.getString("code");
|
||||
// if (!HttpStatus.IOT_SUCCESS.equals(code))
|
||||
// {
|
||||
// throw new ServiceException(code+"-----"+ IotUtil.formatMsg(code));
|
||||
// }
|
||||
// logger.info("IOT请求调用结果:【{}】",result);
|
||||
|
||||
/**4.更新数据库*/
|
||||
return asDeviceMapper.updateAsDevice(asDevice);
|
||||
|
@ -462,7 +462,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
String mac = asDevice.getMac();
|
||||
AsDevice device = asDeviceMapper.selectAsDeviceByMac(mac);
|
||||
if(ObjectUtils.isEmpty(device)){
|
||||
throw new ServiceException("该设备已经被删除");
|
||||
throw new ServiceException("该设备不存在");
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(device.getUserId()) && device.getUserId()>0){
|
||||
throw new ServiceException("该设备已经绑定用户,请先解绑!");
|
||||
|
|
|
@ -61,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="modelId != null "> and model_id = #{modelId}</if>
|
||||
<if test="isDefault != null and isDefault != ''"> and is_default = #{isDefault}</if>
|
||||
</where>
|
||||
order by is_default desc
|
||||
</select>
|
||||
|
||||
<select id="selectAsDeviceByDeviceId" parameterType="Long" resultMap="AsDeviceResult">
|
||||
|
|
Loading…
Reference in New Issue
Block a user