package market.Qms.qcm.mapper;
import java.util.List;

import market.Qms.qcm.vo.QcmChemExam;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.hnshituo.orm.GenericMapper;

public interface QcmChemExamMapper extends GenericMapper<QcmChemExam,Object> {

	@Select("select to_char(to_date(#{work_month}, 'yyyy-mm') + rownum - 1, 'yyyy-MM-dd') from dual connect by rownum <= (add_months(to_date(#{work_month}, 'yyyy-MM'), 1) -to_date(#{work_month}, 'yyyy-MM'))")
	public List<String> doQuaryDaysByMonth(@Param("work_month")String work_month);
	
	@Select("select * from (select WRK_DATE, MACHINE_CODE, CREATE_TIME, CREATE_NAME, memo,\n" +
              "       PARAM1, PARAM2, PARAM7, PARAM8, EID,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param3,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param4,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param5,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param6,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param9,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param10,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param11,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param12\n" +
              "from\n" +
              "                                                                    QCM_CHEM_EXAM\n" +
              "where memo like '%各机组故障时间%' and MACHINE_CODE = '酸洗机组'\n" +
              "  and WRK_DATE like '%' || substr\n" +
              "    (#{wrk_date}, 1, 4) || '%' order by WRK_DATE) where WRK_DATE = #{wrk_date}\n" +
              "union\n" +
              "select * from (select WRK_DATE, MACHINE_CODE, CREATE_TIME, CREATE_NAME, memo,\n" +
              "       PARAM1, PARAM2, PARAM7, PARAM8, EID,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param3,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param4,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param5,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param6,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param9,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param10,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param11,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param12\n" +
              "from\n" +
              "                                                                    QCM_CHEM_EXAM\n" +
              "where memo like '%各机组故障时间%' and MACHINE_CODE = '轧机机组'\n" +
              "  and WRK_DATE like '%' || substr\n" +
              "    (#{wrk_date}, 1, 4) || '%' order by WRK_DATE) where WRK_DATE = #{wrk_date}\n" +
              "union\n" +
              "select * from (select WRK_DATE, MACHINE_CODE, CREATE_TIME, CREATE_NAME, memo,\n" +
              "       PARAM1, PARAM2, PARAM7, PARAM8, EID,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param3,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param4,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param5,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param6,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param9,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param10,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param11,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param12\n" +
              "from\n" +
              "                                                                    QCM_CHEM_EXAM\n" +
              "where memo like '%各机组故障时间%' and MACHINE_CODE = '1500*4mm纵剪机组'\n" +
              "  and WRK_DATE like '%' || substr\n" +
              "    (#{wrk_date}, 1, 4) || '%' order by WRK_DATE) where WRK_DATE = #{wrk_date}\n" +
              "union\n" +
              "select * from (select WRK_DATE, MACHINE_CODE, CREATE_TIME, CREATE_NAME, memo,\n" +
              "       PARAM1, PARAM2, PARAM7, PARAM8, EID,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param3,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param4,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param5,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param6,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param9,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param10,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param11,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param12\n" +
              "from\n" +
              "                                                                    QCM_CHEM_EXAM\n" +
              "where memo like '%各机组故障时间%' and MACHINE_CODE = '1500*12mm纵剪机组'\n" +
              "  and WRK_DATE like '%' || substr\n" +
              "    (#{wrk_date}, 1, 4) || '%' order by WRK_DATE) where WRK_DATE = #{wrk_date}\n" +
              "union\n" +
              "select * from (select WRK_DATE, MACHINE_CODE, CREATE_TIME, CREATE_NAME, memo,\n" +
              "       PARAM1, PARAM2, PARAM7, PARAM8, EID,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param3,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param4,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param5,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param6,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param9,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param10,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param11,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param12\n" +
              "from\n" +
              "                                                                    QCM_CHEM_EXAM\n" +
              "where memo like '%各机组故障时间%' and MACHINE_CODE = '全氢罩式退火炉群'\n" +
              "  and WRK_DATE like '%' || substr\n" +
              "    (#{wrk_date}, 1, 4) || '%' order by WRK_DATE) where WRK_DATE = #{wrk_date}\n" +
              "union\n" +
              "select * from (select WRK_DATE, MACHINE_CODE, CREATE_TIME, CREATE_NAME, memo,\n" +
              "       PARAM1, PARAM2, PARAM7, PARAM8, EID,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param3,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param4,\n" +
              "       sum(PARAM1) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param5,\n" +
              "       sum(PARAM2) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param6,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param9,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 7) order by WRK_DATE) as param10,\n" +
              "       sum(PARAM7) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param11,\n" +
              "       sum(PARAM8) over (partition by substr(WRK_DATE, 1, 4) order by WRK_DATE) as param12\n" +
              "from\n" +
              "                                                                    QCM_CHEM_EXAM\n" +
              "where memo like '%各机组故障时间%' and MACHINE_CODE = '平整机组'\n" +
              "  and WRK_DATE like '%' || substr\n" +
              "    (#{wrk_date}, 1, 4) || '%' order by WRK_DATE) where WRK_DATE = #{wrk_date}")
	public List<QcmChemExam> doQuaryGZTime(@Param("wrk_date")String wrk_date);
}
