Search in sources :

Example 1 with IndexApplicationTodayResponse

use of com.webank.wedatasphere.qualitis.response.IndexApplicationTodayResponse in project Qualitis by WeBankFinTech.

the class IndexController method getTodaySubmitApplications.

/**
 * Paging get applications information that was submitted today.
 * Including details of applications
 * @return
 */
@POST
@Path("application/today")
@Produces(MediaType.APPLICATION_JSON)
public GeneralResponse<?> getTodaySubmitApplications(@Context HttpServletRequest httpServletRequest, PageRequest pageRequest) throws UnExpectedRequestException {
    PageRequest.checkRequest(pageRequest);
    String user = HttpUtils.getUserName(httpServletRequest);
    try {
        IndexApplicationTodayResponse response = indexService.getTodaySubmitApplications(user, pageRequest);
        return new GeneralResponse<>("200", "{&QUERY_SUCCESSFULLY}", response);
    } catch (Exception e) {
        LOG.error("[Home overview]Failed to query API: application/today, internal error", e);
        return new GeneralResponse<>("500", e.getMessage(), -1);
    }
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) IndexApplicationTodayResponse(com.webank.wedatasphere.qualitis.response.IndexApplicationTodayResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 2 with IndexApplicationTodayResponse

use of com.webank.wedatasphere.qualitis.response.IndexApplicationTodayResponse in project Qualitis by WeBankFinTech.

the class IndexServiceImpl method getTodaySubmitApplications.

@Override
public IndexApplicationTodayResponse getTodaySubmitApplications(String username, PageRequest pageRequest) {
    // Find applications submitted today
    String today = DateFormatUtils.format(new Date(), DATE_FORMAT_PATTERN);
    List<Application> applications = getUserApplications(username, today, pageRequest);
    if (applications == null || applications.isEmpty()) {
        LOGGER.info("[Home overview]user:{},date:{},The user and the task submitted by the specified date were not found.", username, today);
        return null;
    }
    // Get total num of applications today
    long totalNum = countUserApplications(username, today);
    // Get successful total num of applications today
    long totalSuccNum = countUserSuccApplications(username, today);
    // Get failed total num of applications today
    long totalFailNum = countUserFailApplications(username, today);
    // Get not pass total num of applications today
    long totalFailCheckNum = countUserFailCheckApplications(username, today);
    LOGGER.info("[Home overview]user:{},date:{},Find {} tasks submitted by the user's specified date, for a total of {}.", username, today, applications.size(), totalNum);
    List<IndexApplicationResponse> applicationResponses = new ArrayList<>();
    for (Application application : applications) {
        List<Task> tasks = taskDao.findByApplication(application);
        IndexApplicationResponse applicationResponse = new IndexApplicationResponse(application, tasks);
        applicationResponses.add(applicationResponse);
    }
    return new IndexApplicationTodayResponse(applicationResponses, totalNum, totalSuccNum, totalFailNum, totalFailCheckNum);
}
Also used : Task(com.webank.wedatasphere.qualitis.entity.Task) IndexApplicationTodayResponse(com.webank.wedatasphere.qualitis.response.IndexApplicationTodayResponse) IndexApplicationResponse(com.webank.wedatasphere.qualitis.response.IndexApplicationResponse) ArrayList(java.util.ArrayList) Application(com.webank.wedatasphere.qualitis.entity.Application) Date(java.util.Date)

Aggregations

IndexApplicationTodayResponse (com.webank.wedatasphere.qualitis.response.IndexApplicationTodayResponse)2 Application (com.webank.wedatasphere.qualitis.entity.Application)1 Task (com.webank.wedatasphere.qualitis.entity.Task)1 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)1 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)1 IndexApplicationResponse (com.webank.wedatasphere.qualitis.response.IndexApplicationResponse)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1