TRX 1 ano atrás
pai
commit
4a4d2b5556

+ 0 - 28
FullCardClient/src/main/java/com/zhongshu/card/client/service/school/GateWayInfoService.java

@@ -1,28 +0,0 @@
-package com.zhongshu.card.client.service.school;
-
-import com.github.microservice.models.device.GateWaySyncParam;
-import com.zhongshu.card.client.model.devices.GateWayInfoModel;
-import com.zhongshu.card.client.model.devices.GateWayInfoParam;
-import com.zhongshu.card.client.model.devices.GateWayInfoSearch;
-import com.github.microservice.net.ResultContent;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-
-import java.util.List;
-
-/**
- * @author TRX
- * @date 2024/6/14
- */
-public interface GateWayInfoService {
-    ResultContent syncGateWayInfo(GateWaySyncParam.GateWaySyncInfo param);
-
-    ResultContent updateGateArea(GateWayInfoParam param);
-
-    ResultContent<Page<GateWayInfoModel>> page(GateWayInfoSearch param, Pageable pageable);
-
-    ResultContent<GateWayInfoModel> getGateWayInfo(String gateWayId);
-
-    ResultContent<List<GateWayInfoModel>> getAllGateWayInfo();
-
-}

+ 0 - 6
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/DeviceSyncController.java

@@ -51,12 +51,6 @@ public class DeviceSyncController {
         return deviceSyncFromIotService.syncDeviceOnLineState(param);
     }
 
-    @Operation(summary = "物联网--同步网关接口", hidden = true)
-    @RequestMapping(value = "syncGateWays", method = {RequestMethod.POST})
-    public ResultContent syncGateWays(@RequestBody GateWaySyncParam param) {
-        return deviceSyncFromIotService.syncGateWays(param);
-    }
-
     @Operation(summary = "物联网--设备权限下发的响应")
     @RequestMapping(value = "markSendResponse", method = {RequestMethod.POST})
     public ResultContent markSendResponse(@RequestBody DevicePermissSendResponseParam param) {

+ 0 - 68
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/GateWayInfoController.java

@@ -1,68 +0,0 @@
-package com.zhongshu.card.server.core.controller.devices;
-
-import com.github.microservice.auth.security.annotations.ResourceAuth;
-import com.github.microservice.auth.security.type.AuthType;
-import com.zhongshu.card.client.model.devices.GateWayInfoModel;
-import com.zhongshu.card.client.model.devices.GateWayInfoParam;
-import com.zhongshu.card.client.model.devices.GateWayInfoSearch;
-import com.github.microservice.net.ResultContent;
-import com.zhongshu.card.client.service.school.GateWayInfoService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.web.PageableDefault;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * 网关
- *
- * @author TRX
- * @date 2024/6/5
- */
-@RestController
-@RequestMapping("/gateWays")
-@Tag(name = "平台-网关管理")
-public class GateWayInfoController {
-
-    @Autowired
-    GateWayInfoService gateWayInfoService;
-
-    //----------------------------基础信息 start------------------------
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "根据网关ID 查询详情", description = "根据网关ID 查询详情 ")
-    @RequestMapping(value = "getGateWayInfo", method = {RequestMethod.GET})
-    public ResultContent<GateWayInfoModel> getGateWayInfo(@RequestParam(name = "gateWayId") String gateWayId) {
-        return this.gateWayInfoService.getGateWayInfo(gateWayId);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "编辑网关的区域", description = "编辑网关的区域")
-    @RequestMapping(value = "updateGateArea", method = {RequestMethod.POST})
-    public ResultContent updateGateArea(@RequestBody GateWayInfoParam param) {
-        return this.gateWayInfoService.updateGateArea(param);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "网关列表-分页查询", description = "网关列表-分页查询")
-    @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
-    public ResultContent<Page<GateWayInfoModel>> page(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
-            @Parameter(required = false) GateWayInfoSearch param) {
-        return gateWayInfoService.page(param, pageable);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "得到所有的网关", description = "得到所有的网关")
-    @RequestMapping(value = "getAllGateWayInfo", method = {RequestMethod.GET})
-    public ResultContent<List<GateWayInfoModel>> getAllGateWayInfo() {
-        return this.gateWayInfoService.getAllGateWayInfo();
-    }
-
-    //----------------------------基础信息 end--------------------------
-
-}

+ 0 - 23
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/GateWayInfoDao.java

