diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java index 0882372..7385b0d 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java @@ -1,11 +1,15 @@ package org.dromara.sample.manage.controller; import cn.dev33.satoken.annotation.SaCheckPermission; +import com.alibaba.fastjson.JSON; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.dromara.common.core.domain.R; +import org.dromara.common.json.utils.JsonUtils; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.satoken.utils.LoginHelper; +import org.dromara.common.sdk.cloudapi.device.OsdDock; import org.dromara.common.web.core.BaseController; import org.dromara.sample.manage.model.dto.DeviceDTO; import org.dromara.sample.manage.model.dto.DeviceFirmwareUpgradeDTO; @@ -23,6 +27,8 @@ import org.dromara.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -70,10 +76,16 @@ public class DeviceController { } //更新设备信息-简版 - @PutMapping("/{workspace_id}/devices/{device_sn}/simple") - public HttpResultResponse updateDeviceSimple(@RequestBody DeviceEntity device, - @PathVariable("workspace_id") String workspaceId - ) { + @PutMapping("/{workspace_id}/devicesUpdate/simple") + public HttpResultResponse updateDeviceSimple( + @RequestBody DeviceEntity device, + @PathVariable("workspace_id") String workspaceId +// @RequestParam(name = "deviceSn") String deviceSn, +// @RequestParam(name = "pushDeptId") Long pushDeptId + ) { +// DeviceEntity device = new DeviceEntity(); +// device.setDeviceSn(deviceSn); +// device.setPushDeptId(pushDeptId); boolean isUpd = deviceService.updateDeiceSimple(device); return isUpd ? HttpResultResponse.success() : HttpResultResponse.error(); } diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java index c1074a0..bda7cef 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java @@ -557,6 +557,9 @@ public class DeviceServiceImpl implements IDeviceService { } }) .collect(Collectors.toList()); +// 扩展部门信息前台显示 + + return new PaginationData(devicesList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal())); } @@ -750,10 +753,14 @@ public class DeviceServiceImpl implements IDeviceService { @Override public boolean updateDeiceSimple(DeviceEntity device) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.set(DeviceEntity::getId,device.getId()); - updateWrapper.set(DeviceEntity::getPushDeptId,device.getPushDeptId()); - int update = mapper.update(updateWrapper); + DeviceEntity deviceEntity = mapper.selectOne(new LambdaQueryWrapper().eq(DeviceEntity::getDeviceSn, device.getDeviceSn())); + int update = 0; + if(ObjectUtil.isNotEmpty(deviceEntity)) { + DeviceEntity entity = new DeviceEntity(); + entity.setId(deviceEntity.getId()); + entity.setPushDeptId(device.getPushDeptId()); + update = mapper.updateById(entity); + } return update > 0; } diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java index 075f8d0..7f1a9ae 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java @@ -168,15 +168,20 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService String deviceSn = MapUtil.getStr(objectMap, "deviceSn", ""); String type = MapUtil.getStr(objectMap, "type", ""); // objectMap.get("type").toString(); + Long pushDeptIdParam = MapUtil.getLong(objectMap, "pushDeptId", null); //默认支持从前台获取值 DeviceDTO deviceDTO = deviceService.getDeviceBySn(deviceSn).orElse(null); //获取rtmpUrl + 默认记录上传 pushDeptId String rtmpUrl = ""; - Long pushDeptId = null; + Long pushDeptId = null; //推送 deptId,支持从设备列表获取默认数据 if (deviceDTO != null) { String childDeviceRtmpUrl = deviceService.getChildDeviceStreamUrlByDeviceSn(deviceDTO.getChildDeviceSn()); rtmpUrl = childDeviceRtmpUrl; pushDeptId = deviceDTO.getPushDeptId(); } + if(ObjectUtil.isNotEmpty(pushDeptIdParam)){ //override - pushDeptId + pushDeptId = pushDeptIdParam; + } + // String configKey = remoteSystemFeign.getConfigKey("xingluo.auto.submit");//通 // System.out.println("configKey"+configKey); EngineRecordEntity record = new EngineRecordEntity(); @@ -184,7 +189,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService // String ip = remoteConfigService.selectStreamIp(); String ip = remoteConfigFeign.getConfigKey("stream"); System.out.println(ip); - ip = "121.237.182.235";//服务器使用ip + ip = "121.237.182.235";//服务器使用ip 【测试】 String md5 = Md5Utils.hash("xuzhou_ai"); //获取token + 设置请求Header和Body(如JSON) JSONObject jsonObj = new JSONObject(); jsonObj.put("username", sanitize("xuzhou_ai")); // sanitize函数见下文