|
@@ -18,6 +18,9 @@ import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.IotTreeMapper;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.google.common.collect.ImmutableList;
|
|
@@ -150,7 +153,6 @@ public class IotInfoServiceImpl implements IotInfoService {
|
|
|
deptName = dept.getName();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
importFileTree(createReqVO.getFolderJson(), classId, deptId, createReqVO.getDeviceId(), deviceCode, deptName);
|
|
|
|
|
|
// List<IotInfoDO> collect = createReqVO.getFileList().stream().map(e -> {
|
|
@@ -287,9 +289,15 @@ public class IotInfoServiceImpl implements IotInfoService {
|
|
|
for (JsonNode itemNode : rootNode) {
|
|
|
// 处理文件夹结构
|
|
|
JsonNode folderStructureNode = itemNode.get("folderStructure");
|
|
|
+ JsonNode files = itemNode.get("files");
|
|
|
+ List<String> fileNames = new ArrayList<>();
|
|
|
+ files.forEach(file -> {
|
|
|
+ String name = file.get("name").asText();
|
|
|
+ fileNames.add(name);
|
|
|
+ });
|
|
|
Long fileClassId = null;
|
|
|
if (folderStructureNode != null) {
|
|
|
- fileClassId = processFolderStructure(folderStructureNode, parentId, deptId, deviceCode, deptName);
|
|
|
+ fileClassId = processFolderStructure(folderStructureNode, parentId, deptId, deviceCode, deptName, fileNames);
|
|
|
}
|
|
|
|
|
|
// todo 处理文件
|
|
@@ -353,7 +361,7 @@ public class IotInfoServiceImpl implements IotInfoService {
|
|
|
* @param deptId 部门ID
|
|
|
* @return 遇到包含"."的文件夹时返回其parentId,否则返回null
|
|
|
*/
|
|
|
- private Long processFolderStructure(JsonNode folderStructureNode, Long parentId, Long deptId, String deviceCode, String deptName) {
|
|
|
+ private Long processFolderStructure(JsonNode folderStructureNode, Long parentId, Long deptId, String deviceCode, String deptName, List<String> fileNames) {
|
|
|
Iterator<String> fieldNames = folderStructureNode.fieldNames();
|
|
|
|
|
|
while (fieldNames.hasNext()) {
|
|
@@ -361,10 +369,12 @@ public class IotInfoServiceImpl implements IotInfoService {
|
|
|
JsonNode folderNode = folderStructureNode.get(folderName);
|
|
|
|
|
|
// 检查文件夹名是否包含".",如果是则返回当前parentId
|
|
|
- if (folderName.contains(".")) {
|
|
|
- return parentId; // 返回当前节点的父ID
|
|
|
+// if (folderName.contains(".")) {
|
|
|
+// return parentId; // 返回当前节点的父ID
|
|
|
+// }
|
|
|
+ if (fileNames.contains(folderName)) {
|
|
|
+ return parentId;
|
|
|
}
|
|
|
-
|
|
|
// 查询是否已存在同名同父节点的记录
|
|
|
IotTreeDO iotTreeDO = iotTreeMapper.selectOne("name", folderName, "parent_id", parentId);
|
|
|
|
|
@@ -389,7 +399,7 @@ public class IotInfoServiceImpl implements IotInfoService {
|
|
|
JsonNode childrenNode = folderNode.get("children");
|
|
|
if (childrenNode != null && !childrenNode.isNull() && !childrenNode.isEmpty()) {
|
|
|
// 递归调用,如果子节点处理中返回了parentId,则向上传递
|
|
|
- Long result = processFolderStructure(childrenNode, currentNodeId, deptId, deviceCode, deptName);
|
|
|
+ Long result = processFolderStructure(childrenNode, currentNodeId, deptId, deviceCode, deptName, fileNames);
|
|
|
if (result != null) {
|
|
|
return result; // 子节点处理中遇到了目标,返回结果
|
|
|
}
|