18 changed files with 524 additions and 137 deletions
			
			
		- 
					23archives/src/main/java/com/storeroom/modules/archives/controller/ArchivesController.java
- 
					62archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java
- 
					39archives/src/main/java/com/storeroom/modules/archives/controller/TagController.java
- 
					10archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCaseCartoning.java
- 
					38archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesTagLog.java
- 
					71archives/src/main/java/com/storeroom/modules/archives/domain/vo/ArchivesSummaryVO.java
- 
					5archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseCartoningRepository.java
- 
					16archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java
- 
					11archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java
- 
					19archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesTagLogRepository.java
- 
					8archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesTagRepository.java
- 
					4archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java
- 
					4archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java
- 
					13archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java
- 
					149archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java
- 
					24archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
- 
					154archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesTagServiceImpl.java
- 
					3system/src/main/resources/application.yml
| @ -0,0 +1,38 @@ | |||||
|  | package com.storeroom.modules.archives.domain; | ||||
|  | 
 | ||||
|  | import com.storeroom.base.BaseEntity; | ||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||
|  | import lombok.Getter; | ||||
|  | import lombok.Setter; | ||||
|  | 
 | ||||
|  | import javax.persistence.*; | ||||
|  | import java.io.Serializable; | ||||
|  | 
 | ||||
|  | @Entity | ||||
|  | @Getter | ||||
|  | @Setter | ||||
|  | @Table(name = "archives_tag_log") | ||||
|  | public class ArchivesTagLog extends BaseEntity implements Serializable { | ||||
|  | 
 | ||||
|  |     @Id | ||||
|  |     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_SEQ") | ||||
|  |     @Column(name="id") | ||||
|  |     private Integer id; | ||||
|  | 
 | ||||
|  |     @Column(name = "tid") | ||||
|  |     @ApiModelProperty(value = "标签id") | ||||
|  |     private String tid; | ||||
|  | 
 | ||||
|  |     @Column(name = "oper_type") | ||||
|  |     @ApiModelProperty(value = "操作类型 1.绑定 2.解绑") | ||||
|  |     private Integer operType; | ||||
|  | 
 | ||||
|  |     @Column(name = "binding_type") | ||||
|  |     @ApiModelProperty(value = "绑定类别 1.档案 2.档案盒 3.层架位") | ||||
|  |     private Integer bindingType; | ||||
|  | 
 | ||||
|  |     @Column(name = "title") | ||||
|  |     @ApiModelProperty(value = "标签标题") | ||||
|  |     private String title; | ||||
|  | 
 | ||||
|  | } | ||||
| @ -0,0 +1,71 @@ | |||||
|  | package com.storeroom.modules.archives.domain.vo; | ||||
|  | 
 | ||||
|  | import com.alibaba.fastjson.annotation.JSONField; | ||||
|  | import com.fasterxml.jackson.annotation.JsonProperty; | ||||
|  | import lombok.Getter; | ||||
|  | import lombok.Setter; | ||||
|  | 
 | ||||
|  | import java.sql.Timestamp; | ||||
|  | 
 | ||||
