package com.xdap.self_development.domain.view;

import com.definesys.mpaas.query.annotation.SQL;
import com.definesys.mpaas.query.annotation.SQLQuery;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.sql.Timestamp;

@SQLQuery(value = {
        //  CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC ,
        @SQL(view = "getAllReport",
                sql = "SELECT br.id AS \"reportId\", br.*, af.id AS \"flowId\" FROM yfsjglpt_model_benchmarking_report br LEFT JOIN ( SELECT af1.* FROM yfsjglpt_model_approval_flow af1 INNER JOIN ( SELECT template_id, MAX(created_time) AS max_create_time FROM yfsjglpt_model_approval_flow WHERE template_id IS NOT NULL GROUP BY template_id ) af2 ON af1.template_id = af2.template_id AND af1.created_time = af2.max_create_time ) af ON af.template_id = br.id WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') ORDER BY br.upload_time DESC")
})
@Data
public class TodoAndReportView {
    private String reportId;
    private String flowId;

    private String title;
    private String manufacturerName;
    private String modelName;
    private String module;
    private String manufacturerAbbreviation;
    private String modelAbbreviation;
    private String productNumber;
    private String plate;
    private String platform;
    private String series;
    private String marketSegment;
    private String projectName;
    private String projectNumber;
    private String createBy;
    private Integer returnNum;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp uploadTime;
    private String filePath;
    private String fileName;
    private String status;
}
