From 2739964a8ed8e8e586971a5271a4d6bf2dbac2e5 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 16 Dec 2022 17:10:03 +0800
Subject: [PATCH] 添加审核工作流

---
 src/main/java/org/springblade/modules/enterprise/wrapper/EnterpriseWrapper.java            |   18 
 src/main/java/org/springblade/modules/reject/wrapper/RejectWrapper.java                    |   50 +++
 src/main/java/org/springblade/modules/application/controller/ApplicationController.java    |   41 ++
 src/main/java/org/springblade/modules/reject/mapper/RejectMapper.xml                       |   27 +
 src/main/java/org/springblade/modules/application/entity/ApplicationEntity.java            |   26 +
 src/main/java/org/springblade/modules/reject/mapper/RejectMapper.java                      |   43 +++
 src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.java            |    9 
 src/main/java/org/springblade/common/utils/CommonUtil.java                                 |   31 ++
 src/main/java/org/springblade/modules/reject/vo/RejectVO.java                              |   35 ++
 src/main/java/org/springblade/flow/core/utils/FlowUtil.java                                |    1 
 src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.xml             |   15 
 src/main/java/org/springblade/flow/core/constant/ProcessConstant.java                      |    5 
 src/main/java/org/springblade/modules/reject/service/impl/RejectServiceImpl.java           |   57 ++++
 src/main/java/org/springblade/modules/reject/controller/RejectController.java              |  126 +++++++++
 src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java      |    3 
 src/main/java/org/springblade/modules/application/service/IApplicationService.java         |   25 +
 src/main/java/org/springblade/modules/reject/dto/RejectDTO.java                            |   34 ++
 src/main/java/org/springblade/modules/reject/service/IRejectService.java                   |   42 +++
 src/main/java/org/springblade/modules/reject/entity/RejectEntity.java                      |   55 +++
 src/main/java/org/springblade/modules/application/service/impl/ApplicationServiceImpl.java |  170 ++++++++++++
 20 files changed, 795 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/springblade/common/utils/CommonUtil.java b/src/main/java/org/springblade/common/utils/CommonUtil.java
index c424bc8..4b46708 100644
--- a/src/main/java/org/springblade/common/utils/CommonUtil.java
+++ b/src/main/java/org/springblade/common/utils/CommonUtil.java
@@ -16,6 +16,12 @@
  */
 package org.springblade.common.utils;
 
+import org.springblade.core.tool.utils.StringUtil;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 /**
  * 通用工具类
  *
@@ -23,4 +29,29 @@
  */
 public class CommonUtil {
 
+	/**
+	 * 生成随时间自增变化的编号
+	 * @param prefixStr 前缀
+	 * @param maxNumber 最大值
+	 * @return
+	 */
+	public final static String createNo(String prefixStr,String maxNumber){
+		SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
+		String caseNo="";
+		if (StringUtil.isNotBlank(maxNumber)) {
+			DecimalFormat decimalFormat = new DecimalFormat("000000");
+			String dateStr = df.format(new Date());
+			int preLength = maxNumber.indexOf(prefixStr) > -1 ? prefixStr.length():0;
+			String value = maxNumber.substring(dateStr.length() + 5 + preLength, maxNumber.length());
+			int i = Integer.parseInt(value) + 1;
+			String k = decimalFormat.format(i);
+			// 订单号
+			caseNo= prefixStr + dateStr + k;
+		} else {
+			//初始、默认值
+			caseNo = prefixStr + df.format(new Date()) + "000001";
+		}
+		return caseNo;
+	}
+
 }
diff --git a/src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java b/src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java
index 0db6bba..8859947 100644
--- a/src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java
+++ b/src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java
@@ -19,9 +19,12 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import lombok.AllArgsConstructor;
 import org.flowable.engine.HistoryService;
+import org.flowable.engine.RuntimeService;
 import org.flowable.engine.TaskService;
 import org.flowable.engine.history.HistoricProcessInstance;
 import org.flowable.engine.history.HistoricProcessInstanceQuery;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.task.api.Task;
 import org.flowable.task.api.TaskQuery;
 import org.flowable.task.api.history.HistoricTaskInstance;
 import org.flowable.task.api.history.HistoricTaskInstanceQuery;
