parent
fda8a2d406
commit
53257ec6ca
|
|
@ -1,22 +1,20 @@
|
|||
//package andromedia.midsuit.process;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.IOException;
|
||||
//import net.ucanaccess.jdbc.JackcessOpenerInterface;
|
||||
//import com.healthmarketscience.jackcess.CryptCodecProvider;
|
||||
//import com.healthmarketscience.jackcess.Database;
|
||||
//import com.healthmarketscience.jackcess.DatabaseBuilder;
|
||||
//
|
||||
//public class CryptCodecOpener implements JackcessOpenerInterface {
|
||||
// @Override
|
||||
// public Database open(File fl,String pwd) throws IOException {
|
||||
// DatabaseBuilder dbd =new DatabaseBuilder(fl);
|
||||
// dbd.setAutoSync(false);
|
||||
// dbd.setCodecProvider(new CryptCodecProvider(pwd));
|
||||
// dbd.setReadOnly(false);
|
||||
// return dbd.open();
|
||||
// }
|
||||
// //Notice that the parameter setting autosync =true is recommended with UCanAccess for performance reasons.
|
||||
// //UCanAccess flushes the updates to disk at transaction end.
|
||||
// //For more details about autosync parameter (and related tradeoff), see the Jackcess documentation.
|
||||
//}
|
||||
package andromedia.midsuit.process;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.healthmarketscience.jackcess.CryptCodecProvider;
|
||||
import com.healthmarketscience.jackcess.Database;
|
||||
import com.healthmarketscience.jackcess.DatabaseBuilder;
|
||||
|
||||
import net.ucanaccess.jdbc.JackcessOpenerInterface;
|
||||
|
||||
public class CryptCodecOpener implements JackcessOpenerInterface {
|
||||
public Database open(File fl, String pwd) throws IOException {
|
||||
DatabaseBuilder dbd = new DatabaseBuilder(fl);
|
||||
dbd.setAutoSync(false);
|
||||
dbd.setCodecProvider(new CryptCodecProvider(pwd));
|
||||
dbd.setReadOnly(false);
|
||||
return dbd.open();
|
||||
}
|
||||
}
|
||||
|
|
@ -12,8 +12,13 @@ import org.apache.poi.ss.usermodel.Row;
|
|||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.compiere.model.MBPartnerLocation;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
import net.ucanaccess.jdbc.UcanaccessDriver;
|
||||
|
||||
|
|
@ -40,7 +45,6 @@ public class MID_UploadPEB extends SvrProcess{
|
|||
TPB.getName().substring(formatIndex).equalsIgnoreCase("xls")){
|
||||
readExcel(TPB);
|
||||
}else{
|
||||
|
||||
readAccess(TPB);
|
||||
}
|
||||
return "";
|
||||
|
|
@ -55,24 +59,60 @@ public class MID_UploadPEB extends SvrProcess{
|
|||
}
|
||||
|
||||
private void readAccess(File TPB) throws Exception{
|
||||
File f_Access = new File(p_File);
|
||||
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
|
||||
UcanaccessDriver driver = new UcanaccessDriver();
|
||||
String databaseURL = "jdbc:ucanaccess://"+TPB.getPath()+";jackcessOpener=andromedia.midsuit.process.CryptCodecOpener";
|
||||
try (Connection connection = DriverManager.getConnection(databaseURL)) {
|
||||
|
||||
String sql = "SELECT CAR FROM tblResPebUr";
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet result = statement.executeQuery(sql);
|
||||
|
||||
while (result.next()) {
|
||||
String id = result.getString(1);
|
||||
System.out.println(id);
|
||||
}
|
||||
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
String databaseURL = "jdbc:ucanaccess://" + f_Access.getPath() + ";jackcessOpener=andromedia.midsuit.process.CryptCodecOpener";
|
||||
try (Connection conn = DriverManager.getConnection(databaseURL)) {
|
||||
|
||||
String sql = "SELECT * FROM tblPebHdr";
|
||||
|
||||
Statement statement = conn.createStatement();
|
||||
ResultSet rs = statement.executeQuery(sql);
|
||||
|
||||
while (rs.next()) {
|
||||
int C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =?", new Object[] { rs.getString("NAMABELI"), getAD_Client_ID()});
|
||||
int C_Currency_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code =? ", new Object[] { rs.getString("KDVAL"), getAD_Client_ID()});
|
||||
int M_PriceList_ID = DB.getSQLValue(get_TrxName(), "SELECT M_PriceList_ID FROM M_PriceList WHERE C_Currency_ID =? AND AD_Client_ID =?", new Object[] { C_Currency_ID, getAD_Client_ID() });
|
||||
int C_DocTypeTarget_ID = DB.getSQLValue(get_TrxName(), "SELECT C_DocType_ID FROM C_DocType WHERE Name =? AND AD_Client_ID =?", new Object[] { "'Sales Order'", getAD_Client_ID()});
|
||||
|
||||
String no_aju = rs.getString("CAR");
|
||||
|
||||
MOrder order = new MOrder(getCtx(), 0, get_TrxName());
|
||||
order.setAD_Org_ID(Env.getContextAsInt(getCtx(), "#AD_Org_ID"));
|
||||
order.set_ValueNoCheck("RegisterNo", rs.getString("NODAFT"));
|
||||
order.setIsSOTrx(false);
|
||||
order.set_ValueNoCheck("RegisterDate", rs.getString("TGDAFT"));
|
||||
order.set_ValueNoCheck("NoAju1", no_aju);
|
||||
order.setC_BPartner_ID(C_BPartner_ID);
|
||||
order.setC_BPartner_Location_ID(MBPartnerLocation.getForBPartner(getCtx(), C_BPartner_ID, get_TrxName())[0].getC_BPartner_Location_ID());
|
||||
order.setC_DocTypeTarget_ID(C_DocTypeTarget_ID);
|
||||
order.setSalesRep_ID(30178);
|
||||
order.setM_Warehouse_ID(30045);
|
||||
order.setC_Currency_ID(C_Currency_ID);
|
||||
order.setM_PriceList_ID(M_PriceList_ID);
|
||||
order.saveEx();
|
||||
|
||||
String sqlDtl = "SELECT * FROM tblPebDtl WHERE CAR = " + "'" + no_aju + "'";
|
||||
ResultSet rsDtl = statement.executeQuery(sqlDtl);
|
||||
|
||||
while (rsDtl.next()) {
|
||||
int M_Product_ID = DB.getSQLValue(get_TrxName(), "SELECT M_Product_ID FROM M_Product WHERE Value =?", new Object[] { rsDtl.getString("KDBRG") });
|
||||
int C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =?", new Object[] { rsDtl.getString("JNSATUAN") });
|
||||
|
||||
MOrderLine oLine = new MOrderLine(getCtx(), 0, get_TrxName());
|
||||
oLine.setHeaderInfo(order);
|
||||
oLine.setM_Product_ID(M_Product_ID);
|
||||
oLine.setC_UOM_ID(C_UOM_ID);
|
||||
oLine.setQty(rsDtl.getBigDecimal("JMSATUAN"));
|
||||
oLine.setPriceList(rsDtl.getBigDecimal("FOBPERBRG"));
|
||||
oLine.setPriceActual(rsDtl.getBigDecimal("FOBPERBRG"));
|
||||
oLine.saveEx();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class MID_UploadTPB extends SvrProcess{
|
|||
int MID_AJUDocType_ID = DB.getSQLValue(get_TrxName(), "SELECT MID_AJUDocumentType_ID FROM MID_AjuDocumentType WHERE Value =?", new Object[] { AJU_DocType_Value });
|
||||
order.set_ValueNoCheck("MID_AJUDocumentType_ID", MID_AJUDocType_ID);
|
||||
|
||||
int C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =?", new Object[] { row.getCell(3).getStringCellValue(), getAD_Client_ID()});
|
||||
int C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =? AND IsVendor = 'Y' AND IsCustomer = 'N'", new Object[] { row.getCell(3).getStringCellValue(), getAD_Client_ID()});
|
||||
int C_Currency_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code =? ", new Object[] { row.getCell(88).getStringCellValue()});
|
||||
order.setC_BPartner_ID(C_BPartner_ID);
|
||||
order.setC_BPartner_Location_ID(MBPartnerLocation.getForBPartner(getCtx(), C_BPartner_ID, get_TrxName())[0].getC_BPartner_Location_ID());
|
||||
|
|
|
|||
Loading…
Reference in New Issue