Commit f81068b9 authored by neo's avatar neo

[dev] add aprroval some demo impl and moco db

parent 2f88c13b
......@@ -11,6 +11,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.approval.ApprovalDto;
import pwc.taxtech.atms.dto.approval.ApprovalTask;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
......@@ -20,9 +22,9 @@ import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/api/v1/leave")
public class LeaveController {
private static Logger logger = LoggerFactory.getLogger(LeaveController.class);
@RequestMapping(value = "/api/v1/approval")
public class ApprovalController {
private static Logger logger = LoggerFactory.getLogger(ApprovalController.class);
@Autowired
RuntimeService runtimeService;
@Autowired
......@@ -32,40 +34,56 @@ public class LeaveController {
@ResponseBody
@RequestMapping(value = "/deploy", method = RequestMethod.POST)
public ResponseEntity deploy(){
repositoryService.createDeployment().addClasspathResource("bpmn/leave.bpmn").deploy();
return ResponseEntity.ok().build();
public ResponseEntity deploy() {
repositoryService.createDeployment().addClasspathResource("bpmn/approval.bpmn").deploy();
return ResponseEntity.ok().build();
}
@ResponseBody
@RequestMapping(value = "/save", method = RequestMethod.POST)
public Leave save(@RequestBody Leave user) {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("leaveProcess");
user.setInstaceId(pi.getId());
insert(user);//todo use service insert
return user;
@RequestMapping(value = "/commit", method = RequestMethod.POST)
public ApprovalDto approval(@RequestBody ApprovalDto dto) {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("approvalProcess");
dto.setInstaceId(pi.getId());
mocoInsert(dto);//todo use service insert
return dto;
}
@ResponseBody
@RequestMapping(value = "/data/{assignee}")
public List<MyTask> data(@PathVariable String assignee) {
@RequestMapping(value = "/tasks/{assignee}")
public List<ApprovalTask> data(@PathVariable String assignee) {
List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).list();
List<MyTask> list = new ArrayList<>();
List<ApprovalTask> list = new ArrayList<>();
for (Task task : tasks) {
MyTask t = new MyTask();
t.setTaskId(task.getId());
t.setName(task.getName());
t.setAssignee(task.getAssignee());
t.setExecutionId(task.getExecutionId());
t.setProcessInstanceId(task.getProcessInstanceId());
t.setProcessDefinitionId(task.getProcessDefinitionId());
list.add(t);
ApprovalTask t = new ApprovalTask();
list.add(t.copyfrom(task));
}
return list;
}
@RequestMapping(value = "/shwoImg/{procDefId}")//获取流程图
public void shwoImg(@PathVariable String procDefId, HttpServletResponse response) {
@ResponseBody
@RequestMapping(value = "/check/{taskId}")
public String check(@PathVariable String taskId, @RequestParam Integer committed, @RequestParam Integer decide) {
Map<String, Object> map = new HashMap<>();
if (committed != null) {
map.put("committed", committed);
taskService.complete(taskId, map);
if(committed==1)mocoHasCommittedAndOver();
} else if (decide != null) {
map.put("decide", decide);
taskService.complete(taskId, map);
if(decide==1)mocoAggreAndOver();
else mocoDisAggreAndOver();
}
return taskId;
}
private void mocoHasCommitted() {
}
@RequestMapping(value = "/show/{procDefId}")//获取流程图
public void showImg(@PathVariable String procDefId, HttpServletResponse response) {
try {
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
String diagramResourceName = pd.getDiagramResourceName();
......@@ -83,7 +101,7 @@ public class LeaveController {
@ResponseBody
@RequestMapping(value = "/showImg/{procDefId}/{executionId}")//获取流程坐标
public Rect showImg(@PathVariable String procDefId,@PathVariable String executionId ) {
public Rect showImg(@PathVariable String procDefId, @PathVariable String executionId) {
Rect rect = new Rect();
try {
repositoryService.getProcessDefinition(procDefId);
......@@ -98,17 +116,8 @@ public class LeaveController {
return rect;
}
@ResponseBody
@RequestMapping(value = "/check/{taskId}")
public String check(@PathVariable String taskId) {
Map<String, Object> map = new HashMap<>();
map.put("day", 3);
taskService.complete(taskId,map);
logger.debug("success ...........");
return taskId;
}
static class Rect{
static class Rect {
String X;
String Y;
String width;
......@@ -148,115 +157,29 @@ public class LeaveController {
}
static class MyTask {
String taskId;
String name;
String assignee;
String executionId;
String processInstanceId;
String processDefinitionId;
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAssignee() {
return assignee;
}
public void setAssignee(String assignee) {
this.assignee = assignee;
}
public String getExecutionId() {
return executionId;
}
public void setExecutionId(String executionId) {
this.executionId = executionId;
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
public void setProcessDefinitionId(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
private void mocoDisAggreAndOver() {
logger.debug("------------------------update db -----------------------------------");
logger.debug("dis aggre");
logger.debug("------------------------updage db-----------------------------------");
}
static class Leave {
String name;
Integer day;
String leaveReason;
String instaceId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getDay() {
return day;
}
public void setDay(Integer day) {
this.day = day;
}
public String getLeaveReason() {
return leaveReason;
}
public void setLeaveReason(String leaveReason) {
this.leaveReason = leaveReason;
}
public String getInstaceId() {
return instaceId;
}
public void setInstaceId(String instaceId) {
this.instaceId = instaceId;
}
private void mocoAggreAndOver() {
logger.debug("------------------------update db-----------------------------------");
logger.debug("aggree");
logger.debug("------------------------update db-----------------------------------");
}
@Override
public String toString() {
return "Leave{" +
"name='" + name + '\'' +
", day=" + day +
", leaveReason='" + leaveReason + '\'' +
", instaceId='" + instaceId + '\'' +
'}';
}
private void mocoHasCommittedAndOver() {
logger.debug("-------------------------update db----------------------------------");
logger.debug("has committed");
logger.debug("-------------------------update db----------------------------------");
}
private void insert(Leave leave) {
logger.debug("save leave info {}", leave.toString());
private void mocoInsert(ApprovalDto dto) {
logger.debug("-------------------------insert db----------------------------------");
logger.debug("save approval {}", dto.toString());
logger.debug("-------------------------insert db----------------------------------");
}
}
package pwc.taxtech.atms.dto.approval;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ApprovalDto {
private String projectId;
private Long reportId;
private Integer period;
private String instaceId;
private String status;//committed,agreed,disagreed
@Override
public String toString() {
return "ApprovalDto{" +
"projectId='" + projectId + '\'' +
", reportId=" + reportId +
", period=" + period +
", instaceId='" + instaceId + '\'' +
", status='" + status + '\'' +
'}';
}
}
package pwc.taxtech.atms.dto.approval;
import lombok.Getter;
import lombok.Setter;
import org.activiti.engine.task.Task;
import pwc.taxtech.atms.controller.ApprovalController;
@Getter
@Setter
public class ApprovalTask {
private String taskId;
private String name;
private String assignee;
private String executionId;
private String processInstanceId;
private String processDefinitionId;
@Override
public String toString() {
return "ApprovalTask{" +
"taskId='" + taskId + '\'' +
", name='" + name + '\'' +
", assignee='" + assignee + '\'' +
", executionId='" + executionId + '\'' +
", processInstanceId='" + processInstanceId + '\'' +
", processDefinitionId='" + processDefinitionId + '\'' +
'}';
}
public ApprovalTask copyfrom(Task task) {
setTaskId(task.getId());
setName(task.getName());
setAssignee(task.getAssignee());
setExecutionId(task.getExecutionId());
setProcessInstanceId(task.getProcessInstanceId());
setProcessDefinitionId(task.getProcessDefinitionId());
return this;
}
}
......@@ -16,7 +16,7 @@
<!-- https://springcloud.cc/spring-security-zhcn.html -->
<intercept-url pattern="/api/v1/cache/getallcache" access="permitAll" />
<intercept-url pattern="/api/v1/user/login" access="permitAll" />
<intercept-url pattern="/api/v1/leave/**" access="permitAll" />
<intercept-url pattern="/api/v1/approval/**" access="permitAll" />
<intercept-url pattern="/api/**" access="authenticated" />
<intercept-url pattern="/**" access="permitAll" />
<headers>
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/testm1539848247913" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1539848247913" name="" targetNamespace="http://www.activiti.org/testm1539848247913" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="approvalProcess" isClosed="false" isExecutable="true" name="ApprovalProcess" processType="None">
<startEvent id="_2" name="StartEvent"/>
<userTask activiti:assignee="accountant" activiti:exclusive="true" id="_3" name="税务会计"/>
<sequenceFlow id="_4" sourceRef="_2" targetRef="_3"/>
<userTask activiti:assignee="manager" activiti:exclusive="true" id="_5" name="税务经理"/>
<endEvent id="_7" name="EndEvent"/>
<endEvent id="_9" name="EndEvent"/>
<exclusiveGateway gatewayDirection="Unspecified" id="_12" name="ExclusiveGateway"/>
<sequenceFlow id="_13" sourceRef="_5" targetRef="_12"/>
<sequenceFlow id="_8" name="通过" sourceRef="_12" targetRef="_7">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${decide == 1}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_10" name="驳回" sourceRef="_12" targetRef="_9">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${decide == 0}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway gatewayDirection="Unspecified" id="_11" name="ExclusiveGateway"/>
<sequenceFlow id="_14" name="提审" sourceRef="_3" targetRef="_11"/>
<sequenceFlow id="_15" name="未提交" sourceRef="_11" targetRef="_5">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${commited == 0}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_16" name="已提交" sourceRef="_11" targetRef="_9">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${commited == 1}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram documentation="background=#FFFFFF;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="approvalProcess">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<dc:Bounds height="32.0" width="32.0" x="55.0" y="380.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<dc:Bounds height="55.0" width="85.0" x="190.0" y="370.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
<dc:Bounds height="55.0" width="85.0" x="445.0" y="235.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7">
<dc:Bounds height="32.0" width="32.0" x="765.0" y="105.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_9" id="Shape-_9">
<dc:Bounds height="32.0" width="32.0" x="765.0" y="425.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_12" id="Shape-_12" isMarkerVisible="false">
<dc:Bounds height="32.0" width="32.0" x="620.0" y="245.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_11" id="Shape-_11" isMarkerVisible="false">
<dc:Bounds height="32.0" width="32.0" x="390.0" y="380.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_5" targetElement="_12">
<di:waypoint x="545.0" y="262.5"/>
<di:waypoint x="620.0" y="261.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_15" id="BPMNEdge__15" sourceElement="_11" targetElement="_5">
<di:waypoint x="437.0" y="396.0"/>
<di:waypoint x="445.0" y="262.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_14" id="BPMNEdge__14" sourceElement="_3" targetElement="_11">
<di:waypoint x="290.0" y="397.5"/>
<di:waypoint x="390.0" y="396.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_16" id="BPMNEdge__16" sourceElement="_11" targetElement="_9">
<di:waypoint x="437.0" y="396.0"/>
<di:waypoint x="765.0" y="441.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_4" id="BPMNEdge__4" sourceElement="_2" targetElement="_3">
<di:waypoint x="102.0" y="396.0"/>
<di:waypoint x="190.0" y="397.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_12" targetElement="_7">
<di:waypoint x="667.0" y="261.0"/>
<di:waypoint x="765.0" y="121.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_12" targetElement="_9">
<di:waypoint x="667.0" y="261.0"/>
<di:waypoint x="765.0" y="441.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment