|
|
@ -2,6 +2,7 @@ package com.storeroom.modules.archives.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
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; |
|
|
@ -109,14 +110,16 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Object edit(ArchivesDTO dto) { |
|
|
|
// String dtoId = null; |
|
|
|
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 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()))){ |
|
|
@ -158,10 +161,67 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
insertValue = insertValue.length() != 0 ? insertValue.substring(0,insertValue.length()-1) : ""; |
|
|
|
updateValue = updateValue.length() != 0 ? updateValue.substring(0,updateValue.length()-1) : ""; |
|
|
|
insertFiled = "id,"+insertFiled; |
|
|
|
insertValue = "'"+NanoIdUtils.randomNanoId()+"',"+insertValue; |
|
|
|
String insertId = NanoIdUtils.randomNanoId(); |
|
|
|
insertValue = "'"+insertId+"',"+insertValue; |
|
|
|
String sql = StringUtils.isEmpty(dto.getId()) ? "insert into " + archivesType.getEnName() + "(" + insertFiled +") values ("+insertValue+")" |
|
|
|
: "update "+archivesType.getEnName() +" set "+updateValue+" where id = '"+dto.getId()+"'"; |
|
|
|
int result = entityManager.createNativeQuery(sql).executeUpdate(); |
|
|
|
//成功编辑表之后 |
|
|
|
if(result>0){ |
|
|
|
//修改 |
|
|
|
if(!StringUtils.isEmpty(dto.getId())){ |
|
|
|
archivesSummary = archivesSummaryRepository.findById(dto.getId()).get(); |
|
|
|
}else{ |
|
|
|
archivesSummary.setArchivesId(insertId); |
|
|
|
archivesSummary.setChild(0); |
|
|
|
} |
|
|
|
|
|
|
|
//档号 |
|
|
|
if(filedNameList.contains("archive_no")) |
|
|
|
archivesSummary.setArchiveNo(json.get("archive_no")==null?null:json.get("archive_no")+""); |
|
|
|
//分类号 |
|
|
|
if(filedNameList.contains("archive_ctg_no")) |
|
|
|
archivesSummary.setArchiveCtgNo(json.get("archive_ctg_no")==null?null:json.get("archive_ctg_no")+""); |
|
|
|
//全宗号 |
|
|
|
if(filedNameList.contains("fonds_no")) |
|
|
|
archivesSummary.setFondsNo(json.get("fonds_no")==null?null:json.get("fonds_no")+""); |
|
|
|
//项目号 |
|
|
|
if(filedNameList.contains("item_no")) |
|
|
|
archivesSummary.setItemNo(json.get("item_no")==null?null:json.get("item_no")+""); |
|
|
|
//案卷号 |
|
|
|
if(filedNameList.contains("record_no")) |
|
|
|
archivesSummary.setRecordNo(json.get("record_no")==null?null:json.get("record_no")+""); |
|
|
|
//题名 |
|
|
|
if(filedNameList.contains("maintitle")) |
|
|
|
archivesSummary.setMaintitle(json.get("maintitle")==null?null:json.get("maintitle")+""); |
|
|
|
//密级 |
|
|
|
if(filedNameList.contains("security_class")) |
|
|
|
archivesSummary.setSecurityClass(json.get("security_class")==null?null:json.get("security_class")+""); |
|
|
|
//保管期限 |
|
|
|
if(filedNameList.contains("retention")) |
|
|
|
archivesSummary.setRetention(json.get("retention")==null?null:json.get("retention")+""); |
|
|
|
//归档年度 |
|
|
|
if(filedNameList.contains("archive_year")) |
|
|
|
archivesSummary.setArchiveYear(json.get("archive_year")==null?null:Integer.parseInt(json.get("archive_year")+"")); |
|
|
|
//责任人 |
|
|
|
if(filedNameList.contains("responsibleby")) |
|
|
|
archivesSummary.setResponsibleby(json.get("responsibleby")==null?null:json.get("responsibleby")+""); |
|
|
|
//部门名称 |
|
|
|
if(filedNameList.contains("department")) |
|
|
|
archivesSummary.setDepartment(json.get("department")==null?null:json.get("department")+""); |
|
|
|
//立卷人 |
|
|
|
if(filedNameList.contains("filing_person")) |
|
|
|
archivesSummary.setFilingPerson(json.get("filing_person")==null?null:json.get("filing_person")+""); |
|
|
|
//立卷时间 |
|
|
|
if(filedNameList.contains("filing_date")) |
|
|
|
archivesSummary.setFilingDate(json.get("filing_date")==null?null:json.get("filing_date")+""); |
|
|
|
|
|
|
|
|
|
|
|
archivesSummary.setCategoryId(archivesType.getId());//门类id |
|
|
|
archivesSummary.setCategoryName(archivesType.getCnName());//门类名称 |
|
|
|
archivesSummary.setCategoryType(archivesType.getIsType());//门类级别 |
|
|
|
archivesSummary.setArchivesTableName(archivesType.getEnName());//档案表名 |
|
|
|
} |
|
|
|
return "成功更新"+result+"条数据。"; |
|
|
|
} |
|
|
|
|
|
|
@ -170,7 +230,7 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
public Object delete(ArchivesDTO dto) { |
|
|
|
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); |
|
|
|
String queryTable = archivesType.getEnName(); |
|
|
|
String sql = "update " + queryTable + " set is_delete_time = '" +sdf.format(new Date())+"',is_delete_man='"+dto.getDelMan()+"' where id = '"+dto.getId()+"'"; |
|
|
|
String sql = "update " + queryTable + " set is_delete_time = '" +sdf.format(new Date())+"',is_delete_man='"+dto.getDelMan()+"' where id in ("+dto.getIds()+")"; |
|
|
|
int result = entityManager.createNativeQuery(sql).executeUpdate(); |
|
|
|
return result; |
|
|
|
} |
|
|
@ -180,11 +240,11 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
public Object completelyDelete(ArchivesDTO dto) { |
|
|
|
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); |
|
|
|
String queryTable = archivesType.getEnName(); |
|
|
|
String sql = "delete from " +queryTable+" where id = '"+dto.getId()+"'"; |
|
|
|
String sql = "delete from " +queryTable+" where id in ("+dto.getIds()+")"; |
|
|
|
int result = entityManager.createNativeQuery(sql).executeUpdate(); |
|
|
|
int result1 = 0; |
|
|
|
if(ArchivesTypeEnum.inChive.getCode() == archivesType.getIsType() || ArchivesTypeEnum.files.getCode() == archivesType.getIsType()){ |
|
|
|
String sql1 = "delete from file_" +queryTable+" where parents_id = '"+dto.getId()+"'"; |
|
|
|
String sql1 = "delete from file_" +queryTable+" where parents_id in ("+dto.getIds()+")"; |
|
|
|
result1 = entityManager.createNativeQuery(sql1).executeUpdate(); |
|
|
|
} |
|
|
|
return result+","+result1; |
|
|
|