| | |
| | | import com.walker.di.DataImportException; |
| | | import com.walker.file.FileInfo; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.infrastructure.utils.FileCopyUtils; |
| | | import com.walker.infrastructure.utils.NumberGenerator; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | @PostMapping("/import") |
| | | public ResponseValue importExcel(MultipartFile file, boolean updateSupport){ |
| | | try { |
| | | // ~~~~~~~~~~~~~~~~~~~~~ 测试 |
| | | // String filePath = "d:/tmp/test_user_001.csv"; |
| | | // FileOutputStream fileOutputStream = new FileOutputStream(new File(filePath)); |
| | | // FileCopyUtils.copy(file.getInputStream(), fileOutputStream); |
| | | // logger.info("文件写入成功:{}", filePath); |
| | | // FileInfo testFileInfo = this.uploadFileToRemote(filePath, null, String.valueOf(this.getOwner())); |
| | | |
| | | // 2024-02-23 以下代码成功执行,暂时注释 |
| | | // FileInfo testFileInfo = this.uploadFileToRemote(file.getInputStream(), "avatar.jpg", null, file.getSize(), null, String.valueOf(Constants.OWNER_PLATFORM)); |
| | | // logger.info("testFileInfo = {}", testFileInfo); |
| | | // ~~~~~~~~~~~~~~~~~~~~~ 测试 end |
| | | |
| | | UserDataImportor dataImportor = new UserDataImportor(file.getInputStream()); |
| | | dataImportor.setId("user_import"); |
| | | this.getDataImportEngine().executeImport(dataImportor, this.getCurrentUserPrincipal().getUserName()); |
| | |
| | | logger.info("错误结果文件:{}", dataImportor.getErrorFile()); |
| | | |
| | | // FileInfo errorFileInfo = this.uploadFileToRemote(dataImportor.getErrorFile()); |
| | | // this.uploadFileToRemote(file.getInputStream(), null, null, String.valueOf(this.getOwner()),) |
| | | // 这里会报错,因为上传 s3 oss时动态生成的文件,总是说读取长度和期望长度不一致: |
| | | // 保存文件到【oss】错误:Data read has a different length than the expected: dataLength=2764; expectedLength=107374178304; |
| | | FileInfo errorFileInfo = this.uploadFileToRemote(dataImportor.getErrorFile(), null, String.valueOf(this.getOwner())); |
| | | if(errorFileInfo != null){ |
| | | logger.debug("用户导入存在'不符合数据': ,", errorFileInfo.toString()); |