Beispiel #1
0
  public void calculateFromAppUserRecordDTO(AppUserCommentRecordDTO appUserCommentRecordDTO) {

    double commentScore = appUserCommentRecordDTO.getCommentScore(); // 手机端评价分数
    this.setCommentTotalScore(NumberUtil.doubleVal(this.getCommentTotalScore()) + commentScore);
    this.setRecordAmount(NumberUtil.longValue(this.getRecordAmount()) + 1);

    if (commentScore == 5) {
      this.setCommentFiveAmount(NumberUtil.longValue(this.getCommentFiveAmount()) + 1);
    } else if (commentScore == 4) {
      this.setCommentFourAmount(NumberUtil.longValue(this.getCommentFourAmount()) + 1);
    } else if (commentScore == 3) {
      this.setCommentThreeAmount(NumberUtil.longValue(this.getCommentThreeAmount()) + 1);
    } else if (commentScore == 2) {
      this.setCommentTwoAmount(NumberUtil.longValue(this.getCommentTwoAmount()) + 1);
    } else {
      this.setCommentOneAmount(NumberUtil.longValue(this.getCommentOneAmount()) + 1);
    }
  }
Beispiel #2
0
  public void calculate() {
    if (getRecordAmount() == 0L) {
      this.setTotalScore(0D);
      this.setTotalScoreSpan(ZER0_SPAN);
      this.setQualityScoreSpan(ZER0_SPAN);
      this.setPerformanceScoreSpan(ZER0_SPAN);
      this.setAttitudeScoreSpan(ZER0_SPAN);
      this.setSpeedScoreSpan(ZER0_SPAN);

    } else {
      double recordAmount = getRecordAmount().doubleValue();

      if (NumberUtil.longValue(this.getCommentFiveAmount())
              + NumberUtil.longValue(this.getCommentFourAmount())
              + NumberUtil.longValue(this.getCommentThreeAmount())
              + NumberUtil.longValue(this.getCommentTwoAmount())
              + NumberUtil.longValue(this.getCommentOneAmount())
          <= 0) {
        this.setTotalScore(
            NumberUtil.toReserve(
                (getTotalScore() + NumberUtil.doubleVal(getCommentTotalScore()))
                    / (getRecordAmount() * 4)));
      } else {
        this.setTotalScore(
            NumberUtil.round(
                (this.getTotalScore() + NumberUtil.doubleVal(this.getCommentTotalScore()))
                    / this.getRecordAmount(),
                1));
      }

      int totalScoreIntValue = getTotalScore().intValue();
      if (getTotalScore() - totalScoreIntValue > 0) {
        this.setTotalScoreSpan(
            ((5 - totalScoreIntValue - CommentConstant.SCORE_UNIT) / CommentConstant.SCORE_UNIT)
                * CommentConstant.SPAN_SIZE);
      } else {
        this.setTotalScoreSpan(
            ((5 - totalScoreIntValue) / CommentConstant.SCORE_UNIT) * CommentConstant.SPAN_SIZE);
      }

      this.setQualityTotalScore(NumberUtil.toReserve(getQualityTotalScore() / getRecordAmount()));
      int qualityScoreIntValue = getQualityTotalScore().intValue();
      if (getQualityTotalScore() - qualityScoreIntValue > 0) {
        this.setQualityScoreSpan(
            ((5 - qualityScoreIntValue - CommentConstant.SCORE_UNIT) / CommentConstant.SCORE_UNIT)
                * CommentConstant.SPAN_SIZE);
      } else {
        this.setQualityScoreSpan(
            ((5 - qualityScoreIntValue) / CommentConstant.SCORE_UNIT) * CommentConstant.SPAN_SIZE);
      }

      this.setQualityFiveAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getQualityFiveAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setQualityFourAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getQualityFourAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setQualityThreeAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getQualityThreeAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setQualityTwoAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getQualityTwoAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setQualityOneAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getQualityOneAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);

      this.setPerformanceTotalScore(
          NumberUtil.toReserve(getPerformanceTotalScore() / getRecordAmount()));

      int performanceScoreIntValue = getPerformanceTotalScore().intValue();
      if (getPerformanceTotalScore() - performanceScoreIntValue > 0) {
        this.setPerformanceScoreSpan(
            ((5 - performanceScoreIntValue - CommentConstant.SCORE_UNIT)
                    / CommentConstant.SCORE_UNIT)
                * CommentConstant.SPAN_SIZE);
      } else {
        this.setPerformanceScoreSpan(
            ((5 - performanceScoreIntValue) / CommentConstant.SCORE_UNIT)
                * CommentConstant.SPAN_SIZE);
      }

      this.setPerformanceFiveAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getPerformanceFiveAmount() * HUNDRED / recordAmount,
                      NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setPerformanceFourAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getPerformanceFourAmount() * HUNDRED / recordAmount,
                      NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setPerformanceThreeAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getPerformanceThreeAmount() * HUNDRED / recordAmount,
                      NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setPerformanceTwoAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getPerformanceTwoAmount() * HUNDRED / recordAmount,
                      NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setPerformanceOneAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getPerformanceOneAmount() * HUNDRED / recordAmount,
                      NumberUtil.MONEY_PRECISION))
              + PERCENT);

      this.setSpeedTotalScore(NumberUtil.toReserve(getSpeedTotalScore() / getRecordAmount()));

      int speedScoreIntValue = getSpeedTotalScore().intValue();
      if (getSpeedTotalScore() - speedScoreIntValue > 0) {
        this.setSpeedScoreSpan(
            ((5 - speedScoreIntValue - CommentConstant.SCORE_UNIT) / CommentConstant.SCORE_UNIT)
                * CommentConstant.SPAN_SIZE);
      } else {
        this.setSpeedScoreSpan(
            ((5 - speedScoreIntValue) / CommentConstant.SCORE_UNIT) * CommentConstant.SPAN_SIZE);
      }

      this.setSpeedFiveAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getSpeedFiveAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setSpeedFourAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getSpeedFourAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setSpeedThreeAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getSpeedThreeAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setSpeedTwoAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getSpeedTwoAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setSpeedOneAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getSpeedOneAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);

      this.setAttitudeTotalScore(NumberUtil.toReserve(getAttitudeTotalScore() / getRecordAmount()));

      int attitudeScoreIntValue = getAttitudeTotalScore().intValue();
      if (getAttitudeTotalScore() - attitudeScoreIntValue > 0) {
        this.setAttitudeScoreSpan(
            ((5 - attitudeScoreIntValue - CommentConstant.SCORE_UNIT) / CommentConstant.SCORE_UNIT)
                * CommentConstant.SPAN_SIZE);
      } else {
        this.setAttitudeScoreSpan(
            ((5 - attitudeScoreIntValue) / CommentConstant.SCORE_UNIT) * CommentConstant.SPAN_SIZE);
      }

      this.setAttitudeFiveAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getAttitudeFiveAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setAttitudeFourAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getAttitudeFourAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setAttitudeThreeAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getAttitudeThreeAmount() * HUNDRED / recordAmount,
                      NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setAttitudeTwoAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getAttitudeTwoAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
      this.setAttitudeOneAmountPer(
          String.valueOf(
                  NumberUtil.toReserve(
                      getAttitudeOneAmount() * HUNDRED / recordAmount, NumberUtil.MONEY_PRECISION))
              + PERCENT);
    }
  }
  public CustomerSupplierSolrIndexDTO(CustomerDTO customerDTO, String doc_type) {
    this.doc_type = doc_type;
    this.id = customerDTO.getId();
    this.shop_id = customerDTO.getShopId();
    this.customer_or_supplier = "customer";
    this.customer_or_supplier_shop_id =
        customerDTO.getCustomerShopId() == null ? "" : customerDTO.getCustomerShopId().toString();
    this.name = customerDTO.getName();
    this.address = customerDTO.getAddress();
    this.contactDTOList = customerDTO.getContactDTOList();
    this.created_time = customerDTO.getCreationDate();
    if (CollectionUtils.isNotEmpty(customerDTO.getVehicleDTOList())) {
      license_nos = new ArrayList<String>();
      vehicle_brands = new ArrayList<String>();
      vehicle_models = new ArrayList<String>();
      vehicle_colors = new ArrayList<String>();
      vehicle_details = new ArrayList<String>();
      for (VehicleDTO vehicleDTO : customerDTO.getVehicleDTOList()) {
        StringBuffer sb = new StringBuffer();
        if (StringUtils.isNotBlank(vehicleDTO.getLicenceNo())) {
          license_nos.add(vehicleDTO.getLicenceNo());
          sb.append(vehicleDTO.getLicenceNo());
        }
        if (StringUtils.isNotBlank(vehicleDTO.getBrand())) {
          vehicle_brands.add(vehicleDTO.getBrand());
          sb.append(" ").append(vehicleDTO.getBrand());
        }
        if (StringUtils.isNotBlank(vehicleDTO.getModel())) {
          vehicle_models.add(vehicleDTO.getModel());
          sb.append(" ").append(vehicleDTO.getModel());
        }
        if (StringUtils.isNotBlank(vehicleDTO.getColor())) {
          vehicle_colors.add(vehicleDTO.getColor());
          sb.append(" ").append(vehicleDTO.getColor());
        }
        vehicle_details.add(sb.toString().trim());
      }
    }
    this.total_amount = customerDTO.getTotalAmount();
    this.total_debt = customerDTO.getTotalReceivable();
    this.last_expense_time = customerDTO.getLastExpenseTime();
    this.total_return_debt = customerDTO.getTotalReturnDebt();

    if (customerDTO.getMemberDTO() != null
        && customerDTO.getMemberDTO().getStatus() != MemberStatus.DISABLED) {
      this.member_no = customerDTO.getMemberDTO().getMemberNo();
      this.member_type = customerDTO.getMemberDTO().getType();
      this.balance = NumberUtil.doubleVal(customerDTO.getMemberDTO().getBalance());
    } else {
      this.member_type = "非会员";
    }
    this.status = customerDTO.getStatus();
    this.relationType = customerDTO.getRelationType();
    this.vehicles = customerDTO.getVehicleDTOList();
    List<Long> areaIdList = new ArrayList<Long>();
    if (customerDTO.getProvince() != null) {
      areaIdList.add(customerDTO.getProvince());
    }
    if (customerDTO.getCity() != null) {
      areaIdList.add(customerDTO.getCity());
    }
    if (customerDTO.getRegion() != null) {
      areaIdList.add(customerDTO.getRegion());
    }
    this.setArea_ids(areaIdList);
    this.setArea_info(customerDTO.getAreaInfo());
    this.setDual_identity_id(customerDTO.getSupplierId());
    this.total_deposit = customerDTO.getDeposit();
    this.is_obd = customerDTO.getIsObd();
    this.setAppUser(customerDTO.isAppUser());
  }
