From 9892e4d56dfda27f9be238df0fa12cfa71468205 Mon Sep 17 00:00:00 2001
From: yaozc2021 <yaozc@yhzhg.cn>
Date: Fri, 24 Jan 2025 09:39:50 +0000
Subject: [PATCH] Merge branch 'wcd-2411-update' of http://192.168.1.110:5678/r/pms-upgrade into wcd

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/contract/service/impl/ContractServiceImpl.java |  204 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 129 insertions(+), 75 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/contract/service/impl/ContractServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/contract/service/impl/ContractServiceImpl.java
index 159eb8c..02895cc 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/contract/service/impl/ContractServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/contract/service/impl/ContractServiceImpl.java
@@ -317,9 +317,13 @@
                     ContractInvoicePaymentQueryCriteria invoicePaymentQueryCriteria = new ContractInvoicePaymentQueryCriteria();
                     invoicePaymentQueryCriteria.setPaymentId(payment.getPaymentId());
                     List<ContractInvoicePayment> invoicePaymentList = contractInvoicePaymentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,invoicePaymentQueryCriteria,criteriaBuilder));
-                    for (ContractInvoicePayment invoicePayment : invoicePaymentList) {
-                        ContractInvoice invoice = contractInvoiceRepository.getById(invoicePayment.getInvoiceId());
-                        invoiceList.add(invoice);
+                    if (invoicePaymentList.size() > 0) {
+                        for (ContractInvoicePayment invoicePayment : invoicePaymentList) {
+                            ContractInvoice invoice = contractInvoiceRepository.getById(invoicePayment.getInvoiceId());
+                            invoiceList.add(invoice);
+                        }
+                    } else {
+                        invoiceList.add(new ContractInvoice());
                     }
                 } else {
                     invoiceList.add(new ContractInvoice());
@@ -691,9 +695,9 @@
         }
 
         // 判断合同类型
