Commit b2c7a4ed0dc45f300b832d0e81aa8e0f34fd5734

Authored by youxiw2000
1 parent 2384736f

m

Showing 19 changed files with 2428 additions and 2232 deletions

Too many changes to show.

To preserve performance only 19 of 140 files are displayed.

trash-activiti/src/main/java/com/trash/activiti/domain/ActWorkflowFormData.java
1 -package com.trash.activiti.domain;  
2 -  
3 -import org.activiti.api.task.model.Task;  
4 -import org.apache.commons.lang3.builder.ToStringBuilder;  
5 -import org.apache.commons.lang3.builder.ToStringStyle;  
6 -import org.apache.ibatis.type.Alias;  
7 -  
8 -import com.trash.common.core.domain.BaseEntity;  
9 -import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;  
10 -  
11 -import java.util.List;  
12 -  
13 -/**  
14 - * 动态单对象 act_workflow_formdata  
15 - *  
16 - * @author danny  
17 - * @date 2020-11-02  
18 - */  
19 -@Alias("ActWorkflowFormData")  
20 -public class ActWorkflowFormData extends BaseEntity  
21 -{  
22 - private static final long serialVersionUID = 1L;  
23 -  
24 - /** 唯一标识符 */  
25 - private Long id;  
26 -  
27 - /** 事务Id */  
28 - private String businessKey;  
29 -  
30 - /** 表单Key */  
31 - private String formKey;  
32 -  
33 -  
34 - /** 表单id */  
35 - private String controlId;  
36 - /** 表单名称 */  
37 - private String controlName;  
38 -  
39 - /** 表单值 */  
40 - private String controlValue;  
41 -  
42 - /** 任务节点名称 */  
43 - private String taskNodeName;  
44 -  
45 - private String createName;  
46 -  
47 - public ActWorkflowFormData() {  
48 - }  
49 -  
50 - public ActWorkflowFormData(String businessKey,ActWorkflowFormDataDTO actWorkflowFormDataDTO, Task task) {  
51 - this.businessKey = businessKey;  
52 - this.formKey = task.getFormKey();  
53 - this.controlId = actWorkflowFormDataDTO.getControlId();  
54 - this.controlName = actWorkflowFormDataDTO.getControlLable();  
55 - if ("radio".equals(actWorkflowFormDataDTO.getControlType())) {  
56 - int i = Integer.parseInt(actWorkflowFormDataDTO.getControlValue());  
57 - this.controlValue = actWorkflowFormDataDTO.getControlDefault().split("--__--")[i];  
58 - }else {  
59 - this.controlValue = actWorkflowFormDataDTO.getControlValue();  
60 - }  
61 - this.taskNodeName = task.getName();  
62 - }  
63 -  
64 - public void setId(Long id)  
65 - {  
66 - this.id = id;  
67 - }  
68 -  
69 - public Long getId()  
70 - {  
71 - return id;  
72 - }  
73 -  
74 - public String getBusinessKey() {  
75 - return businessKey;  
76 - }  
77 -  
78 - public void setBusinessKey(String businessKey) {  
79 - this.businessKey = businessKey;  
80 - }  
81 -  
82 - public void setFormKey(String formKey)  
83 - {  
84 - this.formKey = formKey;  
85 - }  
86 -  
87 - public String getFormKey()  
88 - {  
89 - return formKey;  
90 - }  
91 - public void setControlId(String controlId)  
92 - {  
93 - this.controlId = controlId;  
94 - }  
95 -  
96 - public String getControlId()  
97 - {  
98 - return controlId;  
99 - }  
100 -  
101 - public String getControlName() {  
102 - return controlName;  
103 - }  
104 -  
105 - public void setControlName(String controlName) {  
106 - this.controlName = controlName;  
107 - }  
108 -  
109 - public void setControlValue(String controlValue)  
110 - {  
111 - this.controlValue = controlValue;  
112 - }  
113 -  
114 - public String getControlValue()  
115 - {  
116 - return controlValue;  
117 - }  
118 - public void setTaskNodeName(String taskNodeName)  
119 - {  
120 - this.taskNodeName = taskNodeName;  
121 - }  
122 -  
123 - public String getTaskNodeName()  
124 - {  
125 - return taskNodeName;  
126 - }  
127 -  
128 - public String getCreateName() {  
129 - return createName;  
130 - }  
131 -  
132 - public void setCreateName(String createName) {  
133 - this.createName = createName;  
134 - }  
135 -  
136 - @Override  
137 - public String toString() {  
138 - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)  
139 - .append("id", getId())  
140 - .append("procInstId", getBusinessKey())  
141 - .append("formKey", getFormKey())  
142 - .append("controlId", getControlId())  
143 - .append("controlValue", getControlValue())  
144 - .append("taskNodeName", getTaskNodeName())  
145 - .append("createBy", getCreateBy())  
146 - .append("createTime", getCreateTime())  
147 - .toString();  
148 - }  
149 -} 1 +package com.trash.activiti.domain;
  2 +
  3 +import org.activiti.api.task.model.Task;
  4 +import org.apache.commons.lang3.builder.ToStringBuilder;
  5 +import org.apache.commons.lang3.builder.ToStringStyle;
  6 +import org.apache.ibatis.type.Alias;
  7 +
  8 +import com.trash.common.core.domain.BaseEntity;
  9 +import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 动态单对象 act_workflow_formdata
  15 + *
  16 + * @author danny
  17 + * @date 2020-11-02
  18 + */
  19 +@Alias("ActWorkflowFormData")
  20 +public class ActWorkflowFormData extends BaseEntity
  21 +{
  22 + private static final long serialVersionUID = 1L;
  23 +
  24 + /** 唯一标识符 */
  25 + private Long id;
  26 +
  27 + /** 事务Id */
  28 + private String businessKey;
  29 +
  30 + /** 表单Key */
  31 + private String formKey;
  32 +
  33 +
  34 + /** 表单id */
  35 + private String controlId;
  36 + /** 表单名称 */
  37 + private String controlName;
  38 +
  39 + /** 表单值 */
  40 + private String controlValue;
  41 +
  42 + /** 任务节点名称 */
  43 + private String taskNodeName;
  44 +
  45 + private String createName;
  46 +
  47 + public ActWorkflowFormData() {
  48 + }
  49 +
  50 + public ActWorkflowFormData(String businessKey,ActWorkflowFormDataDTO actWorkflowFormDataDTO, Task task) {
  51 + this.businessKey = businessKey;
  52 + this.formKey = task.getFormKey();
  53 + this.controlId = actWorkflowFormDataDTO.getControlId();
  54 + this.controlName = actWorkflowFormDataDTO.getControlLable();
  55 + if ("radio".equals(actWorkflowFormDataDTO.getControlType())) {
  56 + int i = Integer.parseInt(actWorkflowFormDataDTO.getControlValue());
  57 + this.controlValue = actWorkflowFormDataDTO.getControlDefault().split("--__--")[i];
  58 + }else {
  59 + this.controlValue = actWorkflowFormDataDTO.getControlValue();
  60 + }
  61 + this.taskNodeName = task.getName();
  62 + }
  63 +
  64 + public void setId(Long id)
  65 + {
  66 + this.id = id;
  67 + }
  68 +
  69 + public Long getId()
  70 + {
  71 + return id;
  72 + }
  73 +
  74 + public String getBusinessKey() {
  75 + return businessKey;
  76 + }
  77 +
  78 + public void setBusinessKey(String businessKey) {
  79 + this.businessKey = businessKey;
  80 + }
  81 +
  82 + public void setFormKey(String formKey)
  83 + {
  84 + this.formKey = formKey;
  85 + }
  86 +
  87 + public String getFormKey()
  88 + {
  89 + return formKey;
  90 + }
  91 + public void setControlId(String controlId)
  92 + {
  93 + this.controlId = controlId;
  94 + }
  95 +
  96 + public String getControlId()
  97 + {
  98 + return controlId;
  99 + }
  100 +
  101 + public String getControlName() {
  102 + return controlName;
  103 + }
  104 +
  105 + public void setControlName(String controlName) {
  106 + this.controlName = controlName;
  107 + }
  108 +
  109 + public void setControlValue(String controlValue)
  110 + {
  111 + this.controlValue = controlValue;
  112 + }
  113 +
  114 + public String getControlValue()
  115 + {
  116 + return controlValue;
  117 + }
  118 + public void setTaskNodeName(String taskNodeName)
  119 + {
  120 + this.taskNodeName = taskNodeName;
  121 + }
  122 +
  123 + public String getTaskNodeName()
  124 + {
  125 + return taskNodeName;
  126 + }
  127 +
  128 + public String getCreateName() {
  129 + return createName;
  130 + }
  131 +
  132 + public void setCreateName(String createName) {
  133 + this.createName = createName;
  134 + }
  135 +
  136 + @Override
  137 + public String toString() {
  138 + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
  139 + .append("id", getId())
  140 + .append("procInstId", getBusinessKey())
  141 + .append("formKey", getFormKey())
  142 + .append("controlId", getControlId())
  143 + .append("controlValue", getControlValue())
  144 + .append("taskNodeName", getTaskNodeName())
  145 + .append("createBy", getCreateBy())
  146 + .append("createTime", getCreateTime())
  147 + .toString();
  148 + }
  149 +}
trash-activiti/src/main/java/com/trash/activiti/domain/dto/ActWorkflowFormDataDTO.java
1 -package com.trash.activiti.domain.dto;  
2 -  
3 -  
4 -import com.trash.common.core.domain.BaseEntity;  
5 -  
6 -import java.util.List;  
7 -  
8 -  
9 -/**  
10 - * 动态单对象 act_workflow_formdata  
11 - *  
12 - * @author danny  
13 - * @date 2020-11-01  
14 - */  
15 -public class ActWorkflowFormDataDTO extends BaseEntity  
16 -{  
17 - private static final long serialVersionUID = 1L;  
18 -  
19 -  
20 - /** 表单id */  
21 - private String controlId;  
22 - private String controlType;  
23 -  
24 -  
25 -  
26 - /** 表单名称 */  
27 - private String controlLable;  
28 -  
29 - private String controlIsParam;  
30 -  
31 - /** 表单值 */  
32 - private String controlValue;  
33 - private String controlDefault;  
34 -  
35 - private String deptCode;  
36 -  
37 - private String index;  
38 - public String getIndex() {  
39 - return index;  
40 - }  
41 -  
42 - public void setIndex(String index) {  
43 - this.index = index;  
44 - }  
45 -  
46 - public String getDeptCode() {  
47 - return deptCode;  
48 - }  
49 -  
50 - public void setDeptCode(String deptCode) {  
51 - this.deptCode = deptCode;  
52 - }  
53 -  
54 - public void setControlId(String controlId)  
55 - {  
56 - this.controlId = controlId;  
57 - }  
58 -  
59 - public String getControlId()  
60 - {  
61 - return controlId;  
62 - }  
63 - public void setControlValue(String controlValue)  
64 - {  
65 - this.controlValue = controlValue;  
66 - }  
67 -  
68 - public String getControlValue()  
69 - {  
70 - return controlValue;  
71 - }  
72 -  
73 -  
74 - public String getControlIsParam() {  
75 - return controlIsParam;  
76 - }  
77 -  
78 - public void setControlIsParam(String controlIsParam) {  
79 - this.controlIsParam = controlIsParam;  
80 - }  
81 -  
82 - public String getControlLable() {  
83 - return controlLable;  
84 - }  
85 -  
86 - public void setControlLable(String controlLable) {  
87 - this.controlLable = controlLable;  
88 - }  
89 -  
90 - public String getControlDefault() {  
91 - return controlDefault;  
92 - }  
93 -  
94 - public void setControlDefault(String controlDefault) {  
95 - this.controlDefault = controlDefault;  
96 - }  
97 -  
98 - public String getControlType() {  
99 - return controlType;  
100 - }  
101 -  
102 - public void setControlType(String controlType) {  
103 - this.controlType = controlType;  
104 - }  
105 -} 1 +package com.trash.activiti.domain.dto;
  2 +
  3 +
  4 +import com.trash.common.core.domain.BaseEntity;
  5 +
  6 +import java.util.List;
  7 +
  8 +
  9 +/**
  10 + * 动态单对象 act_workflow_formdata
  11 + *
  12 + * @author danny
  13 + * @date 2020-11-01
  14 + */
  15 +public class ActWorkflowFormDataDTO extends BaseEntity
  16 +{
  17 + private static final long serialVersionUID = 1L;
  18 +
  19 +
  20 + /** 表单id */
  21 + private String controlId;
  22 + private String controlType;
  23 +
  24 +
  25 +
  26 + /** 表单名称 */
  27 + private String controlLable;
  28 +
  29 + private String controlIsParam;
  30 +
  31 + /** 表单值 */
  32 + private String controlValue;
  33 + private String controlDefault;
  34 +
  35 + private String deptCode;
  36 +
  37 + private String index;
  38 + public String getIndex() {
  39 + return index;
  40 + }
  41 +
  42 + public void setIndex(String index) {
  43 + this.index = index;
  44 + }
  45 +
  46 + public String getDeptCode() {
  47 + return deptCode;
  48 + }
  49 +
  50 + public void setDeptCode(String deptCode) {
  51 + this.deptCode = deptCode;
  52 + }
  53 +
  54 + public void setControlId(String controlId)
  55 + {
  56 + this.controlId = controlId;
  57 + }
  58 +
  59 + public String getControlId()
  60 + {
  61 + return controlId;
  62 + }
  63 + public void setControlValue(String controlValue)
  64 + {
  65 + this.controlValue = controlValue;
  66 + }
  67 +
  68 + public String getControlValue()
  69 + {
  70 + return controlValue;
  71 + }
  72 +
  73 +
  74 + public String getControlIsParam() {
  75 + return controlIsParam;
  76 + }
  77 +
  78 + public void setControlIsParam(String controlIsParam) {
  79 + this.controlIsParam = controlIsParam;
  80 + }
  81 +
  82 + public String getControlLable() {
  83 + return controlLable;
  84 + }
  85 +
  86 + public void setControlLable(String controlLable) {
  87 + this.controlLable = controlLable;
  88 + }
  89 +
  90 + public String getControlDefault() {
  91 + return controlDefault;
  92 + }
  93 +
  94 + public void setControlDefault(String controlDefault) {
  95 + this.controlDefault = controlDefault;
  96 + }
  97 +
  98 + public String getControlType() {
  99 + return controlType;
  100 + }
  101 +
  102 + public void setControlType(String controlType) {
  103 + this.controlType = controlType;
  104 + }
  105 +}
trash-activiti/src/main/java/com/trash/activiti/mapper/ActWorkflowFormDataMapper.java
1 -package com.trash.activiti.mapper;  
2 -  
3 -import java.util.Date;  
4 -import java.util.List;  
5 -import java.util.Map;  
6 -  
7 -import org.apache.ibatis.annotations.Param;  
8 -  
9 -import com.trash.activiti.domain.ActWorkflowFormData;  
10 -  
11 -import javax.xml.crypto.Data;  
12 -  
13 -/**  
14 - * 动态单Mapper接口  
15 - *  
16 - * @author danny  
17 - * @date 2020-11-02  
18 - */  
19 -public interface ActWorkflowFormDataMapper  
20 -{  
21 - /**  
22 - * 查询动态单  
23 - *  
24 - * @param id 动态单ID  
25 - * @return 动态单  
26 - */  
27 - ActWorkflowFormData selectActWorkflowFormDataById(Long id);  
28 - /**  
29 - * 查询动态单  
30 - *  
31 - * @param businessKey 动态单ID  
32 - * @return 动态单  
33 - */  
34 - List<ActWorkflowFormData> selectActWorkflowFormDataByBusinessKey(String businessKey);  
35 -  
36 - /**  
37 - * 查询动态单列表  
38 - *  
39 - * @param ActWorkflowFormData 动态单  
40 - * @return 动态单集合  
41 - */  
42 - List<ActWorkflowFormData> selectActWorkflowFormDataList(ActWorkflowFormData ActWorkflowFormData);  
43 -  
44 - /**  
45 - * 新增动态单  
46 - *  
47 - * @param ActWorkflowFormData 动态单  
48 - * @return 结果  
49 - */  
50 - int insertActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);  
51 -  
52 -  
53 - /**  
54 - * 新增动态单  
55 - *  
56 - * @param  
57 - * @return 结果  
58 - */  
59 - int insertActWorkflowFormDatas(@Param("createBy") String createBy, @Param("ActWorkflowFormData") List<ActWorkflowFormData> ActWorkflowFormData, Date date, String createName);  
60 -  
61 -  
62 -  
63 -  
64 - /**  
65 - * 修改动态单  
66 - *  
67 - * @param ActWorkflowFormData 动态单  
68 - * @return 结果  
69 - */  
70 - int updateActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);  
71 -  
72 - /**  
73 - * 删除动态单  
74 - *  
75 - * @param id 动态单ID  
76 - * @return 结果  
77 - */  
78 - int deleteActWorkflowFormDataById(Long id);  
79 -  
80 - /**  
81 - * 批量删除动态单  
82 - *  
83 - * @param ids 需要删除的数据ID  
84 - * @return 结果  
85 - */  
86 - int deleteActWorkflowFormDataByIds(Long[] ids);  
87 -  
88 - List<ActWorkflowFormData> selectActWorkFlowFormDataListByUser(@Param("username") String username);  
89 - List<ActWorkflowFormData> selectNewActWorkflowFormDataByBusinessKey(Map<String,String> map);  
90 -} 1 +package com.trash.activiti.mapper;
  2 +
  3 +import java.util.Date;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import org.apache.ibatis.annotations.Param;
  8 +
  9 +import com.trash.activiti.domain.ActWorkflowFormData;
  10 +
  11 +import javax.xml.crypto.Data;
  12 +
  13 +/**
  14 + * 动态单Mapper接口
  15 + *
  16 + * @author danny
  17 + * @date 2020-11-02
  18 + */
  19 +public interface ActWorkflowFormDataMapper
  20 +{
  21 + /**
  22 + * 查询动态单
  23 + *
  24 + * @param id 动态单ID
  25 + * @return 动态单
  26 + */
  27 + ActWorkflowFormData selectActWorkflowFormDataById(Long id);
  28 + /**
  29 + * 查询动态单
  30 + *
  31 + * @param businessKey 动态单ID
  32 + * @return 动态单
  33 + */
  34 + List<ActWorkflowFormData> selectActWorkflowFormDataByBusinessKey(String businessKey);
  35 +
  36 + /**
  37 + * 查询动态单列表
  38 + *
  39 + * @param ActWorkflowFormData 动态单
  40 + * @return 动态单集合
  41 + */
  42 + List<ActWorkflowFormData> selectActWorkflowFormDataList(ActWorkflowFormData ActWorkflowFormData);
  43 +
  44 + /**
  45 + * 新增动态单
  46 + *
  47 + * @param ActWorkflowFormData 动态单
  48 + * @return 结果
  49 + */
  50 + int insertActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);
  51 +
  52 +
  53 + /**
  54 + * 新增动态单
  55 + *
  56 + * @param
  57 + * @return 结果
  58 + */
  59 + int insertActWorkflowFormDatas(@Param("createBy") String createBy, @Param("ActWorkflowFormData") List<ActWorkflowFormData> ActWorkflowFormData, Date date, String createName);
  60 +
  61 +
  62 +
  63 +
  64 + /**
  65 + * 修改动态单
  66 + *
  67 + * @param ActWorkflowFormData 动态单
  68 + * @return 结果
  69 + */
  70 + int updateActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);
  71 +
  72 + /**
  73 + * 删除动态单
  74 + *
  75 + * @param id 动态单ID
  76 + * @return 结果
  77 + */
  78 + int deleteActWorkflowFormDataById(Long id);
  79 +
  80 + /**
  81 + * 批量删除动态单
  82 + *
  83 + * @param ids 需要删除的数据ID
  84 + * @return 结果
  85 + */
  86 + int deleteActWorkflowFormDataByIds(Long[] ids);
  87 +
  88 + List<ActWorkflowFormData> selectActWorkFlowFormDataListByUser(@Param("username") String username);
  89 + List<ActWorkflowFormData> selectNewActWorkflowFormDataByBusinessKey(Map<String,String> map);
  90 +}
trash-activiti/src/main/java/com/trash/activiti/service/IActTaskService.java
1 -package com.trash.activiti.service;  
2 -  
3 -import com.github.pagehelper.Page;  
4 -import com.trash.common.core.page.PageDomain;  
5 -import com.trash.activiti.domain.dto.ActTaskDTO;  
6 -import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;  
7 -  
8 -import java.text.ParseException;  
9 -import java.util.List;  
10 -  
11 -public interface IActTaskService {  
12 - Page<ActTaskDTO> selectProcessDefinitionList(PageDomain pageDomain);  
13 - List<String>formDataShow(String taskID);  
14 - int formDataSave(String taskID, List<ActWorkflowFormDataDTO> awfs) throws ParseException;  
15 -  
16 - Page<ActTaskDTO> selectRuntimeTaskHistoryDefinitionList(PageDomain pageDomain);  
17 -  
18 - Page<ActTaskDTO> selectTaskEndHistoryDefinitionList(PageDomain pageDomain);  
19 -  
20 - public void endAllThreesteptask(String type);  
21 -  
22 - public void deleteProcessById(String type);  
23 -} 1 +package com.trash.activiti.service;
  2 +
  3 +import com.github.pagehelper.Page;
  4 +import com.trash.common.core.page.PageDomain;
  5 +import com.trash.activiti.domain.dto.ActTaskDTO;
  6 +import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;
  7 +
  8 +import java.text.ParseException;
  9 +import java.util.List;
  10 +
  11 +public interface IActTaskService {
  12 + Page<ActTaskDTO> selectProcessDefinitionList(PageDomain pageDomain);
  13 + List<String>formDataShow(String taskID);
  14 + int formDataSave(String taskID, List<ActWorkflowFormDataDTO> awfs) throws ParseException;
  15 +
  16 + Page<ActTaskDTO> selectRuntimeTaskHistoryDefinitionList(PageDomain pageDomain);
  17 +
  18 + Page<ActTaskDTO> selectTaskEndHistoryDefinitionList(PageDomain pageDomain);
  19 +
  20 + public void endAllThreesteptask(String type);
  21 +
  22 + public void deleteProcessById(String type);
  23 +}
