Commit 23bc0b33 authored by wansari's avatar wansari

W15JSUN015 updated source for updating last_phyc_date of stock for stock count activity.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@100245 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 38a1202b
......@@ -123,14 +123,19 @@ public class StatusChangeRequest implements Schedule {
pstmt = conn.prepareStatement(sql);
rs=pstmt.executeQuery();
if(rs.next()){
if(rs.next())
{
tranRefSer=rs.getString("REF_SER");
}
if(pstmt != null){
pstmt.close();pstmt = null;
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null){
rs.close();rs = null;
if (rs != null)
{
rs.close();
rs = null;
}
sqlStr = "SELECT S.QTY_PER_ART,S.UNIT,S.MFG_DATE,S.EXP_DATE,S.QUANTITY,S.NO_ART,S.LOC_CODE,S.LOT_SL,S.LOT_NO,S.ITEM_CODE,D.LINE_NO,"
......@@ -141,8 +146,8 @@ public class StatusChangeRequest implements Schedule {
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
while(rs.next())
{
qtyPerArt = checkNullAndTrim(rs.getString("QTY_PER_ART"));
......@@ -240,8 +245,16 @@ public class StatusChangeRequest implements Schedule {
System.out.println("Exception :StatusChange :"+e.getMessage());
try
{
pstmt.close();
rs.close();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
conn.rollback();
}
catch(Exception e1)
......@@ -249,14 +262,29 @@ public class StatusChangeRequest implements Schedule {
System.out.println("StatusChangeRequest.statusChange()"+e.getMessage());
}
}
finally{
try{
finally
{
try
{
conn.commit();
pstmt.close();
rs.close();
conn.close();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch (Exception e) {
catch (Exception e)
{
System.out.println("Error in Status Change : "+e.getMessage());
}
}
......@@ -370,12 +398,21 @@ public class StatusChangeRequest implements Schedule {
pstmtInterface.setString(1, "B");
pstmtInterface.setTimestamp(2, getCurrtDate());
rsInterface = pstmtInterface.executeQuery();
if(rsInterface.next())
{
count = rsInterface.getInt(1);
}
rsInterface.close();rsInterface = null;
pstmtInterface.close();pstmtInterface = null;
if(pstmtInterface != null)
{
pstmtInterface.close();
pstmtInterface=null;
}
if(rsInterface != null)
{
rsInterface.close();
rsInterface=null;
}
System.out.println("Count from swms_to_amws for in_out B="+count);
......@@ -386,6 +423,7 @@ public class StatusChangeRequest implements Schedule {
pstmt.setString(1, loginSiteCode);
pstmt.setTimestamp(2, getCurrtDate());
rs = pstmt.executeQuery();
while(rs.next())
{
tranId = checkNullAndTrim(rs.getString("TRAN_ID"));
......@@ -413,16 +451,17 @@ public class StatusChangeRequest implements Schedule {
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"));
itemCode = checkNull(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"));
lotNo = checkNull(rsPhyscan.getString("LOT_NO"));
lotSl = checkNull(rsPhyscan.getString("LOT_SL"));
palletNo = checkNull(rsPhyscan.getString("LOC_CODE"));
//quantity = rs.getDouble("QUANTITY");
//notArt = rs.getDouble("NO_ART");
//qtyPerArt = rs.getDouble("QTY_PER_ART");
......@@ -467,12 +506,28 @@ public class StatusChangeRequest implements Schedule {
interfaceArrList.add(interfaceHmap);
}
pstmtPhyscan.close();pstmtPhyscan = null;
rsPhyscan.close();rsPhyscan = null;
if(rsPhyscan != null)
{
rsPhyscan.close();
rsPhyscan=null;
}
if(pstmtPhyscan != null)
{
pstmtPhyscan.close();
pstmtPhyscan=null;
}
}
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(rs != null)
{
rs.close();
rs=null;
}
if(pstmt != 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());
......@@ -486,6 +541,10 @@ public class StatusChangeRequest implements Schedule {
{
System.out.println("***************Stock Count Activty is already already runn today************");
}
//Changed by wasim on 19-02-2016 for updating last_phyc_date in stock W15JSUN015 [START]
updatePhyscanDate(conn);
//Changed by wasim on 19-02-2016 for updating last_phyc_date in stock W15JSUN015 [END]
}
catch(Exception e)
{
......@@ -508,14 +567,40 @@ public class StatusChangeRequest implements Schedule {
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;}
if(pstmtInterface != null){pstmtInterface.close();pstmtInterface=null;}
if(rsInterface != null){rsInterface.close();rsInterface=null;}
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;
}
if(pstmtInterface != null)
{
pstmtInterface.close();
pstmtInterface=null;
}
if(rsInterface != null)
{
rsInterface.close();
rsInterface=null;
}
}
catch(Exception se)
{
......@@ -545,4 +630,173 @@ public class StatusChangeRequest implements Schedule {
return (currDate);
}
//Changed by wasim on 28-01-2016 for using same schedular for stock count activity W15JSUN015 [END]
//Changed by wasim on 19-02-2016 to update the last_phy_scan date after acknowledgment received [START]
public void updatePhyscanDate(Connection conn) throws RemoteException,ITMException
{
//Connection conn = null;
String sql = "",sqlUpdate = "",sqlPhyscan = "",refId = "",locCode = "",siteCode = "",itemCode = "",lotNo = "",lotSl = "",lineNo = "";
PreparedStatement pstmtUpdate = null,pstmt = null,pstmtPhyscan = null;
ResultSet rs= null,rsPhyscan = null;
int updCnt = 0;
double qtyPhysical = 0,phyInput = 0;
Timestamp tranDateAck = null;
boolean isError = false;
try
{
System.out.println("inside updatePhyscanDate");
/*ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);*/
sql = "SELECT REF_ID,LINE_NO,TOTAL_QTY,QUANTITY FROM WMS_TO_HOST WHERE IN_OUT = 'B' AND REF_ID IN "
+ "(SELECT REF_ID FROM SWMS_TO_AWMS WHERE SCHEDULE_STATUS = 'N')";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next())
{
refId = checkNullAndTrim(rs.getString("REF_ID"));
lineNo = checkNullAndTrim(rs.getString("LINE_NO"));
qtyPhysical = rs.getDouble("TOTAL_QTY");
phyInput = rs.getDouble("QUANTITY");
System.out.println("REF_ID["+refId+"]LINE_NO["+lineNo+"]QUANTITY["+phyInput+"]TOTAL_QTY["+qtyPhysical+"]TRANS_DT_ACK["+tranDateAck+"]");
sqlPhyscan = " SELECT D.ITEM_CODE,D.LOT_NO,D.LOT_SL,D.LOC_CODE,D.SITE_CODE FROM PHYSCAN P,PHYSCANDET D WHERE "
+ " P.TRAN_ID = D.TRAN_ID AND D.TRAN_ID = ? AND D.LINE_NO = ?";
pstmtPhyscan = conn.prepareStatement(sqlPhyscan);
pstmtPhyscan.setString(1, refId);
pstmtPhyscan.setString(2, lineNo);
rsPhyscan = pstmtPhyscan.executeQuery();
if(rsPhyscan.next())
{
itemCode = checkNull(rsPhyscan.getString("ITEM_CODE"));
lotNo = checkNull(rsPhyscan.getString("LOT_NO"));
lotSl = checkNull(rsPhyscan.getString("LOT_SL"));
locCode = checkNull(rsPhyscan.getString("LOC_CODE"));
siteCode = checkNull(rsPhyscan.getString("SITE_CODE"));
sqlUpdate = "UPDATE STOCK SET LAST_PHYC_DATE = ? WHERE ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ? AND LOC_CODE = ? AND SITE_CODE = ?";
pstmtUpdate = conn.prepareStatement(sqlUpdate);
pstmtUpdate.setTimestamp(1, getCurrtDate());
pstmtUpdate.setString(2, itemCode);
pstmtUpdate.setString(3, lotNo);
pstmtUpdate.setString(4, lotSl);
pstmtUpdate.setString(5, locCode);
pstmtUpdate.setString(6, siteCode);
updCnt = pstmtUpdate.executeUpdate();
System.out.println("Updated cnt="+updCnt);
if(pstmtUpdate != null)
{
pstmtUpdate.close();
pstmtUpdate=null;
}
sqlUpdate = "UPDATE PHYSCANDET SET QTY_PHYSICAL = ?,PHY_INPUT = ? WHERE TRAN_ID = ? AND LINE_NO = ?";
pstmtUpdate = conn.prepareStatement(sqlUpdate);
pstmtUpdate.setDouble(1, qtyPhysical);
pstmtUpdate.setDouble(2, phyInput);
pstmtUpdate.setString(3, refId);
pstmtUpdate.setString(4, lineNo);
updCnt = pstmtUpdate.executeUpdate();
System.out.println("Updated cnt="+updCnt);
if(pstmtUpdate != null)
{
pstmtUpdate.close();
pstmtUpdate=null;
}
sqlUpdate = "UPDATE SWMS_TO_AWMS SET SCHEDULE_STATUS = 'Y' WHERE REF_ID = ? AND LINE_NO = ?";
pstmtUpdate = conn.prepareStatement(sqlUpdate);
pstmtUpdate.setString(1, refId);
pstmtUpdate.setString(2, lineNo);
updCnt = pstmtUpdate.executeUpdate();
System.out.println("Updated ="+updCnt);
if(pstmtUpdate != null)
{
pstmtUpdate.close();
pstmtUpdate=null;
}
}
if(pstmtPhyscan != null)
{
pstmtPhyscan.close();
pstmtPhyscan=null;
}
if(rsPhyscan != null)
{
rsPhyscan.close();
rsPhyscan=null;
}
}
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
if(rs != null)
{
rs.close();
rs=null;
}
}
catch(Exception e)
{
isError = true;
System.out.println("Exception caught updatePhyscanDate");
throw new ITMException(e);
}
finally
{
try
{
System.out.println("updatePhyscanDate isError="+isError);
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
if(rs != null)
{
rs.close();
rs=null;
}
if(pstmtPhyscan != null)
{
pstmtPhyscan.close();
pstmtPhyscan=null;
}
if(pstmtUpdate != null)
{
pstmtUpdate.close();
pstmtUpdate=null;
}
if(rsPhyscan != null)
{
rsPhyscan.close();
rsPhyscan=null;
}
}
catch(Exception se)
{
throw new ITMException(se);
}
}
}
private String checkNull( String input )
{
if( input == null )
{
input = "";
}
return input;
}
//Changed by wasim on 19-02-2016 to update the last_phy_scan date after acknowledgment received [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