Merge branch 'wcd-2411-update' of http://192.168.1.110:5678/r/pms-upgrade into wcd
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | |
| | | "CASE WHEN ?8 IS NOT NULL THEN contract_payment_state = ?8 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?9 IS NOT NULL THEN service_payment_state = ?9 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?10 IS NOT NULL THEN contract_status = ?10 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?11 IS NOT NULL THEN contract_area_code LIKE concat(?11,'%') ELSE 1 = 1 END",nativeQuery = true) |
| | | "CASE WHEN ?11 IS NOT NULL THEN contract_area_code LIKE concat(?11,'%') ELSE 1 = 1 END AND " + |
| | | "company_id IN ?12",nativeQuery = true) |
| | | BigDecimal contractTotalMoney( |
| | | String contractNumber, String contractName, Long firstId, Long secondId, String signStartDate, String signEndDate, String contractType, String contractPaymentState, |
| | | String servicePaymentState, String contractStatus, String contractAreaCode |
| | | String servicePaymentState, String contractStatus, String contractAreaCode, Set<Long> companyIdSet |
| | | ); |
| | | |
| | | /** |
| | |
| | | "CASE WHEN ?9 IS NOT NULL THEN service_payment_state = ?9 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?10 IS NOT NULL THEN contract_status = ?10 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?11 IS NOT NULL THEN contract_area_code LIKE concat(?11,'%') ELSE 1 = 1 END AND " + |
| | | "contract_amount IS NOT NULL AND contract_amount != ''",nativeQuery = true) |
| | | "contract_amount IS NOT NULL AND contract_amount != '' AND company_id IN ?12",nativeQuery = true) |
| | | List<Contract> findContractAmountNotNull( |
| | | String contractNumber, String contractName, Long firstId, Long secondId, String signStartDate, String signEndDate, String contractType, String contractPaymentState, |
| | | String servicePaymentState, String contractStatus, String contractAreaCode |
| | | String servicePaymentState, String contractStatus, String contractAreaCode, Set<Long> companyIdSet |
| | | ); |
| | | |
| | | /** |
| | |
| | | "CASE WHEN ?8 IS NOT NULL THEN contract_payment_state = ?8 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?9 IS NOT NULL THEN service_payment_state = ?9 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?10 IS NOT NULL THEN contract_status = ?10 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?11 IS NOT NULL THEN contract_area_code LIKE concat(?11,'%') ELSE 1 = 1 END",nativeQuery = true) |
| | | "CASE WHEN ?11 IS NOT NULL THEN contract_area_code LIKE concat(?11,'%') ELSE 1 = 1 END AND " + |
| | | "company_id IN ?12",nativeQuery = true) |
| | | BigDecimal serviceTotalMoney( |
| | | String contractNumber, String contractName, Long firstId, Long secondId, String signStartDate, String signEndDate, String contractType, String contractPaymentState, |
| | | String servicePaymentState, String contractStatus, String contractAreaCode |
| | | String servicePaymentState, String contractStatus, String contractAreaCode, Set<Long> companyIdSet |
| | | ); |
| | | |
| | | /** |
| | |
| | | "CASE WHEN ?9 IS NOT NULL THEN service_payment_state = ?9 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?10 IS NOT NULL THEN contract_status = ?10 ELSE 1 = 1 END AND " + |
| | | "CASE WHEN ?11 IS NOT NULL THEN contract_area_code LIKE concat(?11,'%') ELSE 1 = 1 END AND " + |
| | | "service_amount IS NOT NULL AND service_amount != ''",nativeQuery = true) |
| | | "service_amount IS NOT NULL AND service_amount != '' AND company_id IN ?12",nativeQuery = true) |
| | | List<Contract> findServiceAmountNotNull( |
| | | String contractNumber, String contractName, Long firstId, Long secondId, String signStartDate, String signEndDate, String contractType, String contractPaymentState, |
| | | String servicePaymentState, String contractStatus, String contractAreaCode |
| | | String servicePaymentState, String contractStatus, String contractAreaCode, Set<Long> companyIdSet |
| | | ); |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public Integer contractDelayTotalAmount(ContractQueryCriteria criteria){ |
| | | criteria.setCompanys(SecurityUtils.getCompanyIds()); |
| | | // 合同款延期数 |
| | | Integer contractDelayTotalAmount = 0; |
| | | // 搜索数据处理 |
| | |
| | | // 查询有合同款的合同数据 |
| | | 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 ++) { |
| | |
| | | */ |
| | | @Override |
| | | public BigDecimal contractDelayTotalMoney(ContractQueryCriteria criteria){ |
| | | criteria.setCompanys(SecurityUtils.getCompanyIds()); |
| | | // 合同款延期金额 |
| | | BigDecimal contractDelayTotalMoney = new BigDecimal("0.00"); |
| | | // 搜索数据处理 |
| | |
| | | // 查询有合同款的合同数据 |
| | | 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 ++) { |
| | |
| | | */ |
| | | @Override |
| | | public BigDecimal advancePaymentTotalMoney(ContractQueryCriteria criteria){ |
| | | criteria.setCompanys(SecurityUtils.getCompanyIds()); |
| | | // 预收款总金额 |
| | | BigDecimal advancePaymentTotalMoney = new BigDecimal("0.00"); |
| | | // 查询所有合同信息 |
| | |
| | | */ |
| | | @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; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public Integer serviceDelayTotalAmount(ContractQueryCriteria criteria){ |
| | | criteria.setCompanys(SecurityUtils.getCompanyIds()); |
| | | // 运维服务延期数 |
| | | Integer serviceDelayTotalAmount = 0; |
| | | // 搜索数据处理 |
| | |
| | | // 查询有运维服务的合同数据 |
| | | 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 ++) { |
| | |
| | | */ |
| | | @Override |
| | | public BigDecimal serviceDelayTotalMoney(ContractQueryCriteria criteria){ |
| | | criteria.setCompanys(SecurityUtils.getCompanyIds()); |
| | | // 运维服务延期金额 |
| | | BigDecimal serviceDelayTotalMoney = new BigDecimal("0.00"); |
| | | // 搜索数据处理 |
| | |
| | | // 查询有运维服务的合同数据 |
| | | 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 ++) { |
| | |
| | | */ |
| | | @Override |
| | | public BigDecimal receivePaymentTotalMoney(ContractQueryCriteria criteria){ |
| | | criteria.setCompanys(SecurityUtils.getCompanyIds()); |
| | | // 应收款总金额 |
| | | BigDecimal receivePaymentTotalMoney = new BigDecimal("0.00"); |
| | | // 查询所有合同信息 |
| | |
| | | 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; |
| | | try { |
| | | String contractAreaCode = Arrays.stream(contractArea.split("/")).filter(item -> StringUtils.isNotBlank(item)).reduce("", (concatStr, itemStr) -> { |
| | | if (concatStr.length() == 0) { |
| | | return provinceMap.get(itemStr); |
| | |
| | | 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); |
| | | customizeErrorColumn("合同所属地区编码校验未通过", finalRowNum, errorMap); |
| | | return concatStr; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | 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 |
| | | 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(合同付款信息) |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 预警 |
| | | * |