diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java index e3dd405..78b0092 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java +++ b/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java @@ -22,9 +22,9 @@ public class CaseController { @ApiOperation("档案盒列表") @GetMapping("/initCaseList") public ApiResponse initCaseList( - String tid, String caseName, Pageable page + String tid, String caseName,String barcode, Pageable page ){ - return ApiResponse.success(caseService.initCaseList(tid,caseName,page)); + return ApiResponse.success(caseService.initCaseList(tid,caseName,barcode,page)); } @ApiOperation("档案盒编辑") @@ -35,7 +35,7 @@ public class CaseController { return ApiResponse.success(caseService.edit(dto)); } - @ApiOperation("档案盒绑定标签") + @ApiOperation("绑定标签") @PostMapping("/bingdingLabel") public ApiResponse bingdingLabel( @Validated @RequestBody CaseDTO dto @@ -50,6 +50,21 @@ public class CaseController { } } + @ApiOperation("档案盒装盒列表") + @GetMapping("/initCartoningList") + public ApiResponse initCartoningList( + String tid, String caseName,String barcode,Integer caseType, Pageable page + ){ + return ApiResponse.success(caseService.initCartoningList(tid,caseName,barcode,caseType,page)); + } + + @ApiOperation("装盒") + @PostMapping("/cartoning") + public ApiResponse cartoning( + @Validated @RequestBody CaseDTO dto + ){ + return ApiResponse.success(null); + } } diff --git a/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java b/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java index 85e83e8..ca9a19f 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java +++ b/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java @@ -33,6 +33,10 @@ public class ArchivesCase extends BaseEntity implements Serializable { @ApiModelProperty(value = "盒标签") private String tid; + @Column(name = "barcode") + @ApiModelProperty(value = "条形码") + private String barcode; + @Column(name = "folder_location") @ApiModelProperty(value = "存放位置") private String folderLocation; diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java index 2b56a15..64a50c3 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java +++ b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java @@ -8,7 +8,10 @@ import org.springframework.data.jpa.repository.Query; public interface ArchivesCaseRepository extends JpaRepository{ - Page findAllByCaseNameLikeAndTidLike(String caseName, String tid, Pageable page); + Page findAllByCaseNameLikeAndTidLikeAndBarcodeLike(String caseName, String tid,String barcode, Pageable page); + + @Query(" from ArchivesCase where caseType in (0,?4) and caseName like ?1 and tid like ?2 and barcode like ?3") + Page initCartoningList(String caseName, String tid,String barcode,Integer caseType, Pageable page); Integer countAllByTid(String tid); @@ -16,4 +19,7 @@ public interface ArchivesCaseRepository extends JpaRepository pageCase = caseRepository.findAllByCaseNameLikeAndTidLike(caseName,tid,page); + barcode = StringUtils.isEmpty(barcode) ? "%%" : "%"+barcode+"%"; + Page pageCase = caseRepository.findAllByCaseNameLikeAndTidLikeAndBarcodeLike(caseName,tid,barcode,page); return PageUtil.toPage(pageCase); } @@ -71,6 +72,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { @Transactional(rollbackFor = Exception.class) public Object addCaseTag(String caseId, String tid,Integer labelType, String bindingCount,String tagType) { String archivesTable = ""; + Integer returnCount = 0; //若标签已绑定 先解绑 if(!"0".equals(bindingCount)){ switch (tagType){ @@ -92,8 +94,11 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { switch (labelType){ case 1: archivesSummaryRepository.bindTag(tid,caseId); + String sql = "update "+archivesTable+" set tid = null where id = '"+caseId+"'"; + returnCount = entityManager.createNativeQuery(sql).executeUpdate(); break; case 2: + returnCount = caseRepository.bindTag(tid,caseId); break; case 3: break; @@ -102,6 +107,15 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { } } - return null; + return returnCount; + } + + @Override + public Object initCartoningList(String tid, String caseName, String barcode, Integer caseType, Pageable page) { + tid = StringUtils.isEmpty(tid) ? "%%" : "%"+tid+"%"; + caseName = StringUtils.isEmpty(caseName) ? "%%" : "%"+caseName+"%"; + barcode = StringUtils.isEmpty(barcode) ? "%%" : "%"+barcode+"%"; + Page pageCase = caseRepository.initCartoningList(caseName,tid,barcode,caseType,page); + return PageUtil.toPage(pageCase); } } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java index 5c7f3f2..6d45486 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java @@ -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 showFiled = archivesDictionaryRepository.findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(dto.getCategoryId(),true); + List 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; diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/domain/ArchivesCaseCartoning.java b/archives/src/main/java/com/storeroom/modules/dictionary/domain/ArchivesCaseCartoning.java new file mode 100644 index 0000000..5eebaae --- /dev/null +++ b/archives/src/main/java/com/storeroom/modules/dictionary/domain/ArchivesCaseCartoning.java @@ -0,0 +1,39 @@ +package com.storeroom.modules.dictionary.domain; + +import com.storeroom.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Entity +@Getter +@Setter +@Table(name = "archives_case_cartoning") +public class ArchivesCaseCartoning extends BaseEntity implements Serializable { + + @Id + @Column(name = "id") + @NotNull(groups = BaseEntity.Update.class) + @ApiModelProperty(value = "ID", hidden = true) + private String id; + + @ApiModelProperty(value = "档案id") + @Column(name = "archives_id") + private String archivesId; + + @ApiModelProperty(value = "盒id") + @Column(name = "case_id") + private String caseId; + + @ApiModelProperty(value = "门类id") + @Column(name = "category_id") + private String categoryId; + +}