Commit 64255a5f authored by dpawar's avatar dpawar

dynamic error message shown


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94227 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 625369ae
......@@ -7,6 +7,7 @@ import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.MiscDrCrRcpConf;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorEJB;
import java.rmi.RemoteException;
import java.sql.Connection;
......@@ -17,19 +18,25 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import javax.ejb.Stateless;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sun.jmx.snmp.Timestamp;
@Stateless
public class PODProcess extends ProcessEJB implements PODProcessLocal,PODProcessRemote
{
ArrayList<String> podRemainInvIDList=new ArrayList<String>();
String siteCodeG="",invTypeG="";
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
......@@ -78,6 +85,8 @@ public String process(Document dom, Document dom2, String windowName, String xtr
ArrayList <String>inv45dayList=new ArrayList<String>();
ArrayList<String> podProcessInvIDList=new ArrayList<String>();
ArrayList<String> podNotConfList=new ArrayList<String>();
ArrayList<String> podTraceInvList=new ArrayList<String>();
ArrayList<String> miscDrCrInvList=new ArrayList<String>();
Connection conn = null;
ConnDriver connDriver = null;
GenericUtility genericUtility = null;
......@@ -173,8 +182,10 @@ public String process(Document dom, Document dom2, String windowName, String xtr
}
}
if(custCodeFrm.length() > 0 && custCodeTo.length() > 0 && siteCode.length() > 0){
siteCodeG=siteCode;
invTypeG=invType;
sql="select invoice_id from invoice where cust_code__bil between ? and ? and site_code = ? "
+ "and sysdate - conf_date > 517";
+ "and sysdate - conf_date > 570";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, custCodeFrm);
pstmt.setString(2, custCodeTo);
......@@ -224,11 +235,44 @@ public String process(Document dom, Document dom2, String windowName, String xtr
}
}
podProcessInvIDList.clear(); //remove on final----------------------------7826464876----------------
//Need to be discussion. ------------------------------------------@@@@@@@@@@@@@@
/*podProcessInvIDList.clear();
podProcessInvIDList.add("618ID00036");
podProcessInvIDList.add("618ID00037");
podProcessInvIDList.add("618ID00038");
podProcessInvIDList.add("618ID00039");*/
podTraceInvList=getDoneInvoiceIDFromPodTrace(conn);
System.out.println("podTraceInvList---->>["+podTraceInvList+"]");
if(podTraceInvList.size() > 0){
for(String podPrcId : podProcessInvIDList){
if(podTraceInvList.contains(podPrcId)){
podProcessInvIDList.remove(podPrcId);
}
}
}
System.out.println("podProcessInvIDList-->>["+podProcessInvIDList+"]");
miscDrCrInvList=getDoneInvoiceIDFromMiscDrCrRcp(conn);
System.out.println("miscDrCrInvList---->>["+miscDrCrInvList+"]");
Iterator<String> it = podProcessInvIDList.iterator();
if(miscDrCrInvList.size() > 0){
while (it.hasNext()) {
String podPrcId=it.next();
if(miscDrCrInvList.contains(podPrcId)){
System.out.println("---in misc arrayList------");
it.remove();
podProcessInvIDList.remove(podPrcId);
}
podProcessInvIDList.add("618ID00032");
podProcessInvIDList.add("618ID00033");
podProcessInvIDList.add("618ID00044");
}
}
//podProcessInvIDList.clear(); //remove on final----------------------------7826464876----------------
//podProcessInvIDList.add("618ID00044");
System.out.println("Final invoice Id ready for debit note---->>["+podProcessInvIDList+"]");
......@@ -242,34 +286,9 @@ public String process(Document dom, Document dom2, String windowName, String xtr
}
//Check in invoice_trace if item_code_ord (scheme_code) is available or not.
//if yes then checked in bomdet.if scheme code found then for that particular item scheme is apply.
errorString=generateDebitNote(conn, podProcessInvIDList,priceList,xtraParams,siteCode,invType);
System.out.println("Return string from generateDebitNote----->>["+errorString+"]");
if("ITEMNOTACTIVE".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTITMCNAC"; //Item code not active
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("Error".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTPRCNCP";
errorString =itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("Success".equalsIgnoreCase(errorString)){
conn.commit();
errCode="VTPRCCSF";
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("PRICELIST".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTPRCLNE";
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
else if("SCHEME".equalsIgnoreCase(errorString)){
conn.rollback();
errCode="VTSCHME";//scheme is expired for particular item,please check in bomdet
errorString = itmdbAccess.getErrorString("", errCode, "", "", conn);
}
}
}//end try
......@@ -298,24 +317,31 @@ public String process(Document dom, Document dom2, String windowName, String xtr
private String generateDebitNote(Connection conn,ArrayList<String> podProcessInvIDListL,String priceListL,String xtraParams,String siteCode,String invType)
{
ResultSet rs=null;
Connection conn1=null;
PreparedStatement pstmt=null;
ProofOfDelivery pod=null;
ProofOfDeliveryConf podC=null;
Map<String,String> invoiceDetailsMap=null;
HashMap<String,String> podTraceMap=new HashMap();
HashMap<String,String> schemeMap=new HashMap();
HashMap<String,String> partialMap=new HashMap();
Map<String,Double> schemeQty=null;
ArrayList<String> confList=new ArrayList();
String sql="",lotNo="",lotSl="",itemCode="",itemCodeOrd="",itemActive="",detail2xmlString="",errString="";
String custCode="",currCode="",partial="N",QtyInvTrace="",scheme="N";
String custCode="",currCode="",partial="N",QtyInvTrace="",scheme="N",errCode="";
double invRate=0,invQty=0,discount=0,priceListRate=0,detail3Amt=0,detail3AmtT=0,debitNoteAmtDetail=0;
double debitNoteAmtHdr=0,ExchRate=0,actualRate=0,chargQty=0,freeQty=0,netPTS=0;
int lineNotrace=0,lineNo=0,noOfInvoicePrc=0,totalInvoice=0;
pod=ProofOfDelivery.getInstance();
podC=ProofOfDeliveryConf.getInstance();
ITMDBAccessEJB itmdbAccess1=new ITMDBAccessEJB();
ConnDriver connDriver1 = new ConnDriver();
try{
conn1 = connDriver1.getConnectDB("DriverITM");
connDriver1 = null;
System.out.println("priceListL123------>>["+priceListL+"]");
totalInvoice=podProcessInvIDListL.size();
System.out.println("total invoice for process------>>["+totalInvoice+"]");
if(totalInvoice > 0){
for(String invoiceId :podProcessInvIDListL)
{
detail2xmlString="";
......@@ -360,24 +386,30 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
System.out.println("inv. qty done in POD screen---->>["+pod.partialQty+"]");
invQty = invQty - pod.partialQty;
partial="Y";
partialMap.put(invoiceId+","+itemCode, scheme);
System.out.println("Actual inv qty---->>["+invQty+"]");
}
//------------Mehod-----------------------------//
partialMap.put(invoiceId+","+itemCode, partial);
//Check if item code Active or not."N" or null then return error message.
itemActive=pod.getColumnDescr(conn,"active","item","item_code",itemCode);
itemActive=itemActive==null ? "" :itemActive.trim();
if(itemActive.equalsIgnoreCase("N") || itemActive.length()<=0)
{
return "ITEMNOTACTIVE"; // item code not active
errCode="VTITMCNAC"; //Item code not active
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString; // item code not active
}
java.util.Date tranDate=new Date();
priceListRate=getPriceListRate(priceListL, tranDate,itemCode,lotNo,"", conn);
System.out.println("priceListRate----->>["+priceListRate+"]");
if(priceListRate <= 0)
{
return "PRICELIST";
errCode="VTPRCLNE";
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString;
}
//check if scheme is apply or not
......@@ -388,13 +420,20 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
System.out.println("schemeQty map---->>["+schemeQty+"]");
if(schemeQty.size() > 0){
if(schemeQty.get("success") < 0){
return "Error"; // Scheme related error or sql error.
errCode="VTPRCNCP"; // Scheme related error or sql error.
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString;
}
else if(schemeQty.get("success") == 0){
return "SCHEME";
errCode="VTSCHME"; //scheme is expired for particular item,please check in bomdet
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
errString=newErrorMessage(errString, invoiceId);
return errString;
}
else if(schemeQty.get("success") == 1){
scheme="Y";
schemeMap.put(invoiceId+","+itemCode, scheme);
chargQty=schemeQty.get("charge_qty");
freeQty=schemeQty.get("free_qty");
......@@ -409,9 +448,7 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
}
}else{
System.out.println("-------Scheme not apply -----------");
//debitNoteAmtDetail=podC.getDebitNoteAmount(invRate,invQty);
//debitNoteAmtHdr=debitNoteAmtHdr+debitNoteAmtDetail;
schemeMap.put(invoiceId+","+itemCode, scheme);
actualRate=priceListRate - invRate;
detail3Amt= actualRate * invQty;
......@@ -423,25 +460,6 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
} //end isSchemeApply
//insert into podTrace table entry....
podTraceMap.put("line_no", Integer.toString(lineNo));
podTraceMap.put("inv_id", invoiceId);
podTraceMap.put("site_code", siteCode);
podTraceMap.put("item_code", itemCode);
podTraceMap.put("inv_type", invType);
podTraceMap.put("db_qty", Double.toString(invQty));
podTraceMap.put("db_rate", Double.toString(actualRate));
podTraceMap.put("db_amount", Double.toString(detail3AmtT));
podTraceMap.put("partial",partial);
podTraceMap.put("scheme",scheme);
int podTrace=insertDataInPodTrace(conn, podTraceMap);
System.out.println("Return podTrace from insert---->>["+podTrace+"]");
if(podTrace < 0){
return "Error";
}
} //end while invoice trace
rs.close();
......@@ -449,10 +467,10 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
pstmt.close();
pstmt=null;
System.out.println("Detail2 xml-------->>[["+detail2xmlString+"]");
if(detail3AmtT > 0){
invoiceDetailsMap=pod.getDetailsFromInvoice(conn, invoiceId);
custCode=invoiceDetailsMap.get("cust_code").toString();
currCode =pod.checkNull(invoiceDetailsMap.get("curr_code"));
currCode =pod.checkNull(invoiceDetailsMap.get("curr_code")); //xmlStringAll
ExchRate=Double.parseDouble(invoiceDetailsMap.get("exch_rate"));
errString=podC.genDebitNote("PRC",invoiceId,custCode,siteCode,xtraParams,currCode,ExchRate,detail2xmlString,detail3AmtT,conn);
System.out.println("------Error string after DN save--->>["+errString+"]");
......@@ -464,56 +482,122 @@ private String generateDebitNote(Connection conn,ArrayList<String> podProcessInv
System.out.println("Error String on DB Confirmation: "+errString);
if((errString != null ) && errString.indexOf("CONFSUCCES") > -1)
{
int count=checkPODDoneAlready(conn,invoiceId);
if(count > 0){
continue;
}else if(count < 0){
return "Error";
}
int cnt=insertDataInPodTrace(conn1, invoiceId, podC.xmlStringAll, schemeMap, partialMap,"Y");
noOfInvoicePrc++;
confList.add(invoiceId);
System.out.println("noOfInvoicePrc----------------"+noOfInvoicePrc);
if(noOfInvoicePrc==totalInvoice)
return "Success";
else{
System.out.println("in continue----------------");
continue;
if(noOfInvoicePrc==totalInvoice){
errCode="VTPRCCSF";
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
return errString;
}
if(cnt > 0){
conn1.commit();
}
conn.commit();
/*errCode="VTPRCCSF";
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
return errString; */
//return "Success";
}else
return "Error";
}else{
//itmdbAccess.getErrorString("", "VTNCONFT", "", "", conn);
return "Error";
conn.rollback();
int cnt=insertDataInPodTrace(conn1, invoiceId, podC.xmlStringAll, schemeMap, partialMap,"N");
if(cnt > 1)
conn1.commit();
errString=newErrorMessage(errString, invoiceId);
return errString;
}
}else{
conn.rollback();
int cnt=insertDataInPodTrace(conn1, invoiceId, podC.xmlStringAll, schemeMap, partialMap,"N");
if(cnt > 1)
conn1.commit();
errString=newErrorMessage(errString, invoiceId);
return errString;
}
}else {// end detail3AmtT > 0 condition
System.out.println("Debit note gennerated for Rs.0- Invoice ID----->> ["+invoiceId+"]");
}
} //end invoice id for loop
System.out.println("invoice id confirmed-------->>"+confList);
}else{
errCode="VTDNFFP"; //No data found for processing
errString = itmdbAccess1.getErrorString("", errCode, "", "", conn);
return errString;
}
}catch(Exception e)
{
System.out.println("Exception : ");
e.printStackTrace();
return "Error";
}
finally{
if(conn1!=null){
try{
conn1.close();
conn1=null;
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
return errString;
}
private int checkPODDoneAlready (Connection conn,String invoiceIdL)
{
ResultSet rs=null;
PreparedStatement pstmt=null;
String sql="";
int count=0;
ResultSet rs=null,rs1=null;
PreparedStatement pstmt=null,pstmt1=null;
String sql="",remarks="",invID="",itemCodeMisc="",itemCodeInv;
double invQty=0,miscQty=0;
int count=0,lineInvT=0,lineMiscInvT=0;
try{
sql="select count(*) from podtrace where invoice_id = ?";
sql="SELECT d.item_code,d.quantity,h.remarks,d.line_no__invtrace FROM misc_drcr_rcp h, misc_drcr_rdet d "
+ "where remarks like 'Auto%POD%' and h.tran_id=d.tran_id";
//sql="SELECT remarks FROM misc_drcr_rcp where remarks like 'Auto%POD%'";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invoiceIdL);
rs=pstmt.executeQuery();
if(rs.next()){
count=rs.getInt(1);
while(rs.next()){
itemCodeMisc=rs.getString(1);
miscQty=rs.getDouble(2);
remarks=rs.getString(3).trim();
lineMiscInvT=rs.getInt(4);
itemCodeMisc=itemCodeMisc==null ? "" :itemCodeMisc.trim();
invID=remarks.substring(46, remarks.length());
System.out.println("Invoice id after subString----->>["+invID+"]");
if(invID.equalsIgnoreCase(invoiceIdL.trim())){
sql="select invoice_id,inv_line_no,item_code,quantity from invoice_trace where invoice_id = ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, invID.trim());
rs1=pstmt1.executeQuery();
while(rs1.next()){
lineInvT=rs1.getInt(2);
itemCodeInv=rs1.getString(3);
invQty=rs1.getDouble(4);
itemCodeInv=itemCodeInv==null ? "" :itemCodeInv.trim();
System.out.println("itemCodeMisc--->>["+itemCodeMisc+" itemCodeInv-->>["+itemCodeInv+"]");
System.out.println("lineMiscInvT--->>["+lineMiscInvT+" lineInvT-->>["+lineInvT+"]");
if(itemCodeMisc.equalsIgnoreCase(itemCodeInv) && lineMiscInvT == lineInvT){
if(invQty == miscQty){
return 1;
}
}
}
}
}
rs.close();
rs=null;
......@@ -563,7 +647,29 @@ private ArrayList<String> getNotConfirmedInvIdFromHdr(Connection conn)
return podNotConfListL;
}
private int updatePodTraceSuccess(Connection conn,String success,String invID)
{
String sql="";
int lineNo=0,count=0;
double dbAmt=0.0,debitNoteHeaderL=0;
PreparedStatement pstmt=null;
try{
sql="update podtrace set success = ? where invoice_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,success);
pstmt.setString(2, invID);
count=pstmt.executeUpdate();
}//end try
catch(Exception e){
e.printStackTrace();
return 0;
}
System.out.println("update updatePodTraceSuccess@@@----->>["+count+"]");
return count;
}
private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String> inv45dayListL)
{
System.out.println("--------------checkPODDoneOrNot method------------------");
......@@ -599,7 +705,7 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
pstmt=null;
if(inv45dayListL.size() > 0 && podDoneInvIDList.size() > 0){
System.out.println("---both arraylist contains elements-----------");
for (String invId : inv45dayListL) { //required to check if invoice id partially done in POD HDR
for (String invId : inv45dayListL) {
if(!(podDoneInvIDList.contains(invId))){
podProcessInvIDListL.add(invId);
......@@ -608,6 +714,8 @@ private ArrayList<String> getDoneInvoiceIdHDR(Connection conn,ArrayList<String>
}
}else{
return inv45dayListL;
}
System.out.println("podProcessInvIDList----->>[["+podProcessInvIDListL+"]");
......@@ -743,14 +851,37 @@ private Map<String,Double> schemeApply(Connection conn,String invoiceID,String i
}
return schemeQtyMap;
}
private int insertDataInPodTrace(Connection conn,Map<String,String>podTraceMapL)
private int insertDataInPodTrace(Connection conn,String invID,String xmlDataAll,Map<String,String> schemeMapL,Map<String,String> partialMapL,String success)
{
PreparedStatement pstmt=null;
ResultSet rs=null;
String sql="";
String sql="",itemCode="",quantity="",rate="",amount="",scheme="",partial="",lineNoS="";
int count=0;
long tranID=0;
invID=invID==null ? "" :invID.trim();
try{
//DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
//DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = new ValidatorEJB ().parseString(xmlDataAll);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("Detail2");
System.out.println("in continue----------------"+nList.getLength());
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
itemCode=eElement.getElementsByTagName("item_code").item(0).getTextContent();
quantity=eElement.getElementsByTagName("quantity").item(0).getTextContent();
rate=eElement.getElementsByTagName("rate").item(0).getTextContent();
amount=eElement.getElementsByTagName("amount").item(0).getTextContent();
lineNoS=eElement.getElementsByTagName("line_no").item(0).getTextContent();
scheme=schemeMapL.get(invID+","+itemCode.trim());
partial=partialMapL.get(invID+","+itemCode.trim());
System.out.println("scheme in insert pod trace---->>["+scheme+"]");
sql="select tran_id from podtrace order by tran_id DESC";
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
......@@ -763,30 +894,40 @@ private int insertDataInPodTrace(Connection conn,Map<String,String>podTraceMapL)
pstmt.close();
pstmt=null;
sql="insert into podtrace (tran_id,line_no,tran_date,invoice_id,site_code,item_code,inv_type,db_qty,"
+ "db_rate,debit_note_amt,partial,scheme,chg_date,chg_user,chg_term) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "db_rate,debit_note_amt,partial,scheme,chg_date,chg_user,chg_term,success) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, Long.toString(++tranID));
pstmt.setInt(2, Integer.parseInt(podTraceMapL.get("line_no")));
pstmt.setInt(2, Integer.parseInt(lineNoS));
pstmt.setTimestamp(3, new java.sql.Timestamp(new java.util.Date().getTime()) );
pstmt.setString(4, podTraceMapL.get("inv_id"));
pstmt.setString(5, podTraceMapL.get("site_code"));
pstmt.setString(6, podTraceMapL.get("item_code"));
pstmt.setString(7, podTraceMapL.get("inv_type"));
pstmt.setDouble(8, Double.parseDouble(podTraceMapL.get("db_qty")));
pstmt.setDouble(9, Double.parseDouble(podTraceMapL.get("db_rate")));
pstmt.setDouble(10, Double.parseDouble(podTraceMapL.get("db_amount")));
pstmt.setString(11, podTraceMapL.get("partial"));
pstmt.setString(12, podTraceMapL.get("scheme"));
pstmt.setString(4, invID);
pstmt.setString(5, siteCodeG);
pstmt.setString(6,itemCode);
pstmt.setString(7, invTypeG);
pstmt.setDouble(8, Double.parseDouble(quantity));
pstmt.setDouble(9, Double.parseDouble(rate));
pstmt.setDouble(10, Double.parseDouble(amount));
pstmt.setString(11, partial);
pstmt.setString(12, scheme);
pstmt.setTimestamp(13, new java.sql.Timestamp(new java.util.Date().getTime()) );
pstmt.setString(14, "BASE");
pstmt.setString(15, "System");
pstmt.setString(16, success);
count=pstmt.executeUpdate();
pstmt.close();
}//end if
} //end for
}
catch(Exception e)
{
......@@ -796,6 +937,131 @@ private int insertDataInPodTrace(Connection conn,Map<String,String>podTraceMapL)
}
return count;
}
private ArrayList<String> getDoneInvoiceIDFromPodTrace(Connection conn)
{
PreparedStatement pstmt=null;
ResultSet rs=null;
String sql="";
HashSet<String> unqInvID=new HashSet <String>();
ArrayList<String> InvIDList=new ArrayList <String>();
try{
sql="select invoice_id from podtrace where success = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y");
rs=pstmt.executeQuery();
while(rs.next()){
InvIDList.add(rs.getString(1).trim());
}
if(InvIDList.size() > 0){
unqInvID.addAll(InvIDList);
InvIDList.clear();
InvIDList.addAll(unqInvID);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return InvIDList;
}
private ArrayList<String> getDoneInvoiceIDFromMiscDrCrRcp(Connection conn)
{
PreparedStatement pstmt=null,pstmt1=null;
ResultSet rs=null,rs1=null;
String sql="",remarks="",subInvId="";
double sumQuantityMisc=0,sumQuantityInv=0;
HashSet<String> unqInvID=new HashSet <String>();
ArrayList<String> tranIDList=new ArrayList <String>();
ArrayList<String> InvIDList=new ArrayList <String>();
ArrayList<String> InvIDFinalList=new ArrayList <String>();
try{
sql="select tran_id,remarks from misc_drcr_rcp where remarks like 'Auto%POD%'";
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next()){
tranIDList.add(rs.getString(1));
remarks=rs.getString(2);
subInvId=remarks.substring(46, remarks.length());
InvIDList.add(subInvId);
}
if(InvIDList.size() > 0){
unqInvID.addAll(InvIDList);
InvIDList.clear();
InvIDList.addAll(unqInvID);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return InvIDList;
}
private String newErrorMessage(String errString,String invid)
{
System.out.println("In newErrorMessage method--->>["+errString+"]");
String trace="",message="",desc="",redirect="",domID="";
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
StringBuffer newStr=new StringBuffer();
try{
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = new ValidatorEJB ().parseString(errString);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList parentNodeList = doc.getElementsByTagName("error");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
System.out.println("childNodeList length----------------"+parentNodeList.getLength());
for (int i = 0; i < childNodeList.getLength(); i++) {
childNode = childNodeList.item(i);
if(childNode ==null){
System.out.println("child Node is null..............");
}
// System.out.println("ChildNode Name--->>"+childNode.getFirstChild().getTextContent());
if ("message".equalsIgnoreCase(childNode.getNodeName())) {
message=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("description".equalsIgnoreCase(childNode.getNodeName())) {
desc=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("trace".equalsIgnoreCase(childNode.getNodeName())) {
trace=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("redirect".equalsIgnoreCase(childNode.getNodeName())) {
redirect=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
else if ("detailDomId".equalsIgnoreCase(childNode.getNodeName())) {
domID=childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
}
trace=trace+ " Invoice Id : "+invid;
newStr.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
+ "<Errors><error column_name=\"acct_code\" id=\"VMACCT1\" type=\"E\">"
+ "<message><![CDATA["+message+"]]></message>"
+ "<description><![CDATA["+desc+"]]></description>");
newStr.append("<trace><![CDATA["+trace +"]]></trace>");
newStr.append("<redirect><![CDATA["+redirect+"]]></redirect>");
newStr.append("<detailDomId><![CDATA["+domID+"]]></detailDomId>");
newStr.append("</error></Errors>");
System.out.println("Final xml in newErrorMessage--->>[["+newStr.toString()+"]]");
}
catch(Exception e){
e.printStackTrace();
}
return newStr.toString();
}
public double getPriceListRate(String priceList, java.util.Date tranDate, String itemCode, String lotNo, String type, Connection connectionObject) throws RemoteException,ITMException
{
double rate = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment