码迷,mamicode.com
首页 > 其他好文 > 详细

导出数据为Excel文件---Client2

时间:2017-06-29 23:48:17      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:jackson   文件   ext   util   new   ntc   turn   gem   ica   

public class ExportVehMileageClients extends RestfulWSClient<ServiceResponse>{
    private static final Logger LOG=Logger.getLogger(ExportVehMileagesClient.class);
    private static final String WSURL=GET_EXPORTVEHMILEAGES_URL;
    private static final String TYPE=APPLICATION_JSON;
    private static final String ACCEPT=APPLICATION_JSON;
    private static final JacksonJsonProvider PROVIDER=new JacksonJsonProvider();
    public ExportVehMileageClient(){
        super(WSURL,TYPE,ACCEPT,PROVIDER);
    }
    public List<VehicleModel> export(ExportVehMileageModel EVMModel) throws WSException{
        try{
            LOG.info("ExportVehMileages Institution");
            ServiceResponse resp=this.excutePost(EVMModel,ServiceResponse.class);
            if(resp.getHead().getStatus==SERVICE_SUCCESS){
                String body=resp.getBody();
                if(!StringUtils.isEmpty(body)){
                    return tolist(body);
                }else{return null;}
            }else{
                throw new WSException("ExportVehMileages Failure");
            }
        }catch(WSException e){throw new WSException("ExportVehMileages Failure",e);}
    }
    private List<VehicleModel> tolist(String str) throws WSException{
        ObjectMapper om=new ObjectMapper();
        try{
            JavaType javaType=getCollectionType(om,ArrayList.class,VehicleModel.class);
            return om.readValue(str,javaType);
        }catch(Exception e){
            LOG.error("Failed to ExportVehMileages object from json response:"+str,e);
            throw new WSException("Failed to ExportVehMileage",e);
        }
    }
    private JavaType getCollectionType(ObjectMapper mapper,Class<?> collectionClass ,Class<?>... elementClasses){
        return mapper.getTypeFactory().constructParametricType(collectionClass,elementClasses);
    }
}

 

导出数据为Excel文件---Client2

标签:jackson   文件   ext   util   new   ntc   turn   gem   ica   

原文地址:http://www.cnblogs.com/shen199103/p/7096677.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!