package com.sw.mes.yb.report.dao;


import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.report.entity.WipStorageReport;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * @Author
 * @Description：
 * @Date:
 * @Modified By:
 */
public interface WipStorageReportDao extends BaseDao<WipStorageReport, Integer> {

    @Query(value = "select     \n" +
            "processing_order_code as sectionNo,#单晶编号    \n" +
            "start_time as time,#进站时间    \n" +
            "case when (process_name='划线' and `status`=2) OR (process_name='截断' and `status`=0) then '毛棒工序'    \n" +
            "when  process_name='截断' and `status`in (0,1) then '截断工序'    \n" +
            "when  process_name='圆棒检验' and `status`in (0,1) then '圆棒检验工序'    \n" +
            "when  process_name='开方' and `status`in (0,1) then '开方工序'    \n" +
            "when  (process_name='方棒检验' and `status`in (0,1)) OR (process_name='截断' and `status`in (0,1)) then '检验包装' end as processes,    \n" +
            "case   \n" +
            "when (process_name='划线' and `status`in(1,2)) OR (process_name='截断' and `status`=0) then '毛棒'    \n" +
            "when (process_name='截断' and `status`in(1,2)) or process_name='圆棒检验' then '圆棒'   \n" +
            "when (process_name='开方' or process_name='磨削' or process_name='方棒检验') then '方棒'   \n" +
            "end as materialType,   \n" +
            "create_user_name as username,#操作人    \n" +
            "case when `status`=0 then CONCAT(process_name,'待进站')    \n" +
            "when `status`=1 then CONCAT(process_name,'已进站')    \n" +
            "when `status`=2 then CONCAT(process_name,'已出站') end as site_and_status    \n" +
            "from wip_process_detailed_info where start_time>='2023-04-01 08:30:00'", nativeQuery = true)
    List<Map<String, Object>> findAllData();
}