| | |
| | | |
| | | private final static String appId = "46a23e7c5fe54f46a37848dc740dc001"; |
| | | private final static String appSecret = "AxVGmJcsfxEx36zptmr8J+sv7MAhL1mUuwrk4woGUrM="; |
| | | // 测试key |
| | | // private final static String appId = "30980cc0e70246df89f8b96b609db055"; |
| | | // private final static String appSecret = "tZnrux6iKg0DWjFA8Pohf/ht4ARIREv2oHpRbSF/5us="; |
| | | |
| | | private final static String method = "post"; |
| | | |
| | | @PostMapping("/userpush") |
| | | public Object userPush(@RequestBody ApiPushDTO apiPushDTO, HttpServletRequest request) { |
| | | System.out.println("请求参数:" + JSON.toJSONString(apiPushDTO)); |
| | | Map<String, Object> ret = new HashMap<>(); |
| | | |
| | | String clientId = request.getParameter("clientId"); |
| | |
| | | |
| | | int pcount = Runtime.getRuntime().availableProcessors(); |
| | | //最大线程数控制 |
| | | int maxthreadNum = accountBeanList.size(); |
| | | int maxthreadNum = 30; |
| | | ExecutorService executor = new ThreadPoolExecutor(pcount, maxthreadNum, 10, TimeUnit.SECONDS, |
| | | new ArrayBlockingQueue<>(1000), Executors.defaultThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy()); |
| | | System.out.println("开始执行用户处理!!!!!!!!!!!!"); |
| | | //循环list |
| | | for (int i = 0; i < maxthreadNum; i++) { |
| | | final int index = i; |
| | | final AccountBean accountBean = accountBeanList.get(i); |
| | | executor.execute(() -> { |
| | | //业务处理 |
| | | |
| | | executor.execute(() -> { |
| | | //业务处理 |
| | | //循环list |
| | | for (int i = 0; i < maxthreadNum; i++) { |
| | | final int index = i; |
| | | final AccountBean accountBean = accountBeanList.get(i); |
| | | System.out.println("当前线程:" + Thread.currentThread().getName() + " " + index); |
| | | System.out.println("当前处理对象:" + JSON.toJSONString(accountBean)); |
| | | asyncUserGo(accountBean); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | |
| | | // 关闭线程池 |
| | | executor.shutdown(); |
| | | |
| | |
| | | userService.save(saveUser); |
| | | } |
| | | } else { |
| | | //在,看status状态,若为1则删除用户。0更新? |
| | | if (accountBean.getStatus().equals("1")) { |
| | | userService.removeUser(accountBean.getPrincipalId()); |
| | | } else { //更新 |
| | | //在,看status状态,若为1则删除用户。0更新? 先不删除 |
| | | // if (accountBean.getStatus().equals("1")) { |
| | | // userService.removeUser(accountBean.getPrincipalId()); |
| | | // } else { //更新 |
| | | //设置姓名 |
| | | one.setRealName(accountBean.getAttributes().get("realName")); |
| | | one.setName(accountBean.getAttributes().get("realName")); |
| | | userService.updateUser(one); |
| | | } |
| | | // } |
| | | } |
| | | |
| | | } |