Commit ed11f4b8 authored by wansari's avatar wansari

W15JSUN015 updated source for Merging Stock count Activity code


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@100063 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5891b999
package ibase.webitm.utility.wms; package ibase.webitm.utility.wms;
import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -12,10 +13,13 @@ import java.util.Iterator; ...@@ -12,10 +13,13 @@ import java.util.Iterator;
import ibase.scheduler.utility.interfaces.Schedule; import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
public class StatusChangeRequest implements Schedule { public class StatusChangeRequest implements Schedule {
GenericUtility genericUtility = GenericUtility.getInstance();
CommonWmsUtil commonWmsUtility = CommonWmsUtil.getInstance();
@Override @Override
public String schedulePriority(String arg0) throws Exception { public String schedulePriority(String arg0) throws Exception {
...@@ -43,10 +47,14 @@ public class StatusChangeRequest implements Schedule { ...@@ -43,10 +47,14 @@ public class StatusChangeRequest implements Schedule {
System.out.println("Site code = "+siteCode); System.out.println("Site code = "+siteCode);
xtraParams = "loginCode="+userInfo.getEmpCode()+"~~chgTerm="+userInfo.getRemoteHost()+"~~loginSiteCode="+siteCode; xtraParams = "loginCode="+userInfo.getEmpCode()+"~~chgTerm="+userInfo.getRemoteHost()+"~~loginSiteCode="+siteCode;
statusChange(siteCode,scheduleParamXML,xtraParams); statusChange(siteCode,scheduleParamXML,xtraParams);
//Changed by wasim on 28-01-2016 for using same schedular for stock count activity W15JSUN015 [START]
StockCountActivty(siteCode);
//Changed by wasim on 28-01-2016 for using same schedular for stock count activity W15JSUN015 [END]
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Inside catch Main scheduler");
throw new Exception(e); throw new Exception(e);
} }
...@@ -221,19 +229,11 @@ public class StatusChangeRequest implements Schedule { ...@@ -221,19 +229,11 @@ public class StatusChangeRequest implements Schedule {
} }
System.out.println("AWMS Interface List:"+awmsIntrArrList); System.out.println("AWMS Interface List:"+awmsIntrArrList);
connUtil.updateAwmsInterface(awmsIntrArrList, siteCode, conn);
} if(awmsIntrArrList.size() > 0)
catch(SQLException se)
{
System.out.println("SQLException : StatusChange :" +se.getMessage());
try
{ {
pstmt.close(); connUtil.updateAwmsInterface(awmsIntrArrList, siteCode, conn);
rs.close();
conn.rollback();
} }
catch(Exception se1){}
throw new ITMException(se);
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -244,8 +244,10 @@ public class StatusChangeRequest implements Schedule { ...@@ -244,8 +244,10 @@ public class StatusChangeRequest implements Schedule {
rs.close(); rs.close();
conn.rollback(); conn.rollback();
} }
catch(Exception e1){} catch(Exception e1)
throw new ITMException(e); {
System.out.println("StatusChangeRequest.statusChange()"+e.getMessage());
}
} }
finally{ finally{
try{ try{
...@@ -330,5 +332,194 @@ public class StatusChangeRequest implements Schedule { ...@@ -330,5 +332,194 @@ public class StatusChangeRequest implements Schedule {
} }
return str.trim(); return str.trim();
} }
//Changed by wasim on 28-01-2016 for using same schedular for stock count activity W15JSUN015 [START]
public String StockCountActivty(String loginSiteCode) throws RemoteException,ITMException
{
Connection conn = null;
ResultSet rs = null,rsPhyscan = null;
PreparedStatement pstmt = null, pstmtPhyscan = null;
boolean isError = false;
String lineNo = "",itemDescr = "",itemCode = "",unit = "",itemType = "",familyGrp = "",
lotNo = "",lotSl = "",palletNo = "",palletStatus = "",lockStat = "",qcType = "",stroPref = "",analysisClass = "",
errString = "",sql = "",sqlPhyScan = "",tranId = "",invStat = "";
double quantity = 0, noArtQuot = 0,noArtRem = 0,notArt = 0,totalQuantity = 0, qtyPerArt = 0;
Timestamp today = new Timestamp(System.currentTimeMillis());
Timestamp expDate = null;
Timestamp mfgDate = null;
ArrayList interfaceArrList = new ArrayList();
DistCommon distComm = new DistCommon();
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
invStat = distComm.getDisparams("999999","AWMS_LOC_INVSTAT",conn);
invStat = invStat.replace(",", "','");
invStat = "'"+invStat+"'";
System.out.println("AWMS INVSTAT for Physical count: "+invStat);
sql = " SELECT TRAN_ID FROM PHYSCAN WHERE SITE_CODE = ? AND TRAN_DATE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setTimestamp(2, getCurrtDate());
rs = pstmt.executeQuery();
while(rs.next())
{
tranId = checkNullAndTrim(rs.getString("TRAN_ID"));
System.out.println("Physical Scan Tran Id["+tranId+"]");
if(tranId != null && tranId.length() > 0)
{
/*sqlPhyScan = " SELECT D.LINE_NO,S.ITEM_CODE,I.DESCR,I.UNIT,I.ITEM_TYPE,S.LOT_NO,S.LOT_SL,S.LOC_CODE,P.SITE_CODE,S.QUANTITY,S.NO_ART,S.QTY_PER_ART "
+" FROM PHYSCAN P,PHYSCANDET D,STOCK S,ITEM I"
+" WHERE P.TRAN_ID = D.TRAN_ID AND P.TRAN_ID = ?"
+" AND S.ITEM_CODE = D.ITEM_CODE"
+" AND I.ITEM_CODE = S.ITEM_CODE"
+" AND S.LOT_NO = D.LOT_NO"
+" AND S.LOT_SL = D.LOT_SL"
+" AND S.SITE_CODE = D.SITE_CODE"
+" AND S.LOC_CODE = D.LOC_CODE";*/
sqlPhyScan = " SELECT D.LINE_NO,D.ITEM_CODE,D.LOT_NO,D.LOT_SL,D.LOC_CODE,D.QUANTITY"
+" FROM PHYSCAN P,PHYSCANDET D,LOCATION L WHERE P.TRAN_ID = D.TRAN_ID AND P.TRAN_ID = ?"
+" AND P.TRAN_ID NOT IN (SELECT REF_ID FROM SWMS_TO_AWMS WHERE REF_ID = ?)"
+" AND L.LOC_CODE = D.LOC_CODE AND L.INV_STAT IN ("+invStat+")";
pstmtPhyscan = conn.prepareStatement(sqlPhyScan);
pstmtPhyscan.setString(1, tranId);
pstmtPhyscan.setString(2, tranId);
rsPhyscan = pstmtPhyscan.executeQuery();
while(rsPhyscan.next())
{
lineNo = checkNullAndTrim(rsPhyscan.getString("LINE_NO"));
itemCode = checkNullAndTrim(rsPhyscan.getString("ITEM_CODE"));
//itemDescr = checkNullAndTrim(rs.getString("DESCR"));
//unit = checkNullAndTrim(rs.getString("UNIT"));
//itemType = checkNullAndTrim(rs.getString("ITEM_TYPE"));
lotNo = checkNullAndTrim(rsPhyscan.getString("LOT_NO"));
lotSl = checkNullAndTrim(rsPhyscan.getString("LOT_SL"));
palletNo = checkNullAndTrim(rsPhyscan.getString("LOC_CODE"));
//quantity = rs.getDouble("QUANTITY");
//notArt = rs.getDouble("NO_ART");
//qtyPerArt = rs.getDouble("QTY_PER_ART");
//analysisClass = checkNullAndTrim(rs.getString("ANALYSIS_CLASS"));
System.out.println("Pallet No before removing suffix: "+palletNo);
palletNo = (palletNo.charAt(palletNo.trim().length()-1)=='Q') || (palletNo.charAt(palletNo.trim().length()-1)=='M') ||
(palletNo.charAt(palletNo.trim().length()-1)=='S') || (palletNo.charAt(palletNo.trim().length()-1)=='B') ||
(palletNo.charAt(palletNo.trim().length()-1)=='X') || (palletNo.charAt(palletNo.trim().length()-1)=='U') ||
(palletNo.charAt(palletNo.trim().length()-1)=='P') ? palletNo.substring(0,palletNo.trim().length()-1):palletNo;
System.out.println("Pallet No After removing suffix: "+palletNo);
HashMap<String,String> interfaceHmap = new HashMap<String,String>();
interfaceHmap.put("TRAN_ID", "");
interfaceHmap.put("ITEM_CODE", itemCode);
interfaceHmap.put("DESCR", "");
interfaceHmap.put("UNIT", "");
interfaceHmap.put("ITEM_TYPE", "");
interfaceHmap.put("FAMILY_GRP", "");
interfaceHmap.put("IN_OUT", "B");
interfaceHmap.put("REF_SER", "PSCAN");
interfaceHmap.put("REF_ID", tranId);
interfaceHmap.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today)));
interfaceHmap.put("LOT_NO", lotNo);
interfaceHmap.put("LOT_SL", lotSl);
interfaceHmap.put("QUANTITY", "");
interfaceHmap.put("QTY_PER_ART", "");
interfaceHmap.put("TOTAL_QTY", "");
interfaceHmap.put("EXP_DATE", "");
interfaceHmap.put("MFG_DATE", "");
interfaceHmap.put("PALLET_NO", palletNo);
interfaceHmap.put("MSG_STAT", "N");
interfaceHmap.put("PALLET_STATUS", "");
interfaceHmap.put("LOCK_STAT", "");
interfaceHmap.put("ERR_COD", "");
interfaceHmap.put("ERR_DESC", "");
interfaceHmap.put("QC_TYPE", "");
interfaceHmap.put("TRANS_DT_ACK", "");
interfaceHmap.put("STRO_PREF", "");
interfaceHmap.put("LINE_NO", lineNo);
interfaceArrList.add(interfaceHmap);
}
pstmtPhyscan.close();pstmtPhyscan = null;
rsPhyscan.close();rsPhyscan = null;
}
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("Going to insert in host_to_wms and swms_to_awms");
System.out.println("ArrayList size="+interfaceArrList.size());
if(interfaceArrList.size() > 0)
{
commonWmsUtility.updateAwmsInterface(interfaceArrList,loginSiteCode,conn);
}
}
catch(Exception e)
{
isError = true;
System.out.println("Exception caught CountRequest");
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError="+isError);
if(isError)
{
System.out.println("Finally rollbacking");
conn.rollback();
}
else
{
System.out.println("Finally committing");
conn.commit();
}
if(conn != null){conn.close();conn = null;}
if(pstmt != null){pstmt.close();pstmt=null;}
if(rs != null){rs.close();rs=null;}
if(pstmtPhyscan != null){pstmtPhyscan.close();pstmtPhyscan=null;}
if(rsPhyscan != null){rsPhyscan.close();rsPhyscan=null;}
}
catch(Exception se)
{
throw new ITMException(se);
}
}
System.out.println("Final return string" + errString);
return errString;
}
private java.sql.Timestamp getCurrtDate() throws RemoteException,ITMException
{
java.sql.Timestamp currDate = null;
try
{
Object date = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis());
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString()+ " 00:00:00.0");
}
catch (Exception e)
{
throw new ITMException(e);
}
return (currDate);
}
//Changed by wasim on 28-01-2016 for using same schedular for stock count activity W15JSUN015 [END]
} }
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