| | |
| | | package com.vci.web.controller; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.portal.data.PLPageDefination; |
| | | import com.vci.corba.portal.data.PLTabPage; |
| | | import com.vci.corba.portal.data.PLUILayout; |
| | | import com.vci.dto.UIAuthorDTO; |
| | | import com.vci.pagemodel.PLDefinationVO; |
| | | import com.vci.pagemodel.PLTabButtonVO; |
| | | import com.vci.pagemodel.PLUILayoutCloneVO; |
| | | import com.vci.pagemodel.UICloneVO; |
| | | 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.starter.web.util.ControllerUtil; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.service.OsBtmServiceI; |
| | | import com.vci.web.service.UIManagerServiceI; |
| | | 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.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.xml.crypto.Data; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.Comparator; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * UI定义控制层 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询要导出UI上下文树 |
| | | * @param expDatas |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @GetMapping( "/getExpContextTree") |
| | | @VciBusinessLog(operateName = "查询要导出UI上下文树") |
| | | public BaseResult getExpContextTree(String[] expDatas){ |
| | | try { |
| | | return BaseResult.success(uiManagerService.getExpContextTree(Arrays.asList(expDatas)),"Success"); |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "查询要导出UI上下文树时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导出UI上下文 |
| | | * name 链接类型名称 |
| | | * @return |
| | | */ |
| | | @GetMapping("/expUIContextData") |
| | | public void expUIContextData(String[] oids, HttpServletResponse response) throws PLException, IOException { |
| | | uiManagerService.expUIContextData(oids, response); |
| | | @PostMapping("/expUIContextData") |
| | | public void expUIContextData(@RequestBody Map<String,String> expConditionMap, HttpServletResponse response) throws PLException, IOException { |
| | | try { |
| | | String excelPath = uiManagerService.expUIContextData(expConditionMap); |
| | | ControllerUtil.writeFileToResponse(response,excelPath); |
| | | FileUtil.del(LocalFileUtil.getDefaultTempFolder() + File.separator); |
| | | } catch (Exception e) { |
| | | String msg = "导出UI上下文时出现错误,原因:" + 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(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入UI上下文 |
| | | * @param file 上传的文件 |
| | | * @param isCovered 是否覆盖 |
| | | * @param selectBtm 选择导入到的业务类型 |
| | | * @return |
| | | */ |
| | | @PostMapping("/impUiContextData") |
| | | public BaseResult impUIContextData(MultipartFile file){try { |
| | | return uiManagerService.impUIContextData(file); |
| | | }catch (Throwable e) { |
| | | throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); |
| | | } |
| | | @PostMapping("/impUIContextData") |
| | | public BaseResult impUIContextData(MultipartFile file, boolean isCovered,String selectBtm){ |
| | | File file1 = null; |
| | | try { |
| | | //覆盖,不需要传file |
| | | if(!isCovered){ |
| | | String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename()); |
| | | file1 = new File(excelFileName); |
| | | file.transferTo(new File(excelFileName)); |
| | | } |
| | | if (file != null || isCovered) { |
| | | return uiManagerService.impUIContextData(file1, isCovered,selectBtm); |
| | | } else { |
| | | return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"}); |
| | | } |
| | | }catch (Throwable e) { |
| | | throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); |
| | | }finally { |
| | | if(!isCovered){ |
| | | file1.delete(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 业务类型下拉查询 |
| | | * @param baseQueryObject selectBtmType 选择的源对象,带分页信息 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @GetMapping( "/getBtmDatasByPage") |
| | | @VciBusinessLog(operateName = "业务类型下拉查询") |
| | | public BaseResult getBtmDatasByPage(BaseQueryObject baseQueryObject){ |
| | | try { |
| | | return BaseResult.dataGrid(uiManagerService.getBtmDatasByPage(baseQueryObject)); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "业务类型下拉查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 链接类型下拉查询 |
| | | * @param baseQueryObject selectBtmType 选择的源对象,带分页信息 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @GetMapping( "/getLinkDatasByPage") |
| | | @VciBusinessLog(operateName = "链接类型下拉查询") |
| | | public BaseResult getLinkDatasByPage(BaseQueryObject baseQueryObject){ |
| | | try { |
| | | return BaseResult.dataGrid(uiManagerService.getLinkDatasByPage(baseQueryObject)); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "链接类型下拉查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * UI定义下拉查询(templateType为UI定义时的选择对象下拉查询) |
| | | * @param baseQueryObject selectBtmType 选择的源对象,带分页信息 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @GetMapping( "/getUILayoutDatasByPage") |
| | | @VciBusinessLog(operateName = "UI定义下拉查询") |
| | | public BaseResult getUILayoutDatasByPage(BaseQueryObject baseQueryObject){ |
| | | try { |
| | | return BaseResult.dataGrid(uiManagerService.getUILayoutDatasByPage(baseQueryObject)); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "UI定义下拉查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 选择模板下拉查询 |
| | | * @param baseQueryObject |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @GetMapping( "/getPortalVIDatasByPage") |
| | | @VciBusinessLog(operateName = "选择模板下拉查询") |
| | | public BaseResult getPortalVIDatasByPage(BaseQueryObject baseQueryObject){ |
| | | try { |
| | | return BaseResult.dataGrid(uiManagerService.getPortalVIDatasByPage(baseQueryObject)); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "选择模板下拉查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询模板下拉查询 |
| | | * @param baseQueryObject |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @GetMapping( "/getQTInfoDatasByPage") |
| | | @VciBusinessLog(operateName = "查询模板下拉查询") |
| | | public BaseResult getQTInfoDatasByPage(BaseQueryObject baseQueryObject){ |
| | | try { |
| | | return BaseResult.dataGrid(uiManagerService.getQTInfoDatasByPage(baseQueryObject)); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "查询模板下拉查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | |
| | | //页面设计下配置按钮相关接口 |
| | | /** |
| | | * 获取页签区域按钮配置信息 |
| | | * @param pageDefinationOid |
| | | * @return |
| | | */ |
| | | @GetMapping( "/getTabButtons") |
| | | @VciBusinessLog(operateName = "获取页签区域按钮配置信息") |
| | | public BaseResult getTabButtons(String pageDefinationOid){ |
| | | try { |
| | | return BaseResult.dataList(uiManagerService.getTabButtons(pageDefinationOid)); |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "获取页签区域按钮配置信息时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return 保存结果 |
| | | */ |
| | | @PostMapping("/addTabButton") |
| | | public BaseResult addTabButton(@RequestBody PLTabButtonVO tabButtonVO){ |
| | | try { |
| | | return uiManagerService.addTabButton(tabButtonVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "按钮配置信息添加时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return 修改结果 |
| | | */ |
| | | @PutMapping("/updateTabbutton") |
| | | public BaseResult updateTabButton(@RequestBody PLTabButtonVO tabButtonVO){ |
| | | try { |
| | | return uiManagerService.updateTabButton(tabButtonVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "修改按钮配置信息时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除单个按钮配置 |
| | | * @param tabButtonVO |
| | | * @return |
| | | */ |
| | | @DeleteMapping("/deleteTabButton") |
| | | public BaseResult deleteTabButton(@RequestBody PLTabButtonVO tabButtonVO){ |
| | | try { |
| | | return uiManagerService.deleteTabButton(tabButtonVO) ? BaseResult.success("删除单个按钮配置成功!"):BaseResult.fail("删除单个按钮配置失败!"); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "删除单个按钮配置时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 调整为下级按钮 |
| | | * @param tabButtonVO |
| | | * @return 修改结果 |
| | | */ |
| | | @PutMapping("/joinBtn") |
| | | public BaseResult joinBtn(@RequestBody PLTabButtonVO tabButtonVO){ |
| | | try { |
| | | return uiManagerService.joinBtn(tabButtonVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "调整为下级按钮时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 调整为上级按钮 |
| | | * @param tabButtonVO |
| | | * @return 修改结果 |
| | | */ |
| | | @PutMapping("/exitBtn") |
| | | public BaseResult exitBtn(@RequestBody PLTabButtonVO tabButtonVO){ |
| | | try { |
| | | return uiManagerService.exitBtn(tabButtonVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "调整为上级按钮时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取UI/表单/按钮的权限. |
| | | * @param baseQueryObject |
| | | * @return |
| | |
| | | @VciBusinessLog(operateName = "UI授权(树形结构)") |
| | | public BaseResult getUIAuthor(BaseQueryObject baseQueryObject){ |
| | | try { |
| | | return BaseResult.dataList( uiManagerService.getUIAuthor(baseQueryObject)); |
| | | return BaseResult.dataList(uiManagerService.getUIAuthor(baseQueryObject)); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "UI授权加载出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据角色主键获取已授权的信息 |
| | | * @param roleId |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | /* @GetMapping( "/getRightListByRoleId") |
| | | @VciBusinessLog(operateName = "根据角色主键获取已授权的UI主键集合") |
| | | public BaseResult getRightListByRoleId(String roleId){ |
| | | try { |
| | | return BaseResult.success(uiManagerService.getRightListByRoleId(roleId)); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "获取已授权信息时错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | }*/ |
| | | |
| | | /*** |
| | | * @param uiAuthorDTO 勾选的需要保存的数据对象 |
| | | * @return |
| | | */ |
| | | @PostMapping( "/authorizedUI") |
| | | @VciBusinessLog(operateName = "UI授权") |
| | | public BaseResult authorizedUI(UIAuthorDTO uiAuthorDTO){ |
| | | public BaseResult authorizedUI(@RequestBody UIAuthorDTO uiAuthorDTO){ |
| | | try { |
| | | return uiManagerService.authorizedUI(uiAuthorDTO)?BaseResult.success("授权成功!"):BaseResult.fail("授权失败!"); |
| | | }catch (Throwable e) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通过业务类型获取UI上下文包含其下关联的区域定义>页面定义等所有关联数据,归纳成tree结构 |
| | | * @param btmName |
| | | * @param level |
| | | * @return |
| | | */ |
| | | @GetMapping( "/getAllLevelTreeByBtm") |
| | | public BaseResult getAllLevelTreeByBtm(String btmName,String level){ |
| | | try { |
| | | return BaseResult.success(uiManagerService.getAllLevelTreeByBtm(btmName,level)); |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "获取UI树时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 克隆页签 |
| | | * @param uiCloneVO |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | @PostMapping("/clonetabPage") |
| | | public BaseResult clonetabPage(@RequestBody UICloneVO uiCloneVO){ |
| | | try { |
| | | return uiManagerService.clonetabPage(uiCloneVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "克隆页签时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 克隆页面定义 |
| | | * @param uiCloneVO |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | @PostMapping("/clonePageDef") |
| | | public BaseResult clonePageDef(@RequestBody UICloneVO uiCloneVO){ |
| | | try { |
| | | return uiManagerService.clonePageDef(uiCloneVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "克隆页面定义时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 克隆按钮 |
| | | * @param uiCloneVO |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | @PostMapping("/cloneTabButton") |
| | | public BaseResult cloneTabButton(@RequestBody UICloneVO uiCloneVO){ |
| | | try { |
| | | return uiManagerService.cloneTabButton(uiCloneVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "克隆按钮配置时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | } |