View Javadoc
1   package com.foxinmy.weixin4j.qy.model;
2   
3   import com.alibaba.fastjson.JSONArray;
4   import com.alibaba.fastjson.annotation.JSONField;
5   import com.foxinmy.weixin4j.http.weixin.ApiResult;
6   import com.foxinmy.weixin4j.qy.type.BatchStatus;
7   import com.foxinmy.weixin4j.qy.type.BatchType;
8   
9   /**
10   * 异步任务执行结果
11   * 
12   * @className BatchResult
13   * @author jinyu(foxinmy@gmail.com)
14   * @date 2015年3月31日
15   * @since JDK 1.6
16   * @see
17   */
18  public class BatchResult extends ApiResult {
19  
20  	private static final long serialVersionUID = 4985338631992208903L;
21  	/**
22  	 * 任务状态
23  	 */
24  	private int status;
25  	/**
26  	 * 任务类型
27  	 */
28  	private String type;
29  	/**
30  	 * 任务运行总条数
31  	 */
32  	private int total;
33  	/**
34  	 * 目前运行百分比,当任务完成时为100
35  	 */
36  	@JSONField(name = "percentage")
37  	private int percentAge;
38  	/**
39  	 * 预估剩余时间(单位:分钟),当任务完成时为0
40  	 */
41  	@JSONField(name = "remaintime")
42  	private int remainTime;
43  	/**
44  	 * 详细的处理结果 TODO
45  	 */
46  	private JSONArray result;
47  
48  	public int getStatus() {
49  		return status;
50  	}
51  
52  	@JSONField(serialize = false)
53  	public BatchStatus getFormatStatus() {
54  		return BatchStatus.values()[status - 1];
55  	}
56  
57  	public String getType() {
58  		return type;
59  	}
60  
61  	@JSONField(serialize = false)
62  	public BatchType getFormatType() {
63  		return type != null ? BatchType.valueOf(type.toUpperCase()) : null;
64  	}
65  
66  	public int getTotal() {
67  		return total;
68  	}
69  
70  	public int getPercentAge() {
71  		return percentAge;
72  	}
73  
74  	public int getRemainTime() {
75  		return remainTime;
76  	}
77  
78  	public JSONArray getResult() {
79  		return result;
80  	}
81  
82  	// ---------- setter 应该全部去掉
83  
84  	public void setStatus(int status) {
85  		this.status = status;
86  	}
87  
88  	public void setType(String type) {
89  		this.type = type;
90  	}
91  
92  	public void setTotal(int total) {
93  		this.total = total;
94  	}
95  
96  	public void setPercentAge(int percentAge) {
97  		this.percentAge = percentAge;
98  	}
99  
100 	public void setRemainTime(int remainTime) {
101 		this.remainTime = remainTime;
102 	}
103 
104 	public void setResult(JSONArray result) {
105 		this.result = result;
106 	}
107 
108 	@Override
109 	public String toString() {
110 		return "BatchResult [" + super.toString() + ", status=" + status + ", type=" + type + ", total=" + total
111 				+ ", percentAge=" + percentAge + ", remainTime=" + remainTime + ", result=" + result + "]";
112 	}
113 }