Commit de4dddd3 by chenweisong

更新

parent c8c89bc8
package com.keymobile.rest.common.conf;
import com.keymobile.rest.common.bean.ApiResponse;
import com.keymobile.rest.common.constant.ApiConstant;
import com.keymobile.rest.common.exception.TwinkleException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* description: 全局异常处理
*
* @author :ws6049
* @date :2019/1/13 0:26
*/
@RestControllerAdvice
public class ExceptionHandlerConfig {
private static final Logger logger = LoggerFactory.getLogger(ExceptionHandlerConfig.class);
/**
* description: 捕获全局异常
* created by King on 2019/1/13 0:30.
*
* @return ApiResponse
* @Param: ex
*/
@ExceptionHandler(Exception.class)
public ApiResponse globalException(Throwable ex) {
if (ex instanceof TwinkleException) {
logger.warn("访问出错:" + ex.getMessage());
return ApiResponse.fail(ApiConstant.FAILED_CODE, ex.getMessage());
}
logger.error("访问出错:", ex);
return ApiResponse.fail(ApiConstant.FAILED_CODE, "网络不给力");
}
}
package com.keymobile.rest.common.exception;
import lombok.Data;
/**
* description: 通用异常
*
* @author :chenws
* @date :2019/1/12 23:28
*/
@Data
public class TwinkleException extends RuntimeException {
private static final long serialVersionUID = 3455708526465670030L;
public TwinkleException(String msg) {
super(msg);
}
}
package com.keymobile.rest.common.validator;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Collection;
import java.util.Map;
/**
* description: 通用校验抽象类,放校验辅助方法
*
* @author :chenws
* @date :2019/1/12 23:28
*/
public abstract class AbstractValidator {
public static <T> boolean notNull(T value) {
return value != null;
}
public static <T> boolean notEmpty(T[] value) {
return ArrayUtils.isNotEmpty(value);
}
public static <T extends Collection<?>> boolean notEmpty(T value) {
return !(value == null || value.isEmpty());
}
public static <T extends Map<?, ?>> boolean notEmpty(T value) {
return !(value == null || value.isEmpty());
}
public static <T extends CharSequence> boolean notEmpty(T value) {
return StringUtils.isNotEmpty(value);
}
public static boolean maxLength(String value, int maxLength) {
int len = StringUtils.length(value);
return len <= maxLength;
}
public static boolean range(String value, int minLength, int maxLength) {
int len = StringUtils.length(value);
return len >= minLength && len <= maxLength;
}
public static boolean range(Integer value, int min, int max) {
if (value == null) {
return true;
}
return value >= min && value <= max;
}
public static Boolean isNotNULL(Object... value) {
if (null == value || value.length < 1) {
return false;
} else {
for (int i = 0; i < value.length; i++) {
if (null == value[i] || "".equals(value[i].toString()) || "null".equals(value[i].toString().toLowerCase())) {
return false;
}
}
}
return true;
}
}
\ No newline at end of file
package com.keymobile.rest.common.validator;
import com.keymobile.rest.common.exception.TwinkleException;
import java.util.Collection;
import java.util.Map;
import java.util.regex.Pattern;
/**
* description: 通用校验类
*
* @author :chenws
* @date :2019/1/12 23:28
*/
public final class TwinkleValidator extends AbstractValidator {
public static void isTrue(boolean flag, String message) {
if (!flag) {
throw new TwinkleException(message);
}
}
public static void isFalse(boolean flag, String message) {
if (flag) {
throw new TwinkleException(message);
}
}
public static void notLessThan(int value, int flag, String message) {
if (value < flag) {
throw new TwinkleException(message);
}
}
public static void notMessThan(int value, int flag, String message) {
if (value > flag) {
throw new TwinkleException(message);
}
}
public static <T> boolean notNull(T value, String message) {
boolean isValid = notNull(value);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static boolean isNotNumber(String input, String message) {
if (!isNotNULL(input)) {
return false;
}
boolean isValid = Pattern.matches("^\\d+$", input);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static <T extends CharSequence> boolean notEmpty(T value, String message) {
boolean isValid = notEmpty(value);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static <T> boolean notEmpty(T[] value, String message) {
boolean isValid = notEmpty(value);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static <T extends Collection<?>> boolean notEmpty(T value, String message) {
boolean isValid = notEmpty(value);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static <T extends Map<?, ?>> boolean notEmpty(T value, String message) {
boolean isValid = notEmpty(value);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static boolean maxLength(String value, int maxLength, String message) {
boolean isValid = maxLength(value, maxLength);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static boolean range(String value, int minLength, int maxLength, String message) {
boolean isValid = range(value, minLength, maxLength);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
public static boolean range(Integer value, int min, int max, String message) {
boolean isValid = range(value, min, max);
if (!isValid) {
throw new TwinkleException(message);
}
return isValid;
}
}
......@@ -9,5 +9,7 @@ public interface ExcelDao extends JpaRepository<Excel, Long> {
List<Excel> findAllByIdIn(List<Long> ids);
List<Excel> findAllByJobId(long jid);
}
......@@ -11,4 +11,5 @@ public interface JobDao extends JpaRepository<Job, Long> {
Page<Job> findAllByNameLike(String valueOf, Pageable pageable);
Job findByProcessId(String pid);
}
......@@ -3,7 +3,11 @@ package com.keymobile.rest.dao;
import com.keymobile.rest.model.RecordInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface RecordInfoDao extends JpaRepository<RecordInfo, Long> {
List<RecordInfo> findAllByExcelId(long eid);
List<RecordInfo> findAllByUserId(long uid);
}
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -14,6 +15,7 @@ import java.util.List;
/**
* spreadJs 配置的报表
*/
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@AllArgsConstructor
@Data
......@@ -24,18 +26,19 @@ public class Excel implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(columnDefinition = "VARCHAR(300) COMMENT 'SpreadJs表格配置'")
@Column(nullable = false)
private String config;
@Column
private String desc;
@Column(columnDefinition = "DATETIME COMMENT '创建时间'")
@Column(nullable = false, name = "create_at")
@CreationTimestamp
private Timestamp createAt;
// 级别游离关联, 当加载的时候急加载这个对象
@ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
@JsonIgnore
private Job job;
@OneToMany
......
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -16,6 +16,7 @@ import java.util.List;
* @name 流程、任务
* @desc 包含属于哪个activiti流程、相关人员、附件信息id
*/
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor // 自动生成无参数构造函数。
@AllArgsConstructor // 自动生成全参数构造函数。
@Data
......@@ -28,6 +29,7 @@ public class Job implements Serializable {
public static int STATUS_RELEASED = 2;
public static int STATUS_UNRELEASED = 1;
public static int STATUS_COMPLETED = 3;
public static int JUDGE_NEED = 2;
public static int JUDGE_NO_NEED = 1;
......@@ -37,7 +39,7 @@ public class Job implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column
@Column(nullable = false)
private String name;
@Column
......@@ -49,18 +51,17 @@ public class Job implements Serializable {
@Column
private int judge = 2;
@Column
private long processId;
@Column(name = "process_id")
private String processId;
@Column
@Column(name = "start_at")
private Timestamp startAt;
@Column(nullable = false)
@Column(nullable = false, name = "create_at")
@CreationTimestamp
private Timestamp createAt;
@OneToMany
@JsonIgnore
private List<Excel> excelList;
@ManyToOne
......
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -13,6 +13,7 @@ import java.sql.Timestamp;
/**
* spreadJs 填写的数据
*/
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@AllArgsConstructor
@Data
......@@ -23,11 +24,12 @@ public class RecordData implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(columnDefinition = "DATETIME COMMENT '创建时间'")
@Column(name = "create_at", nullable = false, columnDefinition = "DATETIME COMMENT '创建时间'")
@CreationTimestamp
private Timestamp createAt;
@ManyToOne
private RecordInfo recordInfo;
......
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -14,6 +15,7 @@ import java.util.List;
/**
* spreadJs 补录人员信息
*/
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@AllArgsConstructor
@Data
......@@ -25,7 +27,7 @@ public class RecordInfo implements Serializable {
private long id;
@Column(columnDefinition = "DATETIME COMMENT '创建时间'")
@Column(name = "create_at", nullable = false, columnDefinition = "DATETIME COMMENT '创建时间'")
@CreationTimestamp
private Timestamp createAt;
......
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -7,6 +8,7 @@ import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
@NoArgsConstructor
@AllArgsConstructor
@Data
......
......@@ -18,14 +18,23 @@ public class ExcelService {
Excel excel = new Excel();
excel.setConfig(form.getConfig());
excel.setDesc(form.getDesc());
excelDao.save(excel);
excel.setJob(form.getJob());
excel = excelDao.save(excel);
return excel;
}
public Excel get(long id) {
return excelDao.getOne(id);
}
public List<Excel> findAllByIdIn(List<Long> ids) {
return excelDao.findAllByIdIn(ids);
}
public List<Excel> findAllByJobId(long jid) {
return excelDao.findAllByJobId(jid);
}
public void saveAll(List<Excel> excelList) {
excelDao.saveAll(excelList);
}
......
......@@ -35,10 +35,14 @@ public class JobService {
job.setStartAt(Timestamp.valueOf(form.getStartAt()));
}
job.setUser(form.getUser());
jobDao.save(job);
job = jobDao.save(job);
return job;
}
public Job findByProcessId(String pid) {
return jobDao.findByProcessId(pid);
}
public Page<Job> findAll(int pageNo, int pageSize) {
Pageable pageable = convert(pageNo, pageSize);
return jobDao.findAll(pageable);
......
......@@ -2,6 +2,7 @@ package com.keymobile.rest.service;
import com.keymobile.rest.dao.*;
import com.keymobile.rest.model.RecordData;
import com.keymobile.rest.vo.RecordDataForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -11,10 +12,10 @@ public class RecordDataService {
@Autowired
private RecordDataDao recordDataDao;
public RecordData save() {
public RecordData save(RecordDataForm form) {
RecordData data = new RecordData();
recordDataDao.save(data);
data = recordDataDao.save(data);
return data;
}
}
......@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.List;
@Service
public class RecordInfoService {
......@@ -22,7 +23,15 @@ public class RecordInfoService {
info.setUser(user);
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
info.setCreateAt(now);
recordInfoDao.save(info);
info = recordInfoDao.save(info);
return info;
}
public List<RecordInfo> findAllByExcelId(long eid) {
return recordInfoDao.findAllByExcelId(eid);
}
public List<RecordInfo> findByUserId(long uid) {
return recordInfoDao.findAllByUserId(uid);
}
}
package com.keymobile.rest.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.keymobile.rest.model.Job;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -20,4 +22,6 @@ public class ExcelForm {
@ApiModelProperty(name = "desc", value = "表格描述")
private String desc;
@JsonIgnore
private Job job;
}
......@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel
public class JobForm {
......@@ -19,10 +21,10 @@ public class JobForm {
@ApiModelProperty(name = "startAt", value = "自动发起需要提写的时间")
private String startAt;
@ApiModelProperty(name = "excelIds", value = "新建的模板ids, 用逗号隔开")
private String excelIds;
@ApiModelProperty(name = "excels", value = "新建的模板配置数组")
private List<ExcelForm> excels;
@ApiModelProperty(name = "excelIds", value = "补录人员ids, 用逗号隔开")
@ApiModelProperty(name = "userIds", value = "补录人员ids, 用逗号隔开")
private String userIds;
@JsonIgnore
......
......@@ -4,8 +4,15 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel
@Data
public class RecordDataForm {
@ApiModelProperty(required = true, name = "excelId", value = "当前模板id")
private long excelId;
@ApiModelProperty(required = true, name = "dataList", value = "当前数据数组")
private List<Object> dataList;
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/testm1583600477586" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1583600477586" name="" targetNamespace="http://www.activiti.org/testm1583600477586" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="RecordStandardProcess" isClosed="false" isExecutable="true" name="RecordStandardProcess" processType="None">
<startEvent id="RecordStartEvent" name="StartEvent"/>
<userTask activiti:assignee="${userId}" activiti:exclusive="true" id="addData" name="填写补录报表"/>
<userTask activiti:assignee="${managerId}" activiti:exclusive="true" id="addExcel" name="发起流程添加模板"/>
<userTask activiti:assignee="${judgeId}" activiti:exclusive="true" id="JudgeData" name="审核数据"/>
<endEvent id="RecordEndEvent" name="EndEvent"/>
<sequenceFlow id="_8" sourceRef="RecordStartEvent" targetRef="addExcel"/>
<sequenceFlow id="_9" sourceRef="addExcel" targetRef="addData"/>
<sequenceFlow id="_7" sourceRef="addData" targetRef="JudgeData"/>
<exclusiveGateway gatewayDirection="Unspecified" id="JudgeGateway" name="JudgeGateway"/>
<sequenceFlow id="_11" sourceRef="JudgeData" targetRef="JudgeGateway"/>
<sequenceFlow id="_12" sourceRef="JudgeGateway" targetRef="RecordEndEvent">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${pass = true}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_13" sourceRef="JudgeGateway" targetRef="addData">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${pass = false}]]>
</conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="RecordStandardProcess">
<bpmndi:BPMNShape bpmnElement="RecordStartEvent" id="Shape-RecordStartEvent">
<dc:Bounds height="32.0" width="32.0" x="625.0" y="35.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="addData" id="Shape-addData">
<dc:Bounds height="55.0" width="85.0" x="595.0" y="215.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="addExcel" id="Shape-addExcel">
<dc:Bounds height="55.0" width="85.0" x="600.0" y="110.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="JudgeData" id="Shape-JudgeData">
<dc:Bounds height="55.0" width="85.0" x="590.0" y="325.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="RecordEndEvent" id="Shape-RecordEndEvent">
<dc:Bounds height="32.0" width="32.0" x="620.0" y="565.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="JudgeGateway" id="Shape-JudgeGateway" isMarkerVisible="false">
<dc:Bounds height="32.0" width="32.0" x="620.0" y="455.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_10" targetElement="_3">
<di:waypoint x="620.0" y="471.0"/>
<di:waypoint x="500.0" y="345.0"/>
<di:waypoint x="595.0" y="242.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12" sourceElement="_10" targetElement="_6">
<di:waypoint x="636.0" y="487.0"/>
<di:waypoint x="636.0" y="565.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_3" targetElement="_5">
<di:waypoint x="635.0" y="270.0"/>
<di:waypoint x="635.0" y="325.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_2" targetElement="_4">
<di:waypoint x="641.0" y="67.0"/>
<di:waypoint x="641.0" y="110.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="_4" targetElement="_3">
<di:waypoint x="640.0" y="165.0"/>
<di:waypoint x="640.0" y="215.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_11" id="BPMNEdge__11" sourceElement="_5" targetElement="_10">
<di:waypoint x="636.0" y="380.0"/>
<di:waypoint x="636.0" y="455.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
......@@ -11,8 +11,8 @@ spring:
jpa:
show-sql: true
database-platform: org.hibernate.dialect.MySQL5Dialect
# hibernate:
# ddl-auto: update
# hibernate:
# ddl-auto: update
datasource:
url: jdbc:mysql://47.105.193.165:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
......@@ -49,11 +49,11 @@ server:
app:
active-process: RecordProcess.bpmn
active-process: RecordStandardProcess.bpmn
swagger2:
host: localhost:8110
# host: 47.105.236.43/activiti
# host: localhost:8110
host: 47.105.236.43/activiti
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1583416072125" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="demo" isClosed="false" isExecutable="true" name="demo" processType="None">
<startEvent id="Start" name="Start"/>
<userTask activiti:assignee="chenws" activiti:exclusive="true" id="请假" name="请假"/>
<sequenceFlow id="_4" sourceRef="Start" targetRef="请假"/>
<userTask activiti:assignee="主管" activiti:exclusive="true" id="主管" name="主管"/>
<sequenceFlow id="_6" sourceRef="请假" targetRef="主管"/>
<userTask activiti:assignee="总监" activiti:exclusive="true" id="总监" name="总监"/>
<sequenceFlow id="_8" sourceRef="主管" targetRef="总监"/>
<endEvent id="_9" name="EndEvent"/>
<sequenceFlow id="_10" sourceRef="总监" targetRef="_9"/>
</process>
<bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="demo">
<bpmndi:BPMNShape bpmnElement="Start" id="Shape-Start">
<omgdc:Bounds height="32.0" width="32.0" x="50.0" y="120.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="请假" id="Shape-请假">
<omgdc:Bounds height="55.0" width="85.0" x="155.0" y="115.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="主管" id="Shape-主管">
<omgdc:Bounds height="55.0" width="85.0" x="325.0" y="120.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="总监" id="Shape-总监">
<omgdc:Bounds height="55.0" width="85.0" x="465.0" y="135.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_9" id="Shape-_9">
<omgdc:Bounds height="32.0" width="32.0" x="605.0" y="135.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_4" id="BPMNEdge__4" sourceElement="Start" targetElement="_3">
<omgdi:waypoint x="82.0" y="136.0"/>
<omgdi:waypoint x="155.0" y="142.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="_3" targetElement="主管">
<omgdi:waypoint x="240.0" y="142.5"/>
<omgdi:waypoint x="325.0" y="147.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="主管" targetElement="总监">
<omgdi:waypoint x="410.0" y="147.5"/>
<omgdi:waypoint x="465.0" y="162.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="总监" targetElement="_9">
<omgdi:waypoint x="550.0" y="162.5"/>
<omgdi:waypoint x="605.0" y="151.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
......@@ -56,35 +56,54 @@ public class ProcessTest {
// try {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
//
// List<ProcessDefinition> processDefList = processEngine.getRepositoryService().createProcessDefinitionQuery()
// .orderByProcessDefinitionVersion().asc()//按照版本的升序排列
// .list();
// for (ProcessDefinition processDefinition : processDefList) {
List<ProcessDefinition> processDefList = processEngine.getRepositoryService().createProcessDefinitionQuery()
.orderByProcessDefinitionVersion().asc()//按照版本的升序排列
.list();
for (ProcessDefinition processDefinition : processDefList) {
// System.out.println(processDefinition.getName());
//
// runtimeService.startProcessInstanceByKey(processDefinition.getKey());//流程的名称,也可以使用ByID来启动流
// repositoryService.deleteDeployment(processDefinition.getDeploymentId());
// repositoryService.suspendProcessDefinitionByKey(processDefinition.getKey());
// HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery();
// historicProcessInstanceQuery.processDefinitionId(processDefinition.getId());
// List<HistoricProcessInstance> list = historicProcessInstanceQuery.list();
//
// list.forEach(pi -> {
// runtimeService.suspendProcessInstanceById(pi.getId()); // 挂起流程
// runtimeService.deleteProcessInstance(pi.getId(), "删除原因");//删除流程
// });
try {
repositoryService.deleteDeployment(processDefinition.getDeploymentId());
} catch (Exception e) {
// }
}
try {
repositoryService.suspendProcessDefinitionByKey(processDefinition.getKey());
} catch (Exception e) {
List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskAssignee("chenws").list();
for (Task task : tasks) {
System.out.println(task.getName() + "***" + task.getAssignee());
}
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery();
historicProcessInstanceQuery.processDefinitionId(processDefinition.getId());
List<HistoricProcessInstance> list = historicProcessInstanceQuery.list();
list.forEach(pi -> {
try {
runtimeService.suspendProcessInstanceById(pi.getId()); // 挂起流程
} catch (Exception e) {
}
try {
runtimeService.deleteProcessInstance(pi.getId(), "删除原因");//删除流程
} catch (Exception e) {
}
});
}
// List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskAssignee("chenws").list();
// for (Task task : tasks) {
// System.out.println(task.getName() + "***" + task.getAssignee());
// }
// DeploymentBuilder deployBuilder = repositoryService.createDeployment().;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment