Browse Source

【修改】OA入职流程信息

lichen 1 year ago
parent
commit
ab528b205b

+ 4 - 0
yudao-module-bpm/yudao-module-bpm-biz/pom.xml

@@ -26,6 +26,10 @@
             <artifactId>yudao-module-system-api</artifactId>
             <version>${revision}</version>
         </dependency>
+<!--        <dependency>-->
+<!--            <groupId>cn.iocoder.boot</groupId>-->
+<!--            <artifactId>yudao-common</artifactId>-->
+<!--        </dependency>-->
 
         <!-- 业务组件 -->
         <dependency>

+ 27 - 13
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/OaEntryController.java

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.controller.admin.oa;
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntryPageReqVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntryRespVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntrySaveReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskApproveReqVO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.OaEntryDO;
 import cn.iocoder.yudao.module.bpm.service.oa.entry.OaEntryService;
 import org.springframework.web.bind.annotation.*;
@@ -13,7 +14,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.Operation;
 
-import javax.validation.constraints.*;
 import javax.validation.*;
 import javax.servlet.http.*;
 import java.util.*;
@@ -29,7 +29,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
 
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
-
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
 
 @Tag(name = "管理后台 - 入职流程信息")
@@ -41,21 +41,35 @@ public class OaEntryController {
     @Resource
     private OaEntryService oaEntryService;
 
-    @PostMapping("/create")
-    @Operation(summary = "创建入职流程信息")
-    @PreAuthorize("@ss.hasPermission('bpm:oa-entry:create')")
-    public CommonResult<Integer> createOaEntry(@Valid @RequestBody OaEntrySaveReqVO createReqVO) {
-        return success(oaEntryService.createOaEntry(createReqVO));
+    @PostMapping("/start")
+    @Operation(summary = "提交入职流程信息")
+    @PreAuthorize("@ss.hasPermission('bpm:oa-entry:start')")
+    public CommonResult<Integer> startOaEntry(@Valid @RequestBody OaEntrySaveReqVO createReqVO) {
+        return success(oaEntryService.startOaEntry(getLoginUserId(),createReqVO));
     }
 
-    @PutMapping("/update")
-    @Operation(summary = "更新入职流程信息")
-    @PreAuthorize("@ss.hasPermission('bpm:oa-entry:update')")
-    public CommonResult<Boolean> updateOaEntry(@Valid @RequestBody OaEntrySaveReqVO updateReqVO) {
-        oaEntryService.updateOaEntry(updateReqVO);
-        return success(true);
+    @PostMapping("/complete")
+    @Operation(summary = "审批入职流程信息")
+    @PreAuthorize("@ss.hasPermission('bpm:oa-entry:start')")
+    public CommonResult<Integer> completeOaEntry(@Valid @RequestBody OaEntrySaveReqVO createReqVO,@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
+        return success(oaEntryService.completeOaEntry(getLoginUserId(),createReqVO,reqVO));
     }
 
+//    @PostMapping("/return")
+//    @Operation(summary = "撤回入职流程信息")
+//    @PreAuthorize("@ss.hasPermission('bpm:oa-entry:start')")
+//    public CommonResult<Integer> returnCompelete(@Valid @RequestBody OaEntrySaveReqVO createReqVO,@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
+//        return success(oaEntryService.completeOaEntry(getLoginUserId(),createReqVO,reqVO));
+//    }
+
+//    @PutMapping("/update")
+//    @Operation(summary = "更新入职流程信息")
+//    @PreAuthorize("@ss.hasPermission('bpm:oa-entry:update')")
+//    public CommonResult<Boolean> updateOaEntry(@Valid @RequestBody OaEntrySaveReqVO updateReqVO) {
+//        oaEntryService.updateOaEntry(updateReqVO);
+//        return success(true);
+//    }
+
     @DeleteMapping("/delete")
     @Operation(summary = "删除入职流程信息")
     @Parameter(name = "id", description = "编号", required = true)

+ 19 - 22
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/entry/OaEntryPageReqVO.java

@@ -18,9 +18,6 @@ public class OaEntryPageReqVO extends PageParam {
     @Schema(description = "uuid", example = "13471")
     private String entryId;
 
-    @Schema(description = "入职人", example = "王五")
-    private String loginName;
-
     @Schema(description = "部门", example = "2937")
     private String deptId;
 
@@ -48,34 +45,34 @@ public class OaEntryPageReqVO extends PageParam {
     @Schema(description = "工作经验")
     private String workExperience;
 
-    @Schema(description = "入职日期")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private String[] startDate;
-
     @Schema(description = "备注")
     private String remarks;
 
-    @Schema(description = "流程实例id", example = "11656")
-    private String procInsId;
-
-    @Schema(description = "单据状态(0:暂存,1:审批中,2:生效,4:审批完成,3:删除,5作废)", example = "2")
-    private String oaEntryStatus;
-
-    @Schema(description = "审核状态(0:驳回,1:提交,2:审批中,4:审批完成,3:取消结束)", example = "2")
-    private String auditStatus;
-
-    @Schema(description = "当前审核人编号", example = "20994")
-    private String auditLoginId;
-
     @Schema(description = "最后审核时间")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private String[] finalAuditDate;
 
-    @Schema(description = "数据来源,流程添加、手动添加")
-    private String infoSource;
-
     @Schema(description = "创建时间")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    @Schema(description = "入职人", example = "李四")
+    private String entryName;
+
+    @Schema(description = "入职日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private String[] entryDate;
+
+    @Schema(description = "流程实例id", example = "9407")
+    private String procInstId;
+
+    @Schema(description = "审核状态(0暂存、1已提交、2审核中、3已审核、4已关闭、5驳回)", example = "2")
+    private String auditStatus;
+
+    @Schema(description = "当前审核人编号", example = "29870")
+    private String currentAuditEmployeeId;
+
+    @Schema(description = "数据来源,0流程添加、1手动添加")
+    private String infoSource;
+
 }

+ 28 - 32
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/entry/OaEntryRespVO.java

@@ -13,18 +13,10 @@ import com.alibaba.excel.annotation.*;
 @ExcelIgnoreUnannotated
 public class OaEntryRespVO {
 
-    @Schema(description = "入职表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22133")
-    @ExcelProperty("入职表单主键")
-    private Integer id;
-
     @Schema(description = "uuid", example = "13471")
     @ExcelProperty("uuid")
     private String entryId;
 
-    @Schema(description = "入职人", example = "王五")
-    @ExcelProperty("入职人")
-    private String loginName;
-
     @Schema(description = "部门", example = "2937")
     @ExcelProperty("部门")
     private String deptId;
@@ -61,40 +53,44 @@ public class OaEntryRespVO {
     @ExcelProperty("工作经验")
     private String workExperience;
 
-    @Schema(description = "入职日期")
-    @ExcelProperty("入职日期")
-    private String startDate;
-
     @Schema(description = "备注")
     @ExcelProperty("备注")
     private String remarks;
 
-    @Schema(description = "流程实例id", example = "11656")
-    @ExcelProperty("流程实例id")
-    private String procInsId;
-
-    @Schema(description = "单据状态(0:暂存,1:审批中,2:生效,4:审批完成,3:删除,5作废)", example = "2")
-    @ExcelProperty("单据状态(0:暂存,1:审批中,2:生效,4:审批完成,3:删除,5作废)")
-    private String oaEntryStatus;
-
-    @Schema(description = "审核状态(0:驳回,1:提交,2:审批中,4:审批完成,3:取消结束)", example = "2")
-    @ExcelProperty("审核状态(0:驳回,1:提交,2:审批中,4:审批完成,3:取消结束)")
-    private String auditStatus;
-
-    @Schema(description = "当前审核人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20994")
-    @ExcelProperty("当前审核人编号")
-    private String auditLoginId;
-
     @Schema(description = "最后审核时间", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("最后审核时间")
     private String finalAuditDate;
 
-    @Schema(description = "数据来源,流程添加、手动添加")
-    @ExcelProperty("数据来源,流程添加、手动添加")
-    private String infoSource;
-
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;
 
+    @Schema(description = "入职表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "27428")
+    @ExcelProperty("入职表单主键")
+    private Integer id;
+
+    @Schema(description = "入职人", example = "李四")
+    @ExcelProperty("入职人")
+    private String entryName;
+
+    @Schema(description = "入职日期")
+    @ExcelProperty("入职日期")
+    private String entryDate;
+
+    @Schema(description = "流程实例id", example = "9407")
+    @ExcelProperty("流程实例id")
+    private String procInstId;
+
+    @Schema(description = "审核状态(0暂存、1已提交、2审核中、3已审核、4已关闭、5驳回)", example = "2")
+    @ExcelProperty("审核状态(0暂存、1已提交、2审核中、3已审核、4已关闭、5驳回)")
+    private String auditStatus;
+
+    @Schema(description = "当前审核人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29870")
+    @ExcelProperty("当前审核人编号")
+    private String currentAuditEmployeeId;
+
+    @Schema(description = "数据来源,0流程添加、1手动添加", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("数据来源,0流程添加、1手动添加")
+    private String infoSource;
+
 }

+ 25 - 21
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/entry/OaEntrySaveReqVO.java

@@ -9,15 +9,9 @@ import javax.validation.constraints.*;
 @Data
 public class OaEntrySaveReqVO {
 
-    @Schema(description = "入职表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22133")
-    private Integer id;
-
     @Schema(description = "uuid", example = "13471")
     private String entryId;
 
-    @Schema(description = "入职人", example = "王五")
-    private String loginName;
-
     @Schema(description = "部门", example = "2937")
     private String deptId;
 
@@ -45,30 +39,40 @@ public class OaEntrySaveReqVO {
     @Schema(description = "工作经验")
     private String workExperience;
 
-    @Schema(description = "入职日期")
-    private String startDate;
-
     @Schema(description = "备注")
     private String remarks;
 
-    @Schema(description = "流程实例id", example = "11656")
-    private String procInsId;
+    @Schema(description = "最后审核时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "最后审核时间不能为空")
+    private String finalAuditDate;
+
+    @Schema(description = "入职表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "27428")
+    private Integer id;
 
-    @Schema(description = "单据状态(0:暂存,1:审批中,2:生效,4:审批完成,3:删除,5作废)", example = "2")
-    private String oaEntryStatus;
+    @Schema(description = "入职人", example = "李四")
+    private String entryName;
 
-    @Schema(description = "审核状态(0:驳回,1:提交,2:审批中,4:审批完成,3:取消结束)", example = "2")
+    @Schema(description = "入职日期")
+    private String entryDate;
+
+    @Schema(description = "流程实例id", example = "9407")
+    private String procInstId;
+
+    @Schema(description = "审核状态(0暂存、1已提交、2审核中、3已审核、4已关闭、5驳回)", example = "2")
     private String auditStatus;
 
-    @Schema(description = "当前审核人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20994")
+    @Schema(description = "当前审核人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29870")
     @NotEmpty(message = "当前审核人编号不能为空")
-    private String auditLoginId;
+    private String currentAuditEmployeeId;
 
-    @Schema(description = "最后审核时间", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotEmpty(message = "最后审核时间不能为空")
-    private String finalAuditDate;
-
-    @Schema(description = "数据来源,流程添加、手动添加")
+    @Schema(description = "数据来源,0流程添加、1手动添加", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "数据来源,0流程添加、1手动添加不能为空")
     private String infoSource;
 
+    @Schema(description = "审批,true 通过,false 驳回", example = "true")
+    private Boolean auditPass;
+
+    @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}")
+    private Map<String, List<Long>> startUserSelectAssignees;
+
 }

+ 12 - 14
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/OaEntryDO.java

@@ -21,12 +21,12 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
 @NoArgsConstructor
 @AllArgsConstructor
 public class OaEntryDO extends BaseDO {
-
     /**
      * 入职表单主键
      */
     @TableId
     private Integer id;
+
     /**
      * uuid
      */
@@ -34,7 +34,7 @@ public class OaEntryDO extends BaseDO {
     /**
      * 入职人
      */
-    private String loginName;
+    private String entryName;
     /**
      * 部门
      */
@@ -74,33 +74,31 @@ public class OaEntryDO extends BaseDO {
     /**
      * 入职日期
      */
-    private String startDate;
+    private String entryDate;
     /**
      * 备注
      */
     private String remarks;
+
+
     /**
      * 流程实例id
      */
-    private String procInsId;
-    /**
-     * 单据状态(0:暂存,1:审批中,2:生效,4:审批完成,3:删除,5作废)
-     */
-    private String oaEntryStatus;
+    private String procInstId;
     /**
-     * 审核状态(0:驳回,1:提交,2:审批中,4:审批完成,3:取消结束
+     * 审核状态(0暂存、1已提交、2审核中、3已审核、4已关闭、5驳回)
      */
     private String auditStatus;
     /**
-     * 当前审核人编号
+     * 最后审核时间
      */
-    private String auditLoginId;
+    private Date finalAuditDate;
     /**
-     * 最后审核时间
+     * 当前审核人编号
      */
-    private String finalAuditDate;
+    private String currentAuditEmployeeId;
     /**
-     * 数据来源,流程添加、手动添加
+     * 数据来源,0流程添加、1手动添加
      */
     private String infoSource;
 

+ 10 - 9
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/OaEntryMapper.java

@@ -1,12 +1,14 @@
 package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
 
+import java.util.*;
+
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntryPageReqVO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.OaEntryDO;
 import org.apache.ibatis.annotations.Mapper;
-
 /**
  * 入职流程信息 Mapper
  *
@@ -18,7 +20,6 @@ public interface OaEntryMapper extends BaseMapperX<OaEntryDO> {
     default PageResult<OaEntryDO> selectPage(OaEntryPageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<OaEntryDO>()
                 .eqIfPresent(OaEntryDO::getEntryId, reqVO.getEntryId())
-                .likeIfPresent(OaEntryDO::getLoginName, reqVO.getLoginName())
                 .eqIfPresent(OaEntryDO::getDeptId, reqVO.getDeptId())
                 .eqIfPresent(OaEntryDO::getPosition, reqVO.getPosition())
                 .eqIfPresent(OaEntryDO::getEmployeeType, reqVO.getEmployeeType())
@@ -28,15 +29,15 @@ public interface OaEntryMapper extends BaseMapperX<OaEntryDO> {
                 .eqIfPresent(OaEntryDO::getEmail, reqVO.getEmail())
                 .eqIfPresent(OaEntryDO::getEducation, reqVO.getEducation())
                 .eqIfPresent(OaEntryDO::getWorkExperience, reqVO.getWorkExperience())
-                .betweenIfPresent(OaEntryDO::getStartDate, reqVO.getStartDate())
                 .eqIfPresent(OaEntryDO::getRemarks, reqVO.getRemarks())
-                .eqIfPresent(OaEntryDO::getProcInsId, reqVO.getProcInsId())
-                .eqIfPresent(OaEntryDO::getOaEntryStatus, reqVO.getOaEntryStatus())
-                .eqIfPresent(OaEntryDO::getAuditStatus, reqVO.getAuditStatus())
-                .eqIfPresent(OaEntryDO::getAuditLoginId, reqVO.getAuditLoginId())
                 .betweenIfPresent(OaEntryDO::getFinalAuditDate, reqVO.getFinalAuditDate())
-                .eqIfPresent(OaEntryDO::getInfoSource, reqVO.getInfoSource())
                 .betweenIfPresent(OaEntryDO::getCreateTime, reqVO.getCreateTime())
+                .likeIfPresent(OaEntryDO::getEntryName, reqVO.getEntryName())
+                .betweenIfPresent(OaEntryDO::getEntryDate, reqVO.getEntryDate())
+                .eqIfPresent(OaEntryDO::getProcInstId, reqVO.getProcInstId())
+                .eqIfPresent(OaEntryDO::getAuditStatus, reqVO.getAuditStatus())
+                .eqIfPresent(OaEntryDO::getCurrentAuditEmployeeId, reqVO.getCurrentAuditEmployeeId())
+                .eqIfPresent(OaEntryDO::getInfoSource, reqVO.getInfoSource())
                 .orderByDesc(OaEntryDO::getId));
     }
 

+ 15 - 5
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/entry/OaEntryService.java

@@ -1,14 +1,13 @@
 package cn.iocoder.yudao.module.bpm.service.oa.entry;
 
+import javax.validation.*;
+
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntryPageReqVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntrySaveReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskApproveReqVO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.OaEntryDO;
 
-import java.util.*;
-import javax.validation.*;
-
-
 /**
  * 入职流程信息 Service 接口
  *
@@ -19,10 +18,21 @@ public interface OaEntryService {
     /**
      * 创建入职流程信息
      *
+     * @param userId
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Integer startOaEntry(Long userId, @Valid OaEntrySaveReqVO createReqVO);
+
+    /**
+     * 创建入职流程信息
+     *
+     * @param userId
      * @param createReqVO 创建信息
+     * @param reqVO  通过请求
      * @return 编号
      */
-    Integer createOaEntry(@Valid OaEntrySaveReqVO createReqVO);
+    Integer completeOaEntry(Long userId, @Valid OaEntrySaveReqVO createReqVO,@Valid BpmTaskApproveReqVO reqVO);
 
     /**
      * 更新入职流程信息

+ 110 - 4
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/entry/OaEntryServiceImpl.java

@@ -1,14 +1,23 @@
 package cn.iocoder.yudao.module.bpm.service.oa.entry;
 
+import cn.hutool.core.util.IdUtil;
+import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
+import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntryPageReqVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.OaEntrySaveReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskApproveReqVO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.OaEntryDO;
 import cn.iocoder.yudao.module.bpm.dal.mysql.oa.OaEntryMapper;
+import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
+import org.flowable.engine.RuntimeService;
+import org.flowable.engine.TaskService;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.task.api.Task;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
-
 import java.util.*;
 
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -16,7 +25,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 
 
-
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
 
@@ -29,14 +37,110 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
 @Validated
 public class OaEntryServiceImpl implements OaEntryService {
 
+    /**
+     * OA 入职对应的流程定义 KEY
+     */
+    public static final String PROCESS_KEY = "oa_entry_workflow";
+
     @Resource
     private OaEntryMapper oaEntryMapper;
 
+    @Resource
+    private BpmProcessInstanceApi processInstanceApi;
+
+    @Resource
+    private BpmTaskService bpmTaskService;
+
+    @Resource
+    private TaskService taskService;
+
+    @Autowired
+    private RuntimeService runtimeService;
+
     @Override
-    public Integer createOaEntry(OaEntrySaveReqVO createReqVO) {
+    public Integer startOaEntry(Long userId, OaEntrySaveReqVO createReqVO) {
+        //判断是否已经发起流程
+        Boolean auditPass = createReqVO.getAuditPass();
         // 插入
         OaEntryDO oaEntry = BeanUtils.toBean(createReqVO, OaEntryDO.class);
         oaEntryMapper.insert(oaEntry);
+        //如果提交
+        if (auditPass){
+            // 发起 BPM 流程
+            Map<String, Object> processInstanceVariables = new HashMap<>();
+            processInstanceVariables.put("auditPass",auditPass);
+            String processInstanceId = processInstanceApi.createProcessInstance(userId,
+                    new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
+                            .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(oaEntry.getId()))
+                            .setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
+
+            //获取下一个审批人
+            Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
+
+            // 将工作流的编号,单据状态 表单uuid  最后一次审批时间 当前审批人  更新到 OA 入职中
+            oaEntryMapper.updateById(new OaEntryDO().setId(oaEntry.getId()).setProcInstId(processInstanceId).setAuditStatus("1")
+                    .setEntryId(IdUtil.fastSimpleUUID()).setFinalAuditDate(new Date()).setCurrentAuditEmployeeId(task.getAssignee()));
+        }else {
+            // 将单据状态 表单uuid 更新到 OA入职中
+            oaEntryMapper.updateById(new OaEntryDO().setId(oaEntry.getId()).setAuditStatus("0").setEntryId(UUID.randomUUID().toString()));
+        }
+
+        // todo 站内信发送
+        // loanInfoService.sendMassage(actBaseInfo);
+        // 返回
+        return oaEntry.getId();
+    }
+
+    @Override
+    public Integer completeOaEntry(Long userId, OaEntrySaveReqVO createReqVO, BpmTaskApproveReqVO reqVO) {
+        //判断是否已经发起流程
+        Boolean auditPass = createReqVO.getAuditPass();
+        // 修改
+        OaEntryDO oaEntry = BeanUtils.toBean(createReqVO, OaEntryDO.class);
+//        oaEntryMapper.updateById(oaEntry);
+        //判断当前单据是否存在流程实例id,如果不存在说明没有发起流程
+        if (oaEntry.getProcInstId() == null && oaEntry.getProcInstId().equals("")) {
+            // 提交
+            if (createReqVO.getAuditPass()) {
+                // 发起 BPM 流程
+                Map<String, Object> processInstanceVariables = new HashMap<>();
+                processInstanceVariables.put("auditPass", auditPass);
+                String processInstanceId = processInstanceApi.createProcessInstance(userId,
+                        new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
+                                .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(oaEntry.getId()))
+                                .setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
+
+                // 将工作流的编号,单据状态 更新到 OA 入职中
+                oaEntryMapper.updateById(new OaEntryDO().setId(oaEntry.getId()).setProcInstId(processInstanceId).setAuditStatus("1"));
+            }else {
+                // 暂存 将单据状态 更新到 OA 入职中
+                oaEntryMapper.updateById(new OaEntryDO().setId(oaEntry.getId()).setAuditStatus("0"));
+            }
+        } else {
+            //同意
+            if (createReqVO.getAuditPass()) {
+                //审批通过
+                bpmTaskService.approveTask(userId,reqVO);
+                //判断流程是否结束
+                ProcessInstance procIns = runtimeService.createProcessInstanceQuery().processInstanceId(createReqVO.getProcInstId()).active().singleResult();
+                if (procIns != null) {
+                    //说明流程结束
+                    //获取下一个审批人
+                    Task task = taskService.createTaskQuery().processInstanceId(createReqVO.getProcInstId()).singleResult();
+                    //  将单据状态 当前审批人 最后一次审批时间 更新到 OA 入职中
+                    oaEntryMapper.updateById(new OaEntryDO().setId(oaEntry.getId()).setAuditStatus("2").setCurrentAuditEmployeeId(task.getAssignee())
+                            .setFinalAuditDate(new Date()));
+                }else {
+                    //流程结束
+                    //todo 复制信息到入职信息表中
+
+                    //  将单据状态 更新到 OA 入职中
+                    oaEntryMapper.updateById(new OaEntryDO().setId(oaEntry.getId()).setAuditStatus("3").setCurrentAuditEmployeeId(" ").setFinalAuditDate(new Date()));
+                }
+            }
+        }
+        // todo 站内信发送
+        // loanInfoService.sendMassage(actBaseInfo);
         // 返回
         return oaEntry.getId();
     }
@@ -55,7 +159,9 @@ public class OaEntryServiceImpl implements OaEntryService {
         // 校验存在
         validateOaEntryExists(id);
         // 删除
-        oaEntryMapper.deleteById(id);
+//        oaEntryMapper.deleteById(id);
+        //  将单据状态 更新到 OA 入职中
+        oaEntryMapper.updateById((OaEntryDO) new OaEntryDO().setId(id).setDeleted(true));
     }
 
     private void validateOaEntryExists(Integer id) {