瀏覽代碼

加入小程序上传专用接口

wangliang 1 年之前
父節點
當前提交
40adc86a51

+ 28 - 1
sop-api/src/main/java/com/qmth/sop/server/api/SysController.java

@@ -258,7 +258,7 @@ public class SysController {
     @RequestMapping(value = "/file/preview/app", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})
     @OperationLog(logType = LogTypeEnum.PREVIEW)
-    public Result filePreview(@ApiParam(value = "小程序签名key", required = true) @RequestParam String key) throws Exception {
+    public Result filePreviewApp(@ApiParam(value = "小程序签名key", required = true) @RequestParam String key) throws Exception {
         List<BasicAttachment> basicAttachmentList = basicAttachmentService.filePreviewApp(key);
         if (CollectionUtils.isEmpty(basicAttachmentList)) {
             throw ExceptionResultEnum.ATTACHMENT_NO_DATA.exception();
@@ -270,6 +270,33 @@ public class SysController {
         return ResultUtil.ok(editResultList);
     }
 
+    @ApiOperation(value = "小程序文件上传接口")
+    @RequestMapping(value = "/file/upload/app", method = RequestMethod.POST)
+    @Transactional
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = AttachmentResult.class)})
+    @OperationLog(logType = LogTypeEnum.UN_KNOW)
+    @Aac(auth = false)
+    public Result fileUploadApp(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
+                                @ApiParam(value = "上传文件类型", required = true) @RequestParam UploadFileEnum type,
+                                @ApiParam(value = "小程序签名key") @RequestParam(required = false) String key) throws Exception {
+        BasicAttachment basicAttachment = null;
+        try {
+            basicAttachment = basicAttachmentService.saveAttachment(file, type, key);
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            basicAttachmentService.deleteAttachment(basicAttachment);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        }
+        JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
+        String filePath = (String) jsonObject.get(SystemConstant.PATH);
+        return ResultUtil.ok(new AttachmentResult(basicAttachment.getId(), basicAttachmentService.filePreview(basicAttachment.getPath()), filePath, key));
+    }
+
+
     @ApiOperation(value = "文件预览接口")
     @RequestMapping(value = "/file/preview", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBDingApplyController.java

@@ -44,7 +44,7 @@ public class TBDingApplyController {
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @OperationLog(logType = LogTypeEnum.ADD)
-    public Result save(@Valid @ApiParam(value = "考勤异常申请信息", required = true) @RequestBody TBDingApply tbDingApply, BindingResult bindingResult) throws InterruptedException {
+    public Result save(@Valid @ApiParam(value = "考勤异常申请信息", required = true) @RequestBody TBDingApply tbDingApply, BindingResult bindingResult) throws Exception {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }

+ 13 - 1
sop-business/src/main/java/com/qmth/sop/business/entity/TBDingApply.java

@@ -15,6 +15,7 @@ import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
@@ -60,6 +61,9 @@ public class TBDingApply implements Serializable {
     @ApiModelProperty(value = "附件id")
     private String attachmentIds;
 
+    @ApiModelProperty(value = "附件地址")
+    private String attachmentPaths;
+
     @ApiModelProperty(value = "附件id数组")
     @TableField(exist = false)
     @JsonSerialize(using = ToStringSerializer.class)
@@ -95,7 +99,15 @@ public class TBDingApply implements Serializable {
         setId(SystemConstant.getDbUuid());
         setCreateId(userId);
         setCreateTime(System.currentTimeMillis());
-        this.attachmentIds = StringUtils.join(attachmentIdList, SystemConstant.LIST_JOIN_SPLIT);
+        this.attachmentIds = Objects.nonNull(attachmentIdList) ? StringUtils.join(attachmentIdList, SystemConstant.LIST_JOIN_SPLIT) : null;
+    }
+
+    public String getAttachmentPaths() {
+        return attachmentPaths;
+    }
+
+    public void setAttachmentPaths(String attachmentPaths) {
+        this.attachmentPaths = attachmentPaths;
     }
 
     public String getSopNo() {

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/BasicAttachmentService.java

@@ -101,7 +101,7 @@ public interface BasicAttachmentService extends IService<BasicAttachment> {
     /**
      * 文件预览
      *
-     * @param path
+     * @param filePath
      * @return
      */
     public String filePreviewPath(String filePath) throws Exception;

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/TBDingApplyService.java

@@ -28,7 +28,7 @@ public interface TBDingApplyService extends IService<TBDingApply> {
      * @return
      * @throws InterruptedException
      */
-    Boolean saveDingApply(TBDingApply tbDingApply) throws InterruptedException;
+    Boolean saveDingApply(TBDingApply tbDingApply) throws Exception;
 
     /**
      * 异常待审核接口

+ 14 - 24
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -86,7 +86,7 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
      */
     @Override
     @Transactional
-    public Boolean saveDingApply(TBDingApply tbDingApply) throws InterruptedException {
+    public Boolean saveDingApply(TBDingApply tbDingApply) throws Exception {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         TBDing tbDing = tbDingService.getById(tbDingApply.getDingId());
         String sopNo = Objects.nonNull(tbDing) ? tbDing.getSopNo() : tbDingApply.getSopNo();
@@ -101,6 +101,14 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         flowApproveParam.setApproveRemark(FlowApprovePassEnum.START.getTitle());
         Map<String, Object> map = activitiService.taskApprove(flowApproveParam);
         TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
+        if (!CollectionUtils.isEmpty(tbDingApply.getAttachmentIdList())) {
+            List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(tbDingApply.getAttachmentIdList());
+            List<String> paths = new ArrayList<>(basicAttachmentList.size());
+            for (BasicAttachment b : basicAttachmentList) {
+                paths.add(basicAttachmentService.filePreview(b));
+            }
+            tbDingApply.setAttachmentPaths(StringUtils.join(paths, ";"));
+        }
         tbDingApply.setCode(tfCustomFlowEntity.getCode(), tbDingApply.getAttachmentIdList(), sysUser.getId());
         tfCustomFlowEntity.setObjId(tbDingApply.getId());
         tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
@@ -128,26 +136,17 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         IPage<DingApplyUnDoneResult> dingApplyUnDoneResultIPage = this.baseMapper.flowTaskUnDoneList(iPage, serviceId, name, supplierId, customName, startTime, endTime, applyStartTime, applyEndTime, dpr);
         if (Objects.nonNull(dingApplyUnDoneResultIPage) && !CollectionUtils.isEmpty(dingApplyUnDoneResultIPage.getRecords())) {
             for (DingApplyUnDoneResult d : dingApplyUnDoneResultIPage.getRecords()) {
-                if (Objects.nonNull(d.getAttachmentPaths())) {
-                    List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(Arrays.asList(d.getAttachmentPaths().split(",")));
-                    StringJoiner stringJoiner = new StringJoiner(";");
-                    for (BasicAttachment b : basicAttachmentList) {
-                        String path = basicAttachmentService.filePreview(b.getPath());
-                        stringJoiner.add(path);
-                    }
-                    d.setAttachmentPaths(stringJoiner.toString());
-                }
                 TFFlowLog tfFlowLog = tfFlowLogService.findByLastFlowLog(d.getFlowId());
                 if (Objects.nonNull(tfFlowLog) && Objects.nonNull(tfFlowLog.getPendApproveId())) {
                     List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(tfFlowLog.getPendApproveId().split(",")));
                     List<String> userName = sysUserList.stream().map(s -> s.getRealName()).collect(Collectors.toList());
-                    d.setApproveUserName(StringUtils.join(userName, ","));
+                    d.setApproveUserName(StringUtils.join(userName, SystemConstant.LIST_JOIN_SPLIT));
                 } else {
                     d.setApproveUserName("--");
                 }
                 String taskIds = d.getTaskIdArray();
-                if (Objects.nonNull(taskIds) && taskIds.contains(",")) {
-                    String[] taskStrs = taskIds.split(",");
+                if (Objects.nonNull(taskIds) && taskIds.contains(SystemConstant.LIST_JOIN_SPLIT)) {
+                    String[] taskStrs = taskIds.split(SystemConstant.LIST_JOIN_SPLIT);
                     boolean match = false;
                     for (int i = 0; i < taskStrs.length; i++) {
                         Task task = taskService.createTaskQuery().taskId(taskStrs[i]).singleResult();
@@ -205,20 +204,11 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         IPage<DingApplyDoneResult> dingApplyDoneResultIPage = this.baseMapper.flowTaskDoneList(iPage, serviceId, name, supplierId, Objects.nonNull(dingExceptionApprove) ? dingExceptionApprove.getTitle() : null, customName, startTime, endTime, applyStartTime, applyEndTime, dpr);
         if (Objects.nonNull(dingApplyDoneResultIPage) && !CollectionUtils.isEmpty(dingApplyDoneResultIPage.getRecords())) {
             for (DingApplyDoneResult d : dingApplyDoneResultIPage.getRecords()) {
-                if (Objects.nonNull(d.getAttachmentPaths())) {
-                    List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(Arrays.asList(d.getAttachmentPaths().split(",")));
-                    StringJoiner stringJoiner = new StringJoiner(";");
-                    for (BasicAttachment b : basicAttachmentList) {
-                        String path = basicAttachmentService.filePreview(b.getPath());
-                        stringJoiner.add(path);
-                    }
-                    d.setAttachmentPaths(stringJoiner.toString());
-                }
                 String string = tfFlowLogService.findByLastFlowLogApproveUser(d.getFlowId());
                 if (Objects.nonNull(string)) {
-                    List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(string.split(",")));
+                    List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(string.split(SystemConstant.LIST_JOIN_SPLIT)));
                     List<String> userName = sysUserList.stream().map(s -> s.getRealName()).collect(Collectors.toList());
-                    d.setApproveUsersName(StringUtils.join(userName, ","));
+                    d.setApproveUsersName(StringUtils.join(userName, SystemConstant.LIST_JOIN_SPLIT));
                 } else {
                     d.setApproveUsersName("--");
                 }

+ 4 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -1965,4 +1965,7 @@ WHERE id=2;
 
 UPDATE sys_privilege
 SET name='用户查询', url='/api/admin/user/list', `type`='URL', parent_id=15, `sequence`=1, property='SYS', related=NULL, enable=1, default_auth=1, front_display=0
-WHERE id=252;
+WHERE id=252;
+
+--2023.11.10update
+ALTER TABLE t_b_ding_apply ADD attachment_paths varchar(800) NULL COMMENT '附件地址';

+ 3 - 3
sop-business/src/main/resources/mapper/TBDingApplyMapper.xml

@@ -35,7 +35,7 @@
                      tbd.sign_date as exceptionTime,
                      tbda.apply_time as applyTime,
                      tbda.reason,
-                     tbda.attachment_ids as attachmentPaths,
+                     tbda.attachment_paths as attachmentPaths,
                      tbda.create_time as createTime,
                      ss.name as supplierName,
                      ss.code as supplierCode,
@@ -149,7 +149,7 @@
             tbda.create_time as createTime,
             tffa.update_time as flowTime,
             tbda.reason,
-            tbda.attachment_ids as attachmentPaths,
+            tbda.attachment_paths as attachmentPaths,
             (
             select
             CONCAT(tffl.approve_remark, ';' , tffl.create_time)
@@ -194,7 +194,7 @@
             ss.id = tbuas.supplier_id
             left join ACT_HI_TASKINST aht on aht.PROC_INST_ID_ = tffa.flow_id
         <where> 1 = 1 and tfcf.type = 'DING_EXCEPTION_FLOW'
-          and (tffa.status = 'AUDITING' or tffa.status = 'REJECT' or tffa.status = 'FINISH')
+          and tffa.status in ('AUDITING','REJECT','FINISH')
             <!--and aht.ASSIGNEE_ = #{dpr.requestUserId}-->
             <if test="serviceId != null and serviceId != ''">
                 and t.serviceId = #{serviceId}