Commit 0d11f49c authored by msalla's avatar msalla

Link to show missing item in channel partner purchase order to be shown in SO and despatch

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202262 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b32b822f
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class MissingItem extends ValidatorEJB {
CommonConstants commonConstants = new CommonConstants();
public ArrayList getMissingSordDet(String salesOrder,UserInfoBean userInfo) throws RemoteException, ITMException {
// TODO Auto-generated method stub
E12GenericUtility genericUtility = new E12GenericUtility();
ArrayList<MissingItemBean> missingitemList = new ArrayList<MissingItemBean>();
PreparedStatement pstmt = null,pstmt1=null;
ResultSet rs = null,rs1=null;
Connection conn = null;
String sql,itemCodeOrd = null,itemDescr,chPartner = null;
String retString="";
String siteCode="",custCode="";
String disLink="";
String suppCodemnfr,suppCodeCh= null,siteCodeCh = null,itemCode = null;
int cntPO = 0;
//Connection connCP=null;
//ConnDriver connDriver = new ConnDriver();
String itemSer = null;
try
{
System.out.println("enter the loop");
ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB(userInfo);
if (conn == null)
{
setUserInfo(userInfo);
conn = getConnection();
}
conn.setAutoCommit(false);
connDriver = null;
//to find cust_code,site_code from sorder
sql="select cust_code,site_code,item_ser from sorder where sale_order=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,salesOrder);
rs=pstmt.executeQuery();
if(rs.next())
{
siteCode=rs.getString("site_code");
custCode=rs.getString("cust_code");
itemSer=rs.getString("item_ser");
}
System.out.println("SITE_CODE IS:"+siteCode);
System.out.println("custCode IS:"+custCode);
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//to find channelpartner,site_code_ch from site_customer
sql="select channel_partner, DIS_LINK, SITE_CODE__CH from site_customer where cust_code = ? and site_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,custCode);
pstmt.setString(2,siteCode);
rs=pstmt.executeQuery();
if(rs.next())
{
chPartner=rs.getString(1);
disLink=rs.getString(2);
siteCodeCh=rs.getString(3);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("channel partner:"+chPartner);
System.out.println("channel partner:"+disLink);
System.out.println("channel partner:"+siteCodeCh);
if(chPartner.trim().length()==0)
{
//to find channelpartner,site_code_ch from customer
sql="select channel_partner, dis_link,site_code from customer where cust_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,custCode);
rs=pstmt.executeQuery();
if(rs.next())
{
chPartner=rs.getString(1);
disLink=rs.getString(2);
siteCodeCh=rs.getString(3);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
if("Y".equalsIgnoreCase(chPartner))
{
//to find supp_code ,from site_supplier
sql=" select supp_code from site_supplier where site_code = ? and site_code__ch = ? and channel_partner = 'Y' ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCodeCh);
pstmt.setString(2,siteCode);
rs=pstmt.executeQuery();
if(rs.next())
{
suppCodeCh=rs.getString("supp_code");
suppCodemnfr=suppCodeCh;
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
if(suppCodeCh.trim().length()==0)
{
//to find supp_code from supplier
sql=" select supp_code from supplier where site_code = ? and channel_partner = 'Y'";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs=pstmt.executeQuery();
if(rs.next())
{
suppCodeCh=checkNull(rs.getString("supp_code")).trim();
suppCodemnfr=suppCodeCh;
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
//to find item_code_ord and item descr from sorddet
sql="select ITEM_CODE__ORD,ITEM_DESCR from sorddet where SALE_ORDER=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,salesOrder);
rs=pstmt.executeQuery();
while(rs.next())
{
itemCode=rs.getString("ITEM_CODE__ORD");
itemDescr=rs.getString("ITEM_DESCR");
sql = "select count(*) from porder a, porddet b"
+ " where a.purc_order = b.purc_order "
+ " and a.supp_code = ? and a.site_code__dlv = ? "
+ " and a.item_ser = ? and b.item_code = ? "
+ " and a.status = 'O' ";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1,suppCodeCh);
pstmt1.setString(2,siteCodeCh);
pstmt1.setString(3,itemSer);
pstmt1.setString(4,itemCode);
rs1=pstmt1.executeQuery();
if(rs1.next()) {
cntPO=rs1.getInt(1);
System.out.println("count missing data:"+cntPO);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
if(cntPO==0) {
System.out.println("item is missing"+itemCode);
MissingItemBean missingbean=new MissingItemBean();
missingbean.setItemCode(itemCode);
missingbean.setItemDesc(itemDescr);
missingitemList.add(missingbean);
}
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
genericUtility = null;
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(conn != null)
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println("Exception :MissingItem detail:==>\n"+e.getMessage());
}
}
return missingitemList;
}
private String checkNull(String string) {
// TODO Auto-generated method stub
if (string == null) {
string = "";
}
return string;
}
}
package ibase.webitm.ejb.dis;
import ibase.system.config.AppConnectParm;
import ibase.utility.UserInfoBean;
import ibase.webitm.utility.ITMException;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import javax.naming.InitialContext;
public class MissingItemBean implements Serializable{
private String itemCode;
private String itemDesc;
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getItemDesc() {
return itemDesc;
}
public void setItemDesc(String itemDesc) {
this.itemDesc = itemDesc;
}
}
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