|
@@ -78,20 +78,19 @@ public class QhseInfoServiceImpl implements QhseInfoService {
|
|
|
String deviceCode = "";
|
|
String deviceCode = "";
|
|
|
String deptName = "";
|
|
String deptName = "";
|
|
|
|
|
|
|
|
- QhseFileTreeDO iotTreeDO = qhseFileTreeMapper.selectById(createReqVO.getClassId());
|
|
|
|
|
- deptId = Long.valueOf(iotTreeDO.getDeptId());
|
|
|
|
|
|
|
+ deptId = createReqVO.getDeptId();
|
|
|
if (Objects.nonNull(deptId)) {
|
|
if (Objects.nonNull(deptId)) {
|
|
|
DeptRespDTO dept = deptApi.getDept(deptId);
|
|
DeptRespDTO dept = deptApi.getDept(deptId);
|
|
|
if (Objects.nonNull(dept)) {
|
|
if (Objects.nonNull(dept)) {
|
|
|
deptName = dept.getName();
|
|
deptName = dept.getName();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- importFileTree(createReqVO.getFolderJson(), classId, deptId, createReqVO.getDeviceId(), deviceCode, deptName);
|
|
|
|
|
|
|
+ importFileTree(createReqVO.getFolderJson(), classId, deptId, deptName);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- public void importFileTree(String jsonData, Long parentId, Long deptId, Long deviceId, String deviceCode, String deptName) {
|
|
|
|
|
|
|
+ public void importFileTree(String jsonData, Long parentId, Long deptId, String deptName) {
|
|
|
try {
|
|
try {
|
|
|
// 解析JSON数组
|
|
// 解析JSON数组
|
|
|
JsonNode rootNode = objectMapper.readTree(jsonData);
|
|
JsonNode rootNode = objectMapper.readTree(jsonData);
|
|
@@ -110,13 +109,13 @@ public class QhseInfoServiceImpl implements QhseInfoService {
|
|
|
});
|
|
});
|
|
|
Long fileClassId = null;
|
|
Long fileClassId = null;
|
|
|
if (folderStructureNode != null) {
|
|
if (folderStructureNode != null) {
|
|
|
- fileClassId = processFolderStructure(folderStructureNode, parentId, deptId, deviceCode, deptName, fileNames);
|
|
|
|
|
|
|
+ fileClassId = processFolderStructure(folderStructureNode, parentId, deptId, deptName, fileNames);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// todo 处理文件
|
|
// todo 处理文件
|
|
|
JsonNode filesNode = itemNode.get("files");
|
|
JsonNode filesNode = itemNode.get("files");
|
|
|
if (filesNode != null && filesNode.isArray()&&Objects.nonNull(fileClassId)) {
|
|
if (filesNode != null && filesNode.isArray()&&Objects.nonNull(fileClassId)) {
|
|
|
- processFiles(filesNode, parentId, fileClassId, deviceId, deptId, deviceCode, deptName);
|
|
|
|
|
|
|
+ processFiles(filesNode, parentId, fileClassId, deptId, deptName);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -129,7 +128,7 @@ public class QhseInfoServiceImpl implements QhseInfoService {
|
|
|
/**
|
|
/**
|
|
|
* 处理文件
|
|
* 处理文件
|
|
|
*/
|
|
*/
|
|
|
- private void processFiles(JsonNode filesNode, Long rootParentId,Long fileClassId, Long deviceId, Long deptId, String deviceCode, String deptName) {
|
|
|
|
|
|
|
+ private void processFiles(JsonNode filesNode, Long rootParentId,Long fileClassId, Long deptId, String deptName) {
|
|
|
for (JsonNode fileNode : filesNode) {
|
|
for (JsonNode fileNode : filesNode) {
|
|
|
String path = fileNode.get("path").asText();
|
|
String path = fileNode.get("path").asText();
|
|
|
String filePath = fileNode.get("filePath").asText();
|
|
String filePath = fileNode.get("filePath").asText();
|
|
@@ -150,12 +149,10 @@ public class QhseInfoServiceImpl implements QhseInfoService {
|
|
|
QhseInfoDO iotInfoDO = qhseInfoMapper.selectOne("filename", fileName, "class_id", fileClassId);
|
|
QhseInfoDO iotInfoDO = qhseInfoMapper.selectOne("filename", fileName, "class_id", fileClassId);
|
|
|
if (iotInfoDO == null) {
|
|
if (iotInfoDO == null) {
|
|
|
QhseInfoDO info = new QhseInfoDO();
|
|
QhseInfoDO info = new QhseInfoDO();
|
|
|
- info.setDeviceId(deviceId);
|
|
|
|
|
info.setDeptId(deptId);
|
|
info.setDeptId(deptId);
|
|
|
info.setClassId(fileClassId);
|
|
info.setClassId(fileClassId);
|
|
|
info.setFilename(fileName);
|
|
info.setFilename(fileName);
|
|
|
info.setDeleted(false);
|
|
info.setDeleted(false);
|
|
|
- info.setDeviceCode(deviceCode);
|
|
|
|
|
info.setDeptName(deptName);
|
|
info.setDeptName(deptName);
|
|
|
info.setFileType("file");
|
|
info.setFileType("file");
|
|
|
if (fileName.contains("jpg")||fileName.contains("jpeg")||fileName.contains("png")||fileName.contains("gif")) {
|
|
if (fileName.contains("jpg")||fileName.contains("jpeg")||fileName.contains("png")||fileName.contains("gif")) {
|
|
@@ -188,7 +185,7 @@ public class QhseInfoServiceImpl implements QhseInfoService {
|
|
|
return folder.getId();
|
|
return folder.getId();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Long processFolderStructure(JsonNode folderStructureNode, Long parentId, Long deptId, String deviceCode, String deptName, List<String> fileNames) {
|
|
|
|
|
|
|
+ private Long processFolderStructure(JsonNode folderStructureNode, Long parentId, Long deptId, String deptName, List<String> fileNames) {
|
|
|
Iterator<String> fieldNames = folderStructureNode.fieldNames();
|
|
Iterator<String> fieldNames = folderStructureNode.fieldNames();
|
|
|
|
|
|
|
|
while (fieldNames.hasNext()) {
|
|
while (fieldNames.hasNext()) {
|
|
@@ -216,7 +213,6 @@ public class QhseInfoServiceImpl implements QhseInfoService {
|
|
|
folder.setDeleted(false);
|
|
folder.setDeleted(false);
|
|
|
folder.setType("file");
|
|
folder.setType("file");
|
|
|
folder.setDeptId(Math.toIntExact(deptId));
|
|
folder.setDeptId(Math.toIntExact(deptId));
|
|
|
- folder.setDeviceCode(deviceCode);
|
|
|
|
|
folder.setDeptName(deptName);
|
|
folder.setDeptName(deptName);
|
|
|
qhseFileTreeMapper.insert(folder);
|
|
qhseFileTreeMapper.insert(folder);
|
|
|
currentNodeId = folder.getId();
|
|
currentNodeId = folder.getId();
|
|
@@ -226,7 +222,7 @@ public class QhseInfoServiceImpl implements QhseInfoService {
|
|
|
JsonNode childrenNode = folderNode.get("children");
|
|
JsonNode childrenNode = folderNode.get("children");
|
|
|
if (childrenNode != null && !childrenNode.isNull() && !childrenNode.isEmpty()) {
|
|
if (childrenNode != null && !childrenNode.isNull() && !childrenNode.isEmpty()) {
|
|
|
// 递归调用,如果子节点处理中返回了parentId,则向上传递
|
|
// 递归调用,如果子节点处理中返回了parentId,则向上传递
|
|
|
- Long result = processFolderStructure(childrenNode, currentNodeId, deptId, deviceCode, deptName, fileNames);
|
|
|
|
|
|
|
+ Long result = processFolderStructure(childrenNode, currentNodeId, deptId, deptName, fileNames);
|
|
|
if (result != null) {
|
|
if (result != null) {
|
|
|
return result; // 子节点处理中遇到了目标,返回结果
|
|
return result; // 子节点处理中遇到了目标,返回结果
|
|
|
}
|
|
}
|