|
|
@ -12,6 +12,7 @@ import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
@ -31,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
@ -51,7 +53,7 @@ import java.util.List; |
|
|
|
@Slf4j |
|
|
|
@RestController |
|
|
|
@RequestMapping("communityBuildingManager") |
|
|
|
public class CommunityBuildingManagerController { |
|
|
|
public class CommunityBuildingManagerController implements ResultDataResolver { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CommunityBuildingManagerService communityBuildingManagerService; |
|
|
@ -207,6 +209,54 @@ public class CommunityBuildingManagerController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导入excel |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("import") |
|
|
|
public Result importExcel(@RequestPart("file") MultipartFile file) { |
|
|
|
return new Result(); |
|
|
|
/*// 1.暂存文件
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
String extName = originalFilename.substring(originalFilename.lastIndexOf(".")); |
|
|
|
|
|
|
|
Path fileSavePath; |
|
|
|
try { |
|
|
|
Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir(ImportTaskConstants.COMMUNITY_BUILDING_MANAGER, "import"); |
|
|
|
fileSavePath = importPath.resolve(UUID.randomUUID().toString().concat(extName)); |
|
|
|
} catch (IOException e) { |
|
|
|
String errorMsg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
log.error("【楼长单元长导入】创建临时存储文件失败:{}", errorMsg); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "文件上传失败", "文件上传失败"); |
|
|
|
} |
|
|
|
|
|
|
|
InputStream is = null; |
|
|
|
FileOutputStream os = null; |
|
|
|
|
|
|
|
try { |
|
|
|
is = file.getInputStream(); |
|
|
|
os = new FileOutputStream(fileSavePath.toString()); |
|
|
|
IOUtils.copy(is, os); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(ImportTaskConstants.COMMUNITY_BUILDING_MANAGER + "表 importExcel exception", e); |
|
|
|
} finally { |
|
|
|
org.apache.poi.util.IOUtils.closeQuietly(is); |
|
|
|
org.apache.poi.util.IOUtils.closeQuietly(os); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.生成导入任务记录
|
|
|
|
ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException( |
|
|
|
ImportTaskUtils.createImportTask(originalFilename, ImportTaskConstants.COMMUNITY_BUILDING_MANAGER), |
|
|
|
ServiceConstant.EPMET_COMMON_SERVICE, |
|
|
|
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), |
|
|
|
"楼长单元长导入excel错误", |
|
|
|
"楼长单元长导入excel错误"); |
|
|
|
|
|
|
|
// 3.执行导入
|
|
|
|
communityBuildingManagerService.execAsyncExcelImport(fileSavePath, rstData.getTaskId()); |
|
|
|
return new Result();*/ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|