trash-activiti/src/main/java/com/trash/activiti/service/IActWorkflowFormDataService.java
1 -package com.trash.activiti.service;  
2 -  
3 -import java.util.List;  
4 -  
5 -import com.trash.activiti.domain.ActWorkflowFormData;  
6 -  
7 -/**  
8 - * 动态单Service接口  
9 - *  
10 - * @author danny  
11 - * @date 2020-11-02  
12 - */  
13 -public interface IActWorkflowFormDataService  
14 -{  
15 - /**  
16 - * 查询动态单  
17 - *  
18 - * @param id 动态单ID  
19 - * @return 动态单  
20 - */  
21 - ActWorkflowFormData selectActWorkflowFormDataById(Long id);  
22 -  
23 - List<ActWorkflowFormData> selectActWorkflowFormDataByBusinessKey(String businessKey);  
24 -  
25 - /**  
26 - * 查询动态单列表  
27 - *  
28 - * @param ActWorkflowFormData 动态单  
29 - * @return 动态单集合  
30 - */  
31 - List<ActWorkflowFormData> selectActWorkflowFormDataList(ActWorkflowFormData ActWorkflowFormData);  
32 -  
33 - /**  
34 - * 新增动态单  
35 - *  
36 - * @param ActWorkflowFormData 动态单  
37 - * @return 结果  
38 - */  
39 - int insertActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);  
40 -  
41 - /**  
42 - * 新增动态单集合  
43 - * @param ActWorkflowFormDatas 动态表单集合  
44 - * @return  
45 - */  
46 - int insertActWorkflowFormDatas(List<ActWorkflowFormData> ActWorkflowFormDatas);  
47 -  
48 - /**  
49 - * 修改动态单  
50 - *  
51 - * @param ActWorkflowFormData 动态单  
52 - * @return 结果  
53 - */  
54 - int updateActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);  
55 -  
56 - /**  
57 - * 批量删除动态单  
58 - *  
59 - * @param ids 需要删除的动态单ID  
60 - * @return 结果  
61 - */  
62 - int deleteActWorkflowFormDataByIds(Long[] ids);  
63 -  
64 - /**  
65 - * 删除动态单信息  
66 - *  
67 - * @param id 动态单ID  
68 - * @return 结果  
69 - */  
70 - int deleteActWorkflowFormDataById(Long id);  
71 -} 1 +package com.trash.activiti.service;
  2 +
  3 +import java.util.List;
  4 +
  5 +import com.trash.activiti.domain.ActWorkflowFormData;
  6 +
  7 +/**
  8 + * 动态单Service接口
  9 + *
  10 + * @author danny
  11 + * @date 2020-11-02
  12 + */
  13 +public interface IActWorkflowFormDataService
  14 +{
  15 + /**
  16 + * 查询动态单
  17 + *
  18 + * @param id 动态单ID
  19 + * @return 动态单
  20 + */
  21 + ActWorkflowFormData selectActWorkflowFormDataById(Long id);
  22 +
  23 + List<ActWorkflowFormData> selectActWorkflowFormDataByBusinessKey(String businessKey);
  24 +
  25 + /**
  26 + * 查询动态单列表
  27 + *
  28 + * @param ActWorkflowFormData 动态单
  29 + * @return 动态单集合
  30 + */
  31 + List<ActWorkflowFormData> selectActWorkflowFormDataList(ActWorkflowFormData ActWorkflowFormData);
  32 +
  33 + /**
  34 + * 新增动态单
  35 + *
  36 + * @param ActWorkflowFormData 动态单
  37 + * @return 结果
  38 + */
  39 + int insertActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);
  40 +
  41 + /**
  42 + * 新增动态单集合
  43 + * @param ActWorkflowFormDatas 动态表单集合
  44 + * @return
  45 + */
  46 + int insertActWorkflowFormDatas(List<ActWorkflowFormData> ActWorkflowFormDatas);
  47 +
  48 + /**
  49 + * 修改动态单
  50 + *
  51 + * @param ActWorkflowFormData 动态单
  52 + * @return 结果
  53 + */
  54 + int updateActWorkflowFormData(ActWorkflowFormData ActWorkflowFormData);
  55 +
  56 + /**
  57 + * 批量删除动态单
  58 + *
  59 + * @param ids 需要删除的动态单ID
  60 + * @return 结果
  61 + */
  62 + int deleteActWorkflowFormDataByIds(Long[] ids);
  63 +
  64 + /**
  65 + * 删除动态单信息
  66 + *
  67 + * @param id 动态单ID
  68 + * @return 结果
  69 + */
  70 + int deleteActWorkflowFormDataById(Long id);
  71 +}
trash-activiti/src/main/java/com/trash/activiti/service/IActivitiHistoryService.java
1 -package com.trash.activiti.service;  
2 -  
3 -import com.trash.activiti.domain.dto.ActivitiHighLineDTO;  
4 -  
5 -public interface IActivitiHistoryService {  
6 - ActivitiHighLineDTO gethighLine(String instanceId);  
7 -} 1 +package com.trash.activiti.service;
  2 +
  3 +import com.trash.activiti.domain.dto.ActivitiHighLineDTO;
  4 +
  5 +public interface IActivitiHistoryService {
  6 + ActivitiHighLineDTO gethighLine(String instanceId);
  7 +}
trash-activiti/src/main/java/com/trash/activiti/service/IFormHistoryDataService.java
1 -package com.trash.activiti.service;  
2 -  
3 -import java.util.List;  
4 -import java.util.Map;  
5 -  
6 -import com.trash.activiti.domain.ActWorkflowFormData;  
7 -import com.trash.activiti.domain.dto.HistoryDataDTO;  
8 -  
9 -/**  
10 - * 汇讯数码科技(深圳)有限公司  
11 - * 创建日期:2020/11/3-10:19  
12 - * 版本 开发者 日期  
13 - * 1.0 Danny 2020/11/3  
14 - */  
15 -public interface IFormHistoryDataService {  
16 -  
17 - List<ActWorkflowFormData> historyDataShow(String instanceId);  
18 -  
19 - List<ActWorkflowFormData> historyFromDataByTime(Map<String,String> map);  
20 -} 1 +package com.trash.activiti.service;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.trash.activiti.domain.ActWorkflowFormData;
  7 +import com.trash.activiti.domain.dto.HistoryDataDTO;
  8 +
  9 +/**
  10 + * 汇讯数码科技(深圳)有限公司
  11 + * 创建日期:2020/11/3-10:19
  12 + * 版本 开发者 日期
  13 + * 1.0 Danny 2020/11/3
  14 + */
  15 +public interface IFormHistoryDataService {
  16 +
  17 + List<ActWorkflowFormData> historyDataShow(String instanceId);
  18 +
  19 + List<ActWorkflowFormData> historyFromDataByTime(Map<String,String> map);
  20 +}
trash-activiti/src/main/java/com/trash/activiti/service/IProcessDefinitionService.java
1 -package com.trash.activiti.service;  
2 -  
3 -import com.github.pagehelper.Page;  
4 -import com.trash.common.core.domain.AjaxResult;  
5 -import com.trash.common.core.page.PageDomain;  
6 -import com.trash.activiti.domain.dto.DefinitionIdDTO;  
7 -import com.trash.activiti.domain.dto.ProcessDefinitionDTO;  
8 -  
9 -import org.springframework.web.bind.annotation.PathVariable;  
10 -import org.springframework.web.multipart.MultipartFile;  
11 -  
12 -import javax.servlet.http.HttpServletResponse;  
13 -import java.io.IOException;  
14 -  
15 -/**  
16 - * 汇讯数码科技(深圳)有限公司  
17 - * 创建日期:2020/10/22-16:34  
18 - * 版本 开发者 日期  
19 - * 1.0 Danny 2020/10/22  
20 - */  
21 -public interface IProcessDefinitionService {  
22 - /**  
23 - * 获取流程定义集合  
24 - * @param processDefinition  
25 - * @return Page 分页信息  
26 - */  
27 - Page<ProcessDefinitionDTO> selectProcessDefinitionList(ProcessDefinitionDTO processDefinition, PageDomain pageDomain);  
28 - DefinitionIdDTO getDefinitionsByInstanceId(String instanceId);  
29 - /**  
30 - * 删除流程定义  
31 - * @param id  
32 - * @return  
33 - */  
34 - int deleteProcessDefinitionById(String id);  
35 - /**  
36 - * 上传并部署流程定义  
37 - * @param file  
38 - * @return  
39 - * @throws IOException  
40 - */  
41 - void uploadStreamAndDeployment(MultipartFile file) throws IOException;  
42 - /**  
43 - * 启动挂起流程流程定义  
44 - * @param id 流程定义id  
45 - * @param suspendState 流程状态  
46 - * @return  
47 - */  
48 - void suspendOrActiveApply(String id, Integer suspendState);  
49 -  
50 - /**  
51 - * 上传流程流程定义  
52 - * @param multipartFile  
53 - * @return  
54 - */  
55 - String upload(MultipartFile multipartFile) throws IOException;  
56 - /**  
57 - * 通过stringBPMN添加流程定义  
58 - * @param stringBPMN  
59 - * @return  
60 - */  
61 - void addDeploymentByString(String stringBPMN);  
62 -  
63 - /**  
64 - * 获取流程定义XML  
65 - * @param response  
66 - * @param deploymentId  
67 - * @param resourceName  
68 - */  
69 - void getProcessDefineXML(HttpServletResponse response, String deploymentId, String resourceName) throws IOException;  
70 -} 1 +package com.trash.activiti.service;
  2 +
  3 +import com.github.pagehelper.Page;
  4 +import com.trash.common.core.domain.AjaxResult;
  5 +import com.trash.common.core.page.PageDomain;
  6 +import com.trash.activiti.domain.dto.DefinitionIdDTO;
  7 +import com.trash.activiti.domain.dto.ProcessDefinitionDTO;
  8 +
  9 +import org.springframework.web.bind.annotation.PathVariable;
  10 +import org.springframework.web.multipart.MultipartFile;
  11 +
  12 +import javax.servlet.http.HttpServletResponse;
  13 +import java.io.IOException;
  14 +
  15 +/**
  16 + * 汇讯数码科技(深圳)有限公司
  17 + * 创建日期:2020/10/22-16:34
  18 + * 版本 开发者 日期
  19 + * 1.0 Danny 2020/10/22
  20 + */
  21 +public interface IProcessDefinitionService {
  22 + /**
  23 + * 获取流程定义集合
  24 + * @param processDefinition
  25 + * @return Page 分页信息
  26 + */
  27 + Page<ProcessDefinitionDTO> selectProcessDefinitionList(ProcessDefinitionDTO processDefinition, PageDomain pageDomain);
  28 + DefinitionIdDTO getDefinitionsByInstanceId(String instanceId);
  29 + /**
  30 + * 删除流程定义
  31 + * @param id
  32 + * @return
  33 + */
  34 + int deleteProcessDefinitionById(String id);
  35 + /**
  36 + * 上传并部署流程定义
  37 + * @param file
  38 + * @return
  39 + * @throws IOException
  40 + */
  41 + void uploadStreamAndDeployment(MultipartFile file) throws IOException;
  42 + /**
  43 + * 启动挂起流程流程定义
  44 + * @param id 流程定义id
  45 + * @param suspendState 流程状态
  46 + * @return
  47 + */
  48 + void suspendOrActiveApply(String id, Integer suspendState);
  49 +
  50 + /**
  51 + * 上传流程流程定义
  52 + * @param multipartFile
  53 + * @return
  54 + */
  55 + String upload(MultipartFile multipartFile) throws IOException;
  56 + /**
  57 + * 通过stringBPMN添加流程定义
  58 + * @param stringBPMN
  59 + * @return
  60 + */
  61 + void addDeploymentByString(String stringBPMN);
  62 +
  63 + /**
  64 + * 获取流程定义XML
  65 + * @param response
  66 + * @param deploymentId
  67 + * @param resourceName
  68 + */
  69 + void getProcessDefineXML(HttpServletResponse response, String deploymentId, String resourceName) throws IOException;
  70 +}
