whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/webSocket/MyFlowWebSocket.java
@@ -4,7 +4,9 @@
import com.whyc.dto.MyFlowMainDTO;
import com.whyc.dto.Response;
import com.whyc.pojo.UserInf;
import com.whyc.pojo.WorkflowMain;
import com.whyc.service.WorkflowLinkService;
import com.whyc.service.WorkflowMainService;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -30,6 +32,8 @@
    private static WorkflowLinkService service;
    private static WorkflowMainService mainService;
    private Session session;
    private HttpSession httpSession;
@@ -37,6 +41,11 @@
    @Autowired
    public void setService(WorkflowLinkService service) {
        MyFlowWebSocket.service = service;
    }
    @Autowired
    public void setMainService(WorkflowMainService mainService) {
        MyFlowWebSocket.mainService = mainService;
    }
    @OnOpen
@@ -50,7 +59,7 @@
        MyFlowMainDTO myFlowMain = ActionUtil.getGson().fromJson(message, MyFlowMainDTO.class);
        UserInf user = (UserInf) this.httpSession.getAttribute("user");
        final int uId = user.getUId().intValue();
        //final int userId = 1087;
        //final int uId = 1086;
        thread = new Thread("Thread_myFlow") {
            @Override
            public void run() {
@@ -59,7 +68,17 @@
                    threadFlagMap.put(thread.getId(), true);
                    try {
                        if (session.isOpen()) {
                            Response response = service.getFlowMainByUid(uId, myFlowMain.getType(), myFlowMain.getStatus(), myFlowMain.getPageNum(), myFlowMain.getPageSize());
                            Response response = new Response();
                            try {
                                Map<String, Response> resMap = new HashMap<>();
                                Response resInfo = service.getFlowMainByUid(uId, myFlowMain.getType(), myFlowMain.getStatus(), myFlowMain.getPageNum(), myFlowMain.getPageSize());
                                resMap.put("info", resInfo);
                                Response<Map<Integer, Integer>> ownStatistics = mainService.getOwnStatistics2(uId, myFlowMain.getType());
                                resMap.put("statistics", ownStatistics);
                                response.set(1,resMap);
                            }catch (Exception e){
                                response.set(0,"发生异常:"+e.toString());
                            }
                            //推送信息
                            synchronized (session) {
                                session.getBasicRemote().sendObject(response);