吉安感知网项目-后端
linwei
2026-07-08 442f8cf748c2191213ed93ccdd2633ac4f02e038
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/service/impl/GdManageDeviceServiceImpl.java
@@ -325,7 +325,8 @@
      entity.setInsureExpiredTime(parseInsuranceDate(item.getInsuranceInfo()));
      entity.setAreaCode(extractAreaCode(item.getRegionCode()));
      entity.setIsWithDock(item.getIsWithDock());
      entity.setCreateDept(item.getDeptId());
      entity.setCreateDept(parseDeptId(item.getDeptId()));
      entity.setMaintenanceState(item.getMaintenanceState());
      entity.setDevicePayload(
         Optional.ofNullable(item.getLoadList())
            .orElse(Collections.emptyList())
@@ -364,7 +365,8 @@
      entity.setInsureExpiredTime(parseInsuranceDate(item.getInsuranceInfo()));
      entity.setAreaCode(extractAreaCode(item.getRegionCode()));
      entity.setHeight(item.getHeight());
      entity.setCreateDept(item.getDeptId());
      entity.setCreateDept(parseDeptId(item.getDeptId()));
      entity.setMaintenanceState(item.getMaintenanceState());
      return entity;
   }
@@ -463,6 +465,30 @@
   }
   /**
    * 解析部门ID字符串,处理逗号分隔的情况
    * 星图接口可能返回逗号分隔的多个部门ID,这里只取第一个
    *
    * @param deptIdStr 部门ID字符串,可能包含逗号分隔的多个ID
    * @return 第一个部门ID,解析失败返回null
    */
   private Long parseDeptId(String deptIdStr) {
      // 1. 参数校验
      if (StringUtil.isBlank(deptIdStr)) {
         return null;
      }
      try {
         // 2. 处理逗号分隔的情况,只取第一个ID
         String firstDeptId = deptIdStr.split(",")[0].trim();
         // 3. 转换为Long类型
         return Long.valueOf(firstDeptId);
      } catch (NumberFormatException e) {
         // 4. 记录日志并返回null
         log.warn("解析部门ID失败,deptIdStr: {}", deptIdStr, e);
         return null;
      }
   }
   /**
    * 解析星图接口返回的列表数据
    *
    * @param response 接口响应