BAOLH
2026-11-10 c5dfc09145e4e10f99dbf388a4a1433b5c2973e5
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/contract/service/impl/ContractServiceImpl.java
@@ -2932,4 +2932,56 @@
            e.printStackTrace();
        }
    }
    @Override
    public void downloadTable(List<ContractDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, String> contractTypeMap = dictDetailRepository.findByDictName(Constant.CONTRACT_DICT_TYPE).parallelStream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel));
        Map<String, String> paymentStateMap = dictDetailRepository.findByDictName(Constant.PAYMENT_STATE).parallelStream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel));
        Map<String, String> contractStatusMap = dictDetailRepository.findByDictName(Constant.CONTRACT_STATUS).parallelStream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel));
        Map<String, String> acceptStatusMap = dictDetailRepository.findByDictName(Constant.ACCEPT_STATUS).parallelStream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel));
        SimpleDateFormat ymdsdf = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat ymsdf = new SimpleDateFormat("yyyy-MM");
        for (ContractDto contract : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("合同编号", contract.getContractNumber());
            map.put("合同名称", contract.getContractName());
            map.put("所属甲方", contract.getFirstName());
            map.put("所属乙方", contract.getSecondName());
            map.put("签订日期", Optional.ofNullable(contract.getSignDate()).map(ymdsdf::format).orElse(""));
            map.put("业绩日期", Optional.ofNullable(contract.getPerformanceDate()).map(ymsdf::format).orElse(""));
            map.put("开票总金额", contract.getBillingTotalAmount());
            map.put("付款总金额", contract.getPaymentTotalAmount());
            map.put("付款收入金额", contract.getPaymentIncomeAmount());
            map.put("付款支出金额", contract.getPaymentExpendAmount());
            map.put("预收款金额", Optional.ofNullable(contract.getAdvancePayment()).filter(bd -> bd.compareTo(BigDecimal.ZERO) != 0).map(String::valueOf).orElse(""));
            map.put("应收款金额", Optional.ofNullable(contract.getReceivePayment()).filter(bd -> bd.compareTo(BigDecimal.ZERO) != 0).map(String::valueOf).orElse(""));
            map.put("合同费金额", Optional.ofNullable(contract.getContractAmount()).filter(bd -> bd.compareTo(BigDecimal.ZERO) != 0).map(String::valueOf).orElse(""));
            map.put("预计付款日期(合同费)", Optional.ofNullable(contract.getContractPaymentDate()).map(ymdsdf::format).orElse(""));
            map.put("付款状态(合同费)", paymentStateMap.getOrDefault(contract.getContractPaymentState(), ""));
            map.put("延期情况(合同费)", contract.getContractPostponement());
            map.put("服务开始日期", Optional.ofNullable(contract.getServiceStartsDate()).map(ymdsdf::format).orElse(""));
            map.put("运维服务费金额", Optional.ofNullable(contract.getServiceAmount()).filter(bd -> bd.compareTo(BigDecimal.ZERO) != 0).map(String::valueOf).orElse(""));
            map.put("预计付款日期(服务费)", Optional.ofNullable(contract.getServicePaymentDate()).map(ymdsdf::format).orElse(""));
            map.put("付款状态(服务费)", paymentStateMap.getOrDefault(contract.getServicePaymentState(), ""));
            map.put("延期情况(服务费)", contract.getServicePostponement());
            map.put("起始日期", Optional.ofNullable(contract.getStartDate()).map(ymdsdf::format).orElse(""));
            map.put("截止日期", Optional.ofNullable(contract.getEndDate()).map(ymdsdf::format).orElse(""));
            map.put("所属地区", contract.getContractArea());
            map.put("合同类型", contractTypeMap.getOrDefault(contract.getContractType(), ""));
            map.put("合同类型(二级)", contract.getContractSecondType());
            map.put("合同内容", contract.getContractContent());
            map.put("分配项目数(合同费)", contract.getFundContractNum());
            map.put("分配总金额(合同费)", Optional.ofNullable(contract.getFundContractAmount()).filter(bd -> bd.compareTo(BigDecimal.ZERO) != 0).map(String::valueOf).orElse(""));
            map.put("分配项目数(服务费)", contract.getFundServiceNum());
            map.put("分配总金额(服务费)", Optional.ofNullable(contract.getFundServiceAmount()).filter(bd -> bd.compareTo(BigDecimal.ZERO) != 0).map(String::valueOf).orElse(""));
            map.put("合同附件", contract.getRelatedDocumentsAttachment());
            map.put("备注信息", contract.getRemarks());
            map.put("验收状态", acceptStatusMap.getOrDefault(contract.getAcceptStatus(), ""));
            map.put("合同状态", contractStatusMap.getOrDefault(contract.getContractStatus(), ""));
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}