diff --git a/src/main/java/org/springblade/flow/core/constant/ProcessConstant.java b/src/main/java/org/springblade/flow/core/constant/ProcessConstant.java
index 8657f7b..30d72cc 100644
--- a/src/main/java/org/springblade/flow/core/constant/ProcessConstant.java
+++ b/src/main/java/org/springblade/flow/core/constant/ProcessConstant.java
@@ -29,6 +29,11 @@
 	String LEAVE_KEY = "Leave";
 
 	/**
+	 * 请假流程标识
+	 */
+	String AUDIT_KEY = "Audit";
+
+	/**
 	 * 报销流程标识
 	 */
 	String EXPENSE_KEY = "Expense";
diff --git a/src/main/java/org/springblade/flow/core/utils/FlowUtil.java b/src/main/java/org/springblade/flow/core/utils/FlowUtil.java
index fd1b28e..1079714 100644
--- a/src/main/java/org/springblade/flow/core/utils/FlowUtil.java
+++ b/src/main/java/org/springblade/flow/core/utils/FlowUtil.java
@@ -37,6 +37,7 @@
 
 	static {
 		BUSINESS_TABLE.put(ProcessConstant.LEAVE_KEY, "blade_process_leave");
+		BUSINESS_TABLE.put(ProcessConstant.AUDIT_KEY, "sys_application");
 	}
 
 	/**
diff --git a/src/main/java/org/springblade/modules/application/controller/ApplicationController.java b/src/main/java/org/springblade/modules/application/controller/ApplicationController.java
index a9a3b0e..315b403 100644
--- a/src/main/java/org/springblade/modules/application/controller/ApplicationController.java
+++ b/src/main/java/org/springblade/modules/application/controller/ApplicationController.java
@@ -24,13 +24,17 @@
 import javax.validation.Valid;
 
 import org.springblade.Application;
+import org.springblade.common.cache.UserCache;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.flow.core.entity.BladeFlow;
+import org.springblade.flow.demo.leave.entity.ProcessLeave;
 import org.springblade.modules.application.entity.*;
 import org.springblade.modules.enterprise.entity.EnterpriseEntity;
+import org.springblade.modules.reject.entity.RejectEntity;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.modules.application.vo.ApplicationVO;
@@ -100,7 +104,7 @@
 	@PostMapping("/saveVo")
 	@ApiOperationSupport(order = 4)
 	@ApiOperation(value = "自定义新增", notes = "传入applicationVo")
-	public R save(@Valid @RequestBody ApplicationEntity application, @RequestBody BasicInfoEntity basicInfoEntity, @RequestBody CarEntity carEntity,
+	public R saveVo(@Valid @RequestBody ApplicationEntity application, @RequestBody BasicInfoEntity basicInfoEntity, @RequestBody CarEntity carEntity,
 				  @RequestBody PlanEntity planEntity, @RequestBody SchemeEntity schemeEntity, @RequestBody GoodsEntity goodsEntity) {
 		return R.status(applicationService.saveVo(application,basicInfoEntity,carEntity,planEntity,schemeEntity,goodsEntity));
 	}
@@ -145,6 +149,41 @@
 	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
 		return R.status(applicationService.deleteLogic(Func.toLongList(ids)));
 	}
+	//================================工作流========================================
 
+	/**
+	 * 申请表  工作流开始
+	 */
+	@PostMapping("/start-process")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "工作流开始", notes = "传入applicationVo")
+	public R startProcess(@Valid @RequestBody ApplicationEntity application, @RequestBody BasicInfoEntity basicInfoEntity, @RequestBody CarEntity carEntity,
+						  @RequestBody PlanEntity planEntity, @RequestBody SchemeEntity schemeEntity, @RequestBody GoodsEntity goodsEntity) {
+		return R.status(applicationService.startProcess(application,basicInfoEntity,carEntity,planEntity,schemeEntity,goodsEntity));
+	}
 
+	/**
+	 * 详情
+	 *
+	 * @param businessId 主键
+	 */
+	@GetMapping("/process-detail")
+	public R<ApplicationVO> detail(Long businessId) {
+		ApplicationEntity detail = applicationService.getById(businessId);
+		ApplicationVO applicationVO = applicationService.getVo(detail);
+		applicationVO.getFlow().setAssigneeName(UserCache.getUser(detail.getCreateUser()).getName());
+		return R.data(applicationVO);
+	}
+
+	/**
+	 * 完成任务
+	 *
+	 * @param flow 审核信息
+	 */
+	@PostMapping("complete-task")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "完成任务", notes = "传入流程信息")
+	public R completeTask(@ApiParam("任务信息") @RequestBody BladeFlow flow, @RequestBody ApplicationEntity applicationEntity, @RequestBody RejectEntity rejectEntity) {
+		return R.status(applicationService.completeTask(flow,applicationEntity,rejectEntity));
+	}
 }
