Commit 6ae90cf8 authored by ngadkari's avatar ngadkari

changes for new column added ref_no

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@206167 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ce137fde
...@@ -16,6 +16,7 @@ import java.text.SimpleDateFormat; ...@@ -16,6 +16,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.naming.InitialContext; import javax.naming.InitialContext;
...@@ -452,12 +453,20 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit ...@@ -452,12 +453,20 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
NodeList childNodeList = null; NodeList childNodeList = null;
String columnValue="",loginSite="",siteCode="",siteDescr="",custCode="",custName="", baseQty = "", freeQty = ""; String columnValue="",loginSite="",siteCode="",siteDescr="",custCode="",custName="";
String sSQL ="", userId = "", chgTerm = ""; String sSQL ="", userId = "", chgTerm = "";
String itemCode = "", itemDescr ="", todayDate = ""; String itemCode = "", itemDescr ="", todayDate = "";
int domID=0; int domID=0;
String effFrom = "", validUpto = ""; String effFrom = "", validUpto = "";
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
//added by nandkumar gadkari on 22/08/19-------------
String effDateStr="",year="",month="",refNo="",itemList="",nature="",schemeCode="",effDate="";
ArrayList<String> itemCodeList = new ArrayList<String>();
double qtyPer=0,baseQty=0,freeQty=0;
int cnt=0;
Iterator<String> itr = null;
//added by nandkumar gadkari on 22/08/19---------------
try try
{ {
conn = getConnection(); conn = getConnection();
...@@ -540,7 +549,7 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit ...@@ -540,7 +549,7 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit
} }
else if("cust_code".equalsIgnoreCase(currentColumn.trim())) else if("cust_code".equalsIgnoreCase(currentColumn.trim()))
{ {
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom)); custCode = checkNullandTrim(genericUtility.getColumnValue("cust_code", dom));
System.out.println("Customer Code is ===="+custCode); System.out.println("Customer Code is ===="+custCode);
sSQL = "select cust_name from customer where cust_code = ?"; sSQL = "select cust_name from customer where cust_code = ?";
pstmt = conn.prepareStatement(sSQL); pstmt = conn.prepareStatement(sSQL);
...@@ -562,7 +571,71 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit ...@@ -562,7 +571,71 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit
pstmt = null; pstmt = null;
} }
valueXmlString.append("<cust_name><![CDATA[").append(custName).append( "]]></cust_name>\r\n"); valueXmlString.append("<cust_name><![CDATA[").append(custName).append( "]]></cust_name>\r\n");
//added by nandkumar gadkari on 22/08/19----------------start-----------------------------------------------------
effDate = checkNull(genericUtility.getColumnValue("eff_from",dom)).trim();
if((effDate != null && effDate.trim().length() > 0))
{
sSQL = "select to_char(to_date(?),'YYYY') || to_char(to_date(?),'MM') from dual";
pstmt = conn.prepareStatement(sSQL);
pstmt.setString(1,effDate);
pstmt.setString(2,effDate);
rs = pstmt.executeQuery();
if(rs.next())
{
year = rs.getString(1);
System.out.println("year>>>>>>>>>"+custCode+year);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
} }
valueXmlString.append("<ref_no><![CDATA[").append(custCode+year).append( "]]></ref_no>");
}
}
else if("eff_from".equalsIgnoreCase(currentColumn.trim()))
{
custCode = checkNullandTrim(genericUtility.getColumnValue("cust_code", dom));
effDate = checkNull(genericUtility.getColumnValue("eff_from",dom)).trim();
if((effDate != null && effDate.trim().length() > 0))
{
sSQL = "select to_char(to_date(?),'YYYY') || to_char(to_date(?),'MM') from dual";
pstmt = conn.prepareStatement(sSQL);
pstmt.setString(1,effDate);
pstmt.setString(2,effDate);
rs = pstmt.executeQuery();
if(rs.next())
{
year = rs.getString(1);
System.out.println("year>>>>>>>>>"+custCode+year);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<ref_no><![CDATA[").append(custCode+year).append( "]]></ref_no>");
}
}
//added by nandkumar gadkari on 22/08/19----------------end-----------
valueXmlString.append("<chg_user><![CDATA[").append(userId).append( "]]></chg_user>"); valueXmlString.append("<chg_user><![CDATA[").append(userId).append( "]]></chg_user>");
valueXmlString.append("<chg_term><![CDATA[").append(chgTerm).append( "]]></chg_term>"); valueXmlString.append("<chg_term><![CDATA[").append(chgTerm).append( "]]></chg_term>");
valueXmlString.append("<chg_date><![CDATA[").append(todayDate).append( "]]></chg_date>"); valueXmlString.append("<chg_date><![CDATA[").append(todayDate).append( "]]></chg_date>");
...@@ -582,18 +655,146 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit ...@@ -582,18 +655,146 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1)); siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1));
effFrom = checkNull(genericUtility.getColumnValue("eff_from", dom1)); effFrom = checkNull(genericUtility.getColumnValue("eff_from", dom1));
validUpto = checkNull(genericUtility.getColumnValue("valid_upto", dom1)); validUpto = checkNull(genericUtility.getColumnValue("valid_upto", dom1));
baseQty = checkNull(genericUtility.getColumnValue("base_quantity", dom1)); baseQty = checkDoubleNull(genericUtility.getColumnValue("base_quantity", dom1));
freeQty = checkNull(genericUtility.getColumnValue("free_quantity", dom1)); freeQty = checkDoubleNull(genericUtility.getColumnValue("free_quantity", dom1));
refNo = checkNull(genericUtility.getColumnValue("ref_no", dom1));//added by nandkumar gadkari on 22/08/19
System.out.println("custCode ::::["+custCode+"]" + "siteCode ::::["+siteCode+"]"); System.out.println("custCode ::::["+custCode+"]" + "siteCode ::::["+siteCode+"]");
System.out.println("effFrom ::::["+effFrom+"]" + "validUpto ::::["+validUpto+"]"); System.out.println("effFrom ::::["+effFrom+"]" + "validUpto ::::["+validUpto+"]");
System.out.println("baseQty ::::["+baseQty+"]" + "freeQty ::::["+freeQty+"]"); System.out.println("baseQty ::::["+baseQty+"]" + "freeQty ::::["+freeQty+"]");
System.out.println("refNo ::::["+refNo+"]");
if("itm_default".equalsIgnoreCase(currentColumn.trim())) if("itm_default".equalsIgnoreCase(currentColumn.trim()))
{ {
//added by nandkumar gadkari on 22/08/19----------------START-----------
sSQL = "SELECT SCHEME_CODE FROM SCHEME_APPLICABILITY WHERE REF_NO= ? ";
pstmt = conn.prepareStatement(sSQL);
pstmt.setString(1,refNo);
rs = pstmt.executeQuery();
while(rs.next())
{
schemeCode = rs.getString(1);
if(schemeCode != null && schemeCode.trim().length() > 0)
{
sSQL = "SELECT ITEM_CODE from SCHEME_APPLICABILITY where SCHEME_CODE= ? ";
pstmt1 = conn.prepareStatement(sSQL);
pstmt1.setString(1,schemeCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
itemCode = rs1.getString(1);
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
sSQL = "select qty_per,NATURE from bomdet where BOM_CODE= ? ";
pstmt1 = conn.prepareStatement(sSQL);
pstmt1.setString(1,schemeCode);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
qtyPer = rs1.getDouble(1);
nature=rs1.getString(2);
nature = nature == null || nature.trim().length() == 0 ? "" : nature.trim();
if("C".equalsIgnoreCase(nature))
{
baseQty=qtyPer;
}
if("F".equalsIgnoreCase(nature))
{
freeQty=qtyPer;
}
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
sSQL = "select descr from item where item_code = ?";
pstmt1 = conn.prepareStatement(sSQL);
pstmt1.setString(1,itemCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
itemDescr = checkNull(rs1.getString("descr"));
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
domID++;
valueXmlString.append("<Detail2 domID='" + domID + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected='Y' updateFlag='A' status='N' pkNames='' />");
valueXmlString.append("<item_code><![CDATA[" ).append(itemCode).append( "]]></item_code>\r\n" );
valueXmlString.append("<descr><![CDATA[" ).append(itemDescr).append( "]]></descr>\r\n" );
valueXmlString.append("<tran_id><![CDATA[" ).append("").append( "]]></tran_id>\r\n" );
valueXmlString.append("<line_no><![CDATA[" ).append(domID).append( "]]></line_no>\r\n" );
valueXmlString.append("<chargeable_qty><![CDATA[" ).append(baseQty).append( "]]></chargeable_qty>\r\n" );
valueXmlString.append("<free_qty><![CDATA[" ).append(freeQty).append( "]]></free_qty>\r\n" );
valueXmlString.append("<cust_code><![CDATA[" ).append(custCode).append( "]]></cust_code>\r\n" );
valueXmlString.append("<site_code><![CDATA[" ).append(siteCode).append( "]]></site_code>\r\n" );
valueXmlString.append("<ref_no><![CDATA[" ).append(refNo).append( "]]></ref_no>\r\n" );
valueXmlString.append("<scheme_code><![CDATA[" ).append(schemeCode).append( "]]></scheme_code>\r\n" );
valueXmlString.append("</Detail2>\r\n");
itemCodeList.add(itemCode);
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
cnt =itemCodeList.size();
System.out.println("^^^^^^^itemCodeList itemCodeList["+itemCodeList);
if(cnt > 0)
{
itemList = "";
itr = itemCodeList.iterator();
while(itr.hasNext())
{
itemList = itemList + "'"+(String) itr.next() + "'";
if(itr.hasNext())
{
itemList=itemList+ ",";
}
}
}
itemList=itemList == null || itemList.trim().length() == 0 ? "' '" : itemList;
baseQty = checkDoubleNull(genericUtility.getColumnValue("base_quantity", dom1));
freeQty = checkDoubleNull(genericUtility.getColumnValue("free_quantity", dom1));
//added by nandkumar gadkari on 22/08/19----------------end-----------
sSQL = "select descr from item where item_code = ?"; sSQL = "select descr from item where item_code = ?";
pstmt1 = conn.prepareStatement(sSQL); pstmt1 = conn.prepareStatement(sSQL);
sSQL = "select item_code from siteitem where site_code = ?"; sSQL = "select item_code from siteitem where site_code = ? and item_code not in ("+itemList+")"; //item_code not in ( ) Condition added by nandkumar gadkari on 22/08/19
pstmt = conn.prepareStatement(sSQL); pstmt = conn.prepareStatement(sSQL);
pstmt.setString(1,siteCode); pstmt.setString(1,siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -624,6 +825,7 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit ...@@ -624,6 +825,7 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit
valueXmlString.append("<free_qty><![CDATA[" ).append(freeQty).append( "]]></free_qty>\r\n" ); valueXmlString.append("<free_qty><![CDATA[" ).append(freeQty).append( "]]></free_qty>\r\n" );
valueXmlString.append("<cust_code><![CDATA[" ).append(custCode).append( "]]></cust_code>\r\n" ); valueXmlString.append("<cust_code><![CDATA[" ).append(custCode).append( "]]></cust_code>\r\n" );
valueXmlString.append("<site_code><![CDATA[" ).append(siteCode).append( "]]></site_code>\r\n" ); valueXmlString.append("<site_code><![CDATA[" ).append(siteCode).append( "]]></site_code>\r\n" );
valueXmlString.append("<ref_no><![CDATA[" ).append(refNo).append( "]]></ref_no>\r\n" );//added by nandkumar gadkari on 22/08/19
valueXmlString.append("</Detail2>\r\n"); valueXmlString.append("</Detail2>\r\n");
} }
...@@ -1074,6 +1276,10 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit ...@@ -1074,6 +1276,10 @@ public class SchemeDefinitionWizIC extends ValidatorEJB implements SchemeDefinit
{ {
return input == null ? "" : input; return input == null ? "" : input;
} }
private String checkNullandTrim(String input)
{
return input == null ? "" : input.trim();
}
} }
......
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