|
@@ -6,10 +6,6 @@ import com.warm.flow.core.service.DefService;
|
|
import com.warm.flow.core.utils.page.Page;
|
|
import com.warm.flow.core.utils.page.Page;
|
|
import com.warm.flow.orm.entity.FlowDefinition;
|
|
import com.warm.flow.orm.entity.FlowDefinition;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
-import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
-import org.dom4j.Document;
|
|
|
|
-import org.dom4j.io.OutputFormat;
|
|
|
|
-import org.dom4j.io.XMLWriter;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -19,7 +15,6 @@ import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
@@ -54,7 +49,6 @@ public class DefController {
|
|
@PostMapping
|
|
@PostMapping
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Boolean add(@RequestBody FlowDefinition flowDefinition) {
|
|
public Boolean add(@RequestBody FlowDefinition flowDefinition) {
|
|
- flowDefinition.setActivityStatus(0);
|
|
|
|
return defService.checkAndSave(flowDefinition);
|
|
return defService.checkAndSave(flowDefinition);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,7 +66,7 @@ public class DefController {
|
|
*/
|
|
*/
|
|
@DeleteMapping("/{id}")
|
|
@DeleteMapping("/{id}")
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public boolean remove(@PathVariable(name = "id", required = true) Long id) {
|
|
|
|
|
|
+ public boolean remove(@PathVariable(name = "id") Long id) {
|
|
return defService.removeDef(Collections.singletonList(id));
|
|
return defService.removeDef(Collections.singletonList(id));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -95,6 +89,22 @@ public class DefController {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 激活流程
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/active/{definitionId}")
|
|
|
|
+ public Boolean active(@PathVariable("definitionId") Long definitionId) {
|
|
|
|
+ return defService.active(definitionId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 挂起流程
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/unActive/{definitionId}")
|
|
|
|
+ public Boolean unActive(@PathVariable("definitionId") Long definitionId) {
|
|
|
|
+ return defService.unActive(definitionId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 保存流程定义
|
|
* 保存流程定义
|
|
*/
|
|
*/
|
|
@PostMapping("/saveXml")
|
|
@PostMapping("/saveXml")
|
|
@@ -112,34 +122,9 @@ public class DefController {
|
|
return defService.copyDef(id);
|
|
return defService.copyDef(id);
|
|
}
|
|
}
|
|
|
|
|
|
- @PostMapping("/importDefinition")
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public void importDefinition(MultipartFile file) throws Exception {
|
|
|
|
- defService.importXml(file.getInputStream());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @PostMapping("/exportDefinition/{id}")
|
|
|
|
- public void exportDefinition(@PathVariable("id") Long id, HttpServletResponse response) throws Exception {
|
|
|
|
- Document document = defService.exportXml(id);
|
|
|
|
- // 设置生成xml的格式
|
|
|
|
- OutputFormat of = OutputFormat.createPrettyPrint();
|
|
|
|
- // 设置编码格式
|
|
|
|
- of.setEncoding("UTF-8");
|
|
|
|
- of.setIndent(true);
|
|
|
|
- of.setIndent(" ");
|
|
|
|
- of.setNewlines(true);
|
|
|
|
-
|
|
|
|
- // 创建一个xml文档编辑器
|
|
|
|
- XMLWriter writer = new XMLWriter(response.getOutputStream(), of);
|
|
|
|
- writer.setEscapeText(false);
|
|
|
|
- response.reset();
|
|
|
|
- response.setCharacterEncoding("UTF-8");
|
|
|
|
- response.setContentType("application/x-msdownload");
|
|
|
|
- response.setHeader("Content-Disposition", "attachment;");
|
|
|
|
- writer.write(document);
|
|
|
|
- writer.close();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取流程xml定义字符串
|
|
|
|
+ */
|
|
@GetMapping("/xmlString/{id}")
|
|
@GetMapping("/xmlString/{id}")
|
|
public String xmlString(@PathVariable("id") Long id) {
|
|
public String xmlString(@PathVariable("id") Long id) {
|
|
return defService.xmlString(id);
|
|
return defService.xmlString(id);
|
|
@@ -148,33 +133,17 @@ public class DefController {
|
|
/**
|
|
/**
|
|
* 查询流程图
|
|
* 查询流程图
|
|
*/
|
|
*/
|
|
- @GetMapping("/flowChartNoColor/{definitionId}")
|
|
|
|
- public String flowChartNoColor(@PathVariable("definitionId") Long definitionId) throws IOException {
|
|
|
|
- return defService.flowChartNoColor(definitionId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询流程图
|
|
|
|
- */
|
|
|
|
@GetMapping("/flowChart/{instanceId}")
|
|
@GetMapping("/flowChart/{instanceId}")
|
|
public String flowChart(@PathVariable("instanceId") Long instanceId) throws IOException {
|
|
public String flowChart(@PathVariable("instanceId") Long instanceId) throws IOException {
|
|
return defService.flowChart(instanceId);
|
|
return defService.flowChart(instanceId);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 激活流程
|
|
|
|
- */
|
|
|
|
- @GetMapping("/active/{definitionId}")
|
|
|
|
- public Boolean active(@PathVariable("definitionId") Long definitionId) {
|
|
|
|
- return defService.active(definitionId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 挂起流程
|
|
|
|
|
|
+ * 查询流程图
|
|
*/
|
|
*/
|
|
- @GetMapping("/unActive/{definitionId}")
|
|
|
|
- public Boolean unActive(@PathVariable("definitionId") Long definitionId) {
|
|
|
|
- return defService.unActive(definitionId);
|
|
|
|
|
|
+ @GetMapping("/flowChartNoColor/{definitionId}")
|
|
|
|
+ public String flowChartNoColor(@PathVariable("definitionId") Long definitionId) throws IOException {
|
|
|
|
+ return defService.flowChartNoColor(definitionId);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|