Quellcode durchsuchen

:sparkles: 添加新特性。工作流模块

冷冷 vor 7 Jahren
Ursprung
Commit
b76e1c3e3f
35 geänderte Dateien mit 1388 neuen und 457 gelöschten Zeilen
  1. 0 213
      doc/pigx.sql
  2. 322 0
      doc/pigxx.sql
  3. 9 0
      docker-compose.yml
  4. 1 1
      pigx-common/pigx-common-core/src/main/resources/logback-spring.xml
  5. 1 1
      pigx-config/src/main/resources/config/application-dev.yml
  6. 21 1
      pigx-config/src/main/resources/config/pigx-codegen-dev.yml
  7. 1 1
      pigx-config/src/main/resources/config/pigx-daemon-dev.yml
  8. 13 0
      pigx-visual/pigx-activiti/Dockerfile
  9. 101 0
      pigx-visual/pigx-activiti/pom.xml
  10. 40 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/PigxActivitiApplication.java
  11. 42 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/config/MybatisPlusConfigurer.java
  12. 117 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/LeaveBillController.java
  13. 1 8
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/ModelController.java
  14. 5 5
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/ProcessController.java
  15. 33 28
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/TaskController.java
  16. 65 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/CommentDto.java
  17. 0 108
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/DataTable.java
  18. 46 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/LeaveBillDto.java
  19. 41 11
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/ProcessDefDTO.java
  20. 4 1
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/TaskDTO.java
  21. 84 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/entity/LeaveBill.java
  22. 33 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/listener/LeaveProcessTaskListener.java
  23. 16 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/mapper/LeaveBillMapper.java
  24. 44 4
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/ActTaskService.java
  25. 14 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/LeaveBillService.java
  26. 10 2
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/ProcessService.java
  27. 192 39
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ActTaskServiceImpl.java
  28. 33 0
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/LeaveBillServiceImpl.java
  29. 38 23
      pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ProcessServiceImpl.java
  30. 30 0
      pigx-visual/pigx-activiti/src/main/resources/bootstrap.yml
  31. 19 0
      pigx-visual/pigx-activiti/src/main/resources/mapper/LeaveBillMapper.xml
  32. 0 2
      pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm
  33. 2 1
      pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm
  34. 2 0
      pigx-visual/pigx-codegen/src/main/resources/template/index.vue.vm
  35. 8 8
      pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 213
doc/pigx.sql


Datei-Diff unterdrückt, da er zu groß ist
+ 322 - 0
doc/pigxx.sql


+ 9 - 0
docker-compose.yml

@@ -83,6 +83,15 @@ services:
       dockerfile: ./pigx-visual/pigx-codegen/Dockerfile
     restart: always
 
+  pigx-activiti:
+    links:
+      - pigx-eureka
+      - pigx-redis
+    build:
+      context: ./
+      dockerfile: ./pigx-visual/pigx-activiti/Dockerfile
+    restart: always
+
   pigx-tx-manager:
     links:
       - pigx-eureka

+ 1 - 1
pigx-common/pigx-common-core/src/main/resources/logback-spring.xml

@@ -46,7 +46,7 @@
 		</filter>
 	</appender>
 
-	<logger name="com.pig4cloud.pigx.admin.mapper" level="DEBUG">
+	<logger name="org.activiti.engine.impl.db" level="DEBUG">
 		<appender-ref ref="debug" />
 	</logger>
 

+ 1 - 1
pigx-config/src/main/resources/config/application-dev.yml

@@ -97,7 +97,7 @@ swagger:
 ## spring security 配置
 security:
   auth:
-    server: http://localhost:9999/auth/oauth
+    server: http://192.168.0.20:9999/auth/oauth
   oauth2:
     resource:
       token-info-uri: ${security.auth.server}/check_token

+ 21 - 1
pigx-config/src/main/resources/config/pigx-codegen-dev.yml

@@ -13,7 +13,7 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     username: root
     password:  Bjyjht2017!@#
-    url: jdbc:mysql://114.116.30.176:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    url: jdbc:mysql://114.116.21.191:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
   jackson:
     time-zone: GMT+8
     date-format: yyyy-MM-dd HH:mm:ss
@@ -24,3 +24,23 @@ spring:
 mybatis-plus:
   typeAliasesPackage: com.pig4cloud.pigx.codegen.entity
 
