Ver Fonte

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

fuyuchuan há 3 semanas atrás
pai
commit
2619a36d0b

+ 8 - 1
service-oa/service-oa-biz/src/main/java/com/usky/oa/controller/web/OaApprovalController.java

@@ -46,7 +46,14 @@ public class OaApprovalController {
      * @author: fyc
      * @email yuchuan.fu@chinausky.com
      * @date: 2024/12/30 16:19
-     * @param: [queryType, docNo, type, approvalStatus, startTime, endTime, pageNum, pageSize]
+     * @param: queryType 查询类型(1:待处理,2:已处理,3:我收到,4:我发出)
+     * @param: docNo 单据号
+     * @param: formSign 表单标识
+     * @param: approvalStatus 审批状态 1:审批中 2:审批通过 3:不通过
+     * @param: startTime 开始时间
+     * @param: endTime 结束时间
+     * @param: pageNum 页码
+     * @param: pageSize 每页条数
      * @return: com.usky.common.core.bean.CommonPage<com.usky.oa.domain.OaApproval>
      **/
     @GetMapping("/pageList")

+ 1 - 1
service-oa/service-oa-biz/src/main/java/com/usky/oa/domain/OaNode.java

@@ -47,7 +47,7 @@ public class OaNode implements Serializable {
     private Integer nodeType;
 
     /**
-     * 节点审批权限范围(0:指定成员,1:部门主管,2:发起人自选,3:职位
+     * 0:指定成员,1:部门主管,2:发起人自选,3:指定部门,4:指定职位
      */
     private Integer nodeScope;
 

+ 1 - 0
service-oa/service-oa-biz/src/main/java/com/usky/oa/mapper/OaFlowMapper.java

@@ -2,6 +2,7 @@ package com.usky.oa.mapper;
 
 import com.usky.oa.domain.OaFlow;
 import com.usky.common.mybatis.core.CrudMapper;
+import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
 /**

+ 11 - 0
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/DocumentDetailsService.java

@@ -0,0 +1,11 @@
+package com.usky.oa.service;
+
+/**
+ *
+ * @author fyc
+ * @email yuchuan.fu@chinausky.com
+ * @date 2025/3/6
+ */
+public interface DocumentDetailsService {
+    Object getDocumentDetails(String docNo);
+}

+ 3 - 1
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/OaApprovalService.java

@@ -27,7 +27,7 @@ public interface OaApprovalService extends CrudService<OaApproval> {
 
     /**
      * 审批列表
-     * @param queryType 查询类型(1:待处理,2:已处理,3:我收到)
+     * @param queryType 查询类型(1:待处理,2:已处理,3:我收到,4:我发起)
      * @param docNo 单据编号
      * @param formSign 单据类型(请假申请-QJD...按标识查询)
      * @param approvalStatus 审批状态(1:审批中,2:审批通过,3:审批不通过)
@@ -46,6 +46,8 @@ public interface OaApprovalService extends CrudService<OaApproval> {
      */
     void approve(Integer id, Integer approvalStatus, String opinion);
 
+    String getFieldInfo(String docNo);
+
     // xml 流程解析测试
     // void analysisTest(Integer id);
 }

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

@@ -2,6 +2,7 @@ package com.usky.oa.service;
 
 import com.usky.oa.domain.OaFbdDocument;
 import com.usky.common.mybatis.core.CrudService;
+import org.springframework.stereotype.Component;
 
 /**
  * <p>
@@ -11,7 +12,7 @@ import com.usky.common.mybatis.core.CrudService;
  * @author fu
  * @since 2025-02-20
  */
-public interface OaFbdDocumentService extends CrudService<OaFbdDocument> {
+public interface OaFbdDocumentService extends CrudService<OaFbdDocument>{
 
     /**
      * 新增发布申请
@@ -24,4 +25,7 @@ public interface OaFbdDocumentService extends CrudService<OaFbdDocument> {
      * @param oaFbdDocument
      */
     void update(OaFbdDocument oaFbdDocument);
+
+    // 获取审批表数据
+    void getOaApproval(OaFbdDocument oaFbdDocument);
 }

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

@@ -19,6 +19,7 @@ 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.util.*;
@@ -96,7 +97,8 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
 
         LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(OaApproval::getTenantId, tenantId)
-                .eq(OaApproval::getApprovalUid, userId);
+                .eq(OaApproval::getApprovalUid, userId)
+                .orderByDesc(OaApproval::getId);
 
         switch (queryType) {
             case 1:
@@ -122,6 +124,8 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
                         .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), OaApproval::getSubmitDate, startTime, endTime)
                         .orderByDesc(OaApproval::getSubmitDate);
                 break;
+            case 4:
+
             default:
                 throw new RuntimeException("查询类型参数错误");
         }
@@ -147,16 +151,30 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
     }
 
     // 审批
+    @Transactional
     @Override
     public void approve(Integer id, Integer approvalStatus, String opinion) {
-        LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(OaApproval::getId, id);
-        OaApproval oaApproval = oaApprovalMapper.selectOne(queryWrapper);
+        Long userId = SecurityUtils.getUserId();
+        String username = SecurityUtils.getUsername();
+        LocalDateTime now = LocalDateTime.now();
+        Integer tenantId = SecurityUtils.getTenantId();
+
+        LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
+        userQuery.select(SysUser::getUserId, SysUser::getDeptId)
+                .eq(SysUser::getTenantId, tenantId)
+                .eq(SysUser::getDelFlag, 0)
+                .eq(SysUser::getStatus, 0);
+        Map<Long, Long> userDeptMap = sysUserMapper.selectList(userQuery).stream()
+                .collect(Collectors.toMap(SysUser::getUserId, SysUser::getDeptId));
+
+        OaApproval oaApproval = oaApprovalMapper.selectOne(Wrappers.<OaApproval>lambdaQuery().eq(OaApproval::getId, id));
 
+        if (oaApproval == null) {
+            throw new BusinessException("审批信息不存在!请联系管理员");
+        }
         if (!oaApproval.getApprovalUid().equals(SecurityUtils.getUserId())) {
             throw new BusinessException("审批权限不足,暂时无法更改!");
         }
-
         if (oaApproval.getApprovalStatus() != 1) {
             throw new BusinessException("审批状态异常,暂时无法更改!");
         }
@@ -164,87 +182,19 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
             throw new BusinessException("审批类型错误,请重试!");
         }
 
