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


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

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

/**
* @Author
* @Description：
* @Date:
* @Modified By:
*/
public interface ZhxxProgressStatisticsDao extends BaseDao<ZhxxProgressStatistics, Long> {

    @Query(value = "select\n" +
            "lc.crystal_no as crystalNo,\n" +
            "di.create_time as createTime,\n" +
            "di.process_name as processName,\n" +
            "di.status,\n" +
            "lc.specs,\n" +
            "di.weight,\n" +
            "lc.wind_up as windUp, now() as time,lc.product_type as productType\n" +
            "from wip_process_detailed_info di \n" +
            "LEFT JOIN production_long_crystal lc ON di.processing_order_code=lc.crystal_no\n" +
            "WHERE 1=1\n" +
            "and di.create_time>='2023-05-01'\n" +
            "and lc.wind_up <> 'D'",nativeQuery = true)
    List<Map<String, Object>> getWoolStick();

    @Query(value = "#圆棒\n" +
            "select \n" +
            "di.processing_order_code as crystalNo,\n" +
            "di.create_time as createTime,\n" +
            "di.process_name as processName,\n" +
            "di.status,\n" +
            "lc.specs,\n" +
            "di.weight,\n" +
            "lc.wind_up as windUp,now() as time,lc.product_type as productType\n" +
            "from wip_process_detailed_info di\n" +
            "LEFT JOIN\n" +
            "(\n" +
            "select\n" +
            "ld.no,\n" +
            "pl.crystal_no\n" +
            "from production_painting_line_detail ld\n" +
            "LEFT JOIN production_painting_line pl ON ld.operate_reversecut_draw_id=pl.id\n" +
            "GROUP BY ld.no\n" +
            ")a ON a.no=di.processing_order_code\n" +
            "LEFT JOIN production_long_crystal lc ON a.crystal_no=lc.crystal_no\n" +
            "WHERE \n" +
            " di.create_time>='2023-05-01'\n" +
            "and lc.wind_up <> 'D'",nativeQuery = true)
    List<Map<String, Object>> getYbList();

    @Query(value = "#方棒\n" +
            "select \n" +
            "di.processing_order_code as crystalNo,\n" +
            "di.create_time as createTime,\n" +
            "di.process_name as processName,\n" +
            "di.status,\n" +
            "lc.specs,\n" +
            "di.weight,\n" +
            "lc.wind_up as windUp,now() as time,lc.product_type as productType\n" +
            "from\n" +
            "wip_process_detailed_info di\n" +
            "LEFT JOIN zhxx_operate_check_out_data od ON di.processing_order_code=od.fb_section_no\n" +
            "LEFT JOIN yb_inspect_data yid ON yid.section_no=od.yb_section_no\n" +
            "LEFT JOIN production_long_crystal lc ON yid.crystal_no=lc.crystal_no\n" +
            "WHERE \n" +
            "di.create_time>='2023-05-01'\n" +
            "and lc.wind_up <> 'D'",nativeQuery = true)
    List<Map<String, Object>> getFbList();
}