This commit is contained in:
lvleigang 2024-06-25 08:59:10 +08:00
commit f495d7b88d
1 changed files with 210 additions and 143 deletions

View File

@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import sun.java2d.pipe.AAShapePipe; import sun.java2d.pipe.AAShapePipe;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service(value = "comparisonServiceImpl") @Service(value = "comparisonServiceImpl")
public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String> implements IComparisonService { public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String> implements IComparisonService {
@ -50,7 +51,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
} }
//分页查询通用数据数据 //分页查询通用数据数据
@DS("master")
@Override @Override
public JsonResultEntity queryEntityPage(JSONObject json) { public JsonResultEntity queryEntityPage(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
@ -100,13 +100,15 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
for (Map<String, Object> comparisonEntitiePage : comparisonEntitiePages) { for (Map<String, Object> comparisonEntitiePage : comparisonEntitiePages) {
JSONObject jsonObjects=new JSONObject(); JSONObject jsonObjects=new JSONObject();
jsonObjects.put(comparisonEntity.getDbName(),comparisonEntitiePage); jsonObjects.put(comparisonEntity.getDbName(),comparisonEntitiePage);
comparisonDetailsEntity.setFormmainId(String.valueOf(comparisonEntitiePage.get("id"))); if(comparisonDetailsEntity.getDbName()!=null){
//查询明细表数据 comparisonDetailsEntity.setFormmainId(String.valueOf(comparisonEntitiePage.get("id")));
List<Map<String, Object>> maps = comparisonDetailsDao.queryComparisonDetailsPage(comparisonDetailsEntity); //查询明细表数据
if(CollectionUtils.isNotEmpty(maps)){ List<Map<String, Object>> maps = comparisonDetailsDao.queryComparisonDetailsPage(comparisonDetailsEntity);
jsonObjects.put(comparisonDetailsEntity.getDbName(),maps); if(CollectionUtils.isNotEmpty(maps)){
}else { jsonObjects.put(comparisonDetailsEntity.getDbName(),maps);
jsonObjects.put(comparisonDetailsEntity.getDbName(),new JSONArray()); }else {
jsonObjects.put(comparisonDetailsEntity.getDbName(),new JSONArray());
}
} }
list.add(jsonObjects); list.add(jsonObjects);
} }
@ -122,7 +124,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
} }
//新增通用数据数据 //新增通用数据数据
@DS("master")
@Override @Override
public JsonResultEntity saveEntity(JSONObject json) { public JsonResultEntity saveEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
@ -148,108 +149,136 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("根据主数据编码查询信息错误:{}",e.getMessage()); logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败"); return BaseResult.getFailureMessageEntity("保存失败");
} }
String main = jsonObject.getString("main");//获取主表数据 JSONObject jsonObjectMain=new JSONObject();
JSONArray jsonArray = jsonObject.getJSONArray("details");//获取子表数据 JSONArray jsonArray=new JSONArray();
JSONObject jsonObjectMain = JSONObject.parseObject(main); List<JSONArray> arrayList=new ArrayList<>();
if(jsonObjectMain != null ) { //根据dbtype和dbname分组拿到表名称和表类型
Map<String, Object> map = new HashMap<>();//将主表数据存到map中 Map<String, Map<String, List<ComparisonEntity>>> collect = comparisonEntities.stream().collect(Collectors.groupingBy(ComparisonEntity::getDbName, Collectors.groupingBy(ComparisonEntity::getDbType)));
List<Map<String, Object>> mapDetails = new ArrayList<>();//将子表数据存到map中 List<Map.Entry<String, String>> keyPairs = collect.entrySet().stream()
if (comparisonEntities != null && comparisonEntities.size() > 0) { .flatMap(e1 -> e1.getValue().keySet().stream()
map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity,comparisonDetailsEntity); .map(dbname -> new AbstractMap.SimpleEntry<>(e1.getKey(), dbname)))
String uuid = null; .collect(Collectors.toList());
if (jsonObjectMain.getString("id") == null) { // keyPairs 得值为键值对键是表名称值是类型避免多个子表得键一样比如mdm_customer:1,mdm_customer_bank:2,mdm_customer_option_log:2
uuid = UUIDUtils.getUUID(); for (Map.Entry<String, String> keyPair : keyPairs) {
map.put("id", uuid); //如果是1就是主表根据查询出来得主表是否是传输传递得主表
} else { if(keyPair.getValue().equals("1")){
uuid = jsonObjectMain.getString("id"); String main = jsonObject.getString(keyPair.getKey());
map.put("id", jsonObjectMain.getString("id")); if(main!=null){
} jsonObjectMain = JSONObject.parseObject(main);
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); if(!checkStr(jsonObjectMain.getString("id"))){
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); return BaseResult.getFailureMessageEntity("新增时候主表id不能为空");
map.put("org_id", "0"); }
map.put("create_time", new Date()); }
map.put("modify_time", new Date()); }
map.put("sts", "Y"); //如果是2就是明细表根据查询出来得子表是否是传输传递得子表
map.put("data_status", "Y");//新增状态 if(keyPair.getValue().equals("2")){
map.put("add_status", "0");//新增状态 jsonArray= jsonObject.getJSONArray(keyPair.getKey());
map.put("update_status", "1");//修改状态 if(jsonArray!= null) {
map.put("delete_status", "1");//删除状态 for (int i = 0; i < jsonArray.size(); i++) {
ComparisonEntity comparisonEntityRule = comparisonEntities.get(0); JSONObject jsonObjectDetails = jsonArray.getJSONObject(i);
//查询单据规则 只查询主表得明细表不用 jsonObjectDetails.put("table_name", keyPair.getKey());
try { if(!checkStr(jsonObjectDetails.getString("id"))){
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule); return BaseResult.getFailureMessageEntity("新增时候明细id不能为空");
String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1"; }
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule); }
if (documentRule != null) { arrayList.add(jsonArray);
//获取规则前缀 CK }
String rulePrefix = documentRule.substring(0, documentRule.indexOf("-")); }
//获取规则中间日期 yyyy-MM-dd }
String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-")); if(jsonObjectMain!=null && jsonObjectMain.size()>0) {
String ruleMiddle = getRuleDate(ruleDate); Map<String, Object> map = new HashMap<>();//将主表数据存到map中
//获取规则后缀 List<List<Map<String, Object>>> mapDetails = new ArrayList<>();//将子表数据存到map中
String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1); if (comparisonEntities != null && comparisonEntities.size() > 0) {
int ruleSuffix = ruleSuffixLength.length(); map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity, comparisonDetailsEntity);
//生成单据规则 map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
comparisonEntityRule.setRulePrefix(rulePrefix); map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
comparisonEntityRule.setRuleMiddle(ruleMiddle); map.put("org_id", "0");
comparisonEntityRule.setRuleSuffix(ruleSuffix); map.put("create_time", new Date());
try { map.put("modify_time", new Date());
//新生成单据规则保存到数据库 map.put("sts", "Y");
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule); map.put("data_status", "Y");//新增状态
map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则 map.put("add_status", "0");//新增状态
map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号 map.put("update_status", "1");//修改状态
comparisonEntityRule.setMap(map); map.put("delete_status", "1");//删除状态
} catch (Exception e) { ComparisonEntity comparisonEntityRule = comparisonEntities.get(0);
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage()); //查询单据规则 只查询主表得明细表不用
return BaseResult.getFailureMessageEntity("保存失败"); try {
} ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
} String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1";
} catch (Exception e) { logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage()); if (documentRule != null) {
return BaseResult.getFailureMessageEntity("保存失败"); //获取规则前缀 CK
} String rulePrefix = documentRule.substring(0, documentRule.indexOf("-"));
try { //获取规则中间日期 yyyy-MM-dd
List<JSONObject> list=new ArrayList<>(); String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-"));
JSONObject jsonObjectList=new JSONObject(); String ruleMiddle = getRuleDate(ruleDate);
//保存主表数据 //获取规则后缀
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule); String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1);
jsonObjectList.put(comparisonEntityOne.getDbName(),map); int ruleSuffix = ruleSuffixLength.length();
//保存子表数据 //生成单据规则
if (jsonArray != null && jsonArray.size() > 0) { comparisonEntityRule.setRulePrefix(rulePrefix);
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, jsonArray); comparisonEntityRule.setRuleMiddle(ruleMiddle);
if(mapDetails.size()>0 && mapDetails!=null){ comparisonEntityRule.setRuleSuffix(ruleSuffix);
for (Map<String, Object> mapDetail : mapDetails) { try {
String uuidDetail = UUIDUtils.getUUID(); //新生成单据规则保存到数据库
mapDetail.put("id", uuidDetail); ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
mapDetail.put("formmain_id", uuid); map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
mapDetail.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
mapDetail.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); comparisonEntityRule.setMap(map);
mapDetail.put("org_id", "0"); } catch (Exception e) {
mapDetail.put("create_time", new Date()); logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
mapDetail.put("modify_time", new Date()); return BaseResult.getFailureMessageEntity("保存失败");
mapDetail.put("sts", "Y"); }
mapDetail.put("data_status","Y");//新增状态 }
comparisonDetailsEntity.setMapDetails(mapDetail); } catch (Exception e) {
ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity); logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
//comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne); return BaseResult.getFailureMessageEntity("保存失败");
//保存操作日志 }
//controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log"); try {
} List<JSONObject> list = new ArrayList<>();
jsonObjectList.put(comparisonDetailsEntity.getDbName(),mapDetails); JSONObject jsonObjectList = new JSONObject();
} //保存主表数据
}else{ ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
jsonObjectList.put(comparisonDetailsEntity.getDbName(),new ArrayList<>()); jsonObjectList.put(comparisonEntityOne.getDbName(),map);
} //保存子表数据
list.add(jsonObjectList); if (arrayList != null && arrayList.size() > 0) {
//保存操作日志 mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList);
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonEntityRule.getDbName()+"_option_log"); if(mapDetails.size()>0 && mapDetails!=null ){
return BaseResult.getSuccessMessageEntity("保存成功", list); for (List<Map<String, Object>> mapDetail : mapDetails) {
} catch (Exception e) { for (Map<String, Object> stringObjectMap : mapDetail) {
logger.info("保存通用数据时候错误:{}", e.getMessage()); stringObjectMap.put("id", stringObjectMap.get("id"));
return BaseResult.getFailureMessageEntity("保存失败"); stringObjectMap.put("formmain_id", jsonObjectMain.getString("id"));
} stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
} stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
} stringObjectMap.put("org_id", "0");
stringObjectMap.put("create_time", new Date());
stringObjectMap.put("modify_time", new Date());
stringObjectMap.put("sts", "Y");
stringObjectMap.put("data_status", "Y");//新增状态
comparisonDetailsEntity.setMapDetails(stringObjectMap);
comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name")));
stringObjectMap.remove("table_name");
ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity);
comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne);
//保存操作日志
//controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
}
}
jsonObjectList.put(comparisonDetailsEntity.getDbName(), mapDetails);
}
} else {
jsonObjectList.put(comparisonDetailsEntity.getDbName(), new ArrayList<>());
}
list.add(jsonObjectList);
//保存操作日志
controlsLogDaoimpl.saveControlsLog(jsonObjectMain.getString("id"),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonEntityRule.getDbName()+"_option_log");
return BaseResult.getSuccessMessageEntity("保存成功", list);
} catch (Exception e) {
logger.info("保存通用数据时候错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
}
}
return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数"); return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数");
} }
@ -268,11 +297,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
} }
ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class); ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class);
ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity(); ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity();
JSONObject jsonObjectMain=jsonObject.getJSONObject("main");//获取主表数据
JSONArray jsonArray = jsonObject.getJSONArray("details");//获取子表数据
if(!checkStr(jsonObjectMain.getString("id"))){
return BaseResult.getFailureMessageEntity("更新时候主表id不能为空");
}
List<ComparisonEntity> comparisonEntities=new ArrayList<>(); List<ComparisonEntity> comparisonEntities=new ArrayList<>();
//根据主数据编码查询表名称字段名称等信息 10001 //根据主数据编码查询表名称字段名称等信息 10001
try { try {
@ -284,8 +308,41 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("根据主数据编码查询信息错误:{}",e.getMessage()); logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("更新失败"); return BaseResult.getFailureMessageEntity("更新失败");
} }
JSONObject jsonObjectMain=new JSONObject();
JSONArray jsonArray=new JSONArray();
List<JSONArray> arrayList=new ArrayList<>();
//根据dbtype和dbname分组拿到表名称和表类型
Map<String, Map<String, List<ComparisonEntity>>> collect = comparisonEntities.stream().collect(Collectors.groupingBy(ComparisonEntity::getDbName, Collectors.groupingBy(ComparisonEntity::getDbType)));
List<Map.Entry<String, String>> keyPairs = collect.entrySet().stream()
.flatMap(e1 -> e1.getValue().keySet().stream()
.map(dbname -> new AbstractMap.SimpleEntry<>(e1.getKey(), dbname)))
.collect(Collectors.toList());
for (Map.Entry<String, String> keyPair : keyPairs) {
if(keyPair.getValue().equals("1")){
String main = jsonObject.getString(keyPair.getKey());
if(main!=null){
jsonObjectMain = JSONObject.parseObject(main);
if(!checkStr(jsonObjectMain.getString("id"))){
return BaseResult.getFailureMessageEntity("更新时候主表id不能为空");
}
}
}
if(keyPair.getValue().equals("2")){
jsonArray= jsonObject.getJSONArray(keyPair.getKey());
if(jsonArray!= null) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObjectDetails = jsonArray.getJSONObject(i);
if(!checkStr(jsonObjectDetails.getString("id"))){
return BaseResult.getFailureMessageEntity("更新明细表时候明细表id不能为空");
}
jsonObjectDetails.put("table_name", keyPair.getKey());
}
arrayList.add(jsonArray);
}
}
}
Map<String,Object> map=new HashMap<>();//将主表数据存到map中 Map<String,Object> map=new HashMap<>();//将主表数据存到map中
List<Map<String,Object>> mapDetails=new ArrayList<>();//将子表数据存到map中 List<List<Map<String,Object>>> mapDetails=new ArrayList<>();//将子表数据存到map中
if(comparisonEntities !=null && comparisonEntities.size()>0) { if(comparisonEntities !=null && comparisonEntities.size()>0) {
map=spliceMainMap(comparisonEntities,jsonObjectMain,map,comparisonEntity,comparisonDetailsEntity); map=spliceMainMap(comparisonEntities,jsonObjectMain,map,comparisonEntity,comparisonDetailsEntity);
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
@ -315,21 +372,24 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
jsonObjectList.put(comparisonEntity.getDbName(),map); jsonObjectList.put(comparisonEntity.getDbName(),map);
if (integer>0) { if (integer>0) {
//保存子表数据 //保存子表数据
if (jsonArray != null && jsonArray.size() > 0) { if (arrayList != null && arrayList.size() > 0) {
mapDetails=spliceDetailMap(comparisonEntities,mapDetails,jsonArray); mapDetails=spliceDetailMap(comparisonEntities,mapDetails,arrayList);
for (Map<String, Object> mapDetail : mapDetails) { for (List<Map<String, Object>> mapDetail : mapDetails) {
mapDetail.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); for (Map<String, Object> stringObjectMap : mapDetail) {
mapDetail.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
mapDetail.put("org_id", "0"); stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
mapDetail.put("modify_time", new Date()); stringObjectMap.put("org_id", "0");
mapDetail.put("sts", "Y"); stringObjectMap.put("modify_time", new Date());
mapDetail.put("data_status","F");//数据状态 stringObjectMap.put("sts", "Y");
//comparisonDetailsEntity.setFormmainId(jsonObjectMain.getString("id")); stringObjectMap.put("data_status","F");//数据状态
comparisonDetailsEntity.setId(String.valueOf(mapDetail.get("id"))); comparisonDetailsEntity.setId(String.valueOf(stringObjectMap.get("id")));
comparisonDetailsEntity.setMapDetails(mapDetail); comparisonDetailsEntity.setMapDetails(stringObjectMap);
comparisonDetailsDao.updateComparisonDetailsByType(comparisonDetailsEntity); comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name")));
//保存操作日志 stringObjectMap.remove("table_name");
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log"); comparisonDetailsDao.updateComparisonDetailsByType(comparisonDetailsEntity);
//保存操作日志
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
}
} }
jsonObjectList.put(comparisonDetailsEntity.getDbName(),mapDetails); jsonObjectList.put(comparisonDetailsEntity.getDbName(),mapDetails);
}else{ }else{
@ -472,20 +532,27 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
} }
//得到明细表数据 //得到明细表数据
private List<Map<String, Object>> spliceDetailMap(List<ComparisonEntity> comparisonEntities,List<Map<String, Object>> mapDetails,JSONArray jsonArray){ private List<List<Map<String, Object>>> spliceDetailMap(List<ComparisonEntity> comparisonEntities,List<List<Map<String, Object>>> mapDetails,List<JSONArray> arrayList){
if (jsonArray != null && jsonArray.size() > 0) { if (arrayList != null && arrayList.size() > 0) {
for (Object object : jsonArray) { for (JSONArray jsonArray : arrayList) {
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object); List<Map<String,Object>> list=new ArrayList<>();
JSONObject jsonObject=new JSONObject(); for (Object object : jsonArray) {
//遍历主表下面的所有key,字段名 JSONObject jsonObject = new JSONObject();
for (String key : jsonObjectDetails.keySet()) { JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
for (ComparisonEntity entity : comparisonEntities) { //遍历主表下面的所有key,字段名
if (entity.getDbType().equals("2") && entity.getEnName().equals(key)) { for (String key : jsonObjectDetails.keySet()) {
jsonObject.put(key,jsonObjectDetails.getString(key)); for (ComparisonEntity entity : comparisonEntities) {
if (entity.getDbType().equals("2") && entity.getEnName().equals(key)) {
jsonObject.put(key, jsonObjectDetails.getString(key));
}
if(key.equals("table_name")){
jsonObject.put(key,jsonObjectDetails.getString(key));
}
} }
} }
list.add(jsonObject);
} }
mapDetails.add(jsonObject); mapDetails.add(list);
} }
} }
return mapDetails; return mapDetails;