Prechádzať zdrojové kódy

Merge branch 'fu-dev' of uskycloud/usky-modules into master

fuyuchuan 1 mesiac pred
rodič
commit
6b59517d50

+ 21 - 11
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkContentServiceImpl.java

@@ -465,6 +465,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
             }
         }
         Integer tenantId = SecurityUtils.getTenantId();
+        Long nowUserId = SecurityUtils.getUserId();
         LocalDate start = null;
         LocalDate end = null;
         List<Integer> reportIds = new ArrayList<>();
@@ -475,6 +476,8 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
         Set<Integer> reportIdsByProject = new HashSet<>();
         Set<Integer> reportIdsSet = new HashSet<>();
 
+        LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
+
         if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
             DateTimeFormatter formatter = null;
             try {
@@ -486,7 +489,6 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
             end = LocalDate.parse(endDate, formatter);
             startDateTime = start.atStartOfDay();
             endDateTime = end.atTime(23, 59, 59);
-            LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
             reportQuery.select(PmWorkReport::getId).eq(PmWorkReport::getReportStatus, 1).between(PmWorkReport::getSubmitDate, startDateTime, endDateTime);
             reportIdsByDate = pmWorkReportMapper.selectList(reportQuery).stream().map(PmWorkReport::getId).collect(Collectors.toSet());
         }
@@ -498,8 +500,8 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
         }
 
         if (userId != null) {
-            LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
-            reportQuery.eq(PmWorkReport::getSubmitterId, userId);
+            reportQuery.eq(PmWorkReport::getSubmitterId, userId)
+                    .and(wrappers -> wrappers.apply("FIND_IN_SET(" + nowUserId + ", cc_to) > 0"));
             reportIdsByUser = pmWorkReportMapper.selectList(reportQuery).stream().map(PmWorkReport::getId).collect(Collectors.toSet());
             if (reportIdsByProject.isEmpty() && reportIdsByUser.isEmpty()) {
                 return returnPage;
@@ -538,8 +540,16 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
         } else if (!reportIdsByDate.isEmpty()) {
             reportIdsSet.addAll(reportIdsByDate);
         }
+
         reportIds = new ArrayList<>(reportIdsSet);
 
+        if (projectAscription == 1) {
+            LambdaQueryWrapper<PmWorkReport> headerQuery = Wrappers.lambdaQuery();
+            headerQuery.in(!reportIds.isEmpty(), PmWorkReport::getId, reportIds)
+                    .and(wrappers -> wrappers.apply("FIND_IN_SET(" + nowUserId + ", cc_to) > 0"));
+            reportIds = pmWorkReportMapper.selectList(headerQuery).stream().map(PmWorkReport::getId).collect(Collectors.toList());
+        }
+
         List<PmWorkContent> pmWorkContentList = new ArrayList<>();
         Long userId2 = SecurityUtils.getUserId();
         List<Long> userIds = new ArrayList<>();
@@ -588,22 +598,22 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
 
         List<Integer> reportIds2 = pmWorkContentList.stream().distinct().map(PmWorkContent::getReportId).collect(Collectors.toList());
 
-        LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
-        reportQuery.eq(PmWorkReport::getTenantId, tenantId).eq(PmWorkReport::getReportStatus, 1);
+        LambdaQueryWrapper<PmWorkReport> reportQuery1 = Wrappers.lambdaQuery();
+        reportQuery1.eq(PmWorkReport::getTenantId, tenantId).eq(PmWorkReport::getReportStatus, 1);
         if (reportId != null && reportId != 0) {
-            reportQuery.eq(PmWorkReport::getId, reportId);
+            reportQuery1.eq(PmWorkReport::getId, reportId);
         } else {
-            reportQuery.in(PmWorkReport::getId, reportIds2);
+            reportQuery1.in(PmWorkReport::getId, reportIds2);
             // 判断上下滑动以及数量
             if (upOrDown != null && slideSum != null && submitDateTime != null) {
                 if (slideSum > 0) {
                     // 向下滑动
                     if (upOrDown == 0) {
-                        reportQuery.lt(PmWorkReport::getSubmitDate, submitDateTime).orderByDesc(PmWorkReport::getSubmitDate);
+                        reportQuery1.lt(PmWorkReport::getSubmitDate, submitDateTime).orderByDesc(PmWorkReport::getSubmitDate);
                     }
                     // 向上滑动
                     else if (upOrDown == 1) {
-                        reportQuery.gt(PmWorkReport::getSubmitDate, submitDateTime).orderByAsc(PmWorkReport::getSubmitDate);
+                        reportQuery1.gt(PmWorkReport::getSubmitDate, submitDateTime).orderByAsc(PmWorkReport::getSubmitDate);
                     } else {
                         throw new BusinessException("上下滑动参数异常");
                     }
@@ -614,11 +624,11 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
                     throw new BusinessException("滑动数量参数必须是大于0正整数");
                 }
             } else {
-                reportQuery.orderByDesc(PmWorkReport::getSubmitDate);
+                reportQuery1.orderByDesc(PmWorkReport::getSubmitDate);
             }
         }
 
-        reportPage = pmWorkReportMapper.selectPage(new Page<>(pageNum, pageSize), reportQuery);
+        reportPage = pmWorkReportMapper.selectPage(new Page<>(pageNum, pageSize), reportQuery1);
         reportList = reportPage.getRecords();
 
         // 查询已读状态

+ 5 - 11
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/OaFbdDocumentService.java

@@ -1,8 +1,8 @@
 package com.usky.oa.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.usky.oa.domain.OaFbdDocument;
 import com.usky.common.mybatis.core.CrudService;
-import org.springframework.stereotype.Component;
 
 /**
  * <p>
@@ -12,19 +12,13 @@ import org.springframework.stereotype.Component;
  * @author fu
  * @since 2025-02-20
  */
-public interface OaFbdDocumentService extends CrudService<OaFbdDocument>{
+public interface OaFbdDocumentService extends CrudService<OaFbdDocument> {
 
     /**
-     * 新增发布申请
-     * @param oaFbdDocument
-     */
-    void add(OaFbdDocument oaFbdDocument);
+     * 新增发布申请 或 更新发布申请
+     **/
+    void addOrUpDate(OaFbdDocument oaFbdDocument, JSONObject node);
 
-    /**
-     * 更新发布申请
-     * @param oaFbdDocument
-     */
-    void update(OaFbdDocument oaFbdDocument);
 
     // 获取审批表数据
     void getOaApproval(OaFbdDocument oaFbdDocument);

+ 3 - 3
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaApprovalServiceImpl.java

@@ -239,7 +239,7 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
                             // 发送消息通知下一步审批人
                             oaSendMessageCenter.sendAsyncMessage(
                                     oaApproval.getCreateBy(),
-                                    Long.valueOf(oaApproval.getProposer()),
+                                    oaApproval.getApprovalUid(),
                                     approval.getId(),
                                     userIds,
                                     3,
@@ -254,7 +254,7 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
                 Long proposerId = Long.valueOf(oaApproval.getProposer());
                 oaSendMessageCenter.sendAsyncMessage(
                         oaApproval.getCreateBy(),
-                        proposerId,
+                        oaApproval.getApprovalUid(),
                         oaApproval.getId(),
                         Collections.singletonList(proposerId),
                         1,
@@ -266,7 +266,7 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
             // 发送消息通知申请人审核不通过
             oaSendMessageCenter.sendAsyncMessage(
                     oaApproval.getCreateBy(),
-                    proposerId,
+                    oaApproval.getApprovalUid(),
                     oaApproval.getId(),
                     Collections.singletonList(proposerId),
                     0,

+ 6 - 2
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaDocumentServiceImpl.java

@@ -204,6 +204,8 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
         queryWrapper.select(OaFormDefinition::getFieldInfo).eq(OaFormDefinition::getId, oaDocument.get("formId"));
         OaFormDefinition oaFormDefinition = oaFormDefinitionMapper.selectOne(queryWrapper);
 
+        JSONObject node = oaDocument.getJSONObject("node");
+
         if (oaFormDefinition == null) {
             throw new BusinessException("新增表单模板不存在!请联系管理员");
         }
@@ -220,7 +222,7 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
                 oaCgdDocumentService.add(JSON.parseObject(oaDocument.toJSONString(), OaCgdDocument.class));
                 break;
             case "FBD":
-                oaFbdDocumentService.add(JSON.parseObject(oaDocument.toJSONString(), OaFbdDocument.class));
+                oaFbdDocumentService.addOrUpDate(JSON.parseObject(oaDocument.toJSONString(), OaFbdDocument.class), node);
                 break;
             default:
                 throw new BusinessException("新增表单模板不存在!请联系管理员");
@@ -236,6 +238,8 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
         OaFormDefinition oaFormDefinition = oaFormDefinitionMapper.selectOne(queryWrapper);
         String sign = oaFormDefinition.getFieldInfo();
 
+        JSONObject node = jsonDocument.getJSONObject("node");
+
         switch (sign) {
             case "QJD":
                 oaQjdDocumentService.updateQjDocument(JSON.parseObject(jsonDocument.toJSONString(), OaQjdDocument.class));
@@ -247,7 +251,7 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
                 oaCgdDocumentService.update(JSON.parseObject(jsonDocument.toJSONString(), OaCgdDocument.class));
                 break;
             case "FBD":
-                oaFbdDocumentService.update(JSON.parseObject(jsonDocument.toJSONString(), OaFbdDocument.class));
+                oaFbdDocumentService.addOrUpDate(JSON.parseObject(jsonDocument.toJSONString(), OaFbdDocument.class), node);
                 break;
             default:
                 throw new BusinessException("单据模板不存在!请联系管理员");

+ 71 - 84
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaFbdDocumentServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usky.oa.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.usky.common.core.exception.BusinessException;
@@ -15,7 +16,6 @@ import com.usky.system.domain.SysUser;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -63,86 +63,74 @@ public class OaFbdDocumentServiceImpl extends AbstractCrudService<OaFbdDocumentM
     private OaApprovalService oaApprovalService;
 
     @Override
-    public void add(OaFbdDocument oaFbdDocument) {
+    public void addOrUpDate(OaFbdDocument oaFbdDocument, JSONObject node) {
         // 校验表单数据
         validateDocument(oaFbdDocument);
 
-        Long userId = SecurityUtils.getUserId();
-        String username = SecurityUtils.getUsername();
-        Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
-        Integer tenantId = SecurityUtils.getTenantId();
-
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMddHHmmss");
-        LocalDateTime now = LocalDateTime.now();
-        String formattedDate = now.format(formatter);
-
-        LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.select(OaFormDefinition::getFormSign).eq(OaFormDefinition::getId, oaFbdDocument.getFormId());
-        OaFormDefinition oaFormDefinition = oaFormDefinitionMapper.selectOne(queryWrapper);
-        String sign = oaFormDefinition.getFormSign();
-        String docNo = sign + "-" + formattedDate;
-
-        // 插入发布表数据
-        oaFbdDocument.setDocNo(docNo);
-        oaFbdDocument.setProposer(userId);
-        oaFbdDocument.setCreateBy(username);
-        oaFbdDocument.setCreateTime(now);
-        oaFbdDocument.setDeptId(deptId);
-        oaFbdDocument.setTenantId(tenantId);
-        oaFbdDocumentMapper.insert(oaFbdDocument);
-
-        // 插入单据表数据
-        OaDocument oaDocument = new OaDocument();
-        oaDocument.setFormId(oaFbdDocument.getFormId());
-        oaDocument.setType(sign);
-        oaDocument.setDocNo(docNo);
-        oaDocument.setProposer(userId);
-        oaDocument.setDocStatus(oaFbdDocument.getDocStatus());
-        oaDocument.setCreateBy(username);
-        oaDocument.setCreateTime(oaFbdDocument.getCreateTime());
-        oaDocument.setDeptId(deptId);
-        oaDocument.setTenantId(tenantId);
-        oaDocumentMapper.insert(oaDocument);
-
-        // 插入审批表数据,第一条审批记录
-        if (oaFbdDocument.getDocStatus().equals(1)) {
-            getOaApproval(oaFbdDocument);
-        }
-    }
-
-    // 更新发布表数据
-    //@Transactional(rollbackFor = Exception.class)
-    @Transactional
-    @Override
-    public void update(OaFbdDocument oaFbdDocument) {
-        // 验证文档
-        validateDocument(oaFbdDocument);
-
-        // 获取当前用户和时间
         String username = SecurityUtils.getUsername();
         LocalDateTime now = LocalDateTime.now();
         Integer tenantId = SecurityUtils.getTenantId();
-
-        // 设置更新信息
-        oaFbdDocument.setUpdateBy(username);
-        oaFbdDocument.setUpdateTime(now);
-
-        // 更新发布表数据
-        oaFbdDocumentMapper.updateById(oaFbdDocument);
-
-        // 更新总单据状态
-        oaDocumentMapper.update(null, Wrappers.lambdaUpdate(OaDocument.class)
-                .eq(OaDocument::getDocNo, oaFbdDocument.getDocNo())
-                .set(OaDocument::getDocStatus, oaFbdDocument.getDocStatus())
-                .set(OaDocument::getUpdateBy, username)
-                .set(OaDocument::getUpdateTime, now)
-        );
-
-        // 如果文档状态为1,创建并插入审批记录
-        if (oaFbdDocument.getDocStatus() == 1) {
-            OaFbdDocument updatedDocument = oaFbdDocumentMapper.selectById(oaFbdDocument.getId());
-            getOaApproval(updatedDocument);
+        String sign = null;
+
+        if (oaFbdDocument.getId() == null) {
+            // 插入操作
+            Long userId = SecurityUtils.getUserId();
+            Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
+
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMddHHmmss");
+            String formattedDate = now.format(formatter);
+
+            LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
+            queryWrapper.select(OaFormDefinition::getFormSign).eq(OaFormDefinition::getId, oaFbdDocument.getFormId());
+            OaFormDefinition oaFormDefinition = oaFormDefinitionMapper.selectOne(queryWrapper);
+            sign = oaFormDefinition.getFormSign();
+            String docNo = sign + "-" + formattedDate;
+
+            oaFbdDocument.setDocNo(docNo);
+            oaFbdDocument.setProposer(userId);
+            oaFbdDocument.setCreateBy(username);
+            oaFbdDocument.setCreateTime(now);
+            oaFbdDocument.setDeptId(deptId);
+            oaFbdDocument.setTenantId(tenantId);
+            oaFbdDocumentMapper.insert(oaFbdDocument);
+
+            // 插入单据表数据
+            OaDocument oaDocument = new OaDocument();
+            oaDocument.setFormId(oaFbdDocument.getFormId());
+            oaDocument.setType(sign);
+            oaDocument.setDocNo(docNo);
+            oaDocument.setProposer(userId);
+            oaDocument.setDocStatus(oaFbdDocument.getDocStatus());
+            oaDocument.setCreateBy(username);
+            oaDocument.setCreateTime(now);
+            oaDocument.setDeptId(deptId);
+            oaDocument.setTenantId(tenantId);
+            oaDocumentMapper.insert(oaDocument);
+
+            if (oaFbdDocument.getDocStatus().equals(1)) {
+                getOaApproval(oaFbdDocument);
+            }
+        } else {
+            // 更新操作
+            oaFbdDocument.setUpdateBy(username);
+            oaFbdDocument.setUpdateTime(now);
+            oaFbdDocumentMapper.updateById(oaFbdDocument);
+
+            oaDocumentMapper.update(null, Wrappers.lambdaUpdate(OaDocument.class)
+                    .eq(OaDocument::getDocNo, oaFbdDocument.getDocNo())
+                    .set(OaDocument::getDocStatus, oaFbdDocument.getDocStatus())
+                    .set(OaDocument::getUpdateBy, username)
+                    .set(OaDocument::getUpdateTime, now)
+            );
+
+            if (oaFbdDocument.getDocStatus() == 1) {
+                OaFbdDocument updatedDocument = oaFbdDocumentMapper.selectById(oaFbdDocument.getId());
+                getOaApproval(updatedDocument);
+            }
+
+            sign = oaFbdDocumentMapper.selectById(oaFbdDocument.getId()).getDocNo().split("-")[0];
         }
+        oaApprovalGeneration.nodeSave(node, sign);
     }
 
     // 获取审批表数据
@@ -157,8 +145,6 @@ public class OaFbdDocumentServiceImpl extends AbstractCrudService<OaFbdDocumentM
 
         switch (oaNode.getNodeScope()) {
             case 0:
-            case 1:
-            case 2:
                 userIds = Arrays.stream(oaNode.getProposer().split(",")).map(Long::parseLong).collect(Collectors.toList());
                 break;
             case 3:
@@ -191,16 +177,17 @@ public class OaFbdDocumentServiceImpl extends AbstractCrudService<OaFbdDocumentM
             approval.setTenantId(oaFbdDocument.getTenantId());
             approval.setNodeId(oaNode.getId());
             oaApprovalMapper.insert(approval);
+
+            oaSendMessageCenter.sendAsyncMessage(
+                    oaFbdDocument.getCreateBy(),
+                    approval.getApprovalUid(),
+                    oaFbdDocument.getId(),
+                    userIds,
+                    3,
+                    oaApprovalService.getFieldInfo(oaFbdDocument.getDocNo())
+            );
         }
 
-        oaSendMessageCenter.sendAsyncMessage(
-                oaFbdDocument.getCreateBy(),
-                oaFbdDocument.getProposer(),
-                oaFbdDocument.getId(),
-                userIds,
-                3,
-                oaApprovalService.getFieldInfo(oaFbdDocument.getDocNo())
-        );
     }
 
     /**

+ 3 - 0
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaFormDefinitionServiceImpl.java

@@ -18,7 +18,9 @@ import com.usky.oa.service.vo.OaFormNameResponseVO;
 import com.usky.system.domain.SysUser;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.util.*;
@@ -58,6 +60,7 @@ public class OaFormDefinitionServiceImpl extends AbstractCrudService<OaFormDefin
      * @param oaFormDefinition 表单定义对象,包含表单的详细信息
      * @throws BusinessException 当表单名称或标识不符合规范或已存在时抛出
      */
+    @Transactional
     @Override
     public void addForm(OaFormDefinition oaFormDefinition) {
 

+ 24 - 36
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/utils/OaApprovalGeneration.java

@@ -14,16 +14,11 @@ import com.usky.system.domain.SysUser;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
+import java.time.LocalDateTime;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  *
@@ -47,9 +42,6 @@ public class OaApprovalGeneration {
     @Autowired
     private SysUserMapper sysUserMapper;
 
-    @Autowired
-    private OaSendMessageCenter oaSendMessageCenter;
-
     /**
      * @description: 新增流程与节点信息
      * @author: fyc
@@ -58,7 +50,6 @@ public class OaApprovalGeneration {
      * @param: [oaFormDefinition]
      * @return: void
      **/
-    @Async
     public void addGenerate(OaFormDefinition oaFormDefinition) {
         // 新增流程数据
         OaFlow oaFlow = new OaFlow();
@@ -96,14 +87,10 @@ public class OaApprovalGeneration {
 
                 switch (nodeScope) {
                     case 0:
-                    case 2:
                         proposer = node.getString("appointApprover");
                         break;
                     case 1:
-                        Long deptLeader = getDeptLeader();
-                        if (deptLeader != null) {
-                            proposer = deptLeader.toString();
-                        }
+                    case 2:
                         break;
                     case 3:
                         deptId2 = node.getInteger("deptId");
@@ -134,7 +121,6 @@ public class OaApprovalGeneration {
         }
     }
 
-    @Async
     public void updateGenerate(OaFormDefinition oaFormDefinition) {
         Integer formId = oaFormDefinition.getId();
         OaFlow flow = oaFlowMapper.selectOne(Wrappers.lambdaQuery(OaFlow.class).eq(OaFlow::getFormId, formId));
@@ -164,14 +150,10 @@ public class OaApprovalGeneration {
 
                 switch (nodeScope) {
                     case 0:
-                    case 2:
                         proposer = node.getString("appointApprover");
                         break;
                     case 1:
-                        Long deptLeader = getDeptLeader();
-                        if (deptLeader != null) {
-                            proposer = deptLeader.toString();
-                        }
+                    case 2:
                         break;
                     case 3:
                         deptId2 = node.getInteger("deptId");
@@ -197,7 +179,26 @@ public class OaApprovalGeneration {
         }
     }
 
-    private Long getDeptLeader() {
+    public void nodeSave(JSONObject jsonObject, String sign) {
+        Integer flowId = selectBySign(sign).getId();
+        List<JSONObject> nodeList = jsonObject.getJSONArray("node").toJavaList(JSONObject.class);
+        String proposer = null;
+        for (JSONObject node : nodeList) {
+            String nodeNo = node.getString("nodebh");
+            Integer nodeScope = node.getInteger("nodeScope");
+            proposer = node.getString("appointApprover");
+
+            OaNode oaNode = new OaNode();
+            if (nodeScope == 1) {
+                oaNode.setProposer(getDeptLeader().toString());
+            } else if (nodeScope == 2) {
+                oaNode.setProposer(proposer);
+            }
+            oaNodeMapper.update(oaNode, new LambdaQueryWrapper<OaNode>().eq(OaNode::getFlowId, flowId).eq(OaNode::getNodeNo, nodeNo));
+        }
+    }
+
+    public Long getDeptLeader() {
         Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
         Integer tenantId = SecurityUtils.getTenantId();
 
@@ -206,20 +207,7 @@ public class OaApprovalGeneration {
                 .eq(SysDept::getDeptId, deptId)
                 .select(SysDept::getLeader);
         SysDept deptLeader = sysDeptMapper.selectOne(deptLeaderQuery);
-        String leader = deptLeader.getLeader();
-
-        LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
-        userQuery.select(SysUser::getUserId)
-                .eq(SysUser::getTenantId, tenantId)
-                .eq(SysUser::getUserName, leader);
-        SysUser sysUser = sysUserMapper.selectOne(userQuery);
-        return sysUser.getUserId();
-    }
-
-    @Async
-    public void generateApproval(OaApproval approval) {
-        LambdaQueryWrapper<OaApproval> approvalQuery = new LambdaQueryWrapper<>();
-
+        return Long.valueOf(deptLeader.getLeader());
     }
 
     // 根据单据类型获取流程信息

+ 31 - 15
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/utils/OaSendMessageCenter.java

@@ -10,6 +10,7 @@ import com.usky.oa.mapper.OaFormDefinitionMapper;
 import com.usky.oa.mapper.SysUserMapper;
 import com.usky.oa.service.enums.OaBuiltInDocument;
 import com.usky.system.RemoteMceService;
+import com.usky.system.domain.MceRequestVO;
 import com.usky.system.domain.SysUser;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,44 +50,59 @@ public class OaSendMessageCenter {
      * 异步发送消息
      *
      * @param username 提交人账号名
-     * @param submitterId 提交人id
+     * @param approvalUid 审批人userId
      * @param id 数据id
      * @param receivers 接收人userId集合
      * @param isPass 是否通过(0:不通过,1:通过)
+     * @param sign 申请单类型
      */
     @Async
-    public void sendAsyncMessage(String username, Long submitterId, Integer id, List<Long> receivers, Integer isPass, String sign) {
+    public void sendAsyncMessage(String username, Long approvalUid, Integer id, List<Long> receivers, Integer isPass, String sign) {
 
         log.info(username + "的申请开始发送消息中心-----------------------------------");
 
         LambdaQueryWrapper<SysUser> nickNameQuery = Wrappers.lambdaQuery();
         nickNameQuery.select(SysUser::getNickName)
-                .eq(SysUser::getUserId, submitterId);
-        SysUser nickName = sysUserMapper.selectOne(nickNameQuery);
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("infoTitle", INFO_TITLE);
+                .eq(SysUser::getUserId, approvalUid);
+        SysUser user = sysUserMapper.selectOne(nickNameQuery);
+
+        // JSONObject jsonObject = new JSONObject();
+        // jsonObject.put("infoTitle", INFO_TITLE);
+
+        MceRequestVO mceRequestVO = new MceRequestVO();
+        mceRequestVO.setInfoTitle(INFO_TITLE);
 
         switch (isPass) {
             case 0:
-                jsonObject.put("infoContent", nickName.getNickName() + INFO_APPROVE_FAIL);
+                // jsonObject.put("infoContent", nickName.getNickName() + INFO_APPROVE_FAIL);
+                mceRequestVO.setInfoContent(user.getNickName() + INFO_APPROVE_FAIL);
                 break;
             case 1:
-                jsonObject.put("infoContent", nickName.getNickName() + INFO_APPROVE_SUCCESS);
+                // jsonObject.put("infoContent", nickName.getNickName() + INFO_APPROVE_SUCCESS);
+                mceRequestVO.setInfoContent(user.getNickName() + INFO_APPROVE_SUCCESS);
                 break;
             default:
                 OaBuiltInDocument oaBuiltInDocument = OaBuiltInDocument.valueOf(sign);
                 String name = oaBuiltInDocument.getName();
-                jsonObject.put("infoContent", nickName.getNickName() + "的" + name + INFO_CONTENT);
+                // jsonObject.put("infoContent", username + "的" + name + INFO_CONTENT);
+                mceRequestVO.setInfoContent(username + "的" + name + INFO_CONTENT);
         }
 
-        jsonObject.put("infoType", INFO_TYPE);
-        jsonObject.put("id", id);
-        jsonObject.put("infoTypeName", INFO_TITLE);
-        jsonObject.put("userName", username);
-        jsonObject.put("userIds", receivers);
+        // jsonObject.put("infoType", INFO_TYPE);
+        // jsonObject.put("id", id);
+        // jsonObject.put("infoTypeName", INFO_TITLE);
+        // jsonObject.put("userName", username);
+        // jsonObject.put("userIds", receivers);
+
+        mceRequestVO.setInfoType(String.valueOf(INFO_TYPE));
+        mceRequestVO.setId(id);
+        mceRequestVO.setInfoTypeName(INFO_TITLE);
+        mceRequestVO.setUserName(username);
+        mceRequestVO.setUserIds(receivers);
         try {
             // 推送消息中心
-            ApiResult<Void> voidApiResult = remoteMceService.addMce(jsonObject.toString());
+            //ApiResult<Void> voidApiResult = remoteMceService.addMce(jsonObject.toString());
+            ApiResult<Void> voidApiResult = remoteMceService.addMceReceive(mceRequestVO);
 
             if (voidApiResult.isSuccess()) {
                 log.info("申请消息发送成功!");