刘力 3 years ago
parent
commit
c1b21a7f58
  1. 13
      archives/src/main/java/com/storeroom/modules/archives/controller/ArchivesController.java
  2. 8
      archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java
  3. 26
      archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesFileDTO.java
  4. 59
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
  5. 1
      archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java

13
archives/src/main/java/com/storeroom/modules/archives/controller/ArchivesController.java

@ -2,6 +2,7 @@ package com.storeroom.modules.archives.controller;
import com.storeroom.modules.archives.service.ArchivesService;
import com.storeroom.modules.archives.service.dto.ArchivesDTO;
import com.storeroom.modules.archives.service.dto.ArchivesFileDTO;
import com.storeroom.modules.dictionary.service.dto.FieldDTO;
import com.storeroom.utils.ApiResponse;
import com.storeroom.utils.SecurityUtils;
@ -57,13 +58,21 @@ public class ArchivesController {
public ApiResponse<Object> edit(
@Validated @RequestBody ArchivesDTO dto
){
return ApiResponse.success(archivesService.edit(dto));
return archivesService.edit(dto);
}
@ApiOperation("初始化档案附件列表")
@GetMapping("/initArchiveFilesView")
public ApiResponse<Object> initArchiveFilesView(
String categoryId,String archiveId
){
return ApiResponse.success(archivesService.initArchiveFilesView(categoryId,archiveId));
}
@ApiOperation("编辑档案附件")
@PostMapping("/editFile")
public ApiResponse<Object> editFile(
@Validated @RequestBody ArchivesDTO dto
@Validated @RequestBody ArchivesFileDTO dto
){
return ApiResponse.success(archivesService.editFile(dto));
}

8
archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java

@ -1,6 +1,8 @@
package com.storeroom.modules.archives.service;
import com.storeroom.modules.archives.service.dto.ArchivesDTO;
import com.storeroom.modules.archives.service.dto.ArchivesFileDTO;
import com.storeroom.utils.ApiResponse;
import org.springframework.data.domain.Pageable;
public interface ArchivesService {
@ -13,9 +15,11 @@ public interface ArchivesService {
//档案编辑 判断值是否超昂福
Object doeditIsRepeat(String categoryId,String archivesId,String fieldName,String value);
//编辑档案
Object edit(ArchivesDTO dto);
ApiResponse<Object> edit(ArchivesDTO dto);
//初始化档案附件列表
Object initArchiveFilesView(String categoryId,String archiveId);
//编辑档案附件
Object editFile(ArchivesDTO dto);
Object editFile(ArchivesFileDTO dto);
//档案删除进回收站
Object delete(ArchivesDTO dto);
//档案回收站删除

26
archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesFileDTO.java

@ -0,0 +1,26 @@
package com.storeroom.modules.archives.service.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class ArchivesFileDTO {
@JSONField(name="categoryId")
@JsonProperty("categoryId")
private String categoryId;
@JSONField(name="ids")
@JsonProperty("ids")
private List<String> ids;
@JSONField(name="jsonString")
@JsonProperty("jsonString")
private String jsonString;
}

59
archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java

@ -6,11 +6,13 @@ import com.storeroom.modules.archives.domain.ArchivesSummary;
import com.storeroom.modules.archives.repository.ArchivesSummaryRepository;
import com.storeroom.modules.archives.service.ArchivesService;
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.dictionary.domain.ArchivesDictionary;
import com.storeroom.modules.dictionary.domain.ArchivesType;
import com.storeroom.modules.dictionary.repository.ArchivesDictionaryRepository;
import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository;
import com.storeroom.utils.ApiResponse;
import com.storeroom.utils.NanoIdUtils;
import com.storeroom.utils.PageUtil;
import com.storeroom.utils.StringUtils;
@ -139,21 +141,21 @@ public class ArchivesServiceImpl implements ArchivesService {
@Override
@Transactional(rollbackFor = Exception.class)
public Object edit(ArchivesDTO dto) {
public ApiResponse<Object> edit(ArchivesDTO dto) {
ArchivesSummary archivesSummary = new ArchivesSummary();
JSONObject json = new JSONObject(dto.getJsonString());
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get();
List<ArchivesDictionary> showFiled = archivesDictionaryRepository.findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(dto.getCategoryId(),true);
List<String> filedNameList = new ArrayList<>();
String insertFiled = "";
String insertValue = "";
String insertFiled = "category_id,category_name,";
String insertValue = "'"+dto.getCategoryId()+"','"+archivesType.getCnName()+"',";
String updateValue = "";
for(ArchivesDictionary archivesDictionary:showFiled){
filedNameList.add(archivesDictionary.getFieldName());
//是否必填
if(archivesDictionary.getIsRequired()){
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){
if(json.get(archivesDictionary.getFieldName()).equals(objs[1])){
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.setCategoryType(archivesType.getIsType());//门类级别
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
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;
}

1
archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java

@ -14,6 +14,7 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
value = "select field_name from archives_dictionary where category_id = ?1 and is_display is true order by display_order asc")
List<String> findDisPlayField(String categoryId);
List<ArchivesDictionary> findAllByCategoryIdAndIsTypeOrderByIsSequenceAsc(String categoryId,Integer isType);
List<ArchivesDictionary> findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(String categoryId, boolean isInput);

Loading…
Cancel
Save