|
@@ -0,0 +1,245 @@
|
|
|
+package com.zjugis.business.flow.intern.event;
|
|
|
+
|
|
|
+import com.zjugis.business.flow.intern.entity.InternDO;
|
|
|
+import com.zjugis.business.flow.intern.service.InternService;
|
|
|
+import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
+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 com.zjugis.module.adm.api.staff.StaffApi;
|
|
|
+import com.zjugis.module.system.api.dept.DeptApi;
|
|
|
+import com.zjugis.module.system.api.dept.DeptLeaderApi;
|
|
|
+import com.zjugis.module.system.api.dept.dto.DeptLeaderRespDTO;
|
|
|
+import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.zjugis.module.system.api.user.AdminUserApi;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+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.*;
|
|
|
+
|
|
|
+import static com.zjugis.business.constants.FlowStatusConstants.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 工作流-实习生录用审批归档
|
|
|
+ *
|
|
|
+ * @author jzh
|
|
|
+ * @since 2024/2/26 13:28
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/intern-event")
|
|
|
+public class InternEvent extends BaseController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private InternService internService;
|
|
|
+ @Autowired
|
|
|
+ WorkflowClient workflowClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DeptApi deptApi;
|
|
|
+ @Resource
|
|
|
+ private DeptLeaderApi deptLeaderApi;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AdminUserApi adminUserApi;
|
|
|
+ @Resource
|
|
|
+ private StaffApi staffApi;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置流程描述
|
|
|
+ *
|
|
|
+ * @param flowInstance 流程实例
|
|
|
+ * @param activityInstance 活动实例
|
|
|
+ */
|
|
|
+ @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();
|
|
|
+ InternDO entity = internService.findByInstanceId(flowInstanceId);
|
|
|
+ String applyTime = LocalDateTimeUtils.format(entity.getCreateTime(), null);
|
|
|
+ String flowDesc = StringUtils.join(Arrays.asList(entity.getNickname(), applyTime, entity.getDeptName()), "/");
|
|
|
+ entity.setFlowStatus(FLOW_PROCESS);
|
|
|
+ internService.update(entity);
|
|
|
+ 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 触发归档的结束活动实例
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @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();
|
|
|
+ InternDO entity = internService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_FINISHED);
|
|
|
+ entity.setFlowFinishtime(LocalDateTime.now());
|
|
|
+ entity.setReport("0");
|
|
|
+ internService.update(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
|
|
|
+ */
|
|
|
+ @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();
|
|
|
+ InternDO entity = internService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_NULLY);
|
|
|
+ entity.setIsvalid(0);
|
|
|
+ internService.update(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
|
|
|
+ */
|
|
|
+ @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();
|
|
|
+ InternDO entity = internService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_PROCESS);
|
|
|
+ entity.setIsvalid(1);
|
|
|
+ internService.update(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
|
|
|
+ */
|
|
|
+ @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();
|
|
|
+ InternDO entity = internService.findByInstanceId(flowInstanceId);
|
|
|
+ internService.delete(entity.getId());
|
|
|
+ return ok("true");
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转到部门经理
|
|
|
+ */
|
|
|
+ @PostMapping("/to-dept-manager")
|
|
|
+ public String toDeptManager(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ InternDO entity = internService.findByInstanceId(flowInstanceId);
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(entity.getDeptId())) {
|
|
|
+ CommonResult<DeptRespDTO> result = deptApi.getDept(entity.getDeptId());
|
|
|
+ DeptRespDTO dept = result.getCheckedData();
|
|
|
+ if (dept != null && StringUtils.isNotBlank(dept.getLeaderUserId())) {
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", dept.getLeaderUserId());
|
|
|
+ userMaps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("找不到流程id");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转到分管领导
|
|
|
+ */
|
|
|
+ @PostMapping("/to-dept-manager-leader")
|
|
|
+ public String toDeptManagerLeader(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ InternDO entity = internService.findByInstanceId(flowInstanceId);
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(entity.getDeptId())) {
|
|
|
+ DeptLeaderRespDTO deptLeaderRespDTO = deptLeaderApi.getDeptLeaderByDeptId(entity.getDeptId()).getCheckedData();
|
|
|
+ if (deptLeaderRespDTO != null && StringUtils.isNotBlank(deptLeaderRespDTO.getUserId())) {
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", deptLeaderRespDTO.getUserId());
|
|
|
+ userMaps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("找不到流程id");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|