Pārlūkot izejas kodu

应收 应收逾期

wangqifan 5 gadi atpakaļ
vecāks
revīzija
f952c09760

+ 9 - 0
src/main/java/com/izouma/zhumj/dto/report/ReceivableCreditReportDTO.java

@@ -1,6 +1,8 @@
 package com.izouma.zhumj.dto.report;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.izouma.zhumj.domain.sale.Contract;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -24,23 +26,30 @@ import java.math.BigDecimal;
 @ExcelIgnoreUnannotated
 public class ReceivableCreditReportDTO {
     @ApiModelProperty(value = "合同")
+    @ExcelIgnore
     private Contract contract;
 
     @ApiModelProperty(value = "客户名称")
+    @ExcelProperty(value = "客户名称")
     private String customerName;
 
     @ApiModelProperty(value = "当前周期")
+    @ExcelProperty(value = "当前周期")
     private String currentBill;
 
     @ApiModelProperty(value = "消费金额")
+    @ExcelProperty(value = "消费金额")
     private BigDecimal consumedMoney;
 
     @ApiModelProperty(value = "入账金额")
+    @ExcelProperty(value = "入账金额")
     private BigDecimal paidMoney;
 
     @ApiModelProperty(value = "账户余额")
+    @ExcelProperty(value = "账户余额")
     private BigDecimal money;
 
     @ApiModelProperty(value = "门店信息")
+    @ExcelProperty(value = "门店信息")
     private String stores;
 }

+ 0 - 2
src/main/java/com/izouma/zhumj/repo/sale/ContractStoreRepo.java

@@ -42,6 +42,4 @@ public interface ContractStoreRepo extends JpaRepository<ContractStore, Long>, J
     void deleteByContractId(Long contractId);
 
     List<ContractStore> findByStoreId(Long storeId);
-
-    List<ContractStore> findAllByStoreIdNotIn(List<Long> storeIds);
 }

+ 37 - 35
src/main/java/com/izouma/zhumj/service/sale/ContractBillService.java

@@ -341,40 +341,42 @@ public class ContractBillService {
     public Page<ContractBill> arrearsContractBill(String search, LocalDate start, LocalDate end, Pageable pageable) {
         List<Long> breaks = new ArrayList<>();
         contractRepo.findByStatus(ContractStatus.BREAK).forEach(contract -> breaks.add(contract.getId()));
-        List<Long> enabledStore = storeInfoRepo.findAllByStoreStatus(StoreStatus.BUSINESS).stream()
-                .map(StoreInfo::getId).collect(Collectors.toList());
-        List<Long> disabledContractIds = contractStoreRepo.findAllByStoreIdNotIn(enabledStore).stream()
-                .map(ContractStore::getContractId).collect(Collectors.toList());
-        return contractBillRepo.findAll((Specification<ContractBill>) (root, criteriaQuery, criteriaBuilder) -> {
-            List<Predicate> and = new ArrayList<>();
-            and.add(criteriaBuilder.not(root.get("contractId").in(breaks)));
-            and.add(criteriaBuilder.not(root.get("contractId").in(disabledContractIds)));
-            and.add(criteriaBuilder.lessThan(root.get("rest"), BigDecimal.ZERO));
-            if (StringUtils.isNotBlank(search)) {
-                List<Long> customerIds = customerRepo.findByCoFullNameLikeOrCoSimpleNameLike(search, search)
-                        .stream()
-                        .map(Customer::getId)
-                        .collect(Collectors.toList());
-                List<Long> contracts = contractRepo.findAllByCustomerIdIn(customerIds)
-                        .stream()
-                        .map(Contract::getId)
-                        .collect(Collectors.toList());
-                and.add(root.get("contractId").in(contracts));
-            }
-            and.add(criteriaBuilder.not(criteriaBuilder.equal(root.get("status"), BillStatus.COMPLETED)));
-            if (SecurityUtils.hasRole(Authority.NAME.ROLE_SALE)) {
-                and.add(criteriaBuilder.equal(root.get("saleId"), SecurityUtils.getAuthenticatedUser().getId()));
-            }
-            and.add(criteriaBuilder.not(criteriaBuilder.equal(root.get("recharged"), root.get("money"))));
-            if (start != null & end != null) {
-                and.add(criteriaBuilder
-                        .between(root.get("startTime"), start.atStartOfDay(), end.atTime(LocalTime.MAX)));
-            }
-            if (start == null) {
-                and.add(criteriaBuilder
-                        .lessThanOrEqualTo(root.get("startTime"), LocalDate.now().atTime(LocalTime.MAX)));
-            }
-            return criteriaBuilder.and(and.toArray(new Predicate[0]));
-        }, pageable);
+        breaks.addAll(contractStoreRepo.findByStoreId(433L).stream()
+                .map(ContractStore::getContractId).collect(Collectors.toList()));
+        Page<ContractBill> orig = contractBillRepo
+                .findAll((Specification<ContractBill>) (root, criteriaQuery, criteriaBuilder) -> {
+                    List<Predicate> and = new ArrayList<>();
+                    and.add(criteriaBuilder.lessThan(root.get("rest"), BigDecimal.ZERO));
+                    if (StringUtils.isNotBlank(search)) {
+                        List<Long> customerIds = customerRepo.findByCoFullNameLikeOrCoSimpleNameLike(search, search)
+                                .stream()
+                                .map(Customer::getId)
+                                .collect(Collectors.toList());
+                        List<Long> contracts = contractRepo.findAllByCustomerIdIn(customerIds)
+                                .stream()
+                                .map(Contract::getId)
+                                .collect(Collectors.toList());
+                        and.add(root.get("contractId").in(contracts));
+                    }
+                    and.add(criteriaBuilder.not(criteriaBuilder.equal(root.get("status"), BillStatus.COMPLETED)));
+                    if (SecurityUtils.hasRole(Authority.NAME.ROLE_SALE)) {
+                        and.add(criteriaBuilder
+                                .equal(root.get("saleId"), SecurityUtils.getAuthenticatedUser().getId()));
+                    }
+                    and.add(criteriaBuilder.not(criteriaBuilder.equal(root.get("recharged"), root.get("money"))));
+                    if (start != null & end != null) {
+                        and.add(criteriaBuilder
+                                .between(root.get("startTime"), start.atStartOfDay(), end.atTime(LocalTime.MAX)));
+                    }
+                    if (start == null) {
+                        and.add(criteriaBuilder
+                                .lessThanOrEqualTo(root.get("startTime"), LocalDateTime.now()));
+                    }
+                    return criteriaBuilder.and(and.toArray(new Predicate[0]));
+                }, pageable);
+        List<ContractBill> content = orig.getContent();
+        List<ContractBill> result = content.stream()
+                .filter(contractBill -> !breaks.contains(contractBill.getContractId())).collect(Collectors.toList());
+        return new PageImpl<>(result, pageable, orig.getTotalElements());
     }
 }

