diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java index ac96835..80026b1 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java @@ -44,6 +44,7 @@ public class ArchivesServiceImpl implements ArchivesService { return "未查询到到门类信息!"; ArchivesType archivesType = optional.get(); List queryFields = archivesDictionaryRepository.findDisPlayField(categoryId); + List 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 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 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) : ""; diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java b/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java index bb05778..62d97c9 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java @@ -13,6 +13,7 @@ public interface ArchivesDictionaryRepository extends JpaRepository findDisPlayField(String categoryId); +<<<<<<< HEAD List findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(String categoryId, boolean isInput); @Query(value = "INSERT INTO yxk_storeroom.archives_dictionary(id,category_id,field_name,field_cn_name,dictionary_id,is_data_type,is_data_type_details,is_column_length,is_sequence,is_type,is_system VALUES ())", nativeQuery = true) @@ -21,5 +22,11 @@ public interface ArchivesDictionaryRepository extends JpaRepository findDisPlay(String categoryId); + + List findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(String categoryId,boolean isInput); +>>>>>>> fa78bdc2fdf2d68321b9dcc6920bfce2ed1faa85 }