Browse Source

1.盘点模块更新

2.优化其他模块功能
master
xia 3 years ago
parent
commit
0d32901416
  1. 71
      archives/src/main/java/com/storeroom/modules/archives/controller/ArrangeController.java
  2. 2
      archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java
  3. 2
      archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java
  4. 4
      archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java
  5. 6
      archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java
  6. 2
      archives/src/main/java/com/storeroom/modules/archives/controller/TagController.java
  7. 8
      archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCheckBillData.java
  8. 9
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java
  9. 11
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCheckBillDataRepository.java
  10. 28
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCheckBillDetailsRepository.java
  11. 2
      archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java
  12. 9
      archives/src/main/java/com/storeroom/modules/archives/service/ArrangeService.java
  13. 12
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java
  14. 123
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArrangeServiceImpl.java
  15. 133
      archives/src/main/java/com/storeroom/modules/common/ExcelUtil.java
  16. 3
      archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesTypeRepository.java
  17. 2
      archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java
  18. 41
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

71
archives/src/main/java/com/storeroom/modules/archives/controller/ArrangeController.java

@ -1,21 +1,37 @@
package com.storeroom.modules.archives.controller;
import com.storeroom.annotaion.rest.AnonymousGetMapping;
import com.storeroom.modules.archives.domain.ArchivesCheckBill;
import com.storeroom.modules.archives.domain.ArchivesCheckBillDetails;
import com.storeroom.modules.archives.domain.vo.BorrowBillDetailsVO;
import com.storeroom.modules.archives.service.ArrangeService;
import com.storeroom.modules.archives.service.dto.ArrangeAddDTO;
import com.storeroom.modules.common.ExcelUtil;
import com.storeroom.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@RestController
@RequiredArgsConstructor
@Api(tags = "档案盘点")
@RequestMapping("/api/arrange")
public class ArrangeController {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
private final ArrangeService arrangeService;
@ApiOperation("新增盘点")
@ -50,7 +66,7 @@ public class ArrangeController {
return ApiResponse.success(arrangeService.getArrangeDetailes(orderNo,checkResult,page));
}
@ApiOperation("新增盘点")
@ApiOperation("结算盘点")
@PostMapping("/settlement")
public ApiResponse<Object> settlement(
@Validated @RequestBody String orderId
@ -58,4 +74,57 @@ public class ArrangeController {
return ApiResponse.success(arrangeService.settlement(orderId));
}
@ApiOperation("清空完结盘点缓存数据")
@PostMapping("/clean")
public ApiResponse<Object> clean()
{
Date date = new Date();
Timestamp time = new Timestamp(date.getTime());
System.out.println(time);
arrangeService.clean();
return ApiResponse.success(null);
}
@ApiOperation("删除盘点")
@PostMapping("/del")
public ApiResponse<Object> del(
@Validated @RequestBody List<String> orderIds
){
//筛选盘点信息
List<ArchivesCheckBill> bills = arrangeService.findBillsByOrderIds(orderIds);
List<String> delOrderNos = new ArrayList<>();
for(ArchivesCheckBill bill:bills){
if(bill.getCheckState() == 0)
delOrderNos.add(bill.getId());
}
if(delOrderNos.size()!=0)
arrangeService.delBills(delOrderNos);
return ApiResponse.success(delOrderNos.size());
}
@ApiOperation("导出盘点信息")
@AnonymousGetMapping("/exportArrange")
@ResponseBody
public void exportBorrow(
HttpServletResponse response,
@RequestParam("orderNo") String orderNo
){
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
ArchivesCheckBill bill = arrangeService.getArrange(orderNo);
List<ArchivesCheckBillDetails> billDetails = arrangeService.findDetailsAllByOrderNo(orderNo);
XSSFWorkbook wb = ExcelUtil.createArrangeExcel("盘点信息",bill,billDetails);
try {
ExcelUtil.setResponseHeader(response, "借还记录"+format.format(new Date()));
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

2
archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java

@ -249,7 +249,7 @@ public class BorrowController {
bills.removeAll(Collections.singleton(null));
XSSFWorkbook wb = ExcelUtil.createBorrowerExcel("借还记录",bills);
try {
ExcelUtil.setResponseHeader(response, "借还记录"+format.format(new Date())+".xls");
ExcelUtil.setResponseHeader(response, "借还记录"+format.format(new Date()));
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();

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

@ -200,7 +200,7 @@ public class CaseController {
}
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("sheet",Etitle,content,null);
try {
ExcelUtil.setResponseHeader(response, "档案盒记录"+format.format(new Date())+".xls");
ExcelUtil.setResponseHeader(response, "档案盒记录"+format.format(new Date()));
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();

4
archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java

@ -295,7 +295,7 @@ public class RFIDController {
return ApiResponse.success(borrowService.archivesReturnConfirm(rbIds));
}
@ApiOperation("根据单据查看详情")
@ApiOperation("根据借阅单据查看详情")
@AnonymousGetMapping("/initBillDetailsByOrderNo")
public ApiResponse<Object> initBillDetailsByOrderNo(
String orderNo
@ -314,7 +314,7 @@ public class RFIDController {
@ApiOperation("手持机提交盘点数据")
@AnonymousPostMapping("/arrangeDataCommit")
public ApiResponse<Object> arrangeDataCommit(
List<ArchivesCheckBillData> datas
@Validated @RequestBody List<ArchivesCheckBillData> datas
){
return ApiResponse.success(arrangeService.addArrangeData(datas));
}

6
archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java

@ -164,6 +164,10 @@ public class StorageController {
public ApiResponse<Object> grant(
@Validated @RequestBody List<String> caseIds
){
//判断已借出的盒
List<String> borrowCase = caseService.findBorrowCase(caseIds);
caseIds.removeAll(borrowCase);
List<String> caseIdAll = caseService.findCaseIdAllByCaseIds(caseIds);
Map<String,DeviceInfoDto> devices = caseService.findDevicesByCaseIds(caseIdAll);
for(String caseId:caseIdAll){
@ -361,7 +365,7 @@ public class StorageController {
}
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("sheet",Etitle,content,null);
try {
ExcelUtil.setResponseHeader(response, "出入库记录"+format.format(new Date())+".xls");
ExcelUtil.setResponseHeader(response, "出入库记录"+format.format(new Date()));
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();

2
archives/src/main/java/com/storeroom/modules/archives/controller/TagController.java

@ -99,7 +99,7 @@ public class TagController {
}
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("sheet",Etitle,content,null);
try {
ExcelUtil.setResponseHeader(response, "标签使用记录"+format.format(new Date())+".xls");
ExcelUtil.setResponseHeader(response, "标签使用记录"+format.format(new Date()));
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();

8
archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCheckBillData.java

@ -1,12 +1,14 @@
package com.storeroom.modules.archives.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.io.Serializable;
@ -36,11 +38,17 @@ public class ArchivesCheckBillData implements Serializable {
@ApiModelProperty(value = "盒名称")
private String archivesId;
@Column(name = "shelf_id")
@ApiModelProperty(value = "盒名称")
private String shelfId;
@Column(name = "check_result")
@ApiModelProperty(value = "盘点结果")
private Integer checkResult;
@Column(name = "create_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@ApiModelProperty(value = "手持机盘点时间")
private Timestamp createTime;
}

9
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java

@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.beans.IntrospectionException;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -40,7 +41,8 @@ public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, Stri
value = "SELECT distinct asum.archives_id as archivesId,ace.storage_type as storageType,asum.child as child,asum.category_type as categoryType," +
"asum.category_name as categoryName,asum.fonds_no as fondsNo,asum.archive_no as archiveNo,asum.archive_year as archiveYear," +
"asum.maintitle as maintitle,asum.security_class as securityClass,asum.department as department,ace.case_name as caseName," +
"CONCAT(room.name ,'-' , di.device_name , '-' , dat.position_name) as seat,ace.storage_time as storageTime " +
"CONCAT(room.name ,'-' , di.device_name , '-' , dat.position_name) as seat,ace.storage_time as storageTime" +
// ",(select borrow_type from borrow_archives ba where ba.archives_id = asum.archives_id order by create_time desc limit 0,1) as borrowType " +
"FROM archives_case ace " +
"INNER JOIN archives_case_cartoning acc ON ace.id = acc.case_id " +
"INNER JOIN archives_summary asum ON acc.parent_id = asum.archives_id " +
@ -130,4 +132,9 @@ public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, Stri
"INNER JOIN device_info di ON dat.device_info_id = di.id " +
"INNER JOIN storeroom room ON room.id = di.storeroom_id WHERE ace.id = ?1 ")
String findLocationDetailsByCaseId(String caseId);
@Query(nativeQuery = true,
value = "select borrow_type from borrow_archives ba where ba.archives_id in (select parent_id " +
"from archives_case_cartoning acc where acc.case_id = ?1) order by create_time desc limit 0,1 ")
Integer findBorrowCase(String caseId);
}

11
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCheckBillDataRepository.java

@ -11,7 +11,16 @@ import java.util.List;
public interface ArchivesCheckBillDataRepository extends JpaRepository<ArchivesCheckBillData, String>{
@Query(value = "from ArchivesCheckBillData where billId = ?1 order by createTime desc ")
@Query(nativeQuery = true ,
value = "select DISTINCT t1.archives_id,t1.id,t1.bill_id,t1.shelf_id,t1.check_result,t1.rfid,t1.create_time " +
"from archives_check_bill_data t1 inner join (select archives_id,max(create_time) as create_time from " +
"archives_check_bill_data where bill_id = ?1 group by archives_id) t2 " +
"on t1.archives_id = t2.archives_id where t1.create_time = t2.create_time and bill_id =?1 order by t1.create_time desc ")
List<ArchivesCheckBillData> findByOrderId(String orderId);
@Modifying
@Query(nativeQuery = true,
value = "delete from archives_check_bill_data where bill_id in (select id from archives_check_bill where check_state = 2)")
void clean();
}

28
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCheckBillDetailsRepository.java

@ -4,6 +4,7 @@ import com.storeroom.modules.archives.domain.ArchivesCheckBillDetails;
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;
import java.util.List;
@ -12,7 +13,7 @@ import java.util.Map;
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," +
value = "select replace(uuid(),'-','') as id,?1 as bill_id,(select if(count(1)=0,0,4) 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.shelf_id,asy.fonds_no,asy.archives_id," +
"asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class," +
"asy.department,asy.case_name,asy.folder_location_details,asy.create_time " +
@ -23,24 +24,24 @@ public interface ArchivesCheckBillDetailsRepository extends JpaRepository<Archiv
List<ArchivesCheckBillDetails> findDetailsAll(String billId);
@Query(nativeQuery = true,
value = "select replace(uuid(),'-','') as id,?2 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," +
value = "select replace(uuid(),'-','') as id,?2 as bill_id,(select if(count(1)=0,0,4) 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.shelf_id,asy.fonds_no,asy.archives_id," +
"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 where if(?1 is null,1=1,dat.device_info_id in ?1)) " +
"inner join device_archives_tag dat on ace.folder_location = dat.position where dat.device_info_id in ?1) " +
"order by create_time desc")
List<ArchivesCheckBillDetails> findDetailsAllByDeviceId(List<String> deviceIds,String billId);
@Query(nativeQuery = true,
value = "select replace(uuid(),'-','') as id,?2 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," +
value = "select replace(uuid(),'-','') as id,?2 as bill_id,(select if(count(1)=0,0,4) 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.shelf_id,asy.fonds_no,asy.archives_id," +
"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 " +
"if(?1 is null,1=1,category_id in ?1) and " +
"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) " +
@ -48,21 +49,21 @@ public interface ArchivesCheckBillDetailsRepository extends JpaRepository<Archiv
List<ArchivesCheckBillDetails> findDetailsAllByCategoryId(List<String> categroyIds,String billId);
@Query(nativeQuery = true,
value = "select replace(uuid(),'-','') as id,?3 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," +
value = "select replace(uuid(),'-','') as id,?3 as bill_id,(select if(count(1)=0,0,4) 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.shelf_id,asy.fonds_no,asy.archives_id," +
"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 " +
"if(?2 is null,1=1,category_id in ?2) and " +
"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)) " +
"inner join device_archives_tag dat on ace.folder_location = dat.position where 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 and bill_id = ?1 ")
Integer findBorrowCountByOrderId(String orderIds);
value = "select count(1) from archives_check_bill_details where check_result = ?2 and bill_id = ?1 ")
Integer findResultCountByOrderId(String orderIds,Integer checkResult);
@Query(nativeQuery = true,
value = "select * from archives_check_bill_details where bill_id = ?1 " +
@ -73,4 +74,11 @@ public interface ArchivesCheckBillDetailsRepository extends JpaRepository<Archiv
value = "select id as checkId,bill_id as billId,check_result as checkResult,archives_id as archivesId from archives_check_bill_details where bill_id = ?1 ")
List<Map<String,Object>> getArrangeDetailesAllToRFID(String orderNo);
@Query("from ArchivesCheckBillDetails where billId = ?1")
List<ArchivesCheckBillDetails> getArrangeDetailesAll(String orderNo);
@Modifying
@Query("delete from ArchivesCheckBillDetails where billId in ?1")
void deleteByOrderIds(List<String> orderNos);
}

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

@ -42,6 +42,8 @@ public interface ArchivesCaseService {
void batchDelCase(List<ArchivesCase> doDel);
//初始化档案盒日志
Object initCaseLog(Integer operationType,String caseName,String tid,String barcode,Pageable page);
//判断已借出的盒
List<String> findBorrowCase(List<String> caseIds);
//设备删除 设备内是否有档案
Boolean isHaveArchives(List<String> deviceId);

9
archives/src/main/java/com/storeroom/modules/archives/service/ArrangeService.java

@ -2,6 +2,7 @@ package com.storeroom.modules.archives.service;
import com.storeroom.modules.archives.domain.ArchivesCheckBill;
import com.storeroom.modules.archives.domain.ArchivesCheckBillData;
import com.storeroom.modules.archives.domain.ArchivesCheckBillDetails;
import com.storeroom.modules.archives.service.dto.ArrangeAddDTO;
import org.springframework.data.domain.Pageable;
@ -23,5 +24,13 @@ public interface ArrangeService {
Object addArrangeData(List<ArchivesCheckBillData> datas);
//结算
Object settlement(String orderId);
//清空已结算盘点缓存数据
void clean();
//根据单据号集合查询单据集合
List<ArchivesCheckBill> findBillsByOrderIds(List<String> orderNos);
//删除盘点清单
void delBills(List<String> orderNos);
//根据盘点单号获取所有盘点档案
List<ArchivesCheckBillDetails> findDetailsAllByOrderNo(String orderNo);
}

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

@ -450,6 +450,18 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
return PageUtil.toPage(archivesCaseLogRepository.initCaseLog(operationType,caseName,tid,barcode,page));
}
@Override
public List<String> findBorrowCase(List<String> caseIds) {
List<String> r = new ArrayList();
for(String caseId:caseIds){
Integer borrowType = caseRepository.findBorrowCase(caseId);
if(null != borrowType && borrowType != 4){
r.add(caseId);
}
}
return r;
}
@Override
public Boolean isHaveArchives(List<String> deviceId) {
Integer count = caseRepository.isHaveArchives(deviceId);

123
archives/src/main/java/com/storeroom/modules/archives/service/impl/ArrangeServiceImpl.java

@ -8,6 +8,9 @@ import com.storeroom.modules.archives.repository.ArchivesCheckBillDetailsReposit
import com.storeroom.modules.archives.repository.ArchivesCheckBillRepository;
import com.storeroom.modules.archives.service.ArrangeService;
import com.storeroom.modules.archives.service.dto.ArrangeAddDTO;
import com.storeroom.modules.common.ArchivesTypeEnum;
import com.storeroom.modules.dictionary.service.ArchivesTypeService;
import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import com.storeroom.utils.PageUtil;
import com.storeroom.utils.StringUtils;
import lombok.RequiredArgsConstructor;
@ -15,13 +18,13 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
@RequiredArgsConstructor
public class ArrangeServiceImpl implements ArrangeService {
private final ArchivesTypeService archivesTypeService;
private final ArchivesCheckBillRepository archivesCheckBillRepository;
private final ArchivesCheckBillDetailsRepository archivesCheckBillDetailsRepository;
private final ArchivesCheckBillDataRepository archivesCheckBillDataRepository;
@ -29,18 +32,27 @@ public class ArrangeServiceImpl implements ArrangeService {
@Override
@Transactional
public Object addArrange(ArrangeAddDTO dto) {
List<String> categoryIds = new ArrayList<>();
if(null!= dto.getCategoryIds() && dto.getCategoryIds().size()!=0){
//根据门类id获取旗下所有文件集案卷级档案
Set<ArchivesTypeDTO> dtos = archivesTypeService.findArchivesTypeByIds(dto.getCategoryIds());
for(ArchivesTypeDTO archivesTypeDTO : dtos){
if(archivesTypeDTO.getIsType()== ArchivesTypeEnum.archives.getCode() || archivesTypeDTO.getIsType()== ArchivesTypeEnum.files.getCode())
categoryIds.add(archivesTypeDTO.getId());
}
}
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(),bill.getId());
if(null != dto.getDeviceIds() && dto.getDeviceIds().size() !=0 && categoryIds.size() !=0){
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAllByDeviceIdAndCategoryId(dto.getDeviceIds(),categoryIds,bill.getId());
}else if(null != dto.getDeviceIds() && dto.getDeviceIds().size() != 0){
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAllByDeviceId(dto.getDeviceIds(),bill.getId());
}else if(null != dto.getCategoryIds() && dto.getCategoryIds().size() != 0){
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAllByCategoryId(dto.getCategoryIds(),bill.getId());
}else if(categoryIds.size() != 0){
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAllByCategoryId(categoryIds,bill.getId());
}else{
checkDetaills = archivesCheckBillDetailsRepository.findDetailsAll(bill.getId());
}
@ -66,7 +78,7 @@ public class ArrangeServiceImpl implements ArrangeService {
saveDetaills.add(details);
}
saveDetaills = archivesCheckBillDetailsRepository.saveAll(saveDetaills);
bill.setBorrowed(archivesCheckBillDetailsRepository.findBorrowCountByOrderId(bill.getId()));
bill.setBorrowed(archivesCheckBillDetailsRepository.findResultCountByOrderId(bill.getId(),4));
archivesCheckBillRepository.saveAndFlush(bill);
return bill;
}
@ -105,11 +117,100 @@ public class ArrangeServiceImpl implements ArrangeService {
}
@Override
public Object settlement(String orderId) {
public Object settlement(String orderNo) {
Integer correct = 0;//在库
Integer checked = 0;//已盘
Integer noCheck = 0;//未盘
Integer borrowed = 0;//已借
Integer dislocation = 0;//错位
Integer abnormal = 0;//异常
Integer others = 0;//其他
//获取手持机盘点数据
List<ArchivesCheckBillData> datas = archivesCheckBillDataRepository.findByOrderId(orderId);
return null;
List<ArchivesCheckBillData> datas = archivesCheckBillDataRepository.findByOrderId(orderNo);
checked = datas.size();
List<ArchivesCheckBillDetails> details = archivesCheckBillDetailsRepository.getArrangeDetailesAll(orderNo);
Map<String,ArchivesCheckBillDetails> kv = new HashMap<>();
//将需要盘点的数据放进map 方便盘点对比
for(ArchivesCheckBillDetails thisDetails:details){
if(!kv.containsKey(thisDetails.getArchivesId())){
kv.put(thisDetails.getArchivesId(),thisDetails);
}
}
//保存需要更新的数据
Set<ArchivesCheckBillDetails> set = new HashSet();
//对比
for(ArchivesCheckBillData data : datas){
//根据上传数据获取该档案信息
ArchivesCheckBillDetails thisDetails = kv.get(data.getArchivesId());
//当上传档案在清单内
if(null != thisDetails){
if(StringUtils.isEmpty(data.getShelfId())){
//如果此档案为已借
if(thisDetails.getCheckResult() == 4){
thisDetails.setCheckResult(5);
abnormal++;
//否则为正常
}else{
thisDetails.setCheckResult(1);
correct++;
}
}else{
if(thisDetails.getCheckResult() == 4){
thisDetails.setCheckResult(5);
abnormal++;
//在应该在的层架位上
}else if(null != thisDetails.getShelfId() && thisDetails.getShelfId().contains(data.getShelfId())){
thisDetails.setCheckResult(1);
correct++;
}else{
thisDetails.setCheckResult(3);
dislocation++;
}
}
//当上传档案不在清单内
}else{
others++;
}
set.add(thisDetails);
}
List<ArchivesCheckBillDetails> newDetails = archivesCheckBillDetailsRepository.saveAllAndFlush(set);
noCheck = archivesCheckBillDetailsRepository.findResultCountByOrderId(orderNo,0);
borrowed = archivesCheckBillDetailsRepository.findResultCountByOrderId(orderNo,4);
ArchivesCheckBill bill = archivesCheckBillRepository.findBillById(orderNo);
bill.setCorrect(correct);
bill.setChecked(checked);
bill.setOthers(others);
bill.setAbnormal(abnormal);
bill.setDislocation(dislocation);
bill.setNoCheck(noCheck);
bill.setBorrowed(borrowed);
bill.setCheckState(2);
return archivesCheckBillRepository.saveAndFlush(bill);
}
@Override
@Transactional
public void clean() {
archivesCheckBillDataRepository.clean();
}
@Override
public List<ArchivesCheckBill> findBillsByOrderIds(List<String> orderNos) {
return archivesCheckBillRepository.findAllById(orderNos);
}
@Override
@Transactional
public void delBills(List<String> orderNos) {
//删除盘点档案信息
archivesCheckBillDetailsRepository.deleteByOrderIds(orderNos);
//删除盘点信息
archivesCheckBillRepository.deleteAllById(orderNos);
}
@Override
public List<ArchivesCheckBillDetails> findDetailsAllByOrderNo(String orderNo) {
return archivesCheckBillDetailsRepository.getArrangeDetailesAll(orderNo);
}
//生成清单

133
archives/src/main/java/com/storeroom/modules/common/ExcelUtil.java

@ -1,7 +1,10 @@
package com.storeroom.modules.common;
import com.storeroom.modules.archives.domain.ArchivesCheckBill;
import com.storeroom.modules.archives.domain.ArchivesCheckBillDetails;
import com.storeroom.modules.archives.domain.BorrowArchives;
import com.storeroom.modules.archives.domain.vo.BorrowBillDetailsVO;
import com.storeroom.utils.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle;
@ -72,6 +75,12 @@ public class ExcelUtil {
return wb;
}
/**
* 创建借阅导出Excel
* @param fileName
* @param bills
* @return
*/
public static XSSFWorkbook createBorrowerExcel(String fileName, List<BorrowBillDetailsVO> bills){
// 创建一个工作薄
@ -208,6 +217,130 @@ public class ExcelUtil {
return workbook;
}
public static XSSFWorkbook createArrangeExcel(String fileName, ArchivesCheckBill bill,List<ArchivesCheckBillDetails> billDetails){
// 创建一个工作薄
XSSFWorkbook workbook = new XSSFWorkbook();
// 创建一个工作表
XSSFSheet sheet = workbook.createSheet(fileName);
// 设置表头字体格式
XSSFFont headersFont = workbook.createFont();
headersFont.setColor(new XSSFColor(java.awt.Color.DARK_GRAY));
headersFont.setFontHeightInPoints((short) 14);
headersFont.setBold(true);
// 设置正文字体格式
XSSFFont dataSetFont = workbook.createFont();
dataSetFont.setColor(new XSSFColor(java.awt.Color.BLACK));
dataSetFont.setBold(false);
// 创建表头样式
XSSFCellStyle headersStyle = workbook.createCellStyle();
headersStyle.setBorderTop(BorderStyle.THIN);
headersStyle.setBorderBottom(BorderStyle.THIN);
headersStyle.setBorderLeft(BorderStyle.THIN);
headersStyle.setBorderRight(BorderStyle.THIN);
headersStyle.setFont(headersFont);
// 表头内容对齐方式居中
headersStyle.setAlignment(HorizontalAlignment.CENTER);
// 创建文本样式
XSSFCellStyle textStyle = workbook.createCellStyle();
textStyle.setBorderBottom(BorderStyle.THIN);
textStyle.setBorderRight(BorderStyle.THIN);
textStyle.setBorderLeft(BorderStyle.THIN);
textStyle.setBorderTop(BorderStyle.THIN);
textStyle.setFont(dataSetFont);
// 数据内容对齐方式居中
textStyle.setAlignment(HorizontalAlignment.CENTER);
textStyle.setVerticalAlignment(VerticalAlignment.CENTER);
//
int index = 0;
String[] billTitle = {"单据号","所属区域","盘点状态","创建时间","未盘档案","在库档案","错位档案","已借档案","异常档案","其他档案"};
String[] archivesTitle = {"序号","判断结果","子条目数","门类级别","门类名称","全宗号","档号","归档年度","题名","保密程度","部门","盒名称","所在位置","创建时间"};
//清单title
XSSFRow billTitleRow = sheet.createRow(index);
for(int i = 0;i<billTitle.length;i++){
XSSFCell cell = billTitleRow.createCell(i);
cell.setCellStyle(textStyle);
cell.setCellValue(billTitle[i]);
}
index++;
XSSFRow billValueRow = sheet.createRow(index);
XSSFCell billCell0 = billValueRow.createCell(0);billCell0.setCellStyle(textStyle);billCell0.setCellValue(bill.getId());
XSSFCell billCell1 = billValueRow.createCell(1);billCell1.setCellStyle(textStyle);billCell1.setCellValue(bill.getRegion());
String checkState = bill.getCheckState() == 0 ? "待执行" : bill.getCheckState() == 1 ? "执行中" : "已执行";
XSSFCell billCell2 = billValueRow.createCell(2);billCell2.setCellStyle(textStyle);billCell2.setCellValue(checkState);
XSSFCell billCell3 = billValueRow.createCell(3);billCell3.setCellStyle(textStyle);billCell3.setCellValue(sdf1.format(bill.getCreateTime()));
XSSFCell billCell4 = billValueRow.createCell(4);billCell4.setCellStyle(textStyle);billCell4.setCellValue(bill.getNoCheck());
XSSFCell billCell5 = billValueRow.createCell(5);billCell5.setCellStyle(textStyle);billCell5.setCellValue(bill.getCorrect());
XSSFCell billCell6 = billValueRow.createCell(6);billCell6.setCellStyle(textStyle);billCell6.setCellValue(bill.getDislocation());
XSSFCell billCell7 = billValueRow.createCell(7);billCell7.setCellStyle(textStyle);billCell7.setCellValue(bill.getBorrowed());
XSSFCell billCell8 = billValueRow.createCell(8);billCell8.setCellStyle(textStyle);billCell8.setCellValue(bill.getAbnormal());
XSSFCell billCell9 = billValueRow.createCell(9);billCell9.setCellStyle(textStyle);billCell9.setCellValue(bill.getOthers());
index++;
XSSFRow hrRow = sheet.createRow(index);
index++;
XSSFRow archivesTitleRow = sheet.createRow(index);
for(int i = 0;i<archivesTitle.length;i++){
XSSFCell cell = archivesTitleRow.createCell(i);
cell.setCellStyle(textStyle);
cell.setCellValue(archivesTitle[i]);
}
for(int i = 0;i<billDetails.size();i++){
ArchivesCheckBillDetails details = billDetails.get(i);
index++;
XSSFRow archivesValueRow = sheet.createRow(index);
Integer checkResult = details.getCheckResult();
String result = "";
switch (checkResult){
case 0:
result = "丢失";
break;
case 1:
result = "在库";
break;
// case 2:
// result = "已盘";
// break;
case 3:
result = "错位";
break;
case 4:
result = "已借";
break;
case 5:
result = "异常";
break;
default:
result = "其他";
break ;
}
XSSFCell archivesCell0 = archivesValueRow.createCell(0);archivesCell0.setCellStyle(textStyle);archivesCell0.setCellValue(i+1);
XSSFCell archivesCell1 = archivesValueRow.createCell(1);archivesCell1.setCellStyle(textStyle);archivesCell1.setCellValue(result);
XSSFCell archivesCell2 = archivesValueRow.createCell(2);archivesCell2.setCellStyle(textStyle);archivesCell2.setCellValue(details.getChild());
XSSFCell archivesCell3 = archivesValueRow.createCell(3);archivesCell3.setCellStyle(textStyle);archivesCell3.setCellValue(details.getCategoryType()==ArchivesTypeEnum.archives.getCode()?"案卷级":"文件级");
XSSFCell archivesCell4 = archivesValueRow.createCell(4);archivesCell4.setCellStyle(textStyle);archivesCell4.setCellValue(details.getCategoryName());
XSSFCell archivesCell5 = archivesValueRow.createCell(5);archivesCell5.setCellStyle(textStyle);archivesCell5.setCellValue(details.getFondsNo());
XSSFCell archivesCell6 = archivesValueRow.createCell(6);archivesCell6.setCellStyle(textStyle);archivesCell6.setCellValue(details.getArchiveNo());
String archivesYear = details.getArchiveYear()== null? null:details.getArchiveYear().toString();
XSSFCell archivesCell7 = archivesValueRow.createCell(7);archivesCell7.setCellStyle(textStyle);archivesCell7.setCellValue(archivesYear);
XSSFCell archivesCell8 = archivesValueRow.createCell(8);archivesCell8.setCellStyle(textStyle);archivesCell8.setCellValue(details.getMaintitle());
XSSFCell archivesCell9 = archivesValueRow.createCell(9);archivesCell9.setCellStyle(textStyle);archivesCell9.setCellValue(details.getSecurityClass());
XSSFCell archivesCell10 = archivesValueRow.createCell(10);archivesCell10.setCellStyle(textStyle);archivesCell10.setCellValue(details.getDepartment());
XSSFCell archivesCell11 = archivesValueRow.createCell(11);archivesCell11.setCellStyle(textStyle);archivesCell11.setCellValue(details.getCaseName());
XSSFCell archivesCell12 = archivesValueRow.createCell(12);archivesCell12.setCellStyle(textStyle);archivesCell12.setCellValue(details.getFolderLocationDetails());
XSSFCell archivesCell13 = archivesValueRow.createCell(13);archivesCell13.setCellStyle(textStyle);archivesCell13.setCellValue(sdf1.format(details.getCreateTime()));
}
//自适应单元格
for (int i = 0; i < sheet.getLastRowNum(); i++) {
sheet.autoSizeColumn(i);
sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 17 / 10);
}
return workbook;
}
//发送响应流方法
public static void setResponseHeader(HttpServletResponse response, String fileName) {
try {

3
archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesTypeRepository.java

@ -15,6 +15,9 @@ public interface ArchivesTypeRepository extends JpaRepository<ArchivesType, Stri
@Query("from ArchivesType where pid = ?1")
ArchivesType findByPid(String pid);
@Query("from ArchivesType where pid = ?1")
List<ArchivesType> findAllByPid(String pid);
@Query("select pid from ArchivesType where id = ?1")
String findPidById(String id);

2
archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java

@ -52,5 +52,7 @@ public interface ArchivesTypeService {
*/
ArchivesTypeDTO findById(String id);
//根据门类id获取旗下所有文件集档案级门类
Set<ArchivesTypeDTO> findArchivesTypeByIds(List<String> ids);
}

41
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

@ -1,6 +1,7 @@
package com.storeroom.modules.dictionary.service.impl;
import com.storeroom.exception.BaseException;
import com.storeroom.modules.common.ArchivesTypeEnum;
import com.storeroom.modules.dictionary.domain.ArchivesType;
import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository;
import com.storeroom.modules.dictionary.service.ArchivesTypeService;
@ -124,5 +125,45 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
return null;
}
@Override
public Set<ArchivesTypeDTO> findArchivesTypeByIds(List<String> ids) {
Set<ArchivesTypeDTO> dtos = new HashSet<>();
for(String id:ids){
Optional<ArchivesType> optional = archivesTypeRepository.findById(id);
if(optional.isPresent()){
ArchivesType archivesType = optional.get();
//当该门类是文件集或案卷级
if(archivesType.getIsType()== ArchivesTypeEnum.archives.getCode() || archivesType.getIsType()== ArchivesTypeEnum.files.getCode()){
dtos.add(archivesTypeMapper.toDto(archivesType));
//当门类为文件夹或项目 轮询出下面所有文件集/案卷级档案
}else if(archivesType.getIsType() == ArchivesTypeEnum.folder.getCode() || archivesType.getIsType() == ArchivesTypeEnum.project.getCode()){
Set<ArchivesTypeDTO> thidDtos = this.findThisArchivesFileAllChild(archivesType.getId(),null);
if(null!=thidDtos && thidDtos.size()!=0){
dtos.addAll(thidDtos);
}
}
}
}
return dtos;
}
public Set<ArchivesTypeDTO> findThisArchivesFileAllChild(String categoryId,Set<ArchivesTypeDTO> dtos){
if(dtos == null)
dtos = new HashSet<>();
List<ArchivesType> archivesTypes = archivesTypeRepository.findAllByPid(categoryId);
for(ArchivesType archivesType : archivesTypes){
if(archivesType.getIsType() == ArchivesTypeEnum.folder.getCode() || archivesType.getIsType() == ArchivesTypeEnum.project.getCode()){
Set<ArchivesTypeDTO> thidDtos = this.findThisArchivesFileAllChild(archivesType.getId(),dtos);
if(null!=thidDtos && thidDtos.size()!=0){
dtos.addAll(thidDtos);
}
}else if(archivesType.getIsType()== ArchivesTypeEnum.archives.getCode() || archivesType.getIsType()== ArchivesTypeEnum.files.getCode()){
dtos.add(archivesTypeMapper.toDto(archivesType));
}
}
return dtos;
}
}
Loading…
Cancel
Save