From 34c25ddf37a3eb8da9efb04efedad089f13efe83 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 24 七月 2024 18:20:27 +0800 Subject: [PATCH] 部门导入调整,按照部门名称/实现层级关系。枚举导入功能接口上传,属性池添加新增、查询、修改、导出、查看应用范围等接口。业务类型、链接类型、枚举类型增加等接口属性是否产生数据检查、根据属性名修改业务类型和连接类型中对应属性方法,以及属性池中需要的一些下拉查询接口。 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 215 insertions(+), 22 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java index 1933f33..e5c3025 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java @@ -1,23 +1,35 @@ package com.vci.web.controller; +import com.vci.constant.FrameWorkLangCodeConstant; +import com.vci.dto.OsEnumDTO; 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.web.pageModel.KeyValue; -import com.vci.web.pageModel.OsBtmTypeVO; -import com.vci.web.pageModel.OsEnumItemVO; -import com.vci.web.pageModel.OsEnumVO; +import com.vci.pagemodel.KeyValue; +import com.vci.pagemodel.OsEnumItemVO; +import com.vci.pagemodel.OsEnumVO; +import com.vci.starter.web.util.ControllerUtil; +import com.vci.starter.web.util.LangBaseUtil; +import com.vci.starter.web.util.LocalFileUtil; +import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.service.OsEnumServiceI; +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.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +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; +import java.util.Map; /** @@ -37,17 +49,42 @@ private OsEnumServiceI enumService; /** + * 鏃ュ織 + */ + private Logger logger = LoggerFactory.getLogger(getClass()); + + /** * 鑾峰彇鏋氫妇鐨勪笅鎷夋 * @param comboxKey 鏋氫妇鐨勫悕绉� * @return 鏋氫妇鐨勪笅鎷夊�� */ @VciBusinessLog(notStore=true,operateName="鑾峰彇鏋氫妇") - @VciUnCheckRight @GetMapping("/getEnum") public BaseResult<List<KeyValue>> getEnum(String comboxKey){ return BaseResult.success(enumService.getEnum(comboxKey)); } + /** + * 鍙傜収鏋氫妇鍒楄〃 + * @param baseQueryObject 鏌ヨ鏉′欢 + * @return 鍒楄〃鐨勫唴瀹� + */ + @GetMapping( "/referDataGrid") + @VciBusinessLog(operateName = "鍙傜収鏋氫妇鍒楄〃") + public DataGrid<OsEnumVO> referDataGrid(BaseQueryObject baseQueryObject){ + return enumService.referDataGrid(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); + } + + /** + * 鑾峰彇鏋氫妇鐨勬槑缁� + * @param pkEnum 鏋氫妇鐨勪富閿� + * @return 鏋氫妇鐨勯�夐」 + */ + @GetMapping("/gridEnumItemByOid") + @VciBusinessLog(operateName = "鑾峰彇鏋氫妇鐨勬槑缁�") + public DataGrid<OsEnumItemVO> gridEnumItemByOid(String pkEnum){ + return enumService.gridEnumItemByOid(pkEnum); + } /** * 鑾峰彇鏁版嵁鐨勫瘑绾� @@ -62,25 +99,181 @@ } /** - * 鏋氫妇鍒楄〃 - * @param baseQueryObject 鏌ヨ鏉′欢 + * 鏍规嵁鏋氫妇绫诲瀷鑾峰彇鏋氫妇 + * @param enumType 鏌ヨ鏉′欢name * @return 鍒楄〃鐨勫唴瀹� */ - @GetMapping( "/gridEnum") + @GetMapping( "/getEnumMapByType") @VciBusinessLog(operateName = "鏋氫妇鍒楄〃") - public DataGrid<OsEnumVO> gridEnum(BaseQueryObject baseQueryObject){ - return enumService.referDataGrid(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper()); + public BaseResult getEnumMapByType(String enumType) { + try { + return BaseResult.dataList(enumService.getEnumMapByType(enumType)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鏋氫妇绠$悊鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } } /** - * 鑾峰彇鏋氫妇鐨勬槑缁� - * @param pkEnum 鏋氫妇鐨勪富閿� - * @return 鏋氫妇鐨勯�夐」 + * 鏋氫妇鍒楄〃 + * @param enumName 鏌ヨ鏉′欢name + * @return 鍒楄〃鐨勫唴瀹� */ - @GetMapping("/gridEnumItemByOid") - @VciBusinessLog(operateName = "鑾峰彇鏋氫妇鐨勬槑缁�") - public DataGrid<OsEnumItemVO> gridEnumItemByOid(String pkEnum){ - return enumService.gridEnumItemByOid(pkEnum); + @GetMapping( "/getEnumTypeList") + @VciBusinessLog(operateName = "鏋氫妇鍒楄〃") + public BaseResult<List<OsEnumVO>> getEnumTypeList(String enumName) { + try { + return BaseResult.dataList(enumService.getEnumTypeList(enumName)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鏋氫妇绠$悊鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 娣诲姞鍗曟潯鏋氫妇 + * @param osEnumDTO + * @return 鍒楄〃鐨勫唴瀹� + */ + @PostMapping( "/addEnumType") + @VciBusinessLog(operateName = "娣诲姞鏋氫妇") + public BaseResult addEnumType(@RequestBody OsEnumDTO osEnumDTO) { + try { + return enumService.addEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷娣诲姞鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷娣诲姞澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "澧炲姞鏋氫妇绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 淇敼鍗曟潯鏋氫妇锛堝甫淇敼鏋氫妇椤瑰姛鑳斤級 + * @param osEnumDTO + * @return 鍒楄〃鐨勫唴瀹� + */ + @PutMapping( "/updateEnumType") + @VciBusinessLog(operateName = "淇敼鏋氫妇") + public BaseResult updateEnumType(@RequestBody OsEnumDTO osEnumDTO) { + try { + return enumService.updateEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷淇敼鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷淇敼澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "淇敼鏋氫妇绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎鏋氫妇 + * @param osEnumDTOS + * @return 鍒楄〃鐨勫唴瀹� + */ + @DeleteMapping( "/deleteEnumTypes") + @VciBusinessLog(operateName = "鍒犻櫎鏋氫妇") + public BaseResult deleteEnumTypes(@RequestBody List<OsEnumDTO> osEnumDTOS) { + try { + return enumService.deleteEnumTypes(osEnumDTOS) ? BaseResult.success("鏋氫妇绫诲瀷鍒犻櫎鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷鍒犻櫎澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎鏋氫妇绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥� + * @param enumName 鏋氫妇鍚嶇О + * @return map瀵硅薄 + */ + @GetMapping( "/getUsedEnumList") + @VciBusinessLog(operateName = "鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�") + public BaseResult getUsedEnumList(String enumName) { + try { + return BaseResult.dataList(enumService.getUsedEnumList(enumName)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鑾峰彇鏋氫妇鐨勪娇鐢ㄨ寖鍥存椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 瀵煎嚭閫変腑鐨勬灇涓剧被鍨� + * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕 + * @param enumNames 闇�瑕佸鍑虹殑鏋氫妇鍚嶇О + * @param response + */ + @GetMapping( "/exportEnumTypes") + @VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷") + public void exportEnumTypes(String exportFileName,String enumNames, HttpServletResponse response){ + try { + String excelPath = enumService.exportEnumTypes(exportFileName,enumNames); + 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( "/downloadEnumTemplate") + @VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷") + public void downloadEnumTemplate(String exportFileName, HttpServletResponse response){ + try { + String excelPath = enumService.downloadEnumTemplate(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 + */ + @RequestMapping(value = "/importEnumTypes",method = RequestMethod.POST) + public BaseResult importEnumTypes(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 enumService.importEnumTypes(file1); + } else { + return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"}); + } + }catch (Throwable e) { + throw new VciBaseException(e.getMessage(),new String[0],e); + }finally { + file1.delete(); + } } } -- Gitblit v1.9.3