trash-activiti/src/main/java/com/trash/activiti/service/impl/ActTaskServiceImpl.java
1 -package com.trash.activiti.service.impl;  
2 -  
3 -import java.text.ParseException;  
4 -import java.text.SimpleDateFormat;  
5 -import java.util.ArrayList;  
6 -import java.util.Comparator;  
7 -import java.util.HashMap;  
8 -import java.util.HashSet;  
9 -import java.util.List;  
10 -import java.util.Map;  
11 -import java.util.Set;  
12 -import java.util.stream.Collectors;  
13 -  
14 -import org.activiti.api.runtime.shared.identity.UserGroupManager;  
15 -import org.activiti.api.runtime.shared.query.Pageable;  
16 -import org.activiti.api.runtime.shared.security.SecurityManager;  
17 -import org.activiti.api.task.model.Task;  
18 -import org.activiti.api.task.model.builders.TaskPayloadBuilder;  
19 -import org.activiti.bpmn.model.FormProperty;  
20 -import org.activiti.bpmn.model.UserTask;  
21 -import org.activiti.engine.HistoryService;  
22 -import org.activiti.engine.ProcessEngine;  
23 -import org.activiti.engine.ProcessEngines;  
24 -import org.activiti.engine.RepositoryService;  
25 -import org.activiti.engine.RuntimeService;  
26 -import org.activiti.engine.TaskService;  
27 -import org.activiti.engine.history.HistoricProcessInstance;  
28 -import org.activiti.engine.history.HistoricProcessInstanceQuery;  
29 -import org.activiti.engine.runtime.ProcessInstance;  
30 -import org.activiti.engine.runtime.ProcessInstanceQuery;  
31 -import org.activiti.engine.task.IdentityLink;  
32 -import org.apache.commons.collections4.map.HashedMap;  
33 -import org.springframework.beans.factory.annotation.Autowired;  
34 -import org.springframework.stereotype.Service;  
35 -  
36 -import com.alibaba.fastjson.JSONObject;  
37 -import com.github.pagehelper.Page;  
38 -import com.trash.activiti.domain.ActWorkflowFormData;  
39 -import com.trash.activiti.domain.dto.ActTaskDTO;  
40 -import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;  
41 -import com.trash.activiti.mapper.ActReDeploymentMapper;  
42 -import com.trash.activiti.mapper.ActWorkflowFormDataMapper;  
43 -import com.trash.activiti.service.IActTaskService;  
44 -import com.trash.activiti.service.IActWorkflowFormDataService;  
45 -import com.trash.activiti.service.myTaskService;  
46 -import com.trash.common.core.page.PageDomain;  
47 -import com.trash.common.core.redis.RedisCache;  
48 -import com.trash.common.utils.RemoteServerUtils;  
49 -import com.trash.common.utils.SecurityUtils;  
50 -import com.trash.common.utils.ServletUtils;  
51 -import com.trash.common.utils.StringUtils;  
52 -import com.trash.common.utils.util.PostSms;  
53 -import com.trash.common.utils.vo.mt.JsonSmsSend;  
54 -import com.trash.common.utils.vo.mt.Mobile;  
55 -  
56 -@Service  
57 -public class ActTaskServiceImpl implements IActTaskService {  
58 -  
59 - @Autowired  
60 - private RepositoryService repositoryService;  
61 -  
62 - @Autowired  
63 - private myTaskService taskRuntime;  
64 -  
65 - @Autowired  
66 - private TaskService taskService;  
67 -  
68 - @Autowired  
69 - private RuntimeService runtimeService;  
70 -  
71 - @Autowired  
72 - private IActWorkflowFormDataService actWorkflowFormDataService;  
73 -  
74 - @Autowired  
75 - private ActWorkflowFormDataMapper actWorkflowFormDataMapper;  
76 -  
77 - @Autowired  
78 - private ActReDeploymentMapper actMapper;  
79 -  
80 - @Autowired  
81 - SecurityManager securityManager;  
82 -  
83 - @Autowired  
84 - UserGroupManager userGroupManager;  
85 -  
86 - HistoricProcessInstanceQuery processInstanceQuery;  
87 -  
88 - @Autowired  
89 - private RedisCache redisCache;  
90 -  
91 - @Override  
92 - public Page<ActTaskDTO> selectProcessDefinitionList(PageDomain pageDomain) {  
93 - Page<ActTaskDTO> list = new Page<ActTaskDTO>();  
94 - List<ActTaskDTO> actTaskDTOS = new ArrayList<>();  
95 -  
96 - if (ServletUtils.getParameter("role") != null) {  
97 - List<String> posts = new ArrayList<>();  
98 - posts.add(ServletUtils.getParameter("role"));  
99 - SecurityUtils.getLoginUser().getUser().setPostIds(posts);  
100 - }  
101 - if (ServletUtils.getParameter("dept") != null) {  
102 - List<String> roles = new ArrayList<>();  
103 - roles.add(ServletUtils.getParameter("dept"));  
104 - SecurityUtils.getLoginUser().getUser().setRoleIds(roles);  
105 - }  
106 - if (SecurityUtils.getLoginUser().getUser().getPostIds().size() == 0  
107 - || SecurityUtils.getLoginUser().getUser().getRoleIds().size() == 0) {  
108 - return list;  
109 - }  
110 -  
111 - String type = ServletUtils.getParameter("type");  
112 - String prev = ServletUtils.getParameter("prev");  
113 - String name = ServletUtils.getParameter("name");  
114 - if (type != null && type.isEmpty()) {  
115 - type = null;  
116 - }  
117 - if (prev != null && prev.isEmpty()) {  
118 - prev = null;  
119 - }  
120 -  
121 - String[] strings;  
122 - Set<String> keys = new HashSet<String>();  
123 -  
124 - if (type != null && !type.isEmpty()) {  
125 - strings = type.split(",");  
126 - keys = new HashSet<String>();  
127 -  
128 - for (String str : strings) {  
129 - keys.add(str);  
130 - }  
131 - }  
132 - org.activiti.api.runtime.shared.query.Page<Task> pageTasks;  
133 -  
134 - int pageNum = pageDomain.getPageNum();  
135 - int pageSize = pageDomain.getPageSize();  
136 - if (prev == null) {  
137 - pageTasks = taskRuntime.tasks(Pageable.of((pageNum - 1) * pageSize, pageSize), null, keys, name);  
138 - } else {  
139 - pageTasks = taskRuntime.tasks(Pageable.of(0, 999999), null, keys, name);  
140 - }  
141 -  
142 - List<Task> tasks = pageTasks.getContent();  
143 - int totalItems = pageTasks.getTotalItems();  
144 -  
145 - list.setTotal(totalItems);  
146 -  
147 - if (totalItems != 0) {  
148 -  
149 - Set<String> processInstanceIdIds = tasks.parallelStream().map(t -> t.getProcessInstanceId())  
150 - .collect(Collectors.toSet());  
151 -  
152 - if (processInstanceIdIds.size() > 0) {  
153 -  
154 - List<Map<String, Object>> maps = actMapper.selectWorkByIds(processInstanceIdIds);  
155 -  
156 - for (Task task : tasks) {  
157 - try {  
158 - ActTaskDTO dto = new ActTaskDTO(task, maps.parallelStream()  
159 - .filter(t -> t.get("instance_id").equals(task.getProcessInstanceId())).findAny().get());  
160 -  
161 - if (prev != null && !prev.isEmpty()  
162 - && (dto.getPrev() == null || !dto.getPrev().contains(prev))) {  
163 - continue;  
164 - }  
165 -  
166 - list.add(dto);  
167 - } catch (Exception e) {  
168 - e.printStackTrace();  
169 - }  
170 - }  
171 - }  
172 - }  
173 -  
174 - if (prev != null) {  
175 - list.setTotal(list.size());  
176 - }  
177 -  
178 - return list;  
179 - }  
180 -  
181 - @Override  
182 - public Page<ActTaskDTO> selectTaskEndHistoryDefinitionList(PageDomain pageDomain) {  
183 -  
184 - int pageNum = pageDomain.getPageNum();  
185 - int pageSize = pageDomain.getPageSize();  
186 -  
187 - Page<ActTaskDTO> list = new Page<ActTaskDTO>();  
188 -  
189 - ProcessEngine pes = ProcessEngines.getDefaultProcessEngine();  
190 - HistoryService historyService = pes.getHistoryService();  
191 -  
192 - String username = securityManager.getAuthenticatedUserId();  
193 -  
194 - Map map = new HashedMap<>();  
195 -  
196 - String type = ServletUtils.getParameter("type");  
197 - String name = ServletUtils.getParameter("name");  
198 - if (type != null && type.isEmpty()) {  
199 - type = null;  
200 - }  
201 - if (name != null && name.isEmpty()) {  
202 - name = null;  
203 - }  
204 - map.put("username", username);  
205 - if (name != null)  
206 - map.put("name", name);  
207 -  
208 - List<HistoricProcessInstance> processInstanceList;  
209 -  
210 - HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().involvedUser(username)  
211 - .finished().orderByProcessInstanceStartTime().desc();  
212 -  
213 - if (name != null)  
214 - query.processInstanceNameLike("%" + name + "%");  
215 -  
216 - if (type != null && !type.isEmpty()) {  
217 - List<String> types = new ArrayList<String>();  
218 - for (String string : type.split(",")) {  
219 - types.add(string);  
220 - }  
221 - query.processDefinitionKeyIn(types);  
222 - }  
223 -  
224 - list.setTotal(query.count());  
225 -  
226 - processInstanceList = query.listPage((pageNum - 1) * pageSize, pageSize);  
227 -  
228 - // List<ActWorkflowFormData> dataList =  
229 - // actWorkflowFormDataMapper.selectActWorkFlowFormDataListByUser(username);  
230 -  
231 - if (processInstanceList.size() > 0) {  
232 -  
233 - Set<String> idString = new HashSet<String>();  
234 - for (HistoricProcessInstance pi : processInstanceList) {  
235 - idString.add(pi.getId());  
236 - }  
237 -  
238 - List<Map<String, Object>> maps = actMapper.selectHistoryWorkByPIds(idString);  
239 -  
240 - for (HistoricProcessInstance p : processInstanceList) {  
241 - try {  
242 - ActTaskDTO dto = new ActTaskDTO(p, maps.parallelStream()  
243 - .filter(pi -> p.getId().equals(pi.get("instance_id"))).findAny().get());  
244 -  
245 - list.add(dto);  
246 - } catch (Exception e) {  
247 - System.out.println(p.getBusinessKey());  
248 - e.printStackTrace();  
249 - }  
250 - }  
251 -  
252 - }  
253 -  
254 - return list;  
255 - }  
256 -  
257 - @Override  
258 - public Page<ActTaskDTO> selectRuntimeTaskHistoryDefinitionList(PageDomain pageDomain) {  
259 - Page<ActTaskDTO> list = new Page<ActTaskDTO>();  
260 -  
261 - int pageNum = pageDomain.getPageNum();  
262 - int pageSize = pageDomain.getPageSize();  
263 - String username = securityManager.getAuthenticatedUserId();  
264 -  
265 - Map map = new HashedMap<>();  
266 -  
267 - String type = ServletUtils.getParameter("type");  
268 - String name = ServletUtils.getParameter("name");  
269 - map.put("username", username);  
270 - if (type != null && type.isEmpty()) {  
271 - type = null;  
272 - }  
273 - if (name != null && name.isEmpty()) {  
274 - name = null;  
275 - }  
276 -  
277 - ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().involvedUser(username);  
278 -  
279 - if (name != null)  
280 - query.processInstanceNameLike("%" + name + "%");  
281 -  
282 - if (type != null && !type.isEmpty()) {  
283 - Set<String> types = new HashSet<String>();  
284 - for (String string : type.split(",")) {  
285 - types.add(string);  
286 - }  
287 - query.processDefinitionKeys(types);  
288 - }  
289 -  
290 - List<ProcessInstance> processInstanceList = query.list();  
291 -  
292 - list.setTotal(query.count());  
293 -  
294 - processInstanceList = query.listPage((pageNum - 1) * pageSize, pageSize);  
295 -  
296 - if (processInstanceList.size() > 0) {  
297 -  
298 - List<String> pids = processInstanceList.parallelStream().map(p -> p.getId()).collect(Collectors.toList());  
299 -  
300 - List<org.activiti.engine.task.Task> tasks = taskService.createTaskQuery().processInstanceIdIn(pids).list();  
301 -  
302 - Set<String> idString = new HashSet<String>();  
303 - for (ProcessInstance pi : processInstanceList) {  
304 - idString.add(pi.getId());  
305 - }  
306 -  
307 - List<Map<String, Object>> maps = actMapper.selectWorkByIds(idString);  
308 -  
309 - List<ActWorkflowFormData> dataList = actWorkflowFormDataMapper  
310 - .selectActWorkFlowFormDataListByUser(username);  
311 - if (processInstanceList.size() > 0) {  
312 - for (ProcessInstance p : processInstanceList) {  
313 - try {  
314 - ActTaskDTO dto = new ActTaskDTO(p, maps.parallelStream()  
315 - .filter(pi -> p.getProcessInstanceId().equals(pi.get("instance_id"))).findAny().get(),  
316 - dataList.parallelStream().filter(pi -> p.getBusinessKey().equals(pi.getBusinessKey()))  
317 - .findAny().get(),  
318 - tasks.parallelStream().filter(t -> p.getId().equals(t.getProcessInstanceId())).findAny()  
319 - .get());  
320 -  
321 - list.add(dto);  
322 - } catch (Exception e) {  
323 - e.printStackTrace();  
324 - }  
325 - }  
326 -  
327 - }  
328 - }  
329 -  
330 - list.sort(new Comparator<ActTaskDTO>() {  
331 -  
332 - @Override  
333 - public int compare(ActTaskDTO o1, ActTaskDTO o2) {  
334 - // TODO Auto-generated method stub  
335 - return (int) (o2.getCreatedDate().getTime() - o1.getCreatedDate().getTime());  
336 - }  
337 - });  
338 -  
339 - return list;  
340 - }  
341 -  
342 - public void getCheckData(ActTaskDTO actTaskDTOS) {  
343 - ActWorkflowFormData ActWorkflowFormData = new ActWorkflowFormData();  
344 - ActWorkflowFormData.setBusinessKey(actTaskDTOS.getBusinessKey());  
345 - ActWorkflowFormData.setCreateBy(securityManager.getAuthenticatedUserId());  
346 - ActWorkflowFormData.setControlName("审批");  
347 -  
348 - ActWorkflowFormData = actWorkflowFormDataService.selectActWorkflowFormDataList(ActWorkflowFormData).get(0);  
349 -  
350 - actTaskDTOS.setCheckStatus(ActWorkflowFormData.getControlValue().equals("通过") ? "0" : "1");  
351 - actTaskDTOS.setCreatedDate(ActWorkflowFormData.getCreateTime());  
352 -  
353 - }  
354 -  
355 - SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");  
356 -  
357 - @Override  
358 - public List<String> formDataShow(String taskID) {  
359 - Task task = taskRuntime.task(taskID);  
360 - /*  
361 - * ---------------------------------------------------------------------  
362 - * --------- FormProperty_0ueitp2--__!!类型--__!!名称--__!!是否参数--__!!默认值 例子:  
363 - * FormProperty_0lovri0--__!!string--__!!姓名--__!!f--__!!同意!!__--驳回  
364 - * FormProperty_1iu6onu--__!!int--__!!年龄--__!!s  
365 - *  
366 - * 默认值:无、字符常量、FormProperty_开头定义过的控件ID  
367 - * 是否参数:f为不是参数,s是字符,t是时间(不需要int,因为这里int等价于string)  
368 - * 注:类型是可以获取到的,但是为了统一配置原则,都配置到  
369 - */  
370 -  
371 - // 注意!!!!!!!!:表单Key必须要任务编号一模一样,因为参数需要任务key,但是无法获取,只能获取表单key“task.getFormKey()”当做任务key  
372 - UserTask userTask = (UserTask) repositoryService.getBpmnModel(task.getProcessDefinitionId())  
373 - .getFlowElement(task.getFormKey());  
374 -  
375 - if (userTask == null) {  
376 - return null;  
377 - }  
378 - List<FormProperty> formProperties = userTask.getFormProperties();  
379 - List<String> collect = formProperties.stream().map(fp -> fp.getId()).collect(Collectors.toList());  
380 -  
381 - return collect;  
382 - }  
383 -  
384 - @Override  
385 - public int formDataSave(String taskID, List<ActWorkflowFormDataDTO> awfs) throws ParseException {  
386 - Task task = taskRuntime.task(taskID);  
387 -  
388 - ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()  
389 - .processInstanceId(task.getProcessInstanceId()).singleResult();  
390 -  
391 - Map<String, Object> str = processInstance.getProcessVariables();  
392 -  
393 - String desc = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult()  
394 - .getDescription();  
395 - // 办文办事功能:分管领导指定部门时,将部门code存入desc  
396 - if (!StringUtils.isEmpty(awfs.get(0).getDeptCode())) {  
397 - desc = awfs.get(0).getDeptCode();  
398 - }  
399 -  
400 - Boolean hasVariables = false;// 没有任何参数  
401 - HashMap<String, Object> variables = new HashMap<String, Object>();  
402 - // 前端传来的字符串,拆分成每个控件  
403 - List<ActWorkflowFormData> acwfds = new ArrayList<>();  
404 - for (ActWorkflowFormDataDTO awf : awfs) {  
405 - ActWorkflowFormData actWorkflowFormData = new ActWorkflowFormData(processInstance.getBusinessKey(), awf,  
406 - task);  
407 - acwfds.add(actWorkflowFormData);  
408 - // 构建参数集合  
409 - if (!"f".equals(awf.getControlIsParam())) {  
410 - variables.put(awf.getControlId(), awf.getControlValue());  
411 - hasVariables = true;  
412 - }  
413 -  
414 - if (processInstance.getProcessDefinitionKey().equals("handleAffairs")  
415 - && awf.getControlId().equals("FormProperty_0aq22i0")) {  
416 - variables.put("index", awf.getIndex());  
417 - }  
418 - } // for结束  
419 - if (task.getAssignee() == null) {  
420 - taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());  
421 - }  
422 - if (hasVariables) {  
423 - // 带参数完成任务  
424 - taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID).withVariables(variables).build());  
425 - } else {  
426 - taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID).build());  
427 - }  
428 -  
429 - if (desc != null)  
430 - updateThreesetpTask(processInstance, desc);  
431 -  
432 - // 写入数据库  
433 - return actWorkflowFormDataService.insertActWorkflowFormDatas(acwfds);  
434 - }  
435 -  
436 - private void updateThreesetpTask(ProcessInstance processInstance, String placeCode) {  
437 -  
438 - final org.activiti.engine.task.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId())  
439 - .singleResult();  
440 -  
441 - if (task == null)  
442 - return;  
443 -  
444 - if (task != null) {  
445 - String token = SecurityUtils.getLoginUser().getToken();  
446 -  
447 - new Thread(new Runnable() {  
448 -  
449 - @Override  
450 - public void run() {  
451 -  
452 - List<Mobile> mobileList = new ArrayList<Mobile>();  
453 -  
454 - String number = actMapper.getPhoneNumber(processInstance.getProcessDefinitionKey(), task.getName());  
455 -  
456 - if (number != null) {  
457 - String smsString = "工作提醒:您有新的工作流程,请及时处理。";  
458 - Mobile mobile = new Mobile();  
459 - mobile.setMobile(number);  
460 - mobileList.add(mobile);  
461 -  
462 - if (processInstance.getProcessDefinitionKey().equals("workflow_constructsite")) {  
463 -  
464 - JSONObject json = RemoteServerUtils.getConstructionInfo(processInstance.getBusinessKey().split(":")[1],token);  
465 - if (json != null)  
466 - smsString = "审批提醒:您有新的工作流程需要审批 " + json.getString("areaCodeName") + " "  
467 - + json.getString("name");  
468 -  
469 - }  
470 -  
471 - if (processInstance.getProcessDefinitionKey().equals("workflow_caseoffline")) {  
472 -  
473 - String dname = actMapper.getCaseTypeName("case_offline_type",  
474 - processInstance.getBusinessKey().split(":")[1]);  
475 - smsString = "案卷提醒:有一条" + dname + "的案卷,请及时处理。";  
476 - }  
477 -  
478 - JsonSmsSend jsonSmsSend = PostSms.sendSms(mobileList, smsString);  
479 - if (jsonSmsSend != null) {  
480 - if (jsonSmsSend.getState() == 0) {  
481 - System.out.println("发送成功");  
482 - } else {  
483 - System.out.println(jsonSmsSend.getMessage());  
484 - }  
485 - } else {  
486 - System.out.println("发送返回空");  
487 - }  
488 - }  
489 -  
490 - }  
491 -  
492 - }).start();  
493 - }  
494 -  
495 - task.setDescription(placeCode);  
496 -  
497 - List<IdentityLink> list = taskService.getIdentityLinksForTask(task.getId());  
498 -  
499 - if (list.size() == 1) {  
500 - taskService.addCandidateUser(task.getId(), placeCode);  
501 - }  
502 -  
503 - taskService.saveTask(task);  
504 -  
505 - if ("车辆所属企业".equals(task.getName())) {  
506 - org.activiti.engine.task.Task task1 = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();  
507 - taskService.setAssignee(task1.getId(), placeCode);  
508 - return;  
509 - }  
510 -  
511 - }  
512 -  
513 - @Override  
514 - public void deleteProcessById(String type) {  
515 - runtimeService.deleteProcessInstance(type, "删除");  
516 - }  
517 -  
518 - @Override  
519 - public void endAllThreesteptask(String type) {  
520 -  
521 - List<ProcessInstance> processes = runtimeService.createProcessInstanceQuery().processDefinitionKey(type).list();  
522 -  
523 - for (ProcessInstance proc : processes) {  
524 - if (type.equals(proc.getProcessDefinitionKey())) {  
525 - try {  
526 -  
527 - String executionId = proc.getSuperExecutionId();  
528 - Map<String, Object> map = proc.getProcessVariables();  
529 -  
530 - // runtimeService.removeVariable(executionId, variableName);  
531 -  
532 - runtimeService.deleteProcessInstance(proc.getId(), "超时");  
533 - } catch (Exception e) {  
534 - e.printStackTrace();  
535 - }  
536 - }  
537 - }  
538 -  
539 - } 1 +package com.trash.activiti.service.impl;
  2 +
  3 +import java.text.ParseException;
  4 +import java.text.SimpleDateFormat;
  5 +import java.util.ArrayList;
  6 +import java.util.Comparator;
  7 +import java.util.HashMap;
  8 +import java.util.HashSet;
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +import java.util.Set;
  12 +import java.util.stream.Collectors;
  13 +
  14 +import org.activiti.api.runtime.shared.identity.UserGroupManager;
  15 +import org.activiti.api.runtime.shared.query.Pageable;
  16 +import org.activiti.api.runtime.shared.security.SecurityManager;
  17 +import org.activiti.api.task.model.Task;
  18 +import org.activiti.api.task.model.builders.TaskPayloadBuilder;
  19 +import org.activiti.bpmn.model.FormProperty;
  20 +import org.activiti.bpmn.model.UserTask;
  21 +import org.activiti.engine.HistoryService;
  22 +import org.activiti.engine.ProcessEngine;
  23 +import org.activiti.engine.ProcessEngines;
  24 +import org.activiti.engine.RepositoryService;
  25 +import org.activiti.engine.RuntimeService;
  26 +import org.activiti.engine.TaskService;
  27 +import org.activiti.engine.history.HistoricProcessInstance;
  28 +import org.activiti.engine.history.HistoricProcessInstanceQuery;
  29 +import org.activiti.engine.runtime.ProcessInstance;
  30 +import org.activiti.engine.runtime.ProcessInstanceQuery;
  31 +import org.activiti.engine.task.IdentityLink;
  32 +import org.apache.commons.collections4.map.HashedMap;
  33 +import org.springframework.beans.factory.annotation.Autowired;
  34 +import org.springframework.stereotype.Service;
  35 +
  36 +import com.alibaba.fastjson.JSONObject;
  37 +import com.github.pagehelper.Page;
  38 +import com.trash.activiti.domain.ActWorkflowFormData;
  39 +import com.trash.activiti.domain.dto.ActTaskDTO;
  40 +import com.trash.activiti.domain.dto.ActWorkflowFormDataDTO;
  41 +import com.trash.activiti.mapper.ActReDeploymentMapper;
  42 +import com.trash.activiti.mapper.ActWorkflowFormDataMapper;
  43 +import com.trash.activiti.service.IActTaskService;
  44 +import com.trash.activiti.service.IActWorkflowFormDataService;
  45 +import com.trash.activiti.service.myTaskService;
  46 +import com.trash.common.core.page.PageDomain;
  47 +import com.trash.common.core.redis.RedisCache;
  48 +import com.trash.common.utils.RemoteServerUtils;
  49 +import com.trash.common.utils.SecurityUtils;
  50 +import com.trash.common.utils.ServletUtils;
  51 +import com.trash.common.utils.StringUtils;
  52 +import com.trash.common.utils.util.PostSms;
  53 +import com.trash.common.utils.vo.mt.JsonSmsSend;
  54 +import com.trash.common.utils.vo.mt.Mobile;
  55 +
  56 +@Service
  57 +public class ActTaskServiceImpl implements IActTaskService {
  58 +
  59 + @Autowired
  60 + private RepositoryService repositoryService;
  61 +
  62 + @Autowired
  63 + private myTaskService taskRuntime;
  64 +
  65 + @Autowired
  66 + private TaskService taskService;
  67 +
  68 + @Autowired
  69 + private RuntimeService runtimeService;
  70 +
  71 + @Autowired
  72 + private IActWorkflowFormDataService actWorkflowFormDataService;
  73 +
  74 + @Autowired
  75 + private ActWorkflowFormDataMapper actWorkflowFormDataMapper;
  76 +
  77 + @Autowired
  78 + private ActReDeploymentMapper actMapper;
  79 +
  80 + @Autowired
  81 + SecurityManager securityManager;
  82 +
  83 + @Autowired
  84 + UserGroupManager userGroupManager;
  85 +
  86 + HistoricProcessInstanceQuery processInstanceQuery;
  87 +
  88 + @Autowired
  89 + private RedisCache redisCache;
  90 +
  91 + @Override
  92 + public Page<ActTaskDTO> selectProcessDefinitionList(PageDomain pageDomain) {
  93 + Page<ActTaskDTO> list = new Page<ActTaskDTO>();
  94 + List<ActTaskDTO> actTaskDTOS = new ArrayList<>();
  95 +
  96 + if (ServletUtils.getParameter("role") != null) {
  97 + List<String> posts = new ArrayList<>();
  98 + posts.add(ServletUtils.getParameter("role"));
  99 + SecurityUtils.getLoginUser().getUser().setPostIds(posts);
  100 + }
  101 + if (ServletUtils.getParameter("dept") != null) {
  102 + List<String> roles = new ArrayList<>();
  103 + roles.add(ServletUtils.getParameter("dept"));
  104 + SecurityUtils.getLoginUser().getUser().setRoleIds(roles);
  105 + }
  106 + if (SecurityUtils.getLoginUser().getUser().getPostIds().size() == 0
  107 + || SecurityUtils.getLoginUser().getUser().getRoleIds().size() == 0) {
  108 + return list;
  109 + }
  110 +
  111 + String type = ServletUtils.getParameter("type");
  112 + String prev = ServletUtils.getParameter("prev");
  113 + String name = ServletUtils.getParameter("name");
  114 + if (type != null && type.isEmpty()) {
  115 + type = null;
  116 + }
  117 + if (prev != null && prev.isEmpty()) {
  118 + prev = null;
  119 + }
  120 +
  121 + String[] strings;
  122 + Set<String> keys = new HashSet<String>();
  123 +
  124 + if (type != null && !type.isEmpty()) {
  125 + strings = type.split(",");
  126 + keys = new HashSet<String>();
  127 +
  128 + for (String str : strings) {
  129 + keys.add(str);
  130 + }
  131 + }
  132 + org.activiti.api.runtime.shared.query.Page<Task> pageTasks;
  133 +
  134 + int pageNum = pageDomain.getPageNum();
  135 + int pageSize = pageDomain.getPageSize();
  136 + if (prev == null) {
  137 + pageTasks = taskRuntime.tasks(Pageable.of((pageNum - 1) * pageSize, pageSize), null, keys, name);
  138 + } else {
  139 + pageTasks = taskRuntime.tasks(Pageable.of(0, 999999), null, keys, name);
  140 + }
  141 +
  142 + List<Task> tasks = pageTasks.getContent();
  143 + int totalItems = pageTasks.getTotalItems();
  144 +
  145 + list.setTotal(totalItems);
  146 +
  147 + if (totalItems != 0) {
  148 +
  149 + Set<String> processInstanceIdIds = tasks.parallelStream().map(t -> t.getProcessInstanceId())
  150 + .collect(Collectors.toSet());
  151 +
  152 + if (processInstanceIdIds.size() > 0) {
  153 +
  154 + List<Map<String, Object>> maps = actMapper.selectWorkByIds(processInstanceIdIds);
  155 +
  156 + for (Task task : tasks) {
  157 + try {
  158 + ActTaskDTO dto = new ActTaskDTO(task, maps.parallelStream()
  159 + .filter(t -> t.get("instance_id").equals(task.getProcessInstanceId())).findAny().get());
  160 +
  161 + if (prev != null && !prev.isEmpty()
  162 + && (dto.getPrev() == null || !dto.getPrev().contains(prev))) {
  163 + continue;
  164 + }
  165 +
  166 + list.add(dto);
  167 + } catch (Exception e) {
  168 + e.printStackTrace();
  169 + }
  170 + }
  171 + }
  172 + }
  173 +
  174 + if (prev != null) {
  175 + list.setTotal(list.size());
  176 + }
  177 +
  178 + return list;
  179 + }
  180 +
  181 + @Override
  182 + public Page<ActTaskDTO> selectTaskEndHistoryDefinitionList(PageDomain pageDomain) {
  183 +
  184 + int pageNum = pageDomain.getPageNum();
  185 + int pageSize = pageDomain.getPageSize();
  186 +
  187 + Page<ActTaskDTO> list = new Page<ActTaskDTO>();
  188 +
  189 + ProcessEngine pes = ProcessEngines.getDefaultProcessEngine();
  190 + HistoryService historyService = pes.getHistoryService();
  191 +
  192 + String username = securityManager.getAuthenticatedUserId();
  193 +
  194 + Map map = new HashedMap<>();
  195 +
  196 + String type = ServletUtils.getParameter("type");
  197 + String name = ServletUtils.getParameter("name");
  198 + if (type != null && type.isEmpty()) {
  199 + type = null;
  200 + }
  201 + if (name != null && name.isEmpty()) {
  202 + name = null;
  203 + }
  204 + map.put("username", username);
  205 + if (name != null)
  206 + map.put("name", name);
  207 +
  208 + List<HistoricProcessInstance> processInstanceList;
  209 +
  210 + HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().involvedUser(username)
  211 + .finished().orderByProcessInstanceStartTime().desc();
  212 +
  213 + if (name != null)
  214 + query.processInstanceNameLike("%" + name + "%");
  215 +
  216 + if (type != null && !type.isEmpty()) {
  217 + List<String> types = new ArrayList<String>();
  218 + for (String string : type.split(",")) {
  219 + types.add(string);
  220 + }
  221 + query.processDefinitionKeyIn(types);
  222 + }
  223 +
  224 + list.setTotal(query.count());
  225 +
  226 + processInstanceList = query.listPage((pageNum - 1) * pageSize, pageSize);
  227 +
  228 + // List<ActWorkflowFormData> dataList =
  229 + // actWorkflowFormDataMapper.selectActWorkFlowFormDataListByUser(username);
  230 +
  231 + if (processInstanceList.size() > 0) {
  232 +
  233 + Set<String> idString = new HashSet<String>();
  234 + for (HistoricProcessInstance pi : processInstanceList) {
  235 + idString.add(pi.getId());
  236 + }
  237 +
  238 + List<Map<String, Object>> maps = actMapper.selectHistoryWorkByPIds(idString);
  239 +
  240 + for (HistoricProcessInstance p : processInstanceList) {
  241 + try {
  242 + ActTaskDTO dto = new ActTaskDTO(p, maps.parallelStream()
  243 + .filter(pi -> p.getId().equals(pi.get("instance_id"))).findAny().get());
  244 +
  245 + list.add(dto);
  246 + } catch (Exception e) {
  247 + System.out.println(p.getBusinessKey());
  248 + e.printStackTrace();
  249 + }
  250 + }
  251 +
  252 + }
  253 +
  254 + return list;
  255 + }
  256 +
  257 + @Override
  258 + public Page<ActTaskDTO> selectRuntimeTaskHistoryDefinitionList(PageDomain pageDomain) {
  259 + Page<ActTaskDTO> list = new Page<ActTaskDTO>();
  260 +
  261 + int pageNum = pageDomain.getPageNum();
  262 + int pageSize = pageDomain.getPageSize();
  263 + String username = securityManager.getAuthenticatedUserId();
  264 +
  265 + Map map = new HashedMap<>();
  266 +
  267 + String type = ServletUtils.getParameter("type");
  268 + String name = ServletUtils.getParameter("name");
  269 + map.put("username", username);
  270 + if (type != null && type.isEmpty()) {
  271 + type = null;
  272 + }
  273 + if (name != null && name.isEmpty()) {
  274 + name = null;
  275 + }
  276 +
  277 + ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().involvedUser(username);
  278 +
  279 + if (name != null)
  280 + query.processInstanceNameLike("%" + name + "%");
  281 +
  282 + if (type != null && !type.isEmpty()) {
  283 + Set<String> types = new HashSet<String>();
  284 + for (String string : type.split(",")) {
  285 + types.add(string);
  286 + }
  287 + query.processDefinitionKeys(types);
  288 + }
  289 +
  290 + List<ProcessInstance> processInstanceList = query.list();
  291 +
  292 + list.setTotal(query.count());
  293 +
  294 + processInstanceList = query.listPage((pageNum - 1) * pageSize, pageSize);
  295 +
  296 + if (processInstanceList.size() > 0) {
  297 +
  298 + List<String> pids = processInstanceList.parallelStream().map(p -> p.getId()).collect(Collectors.toList());
  299 +
  300 + List<org.activiti.engine.task.Task> tasks = taskService.createTaskQuery().processInstanceIdIn(pids).list();
  301 +
  302 + Set<String> idString = new HashSet<String>();
  303 + for (ProcessInstance pi : processInstanceList) {
  304 + idString.add(pi.getId());
  305 + }
  306 +
  307 + List<Map<String, Object>> maps = actMapper.selectWorkByIds(idString);
  308 +
  309 + List<ActWorkflowFormData> dataList = actWorkflowFormDataMapper
  310 + .selectActWorkFlowFormDataListByUser(username);
  311 + if (processInstanceList.size() > 0) {
  312 + for (ProcessInstance p : processInstanceList) {
  313 + try {
  314 + ActTaskDTO dto = new ActTaskDTO(p, maps.parallelStream()
  315 + .filter(pi -> p.getProcessInstanceId().equals(pi.get("instance_id"))).findAny().get(),
  316 + dataList.parallelStream().filter(pi -> p.getBusinessKey().equals(pi.getBusinessKey()))
  317 + .findAny().get(),
  318 + tasks.parallelStream().filter(t -> p.getId().equals(t.getProcessInstanceId())).findAny()
  319 + .get());
  320 +
  321 + list.add(dto);
  322 + } catch (Exception e) {
  323 + e.printStackTrace();
  324 + }
  325 + }
  326 +
  327 + }
  328 + }
  329 +
  330 + list.sort(new Comparator<ActTaskDTO>() {
  331 +
  332 + @Override
  333 + public int compare(ActTaskDTO o1, ActTaskDTO o2) {
  334 + // TODO Auto-generated method stub
  335 + return (int) (o2.getCreatedDate().getTime() - o1.getCreatedDate().getTime());
  336 + }
  337 + });
  338 +
  339 + return list;
  340 + }
  341 +
  342 + public void getCheckData(ActTaskDTO actTaskDTOS) {
  343 + ActWorkflowFormData ActWorkflowFormData = new ActWorkflowFormData();
  344 + ActWorkflowFormData.setBusinessKey(actTaskDTOS.getBusinessKey());
  345 + ActWorkflowFormData.setCreateBy(securityManager.getAuthenticatedUserId());
  346 + ActWorkflowFormData.setControlName("审批");
  347 +
  348 + ActWorkflowFormData = actWorkflowFormDataService.selectActWorkflowFormDataList(ActWorkflowFormData).get(0);
  349 +
  350 + actTaskDTOS.setCheckStatus(ActWorkflowFormData.getControlValue().equals("通过") ? "0" : "1");
  351 + actTaskDTOS.setCreatedDate(ActWorkflowFormData.getCreateTime());
  352 +
  353 + }
  354 +
  355 + SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
  356 +
  357 + @Override
  358 + public List<String> formDataShow(String taskID) {
  359 + Task task = taskRuntime.task(taskID);
  360 + /*
  361 + * ---------------------------------------------------------------------
  362 + * --------- FormProperty_0ueitp2--__!!类型--__!!名称--__!!是否参数--__!!默认值 例子:
  363 + * FormProperty_0lovri0--__!!string--__!!姓名--__!!f--__!!同意!!__--驳回
  364 + * FormProperty_1iu6onu--__!!int--__!!年龄--__!!s
  365 + *
  366 + * 默认值:无、字符常量、FormProperty_开头定义过的控件ID
  367 + * 是否参数:f为不是参数,s是字符,t是时间(不需要int,因为这里int等价于string)
  368 + * 注:类型是可以获取到的,但是为了统一配置原则,都配置到
  369 + */
  370 +
  371 + // 注意!!!!!!!!:表单Key必须要任务编号一模一样,因为参数需要任务key,但是无法获取,只能获取表单key“task.getFormKey()”当做任务key
  372 + UserTask userTask = (UserTask) repositoryService.getBpmnModel(task.getProcessDefinitionId())
  373 + .getFlowElement(task.getFormKey());
  374 +
  375 + if (userTask == null) {
  376 + return null;
  377 + }
  378 + List<FormProperty> formProperties = userTask.getFormProperties();
  379 + List<String> collect = formProperties.stream().map(fp -> fp.getId()).collect(Collectors.toList());
  380 +
  381 + return collect;
  382 + }
  383 +
  384 + @Override
  385 + public int formDataSave(String taskID, List<ActWorkflowFormDataDTO> awfs) throws ParseException {
  386 + Task task = taskRuntime.task(taskID);
  387 +
  388 + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
  389 + .processInstanceId(task.getProcessInstanceId()).singleResult();
  390 +
  391 + Map<String, Object> str = processInstance.getProcessVariables();
  392 +
  393 + String desc = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult()
  394 + .getDescription();
  395 + // 办文办事功能:分管领导指定部门时,将部门code存入desc
  396 + if (!StringUtils.isEmpty(awfs.get(0).getDeptCode())) {
  397 + desc = awfs.get(0).getDeptCode();
  398 + }
  399 +
  400 + Boolean hasVariables = false;// 没有任何参数
  401 + HashMap<String, Object> variables = new HashMap<String, Object>();
  402 + // 前端传来的字符串,拆分成每个控件
  403 + List<ActWorkflowFormData> acwfds = new ArrayList<>();
  404 + for (ActWorkflowFormDataDTO awf : awfs) {
  405 + ActWorkflowFormData actWorkflowFormData = new ActWorkflowFormData(processInstance.getBusinessKey(), awf,
  406 + task);
  407 + acwfds.add(actWorkflowFormData);
  408 + // 构建参数集合
  409 + if (!"f".equals(awf.getControlIsParam())) {
  410 + variables.put(awf.getControlId(), awf.getControlValue());
  411 + hasVariables = true;
  412 + }
  413 +
  414 + if (processInstance.getProcessDefinitionKey().equals("handleAffairs")
  415 + && awf.getControlId().equals("FormProperty_0aq22i0")) {
  416 + variables.put("index", awf.getIndex());
  417 + }
  418 + } // for结束
  419 + if (task.getAssignee() == null) {
  420 + taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
  421 + }
  422 + if (hasVariables) {
  423 + // 带参数完成任务
  424 + taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID).withVariables(variables).build());
  425 + } else {
  426 + taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskID).build());
  427 + }
  428 +
  429 + checkSMS(processInstance);
  430 +
  431 + if (desc != null)
  432 + updateThreesetpTask(processInstance, desc);
  433 +
  434 + // 写入数据库
  435 + return actWorkflowFormDataService.insertActWorkflowFormDatas(acwfds);
  436 + }
  437 +
  438 +
  439 +
  440 + public void checkSMS(ProcessInstance processInstance){
  441 + final org.activiti.engine.task.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId())
  442 + .singleResult();
  443 +
  444 + if (task == null)
  445 + return;
  446 +
  447 + if (task != null) {
  448 + String token = SecurityUtils.getLoginUser().getToken();
  449 +
  450 + new Thread(new Runnable() {
  451 +
  452 + @Override
  453 + public void run() {
  454 +
  455 + List<Mobile> mobileList = new ArrayList<Mobile>();
  456 +
  457 + String number = actMapper.getPhoneNumber(processInstance.getProcessDefinitionKey(), task.getName());
  458 +
  459 + if (number != null) {
  460 + String smsString = "工作提醒:您有新的工作流程,请及时处理。";
  461 + Mobile mobile = new Mobile();
  462 + mobile.setMobile(number);
  463 + mobileList.add(mobile);
  464 +
  465 + if (processInstance.getProcessDefinitionKey().equals("workflow_constructsite")) {
  466 +
  467 + JSONObject json = RemoteServerUtils.getConstructionInfo(processInstance.getBusinessKey().split(":")[1],token);
  468 + if (json != null)
  469 + smsString = "审批提醒:您有新的工作流程需要审批 " + json.getString("areaCodeName") + " "
  470 + + json.getString("name");
  471 +
  472 + }
  473 +
  474 + if (processInstance.getProcessDefinitionKey().equals("workflow_caseoffline")) {
  475 +
  476 + String dname = actMapper.getCaseTypeName("case_offline_type",
  477 + processInstance.getBusinessKey().split(":")[1]);
  478 + smsString = "案卷提醒:有一条" + dname + "的案卷,请及时处理。";
  479 + }
  480 +
  481 + JsonSmsSend jsonSmsSend = PostSms.sendSms(mobileList, smsString);
  482 + if (jsonSmsSend != null) {
  483 + if (jsonSmsSend.getState() == 0) {
  484 + System.out.println("发送成功");
  485 + } else {
  486 + System.out.println(jsonSmsSend.getMessage());
  487 + }
  488 + } else {
  489 + System.out.println("发送返回空");
  490 + }
  491 + }
  492 +
  493 + }
  494 +
  495 + }).start();
  496 + }
  497 +
  498 + }
  499 +
  500 + private void updateThreesetpTask(ProcessInstance processInstance, String placeCode) {
  501 +
  502 + final org.activiti.engine.task.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId())
  503 + .singleResult();
  504 +
  505 + if (task == null)
  506 + return;
  507 +
  508 + task.setDescription(placeCode);
  509 +
  510 + List<IdentityLink> list = taskService.getIdentityLinksForTask(task.getId());
  511 +
  512 + if (list.size() == 1) {
  513 + taskService.addCandidateUser(task.getId(), placeCode);
  514 + }
  515 +
  516 + taskService.saveTask(task);
  517 +
  518 + if ("车辆所属企业".equals(task.getName())) {
  519 + org.activiti.engine.task.Task task1 = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
  520 + taskService.setAssignee(task1.getId(), placeCode);
  521 + return;
  522 + }
  523 +
  524 + }
  525 +
  526 + @Override
  527 + public void deleteProcessById(String type) {
  528 + runtimeService.deleteProcessInstance(type, "删除");
  529 + }
  530 +
  531 + @Override
  532 + public void endAllThreesteptask(String type) {
  533 +
  534 + List<ProcessInstance> processes = runtimeService.createProcessInstanceQuery().processDefinitionKey(type).list();
  535 +
  536 + for (ProcessInstance proc : processes) {
  537 + if (type.equals(proc.getProcessDefinitionKey())) {
  538 + try {
  539 +
  540 + String executionId = proc.getSuperExecutionId();
  541 + Map<String, Object> map = proc.getProcessVariables();
  542 +
  543 + // runtimeService.removeVariable(executionId, variableName);
  544 +
  545 + runtimeService.deleteProcessInstance(proc.getId(), "超时");
  546 + } catch (Exception e) {
  547 + e.printStackTrace();
  548 + }
  549 + }
  550 + }
  551 +
  552 + }
540 } 553 }
541 \ No newline at end of file 554 \ No newline at end of file
trash-activiti/src/main/java/com/trash/activiti/service/impl/FormHistoryDataServiceImpl.java
1 -package com.trash.activiti.service.impl;  
2 -  
3 -import org.activiti.engine.RuntimeService;  
4 -import org.activiti.engine.TaskService;  
5 -import org.activiti.engine.runtime.ProcessInstance;  
6 -import org.activiti.engine.runtime.ProcessInstanceQuery;  
7 -import org.activiti.engine.task.Task;  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.stereotype.Service;  
10 -  
11 -import com.trash.activiti.domain.ActWorkflowFormData;  
12 -import com.trash.activiti.domain.dto.HistoryDataDTO;  
13 -import com.trash.activiti.domain.dto.HistoryFormDataDTO;  
14 -import com.trash.activiti.mapper.ActWorkflowFormDataMapper;  
15 -import com.trash.activiti.service.IActWorkflowFormDataService;  
16 -import com.trash.activiti.service.IFormHistoryDataService;  
17 -import com.trash.common.utils.DateUtils;  
18 -  
19 -import java.text.SimpleDateFormat;  
20 -import java.util.*;  
21 -import java.util.stream.Collector;  
22 -import java.util.stream.Collectors;  
23 -  
24 -/**  
25 - * 汇讯数码科技(深圳)有限公司  
26 - * 创建日期:2020/11/3-10:20  
27 - * 版本 开发者 日期  
28 - * 1.0 Danny 2020/11/3  
29 - */  
30 -@Service  
31 -public class FormHistoryDataServiceImpl implements IFormHistoryDataService {  
32 - @Autowired  
33 - private IActWorkflowFormDataService actWorkflowFormDataService;  
34 -  
35 - @Autowired  
36 - private ActWorkflowFormDataMapper formDataMapper;  
37 -  
38 -  
39 - private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
40 -  
41 -  
42 - @Autowired  
43 - private RuntimeService runtimeService;  
44 -  
45 - @Autowired  
46 - private TaskService taskService;  
47 -  
48 - @Override  
49 - public List<ActWorkflowFormData> historyDataShow(String businessKey) {  
50 - List<ActWorkflowFormData> returnHistoryFromDataDTOS=new ArrayList<>();  
51 - List<ActWorkflowFormData> actWorkflowFormData=new ArrayList<>();  
52 -  
53 - List<Task> tasks = null;  
54 -  
55 -  
56 - getEditData(businessKey,returnHistoryFromDataDTOS,actWorkflowFormData);  
57 -//  
58 -// if(businessKey.contains("constructsite")){  
59 -// String id = businessKey.split(":")[1];  
60 -// getEditData(id,"constructsite",returnHistoryFromDataDTOS,actWorkflowFormData);  
61 -// }else if(businessKey.contains("earthsites")){  
62 -// String id = businessKey.split(":")[1];  
63 -// getEditData(id,"earthsites",returnHistoryFromDataDTOS,actWorkflowFormData);  
64 -// }else if(businessKey.contains("conract")){  
65 -//  
66 -// String id = businessKey.split(":")[1];  
67 -// getEditData(id,"conract",returnHistoryFromDataDTOS,actWorkflowFormData);  
68 -//  
69 -// }else{  
70 -//  
71 -// tasks =taskService.createTaskQuery().processInstanceBusinessKey(businessKey).list();  
72 -//  
73 -// if(tasks.size() > 0){  
74 -//  
75 -// ActWorkflowFormData afw = new ActWorkflowFormData();  
76 -//  
77 -//  
78 -// afw.setControlName("审批");  
79 -// afw.setControlValue("待处理");  
80 -// afw.setTaskNodeName(tasks.get(0).getName());  
81 -// afw.setCreateBy(tasks.get(0).getName());  
82 -// afw.setCreateName(tasks.get(0).getName());  
83 -// afw.setCreateTime(new Date());  
84 -//  
85 -// returnHistoryFromDataDTOS.add(afw);  
86 -// }  
87 -//  
88 -// actWorkflowFormData = actWorkflowFormDataService.selectActWorkflowFormDataByBusinessKey(businessKey);  
89 -// }  
90 -  
91 -  
92 - for(int i =0;i<actWorkflowFormData.size();i++){  
93 - if(i == actWorkflowFormData.size()-1){  
94 - returnHistoryFromDataDTOS.add(actWorkflowFormData.get(i));  
95 - continue;  
96 - }  
97 -  
98 - ActWorkflowFormData one = actWorkflowFormData.get(i);  
99 - ActWorkflowFormData two = actWorkflowFormData.get(i+1);  
100 -  
101 -  
102 - if(one.getCreateBy().equals(two.getCreateBy()) && one.getCreateTime().getTime() == two.getCreateTime().getTime()){  
103 -  
104 - String twoValue = two.getControlValue() == null ? "" : "," + two.getControlValue();  
105 -  
106 - one.setControlValue(one.getControlValue() + twoValue);  
107 -  
108 - returnHistoryFromDataDTOS.add(one);  
109 - i+=1;  
110 - continue;  
111 - }  
112 -  
113 - returnHistoryFromDataDTOS.add(one);  
114 - }  
115 -  
116 -  
117 -// Map<String, List<ActWorkflowFormData>> collect = actWorkflowFormData.stream().collect(Collectors.groupingBy(ActWorkflowFormData::getTaskNodeName));  
118 -// collect.entrySet().forEach(  
119 -// entry -> {  
120 -// HistoryDataDTO returnHistoryFromDataDTO = new HistoryDataDTO();  
121 -// returnHistoryFromDataDTO.setTaskNodeName(entry.getValue().get(0).getTaskNodeName());  
122 -// returnHistoryFromDataDTO.setCreateName(entry.getValue().get(0).getCreateName());  
123 -// returnHistoryFromDataDTO.setCreatedDate(sdf.format(entry.getValue().get(0).getCreateTime()));  
124 -// returnHistoryFromDataDTO.setFormHistoryDataDTO(entry.getValue().stream().map(awfd->new HistoryFormDataDTO(awfd.getControlName(),awfd.getControlValue())).collect(Collectors.toList()));  
125 -// returnHistoryFromDataDTOS.add(returnHistoryFromDataDTO);  
126 -// }  
127 -// );  
128 -  
129 - returnHistoryFromDataDTOS = returnHistoryFromDataDTOS.stream().sorted((x,y) -> x.getCreateTime().compareTo(y.getCreateTime())).collect(Collectors.toList());  
130 -  
131 -  
132 - return returnHistoryFromDataDTOS;  
133 - }  
134 -  
135 -  
136 - private void getEditData(String businessKey,List<ActWorkflowFormData> returnHistoryFromDataDTOS,List<ActWorkflowFormData> actWorkflowFormData) {  
137 -  
138 - List<Task> tasks =taskService.createTaskQuery().processInstanceBusinessKey(businessKey).list();  
139 - if(tasks.size() > 0){  
140 - ActWorkflowFormData afw = new ActWorkflowFormData();  
141 - afw.setControlName("审批");  
142 - afw.setControlValue("待处理");  
143 - afw.setTaskNodeName(tasks.get(0).getName());  
144 - afw.setCreateBy(tasks.get(0).getName());  
145 - afw.setCreateName(tasks.get(0).getName());  
146 - afw.setCreateTime(new Date());  
147 - returnHistoryFromDataDTOS.add(afw);  
148 - }  
149 - tasks =taskService.createTaskQuery().processInstanceBusinessKey(businessKey.replace(":", "_edit:")).list();  
150 - if(tasks.size() > 0){  
151 - ActWorkflowFormData afw = new ActWorkflowFormData();  
152 - afw.setControlName("审批");  
153 - afw.setControlValue("待处理");  
154 - afw.setTaskNodeName(tasks.get(0).getName());  
155 - afw.setCreateBy(tasks.get(0).getName());  
156 - afw.setCreateName(tasks.get(0).getName());  
157 - afw.setCreateTime(new Date());  
158 - returnHistoryFromDataDTOS.add(afw);  
159 - }  
160 -  
161 - actWorkflowFormData.addAll( actWorkflowFormDataService.selectActWorkflowFormDataByBusinessKey( businessKey));  
162 -  
163 - actWorkflowFormData.addAll( actWorkflowFormDataService.selectActWorkflowFormDataByBusinessKey(businessKey.replace(":", "_edit:")));  
164 -  
165 - }  
166 -  
167 -  
168 - @Override  
169 - public List<ActWorkflowFormData> historyFromDataByTime(Map<String,String> map) {  
170 - List<ActWorkflowFormData> returnHistoryFromDataDTOS=new ArrayList<>();  
171 - List<ActWorkflowFormData> actWorkflowFormData=new ArrayList<>();  
172 -  
173 - String businessKey = map.get("businessKey");  
174 -  
175 -  
176 -  
177 - actWorkflowFormData = formDataMapper.selectNewActWorkflowFormDataByBusinessKey(map);  
178 -  
179 -  
180 -  
181 -  
182 - for(int i =0;i<actWorkflowFormData.size();i++){  
183 - if(i == actWorkflowFormData.size()-1){  
184 - returnHistoryFromDataDTOS.add(actWorkflowFormData.get(i));  
185 - continue;  
186 - }  
187 -  
188 - ActWorkflowFormData one = actWorkflowFormData.get(i);  
189 - ActWorkflowFormData two = actWorkflowFormData.get(i+1);  
190 -  
191 - if(one.getCreateBy().equals(two.getCreateBy()) && one.getCreateTime().getTime() == two.getCreateTime().getTime()){  
192 -  
193 - String twoValue = two.getControlValue() == null ? "" : "," + two.getControlValue();  
194 -  
195 - one.setControlValue(one.getControlValue() + twoValue);  
196 -  
197 - returnHistoryFromDataDTOS.add(one);  
198 - i+=1;  
199 - continue;  
200 - }  
201 -  
202 - returnHistoryFromDataDTOS.add(one);  
203 - }  
204 -  
205 -  
206 -  
207 - returnHistoryFromDataDTOS = returnHistoryFromDataDTOS.stream().sorted((x,y) -> x.getCreateTime().compareTo(y.getCreateTime())).collect(Collectors.toList());  
208 -  
209 -  
210 - return returnHistoryFromDataDTOS;  
211 - }  
212 -  
213 -  
214 -} 1 +package com.trash.activiti.service.impl;
  2 +
  3 +import org.activiti.engine.RuntimeService;
  4 +import org.activiti.engine.TaskService;
  5 +import org.activiti.engine.runtime.ProcessInstance;
  6 +import org.activiti.engine.runtime.ProcessInstanceQuery;
  7 +import org.activiti.engine.task.Task;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import com.trash.activiti.domain.ActWorkflowFormData;
  12 +import com.trash.activiti.domain.dto.HistoryDataDTO;
  13 +import com.trash.activiti.domain.dto.HistoryFormDataDTO;
  14 +import com.trash.activiti.mapper.ActWorkflowFormDataMapper;
  15 +import com.trash.activiti.service.IActWorkflowFormDataService;
  16 +import com.trash.activiti.service.IFormHistoryDataService;
  17 +import com.trash.common.utils.DateUtils;
  18 +
  19 +import java.text.SimpleDateFormat;
  20 +import java.util.*;
  21 +import java.util.stream.Collector;
  22 +import java.util.stream.Collectors;
  23 +
  24 +/**
  25 + * 汇讯数码科技(深圳)有限公司
  26 + * 创建日期:2020/11/3-10:20
  27 + * 版本 开发者 日期
  28 + * 1.0 Danny 2020/11/3
  29 + */
  30 +@Service
  31 +public class FormHistoryDataServiceImpl implements IFormHistoryDataService {
  32 + @Autowired
  33 + private IActWorkflowFormDataService actWorkflowFormDataService;
  34 +
  35 + @Autowired
  36 + private ActWorkflowFormDataMapper formDataMapper;
  37 +
  38 +
  39 + private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  40 +
  41 +
  42 + @Autowired
  43 + private RuntimeService runtimeService;
  44 +
  45 + @Autowired
  46 + private TaskService taskService;
  47 +
  48 + @Override
  49 + public List<ActWorkflowFormData> historyDataShow(String businessKey) {
  50 + List<ActWorkflowFormData> returnHistoryFromDataDTOS=new ArrayList<>();
  51 + List<ActWorkflowFormData> actWorkflowFormData=new ArrayList<>();
  52 +
  53 + List<Task> tasks = null;
  54 +
  55 +
  56 + getEditData(businessKey,returnHistoryFromDataDTOS,actWorkflowFormData);
  57 +//
  58 +// if(businessKey.contains("constructsite")){
  59 +// String id = businessKey.split(":")[1];
  60 +// getEditData(id,"constructsite",returnHistoryFromDataDTOS,actWorkflowFormData);
  61 +// }else if(businessKey.contains("earthsites")){
  62 +// String id = businessKey.split(":")[1];
  63 +// getEditData(id,"earthsites",returnHistoryFromDataDTOS,actWorkflowFormData);
  64 +// }else if(businessKey.contains("conract")){
  65 +//
  66 +// String id = businessKey.split(":")[1];
  67 +// getEditData(id,"conract",returnHistoryFromDataDTOS,actWorkflowFormData);
  68 +//
  69 +// }else{
  70 +//
  71 +// tasks =taskService.createTaskQuery().processInstanceBusinessKey(businessKey).list();
  72 +//
  73 +// if(tasks.size() > 0){
  74 +//
  75 +// ActWorkflowFormData afw = new ActWorkflowFormData();
  76 +//
  77 +//
  78 +// afw.setControlName("审批");
  79 +// afw.setControlValue("待处理");
  80 +// afw.setTaskNodeName(tasks.get(0).getName());
  81 +// afw.setCreateBy(tasks.get(0).getName());
  82 +// afw.setCreateName(tasks.get(0).getName());
  83 +// afw.setCreateTime(new Date());
  84 +//
  85 +// returnHistoryFromDataDTOS.add(afw);
  86 +// }
  87 +//
  88 +// actWorkflowFormData = actWorkflowFormDataService.selectActWorkflowFormDataByBusinessKey(businessKey);
  89 +// }
  90 +
  91 +
  92 + for(int i =0;i<actWorkflowFormData.size();i++){
  93 + if(i == actWorkflowFormData.size()-1){
  94 + returnHistoryFromDataDTOS.add(actWorkflowFormData.get(i));
  95 + continue;
  96 + }
  97 +
  98 + ActWorkflowFormData one = actWorkflowFormData.get(i);
  99 + ActWorkflowFormData two = actWorkflowFormData.get(i+1);
  100 +
  101 +
  102 + if(one.getCreateBy().equals(two.getCreateBy()) && one.getCreateTime().getTime() == two.getCreateTime().getTime()){
  103 +
  104 + String twoValue = two.getControlValue() == null ? "" : "," + two.getControlValue();
  105 +
  106 + one.setControlValue(one.getControlValue() + twoValue);
  107 +
  108 + returnHistoryFromDataDTOS.add(one);
  109 + i+=1;
  110 + continue;
  111 + }
  112 +
  113 + returnHistoryFromDataDTOS.add(one);
  114 + }
  115 +
  116 +
  117 +// Map<String, List<ActWorkflowFormData>> collect = actWorkflowFormData.stream().collect(Collectors.groupingBy(ActWorkflowFormData::getTaskNodeName));
  118 +// collect.entrySet().forEach(
  119 +// entry -> {
  120 +// HistoryDataDTO returnHistoryFromDataDTO = new HistoryDataDTO();
  121 +// returnHistoryFromDataDTO.setTaskNodeName(entry.getValue().get(0).getTaskNodeName());
  122 +// returnHistoryFromDataDTO.setCreateName(entry.getValue().get(0).getCreateName());
  123 +// returnHistoryFromDataDTO.setCreatedDate(sdf.format(entry.getValue().get(0).getCreateTime()));
  124 +// returnHistoryFromDataDTO.setFormHistoryDataDTO(entry.getValue().stream().map(awfd->new HistoryFormDataDTO(awfd.getControlName(),awfd.getControlValue())).collect(Collectors.toList()));
  125 +// returnHistoryFromDataDTOS.add(returnHistoryFromDataDTO);
  126 +// }
  127 +// );
  128 +
  129 + returnHistoryFromDataDTOS = returnHistoryFromDataDTOS.stream().sorted((x,y) -> x.getCreateTime().compareTo(y.getCreateTime())).collect(Collectors.toList());
  130 +
  131 +
  132 + return returnHistoryFromDataDTOS;
  133 + }
  134 +
  135 +
  136 + private void getEditData(String businessKey,List<ActWorkflowFormData> returnHistoryFromDataDTOS,List<ActWorkflowFormData> actWorkflowFormData) {
  137 +
  138 + List<Task> tasks =taskService.createTaskQuery().processInstanceBusinessKey(businessKey).list();
  139 + if(tasks.size() > 0){
  140 + ActWorkflowFormData afw = new ActWorkflowFormData();
  141 + afw.setControlName("审批");
  142 + afw.setControlValue("待处理");
  143 + afw.setTaskNodeName(tasks.get(0).getName());
  144 + afw.setCreateBy(tasks.get(0).getName());
  145 + afw.setCreateName(tasks.get(0).getName());
  146 + afw.setCreateTime(new Date());
  147 + returnHistoryFromDataDTOS.add(afw);
  148 + }
  149 + tasks =taskService.createTaskQuery().processInstanceBusinessKey(businessKey.replace(":", "_edit:")).list();
  150 + if(tasks.size() > 0){
  151 + ActWorkflowFormData afw = new ActWorkflowFormData();
  152 + afw.setControlName("审批");
  153 + afw.setControlValue("待处理");
  154 + afw.setTaskNodeName(tasks.get(0).getName());
  155 + afw.setCreateBy(tasks.get(0).getName());
  156 + afw.setCreateName(tasks.get(0).getName());
  157 + afw.setCreateTime(new Date());
  158 + returnHistoryFromDataDTOS.add(afw);
  159 + }
  160 +
  161 + actWorkflowFormData.addAll( actWorkflowFormDataService.selectActWorkflowFormDataByBusinessKey( businessKey));
  162 +
  163 + actWorkflowFormData.addAll( actWorkflowFormDataService.selectActWorkflowFormDataByBusinessKey(businessKey.replace(":", "_edit:")));
  164 +
  165 + }
  166 +
  167 +
  168 + @Override
  169 + public List<ActWorkflowFormData> historyFromDataByTime(Map<String,String> map) {
  170 + List<ActWorkflowFormData> returnHistoryFromDataDTOS=new ArrayList<>();
  171 + List<ActWorkflowFormData> actWorkflowFormData=new ArrayList<>();
  172 +
  173 + String businessKey = map.get("businessKey");
  174 +
  175 +
  176 +
  177 + actWorkflowFormData = formDataMapper.selectNewActWorkflowFormDataByBusinessKey(map);
  178 +
  179 +
  180 +
  181 +
  182 + for(int i =0;i<actWorkflowFormData.size();i++){
  183 + if(i == actWorkflowFormData.size()-1){
  184 + returnHistoryFromDataDTOS.add(actWorkflowFormData.get(i));
  185 + continue;
  186 + }
  187 +
  188 + ActWorkflowFormData one = actWorkflowFormData.get(i);
  189 + ActWorkflowFormData two = actWorkflowFormData.get(i+1);
  190 +
  191 + if(one.getCreateBy().equals(two.getCreateBy()) && one.getCreateTime().getTime() == two.getCreateTime().getTime()){
  192 +
  193 + String twoValue = two.getControlValue() == null ? "" : "," + two.getControlValue();
  194 +
  195 + one.setControlValue(one.getControlValue() + twoValue);
  196 +
  197 + returnHistoryFromDataDTOS.add(one);
  198 + i+=1;
  199 + continue;
  200 + }
  201 +
  202 + returnHistoryFromDataDTOS.add(one);
  203 + }
  204 +
  205 +
  206 +
  207 + returnHistoryFromDataDTOS = returnHistoryFromDataDTOS.stream().sorted((x,y) -> x.getCreateTime().compareTo(y.getCreateTime())).collect(Collectors.toList());
  208 +
  209 +
  210 + return returnHistoryFromDataDTOS;
  211 + }
  212 +
  213 +
  214 +}
