Skip to content

Commit

Permalink
include uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncaci committed Dec 9, 2023
1 parent 3c9bb6d commit eed31dd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>com.milmove.trdmlambda</groupId>
<artifactId>trdm-lambda</artifactId>
<version>1.0.1.4</version>
<version>1.0.1.5</version>
<name>trdm java spring interface</name>
<description>Project for deploying a Java TRDM interfacer for TGET data.</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;

import com.milmove.trdmlambda.milmove.model.TransportationAccountingCode;
import com.milmove.trdmlambda.milmove.util.SecretFetcher;
Expand Down Expand Up @@ -59,38 +60,42 @@ public Connection getConnection() throws SQLException {
// Batch insert 10k TACs at a time
public void insertTransportationAccountingCodes(List<TransportationAccountingCode> codes) throws SQLException {

String sql = "INSERT INTO transportation_accounting_codes (tac, tac_sys_id, loa_sys_id, tac_fy_txt, tac_fn_bl_mod_cd, org_grp_dfas_cd, tac_mvt_dsg_id, tac_ty_cd, tac_use_cd, tac_maj_clmt_id, tac_bill_act_txt, tac_cost_ctr_nm, buic, tac_hist_cd, tac_stat_cd, trnsprtn_acnt_tx, trnsprtn_acnt_bgn_dt, trnsprtn_acnt_end_dt, dd_actvty_adrs_id, tac_blld_add_frst_ln_tx, tac_blld_add_scnd_ln_tx, tac_blld_add_thrd_ln_tx, tac_blld_add_frth_ln_tx, tac_fnct_poc_nm) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

String sql = "INSERT INTO transportation_accounting_codes (id, tac, tac_sys_id, loa_sys_id, tac_fy_txt, tac_fn_bl_mod_cd, org_grp_dfas_cd, tac_mvt_dsg_id, tac_ty_cd, tac_use_cd, tac_maj_clmt_id, tac_bill_act_txt, tac_cost_ctr_nm, buic, tac_hist_cd, tac_stat_cd, trnsprtn_acnt_tx, trnsprtn_acnt_bgn_dt, trnsprtn_acnt_end_dt, dd_actvty_adrs_id, tac_blld_add_frst_ln_tx, tac_blld_add_scnd_ln_tx, tac_blld_add_thrd_ln_tx, tac_blld_add_frth_ln_tx, tac_fnct_poc_nm) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (Connection conn = this.getConnection(); PreparedStatement pstmt = conn.prepareStatement(sql)) {

int count = 0;

for (TransportationAccountingCode code : codes) {
if (code.getId() == null) {
code.setId(UUID.randomUUID());
}

pstmt.setString(1, code.getTac());
pstmt.setString(2, code.getTacSysID());
pstmt.setString(3, code.getLoaSysID());
pstmt.setString(4, code.getTacFyTxt());
pstmt.setString(5, code.getTacFnBlModCd());
pstmt.setString(6, code.getOrgGrpDfasCd());
pstmt.setString(7, code.getTacMvtDsgID());
pstmt.setString(8, code.getTacTyCd());
pstmt.setString(9, code.getTacUseCd());
pstmt.setString(10, code.getTacMajClmtID());
pstmt.setString(11, code.getTacBillActTxt());
pstmt.setString(12, code.getTacCostCtrNm());
pstmt.setString(13, code.getBuic());
pstmt.setString(14, code.getTacHistCd());
pstmt.setString(15, code.getTacStatCd());
pstmt.setString(16, code.getTrnsprtnAcntTx());
pstmt.setDate(17, java.sql.Date.valueOf(code.getTrnsprtnAcntBgnDt().toLocalDate()));
pstmt.setDate(18, java.sql.Date.valueOf(code.getTrnsprtnAcntEndDt().toLocalDate()));
pstmt.setString(19, code.getDdActvtyAdrsID());
pstmt.setString(20, code.getTacBlldAddFrstLnTx());
pstmt.setString(21, code.getTacBlldAddScndLnTx());
pstmt.setString(22, code.getTacBlldAddThrdLnTx());
pstmt.setString(23, code.getTacBlldAddFrthLnTx());
pstmt.setString(24, code.getTacFnctPocNm());
pstmt.setObject(1, code.getId());
pstmt.setString(2, code.getTac());
pstmt.setString(3, code.getTacSysID());
pstmt.setString(4, code.getLoaSysID());
pstmt.setString(5, code.getTacFyTxt());
pstmt.setString(6, code.getTacFnBlModCd());
pstmt.setString(7, code.getOrgGrpDfasCd());
pstmt.setString(8, code.getTacMvtDsgID());
pstmt.setString(9, code.getTacTyCd());
pstmt.setString(10, code.getTacUseCd());
pstmt.setString(11, code.getTacMajClmtID());
pstmt.setString(12, code.getTacBillActTxt());
pstmt.setString(13, code.getTacCostCtrNm());
pstmt.setString(14, code.getBuic());
pstmt.setString(15, code.getTacHistCd());
pstmt.setString(16, code.getTacStatCd());
pstmt.setString(17, code.getTrnsprtnAcntTx());
pstmt.setDate(18, java.sql.Date.valueOf(code.getTrnsprtnAcntBgnDt().toLocalDate()));
pstmt.setDate(19, java.sql.Date.valueOf(code.getTrnsprtnAcntEndDt().toLocalDate()));
pstmt.setString(20, code.getDdActvtyAdrsID());
pstmt.setString(21, code.getTacBlldAddFrstLnTx());
pstmt.setString(22, code.getTacBlldAddScndLnTx());
pstmt.setString(23, code.getTacBlldAddThrdLnTx());
pstmt.setString(24, code.getTacBlldAddFrthLnTx());
pstmt.setString(25, code.getTacFnctPocNm());
pstmt.addBatch();

// Execute every 10000 rows or when finished with the provided TACs
Expand Down

0 comments on commit eed31dd

Please sign in to comment.