Browse Source

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

fuyuchuan 3 weeks ago
parent
commit
ffd0f04a6f

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

@@ -72,5 +72,10 @@ public class OaFlow implements Serializable {
      */
     private Integer tenantId;
 
+    /**
+     * 表单定义表主键id
+     */
+    private Integer formId;
+
 
 }

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

@@ -192,8 +192,7 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
 
         if (approvalStatus == 2) {
             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));
+            List<OaNode> oaNodes = oaNodeMapper.selectList(Wrappers.<OaNode>lambdaQuery().eq(OaNode::getParentId, nodeId));
             if (!oaNodes.isEmpty()) {
                 for (OaNode oaNode : oaNodes) {
                     List<Long> userIds = new ArrayList<>();
@@ -229,23 +228,24 @@ public class OaApprovalServiceImpl extends AbstractCrudService<OaApprovalMapper,
                             approval.setApprovalUid(userId1);
                             approval.setType(oaNode.getNodeType());
                             approval.setApprovalStatus(1);
+                            approval.setSubmitDate(now);
                             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())
-                        );
+                            // 发送消息通知下一步审批人
+                            oaSendMessageCenter.sendAsyncMessage(
+                                    oaApproval.getCreateBy(),
+                                    Long.valueOf(oaApproval.getProposer()),
+                                    approval.getId(),
+                                    userIds,
+                                    3,
+                                    getFieldInfo(oaApproval.getDocNo())
+                            );
+                        }
                     }
                 }
             }

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

@@ -80,7 +80,6 @@ public class OaFormDefinitionServiceImpl extends AbstractCrudService<OaFormDefin
         validFromScope(oaFormDefinition);
 
         // 获取用户基本信息
-        Long userId = SecurityUtils.getUserId();
         Integer tenantId = SecurityUtils.getTenantId();
         String username = SecurityUtils.getUsername();
         Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
@@ -124,8 +123,8 @@ public class OaFormDefinitionServiceImpl extends AbstractCrudService<OaFormDefin
         LambdaQueryWrapper<OaDocument> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(OaDocument::getTenantId, tenantId)
                 .eq(OaDocument::getType, formSign);
-        OaDocument oaDocument = oaDocumentMapper.selectOne(queryWrapper);
-        if (oaDocument != null) {
+        List<OaDocument> oaDocument = oaDocumentMapper.selectList(queryWrapper);
+        if (!oaDocument.isEmpty()) {
             throw new BusinessException("当前表单下已存在单据,不可修改!");
         }
     }

+ 19 - 2
service-oa/service-oa-biz/src/main/java/com/usky/oa/service/utils/OaApprovalGeneration.java

@@ -62,8 +62,10 @@ public class OaApprovalGeneration {
     public void addGenerate(OaFormDefinition oaFormDefinition) {
         // 新增流程数据
         OaFlow oaFlow = new OaFlow();
+        oaFlow.setFormId(oaFormDefinition.getId());
         oaFlow.setFlowName(oaFormDefinition.getFormName() + "的流程");
         oaFlow.setDocType(oaFormDefinition.getFormSign());
+        oaFlow.setDescription(oaFormDefinition.getFormExplain());
         oaFlow.setCreateBy(oaFormDefinition.getCreateBy());
         oaFlow.setCreateTime(oaFormDefinition.getCreateTime());
         oaFlow.setDeptId(oaFormDefinition.getDeptId());
@@ -134,6 +136,16 @@ 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));
+        Integer flowId = flow.getId();
+
+        flow.setFlowName(oaFormDefinition.getFormName() + "的流程");
+        flow.setDescription(oaFormDefinition.getFormExplain());
+        flow.setUpdateBy(oaFormDefinition.getUpdateBy());
+        flow.setUpdateTime(oaFormDefinition.getUpdateTime());
+        oaFlowMapper.updateById(flow);
+
         String flowInfo = oaFormDefinition.getFlowInfo();
         JSONObject jsonObject = JSONObject.parseObject(flowInfo);
         if (jsonObject.containsKey("node")) {
@@ -152,10 +164,15 @@ public class OaApprovalGeneration {
 
                 switch (nodeScope) {
                     case 0:
-                    case 1:
                     case 2:
                         proposer = node.getString("appointApprover");
                         break;
+                    case 1:
+                        Long deptLeader = getDeptLeader();
+                        if (deptLeader != null) {
+                            proposer = deptLeader.toString();
+                        }
+                        break;
                     case 3:
                         deptId2 = node.getInteger("deptId");
                         break;
@@ -174,7 +191,7 @@ public class OaApprovalGeneration {
                 oaNode.setDeptId(deptId2);
                 oaNode.setJobId(jobId);
                 oaNode.setParentId(lastNodeId);
-                oaNodeMapper.update(oaNode, new LambdaQueryWrapper<OaNode>().eq(OaNode::getNodeNo, nodeNo));
+                oaNodeMapper.update(oaNode, new LambdaQueryWrapper<OaNode>().eq(OaNode::getFlowId, flowId).eq(OaNode::getNodeNo, nodeNo));
                 lastNodeId = oaNode.getId();
             }
         }

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

@@ -14,6 +14,7 @@
         <result column="update_time" property="updateTime" />
         <result column="dept_id" property="deptId" />
         <result column="tenant_id" property="tenantId" />
+        <result column="form_id" property="formId" />
     </resultMap>
 
 </mapper>