+#mybaits-plus配置,修改主键类型,mapper.xml、type 别名等
+mybatis-plus:
+  mapper-locations: classpath:/mapper/*Mapper.xml
+  global-config:
+    #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
+    id-type: 0
+    #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
+    field-strategy: 1
+    #驼峰下划线转换
+    db-column-underline: true
+    #刷新mapper 调试神器
+    refresh-mapper: false
+    # 逻辑删除字段
+    logic-delete-value: 1
+    logic-not-delete-value: 0
+    #自定义SQL注入器
+    sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
+  configuration:
+    map-underscore-to-camel-case: true
+    cache-enabled: true

+ 1 - 1
pigx-config/src/main/resources/config/pigx-daemon-dev.yml

@@ -14,7 +14,7 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     username: root
     password:  Bjyjht2017!@#
-    url: jdbc:mysql://114.116.30.176:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    url: jdbc:mysql://114.116.21.191:3306/pigxx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
   elasticjob:
     # 分布式任务协调依赖zookeeper
     zookeeper:

+ 13 - 0
pigx-visual/pigx-activiti/Dockerfile

@@ -0,0 +1,13 @@
+FROM anapsix/alpine-java:8_server-jre_unlimited
+
+MAINTAINER wangiegie@gmail.com
+
+RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-daemon
+
+WORKDIR /pigx/bin/com.pig4cloud/pigx-activiti
+
+EXPOSE 5002
+
+ADD ./pigx-visual/pigx-activiti/target/pigx-activiti.jar ./
+
+CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-activiti.jar

+ 101 - 0
pigx-visual/pigx-activiti/pom.xml

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~    Copyright (c) 2018-2025, lengleng All rights reserved.
+  ~
+  ~ Redistribution and use in source and binary forms, with or without
+  ~ modification, are permitted provided that the following conditions are met:
+  ~
+  ~ Redistributions of source code must retain the above copyright notice,
+  ~ this list of conditions and the following disclaimer.
+  ~ Redistributions in binary form must reproduce the above copyright
+  ~ notice, this list of conditions and the following disclaimer in the
+  ~ documentation and/or other materials provided with the distribution.
+  ~ Neither the name of the pig4cloud.com developer nor the names of its
+  ~ contributors may be used to endorse or promote products derived from
+  ~ this software without specific prior written permission.
+  ~ Author: lengleng (wangiegie@gmail.com)
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>com.pig4cloud</groupId>
+		<artifactId>pigx-visual</artifactId>
+		<version>${pigx.version}</version>
+	</parent>
+
+	<artifactId>pigx-activiti</artifactId>
+	<packaging>jar</packaging>
+
+	<description>工作流管理模块</description>
+
+	<dependencies>
+		<!--common code -->
+		<dependency>
+			<groupId>com.pig4cloud</groupId>
+			<artifactId>pigx-common-core</artifactId>
+			<version>${pigx.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+		</dependency>
+		<!--mybatis-->
+		<dependency>
+			<groupId>com.baomidou</groupId>
+			<artifactId>mybatis-plus-boot-starter</artifactId>
+			<version>${mbp.boot.version}</version>
+		</dependency>
+		<!-- activiti -->
+		<dependency>
+			<groupId>org.activiti</groupId>
+			<artifactId>activiti-spring-boot-starter-basic</artifactId>
+			<version>${activiti.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.activiti</groupId>
+			<artifactId>activiti-modeler</artifactId>
+			<version>${activiti.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.activiti</groupId>
+			<artifactId>activiti-diagram-rest</artifactId>
+			<version>${activiti.version}</version>
+		</dependency>
+		<!--web 模块-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+			<exclusions>
+				<!--排除tomcat依赖-->
+				<exclusion>
+					<artifactId>spring-boot-starter-tomcat</artifactId>
+					<groupId>org.springframework.boot</groupId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<!--undertow容器-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-undertow</artifactId>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+			<plugin>
+				<groupId>com.spotify</groupId>
+				<artifactId>docker-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

+ 40 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/PigxActivitiApplication.java

@@ -0,0 +1,40 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
+import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+/**
+ * @author lengleng
+ * @date 2018/9/25
+ * 工作流管理模块
+ */
+@EnableDiscoveryClient
+@EnableCircuitBreaker
+@SpringBootApplication(exclude = {SecurityAutoConfiguration.class,org.activiti.spring.boot.SecurityAutoConfiguration.class})
+public class PigxActivitiApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(PigxActivitiApplication.class, args);
+	}
+
+}

+ 42 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/config/MybatisPlusConfigurer.java

@@ -0,0 +1,42 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act.config;
+
+import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author lengleng
+ * @date 2018/9/27
+ * mybatis-plus 配置
+ */
+@Configuration
+@MapperScan("com.pig4cloud.pigx.act.mapper")
+public class MybatisPlusConfigurer {
+	/**
+	 * 分页插件
+	 *
+	 * @return PaginationInterceptor
+	 */
+	@Bean
+	public PaginationInterceptor paginationInterceptor() {
+		return new PaginationInterceptor();
+	}
+}

+ 117 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/LeaveBillController.java

@@ -0,0 +1,117 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act.controller;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.act.entity.LeaveBill;
+import com.pig4cloud.pigx.act.service.ActTaskService;
+import com.pig4cloud.pigx.act.service.LeaveBillService;
+import com.pig4cloud.pigx.act.service.ProcessService;
+import com.pig4cloud.pigx.common.core.util.Query;
+import com.pig4cloud.pigx.common.core.util.R;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+
+/**
+ * 请假流程
+ *
+ * @author 冷冷
+ * @date 2018-09-27 15:20:44
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/leavebill")
+public class LeaveBillController {
+	private final LeaveBillService leaveBillService;
+	private final ProcessService processService;
+	private final ActTaskService actTaskService;
+
+
+	/**
+	 * 列表
+	 *
+	 * @param params
+	 * @return
+	 */
+	@GetMapping("/page")
+	public Page page(@RequestParam Map<String, Object> params) {
+		return leaveBillService.selectPage(new Query<>(params), new EntityWrapper<>());
+	}
+
+
+	/**
+	 * 信息
+	 *
+	 * @param leaveId
+	 * @return R
+	 */
+	@GetMapping("/{leaveId}")
+	public R info(@PathVariable("leaveId") Integer leaveId) {
+		LeaveBill leaveBill = leaveBillService.selectById(leaveId);
+		return new R<>(leaveBill);
+	}
+
+	/**
+	 * 保存
+	 *
+	 * @param leaveBill
+	 * @return R
+	 */
+	@PostMapping
+	public R save(@RequestBody LeaveBill leaveBill) {
+		return new R<>(leaveBillService.insert(leaveBill));
+	}
+
+	/**
+	 * 修改
+	 *
+	 * @param leaveBill
+	 * @return R
+	 */
+	@PutMapping
+	public R update(@RequestBody LeaveBill leaveBill) {
+		leaveBillService.updateById(leaveBill);
+		return new R<>(Boolean.TRUE);
+	}
+
+	/**
+	 * 删除
+	 *
+	 * @param leaveId
+	 * @return R
+	 */
+	@DeleteMapping("/{leaveId}")
+	public R delete(@PathVariable Integer leaveId) {
+		return new R<>(leaveBillService.deleteById(leaveId));
+	}
+
+	/**
+	 * 提交请假流程
+	 *
+	 * @param leaveId
+	 * @return R
+	 */
+	@GetMapping("/submit/{leaveId}")
+	public R submit(@PathVariable("leaveId") Integer leaveId) {
+		return new R<>(processService.saveStartProcess(leaveId));
+	}
+}

+ 1 - 8
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/ModelController.java