+ 7 - 4
src/main/java/com/izouma/zhumj/web/report/ReportController.java

@@ -205,7 +205,8 @@ public class ReportController extends BaseController {
     @GetMapping("/excelDepositDetailReport")
     @ResponseBody
     public void excelDepositDetailReport(HttpServletResponse response, @RequestParam Long storeId, @RequestParam LocalDateTime start, @RequestParam LocalDateTime end, @RequestParam DepositStatus depositStatus) throws IOException {
-        List<DepositDetailDTO> depositDetailDTOList = reportService.allDepositDetail(storeId, start, end, depositStatus);
+        List<DepositDetailDTO> depositDetailDTOList = reportService
+                .allDepositDetail(storeId, start, end, depositStatus);
         ExcelUtils.export(response, depositDetailDTOList, DepositDetailDTO.class);
     }
 
@@ -525,9 +526,11 @@ public class ReportController extends BaseController {
 
     @GetMapping("/excelReceivableCreditReport")
     @ApiOperation("集团房费报表导出")
-    public void excelReceivableCreditReport(HttpServletResponse response, @RequestParam LocalDate start, @RequestParam LocalDate end, @RequestParam(required = false) Long customerId, @RequestParam(required = false) Long storeId, @RequestParam(required = false) Pageable pageable) throws IOException {
-        ExcelUtils.export(response, reportService.receivableCreditReport(start, end, customerId, storeId, pageable)
-                .getContent());
+    public void excelReceivableCreditReport(HttpServletResponse response, @RequestParam LocalDate start, @RequestParam LocalDate end, @RequestParam(required = false) Long customerId, @RequestParam(required = false) Long storeId, Pageable pageable) throws IOException {
+        List<ReceivableCreditReportDTO> result = reportService
+                .receivableCreditReport(start, end, customerId, storeId, pageable)
+                .getContent();
+        ExcelUtils.export(response, result);
     }
 
     @GetMapping("/customerCountReport")

+ 8 - 11
src/main/vue/src/views/ReceivableCreditReport.vue

@@ -273,27 +273,24 @@ export default {
                 });
         },
         download() {
-            let data = {};
+            let params = {};
             if (this.dateRange && this.dateRange.length > 0) {
-                data.start = this.dateRange[0];
-                data.end = this.dateRange[1];
+                params.start = this.dateRange[0];
+                params.end = this.dateRange[1];
             }
             if (this.storeId) {
-                data.storeId = this.storeId;
+                params.storeId = this.storeId;
             }
             if (this.customerId) {
-                data.customerId = this.customerId;
+                params.customerId = this.customerId;
             }
+            params.size = 10000;
+            params.page = 0;
             this.downloading = true;
             this.$axios
                 .get('/report/excelReceivableCreditReport', {
                     responseType: 'blob',
-                    params: {
-                        start: this.dateRange[0],
-                        end: this.dateRange[1],
-                        storeId: this.storeId,
-                        customerId: this.storeId
-                    }
+                    params
                 })
                 .then(res => {
                     console.log(res);