Browse Source

业务流程关联

guarantee-lsq 5 months ago
parent
commit
5cb2d10e86

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/enums/LinkTypeEnum.java

@@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
 import lombok.Getter;
 
 /**
- * @Description 是否启用
+ * @Description 流程关联类型
  * @Author lsq
  * @Date 2024/08/08
  * @Version Copyright (c) 2019,合肥乾元坤合科技有限公司 All rights reserved.

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/custom/CustomWorkflowRelationVO.java

@@ -60,5 +60,7 @@ public class CustomWorkflowRelationVO extends BaseVO implements Serializable {
      */
     private String updateUserName;
 
+    private String flowName; // 流程名称
+
 
 }

+ 2 - 2
platform-dao/src/main/resources/mapper/custom/CustomWorkflowRelationMapper.xml

@@ -49,8 +49,8 @@
         </if>
     </sql>
     <select id="selectList" parameterType="com.platform.dao.dto.custom.CustomWorkflowRelationDTO" resultType="com.platform.dao.vo.query.custom.CustomWorkflowRelationVO">
-        select flowrelation.*
-        from t_custom_workflow_relation as flowrelation
+        select flowrelation.*,flow.name as flowName
+        from t_custom_workflow_relation as flowrelation join t_workflow flow on flow.id = flowrelation.flow_id
         <where>
             <include refid="List_Condition"/>
         </where>

+ 3 - 2
platform-rest/src/main/java/com/platform/rest/controller/custom/CustomWorkflowRelationController.java

@@ -54,7 +54,7 @@ public class CustomWorkflowRelationController {
     @PostMapping
     @PreAuthorize("@pms.hasPermission('custom-flowrelation-add')")
     public R save(@Validated({AddGroup.class}) @RequestBody CustomWorkflowRelationDTO customWorkflowRelationDTO) {
-        return new R<>(customWorkflowRelationService.saveModelByDTO(customWorkflowRelationDTO));
+        return new R<>(customWorkflowRelationService.saveByDTO(customWorkflowRelationDTO));
     }
 
     /**
@@ -67,7 +67,8 @@ public class CustomWorkflowRelationController {
     @PutMapping("/{id}")
     @PreAuthorize("@pms.hasPermission('custom-flowrelation-edit')")
     public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody CustomWorkflowRelationDTO customWorkflowRelationDTO) {
-        customWorkflowRelationService.modModelByDTO(customWorkflowRelationDTO);
+        customWorkflowRelationDTO.setId(id);
+        customWorkflowRelationService.modByDTO(customWorkflowRelationDTO);
         return new R<>();
     }
 

+ 3 - 0
platform-service/src/main/java/com/platform/service/custom/CustomWorkflowRelationService.java

@@ -34,4 +34,7 @@ public interface CustomWorkflowRelationService extends IBaseService<CustomWorkfl
      */
     AbstractPageResultBean<CustomWorkflowRelationVO> selectPageList(CustomWorkflowRelationDTO record, int pageNum, int pageSize);
 
+    CustomWorkflowRelation saveByDTO(CustomWorkflowRelationDTO record);
+
+    void modByDTO(CustomWorkflowRelationDTO record);
 }

+ 43 - 5
platform-service/src/main/java/com/platform/service/custom/impl/CustomWorkflowRelationServiceImpl.java

@@ -1,20 +1,24 @@
 package com.platform.service.custom.impl;
 
+import com.github.pagehelper.PageHelper;
 import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.common.exception.DeniedException;
+import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.util.IdGeneratorUtils;
+import com.platform.common.util.SecurityUtils;
 import com.platform.dao.bean.MyPage;
-import com.github.pagehelper.PageHelper;
-import com.platform.dao.vo.query.custom.CustomWorkflowRelationVO;
 import com.platform.dao.dto.custom.CustomWorkflowRelationDTO;
 import com.platform.dao.entity.custom.CustomWorkflowRelation;
 import com.platform.dao.mapper.custom.CustomWorkflowRelationMapper;
+import com.platform.dao.vo.query.custom.CustomWorkflowRelationVO;
+import com.platform.service.base.impl.BaseServiceImpl;
 import com.platform.service.custom.CustomWorkflowRelationService;
+import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
-import com.platform.service.base.impl.BaseServiceImpl;
-import org.springframework.transaction.annotation.Transactional;
 import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
-import lombok.AllArgsConstructor;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -42,6 +46,40 @@ public class CustomWorkflowRelationServiceImpl extends BaseServiceImpl<CustomWor
         return new MyPage(mapper.selectList(record));
     }
 
+    @Override
+    public CustomWorkflowRelation saveByDTO(CustomWorkflowRelationDTO record) {
+        // 校验重复
+        if(countRepeatNum(record.getLinkType()) > 0){
+            throw new DeniedException("关联类型数据库已存在");
+        }
+        CustomWorkflowRelation entity = BeanConverterUtil.copyObjectProperties(record, CustomWorkflowRelation.class);
+        entity.setId(IdGeneratorUtils.getObjectId());
+        entity.setCreatedTime(LocalDateTime.now());
+        entity.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
+        entity.setCreatedUserName(SecurityUtils.getUserInfo().getRealName());
+        mapper.insertSelective(entity);
+        return entity;
+    }
+
+    private int countRepeatNum(String linkType){
+        CustomWorkflowRelation relation = new CustomWorkflowRelation();
+        relation.setLinkType(linkType);
+        return mapper.selectCount(relation);
+    }
+
+
+    @Override
+    public void modByDTO(CustomWorkflowRelationDTO record) {
+        CustomWorkflowRelation oldRelation = mapper.selectByPrimaryKey(record.getId());
+        String linkType = oldRelation.getLinkType();
+        if(!linkType.equals(record.getLinkType())){
+            if(countRepeatNum(record.getLinkType()) > 0) {
+                throw new DeniedException("修改的关联类型数据库已存在");
+            }
+        }
+        modModelByDTO(record);
+    }
+
     @Override
     public AbstractPageResultBean<CustomWorkflowRelation> selectPageInfo(CustomWorkflowRelationDTO record, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);