17 changed files with 677 additions and 30 deletions
-
31archives/src/main/java/com/storeroom/modules/archives/controller/ArrangeController.java
-
82archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java
-
59archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java
-
41archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCaseLog.java
-
52archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCheckBill.java
-
79archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCheckBillDetails.java
-
21archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseLogRepository.java
-
23archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java
-
78archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCheckBillDetailsRepository.java
-
18archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCheckBillRepository.java
-
4archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java
-
13archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java
-
10archives/src/main/java/com/storeroom/modules/archives/service/ArrangeService.java
-
19archives/src/main/java/com/storeroom/modules/archives/service/dto/ArrangeAddDTO.java
-
92archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java
-
16archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
-
69archives/src/main/java/com/storeroom/modules/archives/service/impl/ArrangeServiceImpl.java
@ -0,0 +1,31 @@ |
|||
package com.storeroom.modules.archives.controller; |
|||
|
|||
import com.storeroom.modules.archives.service.ArrangeService; |
|||
import com.storeroom.modules.archives.service.dto.ArrangeAddDTO; |
|||
import com.storeroom.utils.ApiResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "档案盘点") |
|||
@RequestMapping("/api/arrange") |
|||
public class ArrangeController { |
|||
|
|||
private final ArrangeService arrangeService; |
|||
|
|||
@ApiOperation("新增盘点") |
|||
@PostMapping("/addArrange") |
|||
public ApiResponse<Object> addArrange( |
|||
@Validated @RequestBody ArrangeAddDTO dto |
|||
){ |
|||
return ApiResponse.success(arrangeService.addArrange(dto)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,41 @@ |
|||
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_case_log") |
|||
public class ArchivesCaseLog extends BaseEntity implements Serializable { |
|||
|
|||
@Id |
|||
@GeneratedValue(strategy= GenerationType.IDENTITY) |
|||
private Integer id; |
|||
|
|||
@Column(name = "case_id") |
|||
@ApiModelProperty(value = "盒id") |
|||
private String caseId; |
|||
|
|||
@Column(name = "operation_type") |
|||
@ApiModelProperty(value = "操作类型 1.装盒 2.拆盒") |
|||
private Integer operationType; |
|||
|
|||
@Column(name = "case_name") |
|||
@ApiModelProperty(value = "盒名称") |
|||
private String caseName; |
|||
|
|||
@Column(name = "tid") |
|||
@ApiModelProperty(value = "标签id") |
|||
private String tid; |
|||
|
|||
@Column(name = "barcode") |
|||
@ApiModelProperty(value = "条形码") |
|||
private String barcode; |
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
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.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.Id; |
|||
import javax.persistence.Table; |
|||
import java.io.Serializable; |
|||
|
|||
@Entity |
|||
@Getter |
|||
@Setter |
|||
@Table(name = "archives_check_bill") |
|||
public class ArchivesCheckBill extends BaseEntity implements Serializable { |
|||
|
|||
@Id |
|||
@Column(name = "id") |
|||
private String id; |
|||
|
|||
@Column(name = "region") |
|||
@ApiModelProperty(value = "所在区域") |
|||
private String region; |
|||
|
|||
@Column(name = "check_state") |
|||
@ApiModelProperty(value = "0.待执行 1.执行中 2.已执行") |
|||
private Integer checkState; |
|||
|
|||
@Column(name = "correct") |
|||
@ApiModelProperty(value = "在库档案") |
|||
private Integer correct; |
|||
|
|||
@Column(name = "checked") |
|||
@ApiModelProperty(value = "已盘点档案") |
|||
private Integer checked; |
|||
|
|||
@Column(name = "no_check") |
|||
@ApiModelProperty(value = "未盘点档案") |
|||
private Integer noCheck; |
|||
|
|||
@Column(name = "borrowed") |
|||
@ApiModelProperty(value = "已借出档案") |
|||
private Integer borrowed; |
|||
|
|||
@Column(name = "dislocation") |
|||
@ApiModelProperty(value = "错位档案") |
|||
private Integer dislocation; |
|||
|
|||
} |
@ -0,0 +1,79 @@ |
|||
package com.storeroom.modules.archives.domain; |
|||
|
|||
import com.storeroom.base.BaseEntity; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import java.io.Serializable; |
|||
import java.sql.Timestamp; |
|||
|
|||
@Entity |
|||
@Getter |
|||
@Setter |
|||
@Table(name = "archives_check_bill_details") |
|||
public class ArchivesCheckBillDetails implements Serializable { |
|||
|
|||
@Id |
|||
@Column(name = "id") |
|||
private String id; |
|||
|
|||
@Column(name = "bill_id") |
|||
@ApiModelProperty(value = "盘点单id") |
|||
private String billId; |
|||
|
|||
@Column(name = "check_result") |
|||
@ApiModelProperty(value = "盘点结果 0.未盘点 1.在库 2.错位 3.已借") |
|||
private Integer checkResult; |
|||
|
|||
@Column(name = "child") |
|||
@ApiModelProperty(value = "子条目数") |
|||
private Integer child; |
|||
|
|||
@Column(name = "category_type") |
|||
@ApiModelProperty(value = "门类级别") |
|||
private Integer categoryType; |
|||
|
|||
@Column(name = "category_name") |
|||
@ApiModelProperty(value = "门类名称") |
|||
private String categoryName; |
|||
|
|||
@Column(name = "fonds_no") |
|||
@ApiModelProperty(value = "全宗号") |
|||
private String fondsNo; |
|||
|
|||
@Column(name = "archive_no") |
|||
@ApiModelProperty(value = "档号") |
|||
private String archiveNo; |
|||
|
|||
@Column(name = "archive_year") |
|||
@ApiModelProperty(value = "归档年度") |
|||
private Integer archiveYear; |
|||
|
|||
@Column(name = "maintitle") |
|||
@ApiModelProperty(value = "题名") |
|||
private String maintitle; |
|||
|
|||
@Column(name = "security_class") |
|||
@ApiModelProperty(value = "密级") |
|||
private String securityClass; |
|||
|
|||
@Column(name = "department") |
|||
@ApiModelProperty(value = "部门名称") |
|||
private String department; |
|||
|
|||
@Column(name = "case_name") |
|||
@ApiModelProperty(value = "盒名称") |
|||
private String caseName; |
|||
|
|||
@Column(name = "folder_location_details") |
|||
@ApiModelProperty(value = "存放具体位置") |
|||
private String folderLocationDetails; |
|||
|
|||
@Column(name = "create_time") |
|||
@ApiModelProperty(value = "创建时间") |
|||
private Timestamp createTime; |
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.storeroom.modules.archives.repository; |
|||
|
|||
import com.storeroom.modules.archives.domain.ArchivesCaseLog; |
|||
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.Query; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface ArchivesCaseLogRepository extends JpaRepository<ArchivesCaseLog, Integer>{ |
|||
|
|||
@Query(nativeQuery = true, |
|||
value = "select * from archives_case_log " + |
|||
"where if(?1 is null,1=1,operation_type = ?1) " + |
|||
"and if(?2 is null,1=1,case_name like ?2) " + |
|||
"and if(?3 is null,1=1,tid like ?3) " + |
|||
"and if(?4 is null,1=1,barcode like ?4) order by create_time desc") |
|||
Page<ArchivesCaseLog> initCaseLog(Integer operationType, String caseName, String tid, String barcode,Pageable page); |
|||
|
|||
} |
@ -0,0 +1,78 @@ |
|||
package com.storeroom.modules.archives.repository; |
|||
|
|||
import com.storeroom.modules.archives.domain.ArchivesCheckBillDetails; |
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface ArchivesCheckBillDetailsRepository extends JpaRepository<ArchivesCheckBillDetails, String>{ |
|||
|
|||
@Query(nativeQuery = true, |
|||
value = "select replace(uuid(),'-','') as id,?1 as bill_id,(select if(count(1)=0,0,3) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result," + |
|||
"asy.child,asy.category_type,asy.category_name,asy.fonds_no," + |
|||
"asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class," + |
|||
"asy.department,asy.case_name,asy.folder_location_details,asy.create_time " + |
|||
"from archives_summary asy where " + |
|||
"asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc " + |
|||
"inner join archives_case ace on acc.case_id = ace.id " + |
|||
"inner join device_archives_tag dat on ace.folder_location = dat.position) ") |
|||
List<ArchivesCheckBillDetails> findDetailsAll(String billId); |
|||
|
|||
@Query(nativeQuery = true, |
|||
countQuery = "select count(1) from archives_summary asy where " + |
|||
"asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc " + |
|||
"inner join archives_case ace on acc.case_id = ace.id " + |
|||
"inner join device_archives_tag dat on ace.folder_location = dat.position where if(?1 is null,1=1,dat.device_info_id in ?1)) ", |
|||
value = "select null as id,asy.child,asy.category_type as categoryType,asy.category_name as categoryName,asy.fonds_no as fondsNo," + |
|||
"?2 as billId,(select if(count(1)=0,0,3) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as checkResult," + |
|||
"asy.archive_no as archiveNo,asy.archive_year as archiveYear,asy.maintitle,asy.security_class as securityClass,asy.department,asy.case_name as caseName," + |
|||
"asy.folder_location_details as folderLocationDetails,asy.create_time as createTime from archives_summary asy " + |
|||
"where " + |
|||
"asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc " + |
|||
"inner join archives_case ace on acc.case_id = ace.id " + |
|||
"inner join device_archives_tag dat on ace.folder_location = dat.position where if(?1 is null,1=1,dat.device_info_id in ?1)) " + |
|||
"order by create_time desc") |
|||
List<ArchivesCheckBillDetails> findDetailsAllByDeviceId(List<String> deviceIds,String billId); |
|||
|
|||
@Query(nativeQuery = true, |
|||
countQuery = "select count(1) from archives_summary asy where" + |
|||
"if(?1 is null,1=1,category_id in ?1) and " + |
|||
"asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc " + |
|||
"inner join archives_case ace on acc.case_id = ace.id " + |
|||
"inner join device_archives_tag dat on ace.folder_location = dat.position) ", |
|||
value = "select null as id,asy.child,asy.category_type as categoryType,asy.category_name as categoryName,asy.fonds_no as fondsNo," + |
|||
"?2 as billId,(select if(count(1)=0,0,3) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as checkResult," + |
|||
"asy.archive_no as archiveNo,asy.archive_year as archiveYear,asy.maintitle,asy.security_class as securityClass,asy.department,asy.case_name as caseName," + |
|||
"asy.folder_location_details as folderLocationDetails,asy.create_time as createTime from archives_summary asy " + |
|||
"where " + |
|||
"if(?1 is null,1=1,category_id in ?1) and " + |
|||
"asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc " + |
|||
"inner join archives_case ace on acc.case_id = ace.id " + |
|||
"inner join device_archives_tag dat on ace.folder_location = dat.position) " + |
|||
"order by create_time desc") |
|||
List<ArchivesCheckBillDetails> findDetailsAllByCategoryId(List<String> categroyIds,String billId); |
|||
|
|||
@Query(nativeQuery = true, |
|||
countQuery = "select count(1) from archives_summary asy where" + |
|||
"if(?2 is null,1=1,category_id in ?2) and " + |
|||
"asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc " + |
|||
"inner join archives_case ace on acc.case_id = ace.id " + |
|||
"inner join device_archives_tag dat on ace.folder_location = dat.position where if(?1 is null,1=1,dat.device_info_id in ?1)) ", |
|||
value = "select null as id,asy.child,asy.category_type as categoryType,asy.category_name as categoryName,asy.fonds_no as fondsNo," + |
|||
"?3 as billId,(select if(count(1)=0,0,3) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as checkResult," + |
|||
"asy.archive_no as archiveNo,asy.archive_year as archiveYear,asy.maintitle,asy.security_class as securityClass,asy.department,asy.case_name as caseName," + |
|||
"asy.folder_location_details as folderLocationDetails,asy.create_time as createTime from archives_summary asy " + |
|||
"where " + |
|||
"if(?2 is null,1=1,category_id in ?2) and " + |
|||
"asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc " + |
|||
"inner join archives_case ace on acc.case_id = ace.id " + |
|||
"inner join device_archives_tag dat on ace.folder_location = dat.position where if(?1 is null,1=1,dat.device_info_id in ?1)) " + |
|||
"order by create_time desc") |
|||
List<ArchivesCheckBillDetails> findDetailsAllByDeviceIdAndCategoryId(List<String> deviceIds,List<String> categroyIds,String billId); |
|||
|
|||
@Query(nativeQuery = true, |
|||
value = "select count(1) from archives_check_bill_details where check_result = 3 ") |
|||
Integer findBorrowCountByOrderId(String orderIds); |
|||
|
|||
} |
@ -0,0 +1,18 @@ |
|||
package com.storeroom.modules.archives.repository; |
|||
|
|||
import com.storeroom.modules.archives.domain.ArchivesCheckBill; |
|||
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.Query; |
|||
|
|||
public interface ArchivesCheckBillRepository extends JpaRepository<ArchivesCheckBill, String>{ |
|||
|
|||
@Query(nativeQuery = true, |
|||
value = "select CONCAT ('PD', DATE_FORMAT(now(), '%Y%m%d'),RIGHT(CONCAT " + |
|||
"('00000' , ifnull(max(SUBSTR(id, LENGTH(CONCAT('JY',DATE_FORMAT(now(), '%Y%m%d'))) + 1," + |
|||
"LENGTH(id) - LENGTH(CONCAT ('JY' , DATE_FORMAT(now(), '%Y%m%d'))))) + 1, 1)), 5)) AS id " + |
|||
"from archives_check_bill where SUBSTR(id, 3, 8)=substr(DATE_FORMAT(now(),'%Y%m%d') , 1, 8)") |
|||
String getOrderId(); |
|||
|
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.storeroom.modules.archives.service; |
|||
|
|||
import com.storeroom.modules.archives.service.dto.ArrangeAddDTO; |
|||
|
|||
public interface ArrangeService { |
|||
|
|||
//新增盘点 |
|||
Object addArrange(ArrangeAddDTO dto); |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.storeroom.modules.archives.service.dto; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Getter |
|||
@Setter |
|||
public class ArrangeAddDTO { |
|||
|
|||
//设备id集合 |
|||
private List<String> deviceIds; |
|||
//门类id集合 |
|||
private List<String> categoryIds; |
|||
//所属区域 |
|||
private String region; |
|||
|
|||
} |
@ -0,0 +1,69 @@ |
|||
package com.storeroom.modules.archives.service.impl; |
|||
|
|||
import com.storeroom.modules.archives.domain.ArchivesCheckBill; |
|||
import com.storeroom.modules.archives.domain.ArchivesCheckBillDetails; |
|||
import com.storeroom.modules.archives.repository.ArchivesCheckBillDetailsRepository; |
|||
import com.storeroom.modules.archives.repository.ArchivesCheckBillRepository; |
|||
import com.storeroom.modules.archives.service.ArrangeService; |
|||
import com.storeroom.modules.archives.service.dto.ArrangeAddDTO; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.transaction.Transactional; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ArrangeServiceImpl implements ArrangeService { |
|||
|
|||
private final ArchivesCheckBillRepository archivesCheckBillRepository; |
|||
private final ArchivesCheckBillDetailsRepository archivesCheckBillDetailsRepository; |
|||
|
|||
@Override |
|||
@Transactional |
|||
public Object addArrange(ArrangeAddDTO dto) { |
|||
ArchivesCheckBill bill = this.createBill(dto.getRegion(),0); |
|||
//未成功生成清单 |
|||
if(null == bill) |
|||
return null; |
|||
//获取相关在库档案信息 |
|||
List<ArchivesCheckBillDetails> checkDetaills = null; |
|||
if(null != dto.getDeviceIds() && dto.getDeviceIds().size() !=0 && null != dto.getCategoryIds() && dto.getCategoryIds().size() !=0){ |
|||
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAllByDeviceIdAndCategoryId(dto.getDeviceIds(),dto.getCategoryIds(),dto.getRegion()); |
|||
}else if(null != dto.getDeviceIds() && dto.getDeviceIds().size() != 0){ |
|||
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAllByDeviceId(dto.getDeviceIds(),dto.getRegion()); |
|||
}else if(null != dto.getCategoryIds() && dto.getCategoryIds().size() != 0){ |
|||
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAllByCategoryId(dto.getCategoryIds(),dto.getRegion()); |
|||
}else{ |
|||
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAll(dto.getRegion()); |
|||
} |
|||
|
|||
checkDetaills = archivesCheckBillDetailsRepository.saveAll(checkDetaills); |
|||
bill.setBorrowed(archivesCheckBillDetailsRepository.findBorrowCountByOrderId(bill.getId())); |
|||
return bill; |
|||
} |
|||
|
|||
|
|||
|
|||
//生成清单 |
|||
public ArchivesCheckBill createBill(String region,Integer loop){ |
|||
ArchivesCheckBill bill = null; |
|||
try { |
|||
bill = new ArchivesCheckBill(); |
|||
bill.setId(archivesCheckBillRepository.getOrderId()); |
|||
bill.setCheckState(0); |
|||
bill.setRegion(region); |
|||
bill.setCorrect(0); |
|||
bill.setChecked(0); |
|||
bill.setNoCheck(0); |
|||
bill.setBorrowed(0); |
|||
bill.setDislocation(0); |
|||
}catch (Exception e){ |
|||
if(loop==4) |
|||
return null; |
|||
bill = this.createBill(region,loop); |
|||
} |
|||
return bill; |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue