Add files via upload

This commit is contained in:
gopi17701 2018-08-22 17:29:56 -04:00 committed by GitHub
parent 6250697684
commit 1c623512d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 12 deletions

View File

@ -10,6 +10,7 @@ import java.io.InputStream;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.text.ParseException;
import java.util.List;
import java.util.Properties;
@ -92,15 +93,15 @@ public abstract class DAO {
*/
public abstract void connect() throws AstuteException;
public abstract List<PO> getPOMaster(String PONum, String contractNum, java.sql.Date PODate, String astuteProjectNumber) throws AstuteException;
public abstract List<PO> getPOMaster(String PONum, String contractNum, String PODate, String astuteProjectNumber) throws AstuteException;
public abstract List<PODetail> getPODetail(String PONum, int lineItemNo) throws AstuteException;
public abstract void updatePOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt, String astuteProjectNumber, String title) throws AstuteException;
public abstract void updatePOMaster(String PONum, String contractNum, String PODate, Double contractAmt, String astuteProjectNumber, String title) throws AstuteException;
public abstract void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId, Double remainingQuantity) throws AstuteException;
public abstract void createPOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt, String customerId, String astuteProjectNumber, String title) throws AstuteException;
public abstract void createPOMaster(String PONum, String contractNum, String PODate, Double contractAmt, String customerId, String astuteProjectNumber, String title) throws AstuteException, ParseException;
public abstract void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId, Double remainingQuantity) throws AstuteException;

View File

@ -10,9 +10,11 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.sql.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.text.SimpleDateFormat;
import static com.astute.exceptions.AstuteException.DB_ERROR;
@ -36,17 +38,17 @@ public class SqlDAO extends DAO {
=============================== PO Methods ===============================================
*/
public List<PO> getPOMaster(String PONum, String contractNum, Date PODate, String astuteProjectNumber) throws AstuteException {
public List<PO> getPOMaster(String PONum, String contractNum, String PODate, String astuteProjectNumber) throws AstuteException {
try {
List<PO> pos = new ArrayList<>();
Statement stmt = conn.createStatement();
String sql = "SELECT PO_num, contract_num, PO_date, customer_id, contract_amt, astute_project_num , title FROM PO ";
String sql = "SELECT PO_num, contract_num, PO_date, customer_id, contract_amt, astute_project_num , title, get_previously_billed_amt(PO_num) FROM PO ";
if (PONum != null && !PONum.isEmpty()) {
sql += "WHERE UPPER(PO_num) = '" + PONum.toUpperCase() + "'";
} else if (contractNum != null && !contractNum.isEmpty()) {
sql += "WHERE UPPER(contract_num) = '" + contractNum.toUpperCase()+ "'";
} else if (PODate != null) {
sql += "WHERE PO_date = STR_TO_DATE(" + PODate + ", '%Y-%m-%d')";
sql += "WHERE PO_date = STR_TO_DATE('" + PODate + "', '%m-%d-%Y')";
} else if (astuteProjectNumber!= null && !astuteProjectNumber.isEmpty() ) {
sql += "WHERE UPPER(astute_project_num) = '" + astuteProjectNumber.toUpperCase()+ "'";
}
@ -60,7 +62,13 @@ public class SqlDAO extends DAO {
Double contractAmt = rs.getDouble(5);
String astuteProjectNum = rs.getString(6);
String title = rs.getString(7);
PO po = new PO(poNum, cntrctNum, poDate, customerId, contractAmt,astuteProjectNum,title);
Double previouslyBilledAmount = rs.getDouble(8);
String date = null;
if (poDate != null) {
SimpleDateFormat formatter = new SimpleDateFormat("MM/DD/YYYY");
date = formatter.format(poDate);
}
PO po = new PO(poNum, cntrctNum, date, customerId, contractAmt,astuteProjectNum,title,previouslyBilledAmount);
pos.add(po);
}
return pos;
@ -109,8 +117,10 @@ public class SqlDAO extends DAO {
}
}
public void updatePOMaster(String PONum, String contractNum, Date PODate, Double contractAmt, String astuteProjectNumber, String title) throws AstuteException {
public void updatePOMaster(String PONum, String contractNum, String PODate, Double contractAmt, String astuteProjectNumber, String title) throws AstuteException {
try {
System.out.println("PODate in SQLDAO is "+ PODate);
String sql = "UPDATE PO ";
String updateClause = " SET ";
String whereClause = "";
@ -121,9 +131,9 @@ public class SqlDAO extends DAO {
}
updateClause = updateClause + " contract_num = '" + contractNum + "',";
updateClause = updateClause + " PO_Date = STR_TO_DATE(" + PODate + ", '%Y-%m-%d')" + ",";
updateClause = updateClause + " PO_Date = STR_TO_DATE('" + PODate + "', '%m/%d/%y')" + ",";
updateClause = updateClause + " contract_amt = " + contractAmt+ ",";
updateClause = updateClause + " astute_project_num = '" + astuteProjectNumber +"'";
updateClause = updateClause + " astute_project_num = '" + astuteProjectNumber +"',";
updateClause = updateClause + " title = '" + title +"'";
sql = sql+ updateClause + whereClause;
System.out.println(sql);
@ -187,12 +197,14 @@ public class SqlDAO extends DAO {
}
}
public void createPOMaster(String PONum, String contractNum, Date PODate, Double contractAmt, String customerId, String astuteProjectNumber, String title) throws AstuteException {
public void createPOMaster(String PONum, String contractNum, String PODate, Double contractAmt, String customerId, String astuteProjectNumber, String title) throws AstuteException, ParseException {
try {
Date date= (Date) new SimpleDateFormat("yyyy/mm/dd").parse(PODate);
CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?,?,?,?)}");
stmt.setString(1, PONum);
stmt.setString(2, contractNum);
stmt.setDate(3, PODate);
stmt.setDate(3, date);
stmt.setDouble(4, contractAmt);
stmt.setString(5, customerId);
stmt.setString(6, astuteProjectNumber);