Commit 2bd4629c authored by cpatil's avatar cpatil

add quantity condition n handle exception


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93502 ce508802-f39f-4f6c-b175-0d175dae99d5
parent afb06dd5
......@@ -128,7 +128,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
String siteCode="",itemSer="";
String retStr = "";
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
Object date1 = null;
Timestamp currDate1 =new java.sql.Timestamp(System.currentTimeMillis()) ;
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-mm-dd");
......@@ -142,7 +142,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
String stockSql ="",insertQuery="",stock_lot_no="",stock_loc_code="",stock_lot_sl="";
String calcPotency="";
double rate=0,minPotencyPerc=0,quantity=0,potencyAdj=0,grossRate=0,ctrdet=0;
int lineNo =0,count=0,insrtCtr=0,upd=0,noArt=0,operation=0,counter=0;
int lineNo =0,count=0,insrtCtr=0,upd=0,noArt=0,operation=0,counter=0,batchLoadCnt=0;
double extraQty=0,issQty=0,StockPotencyPerc=0,itemstdpotency=0;
boolean issForBatch =false;
......@@ -183,7 +183,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
diffReplaceQty = new HashMap();
double qtyPerArt=0;
int totalPacket=0;
// for workOrder
if( workOrder != null && workOrder.trim().length() > 0 )
{
......@@ -204,7 +204,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
retStr =itmDBAccessEJB.getErrorString("","VTWORD1","","",conn);
return retStr;
}
sql = " select count(1) from workorder where work_order = ? and status = 'F' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
......@@ -222,8 +222,8 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
retStr =itmDBAccessEJB.getErrorString("","VTWORDER4","","",conn);
return retStr;
}
sql = " select count(1) from workorder_iss i, workorder_issdet d where i.tran_id=d.tran_id " +
" and i.work_order = ? and i.operation = ? " +
" and i.confirmed = 'Y' and i.tran_type != 'R' ";
......@@ -302,8 +302,8 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
retStr =itmDBAccessEJB.getErrorString("","VMOPERINV","","",conn);
return retStr;
}
}
// sql for getdata
......@@ -619,7 +619,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
//pstmt1.setString(5,itemCode);
//pstmt1.setString(6,siteCode);
//pstmt1.setString(7,lotNo);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
......@@ -645,8 +645,8 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
rs.close();
pstmt.close();
System.out.println("@@@@@ issCriteria["+issCriteria+"]");
/*
/*
sql ="select a.bom_code, b.item_code__ref,a.loc_group,a.lot_no__issue "
+" from workorder a, workorder_bill b where a.work_order = b.work_order "
+" and a.work_order = ? "
......@@ -712,7 +712,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
rs =null;
pstmt.close();
pstmt =null;
sql = "select supp_code__mfg from stock where item_code = ? and site_code = ? "
+" and loc_code = ? and lot_no= ? and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
......@@ -733,7 +733,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
issForBatch =true;
}
System.out.println("@@@@ supp_code__mfg......................"+ supp_code__mfg);
*/
*/
stockSql ="select a.lot_no, a.loc_code, a.lot_sl, a.rate, a.gross_rate,a.supp_code__mfg "
+" ,(a.quantity-a.alloc_qty) as stockBalQty "
+" from stock a, invstat b, item c "
......@@ -796,7 +796,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
stockSql = stockSql +" and a.retest_date > ? " ;
//on 31/07/13
stockSql = stockSql +" and ( select count(1) from qc_order where item_code =a.item_code and site_code= a.site_code and lot_no = a.lot_no and status = 'U')=0 " ;
stockSql = stockSql +" and ( a.quantity - a.alloc_qty ) > 0 ";
System.out.println("\n\n\n Query Executed " + stockSql+ "\n\n******************");
pstmt = conn.prepareStatement(stockSql);
pstmt.setTimestamp(1,currDate1);
......@@ -804,7 +804,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
//pstmt.setString(3,itemCode);
//pstmt.setString(4,siteCode);
//pstmt.setString(5,lotNo);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -840,11 +840,11 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
if("Y".equalsIgnoreCase(matchPotency))
{
sql ="select (case when potency_perc is null then 0 else potency_perc end) "
+" from stock where item_code = ? "
+" and site_code = ? "
+" and loc_code = ? "
+" and lot_no = ? "
+" and lot_sl = ? ";
+" from stock where item_code = ? "
+" and site_code = ? "
+" and loc_code = ? "
+" and lot_no = ? "
+" and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
......@@ -865,12 +865,12 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
extraQty = (quantity / StockPotencyPerc * itemstdpotency ) - quantity;
issQty = quantity;
System.out.println("@@@@@@ test extraQty["+extraQty+"]quantity["+quantity+"]issQty["+issQty+"]");
// added by cpatil on 31/07/13 for criteria type is F
if(issCriteria != null && issCriteria.equalsIgnoreCase("F"))
{
sql =" select qty_per_art from stock where item_code = ? and site_code = ? " +
" and loc_code = ? and lot_no = ? and lot_sl = ? ";
" and loc_code = ? and lot_no = ? and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
......@@ -884,7 +884,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
}
rs.close();
pstmt.close();
if( (reqQty % qtyPerArt) > 0 )
{
System.out.println("@@@@@@@reqQty11:["+reqQty+"]");
......@@ -894,13 +894,14 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
}
}
//end
}
if ( stockBalQty > 0 )
{
// insert into workorder_issdet
lnNo++;
batchLoadCnt++;
sql ="insert into workorder_issdet (tran_id,line_no,exp_lev,item_code,loc_code,lot_no," +
" lot_sl,quantity,unit,rate,gross_rate,calc_potency, potency_adj," +
" match_potency,min_potency_perc,adj_potency,work_order)" +
......@@ -930,13 +931,16 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
}
}
pstmt.executeBatch();
pstmt.clearBatch();
System.out.println("Record inserted into detail");
if( pstmt != null )
if( batchLoadCnt > 0)
{
pstmt.close();
pstmt = null;
pstmt.executeBatch();
pstmt.clearBatch();
System.out.println("Record inserted into detail");
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
}
else
......
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