Browse Source

客户端、档案任务管理分页接口相关

liuyc 1 year ago
parent
commit
7e31b26f57

+ 14 - 0
blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/dto/SendsWebSocketArchiveDTO.java

@@ -0,0 +1,14 @@
+package org.springblade.archive.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@AllArgsConstructor
+public class SendsWebSocketArchiveDTO implements Serializable {
+    private Integer pageTotal;
+    private Integer type;
+    private ArchiveTaskDTO dto;
+}

+ 6 - 0
blade-service-api/blade-business-api/pom.xml

@@ -17,6 +17,12 @@
             <groupId>org.springblade</groupId>
             <artifactId>blade-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-archive-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
     <packaging>jar</packaging>
 

+ 10 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/ArchiveFileClient.java

@@ -5,14 +5,19 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.archive.dto.SendsWebSocketArchiveDTO;
+import org.springblade.business.dto.BusinessTaskDTO;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.vo.ArchiveFileVO;
+import org.springblade.business.vo.BusinessTaskPageVO;
 import org.springblade.common.constant.BusinessConstant;
+import org.springblade.core.tool.api.R;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
@@ -117,7 +122,7 @@ public interface ArchiveFileClient {
     boolean updateArchiveFileByBoxNameOne(@RequestParam String boxName, @RequestParam Integer boxNumber);
 
     @PostMapping(API_PREFIX + "/updateRectificationById")
-    boolean updateRectificationById(@RequestParam Long id,@RequestParam Integer rectification);
+    boolean updateRectificationById(@RequestParam Long id, @RequestParam Integer rectification);
 
     //批量查询案卷下的文件
     @PostMapping(API_PREFIX + "/batchSearchArchiveFile")
@@ -134,4 +139,8 @@ public interface ArchiveFileClient {
 
     @PostMapping(API_PREFIX + "/getListByContractId")
     List<ArchiveFile> getListByContractId(@RequestParam Long contractId);
+
+    @PostMapping(API_PREFIX + "/sendWebSocketArchiveMsg")
+    void sendWebSocketArchiveMsg(@RequestBody SendsWebSocketArchiveDTO webSocketArchiveDTO) throws IOException;
+
 }

+ 31 - 3
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileTaskController.java

@@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.poi.util.IOUtils;
 import org.springblade.archive.dto.ArchiveTaskDTO;
+import org.springblade.archive.dto.SendsWebSocketArchiveDTO;
 import org.springblade.archive.vo.ArchiveTaskPageVO;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.entity.Task;
@@ -32,6 +33,7 @@ import org.springblade.manager.feign.SignPfxClient;
 import org.springblade.system.user.entity.User;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.*;
@@ -48,6 +50,7 @@ public class ArchiveFileTaskController extends BladeController {
     private final JdbcTemplate jdbcTemplate;
     private final SignPfxClient signPfxClient;
     private final EVisaClient eVisaClient;
+    private final ArchiveFileClient archiveFileClient;
 
     /**
      * 批量认证(水印图片签章默认认证电签)
@@ -151,7 +154,10 @@ public class ArchiveFileTaskController extends BladeController {
     @PostMapping("/page")
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "档案-任务管理-任务查看分页查询", notes = "传入ArchiveTaskDTO")
-    public R<IPage<ArchiveTaskPageVO>> page(@RequestBody ArchiveTaskDTO dto) {
+    public R<IPage<ArchiveTaskPageVO>> page(@RequestBody ArchiveTaskDTO dto) throws IOException {
+        if (ObjectUtil.isEmpty(dto.getContractIdValue())) {
+            throw new ServiceException("未获取到当前用户所在的合同段信息,请联系管理员");
+        }
         int current = dto.getCurrent();
         int size = dto.getSize();
         //封装入参SQL
@@ -178,7 +184,7 @@ public class ArchiveFileTaskController extends BladeController {
                     sqlString.append(" AND project_id = ?");
                     params.add(dto.getProjectIdValue());
                 } else {
-                    throw new ServiceException("未获取到项目信息,请联系管理员");
+                    throw new ServiceException("未获取到当前用户所在的项目信息,请联系管理员");
                 }
             }
         } else if (contractInfo != null && (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3))) {
@@ -304,7 +310,29 @@ public class ArchiveFileTaskController extends BladeController {
                 .collect(Collectors.toList());
         page.setRecords(pageList);
         page.setTotal(totalCount);
-        return R.data(page);
+
+        R<IPage<ArchiveTaskPageVO>> iPageR = R.data(page);
+
+        //待办推送 TODO 档案暂时不推送,推送时放开
+        /*if (dto.getSelectedType().equals(1)) {
+            if (ObjectUtil.isNotEmpty(iPageR.getData()) && ObjectUtil.isNotEmpty(iPageR.getData().getRecords()) && ObjectUtil.isNotEmpty(dto.getContractIdValue()) && ObjectUtil.isNotEmpty(dto.getProjectIdValue())) {
+                this.sendWebSocketArchiveMsg(new SendsWebSocketArchiveDTO(totalCount, 1, dto));
+            } else if (ObjectUtil.isNotEmpty(dto.getContractIdValue()) && ObjectUtil.isNotEmpty(dto.getProjectIdValue())) {
+                this.sendWebSocketArchiveMsg(new SendsWebSocketArchiveDTO(0, 2, dto));
+            }
+        }*/
+
+        return iPageR;
+    }
+
+    /**
+     * 推送消息
+     *
+     * @throws IOException
+     */
+    @Async
+    public void sendWebSocketArchiveMsg(SendsWebSocketArchiveDTO webSocketArchiveDTO) throws IOException {
+        archiveFileClient.sendWebSocketArchiveMsg(webSocketArchiveDTO);
     }
 
 }