trash-activiti/src/main/java/com/trash/activiti/service/impl/myTaskServiceImpl.java
1 -package com.trash.activiti.service.impl;  
2 -  
3 -import org.activiti.api.model.shared.model.VariableInstance;  
4 -import org.activiti.api.runtime.shared.NotFoundException;  
5 -import org.activiti.api.runtime.shared.identity.UserGroupManager;  
6 -import org.activiti.api.runtime.shared.query.Page;  
7 -import org.activiti.api.runtime.shared.query.Pageable;  
8 -import org.activiti.api.runtime.shared.security.SecurityManager;  
9 -import org.activiti.api.task.model.Task;  
10 -import org.activiti.api.task.model.builders.TaskPayloadBuilder;  
11 -import org.activiti.api.task.model.impl.TaskImpl;  
12 -import org.activiti.api.task.model.payloads.CandidateGroupsPayload;  
13 -import org.activiti.api.task.model.payloads.CandidateUsersPayload;  
14 -import org.activiti.api.task.model.payloads.ClaimTaskPayload;  
15 -import org.activiti.api.task.model.payloads.CompleteTaskPayload;  
16 -import org.activiti.api.task.model.payloads.CreateTaskPayload;  
17 -import org.activiti.api.task.model.payloads.CreateTaskVariablePayload;  
18 -import org.activiti.api.task.model.payloads.DeleteTaskPayload;  
19 -import org.activiti.api.task.model.payloads.GetTaskVariablesPayload;  
20 -import org.activiti.api.task.model.payloads.GetTasksPayload;  
21 -import org.activiti.api.task.model.payloads.ReleaseTaskPayload;  
22 -import org.activiti.api.task.model.payloads.SaveTaskPayload;  
23 -import org.activiti.api.task.model.payloads.UpdateTaskPayload;  
24 -import org.activiti.api.task.model.payloads.UpdateTaskVariablePayload;  
25 -import org.activiti.api.task.runtime.TaskRuntime;  
26 -import org.activiti.api.task.runtime.conf.TaskRuntimeConfiguration;  
27 -import org.activiti.engine.RuntimeService;  
28 -import org.activiti.engine.TaskService;  
29 -import org.activiti.engine.impl.TaskQueryImpl;  
30 -import org.activiti.engine.query.QueryProperty;  
31 -import org.activiti.engine.runtime.ProcessInstance;  
32 -import org.activiti.engine.runtime.ProcessInstanceQuery;  
33 -import org.activiti.engine.task.IdentityLink;  
34 -import org.activiti.engine.task.IdentityLinkType;  
35 -import org.activiti.engine.task.NativeTaskQuery;  
36 -import org.activiti.engine.task.TaskQuery;  
37 -import org.activiti.runtime.api.impl.TaskRuntimeHelper;  
38 -import org.activiti.runtime.api.model.impl.APITaskConverter;  
39 -import org.activiti.runtime.api.model.impl.APIVariableInstanceConverter;  
40 -import org.activiti.runtime.api.query.impl.PageImpl;  
41 -import org.springframework.beans.factory.annotation.Autowired;  
42 -import org.springframework.security.access.prepost.PreAuthorize;  
43 -import org.springframework.stereotype.Service;  
44 -  
45 -import com.sun.jna.Native;  
46 -import com.trash.activiti.service.myTaskService;  
47 -import com.trash.common.utils.SecurityUtils;  
48 -  
49 -import java.util.ArrayList;  
50 -import java.util.Date;  
51 -import java.util.HashSet;  
52 -import java.util.List;  
53 -import java.util.Objects;  
54 -import java.util.Set;  
55 -import java.util.stream.Collector;  
56 -import java.util.stream.Collectors;  
57 -  
58 -@PreAuthorize("hasRole('ACTIVITI_USER')")  
59 -@Service  
60 -public class myTaskServiceImpl implements myTaskService {  
61 -  
62 - private final TaskService taskService;  
63 -  
64 - private final APITaskConverter taskConverter;  
65 -  
66 - private final APIVariableInstanceConverter variableInstanceConverter;  
67 -  
68 - private final TaskRuntimeConfiguration configuration;  
69 -  
70 - private final UserGroupManager userGroupManager;  
71 -  
72 - private final SecurityManager securityManager;  
73 -  
74 - private final TaskRuntimeHelper taskRuntimeHelper;  
75 -  
76 - @Autowired  
77 - RuntimeService runtimeService;  
78 -  
79 - public myTaskServiceImpl(TaskService taskService,  
80 - UserGroupManager userGroupManager,  
81 - SecurityManager securityManager,  
82 - APITaskConverter taskConverter,  
83 - APIVariableInstanceConverter variableInstanceConverter,  
84 - TaskRuntimeConfiguration configuration,  
85 - TaskRuntimeHelper taskRuntimeHelper) {  
86 - this.taskService = taskService;  
87 - this.userGroupManager = userGroupManager;  
88 - this.securityManager = securityManager;  
89 - this.taskConverter = taskConverter;  
90 - this.variableInstanceConverter = variableInstanceConverter;  
91 - this.configuration = configuration;  
92 - this.taskRuntimeHelper = taskRuntimeHelper;  
93 - }  
94 -  
95 - @Override  
96 - public TaskRuntimeConfiguration configuration() {  
97 - return configuration;  
98 - }  
99 -  
100 - @Override  
101 - public Task task(String taskId) {  
102 -  
103 - org.activiti.engine.task.Task task = taskService.createTaskQuery().taskId(taskId).singleResult();  
104 -  
105 - if (task == null) {  
106 - throw new NotFoundException("未找到审批任务 id: " + taskId);  
107 - }  
108 -  
109 -  
110 - return taskConverter.from(task);  
111 - }  
112 -  
113 - @Override  
114 - public Page<Task> tasks(Pageable pageable) {  
115 - return tasks(pageable,null,null,null);  
116 - }  
117 - @Override  
118 - public Page<Task> tasks(Pageable pageable,GetTasksPayload getTasksPayload,Set<String> defKey,String name) {  
119 -  
120 -  
121 - TaskQuery crossQuery = taskService.createTaskQuery();  
122 - TaskQuery crossQuery1 = taskService.createTaskQuery();  
123 -  
124 - TaskQuery userQuery = taskService.createTaskQuery();  
125 -  
126 - userQuery.taskAssignee(SecurityUtils.getUsername());  
127 -  
128 - TaskQuery taskQuery = taskService.createTaskQuery();  
129 -  
130 -  
131 - List<String> pid = new ArrayList<>();  
132 -  
133 - List<String> posts = SecurityUtils.getLoginUser().getUser().getPostIds();  
134 - List<String> roles = SecurityUtils.getLoginUser().getUser().getRoleIds();  
135 -  
136 - if(posts == null || posts == null){  
137 - crossQuery.taskCandidateOrAssigned(SecurityUtils.getUsername());  
138 - crossQuery1.taskCandidateOrAssigned(SecurityUtils.getUsername());  
139 - }else{  
140 -  
141 - for(int i = 0;i<roles.size();i++){  
142 -  
143 - crossQuery = taskService.createTaskQuery().taskCandidateUser(roles.get(i));  
144 - crossQuery1 = taskService.createTaskQuery().taskCandidateGroup(posts.get(i));  
145 -  
146 - List<org.activiti.engine.task.Task> list1 = crossQuery.list();  
147 - List<org.activiti.engine.task.Task> list2 = crossQuery1.list();  
148 -  
149 -  
150 - for(org.activiti.engine.task.Task t1:list1){  
151 -  
152 - for(org.activiti.engine.task.Task t2:list2){  
153 -  
154 - if(t1.getId().equals(t2.getId())){  
155 - pid.add(t1.getProcessInstanceId());  
156 - }  
157 - }  
158 - }  
159 -  
160 - }  
161 - }  
162 -  
163 -  
164 - for(org.activiti.engine.task.Task tasks : userQuery.list()){  
165 - pid.add(tasks.getProcessInstanceId());  
166 - }  
167 -  
168 -  
169 - ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();  
170 -  
171 - if(name != null && !name.isEmpty()){  
172 - query.processInstanceNameLike("%"+name+"%");  
173 - }  
174 - if(defKey.size()>0){  
175 - query.processDefinitionKeys(defKey);  
176 - }  
177 -  
178 - if(pid.size()>0){  
179 - Set<String> idSet = new HashSet<>();  
180 -  
181 - for(String str:pid){  
182 - idSet.add(str);  
183 - }  
184 -  
185 - List<ProcessInstance> pList = query.processInstanceIds(idSet).list();  
186 -  
187 - pid = pList.parallelStream().map(p->p.getId()).collect(Collectors.toList());  
188 - }  
189 -  
190 -  
191 -  
192 - if(pid.size() > 0){  
193 - taskQuery.processInstanceIdIn(pid).orderByTaskCreateTime().desc();  
194 - }else{  
195 - taskQuery.taskAssignee(SecurityUtils.getUsername()).orderByTaskCreateTime().desc();  
196 - }  
197 -  
198 - List<Task> tasks = taskConverter.from(taskQuery.listPage(pageable.getStartIndex(),  
199 - pageable.getMaxItems()));  
200 -  
201 -  
202 - return new PageImpl<>(tasks,Math.toIntExact(taskQuery.count()));  
203 - }  
204 -  
205 - @Override  
206 - public Task complete(CompleteTaskPayload completeTaskPayload) {  
207 - //@TODO: not the most efficient way to return the just completed task, improve  
208 - // we might need to create an empty shell with the task ID and Status only  
209 - Task task;  
210 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
211 - try {  
212 - task = task(completeTaskPayload.getTaskId());  
213 - } catch (IllegalStateException ex) {  
214 - throw new IllegalStateException("The authenticated user cannot complete task" + completeTaskPayload.getTaskId() + " due he/she cannot access to the task");  
215 - }  
216 - // validate the the task does have an assignee  
217 - if (task.getAssignee() == null || task.getAssignee().isEmpty()) {  
218 - throw new IllegalStateException("The task needs to be claimed before trying to complete it");  
219 - }  
220 - if (!task.getAssignee().equals(authenticatedUserId)) {  
221 - throw new IllegalStateException("You cannot complete the task if you are not assigned to it");  
222 - }  
223 -  
224 - taskService.complete(completeTaskPayload.getTaskId(),  
225 - completeTaskPayload.getVariables(), true);  
226 -  
227 -  
228 - ((TaskImpl) task).setStatus(Task.TaskStatus.COMPLETED);  
229 -  
230 - return task;  
231 - }  
232 -  
233 - @Override  
234 - public Task claim(ClaimTaskPayload claimTaskPayload) {  
235 - // Validate that the task is visible by the currently authorized user  
236 - Task task;  
237 - try {  
238 - task = task(claimTaskPayload.getTaskId());  
239 - } catch (IllegalStateException ex) {  
240 - throw new IllegalStateException("The authenticated user cannot claim task" + claimTaskPayload.getTaskId() + " due it is not a candidate for it");  
241 - }  
242 - // validate the the task doesn't have an assignee  
243 - if (task.getAssignee() != null && !task.getAssignee().isEmpty()) {  
244 - throw new IllegalStateException("The task was already claimed, the assignee of this task needs to release it first for you to claim it");  
245 - }  
246 -  
247 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
248 - claimTaskPayload.setAssignee(authenticatedUserId);  
249 - taskService.claim(claimTaskPayload.getTaskId(),  
250 - claimTaskPayload.getAssignee());  
251 -  
252 - return task(claimTaskPayload.getTaskId());  
253 - }  
254 -  
255 - @Override  
256 - public Task release(ReleaseTaskPayload releaseTaskPayload) {  
257 - // Validate that the task is visible by the currently authorized user  
258 - Task task;  
259 - try {  
260 - task = task(releaseTaskPayload.getTaskId());  
261 - } catch (IllegalStateException ex) {  
262 - throw new IllegalStateException("The authenticated user cannot claim task" + releaseTaskPayload.getTaskId() + " due it is not a candidate for it");  
263 - }  
264 - // validate the the task doesn't have an assignee  
265 - if (task.getAssignee() == null || task.getAssignee().isEmpty()) {  
266 - throw new IllegalStateException("You cannot release a task that is not claimed");  
267 - }  
268 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
269 - // validate that you are trying to release task where you are the assignee  
270 - if (!task.getAssignee().equals(authenticatedUserId)) {  
271 - throw new IllegalStateException("You cannot release a task where you are not the assignee");  
272 - }  
273 -  
274 - taskService.unclaim(releaseTaskPayload.getTaskId());  
275 - return task(releaseTaskPayload.getTaskId());  
276 - }  
277 -  
278 - @Override  
279 - public Task update(UpdateTaskPayload updateTaskPayload) {  
280 - return taskRuntimeHelper.applyUpdateTaskPayload(false, updateTaskPayload);  
281 - }  
282 -  
283 - @Override  
284 - public Task delete(DeleteTaskPayload deleteTaskPayload) {  
285 - //@TODO: not the most efficient way to return the just deleted task, improve  
286 - // we might need to create an empty shell with the task ID and Status only  
287 - Task task;  
288 - try {  
289 - task = task(deleteTaskPayload.getTaskId());  
290 - } catch (IllegalStateException ex) {  
291 - throw new IllegalStateException("The authenticated user cannot delete the task" + deleteTaskPayload.getTaskId() + " due it is not the current assignee");  
292 - }  
293 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
294 - // validate that you are trying to delete task where you are the assignee or the owner  
295 - if ((task.getAssignee() == null || task.getAssignee().isEmpty() || !task.getAssignee().equals(authenticatedUserId)) &&  
296 - (task.getOwner() == null || task.getOwner().isEmpty() || !task.getOwner().equals(authenticatedUserId))) {  
297 - throw new IllegalStateException("You cannot delete a task where you are not the assignee/owner");  
298 - }  
299 - TaskImpl deletedTaskData = new TaskImpl(task.getId(),  
300 - task.getName(),  
301 - Task.TaskStatus.CANCELLED);  
302 - if (!deleteTaskPayload.hasReason()) {  
303 - deleteTaskPayload.setReason("Task deleted by " + authenticatedUserId);  
304 - }  
305 - taskService.deleteTask(deleteTaskPayload.getTaskId(),  
306 - deleteTaskPayload.getReason(),  
307 - true);  
308 - return deletedTaskData;  
309 - }  
310 -  
311 - @Override  
312 - public Task create(CreateTaskPayload createTaskPayload) {  
313 - if (createTaskPayload.getName() == null || createTaskPayload.getName().isEmpty()) {  
314 - throw new IllegalStateException("You cannot create a task without name");  
315 - }  
316 -  
317 - org.activiti.engine.task.Task task = taskService.newTask();  
318 - task.setName(createTaskPayload.getName());  
319 - task.setDescription(createTaskPayload.getDescription());  
320 - task.setDueDate(createTaskPayload.getDueDate());  
321 - task.setPriority(createTaskPayload.getPriority());  
322 - if (createTaskPayload.getAssignee() != null && !createTaskPayload.getAssignee().isEmpty()) {  
323 - task.setAssignee(createTaskPayload.getAssignee());  
324 - }  
325 - task.setParentTaskId(createTaskPayload.getParentTaskId());  
326 - task.setFormKey(createTaskPayload.getFormKey());  
327 - task.setOwner(securityManager.getAuthenticatedUserId());  
328 - taskService.saveTask(task);  
329 - taskService.addCandidateUser(task.getId(),  
330 - securityManager.getAuthenticatedUserId());  
331 - if (createTaskPayload.getCandidateGroups() != null && !createTaskPayload.getCandidateGroups().isEmpty()) {  
332 - for ( String g : createTaskPayload.getCandidateGroups() ) {  
333 - taskService.addCandidateGroup(task.getId(),  
334 - g);  
335 - }  
336 - }  
337 -  
338 - if (createTaskPayload.getCandidateUsers() != null && !createTaskPayload.getCandidateUsers().isEmpty()) {  
339 - for ( String u : createTaskPayload.getCandidateUsers() ) {  
340 - taskService.addCandidateUser(task.getId(),  
341 - u);  
342 - }  
343 - }  
344 -  
345 - return taskConverter.from(task);  
346 - }  
347 -  
348 - @Override  
349 - public void addCandidateUsers(CandidateUsersPayload candidateUsersPayload) {  
350 - org.activiti.engine.task.Task internalTask;  
351 - try {  
352 - internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateUsersPayload.getTaskId());  
353 -  
354 - } catch (IllegalStateException ex) {  
355 - throw new IllegalStateException("The authenticated user cannot update the task" + candidateUsersPayload.getTaskId() + " due it is not the current assignee");  
356 - }  
357 -  
358 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
359 -  
360 - // validate that you are trying to add CandidateUsers to the task where you are the assignee  
361 - if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {  
362 - throw new IllegalStateException("You cannot update a task where you are not the assignee");  
363 - }  
364 -  
365 -  
366 - if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) {  
367 - for ( String u : candidateUsersPayload.getCandidateUsers() ) {  
368 - taskService.addCandidateUser(internalTask.getId(),  
369 - u);  
370 - }  
371 - }  
372 - }  
373 -  
374 - @Override  
375 - public void deleteCandidateUsers(CandidateUsersPayload candidateUsersPayload) {  
376 - org.activiti.engine.task.Task internalTask;  
377 - try {  
378 - internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateUsersPayload.getTaskId());  
379 -  
380 - } catch (IllegalStateException ex) {  
381 - throw new IllegalStateException("The authenticated user cannot update the task" + candidateUsersPayload.getTaskId() + " due it is not the current assignee");  
382 - }  
383 -  
384 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
385 -  
386 - // validate that you are trying to add CandidateUsers to the task where you are the assignee  
387 - if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {  
388 - throw new IllegalStateException("You cannot update a task where you are not the assignee");  
389 - }  
390 -  
391 -  
392 - if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) {  
393 - for ( String u : candidateUsersPayload.getCandidateUsers() ) {  
394 - taskService.deleteCandidateUser(internalTask.getId(),  
395 - u);  
396 - }  
397 - }  
398 - }  
399 -  
400 - @Override  
401 - public void addCandidateGroups(CandidateGroupsPayload candidateGroupsPayload) {  
402 - org.activiti.engine.task.Task internalTask;  
403 - try {  
404 - internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateGroupsPayload.getTaskId());  
405 -  
406 - } catch (IllegalStateException ex) {  
407 - throw new IllegalStateException("The authenticated user cannot update the task" + candidateGroupsPayload.getTaskId() + " due it is not the current assignee");  
408 - }  
409 -  
410 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
411 - // validate that you are trying to add CandidateGroups to the task where you are the assignee  
412 - if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {  
413 - throw new IllegalStateException("You cannot update a task where you are not the assignee");  
414 - }  
415 -  
416 -  
417 - if (candidateGroupsPayload.getCandidateGroups() != null && !candidateGroupsPayload.getCandidateGroups().isEmpty()) {  
418 - for ( String g : candidateGroupsPayload.getCandidateGroups() ) {  
419 - taskService.addCandidateGroup(internalTask.getId(),  
420 - g);  
421 - }  
422 - }  
423 - }  
424 -  
425 - @Override  
426 - public void deleteCandidateGroups(CandidateGroupsPayload candidateGroupsPayload) {  
427 - org.activiti.engine.task.Task internalTask;  
428 - try {  
429 - internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateGroupsPayload.getTaskId());  
430 -  
431 - } catch (IllegalStateException ex) {  
432 - throw new IllegalStateException("The authenticated user cannot update the task" + candidateGroupsPayload.getTaskId() + " due it is not the current assignee");  
433 - }  
434 -  
435 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
436 - // validate that you are trying to add CandidateGroups to the task where you are the assignee  
437 - if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {  
438 - throw new IllegalStateException("You cannot update a task where you are not the assignee");  
439 - }  
440 -  
441 -  
442 - if (candidateGroupsPayload.getCandidateGroups() != null && !candidateGroupsPayload.getCandidateGroups().isEmpty()) {  
443 - for ( String g : candidateGroupsPayload.getCandidateGroups() ) {  
444 - taskService.deleteCandidateGroup(internalTask.getId(),  
445 - g);  
446 - }  
447 - }  
448 - }  
449 -  
450 - @Override  
451 - public List<String> userCandidates(String taskId) {  
452 - List<IdentityLink> identityLinks = getIdentityLinks(taskId);  
453 - List<String> userCandidates = new ArrayList<>();  
454 - if (identityLinks != null) {  
455 - for ( IdentityLink i : identityLinks ) {  
456 - if (i.getUserId() != null) {  
457 - if (i.getType().equals(IdentityLinkType.CANDIDATE)) {  
458 - userCandidates.add(i.getUserId());  
459 - }  
460 - }  
461 - }  
462 -  
463 - }  
464 - return userCandidates;  
465 - }  
466 -  
467 - @Override  
468 - public List<String> groupCandidates(String taskId) {  
469 - List<IdentityLink> identityLinks = getIdentityLinks(taskId);  
470 - List<String> groupCandidates = new ArrayList<>();  
471 - if (identityLinks != null) {  
472 - for ( IdentityLink i : identityLinks ) {  
473 - if (i.getGroupId() != null) {  
474 - if (i.getType().equals(IdentityLinkType.CANDIDATE)) {  
475 - groupCandidates.add(i.getGroupId());  
476 - }  
477 - }  
478 - }  
479 -  
480 - }  
481 - return groupCandidates;  
482 - }  
483 -  
484 - @Override  
485 - public List<VariableInstance> variables(GetTaskVariablesPayload getTaskVariablesPayload) {  
486 - taskRuntimeHelper.assertHasAccessToTask(getTaskVariablesPayload.getTaskId());  
487 - return variableInstanceConverter.from(taskRuntimeHelper.getInternalTaskVariables(getTaskVariablesPayload.getTaskId()).values());  
488 - }  
489 -  
490 - @Override  
491 - public void createVariable(CreateTaskVariablePayload createTaskVariablePayload) {  
492 - taskRuntimeHelper.createVariable(false, createTaskVariablePayload);  
493 - }  
494 -  
495 - @Override  
496 - public void updateVariable(UpdateTaskVariablePayload updateTaskVariablePayload) {  
497 - taskRuntimeHelper.updateVariable(false, updateTaskVariablePayload);  
498 - }  
499 -  
500 - private List<IdentityLink> getIdentityLinks(String taskId) {  
501 - String authenticatedUserId = securityManager.getAuthenticatedUserId();  
502 - if (authenticatedUserId != null && !authenticatedUserId.isEmpty()) {  
503 - List<String> userRoles = userGroupManager.getUserRoles(authenticatedUserId);  
504 - List<String> userGroups = userGroupManager.getUserGroups(authenticatedUserId);  
505 - org.activiti.engine.task.Task internalTask = taskService.createTaskQuery().taskCandidateOrAssigned(authenticatedUserId,  
506 - userGroups).taskId(taskId).singleResult();  
507 - if (internalTask == null) {  
508 - throw new NotFoundException("Unable to find task for the given id: " + taskId + " for user: " + authenticatedUserId + " (with groups: " + userGroups + " & with roles: " + userRoles + ")");  
509 - }  
510 - return taskService.getIdentityLinksForTask(taskId);  
511 - }  
512 - throw new IllegalStateException("There is no authenticated user, we need a user authenticated to find tasks");  
513 - }  
514 -  
515 - @Override  
516 - public void save(SaveTaskPayload saveTaskPayload) {  
517 - taskRuntimeHelper.assertHasAccessToTask(saveTaskPayload.getTaskId());  
518 -  
519 - taskService.setVariablesLocal(saveTaskPayload.getTaskId(),  
520 - saveTaskPayload.getVariables());  
521 - }  
522 -  
523 -} 1 +package com.trash.activiti.service.impl;
  2 +
  3 +import org.activiti.api.model.shared.model.VariableInstance;
  4 +import org.activiti.api.runtime.shared.NotFoundException;
  5 +import org.activiti.api.runtime.shared.identity.UserGroupManager;
  6 +import org.activiti.api.runtime.shared.query.Page;
  7 +import org.activiti.api.runtime.shared.query.Pageable;
  8 +import org.activiti.api.runtime.shared.security.SecurityManager;
  9 +import org.activiti.api.task.model.Task;
  10 +import org.activiti.api.task.model.builders.TaskPayloadBuilder;
  11 +import org.activiti.api.task.model.impl.TaskImpl;
  12 +import org.activiti.api.task.model.payloads.CandidateGroupsPayload;
  13 +import org.activiti.api.task.model.payloads.CandidateUsersPayload;
  14 +import org.activiti.api.task.model.payloads.ClaimTaskPayload;
  15 +import org.activiti.api.task.model.payloads.CompleteTaskPayload;
  16 +import org.activiti.api.task.model.payloads.CreateTaskPayload;
  17 +import org.activiti.api.task.model.payloads.CreateTaskVariablePayload;
  18 +import org.activiti.api.task.model.payloads.DeleteTaskPayload;
  19 +import org.activiti.api.task.model.payloads.GetTaskVariablesPayload;
  20 +import org.activiti.api.task.model.payloads.GetTasksPayload;
  21 +import org.activiti.api.task.model.payloads.ReleaseTaskPayload;
  22 +import org.activiti.api.task.model.payloads.SaveTaskPayload;
  23 +import org.activiti.api.task.model.payloads.UpdateTaskPayload;
  24 +import org.activiti.api.task.model.payloads.UpdateTaskVariablePayload;
  25 +import org.activiti.api.task.runtime.TaskRuntime;
  26 +import org.activiti.api.task.runtime.conf.TaskRuntimeConfiguration;
  27 +import org.activiti.engine.RuntimeService;
  28 +import org.activiti.engine.TaskService;
  29 +import org.activiti.engine.impl.TaskQueryImpl;
  30 +import org.activiti.engine.query.QueryProperty;
  31 +import org.activiti.engine.runtime.ProcessInstance;
  32 +import org.activiti.engine.runtime.ProcessInstanceQuery;
  33 +import org.activiti.engine.task.IdentityLink;
  34 +import org.activiti.engine.task.IdentityLinkType;
  35 +import org.activiti.engine.task.NativeTaskQuery;
  36 +import org.activiti.engine.task.TaskQuery;
  37 +import org.activiti.runtime.api.impl.TaskRuntimeHelper;
  38 +import org.activiti.runtime.api.model.impl.APITaskConverter;
  39 +import org.activiti.runtime.api.model.impl.APIVariableInstanceConverter;
  40 +import org.activiti.runtime.api.query.impl.PageImpl;
  41 +import org.springframework.beans.factory.annotation.Autowired;
  42 +import org.springframework.security.access.prepost.PreAuthorize;
  43 +import org.springframework.stereotype.Service;
  44 +
  45 +import com.sun.jna.Native;
  46 +import com.trash.activiti.service.myTaskService;
  47 +import com.trash.common.utils.SecurityUtils;
  48 +
  49 +import java.util.ArrayList;
  50 +import java.util.Date;
  51 +import java.util.HashSet;
  52 +import java.util.List;
  53 +import java.util.Objects;
  54 +import java.util.Set;
  55 +import java.util.stream.Collector;
  56 +import java.util.stream.Collectors;
  57 +
  58 +@PreAuthorize("hasRole('ACTIVITI_USER')")
  59 +@Service
  60 +public class myTaskServiceImpl implements myTaskService {
  61 +
  62 + private final TaskService taskService;
  63 +
  64 + private final APITaskConverter taskConverter;
  65 +
  66 + private final APIVariableInstanceConverter variableInstanceConverter;
  67 +
  68 + private final TaskRuntimeConfiguration configuration;
  69 +
  70 + private final UserGroupManager userGroupManager;
  71 +
  72 + private final SecurityManager securityManager;
  73 +
  74 + private final TaskRuntimeHelper taskRuntimeHelper;
  75 +
  76 + @Autowired
  77 + RuntimeService runtimeService;
  78 +
  79 + public myTaskServiceImpl(TaskService taskService,
  80 + UserGroupManager userGroupManager,
  81 + SecurityManager securityManager,
  82 + APITaskConverter taskConverter,
  83 + APIVariableInstanceConverter variableInstanceConverter,
  84 + TaskRuntimeConfiguration configuration,
  85 + TaskRuntimeHelper taskRuntimeHelper) {
  86 + this.taskService = taskService;
  87 + this.userGroupManager = userGroupManager;
  88 + this.securityManager = securityManager;
  89 + this.taskConverter = taskConverter;
  90 + this.variableInstanceConverter = variableInstanceConverter;
  91 + this.configuration = configuration;
  92 + this.taskRuntimeHelper = taskRuntimeHelper;
  93 + }
  94 +
  95 + @Override
  96 + public TaskRuntimeConfiguration configuration() {
  97 + return configuration;
  98 + }
  99 +
  100 + @Override
  101 + public Task task(String taskId) {
  102 +
  103 + org.activiti.engine.task.Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
  104 +
  105 + if (task == null) {
  106 + throw new NotFoundException("未找到审批任务 id: " + taskId);
  107 + }
  108 +
  109 +
  110 + return taskConverter.from(task);
  111 + }
  112 +
  113 + @Override
  114 + public Page<Task> tasks(Pageable pageable) {
  115 + return tasks(pageable,null,null,null);
  116 + }
  117 + @Override
  118 + public Page<Task> tasks(Pageable pageable,GetTasksPayload getTasksPayload,Set<String> defKey,String name) {
  119 +
  120 +
  121 + TaskQuery crossQuery = taskService.createTaskQuery();
  122 + TaskQuery crossQuery1 = taskService.createTaskQuery();
  123 +
  124 + TaskQuery userQuery = taskService.createTaskQuery();
  125 +
  126 + userQuery.taskAssignee(SecurityUtils.getUsername());
  127 +
  128 + TaskQuery taskQuery = taskService.createTaskQuery();
  129 +
  130 +
  131 + List<String> pid = new ArrayList<>();
  132 +
  133 + List<String> posts = SecurityUtils.getLoginUser().getUser().getPostIds();
  134 + List<String> roles = SecurityUtils.getLoginUser().getUser().getRoleIds();
  135 +
  136 + if(posts == null || posts == null){
  137 + crossQuery.taskCandidateOrAssigned(SecurityUtils.getUsername());
  138 + crossQuery1.taskCandidateOrAssigned(SecurityUtils.getUsername());
  139 + }else{
  140 +
  141 + for(int i = 0;i<roles.size();i++){
  142 +
  143 + crossQuery = taskService.createTaskQuery().taskCandidateUser(roles.get(i));
  144 + crossQuery1 = taskService.createTaskQuery().taskCandidateGroup(posts.get(i));
  145 +
  146 + List<org.activiti.engine.task.Task> list1 = crossQuery.list();
  147 + List<org.activiti.engine.task.Task> list2 = crossQuery1.list();
  148 +
  149 +
  150 + for(org.activiti.engine.task.Task t1:list1){
  151 +
  152 + for(org.activiti.engine.task.Task t2:list2){
  153 +
  154 + if(t1.getId().equals(t2.getId())){
  155 + pid.add(t1.getProcessInstanceId());
  156 + }
  157 + }
  158 + }
  159 +
  160 + }
  161 + }
  162 +
  163 +
  164 + for(org.activiti.engine.task.Task tasks : userQuery.list()){
  165 + pid.add(tasks.getProcessInstanceId());
  166 + }
  167 +
  168 +
  169 + ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
  170 +
  171 + if(name != null && !name.isEmpty()){
  172 + query.processInstanceNameLike("%"+name+"%");
  173 + }
  174 + if(defKey.size()>0){
  175 + query.processDefinitionKeys(defKey);
  176 + }
  177 +
  178 + if(pid.size()>0){
  179 + Set<String> idSet = new HashSet<>();
  180 +
  181 + for(String str:pid){
  182 + idSet.add(str);
  183 + }
  184 +
  185 + List<ProcessInstance> pList = query.processInstanceIds(idSet).list();
  186 +
  187 + pid = pList.parallelStream().map(p->p.getId()).collect(Collectors.toList());
  188 + }
  189 +
  190 +
  191 +
  192 + if(pid.size() > 0){
  193 + taskQuery.processInstanceIdIn(pid).orderByTaskCreateTime().desc();
  194 + }else{
  195 + taskQuery.taskAssignee(SecurityUtils.getUsername()).orderByTaskCreateTime().desc();
  196 + }
  197 +
  198 + List<Task> tasks = taskConverter.from(taskQuery.listPage(pageable.getStartIndex(),
  199 + pageable.getMaxItems()));
  200 +
  201 +
  202 + return new PageImpl<>(tasks,Math.toIntExact(taskQuery.count()));
  203 + }
  204 +
  205 + @Override
  206 + public Task complete(CompleteTaskPayload completeTaskPayload) {
  207 + //@TODO: not the most efficient way to return the just completed task, improve
  208 + // we might need to create an empty shell with the task ID and Status only
  209 + Task task;
  210 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  211 + try {
  212 + task = task(completeTaskPayload.getTaskId());
  213 + } catch (IllegalStateException ex) {
  214 + throw new IllegalStateException("The authenticated user cannot complete task" + completeTaskPayload.getTaskId() + " due he/she cannot access to the task");
  215 + }
  216 + // validate the the task does have an assignee
  217 + if (task.getAssignee() == null || task.getAssignee().isEmpty()) {
  218 + throw new IllegalStateException("The task needs to be claimed before trying to complete it");
  219 + }
  220 + if (!task.getAssignee().equals(authenticatedUserId)) {
  221 + throw new IllegalStateException("You cannot complete the task if you are not assigned to it");
  222 + }
  223 +
  224 + taskService.complete(completeTaskPayload.getTaskId(),
  225 + completeTaskPayload.getVariables(), true);
  226 +
  227 +
  228 + ((TaskImpl) task).setStatus(Task.TaskStatus.COMPLETED);
  229 +
  230 + return task;
  231 + }
  232 +
  233 + @Override
  234 + public Task claim(ClaimTaskPayload claimTaskPayload) {
  235 + // Validate that the task is visible by the currently authorized user
  236 + Task task;
  237 + try {
  238 + task = task(claimTaskPayload.getTaskId());
  239 + } catch (IllegalStateException ex) {
  240 + throw new IllegalStateException("The authenticated user cannot claim task" + claimTaskPayload.getTaskId() + " due it is not a candidate for it");
  241 + }
  242 + // validate the the task doesn't have an assignee
  243 + if (task.getAssignee() != null && !task.getAssignee().isEmpty()) {
  244 + throw new IllegalStateException("The task was already claimed, the assignee of this task needs to release it first for you to claim it");
  245 + }
  246 +
  247 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  248 + claimTaskPayload.setAssignee(authenticatedUserId);
  249 + taskService.claim(claimTaskPayload.getTaskId(),
  250 + claimTaskPayload.getAssignee());
  251 +
  252 + return task(claimTaskPayload.getTaskId());
  253 + }
  254 +
  255 + @Override
  256 + public Task release(ReleaseTaskPayload releaseTaskPayload) {
  257 + // Validate that the task is visible by the currently authorized user
  258 + Task task;
  259 + try {
  260 + task = task(releaseTaskPayload.getTaskId());
  261 + } catch (IllegalStateException ex) {
  262 + throw new IllegalStateException("The authenticated user cannot claim task" + releaseTaskPayload.getTaskId() + " due it is not a candidate for it");
  263 + }
  264 + // validate the the task doesn't have an assignee
  265 + if (task.getAssignee() == null || task.getAssignee().isEmpty()) {
  266 + throw new IllegalStateException("You cannot release a task that is not claimed");
  267 + }
  268 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  269 + // validate that you are trying to release task where you are the assignee
  270 + if (!task.getAssignee().equals(authenticatedUserId)) {
  271 + throw new IllegalStateException("You cannot release a task where you are not the assignee");
  272 + }
  273 +
  274 + taskService.unclaim(releaseTaskPayload.getTaskId());
  275 + return task(releaseTaskPayload.getTaskId());
  276 + }
  277 +
  278 + @Override
  279 + public Task update(UpdateTaskPayload updateTaskPayload) {
  280 + return taskRuntimeHelper.applyUpdateTaskPayload(false, updateTaskPayload);
  281 + }
  282 +
  283 + @Override
  284 + public Task delete(DeleteTaskPayload deleteTaskPayload) {
  285 + //@TODO: not the most efficient way to return the just deleted task, improve
  286 + // we might need to create an empty shell with the task ID and Status only
  287 + Task task;
  288 + try {
  289 + task = task(deleteTaskPayload.getTaskId());
  290 + } catch (IllegalStateException ex) {
  291 + throw new IllegalStateException("The authenticated user cannot delete the task" + deleteTaskPayload.getTaskId() + " due it is not the current assignee");
  292 + }
  293 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  294 + // validate that you are trying to delete task where you are the assignee or the owner
  295 + if ((task.getAssignee() == null || task.getAssignee().isEmpty() || !task.getAssignee().equals(authenticatedUserId)) &&
  296 + (task.getOwner() == null || task.getOwner().isEmpty() || !task.getOwner().equals(authenticatedUserId))) {
  297 + throw new IllegalStateException("You cannot delete a task where you are not the assignee/owner");
  298 + }
  299 + TaskImpl deletedTaskData = new TaskImpl(task.getId(),
  300 + task.getName(),
  301 + Task.TaskStatus.CANCELLED);
  302 + if (!deleteTaskPayload.hasReason()) {
  303 + deleteTaskPayload.setReason("Task deleted by " + authenticatedUserId);
  304 + }
  305 + taskService.deleteTask(deleteTaskPayload.getTaskId(),
  306 + deleteTaskPayload.getReason(),
  307 + true);
  308 + return deletedTaskData;
  309 + }
  310 +
  311 + @Override
  312 + public Task create(CreateTaskPayload createTaskPayload) {
  313 + if (createTaskPayload.getName() == null || createTaskPayload.getName().isEmpty()) {
  314 + throw new IllegalStateException("You cannot create a task without name");
  315 + }
  316 +
  317 + org.activiti.engine.task.Task task = taskService.newTask();
  318 + task.setName(createTaskPayload.getName());
  319 + task.setDescription(createTaskPayload.getDescription());
  320 + task.setDueDate(createTaskPayload.getDueDate());
  321 + task.setPriority(createTaskPayload.getPriority());
  322 + if (createTaskPayload.getAssignee() != null && !createTaskPayload.getAssignee().isEmpty()) {
  323 + task.setAssignee(createTaskPayload.getAssignee());
  324 + }
  325 + task.setParentTaskId(createTaskPayload.getParentTaskId());
  326 + task.setFormKey(createTaskPayload.getFormKey());
  327 + task.setOwner(securityManager.getAuthenticatedUserId());
  328 + taskService.saveTask(task);
  329 + taskService.addCandidateUser(task.getId(),
  330 + securityManager.getAuthenticatedUserId());
  331 + if (createTaskPayload.getCandidateGroups() != null && !createTaskPayload.getCandidateGroups().isEmpty()) {
  332 + for ( String g : createTaskPayload.getCandidateGroups() ) {
  333 + taskService.addCandidateGroup(task.getId(),
  334 + g);
  335 + }
  336 + }
  337 +
  338 + if (createTaskPayload.getCandidateUsers() != null && !createTaskPayload.getCandidateUsers().isEmpty()) {
  339 + for ( String u : createTaskPayload.getCandidateUsers() ) {
  340 + taskService.addCandidateUser(task.getId(),
  341 + u);
  342 + }
  343 + }
  344 +
  345 + return taskConverter.from(task);
  346 + }
  347 +
  348 + @Override
  349 + public void addCandidateUsers(CandidateUsersPayload candidateUsersPayload) {
  350 + org.activiti.engine.task.Task internalTask;
  351 + try {
  352 + internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateUsersPayload.getTaskId());
  353 +
  354 + } catch (IllegalStateException ex) {
  355 + throw new IllegalStateException("The authenticated user cannot update the task" + candidateUsersPayload.getTaskId() + " due it is not the current assignee");
  356 + }
  357 +
  358 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  359 +
  360 + // validate that you are trying to add CandidateUsers to the task where you are the assignee
  361 + if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {
  362 + throw new IllegalStateException("You cannot update a task where you are not the assignee");
  363 + }
  364 +
  365 +
  366 + if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) {
  367 + for ( String u : candidateUsersPayload.getCandidateUsers() ) {
  368 + taskService.addCandidateUser(internalTask.getId(),
  369 + u);
  370 + }
  371 + }
  372 + }
  373 +
  374 + @Override
  375 + public void deleteCandidateUsers(CandidateUsersPayload candidateUsersPayload) {
  376 + org.activiti.engine.task.Task internalTask;
  377 + try {
  378 + internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateUsersPayload.getTaskId());
  379 +
  380 + } catch (IllegalStateException ex) {
  381 + throw new IllegalStateException("The authenticated user cannot update the task" + candidateUsersPayload.getTaskId() + " due it is not the current assignee");
  382 + }
  383 +
  384 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  385 +
  386 + // validate that you are trying to add CandidateUsers to the task where you are the assignee
  387 + if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {
  388 + throw new IllegalStateException("You cannot update a task where you are not the assignee");
  389 + }
  390 +
  391 +
  392 + if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) {
  393 + for ( String u : candidateUsersPayload.getCandidateUsers() ) {
  394 + taskService.deleteCandidateUser(internalTask.getId(),
  395 + u);
  396 + }
  397 + }
  398 + }
  399 +
  400 + @Override
  401 + public void addCandidateGroups(CandidateGroupsPayload candidateGroupsPayload) {
  402 + org.activiti.engine.task.Task internalTask;
  403 + try {
  404 + internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateGroupsPayload.getTaskId());
  405 +
  406 + } catch (IllegalStateException ex) {
  407 + throw new IllegalStateException("The authenticated user cannot update the task" + candidateGroupsPayload.getTaskId() + " due it is not the current assignee");
  408 + }
  409 +
  410 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  411 + // validate that you are trying to add CandidateGroups to the task where you are the assignee
  412 + if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {
  413 + throw new IllegalStateException("You cannot update a task where you are not the assignee");
  414 + }
  415 +
  416 +
  417 + if (candidateGroupsPayload.getCandidateGroups() != null && !candidateGroupsPayload.getCandidateGroups().isEmpty()) {
  418 + for ( String g : candidateGroupsPayload.getCandidateGroups() ) {
  419 + taskService.addCandidateGroup(internalTask.getId(),
  420 + g);
  421 + }
  422 + }
  423 + }
  424 +
  425 + @Override
  426 + public void deleteCandidateGroups(CandidateGroupsPayload candidateGroupsPayload) {
  427 + org.activiti.engine.task.Task internalTask;
  428 + try {
  429 + internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateGroupsPayload.getTaskId());
  430 +
  431 + } catch (IllegalStateException ex) {
  432 + throw new IllegalStateException("The authenticated user cannot update the task" + candidateGroupsPayload.getTaskId() + " due it is not the current assignee");
  433 + }
  434 +
  435 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  436 + // validate that you are trying to add CandidateGroups to the task where you are the assignee
  437 + if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) {
  438 + throw new IllegalStateException("You cannot update a task where you are not the assignee");
  439 + }
  440 +
  441 +
  442 + if (candidateGroupsPayload.getCandidateGroups() != null && !candidateGroupsPayload.getCandidateGroups().isEmpty()) {
  443 + for ( String g : candidateGroupsPayload.getCandidateGroups() ) {
  444 + taskService.deleteCandidateGroup(internalTask.getId(),
  445 + g);
  446 + }
  447 + }
  448 + }
  449 +
  450 + @Override
  451 + public List<String> userCandidates(String taskId) {
  452 + List<IdentityLink> identityLinks = getIdentityLinks(taskId);
  453 + List<String> userCandidates = new ArrayList<>();
  454 + if (identityLinks != null) {
  455 + for ( IdentityLink i : identityLinks ) {
  456 + if (i.getUserId() != null) {
  457 + if (i.getType().equals(IdentityLinkType.CANDIDATE)) {
  458 + userCandidates.add(i.getUserId());
  459 + }
  460 + }
  461 + }
  462 +
  463 + }
  464 + return userCandidates;
  465 + }
  466 +
  467 + @Override
  468 + public List<String> groupCandidates(String taskId) {
  469 + List<IdentityLink> identityLinks = getIdentityLinks(taskId);
  470 + List<String> groupCandidates = new ArrayList<>();
  471 + if (identityLinks != null) {
  472 + for ( IdentityLink i : identityLinks ) {
  473 + if (i.getGroupId() != null) {
  474 + if (i.getType().equals(IdentityLinkType.CANDIDATE)) {
  475 + groupCandidates.add(i.getGroupId());
  476 + }
  477 + }
  478 + }
  479 +
  480 + }
  481 + return groupCandidates;
  482 + }
  483 +
  484 + @Override
  485 + public List<VariableInstance> variables(GetTaskVariablesPayload getTaskVariablesPayload) {
  486 + taskRuntimeHelper.assertHasAccessToTask(getTaskVariablesPayload.getTaskId());
  487 + return variableInstanceConverter.from(taskRuntimeHelper.getInternalTaskVariables(getTaskVariablesPayload.getTaskId()).values());
  488 + }
  489 +
  490 + @Override
  491 + public void createVariable(CreateTaskVariablePayload createTaskVariablePayload) {
  492 + taskRuntimeHelper.createVariable(false, createTaskVariablePayload);
  493 + }
  494 +
  495 + @Override
  496 + public void updateVariable(UpdateTaskVariablePayload updateTaskVariablePayload) {
  497 + taskRuntimeHelper.updateVariable(false, updateTaskVariablePayload);
  498 + }
  499 +
  500 + private List<IdentityLink> getIdentityLinks(String taskId) {
  501 + String authenticatedUserId = securityManager.getAuthenticatedUserId();
  502 + if (authenticatedUserId != null && !authenticatedUserId.isEmpty()) {
  503 + List<String> userRoles = userGroupManager.getUserRoles(authenticatedUserId);
  504 + List<String> userGroups = userGroupManager.getUserGroups(authenticatedUserId);
  505 + org.activiti.engine.task.Task internalTask = taskService.createTaskQuery().taskCandidateOrAssigned(authenticatedUserId,
  506 + userGroups).taskId(taskId).singleResult();
  507 + if (internalTask == null) {
  508 + throw new NotFoundException("Unable to find task for the given id: " + taskId + " for user: " + authenticatedUserId + " (with groups: " + userGroups + " & with roles: " + userRoles + ")");
  509 + }
  510 + return taskService.getIdentityLinksForTask(taskId);
  511 + }
  512 + throw new IllegalStateException("There is no authenticated user, we need a user authenticated to find tasks");
  513 + }
  514 +
  515 + @Override
  516 + public void save(SaveTaskPayload saveTaskPayload) {
  517 + taskRuntimeHelper.assertHasAccessToTask(saveTaskPayload.getTaskId());
  518 +
  519 + taskService.setVariablesLocal(saveTaskPayload.getTaskId(),
  520 + saveTaskPayload.getVariables());
  521 + }
  522 +
  523 +}
