|
@@ -0,0 +1,285 @@
|
|
|
+package com.zjugis.business.flow.officialSeal.event;
|
|
|
+
|
|
|
+
|
|
|
+import com.zjugis.business.constants.OfficialSealNameConstants;
|
|
|
+import com.zjugis.business.constants.PostConstants;
|
|
|
+import com.zjugis.business.converter.officialSeal.OfficialSealOuterConvert;
|
|
|
+import com.zjugis.business.converter.officialSeal.OfficialSealUseConvert;
|
|
|
+import com.zjugis.business.flow.officialSeal.entity.OfficialSealOuterDO;
|
|
|
+import com.zjugis.business.flow.officialSeal.entity.OfficialSealUseDO;
|
|
|
+import com.zjugis.business.flow.officialSeal.service.OfficialSealOuterService;
|
|
|
+import com.zjugis.business.flow.officialSeal.service.OfficialSealUseService;
|
|
|
+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.system.api.dept.DeptApi;
|
|
|
+import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.zjugis.module.system.api.permission.RoleApi;
|
|
|
+import com.zjugis.module.system.api.user.AdminUserApi;
|
|
|
+import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
+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.*;
|
|
|
+
|
|
|
+import static com.zjugis.business.constants.FlowStatusConstants.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zjq
|
|
|
+ * @since 2024-03-15
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/officialSealOuter-event")
|
|
|
+public class OfficialSealOuterEvent extends BaseController {
|
|
|
+
|
|
|
+ public static final Logger log = LoggerFactory.getLogger(OfficialSealOuterEvent.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OfficialSealOuterService officialSealOuterService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private WorkflowClient workflowClient;
|
|
|
+ @Resource
|
|
|
+ private RoleApi roleApi;
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+ @Resource
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置流程描述
|
|
|
+ *
|
|
|
+ * @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();
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ String applyTime = LocalDateTimeUtils.format(entity.getCreateTime(), null);
|
|
|
+ String flowDesc = StringUtils.join(Arrays.asList(entity.getUserNickname(), applyTime, entity.getDeptName()), "/");
|
|
|
+ entity.setFlowStatus(FLOW_PROCESS);
|
|
|
+ officialSealOuterService.updateOfficialSeal(OfficialSealOuterConvert.INSTANCE.convert(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 触发归档的结束活动实例
|
|
|
+ * @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();
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_FINISHED);
|
|
|
+ entity.setFlowFinishtime(LocalDateTime.now());
|
|
|
+ officialSealOuterService.updateOfficialSeal(OfficialSealOuterConvert.INSTANCE.convert(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();
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_NULLY);
|
|
|
+ entity.setIsvalid(0);
|
|
|
+ officialSealOuterService.updateOfficialSeal(OfficialSealOuterConvert.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();
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_PROCESS);
|
|
|
+ entity.setIsvalid(1);
|
|
|
+ officialSealOuterService.updateOfficialSeal(OfficialSealOuterConvert.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();
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ officialSealOuterService.deleteOfficialSeal(entity.getId());
|
|
|
+ return ok("true");
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 部门经理
|
|
|
+ *
|
|
|
+ * @param flowInstanceId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/to-dept-manager")
|
|
|
+ public String toDeptManager(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ DeptRespDTO deptRespDTO = deptApi.getDept(entity.getDeptId()).getCheckedData();
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", deptRespDTO.getLeaderUserId());
|
|
|
+ userMaps.add(map);
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分管部门领导
|
|
|
+ * @param flowInstanceId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/to-dept-manager-leader")
|
|
|
+ public String toDeptManagerLeader(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ DeptRespDTO deptRespDTO = deptApi.getDept(entity.getDeptId()).getCheckedData();
|
|
|
+
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ AdminUserRespDTO userLeader = adminUserApi.getUserLeader(deptRespDTO.getLeaderUserId()).getCheckedData();
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", userLeader.getId());
|
|
|
+ userMaps.add(map);
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用章参与人
|
|
|
+ *
|
|
|
+ * @param flowInstanceId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/use-people")
|
|
|
+ public String userOfficialSealFlow1(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ OfficialSealOuterDO entity = officialSealOuterService.findByInstanceId(flowInstanceId);
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if (entity.getOfficialSealName().equals(OfficialSealNameConstants.WW) || entity.getOfficialSealName().equals(OfficialSealNameConstants.WW_JS)) {
|
|
|
+ int pId = entity.getOfficialSealName().equals(OfficialSealNameConstants.WW) ? PostConstants.OFFICIAL_SEAL_MANAGER : PostConstants.JIANGSU_OFFICIAL_SEAL_MANAGER;
|
|
|
+ Collection<Long> collection = new ArrayList<>();
|
|
|
+ collection.add(Long.valueOf(pId));
|
|
|
+ List<AdminUserRespDTO> userList = adminUserApi.getUserListByPostIds(collection).getCheckedData();
|
|
|
+ for (AdminUserRespDTO adminUserRespDTO : userList) {
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("id", adminUserRespDTO.getId());
|
|
|
+ userMaps.add(map);
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|