package com.vci.web.controller; import com.vci.corba.common.PLException; import com.vci.corba.omd.qtm.QTD; import com.vci.dto.QTInfoDTO; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.service.OsQuereyTemplateServiceI; import org.dom4j.DocumentException; 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.IOException; import java.util.Arrays; import java.util.List; /** * 查询模板的控制器 * @author weidy * @date 2022-3-26 */ @RequestMapping("/templateController") @RestController public class OsQueryTemplateController { /** * 查询模板服务 */ @Autowired private OsQuereyTemplateServiceI quereyTemplateServiceI; /** * 日志 */ private Logger logger = LoggerFactory.getLogger(getClass()); /** * 查询模板的列表 * @param btmName 类型 * @param linkFlag 是否链接类型 :true 链接类型 ,false 业务类型 * @return 查询模板的列表 */ @GetMapping("/queryTemplateList") public BaseResult queryTemplateList(String btmName,Boolean linkFlag){ try { return quereyTemplateServiceI.queryTemplateList(btmName,linkFlag); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 查询模板的列表添加了字段的相关属性 * @param btmName 类型 * @param linkFlag 是否链接类型 :true 链接类型 ,false 业务类型 * @return 查询模板的列表 */ @GetMapping("/queryTemplateListByAttr") public BaseResult queryTemplateListByAttr(String btmName,Boolean linkFlag, String direction){ try { return quereyTemplateServiceI.queryTemplateListByAttr(btmName,linkFlag,direction); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 保存查询模板 * @param qtd 查询模板实体类 * @return 保存结果 */ @PostMapping("/saveTemplate") public BaseResult saveTemplate(@RequestBody QTD qtd){ try { return quereyTemplateServiceI.saveTemplate(qtd); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 修改查询模板 * @param qtd 查询模板实体类 * @return 保存结果 */ @PostMapping("/updateTemplate") public BaseResult updateTemplate(@RequestBody QTD qtd){ try { return quereyTemplateServiceI.updateTemplate(qtd); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 删除查询模板 * @param name 查询模板名 * @return 保存结果 */ @DeleteMapping("/deleteTemplate") public BaseResult deleteTemplate(String name){ try { return quereyTemplateServiceI.deleteTemplate(name); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 查询条件的查询按钮查询lis列表 * @param qtInfoDTO 传输的数据对象: * linkTypeName 链接类型名称、 * rdPositive 方向,true正向,false反向 * btmName 业务类型名称 * combRelaType 业务类型选择值 * versionValue 版本班次值 * isQueryIsLeaf 是否选择下级 * level 子节点层数 * @return 查询结果 */ @PostMapping("/getCriteria") public BaseResult getCriteria(@RequestBody QTInfoDTO qtInfoDTO){ try { return quereyTemplateServiceI.getCriteria(qtInfoDTO); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 业务类型查询模板下的查询条件的查询按钮查询list列表 * @param qtInfoDTO * @return 查询结果 */ @PostMapping("/getCriteriaBtm") public BaseResult getCriteriaBtm(@RequestBody QTInfoDTO qtInfoDTO){ try { return quereyTemplateServiceI.getCriteriaBtm(qtInfoDTO); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 查询条件下的选择查询模板对话框(查询全部模板和所对应的业务类型或链接类型名) * @return */ @GetMapping("/getAllQTs") public BaseResult getAllQTs(){ try { return quereyTemplateServiceI.getAllQTs(); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 查询模板列表 * @param btName 类型名称 * @return 查询结果 */ @GetMapping("/getObjTypeQTs") public BaseResult getObjTypeQTs(String btName){ try { return quereyTemplateServiceI.getObjTypeQTs(btName); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } catch (DocumentException e) { e.printStackTrace(); BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(500); objectBaseResult.setMsg(Arrays.toString(e.getMessage().toCharArray())); return objectBaseResult; } } /** * 检查查询模板名字是否存在 * @param name 查询模板名字 * @return 查询结果 */ @GetMapping("/isExistsQT") public BaseResult isExistsQT(String name){ try { return quereyTemplateServiceI.isExistsQT(name); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 链接类型查询模板保存 * @param qtInfoDTO 保存传输对象 * @return 保存结果 */ @PostMapping("/linkSave") public BaseResult linkSave(@RequestBody QTInfoDTO qtInfoDTO){ try { return quereyTemplateServiceI.linkSave(qtInfoDTO); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 链接类型查询模板树查询,用于界面的导出功能 * @return 查询结果 */ @GetMapping("/getLinkTree") public BaseResult getLinkTree(){ try { return quereyTemplateServiceI.getLinkTree(); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 导出链接类型查询模板 * names 查询模板名 * @return */ @PostMapping("/expLinkTemplate") public void expLinkTemplate(@RequestBody List names,HttpServletResponse response) throws PLException, IOException { quereyTemplateServiceI.expLinkTemplate(names, response); } /** * 导入链接类型查询模板 * @param file 上传的文件 * @return 导入结果 */ @PostMapping("/impLinkTemplate") public BaseResult impLinkTemplate(MultipartFile file){ try { return quereyTemplateServiceI.impLinkTemplate(file); }catch (Throwable e) { throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); } } /** * 查询方案删除 * @param names 查询方案名 * @return 操作结果 */ @DeleteMapping("/deleteLinkTemplate") public BaseResult deleteLinkTemplate(String names){ try { return quereyTemplateServiceI.deleteLinkTemplate(names); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 业务类型查询模板保存 * @param qtInfoDTO 保存传输对象 * @return 保存结果 */ @PostMapping("/btmSave") public BaseResult btmSave(@RequestBody QTInfoDTO qtInfoDTO){ try { return quereyTemplateServiceI.btmSave(qtInfoDTO); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 更新数据库结构 * @return 更新结果 */ @PostMapping("/updateDBStructure") public BaseResult btmSave(){ try { return quereyTemplateServiceI.updateDBStructure(); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 业务类型查询模板树查询,用于界面的导出功能 * @return 查询结果 */ @GetMapping("/getBtmQtTree") public BaseResult getBtmQtTree(){ try { return quereyTemplateServiceI.getBtmQtTree(); } catch (PLException e) { BaseResult objectBaseResult = new BaseResult<>(); objectBaseResult.setCode(Integer.parseInt(e.code)); objectBaseResult.setMsg(Arrays.toString(e.messages)); return objectBaseResult; } } /** * 导出业务类型查询模板 * names 查询模板名 * @return */ @PostMapping("/expBtmQTTemplate") public void expBtmQTTemplate(@RequestBody List names,HttpServletResponse response) throws PLException, IOException { quereyTemplateServiceI.expBtmQTTemplate(names, response); } /** * 导入业务类型查询模板 * @param file 上传的文件 * @return 导入结果 */ @PostMapping("/impBtmTemplate") public BaseResult impBtmTemplate(MultipartFile file){ try { return quereyTemplateServiceI.impBtmTemplate(file); }catch (Throwable e) { throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); } } }