Browse Source

设备信息扩展推送部门配置

dev
李克 1 week ago
parent
commit
0c5947d64c
  1. 16
      dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java
  2. 15
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java
  3. 9
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java

16
dk-modules/sample/src/main/java/org/dromara/sample/manage/controller/DeviceController.java

@ -1,11 +1,15 @@
package org.dromara.sample.manage.controller; package org.dromara.sample.manage.controller;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.dromara.common.core.domain.R; 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.mybatis.core.page.TableDataInfo;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.satoken.utils.LoginHelper; 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.common.web.core.BaseController;
import org.dromara.sample.manage.model.dto.DeviceDTO; import org.dromara.sample.manage.model.dto.DeviceDTO;
import org.dromara.sample.manage.model.dto.DeviceFirmwareUpgradeDTO; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -70,10 +76,16 @@ public class DeviceController {
} }
//更新设备信息-简版 //更新设备信息-简版
@PutMapping("/{workspace_id}/devices/{device_sn}/simple") @PutMapping("/{workspace_id}/devicesUpdate/simple")
public HttpResultResponse updateDeviceSimple(@RequestBody DeviceEntity device, public HttpResultResponse updateDeviceSimple(
@RequestBody DeviceEntity device,
@PathVariable("workspace_id") String workspaceId @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); boolean isUpd = deviceService.updateDeiceSimple(device);
return isUpd ? HttpResultResponse.success() : HttpResultResponse.error(); return isUpd ? HttpResultResponse.success() : HttpResultResponse.error();
} }

15
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()); .collect(Collectors.toList());
// 扩展部门信息前台显示
return new PaginationData<DeviceDTO>(devicesList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal())); return new PaginationData<DeviceDTO>(devicesList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal()));
} }
@ -750,10 +753,14 @@ public class DeviceServiceImpl implements IDeviceService {
@Override @Override
public boolean updateDeiceSimple(DeviceEntity device) { public boolean updateDeiceSimple(DeviceEntity device) {
LambdaUpdateWrapper<DeviceEntity> updateWrapper = new LambdaUpdateWrapper<>(); DeviceEntity deviceEntity = mapper.selectOne(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn, device.getDeviceSn()));
updateWrapper.set(DeviceEntity::getId,device.getId()); int update = 0;
updateWrapper.set(DeviceEntity::getPushDeptId,device.getPushDeptId()); if(ObjectUtil.isNotEmpty(deviceEntity)) {
int update = mapper.update(updateWrapper); DeviceEntity entity = new DeviceEntity();
entity.setId(deviceEntity.getId());
entity.setPushDeptId(device.getPushDeptId());
update = mapper.updateById(entity);
}
return update > 0; return update > 0;
} }

9
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 deviceSn = MapUtil.getStr(objectMap, "deviceSn", "");
String type = MapUtil.getStr(objectMap, "type", ""); // objectMap.get("type").toString(); String type = MapUtil.getStr(objectMap, "type", ""); // objectMap.get("type").toString();
Long pushDeptIdParam = MapUtil.getLong(objectMap, "pushDeptId", null); //默认支持从前台获取值
DeviceDTO deviceDTO = deviceService.getDeviceBySn(deviceSn).orElse(null); DeviceDTO deviceDTO = deviceService.getDeviceBySn(deviceSn).orElse(null);
//获取rtmpUrl + 默认记录上传 pushDeptId //获取rtmpUrl + 默认记录上传 pushDeptId
String rtmpUrl = ""; String rtmpUrl = "";
Long pushDeptId = null; Long pushDeptId = null; //推送 deptId,支持从设备列表获取默认数据
if (deviceDTO != null) { if (deviceDTO != null) {
String childDeviceRtmpUrl = deviceService.getChildDeviceStreamUrlByDeviceSn(deviceDTO.getChildDeviceSn()); String childDeviceRtmpUrl = deviceService.getChildDeviceStreamUrlByDeviceSn(deviceDTO.getChildDeviceSn());
rtmpUrl = childDeviceRtmpUrl; rtmpUrl = childDeviceRtmpUrl;
pushDeptId = deviceDTO.getPushDeptId(); pushDeptId = deviceDTO.getPushDeptId();
} }
if(ObjectUtil.isNotEmpty(pushDeptIdParam)){ //override - pushDeptId
pushDeptId = pushDeptIdParam;
}
// String configKey = remoteSystemFeign.getConfigKey("xingluo.auto.submit");//通 // String configKey = remoteSystemFeign.getConfigKey("xingluo.auto.submit");//通
// System.out.println("configKey"+configKey); // System.out.println("configKey"+configKey);
EngineRecordEntity record = new EngineRecordEntity(); EngineRecordEntity record = new EngineRecordEntity();
@ -184,7 +189,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService
// String ip = remoteConfigService.selectStreamIp(); // String ip = remoteConfigService.selectStreamIp();
String ip = remoteConfigFeign.getConfigKey("stream"); String ip = remoteConfigFeign.getConfigKey("stream");
System.out.println(ip); 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) String md5 = Md5Utils.hash("xuzhou_ai"); //获取token + 设置请求Header和Body(如JSON)
JSONObject jsonObj = new JSONObject(); JSONObject jsonObj = new JSONObject();
jsonObj.put("username", sanitize("xuzhou_ai")); // sanitize函数见下文 jsonObj.put("username", sanitize("xuzhou_ai")); // sanitize函数见下文

Loading…
Cancel
Save