Commit dfb3baf1 authored by pshinde's avatar pshinde

process of Customer Item Update


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97939 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 750b5368
......@@ -14,6 +14,8 @@ import java.sql.*;
import org.w3c.dom.*;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
......@@ -70,7 +72,7 @@ public String process(Document headerDom, Document detailDom, String windowName,
ResultSet rs2 = null;
String sql = "",sql1="";
int updCnt=0;
String custCodeFrom="",custCodeTo="";
String custCodeFrom="",custCodeTo="",preCustCode="";
String siteCodeFr="",siteCodeTo="";
String itemCodeFrom="",itemCodeTo="";
String integralQty="";
......@@ -83,7 +85,7 @@ public String process(Document headerDom, Document detailDom, String windowName,
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
HashMap<String,Double>minQtyMap = new HashMap<String,Double>();
try
{
ConnDriver connDriver = new ConnDriver();
......@@ -91,7 +93,8 @@ public String process(Document headerDom, Document detailDom, String windowName,
connDriver = null;
conn.setAutoCommit(false);
//custCodeFrom = checkNull(genericUtility.getColumnValue("cust_code__from",headerDom ));
//custCodeTo= checkNull(genericUtility.getColumnValue("cust_code__to",headerDom ));
siteCodeFr = checkNull(genericUtility.getColumnValue("site_code__fr",headerDom ));
siteCodeTo= checkNull(genericUtility.getColumnValue("site_code__to",headerDom ));
itemCodeFrom = checkNull(genericUtility.getColumnValue("item_code__from",headerDom ));
......@@ -103,7 +106,8 @@ public String process(Document headerDom, Document detailDom, String windowName,
intQty=Double.parseDouble(integralQty);
}
//System.out.println("custCodeFrom========="+custCodeFrom);
//System.out.println("custCodeTo========="+custCodeTo);
System.out.println("siteCodeFr========="+siteCodeFr);
System.out.println("siteCodeTo========="+siteCodeTo);
System.out.println("itemCodeFrom========="+itemCodeFrom);
......@@ -119,32 +123,37 @@ public String process(Document headerDom, Document detailDom, String windowName,
rs=pstmt.executeQuery();
while(rs.next())
{
custCode=rs.getString("cust_code");
custCode1=rs.getString("cust_code");
siteCode=rs.getString("site_code");
System.out.println("Getting cust code from site_customer====="+custCode);
System.out.println("Getting cust code from site_customer====="+custCode1);
System.out.println("Getting site Code from site_customer====="+siteCode);
// sql="select (case when integral_qty is null then 0 else integral_qty end) as integral_qty,cust_code,item_code from customeritem where item_code >= ? and item_code <= ? and cust_code >= ? and cust_code <= ? order by item_code";
sql="select (case when integral_qty is null then 0 else integral_qty end) as integral_qty,cust_code,item_code from customeritem where item_code >= ? and item_code <= ? and cust_code= ? order by item_code";
sql="select item_code, (case when integral_qty is null then 0 else integral_qty end) as integral_qty,cust_code from customeritem where item_code >= ? and item_code <= ? and cust_code= ? order by item_code";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1,itemCodeFrom);
pstmt1.setString(2,itemCodeTo);
pstmt1.setString(3,custCode);
pstmt1.setString(3,custCode1);
//pstmt1.setString(4,custCodeTo);
rs1=pstmt1.executeQuery();
while(rs1.next())
{
intQtyExst=rs1.getDouble("integral_qty");
custCode1=rs1.getString("cust_code");
custCode=rs1.getString("cust_code");
itemCode=rs1.getString("item_code");
System.out.println("custCode11========"+custCode1);
System.out.println("custCode11========"+custCode);
System.out.println("itemCode========"+itemCode);
System.out.println("Intergral Qty existing========"+intQtyExst);
if(minQtyMap.size()!=0)
{
System.out.println("$$$$$$$Map is not empty");
System.out.println("minQtyMap============="+minQtyMap);
if(!minQtyMap.containsKey(itemCode))
{
System.out.println("!minQtyMap.containsValue(itemCode)%%%%%%%%%%%%%%");
//sql="select min(case when integral_qty is null then 0 else integral_qty end) as min_qty from customeritem where item_code = ?";
sql="select min(case when integral_qty is null then 0 else integral_qty end) as min_qty " +
"from customeritem " +
......@@ -157,6 +166,7 @@ public String process(Document headerDom, Document detailDom, String windowName,
if(rs2.next())
{
minQty=rs2.getDouble("min_qty");
}
pstmt2.close();
rs2.close();
......@@ -164,19 +174,40 @@ public String process(Document headerDom, Document detailDom, String windowName,
rs2 = null;
System.out.println("Getting mininum existing integral quantity for enter ItemCode======"+minQty);
if(!preItemCode.equalsIgnoreCase(itemCode))
{
System.out.println("In if itemcode does not match. ***********");
temp=minQty;
preItemCode=itemCode;
minQtyMap.put(itemCode, minQty);
}
}
else
{
System.out.println("In else item code match *****************");
minQty=temp;
System.out.println("Map is empty *************");
sql="select min(case when integral_qty is null then 0 else integral_qty end) as min_qty " +
"from customeritem " +
"where item_code = ? " +
"and cust_code in (select cust_code from site_customer where site_code = ?) ";
pstmt2=conn.prepareStatement(sql);
pstmt2.setString(1,itemCode);
pstmt2.setString(2,siteCode);
rs2=pstmt2.executeQuery();
if(rs2.next())
{
minQty=rs2.getDouble("min_qty");
}
pstmt2.close();
rs2.close();
pstmt2 = null;
rs2 = null;
System.out.println("Getting mininum existing integral quantity for enter ItemCode======"+minQty);
minQtyMap.put(itemCode, minQty);
}
System.out.println("minQtyMap== check==========="+minQtyMap);
minQty= minQtyMap.get(itemCode);
System.out.println("minQty==from map== ============"+minQty);
System.out.println("Getting minimum quantity through map:===="+minQty);
if(intQtyExst <= minQty)
{
System.out.println("intQtyExst before if======"+intQtyExst);
......@@ -293,6 +324,9 @@ public String process(Document headerDom, Document detailDom, String windowName,
}
}
\ No newline at end of file
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