Commit 8d0c97ca authored by sshinde's avatar sshinde

Add new new functionallity on dated 28062013


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93300 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c50bd4a1
...@@ -16,26 +16,26 @@ import javax.naming.InitialContext; ...@@ -16,26 +16,26 @@ import javax.naming.InitialContext;
import javax.ejb.Stateless; import javax.ejb.Stateless;
@Stateless @Stateless
public class RequirementIC extends ValidatorEJB implements RequirementICLocal, RequirementICRemote // SessionBean
public class RequirementIC extends ValidatorEJB implements RequirementICLocal,RequirementICRemote //SessionBean
{ {
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
SimpleDateFormat simpleDateFormat = null; SimpleDateFormat simpleDateFormat = null;
public String wfValData() throws RemoteException,ITMException public String wfValData() throws RemoteException, ITMException
{ {
System.out.println("wfValData()..."); System.out.println("wfValData()...");
return ""; return "";
} }
// Item Change // Item Change
public String itemChanged() throws RemoteException,ITMException public String itemChanged() throws RemoteException, ITMException
{ {
System.out.println("itemChanged Called..."); System.out.println("itemChanged Called...");
return ""; return "";
} }
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{ {
Document dom = null; Document dom = null;
...@@ -45,42 +45,43 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -45,42 +45,43 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
try try
{ {
System.out.println("xmlString.........::"+xmlString); System.out.println("xmlString.........::" + xmlString);
System.out.println("xmlString1.........::"+xmlString1); System.out.println("xmlString1.........::" + xmlString1);
System.out.println("xmlString2.........::"+xmlString2); System.out.println("xmlString2.........::" + xmlString2);
if (xmlString != null && xmlString.trim().length()!=0) if (xmlString != null && xmlString.trim().length() != 0)
{ {
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
} }
if (xmlString1 != null && xmlString1.trim().length()!=0) if (xmlString1 != null && xmlString1.trim().length() != 0)
{ {
dom1 = genericUtility.parseString(xmlString1); dom1 = genericUtility.parseString(xmlString1);
} }
if (xmlString2 != null && xmlString2.trim().length()!=0) if (xmlString2 != null && xmlString2.trim().length() != 0)
{ {
dom2 = genericUtility.parseString(xmlString2); dom2 = genericUtility.parseString(xmlString2);
} }
errString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams); errString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
} } catch (Exception e)
catch (Exception e)
{ {
System.out.println ("Exception :ProcessControlEJB :itemChanged(String,String):" + e.getMessage() + ":"); System.out.println("Exception :ProcessControlEJB :itemChanged(String,String):" + e.getMessage() + ":");
errString = genericUtility.createErrorString(e); errString = genericUtility.createErrorString(e);
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println ("returning from ProcessControlEJB itemChanged"); System.out.println("returning from ProcessControlEJB itemChanged");
return errString; return errString;
} }
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{ {
String loginSiteCode = ""; String loginSiteCode = "";
String sql = ""; String sql = "";
String columnValue = ""; String columnValue = "";
String userId = ""; String userId = "";
String errString=""; String errString = "";
Connection conn = null; Connection conn = null;
Statement stmt = null; Statement stmt = null;
ResultSet rs = null; ResultSet rs = null;
int lineNo = 0;
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0; int currentFormNo = 0;
...@@ -129,6 +130,9 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -129,6 +130,9 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
double quantity = 0d; double quantity = 0d;
double yieldPerc = 0d; double yieldPerc = 0d;
String winName = ""; // Added by sachin on 26/6/13
double batchReq = 0d;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
try try
{ {
...@@ -138,13 +142,13 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -138,13 +142,13 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
connDriver = null; connDriver = null;
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"); loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
columnValue = genericUtility.getColumnValue(currentColumn,dom); columnValue = genericUtility.getColumnValue(currentColumn, dom);
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
...@@ -154,7 +158,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -154,7 +158,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
{ {
case 1: case 1:
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
if(currentColumn.trim().equals("itm_default")) if (currentColumn.trim().equals("itm_default"))
{ {
valueXmlString.append("<site_code__fr>").append(loginSiteCode).append("</site_code__fr>"); valueXmlString.append("<site_code__fr>").append(loginSiteCode).append("</site_code__fr>");
valueXmlString.append("<site_code__to>").append(loginSiteCode).append("</site_code__to>"); valueXmlString.append("<site_code__to>").append(loginSiteCode).append("</site_code__to>");
...@@ -162,67 +166,80 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -162,67 +166,80 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
break; break;
case 2: case 2:
if(currentColumn.trim().equals("itm_default")) if (currentColumn.trim().equals("itm_default"))
{ {
int detCnt = 0; int detCnt = 0;
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom1); siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1); siteCodeTo = genericUtility.getColumnValue("site_code__to", dom1);
/*
* "SELECT A.TRAN_ID, A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.QUANTITY, A.DUE_DATE, A.UNIT, A.YIELD_PERC "
* + "FROM MPS_ORDER A, ITEM B "+
* "WHERE ( A.ITEM_CODE = B.ITEM_CODE (+)) " +
* "AND A.SITE_CODE >= ? AND A.SITE_CODE <= ? "+
* "AND A.STATUS IN ('P','T','M')";
*/
selectSql = "SELECT A.TRAN_ID, A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.QUANTITY, A.DUE_DATE, A.UNIT, A.YIELD_PERC " + /* Change By Sachin on 26/6/2013 */
"FROM MPS_ORDER A, ITEM B "+
"WHERE ( A.ITEM_CODE = B.ITEM_CODE (+)) " + selectSql = "SELECT A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.UNIT, C.BATCH_QTY, SUM(A.QUANTITY) AS QUANTITY " + "FROM MPS_ORDER A, ITEM B ,BOM C " + "WHERE ( A.ITEM_CODE = B.ITEM_CODE (+)) " + "AND A.SITE_CODE >= ? AND A.SITE_CODE <=? " + "AND A.STATUS IN ('P','T','M') " + "AND A.BOM_CODE=C.BOM_CODE " + "GROUP BY A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.UNIT, C.BATCH_QTY";
"AND A.SITE_CODE >= ? AND A.SITE_CODE <= ? "+
"AND A.STATUS IN ('P','T','M')";
pstmt = conn.prepareStatement(selectSql); pstmt = conn.prepareStatement(selectSql);
pstmt.setString(1, siteCodeFr); pstmt.setString(1, siteCodeFr);
pstmt.setString(2, siteCodeTo); pstmt.setString(2, siteCodeTo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while ( rs.next() ) while (rs.next())
{ {
detCnt++; detCnt++;
dueDate = rs.getDate("DUE_DATE"); lineNo++;
if(dueDate != null) quantity = rs.getDouble("QUANTITY");
{ batchQty = rs.getDouble("BATCH_QTY");
dueDate1 = sdf.format(dueDate); batchReq = (quantity / batchQty);
} System.out.println(" aFTER CALUCLATION Quantity is =" + quantity + " batch quantity is =" + batchQty + "batch Requirement is =" + batchReq);
else
{ /*
dueDate1 = ""; * dueDate = rs.getDate("DUE_DATE"); if (dueDate !=
} * null) { dueDate1 = sdf.format(dueDate); } else {
valueXmlString.append("<Detail2>\r\n"); * dueDate1 = ""; }
valueXmlString.append("<site_code>").append("<![CDATA["+rs.getString("SITE_CODE")+"]]>").append("</site_code>\r\n"); */
valueXmlString.append("<item_code>").append("<![CDATA["+rs.getString("ITEM_CODE")+"]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr protect = '1'>").append("<![CDATA["+rs.getString("DESCR")+"]]>").append("</item_descr>\r\n"); valueXmlString.append("<Detail2 domID='" + lineNo + "' objContext = '" + currentFormNo + "' selected=\"Y\">\r\n");
valueXmlString.append("<quantity>").append("<![CDATA["+rs.getDouble("QUANTITY")+"]]>").append("</quantity>\r\n"); valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("<![CDATA["+dueDate1+"]]>").append("</due_date>\r\n"); valueXmlString.append("<site_code>").append("<![CDATA[" + rs.getString("SITE_CODE") + "]]>").append("</site_code>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA["+rs.getString("UNIT")+"]]>").append("</unit>\r\n"); valueXmlString.append("<item_code>").append("<![CDATA[" + rs.getString("ITEM_CODE") + "]]>").append("</item_code>\r\n");
valueXmlString.append("<yield_perc protect = '1'>").append("<![CDATA["+rs.getString("YIELD_PERC")+"]]>").append("</yield_perc>\r\n"); valueXmlString.append("<item_descr protect = '1'>").append("<![CDATA[" + rs.getString("DESCR") + "]]>").append("</item_descr>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA["+rs.getString("TRAN_ID")+"]]>").append("</tran_id>\r\n"); valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + rs.getString("UNIT") + "]]>").append("</unit>\r\n");
valueXmlString.append("<no_of_batch protect = '1'>").append("<![CDATA[" + batchReq + "]]>").append("</no_of_batch>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[" + rs.getDouble("QUANTITY") + "]]>").append("</quantity>\r\n");
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
} }
rs.close(); rs = null; rs.close();
pstmt.close(); pstmt = null; rs = null;
if ( detCnt == 0 ) pstmt.close();
pstmt = null;
if (detCnt == 0)
{ {
valueXmlString.append("<Detail2>\r\n"); // valueXmlString.append("<Detail2>\r\n");
valueXmlString.append("<Detail2 domID='" + lineNo + "' objContext = '" + currentFormNo + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<site_code>").append("").append("</site_code>\r\n"); valueXmlString.append("<site_code>").append("").append("</site_code>\r\n");
valueXmlString.append("<item_code>").append("").append("</item_code>\r\n"); valueXmlString.append("<item_code>").append("").append("</item_code>\r\n");
valueXmlString.append("<item_descr protect = '1'>").append("").append("</item_descr>\r\n"); valueXmlString.append("<item_descr protect = '1'>").append("").append("</item_descr>\r\n");
valueXmlString.append("<quantity>").append("0").append("</quantity>\r\n"); valueXmlString.append("<quantity>").append("0").append("</quantity>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("").append("</due_date>\r\n"); valueXmlString.append("<no_of_batch protect = '1'>").append("0").append("</no_of_batch>\r\n");
valueXmlString.append("<unit protect = '1'>").append("").append("</unit>\r\n"); valueXmlString.append("<unit protect = '1'>").append("").append("</unit>\r\n");
valueXmlString.append("<yield_perc protect = '1'>").append("").append("</yield_perc>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("").append("</tran_id>\r\n");
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
} }
/* End Change By Sachin on 26/6/2013 */
} }
break; break;
//added by akhilesh
// added by akhilesh
case 3: case 3:
if(currentColumn.trim().equals("itm_default")) if (currentColumn.trim().equals("itm_default"))
{ {
TreeSet itemTreeSet = new TreeSet(); TreeSet itemTreeSet = new TreeSet();
TreeSet siteTreeSet = new TreeSet(); TreeSet siteTreeSet = new TreeSet();
ArrayList tranIdList = new ArrayList(); ArrayList tranIdList = new ArrayList();
...@@ -234,8 +251,8 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -234,8 +251,8 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
String tranIdDom = ""; String tranIdDom = "";
String qtyStr = ""; String qtyStr = "";
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom1); siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1); siteCodeTo = genericUtility.getColumnValue("site_code__to", dom1);
insertSql = "INSERT INTO MPS_ORDER(TRAN_ID, ORDER_TYPE, ITEM_CODE, SITE_CODE, QUANTITY, ORD_DATE, DUE_DATE, STATUS, STATUS_DATE, YIELD_PERC, UNIT ) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; insertSql = "INSERT INTO MPS_ORDER(TRAN_ID, ORDER_TYPE, ITEM_CODE, SITE_CODE, QUANTITY, ORD_DATE, DUE_DATE, STATUS, STATUS_DATE, YIELD_PERC, UNIT ) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
...@@ -250,14 +267,18 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -250,14 +267,18 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
parentNodeList = dom2.getElementsByTagName("Detail2"); parentNodeList = dom2.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength(); parentNodeListLength = parentNodeList.getLength();
for(int p = 0; p < parentNodeListLength; p++) for (int p = 0; p < parentNodeListLength; p++)
{ {
tranIdDom = ""; itemCode = ""; siteCode = ""; qtyStr = ""; quantity = 0d; tranIdDom = "";
itemCode = "";
siteCode = "";
qtyStr = "";
quantity = 0d;
parentNode = parentNodeList.item(p); parentNode = parentNodeList.item(p);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(int c = 0; c < childNodeListLength; c++) for (int c = 0; c < childNodeListLength; c++)
{ {
childNode = childNodeList.item(c); childNode = childNodeList.item(c);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
...@@ -269,78 +290,76 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -269,78 +290,76 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
{ {
tranIdDom = checkNull(childNode.getFirstChild().getNodeValue()); tranIdDom = checkNull(childNode.getFirstChild().getNodeValue());
} }
} } else if (childNodeName.equals("item_code"))
else if (childNodeName.equals("item_code"))
{ {
if (childNode.getFirstChild() != null) if (childNode.getFirstChild() != null)
{ {
itemCode = checkNull(childNode.getFirstChild().getNodeValue()); itemCode = checkNull(childNode.getFirstChild().getNodeValue());
} }
} } else if (childNodeName.equals("site_code"))
else if (childNodeName.equals("site_code"))
{ {
if (childNode.getFirstChild() != null) if (childNode.getFirstChild() != null)
{ {
siteCode = checkNull(childNode.getFirstChild().getNodeValue()); siteCode = checkNull(childNode.getFirstChild().getNodeValue());
} }
} } else if (childNodeName.equals("quantity"))
else if (childNodeName.equals("quantity"))
{ {
if (childNode.getFirstChild() != null) if (childNode.getFirstChild() != null)
{ {
qtyStr = childNode.getFirstChild().getNodeValue(); qtyStr = childNode.getFirstChild().getNodeValue();
if ( qtyStr != null && qtyStr.trim().length() > 0 ) if (qtyStr != null && qtyStr.trim().length() > 0)
{ {
try try
{ {
quantity = Double.parseDouble(qtyStr); quantity = Double.parseDouble(qtyStr);
} } catch (NumberFormatException n)
catch (NumberFormatException n)
{ {
quantity = 0; quantity = 0;
} }
} }
} }
} }
}//End of Inner for loop }// End of Inner for loop
if ( itemCode != null && itemCode.trim().length() > 0 ) if (itemCode != null && itemCode.trim().length() > 0)
{ {
itemTreeSet.add(itemCode); itemTreeSet.add(itemCode);
} }
if ( siteCode != null && siteCode.trim().length() > 0 ) if (siteCode != null && siteCode.trim().length() > 0)
{ {
siteTreeSet.add(siteCode); siteTreeSet.add(siteCode);
} }
if ( tranIdDom == null || tranIdDom.trim().length() == 0 ) if (tranIdDom == null || tranIdDom.trim().length() == 0)
{ {
newDataCnt++; newDataCnt++;
ArrayList newDataList = new ArrayList(); ArrayList newDataList = new ArrayList();
newDataList.add(siteCode); newDataList.add(siteCode);
newDataList.add(itemCode); newDataList.add(itemCode);
newDataList.add(quantity); newDataList.add(quantity);
mpsDataMap.put(""+newDataCnt,newDataList); mpsDataMap.put("" + newDataCnt, newDataList);
pstmtSel1.setString(1, itemCode); pstmtSel1.setString(1, itemCode);
rs = pstmtSel1.executeQuery(); rs = pstmtSel1.executeQuery();
if ( rs.next() ) if (rs.next())
{ {
unit = rs.getString("UNIT"); unit = rs.getString("UNIT");
yieldPerc = rs.getDouble("YIELD_PERC"); yieldPerc = rs.getDouble("YIELD_PERC");
} }
pstmtSel1.clearParameters(); pstmtSel1.clearParameters();
rs.close(); rs = null; rs.close();
rs = null;
pstmtSel.setString(1, siteCode); pstmtSel.setString(1, siteCode);
pstmtSel.setString(2, itemCode); pstmtSel.setString(2, itemCode);
rs = pstmtSel.executeQuery(); rs = pstmtSel.executeQuery();
if ( rs.next() ) if (rs.next())
{ {
batchQty = rs.getDouble("BATCH_QTY"); batchQty = rs.getDouble("BATCH_QTY");
} }
pstmtSel.clearParameters(); pstmtSel.clearParameters();
rs.close(); rs = null; rs.close();
rs = null;
//quantity = batchQty * noOfBatch; // quantity = batchQty * noOfBatch;
tranIdSuffix++; tranIdSuffix++;
...@@ -350,40 +369,40 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -350,40 +369,40 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
tranIdList.add(newTranId); tranIdList.add(newTranId);
pstmtIns.setString(1,newTranId); pstmtIns.setString(1, newTranId);
pstmtIns.setString(2,orderType); pstmtIns.setString(2, orderType);
pstmtIns.setString(3,itemCode); pstmtIns.setString(3, itemCode);
pstmtIns.setString(4,siteCode); pstmtIns.setString(4, siteCode);
pstmtIns.setDouble(5,quantity); pstmtIns.setDouble(5, quantity);
pstmtIns.setTimestamp(6,sysDate); pstmtIns.setTimestamp(6, sysDate);
pstmtIns.setTimestamp(7,sysDate); pstmtIns.setTimestamp(7, sysDate);
pstmtIns.setString(8,status); pstmtIns.setString(8, status);
pstmtIns.setTimestamp(9,sysDate); pstmtIns.setTimestamp(9, sysDate);
pstmtIns.setDouble(10,yieldPerc); pstmtIns.setDouble(10, yieldPerc);
pstmtIns.setString(11,unit); pstmtIns.setString(11, unit);
pstmtIns.addBatch(); pstmtIns.addBatch();
pstmtIns.clearParameters(); pstmtIns.clearParameters();
} }
} }
noOfItem = itemTreeSet.size(); noOfItem = itemTreeSet.size();
if ( noOfItem > 0 ) if (noOfItem > 0)
{ {
itemCodeFr = (String)itemTreeSet.first(); itemCodeFr = (String) itemTreeSet.first();
itemCodeTo = (String)itemTreeSet.last(); itemCodeTo = (String) itemTreeSet.last();
} }
noOfSite = siteTreeSet.size(); noOfSite = siteTreeSet.size();
if ( noOfSite > 0 ) if (noOfSite > 0)
{ {
siteCodeFr = (String)siteTreeSet.first(); siteCodeFr = (String) siteTreeSet.first();
siteCodeTo = (String)siteTreeSet.last(); siteCodeTo = (String) siteTreeSet.last();
} }
int insCnt[] = null; int insCnt[] = null;
insCnt = pstmtIns.executeBatch(); insCnt = pstmtIns.executeBatch();
if ( insCnt.length > 0 ) if (insCnt.length > 0)
{ {
System.out.println("Record inserted into mps_order successfully for tran id =["+insCnt.length +"]"); System.out.println("Record inserted into mps_order successfully for tran id =[" + insCnt.length + "]");
conn.commit(); conn.commit();
} }
...@@ -391,12 +410,12 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -391,12 +410,12 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Date d = new Date(); Date d = new Date();
String runDate = simpleDateFormat.format(d); String runDate = simpleDateFormat.format(d);
cal.setTime(d); cal.setTime(d);
cal.set(Calendar.DATE,1); cal.set(Calendar.DATE, 1);
d = cal.getTime(); d = cal.getTime();
String fromDate = simpleDateFormat.format(d); String fromDate = simpleDateFormat.format(d);
cal.setTime(d); cal.setTime(d);
cal.add(Calendar.MONTH,3); cal.add(Calendar.MONTH, 3);
cal.set(Calendar.DATE,0); cal.set(Calendar.DATE, 0);
d = cal.getTime(); d = cal.getTime();
String toDate = simpleDateFormat.format(d); String toDate = simpleDateFormat.format(d);
System.out.println("From Date :" + fromDate + " To Date :" + toDate); System.out.println("From Date :" + fromDate + " To Date :" + toDate);
...@@ -414,7 +433,8 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -414,7 +433,8 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
argData.append("<item_ser__from>").append("0").append("</item_ser__from>\r\n"); argData.append("<item_ser__from>").append("0").append("</item_ser__from>\r\n");
argData.append("<item_ser__to>").append("ZZ").append("</item_ser__to>\r\n"); argData.append("<item_ser__to>").append("ZZ").append("</item_ser__to>\r\n");
argData.append("<process_cycle>").append("3").append("</process_cycle>\r\n"); argData.append("<process_cycle>").append("3").append("</process_cycle>\r\n");
argData.append("<run_date>").append(runDate).append("</run_date>\r\n"); // 01-10-2007 manoharan argData.append("<run_date>").append(runDate).append("</run_date>\r\n"); // 01-10-2007
// manoharan
argData.append("<dis_plan>").append("N").append("</dis_plan>\r\n"); argData.append("<dis_plan>").append("N").append("</dis_plan>\r\n");
argData.append("<mfg_plan>").append("N").append("</mfg_plan>\r\n"); argData.append("<mfg_plan>").append("N").append("</mfg_plan>\r\n");
argData.append("<mat_plan>").append("Y").append("</mat_plan>\r\n"); argData.append("<mat_plan>").append("Y").append("</mat_plan>\r\n");
...@@ -430,88 +450,90 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -430,88 +450,90 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
String mrpGetData = ""; String mrpGetData = "";
RunMRPPrc runMRPObj = new RunMRPPrc(); RunMRPPrc runMRPObj = new RunMRPPrc();
mrpGetData = runMRPObj.getData(argDom, dom2, "", xtraParams);
System.out.println("mrpGetData =["+mrpGetData+"]"); /* Added by sachin */
parentNode = parentNodeList.item(0);
winName = this.getWinName(parentNode);
mrpGetData = runMRPObj.getData(argDom, dom2, winName, xtraParams);
/* End Added by sachin */
System.out.println("mrpGetData =[" + mrpGetData + "]");
String tranIdStr = "'"; String tranIdStr = "'";
if ( tranIdList != null && tranIdList.size() > 0 ) if (tranIdList != null && tranIdList.size() > 0)
{ {
for (int i = 0; i < tranIdList.size(); i++) for (int i = 0; i < tranIdList.size(); i++)
{ {
tranIdStr = tranIdStr + tranIdList.get(i) + "','"; tranIdStr = tranIdStr + tranIdList.get(i) + "','";
} }
} }
if ( tranIdStr.length() >= 2 ) if (tranIdStr.length() >= 2)
{ {
tranIdStr = tranIdStr.substring(0, tranIdStr.length()-2); tranIdStr = tranIdStr.substring(0, tranIdStr.length() - 2);
} } else
else
{ {
tranIdStr = ""; tranIdStr = "";
} }
if ( tranIdStr != null && tranIdStr.trim().length() > 0 ) if (tranIdStr != null && tranIdStr.trim().length() > 0)
{ {
deleteSql = "DELETE FROM MPS_ORDER WHERE TRAN_ID IN("+tranIdStr+")"; deleteSql = "DELETE FROM MPS_ORDER WHERE TRAN_ID IN(" + tranIdStr + ")";
pstmt = conn.prepareStatement(deleteSql); pstmt = conn.prepareStatement(deleteSql);
delCnt = pstmt.executeUpdate(); delCnt = pstmt.executeUpdate();
if ( delCnt > 0 ) if (delCnt > 0)
{ {
System.out.println("Record deleted from mps_order successfully for tran id =["+tranIdStr+"]"); System.out.println("Record deleted from mps_order successfully for tran id =[" + tranIdStr + "]");
} }
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
return mrpGetData; return mrpGetData;
} }
break; break;
//ended by akhilesh // ended by akhilesh
} }
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
} } catch (Exception e)
catch(Exception e)
{ {
isError = true; isError = true;
System.out.println("Exception :[RequirementIC][itemChanged::case 1:] :==>\n"+e.getMessage()); System.out.println("Exception :[RequirementIC][itemChanged::case 1:] :==>\n" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
return genericUtility.createErrorString(e); return genericUtility.createErrorString(e);
//throw new ITMException(e); // throw new ITMException(e);
} } finally
finally
{ {
try try
{ {
if ( conn != null ) if (conn != null)
{ {
if ( !isError ) if (!isError)
{ {
conn.commit(); conn.commit();
} } else
else
{ {
conn.rollback(); conn.rollback();
} }
if ( rs != null ) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if ( pstmtIns != null ) if (pstmtIns != null)
{ {
pstmtIns.close(); pstmtIns.close();
pstmtIns = null; pstmtIns = null;
} }
if ( pstmtSel != null ) if (pstmtSel != null)
{ {
pstmtSel.close(); pstmtSel.close();
pstmtSel = null; pstmtSel = null;
} }
if ( pstmtSel1 != null ) if (pstmtSel1 != null)
{ {
pstmtSel1.close(); pstmtSel1.close();
pstmtSel1 = null; pstmtSel1 = null;
...@@ -519,8 +541,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -519,8 +541,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
conn.close(); conn.close();
conn = null; conn = null;
} }
} } catch (Exception e)
catch (Exception e)
{ {
} }
} }
...@@ -528,7 +549,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -528,7 +549,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
} }
// Validation // Validation
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{ {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
...@@ -538,18 +559,17 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -538,18 +559,17 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
try try
{ {
dom = parseString(xmlString); dom = parseString(xmlString);
System.out.println("RequirementIC : wfValData(String xmlString) : ==>\n" + xmlString ); System.out.println("RequirementIC : wfValData(String xmlString) : ==>\n" + xmlString);
System.out.println("RequirementIC : wfValData(String xmlString1) : ==>\n" + xmlString1 ); System.out.println("RequirementIC : wfValData(String xmlString1) : ==>\n" + xmlString1);
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 ) if (xmlString2.trim().length() > 0)
{ {
dom2 = parseString("<Root>" + xmlString2+ "</Root>"); dom2 = parseString("<Root>" + xmlString2 + "</Root>");
} }
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} } catch (Exception e)
catch(Exception e)
{ {
System.out.println("Exception : RequirementIC : wfValData(String xmlString) : ==>\n"+e.getMessage()); System.out.println("Exception : RequirementIC : wfValData(String xmlString) : ==>\n" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
...@@ -564,7 +584,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -564,7 +584,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Node childNode = null; Node childNode = null;
String childNodeName = ""; String childNodeName = "";
String errString = ""; String errString = "";
int ctr,currentFormNo=0; int ctr, currentFormNo = 0;
int childNodeListLength; int childNodeListLength;
int count = 0; int count = 0;
...@@ -580,19 +600,18 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -580,19 +600,18 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection(); conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"userId"); userId = getValueFromXTRA_PARAMS(xtraParams, "userId");
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch(currentFormNo) switch (currentFormNo)
{ {
case 1: case 1:
{ {
...@@ -601,33 +620,33 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -601,33 +620,33 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++)
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
int cnt; int cnt;
System.out.println("childNodeName 0. : " + childNodeName); System.out.println("childNodeName 0. : " + childNodeName);
if ( childNodeName.equals("site_code__fr") || childNodeName.equals("site_code__to") ) if (childNodeName.equals("site_code__fr") || childNodeName.equals("site_code__to"))
{ {
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom); siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom); siteCodeTo = genericUtility.getColumnValue("site_code__to", dom);
if ( siteCodeFr == null || siteCodeFr.trim().length() == 0 ) if (siteCodeFr == null || siteCodeFr.trim().length() == 0)
{ {
errCode = "VMSITE11"; errCode = "VMSITE11";
errString = getErrorString("site_code__fr",errCode,userId); errString = getErrorString("site_code__fr", errCode, userId);
break; break;
} }
if ( siteCodeTo == null || siteCodeTo.trim().length() == 0 ) if (siteCodeTo == null || siteCodeTo.trim().length() == 0)
{ {
errCode = "VMSITE12"; errCode = "VMSITE12";
errString = getErrorString("site_code__fr",errCode,userId); errString = getErrorString("site_code__fr", errCode, userId);
break; break;
} }
} }
} }
}//End of Case 1 }// End of Case 1
break; break;
case 2: case 2:
{ {
...@@ -636,20 +655,20 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -636,20 +655,20 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++)
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
int cnt; int cnt;
System.out.println("childNodeName 0. : " + childNodeName); System.out.println("childNodeName 0. : " + childNodeName);
if ( childNodeName.equals("site_code") ) if (childNodeName.equals("site_code"))
{ {
siteCode = genericUtility.getColumnValue("site_code",dom); siteCode = genericUtility.getColumnValue("site_code", dom);
if ( siteCode == null || siteCode.trim().length() == 0 ) if (siteCode == null || siteCode.trim().length() == 0)
{ {
errCode = "VMSITECD"; errCode = "VMSITECD";
errString = getErrorString("site_code",errCode,userId); errString = getErrorString("site_code", errCode, userId);
break; break;
} }
...@@ -658,25 +677,25 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -658,25 +677,25 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if ( rs.next() ) if (rs.next())
{ {
count = rs.getInt("COUNT"); count = rs.getInt("COUNT");
} }
rs.close(); rs = null; rs.close();
if ( count == 0 ) rs = null;
if (count == 0)
{ {
errCode = "VMSITE"; errCode = "VMSITE";
errString = getErrorString(childNodeName,errCode,userId); errString = getErrorString(childNodeName, errCode, userId);
break; break;
} }
} } else if (childNodeName.equals("item_code"))
else if ( childNodeName.equals("item_code") )
{ {
itemCode = genericUtility.getColumnValue("item_code",dom); itemCode = genericUtility.getColumnValue("item_code", dom);
if ( itemCode == null || itemCode.trim().length() == 0 ) if (itemCode == null || itemCode.trim().length() == 0)
{ {
errCode = "VMITEMCD"; errCode = "VMITEMCD";
errString = getErrorString("item_code",errCode,userId); errString = getErrorString("item_code", errCode, userId);
break; break;
} }
...@@ -685,68 +704,80 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R ...@@ -685,68 +704,80 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode); pstmt.setString(1, itemCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if ( rs.next() ) if (rs.next())
{ {
count = rs.getInt("COUNT"); count = rs.getInt("COUNT");
} }
rs.close(); rs = null; rs.close();
if ( count == 0 ) rs = null;
if (count == 0)
{ {
errCode = "VMITEM1"; errCode = "VMITEM1";
errString = getErrorString(childNodeName,errCode,userId); errString = getErrorString(childNodeName, errCode, userId);
break; break;
} }
} } else if (childNodeName.equals("quantity"))
else if ( childNodeName.equals("quantity") )
{ {
quantity = genericUtility.getColumnValue("quantity",dom); quantity = genericUtility.getColumnValue("quantity", dom);
if ( quantity == null || quantity.trim().length() == 0 || quantity.equals("0") ) if (quantity == null || quantity.trim().length() == 0 || quantity.equals("0"))
{ {
errCode = "VMWEQTY"; errCode = "VMWEQTY";
errString = getErrorString("quantity",errCode,userId); errString = getErrorString("quantity", errCode, userId);
break; break;
} }
} }
} }
}//End of Case 1 }// End of Case 1
break; break;
}//End of Switch block }// End of Switch block
} } catch (Exception e)
catch(Exception e)
{ {
System.out.println("Exception ::"+e); System.out.println("Exception ::" + e);
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e); throw new ITMException(e);
} } finally
finally
{ {
try try
{ {
//System.out.println("Closing Connection....."); // System.out.println("Closing Connection.....");
if ( rs != null ) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if ( pstmt != null ) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); conn.close();
conn = null; conn = null;
}catch(Exception se){} } catch (Exception se)
{
}
} }
return errString; return errString;
} }
private String checkNull(String value) private String checkNull(String value)
{ {
if ( value == null ) if (value == null)
{ {
value = ""; value = "";
} }
return value; return value;
} }
/* Added by sachin on 26/6/13 */
private String getWinName(Node node) throws Exception
{
String objName = "";
NamedNodeMap attrMap = node.getAttributes();
objName = attrMap.getNamedItem("objName").getNodeValue();
System.out.println(" Object Name is==>" + objName);
return "w_" + objName;
}
/* End Added by sachin on 26/6/13 */
} }
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