| | |
| | | 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) { |
| | |
| | | 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()); |
| | |
| | | |
| | | 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 |
| | |
| | | |
| | | 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 |
| | |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 预警 |
| | | * |