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
......@@ -13,29 +13,29 @@ import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import java.text.SimpleDateFormat;
import javax.naming.InitialContext;
import javax.ejb.Stateless;
import javax.ejb.Stateless;
@Stateless
public class RequirementIC extends ValidatorEJB implements RequirementICLocal,RequirementICRemote //SessionBean
@Stateless
public class RequirementIC extends ValidatorEJB implements RequirementICLocal, RequirementICRemote // SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
SimpleDateFormat simpleDateFormat = null;
public String wfValData() throws RemoteException,ITMException
public String wfValData() throws RemoteException, ITMException
{
System.out.println("wfValData()...");
return "";
}
// Item Change
public String itemChanged() throws RemoteException,ITMException
public String itemChanged() throws RemoteException, ITMException
{
System.out.println("itemChanged Called...");
return "";
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
......@@ -45,42 +45,43 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("xmlString.........::"+xmlString);
System.out.println("xmlString1.........::"+xmlString1);
System.out.println("xmlString2.........::"+xmlString2);
if (xmlString != null && xmlString.trim().length()!=0)
System.out.println("xmlString.........::" + xmlString);
System.out.println("xmlString1.........::" + xmlString1);
System.out.println("xmlString2.........::" + xmlString2);
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
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);
throw new ITMException(e);
}
System.out.println ("returning from ProcessControlEJB itemChanged");
System.out.println("returning from ProcessControlEJB itemChanged");
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 sql = "";
String columnValue = "";
String userId = "";
String errString="";
String errString = "";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
int lineNo = 0;
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
......@@ -129,6 +130,9 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
double quantity = 0d;
double yieldPerc = 0d;
String winName = ""; // Added by sachin on 26/6/13
double batchReq = 0d;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
......@@ -138,380 +142,398 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
connDriver = null;
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
columnValue = genericUtility.getColumnValue(currentColumn,dom);
if(objContext != null && objContext.trim().length()>0)
columnValue = genericUtility.getColumnValue(currentColumn, dom);
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></Header>");
switch (currentFormNo)
{
case 1:
valueXmlString.append("<Detail1>");
if(currentColumn.trim().equals("itm_default"))
case 1:
valueXmlString.append("<Detail1>");
if (currentColumn.trim().equals("itm_default"))
{
valueXmlString.append("<site_code__fr>").append(loginSiteCode).append("</site_code__fr>");
valueXmlString.append("<site_code__to>").append(loginSiteCode).append("</site_code__to>");
}
valueXmlString.append("</Detail1>");
break;
case 2:
if (currentColumn.trim().equals("itm_default"))
{
int detCnt = 0;
siteCodeFr = genericUtility.getColumnValue("site_code__fr", 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')";
*/
/* Change By Sachin on 26/6/2013 */
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";
pstmt = conn.prepareStatement(selectSql);
pstmt.setString(1, siteCodeFr);
pstmt.setString(2, siteCodeTo);
rs = pstmt.executeQuery();
while (rs.next())
{
valueXmlString.append("<site_code__fr>").append(loginSiteCode).append("</site_code__fr>");
valueXmlString.append("<site_code__to>").append(loginSiteCode).append("</site_code__to>");
detCnt++;
lineNo++;
quantity = rs.getDouble("QUANTITY");
batchQty = rs.getDouble("BATCH_QTY");
batchReq = (quantity / batchQty);
System.out.println(" aFTER CALUCLATION Quantity is =" + quantity + " batch quantity is =" + batchQty + "batch Requirement is =" + batchReq);
/*
* dueDate = rs.getDate("DUE_DATE"); if (dueDate !=
* null) { dueDate1 = sdf.format(dueDate); } else {
* dueDate1 = ""; }
*/
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("<![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("<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("</Detail1>");
break;
case 2:
if(currentColumn.trim().equals("itm_default"))
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (detCnt == 0)
{
int detCnt = 0;
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1);
selectSql = "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')";
pstmt = conn.prepareStatement(selectSql);
pstmt.setString(1, siteCodeFr);
pstmt.setString(2, siteCodeTo);
rs = pstmt.executeQuery();
while ( rs.next() )
{
detCnt++;
dueDate = rs.getDate("DUE_DATE");
if(dueDate != null)
{
dueDate1 = sdf.format(dueDate);
}
else
{
dueDate1 = "";
}
valueXmlString.append("<Detail2>\r\n");
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("<quantity>").append("<![CDATA["+rs.getDouble("QUANTITY")+"]]>").append("</quantity>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("<![CDATA["+dueDate1+"]]>").append("</due_date>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA["+rs.getString("UNIT")+"]]>").append("</unit>\r\n");
valueXmlString.append("<yield_perc protect = '1'>").append("<![CDATA["+rs.getString("YIELD_PERC")+"]]>").append("</yield_perc>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA["+rs.getString("TRAN_ID")+"]]>").append("</tran_id>\r\n");
valueXmlString.append("</Detail2>");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
if ( detCnt == 0 )
{
valueXmlString.append("<Detail2>\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_descr protect = '1'>").append("").append("</item_descr>\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("<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>\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("<item_code>").append("").append("</item_code>\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("<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("</Detail2>");
}
break;
//added by akhilesh
case 3:
if(currentColumn.trim().equals("itm_default"))
{
TreeSet itemTreeSet = new TreeSet();
TreeSet siteTreeSet = new TreeSet();
ArrayList tranIdList = new ArrayList();
/* End Change By Sachin on 26/6/2013 */
}
break;
HashMap mpsDataMap = new HashMap();
// added by akhilesh
case 3:
if (currentColumn.trim().equals("itm_default"))
{
TreeSet itemTreeSet = new TreeSet();
TreeSet siteTreeSet = new TreeSet();
ArrayList tranIdList = new ArrayList();
int newDataCnt = 0;
int noOfSite = 0;
String tranIdDom = "";
String qtyStr = "";
HashMap mpsDataMap = new HashMap();
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1);
int newDataCnt = 0;
int noOfSite = 0;
String tranIdDom = "";
String qtyStr = "";
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( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to", dom1);
pstmtIns = conn.prepareStatement(insertSql);
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( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
selectSql = "SELECT BATCH_QTY FROM BOM WHERE BOM_CODE = (SELECT BOM_CODE FROM SITEITEM WHERE SITE_CODE = ? AND ITEM_CODE = ? )";
pstmtSel = conn.prepareStatement(selectSql);
pstmtIns = conn.prepareStatement(insertSql);
selectSql = "SELECT UNIT,YIELD_PERC FROM ITEM WHERE ITEM_CODE = ? ";
pstmtSel1 = conn.prepareStatement(selectSql);
selectSql = "SELECT BATCH_QTY FROM BOM WHERE BOM_CODE = (SELECT BOM_CODE FROM SITEITEM WHERE SITE_CODE = ? AND ITEM_CODE = ? )";
pstmtSel = conn.prepareStatement(selectSql);
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
selectSql = "SELECT UNIT,YIELD_PERC FROM ITEM WHERE ITEM_CODE = ? ";
pstmtSel1 = conn.prepareStatement(selectSql);
for(int p = 0; p < parentNodeListLength; p++)
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
for (int p = 0; p < parentNodeListLength; p++)
{
tranIdDom = "";
itemCode = "";
siteCode = "";
qtyStr = "";
quantity = 0d;
parentNode = parentNodeList.item(p);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int c = 0; c < childNodeListLength; c++)
{
tranIdDom = ""; itemCode = ""; siteCode = ""; qtyStr = ""; quantity = 0d;
parentNode = parentNodeList.item(p);
childNodeList = parentNode.getChildNodes();
childNode = childNodeList.item(c);
childNodeName = childNode.getNodeName();
childNodeListLength = childNodeList.getLength();
for(int c = 0; c < childNodeListLength; c++)
System.out.println("childNodeName :: " + childNodeName);
if (childNodeName.equals("tran_id"))
{
childNode = childNodeList.item(c);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName :: " + childNodeName);
if (childNodeName.equals("tran_id"))
if (childNode.getFirstChild() != null)
{
if (childNode.getFirstChild() != null)
{
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();
if (qtyStr != null && qtyStr.trim().length() > 0)
{
qtyStr = childNode.getFirstChild().getNodeValue();
if ( qtyStr != null && qtyStr.trim().length() > 0 )
try
{
quantity = Double.parseDouble(qtyStr);
} catch (NumberFormatException n)
{
try
{
quantity = Double.parseDouble(qtyStr);
}
catch (NumberFormatException n)
{
quantity = 0;
}
quantity = 0;
}
}
}
}//End of Inner for loop
if ( itemCode != null && itemCode.trim().length() > 0 )
{
itemTreeSet.add(itemCode);
}
if ( siteCode != null && siteCode.trim().length() > 0 )
{
siteTreeSet.add(siteCode);
}
if ( tranIdDom == null || tranIdDom.trim().length() == 0 )
{
newDataCnt++;
ArrayList newDataList = new ArrayList();
newDataList.add(siteCode);
newDataList.add(itemCode);
newDataList.add(quantity);
mpsDataMap.put(""+newDataCnt,newDataList);
pstmtSel1.setString(1, itemCode);
rs = pstmtSel1.executeQuery();
if ( rs.next() )
{
unit = rs.getString("UNIT");
yieldPerc = rs.getDouble("YIELD_PERC");
}
pstmtSel1.clearParameters();
rs.close(); rs = null;
pstmtSel.setString(1, siteCode);
pstmtSel.setString(2, itemCode);
rs = pstmtSel.executeQuery();
if ( rs.next() )
{
batchQty = rs.getDouble("BATCH_QTY");
}
pstmtSel.clearParameters();
rs.close(); rs = null;
//quantity = batchQty * noOfBatch;
tranIdSuffix++;
String newTranId = "";
newTranId = tranId;
newTranId = newTranId + tranIdSuffix;
tranIdList.add(newTranId);
pstmtIns.setString(1,newTranId);
pstmtIns.setString(2,orderType);
pstmtIns.setString(3,itemCode);
pstmtIns.setString(4,siteCode);
pstmtIns.setDouble(5,quantity);
pstmtIns.setTimestamp(6,sysDate);
pstmtIns.setTimestamp(7,sysDate);
pstmtIns.setString(8,status);
pstmtIns.setTimestamp(9,sysDate);
pstmtIns.setDouble(10,yieldPerc);
pstmtIns.setString(11,unit);
pstmtIns.addBatch();
pstmtIns.clearParameters();
}
}
noOfItem = itemTreeSet.size();
if ( noOfItem > 0 )
{
itemCodeFr = (String)itemTreeSet.first();
itemCodeTo = (String)itemTreeSet.last();
}
noOfSite = siteTreeSet.size();
if ( noOfSite > 0 )
}// End of Inner for loop
if (itemCode != null && itemCode.trim().length() > 0)
{
siteCodeFr = (String)siteTreeSet.first();
siteCodeTo = (String)siteTreeSet.last();
itemTreeSet.add(itemCode);
}
int insCnt[] = null;
insCnt = pstmtIns.executeBatch();
if ( insCnt.length > 0 )
if (siteCode != null && siteCode.trim().length() > 0)
{
System.out.println("Record inserted into mps_order successfully for tran id =["+insCnt.length +"]");
conn.commit();
siteTreeSet.add(siteCode);
}
Calendar cal = Calendar.getInstance();
Date d = new Date();
String runDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.set(Calendar.DATE,1);
d = cal.getTime();
String fromDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.add(Calendar.MONTH,3);
cal.set(Calendar.DATE,0);
d = cal.getTime();
String toDate = simpleDateFormat.format(d);
System.out.println("From Date :" + fromDate + " To Date :" + toDate);
StringBuffer argData = new StringBuffer();
argData = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
argData.append(editFlag).append("</editFlag></Header>");
argData.append("<Detail\r\n>");
argData.append("<date_from>").append(fromDate).append("</date_from>\r\n");
argData.append("<date_to>").append(toDate).append("</date_to>\r\n");
argData.append("<site_code__from>").append(siteCodeFr).append("</site_code__from>\r\n");
argData.append("<site_code__to>").append(siteCodeTo).append("</site_code__to\r\n>");
argData.append("<item_code__from>").append(itemCodeFr).append("</item_code__from>\r\n");
argData.append("<item_code__to>").append(itemCodeTo).append("</item_code__to>\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("<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("<dis_plan>").append("N").append("</dis_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("<made_to_stock>").append("0").append("</made_to_stock>\r\n");
argData.append("<made_to_order>").append("0").append("</made_to_order>\r\n");
argData.append("<balance_intersite>").append("N").append("</balance_intersite>\r\n");
argData.append("<gen_ind>").append("N").append("</gen_ind>\r\n");
argData.append("<wizard>").append("3").append("</wizard>\r\n");
argData.append("</Detail>");
argData.append("</Root>");
argDom = genericUtility.parseString(argData.toString());
String mrpGetData = "";
RunMRPPrc runMRPObj = new RunMRPPrc();
mrpGetData = runMRPObj.getData(argDom, dom2, "", xtraParams);
System.out.println("mrpGetData =["+mrpGetData+"]");
String tranIdStr = "'";
if ( tranIdList != null && tranIdList.size() > 0 )
if (tranIdDom == null || tranIdDom.trim().length() == 0)
{
for (int i = 0; i < tranIdList.size(); i++)
newDataCnt++;
ArrayList newDataList = new ArrayList();
newDataList.add(siteCode);
newDataList.add(itemCode);
newDataList.add(quantity);
mpsDataMap.put("" + newDataCnt, newDataList);
pstmtSel1.setString(1, itemCode);
rs = pstmtSel1.executeQuery();
if (rs.next())
{
tranIdStr = tranIdStr + tranIdList.get(i) + "','";
unit = rs.getString("UNIT");
yieldPerc = rs.getDouble("YIELD_PERC");
}
pstmtSel1.clearParameters();
rs.close();
rs = null;
pstmtSel.setString(1, siteCode);
pstmtSel.setString(2, itemCode);
rs = pstmtSel.executeQuery();
if (rs.next())
{
batchQty = rs.getDouble("BATCH_QTY");
}
pstmtSel.clearParameters();
rs.close();
rs = null;
// quantity = batchQty * noOfBatch;
tranIdSuffix++;
String newTranId = "";
newTranId = tranId;
newTranId = newTranId + tranIdSuffix;
tranIdList.add(newTranId);
pstmtIns.setString(1, newTranId);
pstmtIns.setString(2, orderType);
pstmtIns.setString(3, itemCode);
pstmtIns.setString(4, siteCode);
pstmtIns.setDouble(5, quantity);
pstmtIns.setTimestamp(6, sysDate);
pstmtIns.setTimestamp(7, sysDate);
pstmtIns.setString(8, status);
pstmtIns.setTimestamp(9, sysDate);
pstmtIns.setDouble(10, yieldPerc);
pstmtIns.setString(11, unit);
pstmtIns.addBatch();
pstmtIns.clearParameters();
}
if ( tranIdStr.length() >= 2 )
{
tranIdStr = tranIdStr.substring(0, tranIdStr.length()-2);
}
else
}
noOfItem = itemTreeSet.size();
if (noOfItem > 0)
{
itemCodeFr = (String) itemTreeSet.first();
itemCodeTo = (String) itemTreeSet.last();
}
noOfSite = siteTreeSet.size();
if (noOfSite > 0)
{
siteCodeFr = (String) siteTreeSet.first();
siteCodeTo = (String) siteTreeSet.last();
}
int insCnt[] = null;
insCnt = pstmtIns.executeBatch();
if (insCnt.length > 0)
{
System.out.println("Record inserted into mps_order successfully for tran id =[" + insCnt.length + "]");
conn.commit();
}
Calendar cal = Calendar.getInstance();
Date d = new Date();
String runDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.set(Calendar.DATE, 1);
d = cal.getTime();
String fromDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.add(Calendar.MONTH, 3);
cal.set(Calendar.DATE, 0);
d = cal.getTime();
String toDate = simpleDateFormat.format(d);
System.out.println("From Date :" + fromDate + " To Date :" + toDate);
StringBuffer argData = new StringBuffer();
argData = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
argData.append(editFlag).append("</editFlag></Header>");
argData.append("<Detail\r\n>");
argData.append("<date_from>").append(fromDate).append("</date_from>\r\n");
argData.append("<date_to>").append(toDate).append("</date_to>\r\n");
argData.append("<site_code__from>").append(siteCodeFr).append("</site_code__from>\r\n");
argData.append("<site_code__to>").append(siteCodeTo).append("</site_code__to\r\n>");
argData.append("<item_code__from>").append(itemCodeFr).append("</item_code__from>\r\n");
argData.append("<item_code__to>").append(itemCodeTo).append("</item_code__to>\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("<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("<dis_plan>").append("N").append("</dis_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("<made_to_stock>").append("0").append("</made_to_stock>\r\n");
argData.append("<made_to_order>").append("0").append("</made_to_order>\r\n");
argData.append("<balance_intersite>").append("N").append("</balance_intersite>\r\n");
argData.append("<gen_ind>").append("N").append("</gen_ind>\r\n");
argData.append("<wizard>").append("3").append("</wizard>\r\n");
argData.append("</Detail>");
argData.append("</Root>");
argDom = genericUtility.parseString(argData.toString());
String mrpGetData = "";
RunMRPPrc runMRPObj = new RunMRPPrc();
/* 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 = "'";
if (tranIdList != null && tranIdList.size() > 0)
{
for (int i = 0; i < tranIdList.size(); i++)
{
tranIdStr = "";
tranIdStr = tranIdStr + tranIdList.get(i) + "','";
}
}
if (tranIdStr.length() >= 2)
{
tranIdStr = tranIdStr.substring(0, tranIdStr.length() - 2);
} else
{
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 + ")";
pstmt = conn.prepareStatement(deleteSql);
delCnt = pstmt.executeUpdate();
if (delCnt > 0)
{
deleteSql = "DELETE FROM MPS_ORDER WHERE TRAN_ID IN("+tranIdStr+")";
pstmt = conn.prepareStatement(deleteSql);
delCnt = pstmt.executeUpdate();
if ( delCnt > 0 )
{
System.out.println("Record deleted from mps_order successfully for tran id =["+tranIdStr+"]");
}
pstmt.close();
pstmt = null;
System.out.println("Record deleted from mps_order successfully for tran id =[" + tranIdStr + "]");
}
pstmt.close();
pstmt = null;
}
return mrpGetData;
}
break;
// ended by akhilesh
return mrpGetData;
}
break;
//ended by akhilesh
}
valueXmlString.append("</Root>");
}
catch(Exception e)
} catch (Exception e)
{
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();
return genericUtility.createErrorString(e);
//throw new ITMException(e);
}
finally
// throw new ITMException(e);
} finally
{
try
{
if ( conn != null )
if (conn != null)
{
if ( !isError )
if (!isError)
{
conn.commit();
}
else
} else
{
conn.rollback();
}
if ( rs != null )
if (rs != null)
{
rs.close();
rs = null;
}
if ( pstmtIns != null )
if (pstmtIns != null)
{
pstmtIns.close();
pstmtIns = null;
}
if ( pstmtSel != null )
if (pstmtSel != null)
{
pstmtSel.close();
pstmtSel = null;
}
if ( pstmtSel1 != null )
if (pstmtSel1 != null)
{
pstmtSel1.close();
pstmtSel1 = null;
......@@ -519,8 +541,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
conn.close();
conn = null;
}
}
catch (Exception e)
} catch (Exception e)
{
}
}
......@@ -528,28 +549,27 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
}
// 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 dom1 = null;
Document dom2 = null;
String errString = "";
String errString = "";
System.out.println("wfValData(String)>>>");
try
{
dom = parseString(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 xmlString) : ==>\n" + xmlString);
System.out.println("RequirementIC : wfValData(String xmlString1) : ==>\n" + 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);
}
catch(Exception e)
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} 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();
throw new ITMException(e);
}
......@@ -563,8 +583,8 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
String errString = "";
int ctr,currentFormNo=0;
String errString = "";
int ctr, currentFormNo = 0;
int childNodeListLength;
int count = 0;
......@@ -580,173 +600,184 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"userId");
if(objContext != null && objContext.trim().length()>0)
userId = getValueFromXTRA_PARAMS(xtraParams, "userId");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
switch (currentFormNo)
{
case 1:
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if (childNodeName.equals("site_code__fr") || childNodeName.equals("site_code__to"))
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if ( childNodeName.equals("site_code__fr") || childNodeName.equals("site_code__to") )
siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom);
siteCodeTo = genericUtility.getColumnValue("site_code__to", dom);
if (siteCodeFr == null || siteCodeFr.trim().length() == 0)
{
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom);
if ( siteCodeFr == null || siteCodeFr.trim().length() == 0 )
{
errCode = "VMSITE11";
errString = getErrorString("site_code__fr",errCode,userId);
break;
}
if ( siteCodeTo == null || siteCodeTo.trim().length() == 0 )
{
errCode = "VMSITE12";
errString = getErrorString("site_code__fr",errCode,userId);
break;
}
errCode = "VMSITE11";
errString = getErrorString("site_code__fr", errCode, userId);
break;
}
if (siteCodeTo == null || siteCodeTo.trim().length() == 0)
{
errCode = "VMSITE12";
errString = getErrorString("site_code__fr", errCode, userId);
break;
}
}
}//End of Case 1
}
}// End of Case 1
break;
case 2:
case 2:
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if (childNodeName.equals("site_code"))
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if ( childNodeName.equals("site_code") )
siteCode = genericUtility.getColumnValue("site_code", dom);
if (siteCode == null || siteCode.trim().length() == 0)
{
siteCode = genericUtility.getColumnValue("site_code",dom);
if ( siteCode == null || siteCode.trim().length() == 0 )
{
errCode = "VMSITECD";
errString = getErrorString("site_code",errCode,userId);
break;
}
sql = "SELECT COUNT(*) COUNT FROM SITE WHERE SITE_CODE = ? ";
errCode = "VMSITECD";
errString = getErrorString("site_code", errCode, userId);
break;
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
count = rs.getInt("COUNT");
}
rs.close(); rs = null;
if ( count == 0 )
{
errCode = "VMSITE";
errString = getErrorString(childNodeName,errCode,userId);
break;
}
sql = "SELECT COUNT(*) COUNT FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
else if ( childNodeName.equals("item_code") )
rs.close();
rs = null;
if (count == 0)
{
itemCode = genericUtility.getColumnValue("item_code",dom);
if ( itemCode == null || itemCode.trim().length() == 0 )
{
errCode = "VMITEMCD";
errString = getErrorString("item_code",errCode,userId);
break;
}
sql = "SELECT COUNT(*) COUNT FROM ITEM WHERE ITEM_CODE = ? ";
errCode = "VMSITE";
errString = getErrorString(childNodeName, errCode, userId);
break;
}
} else if (childNodeName.equals("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code", dom);
if (itemCode == null || itemCode.trim().length() == 0)
{
errCode = "VMITEMCD";
errString = getErrorString("item_code", errCode, userId);
break;
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
count = rs.getInt("COUNT");
}
rs.close(); rs = null;
if ( count == 0 )
{
errCode = "VMITEM1";
errString = getErrorString(childNodeName,errCode,userId);
break;
}
sql = "SELECT COUNT(*) COUNT FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
if (count == 0)
{
errCode = "VMITEM1";
errString = getErrorString(childNodeName, errCode, userId);
break;
}
else if ( childNodeName.equals("quantity") )
} else if (childNodeName.equals("quantity"))
{
quantity = genericUtility.getColumnValue("quantity", dom);
if (quantity == null || quantity.trim().length() == 0 || quantity.equals("0"))
{
quantity = genericUtility.getColumnValue("quantity",dom);
if ( quantity == null || quantity.trim().length() == 0 || quantity.equals("0") )
{
errCode = "VMWEQTY";
errString = getErrorString("quantity",errCode,userId);
break;
}
errCode = "VMWEQTY";
errString = getErrorString("quantity", errCode, userId);
break;
}
}
}//End of Case 1
}
}// End of Case 1
break;
}//End of Switch block
}
catch(Exception e)
}// End of Switch block
} catch (Exception e)
{
System.out.println("Exception ::"+e);
System.out.println("Exception ::" + e);
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
} finally
{
try
{
//System.out.println("Closing Connection.....");
if ( rs != null )
// System.out.println("Closing Connection.....");
if (rs != null)
{
rs.close();
rs = null;
}
if ( pstmt != null )
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}catch(Exception se){}
} catch (Exception se)
{
}
}
return errString;
}
private String checkNull(String value)
{
if ( value == null )
if (value == null)
{
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