|
@@ -2,7 +2,9 @@ package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.alibaba.fastjson2.TypeReference;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.system.entity.CommonEntity;
|
|
|
import com.ruoyi.system.entity.TableSql;
|
|
@@ -41,22 +43,41 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
|
|
|
@Override
|
|
|
public int batchInsert(CommonEntity commonEntity) {
|
|
|
+
|
|
|
+
|
|
|
String tableName = (String) commonEntity.getBasicMap().get("tableName");
|
|
|
List<Map<String, String>> list = commonEntity.getAddListMap();
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
for (Object obj : list) {
|
|
|
+ System.out.println(obj);
|
|
|
Map<String, Object> map1 = (Map<String, Object>) obj;
|
|
|
- map1.keySet().forEach(item -> {
|
|
|
- mapList.add((Map<String, Object>) JSON.parse(toUnderScoreCase(item) + map1.get(item)));
|
|
|
- });
|
|
|
+ mapList.add(map1);
|
|
|
}
|
|
|
Set<String> fieldNames = new LinkedHashSet<>();
|
|
|
mapList.stream().forEach(map1 -> {
|
|
|
map1.forEach((key, value) -> {
|
|
|
- fieldNames.add(key);
|
|
|
+ fieldNames.add(toUnderScoreCase(key));
|
|
|
});
|
|
|
});
|
|
|
return commonMapper.batchInsert(fieldNames, tableName, mapList);
|
|
|
+
|
|
|
+
|
|
|
+// String tableName = (String) commonEntity.getBasicMap().get("tableName");
|
|
|
+// List<Map<String, String>> list = commonEntity.getAddListMap();
|
|
|
+// List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+// for (Object obj : list) {
|
|
|
+// Map<String, Object> map1 = (Map<String, Object>) obj;
|
|
|
+// map1.keySet().forEach(item -> {
|
|
|
+// mapList.add((Map<String, Object>) JSON.parse(toUnderScoreCase(item) + map1.get(item)));
|
|
|
+// });
|
|
|
+// }
|
|
|
+// Set<String> fieldNames = new LinkedHashSet<>();
|
|
|
+// mapList.stream().forEach(map1 -> {
|
|
|
+// map1.forEach((key, value) -> {
|
|
|
+// fieldNames.add(key);
|
|
|
+// });
|
|
|
+// });
|
|
|
+// return commonMapper.batchInsert(fieldNames, tableName, mapList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -64,13 +85,13 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
String tableName = (String) commonEntity.getBasicMap().get("tableName");
|
|
|
Map<String, Object> conditions = JSONObject.parseObject(JSON.toJSONString(commonEntity.getConditionMap()));
|
|
|
Map<String, Object> fields = JSONObject.parseObject(JSON.toJSONString(commonEntity.getCommMap()));
|
|
|
- Map<String, Object> endfields = null;
|
|
|
+ Map<String, Object> endfields = new HashMap<>();
|
|
|
fields.keySet().forEach(item -> {
|
|
|
// Map<String, Object> asd = JSONObject.parseObject("{ \"" + toUnderScoreCase(item) + "\":\"" + fields.get(item) + "\"}", new TypeReference<Map<String, Object>>() {
|
|
|
// });
|
|
|
endfields.put(toUnderScoreCase(item), fields.get(item));
|
|
|
});
|
|
|
- return commonMapper.edit(fields, tableName, conditions);
|
|
|
+ return commonMapper.edit(endfields, tableName, conditions);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -128,8 +149,15 @@ public class CommonServiceImpl implements ICommonService {
|
|
|
//查询列表信息
|
|
|
List<Map<String, Object>> mapList = null;
|
|
|
//根据条件获取列表信息
|
|
|
- if (commonEntity.getExeclMap() != null && commonEntity.getExeclMap().size() > 0) {
|
|
|
- mapList = commonEntity.getExeclMap();
|
|
|
+ if (commonEntity.getExeclMap() != null && !commonEntity.getExeclMap().equals("")) {
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ try {
|
|
|
+ mapList = mapper.readValue(commonEntity.getExeclMap(), new TypeReference<List<Map<String, Object>>>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+// mapList = commonEntity.getExeclMap();
|
|
|
} else {
|
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
List<CommonEntity> commonEntities = queryTableList(commonEntity, tableSql);
|