上面商标显示不包括数据表
package ims.sinotrust.bean;
/**
* 创建日期:2006年10月31日
*/
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import snt.common.dao.base.CommonDAO;
import snt.common.dao.base.ICommonDAOService;
import snt.common.web.util.WebUtils;
import snt.common.rs.MemoryResultSet;
/**
* <p>Title: </p>
*
* <p>Description: 商标Bean</p>
*
* <p>Company: sinotrust</p>
*
* @author lizheng
*
*/
public class BrandInfoBean extends CreditReportViewBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static Log logger = LogFactory.getLog(BrandInfoBean.class);
private int brandTotal = -1; //商标总数 , 最大值 3 ,只提供目标公司最近注册的三种商标情况
private String sbrandTotal;
private List<String> regNo; // 注册号
private int size;//在注册号个数
private Map<String, Date> regDate; //注册时间(key: 注册号, val: 注册时间)
private Map<String, ImageIcon> brandImage; //商标图案(key: 注册号, val: 注册时间)
private Date updateTime; //更新时间
/**
*
*/
public BrandInfoBean() {
super();
}
/**
* 从同一个数据库中查询商标及商标图案信息(主要用于Sql Server)
* @param query
* @param SBDNum
* @return
*/
public boolean getBrandInfoBean(ICommonDAOService query,String SBDNum) {
long stime = System.currentTimeMillis();
String sql = WebUtils.getMessage("sql", "BrandInfoBean.only", new Object[]{SBDNum, SBDNum});
logger.info("商标及图案----" + sql);
MemoryResultSet res = query.queryForResultSet(sql);
int size = res != null ? res.getResultList().size() : -1;
if (size <= 0) {//数据为空
return false;
}
try {
this.setBrandTotal(size > 3 ? 3 : size);
this.setSbrandTotal(this.changeType(this.getBrandTotal()));
size = 0;
res.beforeFirst();
while (res.next() && size ++ < this.getBrandTotal() ) {
String regNo = this.changeType(res.getString("RegNo"));
this.getRegNo().add(regNo);
this.getRegDate().put(regNo, this.changeTypeForDate(res.getObject("RegDate")));
this.getBrandImage().put(regNo, new ImageIcon(ImageIO.read(res.getBlob("fImage").getBinaryStream())));
}
} catch (SQLException e) {
logger.error("封装BrandInfoBean出错!", e);
return false;
} catch (IOException e) {
logger.error("封装BrandInfoBean出错!---生成图片出错: ", e);
return false;
}
logger.debug("新华信编号:"+SBDNum+" 商标及图案耗时:"+(System.currentTimeMillis()-stime)+"毫秒");
return true;
}
/**
* 从两个数据库中查询商标及商标图案信息(主要用于db2 + Sql Server)
* 其中 query 用于DB2的查询,commonDao用于 Sql Server 查询。
* @param query
* @param commonDAO
* @param SBDNum
* @return
*/
public boolean getBrandInfoBean(ICommonDAOService query, CommonDAO commonDAO, String SBDNum) {
long stime = System.currentTimeMillis();
MemoryResultSet res = this.query(query, SBDNum);
int size = res != null ? res.getResultList().size() : -1;
if (size <= 0) {//数据为空
return false;
}
try {
this.setBrandTotal(size > 3 ? 3 : size);
size = 0;
res.beforeFirst();
while (res.next() && size ++ < this.getBrandTotal() ) {
String regNo = this.changeType(res.getString("RegNo"));
this.getRegNo().add(regNo);
this.getRegDate().put(regNo, this.changeTypeForDate(res.getObject("RegDate")));
}
this.setSize(this.getRegNo().size());
} catch (SQLException e) {
logger.error("封装BrandInfoBean出错!", e);
return false;
}
try {
this.setBrandImage(this.queryForImageIcon(commonDAO, this.getRegNo()));
} catch (SQLException e) {
logger.error("封装BrandInfoBean出错!", e);
return false;
} catch (IOException e) {
logger.error("封装BrandInfoBean出错!---生成图片出错: ", e);
return false;
}
logger.debug("新华信编号:"+SBDNum+" 封装BrandInfoBean耗时:"+(System.currentTimeMillis()-stime)+"毫秒");
return true;
}
/**
* 从数据库中查询相应数据
* @param query
* @param SBDNum
* @return
*/
private MemoryResultSet query(ICommonDAOService query,String SBDNum) {
// String sql = "select ti.RegNo,RegDate, tm.fImage from t_BrandInfo as ti, tTMImage as tm where case when BRANDCNAME is null or rtrim(ltrim(BRANDCNAME)) = '' then BRANDENAME else BRANDCNAME end + convert(varchar,regdate) in ( select a.brandname + convert(varchar,a.regdate) from ( SELECT case when BRANDCNAME is null or rtrim(ltrim(BRANDCNAME)) = '' then BRANDENAME else BRANDCNAME end as brandname,max(REGDATE) as REGDATE FROM t_BrandInfo where sbdnum = ? GROUP BY case when BRANDCNAME is null or rtrim(ltrim(BRANDCNAME)) = '' then BRANDENAME else BRANDCNAME end ) as a ) and ti.regno = tm.fTMID and sbdnum = ? order by REGDATE desc";
String sql = WebUtils.getMessage("sql", "BrandInfoBean.sql", new Object[]{SBDNum, SBDNum});
logger.info("商标----" + sql);
return query.queryForResultSet(sql);
}
/**
* 查询商标图片,仅在连接两个数据库时用于查询对应 注册号 的商标用
* @param commonDao
* @return
* @throws SQLException
* @throws IOException
*/
public Map<String, ImageIcon> queryForImageIcon(CommonDAO commonDAO, List<String> regNos) throws SQLException, IOException {
StringBuffer para = new StringBuffer();
para.append("'" + regNos.get(0) + "'");
for (int i = 1; i < regNos.size(); i++) {
para.append(",'" + regNos.get(i) + "'");
}
String sql = WebUtils.getMessage("sql", "BrandInfoBean.img", new Object[]{para.toString()});
logger.info("商标图案-----" + sql);
MemoryResultSet queryRes = commonDAO.queryForResultSet(sql);
Map<String, ImageIcon> res = new LinkedHashMap<String, ImageIcon>();
queryRes.beforeFirst();
while (queryRes.next()) {
res.put(queryRes.getString("RegNo"), (ImageIO.read(queryRes.getBlob("fImage").getBinaryStream()) == null ? null : new ImageIcon(ImageIO.read(queryRes.getBlob("fImage").getBinaryStream()))));
}
return res;
}
public void setBrandImage(Map<String, ImageIcon> brandImage) {
this.brandImage = brandImage;
}
public Map<String, ImageIcon> getBrandImage() {
if (this.brandImage == null) {
this.brandImage = new LinkedHashMap<String, ImageIcon>();
}
return this.brandImage;
}
public int getBrandTotal() {
return this.brandTotal;
}
public void setBrandTotal(int brandTotal) {
this.brandTotal = brandTotal;
}
public Map<String, Date> getRegDate() {
if (this.regDate == null) {
this.regDate = new LinkedHashMap<String, Date>();
}
return this.regDate;
}
public List<String> getRegNo() {
if (this.regNo == null) {
this.regNo = new ArrayList<String>();
}
return regNo;
}
public Date getUpdateTime() {
if (this.updateTime == null) {
for (String regNo : this.getRegDate().keySet()) {
if (this.updateTime == null
|| (this.getRegDate().get(regNo)) != null && this.getRegDate().get(regNo).before(this.updateTime) ) {
this.setUpdateTime(this.getRegDate().get(regNo));
}
}
}
return this.updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getSbrandTotal() {
return sbrandTotal;
}
public void setSbrandTotal(String sbrandTotal) {
this.sbrandTotal = sbrandTotal;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
}