Commit ded57384 authored by caluka's avatar caluka

Adding validations for work order and campaign no[M14GSUN002]


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96634 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d0e6a34c
......@@ -17,8 +17,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
......@@ -66,7 +64,7 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
String userId = "";
String sql = "";
String errorType = "";
int cnt = 0,cnt1= 0;
int cnt = 0;
int ctr=0;
int childNodeListLength;
NodeList parentNodeList = null;
......@@ -81,13 +79,9 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
int currentFormNo =0,recCnt=0,recCnt1=0;
int currentFormNo =0;
String bomcode="",amdNo="",lineNo="";
String active = "",confirmed = "";
String bomcodeHdr = "",lineNoBOM = "",updateStatus="",supMfgCode="",itemCode="";
String supCode="",supMfgCodeList[]=null;
String loginSiteCode="",siteCode="";
String loginSiteCode="",workOrder="",campgnNo="";
try
{
System.out.println("@@@@@@@@ wfvaldata called");
......@@ -99,7 +93,7 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
{
currentFormNo = Integer.parseInt(objContext);
}
/*switch(currentFormNo)
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
......@@ -113,269 +107,51 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("bom_code"))
{
bomcode = checkNull(genericUtility.getColumnValue("bom_code", dom));
loginSiteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
System.out.println("@@loginSiteCode"+loginSiteCode);
System.out.println("@@@@ bom_code["+bomcode+"]");
if(bomcode == null || bomcode.trim().length() == 0)
{
errCode = "VTINVBOM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
errCode = isExist("bom","bom_code",bomcode,conn);
if( "FALSE".equalsIgnoreCase(errCode ))
{
errCode = "VTBOMCD3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " select site_code from bom where bom_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomcode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteCode = rs.getString("site_code")==null?"":rs.getString("site_code");;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(siteCode.trim().length() > 0 && siteCode != null)
{
sql = " select confirmed from bom where bom_code = ? and site_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomcode);
pstmt.setString(2,loginSiteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
recCnt++;
confirmed = rs.getString("confirmed")==null?"N":rs.getString("confirmed");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( recCnt == 0 )
{
errCode = "VTBOMCD4";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
sql = " select confirmed from bom where bom_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomcode);
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = rs.getString("confirmed")==null?"N":rs.getString("confirmed");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
if (!("Y".equalsIgnoreCase(confirmed)) )
{
errCode = "VTNOTCONF1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}// end for
break; // case 1 end
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("@@@@@@@@@@@@childNodeListLength["+childNodeListLength+"]");
for(ctr = 0; ctr < childNodeListLength; ctr++)
if(childNodeName.equalsIgnoreCase("work_order"))
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("bom_code"))
{
bomcode = checkNull(genericUtility.getColumnValue("bom_code", dom));
bomcodeHdr = checkNull(genericUtility.getColumnValue("bom_code", dom1));
System.out.println("@@@@ bomcode["+bomcode+"]::::bomcodeHdr["+bomcodeHdr+"]");
} if (childNodeName.equalsIgnoreCase("supp_code__mfg"))
{
supMfgCode=checkNull(this.genericUtility.getColumnValue("supp_code__mfg", dom));
itemCode=checkNull(this.genericUtility.getColumnValue("item_code", dom));
System.out.println(">>>>>>>>>>>>>>supMfgCode for validation:"+supMfgCode);
System.out.println(">>>>>>>>>>>>>>itemCode for validation:"+itemCode);
if (supMfgCode == null || supMfgCode.trim().length()==0)
{
sql = "SELECT count(*) AS cnt FROM siteitem WHERE site_code=? AND item_code=? AND CASE WHEN appr_supp IS NULL THEN 'N' ELSE appr_supp END ='Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println(">>>>>>>>>>>>>>cnt validation:"+cnt);
if(cnt > 0)
{
errCode = "VTAPRSUPP";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//check validation for supp_code__mfg not null
if (supMfgCode != null && supMfgCode.trim().length()>0 && errCode.trim().length()==0 )
{
supMfgCode=supMfgCode.trim();
System.out.println(">>>>>>>>>>>>> supMfgCode not null:" + supMfgCode.toString());
supMfgCodeList = supMfgCode.split(",");
if (supMfgCodeList != null && supMfgCodeList.length > 0)
{
for(int i=0; supMfgCodeList.length>i; i++)
{
supCode="";
supCode = supMfgCodeList[i];
System.out.println(">>>>>>>>>>>>>>> found supCode:" + supCode);
sql = "SELECT count(*) AS cnt FROM supplier WHERE supp_code =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, supCode.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println(">>>>>>>>>>>>>>cnt for supCode:"+cnt);
if(cnt==0)
{
errCode = "VMSUPP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} //end for loop for split supp code
}
}
}//validation end for supp_code__mfg
workOrder = checkNull(genericUtility.getColumnValue("work_order", dom));
campgnNo = checkNull(genericUtility.getColumnValue("campgn_no", dom));
if ( childNodeName.equalsIgnoreCase("line_no__bom"))
if (workOrder != null && workOrder.trim().length() > 0 && campgnNo != null && campgnNo.trim().length() > 0)
{
lineNoBOM = checkNull(genericUtility.getColumnValue("line_no__bom", dom));
bomcode = checkNull(genericUtility.getColumnValue("bom_code", dom));
lineNo = checkNull(genericUtility.getColumnValue("line_no", dom));
System.out.println("@@@@@@lineNoBOM["+lineNoBOM+"]"+"bomcode["+bomcode+"]");
if(lineNoBOM == null || lineNoBOM.trim().length() == 0)
errCode = "INVTRANS";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if((workOrder==null || workOrder.trim().length()==0) && (campgnNo==null|| campgnNo.trim().length()==0))
{
errCode = "VTCMPWORD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(workOrder!=null && workOrder.trim().length()>0)
{
if (!(isExist(conn, "workorder", "work_order", workOrder)))
{
errCode = "VTLINEBLK1";
errCode = "VTWORDNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if( lineNoBOM != null && lineNoBOM.length() > 0 )
{
sql = "select count(1) from bomdet where bom_code = ? and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomcode);
pstmt.setString(2,lineNoBOM);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
}
}
}
if(childNodeName.equalsIgnoreCase("campgn_no"))
{
workOrder = checkNull(genericUtility.getColumnValue("work_order", dom));
campgnNo = checkNull(genericUtility.getColumnValue("campgn_no", dom));
if(campgnNo!=null && campgnNo.trim().length()>0)
{
if (!(isExist(conn, "workorder", "campgn_no", campgnNo)))
{
errCode = "VTBOMDTLN2";
errCode = "VTCMPGNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
java.util.HashSet<String> bomData=new java.util.HashSet<String>();
for(int i =0; i< dom2.getElementsByTagName("Detail2").getLength();i++)
{
updateStatus = checkNull(getCurrentUpdateFlag(dom2.getElementsByTagName("Detail2").item(i)));
System.out.println("lineno ="+genericUtility.getColumnValueFromNode("line_no",dom2.getElementsByTagName("Detail2").item(i)));
bomcode = checkNull(genericUtility.getColumnValueFromNode("bom_code",dom2.getElementsByTagName("Detail2").item(i)));
lineNoBOM = checkNull(genericUtility.getColumnValueFromNode("line_no__bom",dom2.getElementsByTagName("Detail2").item(i)));
System.out.println("bomcode = ["+bomcode+"]"+"Update Status =[ "+updateStatus+"]"+"lineNoBOM["+lineNoBOM+"]");
if(!updateStatus.equalsIgnoreCase("D"))
{
if ( ! bomData.contains(bomcode.trim()+"@"+lineNoBOM.trim()))
{
bomData.add(bomcode.trim()+"@"+lineNoBOM.trim());
}
else
{ errCode = "VTDUPBOMLN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
System.out.println("bomData LIST["+bomData+"]");
}
}
}
}
}
}
}
}
} // end for
}// end for
break; // case 1 end
}*/
}
int errListSize = errList.size();
cnt = 0;
......@@ -472,7 +248,7 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
}
catch(Exception e)
{
System.out.println("Exception : [RoadPermitIC][itemChanged( String, String )] :==>\n" + e.getMessage());
System.out.println("Exception : [WoFirmplanIC][itemChanged( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
......@@ -483,7 +259,6 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String childNodeName = null;
String sql = "",amdNo="";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
NodeList parentNodeList = null;
......@@ -498,16 +273,6 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
int currentFormNo =0;
String columnValue="",workOrder = "",campgnNo = "";
String unit="",unitpotency="",loginSiteCode="";
String linenobom="",itemref="",unitalt="",matchpoten="",adjpotency="",qtyperunit="";
String criticalitem="",supcodemfg="",mfgref="",issvariencetype="",issvarvaltype="",locusagetype="";
double minpotency =0,minqty=0,qtyper=0,qtyperalt=0,leadtime=0,conqty=0,maxbatchqty=0,minbatchqty=0,batchqty=0;
double issVarience = 0;
Timestamp validupto=null;
try
{
Calendar currentDate = Calendar.getInstance();
......@@ -552,19 +317,14 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
}
while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println(" Itemchanged called for [" + currentColumn + "] ==> [" + columnValue + "]");
/*if(currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
campgnNo = checkNull(genericUtility.getColumnValue("campaign_no", dom));
valueXmlString.append("<bom_code protect = \"1\">").append("<![CDATA["+bomcode+"]]>").append("</bom_code>");
}
else*/ if(currentColumn.trim().equalsIgnoreCase("itm_default"))
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
campgnNo = checkNull(genericUtility.getColumnValue("campgn_no", dom));
workOrder = checkNull(genericUtility.getColumnValue("work_order", dom));
System.out.println(" Itemchanged called for [" + currentColumn + "] ==> [" + columnValue + "] campgnNo [" + campgnNo + "] workOrder [" + workOrder + "]");
if ( campgnNo != null && !"null".equals(campgnNo) && campgnNo.trim().length() > 0 )
valueXmlString.append("<campgn_no protect = \"0\">").append("<![CDATA[" + campgnNo + "]]>").append("</campgn_no>");
valueXmlString.append("<work_order protect = \"0\">").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
/*if ( campgnNo != null && !"null".equals(campgnNo) && campgnNo.trim().length() > 0 )
{
valueXmlString.append("<work_order protect = \"1\">").append("<![CDATA[ ]]>").append("</work_order>");
valueXmlString.append("<campgn_no protect = \"0\">").append("<![CDATA[" + campgnNo + "]]>").append("</campgn_no>");
......@@ -573,23 +333,24 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
{
valueXmlString.append("<work_order protect = \"0\">").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<campgn_no protect = \"1\">").append("<![CDATA[ ]]>").append("</campgn_no>");
}
}*/
}
else if(currentColumn.trim().equalsIgnoreCase("campaign_no"))
/*else if(currentColumn.trim().equalsIgnoreCase("campgn_no"))
{
campgnNo = checkNull(genericUtility.getColumnValue("campgn_no", dom));
workOrder = checkNull(genericUtility.getColumnValue("work_order", dom));
System.out.println("campgnNo["+campgnNo+"]>>>>>>>>>>>>>workOrder["+workOrder+"]");
if ( campgnNo != null && !"null".equals(campgnNo) && campgnNo.trim().length() > 0 )
{
valueXmlString.append("<work_order protect = \"1\">").append("<![CDATA[]]>").append("</work_order>");
valueXmlString.append("<work_order protect = \"1\">").append("<![CDATA[]]>").append("</work_order>");
}
else
{
valueXmlString.append("<work_order protect = \"0\">").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<work_order protect = \"0\">").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
}
}
}*/
valueXmlString.append("</Detail1>");
break;
......@@ -632,25 +393,6 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
}
return valueXmlString.toString();
}
private String getCurrentUpdateFlag(Node currDetail)
{
NodeList currDetailList = null;
String updateStatus = "",nodeName = "";
int currDetailListLength = 0;
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
nodeName = currDetailList.item(i).getNodeName();
if (nodeName.equalsIgnoreCase("Attribute"))
{
updateStatus =currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
break;
}
}
return updateStatus;
}
private String checkNull(String input)
{
if(input == null)
......@@ -659,39 +401,39 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
}
return input;
}
private String isExist(String table, String field, String value,Connection conn) throws SQLException
private boolean isExist(Connection conn, String tableName, String columnName, String value) throws ITMException, RemoteException
{
String sql = "",retStr="";
PreparedStatement pstmt = null;
ResultSet rs = null ;
int cnt=0;
sql = " SELECT COUNT(1) FROM "+ table + " WHERE " + field + " = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt > 0)
ResultSet rs = null;
String sql = "";
boolean status = false;
try
{
retStr = "TRUE";
}
if( cnt == 0 )
sql = "SELECT count(*) from " + tableName + " where " + columnName + " = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, value);
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.getBoolean(1))
{
status = true;
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (Exception e)
{
retStr = "FALSE";
System.out.println("Exception in isExist ");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("@@@@ isexist["+value+"]:::["+retStr+"]:::["+cnt+"]");
return retStr;
System.out.println("returning String from isExist ");
return status;
}
private String errorType(Connection conn , String errorCode) throws ITMException
{
String msgType = "";
......
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