diff --git a/src/main/java/org/springblade/modules/application/entity/ApplicationEntity.java b/src/main/java/org/springblade/modules/application/entity/ApplicationEntity.java
index 1b84af0..df62d11 100644
--- a/src/main/java/org/springblade/modules/application/entity/ApplicationEntity.java
+++ b/src/main/java/org/springblade/modules/application/entity/ApplicationEntity.java
@@ -25,6 +25,7 @@
 import java.util.Date;
 import lombok.EqualsAndHashCode;
 import org.springblade.core.tenant.mp.TenantEntity;
+import org.springblade.flow.core.entity.FlowEntity;
 
 /**
  * 申请表 实体类
@@ -36,7 +37,7 @@
 @TableName(value = "sys_application",autoResultMap = true)
 @ApiModel(value = "Application对象", description = "申请表")
 @EqualsAndHashCode(callSuper = true)
-public class ApplicationEntity extends TenantEntity {
+public class ApplicationEntity extends FlowEntity {
 	/**
 	 * 关联的用户id
 	 */
@@ -47,6 +48,16 @@
 	 */
 	@ApiModelProperty(value = "申请编号")
 	private String no;
+	/**
+	 * 货物分类
+	 */
+	@ApiModelProperty(value = "货物分类")
+	private String goodsCategory;
+	/**
+	 * 货物类别
+	 */
+	@ApiModelProperty(value = "货物类别")
+	private String goodsType;
 	/**
 	 * 道路运输经营许可证图片
 	 */
@@ -82,5 +93,16 @@
 	 */
 	@ApiModelProperty(value = "完善意见")
 	private String suggestion;
-
+	/**
+	 * 流程定义id
+	 */
+	private String processDefinitionId;
+	/**
+	 * 流程实例id
+	 */
+	private String processInstanceId;
+	/**
+	 * 审批人
+	 */
+	private String taskUser;
 }
diff --git a/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.java b/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.java
index 278abb7..7422af3 100644
--- a/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.java
+++ b/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.java
@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.application.mapper;
 
+import org.apache.ibatis.annotations.Param;
 import org.springblade.modules.application.entity.ApplicationEntity;
 import org.springblade.modules.application.vo.ApplicationVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -37,7 +38,13 @@
 	 * @param application
 	 * @return
 	 */
-	List<ApplicationVO> selectApplicationPage(IPage page, ApplicationVO application);
+	List<ApplicationVO> selectApplicationPage(IPage page, @Param("application") ApplicationVO application);
 
+	/**
+	 * 获取最大编号
+	 * @return
+	 */
+	ApplicationEntity getMaxNoEntity();
 
+	ApplicationEntity getByNo(@Param("no") String no);
 }
diff --git a/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.xml b/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.xml
index 7221387..73b67a8 100644
--- a/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.xml
+++ b/src/main/java/org/springblade/modules/application/mapper/ApplicationMapper.xml
@@ -6,18 +6,12 @@
     <resultMap id="applicationResultMap" type="org.springblade.modules.application.vo.ApplicationVO">
         <result column="id" property="id"/>
         <result column="no" property="no"/>
-        <result column="basic_info_id" property="basicInfoId"/>
-        <result column="scheme_id" property="schemeId"/>
-        <result column="plan_id" property="planId"/>
-        <result column="goods_id" property="goodsId"/>
-        <result column="car_id" property="carId"/>
         <result column="road_license_url" property="roadLicenseUrl"/>
         <result column="id_license_url" property="idLicenseUrl"/>
         <result column="license_url" property="licenseUrl"/>
         <result column="skeleton_url" property="skeletonUrl"/>
         <result column="attorney_url" property="attorneyUrl"/>
         <result column="suggestion" property="suggestion"/>
-        <result column="tenant_id" property="tenantId"/>
         <result column="create_user" property="createUser"/>
         <result column="create_dept" property="createDept"/>
         <result column="create_time" property="createTime"/>
@@ -44,6 +38,15 @@
         LEFT JOIN sys_application_goods goods ON goods.application_id = app.id
         LEFT JOIN sys_enterprise enterprise ON enterprise.user_id = app.user_id AND enterprise.is_deleted = 0
         where app.is_deleted = 0
