Commit a5a5cd65 authored by msharma's avatar msharma

Error Handling for Allocation,deallocation,stock transfer


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98498 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6c66ce05
......@@ -1034,6 +1034,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
mainStr =null;
return errString;
}
System.out.println("Printing errString["+errString+"]");
if((errString != null ) && (errString.indexOf("Success") > -1 || errString.indexOf("CONFSUCC") >-1))
{
connOne.commit();
......@@ -1118,7 +1119,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
ResultSet rs = null;
GenericUtility genericUtility = null;
Timestamp currDate = null;
String retString = null;
String retString = "";
String empCode = "";
String xmlString = "";
StringBuffer xmlBuff = null;
......@@ -1198,8 +1199,11 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
if(campNo != null && campNo.trim().length() > 0)
{
campflag1 = true;
sql = "select SUM(QUANTITY) AS quantity ,item_code,ord_date,no_art " +
" from workorder where work_order in ( SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? ) group by item_code, ord_date, no_art ";
/*sql = "select SUM(QUANTITY) AS quantity ,item_code,ord_date,no_art " +
" from workorder where work_order in ( SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? ) group by item_code, ord_date, no_art ";*/
//Changed by Manoj dtd 21/08/2015 group by not required
sql = "select SUM(QUANTITY) AS quantity " +
" from workorder where work_order in ( SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? ) group by item_code, ord_date, no_art ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,campNo);
......@@ -1207,7 +1211,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
if(rs.next())
{
totWoQty = Double.parseDouble(df.format(rs.getDouble("quantity")));
orddate = rs.getDate("ord_date");
//orddate = rs.getDate("ord_date");
//noArt = rs.getString("no_art")==null?"0":rs.getString("no_art");
}
if(rs != null)
......@@ -1325,10 +1329,10 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sdf.format(currDate).toString()+"]]></tran_date>");
if(orddate != null)
/*if(orddate != null)
{
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(orddate).toString() +"]]></ref_date>");
}
}*/
xmlBuff.append("<tran_type><![CDATA["+ tranType +"]]></tran_type>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
......@@ -1417,13 +1421,17 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
" from inv_alloc_det where tran_id IN (SELECT TRAN_ID FROM INV_ALLOCATE "+
" WHERE WORK_ORDER IN (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? AND STATUS = 'R')) "+
" and loc_code in(select loc_code from location where inv_stat = ? ) and site_code = ? and item_code= ? "
+ "and case when deallocated is null then 'N' else deallocated end = 'N' ";
+ "and case when deallocated is null then 'N' else deallocated end = 'N' and lot_no=? and lot_sl=? and loc_code=? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,campNo);
pstmt.setString(2,invstat1);
pstmt.setString(3,siteCode);
pstmt.setString(4,itemCode);
pstmt.setString(5,lotno);
pstmt.setString(6,lotsl);
pstmt.setString(7,locCodeFr);
//pstmt.setString(8,explev);
rs = pstmt.executeQuery();
while(rs.next())
{
......@@ -1448,7 +1456,13 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
System.out.println("Calling DistStkUpdEJB....."+ddlg);
if (distStkUpd.updAllocTrace(hashMap, connOne) > 0)
{
System.out.println("distStkUpd.UpdAllocTrace(HashMap, Connection) : Sucessuful!");
System.out.println("distStkUpd.UpdAllocTrace(HashMap, Connection) : Sucessuful!");
}
else
{
retString="DEALLOCERR";
break;
}
hashMapList.add(hashMap);
System.out.println("1393--Printing hashMap--["+hashMap+"]");
......@@ -1488,6 +1502,11 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
{
System.out.println("distStkUpd.UpdAllocTrace(HashMap, Connection) : Sucessuful!");
}
else
{
retString="DEALLOCERR";
}
hashMapList.add(hashMap);
System.out.println("1426--Printing hashMap--["+hashMap+"]");
hashMap=null;
......@@ -1495,551 +1514,407 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
System.out.println("...............just before savdata() ");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("== site code == @"+siteCode);
if(retString.trim().length()==0)
{
retString = saveData(siteCode,xmlString,connOne);
System.out.println("@@@@@2: retString: @"+retString);
System.out.println("--retString finished--");
if (retString.indexOf("Success") > -1)
{
//connOne.commit(); //comment added by sagar on 28/04/2015
System.out.println("@@@@@@3: retString @ "+retString);
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
System.out.println("-tranIdForIssue-"+tranIdForIssue);
StockTransferConf stconf = new StockTransferConf();
//retString = stconf.confirm(tranIdForIssue,xtraParams,""); //comment added by sagar on 28/04/15
System.out.println(">>>>>>>connStatus:"+connStatus);
retString = stconf.confirm(tranIdForIssue,xtraParams,"",connOne,connStatus);//connOne and connStatus added by sagar on 28/04/15
System.out.println("retString from StockTransferConf :: @:: "+retString);//CONFSUCC
if(retString.indexOf("CONFSUCC") > -1)
{
System.out.println("hashMapList.size()["+hashMapList.size()+"]");
//Changes done by manoj dtd 13/04/2015 to allocates stock from to location
if(hashMapList.size()>0)
{
for(int i=0;i<hashMapList.size();i++)
{
hashMap=(HashMap) hashMapList.get(i);
hashMap.put("alloc_qty", -1*Double.parseDouble( hashMap.get("alloc_qty")+""));
hashMap.put("loc_code", locCodeTo);
System.out.println("1456--Printing hashMap--["+hashMap+"]");
if (distStkUpd.updAllocTrace(hashMap, connOne) > 0)
//connOne.commit(); //comment added by sagar on 28/04/2015
System.out.println("@@@@@@3: retString @ "+retString);
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
System.out.println("-tranIdForIssue-"+tranIdForIssue);
StockTransferConf stconf = new StockTransferConf();
//retString = stconf.confirm(tranIdForIssue,xtraParams,""); //comment added by sagar on 28/04/15
System.out.println(">>>>>>>connStatus:"+connStatus);
retString = stconf.confirm(tranIdForIssue,xtraParams,"",connOne,connStatus);//connOne and connStatus added by sagar on 28/04/15
System.out.println("retString from StockTransferConf :: @:: "+retString);//CONFSUCC
if(retString.indexOf("CONFSUCC") > -1)
{
System.out.println("Allocation from loccode to is Sucessuful!");
// commented by cpatil for supreme on 16/04/15 for multiple issue
/*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 = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,hashMap.get("ref_id")+"");
pstmt.setString(3,hashMap.get("item_code")+"");
pstmt.setString(4,hashMap.get("lot_no")+"");
pstmt.setString(5,hashMap.get("lot_sl")+"");
pstmt.setString(6,locCodeFr);
pstmt.setString(7,hashMap.get("site_code")+"");
pstmt.executeUpdate();
pstmt.close();
pstmt=null;*/
}
}
// code for by cpatil for supreme on 16/04/15 for multiple issue start
// Changed by Manoj dtd 06/07/2015 Remove Campaign no. condition and make common for all cases
System.out.println("Remove Campaign no. condition and make common for all cases");
System.out.println("@@@cpatil::campNo["+campNo+"]tranId["+tranId+"]lineno["+lineno+"]siteCode["+siteCode+"]itemCode["+itemCode+"]lotno["+lotno+"]lotsl["+lotsl+"]allocQty["+allocQty+"]reasCode["+reasCode+"]locCodeFr["+locCodeFr+"]explev["+explev+"]locCodeTo["+locCodeTo+"]worder["+worder+"]tranIdInvAlloc["+tranIdInvAlloc+"]actualPropQty["+actualPropQty+"]actualQty["+actualQty+"]batchQuantity["+batchQuantity+"]");
for(int i=0;i<hashMapList.size();i++)
{
hashMap=(HashMap) hashMapList.get(i);
tranId=(String) hashMap.get("ref_id");
siteCode=(String) hashMap.get("site_code");
itemCode=(String) hashMap.get("item_code");
lotno=(String) hashMap.get("lot_no");
lotsl=(String) hashMap.get("lot_sl");
locCodeFr=(String) hashMap.get("loc_code__fr");
explev=(String) hashMap.get("exp_lev");
actualPropQty=Double.parseDouble(""+hashMap.get("alloc_qty"));//Changed by Manoj dtd 20/08/15 Set value from map instead of dom value
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 = ? and exp_lev=? and case when deallocated is null then 'N' else deallocated end <> 'Y' ";
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);
pstmt.setString(7,explev);
rs = pstmt.executeQuery();
if ( rs.next() )
{
count = rs.getInt(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
String deAllocated="N";
System.out.println("batchQuantity["+batchQuantity+"]totWoQty["+totWoQty+"]["+campflag1+"]");
if( (batchQuantity == totWoQty) || campflag1)
{
deAllocated="Y";
}
if(count == 0)
System.out.println("hashMapList.size()["+hashMapList.size()+"]");
//Changes done by manoj dtd 13/04/2015 to allocates stock from to location
if(hashMapList.size()>0)
{
if( (batchQuantity == totWoQty) || campflag1)
for(int i=0;i<hashMapList.size();i++)
{
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 = ? and exp_lev=? and case when deallocated is null then 'N' else deallocated end <> 'Y'";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
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.setString(8,explev);
pstmt.executeUpdate();
if(pstmt != null)
hashMap=(HashMap) hashMapList.get(i);
hashMap.put("alloc_qty", -1*Double.parseDouble( hashMap.get("alloc_qty")+""));
hashMap.put("loc_code", locCodeTo);
System.out.println("1456--Printing hashMap--["+hashMap+"]");
if (distStkUpd.updAllocTrace(hashMap, connOne) > 0)
{
System.out.println("Allocation from loccode to is Sucessuful!");
// commented by cpatil for supreme on 16/04/15 for multiple issue
/*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 = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,hashMap.get("ref_id")+"");
pstmt.setString(3,hashMap.get("item_code")+"");
pstmt.setString(4,hashMap.get("lot_no")+"");
pstmt.setString(5,hashMap.get("lot_sl")+"");
pstmt.setString(6,locCodeFr);
pstmt.setString(7,hashMap.get("site_code")+"");
pstmt.executeUpdate();
pstmt.close();
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.setString(1,tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
pstmt=null;*/
}
else
{
maxlineNo = rs.getInt(1);
retString="ALLOCERR";
}
System.out.println("maxlineNo::"+maxlineNo);
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
sql="update inv_alloc_det set quantity=quantity-?,alloc_qty=alloc_qty-?,DEALLOC_QTY=DEALLOC_QTY+? "
+ "where tran_id=? and site_code=? and item_code=? and lot_no=? and lot_sl=? and loc_code=?"
+ " AND EXP_LEV=? and case when deallocated is null then 'N' else deallocated end <> 'Y'"; // VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,actualPropQty);
pstmt.setDouble(2,actualPropQty);
pstmt.setDouble(3,actualPropQty);
pstmt.setString(4,tranId);
pstmt.setString(5,siteCode);
pstmt.setString(6,itemCode);
pstmt.setString(7,lotno);
pstmt.setString(8,lotsl);
pstmt.setString(9,locCodeFr);
pstmt.setString(10,explev);// VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
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,ALLOC_QTY)" +
" values (?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setInt(2,maxlineNo+1);
pstmt.setString(3,siteCode);
pstmt.setString(4,itemCode);
pstmt.setString(5,lotno);
pstmt.setString(6,lotsl);
pstmt.setDouble(7,actualPropQty);
pstmt.setString(8,remarks);
pstmt.setString(9,reasCode);
pstmt.setString(10,locCodeTo);
pstmt.setString(11,explev);
pstmt.setDouble(12,actualPropQty);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
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);
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;*/
}
}
else
{
// comment and modify below by cpatil on 16/04/15
/*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;*/
sql = " update inv_alloc_det set quantity = quantity-? ,alloc_qty=alloc_qty-? , " +
" DEALLOC_QTY = DEALLOC_QTY+? " +
" where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? "
+ "AND EXP_LEV=? and case when deallocated is null then 'N' else deallocated end <> 'Y'";//VALLABH KADAM add [EXP_LEV] 21/MAY/15
System.out.println(" SQL::update"+sql);
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,actualPropQty);
pstmt.setDouble(2,actualPropQty);
pstmt.setDouble(3,actualPropQty);
pstmt.setString(4,tranId);
pstmt.setString(5,itemCode);
pstmt.setString(6,lotno);
pstmt.setString(7,lotsl);
pstmt.setString(8,locCodeFr);
pstmt.setString(9,siteCode);
pstmt.setString(10,explev);// VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
sql = " update inv_alloc_det set quantity = quantity+? , alloc_qty = alloc_qty+? " +
" where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? "
+ "AND EXP_LEV=? and case when deallocated is null then 'N' else deallocated end <> 'Y'";//VALLABH KADAM add [EXP_LEV] 21/MAY/15
// code for by cpatil for supreme on 16/04/15 for multiple issue start
// Changed by Manoj dtd 06/07/2015 Remove Campaign no. condition and make common for all cases
System.out.println("Remove Campaign no. condition and make common for all cases");
System.out.println("@@@cpatil::campNo["+campNo+"]tranId["+tranId+"]lineno["+lineno+"]siteCode["+siteCode+"]itemCode["+itemCode+"]lotno["+lotno+"]lotsl["+lotsl+"]allocQty["+allocQty+"]reasCode["+reasCode+"]locCodeFr["+locCodeFr+"]explev["+explev+"]locCodeTo["+locCodeTo+"]worder["+worder+"]tranIdInvAlloc["+tranIdInvAlloc+"]actualPropQty["+actualPropQty+"]actualQty["+actualQty+"]batchQuantity["+batchQuantity+"]");
for(int i=0;i<hashMapList.size();i++)
{
hashMap=(HashMap) hashMapList.get(i);
tranId=(String) hashMap.get("ref_id");
siteCode=(String) hashMap.get("site_code");
itemCode=(String) hashMap.get("item_code");
lotno=(String) hashMap.get("lot_no");
lotsl=(String) hashMap.get("lot_sl");
locCodeFr=(String) hashMap.get("loc_code__fr");
explev=(String) hashMap.get("exp_lev");
actualPropQty=Double.parseDouble(""+hashMap.get("alloc_qty"));//Changed by Manoj dtd 20/08/15 Set value from map instead of dom value
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 = ? and exp_lev=? and case when deallocated is null then 'N' else deallocated end <> 'Y' ";
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,(actualPropQty));
pstmt.setDouble(2,(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.setString(9,explev);// VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt.executeUpdate();
pstmt.setString(1,tranId);
pstmt.setString(2,itemCode);
pstmt.setString(3,lotno);
pstmt.setString(4,lotsl);
pstmt.setString(5,locCodeTo);
pstmt.setString(6,siteCode);
pstmt.setString(7,explev);
rs = pstmt.executeQuery();
if ( rs.next() )
{
count = rs.getInt(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
}
}
// code for by cpatil for supreme on 16/04/15 for multiple issue end
}
}
/*if(retString.indexOf("CONFSUCC") > -1)
{
stockMap.put("item_code", itemCode);
stockMap.put("site_code", siteCode);
stockMap.put("loc_code", locCodeFr);
stockMap.put("lot_no", lotno);
stockMap.put("lot_sl", lotsl);
double quantity = 0.0;
if(allocQty != null)
{
quantity = Double.parseDouble(allocQty);
}
stockMap.put("quantity", ""+quantity);
sql = "SELECT INV_STAT FROM LOCATION WHERE LOC_CODE = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
invStatLocCodeTo = checkNull(rs.getString("INV_STAT"));
}
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");
String deAllocated="N";
System.out.println("batchQuantity["+batchQuantity+"]totWoQty["+totWoQty+"]["+campflag1+"]");
if( (batchQuantity == totWoQty) || campflag1)
{
deAllocated="Y";
}
if(count == 0)
{
if(campflag1)
{
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 = ? and exp_lev=? and case when deallocated is null then 'N' else deallocated end <> 'Y'";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
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.setString(8,explev);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
}
else if((batchQuantity == totWoQty))
{
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 = ? and exp_lev=? and case when deallocated is null then 'N' else deallocated end <> 'Y'";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
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.setString(8,explev);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
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.setString(1,tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
{
maxlineNo = rs.getInt(1);
}
System.out.println("maxlineNo::"+maxlineNo);
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
sql="update inv_alloc_det set quantity=quantity-?,alloc_qty=alloc_qty-?,DEALLOC_QTY=DEALLOC_QTY+? "
+ "where tran_id=? and site_code=? and item_code=? and lot_no=? and lot_sl=? and loc_code=?"
+ " AND EXP_LEV=? and case when deallocated is null then 'N' else deallocated end <> 'Y'"; // VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,actualPropQty);
pstmt.setDouble(2,actualPropQty);
pstmt.setDouble(3,actualPropQty);
pstmt.setString(4,tranId);
pstmt.setString(5,siteCode);
pstmt.setString(6,itemCode);
pstmt.setString(7,lotno);
pstmt.setString(8,lotsl);
pstmt.setString(9,locCodeFr);
pstmt.setString(10,explev);// VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
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,ALLOC_QTY)" +
" values (?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setInt(2,maxlineNo+1);
pstmt.setString(3,siteCode);
pstmt.setString(4,itemCode);
pstmt.setString(5,lotno);
pstmt.setString(6,lotsl);
pstmt.setDouble(7,actualPropQty);
pstmt.setString(8,remarks);
pstmt.setString(9,reasCode);
pstmt.setString(10,locCodeTo);
pstmt.setString(11,explev);
pstmt.setDouble(12,actualPropQty);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
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);
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;*/
}
}
else
{
// comment and modify below by cpatil on 16/04/15
/*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;*/
sql = " update inv_alloc_det set quantity = quantity-? ,alloc_qty=alloc_qty-? , " +
" DEALLOC_QTY = DEALLOC_QTY+? " +
" where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? "
+ "AND EXP_LEV=? and case when deallocated is null then 'N' else deallocated end <> 'Y'";//VALLABH KADAM add [EXP_LEV] 21/MAY/15
System.out.println(" SQL::update"+sql);
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,actualPropQty);
pstmt.setDouble(2,actualPropQty);
pstmt.setDouble(3,actualPropQty);
pstmt.setString(4,tranId);
pstmt.setString(5,itemCode);
pstmt.setString(6,lotno);
pstmt.setString(7,lotsl);
pstmt.setString(8,locCodeFr);
pstmt.setString(9,siteCode);
pstmt.setString(10,explev);// VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
sql = " update inv_alloc_det set quantity = quantity+? , alloc_qty = alloc_qty+? " +
" where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? "
+ "AND EXP_LEV=? and case when deallocated is null then 'N' else deallocated end <> 'Y'";//VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt = connOne.prepareStatement(sql);
pstmt.setDouble(1,(actualPropQty));
pstmt.setDouble(2,(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.setString(9,explev);// VALLABH KADAM add [EXP_LEV] 21/MAY/15
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
}
}
// code for by cpatil for supreme on 16/04/15 for multiple issue end
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)
{
retString = "CONFSUCC";
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)
// {
boolean campFlag= false;
if(campNo != null && campNo.trim().length() > 0)
{
campFlag = true;
sql = " update inv_alloc_det set loc_code = ? where tran_id in ( SELECT TRAN_ID FROM INV_ALLOCATE WHERE WORK_ORDER IN (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? )) and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,campNo);
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;
}
}
else if(campFlag == false)
else
{
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.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() )
{
count = rs.getInt(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
if(count == 0)
{
retString="STKTRFCONFERR";
}
/*if(retString.indexOf("CONFSUCC") > -1)
{
if( batchQuantity == totWoQty)
{
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 = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
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;
}else
stockMap.put("item_code", itemCode);
stockMap.put("site_code", siteCode);
stockMap.put("loc_code", locCodeFr);
stockMap.put("lot_no", lotno);
stockMap.put("lot_sl", lotsl);
double quantity = 0.0;
if(allocQty != null)
{
int maxlineNo = 0;
sql = " select max(line_no) as max_line_no from inv_alloc_det where tran_id = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
{
maxlineNo = rs.getInt(1);
}
System.out.println("maxlineNo::"+maxlineNo);
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
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 (?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setInt(2,maxlineNo+1);
pstmt.setString(3,siteCode);
pstmt.setString(4,itemCode);
pstmt.setString(5,lotno);
pstmt.setString(6,lotsl);
pstmt.setDouble(7,actualPropQty);
pstmt.setString(8,remarks);
pstmt.setString(9,reasCode);
pstmt.setString(10,locCodeTo);
pstmt.setString(11,explev);
pstmt.setDouble(12,actualPropQty);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
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);
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;
quantity = Double.parseDouble(allocQty);
}
}
else
{
stockMap.put("quantity", ""+quantity);
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);
sql = "SELECT INV_STAT FROM LOCATION WHERE LOC_CODE = ? ";
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();
pstmt.setString(1,locCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
invStatLocCodeTo = checkNull(rs.getString("INV_STAT"));
}
if(rs != null)
rs.close();
rs = null;
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 = ? ";
// //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,tranId);
pstmt.setString(2,itemCode);
pstmt.setString(3,lotno);
pstmt.setString(4,lotsl);
pstmt.setString(5,locCodeTo);
pstmt.setString(6,siteCode);
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() )
{
lcToqty = rs.getDouble(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)
rs.close();
......@@ -2047,27 +1922,205 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
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;
}
// }
}
}
}*/
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)
{
retString = "CONFSUCC";
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)
// {
boolean campFlag= false;
if(campNo != null && campNo.trim().length() > 0)
{
campFlag = true;
sql = " update inv_alloc_det set loc_code = ? where tran_id in ( SELECT TRAN_ID FROM INV_ALLOCATE WHERE WORK_ORDER IN (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? )) and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,campNo);
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;
}
else if(campFlag == false)
{
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.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() )
{
count = rs.getInt(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
if(count == 0)
{
if( batchQuantity == totWoQty)
{
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 = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
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;
}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.setString(1,tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
{
maxlineNo = rs.getInt(1);
}
System.out.println("maxlineNo::"+maxlineNo);
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
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 (?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setInt(2,maxlineNo+1);
pstmt.setString(3,siteCode);
pstmt.setString(4,itemCode);
pstmt.setString(5,lotno);
pstmt.setString(6,lotsl);
pstmt.setDouble(7,actualPropQty);
pstmt.setString(8,remarks);
pstmt.setString(9,reasCode);
pstmt.setString(10,locCodeTo);
pstmt.setString(11,explev);
pstmt.setDouble(12,actualPropQty);
pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
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);
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;
}
}
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;
}
// }
}
}
}*/
}
else
{
retString="STKTRFERR";
}
}
......
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