@@ -1,23 +0,0 @@
-package com.zhongshu.card.server.core.dao.devices;
-
-import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
-import com.zhongshu.card.server.core.dao.devices.extend.GateWayInfoDaoExtend;
-import com.zhongshu.card.server.core.domain.devices.GateWayInfo;
-
-import java.util.List;
-
-/**
- * Dao
- *
- * @author TRX
- * @date 2024/3/21
- */
-public interface GateWayInfoDao extends MongoDao<GateWayInfo>, GateWayInfoDaoExtend {
-
-    GateWayInfo findTopByGateWayId(String gateWayId);
-
-    List<GateWayInfo> findTop10ByGateWayIdLike(String gateWayId);
-
-    GateWayInfo findTopById(String id);
-
-}

+ 0 - 17
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/extend/GateWayInfoDaoExtend.java

@@ -1,17 +0,0 @@
-package com.zhongshu.card.server.core.dao.devices.extend;
-
-import com.zhongshu.card.client.model.devices.GateWayInfoSearch;
-import com.zhongshu.card.server.core.domain.devices.GateWayInfo;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-
-/**
- * 设备管理
- *
- * @Author TRX
- * @CreateDate: 2023/7/7
- * @Version: 1.0
- */
-public interface GateWayInfoDaoExtend {
-    Page<GateWayInfo> page(Pageable pageable, GateWayInfoSearch param);
-}

+ 0 - 91
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/impl/GateWayInfoDaoImpl.java

@@ -1,91 +0,0 @@
-package com.zhongshu.card.server.core.dao.devices.impl;
-
-import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
-import com.zhongshu.card.client.model.devices.GateWayInfoSearch;
-import com.zhongshu.card.server.core.dao.BaseImpl;
-import com.zhongshu.card.server.core.dao.devices.extend.GateWayInfoDaoExtend;
-import com.zhongshu.card.server.core.domain.school.Area;
-import com.zhongshu.card.server.core.domain.devices.GateWayInfo;
-import com.zhongshu.card.server.core.util.CommonUtil;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.query.Criteria;
-import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.util.CollectionUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * @Author TRX
- * @CreateDate: 2023/4/12
- * @Version: 1.0
- */
-public class GateWayInfoDaoImpl extends BaseImpl implements GateWayInfoDaoExtend {
-
-    @Autowired
-    private MongoTemplate mongoTemplate;
-
-    @Autowired
-    private DBHelper dbHelper;
-
-    @Override
-    public Page<GateWayInfo> page(Pageable pageable, GateWayInfoSearch param) {
-        Criteria criteria = buildCriteria(param);
-
-        if (param.getState() != null) {
-            criteria.and("state").is(param.getState());
-        }
-
-        if (StringUtils.isNotEmpty(param.getAreaId())) {
-            criteria.and("area").is(Area.build(param.getAreaId()));
-        }
-
-        if (StringUtils.isNotEmpty(param.getProjectInfoCode())) {
-            criteria.and("projectInfoCode").is(param.getProjectInfoCode());
-        }
-
-        if (!CommonUtil.longIsEmpty(param.getStartTime()) && !CommonUtil.longIsEmpty(param.getEndTime())) {
-            criteria.and("createTime").gte(param.getStartTime()).and("createTime").lte(param.getEndTime());
-        }
-
-        // 模糊搜索
-        List<Criteria> criterias = new ArrayList<>();
-        if (StringUtils.isNotEmpty(param.getGateWayId())) {
-            Pattern pattern = Pattern.compile("^.*" + param.getGateWayId() + ".*$");
-            criterias.add(Criteria.where("gateWayId").is(pattern));
-        }
-        if (StringUtils.isNotEmpty(param.getGateWayName())) {
-            Pattern pattern = Pattern.compile("^.*" + param.getGateWayName() + ".*$");
-            criterias.add(Criteria.where("gateWayName").is(pattern));
-        }
-
-        if (StringUtils.isNotEmpty(param.getIp())) {
-            Pattern pattern = Pattern.compile("^.*" + param.getIp() + ".*$");
-            criterias.add(Criteria.where("ip").is(pattern));
-        }
-        if (!CollectionUtils.isEmpty(criterias)) {
-            criteria.andOperator(criterias.toArray(new Criteria[]{}));
-        }
-
-        if (StringUtils.isNotEmpty(param.getKeyWord())) {
-            Pattern pattern = Pattern.compile("^.*" + param.getKeyWord() + ".*$");
-            criteria.orOperator(
-                    Criteria.where("gateWayId").regex(pattern),
-                    Criteria.where("gateWayName").regex(pattern),
-                    Criteria.where("ip").regex(pattern)
-            );
-        }
-
-        Sort sort = buildSort(param);
-        Query query = Query.query(criteria);
-        query.with(sort);
-        return dbHelper.pages(query, pageable, GateWayInfo.class);
-    }
-
-}

+ 0 - 43
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/GateWay2Device.java

@@ -1,43 +0,0 @@
-package com.zhongshu.card.server.core.domain.devices;
-
-import com.zhongshu.card.client.type.OnLineState;
-import com.zhongshu.card.server.core.domain.base.SuperMain;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.springframework.data.mongodb.core.mapping.DBRef;
-import org.springframework.data.mongodb.core.mapping.Document;
-
-/**
- * 网关和设备的绑定关系 可能一个设备绑定多个网关 一个网关多个设备 (多对多的关系)
- *
- * @author TRX
- * @date 2024/5/14
- */
-@Data
-@Document
-@NoArgsConstructor
-@AllArgsConstructor
-public class GateWay2Device extends SuperMain {
-
-    @DBRef(lazy = true)
-    @Schema(description = "硬件设备网关信息")
-    private GateWayInfo gateWayInfo;
-
-    @DBRef(lazy = true)
-    @Schema(description = "关联的设备信息")
-    private DeviceInfo deviceInfo;
-
-    @Schema(description = "设备在线状态")
-    private OnLineState state;
-
-    @Schema(description = "绑定时间")
-    private String bindTimeStr;
-
-    @Schema(description = "绑定的项目ID")
-    private String projectId;
-
-    @Schema(description = "所属区域")
-    private String address;
-}

+ 0 - 47
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/GateWayInfo.java

@@ -1,47 +0,0 @@
-package com.zhongshu.card.server.core.domain.devices;
-
-import com.zhongshu.card.client.type.OnLineState;
-import com.zhongshu.card.server.core.domain.base.SuperMain;
-import com.zhongshu.card.server.core.domain.school.Area;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.springframework.data.mongodb.core.mapping.DBRef;
-import org.springframework.data.mongodb.core.mapping.Document;
-
-/**
- * 物联网 硬件设备  网关信息
- *
- * @author TRX
- * @date 2024/5/14
- */
-@Data
-@Document
-@NoArgsConstructor
-@AllArgsConstructor
-public class GateWayInfo extends SuperMain {
-
-    @Schema(description = "网关ID")
-    private String gateWayId;
-
-    @Schema(description = "网关名称")
-    private String gateWayName;
-
-    @Schema(description = "关联的项目code")
-    private String projectInfoCode;
-
-    @Schema(description = "关联的项目Name")
-    private String projectInfoName;
-
-    @Schema(description = "ip地址")
-    private String ip;
-
-    @Schema(description = "网关在线状态")
-    OnLineState state;
-
-    @Schema(description = "所属区域")
-    @DBRef(lazy = true)
-    private Area area;
-
-}

+ 14 - 35
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceSyncFromIotService.java

@@ -2,7 +2,6 @@ package com.zhongshu.card.server.core.service.devices;
 
 import com.github.microservice.models.device.DeviceInfoSyncParam;
 import com.github.microservice.models.device.DeviceSyncListParam;
-import com.github.microservice.models.device.GateWaySyncParam;
 import com.github.microservice.models.hxz.DevicePingInfoParam;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.service.school.DeviceInfoService;
