| | |
| | | package com.vci.web.controller; |
| | | |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.dto.ClonePortalVIDTOList; |
| | | import com.vci.dto.DeletePortalVIDTOList; |
| | | import com.vci.dto.OsBtmTypeDTO; |
| | | import com.vci.dto.PortalVIDTO; |
| | | import com.vci.pagemodel.KeyValue; |
| | | import com.vci.pagemodel.PortalVIVO; |
| | | 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.starter.web.util.ControllerUtil; |
| | | import com.vci.starter.web.util.LangBaseUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.enumpck.ItemDblEnum; |
| | | import com.vci.web.enumpck.ItemTypeEnum; |
| | | import com.vci.web.service.OsPortalVIServiceI; |
| | | import com.vci.web.service.WebBtmIOServiceI; |
| | | 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 javax.servlet.http.HttpServletResponse; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @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); |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 业务类型删除 |
| | | * 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); |
| | | } |
| | | } |
| | | /** |
| | | * 业务类型删除 |
| | | * 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); |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | */ |
| | | @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 btmTypeIds 业务类型的编号,用逗号分割 |
| | | */ |
| | | @PostMapping("/exportExcel") |
| | | @VciBusinessLog(operateName = "导出表单/表格到excel中") |
| | | public void exportExcel(String btmTypeIds,HttpServletResponse response){ |
| | | String excelFileName = portalVIServiceI.exportToExcel(VciBaseUtil.str2List(btmTypeIds)); |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 获取属性字段类型 |
| | | */ |
| | | @GetMapping("/getItemTypeList") |