文件上传websocket成功通知

master
yqy 2 years ago
parent bffa6c7fa6
commit ea74814822

@ -410,15 +410,20 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public void sendMessage(String message, Long userId, String type) { public void sendMessage(String message, Long userId, String type) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("message", message); map.put("message", message);
map.put("code", 500);
if (type.equals("create")) map.put("code", 200);
map.put("type", type); map.put("type", type);
map.put("code", 500);
JSONObject jsonData = new JSONObject(); String messageJSON;
jsonData.putOpt("data", map); if (type.equals("create")){
String messageJSON = JSONUtil.toJsonStr(jsonData); map.put("code", 200);
messageJSON = JSONUtil.toJsonStr(map);
} else {
JSONObject jsonData = new JSONObject();
jsonData.putOpt("data", map);
messageJSON = JSONUtil.toJsonStr(jsonData);
}
webSocketServer.sendMessage(messageJSON, userId); webSocketServer.sendMessage(messageJSON, userId);
} }

@ -96,7 +96,7 @@ public class FileAnalysisTask {
taskClient.updateTask(task); taskClient.updateTask(task);
// 任务自动分配(未开启就不分配) // 任务自动分配(未开启就不分配)
clueService.dynamicTaskDistribution(taskId, uploadType); clueService.dynamicTaskDistribution(taskId, uploadType);
taskClient.sendMessage("上传成功", clueRecords.get(0).getCreateBy(), "create"); taskClient.sendMessage("文件上传成功", clueRecords.get(0).getCreateBy(), "create");
return; return;
} }
//创建任务 //创建任务
@ -106,7 +106,7 @@ public class FileAnalysisTask {
BaseExcelListenerDto baseExcelListenerDto = new BaseExcelListenerDto(userId, uploadType, taskId, oneFileName); BaseExcelListenerDto baseExcelListenerDto = new BaseExcelListenerDto(userId, uploadType, taskId, oneFileName);
clueService.saveTask(baseExcelListenerDto); clueService.saveTask(baseExcelListenerDto);
} }
taskClient.sendMessage("上传成功", clueRecords.get(0).getCreateBy(), "create"); taskClient.sendMessage("文件上传成功", clueRecords.get(0).getCreateBy(), "create");
} }
} }

Loading…
Cancel
Save