Commit 7225aa12 authored by cpatil's avatar cpatil

fright rate calculation code modified


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98438 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f1f2eb43
......@@ -10,7 +10,8 @@ package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.GenericUtility;
// import ibase.webitm.utility.GenericUtility;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
......@@ -31,7 +32,9 @@ import java.sql.Timestamp;
public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, ShipmentLocICRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
//method for validation
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
......@@ -121,7 +124,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
if(childNodeName.equalsIgnoreCase("shipment_id"))
{
shipmentId = genericUtility.getColumnValue("shipment_id", dom);
shipmentId = checkNull(genericUtility.getColumnValue("shipment_id", dom));
//Shipment Date should not be blank.
String keyFlag = setDescription("key_flag", "transetup", "tran_window", "w_shipment_loc", conn);
......@@ -718,6 +721,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
rs = null;
pstmt.close();
pstmt = null;
System.out.println("COUNT["+cnt+"]");
if( cnt > 0)
{
retStr = "TRUE";
......@@ -778,7 +782,8 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
int currentFormNo =0;
......@@ -798,6 +803,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
int i=0,noArt=0;
Timestamp despDate=null;
double netWeightCIss=0;
try
{
......@@ -1291,13 +1297,13 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
{
System.out.println("@@@@@@@@ itemchange charge_code called @@@@@@@@");
chargeCode = genericUtility.getColumnValue("charge_code", dom);
shipmentId = genericUtility.getColumnValue("shipment_id", dom1);
chargeCode = genericUtility.getColumnValue("charge_code", dom)==null?"":genericUtility.getColumnValue("charge_code", dom).trim();
shipmentId = genericUtility.getColumnValue("shipment_id", dom1)==null?"":genericUtility.getColumnValue("shipment_id", dom1).trim();
frtList = genericUtility.getColumnValue("frt_list", dom1);
stanCodeFrom = genericUtility.getColumnValue("stan_code__from", dom1);
stanCodeTo = genericUtility.getColumnValue("stan_code__to", dom1);
loadType = genericUtility.getColumnValue("load_type", dom1);
frtList = genericUtility.getColumnValue("frt_list", dom1)==null?"":genericUtility.getColumnValue("frt_list", dom1).trim();
stanCodeFrom = genericUtility.getColumnValue("stan_code__from", dom1)==null?"":genericUtility.getColumnValue("stan_code__from", dom1).trim();
stanCodeTo = genericUtility.getColumnValue("stan_code__to", dom1)==null?"":genericUtility.getColumnValue("stan_code__to", dom1).trim();
loadType = genericUtility.getColumnValue("load_type", dom1)==null?"":genericUtility.getColumnValue("load_type", dom1).trim();
/*
sql = " select c.descr,b.charges_mode,b.amount,b.charge_code__add,sequence " +
" from shipment a, freight_rate_det b, gencodes c " +
......@@ -1332,9 +1338,9 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
pstmt.setString(3,stanCodeTo );
pstmt.setString(4,loadType );
pstmt.setString(5,shipmentId );
pstmt.setString(6,"CHARGE_CODE" );
pstmt.setString(7,chargeCode );
// pstmt.setString(5,shipmentId );
pstmt.setString(5,"CHARGE_CODE" );
pstmt.setString(6,chargeCode );
rs = pstmt.executeQuery();
if(rs.next())
......@@ -1432,7 +1438,24 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
pstmt.close();
pstmt = null;
nettWeight = (nettWeight + netWeight) * amount;
sql = " select nvl(sum(gross_weight),0) from CONSUME_ISS " +
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, shipmentId);
rs = pstmt.executeQuery();
if( rs.next())
{
grossWeightCIss = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@@@@@grossWeightCIss["+grossWeightCIss+"]");
nettWeight = (nettWeight + netWeight + grossWeightCIss ) * amount;
valueXmlString.append("<amount>").append("<![CDATA["+nettWeight+"]]>").append("</amount>");
}
else if ("V".equalsIgnoreCase(mode) ) //volume
......@@ -1492,7 +1515,7 @@ public class ShipmentLocIC extends ValidatorEJB implements ShipmentLocICLocal, S
System.out.println("@@@@@2 stanCodeShip ["+ stanCodeShip + "]");
stationaDescr = setDescription("descr", "station", "stan_code", stanCodeShip, conn);
valueXmlString.append("<stationa_descr protect = \"1\">").append("<![CDATA["+stationaDescr+"]]>").append("</stationa_descr>");
}
} //stationa_descr
else if( currentColumn.trim().equalsIgnoreCase( "stan_code__dlv" ) )
......
......@@ -265,7 +265,7 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("updCnt["+updCnt+"]");
frtAmt = val;
}
else
......@@ -277,7 +277,7 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("updCnt["+updCnt+"]");
frtAmt = minValue;
} //end if
......@@ -378,13 +378,13 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
}
val = val + frtAmt;
}
else
{
val = frtAmt;
} // end if
System.out.println("@@@@@@ val["+val+"]chargeRate["+chargeRate+"]");
val = ( val * chargeRate)/100 ;
System.out.println("@@@@@@ val["+val+"]");
}
else if("W".equalsIgnoreCase(chargesMode)) // ls_mode = 'W' then//weight
{
......@@ -438,6 +438,7 @@ public class RecalFrtAct extends ActionHandlerEJB implements RecalFrtActLocal, R
val = ( tempNettWeight + tempNetWeight + grossWeightCIss ) * chargeRate ;
System.out.println("@@@@@@ val["+val+"]chargeRate["+chargeRate+"]");
} // end if
......
......@@ -56,16 +56,12 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
String retString="";
String errString = "";
String sql = "";
String lorryNo = "";
String lrNo = "";
String confirmed = "";
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String errCode="",recallFrt="";
double totalFreight=0;
Timestamp lrDate=null;
String errCode="" ;
try
{
......@@ -77,26 +73,20 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
// check whether already confirmed or not
sql = " select confirmed , total_freight , lr_no , lr_date , recall_frt, lorry_no " +
" from shipment where shipment_id = ? ";
sql = " select confirmed from shipment where shipment_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if( rs.next())
{
confirmed = rs.getString("confirmed");
totalFreight = rs.getDouble("total_freight");
lrNo = checkNull(rs.getString("lr_no"));
lrDate = rs.getTimestamp("lr_date");
recallFrt = checkNull(rs.getString("recall_frt"));
lorryNo = checkNull(rs.getString("lorry_no"));
confirmed = checkNull(rs.getString("confirmed"));
}
System.out.println("@@@@confirmed["+confirmed+"]totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
System.out.println("@@@@lrDate["+lrDate+"]recallFrt["+recallFrt+"]lorryNo["+lorryNo+"]");
rs.close();rs = null;
pstmt.close();pstmt = null;
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@shipment_id["+tranId+"]confirmed["+confirmed+"]");
if( "Y".equalsIgnoreCase(confirmed))
{
errString = itmDBAccessLocal.getErrorString("","VTDIST26","");
......@@ -104,8 +94,8 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
}
else
{
errCode = confirmShipmentLoc(tranId,1, xtraParam,conn);
System.out.println("@@@@ confirmQcTransfer::errCode["+errCode+"]");
if( errCode != null && errCode.trim().length() > 0 )
......@@ -118,18 +108,13 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
else
{
conn.commit();
//retString=generateTrackInfo(tranId,conn);
System.out.println("final retString @@@@@"+retString);
// retString=generateTrackInfo(tranId,conn); // comment this method by mahendra
System.out.println("@@@@@@@@@ commit successful...........");
errString = itmDBAccessLocal.getErrorString("","VTCONFIRM","");
System.out.println("@@@@@@@@@ confirm successful...........");
}
}
}
}
catch(Exception e)
{
try{
......@@ -155,6 +140,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
throw new ITMException(se);
}
}
System.out.println("final errString @@@@@"+errString);
return errString;
}
......@@ -163,11 +149,11 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
throws RemoteException, ITMException
{
PreparedStatement pstmt = null, pstmtSql = null;
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null;
int cnt = 0,updCnt=0;
String retString = "", sql = "", errCode = "";
Timestamp sysDate = null, tranDate = null,lrDate=null,lrDateUpd=null;
String sql = "", sql1 = "", errCode = "";
Timestamp sysDate = null, lrDate=null,lrDateUpd=null;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
int cntDist=0,cntConsIss=0;
......@@ -177,35 +163,35 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
try
{
System.out.println("@@@@@@@@@@@@@@@ confirmShipmentLoc method called next..............");
System.out.println("@@@@@@@@@@@@@@@ confirmShipmentLoc method called next.....1, tranId["+tranId+"].........");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDateStr);
sysDate= Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql = " select confirmed , total_freight , lr_no , lr_date , recall_frt, lorry_no " +
" from shipment where shipment_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if( rs.next())
{
confirmed = rs.getString("confirmed");
confirmed = checkNull(rs.getString("confirmed"));
totalFreight = rs.getDouble("total_freight");
lrNo = checkNull(rs.getString("lr_no"));
lrDate = rs.getTimestamp("lr_date");
recallFrt = checkNull(rs.getString("recall_frt"));
lorryNo = checkNull(rs.getString("lorry_no"));
}
System.out.println("@@@@confirmed["+confirmed+"]totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
System.out.println("@@@@lrDate["+lrDate+"]recallFrt["+recallFrt+"]lorryNo["+lorryNo+"]");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@confirmed["+confirmed+"]totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
System.out.println("@@@@lrDate["+lrDate+"]recallFrt["+recallFrt+"]lorryNo["+lorryNo+"]");
// check shipment allocated to at least one despatch or dist issue
sql = " select count(1) " +
......@@ -221,7 +207,9 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
rs = null;
pstmt.close();
pstmt = null;
System.out.println("cnt["+cnt+"]");
if( cnt == 0 ) // ll_cnt = 0 then
{
sql = " select count(1) " +
......@@ -244,7 +232,8 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
{
sql = " select count(1) from CONSUME_ISS " +
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) and confirmed = 'Y' ";
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) " +
" and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
......@@ -323,7 +312,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("@@@@totGwt["+totGwt+"]");
// for despatch
sql = " select desp_id,gross_weight, lr_date, lr_no, lorry_no from despatch " +
" where shipment_id = ? and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
......@@ -336,67 +325,71 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
lrDate = rs.getTimestamp("lr_date");
lrNo = rs.getString("lr_no");
lorryNo = rs.getString("lorry_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]gwtDesp["+gwtDesp+"]");
//calculating the freight amt proportionately
if ( totGwt != 0 ) // lc_tot_gwt <> 0 then
{
//lc_calc_frt = round(((lc_frt_amt * lc_gwt_desp) / lc_tot_gwt),0)
calcFrt = Math.round(((totalFreight * gwtDesp ) / totGwt));
}
else
{
calcFrt = 0;
}
System.out.println("@@@["+calcFrt+"]");
//end if
//this is to check whether total calculated freight doesnot exceed
//the total freight during rounding the figure
totFrt = totFrt + calcFrt;
System.out.println("@@@totFrt["+totFrt+"]");
if( totFrt > frtAmt ) // lc_tot_frt > lc_frt_amt then
{
calcFrt = frtAmt - ( totFrt - calcFrt );
} //end if
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]gwtDesp["+gwtDesp+"]");
//calculating the freight amt proportionately
if ( totGwt != 0 ) // lc_tot_gwt <> 0 then
{
//lc_calc_frt = round(((lc_frt_amt * lc_gwt_desp) / lc_tot_gwt),0)
calcFrt = Math.round(((totalFreight * gwtDesp ) / totGwt));
}
else
{
calcFrt = 0;
}
System.out.println("@@@["+calcFrt+"]");
//end if
//this is to check whether total calculated freight doesnot exceed
//the total freight during rounding the figure
totFrt = totFrt + calcFrt;
System.out.println("@@@totFrt["+totFrt+"]");
if( totFrt > frtAmt ) // lc_tot_frt > lc_frt_amt then
{
calcFrt = frtAmt - ( totFrt - calcFrt );
} //end if
System.out.println("@@@calcFrt["+calcFrt+"]");
System.out.println("@@@calcFrt["+calcFrt+"]");
if( lrDate != null )
{
lrDateUpd = lrDate;
}
if( lrDate != null )
{
lrDateUpd = lrDate;
}
if( lrNo != null )
{
lrNoUpd = lrNo;
}
if( lrNo != null )
{
lrNoUpd = lrNo;
}
if( lorryNo != null )
{
lorryNoUpd = lorryNo;
}
if( lorryNo != null )
{
lorryNoUpd = lorryNo;
}
System.out.println("@@@@@@[despatch]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[despatch]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
System.out.println("@@@@@@[despatch]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[despatch]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
sql1 = " update despatch set freight = ?, lr_no = ? , lr_date = ? ," +
" lorry_no = ? where desp_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, calcFrt);
pstmt1.setString(2, lrNoUpd);
pstmt1.setTimestamp(3, lrDateUpd);
pstmt1.setString(4, lorryNoUpd);
pstmt1.setString(5, despId);
updCnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
sql = " update despatch set freight = ?, lr_no = ? , lr_date = ? ," +
" lorry_no = ? where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, calcFrt);
pstmt.setString(2, lrNoUpd);
pstmt.setTimestamp(3, lrDateUpd);
pstmt.setString(4, lorryNoUpd);
pstmt.setString(5, despId);
updCnt = pstmt.executeUpdate();
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// for distord_iss
sql = " select tran_id,gross_weight,lr_date, lr_no, lorry_no from distord_iss " +
" where shipment_id = ? and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
......@@ -409,67 +402,69 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
lrDate = rs.getTimestamp("lr_date");
lrNo = rs.getString("lr_no");
lorryNo = rs.getString("lorry_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@distOrdIssId["+distOrdIssId+"]::grossWeight["+grossWeight+"]lrDate["+lrDate+"]");
//calculating the freight amt proportionately
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
if( totGwt != 0 ) // lc_tot_gwt <> 0 then
{
calcFrt = Math.round((( totalFreight * grossWeight) / totGwt));
}//end if
System.out.println("@@@@distOrdIssId["+distOrdIssId+"]::grossWeight["+grossWeight+"]lrDate["+lrDate+"]");
System.out.println("calcFrt["+calcFrt+"]");
//this is to check whether total calculated freight doesnot exceed
//the total freight during rounding the figure
//calculating the freight amt proportionately
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
if( totGwt != 0 ) // lc_tot_gwt <> 0 then
{
calcFrt = Math.round((( totalFreight * grossWeight) / totGwt));
}//end if
totFrt = totFrt + calcFrt;
System.out.println("totFrt["+totFrt+"]");
if( totFrt > totalFreight ) // lc_tot_frt > lc_frt_amt then
{
calcFrt = totalFreight - ( totFrt - calcFrt ) ;
}
System.out.println("calcFrt["+calcFrt+"]");
//this is to check whether total calculated freight doesnot exceed
//the total freight during rounding the figure
System.out.println("calcFrt["+calcFrt+"]totalFreight["+totalFreight+"]totFrt["+totFrt+"]");
totFrt = totFrt + calcFrt;
System.out.println("totFrt["+totFrt+"]");
if( totFrt > totalFreight ) // lc_tot_frt > lc_frt_amt then
{
calcFrt = totalFreight - ( totFrt - calcFrt ) ;
}
if( lrDate != null )
{
lrDateUpd = lrDate;
}
System.out.println("calcFrt["+calcFrt+"]totalFreight["+totalFreight+"]totFrt["+totFrt+"]");
if( lrNo != null )
{
lrNoUpd = lrNo;
}
if( lrDate != null )
{
lrDateUpd = lrDate;
}
if( lorryNo != null )
{
lorryNoUpd = lorryNo;
}
if( lrNo != null )
{
lrNoUpd = lrNo;
}
System.out.println("@@@@@@[distord_iss]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[distord_iss]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
if( lorryNo != null )
{
lorryNoUpd = lorryNo;
}
sql = " update distord_iss set frt_amt = ?, lr_no = ? , " +
" lr_date = ?, lorry_no = ? " +
" where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, calcFrt);
pstmt.setString(2, lrNoUpd);
pstmt.setTimestamp(3, lrDateUpd);
pstmt.setString(4, lorryNoUpd);
pstmt.setString(5, distOrdIssId);
updCnt = pstmt.executeUpdate();
System.out.println("@@@@@@[distord_iss]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[distord_iss]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
sql1 = " update distord_iss set frt_amt = ?, lr_no = ? , " +
" lr_date = ?, lorry_no = ? " +
" where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, calcFrt);
pstmt1.setString(2, lrNoUpd);
pstmt1.setTimestamp(3, lrDateUpd);
pstmt1.setString(4, lorryNoUpd);
pstmt1.setString(5, distOrdIssId);
updCnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
////
// for cons_issue
sql = " select cons_issue,gross_weight,lr_date, lr_no, lorry_no from CONSUME_ISS " +
" where cons_issue in ( select ref_id from ship_docs where shipment_id = ? ) and confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
......@@ -482,64 +477,67 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
lrDate = rs.getTimestamp("lr_date");
lrNo = rs.getString("lr_no");
lorryNo = rs.getString("lorry_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@conOrdIssId["+conOrdIssId+"]::grossWeight["+grossWeight+"]lrDate["+lrDate+"]");
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
if( totGwt != 0 ) // lc_tot_gwt <> 0 then
{
calcFrt = Math.round((( totalFreight * grossWeight) / totGwt));
}//end if
System.out.println("@@@@conOrdIssId["+conOrdIssId+"]::grossWeight["+grossWeight+"]lrDate["+lrDate+"]");
System.out.println("calcFrt["+calcFrt+"]");
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
if( totGwt != 0 ) // lc_tot_gwt <> 0 then
{
calcFrt = Math.round((( totalFreight * grossWeight) / totGwt));
}//end if
totFrt = totFrt + calcFrt;
System.out.println("totFrt["+totFrt+"]");
if( totFrt > totalFreight ) // lc_tot_frt > lc_frt_amt then
{
calcFrt = totalFreight - ( totFrt - calcFrt ) ;
}
System.out.println("calcFrt["+calcFrt+"]");
System.out.println("calcFrt["+calcFrt+"]totalFreight["+totalFreight+"]totFrt["+totFrt+"]");
totFrt = totFrt + calcFrt;
System.out.println("totFrt["+totFrt+"]");
if( totFrt > totalFreight ) // lc_tot_frt > lc_frt_amt then
{
calcFrt = totalFreight - ( totFrt - calcFrt ) ;
}
if( lrDate != null )
{
lrDateUpd = lrDate;
}
System.out.println("calcFrt["+calcFrt+"]totalFreight["+totalFreight+"]totFrt["+totFrt+"]");
if( lrNo != null )
{
lrNoUpd = lrNo;
}
if( lrDate != null )
{
lrDateUpd = lrDate;
}
if( lorryNo != null )
{
lorryNoUpd = lorryNo;
}
if( lrNo != null )
{
lrNoUpd = lrNo;
}
System.out.println("@@@@@@[distord_iss]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[distord_iss]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
if( lorryNo != null )
{
lorryNoUpd = lorryNo;
}
sql = " update CONSUME_ISS set FREIGHT_AMT = ?, lr_no = ? , " +
" lr_date = ?, lorry_no = ? " +
" where cons_issue = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, calcFrt);
pstmt.setString(2, lrNoUpd);
pstmt.setTimestamp(3, lrDateUpd);
pstmt.setString(4, lorryNoUpd);
pstmt.setString(5, conOrdIssId);
updCnt = pstmt.executeUpdate();
System.out.println("@@@@@@[distord_iss]::lrDate["+lrDate+"]lrNo["+lrNo+"]lorryNo["+lorryNo+"]");
System.out.println("@@@@@@[distord_iss]::lrDateUpd["+lrDateUpd+"]lrNoUpd["+lrNoUpd+"]lorryNoUpd["+lorryNoUpd+"]");
sql1 = " update CONSUME_ISS set FREIGHT_AMT = ?, lr_no = ? , " +
" lr_date = ?, lorry_no = ? " +
" where cons_issue = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, calcFrt);
pstmt1.setString(2, lrNoUpd);
pstmt1.setTimestamp(3, lrDateUpd);
pstmt1.setString(4, lorryNoUpd);
pstmt1.setString(5, conOrdIssId);
updCnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// END TEST
// END TEST
/*
//calculating the freight amt proportionately
System.out.println("@@@@totGwt["+totGwt+"]::totalFreight["+totalFreight+"]lrNo["+lrNo+"]");
......@@ -555,7 +553,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
totFrt = totFrt + calcFrt;
System.out.println("totFrt["+totFrt+"]");
if( totFrt > totalFreight ) // lc_tot_frt > lc_frt_amt then
{
{ // lc_calc_frt = lc_frt_amt - (lc_tot_frt - lc_calc_frt)
calcFrt = totalFreight - ( totFrt - calcFrt ) ;
}
......@@ -591,9 +589,10 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
*/
/// test
// everything's OK, update shipment.
if( errCode == null || errCode.trim().length() == 0 )
{
......@@ -617,38 +616,38 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
}
return errCode;
}
}
/*public String actionHandler(String tranId) throws RemoteException, ITMException
{
String retString = "";
try
{
//retString = checkNull(split(tranId, xtraParams, forcedFlag,conn,subSQL));
retString = checkNull(split(tranId));
System.out.println("@@@@@@retString is :"+retString);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
}
return retString;
}*/
//public String split(String tranId,String xtraParams,String forcedFlag, Connection conn,String subSQL) throws RemoteException, ITMException
public String generateTrackInfo(String tranId,Connection conn) throws RemoteException, ITMException
{
String retString = "";
String errString="";
StringBuffer xmlBuff = null;
......@@ -658,7 +657,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
PreparedStatement pstmt = null;
ResultSet rs = null, rs1 = null;
String lineNoStr = "",frtTerm = "";
String refId="",custCodeDlv="",dlvAdd1="",dlvAdd2="",dlvCity="",dlvPin="",dlvCountry="",siteDescr="",siteAdd1="",siteAdd2="",siteCity="",sitePin="",noArt="";
String tranCode="",grossWt="",tarewt="",netwt="",unitShip="",bolNo="",scac="",planStartDt="",planEndDt="",shipMtDt="",expDt="";
String despatchId="",invoiceId="",itemCode="",lotNo="",lotSl="",quantity="",quantityOrd="",convQtyStduom="",unitStd="";
......@@ -688,24 +687,24 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
conn = connDriver.getConnectDB( "DriverITM" );
sql = "select shipment_date from shipment where shipment_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
shipmentDate = rs.getDate("shipment_date");
shipmentDate = rs.getDate("shipment_date");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("shipmentDate:"+shipmentDate);
sql = "select SITE_CODE,CUST_CODE__DLV,DLV_ADD1,DLV_ADD2,DLV_CITY,DLV_PIN,COUNT_CODE__DLV,TRAN_CODE , ";
sql = sql + "GROSS_WEIGHT,TARE_WEIGHT ,NETT_WEIGHT,UNIT__SHIP,BOL_NO,SCAC,NO_ART,DESP_ID from despatch where shipment_id=? ";
pstmt = conn.prepareStatement(sql);
......@@ -736,7 +735,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
errString = itmDBAccessLocal.getErrorString("","VTSHIDEXST","");
return errString;
}
rs.close();
rs = null;
pstmt.close();
......@@ -746,10 +745,10 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("tranCode @@@"+tranCode);
System.out.println("noArt @@@"+noArt);
System.out.println("scac @@@"+scac);
sql = "select descr,add1,add2,city,pin from site where site_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
......@@ -771,9 +770,9 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("siteAdd2:"+siteAdd2);
System.out.println("siteCity:"+siteCity);
System.out.println("sitePin:"+sitePin);
sql = "select DRUG_LIC_NO from customer where cust_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeDlv);
......@@ -787,11 +786,11 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
pstmt.close();
pstmt = null;
System.out.println("drugLicNo:"+drugLicNo);
System.out.println("siteCode!!!!! :"+siteCode);
System.out.println("siteDescr :"+siteDescr);
System.out.println("siteAdd1 :"+siteAdd1);
......@@ -813,8 +812,8 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("bolNo :"+bolNo);
System.out.println("scac :"+scac);
System.out.println("noArt :"+noArt);
sql = "select plan_end,plan_start from shipment_route where shipment_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
......@@ -830,12 +829,12 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
pstmt = null;
System.out.println("planStart:"+planStart);
System.out.println("planEnd:"+planEnd);
/*get records for details !!!*/
sql = "select ref_id,ref_ser from ship_docs where shipment_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
......@@ -852,15 +851,15 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
pstmt = null;
System.out.println("refId:"+refId);
System.out.println("refSer:"+refSer);
if(despatchId == null)
{
System.out.println("despatchId found null in ship_docs");
errString = itmDBAccessLocal.getErrorString("","VTDSIDEXST","");
return errString;
}
sql = "select INVOICE_ID ,ITEM_CODE ,LOT_NO ,LOT_SL,QUANTITY ,QUANTITY__ORD,LOC_CODE,CONV__QTY_STDUOM , ";
sql = sql + "UNIT__STD,UNIT ,QUANTITY__STDUOM ,PACK_QTY,GROSS_WEIGHT,TARE_WEIGHT,NETT_WEIGHT,SSCC_18 ";
......@@ -887,8 +886,8 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
tareWt = rs.getString("TARE_WEIGHT");
netWt = rs.getString("NETT_WEIGHT");
sscc_18 = rs.getString("SSCC_18");
invoiceId = invoiceId==null?"":invoiceId.trim();
itemCode = itemCode==null?"":itemCode.trim();
lotNo = lotNo==null?"":lotNo.trim();
......@@ -901,7 +900,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
qtyStduom = qtyStduom==null?"":qtyStduom.trim();
locCode = locCode==null?"":locCode.trim();
sscc_18 = sscc_18==null?"":sscc_18.trim();
System.out.println("invoiceId @@"+cnt+" "+invoiceId);
System.out.println("itemCode @@"+cnt+" "+itemCode);
System.out.println("lotNo @@"+cnt+" "+lotNo);
......@@ -911,7 +910,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("convQtyStduom @@"+cnt+" "+convQtyStduom);
System.out.println("unitStd @@"+cnt+" "+unitStd);
System.out.println("unit @@"+cnt+" "+unit);
tempMap.put("invoice_id"+cnt, invoiceId);
tempMap.put("item_code"+cnt, itemCode);
tempMap.put("lot_no"+cnt, lotNo);
......@@ -927,18 +926,18 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
tempMap.put("gross_wt"+cnt, grossWt);
tempMap.put("tare_wt"+cnt, tareWt);
tempMap.put("net_wt"+cnt, netWt);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("value of cnt :"+cnt);
sql = "select CUST_PORD,PORD_DATE from sorder where sale_order = (select sord_no from despatch where desp_id=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, despatchId);
......@@ -947,7 +946,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
{
custProd = rs.getString("CUST_PORD");
prodDate = rs.getDate("PORD_DATE");
}
rs.close();
rs = null;
......@@ -955,8 +954,8 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
pstmt = null;
System.out.println("custProd: "+custProd);
System.out.println("prodDate: "+prodDate);
siteCode = siteCode==null?"":siteCode.trim();
siteDescr = siteDescr==null?"":siteDescr.trim();
siteAdd1 = siteAdd1==null?"":siteAdd1.trim();
......@@ -983,12 +982,12 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
shipMtDt=shipmentDate==null?"":sdf.format(shipmentDate);
custProd = custProd==null?"":custProd.trim();
purcDate= prodDate==null?"":sdf.format(prodDate);
//create xml for track information
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
......@@ -1009,12 +1008,12 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
System.out.println("details 1 start!!!!!");
/*
* deatails 1 start
* */
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"tnt_tran_info\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
......@@ -1045,32 +1044,32 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
xmlBuff.append("<count_code__dlv><![CDATA["+ dlvCountry +"]]></count_code__dlv>");
xmlBuff.append("<plan_start><![CDATA["+ planStartDt +"]]></plan_start>");
xmlBuff.append("<plan_end><![CDATA["+ planEndDt +"]]></plan_end>");
// xmlBuff.append("<remarks><![CDATA["+ tranId +"]]></remarks>");
// xmlBuff.append("<remarks><![CDATA["+ tranId +"]]></remarks>");
xmlBuff.append("</Detail1>");
lineNo = 0;
/*
* deatils1 end
*
* */
System.out.println("end of details 1");
for(int itemCtr = 1; itemCtr <= cnt; itemCtr++)
{
lineNo++;
System.out.println("lineNo is "+lineNo);
// tempMap = (HashMap)tempList.get(itemCtr);
// tempMap = (HashMap)tempList.get(itemCtr);
/*
* start of Details 2
* */
System.out.println("start of details 2");
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"tnt_tran_info\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id/>");
......@@ -1079,15 +1078,15 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("lineNoStr "+lineNoStr);
// xmlBuff.append("<line_no>" + new Integer(lineNo).toString().length() + "</line_no>");
xmlBuff.append("<line_no>" + lineNoStr + "</line_no>");
xmlBuff.append("<ref_ser><![CDATA["+ refSer +"]]></ref_ser>");
xmlBuff.append("<ref_id><![CDATA["+ refId+"]]></ref_id>");
System.out.println("val of invoice_id "+(String)tempMap.get("invoice_id"+itemCtr) );
System.out.println("val of item_code "+(String)tempMap.get("item_code"+itemCtr) );
xmlBuff.append("<invoice_id><![CDATA["+ (String)tempMap.get("invoice_id"+itemCtr) +"]]></invoice_id>");
xmlBuff.append("<item_code><![CDATA["+ (String)tempMap.get("item_code"+itemCtr) +"]]></item_code>");
sql = "select DESCR,ITEM_CODE__UPC,ITEM_CODE__NDC from item where item_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tempMap.get("item_code"+itemCtr));
......@@ -1105,14 +1104,14 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("itmDescr: "+itmDescr);
System.out.println("itmCodeUPC: "+itmCodeUPC);
System.out.println("itmCodeNDC: "+itmCodeNDC);
itmDescr = itmDescr==null?"":itmDescr.trim();
itmCodeUPC = itmCodeUPC==null?"":itmCodeUPC.trim();
itmCodeNDC = itmCodeNDC==null?"":itmCodeNDC.trim();
sql = "select exp_date from ITEM_LOT_INFO where item_code=? and lot_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tempMap.get("item_code"+itemCtr));
......@@ -1121,7 +1120,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
if (rs.next())
{
expDate = rs.getDate("exp_date");
}
expDt=expDate==null?"":sdf.format(expDate);
rs.close();
......@@ -1131,13 +1130,13 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
System.out.println("itmDescr: "+itmDescr);
System.out.println("itmCodeUPC: "+itmCodeUPC);
System.out.println("itmCodeNDC: "+itmCodeNDC);
itmDescr = itmDescr==null?"":itmDescr.trim();
itmCodeUPC = itmCodeUPC==null?"":itmCodeUPC.trim();
itmCodeNDC = itmCodeNDC==null?"":itmCodeNDC.trim();
xmlBuff.append("<item_descr><![CDATA["+ itmDescr +"]]></item_descr>");
xmlBuff.append("<item_code__ndc><![CDATA["+ itmCodeNDC +"]]></item_code__ndc>");
xmlBuff.append("<item_code__upc><![CDATA["+ itmCodeUPC +"]]></item_code__upc>");
......@@ -1159,21 +1158,21 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
xmlBuff.append("<cust_pord><![CDATA["+ custProd +"]]></cust_pord>");
xmlBuff.append("<pord_date><![CDATA["+ purcDate +"]]></pord_date>");
xmlBuff.append("<sscc_18><![CDATA["+ sscc_18 +"]]></sscc_18>");
xmlBuff.append("</Detail2>");
}//end of for loop
/*
* end of details 2
*
* */
/*
* end of details 2
*
* */
System.out.println("end of details 2");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
......@@ -1184,9 +1183,9 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
retString = saveData(siteCode,xmlString,conn);
System.out.println("#########2: retString:"+retString);
if (retString.indexOf("Success") > -1)
{
System.out.println("Successfully!!!!!!");
......@@ -1197,27 +1196,27 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
{
System.out.println("failed!!!!");
conn.rollback();
errString = itmDBAccessLocal.getErrorString("","VTGTRTIFLD","");
return errString;
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
}
return retString;
}
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException
{
System.out.println("mahendra testing !!!!saving data...........");
......@@ -1251,11 +1250,11 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
}
return retString;
}
private String checkNull( String input )
{
......@@ -1265,7 +1264,7 @@ public class ShipmentLocConf extends ActionHandlerEJB implements ShipmentLocConf
}
return input;
}
}
......@@ -246,6 +246,11 @@ public class ShipmentLocDefaultAct extends ActionHandlerEJB implements ShipmentL
valueXmlString.append("</Detail>\r\n");
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("valueXmlString =" + valueXmlString.toString());
valueXmlString.append("</Root>\r\n");
......
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