|
@@ -25,6 +25,9 @@ import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
+import com.boman.domain.GenTableColumn;
|
|
|
+import com.boman.gen.api.RemoteGenTableColumnService;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.modules.jmreport.common.expetion.JimuReportException;
|
|
|
import org.jeecg.modules.jmreport.common.util.ApiAssert;
|
|
@@ -36,16 +39,12 @@ import org.jeecg.modules.jmreport.common.vo.Result;
|
|
|
import org.jeecg.modules.jmreport.config.client.JmReportTokenClient;
|
|
|
import org.jeecg.modules.jmreport.desreport.dao.JimuReportDbDao;
|
|
|
import org.jeecg.modules.jmreport.desreport.dao.JimuReportDbParamDao;
|
|
|
-import org.jeecg.modules.jmreport.desreport.entity.JmReportDataSource;
|
|
|
-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.entity.*;
|
|
|
import org.jeecg.modules.jmreport.desreport.render.handler.convert.ApiDataConvertAdapter;
|
|
|
import org.jeecg.modules.jmreport.desreport.render.utils.RegexMatches;
|
|
|
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.util.d;
|
|
|
import org.jeecg.modules.jmreport.desreport.util.j;
|
|
@@ -60,14 +59,16 @@ 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.context.annotation.Primary;
|
|
|
import org.springframework.jdbc.UncategorizedSQLException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.client.ResourceAccessException;
|
|
|
|
|
|
-@Service("jmReportDbServiceImpl")
|
|
|
-public class i implements IJmReportDbService {
|
|
|
- private static final Logger a = LoggerFactory.getLogger(i.class);
|
|
|
+@Service
|
|
|
+@Primary
|
|
|
+public class JmReportDbService implements IJmReportDbService {
|
|
|
+ private static final Logger a = LoggerFactory.getLogger(JmReportDbService.class);
|
|
|
@Autowired
|
|
|
private IJmReportDbParamService jmReportParamService;
|
|
|
@Autowired
|
|
@@ -88,9 +89,8 @@ public class i implements IJmReportDbService {
|
|
|
private ApiDataConvertAdapter apiDataConverAdapter;
|
|
|
@Value("${jeecg.jmreport.apiBasePath:}")
|
|
|
private String apiBasePath;
|
|
|
-
|
|
|
- public i() {
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private RemoteGenTableColumnService remoteGenTableColumnService;
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
@@ -125,34 +125,33 @@ public class i implements IJmReportDbService {
|
|
|
this.a(reportDb);
|
|
|
var7 = reportDb.getId();
|
|
|
this.reportDbFieldService.deleteByReportId(var7);
|
|
|
- List var9 = reportDb.getFieldList();
|
|
|
- if (d.a(var9)) {
|
|
|
- Iterator var4 = var9.iterator();
|
|
|
-
|
|
|
- while (var4.hasNext()) {
|
|
|
- JmReportDbField var5 = (JmReportDbField) var4.next();
|
|
|
- var5.setJimuReportDbId(var7);
|
|
|
+ List<JmReportDbField> dbFields = reportDb.getFieldList();
|
|
|
+ if (d.a(dbFields)) {
|
|
|
+ for (JmReportDbField dbField : dbFields) {
|
|
|
+ dbField.setJimuReportDbId(var7);
|
|
|
}
|
|
|
|
|
|
- this.reportDbFieldService.saveOrUpdateBatch(var9);
|
|
|
+ this.reportDbFieldService.saveOrUpdateBatch(dbFields);
|
|
|
}
|
|
|
|
|
|
this.jmReportParamService.deleteByReportId(var7);
|
|
|
- List var10 = reportDb.getParamList();
|
|
|
- if (d.a(var10)) {
|
|
|
- Iterator var11 = var10.iterator();
|
|
|
-
|
|
|
- while (var11.hasNext()) {
|
|
|
- JmReportDbParam var6 = (JmReportDbParam) var11.next();
|
|
|
- var6.setJimuReportHeadId(var7);
|
|
|
- if (var6.getSearchFlag() == null) {
|
|
|
- var6.setSearchFlag(0);
|
|
|
+ List<JmReportDbParam> dbParams = reportDb.getParamList();
|
|
|
+ if (d.a(dbParams)) {
|
|
|
+ for (JmReportDbParam reportDbParam : dbParams) {
|
|
|
+ reportDbParam.setJimuReportHeadId(var7);
|
|
|
+ if (reportDbParam.getSearchFlag() == null) {
|
|
|
+ reportDbParam.setSearchFlag(0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.jmReportParamService.saveOrUpdateBatch(var10);
|
|
|
+ this.jmReportParamService.saveOrUpdateBatch(dbParams);
|
|
|
}
|
|
|
|
|
|
+// JmReportDb db = new JmReportDb();
|
|
|
+// db.setId(reportDb.getId());
|
|
|
+// db.setDbCode(reportDb.getDbCode());
|
|
|
+// db.setDbChName(reportDb.getDbChName());
|
|
|
+ reportDbDao.update(reportDb);
|
|
|
return reportDb;
|
|
|
}
|
|
|
|
|
@@ -201,6 +200,7 @@ public class i implements IJmReportDbService {
|
|
|
return var2;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public boolean queryIsPage(String reportId) {
|
|
|
int var2 = this.reportDbDao.getCountByReportId(reportId);
|
|
|
boolean var3 = false;
|
|
@@ -211,6 +211,7 @@ public class i implements IJmReportDbService {
|
|
|
return var3;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public Map<String, Object> executeSelectSql(String sql, String dbKey, Map<String, Object> params) {
|
|
|
List var4 = this.jmReportParamService.list(params.get("jimuReportHeadId").toString());
|
|
|
JmReportDbParam var6;
|
|
@@ -593,9 +594,10 @@ public class i implements IJmReportDbService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> parseReportSql(String sql, String dbKey, Object paramArray, String type) throws JimuReportException {
|
|
|
- HashMap var5 = new HashMap();
|
|
|
- Object var6 = new ArrayList();
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> parseReportSql(String sql, String dbKey, Object paramArray, String type, String tableName) throws JimuReportException {
|
|
|
+ HashMap<String, Object> var5 = new HashMap<>();
|
|
|
+ List<Map<String, Object>> var6 = new ArrayList<>();
|
|
|
if (oConvertUtils.isNotEmpty(paramArray)) {
|
|
|
sql = this.a(paramArray, sql);
|
|
|
}
|
|
@@ -660,27 +662,40 @@ public class i implements IJmReportDbService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (var6 != null && ((List) var6).size() > 0) {
|
|
|
- ArrayList var19 = new ArrayList();
|
|
|
- Map var21 = (Map) ((List) var6).get(0);
|
|
|
- int var11 = 1;
|
|
|
- Iterator var12 = var21.entrySet().iterator();
|
|
|
-
|
|
|
- while (var12.hasNext()) {
|
|
|
- Entry var13 = (Entry) var12.next();
|
|
|
- String var14 = ((String) var13.getKey()).toLowerCase();
|
|
|
- LinkedHashMap var15 = new LinkedHashMap();
|
|
|
- var15.put("fieldName", var14);
|
|
|
- var15.put("fieldText", var14);
|
|
|
- var15.put("widgetType", "String");
|
|
|
- var15.put("orderNum", var11++);
|
|
|
- var19.add(var15);
|
|
|
- }
|
|
|
|
|
|
- var5.put("fieldList", var19);
|
|
|
- var5.put("paramList", var7);
|
|
|
+ if (CollectionUtils.isEmpty(var6)) {
|
|
|
+ return var5;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询我们自己的gen_table_column
|
|
|
+ List<GenTableColumn> columns = remoteGenTableColumnService.listColumnsByTableName(tableName);
|
|
|
+ if (CollectionUtils.isEmpty(columns)) {
|
|
|
+ return var5;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LinkedHashMap<String, Object>> var19 = new ArrayList<>();
|
|
|
+ Map<String, Object> limitOne = var6.get(0);
|
|
|
+
|
|
|
+ int cnt = 1;
|
|
|
+ for (Entry<String, Object> entry : limitOne.entrySet()) {
|
|
|
+ String limitOneColumnName = entry.getKey().toLowerCase();
|
|
|
+ for (GenTableColumn column : columns) {
|
|
|
+ if (!column.getColumnName().equals(limitOneColumnName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ LinkedHashMap<String, Object> temp = new LinkedHashMap<>();
|
|
|
+ temp.put("fieldName", limitOneColumnName);
|
|
|
+ temp.put("fieldText", column.getColumnComment());
|
|
|
+ temp.put("widgetType", "String");
|
|
|
+ temp.put("orderNum", cnt++);
|
|
|
+ var19.add(temp);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ var5.put("fieldList", var19);
|
|
|
+ var5.put("paramList", var7);
|
|
|
return var5;
|
|
|
}
|
|
|
|