+        <if test="application.userId != null and application.userId !='' ">
+           AND app.user_id = #{application.userId}
+        </if>
+    </select>
+    <select id="getMaxNoEntity" resultType="org.springblade.modules.application.entity.ApplicationEntity">
+        SELECT * from sys_application where is_deleted = 0 ORDER BY create_time DESC LIMIT 1
+    </select>
+    <select id="getByNo" resultType="org.springblade.modules.application.entity.ApplicationEntity">
+        SELECT * FROM sys_application WHERE is_deleted = 0 AND no = #{no}
     </select>
 
 
diff --git a/src/main/java/org/springblade/modules/application/service/IApplicationService.java b/src/main/java/org/springblade/modules/application/service/IApplicationService.java
index 404c92d..c249f13 100644
--- a/src/main/java/org/springblade/modules/application/service/IApplicationService.java
+++ b/src/main/java/org/springblade/modules/application/service/IApplicationService.java
@@ -17,10 +17,12 @@
 package org.springblade.modules.application.service;
 
 import org.springblade.Application;
+import org.springblade.flow.core.entity.BladeFlow;
 import org.springblade.modules.application.entity.*;
 import org.springblade.modules.application.vo.ApplicationVO;
 import org.springblade.core.mp.base.BaseService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.reject.entity.RejectEntity;
 
 /**
  * 申请表 服务类
@@ -43,5 +45,28 @@
 
     ApplicationVO getVo(ApplicationEntity application);
 
+    ApplicationEntity getMaxNoEntity();
+
 	Boolean updateVoById(ApplicationEntity application, BasicInfoEntity basicInfoEntity, CarEntity carEntity, PlanEntity planEntity, SchemeEntity schemeEntity, GoodsEntity goodsEntity);
+
+	ApplicationEntity getByNo(String no);
+
+	/**
+	 * application 工作流
+	 * @param application
+	 * @param basicInfoEntity
+	 * @param carEntity
+	 * @param planEntity
+	 * @param schemeEntity
+	 * @param goodsEntity
+	 * @return
+	 */
+	Boolean startProcess(ApplicationEntity application, BasicInfoEntity basicInfoEntity, CarEntity carEntity, PlanEntity planEntity, SchemeEntity schemeEntity, GoodsEntity goodsEntity);
+
+	/**
+	 * 审核信息
+	 * @param flow
+	 * @return
+	 */
+    Boolean completeTask(BladeFlow flow, ApplicationEntity applicationEntity, RejectEntity rejectEntity);
 }
diff --git a/src/main/java/org/springblade/modules/application/service/impl/ApplicationServiceImpl.java b/src/main/java/org/springblade/modules/application/service/impl/ApplicationServiceImpl.java
index 26b6538..bdbc2dd 100644
--- a/src/main/java/org/springblade/modules/application/service/impl/ApplicationServiceImpl.java
+++ b/src/main/java/org/springblade/modules/application/service/impl/ApplicationServiceImpl.java
@@ -16,9 +16,26 @@
  */
 package org.springblade.modules.application.service.impl;
 
+import com.aliyun.oss.ServiceException;
 import lombok.AllArgsConstructor;
+import org.flowable.bpmn.model.*;
+import org.flowable.engine.RepositoryService;
+import org.flowable.engine.RuntimeService;
+import org.flowable.engine.TaskService;
+import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.task.api.Task;
+import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.support.Kv;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.flow.business.service.IFlowService;
+import org.springblade.flow.core.constant.ProcessConstant;
+import org.springblade.flow.core.entity.BladeFlow;
+import org.springblade.flow.core.utils.FlowUtil;
+import org.springblade.flow.core.utils.TaskUtil;
 import org.springblade.modules.application.entity.*;
 import org.springblade.modules.application.service.*;
 import org.springblade.modules.application.vo.ApplicationVO;
@@ -26,10 +43,14 @@
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.modules.application.wrapper.ApplicationWrapper;
 import org.springblade.modules.enterprise.wrapper.EnterpriseWrapper;
+import org.springblade.modules.reject.entity.RejectEntity;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * 申请表 服务实现类
@@ -46,6 +67,11 @@
 	private final IGoodsService goodsService;
 	private final ICarService carService;
 
