| | |
| | | import com.sandu.ximon.admin.utils.request.LoginRequestParams; |
| | | import com.sandu.ximon.admin.utils.response.CommonResponseVO; |
| | | import com.sandu.ximon.admin.utils.response.DataResponseVO; |
| | | import com.sandu.ximon.admin.vo.*; |
| | | import com.sandu.ximon.admin.vo.IDResponseVO; |
| | | import com.sandu.ximon.admin.vo.LoginResponseVO; |
| | | import com.sandu.ximon.admin.vo.TaskVO; |
| | | |
| | | |
| | | public class TaskAPIUtils { |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | |
| | | IDResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("data",taskVO) |
| | | .put("data", taskVO) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.ADD_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | IDResponseVO.class |
| | | ); |
| | | |
| | | if("access id 错误".equals(responseVO.getMsg())){ |
| | | if ("access id 错误".equals(responseVO.getMsg())) { |
| | | //去获取TOKEN或者ID |
| | | LoginResponseVO responseVO3 = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | System.out.println(responseVO1); |
| | | System.out.println("---------------------------------------------------------"); |
| | |
| | | IDResponseVO responseVO2 = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("data",taskVO)// responseVO1.toString(), |
| | | .put("data", taskVO)// responseVO1.toString(), |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.ADD_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | |
| | | //重新请求数据 |
| | | } |
| | | |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return responseVO.getId(); |
| | | } |
| | | return 0; |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | DataResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("id", taskId) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.GET_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | DataResponseVO.class |
| | | ); |
| | | |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | TaskVO taskVO = responseVO.convert(TaskVO.class); |
| | | return taskVO; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 删除任务 |
| | | * |
| | | * @param taskId |
| | | * @return 0: 成功 1:任务不处于空闲状态 2:服务器删除失败 |
| | | */ |
| | | public static Integer delTask(Integer taskId) { |
| | | |
| | | TaskVO task = getTask(taskId); |
| | | if(task == null) { |
| | | if (task == null) { |
| | | return 0; |
| | | } |
| | | if(0 != task.getExe()) { |
| | | if (0 != task.getExe()) { |
| | | return 1; |
| | | }else { |
| | | } else { |
| | | LoginResponseVO responseVO1 = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new LoginRequestParams( |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | CommonResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("id", taskId) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.DEL_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | CommonResponseVO.class |
| | | ); |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return 0; |
| | | }else{ |
| | | } else { |
| | | return 2; |
| | | } |
| | | } |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | CommonResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("id", taskId) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.RUN_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | CommonResponseVO.class |
| | | ); |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | CommonResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("id", taskId) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.END_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | CommonResponseVO.class |
| | | ); |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | |
| | | /** |
| | | * 暂停 |
| | | * |
| | | * @param taskId |
| | | * @return |
| | | */ |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | CommonResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("id", taskId) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.PAUSE_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | CommonResponseVO.class |
| | | ); |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | |
| | | /** |
| | | * 继续 |
| | | * |
| | | * @param taskId |
| | | * @return |
| | | */ |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | CommonResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("id", taskId) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.PLAY_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | CommonResponseVO.class |
| | | ); |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | |
| | | public static Integer updateTask(Integer taskId, Integer defaultVolumn) { |
| | | TaskVO task = getTask(taskId); |
| | | if(task == null) { |
| | | if (task == null) { |
| | | return 0; |
| | | } |
| | | if(0 != task.getExe()) { |
| | | if (0 != task.getExe()) { |
| | | return 1; |
| | | }else { |
| | | } else { |
| | | task.setVol(defaultVolumn); |
| | | LoginResponseVO responseVO1 = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | CommonResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("data",task) |
| | | .put("id", taskId) |
| | | .put("data", task) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.UPDATE_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | CommonResponseVO.class |
| | | ); |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return 0; |
| | | }else{ |
| | | } else { |
| | | return 2; |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 更新任务 |
| | | * |
| | | * @param taskId |
| | | * @param |
| | | * @return 0:成功 1:服务器无该任务 2:任务正在执行,无法修改 3:服务器修改失败 |
| | | * @return 0:成功 1:服务器无该任务 2:任务正在执行,无法修改 3:服务器修改失败 |
| | | */ |
| | | public static Integer updateTask(// |
| | | Integer taskId, IpVolumeMissionParam param) { |
| | | Integer taskId, IpVolumeMissionParam param) { |
| | | |
| | | TaskVO task = getTask(taskId); |
| | | if(task == null) { |
| | | if (task == null) { |
| | | return 1; |
| | | } |
| | | if(0 != task.getExe()) { |
| | | if (0 != task.getExe()) { |
| | | return 2; |
| | | }else { |
| | | } else { |
| | | task.setName(param.getMissionName()); |
| | | task.setVol(param.getMissionVolume()); |
| | | task.setBdate(param.getOnDate()); |
| | |
| | | task.setTerminals(param.getTerminals()); |
| | | task.setFiles(param.getFiles()); |
| | | task.setExec(param.getExec()); |
| | | task.setWeek(Integer.parseInt(param.getWeek(), 2)); |
| | | |
| | | LoginResponseVO responseVO1 = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | |
| | | ).getParams(), |
| | | BroadcastAPI.LOGIN.getUrl(), CharUtils.UTF8 |
| | | ) |
| | | ,LoginResponseVO.class |
| | | , LoginResponseVO.class |
| | | ); |
| | | CommonResponseVO responseVO = JSON.parseObject( |
| | | BroadcastPostUtils.Post( |
| | | new CommonRequestParams() |
| | | .put("id",taskId) |
| | | .put("data",task) |
| | | .put("id", taskId) |
| | | .put("data", task) |
| | | .getKey(responseVO1), |
| | | BroadcastAPI.UPDATE_TASK.getUrl(), |
| | | CharUtils.UTF8), |
| | | CommonResponseVO.class |
| | | ); |
| | | if(responseVO.isOK()){ |
| | | if (responseVO.isOK()) { |
| | | return 0; |
| | | }else{ |
| | | } else { |
| | | return 3; |
| | | } |
| | | } |