trash-activiti/src/main/java/com/trash/activiti/service/myTaskService.java
1 -package com.trash.activiti.service;  
2 -import java.util.List;  
3 -import java.util.Set;  
4 -  
5 -import org.activiti.api.model.shared.model.VariableInstance;  
6 -import org.activiti.api.runtime.shared.query.Page;  
7 -import org.activiti.api.runtime.shared.query.Pageable;  
8 -import org.activiti.api.task.model.Task;  
9 -import org.activiti.api.task.model.payloads.CandidateGroupsPayload;  
10 -import org.activiti.api.task.model.payloads.CandidateUsersPayload;  
11 -import org.activiti.api.task.model.payloads.ClaimTaskPayload;  
12 -import org.activiti.api.task.model.payloads.CompleteTaskPayload;  
13 -import org.activiti.api.task.model.payloads.CreateTaskPayload;  
14 -import org.activiti.api.task.model.payloads.CreateTaskVariablePayload;  
15 -import org.activiti.api.task.model.payloads.DeleteTaskPayload;  
16 -import org.activiti.api.task.model.payloads.GetTaskVariablesPayload;  
17 -import org.activiti.api.task.model.payloads.GetTasksPayload;  
18 -import org.activiti.api.task.model.payloads.ReleaseTaskPayload;  
19 -import org.activiti.api.task.model.payloads.SaveTaskPayload;  
20 -import org.activiti.api.task.model.payloads.UpdateTaskPayload;  
21 -import org.activiti.api.task.model.payloads.UpdateTaskVariablePayload;  
22 -import org.activiti.api.task.runtime.conf.TaskRuntimeConfiguration;  
23 -  
24 -public interface myTaskService {  
25 -  
26 -  
27 -  
28 - TaskRuntimeConfiguration configuration();  
29 -  
30 - /**  
31 - * Get task by id if the authenticated user:  
32 - * - is the assignee or  
33 - * - is in a group with is assigned to the task or  
34 - * - has admin role  
35 - */  
36 - Task task(String taskId);  
37 -  
38 - /**  
39 - * Get all tasks where  
40 - * - the authenticated user is the actual assignee  
41 - * - the user belongs to a group that is a candidate for the task  
42 - */  
43 - Page<Task> tasks(Pageable pageable);  
44 -  
45 - /**  
46 - * Get all tasks where applying the filters in the Payload  
47 - * - the authenticated user is the actual assignee  
48 - * - the user belongs to a group that is a candidate for the task  
49 - */  
50 -  
51 -  
52 - Page<Task> tasks(Pageable pageable,  
53 - GetTasksPayload getTasksPayload,Set<String> defKey,String name);  
54 -  
55 - /**  
56 - * Creates a task based on the following rules  
57 - * - If an assignee is provided it creates and assign the task to the provided user  
58 - * - If there is no assignee the task is not assigned, just created  
59 - * - The owner of the task is the currently authenticated user (which is automatically added as a candidate)  
60 - * - If a group or list of groups is provided those groups are added as candidates for claiming the task  
61 - */  
62 - Task create(CreateTaskPayload createTaskPayload);  
63 -  
64 - /**  
65 - * Claim a task with the currently authenticated user  
66 - * - If there is no authenticated user throw an IllegalStateException  
67 - * - If the currently authenticated user is not a candidate throw an IllegalStateException  
68 - * - The current approach doesn't support impersonation, it will always take the currently authenticated user  
69 - * - after the claim the task should be in assigned status  
70 - */  
71 - Task claim(ClaimTaskPayload claimTaskPayload);  
72 -  
73 - /**  
74 - * Release a previously claimed task  
75 - * - The authenticated user needs to be the assignee in order to release it  
76 - */  
77 - Task release(ReleaseTaskPayload releaseTaskPayload);  
78 -  
79 - /**  
80 - * Completes the selected task with the variables set in the payload  
81 - * - This method checks that the task is visible by the authenticated user  
82 - * - This method also check that the task is assigned to the currently authenticated user before complete  
83 - * - This method return a shallow Task object with the basic information needed to validate that the task was completed  
84 - */  
85 - Task complete(CompleteTaskPayload completeTaskPayload);  
86 -  
87 - /**  
88 - * Saves the selected task with the variables set in the payload in the task scope  
89 - * - This method checks that the task is visible by the authenticated user  
90 - * - This method also check that the task is assigned to the currently authenticated user  
91 - */  
92 - void save(SaveTaskPayload saveTaskPayload);  
93 -  
94 - /**  
95 - * Updates details of a task  
96 - * - The authenticated user should be able to see the task in order to update its details  
97 - * - The authenticated user needs to be the assignee of the task to update its details, if not he/she will need to claim the task first  
98 - */  
99 - Task update(UpdateTaskPayload updateTaskPayload);  
100 -  
101 - /**  
102 - * Deletes a task  
103 - * - The authenticated user should be able to see the task in order to delete it  
104 - * - The authenticated user needs to be the assignee of the task in order to delete it  
105 - * - this method returns a shallow Task with the necessary information to validate that the task was deleted  
106 - */  
107 - Task delete(DeleteTaskPayload deleteTaskPayload);  
108 -  
109 - void createVariable(CreateTaskVariablePayload createTaskVariablePayload);  
110 - void updateVariable(UpdateTaskVariablePayload updateTaskVariablePayload);  
111 - List<VariableInstance> variables(GetTaskVariablesPayload getTaskVariablesPayload);  
112 -  
113 - void addCandidateUsers(CandidateUsersPayload candidateUsersPayload);  
114 - void deleteCandidateUsers(CandidateUsersPayload candidateUsersPayload);  
115 -  
116 - void addCandidateGroups(CandidateGroupsPayload candidateGroupsPayload);  
117 - void deleteCandidateGroups(CandidateGroupsPayload candidateGroupsPayload);  
118 -  
119 - List<String> userCandidates(String taskId);  
120 - List<String> groupCandidates(String taskId);  
121 -  
122 -} 1 +package com.trash.activiti.service;
  2 +import java.util.List;
  3 +import java.util.Set;
  4 +
  5 +import org.activiti.api.model.shared.model.VariableInstance;
  6 +import org.activiti.api.runtime.shared.query.Page;
  7 +import org.activiti.api.runtime.shared.query.Pageable;
  8 +import org.activiti.api.task.model.Task;
  9 +import org.activiti.api.task.model.payloads.CandidateGroupsPayload;
  10 +import org.activiti.api.task.model.payloads.CandidateUsersPayload;
  11 +import org.activiti.api.task.model.payloads.ClaimTaskPayload;
  12 +import org.activiti.api.task.model.payloads.CompleteTaskPayload;
  13 +import org.activiti.api.task.model.payloads.CreateTaskPayload;
  14 +import org.activiti.api.task.model.payloads.CreateTaskVariablePayload;
  15 +import org.activiti.api.task.model.payloads.DeleteTaskPayload;
  16 +import org.activiti.api.task.model.payloads.GetTaskVariablesPayload;
  17 +import org.activiti.api.task.model.payloads.GetTasksPayload;
  18 +import org.activiti.api.task.model.payloads.ReleaseTaskPayload;
  19 +import org.activiti.api.task.model.payloads.SaveTaskPayload;
  20 +import org.activiti.api.task.model.payloads.UpdateTaskPayload;
  21 +import org.activiti.api.task.model.payloads.UpdateTaskVariablePayload;
  22 +import org.activiti.api.task.runtime.conf.TaskRuntimeConfiguration;
  23 +
  24 +public interface myTaskService {
  25 +
  26 +
  27 +
  28 + TaskRuntimeConfiguration configuration();
  29 +
  30 + /**
  31 + * Get task by id if the authenticated user:
  32 + * - is the assignee or
  33 + * - is in a group with is assigned to the task or
  34 + * - has admin role
  35 + */
  36 + Task task(String taskId);
  37 +
  38 + /**
  39 + * Get all tasks where
  40 + * - the authenticated user is the actual assignee
  41 + * - the user belongs to a group that is a candidate for the task
  42 + */
  43 + Page<Task> tasks(Pageable pageable);
  44 +
  45 + /**
  46 + * Get all tasks where applying the filters in the Payload
  47 + * - the authenticated user is the actual assignee
  48 + * - the user belongs to a group that is a candidate for the task
  49 + */
  50 +
  51 +
  52 + Page<Task> tasks(Pageable pageable,
  53 + GetTasksPayload getTasksPayload,Set<String> defKey,String name);
  54 +
  55 + /**
  56 + * Creates a task based on the following rules
  57 + * - If an assignee is provided it creates and assign the task to the provided user
  58 + * - If there is no assignee the task is not assigned, just created
  59 + * - The owner of the task is the currently authenticated user (which is automatically added as a candidate)
  60 + * - If a group or list of groups is provided those groups are added as candidates for claiming the task
  61 + */
  62 + Task create(CreateTaskPayload createTaskPayload);
  63 +
  64 + /**
  65 + * Claim a task with the currently authenticated user
  66 + * - If there is no authenticated user throw an IllegalStateException
  67 + * - If the currently authenticated user is not a candidate throw an IllegalStateException
  68 + * - The current approach doesn't support impersonation, it will always take the currently authenticated user
  69 + * - after the claim the task should be in assigned status
  70 + */
  71 + Task claim(ClaimTaskPayload claimTaskPayload);
  72 +
  73 + /**
  74 + * Release a previously claimed task
  75 + * - The authenticated user needs to be the assignee in order to release it
  76 + */
  77 + Task release(ReleaseTaskPayload releaseTaskPayload);
  78 +
  79 + /**
  80 + * Completes the selected task with the variables set in the payload
  81 + * - This method checks that the task is visible by the authenticated user
  82 + * - This method also check that the task is assigned to the currently authenticated user before complete
  83 + * - This method return a shallow Task object with the basic information needed to validate that the task was completed
  84 + */
  85 + Task complete(CompleteTaskPayload completeTaskPayload);
  86 +
  87 + /**
  88 + * Saves the selected task with the variables set in the payload in the task scope
  89 + * - This method checks that the task is visible by the authenticated user
  90 + * - This method also check that the task is assigned to the currently authenticated user
  91 + */
  92 + void save(SaveTaskPayload saveTaskPayload);
  93 +
  94 + /**
  95 + * Updates details of a task
  96 + * - The authenticated user should be able to see the task in order to update its details
  97 + * - The authenticated user needs to be the assignee of the task to update its details, if not he/she will need to claim the task first
  98 + */
  99 + Task update(UpdateTaskPayload updateTaskPayload);
  100 +
  101 + /**
  102 + * Deletes a task
  103 + * - The authenticated user should be able to see the task in order to delete it
  104 + * - The authenticated user needs to be the assignee of the task in order to delete it
  105 + * - this method returns a shallow Task with the necessary information to validate that the task was deleted
  106 + */
  107 + Task delete(DeleteTaskPayload deleteTaskPayload);
  108 +
  109 + void createVariable(CreateTaskVariablePayload createTaskVariablePayload);
  110 + void updateVariable(UpdateTaskVariablePayload updateTaskVariablePayload);
  111 + List<VariableInstance> variables(GetTaskVariablesPayload getTaskVariablesPayload);
  112 +
  113 + void addCandidateUsers(CandidateUsersPayload candidateUsersPayload);
  114 + void deleteCandidateUsers(CandidateUsersPayload candidateUsersPayload);
  115 +
  116 + void addCandidateGroups(CandidateGroupsPayload candidateGroupsPayload);
  117 + void deleteCandidateGroups(CandidateGroupsPayload candidateGroupsPayload);
  118 +
  119 + List<String> userCandidates(String taskId);
  120 + List<String> groupCandidates(String taskId);
  121 +
  122 +}
