|
|
@@ -0,0 +1,524 @@
|
|
|
+/**
|
|
|
+ * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
|
|
+ */
|
|
|
+package com.jeeplus.modules.workprojectnotify.web;
|
|
|
+
|
|
|
+import com.jeeplus.common.web.BaseController;
|
|
|
+import com.jeeplus.modules.act.entity.Act;
|
|
|
+import com.jeeplus.modules.act.service.ActTaskService;
|
|
|
+import com.jeeplus.modules.sys.entity.User;
|
|
|
+import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
+import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
|
|
|
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
|
|
|
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
|
|
|
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
|
|
|
+import com.jeeplus.modules.workreimbursement.entity.WorkReimbursement;
|
|
|
+import com.jeeplus.modules.workreimbursement.service.WorkReimbursementNewService;
|
|
|
+import com.jeeplus.modules.workreimbursement.service.WorkReimbursementService;
|
|
|
+import org.activiti.engine.runtime.ProcessInstance;
|
|
|
+import org.activiti.engine.task.Task;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 待办管理-批量报销审批Controller
|
|
|
+ * 用于批量处理和一键处理报销待办数据
|
|
|
+ *
|
|
|
+ * 核心设计:从数据库查询每条报销数据的实际processKey,根据processKey分发到对应的处理方法。
|
|
|
+ * 不同type对应不同的BPMN流程定义(processKey),taskDefKey和审批人判定逻辑各不相同,
|
|
|
+ * 不能通过条件猜测processKey,必须从WorkActivityProcess表中读取实际值。
|
|
|
+ *
|
|
|
+ * processKey与处理方法映射关系:
|
|
|
+ * - newReimbursement → type=13旧报销 → WorkReimbursementService.auditSave
|
|
|
+ * - newReimbursementTwo → type=102新报销 → WorkReimbursementNewService.auditSave
|
|
|
+ * - newReimbursementThree → type=108三期报销 → WorkReimbursementNewService.auditSaveThree
|
|
|
+ * - reimbursementThree → type=112三期报销 → WorkReimbursementNewService.auditSaveReimbursementThree
|
|
|
+ * - electronicInvoiceReimbursement → type=106电子发票 → WorkReimbursementNewService.electronicInvoiceReimbursementAuditSave
|
|
|
+ * - electronicInvoiceReimbursement(109) → type=109电子发票三期 → WorkReimbursementNewService.electronicInvoiceReimbursementThreeAuditSave
|
|
|
+ * - specificInvoiceReimbursement → type=107四部报销 → WorkReimbursementNewService.auditSpecificSave
|
|
|
+ *
|
|
|
+ * @author auto
|
|
|
+ * @version 2026-07-15
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/workprojectnotify/workProjectNotifyBatch")
|
|
|
+public class WorkProjectNotifyBatchController extends BaseController {
|
|
|
+
|
|
|
+ private Logger logger = LoggerFactory.getLogger(WorkProjectNotifyBatchController.class);
|
|
|
+
|
|
|
+ /** 报销相关类型集合 */
|
|
|
+ private static final Set<String> REIMBURSEMENT_TYPES = new HashSet<>(
|
|
|
+ Arrays.asList("13", "102", "106", "107", "108", "109", "112")
|
|
|
+ );
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkProjectNotifyService workProjectNotifyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkReimbursementService workReimbursementService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkReimbursementNewService workReimbursementNewService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ActTaskService actTaskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkActivityProcessDao workActivityProcessDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量审批报销待办(处理勾选的数据)
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "batchApprove")
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("workprojectnotify:batch:approve")
|
|
|
+ public Map<String, Object> batchApprove(@RequestBody List<String> notifyIds) {
|
|
|
+ int successCount = 0;
|
|
|
+ int failCount = 0;
|
|
|
+
|
|
|
+ for (String notifyId : notifyIds) {
|
|
|
+ try {
|
|
|
+ boolean result = processSingleNotify(notifyId);
|
|
|
+ if (result) {
|
|
|
+ successCount++;
|
|
|
+ } else {
|
|
|
+ failCount++;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ failCount++;
|
|
|
+ logger.error("批量审批失败, notifyId: {}, error: {}", notifyId, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("success", true);
|
|
|
+ resultMap.put("totalCount", notifyIds.size());
|
|
|
+ resultMap.put("successCount", successCount);
|
|
|
+ resultMap.put("failCount", failCount);
|
|
|
+ resultMap.put("msg", "处理完成!成功" + successCount + "条,失败" + failCount + "条");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 一键审批所有报销待办(处理全量数据)
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "approveAll")
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("workprojectnotify:batch:approveAll")
|
|
|
+ public Map<String, Object> approveAll() {
|
|
|
+ List<String> reimbursementNotifyIds = findAllReimbursementNotifyIds();
|
|
|
+ if (reimbursementNotifyIds.isEmpty()) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("success", true);
|
|
|
+ resultMap.put("totalCount", 0);
|
|
|
+ resultMap.put("successCount", 0);
|
|
|
+ resultMap.put("failCount", 0);
|
|
|
+ resultMap.put("msg", "没有需要处理的报销待办");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ return batchApprove(reimbursementNotifyIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询所有待审批的报销通知ID
|
|
|
+ */
|
|
|
+ private List<String> findAllReimbursementNotifyIds() {
|
|
|
+ User user = UserUtils.getUser();
|
|
|
+ WorkProjectNotify query = new WorkProjectNotify();
|
|
|
+ query.setUser(user);
|
|
|
+ query.setCompanyId(UserUtils.getSelectCompany().getId());
|
|
|
+ query.setRemarks("待审批");
|
|
|
+
|
|
|
+ List<WorkProjectNotify> allList = workProjectNotifyService.findList(query);
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ for (WorkProjectNotify notify : allList) {
|
|
|
+ if (REIMBURSEMENT_TYPES.contains(notify.getType())) {
|
|
|
+ if (notify.getTitle() != null && notify.getTitle().contains("报销")) {
|
|
|
+ result.add(notify.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理单条报销待办通知
|
|
|
+ * 核心逻辑:从WorkActivityProcess表查出实际processKey,根据processKey分发处理
|
|
|
+ */
|
|
|
+ private boolean processSingleNotify(String notifyId) {
|
|
|
+ WorkProjectNotify notify = workProjectNotifyService.get(notifyId);
|
|
|
+ if (notify == null) {
|
|
|
+ logger.warn("待办记录不存在, notifyId: {}", notifyId);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!REIMBURSEMENT_TYPES.contains(notify.getType())) {
|
|
|
+ logger.warn("非报销类型, notifyId: {}, type: {}", notifyId, notify.getType());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (notify.getTitle() == null || !notify.getTitle().contains("报销")) {
|
|
|
+ logger.warn("标题不包含报销, notifyId: {}, title: {}", notifyId, notify.getTitle());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ WorkReimbursement workReimbursement = workReimbursementService.get(notify.getNotifyId());
|
|
|
+ if (workReimbursement == null) {
|
|
|
+ logger.warn("报销实体不存在, notifyId: {}, notifyRecordId: {}", notifyId, notify.getNotifyId());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ Act act = getByAct(workReimbursement.getProcessInstanceId());
|
|
|
+ if (act == null || act.getTaskId() == null) {
|
|
|
+ logger.warn("无法获取流程任务信息, notifyId: {}, processInstanceId: {}", notifyId, workReimbursement.getProcessInstanceId());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ workReimbursement.setAct(act);
|
|
|
+ act.setFlag("yes");
|
|
|
+ act.setComment("[批量审批同意]");
|
|
|
+
|
|
|
+ // 从数据库查询实际的processKey
|
|
|
+ String processKey = getProcessKeyFromDb(workReimbursement.getProcessInstanceId());
|
|
|
+ if (StringUtils.isBlank(processKey)) {
|
|
|
+ logger.warn("无法获取processKey, notifyId: {}, processInstanceId: {}", notifyId, workReimbursement.getProcessInstanceId());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ String taskDefKey = act.getTaskDefKey();
|
|
|
+ String processInstanceId = workReimbursement.getProcessInstanceId();
|
|
|
+
|
|
|
+ // 根据processKey分发到对应的处理方法
|
|
|
+ switch (processKey) {
|
|
|
+ case "newReimbursement":
|
|
|
+ return processByProcessKey_newReimbursement(workReimbursement, taskDefKey, processInstanceId, notifyId);
|
|
|
+ case "newReimbursementTwo":
|
|
|
+ return processByProcessKey_newReimbursementTwo(workReimbursement, taskDefKey, processInstanceId, notifyId);
|
|
|
+ case "newReimbursementThree":
|
|
|
+ return processByProcessKey_newReimbursementThree(workReimbursement, taskDefKey, processInstanceId, notifyId);
|
|
|
+ case "reimbursementThree":
|
|
|
+ return processByProcessKey_reimbursementThree(workReimbursement, taskDefKey, processInstanceId, notifyId);
|
|
|
+ case "electronicInvoiceReimbursement":
|
|
|
+ return processByProcessKey_electronicInvoiceReimbursement(workReimbursement, taskDefKey, processInstanceId, notifyId);
|
|
|
+ case "specificInvoiceReimbursement":
|
|
|
+ return processByProcessKey_specificInvoiceReimbursement(workReimbursement, taskDefKey, processInstanceId, notifyId);
|
|
|
+ default:
|
|
|
+ logger.warn("未知的processKey: {}, notifyId: {}", processKey, notifyId);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从WorkActivityProcess表查询实际的processKey
|
|
|
+ */
|
|
|
+ private String getProcessKeyFromDb(String processInstanceId) {
|
|
|
+ List<WorkActivityProcess> list = workActivityProcessDao.getByProcessInstanceId(processInstanceId);
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ for (WorkActivityProcess p : list) {
|
|
|
+ if (StringUtils.isNotBlank(p.getProcessKey())) {
|
|
|
+ return p.getProcessKey();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================== processKey=newReimbursement (type=13 旧报销) ======================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * processKey=newReimbursement,对应type=13旧报销
|
|
|
+ * save方法: WorkReimbursementService.save
|
|
|
+ * audit方法: WorkReimbursementService.auditSave
|
|
|
+ * taskDefKey: bmzr, cw, modifyApply
|
|
|
+ */
|
|
|
+ private boolean processByProcessKey_newReimbursement(WorkReimbursement wr, String taskDefKey, String procInsId, String notifyId) {
|
|
|
+ List<User> users = null;
|
|
|
+ if ("bmzr".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 2);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByRoleActivityEnname("cwzg", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else if ("cw".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ }
|
|
|
+ if (users == null || users.isEmpty()) {
|
|
|
+ logger.warn("newReimbursement 审批人为空, notifyId: {}, taskDefKey: {}", notifyId, taskDefKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ workReimbursementService.auditSave(wr, users);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================== processKey=newReimbursementTwo (type=102) ======================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * processKey=newReimbursementTwo,对应type=102
|
|
|
+ * save方法: WorkReimbursementNewService.save
|
|
|
+ * audit方法: WorkReimbursementNewService.auditSave
|
|
|
+ * taskDefKey: bmzr, cw, gsld, modifyApply
|
|
|
+ */
|
|
|
+ private boolean processByProcessKey_newReimbursementTwo(WorkReimbursement wr, String taskDefKey, String procInsId, String notifyId) {
|
|
|
+ List<User> users = null;
|
|
|
+ if ("bmzr".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 2);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByRoleActivityEnname("cwzg", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else if ("cw".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("gsld".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ }
|
|
|
+ if (users == null || users.isEmpty()) {
|
|
|
+ logger.warn("newReimbursementTwo 审批人为空, notifyId: {}, taskDefKey: {}", notifyId, taskDefKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ workReimbursementNewService.auditSave(wr, users);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================== processKey=newReimbursementThree (type=108/109) ======================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * processKey=newReimbursementThree,对应type=108或type=109
|
|
|
+ * save方法: saveReimburseThree(108) 或 electronicInvoiceReimbursementThreeSave(109)
|
|
|
+ * audit方法: auditSaveThree(108) 或 electronicInvoiceReimbursementThreeAuditSave(109)
|
|
|
+ * taskDefKey: bmzr, cw, fpglys, dzfpbxshybxsd, gsld, modifyApply
|
|
|
+ */
|
|
|
+ private boolean processByProcessKey_newReimbursementThree(WorkReimbursement wr, String taskDefKey, String procInsId, String notifyId) {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ LocalDate reimburseLocalDate = LocalDate.of(2024, 2, 21);
|
|
|
+ Date reimburseAuditDate = Date.from(reimburseLocalDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
|
|
|
+ int reimburseResult = wr.getCreateDate().compareTo(reimburseAuditDate);
|
|
|
+
|
|
|
+ List<User> users = null;
|
|
|
+ if ("bmzr".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ if ("0".equals(wr.getReimbursementType())) {
|
|
|
+ if (reimburseResult > 0) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("dzfpbxshybxsd", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("zjbfzribvf", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ } else if ("1".equals(wr.getReimbursementType())) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("dzfpbxshybxsd", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ } else if ("cw".equals(taskDefKey)) {
|
|
|
+ if ("d8cf33fafd2d4f04a603e89f7e28e54c".equals(wr.getOfficeId())) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("bmzr", 2, "7f776d072d7b4c839cef4e63ce6dbfa5", "8", wr.getCreateBy());
|
|
|
+ } else if ("5adafaaa43ab4a11801f9ad264374a06".equals(wr.getOfficeId())) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("bmzr", 2, "6c9ca86e941b4a738c1ab9b006976264", "8", wr.getCreateBy());
|
|
|
+ } else {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("bmzr", 2, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ } else if ("gsld".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("fpglys".equals(taskDefKey) || "dzfpbxshybxsd".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (reimburseResult > 0) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("zjbfzribvf", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ }
|
|
|
+ if (users == null || users.isEmpty()) {
|
|
|
+ logger.warn("newReimbursementThree 审批人为空, notifyId: {}, taskDefKey: {}", notifyId, taskDefKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据reimbursementType区分调用哪个auditSave方法
|
|
|
+ // type=109 电子发票三期 → electronicInvoiceReimbursementThreeAuditSave
|
|
|
+ // type=108 普通三期 → auditSaveThree
|
|
|
+ if ("1".equals(wr.getReimbursementType())) {
|
|
|
+ workReimbursementNewService.electronicInvoiceReimbursementThreeAuditSave(wr, users);
|
|
|
+ } else {
|
|
|
+ workReimbursementNewService.auditSaveThree(wr, users);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================== processKey=reimbursementThree (type=112) ======================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * processKey=reimbursementThree,对应type=112
|
|
|
+ * save方法: WorkReimbursementNewService.saveReimbursementThree
|
|
|
+ * audit方法: WorkReimbursementNewService.auditSaveReimbursementThree
|
|
|
+ * taskDefKey: cw, bmzr, fpglys, dzfpbxshybxsd, gsld, modifyApply
|
|
|
+ */
|
|
|
+ private boolean processByProcessKey_reimbursementThree(WorkReimbursement wr, String taskDefKey, String procInsId, String notifyId) {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ LocalDate reimburseLocalDate = LocalDate.of(2024, 2, 21);
|
|
|
+ Date reimburseAuditDate = Date.from(reimburseLocalDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
|
|
|
+ int reimburseResult = wr.getCreateDate().compareTo(reimburseAuditDate);
|
|
|
+
|
|
|
+ List<User> users = null;
|
|
|
+ if ("bmzr".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ if ("0".equals(wr.getReimbursementType())) {
|
|
|
+ if (reimburseResult > 0) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("dzfpbxshybxsd", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("zjbfzribvf", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ } else if ("1".equals(wr.getReimbursementType())) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("dzfpbxshybxsd", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ } else if ("cw".equals(taskDefKey)) {
|
|
|
+ if ("d8cf33fafd2d4f04a603e89f7e28e54c".equals(wr.getOfficeId())) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("bmzr", 2, "7f776d072d7b4c839cef4e63ce6dbfa5", "8", wr.getCreateBy());
|
|
|
+ } else if ("5adafaaa43ab4a11801f9ad264374a06".equals(wr.getOfficeId())) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("bmzr", 2, "6c9ca86e941b4a738c1ab9b006976264", "8", wr.getCreateBy());
|
|
|
+ } else {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("bmzr", 2, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ } else if ("gsld".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("fpglys".equals(taskDefKey) || "dzfpbxshybxsd".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (reimburseResult > 0) {
|
|
|
+ users = UserUtils.getByRoleActivityEnname("zjbfzribvf", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ }
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ }
|
|
|
+ if (users == null || users.isEmpty()) {
|
|
|
+ logger.warn("reimbursementThree 审批人为空, notifyId: {}, taskDefKey: {}", notifyId, taskDefKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ workReimbursementNewService.auditSaveReimbursementThree(wr, users);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================== processKey=electronicInvoiceReimbursement (type=106) ======================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * processKey=electronicInvoiceReimbursement,对应type=106电子发票报销
|
|
|
+ * save方法: WorkReimbursementNewService.electronicInvoiceReimbursementSave
|
|
|
+ * audit方法: WorkReimbursementNewService.electronicInvoiceReimbursementAuditSave
|
|
|
+ * taskDefKey: bmzr, cw, fpglys, modifyApply
|
|
|
+ */
|
|
|
+ private boolean processByProcessKey_electronicInvoiceReimbursement(WorkReimbursement wr, String taskDefKey, String procInsId, String notifyId) {
|
|
|
+ List<User> users = null;
|
|
|
+ if ("bmzr".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 2);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByRoleActivityEnname("cwzg", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else if ("cw".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ users = UserUtils.getByRoleActivityEnname("cwygevod", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else if ("fpglys".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ }
|
|
|
+ if (users == null || users.isEmpty()) {
|
|
|
+ logger.warn("electronicInvoiceReimbursement 审批人为空, notifyId: {}, taskDefKey: {}", notifyId, taskDefKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ workReimbursementNewService.electronicInvoiceReimbursementAuditSave(wr, users);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================== processKey=specificInvoiceReimbursement (type=107) ======================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * processKey=specificInvoiceReimbursement,对应type=107四部报销
|
|
|
+ * save方法: WorkReimbursementNewService.specificInvoiceReimbursementSave
|
|
|
+ * audit方法: WorkReimbursementNewService.auditSpecificSave
|
|
|
+ * taskDefKey: bmzr, fpglys, modifyApply
|
|
|
+ */
|
|
|
+ private boolean processByProcessKey_specificInvoiceReimbursement(WorkReimbursement wr, String taskDefKey, String procInsId, String notifyId) {
|
|
|
+ List<User> users = null;
|
|
|
+ if ("bmzr".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 2);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByRoleActivityEnname("cwzg", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else if ("cw".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ users = UserUtils.getByRoleActivityEnname("cwygevod", 3, wr.getOfficeId(), "8", wr.getCreateBy());
|
|
|
+ } else if ("fpglys".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 3);
|
|
|
+ if (users == null)
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)) {
|
|
|
+ users = UserUtils.getByProssType(procInsId, 1);
|
|
|
+ }
|
|
|
+ if (users == null || users.isEmpty()) {
|
|
|
+ logger.warn("specificInvoiceReimbursement 审批人为空, notifyId: {}, taskDefKey: {}", notifyId, taskDefKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ workReimbursementNewService.auditSpecificSave(wr, users);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================== 公共方法 ======================
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前流程任务信息
|
|
|
+ * 复制自 WorkProjectNotifyController.getByAct
|
|
|
+ */
|
|
|
+ private Act getByAct(String processInstanceId) {
|
|
|
+ Act act = new Act();
|
|
|
+ ProcessInstance processInstance = actTaskService.getProcIns(processInstanceId);
|
|
|
+ if (processInstance != null) {
|
|
|
+ List<Task> taskList = actTaskService.getCurrentTaskList(processInstance);
|
|
|
+ if (taskList != null && taskList.size() > 1) {
|
|
|
+ for (Task taskInfok : taskList) {
|
|
|
+ if (UserUtils.getUser().getId().equals(taskInfok.getAssignee())) {
|
|
|
+ act.setTaskId(taskInfok.getId());
|
|
|
+ act.setTaskName(taskInfok.getName());
|
|
|
+ act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
|
|
|
+ act.setProcDefId(taskInfok.getProcessDefinitionId());
|
|
|
+ act.setProcInsId(taskInfok.getProcessInstanceId());
|
|
|
+ act.setTask(taskInfok);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (taskList != null && !taskList.isEmpty()) {
|
|
|
+ Task task = actTaskService.getCurrentTaskInfo(processInstance);
|
|
|
+ act.setTaskId(task.getId());
|
|
|
+ act.setTaskName(task.getName());
|
|
|
+ act.setTaskDefKey(task.getTaskDefinitionKey());
|
|
|
+ act.setProcDefId(task.getProcessDefinitionId());
|
|
|
+ act.setProcInsId(task.getProcessInstanceId());
|
|
|
+ act.setTask(task);
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return act;
|
|
|
+ }
|
|
|
+}
|