package com.zzsn.generation;



import com.zzsn.generation.autotype.HashList;
import com.zzsn.generation.autotype.Processrecord;
import com.zzsn.generation.autotype.TypeResult;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;


/**
 * 处理流程
 * 创建人：李东亮   
 * 创建时间：2015-5-27 下午4:26:23   
 * 公司 ：郑州数能软件科技有限公司
 * @version  1.0  
 *
 */
public class Processitem implements Serializable{

	private Long id;
	private Long sid;
	private String tid;
	private Set<TypeResult> typeResults = new HashSet<TypeResult>();
	//字符集
	private String charset;
	private String title;
	private String summary;
	private String keywords;
	private String content;
	private String hash;
	private String author;
	private String sourcesite;
	private String sourceaddress;
	private String currentprocess;
	private String type;
	private String withtagfile;
	private String publishDate;
	private String fileDownLoadPath;
	private String createBy;
	private String createDate;
	private Integer processResult=0;
	//
	private boolean success = false;
	//最后修改时间
	private String lastModified;
	private Long orgId;
	private String origin;
	private String sourceType;
	
	private Long rid;//地域ID
	//特征词
	private String featurewords;
	private Map<String, String> orgTidsmap;
	//组织ids
	private String orgs;
	
	
	/***第三方专用****************/
	//情感分析 1正面 2负面 3中性 4争议
	private String orientation;
	//第三方公司名称
	private String fromWhere;
	//第三方标识ID
	private String fromID;
	
	//正文中包含的图片
	private String imgMap;
	
	/***舆情相关性判断结果****************/
	// 0保留  1删除  2过滤未响应  3过滤出错
	private String relevance;
	private String ordervalue;  //储能优先级字段标识
	//重复标识
	private Integer repeat=0;

	//公司id
	private List<String> coidlist;
	
/****************非持久化字段*************************************/	

	
	//http响应流
	private InputStream  replayInputStream;
	//带标签正文
	private String contentWithTag;
	//
	private String contentImgCvtTag;
	//处理记录
	private List<Processrecord> processrecords = new ArrayList<Processrecord>();
	//重复的PID， 与该Process重复的所有PID 集合
	private List<Processitem> duplicateProcessitems = new ArrayList<Processitem>();
	//正文包含图片
	//private Map<String,ImgData>  imgs ;
	//HashList
	private HashList hashList = new HashList();
	//分词结果
	private String words;
	
	private List<String> wordList;
	
	private List<String> titleWordList;
	
	private String lang;
	//情报课题id status的map
	private Map<Long,String>  taskMaps;

	
	private String html;
	
	//相关地域
	private String relatePlaces;
	//相关人物
	private String relatePerson;
	//相关组织结构
	private String relateOrg;
	//事件
	private String relateEvent;
	//时间
	private String relateDate;
	//试验list
	private List templist;
	
	
	
	
/*****************非持久化字段***************************************/		
	private ByteArrayOutputStream baos;