+	private final IFlowService flowService;
+	private final TaskService taskService;
+	private final RuntimeService runtimeService;
+	private final RepositoryService repositoryService;
+
 	@Override
 	public IPage<ApplicationVO> selectApplicationPage(IPage<ApplicationVO> page, ApplicationVO application) {
 		return page.setRecords(baseMapper.selectApplicationPage(page, application));
@@ -54,6 +80,15 @@
 	@Transactional
 	@Override
 	public Boolean saveVo(ApplicationEntity application, BasicInfoEntity basicInfoEntity, CarEntity carEntity, PlanEntity planEntity, SchemeEntity schemeEntity, GoodsEntity goodsEntity) {
+
+		boolean result = false;
+		//保存
+		ApplicationEntity applicationEntity = getMaxNoEntity();
+		String str = "";
+		if (applicationEntity != null) {
+			str = applicationEntity.getNo();
+		}
+		application.setNo(CommonUtil.createNo("", str));
 		boolean save = super.save(application);
 
 		basicInfoEntity.setApplicationId(application.getId().toString());
@@ -70,8 +105,9 @@
 
 		carEntity.setApplicationId(application.getId().toString());
 		boolean c = carService.save(carEntity);
+		result = b && p && s && g && c && save;
 
-		return b&&p&&s&&g&&c&&save;
+		return result;
 	}
 
 	@Override
@@ -107,7 +143,137 @@
 		boolean s = schemeService.updateById(schemeEntity);
 		boolean g = goodsService.updateById(goodsEntity);
 		boolean update = super.updateById(application);
-		return  b&&p&&s&&g&&c&&update;
+		return b && p && s && g && c && update;
 	}
 
+	@Override
+	public ApplicationEntity getByNo(String no) {
+		return baseMapper.getByNo(no);
+	}
+
+	@Override
+	public Boolean startProcess(ApplicationEntity application, BasicInfoEntity basicInfoEntity, CarEntity carEntity, PlanEntity planEntity, SchemeEntity schemeEntity, GoodsEntity goodsEntity) {
+
+		boolean result = false;
+		String businessTable = FlowUtil.getBusinessTable(ProcessConstant.AUDIT_KEY);
+		if (Func.isEmpty(application.getId())) {
+			//保存
+			ApplicationEntity applicationEntity = getMaxNoEntity();
+			String str = "";
+			if (applicationEntity != null) {
+				str = applicationEntity.getNo();
+			}
+			application.setNo(CommonUtil.createNo("", str));
+			boolean save = super.save(application);
+
+			basicInfoEntity.setApplicationId(application.getId().toString());
+			boolean b = basicInfoService.save(basicInfoEntity);
+
+			planEntity.setApplicationId(application.getId().toString());
+			boolean p = planService.save(planEntity);
+
+			schemeEntity.setApplicationId(application.getId().toString());
+			boolean s = schemeService.save(schemeEntity);
+
+			goodsEntity.setApplicationId(application.getId().toString());
+			boolean g = goodsService.save(goodsEntity);
+
+			carEntity.setApplicationId(application.getId().toString());
+			boolean c = carService.save(carEntity);
+			result = b && p && s && g && c && save;
+
+			//启动流程
+			Kv variables = Kv.create()
+				.set(ProcessConstant.TASK_VARIABLE_CREATE_USER, basicInfoEntity.getName())
+				.set("taskUser", TaskUtil.getTaskUser(application.getTaskUser()));
+			BladeFlow flow = flowService.startProcessInstanceById(application.getProcessDefinitionId(), FlowUtil.getBusinessKey(businessTable, String.valueOf(application.getId())), variables);
+			if (Func.isNotEmpty(flow)) {
+				log.error("流程已启动,流程ID:" + flow.getProcessInstanceId());
+				// 返回流程id写入leave
+				application.setProcessInstanceId(flow.getProcessInstanceId());
+				updateById(application);
+			} else {
+				throw new ServiceException("开启流程失败");
+			}
+		} else {
+			updateById(application);
+		}
+
+		return result;
+	}
+
+	@Override
+	public Boolean completeTask(BladeFlow flow, ApplicationEntity applicationEntity, RejectEntity rejectEntity) {
+		String taskId = flow.getTaskId();
+
+		Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
+
+		//  通过任务对象获取流程实例
+		ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
+		// 通过流程实例获取“业务键”
+		String businessKey = pi.getBusinessKey().split(":")[1];
+
+		//获取实例对象改变业务状态
+		ApplicationEntity entity = getById(businessKey);
+
+		if (!StringUtil.isBlank(applicationEntity.getSuggestion())){
+			entity.setSuggestion(applicationEntity.getSuggestion());
+		}
+		if (entity.getStatus() == 1){
+			entity.setStatus(2);
+		}
+
+		String processInstanceId = flow.getProcessInstanceId();
+		String comment = Func.toStr(flow.getComment(), ProcessConstant.PASS_COMMENT);
+		// 增加评论
+		if (StringUtil.isNoneBlank(processInstanceId, comment)) {
+			taskService.addComment(taskId, processInstanceId, comment);
+		}
+		// 创建变量
+		Map<String, Object> variables = flow.getVariables();
+		if (variables == null) {
+			variables = Kv.create();
+		}
+		variables.put("suggestion",Func.toStr(applicationEntity.getSuggestion(),""));
+		variables.put(ProcessConstant.PASS_KEY, flow.isPass());
+		// 完成任务
+		taskService.complete(taskId, variables);
+
+
+		//判读是否有末尾节点
+		if (getEndNode(task,entity.getProcessDefinitionId())){
+			//判断是否pass
+			if ((Boolean)variables.get(ProcessConstant.PASS_KEY)){
+				//改变业务状态
+				entity.setStatus(10);
+				//生成通行证
+
+
+			}
+		}
+		updateById(entity);
+		return true;
+	}
+
+	/**
+	 * 获取最大编号
+	 *
+	 * @return
+	 */
+	public ApplicationEntity getMaxNoEntity() {
+		return baseMapper.getMaxNoEntity();
+	}
+
+	public boolean getEndNode(Task task,String definitionId){
+		BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionId);
+		FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());
+		List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows();
+		for (SequenceFlow outgoingFlow : outgoingFlows) {
+			FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement();
+			if (targetFlowElement instanceof EndEvent){
+				return true;
+			}
+		}
+		return false;
+	}
 }
diff --git a/src/main/java/org/springblade/modules/enterprise/wrapper/EnterpriseWrapper.java b/src/main/java/org/springblade/modules/enterprise/wrapper/EnterpriseWrapper.java
index ca6afa5..e817c01 100644
--- a/src/main/java/org/springblade/modules/enterprise/wrapper/EnterpriseWrapper.java
+++ b/src/main/java/org/springblade/modules/enterprise/wrapper/EnterpriseWrapper.java
@@ -18,6 +18,7 @@
 
 import org.springblade.core.mp.support.BaseEntityWrapper;
 import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.modules.enterprise.entity.EnterpriseEntity;
 import org.springblade.modules.enterprise.vo.EnterpriseVO;
 import java.util.Objects;
@@ -36,14 +37,19 @@
 
 	@Override
 	public EnterpriseVO entityVO(EnterpriseEntity enterprise) {
-		EnterpriseVO enterpriseVO = Objects.requireNonNull(BeanUtil.copy(enterprise, EnterpriseVO.class));
+		if (ObjectUtil.isNotEmpty(enterprise)){
+			EnterpriseVO enterpriseVO = Objects.requireNonNull(BeanUtil.copy(enterprise, EnterpriseVO.class));
 
-		//User createUser = UserCache.getUser(enterprise.getCreateUser());
-		//User updateUser = UserCache.getUser(enterprise.getUpdateUser());
-		//enterpriseVO.setCreateUserName(createUser.getName());
-		//enterpriseVO.setUpdateUserName(updateUser.getName());
+			//User createUser = UserCache.getUser(enterprise.getCreateUser());
+			//User updateUser = UserCache.getUser(enterprise.getUpdateUser());
+			//enterpriseVO.setCreateUserName(createUser.getName());
+			//enterpriseVO.setUpdateUserName(updateUser.getName());
 
-		return enterpriseVO;
+			return enterpriseVO;
+		}else {
+			return null;
+		}
+
 	}
 
 
