|
@ -471,23 +471,24 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public MixEnvelop<IotDeviceImportRecordVO,IotDeviceImportRecordVO> uploadStream(MultipartFile file, HttpServletRequest request) throws Exception{
|
|
|
public MixEnvelop<IotDeviceImportVO, IotDeviceImportVO> uploadStream(MultipartFile file, HttpServletRequest request) throws Exception {
|
|
|
// 得到文件的完整名称 xxx.txt
|
|
|
String fullName = file.getOriginalFilename();
|
|
|
//得到文件类型
|
|
|
String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
if(!"xls".equals(fileType) || !"xlsx".equals(fileType)){
|
|
|
if (!"xls".equals(fileType) || !"xlsx".equals(fileType)) {
|
|
|
return MixEnvelop.getError("文件格式不正确");
|
|
|
}
|
|
|
String fileName = fullName.substring(0, fullName.lastIndexOf("."));
|
|
|
// String fileName = fullName.substring(0, fullName.lastIndexOf("."));
|
|
|
|
|
|
//解析excel封装对象
|
|
|
AExcelReader excelReader = new IotDeviceImportVOReader();
|
|
|
excelReader.read(file.getInputStream());
|
|
|
List<IotDeviceImportVO> correctLs = excelReader.getCorrectLs();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
List<IotDeviceImportVO> importVOList = objectMapper.readValue(JSONObject.toJSONString(correctLs), new TypeReference<List<IotDeviceImportVO>>() {});
|
|
|
IotDeviceImportRecordVO vo = this.importDevice(null,fileName,null,importVOList);
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create,vo);
|
|
|
List<IotDeviceImportVO> importVOList = objectMapper.readValue(JSONObject.toJSONString(correctLs), new TypeReference<List<IotDeviceImportVO>>() {
|
|
|
});
|
|
|
// IotDeviceImportRecordVO vo = this.importDevice(null,fileName,null,importVOList);
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.FileUpload.message_success_upload, importVOList);
|
|
|
}
|
|
|
}
|