@RequestMapping(method = RequestMethod.POST, value = "importBascpop")
@ResponseBody
public Msg importBascpop(@RequestParam(value = "file", required = true) MultipartFile file){
logger.info("upload files is starting ...");
String result = "";
int num = 0;
try {
List<String[]> lines = XLSXCovertCSVReader.readerInputStream(file.getInputStream(), 5);
if(lines.size() < 1){
return fail("没有导入数据!");
}
List<Bascpop> list = new ArrayList<Bascpop>();
for (int i = 1; i < lines.size(); i++) {
String[] bascpopInfo = lines.get(i);
Bascpop bascpop=new Bascpop();
bascpop.setCode(StringUtils.isNotBlank(bascpopInfo[0])?bascpopInfo[0].trim():"");
bascpop.setValue(StringUtils.isNotBlank(bascpopInfo[1])?bascpopInfo[1].trim():"");
if(StringUtils.isBlank(bascpopInfo[2]) || !NumberUtils.isNumber(bascpopInfo[2].trim())){
logger.info("第{}行索引不是数字类型:{}.",i+1,bascpopInfo[2]);
}else {
bascpop.setIndeno(Integer.valueOf(bascpopInfo[2].trim()).intValue());
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date= sdf.parse(bascpopInfo[3].trim());
bascpop.setModified(date);
if(StringUtils.isBlank(bascpopInfo[4]) || !NumberUtils.isNumber(bascpopInfo[4].trim())){
logger.info("第{}行状态不是数字类型:{}.",i+1,bascpopInfo[4]);
}else {
bascpop.setStatus(Integer.valueOf(bascpopInfo[4].trim()).intValue());
}
num++;
list.add(bascpop);
}
Msg msg= bascpopService.addBascpop(list);
if(msg.getSuccess()){
return success(result.length()==0?"操作成功":result.substring(1));
}
return msg;
} catch (Exception e) {
e.printStackTrace();
return fail("导入失败");
}
}
@ResponseBody
public Msg importBascpop(@RequestParam(value = "file", required = true) MultipartFile file){
logger.info("upload files is starting ...");
String result = "";
int num = 0;
try {
List<String[]> lines = XLSXCovertCSVReader.readerInputStream(file.getInputStream(), 5);
if(lines.size() < 1){
return fail("没有导入数据!");
}
List<Bascpop> list = new ArrayList<Bascpop>();
for (int i = 1; i < lines.size(); i++) {
String[] bascpopInfo = lines.get(i);
Bascpop bascpop=new Bascpop();
bascpop.setCode(StringUtils.isNotBlank(bascpopInfo[0])?bascpopInfo[0].trim():"");
bascpop.setValue(StringUtils.isNotBlank(bascpopInfo[1])?bascpopInfo[1].trim():"");
if(StringUtils.isBlank(bascpopInfo[2]) || !NumberUtils.isNumber(bascpopInfo[2].trim())){
logger.info("第{}行索引不是数字类型:{}.",i+1,bascpopInfo[2]);
}else {
bascpop.setIndeno(Integer.valueOf(bascpopInfo[2].trim()).intValue());
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date= sdf.parse(bascpopInfo[3].trim());
bascpop.setModified(date);
if(StringUtils.isBlank(bascpopInfo[4]) || !NumberUtils.isNumber(bascpopInfo[4].trim())){
logger.info("第{}行状态不是数字类型:{}.",i+1,bascpopInfo[4]);
}else {
bascpop.setStatus(Integer.valueOf(bascpopInfo[4].trim()).intValue());
}
num++;
list.add(bascpop);
}
Msg msg= bascpopService.addBascpop(list);
if(msg.getSuccess()){
return success(result.length()==0?"操作成功":result.substring(1));
}
return msg;
} catch (Exception e) {
e.printStackTrace();
return fail("导入失败");
}
}