ソースを参照

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

gez 2 ヶ月 前
コミット
2cf2bc9a5b

+ 8 - 0
service-oa/service-oa-biz/pom.xml

@@ -49,6 +49,14 @@
             <version>4.1.0</version>
         </dependency>
 
+        <!-- 流程XML解析 -->
+        <!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
+        <dependency>
+            <groupId>org.dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>2.1.1</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 9 - 1
service-oa/service-oa-biz/src/main/java/com/usky/oa/controller/web/OaDocumentController.java

@@ -72,7 +72,15 @@ public class OaDocumentController {
         return oaDocumentService.documentDetails(docNo);
     }
 
-    // 更新单据
+
+    /**
+     * @description: 更新单据
+     * @author: fyc
+     * @email yuchuan.fu@chinausky.com
+     * @date: 2025/1/20 15:47
+     * @param: [jsonDocument]
+     * @return: void
+     **/
     @Log(title = "更新单据", businessType = BusinessType.UPDATE)
     @PostMapping("/update")
     public void approvalCount(@RequestBody JSONObject jsonDocument) {

+ 5 - 0
service-oa/service-oa-biz/src/main/java/com/usky/oa/domain/OaApproval.java

@@ -39,6 +39,11 @@ public class OaApproval implements Serializable {
      */
     private Long approvalUid;
 
+    /**
+     * 申请人id
+     */
+    private Integer proposer;
+
     /**
      * 审批类型(0:审批,1:知会)
      */

+ 15 - 0
service-oa/service-oa-biz/src/main/java/com/usky/oa/mapper/SysUserMapper.java

@@ -0,0 +1,15 @@
+package com.usky.oa.mapper;
+
+import com.usky.common.mybatis.core.CrudMapper;
+import com.usky.system.domain.SysUser;
+import org.springframework.stereotype.Repository;
+
+/**
+ *
+ * @author fyc
+ * @email yuchuan.fu@chinausky.com
+ * @date 2025/1/21
+ */
+@Repository
+public interface SysUserMapper extends CrudMapper<SysUser> {
+}

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

@@ -14,8 +14,11 @@ import com.usky.oa.mapper.OaApprovalMapper;
 import com.usky.oa.mapper.OaDocumentMapper;
 import com.usky.oa.service.OaApprovalService;
 import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.oa.service.utils.OaSendMessageCenter;
 import com.usky.oa.service.vo.OaApprovalCountVO;
+import com.usky.system.domain.SysUser;
 import org.apache.commons.lang3.StringUtils;
+import org.hibernate.validator.internal.constraintvalidators.bv.time.futureorpresent.FutureOrPresentValidatorForReadableInstant;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -24,6 +27,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -44,22 +48,30 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
     @Autowired
     private OaDocumentMapper oaDocumentMapper;
 
-    // 我的申请-待处理、已处理、我发起、我收到-统计
+    @Autowired
+    private OaSendMessageCenter oaSendMessageCenter;
+
+
+    // 我的申请-待处理、已处理、我发起、我收到-统计(暂时统计近一年数据)
     @Override
     public OaApprovalCountVO approvalCount() {
         Long userId = SecurityUtils.getUserId();
         String username = SecurityUtils.getUsername();
         Integer tenantId = SecurityUtils.getTenantId();
 
+        LocalDateTime now = LocalDateTime.now();
+        // 一年前时间
+        LocalDateTime oneYearAgo = now.minusYears(1);
+
         OaApprovalCountVO oaApprovalCountVO = new OaApprovalCountVO();
         // 待处理
-        oaApprovalCountVO.setPendingSum(getPendingSum(tenantId, userId).size());
+        oaApprovalCountVO.setPendingSum(getPendingSum(tenantId, userId, oneYearAgo, now).size());
         // 已处理
-        oaApprovalCountVO.setAlreadySum(getAlreadySum(tenantId, userId).size());
+        oaApprovalCountVO.setAlreadySum(getAlreadySum(tenantId, userId, oneYearAgo, now).size());
         // 我发起
-        oaApprovalCountVO.setMyInitiated(getMyInitiated(tenantId, username).size());
+        oaApprovalCountVO.setMyInitiated(getMyInitiated(tenantId, username, oneYearAgo, now).size());
         // 我收到
-        oaApprovalCountVO.setMyReceived(getMyReceived(tenantId, userId).size());
+        oaApprovalCountVO.setMyReceived(getMyReceived(tenantId, userId, oneYearAgo, now).size());
 
         return oaApprovalCountVO;
     }
@@ -71,16 +83,11 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
         Integer tenantId = SecurityUtils.getTenantId();
         IPage<OaApproval> page = new Page<>(pageNum, pageSize);
 
-        LocalDateTime now = LocalDateTime.now();
-        // 一年前时间
-        LocalDateTime oneYearAgo = now.minusYears(1);
-
         List<Integer> processed = Stream.of(2, 3).collect(Collectors.toList());
 
         LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(OaApproval::getTenantId, tenantId)
-                .eq(OaApproval::getApprovalUid, userId)
-                .between(OaApproval::getCreateTime, oneYearAgo, now);
+                .eq(OaApproval::getApprovalUid, userId).orderByDesc(OaApproval::getApprovalDate);
 
         switch (queryType) {
             case 1:
@@ -127,33 +134,47 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
             throw new BusinessException("审批类型错误,请重试!");
         }
 
+        String username = SecurityUtils.getUsername();
+
+        LocalDateTime now = LocalDateTime.now();
+
         oaApproval.setApprovalStatus(approvalStatus);
         oaApproval.setOpinion(opinion);
-        oaApproval.setApprovalDate(LocalDateTime.now());
-        oaApproval.setUpdateBy(SecurityUtils.getUsername());
-        oaApproval.setUpdateTime(LocalDateTime.now());
+        oaApproval.setApprovalDate(now);
+        oaApproval.setUpdateBy(username);
+        oaApproval.setUpdateTime(now);
         oaApprovalMapper.updateById(oaApproval);
+
+        int isPass = 1;
+        if (approvalStatus == 3) {
+            isPass = 0;
+        }
+
+        List<Long> receivers = Collections.singletonList(Long.valueOf(oaApproval.getProposer()));
+        oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), Long.valueOf(oaApproval.getProposer()), oaApproval.getId(), receivers, isPass);
     }
 
     // 待处理
