Browse Source

1.档案模块编辑后子集合数字段更新

2.档案盒新增入库时间
3.新增出入库模块
master
xia 3 years ago
parent
commit
754455e4d5
  1. 14
      archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java
  2. 5
      archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java
  3. 25
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java
  4. 5
      archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java
  5. 26
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java
  6. 52
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java

14
archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java

@ -18,12 +18,22 @@ public class StorageController {
private final ArchivesCaseService caseService; private final ArchivesCaseService caseService;
@ApiOperation("入库列表")
@ApiOperation("入库列表")
@GetMapping("/readyInto") @GetMapping("/readyInto")
public ApiResponse<Object> readyInto( public ApiResponse<Object> readyInto(
String tid, String caseName,String barcode, Pageable page String tid, String caseName,String barcode, Pageable page
){ ){
return ApiResponse.success(caseService.initCaseList(tid,caseName,barcode,page));
return ApiResponse.success(caseService.readyIntoCase(tid,caseName,barcode,page));
} }
@ApiOperation("已入库盒列表")
@GetMapping("/alReadyInto")
public ApiResponse<Object> alReadyInto(
String caseName,String archiveNo,String title,String location, Pageable page
){
return ApiResponse.success(caseService.alReadyInto(caseName,archiveNo,title,location,page));
}
} }

5
archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java

@ -10,6 +10,7 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
@Entity @Entity
@Getter @Getter
@ -53,4 +54,8 @@ public class ArchivesCase extends BaseEntity implements Serializable {
@ApiModelProperty(value = "入库状态 0.未入 1.待入 2.已入") @ApiModelProperty(value = "入库状态 0.未入 1.待入 2.已入")
private Integer storageType; private Integer storageType;
@Column(name = "storage_time")
@ApiModelProperty(value = "入库时间")
private Timestamp storageTime;
} }

25
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java

@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Map;
public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, String>{ public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, String>{
@ -17,6 +18,30 @@ public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, Stri
"if(?2 is null,1=1,tid like ?2) and if(?3 is null,1=1,barcode like ?3) ") "if(?2 is null,1=1,tid like ?2) and if(?3 is null,1=1,barcode like ?3) ")
Page<ArchivesCase> initCaseList(String caseName, String tid,String barcode, Pageable page); Page<ArchivesCase> initCaseList(String caseName, String tid,String barcode, Pageable page);
@Query(nativeQuery = true,
value = "select * from archives_case where storage_type != 2 and if(?1 is null,1=1,case_name like ?1) and " +
"if(?2 is null,1=1,tid like ?2) and if(?3 is null,1=1,barcode like ?3) ")
Page<ArchivesCase> readyIntoCase(String caseName, String tid,String barcode, Pageable page);
@Query(nativeQuery = true,
value = "SELECT asum.archives_id as archivesId,asum.child as child,asum.category_type as categoryType,asum.category_name as categoryName," +
"asum.fonds_no as fondsNo,asum.archive_no as archiveNo,asum.archive_year as archiveYear,asum.maintitle as maintitle," +
"asum.security_class as securityClass,asum.department as department,ace.case_name as caseName," +
"dct.area_No + '-' + di.device_name + '-' + dat.position as seat,ace.storage_time as storageTime " +
"FROM archives_case ace " +
"INNER JOIN archives_case_cartoning acc ON ace.id = acc.case_id " +
"INNER JOIN archives_summary asum ON acc.archives_id = asum.archives_id " +
"INNER JOIN device_archives_tag dat on asum.shelf_id = dat.id " +
"INNER JOIN dese_cabinet dct on dat.device_info_id = dct.device_info_id " +
"INNER JOIN device_info di on dct.device_info_id = di.id " +
"WHERE ace.storage_type = 2 " +
"AND if(?1 is null,1=1,ace.case_name like ?1) " +
"AND if(?2 is null,1=1,asum.archive_no like ?2) " +
"AND if(?3 is null,1=1,asum.maintitle like ?3) " +
"AND if(?4 is null,1=1,find_in_set(?4,dct.area_No + '-' + di.device_name + '-' + dat.position)) ")
Page<Map<String,Object>> alReadyInto(String caseName, String archiveNo, String title, String location, Pageable page);
@Query(nativeQuery = true, @Query(nativeQuery = true,
value = "select * from archives_case where case_type in (0,?4) and " + value = "select * from archives_case where case_type in (0,?4) and " +
"if(?1 is null,1=1,case_name like ?1) and " + "if(?1 is null,1=1,case_name like ?1) and " +

5
archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java

@ -33,4 +33,9 @@ public interface ArchivesCaseService {
//查看盒内详情 //查看盒内详情
Object findInCase(String caseId); Object findInCase(String caseId);
//查看可入库盒列表
Object readyIntoCase(String tid, String caseName,String barcode, Pageable page);
//查看已入库列表
Object alReadyInto(String caseName,String archiveNo,String title,String location, Pageable page);
} }

26
archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java

@ -353,9 +353,12 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
@Override @Override
public Object findInCase(String caseId) { public Object findInCase(String caseId) {
ArchivesCase archivesCase = caseRepository.findById(caseId).get();
Optional<ArchivesCase> optional = caseRepository.findById(caseId);
if(!optional.isPresent())
return null;
ArchivesCase archivesCase = optional.get();
ArchivesCaseVO vo = new ArchivesCaseVO(); ArchivesCaseVO vo = new ArchivesCaseVO();
BeanUtils.copyProperties(vo,archivesCase);
BeanUtils.copyProperties(archivesCase,vo);
if(null == archivesCase.getCaseType() || archivesCase.getCaseType() == 0) if(null == archivesCase.getCaseType() || archivesCase.getCaseType() == 0)
return null; return null;
Integer code = archivesCase.getCaseType() == 1 ? ArchivesTypeEnum.files.getCode() : ArchivesTypeEnum.inChive.getCode(); Integer code = archivesCase.getCaseType() == 1 ? ArchivesTypeEnum.files.getCode() : ArchivesTypeEnum.inChive.getCode();
@ -363,4 +366,23 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
vo.setArchives(archivesSummaries); vo.setArchives(archivesSummaries);
return vo; return vo;
} }
@Override
public Object readyIntoCase(String tid, String caseName, String barcode, Pageable page) {
tid = StringUtils.isEmpty(tid) ? null : "%"+ tid +"%";
caseName = StringUtils.isEmpty(caseName) ? null : "%"+ caseName +"%";
barcode = StringUtils.isEmpty(barcode) ? null : "%"+ barcode +"%";
Page<ArchivesCase> pageCase = caseRepository.readyIntoCase(caseName,tid,barcode,page);
return PageUtil.toPage(pageCase);
}
@Override
public Object alReadyInto(String caseName, String archiveNo, String title, String location, Pageable page) {
caseName = StringUtils.isEmpty(caseName) ? null : "%"+ caseName +"%";
archiveNo = StringUtils.isEmpty(archiveNo) ? null : "%"+ archiveNo +"%";
title = StringUtils.isEmpty(title) ? null : "%"+ title +"%";
location = StringUtils.isEmpty(location) ? null : "%"+ location +"%";
Page<Map<String,Object>> pageCase = caseRepository.alReadyInto(caseName,archiveNo,title,location,page);
return PageUtil.toPage(pageCase);
}
} }

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

@ -370,6 +370,14 @@ public class ArchivesServiceImpl implements ArchivesService {
}else{ }else{
archivesSummary.setArchivesId(insertId); archivesSummary.setArchivesId(insertId);
archivesSummary.setChild(0); archivesSummary.setChild(0);
//如果有父级
if(!StringUtils.isEmpty(dto.getParentsId())){
ArchivesType archivesTypeP = archivesTypeRepository.findByPid(archivesType.getId());
entityManager.createNativeQuery("update "+archivesTypeP.getEnName()+" set child = (select count(1) from "
+archivesType.getEnName()+"where parent_id ='"+dto.getParentsId()+"') where id = '"+dto.getParentsId()+"'").executeUpdate();
entityManager.createNativeQuery("update archives_summary set child = (select count(1) from "
+archivesType.getEnName()+"where parent_id ='"+dto.getParentsId()+"') where archives_id = '"+dto.getParentsId()+"'").executeUpdate();
}
} }
//档号 //档号
@ -451,6 +459,7 @@ public class ArchivesServiceImpl implements ArchivesService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Object editFile(ArchivesFileDTO dto) { public Object editFile(ArchivesFileDTO dto) {
int result = 0; int result = 0;
String archiveId = "";
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get();
List<ArchivesDictionary> queryShow = archivesDictionaryRepository.findAllByCategoryIdAndIsTypeOrderByIsSequenceAsc(dto.getCategoryId(),3); List<ArchivesDictionary> queryShow = archivesDictionaryRepository.findAllByCategoryIdAndIsTypeOrderByIsSequenceAsc(dto.getCategoryId(),3);
ArchivesDictionary idad = new ArchivesDictionary(); ArchivesDictionary idad = new ArchivesDictionary();
@ -477,8 +486,10 @@ public class ArchivesServiceImpl implements ArchivesService {
String sql = "insert into file_"+archivesType.getEnName()+"("+queryFields+") values ("+insertValue+")"; String sql = "insert into file_"+archivesType.getEnName()+"("+queryFields+") values ("+insertValue+")";
int thisresult = entityManager.createNativeQuery(sql).executeUpdate(); int thisresult = entityManager.createNativeQuery(sql).executeUpdate();
result += thisresult; result += thisresult;
archiveId = json.get("archive_id")+"";
} }
entityManager.createNativeQuery("update "+archivesType.getEnName()+" set child = "+result+" where id='"+archiveId+"'").executeUpdate();
entityManager.createNativeQuery("update archives_summary set child = "+result+" where archives_id = '"+archiveId+"'").executeUpdate();
return result; return result;
} }
@ -486,6 +497,12 @@ public class ArchivesServiceImpl implements ArchivesService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Object deleteFile(ArchivesFileDTO dto,String prefixPath) { public Object deleteFile(ArchivesFileDTO dto,String prefixPath) {
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get();
String archiveId = "";
if(dto.getIds().size()!=0){
archiveId = entityManager.createNativeQuery("select archive_id from "+archivesType.getEnName()
+" where id = '"+dto.getIds().get(0)+"'").getResultList().get(0)+"";
}
String ids = dto.getIds().stream().map(String::valueOf).collect(Collectors.joining("','")); String ids = dto.getIds().stream().map(String::valueOf).collect(Collectors.joining("','"));
ids = ids.length() > 0 ? "'"+ids+"'" : ids; ids = ids.length() > 0 ? "'"+ids+"'" : ids;
// ids.replaceAll("\"",""); // ids.replaceAll("\"","");
@ -501,6 +518,10 @@ public class ArchivesServiceImpl implements ArchivesService {
} }
} }
} }
entityManager.createNativeQuery("update "+archivesType.getEnName()+" set child = (select count(1) from file_"+
archivesType.getEnName()+" where archive_id = '"+archiveId+"') where id='"+archiveId+"'").executeUpdate();
entityManager.createNativeQuery("update archives_summary set child = (select count(1) from file_"+
archivesType.getEnName()+" where archive_id = '"+archiveId+"') where archives_id = '"+archiveId+"'").executeUpdate();
return result; return result;
} }
@ -531,7 +552,22 @@ public class ArchivesServiceImpl implements ArchivesService {
ArchivesSummary archivesSummary = archivesSummaryRepository.findByArchivesId(id); ArchivesSummary archivesSummary = archivesSummaryRepository.findByArchivesId(id);
archivesSummary.setIsDeleteTime(delTime); archivesSummary.setIsDeleteTime(delTime);
archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis())); archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis()));
archivesSummary.setChild(0);
archivesSummaryRepository.saveAndFlush(archivesSummary); archivesSummaryRepository.saveAndFlush(archivesSummary);
//修改父级
Optional<ArchivesType> optional = archivesTypeRepository.findById(archivesType.getId());
if(optional.isPresent()) {
ArchivesType archivesTypeP = optional.get();
String updateChild = "update " + archivesTypeP.getEnName() + " set child = (select count(1) from " + archivesType.getEnName()
+ " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id
+ "')) where id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')";
String updateChild2 = "update archives_summary set child = (select count(1) from " + archivesType.getEnName()
+ " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id
+ "')) where archives_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')";
entityManager.createNativeQuery(updateChild).executeUpdate();
entityManager.createNativeQuery(updateChild2).executeUpdate();
}
} }
//若删除为项目 //若删除为项目
if(archivesType.getIsType() == 2){ if(archivesType.getIsType() == 2){
@ -636,6 +672,20 @@ public class ArchivesServiceImpl implements ArchivesService {
archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis())); archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis()));
archivesSummaryRepository.saveAndFlush(archivesSummary); archivesSummaryRepository.saveAndFlush(archivesSummary);
//修改父级
Optional<ArchivesType> optional = archivesTypeRepository.findById(archivesType.getId());
if(optional.isPresent()){
ArchivesType archivesTypeP = optional.get();
String updateChild = "update "+archivesTypeP.getEnName()+" set child = (select count(1) from "+archivesType.getEnName()
+" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id
+"')) where id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')";
String updateChild2 = "update archives_summary set child = (select count(1) from "+archivesType.getEnName()
+" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id
+"')) where archives_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')";
entityManager.createNativeQuery(updateChild).executeUpdate();
entityManager.createNativeQuery(updateChild2).executeUpdate();
}
success += result; success += result;
} }

Loading…
Cancel
Save