trash-framework/src/main/java/com/trash/framework/security/filter/JwtAuthenticationTokenFilter.java
1 package com.trash.framework.security.filter; 1 package com.trash.framework.security.filter;
2 2
3 -import java.awt.datatransfer.FlavorEvent;  
4 import java.io.IOException; 3 import java.io.IOException;
  4 +import java.util.HashMap;
  5 +import java.util.Map;
  6 +import java.util.Set;
  7 +import java.util.TreeMap;
  8 +
5 import javax.servlet.FilterChain; 9 import javax.servlet.FilterChain;
6 import javax.servlet.ServletException; 10 import javax.servlet.ServletException;
7 -import javax.servlet.http.Cookie; 11 +import javax.servlet.ServletResponse;
8 import javax.servlet.http.HttpServletRequest; 12 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpServletResponse; 13 import javax.servlet.http.HttpServletResponse;
  14 +
  15 +import org.apache.commons.fileupload.servlet.ServletFileUpload;
10 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.http.HttpStatus;
11 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 18 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
12 import org.springframework.security.core.context.SecurityContextHolder; 19 import org.springframework.security.core.context.SecurityContextHolder;
13 import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; 20 import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
14 import org.springframework.stereotype.Component; 21 import org.springframework.stereotype.Component;
15 import org.springframework.web.filter.OncePerRequestFilter; 22 import org.springframework.web.filter.OncePerRequestFilter;
16 23
  24 +import com.alibaba.fastjson.JSON;
  25 +import com.alibaba.fastjson.JSONObject;
  26 +import com.google.gson.Gson;
17 import com.trash.common.config.trashConfig; 27 import com.trash.common.config.trashConfig;
18 import com.trash.common.core.domain.model.LoginUser; 28 import com.trash.common.core.domain.model.LoginUser;
19 import com.trash.common.utils.RemoteServerUtils; 29 import com.trash.common.utils.RemoteServerUtils;
@@ -39,13 +49,15 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter @@ -39,13 +49,15 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
39 /** 系统基础配置 */ 49 /** 系统基础配置 */
40 @Autowired 50 @Autowired
41 private trashConfig trashConfig; 51 private trashConfig trashConfig;
42 - 52 +
  53 + private static final String SQL_REGX = ".*(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|drop|execute)\\b).*";
  54 +
43 55
44 @Override 56 @Override
45 protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) 57 protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
46 throws ServletException, IOException 58 throws ServletException, IOException
47 { 59 {
48 - 60 +
49 61
50 if(RemoteServerUtils.remote == null){ 62 if(RemoteServerUtils.remote == null){
51 RemoteServerUtils.remote = trashConfig.getRemotePath(); 63 RemoteServerUtils.remote = trashConfig.getRemotePath();
@@ -76,10 +88,72 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter @@ -76,10 +88,72 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
76 authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); 88 authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
77 SecurityContextHolder.getContext().setAuthentication(authenticationToken); 89 SecurityContextHolder.getContext().setAuthentication(authenticationToken);
78 } 90 }
79 - chain.doFilter(request, response); 91 +
  92 + if(ServletFileUpload.isMultipartContent(request)){
  93 + chain.doFilter(request, response);
  94 + return;
  95 + }
  96 +
  97 + // 防止流读取一次后就没有了, 所以需要将流继续写出去
  98 + MyRequestWrapper requestWrapper = new MyRequestWrapper(request);
  99 + Gson gson = new Gson();
  100 + // 获取请求参数
  101 + Map<String, Object> paramsMaps = new HashMap<String, Object>();
  102 + if ("POST".equals(request.getMethod().toUpperCase())) {
  103 + String body = requestWrapper.getBody();
  104 + try{
  105 + paramsMaps = gson.fromJson(body, HashMap.class);
  106 + }catch(Exception e){
  107 + e.printStackTrace();
  108 + }
  109 + } else {
  110 + Map<String, String[]> parameterMap = requestWrapper.getParameterMap();
  111 + Set<Map.Entry<String, String[]>> entries = parameterMap.entrySet();
  112 + for (Map.Entry<String, String[]> next : entries) {
  113 + paramsMaps.put(next.getKey(), next.getValue()[0]);
  114 + }
  115 + }
  116 +
  117 + if(paramsMaps != null){
  118 + // 校验SQL注入
  119 + for (Object o : paramsMaps.entrySet()) {
  120 + Map.Entry entry = (Map.Entry) o;
  121 + Object value = entry.getValue();
  122 + if (value != null) {
  123 + boolean isValid = checkSqlInject(value.toString(), response);
  124 + if (!isValid) {
  125 + return;
  126 + }
  127 + }
  128 + }
  129 + }
  130 +
  131 +
  132 +
  133 + chain.doFilter(requestWrapper, response);
80 } 134 }
81 135
82 136
  137 + private boolean checkSqlInject(String value, ServletResponse servletResponse) throws IOException {
  138 + if (null != value && value.matches(SQL_REGX)) {
  139 +// log.error("您输入的参数有非法字符,请输入正确的参数");
  140 + HttpServletResponse response = (HttpServletResponse) servletResponse;
  141 +
  142 + response.setStatus(HttpStatus.BAD_REQUEST.value());
  143 +
  144 + Map<String, String> rsp = new HashMap<>();
  145 + rsp.put("code", HttpStatus.BAD_REQUEST.value() + "");
  146 + rsp.put("message", "您输入的参数有非法字符,请输入正确的参数!");
  147 +
  148 + response.setContentType("application/json;charset=UTF-8");
  149 + response.getWriter().write(JSON.toJSONString(rsp));
  150 + response.getWriter().flush();
  151 + response.getWriter().close();
  152 + return false;
  153 + }
  154 + return true;
  155 + }
  156 +
83 private LoginUser requestRemoteUser(String token) { 157 private LoginUser requestRemoteUser(String token) {
84 return loginService.loginByRemote(token); 158 return loginService.loginByRemote(token);
85 } 159 }
trash-framework/src/main/java/com/trash/framework/security/filter/MyRequestWrapper.java 0 → 100644
  1 +package com.trash.framework.security.filter;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.ByteArrayInputStream;
  5 +import java.io.IOException;
  6 +import java.io.InputStream;
  7 +import java.io.InputStreamReader;
  8 +import java.util.Enumeration;
  9 +import java.util.Map;
  10 +
  11 +import javax.servlet.ReadListener;
  12 +import javax.servlet.ServletInputStream;
  13 +import javax.servlet.http.HttpServletRequest;
  14 +import javax.servlet.http.HttpServletRequestWrapper;
  15 +
  16 +import kotlin.text.Charsets;
  17 +
  18 +public class MyRequestWrapper extends HttpServletRequestWrapper {
  19 + private String body;
  20 + public MyRequestWrapper(HttpServletRequest request) throws IOException {
  21 + super(request);
  22 + StringBuilder stringBuilder = new StringBuilder();
  23 + BufferedReader bufferedReader = null;
  24 + try {
  25 + InputStream inputStream = request.getInputStream();
  26 + if (inputStream != null) {
  27 + bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
  28 + char[] charBuffer = new char[128];
  29 + int bytesRead = -1;
  30 + while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
  31 + stringBuilder.append(charBuffer, 0, bytesRead);
  32 + }
  33 + } else {
  34 + stringBuilder.append("");
  35 + }
  36 + } catch (IOException ex) {
  37 + throw ex;
  38 + } finally {
  39 + if (bufferedReader != null) {
  40 + try {
  41 + bufferedReader.close();
  42 + } catch (IOException ex) {
  43 + throw ex;
  44 + }
  45 + }
  46 + }
  47 + body = stringBuilder.toString();
  48 + }
  49 +
  50 + @Override
  51 + public ServletInputStream getInputStream() throws IOException {
  52 + final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes("UTF-8"));
  53 + ServletInputStream servletInputStream = new ServletInputStream() {
  54 + @Override
  55 + public boolean isFinished() {
  56 + return false;
  57 + }
  58 +
  59 + @Override
  60 + public boolean isReady() {
  61 + return false;
  62 + }
  63 +
  64 + @Override
  65 + public int read() {
  66 + return byteArrayInputStream.read();
  67 + }
  68 +
  69 + @Override
  70 + public void setReadListener(ReadListener listener) {
  71 + // TODO Auto-generated method stub
  72 +
  73 + }
  74 + };
  75 + return servletInputStream;
  76 + }
  77 +
  78 + @Override
  79 + public BufferedReader getReader() throws IOException {
  80 + return new BufferedReader(new InputStreamReader(this.getInputStream(), Charsets.UTF_8));
  81 + }
  82 +
  83 + public String getBody() {
  84 + return this.body;
  85 + }
  86 +
  87 + @Override
  88 + public String getParameter(String name) {
  89 + return super.getParameter(name);
  90 + }
  91 +
  92 + @Override
  93 + public Map<String, String[]> getParameterMap() {
  94 + return super.getParameterMap();
  95 + }
  96 +
  97 + @Override
  98 + public Enumeration<String> getParameterNames() {
  99 + return super.getParameterNames();
  100 + }
  101 +
  102 + @Override
  103 + public String[] getParameterValues(String name) {
  104 + return super.getParameterValues(name);
  105 + }
  106 +}
