Commit fc8e78b9 authored by rtiwari's avatar rtiwari

UPDATED


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95215 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d4338a6e
......@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;
......@@ -104,7 +105,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
String sql= "",worder="",locCodeTo="",batchQuantity="",campNo="";
String resultString = "",errCode="";
String invstat="",invstat1="",tranIdInvAlloc="";
int cnt=0,lineno=1;
int cnt=0,lineno=1,conutNo=0;
Connection conn = null;
ResultSet rs = null,rs1= null;
double issQty=0.0,allocQty=0,allocatedQty=0.0,integralQty=0.0,potencyadj=0.0;
......@@ -296,9 +297,9 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
}
if(campNo != null && campNo.trim().length() > 0)
{
sql = " select tran_id,item_code,lot_no,lot_sl,loc_code,sum(quantity) as quantity "
+" from inv_alloc_det GROUP BY tran_id, item_code, lot_no, lot_sl, loc_code having 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 = ? ) ORDER BY TRAN_ID";
sql = " select item_code,lot_no,lot_sl,loc_code,sum(quantity) as quantity "
+" 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 = ? ) GROUP BY item_code, lot_no, lot_sl, loc_code ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,campNo);
......@@ -309,16 +310,38 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
{
do
{
conutNo ++;
issQty = rs.getDouble("quantity");
if(campNo != null && campNo.trim().length() > 0)
// if(campNo != null && campNo.trim().length() > 0)
// {
// sql = " SELECT WORK_ORDER FROM INV_ALLOCATE WHERE TRAN_ID = ? ";
// pstmt1 = conn.prepareStatement(sql);
// pstmt1.setString(1, rs.getString("tran_id"));
// rs1 = pstmt1.executeQuery();
// if ( rs1.next() )
// {
// worder = rs1.getString(1);
// }
// if(rs1 != null)
// rs1.close();
// rs1 = null;
// if(pstmt1 != null)
// pstmt1.close();
// pstmt1 = null;
// }
if(worder != null && worder.trim().length() > 0)
{
sql = " SELECT WORK_ORDER FROM INV_ALLOCATE WHERE TRAN_ID = ? ";
sql = "select SUM(quantity) from stock_transfer_det where tran_id in (select tran_id from stock_transfer " +
" where ref_id__for = ?) and item_code = ? and lot_no__fr = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, rs.getString("tran_id"));
pstmt1.setString(1, worder);
pstmt1.setString(2, rs.getString("item_code"));
pstmt1.setString(3, rs.getString("lot_no"));
rs1 = pstmt1.executeQuery();
if ( rs1.next() )
{
worder = rs1.getString(1);
allocatedQty = rs1.getDouble(1);
}
if(rs1 != null)
rs1.close();
......@@ -327,48 +350,81 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
pstmt1.close();
pstmt1 = null;
}
sql = "select SUM(quantity) from stock_transfer_det where tran_id in (select tran_id from stock_transfer " +
" where ref_id__for = ?) and item_code = ? and lot_no__fr = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, worder);
pstmt1.setString(2, rs.getString("item_code"));
pstmt1.setString(3, rs.getString("lot_no"));
rs1 = pstmt1.executeQuery();
if ( rs1.next() )
if(campNo != null && campNo.trim().length() > 0)
{
allocatedQty = rs1.getDouble(1);
sql = "select SUM(quantity) from stock_transfer_det where tran_id in (select tran_id from stock_transfer " +
" where ref_id__for in ( select work_order from workorder where CAMPGN_NO = ?)) and item_code = ? and lot_no__fr = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, campNo);
pstmt1.setString(2, rs.getString("item_code"));
pstmt1.setString(3, rs.getString("lot_no"));
rs1 = pstmt1.executeQuery();
if ( rs1.next() )
{
allocatedQty = rs1.getDouble(1);
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
sql = " select site_code,remarks,reas_code,potency_adj,line_no,exp_lev " +
" from inv_alloc_det where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, rs.getString("tran_id"));
pstmt1.setString(2, rs.getString("item_code"));
pstmt1.setString(3, rs.getString("lot_no"));
pstmt1.setString(4, rs.getString("lot_sl"));
pstmt1.setString(5, rs.getString("loc_code"));
rs1 = pstmt1.executeQuery();
if(rs1.next())
if(worder != null && worder.trim().length() > 0)
{
siteCode = rs1.getString("site_code");
remarks = rs1.getString("remarks");
reasCode = rs1.getString("reas_code");
potencyadj = rs1.getDouble("potency_adj");
lineno = rs1.getInt("line_no");
explev = rs1.getString("exp_lev");
sql = " select site_code,remarks,reas_code,potency_adj,line_no,exp_lev " +
" from inv_alloc_det where tran_id = ? and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, rs.getString("tran_id"));
pstmt1.setString(2, rs.getString("item_code"));
pstmt1.setString(3, rs.getString("lot_no"));
pstmt1.setString(4, rs.getString("lot_sl"));
pstmt1.setString(5, rs.getString("loc_code"));
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
siteCode = rs1.getString("site_code");
remarks = rs1.getString("remarks");
reasCode = rs1.getString("reas_code");
potencyadj = rs1.getDouble("potency_adj");
lineno = rs1.getInt("line_no");
explev = rs1.getString("exp_lev");
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
if(campNo != null && campNo.trim().length() > 0)
{
sql = " select site_code,remarks,reas_code,potency_adj,line_no,exp_lev " +
" 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 item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, campNo);
pstmt1.setString(2, rs.getString("item_code"));
pstmt1.setString(3, rs.getString("lot_no"));
pstmt1.setString(4, rs.getString("lot_sl"));
pstmt1.setString(5, rs.getString("loc_code"));
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
siteCode = rs1.getString("site_code");
remarks = rs1.getString("remarks");
reasCode = rs1.getString("reas_code");
potencyadj = rs1.getDouble("potency_adj");
lineno = rs1.getInt("line_no");
explev = rs1.getString("exp_lev");
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
}
if(quantity > 0)
{
......@@ -388,10 +444,18 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
//{
retTabSepStrBuff.append("<Detail2>");
retTabSepStrBuff.append("<tran_id>").append("<![CDATA[" + rs.getString("tran_id") +"]]>").append("</tran_id>");
retTabSepStrBuff.append("<line_no>").append("<![CDATA[" + lineno +"]]>").append("</line_no>");
if(worder != null && worder.trim().length() > 0)
{
retTabSepStrBuff.append("<tran_id>").append("<![CDATA[" + rs.getString("tran_id") +"]]>").append("</tran_id>");
retTabSepStrBuff.append("<line_no>").append("<![CDATA[" + lineno +"]]>").append("</line_no>");
}
if(campNo != null && campNo.trim().length() > 0)
{
retTabSepStrBuff.append("<tran_id>").append("<![CDATA[]]>").append("</tran_id>");
retTabSepStrBuff.append("<line_no>").append("<![CDATA[" + conutNo +"]]>").append("</line_no>");
}
retTabSepStrBuff.append("<site_code>").append("<![CDATA[" + siteCode +"]]>").append("</site_code>");
retTabSepStrBuff.append("<item_code>").append("<![CDATA[" + rs.getString("item_code") +"]]>").append("</item_code>");
......@@ -451,9 +515,13 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
retTabSepStrBuff.append("<potency_adj>").append("<![CDATA[" + potencyadj +"]]>").append("</potency_adj>");
retTabSepStrBuff.append("<loc_code__to>").append("<![CDATA[" +locCodeTo +"]]>").append("</loc_code__to>");
retTabSepStrBuff.append("<work_order>").append("<![CDATA[" + worder +"]]>").append("</work_order>");
if(worder != null && worder.trim().length() > 0)
{
retTabSepStrBuff.append("<work_order>").append("<![CDATA[" + worder +"]]>").append("</work_order>");
}else
{
retTabSepStrBuff.append("<work_order>").append("<![CDATA[]]>").append("</work_order>");
}
retTabSepStrBuff.append("</Detail2>");
//}
......@@ -604,6 +672,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
System.out.println(" batchQuantity ::"+batchQuantity);
String campNo = checkNull(genericUtility.getColumnValue("campgn_no", headerDom));
System.out.println( "campgn no @@@["+ campNo+"]");
HashMap map = new HashMap();
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
......@@ -822,9 +891,9 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
// if((Double.parseDouble(df.format(actualQty - trfedQty)) >= Double.parseDouble(df.format(allocQty2))) || (Double.parseDouble(df.format((allocQty2 + trfedQty)-issueQtyDet)) <= integralQty))
if(campNo != null && campNo.trim().length() > 0)
{
sql = "select quantity from workorder where work_order = ? ";
sql = "select sum(quantity) from workorder where work_order in (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? ) ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,worder);
pstmt.setString(1,campNo);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -842,7 +911,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
if((Double.parseDouble(df.format(actualQty - trfedQty)) >= Double.parseDouble(df.format(allocQty2))) || (Double.parseDouble(df.format(allocQty2 - actualPropQty)) <= integralQty))
{
errString = allocStockToWo(tranId,lineno,siteCode,itemCode,lotno,lotsl,allocQty,reasCode,locCodeFr,explev,locCodeTo,worder,remarks,tranId,actualPropQty,actualQty,batchQuantity,xtraParams,connOne);
errString = allocStockToWo(campNo,tranId,lineno,siteCode,itemCode,lotno,lotsl,allocQty,reasCode,locCodeFr,explev,locCodeTo,worder,remarks,tranId,actualPropQty,actualQty,batchQuantity,xtraParams,connOne);
System.out.println("err String from STOCKTRANS ="+errString);
}
}
......@@ -955,7 +1024,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
}
return errString;
}
private String allocStockToWo(String tranId,String lineno,String siteCode,String itemCode,String lotno,String lotsl,String allocQty,String reasCode,String locCodeFr,String explev,String locCodeTo,String worder,String remarks,String tranIdInvAlloc,double actualPropQty,double actualQty,double batchQuantity,String xtraParams,Connection connOne) throws RemoteException, ITMException
private String allocStockToWo(String campNo,String tranId,String lineno,String siteCode,String itemCode,String lotno,String lotsl,String allocQty,String reasCode,String locCodeFr,String explev,String locCodeTo,String worder,String remarks,String tranIdInvAlloc,double actualPropQty,double actualQty,double batchQuantity,String xtraParams,Connection connOne) throws RemoteException, ITMException
{
String userId = "";
String termId = "";
......@@ -1002,7 +1071,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
double holdQty = 0;
double potencyPerc=0,grossWeight=0,tareWeight=0,netWeight=0;
DecimalFormat df = new DecimalFormat("0.000");
boolean campflag1 = false;
try
{
......@@ -1032,26 +1101,49 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
if(pstmt != null)
pstmt.close();
pstmt = null;
sql = "select quantity,item_code,site_code,bom_code,lot_no,lot_sl,ref_no,ord_date,no_art " +
" from workorder where work_order = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,worder);
rs = pstmt.executeQuery();
if(rs.next())
if(campNo != null && campNo.trim().length() > 0)
{
totWoQty = Double.parseDouble(df.format(rs.getDouble("quantity")));
orddate = rs.getDate("ord_date");
noArt = rs.getString("no_art")==null?"0":rs.getString("no_art");
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 ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,campNo);
rs = pstmt.executeQuery();
if(rs.next())
{
totWoQty = Double.parseDouble(df.format(rs.getDouble("quantity")));
orddate = rs.getDate("ord_date");
noArt = rs.getString("no_art")==null?"0":rs.getString("no_art");
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
}
else if(campflag1 == false && (worder !=null && worder.trim().length() > 0))
{
sql = "select quantity,item_code,site_code,bom_code,lot_no,lot_sl,ref_no,ord_date,no_art " +
" from workorder where work_order = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,worder);
rs = pstmt.executeQuery();
if(rs.next())
{
totWoQty = Double.parseDouble(df.format(rs.getDouble("quantity")));
orddate = rs.getDate("ord_date");
noArt = rs.getString("no_art")==null?"0":rs.getString("no_art");
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
sql = "select item_ser from item where item_code = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,itemCode);
......@@ -1114,9 +1206,10 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sdf.format(currDate).toString()+"]]></tran_date>");
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(orddate).toString() +"]]></ref_date>");
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>");
......@@ -1124,9 +1217,13 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
xmlBuff.append("<item_ser><![CDATA[" + itemSer +"]]></item_ser>");
xmlBuff.append("<emp_code__aprv><![CDATA["+ empCode +"]]></emp_code__aprv>");
xmlBuff.append("<ref_id__for><![CDATA[" + worder +"]]></ref_id__for>");
if(worder == null || worder.trim().length() == 0)
{
xmlBuff.append("<ref_id__for><![CDATA[]]></ref_id__for>");
}else
{
xmlBuff.append("<ref_id__for><![CDATA["+worder+"]]></ref_id__for>");
}
xmlBuff.append("<REF_SER__FOR><![CDATA[" + "w_ord" +"]]></REF_SER__FOR>");
xmlBuff.append("<reas_code><![CDATA[" + reasCode+" ]]></reas_code>");
......@@ -1345,6 +1442,27 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
// 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);
......@@ -1368,7 +1486,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
if(count == 0)
{
if( batchQuantity == totWoQty )
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);
......@@ -1492,6 +1610,8 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
}
// }
}
}
}
}
......
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