|
@@ -0,0 +1,186 @@
|
|
|
+package com.zjugis.business.flow.leave.event;
|
|
|
+
|
|
|
+import com.google.common.base.Strings;
|
|
|
+import com.zjugis.business.converter.leave.LeaveConvert;
|
|
|
+import com.zjugis.business.flow.leave.entity.LeaveDO;
|
|
|
+import com.zjugis.business.flow.leave.entity.LeaveTimeDO;
|
|
|
+import com.zjugis.business.flow.leave.service.LeaveService;
|
|
|
+import com.zjugis.business.flow.leave.service.LeaveTimeService;
|
|
|
+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.spring.resovler.ParamModel;
|
|
|
+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.LocalDate;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author 陈俊
|
|
|
+ * @Date 2023/11/21 17:51
|
|
|
+ * @Version 1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/leave-event")
|
|
|
+public class LeaveEvent extends BaseController {
|
|
|
+
|
|
|
+ public static final Logger log = LoggerFactory.getLogger(LeaveEvent.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private LeaveService leaveService;
|
|
|
+ @Resource
|
|
|
+ private LeaveTimeService leaveTimeService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置流程描述
|
|
|
+ *
|
|
|
+ * @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();
|
|
|
+ LeaveDO entity = leaveService.findByInstanceId(flowInstanceId);
|
|
|
+ String flowDesc = "";
|
|
|
+ if (!Strings.isNullOrEmpty(entity.getDeptName())) {
|
|
|
+ flowDesc += "/" + entity.getDeptName();
|
|
|
+ }
|
|
|
+ if (!Strings.isNullOrEmpty(entity.getUserNickname())) {
|
|
|
+ flowDesc += "/" + entity.getUserNickname();
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setFlowStatus(1);
|
|
|
+ leaveService.updateLeave(LeaveConvert.INSTANCE.convert(entity));
|
|
|
+ flowDesc = flowDesc.length() > 1 ? flowDesc.substring(1) : flowDesc;
|
|
|
+// String result = E_FlowUtils.setFlowDesc(flowDesc, flowInstanceId);
|
|
|
+ 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();
|
|
|
+ LeaveDO entity = leaveService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(90);
|
|
|
+ entity.setFlowFinishtime(LocalDate.now());
|
|
|
+ leaveService.updateLeave(LeaveConvert.INSTANCE.convert(entity));
|
|
|
+ //根据请假情况修改考勤表
|
|
|
+ List<LeaveTimeDO> leaveTimeDOList = leaveTimeService.getListByLeaveId(entity.getId());
|
|
|
+ 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();
|
|
|
+ LeaveDO entity = leaveService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(20);
|
|
|
+ entity.setIsvalid(0);
|
|
|
+ leaveService.updateLeave(LeaveConvert.INSTANCE.convert(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();
|
|
|
+ LeaveDO entity = leaveService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(1);
|
|
|
+ entity.setIsvalid(1);
|
|
|
+ leaveService.updateLeave(LeaveConvert.INSTANCE.convert(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();
|
|
|
+ LeaveDO entity = leaveService.findByInstanceId(flowInstanceId);
|
|
|
+ leaveService.deleteLeave(entity.getId());
|
|
|
+ return ok("true");
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|