只是下边那个数据表右侧的年不固定
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;
/**
* <p>Title: </p>
*
* <p>Description: 专利Bean</p>
*
* <p>Company: sinotrust</p>
*
* @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<String,PatentInfoBean> getPatentInfoBean(ICommonDAOService query,String SBDNum) {
long stime = System.currentTimeMillis();
Map<String,PatentInfoBean> patentInfoMap = new LinkedHashMap<String, PatentInfoBean>();
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;
}
}