Commit 344d6a51 by huangjy

fix:saas端,平台端,小程序设备读取谢日

parent 4a715455
......@@ -7,8 +7,10 @@ import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.dto.saas.device.PlatDeviceEditSaasDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.saas.SaasOperationLogService;
import com.makeit.vo.platform.device.PlatDeviceListVO;
......@@ -20,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Api(tags = "租户管理-租户设备管理")
@RestController
@RequestMapping("/saas/device")
......@@ -55,4 +59,17 @@ public class SaasDeviceController {
return ApiResponseUtils.success();
}
@ApiOperation("读取设备属性 主要读取usrServerInfo信息")
@PostMapping("readDeviceProperties")
public ApiResponseEntity<List<DeviceProperties>> readDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
return ApiResponseUtils.success(platDeviceService.readDeviceProperties(dto));
}
@ApiOperation("编辑设备属性 主要写入usrServerInfo信息")
@PostMapping("editDeviceProperties")
public ApiResponseEntity<?> editDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
platDeviceService.editDeviceProperties(dto);
return ApiResponseUtils.success();
}
}
......@@ -8,9 +8,11 @@ import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.device.PlatDeviceEditDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.task.IotSyncTask;
import com.makeit.vo.platform.device.PlatDeviceListVO;
......@@ -80,5 +82,17 @@ public class PlatDeviceController {
return ApiResponseUtils.success(platDeviceService.productList(dto));
}
@ApiOperation("读取设备属性 主要读取usrServerInfo信息")
@PostMapping("readDeviceProperties")
public ApiResponseEntity<List<DeviceProperties>> readDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
return ApiResponseUtils.success(platDeviceService.readDeviceProperties(dto));
}
@ApiOperation("编辑设备属性 主要写入usrServerInfo信息")
@PostMapping("editDeviceProperties")
public ApiResponseEntity<?> editDeviceProperties(@RequestBody PlatDeviceAttrWechatDTO dto) {
platDeviceService.editDeviceProperties(dto);
return ApiResponseUtils.success();
}
}
......@@ -35,14 +35,7 @@ public class PlatDeviceAttrWechatDTO {
private String readProperties;
//private String usrServerInfo;
@ApiModelProperty(value = "服务信息 {\n" +
" \"password\": \"\",\n" +
" \"port\": 0,\n" +
" \"secure_key\": \"\",\n" +
" \"secure_id\": \"\",\n" +
" \"addr\": \"\",\n" +
" \"username\": \"\"\n" +
" }")
@ApiModelProperty(value = "服务信息 {\"password\":\"1234576\",\"secureKey\":\"kuangshi\",\"secureId\":\"kuangshi\",\"addr\":\"mqtt://121.1.1.2\",\"username\":\"kuangshi\",\"port\":1883} ")
private UserServerInfo usrServerInfo;
}
......@@ -31,11 +31,11 @@ import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.HeaderConst;
import com.makeit.enums.report.DeviceNameEnum;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.module.iot.dto.UserServerInfo;
import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import com.makeit.module.iot.service.IotOrgService;
import com.makeit.module.iot.service.IotProductDeviceService;
......@@ -403,14 +403,28 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Override
public void editDeviceProperties(PlatDeviceAttrWechatDTO dto) {
String deviceId = dto.getDeviceId();
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId));
UserServerInfo usrServerInfo = dto.getUsrServerInfo();
if (other != null && usrServerInfo != null) {
other.setProtocolAccount(usrServerInfo.getUsername());
other.setProtocolPassword(usrServerInfo.getPassword());
other.setProtocolAddress(usrServerInfo.getAddr());
other.setProtocolPort(usrServerInfo.getPort() == null ? "" : usrServerInfo.getPort().toString());
other.setSecureId(usrServerInfo.getSecureId());
other.setSecureKey(usrServerInfo.getSecureKey());
platDeviceOtherService.updateById(other);
}
log.info("写入设备属性请求参数:{}",JSON.toJSONString(dto));
devicePropertiesOperateService.deviceWrite(dto.getDeviceId(), dto.getRadarMount(), dto.getRadarMode(), dto.getRadarHight(),dto.getUsrServerInfo());
devicePropertiesOperateService.deviceWrite(deviceId, dto.getRadarMount(), dto.getRadarMode(), dto.getRadarHight(), usrServerInfo);
if (dto.getRadarMount() != null) {
//更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, dto.getRadarMount())
.eq(PlatRegionSetting::getDeviceId, dto.getDeviceId()));
.eq(PlatRegionSetting::getDeviceId, deviceId));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment