private QutationModifyRecord convertQuotationRecord( ModifyRecord record, LocaleConstants locale, BusinessType businessType) { QutationModifyRecord res = new QutationModifyRecord(); res.setId(record.getId()); res.setCreateOperator(record.getCreateOperator()); res.setModifiedDataId(record.getModifiedDataId()); res.setModifyField(record.getModifyField()); res.setNewValue(record.getNewValue()); res.setOldValue(record.getOldValue()); res.setOperateType(record.getOperateType()); res.setTableName(record.getTableName()); res.setCreateTime(record.getCreateTime()); if (res.getCreateOperator() != null) { Account acc = userService.getAccountByUcId(res.getCreateOperator()); if (acc != null) { res.setOperatorName(acc.getName()); } } List<Code> priceTypeAll = codeServiceImpl.getAllByCodeTypeAndLoacle("quotationMain.priceType", locale.name()); Map<String, Code> priceTypeMap = new HashMap<String, Code>(); if (CollectionUtils.isNotEmpty(priceTypeAll)) { for (Code code : priceTypeAll) { priceTypeMap.put(code.getCodeValue(), code); } } List<Code> businessTypeAll = codeServiceImpl.getAllByCodeTypeAndLoacle("quotationMain.businessType", locale.name()); Map<String, Code> businessTypeMap = new HashMap<String, Code>(); if (CollectionUtils.isNotEmpty(businessTypeAll)) { for (Code code : businessTypeAll) { businessTypeMap.put(code.getCodeValue(), code); } } if (StringUtils.isNotBlank(res.getModifyField())) { DecimalFormat df2 = new DecimalFormat("#.###"); if (res.getModifyField().contains(MODIFY_RECORD_FIELD_CPS)) { // cps List<ModifyTableInfo> table = modifyTableInfoRepository.findByTableNameAndTableFieldAndLocal( MODIFY_RECORD_TABLE_NAME, MODIFY_RECORD_FIELD_CPS, locale.name()); String field = ""; if (table != null && table.size() == 1) { field = table.get(0).getFieldName(); } String[] arr = res.getModifyField().split("\\."); if (arr.length == 2) { String industryId = arr[1]; Code code = codeServiceImpl.getCodeByTypeAndValueAndLocale( "quotationMain.industry", industryId, locale.name()); if (code != null) { field = field + "_" + code.getI18nName(); } } if (StringUtils.isNotBlank(field)) { res.setFieldName(field); } if (StringUtils.isNotBlank(res.getNewValue())) { res.setNewValue(df2.format(Double.valueOf(res.getNewValue()) * 100) + "%"); } if (StringUtils.isNotBlank(res.getOldValue())) { res.setOldValue(df2.format(Double.valueOf(res.getOldValue()) * 100) + "%"); } } else { List<ModifyTableInfo> table = modifyTableInfoRepository.findByTableNameAndTableFieldAndLocal( MODIFY_RECORD_TABLE_NAME, res.getModifyField(), locale.name()); if (table != null && table.size() == 1) { res.setFieldName(table.get(0).getFieldName()); } if (MODIFY_RECORD_FIELD_RATIOREBATE.equals(res.getModifyField()) || MODIFY_RECORD_FIELD_RATIOMINE.equals(res.getModifyField()) || MODIFY_RECORD_FIELD_RATIOCUS.equals(res.getModifyField()) || MODIFY_RECORD_FIELD_RATIO3TH.equals(res.getModifyField())) { // 涉及到比例的类型 if (StringUtils.isNotBlank(res.getNewValue())) { res.setNewValue(df2.format(Double.valueOf(res.getNewValue()) * 100) + "%"); } if (StringUtils.isNotBlank(res.getOldValue())) { res.setOldValue(df2.format(Double.valueOf(res.getOldValue()) * 100) + "%"); } } // 业务类型 if (MODIFY_RECORD_FIELD_BUSSINESSTYPE.equals(res.getModifyField())) { if (StringUtils.isNotBlank(res.getNewValue())) { res.setNewValue(businessTypeMap.get(res.getNewValue()).getI18nName()); } if (StringUtils.isNotBlank(res.getOldValue())) { res.setOldValue(businessTypeMap.get(res.getOldValue()).getI18nName()); } } // 价格种类 if (MODIFY_RECORD_FIELD_PRICETYPE.equals(res.getModifyField())) { if (StringUtils.isNotBlank(res.getNewValue())) { res.setNewValue(priceTypeMap.get(res.getNewValue()).getI18nName()); } if (StringUtils.isNotBlank(res.getOldValue())) { res.setOldValue(priceTypeMap.get(res.getOldValue()).getI18nName()); } } // 平台 if (MODIFY_RECORD_FIELD_PLATFORM.equals(res.getModifyField())) { if (StringUtils.isNotBlank(res.getNewValue())) { AdvertisingPlatform platform = adPlatformService.getByIdAndLocale(res.getNewValue(), locale); if (platform != null) { res.setNewValue(platform.getI18nName()); } } if (StringUtils.isNotBlank(res.getOldValue())) { AdvertisingPlatform platform = adPlatformService.getByIdAndLocale(res.getOldValue(), locale); if (platform != null) { res.setOldValue(platform.getI18nName()); } } } // 站点区域 if (MODIFY_RECORD_FIELD_SITE.equals(res.getModifyField())) { if (StringUtils.isNotBlank(res.getNewValue())) { if (BusinessType.CASH.equals(businessType)) { // 变现 Site site = siteService.findSiteAndI18nById(Long.valueOf(res.getNewValue()), locale); if (site != null) { res.setNewValue(site.getI18nName()); } } if (BusinessType.SALE.equals(businessType)) { // 销售 AgentRegional agent = agentRegionalService.getByIdAndLocale(res.getNewValue(), locale); if (agent != null) { res.setNewValue(agent.getI18nName()); } } } if (StringUtils.isNotBlank(res.getOldValue())) { if (BusinessType.CASH.equals(businessType)) { // 变现 Site site = siteService.findSiteAndI18nById(Long.valueOf(res.getOldValue()), locale); if (site != null) { res.setOldValue(site.getI18nName()); } } if (BusinessType.SALE.equals(businessType)) { // 销售 AgentRegional agent = agentRegionalService.getByIdAndLocale(res.getOldValue(), locale); if (agent != null) { res.setOldValue(agent.getI18nName()); } } } } } } return res; }