-    private List<OaApproval> getPendingSum(Integer tenantId, Long userId) {
+    private List<OaApproval> getPendingSum(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
         LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(OaApproval::getTenantId, tenantId)
                 .eq(OaApproval::getApprovalUid, userId)
-                .eq(OaApproval::getApprovalStatus, 1);
+                .eq(OaApproval::getApprovalStatus, 1)
+                .between(OaApproval::getSubmitDate, oneYearAgo, now);
         List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
         return oaApprovals == null ? Collections.emptyList() : oaApprovals;
     }
 
     // 已处理
-    private List<OaApproval> getAlreadySum(Integer tenantId, Long userId) {
+    private List<OaApproval> getAlreadySum(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
         LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(OaApproval::getTenantId, tenantId)
                 .eq(OaApproval::getApprovalUid, userId)
                 .and(wrapper -> wrapper
                         .eq(OaApproval::getApprovalStatus, 2)
                         .or()
-                        .eq(OaApproval::getApprovalStatus, 3));
+                        .eq(OaApproval::getApprovalStatus, 3))
+                .between(OaApproval::getSubmitDate, oneYearAgo, now);
         List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
         return oaApprovals == null ? Collections.emptyList() : oaApprovals;
     }
@@ -174,20 +195,23 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
     }*/
 
     // 我发起
-    private List<OaDocument> getMyInitiated(Integer tenantId, String username) {
+    private List<OaDocument> getMyInitiated(Integer tenantId, String username, LocalDateTime oneYearAgo, LocalDateTime now) {
         List<OaDocument> oaDocuments = oaDocumentMapper.selectList(new QueryWrapper<OaDocument>().lambda()
                 .select(OaDocument::getDocNo)
                 .eq(OaDocument::getTenantId, tenantId)
-                .eq(OaDocument::getCreateBy, username));
+                .eq(OaDocument::getCreateBy, username)
+                .in(OaDocument::getDocStatus, 1, 2, 3)
+                .between(OaDocument::getCreateTime, oneYearAgo, now));
         return oaDocuments == null ? Collections.emptyList() : oaDocuments;
     }
 
     // 我收到
