标签:one extends station pre dem exception read entry col
实现思路:
List list = new ArrayList();
Map map = new HashMap();
for(i=0;i<list.size;i++){
map=list.get(i);
for (String key : map.keySet()){
System.out.println("key:"+key+",value:"+map.get(key) );
}
}
项目使用:
package com.ilotterytech.bwlbis.warehouse.imports.service; import java.io.IOException; import java.util.List; import java.util.Map; /** * @ Author : zhukaixin * @ Date : 2019-06-05-15:36 * @ Desc :即开票兑奖数据查询 */ @Service @Transactional public class RedemptionDataInquiryService extends DefaultRestService<RedemptionDataInquiry, Long,RedemptionDataInquiryRepository> { /** * 即开票兑奖数据查询数据导入 * * @param multipartFile * @return * @throws IOException */ public HtmlResult saveFileImport(MultipartFile multipartFile) throws IOException { FileReader result = new FileReader(multipartFile.getInputStream(), multipartFile.getOriginalFilename()); ExcelTitleReader excelTitleReader = new ExcelTitleReader(this.getClass().getClassLoader().getResourceAsStream("/res/RedemptionDataInquiry.properties")); //处理返回结果 HtmlResult htmlResult = result.read().asHtmlResult(excelTitleReader); List<Map<String, Object>> contents = htmlResult.getContents(); for (int i = 0; i < contents.size(); i++) { Map<String, Object> m = contents.get(i); //获取第一个Map,因为是ArrayList,所以下标0就是第一个 RedemptionDataInquiry redemptionDataInquiry = new RedemptionDataInquiry(); for (Map.Entry e : m.entrySet()) { //遍历Map if (e.getKey().equals("date")) { redemptionDataInquiry.setDate(String.valueOf(e.getValue())); } else if (e.getKey().equals("district")) { redemptionDataInquiry.setDistrict(String.valueOf(e.getValue())); }else if (e.getKey().equals("stationCode")) { redemptionDataInquiry.setStationCode(String.valueOf(e.getValue())); }else if (e.getKey().equals("generate")) { redemptionDataInquiry.setGenerate(String.valueOf(e.getValue())); } else if (e.getKey().equals("gameName")) { redemptionDataInquiry.setGameName(String.valueOf(e.getValue())); }else if (e.getKey().equals("gameCode")) { redemptionDataInquiry.setGameCode(String.valueOf(e.getValue())); }else if (e.getKey().equals("money")) { redemptionDataInquiry.setMoney(String.valueOf(e.getValue())); }else if (e.getKey().equals("redemptionCommission")) { redemptionDataInquiry.setRedemptionCommission(String.valueOf(e.getValue())); } } save(redemptionDataInquiry); } return htmlResult; } }
标签:one extends station pre dem exception read entry col
原文地址:https://www.cnblogs.com/zhukaixin/p/10985962.html