|
@@ -0,0 +1,1057 @@
|
|
|
+package org.jeecg.modules.jmreport.desreport.a;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import java.io.BufferedInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.DriverManager;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Random;
|
|
|
+import java.util.Scanner;
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
+import org.jeecg.modules.jmreport.api.data.IDataSetFactory;
|
|
|
+import org.jeecg.modules.jmreport.common.annotation.JimuLoginRequired;
|
|
|
+import org.jeecg.modules.jmreport.common.expetion.JimuReportException;
|
|
|
+import org.jeecg.modules.jmreport.common.util.CommonUtils;
|
|
|
+import org.jeecg.modules.jmreport.common.util.MinioUtil;
|
|
|
+import org.jeecg.modules.jmreport.common.util.OssBootUtil;
|
|
|
+import org.jeecg.modules.jmreport.common.util.ViewFreemarker;
|
|
|
+import org.jeecg.modules.jmreport.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.jmreport.common.vo.JmDictModel;
|
|
|
+import org.jeecg.modules.jmreport.common.vo.Result;
|
|
|
+import org.jeecg.modules.jmreport.config.JmReportBaseConfig;
|
|
|
+import org.jeecg.modules.jmreport.config.client.JmReportTokenClient;
|
|
|
+import org.jeecg.modules.jmreport.config.oss.JmReportUploadConfig;
|
|
|
+import org.jeecg.modules.jmreport.desreport.entity.JimuReport;
|
|
|
+import org.jeecg.modules.jmreport.desreport.entity.JmReportDb;
|
|
|
+import org.jeecg.modules.jmreport.desreport.entity.JmReportDbField;
|
|
|
+import org.jeecg.modules.jmreport.desreport.entity.JmReportDbParam;
|
|
|
+import org.jeecg.modules.jmreport.desreport.model.JmPage;
|
|
|
+import org.jeecg.modules.jmreport.desreport.model.QueryVO;
|
|
|
+import org.jeecg.modules.jmreport.desreport.render.utils.FreeMarkerUtils;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJimuReportService;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJmReportDbFieldService;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJmReportDbParamService;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJmReportDbService;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJmReportDbSourceService;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJmReportExportExcel;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJmReportExportPdf;
|
|
|
+import org.jeecg.modules.jmreport.desreport.service.IJmReportMapService;
|
|
|
+import org.jeecg.modules.jmreport.dyndb.vo.JmreportDynamicDataSourceVo;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
+import org.springframework.util.AntPathMatcher;
|
|
|
+import org.springframework.util.Base64Utils;
|
|
|
+import org.springframework.util.FileCopyUtils;
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import org.springframework.web.servlet.HandlerMapping;
|
|
|
+
|
|
|
+@RestController("designReportController")
|
|
|
+@RequestMapping({"/jmreport"})
|
|
|
+public class a {
|
|
|
+ private static final Logger a = LoggerFactory.getLogger(a.class);
|
|
|
+
|
|
|
+ @Value("classpath:static/jmreport/json/excel.virtual.json")
|
|
|
+ private Resource virtualJson;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJimuReportService jmReportDesignService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJmReportDbService reportDbService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJmReportDbParamService jmReportDbParamService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJmReportDbFieldService jmReportDbFieldService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJmReportDbSourceService jmReportDbSourceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJmReportMapService jmReportMapService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJmReportExportExcel exportExcel;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JmReportTokenClient jimuTokenClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JmReportUploadConfig jimuReportUploadConfig;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JmReportBaseConfig jmBaseConfig;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IJmReportExportPdf jmReportExportPdf;
|
|
|
+
|
|
|
+ @RequestMapping({"/demo"})
|
|
|
+ public void a(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception {
|
|
|
+ a.debug(" --- --- ");
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ a(paramHttpServletRequest, paramHttpServletResponse, hashMap, "jmreport/desreport/demo.ftl");
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/list"})
|
|
|
+ public void b(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception {
|
|
|
+ a.debug(" --- --- ");
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ a(paramHttpServletRequest, paramHttpServletResponse, hashMap, "jmreport/desreport/list.ftl");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/excelCreate"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestBody JimuReport paramJimuReport) {
|
|
|
+ a.debug("============EXCEL);
|
|
|
+ try {
|
|
|
+ String str = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ paramJimuReport.setCreateBy(str);
|
|
|
+ paramJimuReport = this.jmReportDesignService.excelCreate(paramJimuReport);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ a.error(exception.getMessage(), exception);
|
|
|
+ return Result.error(exception.getMessage());
|
|
|
+ }
|
|
|
+ return Result.OK(paramJimuReport);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/excelQueryName"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> b(HttpServletRequest paramHttpServletRequest, @RequestBody JimuReport paramJimuReport) {
|
|
|
+ boolean bool = this.jmReportDesignService.excelQueryName(paramJimuReport);
|
|
|
+ if (bool)
|
|
|
+ return Result.OK();
|
|
|
+ return Result.FAIL(", Boolean.valueOf(bool));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/excelQuery"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(@RequestParam(name = "reportType", required = false) String paramString1, @RequestParam(name = "name") String paramString2, @RequestParam(name = "pageNo", defaultValue = "1") Integer paramInteger1, @RequestParam(name = "pageSize", defaultValue = "10") Integer paramInteger2, HttpServletRequest paramHttpServletRequest) {
|
|
|
+ a.debug("============EXCEL);
|
|
|
+ return this.jmReportDesignService.excelQuery(paramString1, paramString2, paramHttpServletRequest, paramInteger1, paramInteger2);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/excelQueryByTemplate"})
|
|
|
+ public Result<?> b(@RequestParam(name = "reportType", required = false) String paramString1, @RequestParam(name = "name") String paramString2, @RequestParam(name = "pageNo", defaultValue = "1") Integer paramInteger1, @RequestParam(name = "pageSize", defaultValue = "10") Integer paramInteger2, HttpServletRequest paramHttpServletRequest) {
|
|
|
+ return this.jmReportDesignService.excelQueryByTemplate(paramString1, paramString2, paramHttpServletRequest, paramInteger1, paramInteger2);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/userinfo"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest) {
|
|
|
+ Result result = Result.OK();
|
|
|
+ String str = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ result.setMessage(str);
|
|
|
+ return Result.OK(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void c(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception {
|
|
|
+ a.debug(" --- --- ");
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ a(paramHttpServletRequest, paramHttpServletResponse, hashMap, "jmreport/desreport/index.ftl");
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/index/{id}"})
|
|
|
+ public void a(@PathVariable("id") String paramString, HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception {
|
|
|
+ a.debug(" --- --- ");
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ if (oConvertUtils.isNotEmpty(paramString))
|
|
|
+ hashMap.put("id", paramString);
|
|
|
+ hashMap.put("mode", this.jmBaseConfig.getMode());
|
|
|
+ String str = "jmreport/desreport/index.ftl";
|
|
|
+ a.info("" + this.jmBaseConfig.getSaas() + " ," + this.jimuTokenClient.getToken());
|
|
|
+ if (this.jmBaseConfig.getSaas().booleanValue() && oConvertUtils.isNotEmpty(this.jimuTokenClient.getToken())) {
|
|
|
+ String str1 = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ JimuReport jimuReport = this.jmReportDesignService.getById(paramString);
|
|
|
+ if (jimuReport != null && !str1.equals(jimuReport.getCreateBy()))
|
|
|
+ str = "jmreport/desreport/authority.ftl";
|
|
|
+ }
|
|
|
+ a(paramHttpServletRequest, paramHttpServletResponse, hashMap, str);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/view/{id}"})
|
|
|
+ public void b(@PathVariable("id") String paramString, HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ if (oConvertUtils.isNotEmpty(paramString))
|
|
|
+ hashMap.put("id", paramString);
|
|
|
+ hashMap.put("shareView", "0");
|
|
|
+ a(paramHttpServletRequest, paramHttpServletResponse, hashMap, "jmreport/desreport/view.ftl");
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/shareView/{id}"})
|
|
|
+ public void a(@PathVariable("id") String paramString, HttpServletResponse paramHttpServletResponse, HttpServletRequest paramHttpServletRequest) throws Exception {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ if (oConvertUtils.isNotEmpty(paramString))
|
|
|
+ hashMap.put("id", paramString);
|
|
|
+ hashMap.put("shareView", "1");
|
|
|
+ a(paramHttpServletRequest, paramHttpServletResponse, hashMap, "jmreport/desreport/view.ftl");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/addViewCount/{id}"})
|
|
|
+ public Result<?> a(@PathVariable("id") String paramString) {
|
|
|
+ Integer integer = Integer.valueOf(this.jmReportDesignService.updateViewCount(paramString));
|
|
|
+ boolean bool = false;
|
|
|
+ if (integer.intValue() > 0)
|
|
|
+ bool = true;
|
|
|
+ return Result.OK("", Boolean.valueOf(bool));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/checkParam/{id}"})
|
|
|
+ public Result<List<JmReportDbParam>> b(@PathVariable(name = "id") String paramString) {
|
|
|
+ Result<List<JmReportDbParam>> result = new Result();
|
|
|
+ List list = this.jmReportDesignService.queryReportParam(paramString);
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ result.setSuccess(false);
|
|
|
+ } else {
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(list);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/show"})
|
|
|
+ public Result<?> a(@RequestParam(name = "id") String paramString, HttpServletRequest paramHttpServletRequest) {
|
|
|
+ String str = paramHttpServletRequest.getParameter("params");
|
|
|
+ try {
|
|
|
+ return this.jmReportDesignService.show(paramString, str);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ a.error(exception.getMessage(), exception);
|
|
|
+ return Result.error(exception.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/save"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestBody JSONObject paramJSONObject) {
|
|
|
+ try {
|
|
|
+ JimuReport jimuReport = this.jmReportDesignService.saveReport(paramJSONObject, paramHttpServletRequest);
|
|
|
+ return Result.OK(jimuReport);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ a.error(exception.getMessage(), exception);
|
|
|
+ return Result.error(");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/get/{id}"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @PathVariable("id") String paramString) {
|
|
|
+ a.debug("============EXCEL JSON);
|
|
|
+ JimuReport jimuReport = this.jmReportDesignService.getById(paramString);
|
|
|
+ return Result.OK(jimuReport);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/mockPieData"})
|
|
|
+ public Result<?> a() {
|
|
|
+ a.debug("============);
|
|
|
+ ArrayList<HashMap<Object, Object>> arrayList = new ArrayList();
|
|
|
+ String[] arrayOfString = { "IE", "Safari", "Firefox", "Opera", "Chrome" };
|
|
|
+ Random random = new Random();
|
|
|
+ for (String str : arrayOfString) {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("name", str);
|
|
|
+ hashMap.put("value", Integer.valueOf(random.nextInt(1901) + 100));
|
|
|
+ arrayList.add(hashMap);
|
|
|
+ }
|
|
|
+ return Result.OK(arrayList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/mockChartData"})
|
|
|
+ public Result<?> b() {
|
|
|
+ a.debug("============);
|
|
|
+ ArrayList<HashMap<Object, Object>> arrayList = new ArrayList();
|
|
|
+ String[] arrayOfString = { ", ", ", ", "};
|
|
|
+ Random random = new Random();
|
|
|
+ for (String str : arrayOfString) {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("name", str);
|
|
|
+ ArrayList<Integer> arrayList1 = new ArrayList();
|
|
|
+ for (byte b = 0; b < 7; b++)
|
|
|
+ arrayList1.add(Integer.valueOf(random.nextInt(1901) + 100));
|
|
|
+ hashMap.put("data", arrayList1);
|
|
|
+ arrayList.add(hashMap);
|
|
|
+ }
|
|
|
+ return Result.OK(arrayList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/upload"})
|
|
|
+ public Result<?> d(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) {
|
|
|
+ Result<?> result = new Result();
|
|
|
+ try {
|
|
|
+ MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest)paramHttpServletRequest;
|
|
|
+ MultipartFile multipartFile = multipartHttpServletRequest.getFile("file");
|
|
|
+ String str1 = paramHttpServletRequest.getParameter("bizType");
|
|
|
+ if (oConvertUtils.isEmpty(str1))
|
|
|
+ str1 = this.jimuReportUploadConfig.getUploadType();
|
|
|
+ String str2 = "";
|
|
|
+ a.debug(" " + str1);
|
|
|
+ if ("alioss".equals(str1)) {
|
|
|
+ a.debug(" alioss");
|
|
|
+ str2 = OssBootUtil.upload(multipartFile, "designreport/images");
|
|
|
+ } else if ("minio".equals(str1)) {
|
|
|
+ a.debug(" minio");
|
|
|
+ str2 = MinioUtil.upload(multipartFile, "designreport/images");
|
|
|
+ } else if ("local".equals(str1)) {
|
|
|
+ a.debug("local");
|
|
|
+ str2 = a(multipartFile, "excel_online");
|
|
|
+ }
|
|
|
+ a.debug(", str2);
|
|
|
+ result.setMessage(str2);
|
|
|
+ result.setSuccess(true);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage("");
|
|
|
+ a.error(exception.getMessage(), exception);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @CrossOrigin
|
|
|
+ @GetMapping({"/img/**"})
|
|
|
+ public void e(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) {
|
|
|
+ String str = e(paramHttpServletRequest);
|
|
|
+ BufferedInputStream bufferedInputStream = null;
|
|
|
+ ServletOutputStream servletOutputStream = null;
|
|
|
+ try {
|
|
|
+ str = str.replace("..", "");
|
|
|
+ if (str.endsWith(","))
|
|
|
+ str = str.substring(0, str.length() - 1);
|
|
|
+ paramHttpServletResponse.setContentType("image/jpeg;charset=utf-8");
|
|
|
+ String str1 = this.jimuReportUploadConfig.getPath().getUpload();
|
|
|
+ String str2 = str1 + File.separator + str;
|
|
|
+ bufferedInputStream = new BufferedInputStream(new FileInputStream(str2));
|
|
|
+ servletOutputStream = paramHttpServletResponse.getOutputStream();
|
|
|
+ byte[] arrayOfByte = new byte[1024];
|
|
|
+ int i;
|
|
|
+ while ((i = bufferedInputStream.read(arrayOfByte)) > 0)
|
|
|
+ servletOutputStream.write(arrayOfByte, 0, i);
|
|
|
+ paramHttpServletResponse.flushBuffer();
|
|
|
+ } catch (IOException iOException) {
|
|
|
+ a.error("+ iOException.getMessage(), iOException);
|
|
|
+ } finally {
|
|
|
+ if (bufferedInputStream != null)
|
|
|
+ try {
|
|
|
+ bufferedInputStream.close();
|
|
|
+ } catch (IOException iOException) {
|
|
|
+ a.error(iOException.getMessage(), iOException);
|
|
|
+ }
|
|
|
+ if (servletOutputStream != null)
|
|
|
+ try {
|
|
|
+ servletOutputStream.close();
|
|
|
+ } catch (IOException iOException) {
|
|
|
+ a.error(iOException.getMessage(), iOException);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String a(File paramFile) {
|
|
|
+ Scanner scanner = null;
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ try {
|
|
|
+ scanner = new Scanner(paramFile, "utf-8");
|
|
|
+ while (scanner.hasNextLine())
|
|
|
+ stringBuilder.append(scanner.nextLine());
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (scanner != null)
|
|
|
+ scanner.close();
|
|
|
+ }
|
|
|
+ return stringBuilder.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void a(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, Map<String, String> paramMap, String paramString) throws Exception {
|
|
|
+ try {
|
|
|
+ paramMap.put("base", paramHttpServletRequest.getContextPath());
|
|
|
+ paramMap.put("baseURL", d.a(paramHttpServletRequest));
|
|
|
+ a.info("freemarker customPrePath: {}", oConvertUtils.getString(paramHttpServletRequest.getAttribute("customPrePath"), ""));
|
|
|
+ paramMap.put("customPrePath", oConvertUtils.getString(paramHttpServletRequest.getAttribute("customPrePath"), ""));
|
|
|
+ paramMap.put("reportConfig", JSON.toJSONString(this.jmBaseConfig));
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ paramMap.put("message", exception.getMessage());
|
|
|
+ }
|
|
|
+ ViewFreemarker.view(paramHttpServletRequest, paramHttpServletResponse, paramString, paramMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String e(HttpServletRequest paramHttpServletRequest) {
|
|
|
+ String str1 = (String)paramHttpServletRequest.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
|
|
|
+ String str2 = (String)paramHttpServletRequest.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
|
|
|
+ return (new AntPathMatcher()).extractPathWithinPattern(str2, str1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/loadTable"})
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestParam("dbSource") String paramString, @RequestParam(name = "pageNo", defaultValue = "1") Integer paramInteger1, @RequestParam(name = "pageSize", defaultValue = "50") Integer paramInteger2) {
|
|
|
+ a.debug("============);
|
|
|
+ if (oConvertUtils.isNotEmpty(paramString)) {
|
|
|
+ JmreportDynamicDataSourceVo jmreportDynamicDataSourceVo = this.jmReportDbSourceService.getByDbKey(paramString);
|
|
|
+ if (jmreportDynamicDataSourceVo == null)
|
|
|
+ return Result.error(");
|
|
|
+ }
|
|
|
+ List list = this.reportDbService.loadDataSourceTable(paramString);
|
|
|
+ Map map = e.a(list, paramInteger1, paramInteger2);
|
|
|
+ return Result.OK(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/loadTableData"})
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestParam(value = "dbSource", required = false) String paramString1, @RequestParam(value = "tableName", required = false) String paramString2, @RequestParam(value = "pageNo", required = false) Integer paramInteger1, @RequestParam(value = "pageSize", required = false) Integer paramInteger2, @RequestParam(value = "sql", required = false) String paramString3, @RequestParam("paramArray") String paramString4) {
|
|
|
+ a.debug("============);
|
|
|
+ if (oConvertUtils.isEmpty(paramString1) && this.jmBaseConfig.getSaas().booleanValue())
|
|
|
+ return Result.error(1001, ");
|
|
|
+ if (oConvertUtils.isNotEmpty(paramString1)) {
|
|
|
+ JmreportDynamicDataSourceVo jmreportDynamicDataSourceVo = this.jmReportDbSourceService.getByDbKey(paramString1);
|
|
|
+ if (jmreportDynamicDataSourceVo == null)
|
|
|
+ return Result.error(");
|
|
|
+ }
|
|
|
+ Map map = null;
|
|
|
+ try {
|
|
|
+ map = this.reportDbService.loadTableData(paramString1, paramString2, paramInteger1, paramInteger2, paramString3, paramString4);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ return Result.error("SQL{}" + exception.getMessage());
|
|
|
+ }
|
|
|
+ return Result.OK(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/queryFieldBySql"})
|
|
|
+ public Result<?> a(@RequestBody JSONObject paramJSONObject) {
|
|
|
+ a.debug("============);
|
|
|
+ String str1 = paramJSONObject.getString("sql");
|
|
|
+ String str2 = paramJSONObject.getString("dbSource");
|
|
|
+ Object object = paramJSONObject.get("paramArray");
|
|
|
+ String str3 = paramJSONObject.getString("type");
|
|
|
+ Integer integer = Integer.valueOf(0);
|
|
|
+ JmreportDynamicDataSourceVo jmreportDynamicDataSourceVo = null;
|
|
|
+ if (oConvertUtils.isEmpty(str2) && this.jmBaseConfig.getSaas().booleanValue())
|
|
|
+ return Result.error(1001, ");
|
|
|
+ if (oConvertUtils.isNotEmpty(str2)) {
|
|
|
+ jmreportDynamicDataSourceVo = this.jmReportDbSourceService.getByDbKey(str2);
|
|
|
+ integer = jmreportDynamicDataSourceVo.getConnectTimes();
|
|
|
+ if (integer != null && integer.intValue() > 5)
|
|
|
+ return Result.error(");
|
|
|
+ if (jmreportDynamicDataSourceVo == null)
|
|
|
+ return Result.error(");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Map map = this.reportDbService.parseReportSql(str1, str2, object, str3);
|
|
|
+ if (map.get("message") != null)
|
|
|
+ return Result.OK(map);
|
|
|
+ return Result.OK(", map);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ if (exception instanceof JimuReportException) {
|
|
|
+ JimuReportException jimuReportException = (JimuReportException)exception;
|
|
|
+ return Result.error(jimuReportException.getExceptionCode(), jimuReportException.getMessage());
|
|
|
+ }
|
|
|
+ return Result.error(exception.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/queryFieldByBean"})
|
|
|
+ public Result<?> b(@RequestBody JSONObject paramJSONObject) {
|
|
|
+ a.debug("============);
|
|
|
+ String str1 = paramJSONObject.getString("javaType");
|
|
|
+ String str2 = paramJSONObject.getString("javaValue");
|
|
|
+ Boolean bool = paramJSONObject.getBoolean("isPage");
|
|
|
+ JSONObject jSONObject = paramJSONObject.getJSONObject("param");
|
|
|
+ Map map = d.a(jSONObject);
|
|
|
+ try {
|
|
|
+ Object object = d.c(str1, str2);
|
|
|
+ if (object != null && object instanceof IDataSetFactory) {
|
|
|
+ IDataSetFactory iDataSetFactory = (IDataSetFactory)object;
|
|
|
+ List list = d.a(iDataSetFactory, map, bool);
|
|
|
+ if (list == null || list.size() == 0)
|
|
|
+ return Result.error(");
|
|
|
+ return Result.OK(", list);
|
|
|
+ }
|
|
|
+ return Result.error("javabean);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ return Result.error(exception.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/executeSelectApi"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestParam("api") String paramString1, @RequestParam("method") String paramString2) {
|
|
|
+ String str1 = paramHttpServletRequest.getParameter("token");
|
|
|
+ String str2 = paramHttpServletRequest.getParameter("apiConvert");
|
|
|
+ String str3 = paramHttpServletRequest.getParameter("paramArray");
|
|
|
+ if (oConvertUtils.isEmpty(str1))
|
|
|
+ str1 = this.jimuTokenClient.getToken();
|
|
|
+ a.info("api= " + paramString1 + ", method= " + paramString2 + ", token= " + str1);
|
|
|
+ Map map = this.reportDbService.executeSelectApi(paramString1, paramString2, str1, str2, str3);
|
|
|
+ List list = this.reportDbService.parseData(map);
|
|
|
+ return Result.OK(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/saveDb"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestBody JmReportDb paramJmReportDb) {
|
|
|
+ a.debug("============saveDb==========");
|
|
|
+ try {
|
|
|
+ String str = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ paramJmReportDb.setCreateBy(str);
|
|
|
+ Date date = new Date();
|
|
|
+ paramJmReportDb.setCreateTime(date);
|
|
|
+ paramJmReportDb.setUpdateTime(date);
|
|
|
+ paramJmReportDb = this.reportDbService.saveDb(paramJmReportDb);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ a.error(exception.getMessage(), exception);
|
|
|
+ return Result.error(exception.getMessage());
|
|
|
+ }
|
|
|
+ return Result.OK(paramJmReportDb);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/field/tree/{reportId}"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> b(HttpServletRequest paramHttpServletRequest, @PathVariable("reportId") String paramString) {
|
|
|
+ a.debug("============fieldTree==========");
|
|
|
+ List list = new ArrayList();
|
|
|
+ try {
|
|
|
+ list = this.reportDbService.fieldTree(paramString);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ }
|
|
|
+ return Result.OK(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/queryIsPage/{reportId}"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> c(HttpServletRequest paramHttpServletRequest, @PathVariable("reportId") String paramString) {
|
|
|
+ boolean bool = this.reportDbService.queryIsPage(paramString);
|
|
|
+ return Result.OK(Boolean.valueOf(bool));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"loadDbData/{dbId}"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> d(HttpServletRequest paramHttpServletRequest, @PathVariable("dbId") String paramString) {
|
|
|
+ a.debug("============loadDbData==========");
|
|
|
+ Map map = this.reportDbService.loadDbData(paramString);
|
|
|
+ return Result.OK(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"initDataSource"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> b(HttpServletRequest paramHttpServletRequest) {
|
|
|
+ a.debug("============initDataSource==========");
|
|
|
+ String str = "";
|
|
|
+ if (this.jmBaseConfig.getSaas().booleanValue())
|
|
|
+ str = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ List list = this.reportDbService.initDataSource(str);
|
|
|
+ return Result.OK(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/delDbData/{dbId}"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> e(HttpServletRequest paramHttpServletRequest, @PathVariable("dbId") String paramString) {
|
|
|
+ a.debug("============delDbData==========");
|
|
|
+ this.reportDbService.delDbData(paramString);
|
|
|
+ return Result.OK();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/deleteParamByIds"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> b(HttpServletRequest paramHttpServletRequest, @RequestBody JSONObject paramJSONObject) {
|
|
|
+ a.debug("============deleteParamByIds==========");
|
|
|
+ JSONArray jSONArray = paramJSONObject.getJSONArray("selectIds");
|
|
|
+ String str1 = paramJSONObject.getString("id");
|
|
|
+ String str2 = paramJSONObject.getString("dbDynSql");
|
|
|
+ this.jmReportDbParamService.deleteParamByIdsAndUpdateDbSql(jSONArray, str1, str2);
|
|
|
+ return Result.OK();
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping({"/deleteFieldByIds"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> f(HttpServletRequest paramHttpServletRequest, @RequestBody String paramString) {
|
|
|
+ a.debug("============deleParams==========");
|
|
|
+ this.jmReportDbFieldService.deleteByIds(paramString);
|
|
|
+ return Result.OK();
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping({"/delete"})
|
|
|
+ @ResponseBody
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> g(HttpServletRequest paramHttpServletRequest, @RequestParam(name = "id", required = true) String paramString) {
|
|
|
+ JimuReport jimuReport = new JimuReport();
|
|
|
+ jimuReport.setId(paramString);
|
|
|
+ jimuReport.setDelFlag(Integer.valueOf(1));
|
|
|
+ this.jmReportDesignService.updateById(jimuReport);
|
|
|
+ return Result.OK(", Boolean.valueOf(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/reportCopy"})
|
|
|
+ @ResponseBody
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> h(HttpServletRequest paramHttpServletRequest, @RequestParam(name = "id", required = true) String paramString) {
|
|
|
+ try {
|
|
|
+ String str = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ JimuReport jimuReport = new JimuReport();
|
|
|
+ jimuReport.setCreateBy(str);
|
|
|
+ Date date = new Date();
|
|
|
+ jimuReport.setCreateTime(date);
|
|
|
+ jimuReport.setUpdateTime(date);
|
|
|
+ jimuReport.setId(paramString);
|
|
|
+ this.jmReportDesignService.reportCopy(jimuReport);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ return Result.error(403, ");
|
|
|
+ }
|
|
|
+ return Result.OK(", Boolean.valueOf(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/setTemplate"})
|
|
|
+ @ResponseBody
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestParam(name = "id", required = true) String paramString, @RequestParam(name = "template", required = true) Integer paramInteger) {
|
|
|
+ JimuReport jimuReport = new JimuReport();
|
|
|
+ jimuReport.setId(paramString);
|
|
|
+ jimuReport.setTemplate(paramInteger);
|
|
|
+ Integer integer = this.jmReportDesignService.updateById(jimuReport);
|
|
|
+ boolean bool = false;
|
|
|
+ if (integer.intValue() > 0)
|
|
|
+ bool = true;
|
|
|
+ return Result.OK(", Boolean.valueOf(bool));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/importExcel"})
|
|
|
+ @ResponseBody
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<Object> a(HttpServletRequest paramHttpServletRequest, @RequestParam("file") MultipartFile paramMultipartFile) throws IOException {
|
|
|
+ Result<Object> result = new Result();
|
|
|
+ Map map = this.jmReportDesignService.importExcel(paramMultipartFile);
|
|
|
+ if (map.size() > 0 && !map.isEmpty()) {
|
|
|
+ result.setResult(map);
|
|
|
+ result.setSuccess(true);
|
|
|
+ } else {
|
|
|
+ result.setSuccess(false);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/exportAllExcel"})
|
|
|
+ @ResponseBody
|
|
|
+ public Result<Object> a(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, @RequestBody JSONObject paramJSONObject) throws IOException {
|
|
|
+ HashMap<Object, Object> hashMap1 = new HashMap<>(paramHttpServletRequest.getParameterMap());
|
|
|
+ boolean bool = hashMap1.containsKey("token");
|
|
|
+ if (bool)
|
|
|
+ hashMap1.remove("token");
|
|
|
+ String str = paramJSONObject.getString("excelConfigId");
|
|
|
+ JSONObject jSONObject = paramJSONObject.getJSONObject("queryParam");
|
|
|
+ long l1 = System.currentTimeMillis();
|
|
|
+ JSONArray jSONArray = paramJSONObject.getJSONArray("base64Arry");
|
|
|
+ Map map = this.exportExcel.exportExcel(str, jSONObject, (List)jSONArray);
|
|
|
+ File file = new File(map.get("name").toString());
|
|
|
+ ServletOutputStream servletOutputStream = paramHttpServletResponse.getOutputStream();
|
|
|
+ SXSSFWorkbook sXSSFWorkbook = (SXSSFWorkbook)map.get("workbook");
|
|
|
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
+ HashMap<Object, Object> hashMap2 = new HashMap<>();
|
|
|
+ try {
|
|
|
+ sXSSFWorkbook.write(byteArrayOutputStream);
|
|
|
+ String str1 = Base64Utils.encodeToString(byteArrayOutputStream.toByteArray());
|
|
|
+ hashMap2.put("file", str1);
|
|
|
+ hashMap2.put("success", Boolean.valueOf(true));
|
|
|
+ hashMap2.put("name", file.getName());
|
|
|
+ } catch (IOException iOException) {
|
|
|
+ iOException.printStackTrace();
|
|
|
+ hashMap2.put("error", iOException.getMessage());
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ byteArrayOutputStream.close();
|
|
|
+ } catch (IOException iOException) {
|
|
|
+ iOException.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ long l2 = System.currentTimeMillis();
|
|
|
+ a.info("+ (l2 - l1) + "ms");
|
|
|
+ return Result.OK(hashMap2);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/print"})
|
|
|
+ public void a(HttpServletResponse paramHttpServletResponse, HttpServletRequest paramHttpServletRequest) throws Exception {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ a(paramHttpServletRequest, paramHttpServletResponse, hashMap, "jmreport/desreport/print.ftl");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/putFile"})
|
|
|
+ @ResponseBody
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<JimuReport> i(HttpServletRequest paramHttpServletRequest, @RequestParam String paramString) {
|
|
|
+ Result<JimuReport> result = new Result();
|
|
|
+ try {
|
|
|
+ MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest)paramHttpServletRequest;
|
|
|
+ MultipartFile multipartFile = multipartHttpServletRequest.getFile("file");
|
|
|
+ String str1 = "";
|
|
|
+ String str2 = this.jimuReportUploadConfig.getUploadType();
|
|
|
+ if ("alioss".equals(str2)) {
|
|
|
+ str1 = OssBootUtil.upload(multipartFile, "designreport/images");
|
|
|
+ } else if ("minio".equals(str2)) {
|
|
|
+ str1 = MinioUtil.upload(multipartFile, "designreport/images");
|
|
|
+ } else {
|
|
|
+ str1 = a(multipartFile, "excel_online");
|
|
|
+ }
|
|
|
+ JimuReport jimuReport = new JimuReport();
|
|
|
+ if (oConvertUtils.isNotEmpty(str1) && oConvertUtils.isNotEmpty(paramString)) {
|
|
|
+ jimuReport.setId(paramString);
|
|
|
+ jimuReport.setThumb(str1);
|
|
|
+ this.jmReportDesignService.updateById(jimuReport);
|
|
|
+ result.setMessage(");
|
|
|
+ result.setResult(jimuReport);
|
|
|
+ }
|
|
|
+ } catch (Exception exception) {
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage("");
|
|
|
+ a.error(exception.getMessage(), exception);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/download/image"})
|
|
|
+ @ResponseBody
|
|
|
+ public Result<Object> f(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws IOException {
|
|
|
+ String str1 = paramHttpServletRequest.getParameter("imageUrl");
|
|
|
+ Result<Object> result = new Result();
|
|
|
+ if (oConvertUtils.isEmpty(str1)) {
|
|
|
+ result.setSuccess(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (!str1.contains("http")) {
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(str1);
|
|
|
+ }
|
|
|
+ String str2 = File.separator + "designreport" + File.separator + "images" + File.separator;
|
|
|
+ String str3 = str1.substring(str1.lastIndexOf("/") + 1);
|
|
|
+ String str4 = this.jimuReportUploadConfig.getPath().getUpload();
|
|
|
+ File file1 = new File(str4 + str2);
|
|
|
+ if (!file1.exists())
|
|
|
+ file1.mkdirs();
|
|
|
+ a.debug("----imageUrl------" + str1);
|
|
|
+ a.debug("----fileName------" + str3);
|
|
|
+ a.debug("----downFilePath------" + str4 + str2 + str3);
|
|
|
+ File file2 = new File(str4 + str2 + str3);
|
|
|
+ if (!file2.exists())
|
|
|
+ d.a(str1, file2);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(str2 + str3);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String a(MultipartFile paramMultipartFile, String paramString) {
|
|
|
+ try {
|
|
|
+ String str1 = this.jimuReportUploadConfig.getPath().getUpload();
|
|
|
+ a.info(" --- local upload path : " + str1 + " --- ");
|
|
|
+ String str2 = null;
|
|
|
+ File file1 = new File(str1 + File.separator + paramString + File.separator);
|
|
|
+ if (!file1.exists())
|
|
|
+ file1.mkdirs();
|
|
|
+ String str3 = paramMultipartFile.getOriginalFilename();
|
|
|
+ str3 = CommonUtils.getFileName(str3);
|
|
|
+ if (str3.indexOf(".") != -1) {
|
|
|
+ str2 = str3.substring(0, str3.lastIndexOf(".")) + "_" + System.currentTimeMillis() + str3.substring(str3.indexOf("."));
|
|
|
+ } else {
|
|
|
+ str2 = str3 + "_" + System.currentTimeMillis();
|
|
|
+ }
|
|
|
+ String str4 = file1.getPath() + File.separator + str2;
|
|
|
+ File file2 = new File(str4);
|
|
|
+ FileCopyUtils.copy(paramMultipartFile.getBytes(), file2);
|
|
|
+ String str5 = null;
|
|
|
+ if (oConvertUtils.isNotEmpty(paramString)) {
|
|
|
+ str5 = paramString + File.separator + str2;
|
|
|
+ } else {
|
|
|
+ str5 = str2;
|
|
|
+ }
|
|
|
+ if (str5.contains("\\"))
|
|
|
+ str5 = str5.replace("\\", "/");
|
|
|
+ return str5;
|
|
|
+ } catch (IOException iOException) {
|
|
|
+ a.error(iOException.getMessage(), iOException);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/addDataSource"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestBody JmReportDataSource paramJmReportDataSource) {
|
|
|
+ return this.reportDbService.addDataSource(paramJmReportDataSource, paramHttpServletRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/querySourceCode"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> b(HttpServletRequest paramHttpServletRequest, @RequestBody JmReportDataSource paramJmReportDataSource) {
|
|
|
+ boolean bool = this.reportDbService.querySourceCode(paramJmReportDataSource);
|
|
|
+ return Result.OK(Boolean.valueOf(bool));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/delDataSource"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> c(HttpServletRequest paramHttpServletRequest, @RequestBody JmReportDataSource paramJmReportDataSource) {
|
|
|
+ this.reportDbService.delDataSource(paramJmReportDataSource);
|
|
|
+ return Result.OK(", Boolean.valueOf(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/testConnection"})
|
|
|
+ public Result a(@RequestBody JmreportDynamicDataSourceVo paramJmreportDynamicDataSourceVo) {
|
|
|
+ Connection connection = null;
|
|
|
+ try {
|
|
|
+ Class.forName(paramJmreportDynamicDataSourceVo.getDbDriver());
|
|
|
+ DriverManager.setLoginTimeout(10);
|
|
|
+ connection = DriverManager.getConnection(paramJmreportDynamicDataSourceVo.getDbUrl(), paramJmreportDynamicDataSourceVo.getDbUsername(), paramJmreportDynamicDataSourceVo.getDbPassword());
|
|
|
+ if (connection != null)
|
|
|
+ return Result.OK(", Boolean.valueOf(true));
|
|
|
+ return Result.OK(", Boolean.valueOf(true));
|
|
|
+ } catch (ClassNotFoundException classNotFoundException) {
|
|
|
+ a.error(classNotFoundException.toString());
|
|
|
+ return Result.error(");
|
|
|
+ } catch (Exception exception) {
|
|
|
+ a.error(exception.toString());
|
|
|
+ return Result.error("+ exception.getMessage());
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (connection != null && !connection.isClosed())
|
|
|
+ connection.close();
|
|
|
+ } catch (SQLException sQLException) {
|
|
|
+ a.error(sQLException.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/qurestApi"})
|
|
|
+ public Result<?> b(@RequestParam(name = "apiSelectId") String paramString, HttpServletRequest paramHttpServletRequest) {
|
|
|
+ String str1 = "";
|
|
|
+ JmReportDb jmReportDb = this.reportDbService.getById(paramString);
|
|
|
+ if (jmReportDb == null)
|
|
|
+ return Result.ok("");
|
|
|
+ String str2 = paramHttpServletRequest.getParameter("token");
|
|
|
+ if (oConvertUtils.isEmpty(str2))
|
|
|
+ str2 = paramHttpServletRequest.getHeader("token");
|
|
|
+ String str3 = jmReportDb.getApiUrl();
|
|
|
+ Map map = this.jimuTokenClient.getUserInfo(str2);
|
|
|
+ str3 = d.a(str3, map, this.jmBaseConfig.getApiBasePath());
|
|
|
+ List list = this.jmReportDbParamService.list(jmReportDb.getId());
|
|
|
+ if ("1".equals(jmReportDb.getDbType())) {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ for (JmReportDbParam jmReportDbParam : list) {
|
|
|
+ if (str3.indexOf(jmReportDbParam.getParamName()) > 0)
|
|
|
+ hashMap.put(jmReportDbParam.getParamName(), jmReportDbParam.getParamValue());
|
|
|
+ }
|
|
|
+ String str = FreeMarkerUtils.a(str3, hashMap);
|
|
|
+ str = str.replace("'", "");
|
|
|
+ if ("0".equals(jmReportDb.getApiMethod())) {
|
|
|
+ str1 = d.b(str, str2);
|
|
|
+ } else {
|
|
|
+ str1 = d.a(str, str2, null);
|
|
|
+ }
|
|
|
+ JSONObject jSONObject = JSONObject.parseObject(str1);
|
|
|
+ return Result.OK(jSONObject);
|
|
|
+ }
|
|
|
+ if ("3".equals(jmReportDb.getDbType())) {
|
|
|
+ JSONObject jSONObject = JSONObject.parseObject(jmReportDb.getJsonData());
|
|
|
+ return Result.OK(jSONObject);
|
|
|
+ }
|
|
|
+ if ("2".equals(jmReportDb.getDbType())) {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ for (JmReportDbParam jmReportDbParam : list)
|
|
|
+ hashMap.put(jmReportDbParam.getParamName(), jmReportDbParam.getParamValue());
|
|
|
+ JSONObject jSONObject = JSONObject.parseObject(jmReportDb.getJsonData());
|
|
|
+ IDataSetFactory iDataSetFactory = d.d(jmReportDb.getJavaType(), jmReportDb.getJavaValue());
|
|
|
+ if ("1".equals(jmReportDb.getIsPage())) {
|
|
|
+ JmPage jmPage = iDataSetFactory.createPageData(hashMap);
|
|
|
+ return Result.OK(jSONObject);
|
|
|
+ }
|
|
|
+ List list1 = iDataSetFactory.createData(hashMap);
|
|
|
+ return Result.OK(list1);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/qurestSql"})
|
|
|
+ public Result<?> c(@RequestParam(name = "apiSelectId") String paramString, HttpServletRequest paramHttpServletRequest) {
|
|
|
+ JmReportDb jmReportDb = this.reportDbService.getById(paramString);
|
|
|
+ List list = this.reportDbService.qurestechSql(jmReportDb);
|
|
|
+ this.jmReportDesignService.replaceDbCode(paramString, list);
|
|
|
+ return Result.OK(d.b(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/dataCodeExist"})
|
|
|
+ public Result<Boolean> a(@RequestParam(name = "reportId") String paramString1, @RequestParam(name = "code") String paramString2) {
|
|
|
+ int i = this.reportDbService.getCount(paramString1, paramString2);
|
|
|
+ return Result.OK(Boolean.valueOf((i > 0)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/getQueryInfo"})
|
|
|
+ public Result<List<QueryVO>> a(@RequestParam(name = "reportId") String paramString1, HttpServletRequest paramHttpServletRequest, @RequestParam("param") String paramString2) {
|
|
|
+ String str = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ if (!this.jmBaseConfig.getSaas().booleanValue())
|
|
|
+ str = "";
|
|
|
+ List list = this.jmReportDesignService.getReportQueryInfo(paramString1, str, paramString2);
|
|
|
+ return Result.OK(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping({"/addChart"})
|
|
|
+ @JimuLoginRequired
|
|
|
+ public Result<?> d(@RequestParam(name = "chartType") String paramString, HttpServletRequest paramHttpServletRequest) {
|
|
|
+ JSONObject jSONObject = this.jmReportDesignService.addChart(paramString);
|
|
|
+ return Result.OK(jSONObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/queryTableName"})
|
|
|
+ public Result<?> a(HttpServletRequest paramHttpServletRequest, @RequestParam("dbSource") String paramString1, @RequestParam("tableName") String paramString2, @RequestParam(name = "pageNo", defaultValue = "1") Integer paramInteger1, @RequestParam(name = "pageSize", defaultValue = "50") Integer paramInteger2) {
|
|
|
+ List list = this.reportDbService.queryTableName(paramString1, paramString2);
|
|
|
+ Map map = e.a(list, paramInteger1, paramInteger2);
|
|
|
+ return Result.OK(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/getReportByUser"})
|
|
|
+ public Result<List<JimuReport>> j(HttpServletRequest paramHttpServletRequest, @RequestParam(name = "reportId") String paramString) {
|
|
|
+ Result<List<JimuReport>> result = new Result();
|
|
|
+ String str = this.jimuTokenClient.getUsername(paramHttpServletRequest);
|
|
|
+ List list = this.jmReportDesignService.getReportByUser(str, paramString);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(list);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/getReportChars"})
|
|
|
+ public Result<List<JSONObject>> b(@RequestParam(name = "reportId") String paramString1, @RequestParam(name = "charId", required = false) String paramString2) {
|
|
|
+ ArrayList<JSONObject> arrayList = new ArrayList();
|
|
|
+ JimuReport jimuReport = this.jmReportDesignService.getById(paramString1);
|
|
|
+ if (jimuReport != null) {
|
|
|
+ String str = jimuReport.getJsonStr();
|
|
|
+ JSONObject jSONObject = JSONObject.parseObject(str);
|
|
|
+ Object object = jSONObject.get("chartList");
|
|
|
+ if (null != object) {
|
|
|
+ JSONArray jSONArray = JSONArray.parseArray(object.toString());
|
|
|
+ for (byte b = 0; b < jSONArray.size(); b++) {
|
|
|
+ JSONObject jSONObject1 = new JSONObject();
|
|
|
+ Object object1 = jSONArray.getJSONObject(b).get("layer_id");
|
|
|
+ Object object2 = jSONArray.getJSONObject(b).get("config");
|
|
|
+ JSONObject jSONObject2 = JSONObject.parseObject(object2.toString());
|
|
|
+ JSONObject jSONObject3 = jSONObject2.getJSONObject("title");
|
|
|
+ Object object3 = jSONObject3.get("text");
|
|
|
+ if (null != object3 && null != object1) {
|
|
|
+ if (oConvertUtils.isNotEmpty(paramString2) && !paramString2.equals(object1)) {
|
|
|
+ jSONObject1.put("id", object1);
|
|
|
+ jSONObject1.put("name", object3);
|
|
|
+ arrayList.add(jSONObject1);
|
|
|
+ }
|
|
|
+ if (oConvertUtils.isEmpty(paramString2)) {
|
|
|
+ jSONObject1.put("id", object1);
|
|
|
+ jSONObject1.put("name", object3);
|
|
|
+ arrayList.add(jSONObject1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.OK(arrayList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/getCharData"})
|
|
|
+ public Result<JSONObject> a(@RequestParam(name = "reportId") String paramString1, @RequestParam(name = "charId") String paramString2, @RequestParam(name = "params") String paramString3, HttpServletRequest paramHttpServletRequest) {
|
|
|
+ String str = paramHttpServletRequest.getParameter("X-Access-Token");
|
|
|
+ JSONObject jSONObject = this.jmReportDesignService.getCharData(paramString1, paramString2, paramString3, str);
|
|
|
+ return Result.OK(jSONObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/verificationToken"})
|
|
|
+ public void c(HttpServletRequest paramHttpServletRequest) {
|
|
|
+ this.jimuTokenClient.verifyToken(paramHttpServletRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping({"/exportPdf"})
|
|
|
+ public Result<Object> b(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, @RequestBody JSONObject paramJSONObject) {
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>(paramHttpServletRequest.getParameterMap());
|
|
|
+ boolean bool = hashMap.containsKey("token");
|
|
|
+ if (bool)
|
|
|
+ hashMap.remove("token");
|
|
|
+ String str1 = paramJSONObject.getString("excelConfigId");
|
|
|
+ JSONObject jSONObject = paramJSONObject.getJSONObject("queryParam");
|
|
|
+ jSONObject.put("printAll", Boolean.valueOf(true));
|
|
|
+ Result result = this.jmReportDesignService.show(str1, jSONObject.toJSONString());
|
|
|
+ JimuReport jimuReport = (JimuReport)result.getResult();
|
|
|
+ String str2 = paramHttpServletRequest.getParameter("dpi");
|
|
|
+ float f = 96.0F;
|
|
|
+ if (oConvertUtils.isNotEmpty(str2))
|
|
|
+ f = Float.parseFloat(str2);
|
|
|
+ JSONArray jSONArray = paramJSONObject.getJSONArray("base64Arry");
|
|
|
+ Map map = this.jmReportExportPdf.exportPdf(jimuReport, jSONArray, f);
|
|
|
+ return Result.OK(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/getLinkageChartInfo"})
|
|
|
+ public Result<Object> d(HttpServletRequest paramHttpServletRequest) {
|
|
|
+ String str1 = paramHttpServletRequest.getParameter("reportId");
|
|
|
+ String str2 = paramHttpServletRequest.getParameter("dbCode");
|
|
|
+ String str3 = paramHttpServletRequest.getParameter("linkageDbCode");
|
|
|
+ List list1 = this.jmReportDbParamService.queryParamByDbcode(str1, str3);
|
|
|
+ List list2 = this.jmReportDbFieldService.queryFieldsByDbcode(str1, str2);
|
|
|
+ HashMap<Object, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("paramList", list1);
|
|
|
+ hashMap.put("fieldList", list2);
|
|
|
+ return Result.OK(hashMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/getListReportDb"})
|
|
|
+ public Result<Map<String, Object>> c(@RequestParam(name = "reportId") String paramString) {
|
|
|
+ HashMap<Object, Object> hashMap1 = new HashMap<>();
|
|
|
+ List list = this.reportDbService.getListReportDb(paramString);
|
|
|
+ HashMap<Object, Object> hashMap2 = new HashMap<>();
|
|
|
+ HashMap<Object, Object> hashMap3 = new HashMap<>();
|
|
|
+ for (JmReportDb jmReportDb : list) {
|
|
|
+ List list1 = this.jmReportDbParamService.list(jmReportDb.getId());
|
|
|
+ hashMap3.put(jmReportDb.getDbCode(), list1);
|
|
|
+ }
|
|
|
+ hashMap1.put("reportDbParam", hashMap3);
|
|
|
+ return Result.OK(hashMap1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping({"/dictCodeSearch"})
|
|
|
+ public Result<List<JmDictModel>> a(@RequestParam(name = "key") String paramString1, @RequestParam(name = "text") String paramString2, @RequestParam(name = "reportId") String paramString3) {
|
|
|
+ Result<List<JmDictModel>> result = new Result();
|
|
|
+ List list = this.reportDbService.getListReportDb(paramString3);
|
|
|
+ String str = this.jimuTokenClient.getUsername();
|
|
|
+ if (oConvertUtils.isEmpty(paramString1))
|
|
|
+ return null;
|
|
|
+ String[] arrayOfString = paramString1.split("__");
|
|
|
+ for (JmReportDb jmReportDb : list) {
|
|
|
+ if (arrayOfString.length == 2 && arrayOfString[0].equals(jmReportDb.getDbCode())) {
|
|
|
+ List list1 = this.jmReportDbFieldService.getByDbId(jmReportDb.getId());
|
|
|
+ for (JmReportDbField jmReportDbField : list1) {
|
|
|
+ if (jmReportDbField.getFieldName().equals(arrayOfString[1])) {
|
|
|
+ JSONObject jSONObject = new JSONObject();
|
|
|
+ List list2 = this.jmReportDesignService.queryQueryDictList(jmReportDb, jmReportDbField, str, paramString2, null);
|
|
|
+ result.setResult(list2);
|
|
|
+ result.setSuccess(true);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|