Merge branch 'grpU8' of http://ufidahz.com.cn:9015/root/kangarooDataCenterV3 into grpU8
This commit is contained in:
commit
64d815ab49
|
@ -73,6 +73,7 @@ public class ComparisonEntity extends BaseEntity {
|
|||
this.viewName = viewName;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getReturnField() {
|
||||
return returnField;
|
||||
}
|
||||
|
|
|
@ -105,10 +105,10 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
//查询主表数据
|
||||
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparisonEntity);
|
||||
|
||||
//递归查询组织树
|
||||
if(comparisonEntities.get(0).getViewName().equals("1")){
|
||||
return recursiveQueryComparison(comparisonEntitiePages,comparisonEntity);
|
||||
}
|
||||
/* //递归查询组织树
|
||||
if(map.get("viewName").equals("1")){
|
||||
return recursiveQueryComparison(comparisonEntitiePages,comparisonEntity);
|
||||
}*/
|
||||
|
||||
if(CollectionUtils.isNotEmpty(comparisonEntitiePages)){
|
||||
for (Map<String, Object> comparisonEntitiePage : comparisonEntitiePages) {
|
||||
|
@ -155,21 +155,21 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
}
|
||||
ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class);
|
||||
ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity();
|
||||
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
|
||||
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
|
||||
String uuid= String.valueOf(UUIDLong.longUUID());
|
||||
try {
|
||||
//根据主数据编码查询表名称,字段名称等信息 10001
|
||||
// comparisonEntities = comparisonDao.queryComparison(comparisonEntity);
|
||||
try {
|
||||
//根据主数据编码查询表名称,字段名称等信息 10001
|
||||
// comparisonEntities = comparisonDao.queryComparison(comparisonEntity);
|
||||
|
||||
//comparisonEntities=getComparisonEntity(comparisonEntity);
|
||||
comparisonEntities=getComparisonEntityCache(comparisonEntity,"main");
|
||||
}catch (Exception e){
|
||||
logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
JSONObject jsonObjectMain=new JSONObject();
|
||||
JSONArray jsonArray=new JSONArray();
|
||||
List<JSONArray> arrayList=new ArrayList<>();
|
||||
//comparisonEntities=getComparisonEntity(comparisonEntity);
|
||||
comparisonEntities=getComparisonEntityCache(comparisonEntity,"main");
|
||||
}catch (Exception e){
|
||||
logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
JSONObject jsonObjectMain=new JSONObject();
|
||||
JSONArray jsonArray=new JSONArray();
|
||||
List<JSONArray> arrayList=new ArrayList<>();
|
||||
|
||||
String tableName=null;
|
||||
//根据dbtype和dbname分组,拿到表名称和表类型
|
||||
|
@ -181,208 +181,208 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
// keyPairs 得值为键值对,键是表名称,值是类型,避免多个子表得键一样,比如:mdm_customer:1,mdm_customer_bank:2,mdm_customer_option_log:2
|
||||
for (Map.Entry<String, String> keyPair : keyPairs) {
|
||||
//如果是1,就是主表,根据查询出来得主表是否是传输传递得主表
|
||||
if(keyPair.getValue().equals("1")){
|
||||
String main = jsonObject.getString(keyPair.getKey());
|
||||
tableName=keyPair.getKey();
|
||||
if(main!=null){
|
||||
jsonObjectMain = JSONObject.parseObject(main);
|
||||
if(!checkStr(jsonObjectMain.getString("data_id"))){
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
|
||||
return BaseResult.getFailureMessageEntity("新增时候主表data_id不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(keyPair.getValue().equals("1")){
|
||||
String main = jsonObject.getString(keyPair.getKey());
|
||||
tableName=keyPair.getKey();
|
||||
if(main!=null){
|
||||
jsonObjectMain = JSONObject.parseObject(main);
|
||||
if(!checkStr(jsonObjectMain.getString("data_id"))){
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
|
||||
return BaseResult.getFailureMessageEntity("新增时候主表data_id不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
//如果是2,就是明细表,根据查询出来得子表是否是传输传递得子表
|
||||
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);
|
||||
jsonObjectDetails.put("table_name", keyPair.getKey());
|
||||
if(!checkStr(jsonObjectDetails.getString("data_id"))){
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
|
||||
return BaseResult.getFailureMessageEntity("新增时候明细data_id不能为空");
|
||||
}
|
||||
}
|
||||
arrayList.add(jsonArray);
|
||||
}
|
||||
}
|
||||
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);
|
||||
jsonObjectDetails.put("table_name", keyPair.getKey());
|
||||
if(!checkStr(jsonObjectDetails.getString("data_id"))){
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
|
||||
return BaseResult.getFailureMessageEntity("新增时候明细data_id不能为空");
|
||||
}
|
||||
}
|
||||
arrayList.add(jsonArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(jsonObjectMain!=null && jsonObjectMain.size()>0) {
|
||||
Map<String, Object> map = new HashMap<>();//将主表数据存到map中
|
||||
List<List<Map<String, Object>>> mapDetails = new ArrayList<>();//将子表数据存到map中
|
||||
if (comparisonEntities != null && comparisonEntities.size() > 0) {
|
||||
map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity, comparisonDetailsEntity);
|
||||
Map<String, Object> map = new HashMap<>();//将主表数据存到map中
|
||||
List<List<Map<String, Object>>> mapDetails = new ArrayList<>();//将子表数据存到map中
|
||||
if (comparisonEntities != null && comparisonEntities.size() > 0) {
|
||||
map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity, comparisonDetailsEntity);
|
||||
|
||||
//根据data_id判断数据是否已经保存在相关表中,避免重复保存
|
||||
List<String> fields = getFields(comparisonEntity);
|
||||
Map<String, Object> mapDataId = new HashMap<>();
|
||||
mapDataId.put("data_id", jsonObjectMain.getString("data_id"));
|
||||
ComparisonEntity comparisonDataId = new ComparisonEntity();
|
||||
comparisonDataId.setMap(mapDataId);
|
||||
comparisonDataId.setDbName(comparisonEntity.getDbName());
|
||||
comparisonDataId.setFields(fields);
|
||||
List<Map<String, Object>> listDataId = comparisonDao.queryComparisonPage(comparisonDataId);
|
||||
if (CollectionUtils.isNotEmpty(listDataId)) {
|
||||
//return BaseResult.getFailureMessageEntity(comparisonEntity.getDbName()+"表中已经存在data_id为:"+jsonObjectMain.getString("data_id")+"的数据");
|
||||
return updateEntity(json);
|
||||
} else {
|
||||
//根据data_id判断数据是否已经保存在相关表中,避免重复保存
|
||||
List<String> fields = getFields(comparisonEntity);
|
||||
Map<String, Object> mapDataId = new HashMap<>();
|
||||
mapDataId.put("data_id", jsonObjectMain.getString("data_id"));
|
||||
ComparisonEntity comparisonDataId = new ComparisonEntity();
|
||||
comparisonDataId.setMap(mapDataId);
|
||||
comparisonDataId.setDbName(comparisonEntity.getDbName());
|
||||
comparisonDataId.setFields(fields);
|
||||
List<Map<String, Object>> listDataId = comparisonDao.queryComparisonPage(comparisonDataId);
|
||||
if (CollectionUtils.isNotEmpty(listDataId)) {
|
||||
//return BaseResult.getFailureMessageEntity(comparisonEntity.getDbName()+"表中已经存在data_id为:"+jsonObjectMain.getString("data_id")+"的数据");
|
||||
return updateEntity(json);
|
||||
} else {
|
||||
|
||||
//如果是树形结构,查询不存在,新增时候需要得到parent_id,根据parent_id查询data_id是否有,之后将查询得父id设置到mdm_up_id中
|
||||
if(comparisonEntities.get(0).getViewName().equals("1")){
|
||||
List<String> fieldParent = getFields(comparisonEntity);
|
||||
Map<String, Object> mapParentId = new HashMap<>();
|
||||
mapDataId.put("data_id", jsonObjectMain.getString("parent_id"));
|
||||
ComparisonEntity comparisonParentId = new ComparisonEntity();
|
||||
comparisonParentId.setMap(mapParentId);
|
||||
comparisonParentId.setDbName(comparisonEntity.getDbName());
|
||||
comparisonParentId.setFields(fieldParent);
|
||||
List<Map<String, Object>> listParentId = comparisonDao.queryComparisonPage(comparisonDataId);
|
||||
//如果根据parentid查询数据不为空,将dataid为parenti得id值设置到mdm_up_id中
|
||||
if(CollectionUtils.isNotEmpty(listParentId)){
|
||||
map.put("mdm_up_id",listParentId.get(0).get("id"));
|
||||
}
|
||||
}
|
||||
//如果是树形结构,查询不存在,新增时候需要得到parent_id,根据parent_id查询data_id是否有,之后将查询得父id设置到mdm_up_id中
|
||||
if(map.get("viewName").equals("1")){
|
||||
List<String> fieldParent = getFields(comparisonEntity);
|
||||
Map<String, Object> mapParentId = new HashMap<>();
|
||||
mapDataId.put("data_id", jsonObjectMain.getString("parent_id"));
|
||||
ComparisonEntity comparisonParentId = new ComparisonEntity();
|
||||
comparisonParentId.setMap(mapParentId);
|
||||
comparisonParentId.setDbName(comparisonEntity.getDbName());
|
||||
comparisonParentId.setFields(fieldParent);
|
||||
List<Map<String, Object>> listParentId = comparisonDao.queryComparisonPage(comparisonDataId);
|
||||
//如果根据parentid查询数据不为空,将dataid为parenti得id值设置到mdm_up_id中
|
||||
if(CollectionUtils.isNotEmpty(listParentId)){
|
||||
map.put("mdm_up_id",listParentId.get(0).get("id"));
|
||||
}
|
||||
}
|
||||
|
||||
//判断输入的主表字段是否是必填项
|
||||
for (ComparisonEntity entity : comparisonEntities) {
|
||||
//如果必填字段不为空
|
||||
if (entity.getRuleValue() != null && entity.getDbType().equals("1")) {
|
||||
//如果值为空,说明没有传这个字段或者这个字段的值为空
|
||||
if (jsonObjectMain.getString(entity.getEnName()) == null || jsonObjectMain.getString(entity.getEnName()).equals("")) {
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
return BaseResult.getFailureMessageEntity(entity.getDbName() + "表的" + entity.getEnName() + "字段不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
//判断输入的主表字段是否是必填项
|
||||
for (ComparisonEntity entity : comparisonEntities) {
|
||||
//如果必填字段不为空
|
||||
if (entity.getRuleValue() != null && entity.getDbType().equals("1")) {
|
||||
//如果值为空,说明没有传这个字段或者这个字段的值为空
|
||||
if (jsonObjectMain.getString(entity.getEnName()) == null || jsonObjectMain.getString(entity.getEnName()).equals("")) {
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
return BaseResult.getFailureMessageEntity(entity.getDbName() + "表的" + entity.getEnName() + "字段不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map.put("id", uuid);
|
||||
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
map.put("org_id", "0");
|
||||
map.put("create_time", new Date());
|
||||
map.put("modify_time", new Date());
|
||||
map.put("sts", "Y");
|
||||
map.put("data_status", "Y");//新增状态
|
||||
map.put("add_status", "0");//新增状态
|
||||
map.put("update_status", "1");//修改状态
|
||||
map.put("delete_status", "1");//删除状态
|
||||
ComparisonEntity comparisonEntityRule = comparisonEntities.get(0);
|
||||
//查询单据规则 只查询主表得,明细表不用
|
||||
try {
|
||||
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
|
||||
String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1";
|
||||
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
|
||||
if (documentRule != null) {
|
||||
//获取规则前缀 CK
|
||||
String rulePrefix = documentRule.substring(0, documentRule.indexOf("-"));
|
||||
//获取规则中间日期 yyyy-MM-dd
|
||||
String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-"));
|
||||
String ruleMiddle = getRuleDate(ruleDate);
|
||||
//获取规则后缀
|
||||
String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1);
|
||||
int ruleSuffix = ruleSuffixLength.length();
|
||||
//生成单据规则
|
||||
comparisonEntityRule.setRulePrefix(rulePrefix);
|
||||
comparisonEntityRule.setRuleMiddle(ruleMiddle);
|
||||
comparisonEntityRule.setRuleSuffix(ruleSuffix);
|
||||
try {
|
||||
//新生成单据规则保存到数据库
|
||||
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
|
||||
map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
|
||||
map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
|
||||
comparisonEntityRule.setMap(map);
|
||||
} catch (Exception e) {
|
||||
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
map.put("id", uuid);
|
||||
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
map.put("org_id", "0");
|
||||
map.put("create_time", new Date());
|
||||
map.put("modify_time", new Date());
|
||||
map.put("sts", "Y");
|
||||
map.put("data_status", "Y");//新增状态
|
||||
map.put("add_status", "0");//新增状态
|
||||
map.put("update_status", "1");//修改状态
|
||||
map.put("delete_status", "1");//删除状态
|
||||
ComparisonEntity comparisonEntityRule = comparisonEntities.get(0);
|
||||
//查询单据规则 只查询主表得,明细表不用
|
||||
try {
|
||||
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
|
||||
String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1";
|
||||
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
|
||||
if (documentRule != null) {
|
||||
//获取规则前缀 CK
|
||||
String rulePrefix = documentRule.substring(0, documentRule.indexOf("-"));
|
||||
//获取规则中间日期 yyyy-MM-dd
|
||||
String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-"));
|
||||
String ruleMiddle = getRuleDate(ruleDate);
|
||||
//获取规则后缀
|
||||
String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1);
|
||||
int ruleSuffix = ruleSuffixLength.length();
|
||||
//生成单据规则
|
||||
comparisonEntityRule.setRulePrefix(rulePrefix);
|
||||
comparisonEntityRule.setRuleMiddle(ruleMiddle);
|
||||
comparisonEntityRule.setRuleSuffix(ruleSuffix);
|
||||
try {
|
||||
//新生成单据规则保存到数据库
|
||||
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
|
||||
map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
|
||||
map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
|
||||
comparisonEntityRule.setMap(map);
|
||||
} catch (Exception e) {
|
||||
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
try {
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
JSONObject jsonObjectList = new JSONObject();
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
try {
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
JSONObject jsonObjectList = new JSONObject();
|
||||
|
||||
//判断明细表字段是否是必填项
|
||||
if (arrayList != null && arrayList.size() > 0) {
|
||||
for (JSONArray jsonArrayDetails : arrayList) {
|
||||
for (Object object : jsonArrayDetails) {
|
||||
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
|
||||
for (ComparisonEntity entity : comparisonEntities) {
|
||||
if (entity.getRuleValue() != null && entity.getDbType().equals("2")) {
|
||||
//如果值为空,说明没有传这个字段或者这个字段的值为空
|
||||
if (jsonObjectDetails.getString(entity.getEnName()) == null || jsonObjectDetails.getString(entity.getEnName()).equals("")) {
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
return BaseResult.getFailureMessageEntity(entity.getDbName() + "表的" + entity.getEnName() + "字段不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//判断明细表字段是否是必填项
|
||||
if (arrayList != null && arrayList.size() > 0) {
|
||||
for (JSONArray jsonArrayDetails : arrayList) {
|
||||
for (Object object : jsonArrayDetails) {
|
||||
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
|
||||
for (ComparisonEntity entity : comparisonEntities) {
|
||||
if (entity.getRuleValue() != null && entity.getDbType().equals("2")) {
|
||||
//如果值为空,说明没有传这个字段或者这个字段的值为空
|
||||
if (jsonObjectDetails.getString(entity.getEnName()) == null || jsonObjectDetails.getString(entity.getEnName()).equals("")) {
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
return BaseResult.getFailureMessageEntity(entity.getDbName() + "表的" + entity.getEnName() + "字段不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//保存主表数据
|
||||
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
|
||||
jsonObjectList.put(comparisonEntityOne.getDbName(), map);
|
||||
//保存子表数据
|
||||
if (arrayList != null && arrayList.size() > 0) {
|
||||
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList);
|
||||
if (mapDetails.size() > 0 && mapDetails != null) {
|
||||
for (List<Map<String, Object>> mapDetail : mapDetails) {
|
||||
for (Map<String, Object> stringObjectMap : mapDetail) {
|
||||
stringObjectMap.put("id", UUIDLong.longUUID());
|
||||
stringObjectMap.put("formmain_id", uuid);
|
||||
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<>());
|
||||
}
|
||||
jsonObjectList.remove(null);
|
||||
list.add(jsonObjectList);
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "1");
|
||||
JSONObject json1 = new JSONObject();
|
||||
json1.put("status", "200");
|
||||
json1.put("list", list);
|
||||
return json1;
|
||||
} catch (Exception e) {
|
||||
logger.info("保存通用数据时候错误:{}", e.getMessage());
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
//保存主表数据
|
||||
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
|
||||
jsonObjectList.put(comparisonEntityOne.getDbName(), map);
|
||||
//保存子表数据
|
||||
if (arrayList != null && arrayList.size() > 0) {
|
||||
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList);
|
||||
if (mapDetails.size() > 0 && mapDetails != null) {
|
||||
for (List<Map<String, Object>> mapDetail : mapDetails) {
|
||||
for (Map<String, Object> stringObjectMap : mapDetail) {
|
||||
stringObjectMap.put("id", UUIDLong.longUUID());
|
||||
stringObjectMap.put("formmain_id", uuid);
|
||||
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<>());
|
||||
}
|
||||
jsonObjectList.remove(null);
|
||||
list.add(jsonObjectList);
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "1");
|
||||
JSONObject json1 = new JSONObject();
|
||||
json1.put("status", "200");
|
||||
json1.put("list", list);
|
||||
return json1;
|
||||
} catch (Exception e) {
|
||||
logger.info("保存通用数据时候错误:{}", e.getMessage());
|
||||
//保存操作日志
|
||||
controlsLogDaoimpl.saveControlsLog(uuid, jsonObject.getString("appName"), jsonObject.getString("appCode"), jsonObject.toJSONString(), "接口新增", jsonObject.getString("optionName"), tableName + "_option_log", "2");
|
||||
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return BaseResult.getFailureMessageEntity("保存失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return BaseResult.getFailureMessageEntity("保存失败","请检查传递参数");
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
|
||||
//根据主数据编码查询表名称,字段名称等信息 10001
|
||||
try {
|
||||
// comparisonEntities = comparisonDao.queryComparison(comparisonEntity);
|
||||
// comparisonEntities = comparisonDao.queryComparison(comparisonEntity);
|
||||
|
||||
//comparisonEntities=getComparisonEntity(comparisonEntity);
|
||||
comparisonEntities=getComparisonEntityCache(comparisonEntity,"main");
|
||||
|
@ -464,7 +464,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
}
|
||||
|
||||
//判断是否是树形结构
|
||||
if(comparisonEntities.get(0).getViewName().equals("1")){
|
||||
if(map.get("viewName").equals("1")){
|
||||
//根据data_id查询出parent_id,再根据parent_id得值查询data_id字段中为这个得值,如果有,将data_id为parent_id得id值保存到mdm_up_id中
|
||||
Map<String,Object> mapParent=new HashMap<>();
|
||||
mapParent.put("data_id",comparisonEntitiePages.get(0).get("parent_id"));
|
||||
|
@ -565,7 +565,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
|
||||
//根据主数据编码查询表名称,字段名称等信息 10001
|
||||
try {
|
||||
// comparisonEntities = comparisonDao.queryComparison(comparisonEntity);
|
||||
// comparisonEntities = comparisonDao.queryComparison(comparisonEntity);
|
||||
|
||||
//comparisonEntities=getComparisonEntity(comparisonEntity);
|
||||
comparisonEntities=getComparisonEntityCache(comparisonEntity,"main");
|
||||
|
@ -623,8 +623,8 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
}
|
||||
|
||||
//递归删除树结构 1.树 2.列表
|
||||
if(comparisonEntities.get(0).getViewName().equals("1")){
|
||||
return recursiveDeleteComparison(comparisonEntitiePages,comparisonEntity);
|
||||
if(map.get("viewName").equals("1")){
|
||||
return recursiveDeleteComparison(comparisonEntitiePages,comparisonEntity);
|
||||
}
|
||||
|
||||
String id = String.valueOf(comparisonEntitiePages.get(0).get("id"));
|
||||
|
@ -685,30 +685,30 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
|||
|
||||
//递归查询组织树
|
||||
private Object recursiveQueryComparison(List<Map<String,Object>> list,ComparisonEntity comparisonEntity){
|
||||
if(CollectionUtils.isNotEmpty(list)) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
List<String> fields = getFields(comparisonEntity);
|
||||
Map<String,Object> mapId=new HashMap<>();
|
||||
mapId.put("mdm_up_id",list.get(0).get("id"));
|
||||
ComparisonEntity comparison=new ComparisonEntity();
|
||||
comparison.setDbName(comparisonEntity.getDbName());
|
||||
comparison.setMap(mapId);
|
||||
comparison.setFields(fields);
|
||||
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparison);
|
||||
if(CollectionUtils.isNotEmpty(comparisonEntitiePages)){
|
||||
recursiveQueryComparison(comparisonEntitiePages,comparisonEntity);
|
||||
for (Map<String, Object> map : list) {
|
||||
map.put("comparisonEntities",comparisonEntitiePages);
|
||||
}
|
||||
}
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
JSONObject json1=new JSONObject();
|
||||
json1.put("status","200");
|
||||
json1.put("pageInfo",pageInfo);
|
||||
return json1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
if(CollectionUtils.isNotEmpty(list)) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
List<String> fields = getFields(comparisonEntity);
|
||||
Map<String,Object> mapId=new HashMap<>();
|
||||
mapId.put("mdm_up_id",list.get(0).get("id"));
|
||||
ComparisonEntity comparison=new ComparisonEntity();
|
||||
comparison.setDbName(comparisonEntity.getDbName());
|
||||
comparison.setMap(mapId);
|
||||
comparison.setFields(fields);
|
||||
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparison);
|
||||
if(CollectionUtils.isNotEmpty(comparisonEntitiePages)){
|
||||
recursiveQueryComparison(comparisonEntitiePages,comparisonEntity);
|
||||
for (Map<String, Object> map : list) {
|
||||
map.put("comparisonEntities",comparisonEntitiePages);
|
||||
}
|
||||
}
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
JSONObject json1=new JSONObject();
|
||||
json1.put("status","200");
|
||||
json1.put("pageInfo",pageInfo);
|
||||
return json1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//根据应用key和应用密钥获取应用编码和应用名称
|
||||
|
|
Loading…
Reference in New Issue