diff --git a/src/main/java/org/springblade/modules/reject/controller/RejectController.java b/src/main/java/org/springblade/modules/reject/controller/RejectController.java
new file mode 100644
index 0000000..26c28c2
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/controller/RejectController.java
@@ -0,0 +1,126 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.reject.entity.RejectEntity;
+import org.springblade.modules.reject.vo.RejectVO;
+import org.springblade.modules.reject.wrapper.RejectWrapper;
+import org.springblade.modules.reject.service.IRejectService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 拒绝申请表 控制器
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("reject/reject")
+@Api(value = "拒绝申请表", tags = "拒绝申请表接口")
+public class RejectController extends BladeController {
+
+	private final IRejectService rejectService;
+
+	/**
+	 * 拒绝申请表 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入reject")
+	public R<RejectVO> detail(RejectEntity reject) {
+		RejectEntity detail = rejectService.getOne(Condition.getQueryWrapper(reject));
+		return R.data(RejectWrapper.build().entityVO(detail));
+	}
+	/**
+	 * 拒绝申请表 分页
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入reject")
+	public R<IPage<RejectVO>> list(RejectEntity reject, Query query) {
+		IPage<RejectEntity> pages = rejectService.page(Condition.getPage(query), Condition.getQueryWrapper(reject));
+		return R.data(RejectWrapper.build().pageVO(pages));
+	}
+
+	/**
+	 * 拒绝申请表 自定义分页
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入reject")
+	public R<IPage<RejectVO>> page(RejectVO reject, Query query) {
+		IPage<RejectVO> pages = rejectService.selectRejectPage(Condition.getPage(query), reject);
+		return R.data(pages);
+	}
+
+	/**
+	 * 拒绝申请表 新增
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入reject")
+	public R save(@Valid @RequestBody RejectEntity reject) {
+		return R.status(rejectService.save(reject));
+	}
+
+	/**
+	 * 拒绝申请表 修改
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入reject")
+	public R update(@Valid @RequestBody RejectEntity reject) {
+		return R.status(rejectService.updateById(reject));
+	}
+
+	/**
+	 * 拒绝申请表 新增或修改
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入reject")
+	public R submit(@Valid @RequestBody RejectEntity reject) {
+		return R.status(rejectService.saveOrUpdate(reject));
+	}
+
+	/**
+	 * 拒绝申请表 删除
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(rejectService.deleteLogic(Func.toLongList(ids)));
+	}
+
+
+}
diff --git a/src/main/java/org/springblade/modules/reject/dto/RejectDTO.java b/src/main/java/org/springblade/modules/reject/dto/RejectDTO.java
new file mode 100644
index 0000000..69cda1a
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/dto/RejectDTO.java
@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.dto;
+
+import org.springblade.modules.reject.entity.RejectEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 拒绝申请表 数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class RejectDTO extends RejectEntity {
+	private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/springblade/modules/reject/entity/RejectEntity.java b/src/main/java/org/springblade/modules/reject/entity/RejectEntity.java
new file mode 100644
index 0000000..bf79c9e
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/entity/RejectEntity.java
@@ -0,0 +1,55 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.tenant.mp.TenantEntity;
+
+/**
+ * 拒绝申请表 实体类
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+@Data
+@TableName("sys_reject")
+@ApiModel(value = "Reject对象", description = "拒绝申请表")
+@EqualsAndHashCode(callSuper = true)
+public class RejectEntity extends TenantEntity {
+
+	/**
+	 * 申请编号
+	 */
+	@ApiModelProperty(value = "申请编号")
+	private String no;
+	/**
+	 * 拒绝理由
+	 */
+	@ApiModelProperty(value = "拒绝理由")
+	private String rejectReason;
+	/**
+	 * 备注
+	 */
+	@ApiModelProperty(value = "备注")
+	private String remark;
+
+}
diff --git a/src/main/java/org/springblade/modules/reject/mapper/RejectMapper.java b/src/main/java/org/springblade/modules/reject/mapper/RejectMapper.java
new file mode 100644
index 0000000..2ad7ff9
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/mapper/RejectMapper.java
@@ -0,0 +1,43 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.mapper;
+
+import org.springblade.modules.reject.entity.RejectEntity;
+import org.springblade.modules.reject.vo.RejectVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 拒绝申请表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+public interface RejectMapper extends BaseMapper<RejectEntity> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param reject
+	 * @return
+	 */
+	List<RejectVO> selectRejectPage(IPage page, RejectVO reject);
+
+
+}
diff --git a/src/main/java/org/springblade/modules/reject/mapper/RejectMapper.xml b/src/main/java/org/springblade/modules/reject/mapper/RejectMapper.xml
new file mode 100644
index 0000000..6eeaef1
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/mapper/RejectMapper.xml
@@ -0,0 +1,27 @@
+<?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="org.springblade.modules.reject.mapper.RejectMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="rejectResultMap" type="org.springblade.modules.reject.entity.RejectEntity">
+        <result column="id" property="id"/>
+        <result column="no" property="no"/>
+        <result column="reject_reason" property="rejectReason"/>
+        <result column="remark" property="remark"/>
+        <result column="tenant_id" property="tenantId"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+    </resultMap>
+
+
+    <select id="selectRejectPage" resultMap="rejectResultMap">
+        select * from sys_reject where is_deleted = 0
+    </select>
+
+
+</mapper>
diff --git a/src/main/java/org/springblade/modules/reject/service/IRejectService.java b/src/main/java/org/springblade/modules/reject/service/IRejectService.java
new file mode 100644
index 0000000..2f69ec5
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/service/IRejectService.java
@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.service;
+
+import org.springblade.modules.reject.entity.RejectEntity;
+import org.springblade.modules.reject.vo.RejectVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 拒绝申请表 服务类
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+public interface IRejectService extends BaseService<RejectEntity> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param reject
+	 * @return
+	 */
+	IPage<RejectVO> selectRejectPage(IPage<RejectVO> page, RejectVO reject);
+
+
+}
diff --git a/src/main/java/org/springblade/modules/reject/service/impl/RejectServiceImpl.java b/src/main/java/org/springblade/modules/reject/service/impl/RejectServiceImpl.java
new file mode 100644
index 0000000..819612f
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/service/impl/RejectServiceImpl.java
@@ -0,0 +1,57 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.service.impl;
+
+import org.springblade.modules.application.entity.ApplicationEntity;
+import org.springblade.modules.application.service.IApplicationService;
+import org.springblade.modules.reject.entity.RejectEntity;
+import org.springblade.modules.reject.vo.RejectVO;
+import org.springblade.modules.reject.mapper.RejectMapper;
+import org.springblade.modules.reject.service.IRejectService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 拒绝申请表 服务实现类
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+@Service
+public class RejectServiceImpl extends BaseServiceImpl<RejectMapper, RejectEntity> implements IRejectService {
+	@Autowired
+	IApplicationService applicationService;
+
+	@Override
+	public IPage<RejectVO> selectRejectPage(IPage<RejectVO> page, RejectVO reject) {
+		return page.setRecords(baseMapper.selectRejectPage(page, reject));
+	}
+
+	@Override
+	public boolean save(RejectEntity entity) {
+		boolean save = super.save(entity);
+
+		ApplicationEntity applicationEntity = applicationService.getByNo(entity.getNo());
+		applicationEntity.setStatus(99);
+
+		boolean update = applicationService.updateById(applicationEntity);
+
+		return update&&save;
+	}
+}
diff --git a/src/main/java/org/springblade/modules/reject/vo/RejectVO.java b/src/main/java/org/springblade/modules/reject/vo/RejectVO.java
new file mode 100644
index 0000000..d418de0
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/vo/RejectVO.java
@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.vo;
+
+import org.springblade.modules.reject.entity.RejectEntity;
+import org.springblade.core.tool.node.INode;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 拒绝申请表 视图实体类
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class RejectVO extends RejectEntity {
+	private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/springblade/modules/reject/wrapper/RejectWrapper.java b/src/main/java/org/springblade/modules/reject/wrapper/RejectWrapper.java
new file mode 100644
index 0000000..eb6a23a
--- /dev/null
+++ b/src/main/java/org/springblade/modules/reject/wrapper/RejectWrapper.java
@@ -0,0 +1,50 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.reject.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.reject.entity.RejectEntity;
+import org.springblade.modules.reject.vo.RejectVO;
+import java.util.Objects;
+
+/**
+ * 拒绝申请表 包装类,返回视图层所需的字段
+ *
+ * @author BladeX
+ * @since 2022-12-15
+ */
+public class RejectWrapper extends BaseEntityWrapper<RejectEntity, RejectVO>  {
+
+	public static RejectWrapper build() {
+		return new RejectWrapper();
+ 	}
+
+	@Override
+	public RejectVO entityVO(RejectEntity reject) {
+		RejectVO rejectVO = Objects.requireNonNull(BeanUtil.copy(reject, RejectVO.class));
+
+		//User createUser = UserCache.getUser(reject.getCreateUser());
+		//User updateUser = UserCache.getUser(reject.getUpdateUser());
+		//rejectVO.setCreateUserName(createUser.getName());
+		//rejectVO.setUpdateUserName(updateUser.getName());
+
+		return rejectVO;
+	}
+
+
+}

--
Gitblit v1.9.3