@@ -25,7 +25,6 @@ import lombok.AllArgsConstructor;
 import org.activiti.engine.repository.Model;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
 import java.util.Map;
 
@@ -39,12 +38,6 @@ import java.util.Map;
 public class ModelController {
 	private final ModelService modelService;
 
-	@GetMapping
-	public String list(org.springframework.ui.Model model, HttpServletRequest request) {
-		model.addAttribute("url", request.getContextPath() + "/model/");
-		return "model/list";
-	}
-
 	@PostMapping(value = "/insert")
 	public R<Boolean> insertForm(@RequestBody @Valid ModelForm form) {
 		modelService.create(form.getName(), form.getKey(), form.getDesc(), form.getCategory());
@@ -58,7 +51,7 @@ public class ModelController {
 		return model.getId();
 	}
 
-	@GetMapping(value = "/list")
+	@GetMapping
 	public Page<Model> list(@RequestParam Map<String, Object> params) {
 		return modelService.selectPage(params);
 	}

+ 5 - 5
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/ProcessController.java

@@ -62,13 +62,13 @@ public class ProcessController {
 		}
 	}
 
-	@PostMapping("/status")
-	public R<Boolean> updateState(@RequestParam String status, @RequestParam String procDefId) {
+	@PutMapping("/status/{procDefId}/{status}")
+	public R<Boolean> updateState(@PathVariable String procDefId, @PathVariable String status) {
 		return new R<>(processService.updateStatus(status, procDefId));
 	}
 
-	@DeleteMapping
-	public R<Boolean> deleteProcIns(@RequestParam String procInsId) {
-		return new R<>(processService.deleteProcIns(procInsId));
+	@DeleteMapping("/{deploymentId}")
+	public R<Boolean> deleteProcIns(@PathVariable String deploymentId) {
+		return new R<>(processService.deleteProcIns(deploymentId));
 	}
 }

+ 33 - 28
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/controller/TaskController.java

@@ -17,43 +17,48 @@
 
 package com.pig4cloud.pigx.act.controller;
 
-import com.pig4cloud.pigx.act.dto.DataTable;
-import com.pig4cloud.pigx.act.dto.StartTaskForm;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.act.dto.LeaveBillDto;
 import com.pig4cloud.pigx.act.service.ActTaskService;
 import com.pig4cloud.pigx.common.core.util.R;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.validation.BindingResult;
+import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
 
 /**
  * @author lengleng
- * @date 2018/9/25
+ * @date 2018/9/28
  */
-@Controller
+@RestController
+@AllArgsConstructor
 @RequestMapping("/task")
 public class TaskController {
+	private final ActTaskService actTaskService;
+
+	@GetMapping("/todo")
+	public Page todo(@RequestParam Map<String, Object> params) {
+		return actTaskService.findTaskByName(params, "lengleng");
+	}
+
+	@GetMapping("/{id}")
+	public R task(@PathVariable String id) {
+		return new R(actTaskService.findTaskByTaskId(id));
+	}
+
+	@PostMapping
+	public R task(@RequestBody LeaveBillDto leaveBillDto) {
+		return new R(actTaskService.submitTask(leaveBillDto));
+	}
+
+	@GetMapping("/view/{id}")
+	public R viewCurrentImage(@PathVariable String id) {
+		return new R(actTaskService.findProcessDefinitionByTaskId(id));
+	}
+
+	@GetMapping("/comment/{id}")
+	public R commitList(@PathVariable String id) {
+		return new R(actTaskService.findCommentByTaskId(id));
+	}
 
-    @Autowired
-	ActTaskService taskService;
-
-    @GetMapping(value = "/todo")
-    public String list(Model model, HttpServletRequest request) {
-        model.addAttribute("url", request.getContextPath()+"/task/todo/");
-        return "task/todoList";
-    }
-
-    @PostMapping("/todo/list")
-    @ResponseBody
-    public DataTable todoList(@RequestBody DataTable dt) {
-        return taskService.getTodoTasks(dt);
-    }
-
-    @PostMapping("/todo/start")
-    public R<Boolean> start(@RequestBody StartTaskForm form, BindingResult result) {
-        return new R<>(Boolean.TRUE);
-    }
 }

+ 65 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/CommentDto.java

@@ -0,0 +1,65 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act.dto;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lengleng
+ * @date 2018/9/28
+ * 批注Dto
+ */
+@Data
+public class CommentDto {
+	/**
+	 * unique identifier for this comment
+	 */
+	private String id;
+
+	/**
+	 * reference to the user that made the comment
+	 */
+	private String userId;
+
+	/**
+	 * time and date when the user made the comment
+	 */
+	private Date time;
+
+	/**
+	 * reference to the task on which this comment was made
+	 */
+	private String taskId;
+
+	/**
+	 * reference to the process instance on which this comment was made
+	 */
+	private String processInstanceId;
+
+	/**
+	 * reference to the type given to the comment
+	 */
+	private String type;
+
+	/**
+	 * the full comment message the user had related to the task and/or process instance
+	 */
+	private String fullMessage;
+}

+ 0 - 108
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/DataTable.java

@@ -1,108 +0,0 @@
-/*
- *    Copyright (c) 2018-2025, lengleng All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the pig4cloud.com developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: lengleng (wangiegie@gmail.com)
- */
-
-package com.pig4cloud.pigx.act.dto;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author lengleng
- * @date 2018/9/25
- */
-public class DataTable<T> implements Serializable {
-    private static final long serialVersionUID = 2252240868205663450L;
-
-
-    private int total;
-    /**
-     * 搜索条件
-     */
-    private Map<String, Object> searchParams;
-
-    /**
-     * 返回列表
-     */
-    private List<T> rows = new ArrayList<>();
-
-    /**
-     * 排序 条件
-     */
-    Map<String, String> sorts;
-
-    /**
-     * 当前页码
-     */
-    private int pageNumber;
-
-    /**
-     * 页码大小
-     */
-    private int pageSize;
-
-
-    public int getPageNumber() {
-        return pageNumber;
-    }
-
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-
-    public int getPageSize() {
-        return pageSize;
-    }
-
-    public void setPageSize(int pageSize) {
-        this.pageSize = pageSize;
-    }
-
-    public int getTotal() {
-        return total;
-    }
-
-    public void setTotal(int total) {
-        this.total = total;
-    }
-
-    public Map<String, Object> getSearchParams() {
-        return searchParams;
-    }
-
-    public void setSearchParams(Map<String, Object> searchParams) {
-        this.searchParams = searchParams;
-    }
-
-    public List<T> getRows() {
-        return rows;
-    }
-
-    public void setRows(List<T> rows) {
-        this.rows = rows;
-    }
-
-
-    public Map<String, String> getSorts() {
-        return sorts;
-    }
-
-    public void setSorts(Map<String, String> sorts) {
-        this.sorts = sorts;
-    }
-}

+ 46 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/LeaveBillDto.java

@@ -0,0 +1,46 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act.dto;
+
+import com.pig4cloud.pigx.act.entity.LeaveBill;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lengleng
+ * @date 2018/9/28
+ * LeaveBillDto
+ */
+@Data
+public class LeaveBillDto extends LeaveBill {
+	/**
+	 * 任务ID
+	 */
+	private String taskId;
+
+	/**
+	 * 任务提交时间
+	 */
+	private Date time;
+
+	/**
+	 * 批准信息
+	 */
+	private String comment;
+}

+ 41 - 11
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/ProcessDefDTO.java

@@ -18,6 +18,8 @@
 package com.pig4cloud.pigx.act.dto;
 
 import lombok.Data;
+import org.activiti.engine.repository.Deployment;
+import org.activiti.engine.repository.ProcessDefinition;
 
 /**
  * @author lengleng
@@ -25,15 +27,43 @@ import lombok.Data;
  */
 @Data
 public class ProcessDefDTO {
-	public String category;
-	public String processonDefinitionId;
-	public String key;
-	public String name;
-	public Integer revision;
-	public Long deploymentTime;
-	public String xmlName;
-	public String picName;
-	public String deploymentId;
-	public Boolean suspend;
-	public String description;
+	private String category;
+	private String processonDefinitionId;
+	private String key;
+	private String name;
+	private Integer revision;
+	private Long deploymentTime;
+	private String xmlName;
+	private String picName;
+	private String deploymentId;
+	private Boolean suspend;
+	private String description;
+	private Integer xAxis;
+	private Integer yAxis;
+	private Integer width;
+	private Integer height;
+
+
+	/**
+	 * 抽取流程定义需要返回的内容
+	 *
+	 * @param processDefinition
+	 * @param deployment
+	 * @return
+	 */
+	public static ProcessDefDTO toProcessDefDTO(ProcessDefinition processDefinition, Deployment deployment) {
+		ProcessDefDTO dto = new ProcessDefDTO();
+		dto.setCategory(processDefinition.getCategory());
+		dto.setProcessonDefinitionId(processDefinition.getId());
+		dto.setKey(processDefinition.getKey());
+		dto.setName(deployment.getName());
+		dto.setRevision(processDefinition.getVersion());
+		dto.setDeploymentTime(deployment.getDeploymentTime().getTime());
+		dto.setXmlName(processDefinition.getResourceName());
+		dto.setPicName(processDefinition.getDiagramResourceName());
+		dto.setDeploymentId(deployment.getId());
+		dto.setSuspend(processDefinition.isSuspended());
+		dto.setDescription(processDefinition.getDescription());
+		return dto;
+	}
 }

+ 4 - 1
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/dto/TaskDTO.java

@@ -19,6 +19,9 @@ package com.pig4cloud.pigx.act.dto;
 
 import lombok.Data;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * @author lengleng
  * @date 2018/9/25
@@ -31,7 +34,7 @@ public class TaskDTO {
 	private String title;
 	private String pdName;
 	private String version;
-	private Long time;
+	private Date time;
 	private String processInstanceId;
 	private String status;
 	private String nodeKey;

+ 84 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/entity/LeaveBill.java

@@ -0,0 +1,84 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act.entity;
+
+import com.baomidou.mybatisplus.activerecord.Model;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableLogic;
+import com.baomidou.mybatisplus.annotations.TableName;
+import com.baomidou.mybatisplus.enums.IdType;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+  import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 请假流程
+ *
+ * @author 冷冷
+ * @date 2018-09-27 15:20:44
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("oa_leave_bill")
+public class LeaveBill extends Model<LeaveBill> {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * ID
+	 */
+	@TableId(type = IdType.AUTO)
+	private Integer leaveId;
+	/**
+	 * 申请人
+	 */
+	private String username;
+	/**
+	 * 天数
+	 */
+	private Integer days;
+	/**
+	 * 备注
+	 */
+	private String content;
+	/**
+	 * 0-未提交,1-未审核,2-批准,9-驳回
+	 */
+	private String state;
+	/**
+	 * 请假时间
+	 */
+	private LocalDateTime createTime;
+	/**
+	 * 修改时间
+	 */
+	private LocalDateTime updateTime;
+	/**
+	 * 删除标志
+	 */
+	@TableLogic
+	private String delFlag;
+
+  /**
+   * 主键值
+   */
+  @Override
+  protected Serializable pkVal() {
+    return this.leaveId;
+  }
+}

+ 33 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/listener/LeaveProcessTaskListener.java

@@ -0,0 +1,33 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act.listener;
+
+import org.activiti.engine.delegate.DelegateTask;
+import org.activiti.engine.delegate.TaskListener;
+
+/**
+ * @author lengleng
+ * @date 2018/9/27
+ * 请假流程监听器对于
+ */
+public class LeaveProcessTaskListener implements TaskListener {
+	@Override
+	public void notify(DelegateTask delegateTask) {
+		delegateTask.addCandidateUser("lengleng");
+	}
+}

+ 16 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/mapper/LeaveBillMapper.java

@@ -0,0 +1,16 @@
+package com.pig4cloud.pigx.act.mapper;
+
+import com.pig4cloud.pigx.act.entity.LeaveBill;
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 请假流程
+ *
+ * @author 冷冷
+ * @date 2018-09-27 15:20:44
+ */
+@Mapper
+public interface LeaveBillMapper extends BaseMapper<LeaveBill> {
+
+}

+ 44 - 4
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/ActTaskService.java

@@ -17,7 +17,13 @@
 
 package com.pig4cloud.pigx.act.service;
 
-import com.pig4cloud.pigx.act.dto.DataTable;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.act.dto.CommentDto;
+import com.pig4cloud.pigx.act.dto.LeaveBillDto;
+import com.pig4cloud.pigx.act.dto.ProcessDefDTO;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author lengleng
@@ -25,11 +31,45 @@ import com.pig4cloud.pigx.act.dto.DataTable;
  */
 public interface ActTaskService {
 
+
+	/**
+	 * 获取用户代办列表
+	 *
+	 * @param params
+	 * @param name
+	 * @return
+	 */
+	Page findTaskByName(Map<String, Object> params, String name);
+
+	/**
+	 * 通过任务ID查询任务信息关联申请单信息
+	 *
+	 * @param id
+	 * @return
+	 */
+	LeaveBillDto findTaskByTaskId(String id);
+
+	/**
+	 * 提交任务
+	 *
+	 * @param leaveBillDto
+	 * @return
+	 */
+	Boolean submitTask(LeaveBillDto leaveBillDto);
+
+	/**
+	 * 根据 taskId 查询 流程定义 (活动任务坐标)
+	 *
+	 * @param taskId
+	 * @return
+	 */
+	ProcessDefDTO findProcessDefinitionByTaskId(String taskId);
+
 	/**
-	 * 获取代办列表
+	 * 通过任务ID 查询批注信息
 	 *
-	 * @param dt
+	 * @param taskId 任务ID
 	 * @return
 	 */
-	DataTable getTodoTasks(DataTable dt);
+	List<CommentDto> findCommentByTaskId(String taskId);
 }

+ 14 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/LeaveBillService.java

@@ -0,0 +1,14 @@
+package com.pig4cloud.pigx.act.service;
+
+import com.baomidou.mybatisplus.service.IService;
+import com.pig4cloud.pigx.act.entity.LeaveBill;
+
+/**
+ * 请假流程
+ *
+ * @author 冷冷
+ * @date 2018-09-27 15:20:44
+ */
+public interface LeaveBillService extends IService<LeaveBill> {
+}
+

+ 10 - 2
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/ProcessService.java

@@ -59,8 +59,16 @@ public interface ProcessService {
 	/**
 	 * 删除流程实例
 	 *
-	 * @param procInsId
+	 * @param deploymentId
 	 * @return
 	 */
-	Boolean deleteProcIns(String procInsId);
+	Boolean deleteProcIns(String deploymentId);
+
+	/**
+	 * 启动流程、更新请假单状态
+	 *
+	 * @param leaveId
+	 * @return
+	 */
+	Boolean saveStartProcess(Integer leaveId);
 }

+ 192 - 39
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ActTaskServiceImpl.java

@@ -17,81 +17,234 @@
 
 package com.pig4cloud.pigx.act.service.impl;
 
+import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
-import com.pig4cloud.pigx.act.dto.DataTable;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.act.dto.CommentDto;
+import com.pig4cloud.pigx.act.dto.LeaveBillDto;
+import com.pig4cloud.pigx.act.dto.ProcessDefDTO;
 import com.pig4cloud.pigx.act.dto.TaskDTO;
+import com.pig4cloud.pigx.act.entity.LeaveBill;
+import com.pig4cloud.pigx.act.mapper.LeaveBillMapper;
 import com.pig4cloud.pigx.act.service.ActTaskService;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.activiti.engine.RepositoryService;
+import org.activiti.engine.RuntimeService;
 import org.activiti.engine.TaskService;
+import org.activiti.engine.impl.identity.Authentication;
+import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
+import org.activiti.engine.impl.pvm.process.ActivityImpl;
 import org.activiti.engine.repository.Deployment;
 import org.activiti.engine.repository.ProcessDefinition;
-import org.activiti.engine.task.TaskInfo;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Comment;
+import org.activiti.engine.task.Task;
 import org.activiti.engine.task.TaskQuery;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * @author lengleng
  * @date 2018/9/25
  */
+@Slf4j
 @Service
 @AllArgsConstructor
 public class ActTaskServiceImpl implements ActTaskService {
-	private final TaskService actTaskService;
+	private final LeaveBillMapper leaveBillMapper;
+	private final TaskService taskService;
+	private final RuntimeService runtimeService;
 	private final RepositoryService repositoryService;
 
+	@Override
+	public Page findTaskByName(Map<String, Object> params, String name) {
+		TaskQuery taskQuery = taskService.createTaskQuery()
+			.taskCandidateOrAssigned(name)
+			.orderByTaskCreateTime().asc();
+
+		int page = MapUtil.getInt(params, "page");
+		int limit = MapUtil.getInt(params, "limit");
+
+		Page result = new Page(page, limit);
+		result.setTotal(taskQuery.count());
+		List<TaskDTO> taskDTOList = new ArrayList<>();
+		taskQuery.list().forEach(task -> {
+			TaskDTO dto = new TaskDTO();
+			dto.setTaskId(task.getId());
+			dto.setTaskName(task.getName());
+			dto.setProcessInstanceId(task.getProcessInstanceId());
+			dto.setNodeKey(task.getTaskDefinitionKey());
+			dto.setCategory(task.getCategory());
+			dto.setTime(task.getCreateTime());
+			taskDTOList.add(dto);
+		});
+		result.setRecords(taskDTOList);
+		return result;
+	}
+
 	/**
-	 * 获取代办列表
+	 * 通过任务ID查询任务信息关联申请单信息
 	 *
-	 * @param dt
+	 * @param taskId
 	 * @return
 	 */
 	@Override
-	public DataTable getTodoTasks(DataTable dt) {
-		String TASK_STATUS_TODO = "todo";
-		String TASK_STATUS_CLAIM = "claim";
-
-		String userId = "lengleng" + "";
-		TaskQuery taskQuery = actTaskService.createTaskQuery().taskCandidateOrAssigned(userId)
-			.active().includeProcessVariables().orderByTaskCreateTime().desc();
-		String category = (String) dt.getSearchParams().get("category");
-		if (StrUtil.isNotBlank(category)) {
-			taskQuery.taskCategory(category);
-		}
-		String title = (String) dt.getSearchParams().get("title");
-		if (StrUtil.isNotBlank(title)) {
-			taskQuery.processVariableValueLikeIgnoreCase("title", "%" + title + "%");
+	public LeaveBillDto findTaskByTaskId(String taskId) {
+		//1:使用任务ID,查询任务对象Task
+		Task task = taskService.createTaskQuery()
+			.taskId(taskId)
+			.singleResult();
+		//2:使用任务对象Task获取流程实例ID
+		String processInstanceId = task.getProcessInstanceId();
+		//3:使用流程实例ID,查询正在执行的执行对象表,返回流程实例对象
+		ProcessInstance pi = runtimeService.createProcessInstanceQuery()
+			.processInstanceId(processInstanceId)
+			.singleResult();
+		//4:使用流程实例对象获取BUSINESS_KEY
+		String buniness_key = pi.getBusinessKey();
+		//5:获取BUSINESS_KEY对应的主键ID,使用主键ID,查询请假单对象(LeaveBill.1)
+		String id = "";
+		if (StrUtil.isNotBlank(buniness_key)) {
+			//截取字符串,取buniness_key小数点的第2个值
+			id = buniness_key.split("\\.")[1];
 		}
-		Map<String, List<TaskDTO>> collect = taskQuery.listPage((dt.getPageNumber() - 1) * dt.getPageSize(), dt.getPageSize())
-			.stream()
-			.map(task -> {
-				TaskDTO dto = getTaskDTO(task, task.getAssignee() == null ?
-					TASK_STATUS_CLAIM : TASK_STATUS_TODO);
-				dto.setTime(task.getCreateTime().getTime());
-				return dto;
-			}).collect(Collectors.groupingBy(TaskDTO::getCategory));
-		dt.setRows(Collections.singletonList(collect));
-		return dt;
+		//查询请假单对象
+		LeaveBill leaveBill = leaveBillMapper.selectById(id);
+
+		LeaveBillDto leaveBillDto = new LeaveBillDto();
+		BeanUtils.copyProperties(leaveBill, leaveBillDto);
+		leaveBillDto.setTaskId(taskId);
+		leaveBillDto.setTime(task.getCreateTime());
+		return leaveBillDto;
 	}
 
+	/**
+	 * 提交任务
+	 *
+	 * @param leaveBillDto
+	 * @return
+	 */
+	@Override
+	public Boolean submitTask(LeaveBillDto leaveBillDto) {
+		//获取任务ID
+		String taskId = leaveBillDto.getTaskId();
+		//批注信息
+		String message = leaveBillDto.getComment();
+		//获取请假单ID
+		Integer id = leaveBillDto.getLeaveId();
+		//1:在完成之前,添加一个批注信息,向act_hi_comment表中添加数据,用于记录对当前申请人的一些审核信息
+		Task task = taskService.createTaskQuery()
+			.taskId(taskId)
+			.singleResult();
+		//获取流程实例ID
+		String processInstanceId = task.getProcessInstanceId();
+
+		// 设置批注用户
+		Authentication.setAuthenticatedUserId("lengleng");
+		taskService.addComment(taskId, processInstanceId, message);
+		/**
+		 * 2:如果连线的名称是“默认提交”,那么就不需要设置,如果不是,就需要设置流程变量
+		 * 在完成任务之前,设置流程变量,按照连线的名称,去完成任务
+		 流程变量的名称:outcome
+		 流程变量的值:连线的名称
+		 */
+		Map<String, Object> variables = new HashMap<String, Object>();
+		String outcome = "";
+		if (outcome != null && !outcome.equals("默认提交")) {
+			variables.put("outcome", outcome);
+		}
+
+		//3:使用任务ID,完成当前人的个人任务,同时流程变量
+		taskService.complete(taskId, variables);
+		//4:当任务完成之后,需要指定下一个任务的办理人(使用类)-----已经开发完成
 
-	private TaskDTO getTaskDTO(TaskInfo task, String status) {
-		ProcessDefinition processDefinition = getProcessDefinition(task.getProcessDefinitionId());
-		String deploymentId = processDefinition.getDeploymentId();
-		Deployment deployment = getDeployment(deploymentId);
+		/**
+		 * 5:在完成任务之后,判断流程是否结束
+		 如果流程结束了,更新请假单表的状态从1变成2(审核中-->审核完成)
+		 */
+		ProcessInstance pi = runtimeService.createProcessInstanceQuery()
+			.processInstanceId(processInstanceId)
+			.singleResult();
+		//流程结束了
+		if (pi == null) {
+			LeaveBill bill = new LeaveBill();
+			bill.setLeaveId(id);
+			bill.setState("2");
+			leaveBillMapper.updateById(bill);
+		}
 		return null;
 	}
 
-	private ProcessDefinition getProcessDefinition(String processDefinitionId) {
-		return repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
+	/**
+	 * 根据 taskId 查询 流程定义 (活动任务坐标)
+	 *
+	 * @param taskId
+	 * @return
+	 */
+	@Override
+	public ProcessDefDTO findProcessDefinitionByTaskId(String taskId) {
+		//使用任务ID,查询任务对象
+		Task task = taskService.createTaskQuery()
+			.taskId(taskId)
+			.singleResult();
+		//获取流程定义ID
+		String processDefinitionId = task.getProcessDefinitionId();
+		//查询流程定义的对象act_re_procdef
+		ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+			.processDefinitionId(processDefinitionId)
+			.singleResult();
+
+		//获取流程定义的实体对象(对应.bpmn文件中的数据)
+		ProcessDefinitionEntity processDefinitionEntity =
+			(ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId);
+
+		//使用流程实例ID,查询正在执行的执行对象表,获取当前活动对应的流程实例对象
+		ProcessInstance pi = runtimeService.createProcessInstanceQuery()
+			.processInstanceId(task.getProcessInstanceId())
+			.singleResult();
+
+		//获取当前活动对象
+		ActivityImpl activityImpl = processDefinitionEntity.findActivity(pi.getActivityId());
+
+		Deployment deployment = repositoryService.createDeploymentQuery()
+			.deploymentId(processDefinition.getDeploymentId()).singleResult();
+		ProcessDefDTO processDefDTO = ProcessDefDTO.toProcessDefDTO(processDefinition, deployment);
+		processDefDTO.setXAxis(activityImpl.getX());
+		processDefDTO.setYAxis(activityImpl.getY());
+		processDefDTO.setWidth(activityImpl.getWidth());
+		processDefDTO.setHeight(activityImpl.getWidth());
+		return processDefDTO;
 	}
 
-	private Deployment getDeployment(String deploymentId) {
-		return repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
+	@Override
+	public List<CommentDto> findCommentByTaskId(String taskId) {
+		//使用当前的任务ID,查询当前流程对应的历史任务ID
+		//使用当前任务ID,获取当前任务对象
+		Task task = taskService.createTaskQuery()
+			.taskId(taskId)
+			.singleResult();
+		//获取流程实例ID
+		List<CommentDto> commentDtoList = new ArrayList<>();
+		List<Comment> commentList = taskService.getProcessInstanceComments(task.getProcessInstanceId());
+
+		commentList.forEach(comment -> {
+			CommentDto commentDto = new CommentDto();
+			commentDto.setId(comment.getId());
+			commentDto.setTime(comment.getTime());
+			commentDto.setType(comment.getType());
+			commentDto.setTaskId(comment.getTaskId());
+			commentDto.setUserId(comment.getUserId());
+			commentDto.setFullMessage(comment.getFullMessage());
+			commentDto.setProcessInstanceId(comment.getProcessInstanceId());
+			commentDtoList.add(commentDto);
+		});
+		return commentDtoList;
 	}
+
 }

+ 33 - 0
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/LeaveBillServiceImpl.java

@@ -0,0 +1,33 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.act.service.impl;
+
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.pig4cloud.pigx.act.entity.LeaveBill;
+import com.pig4cloud.pigx.act.mapper.LeaveBillMapper;
+import com.pig4cloud.pigx.act.service.LeaveBillService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lengleng
+ * @date 2018-09-27
+ */
+@Service("leaveBillService")
+public class LeaveBillServiceImpl extends ServiceImpl<LeaveBillMapper, LeaveBill> implements LeaveBillService {
+
+}

+ 38 - 23
pigx-visual/pigx-activiti/src/main/java/com/pig4cloud/pigx/act/service/impl/ProcessServiceImpl.java

@@ -21,6 +21,8 @@ import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.pig4cloud.pigx.act.dto.ProcessDefDTO;
+import com.pig4cloud.pigx.act.entity.LeaveBill;
+import com.pig4cloud.pigx.act.mapper.LeaveBillMapper;
 import com.pig4cloud.pigx.act.service.ProcessService;
 import lombok.AllArgsConstructor;
 import org.activiti.engine.RepositoryService;
@@ -33,6 +35,7 @@ import org.springframework.stereotype.Service;
 
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -45,6 +48,7 @@ import java.util.Map;
 public class ProcessServiceImpl implements ProcessService {
 	private final RepositoryService repositoryService;
 	private final RuntimeService runtimeService;
+	private final LeaveBillMapper leaveBillMapper;
 
 	/**
 	 * 分页流程列表
@@ -72,7 +76,7 @@ public class ProcessServiceImpl implements ProcessService {
 			.forEach(processDefinition -> {
 				Deployment deployment = repositoryService.createDeploymentQuery()
 					.deploymentId(processDefinition.getDeploymentId()).singleResult();
-				deploymentList.add(toProcessDefDTO(processDefinition, deployment));
+				deploymentList.add(ProcessDefDTO.toProcessDefDTO(processDefinition, deployment));
 			});
 		result.setRecords(deploymentList);
 		return result;
@@ -124,38 +128,49 @@ public class ProcessServiceImpl implements ProcessService {
 	}
 
 	/**
-	 * 删除流程实例
+	 * 删除部署的流程,级联删除流程实例
 	 *
-	 * @param procInsId
+	 * @param deploymentId
 	 * @return
 	 */
 	@Override
-	public Boolean deleteProcIns(String procInsId) {
-		runtimeService.deleteProcessInstance(procInsId, "pigx");
+	public Boolean deleteProcIns(String deploymentId) {
+		repositoryService.deleteDeployment(deploymentId, true);
 		return Boolean.TRUE;
 	}
 
 	/**
-	 * 抽取流程定义需要返回的内容
+	 * 启动流程、更新请假单状态
 	 *
-	 * @param processDefinition
-	 * @param deployment
+	 * @param leaveId
 	 * @return
 	 */
-	private ProcessDefDTO toProcessDefDTO(ProcessDefinition processDefinition, Deployment deployment) {
-
-		ProcessDefDTO dto = new ProcessDefDTO();
-		dto.category = processDefinition.getCategory();
-		dto.processonDefinitionId = processDefinition.getId();
-		dto.key = processDefinition.getKey();
-		dto.name = deployment.getName();
-		dto.revision = processDefinition.getVersion();
-		dto.deploymentTime = deployment.getDeploymentTime().getTime();
-		dto.xmlName = processDefinition.getResourceName();
-		dto.picName = processDefinition.getDiagramResourceName();
-		dto.deploymentId = deployment.getId();
-		dto.suspend = processDefinition.isSuspended();
-		dto.description = processDefinition.getDescription();
-		return dto;
+	@Override
+	public Boolean saveStartProcess(Integer leaveId) {
+		//1:获取请假单ID,使用请假单ID,查询请假单的对象LeaveBill
+		LeaveBill leaveBill = leaveBillMapper.selectById(leaveId);
+		leaveBill.setState("1");
+		//3:使用当前对象获取到流程定义的key(对象的名称就是流程定义的key)
+		String key = leaveBill.getClass().getSimpleName();
+		/**
+		 * 4:从Session中获取当前任务的办理人,使用流程变量设置下一个任务的办理人
+		 * inputUser是流程变量的名称,
+		 * 获取的办理人是流程变量的值
+		 */
+		Map<String, Object> variables = new HashMap<>(1);
+		variables.put("aaaaaaa", "lengleng");
+		/**
+		 * 5:
+		 * (1)使用流程变量设置字符串(格式:LeaveBill.id的形式),通过设置,让启动的流程(流程实例)关联业务
+		 * (2)使用正在执行对象表中的一个字段BUSINESS_KEY(Activiti提供的一个字段),让启动的流程(流程实例)关联业务
+		 */
+		//格式:LeaveBill.id的形式(使用流程变量)
+		String objId = key + "." + leaveBill.getLeaveId();
+		variables.put("objId", objId);
+		//6:使用流程定义的key,启动流程实例,同时设置流程变量,同时向正在执行的执行对象表中的字段BUSINESS_KEY添加业务数据,同时让流程关联业务
+		runtimeService.startProcessInstanceByKey(key, objId, variables);
+		leaveBillMapper.updateById(leaveBill);
+		return Boolean.TRUE;
 	}
+
 }

+ 30 - 0
pigx-visual/pigx-activiti/src/main/resources/bootstrap.yml

@@ -0,0 +1,30 @@
+server:
+  port: 5002
+
+spring:
+  application:
+    name: pigx-activiti
+  #配置中心
+  cloud:
+    config:
+      fail-fast: true
+      name: ${spring.application.name}
+      profile: dev
+      discovery:
+        enabled: true
+        service-id: pigx-config
+  datasource:
+    url: jdbc:mysql://114.116.21.191:3306/ac?characterEncoding=UTF-8&useSSL=false
+    username: root
+    password: Bjyjht2017!@#
+    driver-class-name: com.mysql.jdbc.Driver
+  activiti:
+    check-process-definitions: false
+
+# 注册中心配置
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    service-url:
+      defaultZone: http://pig:pig@192.168.0.20:1025/eureka/

+ 19 - 0
pigx-visual/pigx-activiti/src/main/resources/mapper/LeaveBillMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.pig4cloud.pigx.act.mapper.LeaveBillMapper">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="com.pig4cloud.pigx.act.entity.LeaveBill" id="leaveBillMap">
+        <result property="leaveId" column="leave_id"/>
+        <result property="username" column="username"/>
+        <result property="days" column="days"/>
+        <result property="content" column="content"/>
+        <result property="state" column="state"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+    </resultMap>
+
+
+</mapper>

+ 0 - 2
pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm

@@ -1,6 +1,5 @@
 package ${package}.${moduleName}.controller;
 
-import java.util.Arrays;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,7 +10,6 @@ import com.pig4cloud.pigx.common.core.util.Query;
 import ${package}.${moduleName}.entity.${className};
 import ${package}.${moduleName}.service.${className}Service;
 import com.pig4cloud.pigx.common.core.util.R;
-import java.util.Map;
 
 
 /**

+ 2 - 1
pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm

@@ -3,6 +3,7 @@ package ${package}.${moduleName}.entity;
 import com.baomidou.mybatisplus.activerecord.Model;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
+import com.baomidou.mybatisplus.enums.IdType;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
   #if(${hasBigDecimal})
@@ -28,7 +29,7 @@ public class ${className} extends Model<${className}> {
 	 * $column.comments
 	 */
 	#if($column.columnName == $pk.columnName)
-@TableId
+@TableId(type = IdType.AUTO)
 	#end
 private $column.attrType $column.lowerAttrName;
 #end

+ 2 - 0
pigx-visual/pigx-codegen/src/main/resources/template/index.vue.vm

@@ -154,6 +154,7 @@
         type: 'success'
       })
       done()
+      this.getList()
     })
     },
     /**
@@ -171,6 +172,7 @@
         type: 'success'
       })
       done()
+      this.getList()
     })
     },
     /**

+ 8 - 8
pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm

@@ -1,13 +1,13 @@
 -- 该脚本不要执行,请完善 ID 对应关系,注意层级关系 !!!!
 
 -- 菜单SQL
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
-    values ( '父菜单ID', 'views/${moduleName}/${pathName}/index', '', '0', '${pathName}', 'icon-bangzhushouji', '菜单ID', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理');
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`, `tenant_id`)
+    values ( '父菜单ID', 'views/${moduleName}/${pathName}/index', '', '0', '${pathName}', 'icon-bangzhushouji', '菜单ID', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理','1');
 
 -- 菜单对应按钮SQL
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
-    values ( '菜单ID', null, '${moduleName}_${pathName}_add', '1', null, '1', '子按钮ID1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增');
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
-    values ( '菜单ID', null, '${moduleName}_${pathName}_edit', '1', null, '1', '子按钮ID2', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改');
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
-    values ( '菜单ID', null, '${moduleName}_${pathName}_del', '1', null, '1', '子按钮ID3', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除');
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`, `tenant_id`)
+    values ( '菜单ID', null, '${moduleName}_${pathName}_add', '1', null, '1', '子按钮ID1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增','1');
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`, `tenant_id`)
+    values ( '菜单ID', null, '${moduleName}_${pathName}_edit', '1', null, '1', '子按钮ID2', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改','1');
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`, `tenant_id`)
+    values ( '菜单ID', null, '${moduleName}_${pathName}_del', '1', null, '1', '子按钮ID3', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除','1');