Beispiel #4
0
  public void calculateFromSupplierRecordDTO(SupplierCommentRecordDTO supplierCommentRecordDTO) {
    double qualityScoreFromRecord; // 质量分数
    double performanceScoreFromRecord; // 性价比分数
    double speedScoreFromRecord; // 发货速度分数
    double attitudeScoreFromRecord; // 服务态度分数
    double totalScoreFromRecord; // 总分

    this.setRecordAmount(this.getRecordAmount() + 1);

    qualityScoreFromRecord = NumberUtil.doubleVal(supplierCommentRecordDTO.getQualityScore());
    performanceScoreFromRecord =
        NumberUtil.doubleVal(supplierCommentRecordDTO.getPerformanceScore());
    speedScoreFromRecord = NumberUtil.doubleVal(supplierCommentRecordDTO.getSpeedScore());
    attitudeScoreFromRecord = NumberUtil.doubleVal(supplierCommentRecordDTO.getAttitudeScore());

    totalScoreFromRecord =
        qualityScoreFromRecord
            + performanceScoreFromRecord
            + speedScoreFromRecord
            + attitudeScoreFromRecord;

    this.setTotalScore(getTotalScore() + totalScoreFromRecord);
    this.setQualityTotalScore(this.getQualityTotalScore() + qualityScoreFromRecord);
    this.setPerformanceTotalScore(this.getPerformanceTotalScore() + performanceScoreFromRecord);
    this.setSpeedTotalScore(this.getSpeedTotalScore() + speedScoreFromRecord);
    this.setAttitudeTotalScore(this.getAttitudeTotalScore() + attitudeScoreFromRecord);

    if (qualityScoreFromRecord == 5) {
      this.setQualityFiveAmount(this.getQualityFiveAmount() + 1);
    } else if (qualityScoreFromRecord == 4) {
      this.setQualityFourAmount(this.getQualityFourAmount() + 1);
    } else if (qualityScoreFromRecord == 3) {
      this.setQualityThreeAmount(this.getQualityThreeAmount() + 1);
    } else if (qualityScoreFromRecord == 2) {
      this.setQualityTwoAmount(this.getQualityTwoAmount() + 1);
    } else {
      this.setQualityOneAmount(this.getQualityOneAmount() + 1);
    }

    if (performanceScoreFromRecord == 5) {
      this.setPerformanceFiveAmount(this.getPerformanceFiveAmount() + 1);
    } else if (performanceScoreFromRecord == 4) {
      this.setPerformanceFourAmount(this.getPerformanceFourAmount() + 1);
    } else if (performanceScoreFromRecord == 3) {
      this.setPerformanceThreeAmount(this.getPerformanceThreeAmount() + 1);
    } else if (performanceScoreFromRecord == 2) {
      this.setPerformanceTwoAmount(this.getPerformanceTwoAmount() + 1);
    } else {
      this.setPerformanceOneAmount(this.getPerformanceOneAmount() + 1);
    }

    if (speedScoreFromRecord == 5) {
      this.setSpeedFiveAmount(this.getSpeedFiveAmount() + 1);
    } else if (speedScoreFromRecord == 4) {
      this.setSpeedFourAmount(this.getSpeedFourAmount() + 1);
    } else if (speedScoreFromRecord == 3) {
      this.setSpeedThreeAmount(this.getSpeedThreeAmount() + 1);
    } else if (speedScoreFromRecord == 2) {
      this.setSpeedTwoAmount(this.getSpeedTwoAmount() + 1);
    } else {
      this.setSpeedOneAmount(this.getSpeedOneAmount() + 1);
    }

    if (attitudeScoreFromRecord == 5) {
      this.setAttitudeFiveAmount(this.getAttitudeFiveAmount() + 1);
    } else if (attitudeScoreFromRecord == 4) {
      this.setAttitudeFourAmount(this.getAttitudeFourAmount() + 1);
    } else if (attitudeScoreFromRecord == 3) {
      this.setAttitudeThreeAmount(this.getAttitudeThreeAmount() + 1);
    } else if (attitudeScoreFromRecord == 2) {
      this.setAttitudeTwoAmount(this.getAttitudeTwoAmount() + 1);
    } else {
      this.setAttitudeOneAmount(this.getAttitudeOneAmount() + 1);
    }
  }
  /**
   * 客户 供应商 名称 联系人 车牌号 用左右模糊 词的意义不大 不做分词 所以对应的拼音也不做分词
   *
   * @return
   * @throws Exception
   */
  public SolrInputDocument toSolrDocument() throws Exception {
    SolrInputDocument doc = null;
    PingyinInfo pingyinInfo = null;
    try {
      doc = new SolrInputDocument();
      if (shop_id == null) throw new Exception("shopId is null");

      doc.addField("id", this.id);
      doc.addField("doc_type", this.doc_type);
      doc.addField("shop_id", this.shop_id);

      if (StringUtils.isNotBlank(land_line)) {
        doc.addField("land_line", this.land_line);
      }
      doc.addField("customer_or_supplier", this.customer_or_supplier);
      doc.addField("customer_or_supplier_shop_id", this.customer_or_supplier_shop_id);

      if (StringUtils.isNotBlank(name)) {
        doc.addField("name", this.name);
      } else {
        doc.addField("name", "未填写");
        LOG.warn("[{}-id:{}] name is null.", this.customer_or_supplier, this.id);
      }
      if (CollectionUtils.isNotEmpty(getContactDTOList())) {
        for (ContactDTO contactDTO : getContactDTOList()) {
          if (contactDTO.getId() == null
              || (StringUtils.isBlank(contactDTO.getName())
                  && StringUtils.isBlank(contactDTO.getMobile()))) continue;

          doc.addField("contact_id", contactDTO.getId());
          if (StringUtils.isNotBlank(contactDTO.getName())) {
            doc.addField("contact", contactDTO.getName());
            pingyinInfo = PinyinUtil.getPingyinInfo(contactDTO.getName());
            String contact_fl = pingyinInfo.firstLetters;
            String contact_py = pingyinInfo.pingyin;
            doc.addField("contact_fl", contact_fl);
            doc.addField("contact_py", contact_py);
          } else {
            doc.addField("contact", StringUtil.SOLR_PLACEHOLDER_STRING);
            doc.addField("contact_fl", StringUtil.SOLR_PLACEHOLDER_STRING);
            doc.addField("contact_py", StringUtil.SOLR_PLACEHOLDER_STRING);
          }
          if (!isContactMobileEmpty()) {
            if (StringUtils.isNotBlank(contactDTO.getMobile())) {
              doc.addField("mobile", contactDTO.getMobile());
            } else {
              doc.addField("mobile", StringUtil.SOLR_PLACEHOLDER_STRING);
            }
          }
        }
      }

      if (StringUtils.isNotBlank(address)) {
        doc.addField("address", this.address);
      }
      if (StringUtils.isNotBlank(business_scope)) {
        doc.addField("business_scope", this.business_scope);
      }
      doc.addField("total_amount", this.total_amount == null ? 0d : this.total_amount);
      if ("customer".equals(customer_or_supplier)) {
        doc.addField("last_expense_time", this.last_expense_time);
        if (StringUtils.isNotBlank(member_no)) {
          doc.addField("member_no", member_no);
          doc.addField("member_no_fl", PinyinUtil.converterToFirstSpell(member_no));
          doc.addField("member_no_py", PinyinUtil.converterToPingyin(member_no));
        }
        doc.addField(
            "member_type", StringUtils.isNotBlank(this.member_type) ? this.member_type : "非会员");
        doc.addField("total_deposit", this.total_deposit);
        doc.addField("total_balance", this.balance);
      } else {
        doc.addField("last_inventory_time", this.last_inventory_time);
        doc.addField("total_deposit", this.total_deposit);
      }
      doc.addField("total_debt", (this.total_debt == null || total_debt < 0) ? 0d : total_debt);
      if (NumberUtil.doubleVal(total_debt) < 0) {
        LOG.warn("id:{},debt is illegal{}", id, total_debt);
      }
      doc.addField("created_time", this.created_time);
      if (!StringUtils.isBlank(name)) {
        pingyinInfo = PinyinUtil.getPingyinInfo(this.name);
        this.name_fl = pingyinInfo.firstLetters;
        this.name_py = pingyinInfo.pingyin;
        this.name_fl_sort = pingyinInfo.firstLetter;
        doc.addField("name_fl", name_fl);
        doc.addField("name_py", name_py);
        doc.addField("name_fl_sort", name_fl_sort);
      }
      if (CollectionUtils.isNotEmpty(license_nos)) {
        for (String license_no : license_nos) {
          if (StringUtils.isNotBlank(license_no)) {
            doc.addField("license_no", license_no);
            doc.addField("license_no_fl", PinyinUtil.converterToFirstSpell(license_no));
            doc.addField("license_no_py", PinyinUtil.converterToPingyin(license_no));
          }
        }
      }
      if (CollectionUtils.isNotEmpty(vehicle_brands)) {
        for (String vehicle_brand : vehicle_brands) {
          if (StringUtils.isNotBlank(vehicle_brand)) {
            doc.addField("vehicle_brand", vehicle_brand);
          }
        }
      }
      if (CollectionUtils.isNotEmpty(vehicle_models)) {
        for (String vehicle_model : vehicle_models) {
          if (StringUtils.isNotBlank(vehicle_model)) {
            doc.addField("vehicle_model", vehicle_model);
          }
        }
      }
      if (CollectionUtils.isNotEmpty(vehicle_colors)) {
        for (String vehicle_color : vehicle_colors) {
          if (StringUtils.isNotBlank(vehicle_color)) {
            doc.addField("vehicle_color", vehicle_color);
          }
        }
      }
      if (CollectionUtils.isNotEmpty(vehicle_details)) {
        for (String vehicle_detail : vehicle_details) {
          if (StringUtils.isNotBlank(vehicle_detail)) {
            doc.addField("vehicle_detail", vehicle_detail);
          }
        }
      }
      if (CollectionUtils.isNotEmpty(getArea_ids())) {
        for (Long area_id : getArea_ids()) {
          if (area_id != null) {
            doc.addField("area_ids", area_id);
          }
        }
      }
      doc.addField("area_info", this.area_info);

      doc.addField("status", null == this.status ? CustomerStatus.ENABLED : this.status.toString());
      doc.addField("total_return_debt", NumberUtil.doubleVal(total_return_debt));
      doc.addField("total_return_amount", NumberUtil.doubleVal(total_return_amount));
      doc.addField("total_trade_amount", NumberUtil.doubleVal(total_trade_amount));
      doc.addField("relation_type", this.relationType);
      doc.addField("dual_identity_id", this.dual_identity_id);
      doc.addField("is_obd", this.is_obd);
      doc.addField("is_app", this.isAppUser());
    } catch (IOException e) {
      LOG.error(e.getMessage(), e);
    }
    return doc;
  }