package com.chinacreator.process.dao;

import com.chinacreator.process.util.DataSource;
import com.frameworkset.common.poolman.SQLExecutor;
import org.springframework.stereotype.Component;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

@Component
public class QueryCapOrderDao {


    public List<HashMap> findCapList()throws SQLException {
        String sql = " select * from TL_QUERYCAP_ORDER where  INSERTTIME>sysdate-1/24/60  and CEIL((sysdate-INSERTTIME)*24*60*60)>5 and status!='0' and  RESPPARAMS is null  and  cnt=0\n" +
                "union \n" +
                "select * from TL_QUERYCAP_ORDER where  INSERTTIME>sysdate-1/24/60  and CEIL((sysdate-INSERTTIME)*24*60*60)>19 and status!='0' and  RESPPARAMS is null  and  cnt=1 ";
        return  SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
    }

    public void updateStatus(String status ,String id) throws SQLException {
        String sql="update TL_QUERYCAP_ORDER  set status= ? , cnt=cnt+1 , QRYTIME=SYSDATE where id= ?  ";
        SQLExecutor.updateWithDBName(DataSource.NET3G,sql,status,id);
    }

}
