Commit de14acb1 authored by caluka's avatar caluka

code changed for stock_transfer table insert through master statefull ejb


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98087 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 66477102
...@@ -24,6 +24,7 @@ import ibase.webitm.ejb.dis.DistCommon; ...@@ -24,6 +24,7 @@ import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.InvAllocTraceBean; import ibase.webitm.ejb.dis.InvAllocTraceBean;
import ibase.webitm.ejb.dis.InvHoldGen; import ibase.webitm.ejb.dis.InvHoldGen;
import ibase.webitm.ejb.dis.adv.InvHoldRelConf; import ibase.webitm.ejb.dis.adv.InvHoldRelConf;
import ibase.webitm.ejb.dis.adv.StockTransferConf;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator; import ibase.webitm.utility.TransIDGenerator;
...@@ -120,7 +121,7 @@ public class NearExpirySchedule implements Schedule ...@@ -120,7 +121,7 @@ public class NearExpirySchedule implements Schedule
int count1 = 0; int count1 = 0;
//Changed by sumit sarkar on 24/06/12 END //Changed by sumit sarkar on 24/06/12 END
//Changed by sumit sarkar on 02/10/12 //Changed by sumit sarkar on 02/10/12
String holdStatus="",sql=""; String holdStatus="",sql="",sql1="",itemSer="",siteItemSer="";
int count = 0; int count = 0;
int updCnt = 0; int updCnt = 0;
int lineNo = 0; int lineNo = 0;
...@@ -140,6 +141,8 @@ public class NearExpirySchedule implements Schedule ...@@ -140,6 +141,8 @@ public class NearExpirySchedule implements Schedule
//Changed by sumit on 02/10/12 //Changed by sumit on 02/10/12
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
HashMap strAllocate = null; HashMap strAllocate = null;
...@@ -250,6 +253,7 @@ public class NearExpirySchedule implements Schedule ...@@ -250,6 +253,7 @@ public class NearExpirySchedule implements Schedule
//taking site as a login site code //taking site as a login site code
selectSql = selectSql + " AND A.SITE_CODE = '"+siteCode+"'"; selectSql = selectSql + " AND A.SITE_CODE = '"+siteCode+"'";
} }
System.out.println(" selectSql ["+selectSql+"]"); System.out.println(" selectSql ["+selectSql+"]");
//Changed by sumit sarkar on 21/06/12 insert CHECK_PHYSCAN_VALUE function in sql end. //Changed by sumit sarkar on 21/06/12 insert CHECK_PHYSCAN_VALUE function in sql end.
...@@ -344,10 +348,26 @@ public class NearExpirySchedule implements Schedule ...@@ -344,10 +348,26 @@ public class NearExpirySchedule implements Schedule
System.out.println("**********************"+stockNexpList); System.out.println("**********************"+stockNexpList);
} }
}*/ }*/
//Start Added by chandrashekar 0n 28-05-2015
if(siteCodeExpeMap.containsKey(siteCode)) //Start Added by chandrashekar on 10-06-2015
sql1 = "select item_ser from item where item_code = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, itemCode);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
itemSer = rs1.getString("item_ser") == null ?"":rs1.getString("item_ser");;
System.out.println("itemSer=== " + itemSer);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
siteItemSer = siteCode+"@"+itemSer;
if(siteCodeExpeMap.containsKey(siteItemSer))
{ {
tempList = (ArrayList) siteCodeExpeMap.get(siteCode); tempList = (ArrayList) siteCodeExpeMap.get(siteItemSer);
} }
else else
{ {
...@@ -360,7 +380,8 @@ public class NearExpirySchedule implements Schedule ...@@ -360,7 +380,8 @@ public class NearExpirySchedule implements Schedule
dataMap.put( "loc_code", locCode ); dataMap.put( "loc_code", locCode );
dataMap.put( "lot_no", lotNo ); dataMap.put( "lot_no", lotNo );
dataMap.put( "lot_sl", lotSl ); dataMap.put( "lot_sl", lotSl );
dataMap.put( "loc_code__to", dataVal1 );//expired location to which stock will be transfer dataMap.put( "loc_code__to", dataVal2 );//change by chandra shekar on 10-06-2015
//dataMap.put( "loc_code__to", dataVal1 );//expired location to which stock will be transfer
dataMap.put( "quantity", ""+quantity ); dataMap.put( "quantity", ""+quantity );
dataMap.put( "alloc_qty", ""+allocQty ); dataMap.put( "alloc_qty", ""+allocQty );
dataMap.put( "no_art", ""+noArt ); dataMap.put( "no_art", ""+noArt );
...@@ -370,13 +391,13 @@ public class NearExpirySchedule implements Schedule ...@@ -370,13 +391,13 @@ public class NearExpirySchedule implements Schedule
System.out.println("stockExpList**********************"+stockExpList); System.out.println("stockExpList**********************"+stockExpList);
//Start Added by chandrashekar 0n 28-05-2015 //Start Added by chandrashekar 0n 28-05-2015
tempList.add(dataMap); tempList.add(dataMap);
if(siteCodeExpeMap.containsKey(siteCode)) if(siteCodeExpeMap.containsKey(siteItemSer))
{ {
siteCodeExpeMap.put(siteCode,tempList); siteCodeExpeMap.put(siteItemSer,tempList);
} }
else else
{ {
siteCodeExpeMap.put(siteCode,tempList); siteCodeExpeMap.put(siteItemSer,tempList);
} }
//End Added by chandrashekar 0n 28-05-2015 //End Added by chandrashekar 0n 28-05-2015
//Changed by sumit on 02/10/12 start //Changed by sumit on 02/10/12 start
...@@ -449,6 +470,7 @@ public class NearExpirySchedule implements Schedule ...@@ -449,6 +470,7 @@ public class NearExpirySchedule implements Schedule
//taking site as a login site code //taking site as a login site code
selectSql = selectSql + " AND A.SITE_CODE = '"+siteCode+"'"; selectSql = selectSql + " AND A.SITE_CODE = '"+siteCode+"'";
} }
// otherwise for all site code. // otherwise for all site code.
System.out.println(" selectSql ["+selectSql+"]"); System.out.println(" selectSql ["+selectSql+"]");
...@@ -478,10 +500,24 @@ public class NearExpirySchedule implements Schedule ...@@ -478,10 +500,24 @@ public class NearExpirySchedule implements Schedule
acctCodeInv = rsStock.getString("ACCT_CODE__INV"); acctCodeInv = rsStock.getString("ACCT_CODE__INV");
cctrCodeInv = rsStock.getString("CCTR_CODE__INV"); cctrCodeInv = rsStock.getString("CCTR_CODE__INV");
sql1 = "select item_ser from item where item_code = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, itemCode);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
itemSer = rs1.getString("item_ser") == null ?"":rs1.getString("item_ser");;
System.out.println("itemSer=== " + itemSer);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
siteItemSer = siteCode+"@"+itemSer;
//Start Added by chandrashekar 0n 28-05-2015 //Start Added by chandrashekar 0n 28-05-2015
if(siteCodeNeExpeMap.containsKey(siteCode)) if(siteCodeNeExpeMap.containsKey(siteItemSer))
{ {
tempListNe = (ArrayList) siteCodeNeExpeMap.get(siteCode); tempListNe = (ArrayList) siteCodeNeExpeMap.get(siteItemSer);
} }
else else
{ {
...@@ -494,7 +530,8 @@ public class NearExpirySchedule implements Schedule ...@@ -494,7 +530,8 @@ public class NearExpirySchedule implements Schedule
dataMap.put( "loc_code", locCode ); dataMap.put( "loc_code", locCode );
dataMap.put( "lot_no", lotNo ); dataMap.put( "lot_no", lotNo );
dataMap.put( "lot_sl", lotSl ); dataMap.put( "lot_sl", lotSl );
dataMap.put( "loc_code__to", dataVal2 );//near expiry location to which stock will be transfer dataMap.put( "loc_code__to", dataVal1 );//Change by chandrashekar on 10-june-2015
//dataMap.put( "loc_code__to", dataVal2 );//near expiry location to which stock will be transfer
dataMap.put( "quantity", ""+quantity ); dataMap.put( "quantity", ""+quantity );
dataMap.put( "alloc_qty", ""+allocQty ); dataMap.put( "alloc_qty", ""+allocQty );
dataMap.put( "no_art", ""+noArt ); dataMap.put( "no_art", ""+noArt );
...@@ -504,13 +541,13 @@ public class NearExpirySchedule implements Schedule ...@@ -504,13 +541,13 @@ public class NearExpirySchedule implements Schedule
System.out.println("stockNexpList **********************"+stockNexpList); System.out.println("stockNexpList **********************"+stockNexpList);
//Start Added by chandrashekar 0n 28-05-2015 //Start Added by chandrashekar 0n 28-05-2015
tempListNe.add(dataMap); tempListNe.add(dataMap);
if(siteCodeNeExpeMap.containsKey(siteCode)) if(siteCodeNeExpeMap.containsKey(siteItemSer))
{ {
siteCodeNeExpeMap.put(siteCode,tempListNe); siteCodeNeExpeMap.put(siteItemSer,tempListNe);
} }
else else
{ {
siteCodeNeExpeMap.put(siteCode,tempListNe); siteCodeNeExpeMap.put(siteItemSer,tempListNe);
} }
//End Added by chandrashekar 0n 28-05-2015 //End Added by chandrashekar 0n 28-05-2015
} }
...@@ -702,7 +739,7 @@ public class NearExpirySchedule implements Schedule ...@@ -702,7 +739,7 @@ public class NearExpirySchedule implements Schedule
} }
private String updateQcOrder(String siteCode, ArrayList stockList, String xtraParams, Connection conn) private String updateQcOrder(String siteCode, ArrayList stockList, String xtraParams, Connection conn)
{ {
String errString = "", sql = "", reString = ""; String errString = "", sql = "", reString = "",qcLotsl="";
String listSiteCode = "", itemCode = "", lotNo = "", lotSl = "",qorderNo="",locCode=""; String listSiteCode = "", itemCode = "", lotNo = "", lotSl = "",qorderNo="",locCode="";
double quantity = 0d,qtyPassed=0d,qtyRejected=0d,qtySample=0d,updateQty=0d; double quantity = 0d,qtyPassed=0d,qtyRejected=0d,qtySample=0d,updateQty=0d;
ResultSet rs = null; ResultSet rs = null;
...@@ -739,14 +776,14 @@ public class NearExpirySchedule implements Schedule ...@@ -739,14 +776,14 @@ public class NearExpirySchedule implements Schedule
{ {
locCode = (String) dataMap1.get("loc_code"); locCode = (String) dataMap1.get("loc_code");
} }
sql = "select qorder_no,quantity,qty_passed,qty_rejected,qty_sample from qc_order where site_code = ? " sql = "select qorder_no,quantity,qty_passed,qty_rejected,qty_sample,lot_sl from qc_order where site_code = ? "
+ " and item_code = ? and lot_no= ? and lot_sl= ? and status='U' and loc_code= ? "; + " and item_code = ? and lot_no= ? and status='U' and loc_code= ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, listSiteCode); pstmt.setString(1, listSiteCode);
pstmt.setString(2, itemCode); pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo); pstmt.setString(3, lotNo);
pstmt.setString(4, lotSl); //pstmt.setString(4, lotSl);
pstmt.setString(5, locCode); pstmt.setString(4, locCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
...@@ -755,48 +792,101 @@ public class NearExpirySchedule implements Schedule ...@@ -755,48 +792,101 @@ public class NearExpirySchedule implements Schedule
qtyPassed = rs.getDouble("qty_passed"); qtyPassed = rs.getDouble("qty_passed");
qtyRejected = rs.getDouble("qty_rejected"); qtyRejected = rs.getDouble("qty_rejected");
qtySample = rs.getDouble("qty_sample"); qtySample = rs.getDouble("qty_sample");
qcLotsl = checkNull(rs.getString("lot_sl"));
System.out.println("qorderNo>>>>"+qorderNo); System.out.println("qorderNo>>>>"+qorderNo);
System.out.println("qcLotsl>>>>"+qcLotsl);
} }
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
rs.close(); rs.close();
rs = null; rs = null;
if(qtyPassed>0) if(qcLotsl.trim().length()>0)
{ {
updateQty=quantity-qtyPassed; if (!qcLotsl.equalsIgnoreCase(lotSl))
System.out.println("updateQty>>>>>"+updateQty); {
sql = "update qc_order set test_stat = 'X',quantity= ?,qty_passed=0 where qorder_no = ? " ; System.out.println("lot sl mismatch");
pstmt = conn.prepareStatement(sql); } else
pstmt.setDouble(1, updateQty);
pstmt.setString(2, qorderNo);
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
sql = "select count(*) as count from qc_order_lots where qc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo);
rs = pstmt.executeQuery();
if (rs.next())
{ {
cnt1 = rs.getInt(1); if (qtyPassed > 0)
{
updateQty = quantity - qtyPassed;
System.out.println("updateQty for qcLotsl>>>>>" + updateQty);
sql = "update qc_order set test_stat = 'X',quantity= ?,qty_passed=0 where qorder_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, updateQty);
pstmt.setString(2, qorderNo);
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
sql = "select count(*) as count from qc_order_lots where qc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt1 = rs.getInt(1);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
System.out.println("qc_order_lots qcLotsl count>>>>>>>>>[" + cnt1 + "]");
if (cnt1 > 0)
{
sql = "update qc_order_lots set quantity=0 where qc_order = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo);
updCnt1 = pstmt.executeUpdate();
System.out.println("updCnt1 qcLotsl>>>>>>" + updCnt1);
pstmt.close();
pstmt = null;
}
}
} }
pstmt.close(); }else
pstmt = null; {
rs.close();
rs = null; if (qtyPassed > 0)
System.out.println("qc_order_lots count>>>>>>>>>["+cnt1+"]");
if (cnt1 > 0)
{ {
updateQty = quantity - qtyPassed;
System.out.println("updateQty>>>>>" + updateQty);
sql = "update qc_order set test_stat = 'X',quantity= ?,qty_passed=0 where qorder_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, updateQty);
pstmt.setString(2, qorderNo);
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
sql = "update qc_order_lots set quantity=0 where qc_order = ? " ; sql = "select count(*) as count from qc_order_lots where qc_order=? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo); pstmt.setString(1, qorderNo);
updCnt1 = pstmt.executeUpdate(); rs = pstmt.executeQuery();
System.out.println("updCnt1>>>>>>" + updCnt1); if (rs.next())
{
cnt1 = rs.getInt(1);
}
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
rs.close();
rs = null;
System.out.println("qc_order_lots count>>>>>>>>>[" + cnt1 + "]");
if (cnt1 > 0)
{
sql = "update qc_order_lots set quantity=0 where qc_order = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo);
updCnt1 = pstmt.executeUpdate();
System.out.println("updCnt1>>>>>>" + updCnt1);
pstmt.close();
pstmt = null;
}
} }
} }
} }
...@@ -871,7 +961,11 @@ public class NearExpirySchedule implements Schedule ...@@ -871,7 +961,11 @@ public class NearExpirySchedule implements Schedule
String cctrCodeInv = ""; String cctrCodeInv = "";
String insertSql = ""; String insertSql = "";
String defReasCode = ""; String defReasCode = "";
String siteCodeItemser="";
String itemSer="";
StringBuffer xmlBuff = null;
String xmlString = null;
String errString="";
int count = 0; int count = 0;
int updCnt = 0; int updCnt = 0;
int lineNo = 0; int lineNo = 0;
...@@ -882,6 +976,7 @@ public class NearExpirySchedule implements Schedule ...@@ -882,6 +976,7 @@ public class NearExpirySchedule implements Schedule
double minSelfLife = 0d; double minSelfLife = 0d;
boolean isError = false; boolean isError = false;
boolean quantityFlag = false;
ResultSet rsStock = null; ResultSet rsStock = null;
ResultSet rsItem = null; ResultSet rsItem = null;
...@@ -890,13 +985,14 @@ public class NearExpirySchedule implements Schedule ...@@ -890,13 +985,14 @@ public class NearExpirySchedule implements Schedule
PreparedStatement pstmtHdr = null; PreparedStatement pstmtHdr = null;
PreparedStatement pstmtDet = null; PreparedStatement pstmtDet = null;
java.text.SimpleDateFormat sdf = null;
HashMap strAllocate = null; HashMap strAllocate = null;
ArrayList stockList = null; ArrayList stockList = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean(); InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
StockTransferConf stockTranConf = new StockTransferConf();
try try
{ {
DistCommon distComm = new DistCommon(); DistCommon distComm = new DistCommon();
...@@ -905,53 +1001,76 @@ public class NearExpirySchedule implements Schedule ...@@ -905,53 +1001,76 @@ public class NearExpirySchedule implements Schedule
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ); loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ); userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" ); chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
java.sql.Timestamp currDate = new java.sql.Timestamp( System.currentTimeMillis() ); //java.sql.Timestamp currDate = new java.sql.Timestamp( System.currentTimeMillis() );
java.util.Date currDate = new java.util.Date();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
java.sql.Timestamp expDateCalc = null; java.sql.Timestamp expDateCalc = null;
java.sql.Timestamp expDateStock = null; java.sql.Timestamp expDateStock = null;
//Start Added by chandrashekar on 28-05-2015
Set setItem = siteCodeNeExpeMap.entrySet(); Set setItem = siteCodeNeExpeMap.entrySet();
Iterator itrItem = setItem.iterator(); Iterator itrItem = setItem.iterator();
while(itrItem.hasNext()) while(itrItem.hasNext())
{ {
Map.Entry itemMapEntry = (Map.Entry)itrItem.next(); Map.Entry itemMapEntry = (Map.Entry)itrItem.next();
siteCode = (String)itemMapEntry.getKey(); siteCodeItemser = (String)itemMapEntry.getKey();
System.out.println("Site Code>>>>>>>>>>"+siteCode); System.out.println("siteCodeItemser>>>>>>>>>>"+siteCodeItemser);
stockList = (ArrayList)siteCodeNeExpeMap.get(siteCode); stockList = (ArrayList)siteCodeNeExpeMap.get(siteCodeItemser);
if(siteCodeItemser.split("@").length != 0)
//insertSql = "INSERT INTO STOCK_TRANSFER(TRAN_ID, TRAN_DATE, SITE_CODE, REF_SER__FOR, CONFIRMED, CHG_DATE, CHG_TERM, CHG_USER, SITE_CODE__FR, SITE_CODE__TO, REAS_CODE) VALUES(?,?,?,?,?,?,?,?,?,?,?)"; {
insertSql = "INSERT INTO STOCK_TRANSFER(TRAN_ID, TRAN_DATE, SITE_CODE, REF_SER__FOR, CONFIRMED, CHG_DATE, CHG_TERM, CHG_USER, REAS_CODE) VALUES(?,?,?,?,?,?,?,?,?)";//Change by chandrashekar on 27-05-2015 siteCode = checkNull(siteCodeItemser.split("@")[0]);
pstmtHdr = conn.prepareStatement(insertSql); itemSer = checkNull(siteCodeItemser.split("@")[1]);
}
insertSql = "INSERT INTO STOCK_TRANSFER_DET(TRAN_ID, LINE_NO, ITEM_CODE, QUANTITY, LOC_CODE__FR, LOC_CODE__TO, LOT_NO__FR, LOT_NO__TO, LOT_SL__FR, LOT_SL__TO, ACCT_CODE__CR, ACCT_CODE__DR, CCTR_CODE__DR, CCTR_CODE__CR, NO_ART) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtDet = conn.prepareStatement(insertSql); xmlBuff = null;
xmlBuff = new StringBuffer();
//generate the tran id for w_stock_transfer xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
tranID = generateTranId( "w_stock_transfer", conn ); xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
//Insert into header table i.e stock_transfer xmlBuff.append("<group0>");
pstmtHdr.setString( 1, tranID ); xmlBuff.append("<description>").append("Group0 description").append("</description>");
pstmtHdr.setTimestamp( 2, currDate ); xmlBuff.append("<Header0>");
//pstmtHdr.setString( 3, loginSiteCode ); xmlBuff.append("<objName><![CDATA[").append("stock_transfer").append("]]></objName>");//change done by kunal on 22/03/13 change obj name
pstmtHdr.setString( 3, siteCode ); xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
pstmtHdr.setString( 4, "XFRX" ); xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
pstmtHdr.setString( 5, "N" ); xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
pstmtHdr.setTimestamp( 6, currDate ); xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
pstmtHdr.setString( 7, chgTerm ); xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
pstmtHdr.setString( 8, userId ); xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
//pstmtHdr.setString( 9, siteCode ); xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
//pstmtHdr.setString( 10, siteCode ); xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
pstmtHdr.setString( 9, defReasCode ); xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
updCnt = pstmtHdr.executeUpdate(); xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
pstmtHdr.close(); xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
pstmtHdr = null; xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"stock_transfer\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
System.out.println("current Date>>>>>>"+sdf.format(currDate).toString());
xmlBuff.append("<tran_date><![CDATA["+ sdf.format(currDate).toString() +"]]></tran_date>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
xmlBuff.append("<ref_ser__for><![CDATA["+"XFRX" +"]]></ref_ser__for>");
xmlBuff.append("<ref_id__for><![CDATA[]]></ref_id__for>");
xmlBuff.append("<reas_code><![CDATA["+ defReasCode+"]]></reas_code>");
xmlBuff.append("<item_ser><![CDATA["+ itemSer +"]]></item_ser>");
xmlBuff.append("<confirmed><![CDATA["+"N" +"]]></confirmed>");
xmlBuff.append("<conf_date><![CDATA[]]></conf_date>");
xmlBuff.append("<emp_code__aprv><![CDATA[]]></emp_code__aprv>");
xmlBuff.append("<chg_user><![CDATA[" + userId + "]]></chg_user>");
xmlBuff.append("<chg_term><![CDATA[" + chgTerm + "]]></chg_term>");
xmlBuff.append("<chg_date><![CDATA["+ sdf.format(currDate).toString() + "]]></chg_date>");
xmlBuff.append("<tran_type><![CDATA[]]></tran_type>");
xmlBuff.append("<truck_no><![CDATA[]]></truck_no>");
xmlBuff.append("<ref_date><![CDATA[]]></ref_date>");
xmlBuff.append("</Detail1>");
lineNo = 0;
for ( int ctr = 0; ctr < stockList.size(); ctr++ ) for ( int ctr = 0; ctr < stockList.size(); ctr++ )
{ {
lineNo++; lineNo++;
HashMap dataMap = null; HashMap dataMap = null;
dataMap = (HashMap) stockList.get(ctr); dataMap = (HashMap) stockList.get(ctr);
itemCode = ""; itemCode = "";
siteCode = ""; siteCode = "";
locCode = ""; locCode = "";
...@@ -964,10 +1083,15 @@ public class NearExpirySchedule implements Schedule ...@@ -964,10 +1083,15 @@ public class NearExpirySchedule implements Schedule
quantity = 0d; quantity = 0d;
allocQty = 0d; allocQty = 0d;
noArt = 0d; noArt = 0d;
System.out.println("lineNo>>>>>>"+lineNo);
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"stock_transfer\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<line_no>" + lineNo + "</line_no>");
if (dataMap.get("item_code") != null) if (dataMap.get("item_code") != null)
{ {
itemCode = (String) dataMap.get("item_code"); xmlBuff.append("<item_code><![CDATA["+ (String)dataMap.get("item_code") +"]]></item_code>");
} }
if (dataMap.get("site_code") != null) if (dataMap.get("site_code") != null)
{ {
...@@ -975,19 +1099,21 @@ public class NearExpirySchedule implements Schedule ...@@ -975,19 +1099,21 @@ public class NearExpirySchedule implements Schedule
} }
if (dataMap.get("loc_code") != null) if (dataMap.get("loc_code") != null)
{ {
locCode = (String) dataMap.get("loc_code"); xmlBuff.append("<loc_code__fr><![CDATA["+ (String)dataMap.get("loc_code") +"]]></loc_code__fr>");
} }
if (dataMap.get("loc_code__to") != null) if (dataMap.get("loc_code__to") != null)
{ {
locCodeTo = (String) dataMap.get("loc_code__to"); xmlBuff.append("<loc_code__to><![CDATA["+ (String)dataMap.get("loc_code__to") +"]]></loc_code__to>");
} }
if (dataMap.get("lot_no") != null) if (dataMap.get("lot_no") != null)
{ {
lotNo = (String) dataMap.get("lot_no"); xmlBuff.append("<lot_no__fr><![CDATA["+ (String)dataMap.get("lot_no") +"]]></lot_no__fr>");
xmlBuff.append("<lot_no__to><![CDATA["+ (String)dataMap.get("lot_no") +"]]></lot_no__to>");
} }
if (dataMap.get("lot_sl") != null) if (dataMap.get("lot_sl") != null)
{ {
lotSl = (String) dataMap.get("lot_sl"); xmlBuff.append("<lot_sl__fr><![CDATA["+ (String)dataMap.get("lot_sl") +"]]></lot_sl__fr>");
xmlBuff.append("<lot_sl__to><![CDATA["+ (String)dataMap.get("lot_sl") +"]]></lot_sl__to>");
} }
if (dataMap.get("quantity") != null) if (dataMap.get("quantity") != null)
{ {
...@@ -997,109 +1123,47 @@ public class NearExpirySchedule implements Schedule ...@@ -997,109 +1123,47 @@ public class NearExpirySchedule implements Schedule
{ {
allocQty = Double.parseDouble(dataMap.get("alloc_qty").toString()); allocQty = Double.parseDouble(dataMap.get("alloc_qty").toString());
} }
xmlBuff.append("<quantity><![CDATA["+ (quantity - allocQty) +"]]></quantity>");
if (dataMap.get("no_art") != null) if (dataMap.get("no_art") != null)
{ {
noArt = Double.parseDouble(dataMap.get("no_art").toString()); noArt = Double.parseDouble(dataMap.get("no_art").toString());
xmlBuff.append("<no_art><![CDATA["+ noArt +"]]></no_art>");
} }
if (dataMap.get("acct_code__inv") != null) if (dataMap.get("acct_code__inv") != null)
{ {
acctCodeInv = (String) dataMap.get("acct_code__inv"); xmlBuff.append("<acct_code__cr><![CDATA["+ (String)dataMap.get("acct_code__inv") +"]]></acct_code__cr>");
xmlBuff.append("<acct_code__dr><![CDATA["+ (String)dataMap.get("acct_code__inv") +"]]></acct_code__dr>");
} }
if (dataMap.get("cctr_code__inv") != null) if (dataMap.get("cctr_code__inv") != null)
{ {
cctrCodeInv = (String) dataMap.get("cctr_code__inv"); xmlBuff.append("<cctr_code__dr><![CDATA["+ (String)dataMap.get("cctr_code__inv") +"]]></cctr_code__dr>");
} xmlBuff.append("<cctr_code__cr><![CDATA["+ (String)dataMap.get("cctr_code__inv") +"]]></cctr_code__cr>");
pstmtDet.setString(1, tranID);
pstmtDet.setInt(2, lineNo);
pstmtDet.setString(3, itemCode);
pstmtDet.setDouble(4, (quantity - allocQty));
pstmtDet.setString(5, locCode);
pstmtDet.setString(6, locCodeTo);// expired / Near Expiry
// location to which stock
// will be transfer
pstmtDet.setString(7, lotNo);
pstmtDet.setString(8, lotNo);
pstmtDet.setString(9, lotSl);
pstmtDet.setString(10, lotSl);
pstmtDet.setString(11, acctCodeInv);
pstmtDet.setString(12, acctCodeInv);
pstmtDet.setString(13, cctrCodeInv);
pstmtDet.setString(14, cctrCodeInv);
pstmtDet.setDouble(15, noArt);
pstmtDet.addBatch();
pstmtDet.clearParameters();
dataMap.clear();
strAllocate = new HashMap();
strAllocate.put("tran_date", currDate);
strAllocate.put("ref_ser", "XFRX");
strAllocate.put("ref_id", tranID);
strAllocate.put("ref_line", "" + lineNo);
strAllocate.put("site_code", siteCode);
strAllocate.put("item_code", itemCode);
strAllocate.put("loc_code", locCode);
strAllocate.put("lot_no", lotNo);
strAllocate.put("lot_sl", lotSl);
strAllocate.put("alloc_qty", new Double(quantity));
strAllocate.put("chg_user", userId);
strAllocate.put("chg_term", chgTerm);
// strAllocate.put("chg_win","w_stock_transfer");
strAllocate.put("chg_win", "W_STOCK_TRANSFER_MULTI");// change
// by
// chandrashekar
// on
// 27-05-2015
retString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
strAllocate = null;
System.out.println("retString ::: " + retString);
if (retString != null && retString.trim().length() > 0)
{
isError = true;
retString = "ERROR";
return retString;
} }
xmlBuff.append("</Detail2>");
} }
pstmtDet.executeBatch(); xmlBuff.append("</Header0>");
pstmtDet.clearBatch(); xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
}//End Added by chandrashekar on 28-05-2015
} xmlString = xmlBuff.toString();
catch(BatchUpdateException buex)
{ retString = saveData(siteCode,xmlString,conn);
isError = true; System.out.println("retString>>>>>>"+retString);
retString = "ERROR"; if (retString.indexOf("Success") > -1)
int [] updateCounts = buex.getUpdateCounts(); {
for (int i = 0; i < updateCounts.length; i++) String[] arrayForTranId = retString.split("<TranID>");
{ int endIndex = arrayForTranId[1].indexOf("</TranID>");
System.err.println(" Statement " + i + ":" + updateCounts[i]); System.out.println("***********going for confirmation************");
} String tranIdForIssue = arrayForTranId[1].substring(0, endIndex);
System.err.println(" Message: " + buex.getMessage()); System.out.println("tranIdForIssue" + tranIdForIssue);
System.err.println(" SQLSTATE: " + buex.getSQLState());
System.err.println(" Error code: " + buex.getErrorCode()); retString = stockTranConf.confirm(tranIdForIssue, xtraParams, "", conn,false);
SQLException ex = buex.getNextException(); System.out.println("=====Its Confirmed=====");
while (ex != null) System.out.println("retString from conf ::" + retString);
{ }
System.err.println("SQL exception:");
System.err.println(" Message: " + ex.getMessage());
System.err.println(" SQLSTATE: " + ex.getSQLState());
System.err.println(" Error code: " + ex.getErrorCode());
ex = ex.getNextException();
}
}
catch(SQLException se)
{
isError = true;
retString = "ERROR";
System.out.println("Exception : NearExpiryPrc : process()" +se.getMessage());
try
{
conn.rollback();
} }
catch(Exception se1){}
//throw new ITMException(se);
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -1117,8 +1181,7 @@ public class NearExpirySchedule implements Schedule ...@@ -1117,8 +1181,7 @@ public class NearExpirySchedule implements Schedule
{ {
try try
{ {
invAllocTrace = null; System.out.println("isError>>>>>>>>"+isError);
strAllocate = null;
if ( isError ) if ( isError )
{ {
System.out.println("ROLLBACK the changes......"); System.out.println("ROLLBACK the changes......");
...@@ -1126,38 +1189,13 @@ public class NearExpirySchedule implements Schedule ...@@ -1126,38 +1189,13 @@ public class NearExpirySchedule implements Schedule
retString = "ERROR"; retString = "ERROR";
} }
System.out.println("Closing Database Connection......"); System.out.println("Closing Database Connection......");
if (rsItem != null) }
{ catch(Exception e)
rsItem.close(); {
rsItem = null; e.printStackTrace();
} throw new ITMException(e);
if (pstmtItem != null) }
{
pstmtItem.close();
pstmtItem = null;
}
if (rsStock != null)
{
rsStock.close();
rsStock = null;
}
if (pstmtStock != null)
{
pstmtStock.close();
pstmtStock = null;
}
if (pstmtHdr != null)
{
pstmtHdr.close();
pstmtHdr = null;
}
if (pstmtDet != null)
{
pstmtDet.close();
pstmtDet = null;
}
}catch(Exception se){}
} }
System.out.println("retString........:: " + retString); System.out.println("retString........:: " + retString);
return retString; return retString;
...@@ -2107,6 +2145,30 @@ private String checkNull(String input) ...@@ -2107,6 +2145,30 @@ private String checkNull(String input)
} }
return tranId; return tranId;
}//generateTranTd() }//generateTranTd()
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn);
}
catch(Exception e)
{
System.out.println("Exception :CreateDistOrder :saveData :==>");
throw new ITMException(e);
}
return retString;
}
//Changed by sumit on 02/10/12 modified code as per process end //Changed by sumit on 02/10/12 modified code as per process 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