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 | 167 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 147 insertions(+), 20 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 36029e9..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,17 +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.annotation.permission.VciPermission;
+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.web.dto.OsStatusDTO;
-import com.vci.web.pageModel.OsLifeCycleVO;
-import com.vci.web.pageModel.OsStatusVO;
+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;
/**
* 鐘舵�佺殑鎺у埗鍣�
@@ -36,14 +52,27 @@
private OsLifeCycleServiceI lifeCycleService;
/**
+ * 鏃ュ織
+ */
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
+ /**
* 鐘舵�佺殑鍒楄〃
* @param queryObject 鏌ヨ瀵硅薄
* @return 鏄剧ず瀵硅薄
*/
@GetMapping("/gridStatus")
@VciBusinessLog(operateName = "鏌ョ湅鐘舵�佸垪琛�")
- public DataGrid<OsStatusVO> gridStatus(BaseQueryObject queryObject){
- return statusService.gridStatus(queryObject.getConditionMap(),queryObject.getPageHelper());
+ @VciUnCheckRight
+ public BaseResult<OsStatusVO> gridStatus(BaseQueryObject queryObject){
+ try {
+ return BaseResult.dataGrid(statusService.gridStatus(queryObject.getConditionMap(),queryObject.getPageHelper()));
+ }catch (Exception e) {
+ e.printStackTrace();
+ String exceptionMessage = "灞炴�х鐞嗗垪琛ㄦ煡璇㈡椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
}
/**
@@ -52,8 +81,17 @@
* @return 浣跨敤鐨勭敓鍛藉懆鏈熺殑瀵硅薄
*/
@GetMapping("/listUsed")
- public DataGrid<OsLifeCycleVO> listUsed(String oid){
- return lifeCycleService.listStatusUsed(oid);
+ @VciBusinessLog(operateName = "鏌ヨ鐘舵�佹睜鐨勫簲鐢ㄨ寖鍥�")
+ @VciUnCheckRight
+ public BaseResult<OsLifeCycleVO> listUsed(String oid){
+ try {
+ return BaseResult.dataGrid(lifeCycleService.listStatusUsed(oid));
+ }catch (Exception e) {
+ e.printStackTrace();
+ String exceptionMessage = "灞炴�х鐞嗗垪琛ㄦ煡璇㈡椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
}
/**
@@ -62,9 +100,15 @@
* @return 鎵ц缁撴灉
*/
@PostMapping("/addSave")
- public BaseResult addSave(OsStatusDTO statusDTO){
- statusService.addSave(statusDTO);
- return BaseResult.success();
+ public BaseResult addSave(@RequestBody OsStatusDTO statusDTO){
+ try {
+ return statusService.addSave(statusDTO) ? BaseResult.success("娣诲姞鐘舵�佹垚鍔燂紒"):BaseResult.fail("娣诲姞鐘舵�佸け璐ワ紒");
+ }catch (Exception e) {
+ e.printStackTrace();
+ String exceptionMessage = "娣诲姞鐘舵�佹椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
}
/**
@@ -73,20 +117,32 @@
* @return 鎵ц缁撴灉
*/
@PutMapping("/editSave")
- public BaseResult editSave(OsStatusDTO statusDTO){
- statusService.editSave(statusDTO);
- return BaseResult.success();
+ public BaseResult editSave(@RequestBody OsStatusDTO statusDTO){
+ try {
+ return statusService.editSave(statusDTO) ? BaseResult.success("淇敼鐘舵�佹垚鍔燂紒"):BaseResult.fail("淇敼鐘舵�佸け璐ワ紒");
+ }catch (Exception e) {
+ e.printStackTrace();
+ String exceptionMessage = "淇敼鐘舵�佹椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
}
/**
* 鍒犻櫎鐘舵��
- * @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);
+ }
}
/**
@@ -99,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