Commit 78774c58 authored by cpatil's avatar cpatil

modify for stock allocation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93511 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f8ae4d70
...@@ -17,6 +17,7 @@ import java.text.NumberFormat; ...@@ -17,6 +17,7 @@ import java.text.NumberFormat;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistStkUpdLocal;
import ibase.webitm.ejb.fin.*; import ibase.webitm.ejb.fin.*;
import ibase.webitm.utility.*; import ibase.webitm.utility.*;
import ibase.system.config.*; import ibase.system.config.*;
...@@ -155,9 +156,11 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt ...@@ -155,9 +156,11 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
HashMap diffReplaceQty = null; HashMap diffReplaceQty = null;
//TreeSet expLevSet = null; //TreeSet expLevSet = null;
ArrayList <String>listExpLev=new ArrayList<String>(); ArrayList <String>listExpLev=new ArrayList<String>();
String supp_code__mfgSep =""; String supp_code__mfgSep ="", lotNoIssueTemp = "", operationStr="",tranSer="";
String lotNoList[]; String lotNoList[];
String lotNoIssueTemp = "", operationStr="";
HashMap hashMap = new HashMap();
try try
{ {
if(conn==null) if(conn==null)
...@@ -176,7 +179,16 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt ...@@ -176,7 +179,16 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
operationStr = genericUtility.getColumnValue("operation",headerDom); operationStr = genericUtility.getColumnValue("operation",headerDom);
if( operationStr!= null && operationStr.trim().length() > 0 ) if( operationStr!= null && operationStr.trim().length() > 0 )
{ {
for (char c : operationStr.toCharArray())
{
if (!Character.isDigit(c))
{
retStr =itmDBAccessEJB.getErrorString("","VMOPERINV","","",conn);
return retStr;
}
}
operation = Integer.parseInt(operationStr); operation = Integer.parseInt(operationStr);
} }
deptCode = genericUtility.getColumnValue("dept_code",headerDom); deptCode = genericUtility.getColumnValue("dept_code",headerDom);
System.out.println("@@@@@ data---->workOrder["+workOrder+"]::operation["+operation+"]::dept_code["+deptCode+"]"); System.out.println("@@@@@ data---->workOrder["+workOrder+"]::operation["+operation+"]::dept_code["+deptCode+"]");
...@@ -255,7 +267,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt ...@@ -255,7 +267,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
// for deptCode // for deptCode
if( deptCode == null || deptCode.trim().length() == 0 ) if( deptCode == null || deptCode.trim().length() == 0 )
{ {
retStr =itmDBAccessEJB.getErrorString("","VMWORDRNUL","","",conn); retStr =itmDBAccessEJB.getErrorString("","VMDEPTCNUL","","",conn);
return retStr; return retStr;
} }
else else
...@@ -286,6 +298,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt ...@@ -286,6 +298,7 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
} }
if( operation > 0 ) if( operation > 0 )
{ {
sql ="select count(1) from workorder_bill where work_order = ? and operation = ? "; sql ="select count(1) from workorder_bill where work_order = ? and operation = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,workOrder); pstmt.setString(1,workOrder);
...@@ -926,6 +939,37 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt ...@@ -926,6 +939,37 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
pstmt.setString(17,workOrder); pstmt.setString(17,workOrder);
pstmt.addBatch(); pstmt.addBatch();
pstmt.clearParameters(); pstmt.clearParameters();
// for stock allocation
System.out.println("lineNo :"+lineNo+" itemCode :"+itemCode+" stock_loc_code :"+stock_loc_code+" stock_lot_no :"+stock_lot_no+" stock_lot_sl :"+stock_lot_sl+" reqQty :"+reqQty);
//allocQty = -1 * reqQty;
//line = " " + lineNo;
hashMap.put("tran_date", new java.sql.Date(System.currentTimeMillis()));
hashMap.put("ref_ser",tranSer1);
hashMap.put("ref_id", tranId);
hashMap.put("ref_line", lnNo);
hashMap.put("item_code", itemCode);
hashMap.put("site_code", siteCode);
hashMap.put("loc_code",stock_loc_code);
hashMap.put("lot_no",stock_lot_no);
hashMap.put("lot_sl",stock_lot_sl);
hashMap.put("alloc_qty", new Double(reqQty));
hashMap.put("chg_win","W_WO_ISS_REPLACEMENT");
hashMap.put("chg_user", GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
hashMap.put("chg_term", GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "termId"));
//Calling DistStkUpdEJB
System.out.println("Calling DistStkUpdEJB.....");
if (updAllocTrace(hashMap, conn) > 0)
{
System.out.println("distStkUpd.UpdAllocTrace(HashMap, Connection) : Sucessuful!");
}
// end stock allocation
} }
} }
} }
...@@ -941,6 +985,10 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt ...@@ -941,6 +985,10 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
} }
else else
...@@ -1047,5 +1095,166 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt ...@@ -1047,5 +1095,166 @@ public class WOIssueReplacementPrc extends ProcessEJB implements GenerateReceipt
return s; return s;
} }
public int updAllocTrace(HashMap hmp, Connection conn) throws RemoteException,ITMException
{
String stkOpt = "", tranID = "", keyString = "", sql = "";
String refId = "", refLine = "", refSer = "", itemCode = "", siteCode = "", locCode = "", lotNo = "", lotSl = "";
String chgWin="", chgUser = "", chgTerm = "";
String sqlUpd = "";
PreparedStatement pstmt = null;
Statement stmt = null, stmt1 = null;
ResultSet rs = null;
HashMap keyGenerator = null;
double allocQty = 0d;
int updateCnt = 0, retVal = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
TransIDGenerator transIDGenerator = null;
try
{
stmt = conn.createStatement();
sql = "SELECT STK_OPT FROM ITEM WHERE ITEM_CODE = '" +hmp.get("item_code").toString()+"'";
System.out.println("sql :"+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
{
stkOpt = rs.getString(1);
if (stkOpt.equals("0"))
{
retVal = 0;
return retVal;
}
}
sql="SELECT KEY_STRING FROM TRANSETUP WHERE UPPER(TRAN_WINDOW) = 'T_ALLOCTRACE'";
System.out.println("UpdAllocTrace: sql:"+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
{
keyString = rs.getString(1);
}
else
{
sql = "SELECT KEY_STRING FROM TRANSETUP WHERE UPPER(TRAN_WINDOW) = 'GENERAL' ";
System.out.println("sql :"+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
{
keyString = rs.getString(1);
System.out.println("keyString :"+keyString);
}
}
java.sql.Date today = new java.sql.Date(System.currentTimeMillis());
String tranDate1 = "";
siteCode = hmp.get("site_code").toString();
SimpleDateFormat sdf = new SimpleDateFormat (genericUtility.getApplDateFormat());
tranDate1 = sdf.format(hmp.get("tran_date"));
String transIDXmlString = "<?xml version=\"1.0\"?>\r\n<Root>\r\n" +
"<header>\r\n</header>" +
"<Detail1>" +
"<tran_id></tran_id>" +
"<tran_date>" +tranDate1 + "</tran_date>" +
"<site_code>" + siteCode + "</site_code>" +
"</Detail1></Root>";
System.out.println("transIDXmlString : " + transIDXmlString);
//GETTING DATABASE NAME
CommonConstants.setIBASEHOME();
TransIDGenerator tg = new TransIDGenerator(transIDXmlString, "BASE", CommonConstants.DB_NAME);
String tranId = tg.generateTranSeqID("ATRACE","tran_id", keyString, conn);
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
System.out.println("sql :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setDate(2,java.sql.Date.valueOf(new SimpleDateFormat(genericUtility.getDBDateFormat()).format(hmp.get("tran_date"))));
pstmt.setString(3,hmp.get("ref_ser").toString());
pstmt.setString(4,hmp.get("ref_id").toString());
pstmt.setString(5,hmp.get("ref_line").toString());
pstmt.setString(6,hmp.get("item_code").toString());
pstmt.setString(7,hmp.get("site_code").toString());
pstmt.setString(8,hmp.get("loc_code").toString());
System.out.println("loc_code: '" + hmp.get("loc_code").toString() + "'");
pstmt.setString(9,hmp.get("lot_no").toString());
pstmt.setString(10,hmp.get("lot_sl").toString());
pstmt.setDouble(11,((Double)hmp.get("alloc_qty")).doubleValue());
pstmt.setString(12,hmp.get("chg_win").toString());
pstmt.setString(13,hmp.get("chg_user").toString());
pstmt.setString(14,hmp.get("chg_term").toString());
pstmt.setDate(15,today);
updateCnt = pstmt.executeUpdate();
System.out.println("insertCnt :"+updateCnt);
if (updateCnt <= 0)
{
retVal = 0;
}
else
{
retVal = 1;
}
System.out.println("AllocQty :"+hmp.get("alloc_qty")+"\n item_Code :"+hmp.get("item_code")+"\n sitecode :"+hmp.get("site_code")+"\nlocCode :"+hmp.get("loc_code"));
System.out.println("lotno :"+hmp.get("lot_no")+"\n lotSl :"+hmp.get("lot_sl"));
sqlUpd = "UPDATE STOCK SET ALLOC_QTY = (CASE WHEN ALLOC_QTY IS NULL THEN 0 ELSE ALLOC_QTY END) + "+((Double)hmp.get("alloc_qty")).doubleValue()+" " +
" WHERE ITEM_CODE = '"+hmp.get("item_code").toString()+"'" +
" AND SITE_CODE = '"+hmp.get("site_code").toString()+"' " +
" AND LOC_CODE = '"+hmp.get("loc_code").toString()+"' " +
" AND LOT_NO = '"+hmp.get("lot_no").toString()+"' " +
" AND LOT_SL = '"+hmp.get("lot_sl").toString()+"' ";
System.out.println("Update sql :"+sqlUpd);
stmt1 = conn.createStatement();
updateCnt = stmt1.executeUpdate(sqlUpd);
//End Add Gulzar 18/01/07
System.out.println("updateCnt :"+updateCnt);
if (updateCnt <= 0)
{
retVal = 0;
}
else
{
retVal = 1;
}
}
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in DistStkUpdEJB :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in DistStkUpdEJB :"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Closing Statements.....");
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (stmt1 != null)
{
stmt1.close();
stmt1 = null;
}
}catch(Exception se){}
}
System.out.println("retVal from DistStkUpdEJB :"+retVal);
return retVal;
}
}//class }//class
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