Bläddra i källkod

需求招聘工作流事件

jzh 1 år sedan
förälder
incheckning
cccb099002

+ 0 - 1
zjugis-business/src/main/java/com/zjugis/business/converter/recruit/RecruitConvert.java

@@ -27,5 +27,4 @@ public interface RecruitConvert {
     PageResult<RecruitVO> convertList(PageResult<RecruitDO> list);
 
     RecruitDO convert(RecruitVO recruitVO);
-
 }

+ 1 - 1
zjugis-business/src/main/java/com/zjugis/business/flow/recruit/controller/RecruitDemandController.java

@@ -47,7 +47,7 @@ public class RecruitDemandController extends BaseController {
     }
 
     @GetMapping("/page")
-    @Operation(summary = "招聘需求列表生成")
+    @Operation(summary = "招聘需求列表")
     public CommonResult<PageResult<RecruitVO>> getTravelCostPage(@Valid RecruitPageVO pageReqVO) {
         return CommonResult.success(recruitDemandService.getPage(pageReqVO));
     }

+ 177 - 0
zjugis-business/src/main/java/com/zjugis/business/flow/recruit/event/RecruitEvent.java

@@ -0,0 +1,177 @@
+package com.zjugis.business.flow.recruit.event;
+
+import com.zjugis.business.flow.recruit.entity.RecruitDO;
+import com.zjugis.business.flow.recruit.service.RecruitDemandService;
+import com.zjugis.framework.common.util.date.LocalDateTimeUtils;
+import com.zjugis.framework.workflow.exception.BusinessException;
+import com.zjugis.framework.workflow.model.BaseController;
+import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
+import com.zjugis.framework.workflow.spring.resovler.ParamModel;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Objects;
+
+import static com.zjugis.business.constants.FlowStatusConstants.*;
+
+/**
+ * @Author 陈俊
+ * @Date 2023/11/21 17:51
+ * @Version 1.0
+ */
+@RestController
+@RequestMapping("/recruit-event")
+public class RecruitEvent extends BaseController {
+
+    public static final Logger log = LoggerFactory.getLogger(RecruitEvent.class);
+    @Resource
+    private RecruitDemandService recruitDemandService;
+
+    @Resource
+    private WorkflowClient workflowClient;
+
+    /**
+     * 设置流程描述
+     *
+     * @param flowInstance     流程实例
+     * @param activityInstance 活动实例
+     * @return true/false
+     */
+    @PostMapping("/setFlowDesc")
+    public String setFlowDesc(@ParamModel Map flowInstance, @ParamModel Map activityInstance) {
+        try {
+            if (!Objects.isNull(activityInstance) && activityInstance.containsKey("flowInstanceId")) {
+                String flowInstanceId = activityInstance.get("flowInstanceId").toString();
+                RecruitDO entity = recruitDemandService.findByInstanceId(flowInstanceId);
+                String applyTime = LocalDateTimeUtils.format(entity.getCreateTime(), null);
+                String flowDesc = StringUtils.join(Arrays.asList(entity.getUserNickname(), applyTime, entity.getDeptName()), "/");
+                entity.setFlowStatus(FLOW_PROCESS);
+                recruitDemandService.updateRecruit(entity);
+                flowDesc = flowDesc.length() > 1 ? flowDesc.substring(1) : flowDesc;
+                workflowClient.saveFlowDescribe(flowInstanceId, flowDesc);
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+
+    /**
+     * 流程归档事件
+     *
+     * @param flowInstance                  流程实例
+     * @param triggerFinishActivityInstance 触发归档的结束活动实例
+     * @return
+     */
+    @PostMapping("/flowArchingEvent")
+    public String flowArchingEvent(@ParamModel Map flowInstance, @ParamModel Map triggerFinishActivityInstance) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                RecruitDO entity = recruitDemandService.findByInstanceId(flowInstanceId);
+                entity.setFlowStatus(FLOW_FINISHED);
+                entity.setFlowFinishtime(LocalDateTime.now());
+                recruitDemandService.updateRecruit(entity);
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+    /**
+     * 作废事件
+     *
+     * @param flowInstance     流程实例
+     * @param activityInstance 申请作废所在活动实例
+     * @param nullyApplyUserId 作废申请人ID
+     * @return
+     */
+    @PostMapping("/nullyEvent")
+    public String nullyEvent(@ParamModel Map flowInstance, @ParamModel Map activityInstance, String nullyApplyUserId) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                RecruitDO entity = recruitDemandService.findByInstanceId(flowInstanceId);
+                entity.setFlowStatus(FLOW_NULLY);
+                entity.setIsvalid(0);
+                recruitDemandService.updateRecruit(entity);
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+    /**
+     * 作废恢复事件
+     *
+     * @param flowInstance      流程实例
+     * @param activityInstance  申请作废所在活动实例
+     * @param nullyApplyUserId  作废申请人ID
+     * @param nullyRecoverserId 作废恢复人ID
+     * @return
+     */
+    @PostMapping("/nullyRecoverEvent")
+    public String nullyRecoverEvent(@ParamModel Map flowInstance, @ParamModel Map activityInstance, String nullyApplyUserId, String nullyRecoverserId) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                RecruitDO entity = recruitDemandService.findByInstanceId(flowInstanceId);
+                entity.setFlowStatus(FLOW_PROCESS);
+                entity.setIsvalid(1);
+                recruitDemandService.updateRecruit(entity);
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+
+    /**
+     * 彻底作废事件
+     *
+     * @param flowInstance        流程实例
+     * @param activityInstance    申请作废所在活动实例
+     * @param nullyApplyUserId    作废申请人ID
+     * @param nullyCompleteUserId 彻底作废人ID
+     * @return
+     */
+    @PostMapping("/nullyCompleteEvent")
+    public String nullyCompleteEvent(@ParamModel Map flowInstance, @ParamModel Map activityInstance, String nullyApplyUserId, String nullyCompleteUserId) {
+        try {
+            if (!Objects.isNull(flowInstance) && flowInstance.containsKey("id")) {
+                String flowInstanceId = flowInstance.get("id").toString();
+                RecruitDO entity = recruitDemandService.findByInstanceId(flowInstanceId);
+                recruitDemandService.deleteRecruit(entity.getId());
+                return ok("true");
+            } else {
+                throw new BusinessException("执行事件出错,请联系管理员!");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new BusinessException("执行事件出错,请联系管理员!");
+        }
+    }
+}

+ 11 - 20
zjugis-business/src/main/java/com/zjugis/business/flow/recruit/service/RecruitDemandService.java

@@ -1,52 +1,43 @@
 package com.zjugis.business.flow.recruit.service;
 
-import com.zjugis.business.flow.leave.controller.vo.LeaveCreateReqVO;
-import com.zjugis.business.flow.leave.controller.vo.LeaveUpdateReqVO;
-import com.zjugis.business.flow.leave.entity.LeaveDO;
 import com.zjugis.business.flow.recruit.controller.vo.RecruitPageVO;
 import com.zjugis.business.flow.recruit.controller.vo.RecruitVO;
 import com.zjugis.business.flow.recruit.entity.RecruitDO;
-import com.zjugis.business.flow.travelcost.controller.vo.TravelCostRespVO;
 import com.zjugis.framework.common.pojo.PageResult;
 
 import java.util.Map;
 
-/**
- * @Author 陈俊
- * @Date 2023/11/21 9:14
- * @Version 1.0
- */
+
 public interface RecruitDemandService {
     /**
-     * 创建请假流程
-     * @param createReqVO
-     * @return
+     * 创建招聘流程
      */
     String createRecruit(RecruitVO recruitVO);
 
     /**
-     * 更新请假流程
-     * @param updateReqVO
+     * 更新招聘流程
      */
     void updateRecruit(RecruitVO updateReqVO);
 
     /**
-     * 删除请假流程
-     * @param id
+     * 更新招聘流程
+     */
+    void updateRecruit(RecruitDO recruitDO);
+
+    /**
+     * 删除招聘流程
      */
     void deleteRecruit(String id);
 
     /**
      * 通过流程实例ID查找记录
-     * @param flowInstanceId
-     * @return
+     *
      */
     RecruitDO findByInstanceId(String flowInstanceId);
 
     /**
      * 获取表单参数
-     * @param flowInstanceId
-     * @return
+     *
      */
     Map<String, Object> getFormParams(String flowInstanceId);
 

+ 12 - 1
zjugis-business/src/main/java/com/zjugis/business/flow/recruit/service/impl/RecruitDemandServiceImpl.java

@@ -2,6 +2,8 @@ package com.zjugis.business.flow.recruit.service.impl;
 
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.zjugis.business.bean.entity.ContractInvoice;
 import com.zjugis.business.constants.DictConstants;
 import com.zjugis.business.constants.FlowStatusConstants;
 import com.zjugis.business.converter.common.SelectConvert;
@@ -76,6 +78,13 @@ public class RecruitDemandServiceImpl implements RecruitDemandService {
         recruitDAO.updateById(recruitDO);
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void updateRecruit(RecruitDO recruitDO) {
+        validateRecruitDemandExists(recruitDO.getId());
+        recruitDAO.updateById(recruitDO);
+    }
+
     private void validateRecruitDemandExists(String id) {
         if (recruitDAO.selectById(id) == null) {
             throw exception(RECRUIT_DEMAND_NOT_EXISTS);
@@ -90,7 +99,9 @@ public class RecruitDemandServiceImpl implements RecruitDemandService {
 
     @Override
     public RecruitDO findByInstanceId(String flowInstanceId) {
-        return null;
+        QueryWrapper<RecruitDO> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("INSTANCE_ID",flowInstanceId);
+        return recruitDAO.selectOne(queryWrapper);
     }
 
     @Override