0 \ No newline at end of file 107 \ No newline at end of file
trash-ui/dist.7z
No preview for this file type
trash-ui/src/api/taskmethod.js
@@ -307,15 +307,15 @@ export default { @@ -307,15 +307,15 @@ export default {
307 }) 307 })
308 return; 308 return;
309 } 309 }
310 - if (this.definitionKey == "workflow_company") { 310 + if (this.definitionKey.indexOf("workflow_company") > -1) {
311 this.company = true; 311 this.company = true;
312 return; 312 return;
313 } 313 }
314 - if (this.definitionKey == "workflow_vehicle") { 314 + if (this.definitionKey.indexOf("workflow_vehicle") > -1) {
315 this.vehicle = true; 315 this.vehicle = true;
316 return; 316 return;
317 } 317 }
318 - if (this.definitionKey == "workflow_driver") { 318 + if (this.definitionKey.indexOf("workflow_driver") > -1) {
319 this.driver = true; 319 this.driver = true;
320 return; 320 return;
321 } 321 }
@@ -601,6 +601,9 @@ export default { @@ -601,6 +601,9 @@ export default {
601 this.definitionKey == "workflow_company" || 601 this.definitionKey == "workflow_company" ||
602 this.definitionKey == "workflow_driver" || 602 this.definitionKey == "workflow_driver" ||
603 this.definitionKey == "workflow_vehicle" || 603 this.definitionKey == "workflow_vehicle" ||
  604 + this.definitionKey == "workflow_company_edit" ||
  605 + this.definitionKey == "workflow_driver_edit" ||
  606 + this.definitionKey == "workflow_vehicle_edit" ||
604 this.definitionKey == "workflow_earthsites" || 607 this.definitionKey == "workflow_earthsites" ||
605 this.definitionKey == "workflow_conract" || 608 this.definitionKey == "workflow_conract" ||
606 this.definitionKey == "workflow_conract_edit" || 609 this.definitionKey == "workflow_conract_edit" ||
trash-ui/src/api/three_step.js
@@ -357,7 +357,7 @@ export default { @@ -357,7 +357,7 @@ export default {
357 if(res.result.list[i].name == this.form.name){ 357 if(res.result.list[i].name == this.form.name){
358 let item = res.result.list[i]; 358 let item = res.result.list[i];
359 this.form.objectId = item.id; 359 this.form.objectId = item.id;
360 - this.form.place = Number(item.areaCode); 360 + this.form.place = item.areaCode;
361 this.getCompanyTrucks(item.id); 361 this.getCompanyTrucks(item.id);
362 break; 362 break;
363 } 363 }
@@ -383,7 +383,7 @@ export default { @@ -383,7 +383,7 @@ export default {
383 if(res.result.list[i].name == this.form.name){ 383 if(res.result.list[i].name == this.form.name){
384 let item = res.result.list[i]; 384 let item = res.result.list[i];
385 this.form.objectId = item.id; 385 this.form.objectId = item.id;
386 - this.form.place = Number(item.areaCode) ; 386 + this.form.place = item.areaCode;
387 break; 387 break;
388 } 388 }
389 } 389 }
trash-workFlow/src/main/java/com/trash/business/controller/CompanyCreditController.java
1 -package com.trash.business.controller;  
2 -  
3 -import java.util.ArrayList;  
4 -import java.util.Date;  
5 -import java.util.List;  
6 -  
7 -import com.trash.business.domain.ConstructionCredit;  
8 -import org.springframework.security.access.prepost.PreAuthorize;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.web.bind.annotation.GetMapping;  
11 -import org.springframework.web.bind.annotation.PostMapping;  
12 -import org.springframework.web.bind.annotation.PutMapping;  
13 -import org.springframework.web.bind.annotation.DeleteMapping;  
14 -import org.springframework.web.bind.annotation.PathVariable;  
15 -import org.springframework.web.bind.annotation.RequestBody;  
16 -import org.springframework.web.bind.annotation.RequestMapping;  
17 -import org.springframework.web.bind.annotation.RestController;  
18 -import com.trash.common.annotation.Log;  
19 -import com.trash.common.annotation.RepeatSubmit;  
20 -import com.trash.common.core.controller.BaseController;  
21 -import com.trash.common.core.domain.AjaxResult;  
22 -import com.trash.common.enums.BusinessType;  
23 -import com.trash.business.domain.CompanyCredit;  
24 -import com.trash.business.service.ICompanyCreditService;  
25 -import com.trash.common.utils.SecurityUtils;  
26 -import com.trash.common.utils.poi.ExcelUtil;  
27 -import com.trash.common.core.page.TableDataInfo;  
28 -  
29 -/**  
30 - * 企业失信Controller  
31 - *  
32 - * @author trash  
33 - * @date 2023-04-25  
34 - */  
35 -@RestController  
36 -@RequestMapping("/business/companyCredit")  
37 -public class CompanyCreditController extends BaseController {  
38 - @Autowired  
39 - private ICompanyCreditService companyCreditService;  
40 -  
41 - /**  
42 - * 查询企业失信列表  
43 - */  
44 - @GetMapping("/list")  
45 - public TableDataInfo list(CompanyCredit companyCredit) {  
46 - startPage();  
47 - return getDataTable(companyCreditService.selectCompanyCreditList(companyCredit));  
48 - }  
49 -  
50 - @GetMapping("/historyCredit")  
51 - public TableDataInfo historyCredit(CompanyCredit companyCredit) {  
52 - startPage();  
53 - return getDataTable(companyCreditService.selectCompanyCreditHistory(companyCredit));  
54 - }  
55 -  
56 - @GetMapping("/names")  
57 - public List<String> getNames(CompanyCredit credit) {  
58 - if (credit.getStatus() == 1) {  
59 - credit.setStatus(null);  
60 - }  
61 - return companyCreditService.getNames(credit);  
62 - }  
63 -  
64 - @GetMapping("/places")  
65 - public List<String> getPlaces(CompanyCredit credit) {  
66 - if (credit.getStatus() == 1) {  
67 - credit.setStatus(null);  
68 - }  
69 - return companyCreditService.getPlaces(credit);  
70 - }  
71 -  
72 - /**  
73 - * 导出企业失信列表  
74 - */  
75 - @Log(title = "企业失信", businessType = BusinessType.EXPORT)  
76 - @GetMapping("/export")  
77 - public AjaxResult export(CompanyCredit companyCredit) {  
78 - List<CompanyCredit> list = null;  
79 -  
80 - List<String> withOut = new ArrayList<String>();  
81 -  
82 - String tag = "企业失信";  
83 -  
84 - if (companyCredit.getStatus() == 1) {  
85 - withOut.add("time");  
86 - tag = "企业历史失信";  
87 - list = companyCreditService.selectCompanyCreditHistory(companyCredit);  
88 - } else {  
89 - list = companyCreditService.selectCompanyCreditList(companyCredit);  
90 - }  
91 -  
92 - for (int i = 0; i < list.size(); i++) {  
93 - list.get(i).setId((long) i + 1);  
94 - }  
95 -  
96 - ExcelUtil<CompanyCredit> util = new ExcelUtil<CompanyCredit>(CompanyCredit.class);  
97 -  
98 - return util.exportExcel(list, tag, withOut);  
99 - }  
100 -  
101 - /**  
102 - * 获取企业失信详细信息  
103 - */  
104 - @GetMapping(value = "/{id}")  
105 - public AjaxResult getInfo(@PathVariable("id") Long id) {  
106 - return AjaxResult.success(companyCreditService.selectCompanyCreditById(id));  
107 - }  
108 -  
109 - /**  
110 - * 新增企业失信  
111 - */  
112 - @Log(title = "企业失信", businessType = BusinessType.INSERT)  
113 - @PostMapping  
114 - @RepeatSubmit  
115 - public AjaxResult add(@RequestBody CompanyCredit companyCredit) {  
116 - try {  
117 -  
118 - companyCredit.setCreateBy(SecurityUtils.getUsername());  
119 - companyCredit.setTime(new Date());  
120 -  
121 - return toAjax(companyCreditService.insertCompanyCredit(companyCredit));  
122 - } catch (Exception e) {  
123 - return AjaxResult.error(e.getMessage());  
124 - }  
125 - }  
126 -  
127 - /**  
128 - * 修改企业失信  
129 - */  
130 - @Log(title = "企业失信", businessType = BusinessType.UPDATE)  
131 - @PutMapping  
132 - public AjaxResult edit(@RequestBody CompanyCredit companyCredit) {  
133 - try {  
134 - return toAjax(companyCreditService.updateCompanyCredit(companyCredit));  
135 - } catch (Exception e) {  
136 - return AjaxResult.error(e.getMessage());  
137 - }  
138 - }  
139 -  
140 - /**  
141 - * 删除企业失信  
142 - */  
143 - @Log(title = "企业失信", businessType = BusinessType.DELETE)  
144 - @DeleteMapping("/{ids}")  
145 - public AjaxResult remove(@PathVariable Long[] ids) {  
146 - return toAjax(companyCreditService.deleteCompanyCreditByIds(ids));  
147 - } 1 +package com.trash.business.controller;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.Date;
  5 +import java.util.List;
  6 +
  7 +import com.trash.business.domain.ConstructionCredit;
  8 +import org.springframework.security.access.prepost.PreAuthorize;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.GetMapping;
  11 +import org.springframework.web.bind.annotation.PostMapping;
  12 +import org.springframework.web.bind.annotation.PutMapping;
  13 +import org.springframework.web.bind.annotation.DeleteMapping;
  14 +import org.springframework.web.bind.annotation.PathVariable;
  15 +import org.springframework.web.bind.annotation.RequestBody;
  16 +import org.springframework.web.bind.annotation.RequestMapping;
  17 +import org.springframework.web.bind.annotation.RestController;
  18 +import com.trash.common.annotation.Log;
  19 +import com.trash.common.annotation.RepeatSubmit;
  20 +import com.trash.common.core.controller.BaseController;
  21 +import com.trash.common.core.domain.AjaxResult;
  22 +import com.trash.common.enums.BusinessType;
  23 +import com.trash.business.domain.CompanyCredit;
  24 +import com.trash.business.service.ICompanyCreditService;
  25 +import com.trash.common.utils.SecurityUtils;
  26 +import com.trash.common.utils.poi.ExcelUtil;
  27 +import com.trash.common.core.page.TableDataInfo;
  28 +
  29 +/**
  30 + * 企业失信Controller
  31 + *
  32 + * @author trash
  33 + * @date 2023-04-25
  34 + */
  35 +@RestController
  36 +@RequestMapping("/business/companyCredit")
  37 +public class CompanyCreditController extends BaseController {
  38 + @Autowired
  39 + private ICompanyCreditService companyCreditService;
  40 +
  41 + /**
  42 + * 查询企业失信列表
  43 + */
  44 + @GetMapping("/list")
  45 + public TableDataInfo list(CompanyCredit companyCredit) {
  46 + startPage();
  47 + return getDataTable(companyCreditService.selectCompanyCreditList(companyCredit));
  48 + }
  49 +
  50 + @GetMapping("/historyCredit")
  51 + public TableDataInfo historyCredit(CompanyCredit companyCredit) {
  52 + startPage();
  53 + return getDataTable(companyCreditService.selectCompanyCreditHistory(companyCredit));
  54 + }
  55 +
  56 + @GetMapping("/names")
  57 + public List<String> getNames(CompanyCredit credit) {
  58 + if (credit.getStatus() == 1) {
  59 + credit.setStatus(null);
  60 + }
  61 + return companyCreditService.getNames(credit);
  62 + }
  63 +
  64 + @GetMapping("/places")
  65 + public List<String> getPlaces(CompanyCredit credit) {
  66 + if (credit.getStatus() == 1) {
  67 + credit.setStatus(null);
  68 + }
  69 + return companyCreditService.getPlaces(credit);
  70 + }
  71 +
  72 + /**
  73 + * 导出企业失信列表
  74 + */
  75 + @Log(title = "企业失信", businessType = BusinessType.EXPORT)
  76 + @GetMapping("/export")
  77 + public AjaxResult export(CompanyCredit companyCredit) {
  78 + List<CompanyCredit> list = null;
  79 +
  80 + List<String> withOut = new ArrayList<String>();
  81 +
  82 + String tag = "企业失信";
  83 +
  84 + if (companyCredit.getStatus() == 1) {
  85 + withOut.add("time");
  86 + tag = "企业历史失信";
  87 + list = companyCreditService.selectCompanyCreditHistory(companyCredit);
  88 + } else {
  89 + list = companyCreditService.selectCompanyCreditList(companyCredit);
  90 + }
  91 +
  92 + for (int i = 0; i < list.size(); i++) {
  93 + list.get(i).setId((long) i + 1);
  94 + }
  95 +
  96 + ExcelUtil<CompanyCredit> util = new ExcelUtil<CompanyCredit>(CompanyCredit.class);
  97 +
  98 + return util.exportExcel(list, tag, withOut);
  99 + }
  100 +
  101 + /**
  102 + * 获取企业失信详细信息
  103 + */
  104 + @GetMapping(value = "/{id}")
  105 + public AjaxResult getInfo(@PathVariable("id") Long id) {
  106 + return AjaxResult.success(companyCreditService.selectCompanyCreditById(id));
  107 + }
  108 +
  109 + /**
  110 + * 新增企业失信
  111 + */
  112 + @Log(title = "企业失信", businessType = BusinessType.INSERT)
  113 + @PostMapping
  114 + @RepeatSubmit
  115 + public AjaxResult add(@RequestBody CompanyCredit companyCredit) {
  116 + try {
  117 +
  118 + companyCredit.setCreateBy(SecurityUtils.getUsername());
  119 + companyCredit.setTime(new Date());
  120 +
  121 + return toAjax(companyCreditService.insertCompanyCredit(companyCredit));
  122 + } catch (Exception e) {
  123 + return AjaxResult.error(e.getMessage());
  124 + }
  125 + }
  126 +
  127 + /**
  128 + * 修改企业失信
  129 + */
  130 + @Log(title = "企业失信", businessType = BusinessType.UPDATE)
  131 + @PutMapping
  132 + public AjaxResult edit(@RequestBody CompanyCredit companyCredit) {
  133 + try {
  134 + return toAjax(companyCreditService.updateCompanyCredit(companyCredit));
  135 + } catch (Exception e) {
  136 + return AjaxResult.error(e.getMessage());
  137 + }
  138 + }
  139 +
  140 + /**
  141 + * 删除企业失信
  142 + */
  143 + @Log(title = "企业失信", businessType = BusinessType.DELETE)
  144 + @DeleteMapping("/{ids}")
  145 + public AjaxResult remove(@PathVariable Long[] ids) {
  146 + return toAjax(companyCreditService.deleteCompanyCreditByIds(ids));
  147 + }
148 } 148 }
149 \ No newline at end of file 149 \ No newline at end of file
trash-workFlow/src/main/java/com/trash/business/controller/DriverCreditController.java
1 -package com.trash.business.controller;  
2 -  
3 -import java.util.ArrayList;  
4 -import java.util.Date;  
5 -import java.util.List;  
6 -  
7 -import com.trash.business.domain.ConstructionCredit;  
8 -import org.springframework.security.access.prepost.PreAuthorize;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.web.bind.annotation.GetMapping;  
11 -import org.springframework.web.bind.annotation.PostMapping;  
12 -import org.springframework.web.bind.annotation.PutMapping;  
13 -import org.springframework.web.bind.annotation.DeleteMapping;  
14 -import org.springframework.web.bind.annotation.PathVariable;  
15 -import org.springframework.web.bind.annotation.RequestBody;  
16 -import org.springframework.web.bind.annotation.RequestMapping;  
17 -import org.springframework.web.bind.annotation.RestController;  
18 -import com.trash.common.annotation.Log;  
19 -import com.trash.common.annotation.RepeatSubmit;  
20 -import com.trash.common.core.controller.BaseController;  
21 -import com.trash.common.core.domain.AjaxResult;  
22 -import com.trash.common.enums.BusinessType;  
23 -import com.trash.business.domain.DriverCredit;  
24 -import com.trash.business.mapper.DriverCreditMapper;  
25 -import com.trash.business.service.IDriverCreditService;  
26 -import com.trash.common.utils.SecurityUtils;  
27 -import com.trash.common.utils.poi.ExcelUtil;  
28 -import com.trash.common.core.page.TableDataInfo;  
29 -  
30 -/**  
31 - * 驾驶员失信Controller  
32 - *  
33 - * @author trash  
34 - * @date 2023-04-26  
35 - */  
36 -@RestController  
37 -@RequestMapping("/business/driverCredit")  
38 -public class DriverCreditController extends BaseController {  
39 - @Autowired  
40 - private IDriverCreditService driverCreditService;  
41 -  
42 - @Autowired  
43 - private DriverCreditMapper mapper;  
44 -  
45 - /**  
46 - * 查询驾驶员失信列表  
47 - */  
48 - @GetMapping("/list")  
49 - public TableDataInfo list(DriverCredit driverCredit) {  
50 - startPage();  
51 - List<DriverCredit> list = driverCreditService.selectDriverCreditList(driverCredit);  
52 - return getDataTable(list);  
53 - }  
54 -  
55 - @GetMapping("/historyCredit")  
56 - public TableDataInfo historyCredit(DriverCredit driverCredit) {  
57 - startPage();  
58 - List<DriverCredit> list = driverCreditService.selectDriverCreditHistory(driverCredit);  
59 - return getDataTable(list);  
60 - }  
61 -  
62 - @GetMapping("/names")  
63 - public List<String> getNames(DriverCredit credit) {  
64 -  
65 - if (credit.getStatus() == 1) {  
66 - credit.setStatus(null);  
67 - }  
68 - return mapper.getNames(credit);  
69 - }  
70 -  
71 - @GetMapping("/licenseplates")  
72 - public List<String> getLicenseplates(DriverCredit credit) {  
73 -  
74 - if (credit.getStatus() == 1) {  
75 - credit.setStatus(null);  
76 - }  
77 - return mapper.getLicenseplate(credit);  
78 - }  
79 -  
80 - /**  
81 - * 导出驾驶员失信列表  
82 - */  
83 - @Log(title = "驾驶员失信", businessType = BusinessType.EXPORT)  
84 - @GetMapping("/export")  
85 - public AjaxResult export(DriverCredit driverCredit) {  
86 -  
87 - List<DriverCredit> list = null;  
88 - List<String> withOut = new ArrayList<String>();  
89 -  
90 - if (driverCredit.getStatus() == 1) {  
91 - withOut.add("time");  
92 - list = driverCreditService.selectDriverCreditHistory(driverCredit);  
93 - } else {  
94 -  
95 - list = driverCreditService.selectDriverCreditList(driverCredit);  
96 -  
97 - }  
98 - for (int i = 0; i < list.size(); i++) {  
99 - list.get(i).setId((long) i + 1);  
100 - }  
101 - ExcelUtil<DriverCredit> util = new ExcelUtil<DriverCredit>(DriverCredit.class);  
102 - return util.exportExcel(list, "驾驶员失信", withOut);  
103 - }  
104 -  
105 - /**  
106 - * 获取驾驶员失信详细信息  
107 - */  
108 - @GetMapping(value = "/{id}")  
109 - public AjaxResult getInfo(@PathVariable("id") Long id) {  
110 - return AjaxResult.success(driverCreditService.selectDriverCreditById(id));  
111 - }  
112 -  
113 - /**  
114 - * 新增驾驶员失信  
115 - */  
116 - @Log(title = "驾驶员失信", businessType = BusinessType.INSERT)  
117 - @PostMapping  
118 - @RepeatSubmit  
119 - public AjaxResult add(@RequestBody DriverCredit driverCredit) {  
120 - driverCredit.setCreateBy(SecurityUtils.getUsername());  
121 - driverCredit.setTime(new Date());  
122 - return toAjax(driverCreditService.insertDriverCredit(driverCredit));  
123 - }  
124 -  
125 - /**  
126 - * 修改驾驶员失信  
127 - */  
128 - @Log(title = "驾驶员失信", businessType = BusinessType.UPDATE)  
129 - @PutMapping  
130 - public AjaxResult edit(@RequestBody DriverCredit driverCredit) {  
131 - return toAjax(driverCreditService.updateDriverCredit(driverCredit));  
132 - }  
133 -  
134 - /**  
135 - * 删除驾驶员失信  
136 - */  
137 - @Log(title = "驾驶员失信", businessType = BusinessType.DELETE)  
138 - @DeleteMapping("/{ids}")  
139 - public AjaxResult remove(@PathVariable Long[] ids) {  
140 - return toAjax(driverCreditService.deleteDriverCreditByIds(ids));  
141 - }  
142 -} 1 +package com.trash.business.controller;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.Date;
  5 +import java.util.List;
  6 +
  7 +import com.trash.business.domain.ConstructionCredit;
  8 +import org.springframework.security.access.prepost.PreAuthorize;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.GetMapping;
  11 +import org.springframework.web.bind.annotation.PostMapping;
  12 +import org.springframework.web.bind.annotation.PutMapping;
  13 +import org.springframework.web.bind.annotation.DeleteMapping;
  14 +import org.springframework.web.bind.annotation.PathVariable;
  15 +import org.springframework.web.bind.annotation.RequestBody;
  16 +import org.springframework.web.bind.annotation.RequestMapping;
  17 +import org.springframework.web.bind.annotation.RestController;
  18 +import com.trash.common.annotation.Log;
  19 +import com.trash.common.annotation.RepeatSubmit;
  20 +import com.trash.common.core.controller.BaseController;
  21 +import com.trash.common.core.domain.AjaxResult;
  22 +import com.trash.common.enums.BusinessType;
  23 +import com.trash.business.domain.DriverCredit;
  24 +import com.trash.business.mapper.DriverCreditMapper;
  25 +import com.trash.business.service.IDriverCreditService;
  26 +import com.trash.common.utils.SecurityUtils;
  27 +import com.trash.common.utils.poi.ExcelUtil;
  28 +import com.trash.common.core.page.TableDataInfo;
  29 +
  30 +/**
  31 + * 驾驶员失信Controller
  32 + *
  33 + * @author trash
  34 + * @date 2023-04-26
  35 + */
  36 +@RestController
  37 +@RequestMapping("/business/driverCredit")
  38 +public class DriverCreditController extends BaseController {
  39 + @Autowired
  40 + private IDriverCreditService driverCreditService;
  41 +
  42 + @Autowired
  43 + private DriverCreditMapper mapper;
  44 +
  45 + /**
  46 + * 查询驾驶员失信列表
  47 + */
  48 + @GetMapping("/list")
  49 + public TableDataInfo list(DriverCredit driverCredit) {
  50 + startPage();
  51 + List<DriverCredit> list = driverCreditService.selectDriverCreditList(driverCredit);
  52 + return getDataTable(list);
  53 + }
  54 +
  55 + @GetMapping("/historyCredit")
  56 + public TableDataInfo historyCredit(DriverCredit driverCredit) {
  57 + startPage();
  58 + List<DriverCredit> list = driverCreditService.selectDriverCreditHistory(driverCredit);
  59 + return getDataTable(list);
  60 + }
  61 +
  62 + @GetMapping("/names")
  63 + public List<String> getNames(DriverCredit credit) {
  64 +
  65 + if (credit.getStatus() == 1) {
  66 + credit.setStatus(null);
  67 + }
  68 + return mapper.getNames(credit);
  69 + }
  70 +
  71 + @GetMapping("/licenseplates")
  72 + public List<String> getLicenseplates(DriverCredit credit) {
  73 +
  74 + if (credit.getStatus() == 1) {
  75 + credit.setStatus(null);
  76 + }
  77 + return mapper.getLicenseplate(credit);
  78 + }
  79 +
  80 + /**
  81 + * 导出驾驶员失信列表
  82 + */
  83 + @Log(title = "驾驶员失信", businessType = BusinessType.EXPORT)
  84 + @GetMapping("/export")
  85 + public AjaxResult export(DriverCredit driverCredit) {
  86 +
  87 + List<DriverCredit> list = null;
  88 + List<String> withOut = new ArrayList<String>();
  89 +
  90 + if (driverCredit.getStatus() == 1) {
  91 + withOut.add("time");
  92 + list = driverCreditService.selectDriverCreditHistory(driverCredit);
  93 + } else {
  94 +
  95 + list = driverCreditService.selectDriverCreditList(driverCredit);
  96 +
  97 + }
  98 + for (int i = 0; i < list.size(); i++) {
  99 + list.get(i).setId((long) i + 1);
  100 + }
  101 + ExcelUtil<DriverCredit> util = new ExcelUtil<DriverCredit>(DriverCredit.class);
  102 + return util.exportExcel(list, "驾驶员失信", withOut);
  103 + }
  104 +
  105 + /**
  106 + * 获取驾驶员失信详细信息
  107 + */
  108 + @GetMapping(value = "/{id}")
  109 + public AjaxResult getInfo(@PathVariable("id") Long id) {
  110 + return AjaxResult.success(driverCreditService.selectDriverCreditById(id));
  111 + }
  112 +
  113 + /**
  114 + * 新增驾驶员失信
  115 + */
  116 + @Log(title = "驾驶员失信", businessType = BusinessType.INSERT)
  117 + @PostMapping
  118 + @RepeatSubmit
  119 + public AjaxResult add(@RequestBody DriverCredit driverCredit) {
  120 + driverCredit.setCreateBy(SecurityUtils.getUsername());
  121 + driverCredit.setTime(new Date());
  122 + return toAjax(driverCreditService.insertDriverCredit(driverCredit));
  123 + }
  124 +
  125 + /**
  126 + * 修改驾驶员失信
  127 + */
  128 + @Log(title = "驾驶员失信", businessType = BusinessType.UPDATE)
  129 + @PutMapping
  130 + public AjaxResult edit(@RequestBody DriverCredit driverCredit) {
  131 + return toAjax(driverCreditService.updateDriverCredit(driverCredit));
  132 + }
  133 +
  134 + /**
  135 + * 删除驾驶员失信
  136 + */
  137 + @Log(title = "驾驶员失信", businessType = BusinessType.DELETE)
  138 + @DeleteMapping("/{ids}")
  139 + public AjaxResult remove(@PathVariable Long[] ids) {
  140 + return toAjax(driverCreditService.deleteDriverCreditByIds(ids));
  141 + }
  142 +}