@ -1,20 +1,20 @@
package com.storeroom.modules.archives.service.impl ;
package com.storeroom.modules.archives.service.impl ;
import com.storeroom.modules.archives.domain.ArchivesCase ;
import com.storeroom.modules.archives.domain.ArchivesCaseCartoning ;
import com.storeroom.modules.archives.domain.ArchivesSummary ;
import com.storeroom.modules.archives.domain.StorageLog ;
import com.storeroom.modules.archives.repository.ArchivesCaseCartoningRepository ;
import com.storeroom.modules.archives.repository.ArchivesCaseRepository ;
import com.storeroom.modules.archives.repository.ArchivesSummaryRepository ;
import com.storeroom.modules.archives.repository.StorageLogRepository ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.TypeReference ;
import com.storeroom.modules.archives.domain.* ;
import com.storeroom.modules.archives.repository.* ;
import com.storeroom.modules.archives.service.ArchivesCaseService ;
import com.storeroom.modules.archives.service.ArchivesCaseService ;
import com.storeroom.modules.archives.service.dto.ArchivesCaseCartoningDTO ;
import com.storeroom.modules.archives.service.dto.ArchivesCaseCartoningDTO ;
import com.storeroom.modules.archives.domain.vo.ArchivesCaseVO ;
import com.storeroom.modules.archives.domain.vo.ArchivesCaseVO ;
import com.storeroom.modules.archives.service.dto.CaseDTO ;
import com.storeroom.modules.archives.service.dto.CaseDTO ;
import com.storeroom.modules.archives.service.dto.CollectDTO ;
import com.storeroom.modules.archives.service.dto.CollectDTO ;
import com.storeroom.modules.common.ArchivesTypeEnum ;
import com.storeroom.modules.common.ArchivesTypeEnum ;
import com.storeroom.modules.device.domain.DeviceInfo ;
import com.storeroom.modules.device.repository.DeviceArchivesTagRepository ;
import com.storeroom.modules.device.repository.DeviceArchivesTagRepository ;
import com.storeroom.modules.device.repository.DeviceInfoRepository ;
import com.storeroom.modules.device.service.dto.DeviceInfoDto ;
import com.storeroom.modules.device.service.mapstruct.DeviceInfoMapper ;
import com.storeroom.modules.dictionary.domain.ArchivesType ;
import com.storeroom.modules.dictionary.domain.ArchivesType ;
import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository ;
import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository ;
import com.storeroom.utils.NanoIdUtils ;
import com.storeroom.utils.NanoIdUtils ;
@ -38,16 +38,24 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
@RequiredArgsConstructor
public class ArchivesCaseServiceImpl implements ArchivesCaseService {
public class ArchivesCaseServiceImpl implements ArchivesCaseService {
private final DeviceInfoMapper deviceInfoMapper ;
private final DeviceInfoRepository deviceInfoRepository ;
private final ArchivesCaseRepository caseRepository ;
private final ArchivesCaseRepository caseRepository ;
private final ArchivesSummaryRepository archivesSummaryRepository ;
private final ArchivesSummaryRepository archivesSummaryRepository ;
private final ArchivesTypeRepository archivesTypeRepository ;
private final ArchivesTypeRepository archivesTypeRepository ;
private final ArchivesCaseCartoningRepository archivesCaseCartoningRepository ;
private final ArchivesCaseCartoningRepository archivesCaseCartoningRepository ;
private final StorageLogRepository storageLogRepository ;
private final StorageLogRepository storageLogRepository ;
private final StorageDetailsLogRepository storageDetailsLogRepository ;
private final DeviceArchivesTagRepository deviceArchivesTagRepository ;
private final DeviceArchivesTagRepository deviceArchivesTagRepository ;
@PersistenceContext
@PersistenceContext
EntityManager entityManager ;
EntityManager entityManager ;
@Override
public ArchivesCase findById ( String caseId ) {
return caseRepository . findCaseById ( caseId ) ;
}
@Override
@Override
public Object initCaseList ( String tid , String caseName , String barcode , Pageable page ) {
public Object initCaseList ( String tid , String caseName , String barcode , Pageable page ) {
tid = StringUtils . isEmpty ( tid ) ? null : "%" + tid + "%" ;
tid = StringUtils . isEmpty ( tid ) ? null : "%" + tid + "%" ;
@ -57,6 +65,11 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
return PageUtil . toPage ( pageCase ) ;
return PageUtil . toPage ( pageCase ) ;
}
}
@Override
public Object initCaseAll ( Pageable page ) {
return PageUtil . toPage ( caseRepository . initCaseAll ( page ) ) ;
}
@Override
@Override
public Object caseNameIsRepeat ( String caseId , String caseName ) {
public Object caseNameIsRepeat ( String caseId , String caseName ) {
List < ArchivesCase > caseList = caseRepository . findAllByCaseName ( caseName ) ;
List < ArchivesCase > caseList = caseRepository . findAllByCaseName ( caseName ) ;
@ -486,15 +499,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
archivesSummaryRepository . saveAllAndFlush ( archices ) ;
archivesSummaryRepository . saveAllAndFlush ( archices ) ;
List < StorageLog > storageLogs = new ArrayList < > ( ) ;
List < StorageLog > storageLogs = new ArrayList < > ( ) ;
for ( ArchivesCase archivesCase : cases ) {
for ( ArchivesCase archivesCase : cases ) {
StorageLog log = new StorageLog ( ) ;
log . setCaseId ( archivesCase . getId ( ) ) ;
log . setCaseName ( archivesCase . getCaseName ( ) ) ;
log . setDepositNum ( archivesCase . getDepositNum ( ) ) ;
log . setTid ( archivesCase . getTid ( ) ) ;
log . setBarcode ( archivesCase . getBarcode ( ) ) ;
log . setStorageType ( isCallback ? 1 : 2 ) ;
log . setFolderLocationDetails ( deviceArchivesTagRepository . findPositionDetailsByShelfId ( archivesCase . getShelfId ( ) ) ) ;
storageLogs . add ( log ) ;
this . recordStorage ( archivesCase , isCallback ? 1 : 2 ) ;
}
}
storageLogRepository . saveAll ( storageLogs ) ;
storageLogRepository . saveAll ( storageLogs ) ;
return cases ;
return cases ;
@ -507,63 +512,113 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
@Override
@Override
public Object collectConfirm ( List < String > caseIds ) {
public Object collectConfirm ( List < String > caseIds ) {
List < ArchivesCase > cases = caseRepository . findAllById ( caseIds ) ;
caseRepository . manualConfirm ( caseIds , 2 ) ;
caseRepository . manualConfirm ( caseIds , 2 ) ;
for ( ArchivesCase thisCase : cases ) {
this . recordStorage ( thisCase , 2 ) ;
}
return caseIds . size ( ) ;
return caseIds . size ( ) ;
}
}
@Override
@Override
public Object grant ( boolean isCallback , String caseNo ) {
String [ ] caseIds = caseNo . split ( "," ) ;
List < ArchivesCase > cases = new ArrayList < > ( ) ;
if ( isCallback ) {
public List < String > findCaseIdAllByCaseIds ( List < String > caseIds ) {
return caseRepository . initCaseIdAllByCaseId ( caseIds ) ;
}
@Override
public Map < String , DeviceInfoDto > findDevicesByCaseIds ( List < String > caseIds ) {
Map < String , DeviceInfoDto > map = new HashMap < > ( ) ;
for ( String caseId : caseIds ) {
for ( String caseId : caseIds ) {
ArchivesCase thisCase = caseRepository . findById ( caseId ) . get ( ) ;
thisCase . setStorageType ( 3 ) ;
cases . add ( thisCase ) ;
DeviceInfo deviceInfo = deviceInfo Repository. findDevice ByCase Id ( caseId ) ;
if ( null ! = deviceInfo )
map . put ( caseId , deviceInfoMapper . toDto ( deviceInfo ) ) ;
}
}
cases = caseRepository . saveAllAndFlush ( cases ) ;
return map ;
}
@Override
public Integer grant ( boolean isCallback , String caseId ) {
ArchivesCase archivesCase = caseRepository . findById ( caseId ) . get ( ) ;
Integer deviceType = archivesCase . getFolderLocation ( ) . split ( "-" ) . length = = 5 ? 1 : 2 ;
if ( isCallback ) {
archivesCase . setStorageType ( 3 ) ;
} else {
} else {
Set < ArchivesSummary > summarySet = new HashSet < > ( ) ;
for ( String caseId : caseIds ) {
ArchivesCase thisCase = caseRepository . findById ( caseId ) . get ( ) ;
thisCase . setStorageType ( 0 ) ;
thisCase . setShelfId ( null ) ;
thisCase . setFolderLocation ( null ) ;
thisCase . setFolderLocationDetails ( null ) ;
cases . add ( thisCase ) ;
archivesCase . setStorageType ( 0 ) ;
archivesCase . setShelfId ( null ) ;
archivesCase . setFolderLocation ( null ) ;
archivesCase . setFolderLocationDetails ( null ) ;
List < ArchivesSummary > thisSummarys = archivesSummaryRepository . findAllByCaseNoLike ( caseId ) ;
List < ArchivesSummary > thisSummarys = archivesSummaryRepository . findAllByCaseNoLike ( caseId ) ;
summarySet . addAll ( thisSummarys ) ;
}
List < ArchivesSummary > grantSummary = new ArrayList < > ( ) ;
List < ArchivesSummary > grantSummary = new ArrayList < > ( ) ;
for ( ArchivesSummary thisSummary : summarySet ) {
for ( ArchivesSummary thisSummary : thisSummarys ) {
thisSummary . setShelfId ( null ) ;
thisSummary . setShelfId ( null ) ;
thisSummary . setFolderLocation ( null ) ;
thisSummary . setFolderLocation ( null ) ;
thisSummary . setFolderLocationDetails ( null ) ;
thisSummary . setFolderLocationDetails ( null ) ;
grantSummary . add ( thisSummary ) ;
grantSummary . add ( thisSummary ) ;
}
}
cases = caseRepository . saveAllAndFlush ( cases ) ;
archivesSummaryRepository . saveAllAndFlush ( grantSummary ) ;
archivesSummaryRepository . saveAllAndFlush ( grantSummary ) ;
}
}
List < StorageLog > storageLogs = new ArrayList < > ( ) ;
for ( ArchivesCase archivesCase : cases ) {
StorageLog log = new StorageLog ( ) ;
log . setCaseId ( archivesCase . getId ( ) ) ;
log . setCaseName ( archivesCase . getCaseName ( ) ) ;
log . setDepositNum ( archivesCase . getDepositNum ( ) ) ;
log . setTid ( archivesCase . getTid ( ) ) ;
log . setBarcode ( archivesCase . getBarcode ( ) ) ;
log . setStorageType ( isCallback ? 3 : 4 ) ;
log . setFolderLocationDetails ( isCallback ? deviceArchivesTagRepository . findPositionDetailsByShelfId ( archivesCase . getShelfId ( ) ) : null ) ;
storageLogs . add ( log ) ;
}
storageLogRepository . saveAll ( storageLogs ) ;
return caseIds . length ;
archivesCase = caseRepository . saveAndFlush ( archivesCase ) ;
this . recordStorage ( archivesCase , isCallback ? 3 : 4 ) ;
return deviceType ;
}
}
/ / @Override
/ / public Object grant ( boolean isCallback , String caseNo ) {
/ / String [ ] caseIds = caseNo . split ( "," ) ;
/ / List < ArchivesCase > cases = new ArrayList < > ( ) ;
/ / if ( isCallback ) {
/ / for ( String caseId : caseIds ) {
/ / ArchivesCase thisCase = caseRepository . findById ( caseId ) . get ( ) ;
/ / thisCase . setStorageType ( 3 ) ;
/ / cases . add ( thisCase ) ;
/ / }
/ / cases = caseRepository . saveAllAndFlush ( cases ) ;
/ / } else {
/ / Set < ArchivesSummary > summarySet = new HashSet < > ( ) ;
/ / for ( String caseId : caseIds ) {
/ / ArchivesCase thisCase = caseRepository . findById ( caseId ) . get ( ) ;
/ / thisCase . setStorageType ( 0 ) ;
/ / thisCase . setShelfId ( null ) ;
/ / thisCase . setFolderLocation ( null ) ;
/ / thisCase . setFolderLocationDetails ( null ) ;
/ / cases . add ( thisCase ) ;
/ / List < ArchivesSummary > thisSummarys = archivesSummaryRepository . findAllByCaseNoLike ( caseId ) ;
/ / summarySet . addAll ( thisSummarys ) ;
/ / }
/ / List < ArchivesSummary > grantSummary = new ArrayList < > ( ) ;
/ / for ( ArchivesSummary thisSummary : summarySet ) {
/ / thisSummary . setShelfId ( null ) ;
/ / thisSummary . setFolderLocation ( null ) ;
/ / thisSummary . setFolderLocationDetails ( null ) ;
/ / grantSummary . add ( thisSummary ) ;
/ / }
/ / cases = caseRepository . saveAllAndFlush ( cases ) ;
/ / archivesSummaryRepository . saveAllAndFlush ( grantSummary ) ;
/ / }
/ / List < StorageLog > storageLogs = new ArrayList < > ( ) ;
/ / for ( ArchivesCase archivesCase : cases ) {
/ / StorageLog log = new StorageLog ( ) ;
/ / log . setCaseId ( archivesCase . getId ( ) ) ;
/ / log . setCaseName ( archivesCase . getCaseName ( ) ) ;
/ / log . setDepositNum ( archivesCase . getDepositNum ( ) ) ;
/ / log . setTid ( archivesCase . getTid ( ) ) ;
/ / log . setBarcode ( archivesCase . getBarcode ( ) ) ;
/ / log . setStorageType ( isCallback ? 3 : 4 ) ;
/ / log . setFolderLocationDetails ( isCallback ? deviceArchivesTagRepository . findPositionDetailsByShelfId ( archivesCase . getShelfId ( ) ) : null ) ;
/ / storageLogs . add ( log ) ;
/ / }
/ / storageLogRepository . saveAll ( storageLogs ) ;
/ / return caseIds . length ;
/ / }
@Override
@Override
public Object grantConfirm ( List < String > archivesIds ) {
Set < String > caseIds = caseRepository . findCaseIdsByarchivesIds ( archivesIds ) ;
caseRepository . manualConfirm ( caseIds . stream ( ) . toList ( ) , 0 ) ;
public Object grantConfirm ( List < String > caseIds ) {
List < ArchivesCase > cases = caseRepository . findAllById ( caseIds ) ;
caseRepository . manualConfirm ( caseIds , 0 ) ;
for ( ArchivesCase thisCase : cases ) {
this . recordStorage ( thisCase , 4 ) ;
}
return caseIds . size ( ) ;
return caseIds . size ( ) ;
}
}
@ -575,6 +630,11 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
return PageUtil . toPage ( storageLogRepository . initStorageLogList ( storageType , caseName , tid , barcode , page ) ) ;
return PageUtil . toPage ( storageLogRepository . initStorageLogList ( storageType , caseName , tid , barcode , page ) ) ;
}
}
@Override
public Object initStorageLogDetailes ( Integer logId ) {
return storageDetailsLogRepository . findAllByLogId ( logId ) ;
}
@Override
@Override
public List < StorageLog > initStorageLogList ( List < Integer > logs ) {
public List < StorageLog > initStorageLogList ( List < Integer > logs ) {
return storageLogRepository . findAllById ( logs ) ;
return storageLogRepository . findAllById ( logs ) ;
@ -596,4 +656,26 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
caseRepository . saveAndFlush ( archivesCase ) ;
caseRepository . saveAndFlush ( archivesCase ) ;
return null ;
return null ;
}
}
/ / 添加出入库日志
public StorageLog recordStorage ( ArchivesCase thisCase , Integer StorageType ) {
StorageLog log = new StorageLog ( ) ;
log . setCaseId ( thisCase . getId ( ) ) ;
log . setCaseName ( thisCase . getCaseName ( ) ) ;
log . setDepositNum ( thisCase . getDepositNum ( ) ) ;
log . setTid ( thisCase . getTid ( ) ) ;
log . setBarcode ( thisCase . getBarcode ( ) ) ;
log . setStorageType ( StorageType ) ;
log . setFolderLocationDetails ( thisCase . getFolderLocationDetails ( ) ) ;
log = storageLogRepository . save ( log ) ;
List < Map < String , Object > > lists = storageDetailsLogRepository . inCaseArchives ( thisCase . getId ( ) ) ;
List < StorageDetailsLog > sdLog = JSON . parseObject ( JSON . toJSONString ( lists ) , new TypeReference < List < StorageDetailsLog > > ( ) { } ) ;
for ( StorageDetailsLog logDetails : sdLog ) {
logDetails . setLogId ( log . getId ( ) ) ;
}
storageDetailsLogRepository . saveAllAndFlush ( sdLog ) ;
return log ;
}
}
}