Commit 8faee540 authored by wansari's avatar wansari

W15GSUN003 updated for location code update and allocation on location


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99340 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ee1acddd
...@@ -208,15 +208,16 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -208,15 +208,16 @@ public class ScheduleAWMSInOutTasks implements Schedule
private String stockTransfer(HashMap interfaceMap,String xtraParams,Connection conn) throws SQLException, ITMException private String stockTransfer(HashMap interfaceMap,String xtraParams,Connection conn) throws SQLException, ITMException
{ {
PreparedStatement pstmt=null, pstmtHdr = null, pstmtDet = null,pstmtInterface = null,pstmtUpdate = null,pstmtDso = null; PreparedStatement pstmt=null, pstmtHdr = null, pstmtDet = null,pstmtInterface = null,pstmtUpdate = null,pstmtDso = null,pstmtQc = null;
ResultSet rs = null,rsInterface = null,rsDso = null; ResultSet rs = null,rsInterface = null,rsDso = null,rsQc = null;
String sql = "",insertSql = "",tranID = "",loginSiteCode = "",userId = "",errString = "",sqlInterface = "",sqlUpdate = "",sqlDso = ""; String sql = "",insertSql = "",tranID = "",loginSiteCode = "",userId = "",errString = "",sqlInterface = "",sqlUpdate = "",sqlDso = "",
sqlQc = "",locCodeQuarnt = "";
String refSer = "",refId = "",noArt = "",itemCode = "",lotNo = "",lotSl = "",acctCodeInv = "",cctrCodeInv = "", String refSer = "",refId = "",itemCode = "",lotNo = "",lotSl = "",acctCodeInv = "",cctrCodeInv = "",noArt = "",
palletNo = "",locCodeTo = "",locCodeFrom = "",siteCode = "",lineNoInterface = ""; palletNo = "",locCodeTo = "",locCodeFrom = "",siteCode = "",lineNoInterface = "",qcOrderStatus = "",locCodeReturn = "";
Double quantity = 0d; double quantity = 0,allocQty = 0;
int updCnt = 0,lineNo = 0,countDso = 0; int updCnt = 0,lineNo = 0,countDso = 0;
//HashMap hashMap = new HashMap(); //HashMap hashMap = new HashMap();
...@@ -231,6 +232,7 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -231,6 +232,7 @@ public class ScheduleAWMSInOutTasks implements Schedule
ArrayList lineNoList = new ArrayList(); ArrayList lineNoList = new ArrayList();
ArrayList tranIdList = new ArrayList(); ArrayList tranIdList = new ArrayList();
ArrayList allocList = new ArrayList(); ArrayList allocList = new ArrayList();
ArrayList locationList = new ArrayList();
ArrayList tranIdIssList = new ArrayList(); ArrayList tranIdIssList = new ArrayList();
boolean isRecordExist = false; boolean isRecordExist = false;
...@@ -264,13 +266,19 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -264,13 +266,19 @@ public class ScheduleAWMSInOutTasks implements Schedule
if(countDso == 0) if(countDso == 0)
{ {
sql = "SELECT D.TRAN_ID,D.ITEM_CODE,D.LINE_NO,D.QUANTITY,D.LOT_NO,D.LOT_SL,D.LOC_CODE,H.SITE_CODE" //Changed by wasim on 04-12-2015 to join sql from stock and DISTORD_ISSDET
/*sql = "SELECT D.TRAN_ID,D.ITEM_CODE,D.LINE_NO,D.QUANTITY,D.LOT_NO,D.LOT_SL,D.LOC_CODE,H.SITE_CODE"
+" FROM DISTORD_ISSDET D,DISTORD_ISS H WHERE D.TRAN_ID = H.TRAN_ID AND H.CONFIRMED = 'N' AND D.DIST_ORDER = ?" +" FROM DISTORD_ISSDET D,DISTORD_ISS H WHERE D.TRAN_ID = H.TRAN_ID AND H.CONFIRMED = 'N' AND D.DIST_ORDER = ?"
+ "AND D.LINE_NO = ? AND D.QUANTITY > 0"; + "AND D.LINE_NO = ? AND D.QUANTITY > 0";*/
sql = "SELECT D.TRAN_ID,D.ITEM_CODE,D.LINE_NO,S.QUANTITY,D.LOT_NO,D.LOT_SL,D.LOC_CODE,H.SITE_CODE,S.ALLOC_QTY"
+" FROM DISTORD_ISSDET D,DISTORD_ISS H,STOCK S "
+" WHERE D.TRAN_ID = H.TRAN_ID AND H.CONFIRMED = 'N' AND D.DIST_ORDER = ?"
+" AND D.LINE_NO = ? AND D.QUANTITY > 0 AND S.LOC_CODE = D.LOC_CODE AND S.LOT_NO = D.LOT_NO"
+" AND S.LOT_SL = D.LOT_SL AND S.ITEM_CODE = D.ITEM_CODE AND S.SITE_CODE = H.SITE_CODE";
} }
else else
{ {
sql = "SELECT ITEM_CODE,LINE_NO,QUANTITY,QTY_ALLOC,UNIT,LOT_NO,LOT_SL,MFG_DATE,EXP_DATE,LOC_CODE,SITE_CODE__MFG AS SITE_CODE" sql = "SELECT ITEM_CODE,LINE_NO,QUANTITY,QTY_ALLOC,LOT_NO,LOT_SL,LOC_CODE,SITE_CODE__MFG AS SITE_CODE"
+ " FROM DISTORDER_ALLOC WHERE DIST_ORDER = ? AND LINE_NO = ? AND QUANTITY > 0"; + " FROM DISTORDER_ALLOC WHERE DIST_ORDER = ? AND LINE_NO = ? AND QUANTITY > 0";
} }
} }
...@@ -281,23 +289,26 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -281,23 +289,26 @@ public class ScheduleAWMSInOutTasks implements Schedule
} }
else if("PZ".equalsIgnoreCase(refSer)) else if("PZ".equalsIgnoreCase(refSer))
{ {
sql = "SELECT P.ITEM_CODE,P.LINE_NO,P.QUANTITY,S.ALLOC_QTY,S.UNIT,P.LOT_NO,P.LOT_SL,S.MFG_DATE,S.EXP_DATE," sql = "SELECT P.ITEM_CODE,P.LINE_NO,P.QUANTITY,P.ALLOC_QTY,P.LOT_NO,P.LOT_SL,P.NO_ART,"
+ " P.LOC_CODE,P.SITE_CODE,P.PALLET_NO FROM PALLET_DET P,STOCK S WHERE TRAN_ID = ? AND P.LINE_NO = ?" + " P.LOC_CODE,P.SITE_CODE,P.PALLET_NO FROM PALLET_DET P,STOCK S WHERE TRAN_ID = ? AND P.LINE_NO = ?"
+ " AND P.ITEM_CODE = S.ITEM_CODE AND P.SITE_CODE = S.SITE_CODE" + " AND P.ITEM_CODE = S.ITEM_CODE AND P.SITE_CODE = S.SITE_CODE"
+ " AND P.LOC_CODE = S.LOC_CODE AND P.LOT_NO = S.LOT_NO AND P.LOT_SL = S.LOT_SL AND S.QUANTITY > 0"; + " AND P.LOC_CODE = S.LOC_CODE AND P.LOT_NO = S.LOT_NO AND P.LOT_SL = S.LOT_SL AND S.QUANTITY > 0";
sqlQc = "SELECT STATUS FROM QC_ORDER WHERE SITE_CODE = ? AND LOC_CODE = ? AND ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ?";
pstmtQc = conn.prepareStatement(sqlQc);
} }
else if("PR".equalsIgnoreCase(refSer)) else if("PR".equalsIgnoreCase(refSer))
{ {
sql = "SELECT S.ITEM_CODE,S.QUANTITY,S.LOT_NO,S.LOT_SL,P.LOC_CODE,P.PALLET_NO,"+ sql = "SELECT S.ITEM_CODE,S.QUANTITY,S.LOT_NO,S.LOT_SL,P.LOC_CODE,S.LOC_CODE AS LOC_CODE_FROM,S.ALLOC_QTY,P.NO_ART"+ //Changed by wasim on 4-12-2015 to take loc_code from stock
" S.SITE_CODE FROM STOCK S,PALLET_REQ_DET P WHERE S.LOC_CODE = P.PALLET_NO AND S.INV_STAT = 'AWMS'" + " S.SITE_CODE FROM STOCK S,PALLET_REQ_DET P WHERE AND S.INV_STAT = 'AWMS'" +
" AND P.TRAN_ID = ? AND P.LINE_NO = ? AND S.QUANTITY > 0"; " AND P.TRAN_ID = ? AND P.LINE_NO = ? AND (S.LOC_CODE = P.PALLET_NO OR S.LOC_CODE = ? )AND S.QUANTITY > 0"; //Changed by wasim on 4-12-2015 to check Q loc code if not found data
} }
else if("PRS".equalsIgnoreCase(refSer)) else if("PRS".equalsIgnoreCase(refSer))
{ {
sql = "SELECT P.ITEM_CODE,P.QUANTITY,P.LOT_NO,P.LOT_SL,P.LOC_CODE,P.PALLET_NO,H.SITE_CODE" sql = "SELECT P.ITEM_CODE,S.QUANTITY,P.LOT_NO,P.LOT_SL,P.LOC_CODE,S.LOC_CODE AS LOC_CODE_FROM,H.SITE_CODE,S.ALLOC_QTY,P.NO_ART"//Changed by wasim on 13-12-2015 to take quantity from stock not from pallet_det
+" FROM PALLET_REQ_DET P,STOCK S,PALLET_REQ_HDR H WHERE P.TRAN_ID = ? AND P.LINE_NO = ?" +" FROM PALLET_REQ_DET P,STOCK S,PALLET_REQ_HDR H WHERE P.TRAN_ID = ? AND P.LINE_NO = ?"
+" AND P.TRAN_ID = H.TRAN_ID AND P.ITEM_CODE = S.ITEM_CODE" +" AND P.TRAN_ID = H.TRAN_ID AND P.ITEM_CODE = S.ITEM_CODE"
+" AND H.SITE_CODE = S.SITE_CODE AND P.PALLET_NO = S.LOC_CODE" +" AND H.SITE_CODE = S.SITE_CODE AND (P.PALLET_NO = S.LOC_CODE OR S.LOC_CODE = ? )" //Changed by wasim on 4-12-2015 to check Q loc code if not found data
+" AND P.LOT_NO = S.LOT_NO" +" AND P.LOT_NO = S.LOT_NO"
+" AND P.LOT_SL = S.LOT_SL"; +" AND P.LOT_SL = S.LOT_SL";
} }
...@@ -308,7 +319,7 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -308,7 +319,7 @@ public class ScheduleAWMSInOutTasks implements Schedule
pstmtDet = conn.prepareStatement(insertSql); pstmtDet = conn.prepareStatement(insertSql);
sqlInterface = "SELECT DISTINCT (LINE_NO) FROM WMS_TO_HOST WHERE REF_ID = ? AND MSG_STAT != 'E'" sqlInterface = "SELECT DISTINCT (LINE_NO),PALLET_NO FROM WMS_TO_HOST WHERE REF_ID = ? AND MSG_STAT != 'E'"
+ " AND LINE_NO IN (SELECT LINE_NO FROM SWMS_TO_AWMS WHERE REF_ID = ? AND SCHEDULE_STATUS = 'N')";//Changed by wasim on 26-11-15 to schedule_status is null to N + " AND LINE_NO IN (SELECT LINE_NO FROM SWMS_TO_AWMS WHERE REF_ID = ? AND SCHEDULE_STATUS = 'N')";//Changed by wasim on 26-11-15 to schedule_status is null to N
pstmtInterface = conn.prepareStatement(sqlInterface); pstmtInterface = conn.prepareStatement(sqlInterface);
pstmtInterface.setString(1, refId); pstmtInterface.setString(1, refId);
...@@ -358,6 +369,13 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -358,6 +369,13 @@ public class ScheduleAWMSInOutTasks implements Schedule
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId); pstmt.setString(1, refId);
pstmt.setString(2, lineNoInterface); pstmt.setString(2, lineNoInterface);
//Changed by wasim on 4-12-2015 to check Q loc code if not found data [start]
if("PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer))
{
locCodeQuarnt = checkNullAndTrim(rsInterface.getString("PALLET_NO"));
pstmt.setString(3, locCodeQuarnt+"Q");
}
//Changed by wasim on 4-12-2015 to check Q loc code if not found data [end]
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while(rs.next()) while(rs.next())
{ {
...@@ -372,20 +390,48 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -372,20 +390,48 @@ public class ScheduleAWMSInOutTasks implements Schedule
if("PZ".equalsIgnoreCase(refSer)) if("PZ".equalsIgnoreCase(refSer))
{ {
//locCodeFrom = checkNullAndTrim(rs.getString("LOC_CODE"));
//locCodeTo = checkNullAndTrim(rs.getString("PALLET_NO"));
locCodeFrom = checkNullAndTrim(rs.getString("LOC_CODE")); locCodeFrom = checkNullAndTrim(rs.getString("LOC_CODE"));
locCodeTo = checkNullAndTrim(rs.getString("PALLET_NO")); locCodeTo = checkNullAndTrim(rs.getString("PALLET_NO"));
allocQty = rs.getDouble("ALLOC_QTY");//Changed by wasim on 02-12-2015 for allocating stock to loc code to for palletization
noArt = checkNullAndTrim(rs.getString("NO_ART"));//Changed by wasim on 03-12-2015
System.out.println("Before location code TO is=["+locCodeTo+"]");
pstmtQc.setString(1, siteCode);
pstmtQc.setString(2, locCodeFrom);
pstmtQc.setString(3, itemCode);
pstmtQc.setString(4, lotNo);
pstmtQc.setString(5, lotSl);
rsQc = pstmtQc.executeQuery();
if(rsQc.next())
{
qcOrderStatus = checkNullAndTrim(rsQc.getString("STATUS"));
}
pstmtQc.clearParameters();
System.out.println("Qc order status is=["+qcOrderStatus+"]");
if("U".equalsIgnoreCase(qcOrderStatus))
{
locCodeTo = locCodeTo + "Q";
}
System.out.println("Final location code TO is=["+locCodeTo+"]");
} }
//else if("PR".equalsIgnoreCase(refSer))Changed by wasim on 19-11-2015 to add new ref ser PRS //else if("PR".equalsIgnoreCase(refSer))Changed by wasim on 19-11-2015 to add new ref ser PRS
else if("PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer)) else if("PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer))
{ {
locCodeFrom = checkNullAndTrim(rs.getString("PALLET_NO")); //Changed by wasim on 04-12-2014 to take loc_code from stock as loc_code from
//locCodeFrom = checkNullAndTrim(rs.getString("PALLET_NO"));
locCodeFrom = checkNullAndTrim(rs.getString("LOC_CODE_FROM"));
locCodeTo = checkNullAndTrim(rs.getString("LOC_CODE")); locCodeTo = checkNullAndTrim(rs.getString("LOC_CODE"));
allocQty = rs.getDouble("ALLOC_QTY");//Changed by wasim on 02-11-2015 to get alloc quantity
noArt = checkNullAndTrim(rs.getString("NO_ART"));//Changed by wasim on 03-12-2015
} }
else else
{ {
locCodeFrom = checkNullAndTrim(rs.getString("LOC_CODE")); locCodeFrom = checkNullAndTrim(rs.getString("LOC_CODE"));
allocQty = rs.getDouble("ALLOC_QTY");
if(countDso == 0 && "D-SO".equalsIgnoreCase(refSer)) if(countDso == 0 && "D-SO".equalsIgnoreCase(refSer))
{ {
tranIdIssList.add(checkNullAndTrim(rs.getString("TRAN_ID")));//Added by wasim on 10-11-2015 tranIdIssList.add(checkNullAndTrim(rs.getString("TRAN_ID")));//Added by wasim on 10-11-2015
...@@ -412,27 +458,26 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -412,27 +458,26 @@ public class ScheduleAWMSInOutTasks implements Schedule
pstmtDet.setString( 14, cctrCodeInv ); pstmtDet.setString( 14, cctrCodeInv );
pstmtDet.setString( 15, noArt ); pstmtDet.setString( 15, noArt );
//pstmtDet.addBatch();
//pstmtDet.clearParameters();
updCnt = pstmtDet.executeUpdate(); updCnt = pstmtDet.executeUpdate();
System.out.println("UPdate in stock transfer det="+updCnt); System.out.println("UPdate in stock transfer det="+updCnt);
pstmtDet.clearParameters(); pstmtDet.clearParameters();
//if("PR".equalsIgnoreCase(refSer))Changed by wasim on 19-11-2015 to add new ref ser PRS //if("PR".equalsIgnoreCase(refSer))Changed by wasim on 19-11-2015 to add new ref ser PRS
if("PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer)) //if("PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer)) Changed by wasim on 19-11-2015 to add new ref ser D-SO to allocate stock on from location
if("PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer) || "D-SO".equalsIgnoreCase(refSer))
{ {
System.out.println("Going for Allocation location code from for PR/PRS"); System.out.println("Going for Allocation location code from for PR/PRS");
HashMap hashMap = new HashMap(); HashMap hashMap = new HashMap();
hashMap.put("tran_date", new java.sql.Date(System.currentTimeMillis())); hashMap.put("tran_date", new java.sql.Date(System.currentTimeMillis()));
hashMap.put("ref_ser",refSer); hashMap.put("ref_ser",refSer);
hashMap.put("ref_id", tranID); hashMap.put("ref_id", refId);//Changed by wasim on 03-12-2015 from tranId to refId.
hashMap.put("ref_line", String.valueOf(lineNo)); hashMap.put("ref_line", lineNoInterface);//Changed by wasim on 03-12-2015 from stringValueof to normal
hashMap.put("item_code", itemCode); hashMap.put("item_code", itemCode);
hashMap.put("site_code", siteCode); hashMap.put("site_code", siteCode);
hashMap.put("loc_code",locCodeFrom); hashMap.put("loc_code",locCodeFrom);
hashMap.put("lot_no",lotNo); hashMap.put("lot_no",lotNo);
hashMap.put("lot_sl",lotSl); hashMap.put("lot_sl",lotSl);
hashMap.put("alloc_qty", quantity); hashMap.put("alloc_qty", (quantity-allocQty));//Changed by wasim on 03-12-2015 to allocate quantity which is remaining
hashMap.put("chg_win","W_STOCK_TRANSFER_MULTI"); hashMap.put("chg_win","W_STOCK_TRANSFER_MULTI");
hashMap.put("chg_user", userId); hashMap.put("chg_user", userId);
hashMap.put("chg_term", chgTerm); hashMap.put("chg_term", chgTerm);
...@@ -449,28 +494,43 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -449,28 +494,43 @@ public class ScheduleAWMSInOutTasks implements Schedule
//if("D-SO".equalsIgnoreCase(refSer) || "S-ORD".equalsIgnoreCase(refSer) || "PR".equalsIgnoreCase(refSer)) //if("D-SO".equalsIgnoreCase(refSer) || "S-ORD".equalsIgnoreCase(refSer) || "PR".equalsIgnoreCase(refSer))
//Changed by wasim on 19-11-2015 to remove ref ser PRS/PR //Changed by wasim on 19-11-2015 to remove ref ser PRS/PR
//if("D-SO".equalsIgnoreCase(refSer) || "S-ORD".equalsIgnoreCase(refSer) || "PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer)) //if("D-SO".equalsIgnoreCase(refSer) || "S-ORD".equalsIgnoreCase(refSer) || "PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer))
if("D-SO".equalsIgnoreCase(refSer) || "S-ORD".equalsIgnoreCase(refSer)) if("D-SO".equalsIgnoreCase(refSer) || "S-ORD".equalsIgnoreCase(refSer) || "PZ".equalsIgnoreCase(refSer) || "PR".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer))
{ {
//HashMap allocation = new HashMap();
ArrayList allocLocList = new ArrayList();
System.out.println("Going for Allocation location code TO"); System.out.println("Going for Allocation location code TO");
HashMap hashMap = new HashMap(); HashMap hashMap = new HashMap();
hashMap.put("tran_date", new java.sql.Date(System.currentTimeMillis())); hashMap.put("tran_date", new java.sql.Date(System.currentTimeMillis()));
hashMap.put("ref_ser",refSer); hashMap.put("ref_ser",refSer);
hashMap.put("ref_id", tranID); hashMap.put("ref_id", refId);
hashMap.put("ref_line", String.valueOf(lineNo)); hashMap.put("ref_line", lineNoInterface);
hashMap.put("item_code", itemCode); hashMap.put("item_code", itemCode);
hashMap.put("site_code", siteCode); hashMap.put("site_code", siteCode);
hashMap.put("loc_code",locCodeTo); hashMap.put("loc_code",locCodeTo);
hashMap.put("lot_no",lotNo); hashMap.put("lot_no",lotNo);
hashMap.put("lot_sl",lotSl); hashMap.put("lot_sl",lotSl);
hashMap.put("alloc_qty", quantity);
hashMap.put("chg_win","W_STOCK_TRANSFER_MULTI"); hashMap.put("chg_win","W_STOCK_TRANSFER_MULTI");
hashMap.put("chg_user", userId); hashMap.put("chg_user", userId);
hashMap.put("chg_term", chgTerm); hashMap.put("chg_term", chgTerm);
if(("PZ".equalsIgnoreCase(refSer) || "PRS".equalsIgnoreCase(refSer) || "PR".equalsIgnoreCase(refSer) || "D-SO".equalsIgnoreCase(refSer)) && allocQty > 0)
{
//allocation = checkStockAllocation(siteCode,itemCode,lotNo,lotSl,locCodeFrom,locCodeTo,conn);
allocLocList = checkStockAllocation(siteCode,itemCode,lotNo,lotSl,locCodeFrom,locCodeTo,conn);
hashMap.put("alloc_qty", allocQty);
allocList.add(hashMap);
locationList.add(allocLocList);
}
//Changed by wasim on 04-12-2015 as working for d-so will be same as PR
/*else if("D-SO".equalsIgnoreCase(refSer) || "S-ORD".equalsIgnoreCase(refSer))
{
hashMap.put("alloc_qty", quantity);
allocList.add(hashMap); allocList.add(hashMap);
}*/
} }
sqlUpdate = "UPDATE SWMS_TO_AWMS SET SCHEDULE_STATUS = 'Y' WHERE REF_ID = ? AND LINE_NO = ?"; sqlUpdate = "UPDATE SWMS_TO_AWMS SET SCHEDULE_STATUS = 'Y' WHERE REF_ID = ? AND LINE_NO = ?";
pstmtUpdate = conn.prepareStatement(sqlUpdate); pstmtUpdate = conn.prepareStatement(sqlUpdate);
pstmtUpdate.setString(1, refId); pstmtUpdate.setString(1, refId);
...@@ -508,21 +568,22 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -508,21 +568,22 @@ public class ScheduleAWMSInOutTasks implements Schedule
if( errString != null && errString.indexOf( "CONFSUCC" ) > -1) if( errString != null && errString.indexOf( "CONFSUCC" ) > -1)
{ {
//Changed by wasim on 30-11-2015 to not allow to allocate stock for location code to for PR/PRS [END] //Changed by wasim on 30-11-2015 to not allow to allocate stock for location code to for PR/PRS [END]
/*errString = allocStockLocCodeTo(allocList,tranIdIssList,refSer,refId,countDso,conn); errString = allocStockLocCodeTo(allocList,tranIdIssList,refSer,refId,countDso,conn);
System.out.println("Return from alloc To for PR/PRS="+errString); System.out.println("Return from alloc To for PR/PRS="+errString);
allocList.clear();//Changed by wasim on to clear list for PR/PRS as we take pallet one by one for this ref ser. allocList.clear();//Changed by wasim on to clear list for PR/PRS as we take pallet one by one for this ref ser.
if(errString != null && (errString.indexOf("CONFSTKSUCC") > -1)) if(errString != null && (errString.indexOf("CONFSTKSUCC") > -1))
{ {
System.out.println("Stock Transfer confirmed successfully------------"); System.out.println("Stock Transfer allocation on location code TO updated successfully");
updateLocation(locationList,conn);
conn.commit(); conn.commit();
} }
else else
{ {
throw new Exception (errString); throw new Exception (errString);
}*/ }
conn.commit(); //conn.commit();
//Changed by wasim on 30-11-2015 to not allow to allocate stock for location code to for PR/PRS [END] //Changed by wasim on 30-11-2015 to not allow to allocate stock for location code to for PR/PRS [END]
} }
else else
...@@ -553,9 +614,6 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -553,9 +614,6 @@ public class ScheduleAWMSInOutTasks implements Schedule
if("D-SO".equalsIgnoreCase(refSer) && countDso > 0)//Changed by wasim on 09-11-2015 to add countDso if dist issue required if("D-SO".equalsIgnoreCase(refSer) && countDso > 0)//Changed by wasim on 09-11-2015 to add countDso if dist issue required
{ {
System.out.println("Going for Distribution issue"); System.out.println("Going for Distribution issue");
//errString = callDistIssue(refId,xtraParams,conn);//Using club
//CreateDistIssue disIssue = new CreateDistIssue();//VTCONPARM
//errString = disIssue.createDistIssue(loginSiteCode, "<Root><TranID>" + refId + "</TranID></Root>", xtraParams, conn);
errString = callDistIssue(loginSiteCode, refId,lineNoList, xtraParams, conn); errString = callDistIssue(loginSiteCode, refId,lineNoList, xtraParams, conn);
System.out.println("Return from dist issue"+errString); System.out.println("Return from dist issue"+errString);
...@@ -585,9 +643,15 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -585,9 +643,15 @@ public class ScheduleAWMSInOutTasks implements Schedule
throw new Exception (errString); throw new Exception (errString);
} }
} }
else if ("PZ".equalsIgnoreCase(refSer) || "D-SO".equalsIgnoreCase(refSer))//D-SO is required if dist_issue already created then only stock transfer will be done else if ("PZ".equalsIgnoreCase(refSer))
{
updateLocation(locationList,conn);
conn.commit();
System.out.println("Stock Transfer for PZ completed successfully and committed");
}
else if ("D-SO".equalsIgnoreCase(refSer))//D-SO is required if dist_issue already created then only stock transfer will be done
{ {
System.out.println("Stock Transfer for PZ/D-SO completed successfully and committed"); System.out.println("Stock Transfer for D-SO completed successfully and committed");
conn.commit(); conn.commit();
} }
} }
...@@ -938,95 +1002,200 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -938,95 +1002,200 @@ public class ScheduleAWMSInOutTasks implements Schedule
return tranId; return tranId;
} }
private boolean checkCountPalletReq(String refId,Connection conn) throws ITMException, Exception private ArrayList checkStockAllocation(String siteCode,String itemCode,String lotNo,String lotSl,String locCodeFrom,String locCodeTo,Connection conn) throws ITMException, Exception
{ {
boolean result = false; String sqlSordAlloc = "",sqlDisorderAlloc = "",sqlDistIss = "",locCodeReturn = "",tranId = "";
int countWms = 0; PreparedStatement pstmt = null;
int countAWms = 0;
PreparedStatement pstmt=null;
ResultSet rs = null; ResultSet rs = null;
String sql = "",scheduleStatus = ""; String sql = "",scheduleStatus = "",tableName = "",lineNo = "",refSer = "",id = "";
double quantity = 0;
boolean flag = false;
ArrayList allocLocList = new ArrayList();
try try
{ {
System.out.println("inside checkStockAllocation");
sql = "SELECT COUNT(*) AS COUNT FROM INTERFACE2 WHERE REF_ID = ?"; sql = "SELECT SALE_ORDER,LOC_CODE,QUANTITY,LINE_NO FROM SORDALLOC WHERE SITE_CODE = ? AND ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ?"
+" AND LOC_CODE = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId); pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo);
pstmt.setString(4, lotSl);
pstmt.setString(5, locCodeFrom);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) while(rs.next())
{ {
countWms = rs.getInt("COUNT"); tranId = checkNullAndTrim(rs.getString("SALE_ORDER"));
locCodeReturn = checkNullAndTrim(rs.getString("LOC_CODE"));
quantity = rs.getDouble("QUANTITY");
lineNo = checkNullAndTrim(rs.getString("LINE_NO"));
tableName = "SORDALLOC";
refSer = "S-ORD";
id = "SALE_ORDER";
flag = true;
HashMap hm = new HashMap();
hm.put("LOC_CODE_NEW", locCodeTo);
hm.put("LINE_NO", lineNo);
hm.put("TABLE", tableName);
hm.put("TRAN_ID", tranId);
hm.put("REF_SER", refSer);
hm.put("ID", id);
allocLocList.add(hm);
} }
rs.close();rs = null; rs.close();rs = null;
pstmt.close();pstmt = null; pstmt.close();pstmt = null;
sql = "SELECT COUNT(*) AS COUNT FROM INTERFACE WHERE REF_ID = ?"; sql = "SELECT D.DIST_ORDER,D.LOC_CODE,D.QUANTITY,D.LINE_NO FROM DISTORDER_ALLOC D,DISTORDER H WHERE H.SITE_CODE = ? AND D.ITEM_CODE = ? "
+ "AND D.LOT_NO = ? AND D.LOT_SL = ? AND D.LOC_CODE = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId); pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo);
pstmt.setString(4, lotSl);
pstmt.setString(5, locCodeFrom);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) while(rs.next())
{ {
countAWms = rs.getInt("COUNT"); tranId = checkNullAndTrim(rs.getString("DIST_ORDER"));
} locCodeReturn = checkNullAndTrim(rs.getString("LOC_CODE"));
rs.close();rs = null; quantity = rs.getDouble("QUANTITY");
pstmt.close();pstmt = null; lineNo = checkNullAndTrim(rs.getString("LINE_NO"));
tableName = "DISTORDER_ALLOC";
refSer = "D-SO";
id = "DIST_ORDER";
flag = true;
System.out.println("Count WMS is="+countWms); HashMap hm = new HashMap();
System.out.println("Count AWMS is="+countAWms); hm.put("LOC_CODE_NEW", locCodeTo);
hm.put("LINE_NO", lineNo);
hm.put("TABLE", tableName);
hm.put("TRAN_ID", tranId);
hm.put("REF_SER", refSer);
hm.put("ID", id);
if(countWms == countAWms) allocLocList.add(hm);
{
return true;
} }
rs.close();rs = null;
pstmt.close();pstmt = null;
/*sql = "SELECT SCHEDULE_STATUS FROM INTERFACE2 WHERE REF_ID = ?"; sql = "SELECT D.TRAN_ID,D.LOC_CODE,D.QUANTITY,D.LINE_NO FROM DISTORD_ISSDET D,DISTORD_ISS H WHERE H.SITE_CODE = ? AND D.ITEM_CODE = ? AND D.LOT_NO = ?"
+" AND D.LOT_SL = ? AND D.LOC_CODE = ? AND H.TRAN_ID = D.TRAN_ID";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId); pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo);
pstmt.setString(4, lotSl);
pstmt.setString(5, locCodeFrom);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) while(rs.next())
{ {
scheduleStatus = checkNullAndTrim(rs.getString("SCHEDULE_STATUS")); tranId = checkNullAndTrim(rs.getString("TRAN_ID"));
locCodeReturn = checkNullAndTrim(rs.getString("LOC_CODE"));
quantity = rs.getDouble("QUANTITY");
lineNo = checkNullAndTrim(rs.getString("LINE_NO"));
tableName = "DISTORD_ISSDET";
refSer = "D-SO";
id = "TRAN_ID";
flag = true;
HashMap hm = new HashMap();
hm.put("LOC_CODE_NEW", locCodeTo);
hm.put("LINE_NO", lineNo);
hm.put("TABLE", tableName);
hm.put("TRAN_ID", tranId);
hm.put("REF_SER", refSer);
hm.put("ID", id);
allocLocList.add(hm);
} }
rs.close();rs = null; rs.close();rs = null;
pstmt.close();pstmt = null; pstmt.close();pstmt = null;
if("N".equalsIgnoreCase(scheduleStatus)) /*hm.put("LOC_CODE_NEW", locCodeTo);
hm.put("LINE_NO", lineNo);
hm.put("TABLE", tableName);
hm.put("TRAN_ID", tranId);
hm.put("REF_SER", refSer);
hm.put("ID", id);*/
}
catch(Exception e)
{ {
throw new ITMException(e);
sql = "SELECT COUNT(*) AS COUNT FROM INTERFACE2 WHERE REF_ID = ?"; }
pstmt = conn.prepareStatement(sql); finally
pstmt.setString(1, refId); {
rs = pstmt.executeQuery(); try
if(rs.next())
{ {
countWms = rs.getInt("COUNT"); if(pstmt != null){pstmt.close();pstmt = null;}
if(rs != null){rs.close();rs = null;}
} }
rs.close();rs = null; catch(Exception ex)
pstmt.close();pstmt = null;
sql = "SELECT COUNT(*) AS COUNT FROM INTERFACE WHERE REF_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refId);
rs = pstmt.executeQuery();
if(rs.next())
{ {
countAWms = rs.getInt("COUNT"); throw new ITMException(ex);
} }
rs.close();rs = null; }
pstmt.close();pstmt = null; return allocLocList;
}
private String updateLocation(ArrayList locList,Connection conn) throws ITMException, Exception
{
String sqlSordAlloc = "",sqlDisorderAlloc = "",sqlDistIss = "",locCodeReturn = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "",scheduleStatus = "",tableName = "",locCode = "",refSer = "",tranId = "",id = "",lineNo = "";
double quantity = 0;
boolean flag = false;
HashMap hm = new HashMap();
String retString = "";
int updCount = 0;
try
{
System.out.println("inside updateLocation");
Iterator itr = locList.iterator();
System.out.println("Array Total size="+locList.size());
while(itr.hasNext())
{
ArrayList mainList = new ArrayList();
mainList = (ArrayList) itr.next();
Iterator itrMain = mainList.iterator();
System.out.println("Count WMS is="+countWms); System.out.println("Main Array List size="+mainList.size());
System.out.println("Count AWMS is="+countAWms); while(itrMain.hasNext())
{
HashMap detail = new HashMap();
detail = (HashMap) itrMain.next();
if(countWms == countAWms) if(detail.size() > 0)
{ {
return true; tableName = (String) detail.get("TABLE");
locCode = (String) detail.get("LOC_CODE_NEW");
lineNo = (String) detail.get("LINE_NO");
refSer = (String) detail.get("REF_SER");
tranId = (String) detail.get("TRAN_ID");
id = (String) detail.get("ID");
lineNo = " " + lineNo;
lineNo = lineNo.substring( lineNo.length()-3 );
sql = "UPDATE "+tableName+" SET LOC_CODE = ? WHERE "+id+" = ? AND LINE_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
pstmt.setString(2, tranId);
pstmt.setString(3, lineNo);
updCount = pstmt.executeUpdate();
System.out.println("Update="+updCount);
pstmt.clearParameters();
}
}
} }
}*/
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
...@@ -1041,7 +1210,7 @@ public class ScheduleAWMSInOutTasks implements Schedule ...@@ -1041,7 +1210,7 @@ public class ScheduleAWMSInOutTasks implements Schedule
throw new ITMException(ex); throw new ITMException(ex);
} }
} }
return result; return retString;
} }
/*private String callDistIssue(String tranID,String xtraParams,Connection conn) throws ITMException, Exception /*private String callDistIssue(String tranID,String xtraParams,Connection conn) throws ITMException, Exception
{ {
......
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