-    private List<OaApproval> getMyReceived(Integer tenantId, Long userId) {
+    private List<OaApproval> getMyReceived(Integer tenantId, Long userId, LocalDateTime oneYearAgo, LocalDateTime now) {
         LambdaQueryWrapper<OaApproval> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(OaApproval::getTenantId, tenantId)
                 .eq(OaApproval::getApprovalUid, userId)
-                .eq(OaApproval::getType, 1);
+                .eq(OaApproval::getType, 1)
+                .between(OaApproval::getSubmitDate, oneYearAgo, now);
         List<OaApproval> oaApprovals = oaApprovalMapper.selectList(queryWrapper);
         return oaApprovals == null ? Collections.emptyList() : oaApprovals;
     }

+ 16 - 15
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaDocumentServiceImpl.java

@@ -14,6 +14,8 @@ import com.usky.oa.service.OaDocumentService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.oa.service.OaJbdDocumentService;
 import com.usky.oa.service.OaQjdDocumentService;
+import com.usky.oa.service.utils.OaSendMessageCenter;
+import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -21,7 +23,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -59,6 +63,9 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
     @Autowired
     private OaApprovalMapper oaApprovalMapper;
 
+    @Autowired
+    private OaSendMessageCenter oaSendMessageCenter;
+
     private static final String TABLE_HEAD = "oa_";
     private static final String TABLE_SUFFIX = "_document";
 
@@ -149,7 +156,6 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
     }
 
     // 提交单据
-    @Transactional
     @Override
     public void submit(String docNo, Integer docStatus) {
         if (docStatus != 1) {
@@ -166,6 +172,7 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
         Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
         Integer tenantId = SecurityUtils.getTenantId();
         String username = SecurityUtils.getUsername();
+        Long userId = SecurityUtils.getUserId();
         LocalDateTime now = LocalDateTime.now();
 
         String formSign = getFormSign(docNo);
@@ -192,12 +199,15 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
                 .set(OaDocument::getUpdateTime, now)
                 .eq(OaDocument::getDocNo, docNo));
 
-        // 生成两条审批记录数据
+        // 生成审批记录
         OaApproval oaApproval = new OaApproval();
         oaApproval.setDocNo(docNo);
         oaApproval.setType(0);
         oaApproval.setApprovalStatus(1);
-        oaApproval.setApprovalUid(226L);
+        // 随机选择一个审批人(涛、哲)
+        long approvalUid = RandomUtils.nextBoolean() ? 101 : 105;
+        oaApproval.setApprovalUid(approvalUid);
+        oaApproval.setProposer(Math.toIntExact(userId));
         oaApproval.setCreateBy(username);
         oaApproval.setCreateTime(now);
         oaApproval.setSubmitDate(now);
@@ -205,18 +215,9 @@ public class OaDocumentServiceImpl extends AbstractCrudService<OaDocumentMapper,
         oaApproval.setTenantId(tenantId);
         oaApprovalMapper.insert(oaApproval);
 
-        OaApproval oaApproval1 = new OaApproval();
-        oaApproval1.setDocNo(docNo);
-        oaApproval1.setType(1);
-        oaApproval1.setApprovalStatus(1);
-        oaApproval1.setApprovalUid(157L);
-        oaApproval1.setCreateBy(username);
-        oaApproval1.setCreateTime(now);
-        oaApproval1.setSubmitDate(now);
-        oaApproval1.setDeptId(deptId);
-        oaApproval1.setTenantId(tenantId);
-        oaApprovalMapper.insert(oaApproval1);
-
+        // 发送审批消息
+        List<Long> receivers = Collections.singletonList(oaApproval.getApprovalUid());
+        oaSendMessageCenter.sendAsyncMessage(oaApproval.getCreateBy(), userId, oaApproval.getId(), receivers,3);
     }
 
     // 获取单据类型

+ 39 - 12
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaJbdDocumentServiceImpl.java

@@ -13,6 +13,7 @@ import com.usky.oa.mapper.OaJbdDocumentMapper;
 import com.usky.oa.service.OaJbdDocumentService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.oa.service.enums.OaBuiltInDocument;
+import com.usky.oa.service.utils.OaSendMessageCenter;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +22,8 @@ import org.springframework.stereotype.Service;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * <p>
@@ -42,6 +45,9 @@ public class OaJbdDocumentServiceImpl extends AbstractCrudService<OaJbdDocumentM
     @Autowired
     private OaApprovalMapper oaApprovalMapper;
 
+    @Autowired
+    private OaSendMessageCenter oaSendMessageCenter;
+
     @Override
     public void add(OaJbdDocument oaJbdDocument) {
         Long userId = SecurityUtils.getUserId();
@@ -86,14 +92,18 @@ public class OaJbdDocumentServiceImpl extends AbstractCrudService<OaJbdDocumentM
             oaApproval.setDocNo(oaJbdDocument.getDocNo());
             oaApproval.setType(0);
             oaApproval.setApprovalStatus(1);
-            long approvalUid = RandomUtils.nextBoolean() ? 226L : 157L;
-            oaApproval.setApprovalUid(approvalUid);
+            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);
         }
     }
 
@@ -102,16 +112,42 @@ public class OaJbdDocumentServiceImpl extends AbstractCrudService<OaJbdDocumentM
         if (StringUtils.isBlank(oaJbdDocument.getDocNo())) {
             throw new BusinessException("更新单据编号传参异常!");
         }
+
+        LocalDateTime now = LocalDateTime.now();
+        Long userId = SecurityUtils.getUserId();
+
         validateOaJbDocument(oaJbdDocument);
         oaJbdDocument.setUpdateBy(SecurityUtils.getUsername());
         oaJbdDocument.setUpdateTime(LocalDateTime.now());
         oaJbdDocumentMapper.updateById(oaJbdDocument);
 
         oaDocumentMapper.update(null, Wrappers.lambdaUpdate(OaDocument.class)
+                .eq(OaDocument::getDocNo, oaJbdDocument.getDocNo())
                 .set(OaDocument::getDocStatus, oaJbdDocument.getDocStatus())
                 .set(OaDocument::getUpdateBy, oaJbdDocument.getCreateBy())
                 .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);
+        }
     }
 
     /**
@@ -136,19 +172,10 @@ public class OaJbdDocumentServiceImpl extends AbstractCrudService<OaJbdDocumentM
             throw new BusinessException("加班开始时间或结束时间输入异常!请确保开始时间不晚于结束时间");
         }
 
-        if (oaJbdDocument.getDuration() == null || oaJbdDocument.getDuration() <= 0) {
+        if (duration == null || duration <= 0) {
             throw new BusinessException("加班时长必须大于0!");
         }
 
-        long hours = ChronoUnit.HOURS.between(startTime, endTime);
-        long days = ChronoUnit.DAYS.between(startTime, endTime);
-        if (days > 0) {
-            hours -= days * 16;
-        }
-        if (hours != duration) {
-            throw new BusinessException("加班时长与实际时长不一致,请重试!");
-        }
-
         if (StringUtils.isBlank(oaJbdDocument.getReason())) {
             throw new BusinessException("加班原因不能为空!");
         } else if (oaJbdDocument.getReason().length() > 255) {

+ 20 - 6
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/impl/OaQjdDocumentServiceImpl.java

@@ -16,6 +16,7 @@ import com.usky.oa.mapper.OaQjdDocumentMapper;
 import com.usky.oa.service.OaQjdDocumentService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.oa.service.enums.OaBuiltInDocument;
+import com.usky.oa.service.utils.OaSendMessageCenter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -25,6 +26,8 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * <p>
@@ -50,6 +53,9 @@ public class OaQjdDocumentServiceImpl extends AbstractCrudService<OaQjdDocumentM
     @Autowired
     private OaApprovalMapper oaApprovalMapper;
 
+    @Autowired
+    private OaSendMessageCenter oaSendMessageCenter;
+
     @Override
     public void addQjDocument(OaQjdDocument oaQjdDocument) {
 
@@ -99,15 +105,18 @@ public class OaQjdDocumentServiceImpl extends AbstractCrudService<OaQjdDocumentM
             oaApproval.setDocNo(docNo);
             oaApproval.setType(0);
             oaApproval.setApprovalStatus(1);
-            // 随机选择一个审批人
-            long approvalUid = RandomUtils.nextBoolean() ? 226L : 157L;
-            oaApproval.setApprovalUid(approvalUid);
+            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);
         }
     }
 
@@ -123,12 +132,14 @@ public class OaQjdDocumentServiceImpl extends AbstractCrudService<OaQjdDocumentM
         LocalDateTime now = LocalDateTime.now();
         Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
         Integer tenantId = SecurityUtils.getTenantId();
+        Long userId = SecurityUtils.getUserId();
 
         oaQjdDocument.setUpdateBy(username);
         oaQjdDocument.setUpdateTime(now);
         oaQjdDocumentMapper.updateById(oaQjdDocument);
 
         oaDocumentMapper.update(null, Wrappers.lambdaUpdate(OaDocument.class)
+                .eq(OaDocument::getDocNo, oaQjdDocument.getDocNo())
                 .set(OaDocument::getDocStatus, oaQjdDocument.getDocStatus())
                 .set(OaDocument::getUpdateBy, username)
                 .set(OaDocument::getUpdateTime, oaQjdDocument.getUpdateTime())
@@ -140,15 +151,18 @@ public class OaQjdDocumentServiceImpl extends AbstractCrudService<OaQjdDocumentM
             oaApproval.setDocNo(oaQjdDocument.getDocNo());
             oaApproval.setType(0);
             oaApproval.setApprovalStatus(1);
-            // 随机选择一个审批人
-            long approvalUid = RandomUtils.nextBoolean() ? 226L : 157L;
-            oaApproval.setApprovalUid(approvalUid);
+            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);
         }
     }
 

+ 46 - 25
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/utils/OaSendMessageCenter.java

@@ -5,9 +5,13 @@ 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.mapper.SysUserMapper;
+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 java.util.*;
 import java.util.stream.Collectors;
@@ -22,51 +26,68 @@ import java.util.stream.Collectors;
 @Configuration
 public class OaSendMessageCenter {
 
+    @Autowired
+    private RemoteMceService remoteMceService;
+
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
     private static final String INFO_TITLE = "审批提醒";
     private static final String INFO_CONTENT = "的申请";
-    private static final int INFO_TYPE = 6;
+    private static final String INFO_APPROVE_FAIL = "审核不通过";
+    private static final String INFO_APPROVE_SUCCESS = "审核通过";
+    private static final int INFO_TYPE = 3;
+
+    /**
+     * 异步发送消息
+     *
+     * @param username 提交人账号名
+     * @param submitterId 提交人id
+     * @param id 数据id
+     * @param receivers 接收人userId集合
+     * @param isPass 是否通过(0:不通过,1:通过)
+     */
+    @Async
+    public void sendAsyncMessage(String username, Long submitterId, Integer id, List<Long> receivers, Integer isPass) {
 
-    /*public void sendAsyncMessage(PmWorkReport newReport) {
-        String username = newReport.getCreateBy();
-        Long submitterId = newReport.getSubmitterId();
         log.info(username + "的申请开始发送消息中心-----------------------------------");
-        List<Long> userId = new ArrayList<>();
-        if (!newReport.getCcTo().isEmpty()) {
-            userId = Optional.of(newReport.getCcTo())
-                    .map(ccTo -> Arrays.stream(ccTo.split(","))
-                            .map(Long::parseLong)
-                            .collect(Collectors.toList()))
-                    .orElse(Collections.emptyList());
-        } else {
-            throw new BusinessException( newReport.getCreateBy() + "的报告:" + newReport.getId() + ",抄送人为空,无需发送消息中心");
-        }
+
         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);
-        jsonObject.put("infoContent", nickName.getNickName() + INFO_CONTENT);
+
+        switch (isPass) {
+            case 0:
+                jsonObject.put("infoContent", nickName.getNickName() + INFO_APPROVE_FAIL);
+                break;
+            case 1:
+                jsonObject.put("infoContent", nickName.getNickName() + INFO_APPROVE_SUCCESS);
+                break;
+            default:
+                jsonObject.put("infoContent", nickName.getNickName() + INFO_CONTENT);
+        }
+
         jsonObject.put("infoType", INFO_TYPE);
-        jsonObject.put("id", newReport.getId());
+        jsonObject.put("id", id);
         jsonObject.put("infoTypeName", INFO_TITLE);
-        jsonObject.put("userName", newReport.getCreateBy());
-        if (!userId.isEmpty()) {
-            jsonObject.put("userIds", userId);
-        }
+        jsonObject.put("userName", username);
+        jsonObject.put("userIds", receivers);
         try {
             // 推送消息中心
             ApiResult<Void> voidApiResult = remoteMceService.addMce(jsonObject.toString());
 
             if (voidApiResult.isSuccess()) {
-                log.info("报告消息发送成功!");
+                log.info("申请消息发送成功!");
             } else {
-                log.error("报告消息发送失败!");
+                log.error("申请消息发送失败!");
             }
         } catch (Exception e) {
-            log.error("报告发送消息时发生异常", e);
+            log.error("申请发送消息时发生异常", e);
         }
-        log.info(username + "的工作报告发送消息中心完成-----------------------------------");
-    }*/
+        log.info(username + "的申请发送消息中心完成-----------------------------------");
+    }
 
 }

+ 1 - 0
service-oa/service-oa-biz/src/main/resources/mapper/oa/OaApprovalMapper.xml

@@ -7,6 +7,7 @@
         <id column="id" property="id" />
         <result column="doc_no" property="docNo" />
         <result column="approval_uid" property="approvalUid" />
+        <result column="proposer" property="proposer" />
         <result column="type" property="type" />
         <result column="approval_status" property="approvalStatus" />
         <result column="opinion" property="opinion" />