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

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

只是下边那个数据表右侧的年不固定

package ims.sinotrust.bean;/** * 创建日期:2006年10月31日 */import ims.sinotrust.util.FormatBigDecimal;import java.io.Serializable;import java.util.Date;import java.util.LinkedHashMap;import java.util.Map;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import snt.common.dao.base.ICommonDAOService;import snt.common.rs.MemoryResultSet;import snt.common.web.util.UtilDateConverter;import snt.common.web.util.WebUtils;/** * 

Title:

* *

Description: 专利Bean

* *

Company: sinotrust

* * @author lizheng * */public class PatentInfoBean extends CreditReportViewBean implements Serializable { /** * */ /** 发明专利 */ public static final String INVENT_BRAND = "1"; /** 实用新型专利 */ public static final String PRACTICAL_BRAND = "2"; /** 外观设计专利 */ public static final String SURFACE_BRAND = "3"; private static final long serialVersionUID = 1L; private static Log logger = LogFactory.getLog(PatentInfoBean.class); private Date updateTime; //更新时间 private String year = ""; //年度(如:2005, 则表示 2005 年的专利情况,note:如果为 0 则表示所有年度专利情况, 默认值 "") private String patentTotalSize;//专利总数(合计) private String inventBrandSize;//发明专利数量(合计) private String practicalBrandSize;//实用新型专利数量(合计) private String surfaceBrandSize;//外观设计专利数量(合计) /** * */ public PatentInfoBean() { super(); } public Map
getPatentInfoBean(ICommonDAOService query,String SBDNum) { long stime = System.currentTimeMillis(); Map
patentInfoMap = new LinkedHashMap
(); MemoryResultSet res = this.query(query, SBDNum); if (res == null || res.getResultList().size() <= 0) { return null; } patentInfoMap.put("0", new PatentInfoBean()); try { boolean isAddPatentMap = true; //计算总的专利数 int[] cnt = {0, 0, 0, 0}; //专利总数计数器(按专利类型分,0: 所有类型 1: 发明专利, 2: 实用新型专利, 3: 外观设计专利) res.beforeFirst(); while (res.next() && patentInfoMap.size()<4) { String tempYear = res.getString("AFFICHEYEAR"); // 年度 PatentInfoBean patentInfoBean = patentInfoMap.get(tempYear); if(patentInfoBean == null){ patentInfoBean = new PatentInfoBean(); patentInfoMap.put(tempYear, patentInfoBean); } patentInfoBean.setYear(tempYear+WebUtils.getMessage("java._ACCM00010")); cnt[0] += res.getInt("cnt"); String tempType = res.getString("istype"); int count = res.getInt("cnt"); if (PatentInfoBean.INVENT_BRAND.equalsIgnoreCase(tempType)) {// if (patentMapSize < 4 && isAddPatentMap) { patentInfoBean.setInventBrandSize(FormatBigDecimal.format(count)); // } cnt[1] += count; } else if (PatentInfoBean.PRACTICAL_BRAND.equalsIgnoreCase(tempType)) {// if (patentMapSize < 4 && isAddPatentMap) { patentInfoBean.setPracticalBrandSize(FormatBigDecimal.format(count)); // } cnt[2] += count; } else if (PatentInfoBean.SURFACE_BRAND.equalsIgnoreCase(tempType)) {// if (patentMapSize < 4 && isAddPatentMap) { patentInfoBean.setSurfaceBrandSize(FormatBigDecimal.format(count)); // } cnt[3] += count; } else { logger.error("不存在该种类型 : " + tempType); } String tempUpdateTime = res.getString("UPDATETIME"); //更新时间(字符串) Date tempDate = null; try { //2006-12-22 阳临时修改 tempDate = UtilDateConverter.parse(tempUpdateTime == null ? "" : tempUpdateTime); } catch (Throwable e) { logger.info("专利更新日期的格式不正确,不能正确转换为日期 : " + tempUpdateTime, e); } if (this.getUpdateTime() == null || (tempDate != null && tempDate.before(this.getUpdateTime()))) { this.setUpdateTime(tempDate); } isAddPatentMap = patentInfoMap.size() >= 4 ? false : true; } patentInfoMap.get("0").setYear(WebUtils.getMessage("java._ACCM00009")); patentInfoMap.get("0").setInventBrandSize(FormatBigDecimal.format(cnt[1])== null ?"--":FormatBigDecimal.format(cnt[1])); patentInfoMap.get("0").setPracticalBrandSize(FormatBigDecimal.format(cnt[2])); patentInfoMap.get("0").setSurfaceBrandSize(FormatBigDecimal.format(cnt[3])); } catch (Exception e) { logger.error("封装专利PatentInfoBean出错!", e); } logger.debug("新华信编号:"+SBDNum+" 查询专利信息:"+(System.currentTimeMillis()-stime)+"毫秒"); return patentInfoMap; } /** * 从数据库中查询相应数据 * @param query * @param SBDNum * @return */ private MemoryResultSet query(ICommonDAOService query, String SBDNum) { String sql = WebUtils.getMessage("sql", "PatentInfoBean.sql", new Object[]{SBDNum}); logger.info("专利--" + sql); return query.queryForResultSet(sql); } public String getYear() { return year; } public void setYear(String year) { this.year = year; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public void setPatentTotalSize(String patentTotalSize) { this.patentTotalSize = patentTotalSize; } public String getPatentTotalSize() { int total = 0; if(!"--".equals(getInventBrandSize())){ total = total + Integer.parseInt(getInventBrandSize()); } if(!"--".equals(getPracticalBrandSize())){ total = total + Integer.parseInt(getPracticalBrandSize()); } if(!"--".equals(getSurfaceBrandSize())){ total = total + Integer.parseInt(getSurfaceBrandSize()); } if(total == 0){ return "--"; }else{ patentTotalSize = String.valueOf(total); } return patentTotalSize; } public String getInventBrandSize() { if(inventBrandSize == null){ return "--"; } return inventBrandSize; } public void setInventBrandSize(String inventBrandSize) { this.inventBrandSize = inventBrandSize; } public String getPracticalBrandSize() { if(practicalBrandSize == null){ return "--"; } return practicalBrandSize; } public void setPracticalBrandSize(String practicalBrandSize) { this.practicalBrandSize = practicalBrandSize; } public String getSurfaceBrandSize() { if(surfaceBrandSize == null){ return "--"; } return surfaceBrandSize; } public void setSurfaceBrandSize(String surfaceBrandSize) { this.surfaceBrandSize = surfaceBrandSize; } }

 

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

你可能感兴趣的文章
Vue动态生成el-checkbox点击无法选中的解决方法
查看>>
python __future__
查看>>
MySQL Tricks1
查看>>
python 变量作用域问题(经典坑)
查看>>
pytorch
查看>>
pytorch(二)
查看>>
pytorch(三)
查看>>
pytorch(四)
查看>>
pytorch(5)
查看>>
pytorch(6)
查看>>
ubuntu相关
查看>>
C++ 调用json
查看>>
nano中设置脚本开机自启动
查看>>
动态库调动态库
查看>>
Kubernetes集群搭建之CNI-Flanneld部署篇
查看>>
k8s web终端连接工具
查看>>
手绘VS码绘(一):静态图绘制(码绘使用P5.js)
查看>>
手绘VS码绘(二):动态图绘制(码绘使用Processing)
查看>>
基于P5.js的“绘画系统”
查看>>
《达芬奇的人生密码》观后感
查看>>