From 393d45fd74437258b71e333376e11540b8f20ece Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 10:22:28 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/renren/common/controller/AdminController.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java index 13575f03..9324b49a 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java @@ -6,9 +6,11 @@ import io.renren.common.utils.Result; import io.renren.common.utils.UpdateUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -21,6 +23,8 @@ public class AdminController { @Autowired private UpdateUtil updateUtil; + @Value("${spring.profiles.active}") + private String active; // 现有生效 /** * @param updateFile 更新包下载地址 @@ -31,7 +35,11 @@ public class AdminController { @ApiOperation("进行后台程序更新") @LogOperation("进行后台程序更新") public Result update(String updateFile, String active) { - return new Result().ok(""); + if (StringUtils.isEmpty(active)) { + active = this.active; + } + boolean success = updateUtil.update(updateFile, active); + return new Result().ok(String.valueOf(success)); } } From 59a2ad1fe696df2895cc71a2bb6119b957fdc5d8 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 10:47:33 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=8C=85=E5=A4=B1=E8=B4=A5=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/renren/common/utils/UpdateUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java index 236e844d..a8f159f4 100644 --- a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java +++ b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java @@ -56,7 +56,7 @@ public class UpdateUtil { if (!folder.isDirectory()) { folder.mkdirs(); } - Request request = new Request.Builder().url(updateFile).build(); + Request request = new Request.Builder().url(updateFile).addHeader("Connection", "close").get().build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { try (InputStream is = response.body().byteStream(); FileOutputStream fos = new FileOutputStream(file)) { From 6335d7c5c6d0a0c03e273d7dfeb8388c11664665 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 12:32:50 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E3=80=82=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/renren/common/utils/UpdateUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java index a8f159f4..e9cf111d 100644 --- a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java +++ b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java @@ -74,7 +74,7 @@ public class UpdateUtil { return file.getAbsolutePath(); } } else { - logger.error("下载更新包失败:{}", updateFile); + logger.error("下载更新包失败:{},错误码:{}", updateFile, response.code()); } } catch (IOException e) { logger.error("下载更新包失败:" + updateFile, e); From 5b8f4b56ff3155bb8a05385346a5ed5e7b23323c Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 12:54:30 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E5=B1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/renren/common/utils/UpdateUtil.java | 3 ++- renren-admin/src/main/resources/assembly/bin/update.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java index e9cf111d..3d269a36 100644 --- a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java +++ b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java @@ -87,7 +87,8 @@ public class UpdateUtil { * @param active 启动程序的配置文件 */ private void execUpdate(String updateFilePath, String active) { - String cmd = String.format("cd %s && sh update.sh %s %s", pwd, pwd, updateFilePath, "renren-admin", active); + String[] cmd = {"/bin/sh", "-c", String.format("cd %s && sh update.sh %s %s %s %s", pwd, pwd, updateFilePath, "renren-admin", active)}; +// String cmd = String.format("cd %s && sh update.sh %s %s", pwd, pwd, updateFilePath, "renren-admin", active); logger.info("执行指令:{}", cmd); logger.info(RuntimeUtil.execForStr(cmd)); } diff --git a/renren-admin/src/main/resources/assembly/bin/update.sh b/renren-admin/src/main/resources/assembly/bin/update.sh index f0b130eb..535b6120 100644 --- a/renren-admin/src/main/resources/assembly/bin/update.sh +++ b/renren-admin/src/main/resources/assembly/bin/update.sh @@ -98,7 +98,7 @@ if [ -f "${APP_DIR}/tmp/${APP_NAME}/${APP_NAME}.jar" ]; then \cp -rf ${APP_DIR}/tmp/${APP_NAME}/${APP_NAME}.jar ${APP_DIR}/ echo "${APP_NAME} 项目更新完成" else - echo "${APP_NAME} 项目程序不存在" + echo "${APP_NAME} 项目程序不存在 ${APP_DIR}/tmp/${APP_NAME}/${APP_NAME}.jar" fi # 移除更新包以及更新的项目 From 9b66fa7b2189388329d85d92cf7dcaf3cf82d4ff Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 13:07:42 +0800 Subject: [PATCH 05/12] 500 --- .../java/io/renren/common/controller/AdminController.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java index 9324b49a..f4c7d47b 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java @@ -1,11 +1,9 @@ package io.renren.common.controller; -import io.renren.common.annotation.LogOperation; import io.renren.common.utils.Result; import io.renren.common.utils.UpdateUtil; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,8 +30,6 @@ public class AdminController { * @return */ @PostMapping(value = "/update") - @ApiOperation("进行后台程序更新") - @LogOperation("进行后台程序更新") public Result update(String updateFile, String active) { if (StringUtils.isEmpty(active)) { active = this.active; From 40c6cd37a76947dbbaa9919afdc896a2301564f7 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 14:02:08 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- renren-admin/src/main/resources/assembly/bin/renren-admin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renren-admin/src/main/resources/assembly/bin/renren-admin.sh b/renren-admin/src/main/resources/assembly/bin/renren-admin.sh index 12f978dc..ac625a6b 100644 --- a/renren-admin/src/main/resources/assembly/bin/renren-admin.sh +++ b/renren-admin/src/main/resources/assembly/bin/renren-admin.sh @@ -19,7 +19,7 @@ fi #开始方法 start() { cd $JAR_ROOT - nohup java -Dfile.encoding=utf-8 -server -Xms256m -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Duser.timezone=GMT+08 -XX:HeapDumpPath=./ -jar --spring.profiles.active=$PROFILES_ACTIVE $JAR_PATH >$LOG_PATH 2>&1 & + nohup java -Dfile.encoding=utf-8 -server -Xms256m -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Duser.timezone=GMT+08 -XX:HeapDumpPath=./ -jar $JAR_PATH --spring.profiles.active=$PROFILES_ACTIVE >$LOG_PATH 2>&1 & echo "$JAR_PATH start success." } From 45a8f3f6cba1d8e9d7f0750b1ed2e9de06580ef0 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 15:01:26 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E5=B1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/renren/common/utils/UpdateUtil.java | 3 ++- renren-admin/src/main/resources/assembly/bin/update.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java index 3d269a36..e155cc55 100644 --- a/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java +++ b/renren-admin/src/main/java/io/renren/common/utils/UpdateUtil.java @@ -14,6 +14,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -89,7 +90,7 @@ public class UpdateUtil { private void execUpdate(String updateFilePath, String active) { String[] cmd = {"/bin/sh", "-c", String.format("cd %s && sh update.sh %s %s %s %s", pwd, pwd, updateFilePath, "renren-admin", active)}; // String cmd = String.format("cd %s && sh update.sh %s %s", pwd, pwd, updateFilePath, "renren-admin", active); - logger.info("执行指令:{}", cmd); + logger.info("执行指令:{}", Arrays.asList(cmd).toString()); logger.info(RuntimeUtil.execForStr(cmd)); } } diff --git a/renren-admin/src/main/resources/assembly/bin/update.sh b/renren-admin/src/main/resources/assembly/bin/update.sh index 535b6120..e9328ad4 100644 --- a/renren-admin/src/main/resources/assembly/bin/update.sh +++ b/renren-admin/src/main/resources/assembly/bin/update.sh @@ -105,5 +105,5 @@ fi rm -rf ${APP_DIR}/tmp/* # 重启平台 -sh ${APP_DIR}/renren-admin.sh start ${$PROFILES_ACTIVE} +sh ${APP_DIR}/renren-admin.sh start ${PROFILES_ACTIVE} exit 0 From dfe77f31a21a8fed7a6d63d7c9293df05d7e27f4 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 15:20:43 +0800 Subject: [PATCH 08/12] =?UTF-8?q?TODO=20=E5=88=97=E5=87=BA=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/AdminController.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java index f4c7d47b..dc888827 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java @@ -9,21 +9,27 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + @Api(tags = "管理员后台") @RestController @RequestMapping("/admin") public class AdminController { private static final Logger logger = LoggerFactory.getLogger(AdminController.class); - + private static final String pwd = System.getProperty("user.dir"); @Autowired private UpdateUtil updateUtil; @Value("${spring.profiles.active}") private String active; // 现有生效 + /** * @param updateFile 更新包下载地址 * @param active 重启完成后的配置环境 @@ -38,4 +44,12 @@ public class AdminController { return new Result().ok(String.valueOf(success)); } + @GetMapping(value = "logFiles") + public Result> logFiles() { + List result = new ArrayList<>(); + File file = new File(pwd + File.separator + "logs"); + File[] tempFile = file.listFiles(); + return new Result>().ok(result); + } + } From d56742d9a01e93342d191cf744b6021ff93573b5 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 15:38:43 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E5=88=97=E5=87=BA=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8E=E6=8F=90=E4=BE=9B=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/AdminController.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java index dc888827..6aa69987 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java @@ -9,6 +9,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -16,7 +20,10 @@ import org.springframework.web.bind.annotation.RestController; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Api(tags = "管理员后台") @RestController @@ -44,12 +51,41 @@ public class AdminController { return new Result().ok(String.valueOf(success)); } + /** + * 列出所有日志文件 + * + * @return + */ @GetMapping(value = "logFiles") public Result> logFiles() { List result = new ArrayList<>(); File file = new File(pwd + File.separator + "logs"); File[] tempFile = file.listFiles(); + result = Arrays.asList(tempFile).stream().filter(index -> index.isFile()).map(index -> index.getName()).collect(Collectors.toList()); return new Result>().ok(result); } + /** + * 下载日志文件 + * + * @param file + * @return + */ + @GetMapping(value = "downloadLog") + public ResponseEntity downloadLogFile(String file) { + File file_ = new File(pwd + File.separator + "logs" + File.separator + file); + if (!file_.exists()) { + return null; + } + HttpHeaders headers = new HttpHeaders(); + headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); + headers.add("Content-Disposition", "attachment; filename=" + file_.getName()); + headers.add("Pragma", "no-cache"); + headers.add("Expires", "0"); + headers.add("Last-Modified", new Date().toString()); + headers.add("ETag", String.valueOf(System.currentTimeMillis())); + return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file_)); + + } + } From bf342a70ae220d92bf24775c73a1acf29b0cd236 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 8 Nov 2022 15:55:41 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/renren/common/controller/AdminController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java index 6aa69987..223bc5cd 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java @@ -84,7 +84,7 @@ public class AdminController { headers.add("Expires", "0"); headers.add("Last-Modified", new Date().toString()); headers.add("ETag", String.valueOf(System.currentTimeMillis())); - return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file_)); + return ResponseEntity.ok().headers(headers).contentLength(file_.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file_)); } From 184950d030a45ea695d66af917ddaa4c99de5d38 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Wed, 9 Nov 2022 09:46:16 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=83=BD=E5=8A=9B?= =?UTF-8?q?=E6=8C=82=E6=8E=A5=E5=86=85=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 3 - .../controller/ResourceController.java | 91 ++++++++++++++++++- 2 files changed, 89 insertions(+), 5 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java index 8b1b3b22..cdec54b8 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java @@ -505,9 +505,6 @@ public class CensusController { SysDeptDTO sysDeptDTO = sysDeptService.get(user.getDeptId()); params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域 } -// else if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) { // 超级管理员 -// -// } ArrayList resultList = (ArrayList) resourceDao.selectCensusResourceTable(params); List> date = resultList.stream().map(index -> { List data = new ArrayList<>(); diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 9fe3bd84..91e76da5 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -16,11 +16,17 @@ import io.renren.modules.resource.dataResource.DataResourceFactory; import io.renren.modules.resource.dto.GetDataResourceListDto; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.excel.ResourceExcelImportListener; +import io.renren.modules.resource.excel.census.config.CustomCellWriteHeightConfig; +import io.renren.modules.resource.excel.census.config.CustomCellWriteWeightConfig; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService; import io.renren.modules.resource.videoPreview.VideoPreviewFactory; +import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.security.user.UserDetail; import io.renren.modules.sys.dto.SysDeptDTO; +import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.service.SysDeptService; +import io.renren.modules.sys.service.SysUserService; import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -41,8 +47,10 @@ import springfox.documentation.annotations.ApiIgnore; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; +import java.net.URLEncoder; import java.nio.charset.Charset; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -109,6 +117,9 @@ public class ResourceController { @Autowired private SysDeptService sysDeptService; + @Autowired + private SysUserService sysUserService; + @Resource(name = "${hisense.gateway.name}") private ApiGateway apiGateway; @@ -146,6 +157,82 @@ public class ResourceController { return new Result>().ok(page); } + @GetMapping("/export") + @ApiOperation("导出资源") + @LogOperation("导出资源") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), + @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + }) + public void exportSelectCensusResourceTable(@RequestParam Map params, HttpServletResponse response) throws IOException { + UserDetail user = SecurityUser.getUser(); + if (user.getDeptId() != null) { + SysDeptDTO sysDeptDTO = sysDeptService.get(user.getDeptId()); + params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域 + } + List result = resourceService.list(params); + List> date = result.stream().map(index -> { + List data = new ArrayList<>(); + data.add(index.getName()); + data.add(index.getDescription()); + Optional sysDeptDTOOptional = Optional.ofNullable(sysDeptService.get(index.getDeptId() == null ? 0l : index.getDeptId())); + if (sysDeptDTOOptional.isPresent()) { + data.add(sysDeptDTOOptional.get().getName()); + } else { + data.add("--"); + } + Optional yyly = index.getInfoList().stream().filter(index_ -> index_.getAttrType().equals("应用领域") && index_.getDelFlag().intValue() == 0).map(index_ -> index_.getAttrValue()).findFirst(); + if (yyly.isPresent()) { + data.add(yyly.get()); + } else { + data.add("--"); + } + data.add(index.getCreateDate() == null ? "--" : index.getCreateDate().toString()); + + SysUserDTO userDTO = sysUserService.get(index.getCreator() == null ? 0l : index.getCreator()); + if (userDTO != null) { + data.add(userDTO.getUsername()); + } else { + data.add("--"); + } + return data; + }).collect(Collectors.toList()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("资源导出_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream()).head(exportSelectCensusResourceTableHead()) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("上架情况").doWrite(date); + } + + private List> exportSelectCensusResourceTableHead() { + List> list = new ArrayList<>(); + List head0 = new ArrayList<>(); + head0.add("名称"); + List head1 = new ArrayList<>(); + head1.add("描述"); + List head2 = new ArrayList<>(); + head2.add("归属部门"); + List head3 = new ArrayList<>(); + head3.add("应用领域"); + List head4 = new ArrayList<>(); + head4.add("上架时间"); + List head5 = new ArrayList<>(); + head4.add("上架账号"); + list.add(head0); + list.add(head1); + list.add(head2); + list.add(head3); + list.add(head4); + list.add(head5); + return list; + } + @PostMapping("/pageWithAttrs") @ApiOperation("分页查询资源信息2") @LogOperation("分页查询资源信息2") @@ -444,8 +531,8 @@ public class ResourceController { @ApiOperation("资源列表转发") @LogOperation("资源列表转发") public Result yaweiApproveStatus(@ApiParam("页数") Integer page, - @ApiParam("页大小") Integer size, - @ApiParam("资源模糊搜索") String title) { + @ApiParam("页大小") Integer size, + @ApiParam("资源模糊搜索") String title) { if (page == null) page = 1; if (size == null) size = 10; From 8a4e11430e28f38b285b675e98500605c8a02bea Mon Sep 17 00:00:00 2001 From: wangliwen Date: Wed, 9 Nov 2022 09:47:09 +0800 Subject: [PATCH 12/12] ... --- .../resource/controller/ResourceController.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 91e76da5..3fe9c2be 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -21,8 +21,6 @@ import io.renren.modules.resource.excel.census.config.CustomCellWriteWeightConfi import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService; import io.renren.modules.resource.videoPreview.VideoPreviewFactory; -import io.renren.modules.security.user.SecurityUser; -import io.renren.modules.security.user.UserDetail; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.service.SysDeptService; @@ -168,11 +166,11 @@ public class ResourceController { @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), }) public void exportSelectCensusResourceTable(@RequestParam Map params, HttpServletResponse response) throws IOException { - UserDetail user = SecurityUser.getUser(); - if (user.getDeptId() != null) { - SysDeptDTO sysDeptDTO = sysDeptService.get(user.getDeptId()); - params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域 - } +// UserDetail user = SecurityUser.getUser(); +// if (user.getDeptId() != null) { +// SysDeptDTO sysDeptDTO = sysDeptService.get(user.getDeptId()); +// params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域 +// } List result = resourceService.list(params); List> date = result.stream().map(index -> { List data = new ArrayList<>();