liuyc 2 жил өмнө
parent
commit
a5f5afae29

+ 24 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/MessageWarningController.java

@@ -228,8 +228,30 @@ public class MessageWarningController extends BladeController {
     @PostMapping("/remove")
     @ApiOperationSupport(order = 2)
     @ApiOperation(value = "逻辑删除", notes = "传入ids")
-    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
-        return R.status(this.messageWarningService.deleteLogic(Func.toLongList(ids)));
+    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) throws IOException {
+        if (this.messageWarningService.deleteLogic(Func.toLongList(ids))) {
+            //通过WebSocket推送数量条数
+            if (ObjectUtil.isNotEmpty(AuthUtil.getUserId())) {
+                Map<String, String> webSocketMessageMap = WebSocket.getWebSocketMessageMap();
+                Set<Map.Entry<String, String>> message = webSocketMessageMap.entrySet();
+                for (Map.Entry<String, String> entry : message) {
+                    String userId = entry.getKey();
+                    if (userId.equals(AuthUtil.getUserId().toString())) { //只推送当前用户
+                        String projectAndContractId = entry.getValue();
+                        if (StringUtils.isNotEmpty(projectAndContractId) && StringUtils.isNotEmpty(userId)) {
+                            String projectId = projectAndContractId.split(",")[0];
+                            String contractId = projectAndContractId.split(",")[1];
+                            Map<String, String> stringMap = iTaskService.getTaskCount(projectId, contractId, userId);
+
+                            webSocket.sendMessageByUserId(AuthUtil.getUserId().toString(), JSON.toJSONString(stringMap));
+                        }
+                    }
+                }
+            }
+            return R.status(true);
+        }
+
+        return R.status(false);
     }