刘力 3 years ago
parent
commit
6bd4cee288
  1. 21
      archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java
  2. 4
      archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java
  3. 8
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java
  4. 2
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java
  5. 4
      archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java
  6. 4
      archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesDTO.java
  7. 20
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java
  8. 70
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
  9. 39
      archives/src/main/java/com/storeroom/modules/dictionary/domain/ArchivesCaseCartoning.java

21
archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java

@ -22,9 +22,9 @@ public class CaseController {
@ApiOperation("档案盒列表")
@GetMapping("/initCaseList")
public ApiResponse<Object> 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<Object> bingdingLabel(
@Validated @RequestBody CaseDTO dto
@ -50,6 +50,21 @@ public class CaseController {
}
}
@ApiOperation("档案盒装盒列表")
@GetMapping("/initCartoningList")
public ApiResponse<Object> 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<Object> cartoning(
@Validated @RequestBody CaseDTO dto
){
return ApiResponse.success(null);
}
}

4
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;

8
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<ArchivesCase, String>{
Page<ArchivesCase> findAllByCaseNameLikeAndTidLike(String caseName, String tid, Pageable page);
Page<ArchivesCase> 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<ArchivesCase> initCartoningList(String caseName, String tid,String barcode,Integer caseType, Pageable page);
Integer countAllByTid(String tid);
@ -16,4 +19,7 @@ public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, Stri
value = "update archives_case set tid = null where tid = ?1")
void unbindTag(String tid);
@Query(nativeQuery = true,
value = "update archives_case set tid ?1 where id = ?2 ")
Integer bindTag(String tid,String archivesId);
}

2
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java

@ -17,7 +17,7 @@ public interface ArchivesSummaryRepository extends JpaRepository<ArchivesSummary
@Query(nativeQuery = true,
value = "update archives_summary set tag_no ?1 where archives_id = ?2 ")
void bindTag(String tid,String archivesId);
Integer bindTag(String tid,String archivesId);
ArchivesSummary findFirstByTagNo(String tagNo);

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

@ -5,13 +5,15 @@ import org.springframework.data.domain.Pageable;
public interface ArchivesCaseService {
//初始化档案盒列表
Object initCaseList(String tid, String caseName, Pageable page);
Object initCaseList(String tid, String caseName,String barcode, Pageable page);
//编辑档案盒信息
Object edit(CaseDTO dto);
//查询该标签是否绑定过
String findIsBingdingLabel(String label);
//添加盒标签
Object addCaseTag(String caseId,String tid,Integer labelType,String bindingCount,String tagType);
//档案盒装盒列表
Object initCartoningList(String tid, String caseName,String barcode,Integer caseType, Pageable page);
}

4
archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesDTO.java

@ -13,6 +13,10 @@ public class ArchivesDTO {
@JsonProperty("id")
private String id;
@JSONField(name="ids")
@JsonProperty("ids")
private String ids;
@JSONField(name="categoryId")
@JsonProperty("categoryId")
private String categoryId;

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

@ -29,10 +29,11 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
EntityManager entityManager;
@Override
public Object initCaseList(String tid, String caseName, Pageable page) {
public Object initCaseList(String tid, String caseName,String barcode, Pageable page) {
tid = StringUtils.isEmpty(tid) ? "%%" : "%"+tid+"%";
caseName = StringUtils.isEmpty(caseName) ? "%%" : "%"+caseName+"%";
Page<ArchivesCase> pageCase = caseRepository.findAllByCaseNameLikeAndTidLike(caseName,tid,page);
barcode = StringUtils.isEmpty(barcode) ? "%%" : "%"+barcode+"%";
Page<ArchivesCase> 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<ArchivesCase> pageCase = caseRepository.initCartoningList(caseName,tid,barcode,caseType,page);
return PageUtil.toPage(pageCase);
}
}

70
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<ArchivesDictionary> showFiled = archivesDictionaryRepository.findAllByCategoryIdAndIsInputOrderByIsSequenceAsc(dto.getCategoryId(),true);
List<String> 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;

39
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;
}
Loading…
Cancel
Save