
package com.lideeyunji.core.framework.config.job;

import com.lideeyunji.core.framework.service.ILideeYunJiService;
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
import com.lideeyunji.tool.framework.tenant.core.aop.TenantIgnore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.*;

/**
 * 保存模块使用记录
 */
@Slf4j
@Component("anyToGrBiSasetdtl")
public class anyToGrBiSasetdtl implements JobHandler {

    @Autowired
    private ILideeYunJiService lideeYunJiService;

    @Override
    @TenantIgnore
    public String execute(String param) {
        log.info("*********** 同步销售明细 ************");
        //读取oralce数据




        String resultStr = "*********** 保存模块使用记录完成，共保存了1000条 ************";
        log.info(resultStr);
        return resultStr;
    }



    // 数据库连接信息
    private static final String URL = "jdbc:oracle:thin:@192.168.1.247:1521:gryy";
    private static final String USERNAME = "GRYYBI";
    private static final String PASSWORD = "xxb147258367";

    public static void main(String[] args) {
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;

        try {
            // 1. 加载Oracle JDBC驱动
            Class.forName("oracle.jdbc.driver.OracleDriver");
            // 2. 建立数据库连接
            conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
            // 3. 创建Statement对象
            stmt = conn.createStatement();
            // 4. 执行查询语句
            String sql = "select * from GR_BI_SA_SETDTL  where update_time > TO_DATE('2026-01-19 12:12:12',  'YYYY-MM-DD HH24:MI:SS') ORDER BY UPDATE_TIME DESC";
            rs = stmt.executeQuery(sql);
            // 5. 处理查询结果
            while (rs.next()) {
               //写入到数据中台表




                System.out.println(rs.getString("SASETTLEDTLID"));

            }

        } catch (ClassNotFoundException e) {
            System.out.println("Oracle JDBC驱动未找到！");
            e.printStackTrace();
        } catch (SQLException e) {
            System.out.println("数据库访问异常！");
            e.printStackTrace();
        } finally {
            // 6. 关闭资源
            try {
                if (rs != null) rs.close();
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}
