SqlServer数据导入mysql数据库

代码中有注释

    @Override
    public void test6() throws Exception {
        Connection sqlServerConn = null;
        Connection mysqlConn = null;
        Statement sqlServerStmt = null;
        PreparedStatement mysqlPstmt = null;
        PreparedStatement mysqlPstmt2 = null;
        PreparedStatement mysqlPstmt3 = null;
        PreparedStatement mysqlPstmt4 = null;
        PreparedStatement mysqlPstmt5 = null;
        ResultSet rs = null;
        ResultSet ss = null;
        ResultSet per = null;
        ResultSet perpid = null;
        ResultSet perpids = null;
        try {
            // 连接SqlServer数据库
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            sqlServerConn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=dbo", "aa", "aa");
            sqlServerStmt = sqlServerConn.createStatement();

            // 连接MySQL数据库
            Class.forName("com.mysql.cj.jdbc.Driver");
            mysqlConn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/ghrj-cwrj-dz?serverTimezone=UTC&useSSL=false", "root", "123456");
            mysqlPstmt = mysqlConn.prepareStatement("INSERT INTO pay_reimbursement_head (ID, IS_ENABLED ,COMPANY_ID,DEPARTMENT_ID,DEPARTMENT_NAME,YEAR,NUM,PROPOSER_NAME,CREATOR,CREATE_DT,UPDATER,UPDATE_DT,FOLDER_ID,APPROVAL_STATUS,PID,MONEY,TYPE,REMARK,IS_IMPORT,IS_PAYMENT_EXCEL,IS_PRINT,IS_SUPPLEMENT_ACCESSORIES,ACCOUNT_ID,ACCOUNT_ITEM_ID,VOUCHER,POSTSCRIPT,VOUCHER_ID,IS_ADVANCE_CHARGE) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            mysqlPstmt2 = mysqlConn.prepareStatement("INSERT INTO pay_reimbursement_item (ID, IS_ENABLED ,CREATOR,CREATE_DT,UPDATER,UPDATE_DT,REIMBURSEMENT_ID,BUDGET_ITEM_ID,EXPENSE_ITEM_ID,SUBJECT_ID,MONEY,DESCRIPTION,EXPENSE_CHECK,PER_CAPITA,SUBJECTS_CD,SUBJECTS_NM,SPENDING_CONTENT_ID) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            mysqlPstmt3 = mysqlConn.prepareStatement("INSERT INTO pay_reimbursement_person (ID, IS_ENABLED ,CREATOR,CREATE_DT,UPDATER,UPDATE_DT,REIMBURSEMENT_ID,BANK,ACCOUNT,NAME,MONEY,IS_PAYMENT,PAYMENT_DT) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
            mysqlPstmt4 = mysqlConn.prepareStatement("INSERT INTO wf_objectify (ID, DEPLOY_ID,TYPE,IS_ENABLED,CREATOR,CREATE_DT,UPDATER,UPDATE_DT,OBJECT_ID,COMPANY_ID,ACCOUNT_ID,ACCOUNT_ITEM_ID,NAME,DEPARTMENT_NAME) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            mysqlPstmt5 = mysqlConn.prepareStatement("INSERT INTO wf_objectify_item (ID, OBJECTIFY_ID,DEPLOYITEMITEM_ID,USER_ID,USER_NAME,REMARK,IS_ENABLED,CREATOR,WORKFLOW_DT,CREATE_DT,UPDATER,UPDATE_DT,OPINION,NAME,URL,TYPE) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

            // 从SqlServer中读取数据
            rs = sqlServerStmt.executeQuery("SELECT \n" +
                    "                        H.ID, \n" +
                    "                        H.REIMBURSE_NUM,\n" +
                    "                        H.ORG_ID,\n" +
                    "                    ORG.NM1 AS NM1,\n" +
                    "                        H.REIMBURSE_MONEY,\n" +
                    "                        H.STATUS_CLS,\n" +
                    "                        H.FOLDER_ID,\n" +
                    "                        H.IS_ENABLED,\n" +
                    "                        H.PID,\n" +
                    "                        H.CREATOR,\n" +
                    "                        U.USER_NM as CREATOR_NAME,\n" +
                    "                        us.USER_NM as UPDATER_NAME,\n" +
                    "                        H.UPDATER,\n" +
                    "                        H.CREATOR_DT,\n" +
                    "                        H.UPDATE_DT,\n" +
                    "                        H.REMARK,\n" +
                    "                        H.BILL_FILL,\n" +
                    "                        H.FILL_PRPPOSER,\n" +
                    "                    tianbao.USER_NM as tinabaoname,\n" +
                    "                        H.IS_IMPORT,\n" +
                    "                        H.IS_PAYMENT,\n" +
                    "                        H.IS_PAYMENT_DT,\n" +
                    "                        H.IS_IMPORT_DT,\n" +
                    "                        H.PHONE,\n" +
                    "                        H.DURATION_TYPE,\n" +
                    "                        H.FAILURE_NOTE,\n" +
                    "                        H.BX_WORKFLOW,\n" +
                    "                        H.NUMBER \n" +
                    "                    FROM \n" +
                    "                        T_REIMBURSE_HEAD H\n" +
                    "                        LEFT JOIN M_USER U ON U.ID = H.CREATOR\n" +
                    "                    LEFT JOIN M_USER us on us.id = h.UPDATER\n" +
                    "                    LEFT JOIN M_ORGANIZATION ORG ON ORG.ID=H.ORG_ID\n" +
                    "                    LEFT JOIN M_USER tianbao on tianbao.id= h.FILL_PRPPOSER\n" +
                    "\t\t\t\t\t\t\t\t\t\twhere h.CREATOR_DT >'2022-12-31 23:59:59' and H.IS_ENABLED=1;");
            while (rs.next()) {
                long newId = CommonFields.getSnowflakeId();

                // 获取数据
                String id = rs.getString("id");
                String REIMBURSE_NUM = rs.getString("REIMBURSE_NUM");
                String ORG_ID = rs.getString("ORG_ID");
                String NM1 = rs.getString("NM1");
                String CREATOR_NAME = rs.getString("CREATOR_NAME");
                String UPDATER_NAME = rs.getString("UPDATER_NAME");
                BigDecimal REIMBURSE_MONEY = rs.getBigDecimal("REIMBURSE_MONEY");
                String STATUS_CLS = rs.getString("STATUS_CLS");
                String FOLDER_ID = rs.getString("FOLDER_ID");
                String IS_ENABLED = rs.getString("IS_ENABLED");
                String PID = rs.getString("PID");
                String CREATOR = rs.getString("CREATOR");

                String UPDATER = rs.getString("UPDATER");
                Date CREATOR_DT = rs.getTimestamp("CREATOR_DT");
                Date UPDATE_DT = rs.getTimestamp("UPDATE_DT");
                String REMARK = rs.getString("REMARK");
                String BILL_FILL = rs.getString("BILL_FILL");
                String FILL_PRPPOSER = rs.getString("FILL_PRPPOSER");
                String tinabaoname = rs.getString("tinabaoname");
                int IS_IMPORT = rs.getInt("IS_IMPORT");
                String IS_PAYMENT = rs.getString("IS_PAYMENT");
                String IS_PAYMENT_DT = rs.getString("IS_PAYMENT_DT");
                String PHONE = rs.getString("PHONE");
                String DURATION_TYPE = rs.getString("DURATION_TYPE");
                String BX_WORKFLOW = rs.getString("BX_WORKFLOW");
                String pids = rs.getString("pid");
                DateFormat sqlServerDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                DateFormat mysqlDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Date CREATORDT = sqlServerDateFormat.parse(String.valueOf(CREATOR_DT));
                Date UPDATEDT = sqlServerDateFormat.parse(String.valueOf(UPDATE_DT));
                // 生成新的ID
                Long pid = CommonFields.getSnowflakeId();
                Long folderId = CommonFields.getSnowflakeId();
                String APPROVAL_STATUS = STATUS_CLS.substring(1);
                // 插入到MySQL中
                mysqlPstmt.setLong(1, newId);
                mysqlPstmt.setInt(2, Integer.parseInt(IS_ENABLED));
                mysqlPstmt.setLong(3, 1);
                mysqlPstmt.setString(5,NM1);


                String mysqlbumen = "SELECT * FROM back_department WHERE NAME = ?";
                PreparedStatement mysqlStmtbumen = mysqlConn.prepareStatement(mysqlbumen);
                mysqlStmtbumen.setString(1, NM1);
                ResultSet mysqlRsbumen = mysqlStmtbumen.executeQuery();
                while (mysqlRsbumen.next()) {
                    String bumenId = mysqlRsbumen.getString("id");
                    mysqlPstmt.setLong(4, Long.parseLong(bumenId));
                }


                mysqlPstmt.setInt(6, Integer.parseInt(DURATION_TYPE));
                mysqlPstmt.setString(7, REIMBURSE_NUM);
                mysqlPstmt.setString(8, tinabaoname);
                String cruserId = null;
                String mysqlSql = "SELECT * FROM sys_user WHERE name = ?";
                PreparedStatement mysqlStmt = mysqlConn.prepareStatement(mysqlSql);
                mysqlStmt.setString(1, CREATOR_NAME);
                ResultSet mysqlRs = mysqlStmt.executeQuery();
                while (mysqlRs.next()) {
                    cruserId = mysqlRs.getString("id");
                    mysqlPstmt.setLong(9, Long.parseLong(cruserId));
                }
                mysqlPstmt.setString(10, mysqlDateFormat.format(CREATORDT));
                String mysqlSql2 = "SELECT * FROM sys_user WHERE name = ?";
                PreparedStatement mysqlStmt2 = mysqlConn.prepareStatement(mysqlSql2);
                mysqlStmt2.setString(1, UPDATER_NAME);
                ResultSet mysqlRs2 = mysqlStmt2.executeQuery();
                String UPDATERId = null;
                while (mysqlRs2.next()) {
                     UPDATERId = mysqlRs2.getString("id");
                    mysqlPstmt.setLong(11, Long.parseLong(UPDATERId));
                }

                mysqlPstmt.setString(12, mysqlDateFormat.format(UPDATEDT));
                mysqlPstmt.setLong(13, folderId);
                mysqlPstmt.setInt(14, Integer.parseInt(APPROVAL_STATUS));
                mysqlPstmt.setLong(15, pid);
                mysqlPstmt.setBigDecimal(16, REIMBURSE_MONEY);
                mysqlPstmt.setString(17, BILL_FILL);
                mysqlPstmt.setString(18, REMARK);
                mysqlPstmt.setInt(19, IS_IMPORT);
                mysqlPstmt.setInt(20, 0);
                mysqlPstmt.setInt(21, 0);
                mysqlPstmt.setInt(22, 0);
                mysqlPstmt.setLong(23, 223947000432l);
                mysqlPstmt.setLong(24, 223947000496l);
                mysqlPstmt.setInt(25, 0);
                mysqlPstmt.setString(26, "");
                mysqlPstmt.setLong(27, 0);
                mysqlPstmt.setInt(28, 0);
                mysqlPstmt.executeUpdate();
                PreparedStatement stmt = sqlServerConn.prepareStatement("SELECT\n" +
                        "i.ID, \n" +
                        "i.REIMBURSE_CD, \n" +
                        "i.BSUBJECT_ID, \n" +
                        "(SELECT BSUBJECT_NM from M_BUDGET_SUBJECT WHERE id =i.BSUBJECT_ID) as kemu,\n" +
                        "i.BUDGET_CD, \n" +
                        "(SELECT nm1 FROM M_ORGANIZATION WHERE id=(SELECT  head.ORG_ID from T_BUDGET_LINE item  \n" +
                        "left join T_BUDGET_HEAD head on item.BUDGET_CD=head.id\n" +
                        "WHERE item.id =i.BUDGET_CD))\n" +
                        "as yusuan,\n" +
                        "i.EXPENSE_ID, \n" +
                        "i.REPAYMENT_ID, \n" +
                        "i.REIMBURSE_MONEY, \n" +
                        "i.REPAY_MONEY, \n" +
                        "i.IS_ENABLED, \n" +
                        "i.PID, \n" +
                        "i.CREATOR, \n" +
                        "i.UPDATER, \n" +
                        "i.CREATOR_DT, \n" +
                        "i.UPDATE_DT, \n" +
                        "i.REMARK, \n" +
                        "i.STATUS_CLS, \n" +
                        "i.BORROW_ID, \n" +
                        "i.BORROW_MONEY, \n" +
                        "i.WAIT_MONEY, \n" +
                        "i.SPENDING_CONTENT_ID,\n" +
                        "(SELECT SCONTENT_NM FROM M_SPENDING_CONTENT where id =i.SPENDING_CONTENT_ID) as SCONTENT_NM\n" +
                        "FROM\n" +
                        "T_REIMBURSE_LINE i where i.REIMBURSE_CD = ?");
                stmt.setString(1, id);
                ss = stmt.executeQuery();
                while (ss.next()) {
                    String ids = ss.getString("id");
                    String REIMBURSE_CD = ss.getString("REIMBURSE_CD");
                    String BSUBJECT_ID = ss.getString("BSUBJECT_ID");
                    String kemu = ss.getString("kemu");
                    String BUDGET_CD = ss.getString("BUDGET_CD");
                    String yusuan = ss.getString("yusuan");
                    String EXPENSE_ID = ss.getString("EXPENSE_ID");
                    String REPAYMENT_ID = ss.getString("REPAYMENT_ID");
                    BigDecimal REIMBURSE_MONEYi = ss.getBigDecimal("REIMBURSE_MONEY");
                    String REPAY_MONEY = ss.getString("REPAY_MONEY");
                    String IS_ENABLEDi = ss.getString("IS_ENABLED");
                    String CREATOR_DTi = ss.getString("CREATOR_DT");
                    String UPDATE_DTi = ss.getString("UPDATE_DT");
                    String REMARKi = ss.getString("REMARK");
                    String BORROW_ID = ss.getString("BORROW_ID");
                    String BORROW_MONEY = ss.getString("BORROW_MONEY");
                    String SCONTENT_NM = ss.getString("SCONTENT_NM");
                    String WAIT_MONEY = ss.getString("WAIT_MONEY");
                    String SPENDING_CONTENT_ID = ss.getString("SPENDING_CONTENT_ID");
                    DateFormat sqlServerDateFormats = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                    DateFormat mysqlDateFormats = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date CREATOR_DTit = sqlServerDateFormats.parse(String.valueOf(CREATOR_DTi));
                    Date UPDATE_DTit = sqlServerDateFormats.parse(String.valueOf(UPDATE_DTi));
                    // 生成新的ID
                    long newIds = CommonFields.getSnowflakeId();
                    // 插入到MySQL中
                    mysqlPstmt2.setLong(1, newIds);
                    mysqlPstmt2.setLong(2, Long.parseLong(IS_ENABLEDi));
                    mysqlPstmt2.setLong(3, Long.parseLong(cruserId));
                    mysqlPstmt2.setString(4, mysqlDateFormats.format(CREATOR_DTit));
                    mysqlPstmt2.setLong(5, Long.parseLong(UPDATERId));
                    mysqlPstmt2.setString(6, mysqlDateFormats.format(UPDATE_DTit));
                    mysqlPstmt2.setLong(7, newId);
                    String mysqlSql3 = "SELECT id  FROM pay_budget_head where DEPARTMENT_NAME=? and IS_ENABLED=1";
                    PreparedStatement mysqlStmt3 = mysqlConn.prepareStatement(mysqlSql3);
                    mysqlStmt3.setString(1, yusuan);
                    ResultSet mysqlRs3 = mysqlStmt3.executeQuery();
                    while (mysqlRs3.next()) {
                        String budgetid = mysqlRs3.getString("id");
                        mysqlPstmt2.setLong(8, Long.parseLong(budgetid));
                    }
                    mysqlPstmt2.setLong(8, 1);
                    mysqlPstmt2.setLong(9,0);
                    String mysqlSql4 = "SELECT id,CD,NM FROM  pay_sys_subject where NM=?";
                    PreparedStatement mysqlStmt4 = mysqlConn.prepareStatement(mysqlSql4);
                    mysqlStmt4.setString(1, kemu);
                    ResultSet mysqlRs4 = mysqlStmt4.executeQuery();
                    while (mysqlRs4.next()) {
                        String subjectid = mysqlRs4.getString("id");
                        String subjectCD = mysqlRs4.getString("CD");
                        String subjectNm = mysqlRs4.getString("NM");
                        mysqlPstmt2.setLong(10, Long.parseLong(subjectid));
                        mysqlPstmt2.setLong(15, Long.parseLong(subjectCD));
                        mysqlPstmt2.setString(16, subjectNm);

                    }
                    mysqlPstmt2.setBigDecimal(11, REIMBURSE_MONEYi);
                    mysqlPstmt2.setString(12, REMARKi);
                    mysqlPstmt2.setInt(13, 0);
                    mysqlPstmt2.setString(14, "");
                    String mysqlSql5 = "SELECT id FROM  pay_sys_subject_cost where SCONTENT_NM=?";
                    PreparedStatement mysqlStmt5 = mysqlConn.prepareStatement(mysqlSql5);
                    mysqlStmt5.setString(1, SCONTENT_NM);
                    ResultSet mysqlRs5 = mysqlStmt5.executeQuery();
                    while (mysqlRs5.next()) {
                        String SPENDINGCONTENTID = mysqlRs5.getString("id");
                        mysqlPstmt2.setLong(17, Long.parseLong(SPENDINGCONTENTID));
                    }
                    mysqlPstmt2.executeUpdate();
                }
                PreparedStatement stmts = sqlServerConn.prepareStatement("SELECT\n" +
                        "\tID, \n" +
                        "\tPRPPOSER_ID, \n" +
                        "\tREIMBURSE_HEAD_ID, \n" +
                        "\tPRPPOSER_NAME, \n" +
                        "\tMONEY, \n" +
                        "\tIS_ENABLED, \n" +
                        "\tCREATOR, \n" +
                        "\tCREATOR_DT, \n" +
                        "\tIS_PAYMENT, \n" +
                        "\tREMARK, \n" +
                        "\tIS_PAYMENT_DT, \n" +
                        "\tACCOUNT, \n" +
                        "\tBANK, \n" +
                        "\tORDERS\n" +
                        "FROM\n" +
                        "T_REIMBURSE_HEAD_PERSON where REIMBURSE_HEAD_ID=?");
                stmts.setString(1, id);
                per = stmts.executeQuery();
                while (per.next()) {
                    String ids = per.getString("id");
                    String PRPPOSER_NAME = per.getString("PRPPOSER_NAME");
                    BigDecimal MONEY = per.getBigDecimal("MONEY");
                    Date CREATOR_DTP = per.getTimestamp("CREATOR_DT");
                    int IS_ENABLEDP = per.getInt("IS_ENABLED");
                    int IS_PAYMENTP = per.getInt("IS_PAYMENT");
                    String IS_PAYMENT_DTS = per.getString("IS_PAYMENT_DT");
                    String ACCOUNT = per.getString("ACCOUNT");
                    String BANK = per.getString("BANK");
                    DateFormat sqlServerDateFormatss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                    DateFormat mysqlDateFormats = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date CREATOR_DTSP = sqlServerDateFormatss.parse(String.valueOf(CREATOR_DTP));
                    Date IS_PAYMENT_DTP = sqlServerDateFormatss.parse(String.valueOf(IS_PAYMENT_DTS));
                    // 生成新的ID
                    long newIdss = CommonFields.getSnowflakeId();
                    // 插入到MySQL中
                    mysqlPstmt3.setLong(1, newIdss);
                    mysqlPstmt3.setInt(2, IS_ENABLEDP);
                    mysqlPstmt3.setLong(3, Long.parseLong(cruserId));
                    mysqlPstmt3.setLong(5, Long.parseLong(cruserId));
                    mysqlPstmt3.setString(4, mysqlDateFormats.format(CREATOR_DTSP));
                    mysqlPstmt3.setString(6, mysqlDateFormats.format(CREATOR_DTSP));
                    mysqlPstmt3.setLong(7, newId);
                    mysqlPstmt3.setString(8, BANK);
                    mysqlPstmt3.setString(9, ACCOUNT);
                    mysqlPstmt3.setString(10, PRPPOSER_NAME);
                    mysqlPstmt3.setBigDecimal(11, MONEY);
                    mysqlPstmt3.setInt(12, IS_PAYMENTP);
                    mysqlPstmt3.setString(13, mysqlDateFormats.format(IS_PAYMENT_DTP));
                    mysqlPstmt3.executeUpdate();
                }
                PreparedStatement stmtpid = sqlServerConn.prepareStatement("SELECT\n" +
                        "                        m.ID,\n" +
                        "                        m.TYPE,\n" +
                        "                        m.DEPLOY_ID,\n" +
                        "                        m.JUDGE_ID,\n" +
                        "                        m.IS_ENABLED,\n" +
                        "                        m.CREATOR,\n" +
                        "                        U.USER_NM,\n" +
                        "                        m.CREATOR_DT,\n" +
                        "                        m.OBJECT_ID,\n" +
                        "\t\t\t\t\t\t\t\t\t\t\t\td.NAME\n" +
                        "                        FROM\n" +
                        "                        M_OBJECTIFY m\n" +
                        "                        LEFT JOIN M_USER u on u.id=M.CREATOR\n" +
                        "                        LEFT JOIN M_DEPLOY d on d.ID=m.DEPLOY_ID\n" +
                        "                        WHERE M.ID=?");
                stmtpid.setString(1, pids);
                perpid = stmtpid.executeQuery();
                while (perpid.next()) {
                    String ids = perpid.getString("id");
                    String TYPE = perpid.getString("TYPE");
                    String lieNAME = perpid.getString("NAME");
                    String DEPLOY_ID = perpid.getString("DEPLOY_ID");
                    String JUDGE_ID = perpid.getString("JUDGE_ID");
                    int ISOB_ENABLED = perpid.getInt("IS_ENABLED");
                    String USER_NM = perpid.getString("USER_NM");
                    Date OBCREATOR_DT = perpid.getTimestamp("CREATOR_DT");
                    String OBJECT_ID = perpid.getString("OBJECT_ID");
                    DateFormat sqlServerDateFormatss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                    DateFormat mysqlDateFormats = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date piddate = sqlServerDateFormatss.parse(String.valueOf(OBCREATOR_DT));
                    // 插入到MySQL中
                    mysqlPstmt4.setLong(1, pid);
                    mysqlPstmt4.setLong(2, 0);
                    mysqlPstmt4.setString(3, TYPE);
                    mysqlPstmt4.setInt(4,ISOB_ENABLED);
                    String mysqlSql6 = "SELECT * FROM sys_user WHERE name = ?";
                    PreparedStatement mysqlStmt6 = mysqlConn.prepareStatement(mysqlSql6);
                    mysqlStmt6.setString(1, USER_NM);
                    ResultSet mysqlRs6 = mysqlStmt6.executeQuery();
                    while (mysqlRs6.next()) {
                        String OBcruserId = mysqlRs6.getString("id");
                        mysqlPstmt4.setLong(5, Long.parseLong(OBcruserId));
                        mysqlPstmt4.setLong(7, Long.parseLong(OBcruserId));
                    }
                    mysqlPstmt4.setString(6, mysqlDateFormats.format(piddate));
                    mysqlPstmt4.setString(8, mysqlDateFormats.format(piddate));
                    mysqlPstmt4.setLong(9, folderId);
                    mysqlPstmt4.setLong(10, 1);
                    mysqlPstmt4.setLong(11, 223947000432l);
                    mysqlPstmt4.setLong(12, 223947000496l);
                    mysqlPstmt4.setString(13, lieNAME);
                    mysqlPstmt4.setString(14, "工会");
                    mysqlPstmt4.executeUpdate();

                    PreparedStatement stmtpids = sqlServerConn.prepareStatement("SELECT\n" +
                            "                            m.ID, \n" +
                            "                            m.OBJECTIFY_ID, \n" +
                            "                            m.DEPLOYITEMITEM_ID, \n" +
                            "                            m.USER_ID, \n" +
                            "                            (SELECT USER_NM FROM M_USER where id = USER_ID) as userName,\n" +
                            "                            m.WORKFLOW_DT, \n" +
                            "                            m.REMARK, \n" +
                            "                            m.OPINION, \n" +
                            "                            m.GROUP_ID, \n" +
                            "                            m.IS_ENABLED, \n" +
                            "                            m.CREATOR, \n" +
                            "                            u.USER_NM,\n" +
                            "                            m.CREATOR_DT,\n" +
                            "\t\t\t\t\t\t\t\t\t\t\t\t\t\tdii.NAME\n" +
                            "                            FROM\n" +
                            "                             M_OBJECTIFYITEM  M\n" +
                            "                            LEFT JOIN M_USER U ON m.CREATOR=u.ID\n" +
                            "\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN M_DEPLOYITEMITEM dii on M.DEPLOYITEMITEM_ID=dii.ID\n" +
                            "                            where OBJECTIFY_ID =?");
                    stmtpids.setString(1, ids);
                    perpids = stmtpids.executeQuery();
                    while (perpids.next()) {
                        String idss = perpids.getString("id");
                        String USER_ID = perpids.getString("USER_ID");
                        String userNameobj = perpids.getString("userName");
                        Date WORKFLOW_DT = perpids.getTimestamp("WORKFLOW_DT");
                        String REMARKOBI = perpids.getString("REMARK");
                        int OPINION = perpids.getInt("OPINION");
                        String GROUP_ID = perpids.getString("GROUP_ID");
                        String jiedian = perpids.getString("NAME");
                        int IS_ENABLEDOBI = perpids.getInt("IS_ENABLED");
                        String USER_NMOB = perpids.getString("USER_NM");
                        Date CREATOR_DTOBI = perpids.getTimestamp("CREATOR_DT");
                        DateFormat sqlServerDateFormatsss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                        DateFormat mysqlDateFormatss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        Date wdate = sqlServerDateFormatsss.parse(String.valueOf(WORKFLOW_DT));
                        Date cdate = sqlServerDateFormatsss.parse(String.valueOf(CREATOR_DTOBI));
                        // 插入到MySQL中
                        mysqlPstmt5.setLong(1, CommonFields.getSnowflakeId());
                        mysqlPstmt5.setLong(2, pid);
                        mysqlPstmt5.setLong(3, 0);
                        String mysqlSql7 = "SELECT id FROM sys_user WHERE name = ?";
                        PreparedStatement mysqlStmt7 = mysqlConn.prepareStatement(mysqlSql7);
                        mysqlStmt7.setString(1, userNameobj);
                        ResultSet mysqlRs7 = mysqlStmt7.executeQuery();
                        while (mysqlRs7.next()) {
                            String ObiuserId = mysqlRs7.getString("id");
                            mysqlPstmt5.setLong(4, Long.parseLong(ObiuserId));
                        }
                        mysqlPstmt5.setString(5, userNameobj);
                        mysqlPstmt5.setString(6, REMARKOBI);
                        mysqlPstmt5.setInt(7, IS_ENABLEDOBI);
                        String mysqlSql8 = "SELECT id FROM sys_user WHERE name = ?";
                        PreparedStatement mysqlStmt8 = mysqlConn.prepareStatement(mysqlSql8);
                        mysqlStmt8.setString(1, USER_NMOB);
                        ResultSet mysqlRs8 = mysqlStmt8.executeQuery();
                        while (mysqlRs8.next()) {
                            String ObicruserId = mysqlRs8.getString("id");
                            mysqlPstmt5.setLong(8, Long.parseLong(ObicruserId));
                            mysqlPstmt5.setLong(11, Long.parseLong(ObicruserId));
                        }
                        mysqlPstmt5.setString(9, mysqlDateFormatss.format(wdate));
                        mysqlPstmt5.setString(10, mysqlDateFormatss.format(cdate));
                        mysqlPstmt5.setString(12, mysqlDateFormatss.format(cdate));
                        mysqlPstmt5.setInt(13, OPINION);
                        mysqlPstmt5.setString(14, jiedian);
                        mysqlPstmt5.setString(15, "测试");
                        mysqlPstmt5.setInt(16, 1);
                        mysqlPstmt5.executeUpdate();
                    }
                }
            }
        } catch (SQLException se) {
            se.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // 关闭连接和释放资源
            try {
                if (rs != null)
                    rs.close();
                if (ss != null)
                    ss.close();
            } catch (SQLException se2) {
            }
            try {
                if (sqlServerStmt != null)
                    sqlServerStmt.close();
            } catch (SQLException se3) {
            }
            try {
                if (mysqlPstmt != null)
                    mysqlPstmt.close();
            } catch (SQLException se4) {
            }
            try {
                if (sqlServerConn != null)
                    sqlServerConn.close();
            } catch (SQLException se5) {
                se5.printStackTrace();
            }
            try {
                if (mysqlConn != null)
                    mysqlConn.close();
            } catch (SQLException se6) {
                se6.printStackTrace();
            }
        }
    }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值