@@ -34,22 +33,19 @@ import java.util.List;
 public class DeviceSyncFromIotService {
 
     @Autowired
-    DeviceInfoService deviceInfoService;
+    private DeviceInfoService deviceInfoService;
 
     @Autowired
-    OrganizationDao organizationDao;
+    private OrganizationDao organizationDao;
 
     @Autowired
-    OrganizationRelationDao organizationRelationDao;
+    private OrganizationRelationDao organizationRelationDao;
 
     @Autowired
-    OperationLogsService operationLogsService;
+    private OperationLogsService operationLogsService;
 
     @Autowired
-    GateWayInfoServiceImpl gateWayService;
-
-    @Autowired
-    CommonService commonService;
+    private CommonService commonService;
 
     @Autowired
     private DeviceInfoDao deviceInfoDao;
@@ -85,22 +81,27 @@ public class DeviceSyncFromIotService {
     public ResultContent syncDeviceOnLineState(DevicePingInfoParam param) {
         HashMap<String, Object> where = new HashMap<>();
         where.put("deviceId", param.getDeviceId());
+        OnLineState onLineState = CommonUtil.getEnumByName(OnLineState.class, param.getOnLineState());
 
         HashMap<String, Object> map = new HashMap<>();
         map.put("lastOnlineTime", param.getLastOnlineTime());
         map.put("lastOfflineTime", param.getLastOfflineTime());
-        map.put("onLineState", CommonUtil.getEnumByName(OnLineState.class, param.getOnLineState()));
-        map.put("state", param.getState());
+        map.put("onLineState", onLineState);
+        if (param.getState() != null) {
+            map.put("state", param.getState());
+        }
         map.put("lastOnlineTimeStr", DateUtils.paresTime(param.getLastOnlineTime(), DateUtils.FORMAT_LONG));
 
         commonService.updateData(where, map, DeviceInfo.class.getSimpleName());
         commonService.updateData(where, map, DeviceBind.class.getSimpleName());
 
         HashMap<String, Object> bindMap = new HashMap<>();
-        bindMap.put("onLineState", CommonUtil.getEnumByName(OnLineState.class, param.getOnLineState()));
+        bindMap.put("onLineState", onLineState);
         commonService.updateData(where, bindMap, DevicePermiss.class.getSimpleName());
 
-        log.info("同步在线状态syncDeviceOnLineState: {}", param.getDeviceId());
+        log.info("同步在线状态syncDeviceOnLineState: {} {} {}", param.getDeviceId(),
+                DateUtils.paresTime(System.currentTimeMillis(), "HH:mm:ss SSS"),
+                onLineState);
         return ResultContent.buildSuccess();
     }
 
@@ -116,26 +117,4 @@ public class DeviceSyncFromIotService {
         return ResultContent.buildSuccess();
     }
 
-    /**
-     * 同步网关列表
-     *
-     * @param param
-     * @return
-     */
-    public ResultContent syncGateWays(GateWaySyncParam param) {
-        List<GateWaySyncParam.GateWaySyncInfo> list = param.getList();
-        log.info("syncGateWays: {}", list.size());
-        if (ObjectUtils.isNotEmpty(list)) {
-            for (GateWaySyncParam.GateWaySyncInfo syncInfo : list) {
-                ResultContent content = gateWayService.syncGateWayInfo(syncInfo);
-                if (content.isSuccess()) {
-                    log.info("同步网关成功:{}", syncInfo.getGateWayName());
-                } else {
-                    log.warn("同步网关失败:{}", content.getMsg());
-                }
-            }
-        }
-        return ResultContent.buildSuccess();
-    }
-
 }

+ 0 - 132
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/GateWayInfoServiceImpl.java

@@ -1,132 +0,0 @@
-package com.zhongshu.card.server.core.service.devices;
-
-import com.github.microservice.components.data.base.util.PageEntityUtil;
-import com.github.microservice.models.device.GateWaySyncParam;
-import com.zhongshu.card.client.model.devices.GateWayInfoModel;
-import com.zhongshu.card.client.model.devices.GateWayInfoParam;
-import com.zhongshu.card.client.model.devices.GateWayInfoSearch;
-import com.github.microservice.net.ResultContent;
-import com.zhongshu.card.client.service.school.GateWayInfoService;
-import com.zhongshu.card.server.core.dao.org.OrganizationDao;
-import com.zhongshu.card.server.core.dao.school.AreaDao;
-import com.zhongshu.card.server.core.dao.devices.GateWayInfoDao;
-import com.zhongshu.card.server.core.domain.school.Area;
-import com.zhongshu.card.server.core.domain.devices.GateWayInfo;
-import com.zhongshu.card.server.core.service.base.SuperService;
-import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
-import com.zhongshu.card.server.core.service.school.AreaServiceImpl;
-import com.zhongshu.card.server.core.util.BeanUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.ObjectUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.stereotype.Service;
-import org.springframework.util.Assert;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * @author TRX
- * @date 2024/7/2
- */
-@Slf4j
-@Service
-public class GateWayInfoServiceImpl extends SuperService implements GateWayInfoService {
-
-    @Autowired
-    GateWayInfoDao gateWayInfoDao;
-
-    @Autowired
-    AreaDao areaDao;
-
-    @Autowired
-    AreaServiceImpl areaService;
-
-    @Autowired
-    private OrganizationServiceImpl organizationServiceImpl;
-
-    @Autowired
-    OrganizationDao organizationDao;
-
-    /**
-     * 同步网关信息
-     *
-     * @param param
-     * @return
-     */
-    @Override
-    public ResultContent syncGateWayInfo(GateWaySyncParam.GateWaySyncInfo param) {
-        Assert.hasText(param.getGateWayId(), "gateWayId不能为空");
-        // 设备号
-        String gateWayId = param.getGateWayId();
-        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(gateWayId);
-        if (ObjectUtils.isNotEmpty(gateWayInfo)) {
-        } else {
-            gateWayInfo = new GateWayInfo();
-            initEntityNoCheckOid(gateWayInfo);
-        }
-        BeanUtils.copyProperties(param, gateWayInfo, "id");
-        gateWayInfo.setProjectInfoName(organizationServiceImpl.getOrgNameByCode(param.getProjectInfoCode()));
-        gateWayInfoDao.save(gateWayInfo);
-        return ResultContent.buildSuccess();
-    }
-
-    /**
-     * 修改网管的区域
-     *
-     * @param param
-     * @return
-     */
-    @Override
-    public ResultContent updateGateArea(GateWayInfoParam param) {
-        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
-        if (ObjectUtils.isEmpty(gateWayInfo)) {
-            return ResultContent.buildFail(String.format("网关不存在:%s", param.getGateWayId()));
-        }
-        Area area = areaDao.findTopById(param.getAreaId());
-        gateWayInfo.setArea(area);
-        gateWayInfoDao.save(gateWayInfo);
-        return ResultContent.buildSuccess();
-    }
-
-    @Override
-    public ResultContent<Page<GateWayInfoModel>> page(GateWayInfoSearch param, Pageable pageable) {
-        initOidSearchParamNoCheckOid(param);
-        Page<GateWayInfo> page = gateWayInfoDao.page(pageable, param);
-        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
-    }
-
-    @Override
-    public ResultContent<GateWayInfoModel> getGateWayInfo(String gateWayId) {
-        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(gateWayId);
-        if (ObjectUtils.isEmpty(gateWayInfo)) {
-            return ResultContent.buildFail(String.format("网关不存在:%s", gateWayId));
-        }
-        return ResultContent.buildSuccess(toModel(gateWayInfo));
-    }
-
-    @Override
-    public ResultContent<List<GateWayInfoModel>> getAllGateWayInfo() {
-        List<GateWayInfo> gateWayInfos = gateWayInfoDao.findAll();
-        List<GateWayInfoModel> models = new ArrayList<>();
-        if (ObjectUtils.isNotEmpty(gateWayInfos)) {
-            models = gateWayInfos.stream().map(this::toModel).collect(Collectors.toList());
-        }
-        return ResultContent.buildSuccess(models);
-    }
-
-    public GateWayInfoModel toModel(GateWayInfo entity) {
-        GateWayInfoModel model = null;
-        if (ObjectUtils.isNotEmpty(entity)) {
-            model = new GateWayInfoModel();
-            BeanUtils.copyProperties(entity, model);
-            // 区域
-            model.setArea(areaService.toModel(entity.getArea()));
-        }
-        return model;
-    }
-
-}

+ 5 - 3
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/permissVerify/DevicePermissVerifyService.java

@@ -1,8 +1,8 @@
 package com.zhongshu.card.server.core.service.permissVerify;
 
 import com.github.microservice.models.gateDoor.use.DeviceUseParam;
-import com.github.microservice.types.deviceUse.DeviceState;
 import com.github.microservice.net.ResultContent;
+import com.github.microservice.types.deviceUse.DeviceState;
 import com.zhongshu.card.client.model.devices.permiss.PermissSettingListSearch;
 import com.zhongshu.card.client.model.devices.permiss.TimeSlotModel;
 import com.zhongshu.card.client.model.devices.permiss.TimeSlotWeekModel;
@@ -97,7 +97,9 @@ public class DevicePermissVerifyService {
             if (userAccount.getState() != UserState.Normal) {
                 return ResultContent.buildFail("用户不可用");
             }
-            deviceUserParam.setUserName(userAccount.getName());
+            if (ObjectUtils.isNotEmpty(deviceUserParam)) {
+                deviceUserParam.setUserName(userAccount.getName());
+            }
             stopWatch.stop();
         }
 
@@ -116,7 +118,6 @@ public class DevicePermissVerifyService {
 
         boolean hasPermission = false;
         String projectOid = deviceInfo.getProjectOid();
-        deviceUserParam.setProjectOid(projectOid);
 
         if (isSystemUser) {
             // 系统用户类型
@@ -200,6 +201,7 @@ public class DevicePermissVerifyService {
         }
 
         if (ObjectUtils.isNotEmpty(deviceUserParam)) {
+            deviceUserParam.setProjectOid(projectOid);
             deviceUserParam.setUseTime(stopWatch.getTotalTimeMillis());
         }
         log.info("权限验证:{} {}", stopWatch.prettyPrint(), msg);