| | |
| | | package com.vci.web.controller; |
| | | |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.dto.ClonePortalVIDTOList; |
| | | import com.vci.dto.DeletePortalVIDTOList; |
| | | import com.vci.dto.PortalVIDTO; |
| | | import com.vci.pagemodel.KeyValue; |
| | | import com.vci.pagemodel.PortalVIVO; |
| | | 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.LangBaseUtil; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.enumpck.ItemDblEnum; |
| | | import com.vci.web.enumpck.ItemTypeEnum; |
| | | import com.vci.enumpck.UI.ItemTypeEnum; |
| | | import com.vci.web.service.OsPortalVIServiceI; |
| | | 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.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 公式控制器 |
| | | * 表单/表格控制器 |
| | | * @author weidy |
| | | * @date 2022-2-11 |
| | | */ |
| | | @VciBusinessLog(modelName="表单/表格控制器",notStore=true) |
| | | @RestController |
| | | @RequestMapping("/portalVIController") |
| | | public class WebPortalVIController { |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | @Autowired |
| | | private OsPortalVIServiceI portalVIServiceI; |
| | | /** |
| | | * 表单列表 |
| | |
| | | * @param baseQueryObject 查询条件 |
| | | * @return 列表的内容 |
| | | */ |
| | | @GetMapping( "/referDataGrid") |
| | | @GetMapping( "/gridPortalVIDatas") |
| | | @VciBusinessLog(operateName = "表单/表格列表") |
| | | public DataGrid<PortalVIVO> referDataGrid(BaseQueryObject baseQueryObject){ |
| | | public DataGrid<PortalVIVO> gridPortalVIDatas(BaseQueryObject baseQueryObject){ |
| | | return portalVIServiceI.gridPortalVIVOs(baseQueryObject); |
| | | } |
| | | |
| | | |
| | | /** |
| | | *根据表单id获取具体数据 |
| | | * @param id |
| | | * @param viType |
| | | * @return |
| | | */ |
| | | @GetMapping( "/getPortalVIById") |
| | | @VciBusinessLog(operateName = "获取表单/表格数据") |
| | | public BaseResult getPortalVIById(@RequestParam("id") String id,@RequestParam("viType") String viType){ |
| | | try{ |
| | | PortalVIVO portalVIVO= portalVIServiceI.getPortalVIById(id,viType); |
| | | return BaseResult.success(portalVIVO); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "获取表单/表格数据时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | /** |
| | | * 表单/table保存 |
| | | * @param portalVIDTO |
| | | * @return |
| | | */ |
| | | @PostMapping("/savePortalVI") |
| | | @VciBusinessLog(operateName = "添加表单/表格") |
| | | @VciBusinessLog(operateName = "保存表单/表格") |
| | | public BaseResult savePortalVI(@RequestBody PortalVIDTO portalVIDTO){ |
| | | if(StringUtils.isNotBlank(portalVIDTO.getId())){ |
| | | return portalVIServiceI.edit(portalVIDTO); |
| | | return portalVIServiceI.editSave(portalVIDTO); |
| | | }else{ |
| | | return portalVIServiceI.add(portalVIDTO); |
| | | return portalVIServiceI.addSave(portalVIDTO); |
| | | } |
| | | } |
| | | /** |
| | | * 表单/table删除 |
| | | * btmTypeDTO 业务类型对象 |
| | | * @return 删除结果 |
| | | */ |
| | | @DeleteMapping("/delete") |
| | | @VciBusinessLog(operateName = "删除表单/表格") |
| | | public BaseResult delete(@RequestBody DeletePortalVIDTOList deletePortalVIDTOList){ |
| | | try { |
| | | return portalVIServiceI.delete(deletePortalVIDTOList) ? BaseResult.success("删除成功!"):BaseResult.fail("删除失败!"); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "删除表单时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | /** |
| | | * 表单/table删除 |
| | | * btmTypeDTO 业务类型对象 |
| | | * @return 删除结果 |
| | | */ |
| | | @DeleteMapping("/deleteByIds") |
| | | @VciBusinessLog(operateName = "删除表单/表格") |
| | | public BaseResult deleteByIds(@RequestParam("ids") String ids){ |
| | | try { |
| | | return portalVIServiceI.delete(ids) ? BaseResult.success("删除成功!"):BaseResult.fail("删除失败!"); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 表单/table克隆 |
| | | * @param portalVIDTOList clong对象 |
| | | * @return |
| | | */ |
| | | @PostMapping("/clone") |
| | | @VciBusinessLog(operateName = "克隆表单/表格") |
| | | public BaseResult clone(@RequestBody ClonePortalVIDTOList portalVIDTOList){ |
| | | try { |
| | | return portalVIServiceI.clone(portalVIDTOList) ? BaseResult.success("克隆成功!"):BaseResult.fail("克隆失败!"); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "克隆表单/表格时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 导出数据库的表信息到excel |
| | | * @param response 响应对象 |
| | | * @param ids 业务类型的编号,用逗号分割 |
| | | */ |
| | | @PostMapping("/exportExcel") |
| | | @VciBusinessLog(operateName = "导出表单/表格到excel中") |
| | | public void exportExcel(String ids,HttpServletResponse response){ |
| | | String excelFileName = portalVIServiceI.exportToExcel(VciBaseUtil.str2List(ids)); |
| | | try { |
| | | ControllerUtil.writeFileToResponse(response,excelFileName); |
| | | } catch (IOException e) { |
| | | try { |
| | | ControllerUtil.writeDataToResponse(response, LangBaseUtil.getErrorMsg(e).getBytes(StandardCharsets.UTF_8),null); |
| | | } catch (IOException ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导出数据库的表信息到excel |
| | | * @param file 上传的文件 |
| | | */ |
| | | @PostMapping("/importData") |
| | | @VciBusinessLog(operateName = "导入表单/表格") |
| | | public BaseResult importData(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 portalVIServiceI.importData(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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取属性字段类型 |
| | | */ |
| | |
| | | * 获取超链接弹出方法 |
| | | */ |
| | | @GetMapping("/getItemDblList") |
| | | @VciBusinessLog(operateName = "属性字段类型") |
| | | @VciBusinessLog(operateName = "超链接类型") |
| | | public BaseResult<List<KeyValue>> getItemDblList(){ |
| | | return BaseResult.dataList(ItemDblEnum.getEnumAll()); |
| | | } |