|  | @Getter | ||||
|  | @Setter | ||||
|  | public class ArchivesSummaryVO { | ||||
|  | 
 | ||||
|  |     @JSONField(name="archivesId") | ||||
|  |     @JsonProperty("archives_id") | ||||
|  |     private String archivesId; | ||||
|  | 
 | ||||
|  |     @JSONField(name="categoryId") | ||||
|  |     @JsonProperty("category_id") | ||||
|  |     private String categoryId; | ||||
|  | 
 | ||||
|  |     @JSONField(name="categoryName") | ||||
|  |     @JsonProperty("category_name") | ||||
|  |     private String categoryName; | ||||
|  | 
 | ||||
|  |     @JSONField(name="categoryType") | ||||
|  |     @JsonProperty("category_type") | ||||
|  |     private Integer categoryType; | ||||
|  | 
 | ||||
|  |     @JSONField(name="tid") | ||||
|  |     @JsonProperty("tid") | ||||
|  |     private String tid; | ||||
|  | 
 | ||||
|  |     @JSONField(name="fondsNo") | ||||
|  |     @JsonProperty("fonds_no") | ||||
|  |     private String fondsNo; | ||||
|  | 
 | ||||
|  |     @JSONField(name="archiveNo") | ||||
|  |     @JsonProperty("archive_no") | ||||
|  |     private String archiveNo; | ||||
|  | 
 | ||||
|  |     @JSONField(name="department") | ||||
|  |     @JsonProperty("department") | ||||
|  |     private String department; | ||||
|  | 
 | ||||
|  |     @JSONField(name="archiveYear") | ||||
|  |     @JsonProperty("archive_year") | ||||
|  |     private Integer archiveYear; | ||||
|  | 
 | ||||
|  |     @JSONField(name="maintitle") | ||||
|  |     @JsonProperty("maintitle") | ||||
|  |     private String maintitle; | ||||
|  | 
 | ||||
|  |     @JSONField(name="retention") | ||||
|  |     @JsonProperty("retention") | ||||
|  |     private String retention; | ||||
|  | 
 | ||||
|  |     @JSONField(name="securityClass") | ||||
|  |     @JsonProperty("security_class") | ||||
|  |     private String securityClass; | ||||
|  | 
 | ||||
|  | //    @JSONField(name="createTime") | ||||
|  | //    @JsonProperty("create_time") | ||||
|  | //    private Timestamp create_time; | ||||
|  | // | ||||
|  | //    @JSONField(name="updateTime") | ||||
|  | //    @JsonProperty("update_time") | ||||
|  | //    private Timestamp update_time; | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | } | ||||
| @ -0,0 +1,19 @@ | |||||
|  | package com.storeroom.modules.archives.repository; | ||||
|  | 
 | ||||
|  | import com.storeroom.modules.archives.domain.ArchivesTagLog; | ||||
|  | import org.springframework.data.domain.Page; | ||||
|  | import org.springframework.data.domain.Pageable; | ||||
|  | import org.springframework.data.jpa.repository.JpaRepository; | ||||
|  | import org.springframework.data.jpa.repository.Modifying; | ||||
|  | import org.springframework.data.jpa.repository.Query; | ||||
|  | 
 | ||||
|  | public interface ArchivesTagLogRepository extends JpaRepository<ArchivesTagLog, String>{ | ||||
|  | 
 | ||||
|  |     @Query(nativeQuery = true, | ||||
|  |             value = "select * from archives_tag_log where if(?1 is null,1=1,tid like ?1) " + | ||||
|  |                     "and if(?2 is null,1=1,title like ?2) " + | ||||
|  |                     "and if(?3 is null,1=1,oper_type = ?3) " + | ||||
|  |                     "and if(?4 is null,1=1,binding_type = ?4) ") | ||||
|  |     Page<ArchivesTagLog> initTagLogList(String tid, String title, Integer operType, Integer bindingType, Pageable page); | ||||
|  | 
 | ||||
|  | } | ||||
| @ -1,10 +1,21 @@ | |||||
| package com.storeroom.modules.archives.service; | package com.storeroom.modules.archives.service; | ||||
| 
 | 
 | ||||
|  | import com.storeroom.modules.archives.service.dto.CaseDTO; | ||||
| import org.springframework.data.domain.Pageable; | import org.springframework.data.domain.Pageable; | ||||
| 
 | 
 | ||||
| public interface ArchivesTagService { |  | ||||
|  | import java.util.List; | ||||
| 
 | 
 | ||||
|  | public interface ArchivesTagService { | ||||
| 
 | 
 | ||||
|  |     //初始化标签列表 | ||||
|     Object initTagList(String tid, String query,Integer isType, Pageable page); |     Object initTagList(String tid, String query,Integer isType, Pageable page); | ||||
|  |     //初始化标签日志列表 | ||||
|  |     Object initTagLogList(String tid, String title,Integer operType,Integer bindingType, Pageable page); | ||||
|  |     //查看标签是否绑定 | ||||
|  |     Integer findIsBingdingLabel(String label); | ||||
|  |     //绑定标签 | ||||
|  |     Object addTag(String caseId,String tid,Integer labelType,Integer tagType); | ||||
|  |     //解绑标签 | ||||
|  |     Object unbindTag(List<CaseDTO> dtos); | ||||
| 
 | 
 | ||||
| } | } | ||||
| @ -1,22 +1,174 @@ | |||||
| 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.ArchivesSummary; | ||||
|  | import com.storeroom.modules.archives.domain.ArchivesTag; | ||||
|  | import com.storeroom.modules.archives.domain.ArchivesTagLog; | ||||
|  | import com.storeroom.modules.archives.repository.ArchivesCaseRepository; | ||||
|  | import com.storeroom.modules.archives.repository.ArchivesSummaryRepository; | ||||
|  | import com.storeroom.modules.archives.repository.ArchivesTagLogRepository; | ||||
| import com.storeroom.modules.archives.repository.ArchivesTagRepository; | import com.storeroom.modules.archives.repository.ArchivesTagRepository; | ||||
| import com.storeroom.modules.archives.service.ArchivesTagService; | import com.storeroom.modules.archives.service.ArchivesTagService; | ||||
|  | import com.storeroom.modules.archives.service.dto.CaseDTO; | ||||
|  | import com.storeroom.utils.PageUtil; | ||||
| import com.storeroom.utils.StringUtils; | import com.storeroom.utils.StringUtils; | ||||
| import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
| import org.springframework.data.domain.Pageable; | import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||
|  | 
 | ||||
|  | import javax.persistence.EntityManager; | ||||
|  | import javax.persistence.PersistenceContext; | ||||
|  | import java.util.List; | ||||
|  | import java.util.Optional; | ||||
| 
 | 
 | ||||
| @Service | @Service | ||||
| @RequiredArgsConstructor | @RequiredArgsConstructor | ||||
| public class ArchivesTagServiceImpl implements ArchivesTagService { | public class ArchivesTagServiceImpl implements ArchivesTagService { | ||||
| 
 | 
 | ||||
|     private final ArchivesTagRepository archivesTagRepository; |     private final ArchivesTagRepository archivesTagRepository; | ||||
|  |     private final ArchivesTagLogRepository archivesTagLogRepository; | ||||
|  |     private final ArchivesSummaryRepository archivesSummaryRepository; | ||||
|  |     private final ArchivesCaseRepository caseRepository; | ||||
|  | 
 | ||||
|  |     @PersistenceContext | ||||
|  |     EntityManager entityManager; | ||||
| 
 | 
 | ||||
|     @Override |     @Override | ||||
|     public Object initTagList(String tid, String query, Integer isType, Pageable page) { |     public Object initTagList(String tid, String query, Integer isType, Pageable page) { | ||||
|         tid = null != tid ? "%"+tid+"%" : null; |         tid = null != tid ? "%"+tid+"%" : null; | ||||
|         query = null != query ? "%"+query+"%" : null; |         query = null != query ? "%"+query+"%" : null; | ||||
|         return archivesTagRepository.initTagList(tid,query,isType,page); |  | ||||
|  |         return PageUtil.toPage(archivesTagRepository.initTagList(tid,query,isType,page)); | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     public Object initTagLogList(String tid, String title, Integer operType, Integer bindingType, Pageable page) { | ||||
|  |         tid = null != tid ? "%"+tid+"%" : null; | ||||
|  |         title = null != title ? "%"+title+"%" : null; | ||||
|  |         return PageUtil.toPage(archivesTagLogRepository.initTagLogList(tid,title,operType,bindingType,page)); | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     public Integer findIsBingdingLabel(String label) { | ||||
|  |         Optional<ArchivesTag> optional = archivesTagRepository.findById(label); | ||||
|  |         if(!optional.isPresent()){ | ||||
|  |             return 0; | ||||
|  |         }else{ | ||||
|  |             ArchivesTag tag = optional.get(); | ||||
|  |             return tag.getIsType() == null ? 0 : tag.getIsType(); | ||||
|  |         } | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||
|  |     public Object addTag(String parentId, String tid, Integer labelType, Integer tagType) { | ||||
|  |         String archivesTable = ""; | ||||
|  |         String oldTid = ""; | ||||
|  |         Integer returnCount = 0; | ||||
|  |         //若原标签有绑定  先解绑 | ||||
|  |         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; | ||||
|  |         } | ||||
|  |         Object title = ""; | ||||
|  |         //绑定标签 | ||||
|  |         switch (labelType){ | ||||
|  |             case 1: | ||||
|  |                 oldTid = archivesSummaryRepository.findByArchivesId(parentId).getTagNo(); | ||||
|  |                 archivesSummaryRepository.bindTag(tid,parentId); | ||||
|  |                 String sql = "update "+archivesTable+" set tid = null where id = '"+parentId+"'"; | ||||
|  |                 returnCount = entityManager.createNativeQuery(sql).executeUpdate(); | ||||
|  |                 title =  entityManager.createNativeQuery("select maintitle from "+archivesTable+" where id = '"+parentId+"'").getResultList().get(0); | ||||
|  |                 break; | ||||
|  |             case 2: | ||||
|  |                 ArchivesCase archivesCase = caseRepository.findById(parentId).get(); | ||||
|  |                 title = archivesCase.getCaseName(); | ||||
|  |                 oldTid = archivesCase.getTid(); | ||||
|  |                 returnCount = caseRepository.bindTag(tid,parentId); | ||||
|  |                 break; | ||||
|  |             case 3: | ||||
|  |                 break; | ||||
|  |             default: | ||||
|  |                 break; | ||||
|  |         } | ||||
|  |         //清空原本tid | ||||
|  |         if(!StringUtils.isEmpty(oldTid)){ | ||||
|  |             archivesTagRepository.unbindTag(oldTid); | ||||
|         } |         } | ||||
|  | 
 | ||||
|  |         Optional<ArchivesTag> optional = archivesTagRepository.findById(tid); | ||||
|  |         ArchivesTag tag = optional.isPresent() ? optional.get() : new ArchivesTag(); | ||||
|  |         if(tagType==1||tagType==2||tagType==3){ | ||||
|  |             ArchivesTagLog unbingLog = new ArchivesTagLog(); | ||||
|  |             unbingLog.setTid(tid); | ||||
|  |             unbingLog.setOperType(2); | ||||
|  |             unbingLog.setBindingType(tagType); | ||||
|  |             unbingLog.setTitle(tag.getTitle()); | ||||
|  |             archivesTagLogRepository.save(unbingLog); | ||||
|  |         } | ||||
|  | 
 | ||||
|  |         tag.setTid(tid); | ||||
|  |         tag.setParentsId(parentId); | ||||
|  |         tag.setIsType(labelType); | ||||
|  |         tag.setTitle(title==null?"":title+""); | ||||
|  |         tag = archivesTagRepository.saveAndFlush(tag); | ||||
|  | 
 | ||||
|  |         ArchivesTagLog bingLog = new ArchivesTagLog(); | ||||
|  |         bingLog.setTid(tid); | ||||
|  |         bingLog.setOperType(1); | ||||
|  |         bingLog.setBindingType(labelType); | ||||
|  |         bingLog.setTitle(tag.getTitle()); | ||||
|  |         archivesTagLogRepository.save(bingLog); | ||||
|  |         return returnCount; | ||||
|  |     } | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||
|  |     public Object unbindTag(List<CaseDTO> dtos) { | ||||
|  |         Integer result = 0; | ||||
|  |         for(CaseDTO dto:dtos){ | ||||
|  |             String tid = dto.getTid(); | ||||
|  |             Integer labelType = dto.getLabelType(); | ||||
|  | 
 | ||||
|  |             ArchivesTag tag = archivesTagRepository.findById(tid).get(); | ||||
|  |             ArchivesTagLog unbingLog = new ArchivesTagLog(); | ||||
|  |             unbingLog.setTid(tid); | ||||
|  |             unbingLog.setOperType(2); | ||||
|  |             unbingLog.setBindingType(labelType); | ||||
|  |             unbingLog.setTitle(tag.getTitle()); | ||||
|  | 
 | ||||
|  |             switch (labelType){ | ||||
|  |                 case 1: | ||||
|  |                     ArchivesSummary archivesSummary = archivesSummaryRepository.findFirstByTagNo(tid); | ||||
|  |                     archivesSummaryRepository.unbindTag(tid); | ||||
|  |                     String archivesTable = archivesSummary.getArchivesTableName(); | ||||
|  |                     String sql = "update "+archivesTable+" set tid = null where id = '"+archivesSummary.getArchivesId()+"'"; | ||||
|  |                     result = entityManager.createNativeQuery(sql).executeUpdate(); | ||||
|  |                     archivesTagLogRepository.save(unbingLog); | ||||
|  |                     break; | ||||
|  |                 case 2: | ||||
|  |                     caseRepository.unbindTag(tid); | ||||
|  |                     archivesTagLogRepository.save(unbingLog); | ||||
|  |                     result = 1; | ||||
|  |                     break; | ||||
|  |                 default: | ||||
|  |                     break; | ||||
|  |             } | ||||
|  |             archivesTagRepository.unbindTag(tid); | ||||
|  |             result++; | ||||
|  |         } | ||||
|  |         return result; | ||||
|  |     } | ||||
|  | 
 | ||||
|  | 
 | ||||
| } | } | ||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue