Company41ReqDTO query = reqDTO.getQuery();
reqDTO.setPageNum(CommonConstant.EXPORT_START_PAGE);
reqDTO.setPageSize(CommonConstant.EXPORT_MAX_SIZE);
Up4Enum e = Up4Enum.getEnumByCode(query.getType());
ActionUtils.doIfObjNull(e,() -> {
throw new BusinessException("param of 'type' error");
});
Class<?> templateClass = null;
List<Object> templateList = new ArrayList<>();
switch (e){
case UP_GAUGE: templateClass = Company41GaugeTemplate.class;break;
case UP_BOARD: templateClass = Company41BoardTemplate.class;break;
case UP_CLOUD: templateClass = Company41CloudTemplate.class;break;
case UP_MARK: templateClass = Company41MarkTemplate.class;break;
}
try {
List<Company41VO> recordList = this.listCompany41(reqDTO).getRecords();
for(Company41VO company41 : recordList){
Object template = templateClass.newInstance();
if(e.getCode().equals("UP_GAUGE")){
Company41GaugeTemplate t = (Company41GaugeTemplate)template;
BeanUtils.copyProperties(company41,t);
t.setProduct(StrUtils.list2str(company41.getProductList()));
templateList.add(t);
}else if(e.getCode().equals("UP_BOARD")){
Company41BoardTemplate t = (Company41BoardTemplate)template;
BeanUtils.copyProperties(company41,t);
t.setProduct(StrUtils.list2str(company41.getProductList()));
templateList.add(t);
}else if(e.getCode().equals("UP_CLOUD")){
Company41CloudTemplate t = (Company41CloudTemplate)template;
BeanUtils.copyProperties(company41,t);
t.setProduct(StrUtils.list2str(company41.getProductList()));
templateList.add(t);
}else{
Company41MarkTemplate t = (Company41MarkTemplate)template;
BeanUtils.copyProperties(company41,t);
t.setProduct(StrUtils.list2str(company41.getProductList()));
templateList.add(t);
}
}
}catch (Exception exception){
}
String result = ossService.uploadExcelReturnPath(e.getName(), e.getName(),templateClass,templateList);
return result;
反射生成不同类型模板
最新推荐文章于 2024-08-04 11:58:19 发布