From 93cfe891a02766e0c56c5781eb6ca8a5cc5fb16f Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期三, 31 七月 2024 11:43:13 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/VciOsStatusController.java |  160 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 144 insertions(+), 16 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 718362f..2371ba8 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,16 +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;
 
 /**
  * 鐘舵�佺殑鎺у埗鍣�
@@ -35,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);
+        }
     }
 
     /**
@@ -51,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);
+        }
     }
 
     /**
@@ -61,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);
+        }
     }
 
     /**
@@ -72,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);
+        }
     }
 
     /**
@@ -98,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);
+            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