Commit d5519262 authored by ssalve's avatar ssalve

Sarita: Done changes on 13 NOV 2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192848 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0bb967ea
/**
* PURPOSE : Pre Save Logic
* AUTHOR : Priyanka Chavan.
*/
* PURPOSE : Pre Save Logic
* AUTHOR : Priyanka Chavan.
*/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
......@@ -53,42 +53,65 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
errString = issueAdjReceiptAndIssue(tranID, xtraParams, forcedFlag,conn);
System.out.println("[Errorstring :::::::::["+errString+"]]");
if (errString == null || errString.trim().length() == 0)
{
conn.close();
conn = null;
} else
errString = itmDBAccessEJB.getErrorString("", "VTAUTOSPLT", "", "", conn);
conn.commit();
/*if(conn != null)
{
conn.close();
conn = null;
}*/
}
else
{
conn.close();
conn = null;
return errString;
conn.rollback();
/*if(conn != null)
{
conn.close();
conn = null;
}*/
//return errString;
}
}
catch(Exception e)
{
//Added by Anjali
try
{
conn.rollback();
}
catch (SQLException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
throw new ITMException(e1);
}
System.out.println("Exception Inside [SRLContainerSplit [confirm] Method] ::["+e+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally {
try {
if (conn != null) {
System.out
.println("InSide finally.. rollbacking >>>>>>>>>>>>>>>>> ");
finally
{
try
{
if (conn != null)
{
System.out.println("InSide finally.. rollbacking >>>>>>>>>>>>>>>>> ");
conn.rollback();
conn.close();
System.out
.println("InSide finally.. Connection has been closed >>>>>>>>>>>>>>>>>>>>>>>>> ");
System.out.println("InSide finally.. Connection has been closed >>>>>>>>>>>>>>>>>>>>>>>>> ");
}
conn = null;
} catch (SQLException se) {
System.out.println("SQL Exception in finaly >>>> "
+ se.getMessage());
}
catch (SQLException se)
{
System.out.println("SQL Exception in finaly >>>> "+ se.getMessage());
throw new ITMException(se);
} catch (Exception d) {
}
catch (Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
......@@ -130,8 +153,9 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
String avalibleFrLocCode = "";
//Added by sarita on 29 OCT 2018 [END]
//Added by sarita on 02 NOV 2018 [START]
HashMap stockMap = new HashMap<>();
ArrayList stockDataList = new ArrayList();
String refSer = "", autoConfirm = "", taxForm = "", chgTerm = "",wrkflwInit = "", wrkflwOpt = "", transactionID = "";
String refSer = "", chgTerm = "",wrkflwInit = "", wrkflwOpt = "", transactionID = "";
XML2DBEJB xml2DBLocal = new XML2DBEJB();
boolean isWrkflwToBeInitiated = false;
UserInfoBean userInfo = null;
......@@ -196,15 +220,15 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
//Commented & Added by sarita to perform validation on location as location should not be GIT Location on 29 OCT 2018 [START]
//sql = "select count(*) as cnt from stock where ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ? AND quantity > 0";
sql = "select a.available "
+ "from invstat a , Location b , Stock c "
+ "where a.inv_stat = b.inv_stat "
+ "AND b.loc_code = c.loc_code "
+ "AND c.ITEM_CODE = ? "
+ "AND c.LOT_NO = ? "
+ "AND c.LOT_SL = ? "
+ "AND c.quantity > 0 "
+ "group by a.available ,c.loc_code,c.item_code,c.lot_no,c.lot_sl,c.quantity";
sql = "select a.available "
+ "from invstat a , Location b , Stock c "
+ "where a.inv_stat = b.inv_stat "
+ "AND b.loc_code = c.loc_code "
+ "AND c.ITEM_CODE = ? "
+ "AND c.LOT_NO = ? "
+ "AND c.LOT_SL = ? "
+ "AND c.quantity > 0 "
+ "group by a.available ,c.loc_code,c.item_code,c.lot_no,c.lot_sl,c.quantity";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCodeHdr);
pstmt.setString(2, lotNoHdr);
......@@ -215,9 +239,13 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
while(rs.next())
{
stkCnt++;
stockMap = new HashMap<>();
avalibleFrLocCode = rs.getString("available");
stockDataList.add(stkCnt);
stockDataList.add(avalibleFrLocCode);
/*stockDataList.add(stkCnt);
stockDataList.add(avalibleFrLocCode);*/
stockMap.put("count", stkCnt);
stockMap.put("available", avalibleFrLocCode);
stockDataList.add(stockMap);
//Added by sarita to store data into ArrayList on 02 NOV 2018 [END]
}
System.out.println("[SRLContainerSplit] Count is ["+cnt+"] && Available in invstat is ["+avalibleFrLocCode+"]");
......@@ -243,7 +271,7 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
}
//if(cnt > 1) -- Commented and Added by sarita on 02 NOV 2018
if(stockDataList.size() > 2)
if(stockDataList.size() > 1)
{
//retSting = itmDBAccessEJB.getErrorString("", "INVRCDSTOC", "");//itmDBAccessEJB.getErrorString("","VTBLNKDTL","","",conn);
retSting = itmDBAccessEJB.getErrorString("", "INVRCDSTOC", "", "", conn);
......@@ -261,10 +289,14 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
}*/
else
{
stkCnt = (Integer)stockDataList.get(0);
avalibleFrLocCode = (String)stockDataList.get(1);
HashMap newMap = new HashMap<>();
newMap = (HashMap) stockDataList.get(0);
/*stkCnt = (Integer)stockDataList.get(0);
avalibleFrLocCode = (String)stockDataList.get(1);*/
stkCnt = (int) newMap.get("count");
avalibleFrLocCode = (String) newMap.get("available");
System.out.println("avalibleFrLocCode ["+avalibleFrLocCode+"]");
if((stkCnt == 1) && ("N".equalsIgnoreCase(avalibleFrLocCode)))
if("N".equalsIgnoreCase(avalibleFrLocCode))
{
retSting = itmDBAccessEJB.getErrorString("", "VTINVGIT", "", "", conn);//Please check the GIT Location Code, it does not exists or not for internal use.
isError = true;
......@@ -434,6 +466,19 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
return retSting;
}
}//if(rsStock.next())
//Added by Anjali R. S
if(rsStock != null)
{
rsStock.close();
rsStock = null;
}
if(pstmtStock != null)
{
pstmtStock.close();
pstmtStock = null;
}
//Added by Anjali R. E
valueXmlforIssue.append("</Header0>\n");
valueXmlforIssue.append("</group0>\n");
......@@ -545,8 +590,16 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
valueXmlforReceipt.append("</Detail2>\n");
cntRCP++;
}
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;
}
valueXmlforReceipt.append("</Header0>");
valueXmlforReceipt.append("</group0>");
valueXmlforReceipt.append("</DocumentRoot>");
......@@ -605,14 +658,17 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
System.out.println("Saving Data for Receipt");
//Commented and Added by sarit aon 02 NOV 2018 [START]
//retSting = saveData(siteCode,valueXmlforReceipt.toString(),conn,userId);
String sql1 = "SELECT REF_SER, AUTO_CONFIRM, TAX_FORMS, WRKFLW_INIT, WORKFLOW_OPT FROM TRANSETUP WHERE TRAN_WINDOW = 'w_adj_rcp'" ;
//Modified by Anjali.Start
//String sql1 = "SELECT REF_SER, AUTO_CONFIRM, TAX_FORMS, WRKFLW_INIT, WORKFLOW_OPT FROM TRANSETUP WHERE TRAN_WINDOW = 'w_adj_rcp'" ;
String sql1 = "SELECT REF_SER, WRKFLW_INIT, WORKFLOW_OPT FROM TRANSETUP WHERE TRAN_WINDOW = 'w_adj_rcp'" ;
//Modified by Anjali.End
pstmt = conn.prepareStatement(sql1);
rs = pstmt.executeQuery();
if( rs.next() )
{
refSer = checkNull(rs.getString( "REF_SER" ));
autoConfirm = checkNull(rs.getString( "AUTO_CONFIRM" ));
taxForm = checkNull(rs.getString( "TAX_FORMS" ));
//autoConfirm = checkNull(rs.getString( "AUTO_CONFIRM" ));//Commented by anjali
//taxForm = checkNull(rs.getString( "TAX_FORMS" ));//Commented by anjali
wrkflwInit = checkNull(rs.getString( "WRKFLW_INIT" ));
wrkflwOpt = checkNull(rs.getString( "WORKFLOW_OPT" ));
}
......@@ -629,16 +685,17 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
CommonDBAccessRemote dbAccessRemote = new CommonDBAccessEJB();
userInfo = dbAccessRemote.createUserInfo(userId);
HashMap totFormsMap = getTransInfo(conn);
//HashMap totFormsMap = getTransInfo(conn);
formCnt = getTransInfo("w_adj_rcp",conn);
String totForms = (String)totFormsMap.get("TOTAL_FORMS");
if(totForms != null && totForms.length() > 0)
/*if(totForms != null && totForms.trim().length() > 0)
{
formCnt = Integer.parseInt(totForms);
}
}*/
System.out.println("Form Count is == ["+formCnt+"]");
retSting = xml2DBLocal.saveXML2DB(refSer,valueXmlforReceipt.toString(),"adj_rcp", "A", formCnt, true, userId, "tran_id",false,xtraParams,null,wrkflwInit,isWrkflwToBeInitiated,wrkflwOpt,null,"","",false, conn, false, userInfo);
transactionID = retSting;
//transactionID = retSting;
System.out.println("Data Saved Successfully for Receipt" +retSting );
//if(retSting.indexOf("Success") > -1)
......@@ -647,7 +704,8 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
//Added and Commented by sarita on 02 NOV 2018 [START]
/*String[] arrayForTranId = retSting.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
tranIdForReciept = arrayForTranId[1].substring(0,endIndex); System.out.println("tranIdForReciept["+tranIdForReciept+"]");
tranIdForReciept = arrayForTranId[1].substring(0,endIndex);
System.out.println("tranIdForReciept["+tranIdForReciept+"]");
//Commented by sarita on 19MARCH2018
//conn.commit();*/
tranIdForReciept = retSting;
......@@ -723,8 +781,11 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
//Commented by sarita on 14APR2018 [end] -- removed column status from srl_contents table
//Prompt messages showing transaction Splitted Successfullly!!!!!
//retSting = itmDBAccessEJB.getErrorString("", "VTAUTOSPLT", "");//itmDBAccessEJB.getErrorString("","VTBLNKDTL","","",conn);
retSting = itmDBAccessEJB.getErrorString("", "VTAUTOSPLT", "", "", conn);
return retSting;
//Modified by Anjali .S
/*retSting = itmDBAccessEJB.getErrorString("", "VTAUTOSPLT", "", "", conn);
return retSting;*/
retSting = "";
//Modified by Anjali .E
}
else
{
......@@ -758,7 +819,8 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
}
else
{
conn.commit();
//Modified by Anjali R. [Ideally connection commit will not happend here.Connection was not created in this method seems this method will not be commited the transaction]
//conn.commit();
System.out.println("SRLContainerSplit connection committed");
}
if(rs != null)
......@@ -771,11 +833,24 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
pstmt.close();
pstmt = null;
}
if(conn != null)
//Added by Anjali R. S
if(rsStock != null)
{
rsStock.close();
rsStock = null;
}
if(pstmtStock != null)
{
pstmtStock.close();
pstmtStock = null;
}
/*if(conn != null)
{
conn.close();
conn = null;
}
}*/
//Added by Anjali R. E
}
catch(Exception e)
{
......@@ -832,19 +907,21 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
public String confirmIssueAndReceipt(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn,String userId) throws ITMException
{
String methodName = "";
//Commented by Anjali R. Start[unused variables]
/*String methodName = "";
String compName = "";
String retString = "";
String serviceCode = "";
String serviceURI = "";
String actionURI = "";
String sql = "";
String sql = "";*/
//Commented by Anjali R. End[unused variables]
String retString = "";
PreparedStatement pStmt = null;
ResultSet rs = null;
System.out.println("confirmIssueAndReceipt(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) called >>><!@#>");
try
{
CommonDBAccessEJB dbAccessRemote = new CommonDBAccessEJB();
UserInfoBean userInfo = dbAccessRemote.createUserInfo(userId);
......@@ -886,23 +963,24 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
return retString;
}
//Added by method to get Total Forms Information on 02 NOV 2018 [START]
public HashMap getTransInfo(Connection conn) throws ITMException
//Added by sarita method to get Total Forms Information on 02 NOV 2018 [START]
public Integer getTransInfo(String winName , Connection conn) throws ITMException
{
PreparedStatement pstmtObj = null;
ResultSet rsObj = null;
int totalForms = 0;
HashMap objMap = new HashMap();
String totalForms = "";
int totForms = 0;
//HashMap objMap = new HashMap();
try
{
String winName = "w_adj_rcp";
//String winName = "w_adj_rcp";
String objFormSql = "SELECT COUNT(*) AS COUNT FROM OBJ_FORMS WHERE WIN_NAME = ?";
pstmtObj = conn.prepareStatement(objFormSql);
pstmtObj.setString(1,winName);
rsObj = pstmtObj.executeQuery();
if ( rsObj.next())
{
totalForms = rsObj.getInt("COUNT");
totalForms = checkNull(rsObj.getString("COUNT"));
}
if(rsObj != null)
{
......@@ -914,7 +992,24 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
pstmtObj.close();
pstmtObj = null;
}
objMap.put("TOTAL_FORMS", ""+totalForms); System.out.println("objMap ::"+objMap);
if(totalForms == null || totalForms.trim().length() == 0)
{
totForms = 0;
}
else
{
try
{
totForms = Integer.parseInt(totalForms);
}
catch(Exception e)
{
System.err.println("getTransInfo--["+e.getMessage()+"]");
e.printStackTrace();
totForms = 0;
}
}
//objMap.put("TOTAL_FORMS", ""+totalForms); System.out.println("objMap ::"+objMap);
}
catch (Exception e)
{
......@@ -942,7 +1037,8 @@ public class SRLContainerSplit extends ActionHandlerEJB implements SRLContainerS
throw new ITMException(e1);
}
}
return objMap;
System.out.println("totForms--["+totForms+"]");
return totForms ;
}
//Added by method to get Total Forms Information on 02 NOV 2018 [END]
//Added by sarita method to get Total Forms Information on 02 NOV 2018 [END]
}
\ 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