|
14 | 14 |
|
15 | 15 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
16 | 16 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
17 |
| -import com.wansenai.bo.CollectionBO; |
18 | 17 | import com.wansenai.bo.FileDataBO;
|
19 | 18 | import com.wansenai.bo.PaymentBO;
|
| 19 | +import com.wansenai.bo.PaymentDataExportBO; |
20 | 20 | import com.wansenai.dto.financial.AddOrUpdatePaymentDTO;
|
21 | 21 | import com.wansenai.dto.financial.QueryPaymentDTO;
|
22 | 22 | import com.wansenai.entities.financial.FinancialMain;
|
|
34 | 34 | import com.wansenai.utils.constants.CommonConstants;
|
35 | 35 | import com.wansenai.utils.enums.BaseCodeEnum;
|
36 | 36 | import com.wansenai.utils.enums.CollectionPaymentCodeEnum;
|
| 37 | +import com.wansenai.utils.excel.ExcelUtils; |
37 | 38 | import com.wansenai.utils.response.Response;
|
38 |
| -import com.wansenai.vo.financial.CollectionDetailVO; |
39 |
| -import com.wansenai.vo.financial.CollectionVO; |
40 | 39 | import com.wansenai.vo.financial.PaymentDetailVO;
|
41 | 40 | import com.wansenai.vo.financial.PaymentVO;
|
| 41 | +import jakarta.servlet.http.HttpServletResponse; |
42 | 42 | import org.springframework.stereotype.Service;
|
43 | 43 | import org.springframework.util.StringUtils;
|
44 | 44 |
|
|
48 | 48 | import java.util.Arrays;
|
49 | 49 | import java.util.List;
|
50 | 50 | import java.util.Optional;
|
| 51 | +import java.util.concurrent.ConcurrentHashMap; |
51 | 52 | import java.util.stream.Collectors;
|
52 | 53 |
|
53 | 54 | @Service
|
@@ -141,6 +142,41 @@ public Response<Page<PaymentVO>> getPaymentReceiptPageList(QueryPaymentDTO query
|
141 | 142 | return Response.responseData(result);
|
142 | 143 | }
|
143 | 144 |
|
| 145 | + private List<PaymentVO> getPaymentReceiptList(QueryPaymentDTO queryPaymentDTO) { |
| 146 | + var financialMainList = lambdaQuery() |
| 147 | + .eq(queryPaymentDTO.getFinancialPersonId() != null, FinancialMain::getOperatorId, queryPaymentDTO.getFinancialPersonId()) |
| 148 | + .eq(queryPaymentDTO.getAccountId() != null, FinancialMain::getAccountId, queryPaymentDTO.getAccountId()) |
| 149 | + .eq(queryPaymentDTO.getStatus() != null, FinancialMain::getStatus, queryPaymentDTO.getStatus()) |
| 150 | + .eq(queryPaymentDTO.getSupplierId() != null, FinancialMain::getRelatedPersonId, queryPaymentDTO.getSupplierId()) |
| 151 | + .eq(StringUtils.hasLength(queryPaymentDTO.getReceiptNumber()), FinancialMain::getReceiptNumber, queryPaymentDTO.getReceiptNumber()) |
| 152 | + .like(StringUtils.hasLength(queryPaymentDTO.getRemark()), FinancialMain::getRemark, queryPaymentDTO.getRemark()) |
| 153 | + .ge(StringUtils.hasLength(queryPaymentDTO.getStartDate()), FinancialMain::getReceiptDate, queryPaymentDTO.getStartDate()) |
| 154 | + .le(StringUtils.hasLength(queryPaymentDTO.getEndDate()), FinancialMain::getReceiptDate, queryPaymentDTO.getEndDate()) |
| 155 | + .eq(FinancialMain::getType, "付款") |
| 156 | + .eq(FinancialMain::getDeleteFlag, CommonConstants.NOT_DELETED) |
| 157 | + .list(); |
| 158 | + |
| 159 | + var paymentVOList = new ArrayList<PaymentVO>(financialMainList.size() + 1); |
| 160 | + financialMainList.forEach(item -> { |
| 161 | + var paymentVo = PaymentVO.builder() |
| 162 | + .id(item.getId()) |
| 163 | + .receiptNumber(item.getReceiptNumber()) |
| 164 | + .supplierName(commonService.getSupplierName(item.getRelatedPersonId())) |
| 165 | + .receiptDate(item.getReceiptDate()) |
| 166 | + .financialPerson(commonService.getOperatorName(item.getOperatorId())) |
| 167 | + .paymentAccountName(commonService.getAccountName(item.getAccountId())) |
| 168 | + .totalPaymentAmount(item.getTotalAmount()) |
| 169 | + .discountAmount(item.getDiscountAmount()) |
| 170 | + .actualPaymentAmount(item.getChangeAmount()) |
| 171 | + .status(item.getStatus()) |
| 172 | + .remark(item.getRemark()) |
| 173 | + .build(); |
| 174 | + |
| 175 | + paymentVOList.add(paymentVo); |
| 176 | + }); |
| 177 | + return paymentVOList; |
| 178 | + } |
| 179 | + |
144 | 180 | @Override
|
145 | 181 | public Response<PaymentDetailVO> getPaymentReceiptDetail(Long id) {
|
146 | 182 | if (id == null) {
|
@@ -354,4 +390,35 @@ public Response<String> updatePaymentReceiptStatus(List<Long> ids, Integer statu
|
354 | 390 | }
|
355 | 391 | return Response.responseMsg(CollectionPaymentCodeEnum.UPDATE_PAYMENT_RECEIPT_SUCCESS);
|
356 | 392 | }
|
| 393 | + |
| 394 | + @Override |
| 395 | + public void exportPaymentReceipt(QueryPaymentDTO queryPaymentDTO, HttpServletResponse response) { |
| 396 | + var exportMap = new ConcurrentHashMap<String, List<List<Object>>>(); |
| 397 | + var mainData = getPaymentReceiptList(queryPaymentDTO); |
| 398 | + if (!mainData.isEmpty()) { |
| 399 | + exportMap.put("付款单", ExcelUtils.getSheetData(mainData)); |
| 400 | + if (queryPaymentDTO.getIsExportDetail()) { |
| 401 | + var subData = new ArrayList<PaymentDataExportBO>(); |
| 402 | + for (PaymentVO paymentVO : mainData) { |
| 403 | + var detail = getPaymentReceiptDetail(paymentVO.getId()).getData().getTableData(); |
| 404 | + if (!detail.isEmpty()) { |
| 405 | + detail.forEach(item -> { |
| 406 | + var data = PaymentDataExportBO.builder() |
| 407 | + .supplierName(paymentVO.getSupplierName()) |
| 408 | + .receiptNumber(paymentVO.getReceiptNumber()) |
| 409 | + .purchaseReceiptNumber(item.getPurchaseReceiptNumber()) |
| 410 | + .paymentArrears(item.getPaymentArrears()) |
| 411 | + .prepaidArrears(item.getPrepaidArrears()) |
| 412 | + .thisPaymentAmount(item.getThisPaymentAmount()) |
| 413 | + .remark(item.getRemark()) |
| 414 | + .build(); |
| 415 | + subData.add(data); |
| 416 | + }); |
| 417 | + } |
| 418 | + } |
| 419 | + exportMap.put("付款单明细", ExcelUtils.getSheetData(subData)); |
| 420 | + } |
| 421 | + ExcelUtils.exportManySheet(response, "付款单", exportMap); |
| 422 | + } |
| 423 | + } |
357 | 424 | }
|
0 commit comments