| | |
| | | return new Response<Map<Integer,Integer>>().set(1,statistics); |
| | | } |
| | | |
| | | /** |
| | | * 增加了全部 key=0 |
| | | * @param userId |
| | | * @param type |
| | | * @see com.whyc.constant.WorkflowEnum |
| | | * |
| | | * @return |
| | | */ |
| | | public Response<Map<Integer,Integer>> getOwnStatistics2(int userId, int type) { |
| | | Map<Integer,Integer> statistics = new HashMap<>(); |
| | | statistics.put(0,0); |
| | | statistics.put(1,0); |
| | | statistics.put(2,0); |
| | | statistics.put(3,0); |
| | | QueryWrapper<WorkflowMain> query = Wrappers.query(); |
| | | query.eq("create_user_id",userId); |
| | | List<WorkflowMain> mains = mapper.selectList(query); |
| | | Map<Integer, List<WorkflowMain>> statusListMap = mains.stream().collect(Collectors.groupingBy(WorkflowMain::getStatus)); |
| | | Set<Integer> statusSet = statusListMap.keySet(); |
| | | int sum = 0; |
| | | for (Integer status : statusSet) { |
| | | int size = statusListMap.get(status).size(); |
| | | statistics.put(status, size); |
| | | sum+=size; |
| | | } |
| | | statistics.put(0,sum); |
| | | return new Response<Map<Integer,Integer>>().set(1,statistics); |
| | | } |
| | | |
| | | public Response<PageInfo<WorkflowMain>> ownListPage(int userId, int type, int status, int pageNum, int pageSize) { |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<WorkflowMain> mains = getOwnListByUserAndType(userId,type,status); |
| | |
| | | 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; |
| | |
| | | |
| | | private static WorkflowLinkService service; |
| | | |
| | | private static WorkflowMainService mainService; |
| | | |
| | | private Session session; |
| | | |
| | | private HttpSession httpSession; |
| | |
| | | @Autowired |
| | | public void setService(WorkflowLinkService service) { |
| | | MyFlowWebSocket.service = service; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setMainService(WorkflowMainService mainService) { |
| | | MyFlowWebSocket.mainService = mainService; |
| | | } |
| | | |
| | | @OnOpen |
| | |
| | | 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, 3); |
| | | resMap.put("statistics", ownStatistics); |
| | | response.set(1,resMap); |
| | | }catch (Exception e){ |
| | | response.set(0,"发生异常:"+e.toString()); |
| | | } |
| | | //推送信息 |
| | | synchronized (session) { |
| | | session.getBasicRemote().sendObject(response); |