|
|
@ -1,10 +1,11 @@ |
|
|
|
package com.storeroom.modules.archives.service.impl; |
|
|
|
|
|
|
|
import com.storeroom.modules.archives.domain.ArchivesCase; |
|
|
|
import com.storeroom.modules.archives.domain.ArchivesSummary; |
|
|
|
import com.storeroom.modules.archives.repository.ArchivesCaseRepository; |
|
|
|
import com.storeroom.modules.archives.repository.ArchivesSummaryRepository; |
|
|
|
import com.storeroom.modules.archives.service.ArchivesCaseService; |
|
|
|
import com.storeroom.modules.dictionary.service.dto.CaseDTO; |
|
|
|
import com.storeroom.modules.archives.service.dto.CaseDTO; |
|
|
|
import com.storeroom.utils.NanoIdUtils; |
|
|
|
import com.storeroom.utils.PageUtil; |
|
|
|
import com.storeroom.utils.StringUtils; |
|
|
@ -12,8 +13,10 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.sql.Timestamp; |
|
|
|
import javax.persistence.EntityManager; |
|
|
|
import javax.persistence.PersistenceContext; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
@ -22,6 +25,8 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { |
|
|
|
|
|
|
|
private final ArchivesCaseRepository caseRepository; |
|
|
|
private final ArchivesSummaryRepository archivesSummaryRepository; |
|
|
|
@PersistenceContext |
|
|
|
EntityManager entityManager; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object initCaseList(String tid, String caseName, Pageable page) { |
|
|
@ -32,6 +37,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Object edit(CaseDTO dto) { |
|
|
|
ArchivesCase archivesCase = null; |
|
|
|
if(!StringUtils.isEmpty(dto.getId())){ |
|
|
@ -47,15 +53,55 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Integer findIsBingdingLabel(String tid,Integer labelType) { |
|
|
|
if(labelType==1){ |
|
|
|
return archivesSummaryRepository.countAllByTagNo(tid); |
|
|
|
}else if(labelType==2){ |
|
|
|
return caseRepository.countAllByTid(tid); |
|
|
|
}else if(labelType==3){ |
|
|
|
return 0; |
|
|
|
public String findIsBingdingLabel(String tid) { |
|
|
|
Integer archivesTag = archivesSummaryRepository.countAllByTagNo(tid); |
|
|
|
if(archivesTag == 0){ |
|
|
|
Integer caseTag = caseRepository.countAllByTid(tid); |
|
|
|
if(caseTag==0){ |
|
|
|
return "0,0"; |
|
|
|
}else{ |
|
|
|
return 0; |
|
|
|
return "2,"+caseTag; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
return "1,"+archivesTag; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Object addCaseTag(String caseId, String tid,Integer labelType, String bindingCount,String tagType) { |
|
|
|
String archivesTable = ""; |
|
|
|
//若标签已绑定 先解绑 |
|
|
|
if(!"0".equals(bindingCount)){ |
|
|
|
switch (tagType){ |
|
|
|
case "1": |
|
|
|
ArchivesSummary archivesSummary = archivesSummaryRepository.findFirstByTagNo(tid); |
|
|
|
archivesSummaryRepository.unbindTag(tid); |
|
|
|
archivesTable = archivesSummary.getArchivesTableName(); |
|
|
|
String sql = "update "+archivesTable+" set tid = null where id = '"+archivesSummary.getArchivesId()+"'"; |
|
|
|
entityManager.createNativeQuery(sql).executeUpdate(); |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
caseRepository.unbindTag(tid); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
//绑定标签 |
|
|
|
switch (labelType){ |
|
|
|
case 1: |
|
|
|
archivesSummaryRepository.bindTag(tid,caseId); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |