java分批处理10万数据_使用java多线程分批处理数据工具类

packagecom.ts.common.model;importjava.io.Serializable;importcom.alibaba.fastjson.JSON;/*** 返回结果统一bean

*

* ResultBean

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:49:46

*@version2.0

**/

public class ResultBean implementsSerializable {private static final long serialVersionUID = 1L;//成功状态

public static final int SUCCESS = 1;//处理中状态

public static final int PROCESSING = 0;//失败状态

public static final int FAIL = -1;//描述

private String msg = "success";//状态默认成功

private int code =SUCCESS;//备注

privateString remark;//返回数据

privateT data;publicResultBean() {super();

}publicResultBean(T data) {super();this.data =data;

}/*** 使用异常创建结果*/

publicResultBean(Throwable e) {super();this.msg =e.toString();this.code =FAIL;

}/***

* 实例化结果默认成功状态

* 方法名:newInstance

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:51:26

*@returnResultBean

*@exception

*@since2.0*/

public static ResultBeannewInstance() {

ResultBean instance = new ResultBean();//默认返回信息

instance.code =SUCCESS;

instance.msg= "success";returninstance;

}/***

* 实例化结果默认成功状态和数据

* 方法名:newInstance

* 创建人:wangbeidou

* 时间:2018年5月10日-下午2:13:16

*@paramdata

*@returnResultBean

*@exception

*@since2.0*/

public static ResultBeannewInstance(T data) {

ResultBean instance = new ResultBean();//默认返回信息

instance.code =SUCCESS;

instance.msg= "success";

instance.data=data;returninstance;

}/***

* 实例化返回结果

* 方法名:newInstance

* 创建人:wangbeidou

* 时间:2018年4月12日-下午4:00:53

*@paramcode

*@parammsg

*@returnResultBean

*@exception

*@since2.0*/

public static ResultBean newInstance(intcode, String msg) {

ResultBean instance = new ResultBean();//默认返回信息

instance.code =code;

instance.msg=msg;returninstance;

}/***

* 实例化返回结果

* 方法名:newInstance

* 创建人:wangbeidou

* 时间:2018年4月12日-下午4:00:35

*@paramcode

*@parammsg

*@paramdata

*@returnResultBean

*@exception

*@since2.0*/

public static ResultBean newInstance(intcode, String msg, T data) {

ResultBean instance = new ResultBean();//默认返回信息

instance.code =code;

instance.msg=msg;

instance.data=data;returninstance;

}/***

* 设置返回数据

* 方法名:setData

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:52:01

*@paramdata

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeansetData(T data){this.data =data;return this;

}/***

* 设置结果描述

* 方法名:setMsg

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:52:34

*@parammsg

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeansetMsg(String msg){this.msg =msg;return this;

}/***

* 设置状态

* 方法名:setCode

* 创建人:wangbeidou

* 时间:2018年4月12日-下午4:17:56

*@paramcode

*@returnResultBean

*@exception

*@since2.0*/

public ResultBean setCode(intcode){this.code =code;return this;

}/***

* 设置备注)

* 方法名:setRemark

* 创建人:wangbeidou

* 时间:2018年4月12日-下午5:47:29

*@paramremark

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeansetRemark(String remark){this.remark =remark;return this;

}/***

* 设置成功描述和返回数据

* 方法名:success

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:52:58

*@parammsg

*@paramdata

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeansuccess(String msg, T data){this.code =SUCCESS;this.data =data;this.msg =msg;return this;

}/***

* 设置成功返回结果描述

* 方法名:success

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:53:31

*@parammsg

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeansuccess(String msg){this.code =SUCCESS;this.msg =msg;return this;

}/***

* 设置处理中描述和返回数据

* 方法名:success

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:52:58

*@parammsg

*@paramdata

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeanprocessing(String msg, T data){this.code =PROCESSING;this.data =data;this.msg =msg;return this;

}/***

* 设置处理中返回结果描述

* 方法名:success

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:53:31

*@parammsg

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeanprocessing(String msg){this.code =PROCESSING;this.msg =msg;return this;

}/***

* 设置失败返回描述和返回数据

* 方法名:fail

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:54:04

*@parammsg

*@paramdata

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeanfail(String msg, T data){this.code =FAIL;this.data =data;this.msg =msg;return this;

}/***

* 设置失败返回描述

* 方法名:fail

* 创建人:wangbeidou

* 时间:2018年4月12日-下午3:54:32

*@parammsg

*@returnResultBean

*@exception

*@since2.0*/

public ResultBeanfail(String msg){this.code =FAIL;this.msg =msg;return this;

}publicT getData() {returndata;

}publicString getMsg() {returnmsg;

}public intgetCode() {returncode;

}publicString getRemark() {returnremark;

}/***

* 生成json字符串

* 方法名:json

* 创建人:wangbeidou

* 时间:2018年4月12日-下午4:42:28

*@returnString

*@exception

*@since2.0*/

publicString json(){return JSON.toJSONString(this);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值