Commit 9f862959 authored by pshinde's avatar pshinde

process of Customer Item Update


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97933 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 56125e6f
......@@ -64,16 +64,19 @@ public String process(Document headerDom, Document detailDom, String windowName,
boolean isError = false;
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
PreparedStatement pstmt2 = null;
ResultSet rs = null;
ResultSet rs1 = null;
ResultSet rs2 = null;
String sql = "",sql1="";
int updCnt=0;
String custCodeFrom="",custCodeTo="";
String siteCodeFr="",siteCodeTo="";
String itemCodeFrom="",itemCodeTo="";
String integralQty="";
double intQty=0,minQty=0,intQtyExst=0,temp=0;
String custCode="",itemCode="",preItemCode="";
String custCode="",itemCode="",preItemCode="",custCode1="",siteCode="";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
......@@ -88,8 +91,9 @@ 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 ));
itemCodeTo = checkNull(genericUtility.getColumnValue("item_code__to",headerDom ));
integralQty = checkNull(genericUtility.getColumnValue("integral_qty",headerDom ));
......@@ -99,47 +103,66 @@ 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);
System.out.println("itemCodeTo========="+itemCodeTo);
System.out.println("integralQty========="+integralQty);
System.out.println("intQty========="+intQty);
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";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCodeFrom);
pstmt.setString(2,itemCodeTo);
pstmt.setString(3,custCodeFrom);
pstmt.setString(4,custCodeTo);
sql="select cust_code,site_code from site_customer where site_code >= ? and site_code <= ? order by site_code ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCodeFr);
pstmt.setString(2,siteCodeTo);
rs=pstmt.executeQuery();
while(rs.next())
{
intQtyExst=rs.getDouble("integral_qty");
custCode=rs.getString("cust_code");
itemCode=rs.getString("item_code");
siteCode=rs.getString("site_code");
System.out.println("Getting cust code from site_customer====="+custCode);
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";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1,itemCodeFrom);
pstmt1.setString(2,itemCodeTo);
pstmt1.setString(3,custCode);
//pstmt1.setString(4,custCodeTo);
rs1=pstmt1.executeQuery();
while(rs1.next())
{
intQtyExst=rs1.getDouble("integral_qty");
custCode1=rs1.getString("cust_code");
itemCode=rs1.getString("item_code");
System.out.println("custCode========"+custCode);
System.out.println("custCode11========"+custCode1);
System.out.println("itemCode========"+itemCode);
System.out.println("Intergral Qty existing========"+intQtyExst);
sql="select min(case when integral_qty is null then 0 else integral_qty end) as min_qty from customeritem where item_code = ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1,itemCode);
rs1=pstmt1.executeQuery();
if(rs1.next())
//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 " +
"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=rs1.getDouble("min_qty");
minQty=rs2.getDouble("min_qty");
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
System.out.println("Getting mininum existing integral quantity======"+minQty);
pstmt2.close();
rs2.close();
pstmt2 = null;
rs2 = null;
System.out.println("Getting mininum existing integral quantity for enter ItemCode======"+minQty);
if(!preItemCode.equalsIgnoreCase(itemCode))
{
......@@ -177,28 +200,33 @@ public String process(Document headerDom, Document detailDom, String windowName,
sql1="update customeritem set integral_qty= ? where item_code= ? and cust_code= ? ";
System.out.println("sql :" + sql1);
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1,intQtyExst);
pstmt1.setString(2,itemCode);
pstmt1.setString(3,custCode);
pstmt2 = conn.prepareStatement(sql1);
pstmt2.setDouble(1,intQtyExst);
pstmt2.setString(2,itemCode);
pstmt2.setString(3,custCode);
updCnt = pstmt1.executeUpdate();
updCnt = pstmt2.executeUpdate();
System.out.println(updCnt + " Records Updated");
if(updCnt>0)
{
System.out.println("Process Sucessful");
}
pstmt1.close();
pstmt1 = null;
pstmt2.close();
pstmt2 = null;
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
} // end of try code
catch(Exception e)
{
......
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