|  | @ -6,11 +6,13 @@ import com.storeroom.modules.archives.domain.ArchivesSummary; | 
		
	
		
			
				|  |  | import com.storeroom.modules.archives.repository.ArchivesSummaryRepository; |  |  | import com.storeroom.modules.archives.repository.ArchivesSummaryRepository; | 
		
	
		
			
				|  |  | import com.storeroom.modules.archives.service.ArchivesService; |  |  | import com.storeroom.modules.archives.service.ArchivesService; | 
		
	
		
			
				|  |  | import com.storeroom.modules.archives.service.dto.ArchivesDTO; |  |  | import com.storeroom.modules.archives.service.dto.ArchivesDTO; | 
		
	
		
			
				|  |  |  |  |  | import com.storeroom.modules.archives.service.dto.ArchivesFileDTO; | 
		
	
		
			
				|  |  | import com.storeroom.modules.common.ArchivesTypeEnum; |  |  | import com.storeroom.modules.common.ArchivesTypeEnum; | 
		
	
		
			
				|  |  | import com.storeroom.modules.dictionary.domain.ArchivesDictionary; |  |  | import com.storeroom.modules.dictionary.domain.ArchivesDictionary; | 
		
	
		
			
				|  |  | import com.storeroom.modules.dictionary.domain.ArchivesType; |  |  | import com.storeroom.modules.dictionary.domain.ArchivesType; | 
		
	
		
			
				|  |  | import com.storeroom.modules.dictionary.repository.ArchivesDictionaryRepository; |  |  | import com.storeroom.modules.dictionary.repository.ArchivesDictionaryRepository; | 
		
	
		
			
				|  |  | import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository; |  |  | import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository; | 
		
	
		
			
				|  |  |  |  |  | import com.storeroom.utils.ApiResponse; | 
		
	
		
			
				|  |  | import com.storeroom.utils.NanoIdUtils; |  |  | import com.storeroom.utils.NanoIdUtils; | 
		
	
		
			
				|  |  | import com.storeroom.utils.PageUtil; |  |  | import com.storeroom.utils.PageUtil; | 
		
	
		
			
				|  |  | import com.storeroom.utils.StringUtils; |  |  | import com.storeroom.utils.StringUtils; | 
		
	
	
		
			
				|  | @ -139,21 +141,21 @@ public class ArchivesServiceImpl implements ArchivesService { | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     @Override |  |  |     @Override | 
		
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class) |  |  |     @Transactional(rollbackFor = Exception.class) | 
		
	
		
			
				|  |  |     public Object edit(ArchivesDTO dto) { |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     public ApiResponse<Object> edit(ArchivesDTO dto) { | 
		
	
		
			
				|  |  |         ArchivesSummary archivesSummary = new ArchivesSummary(); |  |  |         ArchivesSummary archivesSummary = new ArchivesSummary(); | 
		
	
		
			
				|  |  |         JSONObject json = new JSONObject(dto.getJsonString()); |  |  |         JSONObject json = new JSONObject(dto.getJsonString()); | 
		
	
		
			
				|  |  |         ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); |  |  |         ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); | 
		
	
		
			
				|  |  |         List<ArchivesDictionary> showFiled = archivesDictionaryRepository.findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(dto.getCategoryId(),true); |  |  |         List<ArchivesDictionary> showFiled = archivesDictionaryRepository.findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(dto.getCategoryId(),true); | 
		
	
		
			
				|  |  |         List<String> filedNameList = new ArrayList<>(); |  |  |         List<String> filedNameList = new ArrayList<>(); | 
		
	
		
			
				|  |  |         String insertFiled = ""; |  |  |  | 
		
	
		
			
				|  |  |         String insertValue = ""; |  |  |  | 
		
	
		
			
				|  |  |  |  |  |         String insertFiled = "category_id,category_name,"; | 
		
	
		
			
				|  |  |  |  |  |         String insertValue = "'"+dto.getCategoryId()+"','"+archivesType.getCnName()+"',"; | 
		
	
		
			
				|  |  |         String updateValue = ""; |  |  |         String updateValue = ""; | 
		
	
		
			
				|  |  |         for(ArchivesDictionary archivesDictionary:showFiled){ |  |  |         for(ArchivesDictionary archivesDictionary:showFiled){ | 
		
	
		
			
				|  |  |             filedNameList.add(archivesDictionary.getFieldName()); |  |  |             filedNameList.add(archivesDictionary.getFieldName()); | 
		
	
		
			
				|  |  |             //是否必填 |  |  |             //是否必填 | 
		
	
		
			
				|  |  |             if(archivesDictionary.getIsRequired()){ |  |  |             if(archivesDictionary.getIsRequired()){ | 
		
	
		
			
				|  |  |                 if(null == json.get(archivesDictionary.getFieldName()) || "null".equals(json.get(archivesDictionary.getFieldName())) || "".equals(json.get(archivesDictionary.getFieldName()))){ |  |  |                 if(null == json.get(archivesDictionary.getFieldName()) || "null".equals(json.get(archivesDictionary.getFieldName())) || "".equals(json.get(archivesDictionary.getFieldName()))){ | 
		
	
		
			
				|  |  |                     return archivesDictionary.getFieldName()+"不可为空!"; |  |  |  | 
		
	
		
			
				|  |  |  |  |  |                     return ApiResponse.error(50001,archivesDictionary.getFieldName()+"不可为空!"); | 
		
	
		
			
				|  |  |                 } |  |  |                 } | 
		
	
		
			
				|  |  |             } |  |  |             } | 
		
	
		
			
				|  |  |             //是否重复 |  |  |             //是否重复 | 
		
	
	
		
			
				|  | @ -167,7 +169,7 @@ public class ArchivesServiceImpl implements ArchivesService { | 
		
	
		
			
				|  |  |                         for(Object[] objs:list){ |  |  |                         for(Object[] objs:list){ | 
		
	
		
			
				|  |  |                             if(json.get(archivesDictionary.getFieldName()).equals(objs[1])){ |  |  |                             if(json.get(archivesDictionary.getFieldName()).equals(objs[1])){ | 
		
	
		
			
				|  |  |                                 if(dto.getId() == null || !dto.getId().equals(objs[0])){ |  |  |                                 if(dto.getId() == null || !dto.getId().equals(objs[0])){ | 
		
	
		
			
				|  |  |                                     return archivesDictionary.getFieldName()+"不可重复"; |  |  |  | 
		
	
		
			
				|  |  |  |  |  |                                     return ApiResponse.error(50002,archivesDictionary.getFieldName()+"不可重复"); | 
		
	
		
			
				|  |  |                                 } |  |  |                                 } | 
		
	
		
			
				|  |  |                             } |  |  |                             } | 
		
	
		
			
				|  |  |                         } |  |  |                         } | 
		
	
	
		
			
				|  | @ -251,12 +253,55 @@ public class ArchivesServiceImpl implements ArchivesService { | 
		
	
		
			
				|  |  |             archivesSummary.setCategoryName(archivesType.getCnName());//门类名称 |  |  |             archivesSummary.setCategoryName(archivesType.getCnName());//门类名称 | 
		
	
		
			
				|  |  |             archivesSummary.setCategoryType(archivesType.getIsType());//门类级别 |  |  |             archivesSummary.setCategoryType(archivesType.getIsType());//门类级别 | 
		
	
		
			
				|  |  |             archivesSummary.setArchivesTableName(archivesType.getEnName());//档案表名 |  |  |             archivesSummary.setArchivesTableName(archivesType.getEnName());//档案表名 | 
		
	
		
			
				|  |  |  |  |  |             archivesSummary = archivesSummaryRepository.saveAndFlush(archivesSummary); | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |         return ApiResponse.success("成功更新"+result+"条数据。"); | 
		
	
		
			
				|  |  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |  |     public Object initArchiveFilesView(String categoryId,String archiveId) { | 
		
	
		
			
				|  |  |  |  |  |         JSONObject json = new JSONObject(); | 
		
	
		
			
				|  |  |  |  |  |         ArchivesType archivesType = archivesTypeRepository.findById(categoryId).get(); | 
		
	
		
			
				|  |  |  |  |  |         List<ArchivesDictionary> queryShow = archivesDictionaryRepository.findAllByCategoryIdAndIsTypeOrderByIsSequenceAsc(categoryId,3); | 
		
	
		
			
				|  |  |  |  |  |         json.put("queryShow",queryShow); | 
		
	
		
			
				|  |  |  |  |  |         List<String> fields = queryShow.stream().map(archivesDictionary -> { | 
		
	
		
			
				|  |  |  |  |  |             return archivesDictionary.getFieldName(); | 
		
	
		
			
				|  |  |  |  |  |         }).collect(Collectors.toList()); | 
		
	
		
			
				|  |  |  |  |  |         fields.add("id"); | 
		
	
		
			
				|  |  |  |  |  |         String queryFields = fields.stream().map(String::valueOf).collect(Collectors.joining(",")); | 
		
	
		
			
				|  |  |  |  |  |         String sql = "select "+queryFields+" from file_"+archivesType.getEnName()+" where archive_id = '"+archiveId+"'"; | 
		
	
		
			
				|  |  |  |  |  |         List<Object[]> list = entityManager.createNativeQuery(sql).getResultList(); | 
		
	
		
			
				|  |  |  |  |  |         List<Map> returnlist = new ArrayList<>(); | 
		
	
		
			
				|  |  |  |  |  |         for(Object[] objs:list){ | 
		
	
		
			
				|  |  |  |  |  |             Map map = new HashMap(); | 
		
	
		
			
				|  |  |  |  |  |             for(int i = 0;i<fields.size();i++){ | 
		
	
		
			
				|  |  |  |  |  |                 map.put(fields.get(i),objs[i]); | 
		
	
		
			
				|  |  |             } |  |  |             } | 
		
	
		
			
				|  |  |         return "成功更新"+result+"条数据。"; |  |  |  | 
		
	
		
			
				|  |  |  |  |  |             returnlist.add(map); | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |         json.put("returnlist",returnlist); | 
		
	
		
			
				|  |  |  |  |  |         return json; | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     @Override |  |  |     @Override | 
		
	
		
			
				|  |  |     public Object editFile(ArchivesDTO dto) { |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
		
	
		
			
				|  |  |  |  |  |     public Object editFile(ArchivesFileDTO dto) { | 
		
	
		
			
				|  |  |  |  |  |         ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); | 
		
	
		
			
				|  |  |  |  |  |         List<ArchivesDictionary> queryShow = archivesDictionaryRepository.findAllByCategoryIdAndIsTypeOrderByIsSequenceAsc(dto.getCategoryId(),3); | 
		
	
		
			
				|  |  |  |  |  |         JSONArray jsonArray = new JSONArray(dto.getJsonString()); | 
		
	
		
			
				|  |  |  |  |  |         String archivesId = new JSONObject(jsonArray.get(0)).get("archive_id")+""; | 
		
	
		
			
				|  |  |  |  |  |         List<String> fields = queryShow.stream().map(archivesDictionary -> { | 
		
	
		
			
				|  |  |  |  |  |             return archivesDictionary.getFieldName(); | 
		
	
		
			
				|  |  |  |  |  |         }).collect(Collectors.toList()); | 
		
	
		
			
				|  |  |  |  |  |         fields.add("id"); | 
		
	
		
			
				|  |  |  |  |  |         for (Object obj:jsonArray){ | 
		
	
		
			
				|  |  |  |  |  |             JSONObject json = new JSONObject(obj); | 
		
	
		
			
				|  |  |  |  |  |             String insertValue = ""; | 
		
	
		
			
				|  |  |  |  |  |             for(ArchivesDictionary archivesDictionary:queryShow){ | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |         return null; |  |  |         return null; | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
	
		
			
				|  | 
 |