| | |
| | | import com.product.server.report.service.idel.IReportDatasourceService; |
| | | import com.product.util.config.SystemParamSet; |
| | | |
| | | |
| | | /** |
| | | * 配置报表数据源 |
| | | * |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api/report-datasource") |
| | | public class ReportDatasourceController extends AbstractBaseController{ |
| | | |
| | | |
| | | @Autowired |
| | | ReportDatasourceService reportDatasourceService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 报表数据源列表 |
| | | * @param response |
| | |
| | | public String listDatasource(HttpServletResponse response,HttpServletRequest request) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse=null; |
| | | Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if(bean != null){ |
| | | RequestParameterEntity reqp=(RequestParameterEntity)bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断参数是否为空 |
| | | if(bean == null || fse == null) { |
| | | return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | //判断表名是否正常 |
| | | if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) { |
| | | return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); |
| | | } |
| | | DataTableEntity dt=reportDatasourceService.listDatasource(fse); |
| | | return OK_List(dt); |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG); |
| | | return OK_List(reportDatasourceService.listDatasource(fse)); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e.getCode(),e.getMessage()); |
| | |
| | | return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 报表数据源详情 |
| | | * @param response |
| | |
| | | public String findDatasource(HttpServletResponse response,HttpServletRequest request) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse=null; |
| | | Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if(bean != null){ |
| | | RequestParameterEntity reqp=(RequestParameterEntity)bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断参数是否为空 |
| | | if(bean == null || fse == null) { |
| | | return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | //判断表名是否正常 |
| | | if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) { |
| | | return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG); |
| | | //判断uuid是否为空 |
| | | if (StringUtils.isEmpty(fse.getUUID())) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | FieldSetEntity dt=reportDatasourceService.findDatasource(fse.getUUID()); |
| | | return OK_List(dt); |
| | | return OK_List(reportDatasourceService.findDatasource(fse.getUUID())); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e.getCode(),e.getMessage()); |
| | |
| | | return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 数据源-保存 |
| | | * @param response |
| | |
| | | public String updateDatasource(HttpServletRequest request) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse=null; |
| | | Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if(bean != null){ |
| | | RequestParameterEntity reqp=(RequestParameterEntity)bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断参数是否为空 |
| | | if(bean == null || fse == null) { |
| | | return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | //判断表名是否正常 |
| | | if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) { |
| | | return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG); |
| | | IReportDatasourceService service=(IReportDatasourceService)getProxyInstance(reportDatasourceService); |
| | | String uuid = service.saveDatasource(fse); |
| | | return OK_Add(uuid); |
| | |
| | | public String copyDatasource(HttpServletRequest request) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse = null; |
| | | Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if (bean != null) { |
| | | RequestParameterEntity reqp = (RequestParameterEntity) bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断参数是否为空 |
| | | if (bean == null || fse == null) { |
| | | return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | //判断表名是否正常 |
| | | if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) { |
| | | return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG); |
| | | return OK_List(reportDatasourceService.copyDatasource(fse)); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | |
| | | return this.error(ReportCode.REPORT_DATASOURCE_COPY_FAIL.getValue(), ReportCode.REPORT_DATASOURCE_COPY_FAIL.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 报表数据源删除 |
| | | * @param response |
| | |
| | | public String deleteDatasource(HttpServletResponse response,HttpServletRequest request) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse=null; |
| | | Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if(bean != null){ |
| | | RequestParameterEntity reqp=(RequestParameterEntity)bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断参数是否为空 |
| | | if(bean == null || fse == null) { |
| | | return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | //判断表名是否正常 |
| | | if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG.equals(fse.getTableName())) { |
| | | return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG); |
| | | //判断uuid是否为空 |
| | | if (StringUtils.isEmpty(fse.getUUID())) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | |
| | | boolean succ=service.deleteDatasource(fse.getUUID()); |
| | | if (succ) { |
| | | return OK(); |
| | | }else { |
| | | return this.error(SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getValue(), SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getText()); |
| | | } |
| | | return this.error(SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getValue(), SystemCode.SYTEM_REPORT_DATASOURCE_DELETE_ERROR.getText()); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e.getCode(),e.getMessage()); |
| | |
| | | return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 报表sql解析与验证 |
| | | * @param response |
| | |
| | | public String sqlVerify(HttpServletResponse response,HttpServletRequest request) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse=null; |
| | | Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if(bean != null){ |
| | | RequestParameterEntity reqp=(RequestParameterEntity)bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断参数是否为空 |
| | | if(bean == null || fse == null) { |
| | | return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); |
| | | //判断uuid是否为空 |
| | | if (StringUtils.isEmpty(fse.getString(CmnConst.SQL_TEXT))) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | |
| | | return OK_List(dt); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e.getCode()); |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error("", ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage()); |
| | | return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取系统参数 |
| | | * @param response |
| | |
| | | return this.error("", e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 报表数据源详情 |
| | | * @param response |
| | |
| | | public String getDataReouceOfField(HttpServletResponse response,HttpServletRequest request) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse=null; |
| | | Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if(bean != null){ |
| | | RequestParameterEntity reqp=(RequestParameterEntity)bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断参数是否为空 |
| | | if(bean == null || fse == null) { |
| | | return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | //判断表名是否正常 |
| | | if (!CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG_FIELD.equals(fse.getTableName())) { |
| | | return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); |
| | | } |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_REPORT_DATASOURCE_CONFIG_FIELD); |
| | | //判断uuid是否为空 |
| | | if (StringUtils.isEmpty(fse.getUUID())) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | DataTableEntity dt=reportDatasourceService.getDataReouceOfField(fse.getUUID()); |
| | | return OK_List(dt); |
| | | return OK_List(reportDatasourceService.getDataReouceOfField(fse.getUUID())); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e.getCode(),e.getMessage()); |
| | |
| | | return this.error(ReportCode.REPORT_DATASOURCE_ERROR.getValue(), ReportCode.REPORT_DATASOURCE_ERROR.getText()+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 报表数据源详情 |
| | | * @param response |