wangliang преди 3 години
родител
ревизия
fa56f5804b

+ 15 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlow.java

@@ -36,6 +36,9 @@ public class TFFlow extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "流程名称")
     private String name;
 
+    @ApiModelProperty(value = "流程key")
+    private String flowKey;
+
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     private Boolean enable;
 
@@ -46,23 +49,33 @@ public class TFFlow extends BaseEntity implements Serializable {
 
     }
 
-    public TFFlow(Long schoolId, Long orgId, String name, Long userId) {
+    public TFFlow(Long schoolId, Long orgId, String name, Long userId, String flowKey) {
         setId(SystemConstant.getDbUuid());
         this.schoolId = schoolId;
 //        this.orgId = orgId;
         this.name = name;
+        this.flowKey = flowKey;
         setCreateId(userId);
     }
 
-    public TFFlow(Long schoolId, Long orgId, String name, Boolean publish, Long userId) {
+    public TFFlow(Long schoolId, Long orgId, String name, Boolean publish, Long userId, String flowKey) {
         setId(SystemConstant.getDbUuid());
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.name = name;
         this.publish = publish;
+        this.flowKey = flowKey;
         setCreateId(userId);
     }
 
+    public String getFlowKey() {
+        return flowKey;
+    }
+
+    public void setFlowKey(String flowKey) {
+        this.flowKey = flowKey;
+    }
+
     public Long getSchoolId() {
         return schoolId;
     }

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowService.java

@@ -38,4 +38,12 @@ public interface TFFlowService extends IService<TFFlow> {
      * @return
      */
     public IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, String startName, Long schoolId, Long orgId);
+
+    /**
+     * 根据key查找流程
+     *
+     * @param flowKey
+     * @return
+     */
+    public Integer findByFlowKey(String flowKey);
 }

+ 5 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -131,6 +131,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @Resource
     TFFlowApproveService tfFlowApproveService;
 
+    @Resource
+    TFFlowService tfFlowService;
+
     @Override
     public List<ExamTask> listByCourseCode(Long schoolId, String code) {
         QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
@@ -337,6 +340,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 examTask.setStatus(ExamStatusEnum.DRAFT);
             } else {
                 if (Objects.isNull(examTask.getFlowId())) {
+                    //TODO 这里以后要判断学校code来取流程key
                     examTask.setStatus(ExamStatusEnum.SUBMIT);
                     Map<String, Object> map = new HashMap<>();
                     map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
@@ -582,6 +586,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             if (userId != null && userId.length() > 0 && !userId.equals("null")) {
                 examTask.setUserId(SystemConstant.convertIdToLong(userId));
                 if (Objects.isNull(examTask.getFlowId())) {
+                    //TODO 这里以后要判断学校code来取流程key
                     examTask.setStatus(ExamStatusEnum.SUBMIT);
                     Map<String, Object> map = new HashMap<>();
                     map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));

+ 20 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowServiceImpl.java

@@ -1,11 +1,14 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.bean.result.FlowApproveResult;
 import com.qmth.distributed.print.business.entity.TFFlow;
 import com.qmth.distributed.print.business.mapper.TFFlowMapper;
 import com.qmth.distributed.print.business.service.TFFlowService;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -52,4 +55,21 @@ public class TFFlowServiceImpl extends ServiceImpl<TFFlowMapper, TFFlow> impleme
     public IPage<FlowApproveResult> flowApproveList(IPage<Map> iPage, String startName, Long schoolId, Long orgId) {
         return tfFlowMapper.flowApproveList(iPage, startName, schoolId, orgId);
     }
+
+    /**
+     * 根据key查找流程
+     *
+     * @param flowKey
+     * @return
+     */
+    @Override
+    public Integer findByFlowKey(String flowKey) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        QueryWrapper<TFFlow> tfFlowQueryWrapper = new QueryWrapper<>();
+        tfFlowQueryWrapper.lambda().eq(TFFlow::getSchoolId, sysUser.getSchoolId())
+                .eq(TFFlow::getFlowKey, flowKey)
+                .eq(TFFlow::getEnable, true)
+                .eq(TFFlow::getPublish, true);
+        return this.count(tfFlowQueryWrapper);
+    }
 }

+ 21 - 14
distributed-print/src/main/java/com/qmth/distributed/print/api/TFFlowController.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.api;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.annotation.Aac;
@@ -75,15 +76,14 @@ public class TFFlowController {
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/register", method = RequestMethod.POST)
     public Result register(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
-                           @ApiParam(value = "流程文件名称", required = false) @RequestParam(required = false) String name,
-                           @ApiParam(value = "流程是否发布,true:发布,false:不发布", required = false) @RequestParam(required = false) Boolean publish) {
+                           @ApiParam(value = "流程文件名称", required = true) @RequestParam String name) {
         BasicAttachment basicAttachment = null;
         try {
             int temp = file.getOriginalFilename().lastIndexOf(".");
             String fileName = file.getOriginalFilename().substring(0, temp);
             String format = file.getOriginalFilename().substring(temp, file.getOriginalFilename().length());
-            if (!format.equalsIgnoreCase(".bpmn") && !format.contains("bpmn20.xml")) {
-                throw ExceptionResultEnum.ERROR.exception("上传的流程文件格式只能为.bmpn或bpmn20.xml");
+            if (!format.equalsIgnoreCase(".bpmn")) {
+                throw ExceptionResultEnum.ERROR.exception("上传的流程文件格式只能为.bmpn");
             }
             basicAttachment = printCommonService.saveAttachment(file, ServletUtil.getRequestMd5(), UploadFileEnum.FILE);
             if (Objects.isNull(basicAttachment)) {
@@ -91,7 +91,7 @@ public class TFFlowController {
             }
             activitiService.uploadDeployment(file);
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-            TFFlow tfFlow = new TFFlow(SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), Objects.isNull(name) ? fileName : name, publish, sysUser.getId());
+            TFFlow tfFlow = new TFFlow(SystemConstant.getHeadOrUserSchoolId(), sysUser.getOrgId(), name, sysUser.getId(), fileName);
             tfFlowService.save(tfFlow);
         } catch (Exception e) {
             log.error("请求出错", e);
@@ -111,17 +111,24 @@ public class TFFlowController {
         return ResultUtil.ok(new EditResult(basicAttachment.getId()));
     }
 
-    @ApiOperation(value = "发布流程")
+//    @ApiOperation(value = "发布流程")
+//    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
+//    @RequestMapping(value = "/publish", method = RequestMethod.POST)
+//    public Result publish(@ApiParam(value = "流程文件id", required = true) @RequestParam String id) {
+//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+//        UpdateWrapper tfFlowUpdateWrapper = new UpdateWrapper<>();
+//        tfFlowUpdateWrapper.lambda().eq(TFFlow::getId, Long.parseLong(id))
+//                .set(TFFlow::getPublish, true)
+//                .set(TFFlow::getUpdateId, sysUser.getId())
+//                .set(TFFlow::getUpdateTime, System.currentTimeMillis());
+//        return ResultUtil.ok(tfFlowService.update(tfFlowUpdateWrapper));
+//    }
+
+    @ApiOperation(value = "删除流程")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
-    @RequestMapping(value = "/publish", method = RequestMethod.POST)
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
     public Result publish(@ApiParam(value = "流程文件id", required = true) @RequestParam String id) {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        UpdateWrapper<TFFlow> tfFlowUpdateWrapper = new UpdateWrapper<>();
-        tfFlowUpdateWrapper.lambda().eq(TFFlow::getId, id)
-                .set(TFFlow::getPublish, true)
-                .set(TFFlow::getUpdateId, sysUser.getId())
-                .set(TFFlow::getUpdateTime, System.currentTimeMillis());
-        return ResultUtil.ok(tfFlowService.update(tfFlowUpdateWrapper));
+        return ResultUtil.ok();
     }
 
     @ApiOperation(value = "流程列表")