博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数据模型封装--按行显示(java)
阅读量:4118 次
发布时间:2019-05-25

本文共 6799 字,大约阅读时间需要 22 分钟。

 

上面商标显示不包括数据表

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;/** * 

Title:

* *

Description: 商标Bean

* *

Company: sinotrust

* * @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
regNo; // 注册号 private int size;//在注册号个数 private Map
regDate; //注册时间(key: 注册号, val: 注册时间) private Map
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
queryForImageIcon(CommonDAO commonDAO, List
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
res = new LinkedHashMap
(); 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
brandImage) { this.brandImage = brandImage; } public Map
getBrandImage() { if (this.brandImage == null) { this.brandImage = new LinkedHashMap
(); } return this.brandImage; } public int getBrandTotal() { return this.brandTotal; } public void setBrandTotal(int brandTotal) { this.brandTotal = brandTotal; } public Map
getRegDate() { if (this.regDate == null) { this.regDate = new LinkedHashMap
(); } return this.regDate; } public List
getRegNo() { if (this.regNo == null) { this.regNo = new ArrayList
(); } 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; } }

 

转载地址:http://nedpi.baihongyu.com/

你可能感兴趣的文章
LeetCode第44题思悟——通配符匹配(wildcard-matching)
查看>>
LeetCode第45题思悟——跳跃游戏(jump-game-ii)
查看>>
LeetCode第46题思悟——全排列(permutations)
查看>>
LeetCode第47题思悟—— 全排列 II(permutations-ii)
查看>>
LeetCode第48题思悟——旋转图像(rotate-image)
查看>>
驱动力3.0,动力全开~
查看>>
记CSDN访问量10万+
查看>>
Linux下Oracle数据库账户被锁:the account is locked问题的解决
查看>>
记CSDN访问20万+
查看>>
Windows 环境下Webstorm 2020.3 版本在右下角找不到Git分支切换部件的一种解决方法
查看>>
Electron-Vue项目中遇到fs.rm is not a function问题的解决过程
查看>>
飞机换乘次数最少问题的两种解决方案
查看>>
有向无回路图的理解
查看>>
设计模式中英文汇总分类
查看>>
WPF实现蜘蛛纸牌游戏
查看>>
单例模式
查看>>
工厂方法模式
查看>>
模板方法模式
查看>>
数据结构之队列、栈
查看>>
数据结构之树
查看>>