	public ByteArrayOutputStream getBaos() {
		return baos;
	}
	public void setBaos(ByteArrayOutputStream baos) {
		this.baos = baos;
	}
	public InputStream getReplayInputStream() {
		return replayInputStream;
	}
	public void setReplayInputStream(InputStream replayInputStream) {
		this.replayInputStream = replayInputStream;
	}
	
	

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getSummary() {
		return summary;
	}
	public void setSummary(String summary) {
		this.summary = summary;
	}
	public String getKeywords() {
		return keywords;
	}
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}



	
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getHash() {
		return hash;
	}
	public void setHash(String hash) {
		this.hash = hash;
	}

	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getSourcesite() {
		return sourcesite;
	}
	public void setSourcesite(String sourcesite) {
		this.sourcesite = sourcesite;
	}
	public String getSourceaddress() {
		return sourceaddress;
	}
	public void setSourceaddress(String sourceaddress) {
		this.sourceaddress = sourceaddress;
	}
	public String getCurrentprocess() {
		return currentprocess;
	}
	public void setCurrentprocess(String currentprocess) {
		this.currentprocess = currentprocess;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getWithtagfile() {
		return withtagfile;
	}
	public void setWithtagfile(String withtagfile) {
		this.withtagfile = withtagfile;
	}
	public String getPublishDate() {
		return publishDate;
	}
	public void setPublishDate(String publishDate) {
		this.publishDate = publishDate;
	}
	public String getCreateBy() {
		return createBy;
	}
	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}
	public String getCreateDate() {
		return createDate;
	}
	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}
	
	
	public String getTid() {
		return tid;
	}
	public void setTid(String tid) {
		this.tid = tid;
	}
	public Long getSid() {
		return sid;
	}
	public void setSid(Long sid) {
		this.sid = sid;
	}
   

	
	public Set<TypeResult> getStreeItems() {
		return typeResults;
	}
	
	public Map<Long,Map<Long,String>> convertStreeItems(){
//		Map<Long,String> typeResult = new HashMap<Long,String>();
		Map<Long,Map<Long,String>>  result = new HashMap<Long,Map<Long,String>>();
		for(TypeResult si : typeResults){
			if (null==si.getTid()) {
				continue;
			}
//			typeResult.put(si.getTid(), si.getMetchKeywords());
//			Set<Long> tids = result.get(si.getOrgId());
			Map<Long,String> typeResult = result.get(si.getOrgId());
			if(null != typeResult){
				typeResult.put(si.getTid(), si.getMatchKeywords());
				result.put(si.getOrgId(), typeResult);
			} else {
				typeResult = new HashMap<Long,String>();
				typeResult.put(si.getTid(), si.getMatchKeywords());
				result.put(si.getOrgId(), typeResult);
			}
		}
		
		return result;
	}
	public void setStreeItems(Set<TypeResult> typeResults) {
		this.typeResults = typeResults;
	}
	public String getCharset() {
		return charset;
	}
	public void setCharset(String charset) {
		this.charset = charset;
	}
	public String getContentWithTag() {
		return contentWithTag;
	}
	public void setContentWithTag(String contentWithTag) {
		this.contentWithTag = contentWithTag;
	}
	public Integer getProcessResult() {
		return processResult;
	}
	public void setProcessResult(Integer processResult) {
		this.processResult = processResult;
	}
	public List<Processrecord> getProcessrecords() {
		return processrecords;
	}
	public void setProcessrecords(List<Processrecord> processrecords) {
		this.processrecords = processrecords;
	}



	public HashList getHashList() {
		return hashList;
	}
	public void setHashList(HashList hashList) {
		this.hashList = hashList;
	}
	public String getWords() {
		return words;
	}
	public void setWords(String words) {
		this.words = words;
	}
	public String getLang() {
		return lang;
	}
	public void setLang(String lang) {
		this.lang = lang;
	}
	public String getLastModified() {
		return lastModified;
	}
	public void setLastModified(String lastModified) {
		this.lastModified = lastModified;
	}
	public Long getOrgId() {
		return orgId;
	}
	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}
	public List<String> getWordList() {
		return wordList;
	}
	public void setWordList(List<String> wordList) {
		this.wordList = wordList;
	}
	public String getOrigin() {
		return origin;
	}
	public void setOrigin(String origin) {
		this.origin = origin;
	}

	public Long getRid() {
		return rid;
	}
	public void setRid(Long rid) {
		this.rid = rid;
	}
	public List<String> getTitleWordList() {
		return titleWordList;
	}
	public void setTitleWordList(List<String> titleWordList) {
		this.titleWordList = titleWordList;
	}
	public Map<Long, String> getTaskMaps() {
		return taskMaps;
	}
	public void setTaskMaps(Map<Long, String> taskMaps) {
		this.taskMaps = taskMaps;
	}
	public String getOrientation() {
		return orientation;
	}
	public void setOrientation(String orientation) {
		this.orientation = orientation;
	}
	public String getHtml() {
		return html;
	}
	public void setHtml(String html) {
		this.html = html;
	}
	public String getFromWhere() {
		return fromWhere;
	}
	public void setFromWhere(String fromWhere) {
		this.fromWhere = fromWhere;
	}
	public String getFromID() {
		return fromID;
	}
	public void setFromID(String fromID) {
		this.fromID = fromID;
	}
	public String getSourceType() {
		return sourceType;
	}
	public void setSourceType(String sourceType) {
		this.sourceType = sourceType;
	}
    public String getFeaturewords() {
        return featurewords;
    }
    public void setFeaturewords(String featurewords) {
        this.featurewords = featurewords;
    }
    public String getImgMap() {
        return imgMap;
    }
    public void setImgMap(String imgMap) {
        this.imgMap = imgMap;
    }
    
    public String getFileDownLoadPath() {
        return fileDownLoadPath;
    }
    public void setFileDownLoadPath(String fileDownLoadPath) {
        this.fileDownLoadPath = fileDownLoadPath;
    }
    public boolean isSuccess() {
        if(this.getCurrentprocess()==null){
            return false;
        }
        if(this.getProcessResult()==null){
            return false;
        }
        if(this.getCurrentprocess().equals(Constants.EMOTION)&&this.getProcessResult().equals(1)){
            return true;
        }
        
        return false;
    }
   
	
	

    public String getContentImgCvtTag() {
        return contentImgCvtTag;
    }
    public void setContentImgCvtTag(String contentImgCvtTag) {
        this.contentImgCvtTag = contentImgCvtTag;
    }
    public static void main(String[] args) {
        String str = "2015%E5%85%A8%E5%9B%BD%E6%B1%BD%E8%BD%A6%E5%88%B6%E9%80%A0%E4%BC%81%E4%B8%9A%E5%90%8D%E5%BD%95";
        try {
          str =   URLDecoder.decode(str,"UTF-8");
          System.out.println(str);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    public String getRelatePlaces() {
        return relatePlaces;
    }
    public void setRelatePlaces(String relatePlaces) {
        this.relatePlaces = relatePlaces;
    }
    public String getRelatePerson() {
        return relatePerson;
    }
    public void setRelatePerson(String relatePerson) {
        this.relatePerson = relatePerson;
    }
    public String getRelateOrg() {
        return relateOrg;
    }
    public void setRelateOrg(String relateOrg) {
        this.relateOrg = relateOrg;
    }
    public String getRelateEvent() {
        return relateEvent;
    }
    public void setRelateEvent(String relateEvent) {
        this.relateEvent = relateEvent;
    }
    public String getRelateDate() {
        return relateDate;
    }
    public void setRelateDate(String relateDate) {
        this.relateDate = relateDate;
    }
    public List<Processitem> getDuplicateProcessitems() {
        return duplicateProcessitems;
    }
    public void setDuplicateProcessitems(List<Processitem> duplicateProcessitems) {
        this.duplicateProcessitems = duplicateProcessitems;
    }
	public String getRelevance() {
		return relevance;
	}
	public void setRelevance(String relevance) {
		this.relevance = relevance;
	}
	public String getOrdervalue() {
		return ordervalue;
	}
	public void setOrdervalue(String ordervalue) {
		this.ordervalue = ordervalue;
	}
	public Integer getRepeat() {
		return repeat;
	}
	public void setRepeat(Integer repeat) {
		this.repeat = repeat;
	}
	public List getTemplist() {
		return templist;
	}
	public void setTemplist(List templist) {
		this.templist = templist;
	}
	public Map<String, String> getOrgTidsmap() {
		return orgTidsmap;
	}
	public void setOrgTidsmap(Map<String, String> orgTidsmap) {
		this.orgTidsmap = orgTidsmap;
	}
	public List<String> getCoidlist() {
		return coidlist;
	}
	public void setCoidlist(List<String> coidlist) {
		this.coidlist = coidlist;
	}
	public String getOrgs() {
		return orgs;
	}
	public void setOrgs(String orgs) {
		this.orgs = orgs;
	}

	
}
