Commit 179f9062 authored by rtiwari's avatar rtiwari

updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94220 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 66be8737
...@@ -13,6 +13,8 @@ import ibase.webitm.utility.GenericUtility; ...@@ -13,6 +13,8 @@ import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator; import ibase.webitm.utility.TransIDGenerator;
import java.io.File;
import java.io.FileWriter;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
...@@ -122,7 +124,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -122,7 +124,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
try try
{ {
System.out.println("WoTransferPrc getData called :: ::"); System.out.println("WoTransferPrc getData 5-4-0-36 called :: ::");
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
...@@ -144,7 +146,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -144,7 +146,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
} }
if(worder != null && worder.trim().length() > 0) if(worder != null && worder.trim().length() > 0)
{ {
sql = "select count(*) from workorder where work_order = ? and status not in ('F') "; sql = "select count(*) from workorder where work_order = ? and status in ('R') ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,worder); pstmt.setString(1,worder);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -1070,166 +1072,131 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -1070,166 +1072,131 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
String tranIdForIssue = arrayForTranId[1].substring(0,endIndex); String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
System.out.println("-tranIdForIssue-"+tranIdForIssue); System.out.println("-tranIdForIssue-"+tranIdForIssue);
stockMap.put("item_code", itemCode); StockTransferConf stconf = new StockTransferConf();
stockMap.put("site_code", siteCode); retString = stconf.confirm(tranIdForIssue,xtraParams,"");
stockMap.put("loc_code", locCodeFr); System.out.println("retString from StockTransferConf :: @:: "+retString);//CONFSUCC
stockMap.put("lot_no", lotno); if(retString.indexOf("CONFSUCC") > -1)
stockMap.put("lot_sl", lotsl); {
double quantity = 0.0;
if(allocQty != null) stockMap.put("item_code", itemCode);
{ stockMap.put("site_code", siteCode);
quantity = Double.parseDouble(allocQty); stockMap.put("loc_code", locCodeFr);
} stockMap.put("lot_no", lotno);
stockMap.put("quantity", ""+quantity); stockMap.put("lot_sl", lotsl);
double quantity = 0.0;
sql = "SELECT INV_STAT FROM LOCATION WHERE LOC_CODE = ? "; if(allocQty != null)
pstmt = connOne.prepareStatement(sql); {
pstmt.setString(1,locCodeTo); quantity = Double.parseDouble(allocQty);
rs = pstmt.executeQuery(); }
if(rs.next()) stockMap.put("quantity", ""+quantity);
{
invStatLocCodeTo = checkNull(rs.getString("INV_STAT")); sql = "SELECT INV_STAT FROM LOCATION WHERE LOC_CODE = ? ";
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
// //if(invStatLocCodeTo.trim().equalsIgnoreCase(locCodeTo.trim()) && invStatLocCodeTo.trim().equalsIgnoreCase(partialGrlLoc.trim()))
// {
// stockMap.put("no_art", allocQty);
// }
// else
// {
stockMap.put("no_art", noArt);
// }
stockMap.put("tran_ser", "XFRX");
stockMap.put("acct_code__cr",acctCodeInv1);
stockMap.put("cctr_code__cr",cctrCodeInv1);
stockMap.put("acct_code_inv",acctCodeInv1);
stockMap.put("cctr_code_inv",cctrCodeInv1);
sql = "select acct_code__inv, cctr_code__inv, "
+ "exp_date, pack_code, mfg_date, site_code__mfg, "
+ "pack_instr, supp_code__mfg, retest_date, "
+ "gross_rate, rate, conv__qty_stduom, unit__alt, batch_no, batch_size, "
+ "unit, grade, remarks, dimension, quantity ,hold_qty,actual_rate ,partial_used "
+ ",potency_perc, inv_stat, gross_weight, tare_weight, net_weight, lot_sl__org " // added by cpatil on 20/11/13 compare with pb code and adding missing field
+ "from stock "
+ "where item_code = ? "
+ "and site_code = ? "
+ "and loc_code = ? "
+ "and lot_no = ? "
+ "and lot_sl = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCodeFr);
pstmt.setString(4,lotno);
pstmt.setString(5,lotsl);
rs = pstmt.executeQuery();
if ( rs.next() )
{
expDate = rs.getTimestamp("exp_date");
packCode = rs.getString("pack_code");
mfgDate = rs.getTimestamp("mfg_date");
siteCodeMfg = rs.getString("site_code__mfg");
packInstr = rs.getString("pack_instr");
suppCodeMfg = rs.getString("supp_code__mfg");
restestDate = rs.getTimestamp("retest_date");
stkGrossRate = rs.getDouble("gross_rate");
stkRate = rs.getDouble("rate");
System.out.println("stkGrossRate"+stkGrossRate+"stkRate"+stkRate);
convQtyStduom = rs.getDouble("conv__qty_stduom");
unitAlt = rs.getString("unit__alt");
batchNo = rs.getString("batch_no");
batchSize = rs.getDouble("batch_size");
unit = rs.getString("unit");
grade = rs.getString("grade");
remarks1 = rs.getString("remarks");
dimension = rs.getString("dimension");
stkQuantity = rs.getDouble("quantity");
holdQuantity = rs.getDouble("hold_qty");
actualRate = rs.getDouble("actual_rate");
//partialUsed = checkNull(rs.getString("partial_used"));
potencyPerc = rs.getDouble("potency_perc");
grossWeight = rs.getDouble("gross_weight");
tareWeight = rs.getDouble("tare_weight");
netWeight = rs.getDouble("net_weight");
//lotSlOrg = rs.getString("lot_sl__org");
stockMap.put("rate",Double.toString(stkRate));
stockMap.put("gross_rate",Double.toString(stkGrossRate));
System.out.println("stkGrossRate:::"+Double.toString(stkRate)+"stkRate::::"+Double.toString(stkGrossRate));
stockMap.put("tran_id", tranIdForIssue );
stockMap.put("tran_date",currDate );
stockMap.put("qty_stduom", ""+quantity);
stockMap.put("unit",unit);
stockMap.put("grade",grade);
stockMap.put("remarks",remarks1);
stockMap.put("dimension",dimension);
stockMap.put("tran_type", "I");
stockMap.put("exp_date", expDate);
stockMap.put("pack_code", packCode);
stockMap.put("mfg_date", mfgDate);
stockMap.put("site_code__mfg", siteCodeMfg);
stockMap.put("pack_instr", packInstr);
stockMap.put("supp_code__mfg", suppCodeMfg);
stockMap.put("retest_date", restestDate);
stockMap.put("conv__qty_stduom", ""+convQtyStduom);
stockMap.put("unit__alt", unitAlt);
stockMap.put("batch_no", batchNo);
stockMap.put("batch_size", ""+batchSize);
stockMap.put("actual_rate", actualRate);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
boolean isError = false;
errList = allocTransfer(siteCode,itemCode,locCodeFr ,
lotno,lotsl,locCodeTo ,lotno,lotsl,
actualPropQty,stockMap, xtraParams , connOne );
System.out.println("from alloc transfer=="+errList.toString());
retString = errList.get(0).toString() ;
System.out.println("FROM allocTransfer 0 : "+retString);
if ( retString != null && retString.trim().length() > 0 )
{
isError = true;
}
stockMap.clear();
if(isError == false)
{
System.out.println(" STOCK ALLOCATED SUCCESSFULL");
StockTransferConf stconf = new StockTransferConf();
retString = stconf.confirm(tranIdForIssue,xtraParams,"");
System.out.println("retString from confirmStocktrans :: @:: "+retString);//CONFSUCC
if(retString.indexOf("CONFSUCC") > -1)
{
int count = 0,recIn=0 ;
sql = " select count(*) from inv_alloc_det where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = connOne.prepareStatement(sql); pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId); pstmt.setString(1,locCodeTo);
pstmt.setString(2,itemCode); rs = pstmt.executeQuery();
pstmt.setString(3,lotno); if(rs.next())
pstmt.setString(4,lotsl); {
pstmt.setString(5,locCodeTo); invStatLocCodeTo = checkNull(rs.getString("INV_STAT"));
pstmt.setString(6,siteCode);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
// //if(invStatLocCodeTo.trim().equalsIgnoreCase(locCodeTo.trim()) && invStatLocCodeTo.trim().equalsIgnoreCase(partialGrlLoc.trim()))
// {
// stockMap.put("no_art", allocQty);
// }
// else
// {
stockMap.put("no_art", noArt);
// }
stockMap.put("tran_ser", "XFRX");
stockMap.put("acct_code__cr",acctCodeInv1);
stockMap.put("cctr_code__cr",cctrCodeInv1);
stockMap.put("acct_code_inv",acctCodeInv1);
stockMap.put("cctr_code_inv",cctrCodeInv1);
sql = "select acct_code__inv, cctr_code__inv, "
+ "exp_date, pack_code, mfg_date, site_code__mfg, "
+ "pack_instr, supp_code__mfg, retest_date, "
+ "gross_rate, rate, conv__qty_stduom, unit__alt, batch_no, batch_size, "
+ "unit, grade, remarks, dimension, quantity ,hold_qty,actual_rate ,partial_used "
+ ",potency_perc, inv_stat, gross_weight, tare_weight, net_weight, lot_sl__org " // added by cpatil on 20/11/13 compare with pb code and adding missing field
+ "from stock "
+ "where item_code = ? "
+ "and site_code = ? "
+ "and loc_code = ? "
+ "and lot_no = ? "
+ "and lot_sl = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCodeFr);
pstmt.setString(4,lotno);
pstmt.setString(5,lotsl);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if ( rs.next() ) if ( rs.next() )
{ {
count = rs.getInt(1); expDate = rs.getTimestamp("exp_date");
packCode = rs.getString("pack_code");
mfgDate = rs.getTimestamp("mfg_date");
siteCodeMfg = rs.getString("site_code__mfg");
packInstr = rs.getString("pack_instr");
suppCodeMfg = rs.getString("supp_code__mfg");
restestDate = rs.getTimestamp("retest_date");
stkGrossRate = rs.getDouble("gross_rate");
stkRate = rs.getDouble("rate");
System.out.println("stkGrossRate"+stkGrossRate+"stkRate"+stkRate);
convQtyStduom = rs.getDouble("conv__qty_stduom");
unitAlt = rs.getString("unit__alt");
batchNo = rs.getString("batch_no");
batchSize = rs.getDouble("batch_size");
unit = rs.getString("unit");
grade = rs.getString("grade");
remarks1 = rs.getString("remarks");
dimension = rs.getString("dimension");
stkQuantity = rs.getDouble("quantity");
holdQuantity = rs.getDouble("hold_qty");
actualRate = rs.getDouble("actual_rate");
//partialUsed = checkNull(rs.getString("partial_used"));
potencyPerc = rs.getDouble("potency_perc");
grossWeight = rs.getDouble("gross_weight");
tareWeight = rs.getDouble("tare_weight");
netWeight = rs.getDouble("net_weight");
//lotSlOrg = rs.getString("lot_sl__org");
stockMap.put("rate",Double.toString(stkRate));
stockMap.put("gross_rate",Double.toString(stkGrossRate));
System.out.println("stkGrossRate:::"+Double.toString(stkRate)+"stkRate::::"+Double.toString(stkGrossRate));
stockMap.put("tran_id", tranIdForIssue );
stockMap.put("tran_date",currDate );
stockMap.put("qty_stduom", ""+quantity);
stockMap.put("unit",unit);
stockMap.put("grade",grade);
stockMap.put("remarks",remarks1);
stockMap.put("dimension",dimension);
stockMap.put("tran_type", "I");
stockMap.put("exp_date", expDate);
stockMap.put("pack_code", packCode);
stockMap.put("mfg_date", mfgDate);
stockMap.put("site_code__mfg", siteCodeMfg);
stockMap.put("pack_instr", packInstr);
stockMap.put("supp_code__mfg", suppCodeMfg);
stockMap.put("retest_date", restestDate);
stockMap.put("conv__qty_stduom", ""+convQtyStduom);
stockMap.put("unit__alt", unitAlt);
stockMap.put("batch_no", batchNo);
stockMap.put("batch_size", ""+batchSize);
stockMap.put("actual_rate", actualRate);
} }
if(rs != null) if(rs != null)
rs.close(); rs.close();
...@@ -1237,133 +1204,176 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -1237,133 +1204,176 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
if(pstmt != null) if(pstmt != null)
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(count == 0)
boolean isError = false;
errList = allocTransfer(siteCode,itemCode,locCodeFr ,
lotno,lotsl,locCodeTo ,lotno,lotsl,
actualPropQty,stockMap, xtraParams , connOne );
System.out.println("from alloc transfer=="+errList.toString());
retString = errList.get(0).toString() ;
System.out.println("FROM allocTransfer 0 : "+retString);
if ( retString != null && retString.trim().length() > 0 )
{ {
if( batchQuantity == totWoQty) isError = true;
{ }
sql = " update inv_alloc_det set loc_code = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? "; stockMap.clear();
pstmt = connOne.prepareStatement(sql); if(isError == false)
pstmt.setString(1,locCodeTo); {
pstmt.setString(2,tranId); retString = "CONFSUCC";
pstmt.setString(3,itemCode); System.out.println(" STOCK ALLOCATED SUCCESSFULL");
pstmt.setString(4,lotno); // StockTransferConf stconf = new StockTransferConf();
pstmt.setString(5,lotsl); // retString = stconf.confirm(tranIdForIssue,xtraParams,"");
pstmt.setString(6,locCodeFr); // System.out.println("retString from confirmStocktrans :: @:: "+retString);//CONFSUCC
pstmt.setString(7,siteCode); // if(retString.indexOf("CONFSUCC") > -1)
pstmt.executeUpdate(); // {
if(pstmt != null) int count = 0,recIn=0 ;
pstmt.close(); sql = " select count(*) from inv_alloc_det where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = null;
}else
{
int maxlineNo = 0;
sql = " select max(line_no) as max_line_no from inv_alloc_det where tran_id = ? ";
pstmt = connOne.prepareStatement(sql); pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId); pstmt.setString(1,tranId);
pstmt.setString(2,itemCode);
pstmt.setString(3,lotno);
pstmt.setString(4,lotsl);
pstmt.setString(5,locCodeTo);
pstmt.setString(6,siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if ( rs.next() ) if ( rs.next() )
{ {
maxlineNo = rs.getInt(1); count = rs.getInt(1);
} }
System.out.println("maxlineNo::"+maxlineNo);
if(rs != null) if(rs != null)
rs.close(); rs.close();
rs = null; rs = null;
if(pstmt != null) if(pstmt != null)
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql = " Insert into inv_alloc_det(TRAN_ID,LINE_NO,SITE_CODE,ITEM_CODE,LOT_NO,LOT_SL,QUANTITY,REMARKS,REAS_CODE,LOC_CODE,EXP_LEV,ISSUE_QTY)" + if(count == 0)
" values (?,?,?,?,?,?,?,?,?,?,?,?)"; {
pstmt = connOne.prepareStatement(sql); if( batchQuantity == totWoQty)
pstmt.setString(1,tranId); {
pstmt.setInt(2,maxlineNo+1); sql = " update inv_alloc_det set loc_code = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt.setString(3,siteCode); pstmt = connOne.prepareStatement(sql);
pstmt.setString(4,itemCode); pstmt.setString(1,locCodeTo);
pstmt.setString(5,lotno); pstmt.setString(2,tranId);
pstmt.setString(6,lotsl); pstmt.setString(3,itemCode);
pstmt.setDouble(7,actualPropQty); pstmt.setString(4,lotno);
pstmt.setString(8,remarks); pstmt.setString(5,lotsl);
pstmt.setString(9,reasCode); pstmt.setString(6,locCodeFr);
pstmt.setString(10,locCodeTo); pstmt.setString(7,siteCode);
pstmt.setString(11,explev); pstmt.executeUpdate();
pstmt.setDouble(12,actualPropQty); if(pstmt != null)
pstmt.executeUpdate(); pstmt.close();
if(pstmt != null) pstmt = null;
pstmt.close(); }else
pstmt = null; {
sql = " update inv_alloc_det set quantity = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
System.out.println(" SQL::update"+sql); int maxlineNo = 0;
pstmt = connOne.prepareStatement(sql); sql = " select max(line_no) as max_line_no from inv_alloc_det where tran_id = ? ";
pstmt.setDouble(1,(actualQty - actualPropQty)); pstmt = connOne.prepareStatement(sql);
pstmt.setString(2,tranId); pstmt.setString(1,tranId);
pstmt.setString(3,itemCode); rs = pstmt.executeQuery();
pstmt.setString(4,lotno); if ( rs.next() )
pstmt.setString(5,lotsl); {
pstmt.setString(6,locCodeFr); maxlineNo = rs.getInt(1);
pstmt.setString(7,siteCode); }
pstmt.executeUpdate(); System.out.println("maxlineNo::"+maxlineNo);
if(pstmt != null) if(rs != null)
pstmt.close(); rs.close();
pstmt = null; rs = null;
} if(pstmt != null)
} pstmt.close();
else pstmt = null;
{ sql = " Insert into inv_alloc_det(TRAN_ID,LINE_NO,SITE_CODE,ITEM_CODE,LOT_NO,LOT_SL,QUANTITY,REMARKS,REAS_CODE,LOC_CODE,EXP_LEV,ISSUE_QTY)" +
" values (?,?,?,?,?,?,?,?,?,?,?,?)";
sql = " update inv_alloc_det set quantity = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? "; pstmt = connOne.prepareStatement(sql);
System.out.println(" SQL::update"+sql); pstmt.setString(1,tranId);
pstmt = connOne.prepareStatement(sql); pstmt.setInt(2,maxlineNo+1);
pstmt.setDouble(1,(actualQty - actualPropQty)); pstmt.setString(3,siteCode);
pstmt.setString(2,tranId); pstmt.setString(4,itemCode);
pstmt.setString(3,itemCode); pstmt.setString(5,lotno);
pstmt.setString(4,lotno); pstmt.setString(6,lotsl);
pstmt.setString(5,lotsl); pstmt.setDouble(7,actualPropQty);
pstmt.setString(6,locCodeFr); pstmt.setString(8,remarks);
pstmt.setString(7,siteCode); pstmt.setString(9,reasCode);
pstmt.executeUpdate(); pstmt.setString(10,locCodeTo);
if(pstmt != null) pstmt.setString(11,explev);
pstmt.close(); pstmt.setDouble(12,actualPropQty);
pstmt = null; pstmt.executeUpdate();
double lcToqty=0.0; if(pstmt != null)
sql = " select quantity from inv_alloc_det where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? "; pstmt.close();
pstmt = connOne.prepareStatement(sql); pstmt = null;
pstmt.setString(1,tranId); sql = " update inv_alloc_det set quantity = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt.setString(2,itemCode); System.out.println(" SQL::update"+sql);
pstmt.setString(3,lotno); pstmt = connOne.prepareStatement(sql);
pstmt.setString(4,lotsl); pstmt.setDouble(1,(actualQty - actualPropQty));
pstmt.setString(5,locCodeTo); pstmt.setString(2,tranId);
pstmt.setString(6,siteCode); pstmt.setString(3,itemCode);
rs = pstmt.executeQuery(); pstmt.setString(4,lotno);
if ( rs.next() ) pstmt.setString(5,lotsl);
{ pstmt.setString(6,locCodeFr);
lcToqty = rs.getDouble(1); pstmt.setString(7,siteCode);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
}
}
else
{
sql = " update inv_alloc_det set quantity = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
System.out.println(" SQL::update"+sql);
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,(actualQty - actualPropQty));
pstmt.setString(2,tranId);
pstmt.setString(3,itemCode);
pstmt.setString(4,lotno);
pstmt.setString(5,lotsl);
pstmt.setString(6,locCodeFr);
pstmt.setString(7,siteCode);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
double lcToqty=0.0;
sql = " select quantity from inv_alloc_det where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setString(2,itemCode);
pstmt.setString(3,lotno);
pstmt.setString(4,lotsl);
pstmt.setString(5,locCodeTo);
pstmt.setString(6,siteCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
lcToqty = rs.getDouble(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
sql = "update inv_alloc_det set quantity = ? ,ISSUE_QTY = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,(lcToqty + actualPropQty));
pstmt.setDouble(2,(lcToqty + actualPropQty));
pstmt.setString(3,tranId);
pstmt.setString(4,itemCode);
pstmt.setString(5,lotno);
pstmt.setString(6,lotsl);
pstmt.setString(7,locCodeTo);
pstmt.setString(8,siteCode);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
}
// }
} }
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
sql = "update inv_alloc_det set quantity = ? ,ISSUE_QTY = ? where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,(lcToqty + actualPropQty));
pstmt.setDouble(2,(lcToqty + actualPropQty));
pstmt.setString(3,tranId);
pstmt.setString(4,itemCode);
pstmt.setString(5,lotno);
pstmt.setString(6,lotsl);
pstmt.setString(7,locCodeTo);
pstmt.setString(8,siteCode);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
}
}
} }
} }
// if((retString != null ) && retString.indexOf("Success") > -1 || retString.indexOf("CONFSUCC") >-1) // if((retString != null ) && retString.indexOf("Success") > -1 || retString.indexOf("CONFSUCC") >-1)
...@@ -1470,8 +1480,12 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -1470,8 +1480,12 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
ArrayList retValue = new ArrayList(); ArrayList retValue = new ArrayList();
HashMap hashMap = null; HashMap hashMap = null;
HashMap tempMap = null ; HashMap tempMap = null ;
// Connection conn1 = null;
try try
{ {
//ConnDriver connDriver = new ConnDriver();
// conn1 = connDriver.getConnectDB("DriverITM");
//connDriver = null;
String dbDateFormat = genericUtility.getDBDateFormat(); String dbDateFormat = genericUtility.getDBDateFormat();
String applDateFormat = genericUtility.getApplDateFormat();//-- String applDateFormat = genericUtility.getApplDateFormat();//--
SimpleDateFormat sdfD = new SimpleDateFormat(applDateFormat);//-- SimpleDateFormat sdfD = new SimpleDateFormat(applDateFormat);//--
...@@ -1598,7 +1612,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -1598,7 +1612,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
stockMap.put("quantity", ""+stockQty); stockMap.put("quantity", ""+stockQty);
stockMap.put("qty_stduom", ""+stockQty); stockMap.put("qty_stduom", ""+stockQty);
//stock update for tran type = "I" //stock update for tran type = "I"
errString = updateStock( stockMap, xtraParams, conn ); //updateStock called only once's errString = updateStock( stockMap, xtraParams, conn ); //updateStock ALLOC_QTY
System.out.println("stock update FOR I ....."+errString); System.out.println("stock update FOR I ....."+errString);
if ( errString != null && errString.trim().length() > 0 ) if ( errString != null && errString.trim().length() > 0 )
{ {
...@@ -1634,7 +1648,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -1634,7 +1648,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
do //iterate rs for deallcation do //iterate rs for deallcation
{ {
splitQty = 0; splitQty = 0;
refSer = checkNull(rs.getString( "ref_ser" )) ; refSer = checkNull(rs.getString( "ref_ser" ));
refId = checkNull(rs.getString( "ref_id" )); refId = checkNull(rs.getString( "ref_id" ));
// //refLine = rs.getInt("ref_line"); // //refLine = rs.getInt("ref_line");
refLine = Integer.parseInt( checkNull(rs.getString("ref_line")).trim().length() == 0 ?"0":rs.getString("ref_line").trim()) ; refLine = Integer.parseInt( checkNull(rs.getString("ref_line")).trim().length() == 0 ?"0":rs.getString("ref_line").trim()) ;
...@@ -1673,8 +1687,9 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -1673,8 +1687,9 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
hashMap.put("alloc_qty",new Double(quantity)); hashMap.put("alloc_qty",new Double(quantity));
hashMap.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode")); hashMap.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
hashMap.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId")); hashMap.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
errString = invAllocTrace.updateInvallocTrace(hashMap, conn); // errString = invAllocTrace.updateInvallocTrace(hashMap, conn); // COMMENTED FOR USE EXISTING METHOD
System.out.println("updateInvallocTrace 2....."+errString); errString = updateInvallocTrace(hashMap, conn);
System.out.println("updateInvallocTrace 2.LOCAL...."+errString);
if ( errString != null && errString.trim().length() > 0 ) if ( errString != null && errString.trim().length() > 0 )
{ {
retValue.add("Error"); retValue.add("Error");
...@@ -1683,6 +1698,12 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -1683,6 +1698,12 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
} }
else else
{ {
// if(conn1 != null)
// {
// conn1.commit();
// conn1.close();
// conn = null;
// }
System.out.println("DeAlloc updateInvallocTrace(HashMap, Connection) : Sucessuful!"); System.out.println("DeAlloc updateInvallocTrace(HashMap, Connection) : Sucessuful!");
System.out.println("refSer:::::"+refSer); System.out.println("refSer:::::"+refSer);
if("S-ORD".equalsIgnoreCase(refSer.trim())) //sale order if("S-ORD".equalsIgnoreCase(refSer.trim())) //sale order
...@@ -2521,7 +2542,6 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -2521,7 +2542,6 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
} }
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
if(pstmt != null) if(pstmt != null)
...@@ -5667,4 +5687,333 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -5667,4 +5687,333 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
System.out.println("Returning Value from adjustStkValue : "+errString); System.out.println("Returning Value from adjustStkValue : "+errString);
return errString; return errString;
} }
public String updateInvallocTrace(HashMap invallocTraceMap, Connection conn) throws ITMException,Exception
{
String fileDest = "";
double tempAllocQty = 0;
try
{
//changes by gulzar on 12/12/2011 to write the log file in jboss log location
//f = new FileWriter("invalloc.log", true);
fileDest = CommonConstants.JBOSSHOME + File.separator + "server" + File.separator + "default" + File.separator + "log" + File.separator + "invalloc.log";
//f = new FileWriter( fileDest, true);
}
catch(Exception e)
{
System.out.println(e.getMessage());
// writeException(e, fileDest );
}
String errString = "";
String errCode = "" ;
String sql = null ;
String sqlUpdate = null ;
String keyStringQuery = null ;
CommonConstants commonConstants = new CommonConstants();
String refSer = (String)invallocTraceMap.get("ref_ser");
String refId = (String)invallocTraceMap.get("ref_id");
String refLine = (String)invallocTraceMap.get("ref_line");
String siteCode = (String)invallocTraceMap.get("site_code");
String itemCode = (String)invallocTraceMap.get("item_code");
String locCode = (String)invallocTraceMap.get("loc_code");
String lotNo = (String)invallocTraceMap.get("lot_no");
String lotSl = (String)invallocTraceMap.get("lot_sl");
double allocQty = ((Double)invallocTraceMap.get("alloc_qty")).doubleValue();
String chgUser = (String)invallocTraceMap.get("chg_user");
String chgTerm = (String)invallocTraceMap.get("chg_term");
String chgWin = (String)invallocTraceMap.get("chg_win");
if(lotNo == null)
lotNo = " ";
if(lotSl == null)
lotSl = " ";
//Changed by gulzar on 12/12/2011
if ( chgUser == null || chgUser.trim().length() == 0 )
{
chgUser = "SYSTEM";
}
if ( chgTerm == null || chgTerm.trim().length() == 0 )
{
chgTerm = "SYSTEM";
}
//End changes by gulzar on 12/12/2011
java.sql.Date chgDate = new java.sql.Date(System.currentTimeMillis());
java.sql.Date tranDate = new java.sql.Date(System.currentTimeMillis());
PreparedStatement pstmt = null ;
ResultSet rSet = null, rs = null ;
Statement stmt = null ;
String tranId = null ;
try
{
keyStringQuery = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE UPPER(TRAN_WINDOW) = 'T_ALLOCTRACE'";
System.out.println("keyStringQuery--------->>"+keyStringQuery);
stmt = conn.createStatement();
rSet = stmt.executeQuery(keyStringQuery);
System.out.println("keyString :"+rSet.toString());
String tranSer1 = "";
String keyString = "";
String keyCol = "";
if (rSet.next())
{
keyString = rSet.getString(1);
keyCol = rSet.getString(2);
tranSer1 = rSet.getString(3);
}
rSet.close();
stmt.close();
rSet = null;
stmt = null;
// 31/10/13 manoharan locking to be done before allocation
if (CommonConstants.DB_NAME.equalsIgnoreCase("DB2") || CommonConstants.DB_NAME.equalsIgnoreCase("MYSQL") ){
sql =" select alloc_qty from stock where item_code = ?"
+" and site_code = ?"
+" and loc_code = ?"
+" and lot_no = ?"
+"and lot_sl = ? for update ";
}
else if (CommonConstants.DB_NAME.equalsIgnoreCase("MSSQL")){
sql =" select alloc_qty from stock (updlock) where item_code = ?"
+" and site_code = ?"
+" and loc_code = ?"
+" and lot_no = ?"
+"and lot_sl = ? ";
}
else
{
sql =" select alloc_qty from stock where item_code = ?"
+" and site_code = ?"
+" and loc_code = ?"
+" and lot_no = ?"
+"and lot_sl = ? for update nowait ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
rs = pstmt.executeQuery();
if(rs.next())
{
tempAllocQty = rs.getDouble(1);
}
else
{
errString = "VTLCKERR";
}
pstmt.close();
rs.close();
if (errString != null && errString.trim().length() > 0)
{
return errString;
}
// end
// f.write(keyString + " " + keyCol + " " + tranSer1+ "\r\n");
System.out.println("keyString :"+ keyString);
System.out.println("keyCol :"+ keyCol);
System.out.println("tranSer1 :"+ tranSer1);
String xmlValues = "";
String tranDateStr = getCurrdateAppFormat(); //added by rajendra on 17/04/09 for tran date
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + tranDateStr + "</tran_date>"; //added by rajendra on 17/04/09
xmlValues = xmlValues +"</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", commonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
// f.write("trace tran id ... " +tranId + "\r\n");
System.out.println("tranId :"+tranId);
sql = "INSERT INTO INVALLOC_TRACE (TRAN_ID, TRAN_DATE, REF_SER, REF_ID,"
+"REF_LINE,ITEM_CODE, SITE_CODE, LOC_CODE,LOT_NO, LOT_SL, ALLOC_QTY, CHG_WIN,"
+"CHG_USER, CHG_TERM, CHG_DATE )VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
System.out.println("trans id="+ tranId);
System.out.println("tranDate="+ tranDate);
System.out.println("refSer="+ refSer);
System.out.println("refId="+ refId);
System.out.println("refLine="+ refLine);
System.out.println("itemCode="+ itemCode);
System.out.println("siteCodeShip="+ siteCode);
System.out.println("locCode="+ locCode);
System.out.println("lotNo="+ lotNo);
System.out.println("LOT_SL="+ lotSl);
System.out.println("ALLOC_QTY="+ allocQty);
System.out.println("chgWin="+ chgWin);
System.out.println("chgUser="+ chgUser);
System.out.println("chgTerm="+ chgTerm);
System.out.println("chgDate="+ chgDate);
// f.write("trans id="+ tranId+"\n");
// f.write("tranDate="+ tranDate+"\n");
// f.write("refSer="+ refSer+"\n");
// f.write("refId="+ refId+"\n");
// f.write("refLine="+ refLine+"\n");
// f.write("itemCode="+ itemCode+"\n");
// f.write("locCode="+ locCode+"\n");
// f.write("lotNo="+ lotNo+"\n");
// f.write("lotSl="+ lotSl+"\n");
// f.write("ALLOC_QTY="+ allocQty+"\n");
pstmt.setString(1,tranId);
pstmt.setDate(2,tranDate);
pstmt.setString(3,refSer);
pstmt.setString(4,refId);
pstmt.setString(5,refLine);
pstmt.setString(6,itemCode );
pstmt.setString(7,siteCode);
pstmt.setString(8,locCode);
pstmt.setString(9,lotNo );
pstmt.setString(10,lotSl);
pstmt.setDouble(11,allocQty);
pstmt.setString(12,chgWin);
pstmt.setString(13,chgUser);
pstmt.setString(14,chgTerm);
pstmt.setDate(15,chgDate);
pstmt.executeUpdate();
//added by msalam on 281209 start
pstmt.close();
pstmt = null;
//added by msalam on 281209 end
System.out.println("insertion of sql inside updateInvallocTrace success on date "+ chgDate);
System.out.println("Allocate trace Updated...............................");
sqlUpdate = "UPDATE STOCK SET ALLOC_QTY =(CASE WHEN ALLOC_QTY IS NULL THEN 0 ELSE ALLOC_QTY END) + ? "
+"WHERE ITEM_CODE = '"+itemCode+"' AND SITE_CODE = '"+ siteCode+"' AND LOC_CODE ='"+locCode+"' AND LOT_NO = '"+lotNo+"' AND LOT_SL = '"+lotSl+"'";
pstmt = conn.prepareStatement(sqlUpdate);
pstmt.setDouble(1,allocQty) ;
System.out.println("sqlUpdate "+ sqlUpdate);
int i = pstmt.executeUpdate() ;
pstmt.close();
pstmt = null;
System.out.println("Records updated "+ i);
// if(i>0)
// {
// f.write("sqlUpdate="+ sqlUpdate+"\n"+"Stock update success fully........................."+i+"\n");
// }
// else
// {
// throw new ITMException(new Exception("Unable to update stock for [" + sqlUpdate + "]"));
// }
// }
System.out.println("Updated End.") ;
// f.write("Updated End..........");
}
catch(SQLException e)
{
// f.write("TRANSATION ROLL BACK IN updateInvallocTrace"+"\n");
try{conn.rollback();}catch(Exception ee2){}
//writeException(e, fileDest);
System.out.println("SQLException :updateInvallocTrace : " + sqlUpdate + "\n" +e.getMessage());
System.out.println("ALLOC_QTY : " + allocQty);
System.out.println("ITEM_CODE : " + itemCode);
System.out.println("SITE_CODE : " + siteCode);
System.out.println("LOC_CODE : " + locCode);
System.out.println("LOT_NO : " + lotNo);
System.out.println("LOT_SL : " + lotSl);
errString = e.getMessage();
e.printStackTrace();
//return errString;
throw new ITMException(e);
}
catch(Exception e)
{
//writeException(e, fileDest);
System.out.println("Exception :updateInvallocTrace :" + sqlUpdate + "\n" +e.getMessage());
errString = e.getMessage();
e.printStackTrace();
try
{
// f.write("TRANSATION ROLL BACK IN updateInvallocTrace"+"\n");
try{conn.rollback();}catch(Exception ee2){}
}
catch(Exception e1)
{
// writeException(e, fileDest);
errString = e1.getMessage();
e = e1;
}
//return errString;
throw new ITMException(e);
}
finally
{
try
{
// f.close();
if(conn != null)
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
// conn.close();
// conn = null;
}
}
catch(Exception e)
{
try{
conn.rollback();
//f.write("TRANSATION ROLL BACK IN updateInvallocTrace"+"\n");
}catch(Exception ee2){}
errString = e.getMessage();
e.printStackTrace();
//writeException(e, fileDest);
return errString;
}
//return errString;
}
return errString;
}
private String getCurrdateAppFormat()
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
} }
\ No newline at end of file
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