-        String username = SecurityUtils.getUsername();
-
-        LocalDateTime now = LocalDateTime.now();
-
+        oaApproval.setApprovalUid(userId);
         oaApproval.setApprovalStatus(approvalStatus);
-        oaApproval.setOpinion(opinion);
+        oaApproval.setOpinion(opinion == null ? "" : opinion);
         oaApproval.setApprovalDate(now);
         oaApproval.setUpdateBy(username);
         oaApproval.setUpdateTime(now);
         oaApprovalMapper.updateById(oaApproval);
 
-        boolean isPass = approvalStatus != 3;
-        Long proposerId = Long.valueOf(oaApproval.getProposer());
-        List<Long> receivers = Collections.singletonList(proposerId);
-        oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), proposerId, oaApproval.getId(), receivers, isPass ? 1 : 0);
-
         if (approvalStatus == 2) {
-            LambdaQueryWrapper<OaApproval> approvalLambdaQueryWrapper = new LambdaQueryWrapper<>();
-            approvalLambdaQueryWrapper.eq(OaApproval::getDocNo, oaApproval.getDocNo())
-                    .eq(OaApproval::getApprovalStatus, 1);
-            List<OaApproval> oaApprovals = oaApprovalMapper.selectList(approvalLambdaQueryWrapper);
-
-            if (oaApprovals.isEmpty()) {
-                LambdaQueryWrapper<OaNode> nodeQuery = new LambdaQueryWrapper<>();
-                nodeQuery.eq(OaNode::getParentId, oaApproval.getNodeId())
-                        .orderByAsc(OaNode::getId);
-                List<OaNode> oaNodes = oaNodeMapper.selectList(nodeQuery);
-
-                Integer tenantId = SecurityUtils.getTenantId();
-                Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
-                for (OaNode oaNode : oaNodes) {
-                    List<Long> userIds = new ArrayList<>();
-                    switch (oaNode.getNodeScope()) {
-                        case 0:
-                        case 1:
-                        case 2:
-                            userIds = Arrays.stream(oaNode.getProposer().split(",")).map(Long::parseLong).collect(Collectors.toList());
-                            break;
-                        case 3:
-                            LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
-                            userQuery.select(SysUser::getUserId)
-                                    .eq(SysUser::getTenantId, tenantId)
-                                    .eq(SysUser::getDelFlag, 0)
-                                    .eq(SysUser::getStatus, 0)
-                                    .eq(SysUser::getDeptId, oaNode.getDeptId());
-                            userIds = sysUserMapper.selectList(userQuery).stream().map(SysUser::getUserId).collect(Collectors.toList());
-                            break;
-                        case 4:
-                            LambdaQueryWrapper<SysUserPost> userRoleQuery = new LambdaQueryWrapper<>();
-                            userRoleQuery.eq(SysUserPost::getPostId, oaNode.getJobId());
-                            userIds = sysUserPostMapper.selectList(userRoleQuery).stream().map(SysUserPost::getUserId).collect(Collectors.toList());
-                            break;
-                    }
-
-                    for (Long userId1 : userIds) {
-                        OaApproval approval = new OaApproval();
-                        approval.setDocNo(oaApproval.getDocNo());
-                        approval.setProposer(Math.toIntExact(userId1));
-                        approval.setType(oaNode.getNodeType());
-                        approval.setApprovalStatus(1);
-                        approval.setCreateTime(now);
-                        approval.setCreateBy(username);
-                        approval.setDeptId(deptId);
-                        approval.setTenantId(tenantId);
-                        approval.setNodeId(oaNode.getId());
-                        oaApprovalMapper.insert(approval);
-                    }
-                }
-            } else {
-                for (OaApproval approval : oaApprovals) {
-                    approval.setApprovalStatus(2);
-                    oaApprovalMapper.updateById(approval);
-                }
-
-                LambdaQueryWrapper<OaNode> nodeQuery = new LambdaQueryWrapper<>();
-                nodeQuery.eq(OaNode::getParentId, oaApproval.getNodeId())
-                        .orderByAsc(OaNode::getId);
-                List<OaNode> oaNodes = oaNodeMapper.selectList(nodeQuery);
-
-                Integer tenantId = SecurityUtils.getTenantId();
-                Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
+            Integer nodeId = oaApprovalMapper.selectById(oaApproval.getId()).getNodeId();
+            Integer parentId = oaNodeMapper.selectById(nodeId).getParentId();
+            List<OaNode> oaNodes = oaNodeMapper.selectList(Wrappers.<OaNode>lambdaQuery().eq(OaNode::getId, parentId));
+            if (!oaNodes.isEmpty()) {
                 for (OaNode oaNode : oaNodes) {
                     List<Long> userIds = new ArrayList<>();
                     switch (oaNode.getNodeScope()) {
@@ -254,13 +204,13 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
                             userIds = Arrays.stream(oaNode.getProposer().split(",")).map(Long::parseLong).collect(Collectors.toList());
                             break;
                         case 3:
-                            LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
-                            userQuery.select(SysUser::getUserId)
+                            LambdaQueryWrapper<SysUser> userQuery1 = new LambdaQueryWrapper<>();
+                            userQuery1.select(SysUser::getUserId, SysUser::getNickName, SysUser::getDeptId)
                                     .eq(SysUser::getTenantId, tenantId)
                                     .eq(SysUser::getDelFlag, 0)
                                     .eq(SysUser::getStatus, 0)
                                     .eq(SysUser::getDeptId, oaNode.getDeptId());
-                            userIds = sysUserMapper.selectList(userQuery).stream().map(SysUser::getUserId).collect(Collectors.toList());
+                            userIds = sysUserMapper.selectList(userQuery1).stream().map(SysUser::getUserId).collect(Collectors.toList());
                             break;
                         case 4:
                             LambdaQueryWrapper<SysUserPost> userRoleQuery = new LambdaQueryWrapper<>();
@@ -269,24 +219,70 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
                             break;
                     }
 
-                    for (Long userId1 : userIds) {
-                        OaApproval approval = new OaApproval();
-                        approval.setDocNo(oaApproval.getDocNo());
-                        approval.setProposer(Math.toIntExact(userId1));
-                        approval.setType(oaNode.getNodeType());
-                        approval.setApprovalStatus(1);
-                        approval.setCreateTime(now);
-                        approval.setCreateBy(username);
-                        approval.setDeptId(deptId);
-                        approval.setTenantId(tenantId);
-                        approval.setNodeId(oaNode.getId());
-                        oaApprovalMapper.insert(approval);
+                    if (userIds.isEmpty()) {
+                        log.error("审批节点无用户,审批失败!");
+                    } else {
+                        for (Long userId1 : userIds) {
+                            OaApproval approval = new OaApproval();
+                            approval.setDocNo(oaApproval.getDocNo());
+                            approval.setProposer(oaApproval.getProposer());
+                            approval.setApprovalUid(userId1);
+                            approval.setType(oaNode.getNodeType());
+                            approval.setApprovalStatus(1);
+                            approval.setCreateTime(now);
+                            approval.setCreateBy(username);
+                            approval.setDeptId(userDeptMap.get(userId1));
+                            approval.setTenantId(tenantId);
+                            approval.setNodeId(oaNode.getId());
+                            oaApprovalMapper.insert(approval);
+                        }
+
+                        // 发送消息通知下一步审批人
+                        oaSendMessageCenter.sendAsyncMessage(
+                                oaApproval.getCreateBy(),
+                                Long.valueOf(oaApproval.getProposer()),
+                                oaApproval.getId(),
+                                userIds,
+                                3,
+                                getFieldInfo(oaApproval.getDocNo())
+                        );
                     }
                 }
             }
+            // 后无节点,发送消息通知申请人审核通过
+            else {
+                Long proposerId = Long.valueOf(oaApproval.getProposer());
+                oaSendMessageCenter.sendAsyncMessage(
+                        oaApproval.getCreateBy(),
+                        proposerId,
+                        oaApproval.getId(),
+                        Collections.singletonList(proposerId),
+                        1,
+                        getFieldInfo(oaApproval.getDocNo())
+                );
+            }
         } else if (oaApproval.getApprovalStatus() == 3) {
+            Long proposerId = Long.valueOf(oaApproval.getProposer());
+            // 发送消息通知申请人审核不通过
+            oaSendMessageCenter.sendAsyncMessage(
+                    oaApproval.getCreateBy(),
+                    proposerId,
+                    oaApproval.getId(),
+                    Collections.singletonList(proposerId),
+                    0,
+                    getFieldInfo(oaApproval.getDocNo())
+            );
         }
+    }
 
+    @Override
+    public String getFieldInfo(String docNo) {
+        String sgin = docNo.split("-")[0];
+        LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.select(OaFormDefinition::getFieldInfo)
+                .eq(OaFormDefinition::getFormSign, sgin);
+        OaFormDefinition oaFormDefinition = oaFormDefinitionMapper.selectOne(queryWrapper);
+        return oaFormDefinition.getFieldInfo();
     }
 
     // xml 流程解析测试

+ 24 - 22
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaDocumentServiceImpl.java

@@ -136,8 +136,9 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
     public Object documentDetails(String docNo) {
         Object documentDetails = null;
         String type = getFormSign(docNo);
+        String fieldInfo = oaFormDefinitionMapper.selectOne(Wrappers.lambdaQuery(OaFormDefinition.class).eq(OaFormDefinition::getFormSign, type)).getFieldInfo();
 
-        switch (type) {
+        switch (fieldInfo) {
             case "QJD":
                 OaQjdDocument oaQjdDocument = oaQjdDocumentMapper.selectOne(Wrappers.lambdaQuery(OaQjdDocument.class).eq(OaQjdDocument::getDocNo, docNo));
                 oaQjdDocument.setCreateBy(getNickName(oaQjdDocument.getProposer()));
@@ -148,6 +149,16 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
                 oaJbdDocument.setCreateBy(getNickName(oaJbdDocument.getProposer()));
                 documentDetails = oaJbdDocument;
                 break;
+            case "CGD":
+                OaCgdDocument oaCgdDocument = oaCgdDocumentMapper.selectOne(Wrappers.lambdaQuery(OaCgdDocument.class).eq(OaCgdDocument::getDocNo, docNo));
+                oaCgdDocument.setCreateBy(getNickName(oaCgdDocument.getProposer()));
+                documentDetails = oaCgdDocument;
+                break;
+            case "FBD":
+                OaFbdDocument oaFbdDocument = oaFbdDocumentMapper.selectOne(Wrappers.lambdaQuery(OaFbdDocument.class).eq(OaFbdDocument::getDocNo, docNo));
+                oaFbdDocument.setCreateBy(getNickName(oaFbdDocument.getProposer()));
+                documentDetails = oaFbdDocument;
+                break;
         }
 
         if (documentDetails == null) {
@@ -175,18 +186,25 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
             case "JBD":
                 oaJbdDocumentMapper.delete(Wrappers.lambdaQuery(OaJbdDocument.class).eq(OaJbdDocument::getDocNo, docNo));
                 break;
+            case "CGD":
+                oaCgdDocumentMapper.delete(Wrappers.lambdaQuery(OaCgdDocument.class).eq(OaCgdDocument::getDocNo, docNo));
+                break;
+            case "FBD":
+                oaFbdDocumentMapper.delete(Wrappers.lambdaQuery(OaFbdDocument.class).eq(OaFbdDocument::getDocNo, docNo));
+                break;
         }
         oaDocumentMapper.delete(Wrappers.lambdaQuery(OaDocument.class).eq(OaDocument::getDocNo, docNo));
     }
 
     // 新增单据
+    @Transactional
     @Override
     public void addDoc(JSONObject oaDocument) {
         LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(OaFormDefinition::getFieldInfo).eq(OaFormDefinition::getId, oaDocument.get("formId"));
         OaFormDefinition oaFormDefinition = oaFormDefinitionMapper.selectOne(queryWrapper);
 
-        if (oaFormDefinition == null){
+        if (oaFormDefinition == null) {
             throw new BusinessException("新增表单模板不存在!请联系管理员");
         }
         String sign = oaFormDefinition.getFieldInfo();
@@ -210,6 +228,7 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
     }
 
     // 更新单据
+    @Transactional
     @Override
     public void updateDoc(JSONObject jsonDocument) {
         LambdaQueryWrapper<OaFormDefinition> queryWrapper = Wrappers.lambdaQuery();
@@ -236,6 +255,7 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
     }
 
     // 提交单据
+    @Transactional
     @Override
     public void submit(String docNo, Integer docStatus) {
         if (docStatus != 1) {
@@ -256,6 +276,7 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
         LocalDateTime now = LocalDateTime.now();
 
         String formSign = getFormSign(docNo);
+        formSign = oaFormDefinitionMapper.selectOne(Wrappers.lambdaQuery(OaFormDefinition.class).eq(OaFormDefinition::getFormSign, formSign)).getFieldInfo();
 
         switch (formSign) {
             case "QJD":
@@ -285,6 +306,7 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
                         .set(OaFbdDocument::getUpdateBy, username)
                         .set(OaFbdDocument::getUpdateTime, now)
                         .eq(OaFbdDocument::getDocNo, docNo));
+                oaFbdDocumentService.getOaApproval(oaFbdDocumentMapper.selectOne(Wrappers.lambdaQuery(OaFbdDocument.class).eq(OaFbdDocument::getDocNo, docNo)));
                 break;
         }
         oaDocumentMapper.update(null, Wrappers.lambdaUpdate(OaDocument.class)
@@ -292,26 +314,6 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
                 .set(OaDocument::getUpdateBy, username)
                 .set(OaDocument::getUpdateTime, now)
                 .eq(OaDocument::getDocNo, docNo));
-
-        // 生成审批记录
-        OaApproval oaApproval = new OaApproval();
-        oaApproval.setDocNo(docNo);
-        oaApproval.setType(0);
-        oaApproval.setApprovalStatus(1);
-        // 随机选择一个审批人(涛、哲)
-        long approvalUid = RandomUtils.nextBoolean() ? 101 : 105;
-        oaApproval.setApprovalUid(approvalUid);
-        oaApproval.setProposer(Math.toIntExact(userId));
-        oaApproval.setCreateBy(username);
-        oaApproval.setCreateTime(now);
-        oaApproval.setSubmitDate(now);
-        oaApproval.setDeptId(deptId);
-        oaApproval.setTenantId(tenantId);
-        oaApprovalMapper.insert(oaApproval);
-
-        // 发送审批消息
-        List<Long> receivers = Collections.singletonList(oaApproval.getApprovalUid());
-        oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), userId, oaApproval.getId(), receivers, INFO_TYPE);
     }
 
     // 获取单据类型

+ 78 - 59
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaFbdDocumentServiceImpl.java

@@ -6,13 +6,16 @@ import com.usky.common.core.exception.BusinessException;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.oa.domain.*;
 import com.usky.oa.mapper.*;
+import com.usky.oa.service.OaApprovalService;
 import com.usky.oa.service.OaFbdDocumentService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.oa.service.utils.OaApprovalGeneration;
+import com.usky.oa.service.utils.OaSendMessageCenter;
 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;
@@ -50,6 +53,15 @@ public class OaFbdDocumentServiceImpl extends AbstractCrudService<OaFbdDocumentM
     @Autowired
     private SysUserPostMapper sysUserPostMapper;
 
+    @Autowired
+    private OaApprovalGeneration oaApprovalGeneration;
+
+    @Autowired
+    private OaSendMessageCenter oaSendMessageCenter;
+
+    @Autowired
+    private OaApprovalService oaApprovalService;
+
     @Override
     public void add(OaFbdDocument oaFbdDocument) {
         // 校验表单数据
@@ -94,62 +106,31 @@ public class OaFbdDocumentServiceImpl extends AbstractCrudService<OaFbdDocumentM
 
         // 插入审批表数据,第一条审批记录
         if (oaFbdDocument.getDocStatus().equals(1)) {
-            OaApprovalGeneration oaApprovalGeneration = new OaApprovalGeneration();
-            OaFlow oaFlow = oaApprovalGeneration.selectBySign(sign);
-            OaNode oaNode = oaApprovalGeneration.selectByFlowId(oaFlow.getId());
-
-            List<Long> userIds = new ArrayList<>();
-
-            switch (oaNode.getNodeScope()) {
-                case 0:
-                case 1:
-                case 2:
-                    userIds = Arrays.stream(oaNode.getProposer().split(",")).map(Long::parseLong).collect(Collectors.toList());
-                    break;
-                case 3:
-                    LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
-                    userQuery.select(SysUser::getUserId)
-                            .eq(SysUser::getTenantId, tenantId)
-                            .eq(SysUser::getDelFlag, 0)
-                            .eq(SysUser::getStatus, 0)
-                            .eq(SysUser::getDeptId, oaNode.getDeptId());
-                    userIds = sysUserMapper.selectList(userQuery).stream().map(SysUser::getUserId).collect(Collectors.toList());
-                    break;
-                case 4:
-                    LambdaQueryWrapper<SysUserPost> userRoleQuery = new LambdaQueryWrapper<>();
-                    userRoleQuery.eq(SysUserPost::getPostId, oaNode.getJobId());
-                    userIds = sysUserPostMapper.selectList(userRoleQuery).stream().map(SysUserPost::getUserId).collect(Collectors.toList());
-                    break;
-            }
-
-            for (Long userId1 : userIds) {
-                OaApproval approval = new OaApproval();
-                approval.setDocNo(docNo);
-                approval.setProposer(Math.toIntExact(userId1));
-                approval.setType(oaNode.getNodeType());
-                approval.setApprovalStatus(1);
-                approval.setCreateTime(now);
-                approval.setCreateBy(username);
-                approval.setDeptId(deptId);
-                approval.setTenantId(tenantId);
-                approval.setNodeId(oaNode.getId());
-                oaApprovalMapper.insert(approval);
-            }
+            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())
@@ -157,31 +138,69 @@ public class OaFbdDocumentServiceImpl extends AbstractCrudService<OaFbdDocumentM
                 .set(OaDocument::getUpdateTime, now)
         );
 
-        if (oaFbdDocument.getDocStatus().equals(1)) {
-
-            Integer formId = oaFbdDocument.getFormId();
-
-            LambdaQueryWrapper<OaFormDefinition> formQuery = new LambdaQueryWrapper<>();
-            formQuery.eq(OaFormDefinition::getId, formId)
-                    .select(OaFormDefinition::getFormSign);
-            OaFormDefinition oaFormDefinition = oaFormDefinitionMapper.selectOne(formQuery);
-            String formSign = oaFormDefinition.getFormSign();
+        // 如果文档状态为1,创建并插入审批记录
+        if (oaFbdDocument.getDocStatus() == 1) {
+            OaFbdDocument updatedDocument = oaFbdDocumentMapper.selectById(oaFbdDocument.getId());
+            getOaApproval(updatedDocument);
+        }
+    }
 
-            OaApprovalGeneration oaApprovalGeneration = new OaApprovalGeneration();
-            OaFlow oaFlow = oaApprovalGeneration.selectBySign(formSign);
-            OaNode oaNode = oaApprovalGeneration.selectByFlowId(oaFlow.getId());
+    // 获取审批表数据
+    @Override
+    public void getOaApproval(OaFbdDocument oaFbdDocument) {
+        String docNo = oaFbdDocument.getDocNo();
+        String formSign = docNo.split("-")[0];
+        OaFlow oaFlow = oaApprovalGeneration.selectBySign(formSign);
+        OaNode oaNode = oaApprovalGeneration.selectByFlowId(oaFlow.getId());
+
+        List<Long> userIds = new ArrayList<>();
+
+        switch (oaNode.getNodeScope()) {
+            case 0:
+            case 1:
+            case 2:
+                userIds = Arrays.stream(oaNode.getProposer().split(",")).map(Long::parseLong).collect(Collectors.toList());
+                break;
+            case 3:
+                LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
+                userQuery.select(SysUser::getUserId)
+                        .eq(SysUser::getTenantId, oaFlow.getTenantId())
+                        .eq(SysUser::getDelFlag, 0)
+                        .eq(SysUser::getStatus, 0)
+                        .eq(SysUser::getDeptId, oaNode.getDeptId());
+                userIds = sysUserMapper.selectList(userQuery).stream().map(SysUser::getUserId).collect(Collectors.toList());
+                break;
+            case 4:
+                LambdaQueryWrapper<SysUserPost> userRoleQuery = new LambdaQueryWrapper<>();
+                userRoleQuery.eq(SysUserPost::getPostId, oaNode.getJobId());
+                userIds = sysUserPostMapper.selectList(userRoleQuery).stream().map(SysUserPost::getUserId).collect(Collectors.toList());
+                break;
+        }
 
+        for (Long userId1 : userIds) {
             OaApproval approval = new OaApproval();
-            approval.setDocNo(oaFbdDocument.getDocNo());
+            approval.setDocNo(docNo);
             approval.setProposer(Math.toIntExact(oaFbdDocument.getProposer()));
             approval.setType(oaNode.getNodeType());
             approval.setApprovalStatus(1);
-            approval.setCreateTime(now);
-            approval.setCreateBy(username);
+            approval.setApprovalUid(userId1);
+            approval.setSubmitDate(oaFbdDocument.getCreateTime());
+            approval.setCreateTime(oaFbdDocument.getCreateTime());
+            approval.setCreateBy(oaFbdDocument.getCreateBy());
             approval.setDeptId(oaFbdDocument.getDeptId());
             approval.setTenantId(oaFbdDocument.getTenantId());
+            approval.setNodeId(oaNode.getId());
             oaApprovalMapper.insert(approval);
         }
+
+        oaSendMessageCenter.sendAsyncMessage(
+                oaFbdDocument.getCreateBy(),
+                oaFbdDocument.getProposer(),
+                oaFbdDocument.getId(),
+                userIds,
+                3,
+                oaApprovalService.getFieldInfo(oaFbdDocument.getDocNo())
+        );
     }
 
     /**
@@ -211,10 +230,10 @@ public class OaFbdDocumentServiceImpl extends AbstractCrudService<OaFbdDocumentM
             throw new BusinessException("上线功能不能为空!");
         } else if (oaFbdDocument.getOnlineFunction().length() > 250) {
             throw new BusinessException("上线功能长度不能超过250个字!");
-        } else if (oaFbdDocument.getPreparation().length() > 64) {
+        } else if (oaFbdDocument.getPreparation() != null && oaFbdDocument.getPreparation().length() > 64) {
             throw new BusinessException("上线前准备不能超过250个字!");
-        } else if (oaFbdDocument.getAnnex().length() > 125) {
-            throw new BusinessException("附件长度不能超过125个字符!");
+        } else if (oaFbdDocument.getAnnex() != null && oaFbdDocument.getAnnex().length() > 500) {
+            throw new BusinessException("附件上传数量超!");
         }
     }
 

+ 15 - 1
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaFormDefinitionServiceImpl.java

@@ -98,6 +98,7 @@ public class OaFormDefinitionServiceImpl extends AbstractCrudService<OaFormDefin
             oaFormDefinition.setFormVersion(1);
             oaFormDefinition.setFormStatus(2);
             oaFormDefinitionMapper.insert(oaFormDefinition);
+            oaApprovalGeneration.addGenerate(oaFormDefinition);
         } else {
             oaFormDefinition.setUpdateBy(username);
             oaFormDefinition.setUpdateTime(now);
@@ -111,9 +112,22 @@ public class OaFormDefinitionServiceImpl extends AbstractCrudService<OaFormDefin
                 throw new BusinessException("表单标识不可修改!");
             }
 
+            // 校验是否能够进行修改
+            selectIsHaveDocument(formSign, tenantId);
             oaFormDefinitionMapper.updateById(oaFormDefinition);
+            oaApprovalGeneration.updateGenerate(oaFormDefinition);
+        }
+    }
+
+    // 更新时表单下存在已生成单据时,不允许修改表单任何信息
+    private void selectIsHaveDocument(String formSign, Integer tenantId) {
+        LambdaQueryWrapper<OaDocument> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(OaDocument::getTenantId, tenantId)
+                .eq(OaDocument::getType, formSign);
+        OaDocument oaDocument = oaDocumentMapper.selectOne(queryWrapper);
+        if (oaDocument != null) {
+            throw new BusinessException("当前表单下已存在单据,不可修改!");
         }
-        oaApprovalGeneration.addGenerate(oaFormDefinition);
     }
 
     /**

+ 1 - 49
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaJbdDocumentServiceImpl.java

@@ -83,28 +83,6 @@ public class OaJbdDocumentServiceImpl extends AbstractCrudService<OaJbdDocumentM
         oaDocument.setDeptId(deptId);
         oaDocument.setTenantId(tenantId);
         oaDocumentMapper.insert(oaDocument);
-
-        // 如果直接提交则生成一条单据记录
-        Integer docStatus = oaJbdDocument.getDocStatus();
-        if (docStatus.equals(1)) {
-            // 生成一条审批记录数据
-            OaApproval oaApproval = new OaApproval();
-            oaApproval.setDocNo(oaJbdDocument.getDocNo());
-            oaApproval.setType(0);
-            oaApproval.setApprovalStatus(1);
-            oaApproval.setApprovalUid(105L);
-            oaApproval.setProposer(Math.toIntExact(userId));
-            oaApproval.setCreateBy(oaJbdDocument.getCreateBy());
-            oaApproval.setCreateTime(now);
-            oaApproval.setSubmitDate(now);
-            oaApproval.setDeptId(oaJbdDocument.getDeptId());
-            oaApproval.setTenantId(oaJbdDocument.getTenantId());
-            oaApprovalMapper.insert(oaApproval);
-
-            // 发送审批消息
-            List<Long> receivers = Collections.singletonList(oaApproval.getApprovalUid());
-            oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), userId, oaApproval.getId(), receivers, 3);
-        }
     }
 
     @Override
@@ -124,30 +102,9 @@ public class OaJbdDocumentServiceImpl extends AbstractCrudService<OaJbdDocumentM
         oaDocumentMapper.update(null, Wrappers.lambdaUpdate(OaDocument.class)
                 .eq(OaDocument::getDocNo, oaJbdDocument.getDocNo())
                 .set(OaDocument::getDocStatus, oaJbdDocument.getDocStatus())
-                .set(OaDocument::getUpdateBy, oaJbdDocument.getCreateBy())
+                .set(OaDocument::getUpdateBy, oaJbdDocument.getUpdateBy())
                 .set(OaDocument::getUpdateTime, oaJbdDocument.getUpdateTime())
         );
-
-        Integer docStatus = oaJbdDocument.getDocStatus();
-        if (docStatus.equals(1)) {
-            // 生成一条审批记录数据
-            OaApproval oaApproval = new OaApproval();
-            oaApproval.setDocNo(oaJbdDocument.getDocNo());
-            oaApproval.setType(0);
-            oaApproval.setApprovalStatus(1);
-            oaApproval.setApprovalUid(105L);
-            oaApproval.setProposer(Math.toIntExact(userId));
-            oaApproval.setCreateBy(oaJbdDocument.getCreateBy());
-            oaApproval.setCreateTime(now);
-            oaApproval.setSubmitDate(now);
-            oaApproval.setDeptId(oaJbdDocument.getDeptId());
-            oaApproval.setTenantId(oaJbdDocument.getTenantId());
-            oaApprovalMapper.insert(oaApproval);
-
-            // 发送审批消息
-            List<Long> receivers = Collections.singletonList(oaApproval.getApprovalUid());
-            oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), userId, oaApproval.getId(), receivers, 3);
-        }
     }
 
     /**
@@ -191,11 +148,6 @@ public class OaJbdDocumentServiceImpl extends AbstractCrudService<OaJbdDocumentM
 
     @Override
     public void delByDocNo(String docNo) {
-
-        if (StringUtils.isBlank(docNo)) {
-            throw new BusinessException("加班单据编号不能为空!");
-        }
-
         Integer tenantId = SecurityUtils.getTenantId();
         Long userId = SecurityUtils.getUserId();
 

+ 0 - 40
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaQjdDocumentServiceImpl.java

@@ -98,26 +98,6 @@ public class OaQjdDocumentServiceImpl extends AbstractCrudService<OaQjdDocumentM
         oaDocument.setDeptId(deptId);
         oaDocument.setTenantId(tenantId);
         oaDocumentMapper.insert(oaDocument);
-
-        if (oaQjdDocument.getDocStatus().equals(1)) {
-            // 生成第一条审批记录数据
-            OaApproval oaApproval = new OaApproval();
-            oaApproval.setDocNo(docNo);
-            oaApproval.setType(0);
-            oaApproval.setApprovalStatus(1);
-            oaApproval.setApprovalUid(101L);
-            oaApproval.setProposer(Math.toIntExact(userId));
-            oaApproval.setCreateBy(username);
-            oaApproval.setCreateTime(now);
-            oaApproval.setSubmitDate(now);
-            oaApproval.setDeptId(deptId);
-            oaApproval.setTenantId(tenantId);
-            oaApprovalMapper.insert(oaApproval);
-
-            // 发送审批消息
-            List<Long> receivers = Collections.singletonList(oaApproval.getApprovalUid());
-            oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), userId, oaApproval.getId(), receivers, 3);
-        }
     }
 
     @Override
@@ -144,26 +124,6 @@ public class OaQjdDocumentServiceImpl extends AbstractCrudService<OaQjdDocumentM
                 .set(OaDocument::getUpdateBy, username)
                 .set(OaDocument::getUpdateTime, oaQjdDocument.getUpdateTime())
         );
-
-        if (oaQjdDocument.getDocStatus().equals(1)) {
-            // 生成一条审批记录数据
-            OaApproval oaApproval = new OaApproval();
-            oaApproval.setDocNo(oaQjdDocument.getDocNo());
-            oaApproval.setType(0);
-            oaApproval.setApprovalStatus(1);
-            oaApproval.setApprovalUid(101L);
-            oaApproval.setProposer(Math.toIntExact(userId));
-            oaApproval.setCreateBy(username);
-            oaApproval.setCreateTime(now);
-            oaApproval.setSubmitDate(now);
-            oaApproval.setDeptId(deptId);
-            oaApproval.setTenantId(tenantId);
-            oaApprovalMapper.insert(oaApproval);
-
-            // 发送审批消息
-            List<Long> receivers = Collections.singletonList(oaApproval.getApprovalUid());
-            oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), userId, oaApproval.getId(), receivers, 3);
-        }
     }
 
     /**

+ 44 - 31
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/utils/OaApprovalGeneration.java

@@ -16,8 +16,14 @@ 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.util.List;
+import java.util.stream.Collectors;
 
 /**
  *
@@ -26,7 +32,7 @@ import java.util.List;
  * @date 2025/2/21
  */
 @Slf4j
-@Configuration
+@Service
 public class OaApprovalGeneration {
 
     @Autowired
@@ -41,6 +47,9 @@ public class OaApprovalGeneration {
     @Autowired
     private SysUserMapper sysUserMapper;
 
+    @Autowired
+    private OaSendMessageCenter oaSendMessageCenter;
+
     /**
      * @description: 新增流程与节点信息
      * @author: fyc
@@ -71,7 +80,8 @@ public class OaApprovalGeneration {
         JSONObject jsonObject = JSONObject.parseObject(flowInfo);
         if (jsonObject.containsKey("node")) {
             List<JSONObject> nodeList = jsonObject.getJSONArray("node").toJavaList(JSONObject.class);
-            Integer lastNodeId = null; // 用于记录上一个节点的 ID
+            // 用于记录上一个节点的 ID
+            Integer lastNodeId = null;
 
             for (JSONObject node : nodeList) {
                 String nodeNo = node.getString("nodebh");
@@ -112,7 +122,8 @@ public class OaApprovalGeneration {
                 oaNode.setProposer(proposer);
                 oaNode.setDeptId(deptId2);
                 oaNode.setJobId(jobId);
-                oaNode.setParentId(lastNodeId); // 使用上一个节点的 ID 作为父节点
+                // 使用上一个节点的 ID 作为父节点,第一个节点的父节点 ID 设置为 0
+                oaNode.setParentId(lastNodeId == null ? 0 : lastNodeId);
                 oaNodeMapper.insert(oaNode);
 
                 // 更新 lastNodeId 为当前节点的 ID
@@ -121,41 +132,24 @@ public class OaApprovalGeneration {
         }
     }
 
-    private Long getDeptLeader() {
-        Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
-        Integer tenantId = SecurityUtils.getTenantId();
-
-        LambdaQueryWrapper<SysDept> deptLeaderQuery = new LambdaQueryWrapper<>();
-        deptLeaderQuery.eq(SysDept::getTenantId, tenantId)
-                .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 updateGenerate(OaFormDefinition oaFormDefinition) {
         String flowInfo = oaFormDefinition.getFlowInfo();
         JSONObject jsonObject = JSONObject.parseObject(flowInfo);
         if (jsonObject.containsKey("node")) {
             List<JSONObject> nodeList = jsonObject.getJSONArray("node").toJavaList(JSONObject.class);
+            // 用于记录上一个节点的 ID
+            Integer lastNodeId = null;
+
             for (JSONObject node : nodeList) {
+                String nodeNo = node.getString("nodebh");
+                String nodeName = node.getString("nodeName");
                 Integer nodeType = node.getInteger("nodeType");
                 Integer nodeScope = node.getInteger("nodeScope");
                 String proposer = null;
                 Integer deptId2 = null;
                 Integer jobId = null;
 
-                // 用于记录上一个节点的 ID
-                Integer lastNodeId = null;
-
                 switch (nodeScope) {
                     case 0:
                     case 1:
@@ -173,18 +167,38 @@ public class OaApprovalGeneration {
                 }
 
                 OaNode oaNode = new OaNode();
+                oaNode.setNodeName(nodeName);
                 oaNode.setNodeType(nodeType);
                 oaNode.setNodeScope(nodeScope);
                 oaNode.setProposer(proposer);
                 oaNode.setDeptId(deptId2);
                 oaNode.setJobId(jobId);
                 oaNode.setParentId(lastNodeId);
-                oaNodeMapper.insert(oaNode);
+                oaNodeMapper.update(oaNode, new LambdaQueryWrapper<OaNode>().eq(OaNode::getNodeNo, nodeNo));
                 lastNodeId = oaNode.getId();
             }
         }
     }
 
+    private Long getDeptLeader() {
+        Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
+        Integer tenantId = SecurityUtils.getTenantId();
+
+        LambdaQueryWrapper<SysDept> deptLeaderQuery = new LambdaQueryWrapper<>();
+        deptLeaderQuery.eq(SysDept::getTenantId, tenantId)
+                .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<>();
@@ -193,16 +207,15 @@ public class OaApprovalGeneration {
 
     // 根据单据类型获取流程信息
     public OaFlow selectBySign(String sign) {
-        LambdaQueryWrapper<OaFlow> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(OaFlow::getDocType, sign);
-        return oaFlowMapper.selectOne(queryWrapper);
+        return oaFlowMapper.selectOne(Wrappers.lambdaQuery(OaFlow.class).eq(OaFlow::getDocType, sign));
     }
 
     // 根据流程ID获取节点信息
     public OaNode selectByFlowId(Integer flowId) {
         LambdaQueryWrapper<OaNode> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(OaNode::getFlowId, flowId);
-        return oaNodeMapper.selectOne(queryWrapper);
+        queryWrapper.eq(OaNode::getFlowId, flowId)
+                .orderByAsc(OaNode::getId);
+        return oaNodeMapper.selectList(queryWrapper).get(0);
     }
 
 }

+ 13 - 4
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/utils/OaSendMessageCenter.java

@@ -5,13 +5,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.exception.BusinessException;
+import com.usky.oa.domain.OaFormDefinition;
+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.SysUser;
 import lombok.extern.slf4j.Slf4j;
 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 java.util.*;
 import java.util.stream.Collectors;
@@ -23,7 +27,7 @@ import java.util.stream.Collectors;
  * @date 2025/1/9
  */
 @Slf4j
-@Configuration
+@Component
 public class OaSendMessageCenter {
 
     @Autowired
@@ -32,8 +36,11 @@ public class OaSendMessageCenter {
     @Autowired
     private SysUserMapper sysUserMapper;
 
+    @Autowired
+    private OaFormDefinitionMapper oaFormDefinitionMapper;
+
     private static final String INFO_TITLE = "审批提醒";
-    private static final String INFO_CONTENT = "的申请";
+    private static final String INFO_CONTENT = "待审批";
     private static final String INFO_APPROVE_FAIL = "审核不通过";
     private static final String INFO_APPROVE_SUCCESS = "审核通过";
     private static final int INFO_TYPE = 3;
@@ -48,7 +55,7 @@ public class OaSendMessageCenter {
      * @param isPass 是否通过(0:不通过,1:通过)
      */
     @Async
-    public void sendAsyncMessage(String username, Long submitterId, Integer id, List<Long> receivers, Integer isPass) {
+    public void sendAsyncMessage(String username, Long submitterId, Integer id, List<Long> receivers, Integer isPass, String sign) {
 
         log.info(username + "的申请开始发送消息中心-----------------------------------");
 
@@ -67,7 +74,9 @@ public class OaSendMessageCenter {
                 jsonObject.put("infoContent", nickName.getNickName() + INFO_APPROVE_SUCCESS);
                 break;
             default:
-                jsonObject.put("infoContent", nickName.getNickName() + INFO_CONTENT);
+                OaBuiltInDocument oaBuiltInDocument = OaBuiltInDocument.valueOf(sign);
+                String name = oaBuiltInDocument.getName();
+                jsonObject.put("infoContent", nickName.getNickName() + "的" + name + INFO_CONTENT);
         }
 
         jsonObject.put("infoType", INFO_TYPE);