提交 de7de381 authored 作者: zhoushaopan's avatar zhoushaopan

[工作流模块] 新增了文件上传接口

上级 1e9eb789
...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -52,6 +53,12 @@ public class FlowsInfoController { ...@@ -52,6 +53,12 @@ public class FlowsInfoController {
return ResultUtil.success(flowsInfoList,"查询成功"); return ResultUtil.success(flowsInfoList,"查询成功");
} }
@PostMapping("/upLoadFile")
@ApiOperation(value = "上传文件")
public String upLoadFile(@RequestParam("file") MultipartFile file){
return workFlowService.upLoadFile(file);
}
@GetMapping("editFlow") @GetMapping("editFlow")
@ApiOperation(value = "编辑流程") @ApiOperation(value = "编辑流程")
public ResponseEntity editFlow(Integer id){ public ResponseEntity editFlow(Integer id){
......
...@@ -30,7 +30,7 @@ public interface WorkFlowService { ...@@ -30,7 +30,7 @@ public interface WorkFlowService {
* @param file file文件 * @param file file文件
* @return 路径名称 * @return 路径名称
*/ */
String saveXml(@RequestParam("file") MultipartFile file); String upLoadFile(@RequestParam("file") MultipartFile file);
/** /**
* 接收前端的流程文件 * 接收前端的流程文件
......
...@@ -96,7 +96,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -96,7 +96,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
@Override @Override
public String saveXml(@RequestParam("file") MultipartFile file) { public String upLoadFile(@RequestParam("file") MultipartFile file) {
String realPath = null; String realPath = null;
if (!file.isEmpty()) { if (!file.isEmpty()) {
//获取文件名 //获取文件名
...@@ -115,44 +115,6 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -115,44 +115,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
//解析xml
//1.创建Reader对象
SAXReader reader = new SAXReader();
//2.加载xml
Document document = null;
try {
document = reader.read(fileNew);
} catch (DocumentException e) {
e.printStackTrace();
}
//3.获取根节点
Element rootElement = document.getRootElement();
Iterator iterator = rootElement.elementIterator();
String processId = null;
String processName = null;
Element stu = (Element) iterator.next();
List<Attribute> attributes = stu.attributes();
System.out.println("======获取属性值======");
for (Attribute attribute : attributes) {
if ("id".equals(attribute.getName())) {
processId = attribute.getValue();
System.out.println("processId的值是:" + processId);
}
if ("name".equals(attribute.getName())) {
processName = attribute.getValue();
System.out.println("processName的值是:" + processName);
}
}
//保存processId和processName 到数据库里面
FlowsInfo flowsInfo = new FlowsInfo();
flowsInfo.setFlowKey(processId);
flowsInfo.setFlowName(processName);
flowsInfo.setResourceName(file.getOriginalFilename());
//状态为未部署
flowsInfo.setState(1);
flowsInfo.setFilePath(realPath);
flowsInfoMapper.save(flowsInfo);
} }
return realPath; return realPath;
} }
...@@ -330,7 +292,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -330,7 +292,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
if (taskVo.getComments() != null) { if (taskVo.getComments() != null) {
taskService.addComment(task.getId(), processInstanceId, taskVo.getComments()); taskService.addComment(task.getId(), processInstanceId, taskVo.getComments());
} }
//先判断 //先判断
if (taskVo.getHandlingOpinion() != null){ if (taskVo.getHandlingOpinion() != null){
taskVo.getMap().put("handlingOpinion", taskVo.getHandlingOpinion()); taskVo.getMap().put("handlingOpinion", taskVo.getHandlingOpinion());
} }
......
...@@ -495,4 +495,8 @@ class WorkflowCoreApplicationTests_workflow { ...@@ -495,4 +495,8 @@ class WorkflowCoreApplicationTests_workflow {
.andDo(print());//打印输出结果 .andDo(print());//打印输出结果
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论