|
@@ -33,6 +33,8 @@ import com.bizmatics.service.vo.DeviceImportVo;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
@@ -475,11 +477,13 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Transactional
|
|
|
@Override
|
|
|
public void deviceImport(MultipartFile multipartFile) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
ImportParams params = new ImportParams();
|
|
|
params.setHeadRows(1);
|
|
|
+ String err="文件导入失败";
|
|
|
try {
|
|
|
List<DeviceImportVo> deviceImportVos = ExcelImportUtil.importExcel(multipartFile.getInputStream(),
|
|
|
DeviceImportVo.class, params);
|
|
@@ -501,15 +505,18 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
deviceStatus.setSiteId(siteId);
|
|
|
deviceStatusService.save(deviceStatus);
|
|
|
}catch (Exception e){
|
|
|
- throw new BusinessException("文件导入失败,第"+rot+"行数据导入失败");
|
|
|
+ err="文件导入失败,第"+rot+"行数据导入失败";
|
|
|
+// throw new BusinessException("文件导入失败,第"+rot+"行数据导入失败");
|
|
|
}
|
|
|
rot++;
|
|
|
}
|
|
|
}else {
|
|
|
- throw new BusinessException("文件不能为空");
|
|
|
+ err="文件不能为空";
|
|
|
+// throw new BusinessException("文件不能为空");
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
- throw new BusinessException("文件导入失败"+e.getMessage());
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ throw new BusinessException(err);
|
|
|
}
|
|
|
}
|
|
|
|