From e937d0111a52e2c13c50bbc3386d20a12d125899 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 06 九月 2024 10:54:54 +0800
Subject: [PATCH] 链接类型查询模板
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java | 103 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 96 insertions(+), 7 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java
index db761d4..31076f5 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java
@@ -1,20 +1,33 @@
package com.vci.web.controller;
+import com.vci.constant.FrameWorkLangCodeConstant;
+import com.vci.dto.OsAttributeDTO;
import com.vci.starter.web.annotation.controller.VciUnCheckRight;
import com.vci.starter.web.annotation.log.VciBusinessLog;
+import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseQueryObject;
import com.vci.starter.web.pagemodel.BaseResult;
-import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.dto.OsStatusDTO;
import com.vci.pagemodel.OsLifeCycleVO;
import com.vci.pagemodel.OsStatusVO;
+import com.vci.starter.web.util.ControllerUtil;
+import com.vci.starter.web.util.LocalFileUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.web.service.OsLifeCycleServiceI;
import com.vci.web.service.OsStatusServiceI;
+import com.vci.web.util.Func;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
/**
* 鐘舵�佺殑鎺у埗鍣�
@@ -87,7 +100,6 @@
* @return 鎵ц缁撴灉
*/
@PostMapping("/addSave")
- @VciUnCheckRight
public BaseResult addSave(@RequestBody OsStatusDTO statusDTO){
try {
return statusService.addSave(statusDTO) ? BaseResult.success("娣诲姞鐘舵�佹垚鍔燂紒"):BaseResult.fail("娣诲姞鐘舵�佸け璐ワ紒");
@@ -118,13 +130,19 @@
/**
* 鍒犻櫎鐘舵��
- * @param oids 鐘舵�佺殑涓婚敭
+ * @param osStatusDTOS 鐘舵�佺殑DTO瀵硅薄
* @return 鎵ц缁撴灉
*/
- @DeleteMapping("/delete")
- public BaseResult delete(String oids){
- statusService.delete(oids);
- return BaseResult.success();
+ @DeleteMapping("/deleteStatus")
+ public BaseResult deleteStatus(@RequestBody List<OsStatusDTO> osStatusDTOS){
+ try {
+ return statusService.deleteStatus(osStatusDTOS) ? BaseResult.success("鍒犻櫎鐘舵�佹垚鍔燂紒"):BaseResult.fail("鍒犻櫎鐘舵�佸け璐ワ紒");
+ }catch (Exception e) {
+ e.printStackTrace();
+ String exceptionMessage = "鍒犻櫎鐘舵�佹椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
}
/**
@@ -137,4 +155,75 @@
return BaseResult.success(statusService.getObjectByOid(oid));
}
+ /**
+ * 瀵煎嚭鐘舵��
+ * @param exportFileName
+ * @param statusOids
+ * @param response
+ */
+ @GetMapping( "/exportStatus")
+ @VciBusinessLog(operateName = "瀵煎嚭鐘舵��")
+ public void exportStatus(String exportFileName,String statusOids, HttpServletResponse response){
+ try {
+ String excelPath = statusService.exportStatus(exportFileName,statusOids,true);
+ ControllerUtil.writeFileToResponse(response,excelPath);
+ } catch (Exception e) {
+ String msg = "瀵煎嚭鐘舵�佹椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+ try {
+ //鍑洪敊鏃�
+ e.printStackTrace();
+ ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null);
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 涓嬭浇鐘舵�佸鍏ユā鏉�
+ * @param exportFileName
+ * @param response
+ */
+ @GetMapping( "/downloadStatusTemplate")
+ @VciBusinessLog(operateName = "瀵煎嚭鐘舵��")
+ public void downloadStatusTemplate(String exportFileName, HttpServletResponse response){
+ try {
+ String excelPath = statusService.downloadStatusTemplate(exportFileName);
+ ControllerUtil.writeFileToResponse(response,excelPath);
+ } catch (Exception e) {
+ String msg = "涓嬭浇鏋氫妇瀵煎叆妯℃澘鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ try {
+ //鍑洪敊鏃�
+ e.printStackTrace();
+ ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null);
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 瀵煎叆鐘舵��
+ * @param file
+ * @return
+ */
+ @PostMapping("/importStatus")
+ @VciBusinessLog(operateName = "瀵煎叆鐘舵��")
+ public BaseResult importStatus(MultipartFile file){
+ String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename());
+ File file1 = new File(excelFileName);
+ try {
+ file.transferTo(new File(excelFileName));
+ if (file != null) {
+ return statusService.importStatus(file1);
+ } else {
+ return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
+ }
+ }catch (Throwable e) {
+ throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e);
+ }finally {
+ file1.delete();
+ }
+ }
+
}
--
Gitblit v1.9.3