package cc.smtweb.biz.mztb.web.task;

import cc.smtweb.biz.mztb.web.base.DbSourceConfig;
import cc.smtweb.biz.mztb.web.tool.DbUtil;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.system.bpm.web.sys.base.job.BaseJob;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import lombok.SneakyThrows;

import java.lang.invoke.SwitchPoint;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class AddNewPartyAndAccountTask extends BaseJob {

    @Override
    protected String work() {
        // 查询前置库推送的机构和账号信息
        DbEngine instance = DbEngine.getInstance();
        DbSourceConfig dbSourceConfig = instance.findDao(DbSourceConfig.class).queryEntityWhere("dsc_use_state = 0");
        Connection connection = null;
        ResultSet resultSet = null;
        List<SwMap> partys = new ArrayList<>();
        try {
            connection = DriverManager.getConnection(dbSourceConfig.getWholeUrl(), dbSourceConfig.getUsername(), dbSourceConfig.getPassword());
            DbUtil dbUtil = new DbUtil(connection);
            resultSet = dbUtil.dbHandSql("", "query"); // 查询机构信息系
            if(resultSet != null) {
                while (resultSet.next()) {
                    SwMap party = new SwMap();
                    partys.add(party);
                }
                return null;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        // 在当前系统 建立机构和账号数据,将账号信息写入缓存
        return null;
    }
}
