|
|
@ -44,6 +44,7 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
return "未查询到到门类信息!"; |
|
|
|
ArchivesType archivesType = optional.get(); |
|
|
|
List<String> queryFields = archivesDictionaryRepository.findDisPlayField(categoryId); |
|
|
|
List<ArchivesDictionary> queryShow = archivesDictionaryRepository.findDisPlay(categoryId); |
|
|
|
String queryField = queryFields.stream().map(String::valueOf).collect(Collectors.joining(",")); |
|
|
|
String queryTable = archivesType.getEnName(); |
|
|
|
String quertOrder = ""; |
|
|
@ -59,7 +60,7 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
|
|
|
|
List<Object[]> list = entityManager.createNativeQuery("select "+queryField+" from "+queryTable+additional+quertOrder).getResultList(); |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("queryFields",queryFields); |
|
|
|
json.put("queryFields",queryShow); |
|
|
|
json.put("showlist",list); |
|
|
|
return json; |
|
|
|
} |
|
|
@ -95,7 +96,7 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
public Object edit(ArchivesDTO dto) { |
|
|
|
dto = new ArchivesDTO(); |
|
|
|
dto.setJsonString("{'category_name':'测试111','remarks':'这是一个备注2'}"); |
|
|
|
String dtoId = "42DA07A3174510955C5635"; |
|
|
|
String dtoId = "42DA07A3174510955C5636"; |
|
|
|
// String dtoId = null; |
|
|
|
JSONObject json = new JSONObject(dto.getJsonString()); |
|
|
|
String categoryId = "FFAFBB1647D459C82080A"; |
|
|
@ -105,27 +106,42 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
String insertValue = ""; |
|
|
|
String updateValue = ""; |
|
|
|
for(ArchivesDictionary archivesDictionary:showFiled){ |
|
|
|
//是否必填 |
|
|
|
if(archivesDictionary.getIsRequired()){ |
|
|
|
if(null == json.get(archivesDictionary.getFieldName()) || "".equals(json.get(archivesDictionary.getFieldName()))){ |
|
|
|
return archivesDictionary.getFieldName()+"不可为空!"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//是否重复 |
|
|
|
if(archivesDictionary.getIsRepeat()){ |
|
|
|
|
|
|
|
//判断是否为空 |
|
|
|
if(null != json.get(archivesDictionary.getFieldName()) && !"".equals(json.get(archivesDictionary.getFieldName()))){ |
|
|
|
String thissql = "select id,"+archivesDictionary.getFieldName()+" from "+archivesType.getEnName()+" where "+ |
|
|
|
archivesDictionary.getFieldName() +" = '"+json.get(archivesDictionary.getFieldName())+"'"; |
|
|
|
List<Object[]> list = entityManager.createNativeQuery(thissql).getResultList(); |
|
|
|
if(list.size()!=0){ |
|
|
|
for(Object[] objs:list){ |
|
|
|
if(json.get(archivesDictionary.getFieldName()).equals(objs[1])){ |
|
|
|
if(!dtoId.equals(objs[0])){ |
|
|
|
return archivesDictionary.getFieldName()+"不可重复"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtils.isEmpty(dtoId)){ |
|
|
|
insertFiled +=archivesDictionary.getFieldName()+","; |
|
|
|
|
|
|
|
insertValue += archivesDictionary.getIsDataType() == 1 ? |
|
|
|
null == json.get(archivesDictionary.getFieldName()) ? null+"," : "'"+json.get(archivesDictionary.getFieldName())+"'," |
|
|
|
: json.get(archivesDictionary.getFieldName()) +","; |
|
|
|
String thisValue = |
|
|
|
archivesDictionary.getIsDataType() == 1 ? |
|
|
|
json.get(archivesDictionary.getFieldName()) == null ? null : "'"+json.get(archivesDictionary.getFieldName())+"'" |
|
|
|
:json.get(archivesDictionary.getFieldName())+""; |
|
|
|
updateValue += archivesDictionary.getFieldName() + "=" + thisValue +","; |
|
|
|
|
|
|
|
}else { |
|
|
|
String thisValue = archivesDictionary.getIsDataType() == 1 ? |
|
|
|
json.get(archivesDictionary.getFieldName()) == null ? null : "'" + json.get(archivesDictionary.getFieldName()) + "'" |
|
|
|
: json.get(archivesDictionary.getFieldName()) + ""; |
|
|
|
updateValue += archivesDictionary.getFieldName() + "=" + thisValue + ","; |
|
|
|
} |
|
|
|
} |
|
|
|
insertFiled = insertFiled.length() != 0 ? insertFiled.substring(0,insertFiled.length()-1) : ""; |
|
|
|
insertValue = insertValue.length() != 0 ? insertValue.substring(0,insertValue.length()-1) : ""; |
|
|
|