|
@@ -0,0 +1,402 @@
|
|
|
+package com.zjugis.business.flow.resignApply.event;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.zjugis.business.constants.StaffStateConstants;
|
|
|
+import com.zjugis.business.flow.resign.dao.ResignDAO;
|
|
|
+import com.zjugis.business.flow.resign.entity.ResignDO;
|
|
|
+import com.zjugis.business.flow.resign.entity.ResignDetailDO;
|
|
|
+import com.zjugis.business.flow.resign.service.ResignDetailService;
|
|
|
+import com.zjugis.business.flow.resign.service.ResignService;
|
|
|
+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.adm.api.staff.dto.StaffStateDTO;
|
|
|
+import com.zjugis.module.system.api.dept.DeptApi;
|
|
|
+import com.zjugis.module.system.api.dept.DeptLeaderApi;
|
|
|
+import com.zjugis.module.system.api.user.AdminUserApi;
|
|
|
+import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+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.*;
|
|
|
+import static com.zjugis.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author jzh
|
|
|
+ * @since 2024/2/26 13:28
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/resignApply-event")
|
|
|
+public class ResignApplyEvent extends BaseController {
|
|
|
+
|
|
|
+ @Value("${resign.data.softDeptIds}")
|
|
|
+ private String softDeptIds;
|
|
|
+
|
|
|
+ @Value("${resign.data.planDeptIds}")
|
|
|
+ private String planDeptIds;
|
|
|
+
|
|
|
+ @Value("${resign.data.softPostIds}")
|
|
|
+ private String softPostIds;
|
|
|
+
|
|
|
+ @Value("${resign.data.planDeptIds}")
|
|
|
+ private String planPostIds;
|
|
|
+
|
|
|
+ @Value("${resign.data.checkDeptIds}")
|
|
|
+ private String checkDeptIds;
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ResignDAO resignDAO;
|
|
|
+ @Resource
|
|
|
+ private ResignDetailService resignDetailService;
|
|
|
+ @Resource
|
|
|
+ private ResignService resignService;
|
|
|
+ @Resource
|
|
|
+ private StaffApi staffApi;
|
|
|
+ @Autowired
|
|
|
+ WorkflowClient workflowClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DeptApi deptApi;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AdminUserApi adminUserApi;
|
|
|
+ @Resource
|
|
|
+ private DeptLeaderApi deptLeaderApi;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置流程描述
|
|
|
+ *
|
|
|
+ * @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();
|
|
|
+ ResignDO entity = resignService.findByInstanceId(flowInstanceId);
|
|
|
+ String applyTime = LocalDateTimeUtils.format(entity.getCreateTime(), null);
|
|
|
+ String flowDesc = StringUtils.join(Arrays.asList(entity.getNickname(), applyTime, entity.getDeptName()), "/");
|
|
|
+ entity.setFlowStatus(FLOW_PROCESS);
|
|
|
+ resignDAO.updateById(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
|
|
|
+ */
|
|
|
+ @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();
|
|
|
+ ResignDO entity = resignDAO.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_FINISHED);
|
|
|
+ entity.setFlowFinishtime(LocalDateTime.now());
|
|
|
+ resignDAO.updateById(entity);
|
|
|
+
|
|
|
+ //数据归档 更新员工状态并员工账号
|
|
|
+ StaffStateDTO dto = new StaffStateDTO();
|
|
|
+ dto.setUserId(entity.getUserId());
|
|
|
+ dto.setState(StaffStateConstants.RESIGN);
|
|
|
+ CommonResult<String> res = staffApi.updateStaffState(dto);
|
|
|
+ res.getCheckedData();
|
|
|
+ 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();
|
|
|
+ ResignDO entity = resignDAO.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_NULLY);
|
|
|
+ entity.setIsvalid(0);
|
|
|
+ resignDAO.updateById(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();
|
|
|
+ ResignDO entity = resignDAO.findByInstanceId(flowInstanceId);
|
|
|
+ entity.setFlowStatus(FLOW_PROCESS);
|
|
|
+ entity.setIsvalid(1);
|
|
|
+ resignDAO.updateById(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();
|
|
|
+ ResignDO entity = resignService.findByInstanceId(flowInstanceId);
|
|
|
+ resignService.delete(entity.getId());
|
|
|
+ return ok("true");
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工作接收人
|
|
|
+ *
|
|
|
+ * @param flowInstanceId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/workReceiver")
|
|
|
+ public String unfinishedReceiver(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ ResignDO entity = resignService.findByInstanceId(flowInstanceId);
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ List<ResignDetailDO> detailDOS = resignDetailService.getListByResignId(entity.getId());
|
|
|
+ if (CollectionUtil.isNotEmpty(detailDOS)) {
|
|
|
+ Set<String> ids = convertSet(detailDOS, ResignDetailDO::getReceiver);
|
|
|
+
|
|
|
+
|
|
|
+ ids.forEach(v -> {
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ if (v != null) {
|
|
|
+ map.put("id", v);
|
|
|
+ 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("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据中心接收人
|
|
|
+ */
|
|
|
+ @PostMapping("/dataReceiver")
|
|
|
+ public String dataReceiver(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ ResignDO entity = resignService.findByInstanceId(flowInstanceId);
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ String deptId = deptApi.getSecondDeptByDeptId(entity.getDeptId()).getCheckedData().getId();
|
|
|
+ if (deptId != null) {
|
|
|
+ List<AdminUserRespDTO> users = adminUserApi.getUserListByPostIds(dataLocationCheck(deptId)).getCheckedData();
|
|
|
+ if (CollectionUtil.isNotEmpty(users)) {
|
|
|
+ Set<String> ids = convertSet(users, AdminUserRespDTO::getId);
|
|
|
+
|
|
|
+ ids.forEach(v -> {
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ if (v != null) {
|
|
|
+ map.put("id", v);
|
|
|
+ userMaps.add(map);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否存在
|
|
|
+ */
|
|
|
+ @PostMapping("/location/{type}")
|
|
|
+ public String existLocation(@ParamModel Map flowInstance, @PathVariable String type) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+
|
|
|
+ ResignDO entity = resignService.findByInstanceId(flowInstanceId);
|
|
|
+
|
|
|
+ if (type.equals(entity.getLzygszd())) {
|
|
|
+ return "true";
|
|
|
+ } else {
|
|
|
+ return "false";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断部门是软件板块还是规划板块
|
|
|
+ * 1空间信息/规划/江苏分公司 2其他
|
|
|
+ */
|
|
|
+ @PostMapping("/department/{type}")
|
|
|
+ public String department(@ParamModel Map flowInstance, @PathVariable String type) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+
|
|
|
+
|
|
|
+ ResignDO entity = resignService.findByInstanceId(flowInstanceId);
|
|
|
+ String deptId = deptApi.getSecondDeptByDeptId(entity.getDeptId()).getCheckedData().getId();
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case "1":
|
|
|
+ if (deptCheck(deptId)) {
|
|
|
+ return "true";
|
|
|
+ } else {
|
|
|
+ return "false";
|
|
|
+ }
|
|
|
+ case "2":
|
|
|
+ if (!deptCheck(deptId)) {
|
|
|
+ return "true";
|
|
|
+ } else {
|
|
|
+ return "false";
|
|
|
+ }
|
|
|
+
|
|
|
+ default:
|
|
|
+ return "false";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean deptCheck(String deptId) {
|
|
|
+ return checkDeptIds.contains(deptId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Long> dataLocationCheck(String deptId) {
|
|
|
+ List<Long> postIds = new ArrayList<>();
|
|
|
+ if (softDeptIds.contains(deptId)) {
|
|
|
+ postIds.addAll(convertStringListToLongList(Arrays.asList(softPostIds.split(","))));
|
|
|
+ } else if (planDeptIds.contains(deptId)) {
|
|
|
+ postIds.addAll(convertStringListToLongList(Arrays.asList(planPostIds.split(","))));
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("部门不存在,请联系管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+ return postIds;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static List<Long> convertStringListToLongList(List<String> stringList) {
|
|
|
+ List<Long> longList = new ArrayList<>();
|
|
|
+ for (String item : stringList) {
|
|
|
+ try {
|
|
|
+ Long.parseLong(item);
|
|
|
+ longList.add(Long.valueOf(item));
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new BusinessException("格式转换失败,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return longList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|