Commit 6b481ecb authored by caluka's avatar caluka

change message when scheduler execution fails


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98102 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8f3c1ccb
...@@ -53,6 +53,7 @@ public class NearExpirySchedule implements Schedule ...@@ -53,6 +53,7 @@ public class NearExpirySchedule implements Schedule
String chgTerm = null; String chgTerm = null;
static long count_records=0; static long count_records=0;
boolean isError = false; boolean isError = false;
boolean isInsert = false;
public String schedulePriority( String wrkflwPriority )throws Exception public String schedulePriority( String wrkflwPriority )throws Exception
{ {
...@@ -121,7 +122,7 @@ public class NearExpirySchedule implements Schedule ...@@ -121,7 +122,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="",sql1="",itemSer="",siteItemSer=""; String holdStatus="",sql="",sql1="",itemSer="",siteItemSer="",remarksFlag="";
int count = 0; int count = 0;
int updCnt = 0; int updCnt = 0;
int lineNo = 0; int lineNo = 0;
...@@ -571,6 +572,7 @@ public class NearExpirySchedule implements Schedule ...@@ -571,6 +572,7 @@ public class NearExpirySchedule implements Schedule
if ( stockExpList.size() > 0 && count > 0) if ( stockExpList.size() > 0 && count > 0)
{ {
System.out.println("Calling EXPIRED-------------------->"); System.out.println("Calling EXPIRED-------------------->");
isInsert=true;
//Changed by Rohan on 3/7/12 //Changed by Rohan on 3/7/12
//retString = holdGen.generateHoldTrans( dataVal1, "EXPIRED","EXP", siteCode, stockExpList, "", conn ); //retString = holdGen.generateHoldTrans( dataVal1, "EXPIRED","EXP", siteCode, stockExpList, "", conn );
...@@ -613,6 +615,7 @@ public class NearExpirySchedule implements Schedule ...@@ -613,6 +615,7 @@ public class NearExpirySchedule implements Schedule
if ( stockNexpList.size() > 0 && count1 > 0 ) if ( stockNexpList.size() > 0 && count1 > 0 )
{ {
System.out.println("going to insert in inv_hold for NEAREXPIRY----> "); System.out.println("going to insert in inv_hold for NEAREXPIRY----> ");
isInsert=true;
//Changed by Rohan on 3/7/12 //Changed by Rohan on 3/7/12
//retString = holdGen.generateHoldTrans( dataVal2, "NEAREXPIRY","NEXP", siteCode, stockNexpList, "", conn ); //retString = holdGen.generateHoldTrans( dataVal2, "NEAREXPIRY","NEXP", siteCode, stockNexpList, "", conn );
retString = holdGen.generateHoldTrans( dataVal1, "NEAREXPIRY","NEXP", siteCode, stockNexpList, "", conn ); retString = holdGen.generateHoldTrans( dataVal1, "NEAREXPIRY","NEXP", siteCode, stockNexpList, "", conn );
...@@ -627,8 +630,9 @@ public class NearExpirySchedule implements Schedule ...@@ -627,8 +630,9 @@ public class NearExpirySchedule implements Schedule
{ {
if ( stockExpList.size() > 0 && count > 0 ) if ( stockExpList.size() > 0 && count > 0 )
{ {
remarksFlag="EXPR";
//retString = inventoryTransfer( stockExpList, "w_stock_transfer", xtraParams, conn ); //retString = inventoryTransfer( stockExpList, "w_stock_transfer", xtraParams, conn );
retString = inventoryTransfer( siteCodeExpeMap, "w_stock_transfer", xtraParams, conn );//Change by chandrashekar 0n 28-05-2015 retString = inventoryTransfer( siteCodeExpeMap, "w_stock_transfer", xtraParams, remarksFlag,conn );//Change by chandrashekar 0n 28-05-2015
} }
if ( retString != null && retString.trim().length() > 0 && retString.trim().equalsIgnoreCase("ERROR") ) if ( retString != null && retString.trim().length() > 0 && retString.trim().equalsIgnoreCase("ERROR") )
...@@ -639,9 +643,9 @@ public class NearExpirySchedule implements Schedule ...@@ -639,9 +643,9 @@ public class NearExpirySchedule implements Schedule
if ( stockNexpList.size() > 0 && count1 > 0) if ( stockNexpList.size() > 0 && count1 > 0)
{ {
remarksFlag="NEXP";
//retString = inventoryTransfer( stockNexpList, "w_stock_transfer", xtraParams, conn ); //retString = inventoryTransfer( stockNexpList, "w_stock_transfer", xtraParams, conn );
retString = inventoryTransfer( siteCodeNeExpeMap, "w_stock_transfer", xtraParams, conn );//Change by chandrashekar 0n 28-05-2015 retString = inventoryTransfer( siteCodeNeExpeMap, "w_stock_transfer", xtraParams,remarksFlag, conn );//Change by chandrashekar 0n 28-05-2015
} }
if ( retString != null && retString.trim().length() > 0 && retString.trim().equalsIgnoreCase("ERROR") ) if ( retString != null && retString.trim().length() > 0 && retString.trim().equalsIgnoreCase("ERROR") )
...@@ -682,11 +686,13 @@ public class NearExpirySchedule implements Schedule ...@@ -682,11 +686,13 @@ public class NearExpirySchedule implements Schedule
invAllocTrace = null; invAllocTrace = null;
//Changed by sumit on 05/07/12 change the condition. //Changed by sumit on 05/07/12 change the condition.
//if ( count == 0 ) //if ( count == 0 )
System.out.println("isInsert flag>>>>>"+isInsert);
if ( count == 0 && count1 == 0) if ( count == 0 && count1 == 0)
{ {
retString = itmDBAccess.getErrorString("","NODATAERR",""); retString = itmDBAccess.getErrorString("","NODATAERR","");
} }
else if ( !isError ) else if ( !isError && isInsert )
{ {
System.out.println("COMMITING the changes......"); System.out.println("COMMITING the changes......");
conn.commit(); conn.commit();
...@@ -730,7 +736,7 @@ public class NearExpirySchedule implements Schedule ...@@ -730,7 +736,7 @@ public class NearExpirySchedule implements Schedule
return retString; return retString;
} }
public String inventoryTransfer( HashMap<String , ArrayList<String>> siteCodeNeExpeMap, String windowName,String xtraParams, Connection conn ) throws RemoteException,ITMException public String inventoryTransfer( HashMap<String , ArrayList<String>> siteCodeNeExpeMap, String windowName,String xtraParams,String remarksFlag, Connection conn ) throws RemoteException,ITMException
{ {
String salesPerson = ""; String salesPerson = "";
String itemCode = ""; String itemCode = "";
...@@ -859,7 +865,7 @@ public class NearExpirySchedule implements Schedule ...@@ -859,7 +865,7 @@ public class NearExpirySchedule implements Schedule
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 = "";
...@@ -874,42 +880,6 @@ public class NearExpirySchedule implements Schedule ...@@ -874,42 +880,6 @@ 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)
{
itemCode=(String) dataMap.get("item_code");
xmlBuff.append("<item_code><![CDATA["+ (String)dataMap.get("item_code") +"]]></item_code>");
}
if (dataMap.get("site_code") != null)
{
siteCode = (String) dataMap.get("site_code");
}
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)
{
xmlBuff.append("<loc_code__to><![CDATA["+ (String)dataMap.get("loc_code__to") +"]]></loc_code__to>");
}
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)
{
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)
{ {
quantity = Double.parseDouble(dataMap.get("quantity").toString()); quantity = Double.parseDouble(dataMap.get("quantity").toString());
...@@ -918,24 +888,65 @@ public class NearExpirySchedule implements Schedule ...@@ -918,24 +888,65 @@ 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((quantity - allocQty)>0)
if (dataMap.get("no_art") != null)
{ {
noArt = Double.parseDouble(dataMap.get("no_art").toString()); lineNo++;
xmlBuff.append("<no_art><![CDATA["+ noArt +"]]></no_art>"); xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"stock_transfer\" objContext=\"2\">");
} xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
if (dataMap.get("acct_code__inv") != null) xmlBuff.append("<tran_id/>");
{ xmlBuff.append("<line_no>" + lineNo + "</line_no>");
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("item_code") != null)
} {
if (dataMap.get("cctr_code__inv") != null) itemCode = (String) dataMap.get("item_code");
{ xmlBuff.append("<item_code><![CDATA[" + (String) dataMap.get("item_code") + "]]></item_code>");
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>"); if (dataMap.get("site_code") != null)
{
siteCode = (String) dataMap.get("site_code");
}
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)
{
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)
{
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)
{
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>");
}
xmlBuff.append("<quantity><![CDATA[" + (quantity - allocQty) + "]]></quantity>");
if (dataMap.get("no_art") != null)
{
noArt = Double.parseDouble(dataMap.get("no_art").toString());
xmlBuff.append("<no_art><![CDATA[" + noArt + "]]></no_art>");
}
if (dataMap.get("acct_code__inv") != null)
{
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)
{
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>");
}
xmlBuff.append("</Detail2>");
} }
xmlBuff.append("</Detail2>");
} }
xmlBuff.append("</Header0>"); xmlBuff.append("</Header0>");
xmlBuff.append("</group0>"); xmlBuff.append("</group0>");
...@@ -958,7 +969,8 @@ public class NearExpirySchedule implements Schedule ...@@ -958,7 +969,8 @@ public class NearExpirySchedule implements Schedule
System.out.println("retString from conf ::" + retString); System.out.println("retString from conf ::" + retString);
if (retString.indexOf("CONFSUCC") > -1) if (retString.indexOf("CONFSUCC") > -1)
{ {
retString=updateQcOrder(siteCode,itemCode,lotNo,locCode,lotSl,conn); isInsert =true;
retString=updateQcOrder(stockList,siteCode,itemCode,lotNo,locCode,lotSl,remarksFlag,locCodeTo,conn);
} }
} }
...@@ -999,99 +1011,91 @@ public class NearExpirySchedule implements Schedule ...@@ -999,99 +1011,91 @@ public class NearExpirySchedule implements Schedule
System.out.println("retString........:: " + retString); System.out.println("retString........:: " + retString);
return retString; return retString;
} }
private String updateQcOrder(String siteCode, String itemCode,String lotNo, String locCode,String lotSl,Connection conn) private String updateQcOrder( ArrayList stockList,String siteCode, String itemCode,String lotNo, String locCode,String lotSl,String remarksFlag,String locCodeTo,Connection conn)
{ {
String errString = "", sql = "", reString = "",qcLotsl=""; String errString = "", sql = "", reString = "",qcLotsl="";
String listSiteCode = "",qorderNo=""; String listSiteCode = "",qorderNo="",remarks="";
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;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
int updCnt1=0,updCnt=0,cnt1=0; int updCnt1=0,updCnt=0,cnt1=0;
DistCommon distComm = new DistCommon();
try try
{ {
sql = "select qorder_no,quantity,qty_passed,qty_rejected,qty_sample,lot_sl from qc_order where site_code = ? " for ( int ctr = 0; ctr < stockList.size(); ctr++ )
//+ " and item_code = ? and lot_no= ? and status='U' and loc_code= ? "; {
+ " and item_code = ? and lot_no= ? and status='U' "; HashMap dataMap2 = null;
pstmt = conn.prepareStatement(sql); dataMap2 = (HashMap) stockList.get(ctr);
pstmt.setString(1, siteCode); itemCode = "";
pstmt.setString(2, itemCode); siteCode = "";
pstmt.setString(3, lotNo); locCode = "";
//pstmt.setString(4, lotSl); lotNo = "";
//pstmt.setString(4, locCode); lotSl = "";
rs = pstmt.executeQuery(); locCodeTo = "";
if (rs.next()) remarks="";
{ quantity = 0d;
qorderNo = rs.getString("qorder_no"); qtyPassed=0d;
quantity = rs.getDouble("quantity"); if (dataMap2.get("item_code") != null)
qtyPassed = rs.getDouble("qty_passed"); {
qtyRejected = rs.getDouble("qty_rejected"); itemCode = (String) dataMap2.get("item_code");
qtySample = rs.getDouble("qty_sample"); }
qcLotsl = checkNull(rs.getString("lot_sl")); if (dataMap2.get("site_code") != null)
{
System.out.println("qorderNo>>>>"+qorderNo); siteCode = (String) dataMap2.get("site_code");
System.out.println("qcLotsl>>>>"+qcLotsl); }
} if (dataMap2.get("lot_no") != null)
pstmt.close(); {
pstmt = null; lotNo = (String) dataMap2.get("lot_no");
rs.close(); }
rs = null; if (dataMap2.get("loc_code__to") != null)
if(qcLotsl.trim().length()>0) {
locCodeTo=(String)dataMap2.get("loc_code__to");
}
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 status='U' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo);
rs = pstmt.executeQuery();
if (rs.next())
{
qorderNo = rs.getString("qorder_no");
quantity = rs.getDouble("quantity");
qtyPassed = rs.getDouble("qty_passed");
qtyRejected = rs.getDouble("qty_rejected");
qtySample = rs.getDouble("qty_sample");
qcLotsl = checkNull(rs.getString("lot_sl"));
System.out.println("qorderNo>>>>" + qorderNo);
System.out.println("qcLotsl>>>>" + qcLotsl);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (qcLotsl.trim().length() > 0)
{
if (!qcLotsl.equalsIgnoreCase(lotSl))
{ {
if (!qcLotsl.equalsIgnoreCase(lotSl)) System.out.println("lot sl mismatch");
{ } else
System.out.println("lot sl mismatch");
} else
{
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;
}
}
}
}else
{ {
if (qtyPassed > 0) if (qtyPassed > 0)
{ {
updateQty = quantity - qtyPassed; updateQty = quantity - qtyPassed;
System.out.println("updateQty>>>>>" + updateQty); if ("EXPR".equalsIgnoreCase(remarksFlag))
sql = "update qc_order set test_stat = 'X',quantity= ?,qty_passed=0 where qorder_no = ? "; {
remarks = "Expired material transferred to " + locCodeTo + " location";
} else
{
remarks = "Near expired material transferred to " + locCodeTo + " location";
}
sql = "update qc_order set test_stat = 'X',quantity= ?,qty_passed=0 ,remarks=? where qorder_no = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, updateQty); pstmt.setDouble(1, updateQty);
pstmt.setString(2, qorderNo); pstmt.setString(2, remarks);
pstmt.setString(3, qorderNo);
updCnt = pstmt.executeUpdate(); updCnt = pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
...@@ -1109,7 +1113,7 @@ public class NearExpirySchedule implements Schedule ...@@ -1109,7 +1113,7 @@ public class NearExpirySchedule implements Schedule
rs.close(); rs.close();
rs = null; rs = null;
System.out.println("qc_order_lots count>>>>>>>>>[" + cnt1 + "]"); System.out.println("qc_order_lots qcLotsl count>>>>>>>>>[" + cnt1 + "]");
if (cnt1 > 0) if (cnt1 > 0)
{ {
...@@ -1117,12 +1121,61 @@ public class NearExpirySchedule implements Schedule ...@@ -1117,12 +1121,61 @@ public class NearExpirySchedule implements Schedule
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo); pstmt.setString(1, qorderNo);
updCnt1 = pstmt.executeUpdate(); updCnt1 = pstmt.executeUpdate();
System.out.println("updCnt1>>>>>>" + updCnt1); System.out.println("updCnt1 qcLotsl>>>>>>" + updCnt1);
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
} }
} else
{
if (qtyPassed > 0)
{
updateQty = quantity - qtyPassed;
if ("EXPR".equalsIgnoreCase(remarksFlag))
{
remarks = "Expired material transferred to " + locCodeTo + " location";
} else
{
remarks = "Near expired material transferred to " + locCodeTo + " location";
}
sql = "update qc_order set test_stat = 'X',quantity= ?,qty_passed=0,remarks=? where qorder_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, updateQty);
pstmt.setString(2, remarks);
pstmt.setString(3, 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;
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;
}
}
}
}
} catch (Exception e) } catch (Exception e)
{ {
......
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