+ 49 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -1073,7 +1073,10 @@ public class TaskController extends BladeController {
     @PostMapping("/page")
     @ApiOperationSupport(order = 1)
     @ApiOperation(value = "资料填报-任务管理-任务查看分页查询", notes = "传入BusinessTaskDTO")
-    public R<IPage<BusinessTaskPageVO>> page(@RequestBody BusinessTaskDTO dto) {
+    public R<IPage<BusinessTaskPageVO>> page(@RequestBody BusinessTaskDTO dto) throws IOException {
+        if (ObjectUtil.isEmpty(dto.getContractIdValue())) {
+            throw new ServiceException("未获取到当前用户所在的合同段信息,请联系管理员");
+        }
         int current = dto.getCurrent();
         int size = dto.getSize();
         //封装入参SQL
@@ -1100,7 +1103,7 @@ public class TaskController extends BladeController {
                     sqlString.append(" AND project_id = ?");
                     params.add(dto.getProjectIdValue());
                 } else {
-                    throw new ServiceException("未获取到项目信息,请联系管理员");
+                    throw new ServiceException("未获取到当前用户所在的项目信息,请联系管理员");
                 }
             }
         } else if (contractInfo != null && (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3))) {
@@ -1229,7 +1232,50 @@ public class TaskController extends BladeController {
                 .collect(Collectors.toList());
         page.setRecords(pageList);
         page.setTotal(totalCount);
-        return R.data(page);
+
+        R<IPage<BusinessTaskPageVO>> iPageR = R.data(page);
+
+        //待办推送
+        if (dto.getSelectedType().equals(1)) {
+            if (ObjectUtil.isNotEmpty(iPageR.getData()) && ObjectUtil.isNotEmpty(iPageR.getData().getRecords()) && ObjectUtil.isNotEmpty(dto.getContractIdValue()) && ObjectUtil.isNotEmpty(dto.getProjectIdValue())) {
+                this.sendsWebSocketCount(iPageR, 1, dto);
+            } else if (ObjectUtil.isNotEmpty(dto.getContractIdValue()) && ObjectUtil.isNotEmpty(dto.getProjectIdValue())) {
+                this.sendsWebSocketCount(null, 2, dto);
+            }
+        }
+
+        return iPageR;
+    }
+
+    /**
+     * 推送消息
+     *
+     * @param iPageR
+     * @param type
+     * @param dto
+     * @throws IOException
+     */
+    @Async
+    public void sendsWebSocketCount(R<IPage<BusinessTaskPageVO>> iPageR, int type, BusinessTaskDTO dto) throws IOException {
+        if (ObjectUtil.isEmpty(dto.getCurrentContractId())) {
+            //如果getCurrentContractId=null,那么表示是APP的待办查询(web端不为null)
+            dto.setCurrentContractId(dto.getContractIdValue());
+        }
+        if (type == 1) {
+            Map<String, String> stringMap = iTaskService.getTaskCount(dto.getProjectIdValue().toString(), dto.getCurrentContractId().toString(), SecureUtil.getUserId().toString());
+            stringMap.put("taskCount", String.valueOf(iPageR.getData().getTotal()));
+            long messageCount = Long.parseLong(stringMap.get("messageCount"));
+            long taskCount = Long.parseLong(stringMap.get("taskCount"));
+            stringMap.put("allCount", String.valueOf(messageCount + taskCount));
+            webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
+        } else if (type == 2) {
+            Map<String, String> stringMap = iTaskService.getTaskCount(dto.getProjectIdValue().toString(), dto.getCurrentContractId().toString(), SecureUtil.getUserId().toString());
+            stringMap.put("taskCount", "0");
+            long messageCount = Long.parseLong(stringMap.get("messageCount"));
+            long taskCount = Long.parseLong(stringMap.get("taskCount"));
+            stringMap.put("allCount", String.valueOf(messageCount + taskCount));
+            webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
+        }
     }
 
 

+ 47 - 5
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/ArchiveFileClientImpl.java

@@ -1,29 +1,43 @@
 package org.springblade.business.feignClient;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
+import org.springblade.archive.dto.ArchiveTaskDTO;
+import org.springblade.archive.dto.SendsWebSocketArchiveDTO;
 import org.springblade.archive.entity.ArchivesAuto;
+import org.springblade.archive.vo.ArchiveTaskPageVO;
 import org.springblade.archive.vo.ArchivesAutoVO;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.feign.ArchiveFileClient;
 import org.springblade.business.mapper.ArchiveFileMapper;
 import org.springblade.business.service.IArchiveFileService;
 import org.springblade.business.service.ITaskService;
+import org.springblade.business.socket.WebSocket;
 import org.springblade.business.vo.ArchiveFileVO;
+import org.springblade.business.vo.TaskQueryVO;
+import org.springblade.business.vo.TaskVO;
 import org.springblade.common.utils.FileUtils;
 import org.springblade.common.vo.FileSize;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.feign.ContractClient;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.IOException;
 import java.util.*;
 
 
@@ -35,10 +49,12 @@ public class ArchiveFileClientImpl implements ArchiveFileClient {
 
     private final ArchiveFileMapper fileMapper;
 
-    private ContractClient contractClient;
+    private final ContractClient contractClient;
 
     private final ITaskService iTaskService;
 
+    private final WebSocket webSocket;
+
 
     @Override
     public void saveArchiveFile(ArchiveFileVO vo) {
@@ -165,7 +181,7 @@ public class ArchiveFileClientImpl implements ArchiveFileClient {
                     System.out.println(type);
                 }
             }
-        }else {
+        } else {
             List<ArchivesAutoVO> autos = fileMapper.getAllArchiveAutoByContractType(projectId);
             for (ArchivesAutoVO l : autos) {
                 String type = l.getContractType();
@@ -279,9 +295,9 @@ public class ArchiveFileClientImpl implements ArchiveFileClient {
     }
 
     @Override
-    public boolean updateRectificationById(Long id,Integer rectification) {
+    public boolean updateRectificationById(Long id, Integer rectification) {
         try {
-            fileMapper.updateRectificationById(id,rectification);
+            fileMapper.updateRectificationById(id, rectification);
         } catch (Exception e) {
             e.printStackTrace();
             return false;
@@ -297,7 +313,7 @@ public class ArchiveFileClientImpl implements ArchiveFileClient {
 
     @Override
     public void addOrUpdateArchiveFileBusinessData(Long nodeId, Long keyId, Long contractId, String formDataId) {
-        iTaskService.addOrUpdateArchiveFileBusinessData(nodeId,keyId,contractId,formDataId);
+        iTaskService.addOrUpdateArchiveFileBusinessData(nodeId, keyId, contractId, formDataId);
     }
 
     @Override
@@ -315,4 +331,30 @@ public class ArchiveFileClientImpl implements ArchiveFileClient {
         return fileMapper.getListByContractId(contractId);
     }
 
+    @Override
+    public void sendWebSocketArchiveMsg(SendsWebSocketArchiveDTO webSocketArchiveDTO) throws IOException {
+        Integer pageTotal = webSocketArchiveDTO.getPageTotal();
+        Integer type = webSocketArchiveDTO.getType();
+        ArchiveTaskDTO dto = webSocketArchiveDTO.getDto();
+        if (ObjectUtil.isEmpty(dto.getCurrentContractId())) {
+            //如果getCurrentContractId=null,那么表示是APP的待办查询(web端不为null)
+            dto.setCurrentContractId(dto.getContractIdValue());
+        }
+        if (type == 1) {
+            Map<String, String> stringMap = iTaskService.getTaskCountArchive(dto.getProjectIdValue().toString(), dto.getCurrentContractId().toString(), SecureUtil.getUserId().toString());
+            stringMap.put("taskCount", String.valueOf(pageTotal));
+            long messageCount = Long.parseLong(stringMap.get("messageCount"));
+            long taskCount = Long.parseLong(stringMap.get("taskCount"));
+            stringMap.put("allCount", String.valueOf(messageCount + taskCount));
+            webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
+        } else if (type == 2) {
+            Map<String, String> stringMap = iTaskService.getTaskCountArchive(dto.getProjectIdValue().toString(), dto.getCurrentContractId().toString(), SecureUtil.getUserId().toString());
+            stringMap.put("taskCount", "0");
+            long messageCount = Long.parseLong(stringMap.get("messageCount"));
+            long taskCount = Long.parseLong(stringMap.get("taskCount"));
+            stringMap.put("allCount", String.valueOf(messageCount + taskCount));
+            webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
+        }
+    }
+
 }