只是下邊那個數據表右側的年不固定
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;
}
}