-        if (Constant.CONTRACT_DEVELOP_SERVICE.equals(resources.getContractSecondType())) {
+        if (Constant.CONTRACT_TECHNOLOGY.equals(resources.getContractType()) && Constant.CONTRACT_DEVELOP_SERVICE.equals(resources.getContractSecondType())) {
             // 不处理
-        } else if (Constant.CONTRACT_SERVICE.equals(resources.getContractSecondType())) {
+        } else if (Constant.CONTRACT_TECHNOLOGY.equals(resources.getContractType()) && Constant.CONTRACT_SERVICE.equals(resources.getContractSecondType())) {
             // 合同费金额
             resources.setContractAmount(null);
             // 预计付款日期
@@ -761,7 +765,7 @@
             BigDecimal contractAmount = contractPaymentRepository.findByContractIdAndFundType(contract.getContractId(), Constant.FUND_CONTRACT);
             contractAmount = contractAmount == null ? new BigDecimal(0) : contractAmount;
             // 判断合同款项付款金额
-            if(Constant.CONTRACT_SERVICE.equals(contract.getContractSecondType())) {
+            if(Constant.CONTRACT_TECHNOLOGY.equals(contract.getContractType()) && Constant.CONTRACT_SERVICE.equals(contract.getContractSecondType())) {
                 // 付款状态
                 contract.setContractPaymentState(null);
             } else if(contractAmount.compareTo(new BigDecimal(0)) == 0) {
@@ -796,7 +800,7 @@
                 BigDecimal serviceAmount = contractPaymentRepository.findByContractIdAndFundType(contract.getContractId(), Constant.FUND_SERVICE);
                 serviceAmount = serviceAmount == null ? new BigDecimal(0) : serviceAmount;
                 // 判断服务款项付款金额
-                if(Constant.CONTRACT_DEVELOP.equals(contract.getContractSecondType())) {
+                if(Constant.CONTRACT_TECHNOLOGY.equals(contract.getContractType()) && Constant.CONTRACT_DEVELOP.equals(contract.getContractSecondType())) {
                     // 付款状态
                     contract.setServicePaymentState(null);
                 } else if(serviceAmount.compareTo(new BigDecimal(0)) == 0) {
@@ -853,13 +857,9 @@
                 // 是否有真实合同
                 contractNumber.append(newTrueContract);
             }
-            if (oldSignYear.equals(newSignYear)) {
-                contractNumber.append(resources.getContractNumber().substring(15));
-            } else {
-                // 全部公司当年编号(以签订日期为准)(因先存后改故排除本身数据)
-                Long allCompanySort = contractRepository.countAllContractSort(String.valueOf(calendar.get(Calendar.YEAR)), resources.getContractId());
-                contractNumber.append(String.format("%04d", (allCompanySort == null ? 0L : allCompanySort) + 1));
-            }
+            // 全部公司当年编号(以签订日期为准)
+            // TODO:250115业务方提出修改为以创建日期为准
+            contractNumber.append(resources.getContractNumber().substring(15));
 
             if (resources.getContractNumber().equals(contractNumber.toString())) {
                 return resources;
@@ -918,6 +918,8 @@
                 contractNumber.append("Y");
             }
             // 全部公司当年编号(以签订日期为准)(因先存后改故排除本身数据)
+            // TODO:250115业务方提出修改为以创建日期为准
+            calendar.setTime(resources.getCreateTime());
             Long allCompanySort = contractRepository.countAllContractSort(String.valueOf(calendar.get(Calendar.YEAR)), resources.getContractId());
             contractNumber.append(String.format("%04d", (allCompanySort == null ? 0L : allCompanySort) + 1));
 
@@ -937,13 +939,14 @@
      */
     @Override
     public BigDecimal contractTotalMoney(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 搜索数据处理
         String signStartDate = criteria.getSignDate() != null ? criteria.getSignDate().get(0).toString() : null;
         String signEndDate = criteria.getSignDate() != null ? criteria.getSignDate().get(1).toString() : null;
         // 查询合同款总金额
         BigDecimal contractTotalMoney = contractRepository.contractTotalMoney(
                 criteria.getContractNumber(), criteria.getContractName(), criteria.getFirstId(), criteria.getSecondId(), signStartDate, signEndDate, criteria.getContractType(),
-                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode()
+                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode(), criteria.getCompanys()
         );
         return contractTotalMoney;
     }
@@ -955,6 +958,7 @@
      */
     @Override
     public Integer contractDelayTotalAmount(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 合同款延期数
         Integer contractDelayTotalAmount = 0;
         // 搜索数据处理
@@ -963,7 +967,7 @@
         // 查询有合同款的合同数据
         List<Contract> contractList = contractRepository.findContractAmountNotNull(
                 criteria.getContractNumber(), criteria.getContractName(), criteria.getFirstId(), criteria.getSecondId(), signStartDate, signEndDate, criteria.getContractType(),
-                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode()
+                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode(), criteria.getCompanys()
         );
         // 循环有合同款的合同数据
         for(int i = 0; i < contractList.size(); i ++) {
@@ -991,6 +995,7 @@
      */
     @Override
     public BigDecimal contractDelayTotalMoney(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 合同款延期金额
         BigDecimal contractDelayTotalMoney = new BigDecimal("0.00");
         // 搜索数据处理
@@ -999,7 +1004,7 @@
         // 查询有合同款的合同数据
         List<Contract> contractList = contractRepository.findContractAmountNotNull(
                 criteria.getContractNumber(), criteria.getContractName(), criteria.getFirstId(), criteria.getSecondId(), signStartDate, signEndDate, criteria.getContractType(),
-                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode()
+                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode(), criteria.getCompanys()
         );
         // 循环有合同款的合同数据
         for(int i = 0; i < contractList.size(); i ++) {
@@ -1029,6 +1034,7 @@
      */
     @Override
     public BigDecimal advancePaymentTotalMoney(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 预收款总金额
         BigDecimal advancePaymentTotalMoney = new BigDecimal("0.00");
         // 查询所有合同信息
@@ -1048,13 +1054,14 @@
      */
     @Override
     public BigDecimal serviceTotalMoney(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 搜索数据处理
         String signStartDate = criteria.getSignDate() != null ? criteria.getSignDate().get(0).toString() : null;
         String signEndDate = criteria.getSignDate() != null ? criteria.getSignDate().get(1).toString() : null;
         // 查询运维服务总金额
         BigDecimal serviceTotalMoney = contractRepository.serviceTotalMoney(
                 criteria.getContractNumber(), criteria.getContractName(), criteria.getFirstId(), criteria.getSecondId(), signStartDate, signEndDate, criteria.getContractType(),
-                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode()
+                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode(), criteria.getCompanys()
         );
         return serviceTotalMoney;
     }
@@ -1066,6 +1073,7 @@
      */
     @Override
     public Integer serviceDelayTotalAmount(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 运维服务延期数
         Integer serviceDelayTotalAmount = 0;
         // 搜索数据处理
@@ -1074,7 +1082,7 @@
         // 查询有运维服务的合同数据
         List<Contract> contractList = contractRepository.findServiceAmountNotNull(
                 criteria.getContractNumber(), criteria.getContractName(), criteria.getFirstId(), criteria.getSecondId(), signStartDate, signEndDate, criteria.getContractType(),
-                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode()
+                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode(), criteria.getCompanys()
         );
         // 循环有运维服务的合同数据
         for(int i = 0; i < contractList.size(); i ++) {
@@ -1149,6 +1157,7 @@
      */
     @Override
     public BigDecimal serviceDelayTotalMoney(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 运维服务延期金额
         BigDecimal serviceDelayTotalMoney = new BigDecimal("0.00");
         // 搜索数据处理
@@ -1157,7 +1166,7 @@
         // 查询有运维服务的合同数据
         List<Contract> contractList = contractRepository.findServiceAmountNotNull(
                 criteria.getContractNumber(), criteria.getContractName(), criteria.getFirstId(), criteria.getSecondId(), signStartDate, signEndDate, criteria.getContractType(),
-                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode()
+                criteria.getContractPaymentState(), criteria.getServicePaymentState(), criteria.getContractStatus(), criteria.getContractAreaCode(), criteria.getCompanys()
         );
         // 循环有运维服务的合同数据
         for(int i = 0; i < contractList.size(); i ++) {
@@ -1236,6 +1245,7 @@
      */
     @Override
     public BigDecimal receivePaymentTotalMoney(ContractQueryCriteria criteria){
+        criteria.setCompanys(SecurityUtils.getCompanyIds());
         // 应收款总金额
         BigDecimal receivePaymentTotalMoney = new BigDecimal("0.00");
         // 查询所有合同信息
@@ -1260,7 +1270,8 @@
             throw new BadRequestException("上传失败");
         }
 
-        ExcelReader reader = ExcelUtil.getReader(FileUtil.toFile(file));
+        File uploadFile = FileUtil.toFile(file);
+        ExcelReader reader = ExcelUtil.getReader(uploadFile);
         List<Map<String,Object>> readAll = reader.readAll();
         if (ObjectUtil.isNull(readAll)) {
             throw new BadRequestException("Excel解析失败");
@@ -1278,6 +1289,8 @@
             Map<String, Long> secondMap = contractSecondRepository.findAll().stream().collect(Collectors.toMap(ContractSecond::getSecondName, ContractSecond::getSecondId));
             Map<String, Long> companyMap = sysCompanyRepository.findAll().stream().collect(Collectors.toMap(SysCompany::getLabel, SysCompany::getId));
             Map<String, String> provinceMap = chinaAreaMap.get("86").entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            SimpleDateFormat useSdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
             int rowNum = 1;
 
             for (Map<String,Object> row: readAll) {
@@ -1316,29 +1329,30 @@
                     contract.setContractArea(contractArea);
                     // 合同所属地区编码
                     int finalRowNum = rowNum;
-                    String contractAreaCode = Arrays.stream(contractArea.split("/")).filter(item -> StringUtils.isNotBlank(item)).reduce("", (concatStr, itemStr) -> {
-                        if (concatStr.length() == 0) {
-                            return provinceMap.get(itemStr);
-                        } else {
-                            if (itemStr.equals("本级")) {
-                                return concatStr;
+                    try {
+                        String contractAreaCode = Arrays.stream(contractArea.split("/")).filter(item -> StringUtils.isNotBlank(item)).reduce("", (concatStr, itemStr) -> {
+                            if (concatStr.length() == 0) {
+                                return provinceMap.get(itemStr);
                             } else {
-                                List<String> contractAreaCodeList = Arrays.stream(concatStr.split("/")).collect(Collectors.toList());
-                                String superAreaCode = contractAreaCodeList.get(contractAreaCodeList.size() - 1);
-                                Map<String, String> superAreaMap = chinaAreaMap.get(superAreaCode).entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
-                                if (superAreaMap.containsKey(itemStr)) {
-                                    return concatStr.concat("/").concat(superAreaMap.get(itemStr));
-                                } else {
-                                    String newKey = "合同所属地区编码校验未通过";
-                                    List<Integer> errorRows = errorMap.containsKey(newKey) ? errorMap.get(newKey) : new ArrayList<>();
-                                    errorRows.add(finalRowNum);
-                                    errorMap.put(newKey, errorRows);
+                                if (itemStr.equals("本级")) {
                                     return concatStr;
+                                } else {
+                                    List<String> contractAreaCodeList = Arrays.stream(concatStr.split("/")).collect(Collectors.toList());
+                                    String superAreaCode = contractAreaCodeList.get(contractAreaCodeList.size() - 1);
+                                    Map<String, String> superAreaMap = chinaAreaMap.get(superAreaCode).entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
+                                    if (superAreaMap.containsKey(itemStr)) {
+                                        return concatStr.concat("/").concat(superAreaMap.get(itemStr));
+                                    } else {
+                                        customizeErrorColumn("合同所属地区编码校验未通过", finalRowNum, errorMap);
+                                        return concatStr;
+                                    }
                                 }
                             }
-                        }
-                    });
-                    contract.setContractAreaCode(contractAreaCode);
+                        });
+                        contract.setContractAreaCode(contractAreaCode);
+                    } catch (Exception e) {
+                        customizeErrorColumn("合同所属地区输入错误", rowNum, errorMap);
+                    }
                 }
                 if (checkRequiredColumn(row, "合同类型", rowNum, errorMap) && checkTypeColumn(row, "合同类型", rowNum, errorMap)) {
                     contract.setContractType(ElAdminConstant.Enum.ContractTypeDict.findByImportValue(row.get("合同类型").toString()).getDictValue());
@@ -1366,7 +1380,18 @@
 
                     if (checkRequiredColumn(row, "开票日期", rowNum, errorMap)) {
                         // billingTime
-                        invoice.setBillingTime(Timestamp.valueOf(row.get("开票日期").toString()));
+                        try {
+                            invoice.setBillingTime(Timestamp.valueOf(row.get("开票日期").toString()));
+                        } catch (IllegalArgumentException illegalArgumentException) {
+                            try {
+                                // 仅日期转换问题再次尝试
+                                invoice.setBillingTime(Timestamp.valueOf(useSdf.format(sdf.parse(row.get("开票日期").toString()))));
+                            } catch (Exception e) {
+                                customizeErrorColumn("开票日期输入错误", rowNum, errorMap);
+                            }
+                        } catch (Exception e) {
+                            customizeErrorColumn("开票日期输入错误", rowNum, errorMap);
+                        }
                     }
                     if (checkRequiredColumn(row, "税前开票金额", rowNum, errorMap)) {
                         // beforeTaxAmount
@@ -1394,10 +1419,23 @@
                 if (ObjectUtil.isNotEmpty(row.get("付款总金额"))) {
                     // paymentTotalAmount(计算)
                     payment.setPaymentAmount(new BigDecimal(row.get("付款总金额").toString()));
+                    // NOTE:暂定算为合同收入,PaymentType为无处使用字段,此行代码仅为通过验证,可删除
+                    payment.setPaymentType(Constant.CONTRACR_REVENUE);
 
                     if (checkRequiredColumn(row, "付款时间", rowNum, errorMap)) {
                         // paymentTime(合同付款信息)
-                        payment.setPaymentTime(Timestamp.valueOf(row.get("付款时间").toString()));
+                        try {
+                            payment.setPaymentTime(Timestamp.valueOf(row.get("付款时间").toString()));
+                        } catch (IllegalArgumentException illegalArgumentException) {
+                            try {
+                                // 仅日期转换问题再次尝试
+                                payment.setPaymentTime(Timestamp.valueOf(useSdf.format(sdf.parse(row.get("付款时间").toString()))));
+                            } catch (Exception e) {
+                                customizeErrorColumn("付款时间输入错误", rowNum, errorMap);
+                            }
+                        } catch (Exception e) {
+                            customizeErrorColumn("付款时间输入错误", rowNum, errorMap);
+                        }
                     }
                     if (checkRequiredColumn(row, "付款类型", rowNum, errorMap) && checkTypeColumn(row, "付款类型", rowNum, errorMap)) {
                         // fundType
@@ -1432,46 +1470,50 @@
 //                if (checkRequiredColumn(row, "应收款金额", rowNum, errorMap)) {
 //                    // receivePayment(计算)
 //                }
-                if (ObjectUtil.isNotEmpty(row.get("合同类型(二级)")) && !row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_SERVICE)) {
-                    if (checkRequiredColumn(row, "合同费金额", rowNum, errorMap)) {
-                        contract.setContractAmount(new BigDecimal(row.get("合同费金额").toString()));
+                if (ObjectUtil.isNotEmpty(row.get("合同类型")) && ObjectUtil.isNotEmpty(row.get("合同类型(二级)"))) {
+                    // 合同费
+                    if (!(row.get("合同类型").toString().equals(Constant.CONTRACT_TECHNOLOGY) && row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_SERVICE))) {
+                        if (checkRequiredColumn(row, "合同费金额", rowNum, errorMap)) {
+                            contract.setContractAmount(new BigDecimal(row.get("合同费金额").toString()));
+                        }
+                        if (checkRequiredColumn(row, "合同费预计付款日期", rowNum, errorMap)) {
+                            contract.setContractPaymentDate(Timestamp.valueOf(row.get("合同费预计付款日期").toString()));
+                        }
+                        if (checkRequiredColumn(row, "合同费付款状态", rowNum, errorMap) && checkTypeColumn(row, "合同费付款状态", rowNum, errorMap)) {
+                            if (row.get("合同费付款状态").toString().equals("未付款")) {
+                                contract.setContractPaymentState(Constant.PAYMENT_NOT);
+                            } else if (row.get("合同费付款状态").toString().equals("部分付款")) {
+                                contract.setContractPaymentState(Constant.PAYMENT_PART);
+                            } else if (row.get("合同费付款状态").toString().equals("已付款")) {
+                                contract.setContractPaymentState(Constant.PAYMENT_ALREADY);
+                            }
+                        }
                     }
-                    if (checkRequiredColumn(row, "合同费预计付款日期", rowNum, errorMap)) {
-                        contract.setContractPaymentDate(Timestamp.valueOf(row.get("合同费预计付款日期").toString()));
-                    }
-                    if (checkRequiredColumn(row, "合同费付款状态", rowNum, errorMap) && checkTypeColumn(row, "合同费付款状态", rowNum, errorMap)) {
-                        if (row.get("合同费付款状态").toString().equals("未付款")) {
-                            contract.setContractPaymentState(Constant.PAYMENT_NOT);
-                        } else if (row.get("合同费付款状态").toString().equals("部分付款")) {
-                            contract.setContractPaymentState(Constant.PAYMENT_PART);
-                        } else if (row.get("合同费付款状态").toString().equals("已付款")) {
-                            contract.setContractPaymentState(Constant.PAYMENT_ALREADY);
+                    // 服务费
+                    if (row.get("合同类型").toString().equals(Constant.CONTRACT_TECHNOLOGY) && (row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_SERVICE) || row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_DEVELOP_SERVICE))) {
+                        if (row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_DEVELOP_SERVICE) && checkRequiredColumn(row, "服务开始日期", rowNum, errorMap)) {
+                            contract.setServiceStartsDate(Timestamp.valueOf(row.get("服务开始日期").toString()));
+                        }
+                        if (checkRequiredColumn(row, "服务费金额", rowNum, errorMap)) {
+                            contract.setServiceAmount(new BigDecimal(row.get("服务费金额").toString()));
+                        }
+                        if (checkRequiredColumn(row, "服务费预计付款日期", rowNum, errorMap)) {
+                            contract.setServicePaymentDate(Timestamp.valueOf(row.get("服务费预计付款日期").toString()));
+                        }
+                        if (checkRequiredColumn(row, "服务费付款状态", rowNum, errorMap) && checkTypeColumn(row, "服务费付款状态", rowNum, errorMap)) {
+                            if (row.get("服务费付款状态").toString().equals("未付款")) {
+                                contract.setServicePaymentState(Constant.PAYMENT_NOT);
+                            } else if (row.get("服务费付款状态").toString().equals("部分付款")) {
+                                contract.setServicePaymentState(Constant.PAYMENT_PART);
+                            } else if (row.get("服务费付款状态").toString().equals("已付款")) {
+                                contract.setServicePaymentState(Constant.PAYMENT_ALREADY);
+                            }
                         }
                     }
                 }
 //                if (checkRequiredColumn(row, "合同费延期情况", rowNum, errorMap)) {
 //                    // contractPostponement
 //                }
-                if (ObjectUtil.isNotEmpty(row.get("合同类型(二级)")) && (row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_SERVICE) || row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_DEVELOP_SERVICE))) {
-                    if (row.get("合同类型(二级)").toString().equals(Constant.CONTRACT_DEVELOP_SERVICE) && checkRequiredColumn(row, "服务开始日期", rowNum, errorMap)) {
-                        contract.setServiceStartsDate(Timestamp.valueOf(row.get("服务开始日期").toString()));
-                    }
-                    if (checkRequiredColumn(row, "服务费金额", rowNum, errorMap)) {
-                        contract.setServiceAmount(new BigDecimal(row.get("服务费金额").toString()));
-                    }
-                    if (checkRequiredColumn(row, "服务费预计付款日期", rowNum, errorMap)) {
-                        contract.setServicePaymentDate(Timestamp.valueOf(row.get("服务费预计付款日期").toString()));
-                    }
-                    if (checkRequiredColumn(row, "服务费付款状态", rowNum, errorMap) && checkTypeColumn(row, "服务费付款状态", rowNum, errorMap)) {
-                        if (row.get("服务费付款状态").toString().equals("未付款")) {
-                            contract.setServicePaymentState(Constant.PAYMENT_NOT);
-                        } else if (row.get("服务费付款状态").toString().equals("部分付款")) {
-                            contract.setServicePaymentState(Constant.PAYMENT_PART);
-                        } else if (row.get("服务费付款状态").toString().equals("已付款")) {
-                            contract.setServicePaymentState(Constant.PAYMENT_ALREADY);
-                        }
-                    }
-                }
 //                if (checkRequiredColumn(row, "服务费延期情况", rowNum, errorMap)) {
 //                    // servicePostponement
 //                }
@@ -1576,6 +1618,11 @@
         } catch (Exception e){
             e.printStackTrace();
             throw new BadRequestException("数据保存失败");
+        } finally {
+            reader.close();
+            if (uploadFile.exists()) {
+                uploadFile.deleteOnExit();
+            }
         }
 
         return finalMap;
@@ -1654,6 +1701,13 @@
         }
     }
 
+    private Boolean customizeErrorColumn(String key, Integer rowNum, Map<String, List<Integer>> errorMap) {
+        List<Integer> errorRows = errorMap.containsKey(key) ? errorMap.get(key) : new ArrayList<>();
+        errorRows.add(rowNum);
+        errorMap.put(key, errorRows);
+        return false;
+    }
+
     /**
      * 预警
      *

--
Gitblit v1.9.3