1、onlyoffice回调接口
2、优化导出任务树
This commit is contained in:
@@ -91,6 +91,9 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
|
||||
String firstNodeTag;
|
||||
|
||||
List<String> nodeTypeList = Arrays.asList(NodeTypeEnum.MACHINE.getValue(),NodeTypeEnum.WORKSPACE.getValue(),NodeTypeEnum.DISCIPLINE.getValue(),NodeTypeEnum.TASK.getValue(),NodeTypeEnum.PERFORMANCE.getValue());
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public SdmResponse add(JSONObject jsonObject) {
|
||||
@@ -1974,16 +1977,116 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
List<ExportExcelFormat> exportExcelFormats = taskTreeExportExcelFormat.getExcelHeaders();
|
||||
SdmResponse taskRespond = getTaskTree(req);
|
||||
SdmResponse response = new SdmResponse();
|
||||
List<ProjectNodePo> allTopProjectNodeList = new ArrayList<>();
|
||||
if(taskRespond.isSuccess()) {
|
||||
List<ProjectNodePo> realTopProjectNodeList = (List<ProjectNodePo>) taskRespond.getData();
|
||||
if (CollectionUtils.isEmpty(realTopProjectNodeList)) {
|
||||
return response;
|
||||
}
|
||||
ExcelUtil.exportExcelWithMerge(JSONArray.from(taskRespond.getData()),exportExcelFormats,httpServletResponse);
|
||||
// 补充空节点,暂时定死顺序:机台——》工位——》学科——》任务——》指标
|
||||
for (ProjectNodePo projectNodePo : realTopProjectNodeList) {
|
||||
if (NodeTypeEnum.MACHINE.getValue().equals(projectNodePo.getNodeType())) {
|
||||
fillChildrenNode(projectNodePo);
|
||||
allTopProjectNodeList.add(projectNodePo);
|
||||
continue;
|
||||
}
|
||||
// 先补全前面类型节点
|
||||
ProjectNodePo machineNode = new ProjectNodePo();
|
||||
if (NodeTypeEnum.WORKSPACE.getValue().equals(projectNodePo.getNodeType())) {
|
||||
machineNode.setNodeName(" ");
|
||||
machineNode.setNodeCode(" ");
|
||||
machineNode.setNodeType(NodeTypeEnum.MACHINE.getValue());
|
||||
machineNode.setChildren(Collections.singletonList(projectNodePo));
|
||||
fillChildrenNode(machineNode);
|
||||
}else if (NodeTypeEnum.DISCIPLINE.getValue().equals(projectNodePo.getNodeType())) {
|
||||
machineNode.setNodeName(" ");
|
||||
machineNode.setNodeCode(" ");
|
||||
machineNode.setNodeType(NodeTypeEnum.MACHINE.getValue());
|
||||
NodeAllBase workspaceNode = new ProjectNodePo();
|
||||
workspaceNode.setNodeName(" ");
|
||||
workspaceNode.setNodeCode(" ");
|
||||
workspaceNode.setNodeType(NodeTypeEnum.WORKSPACE.getValue());
|
||||
workspaceNode.setChildren(Collections.singletonList(projectNodePo));
|
||||
machineNode.setChildren(Collections.singletonList(workspaceNode));
|
||||
fillChildrenNode(machineNode);
|
||||
}else if (NodeTypeEnum.TASK.getValue().equals(projectNodePo.getNodeType())) {
|
||||
machineNode.setNodeName(" ");
|
||||
machineNode.setNodeCode(" ");
|
||||
machineNode.setNodeType(NodeTypeEnum.MACHINE.getValue());
|
||||
ProjectNodePo workspaceNode = new ProjectNodePo();
|
||||
workspaceNode.setNodeName(" ");
|
||||
workspaceNode.setNodeCode(" ");
|
||||
workspaceNode.setNodeType(NodeTypeEnum.WORKSPACE.getValue());
|
||||
ProjectNodePo disciplineNode = new ProjectNodePo();
|
||||
disciplineNode.setNodeName(" ");
|
||||
disciplineNode.setNodeCode(" ");
|
||||
disciplineNode.setNodeType(NodeTypeEnum.DISCIPLINE.getValue());
|
||||
disciplineNode.setChildren(Collections.singletonList(projectNodePo));
|
||||
workspaceNode.setChildren(Collections.singletonList(disciplineNode));
|
||||
machineNode.setChildren(Collections.singletonList(workspaceNode));
|
||||
fillChildrenNode(machineNode);
|
||||
}
|
||||
allTopProjectNodeList.add(machineNode);
|
||||
}
|
||||
ExcelUtil.exportExcelWithMerge(JSONArray.from(allTopProjectNodeList),exportExcelFormats,httpServletResponse,taskTreeExportExcelFormat.getHiddenList());
|
||||
} else {
|
||||
response = SdmResponse.failed(taskRespond.getMessage());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
private NodeAllBase fillChildrenNode(NodeAllBase projectNodePo) {
|
||||
String nodeType = projectNodePo.getNodeType();
|
||||
if (StringUtils.isBlank(projectNodePo.getNodeCode())) {
|
||||
projectNodePo.setNodeCode(" ");
|
||||
}
|
||||
if (NodeTypeEnum.DISCIPLINE.getValue().equals(nodeType)) {
|
||||
return projectNodePo;
|
||||
}
|
||||
List<NodeAllBase> childrenNodeList = projectNodePo.getChildren();
|
||||
if (CollectionUtils.isEmpty(childrenNodeList)) {
|
||||
return projectNodePo;
|
||||
}
|
||||
String childrenNodeType = nodeTypeList.get(nodeTypeList.indexOf(nodeType) + 1);
|
||||
List<Long> removeIdList = new ArrayList<>();
|
||||
List<ProjectNodePo> newNodeList = new ArrayList<>();
|
||||
for (NodeAllBase childNode : childrenNodeList) {
|
||||
if (childrenNodeType.equals(childNode.getNodeType()) && CollectionUtils.isEmpty(childNode.getChildren())) {
|
||||
continue;
|
||||
}
|
||||
if (!childrenNodeType.equals(childNode.getNodeType())) {
|
||||
ProjectNodePo emptyNode = new ProjectNodePo();
|
||||
emptyNode.setNodeName(" ");
|
||||
emptyNode.setNodeCode(" ");
|
||||
emptyNode.setNodeType(childrenNodeType);
|
||||
if (CollectionUtils.isEmpty(childNode.getChildren())) {
|
||||
emptyNode.setChildren(Collections.singletonList(childNode));
|
||||
// childNode = emptyNode;
|
||||
}else {
|
||||
emptyNode.setChildren(Collections.singletonList(fillChildrenNode(childNode)));
|
||||
// childNode = emptyNode;
|
||||
}
|
||||
removeIdList.add(childNode.getId());
|
||||
newNodeList.add(emptyNode);
|
||||
}else {
|
||||
fillChildrenNode(childNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(removeIdList)) {
|
||||
Iterator<NodeAllBase> iterator = childrenNodeList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
NodeAllBase nodeAllBase = iterator.next();
|
||||
if (removeIdList.contains(nodeAllBase.getId())) { // 假设我们想删除所有偶数
|
||||
iterator.remove(); // 使用迭代器的remove方法安全删除元素
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(newNodeList)) {
|
||||
childrenNodeList.addAll(newNodeList);
|
||||
}
|
||||
return projectNodePo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user