@ResponseBody
 @RequestMapping(params = "method=getCategoryItemSearch")
 public Object getCategoryItemSearch(
     ModelMap model,
     HttpServletRequest request,
     CategoryServiceSearchDTO categoryServiceSearchDTO) {
   RFITxnService txnService = ServiceManager.getService(RFITxnService.class);
   Long shopId = WebUtil.getShopId(request);
   Long startPageNo = 1l;
   if (StringUtils.isNotBlank(request.getParameter("startPageNo"))
       && NumberUtil.isNumber(request.getParameter("startPageNo"))) {
     startPageNo = NumberUtil.longValue(request.getParameter("startPageNo"));
   }
   Map<String, Object> returnMap = new HashMap<String, Object>();
   try {
     if (categoryServiceSearchDTO == null) {
       categoryServiceSearchDTO = new CategoryServiceSearchDTO();
     }
     Pager pager = null;
     // 全部
     if (categoryServiceSearchDTO.getCategoryServiceType() == null) {
       categoryServiceSearchDTO.setServiceDTOs(
           txnService.getServicesByCategory(
               shopId,
               categoryServiceSearchDTO.getServiceName(),
               categoryServiceSearchDTO.getCategoryName(),
               CategoryType.BUSINESS_CLASSIFICATION,
               startPageNo,
               PAGE_SIZE));
       pager =
           new Pager(
               txnService.countServiceByCategory(
                   shopId,
                   categoryServiceSearchDTO.getServiceName(),
                   categoryServiceSearchDTO.getCategoryName(),
                   CategoryType.BUSINESS_CLASSIFICATION),
               startPageNo.intValue(),
               (int) PAGE_SIZE);
     }
     categoryServiceSearchDTO.setCategoryDTOs(txnService.getCategoryByShopId(shopId));
     returnMap.put("pager", pager);
     returnMap.put("categoryServiceSearchDTO", categoryServiceSearchDTO);
     returnMap.put("result", new Result(true));
     return returnMap;
   } catch (Exception e) {
     LOG.debug("/category.do");
     LOG.debug("method=getCategoryItemSearch");
     LOG.error(e.getMessage(), e);
     returnMap.put("result", new Result(false));
     return returnMap;
   }
 }
Beispiel #2
0
  public List<ItemIndexDTO> toInOutRecordDTO(InventoryCheckDTO inventoryCheckDTO) {
    List<ItemIndexDTO> itemIndexDTOList = new ArrayList<ItemIndexDTO>();

    if (inventoryCheckDTO.getMergeInOutRecordFlag()) {
      if (NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount()) > 0) {
        ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
        itemIndexDTO.setItemType(ItemTypes.OUT);
        itemIndexDTO.setInOutRecordId(this.getId());
        itemIndexDTO.setItemCount(
            NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount()));
        itemIndexDTO.setUnit(this.getSellUnit());
        itemIndexDTOList.add(itemIndexDTO);
      } else if (NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount())
          < 0) {
        ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
        itemIndexDTO.setItemType(ItemTypes.IN);
        itemIndexDTO.setInOutRecordId(this.getId());
        itemIndexDTO.setItemCount(
            NumberUtil.round(this.getActualInventoryAmount() - this.getInventoryAmount(), 1));
        itemIndexDTO.setUnit(this.getSellUnit());
        itemIndexDTOList.add(itemIndexDTO);
      }
    } else {
      if (!ArrayUtils.isEmpty(this.getOutStorageRelationDTOs())) {
        for (OutStorageRelationDTO outStorageRelationDTO : getOutStorageRelationDTOs()) {
          ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
          itemIndexDTO.setItemType(ItemTypes.OUT);
          itemIndexDTO.setInOutRecordId(outStorageRelationDTO.getId());
          itemIndexDTO.setRelatedSupplierId(outStorageRelationDTO.getRelatedSupplierId());
          itemIndexDTO.setRelatedSupplierName(outStorageRelationDTO.getRelatedSupplierName());
          itemIndexDTO.setItemCount(outStorageRelationDTO.getSupplierRelatedAmount());
          itemIndexDTO.setUnit(outStorageRelationDTO.getOutStorageUnit());
          itemIndexDTOList.add(itemIndexDTO);
        }
      }
      if (!ArrayUtils.isEmpty(this.getInStorageRecordDTOs())) {
        for (InStorageRecordDTO inStorageRecordDTO : getInStorageRecordDTOs()) {
          ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
          itemIndexDTO.setItemType(ItemTypes.IN);
          itemIndexDTO.setInOutRecordId(inStorageRecordDTO.getId());
          itemIndexDTO.setRelatedSupplierId(inStorageRecordDTO.getSupplierId());
          itemIndexDTO.setRelatedSupplierName(inStorageRecordDTO.getSupplierName());
          itemIndexDTO.setItemCount(inStorageRecordDTO.getSupplierRelatedAmount());
          itemIndexDTO.setUnit(inStorageRecordDTO.getInStorageUnit());
          itemIndexDTOList.add(itemIndexDTO);
        }
      }
    }

    return itemIndexDTOList;
  }
Beispiel #3
0
 public GsmVehicleDataDTO toDTO() {
   GsmVehicleDataDTO gsmVehicleDataDTO = new GsmVehicleDataDTO();
   gsmVehicleDataDTO.setId(this.get_id().get$oid().toString());
   gsmVehicleDataDTO.setUuid(this.getUuid());
   gsmVehicleDataDTO.setImei(this.getImei());
   gsmVehicleDataDTO.setAppUserNo(this.getAppUserNo());
   gsmVehicleDataDTO.setUserType(getUserType());
   gsmVehicleDataDTO.setDoor(this.getDoor());
   gsmVehicleDataDTO.setCurMil(this.getCurMil());
   gsmVehicleDataDTO.setMile(this.getMile());
   gsmVehicleDataDTO.setUploadTime(NumberUtil.longValue((this.getUploadTime().get$numberLong())));
   gsmVehicleDataDTO.setUploadServerTime(
       NumberUtil.longValue(this.getUploadServerTime().get$numberLong()));
   gsmVehicleDataDTO.setDttpe(this.getDttpe());
   gsmVehicleDataDTO.setSpwr(String.valueOf(NumberUtil.round(this.getSpwr())));
   gsmVehicleDataDTO.setVoltageForOxygenSensor(
       String.valueOf(NumberUtil.round(this.getVoltageForOxygenSensor())));
   gsmVehicleDataDTO.setRpf(getRpf());
   gsmVehicleDataDTO.setRpm(this.getRpm());
   gsmVehicleDataDTO.setVss(this.getVss());
   gsmVehicleDataDTO.setLon(this.getLon());
   gsmVehicleDataDTO.setLonDir(this.getLonDir());
   gsmVehicleDataDTO.setLat(this.getLat());
   gsmVehicleDataDTO.setLatDir(this.getLatDir());
   gsmVehicleDataDTO.setGpsSpeed(this.getGpsSpeed());
   gsmVehicleDataDTO.setGpsHeading(this.getGpsHeading());
   gsmVehicleDataDTO.setGpsDataValidity(this.getGpsDataValidity());
   gsmVehicleDataDTO.setaOilWear(this.getaOilWear());
   gsmVehicleDataDTO.setrOilMass(this.getrOilMass());
   gsmVehicleDataDTO.setbOilWear(this.getbOilWear());
   gsmVehicleDataDTO.setmOilWear(this.getmOilWear());
   gsmVehicleDataDTO.setVehicleStatus(this.getVehicleStatus());
   gsmVehicleDataDTO.setRdtc(this.getRdtc());
   gsmVehicleDataDTO.setGsmVehicleStatus(this.getGsmVehicleStatus());
   gsmVehicleDataDTO.setThrottlePosition(this.getThrottlePosition());
   gsmVehicleDataDTO.setGx(this.getGx());
   gsmVehicleDataDTO.setGy(this.getGy());
   gsmVehicleDataDTO.setGz(this.getGz());
   gsmVehicleDataDTO.setWbtm(this.getWbtm());
   gsmVehicleDataDTO.setrOilMassType(this.getrOilMassType());
   gsmVehicleDataDTO.setCountry(this.getCountry());
   gsmVehicleDataDTO.setSupplier(this.getSupplier());
   gsmVehicleDataDTO.setBase_station(this.getBase_station());
   gsmVehicleDataDTO.setDist_id(this.getDist_id());
   return gsmVehicleDataDTO;
 }
Beispiel #4
0
 /**
  * 从excel文件导入客户数据到本地数据库
  *
  * @return
  */
 @RequestMapping(params = "method=importOrderFromExcel")
 @ResponseBody
 public void importOrderFromExcel(HttpServletRequest request, HttpServletResponse response) {
   ImportContext importContext = new ImportContext();
   String result = null;
   importContext.setShopId((Long) request.getSession().getAttribute("shopId"));
   String importRecordIds = request.getParameter("importRecordId");
   List<Long> importRecordIdlist = NumberUtil.parseLongValues(importRecordIds);
   Map<String, String> fieldMapping =
       JsonUtil.jsonToStringMap(request.getParameter("fieldMapping"));
   if (importRecordIdlist == null
       || importRecordIdlist.isEmpty()
       || fieldMapping == null
       || fieldMapping.isEmpty()) {
     result = ImportConstants.MESSAGE_NEED_FILE_OR_MAPPING;
   }
   importContext.setImportRecordIdList(importRecordIdlist);
   importContext.setFieldMapping(fieldMapping);
   importContext.setType(ImportConstants.Type.TYPE_ORDER);
   ImportResult importResult = null;
   try {
     importResult = txnService.importOrderFromExcel(importContext);
   } catch (Exception e) {
     LOG.error(e.getMessage(), e);
   }
   result = JsonUtil.objectToJson(importResult);
   PrintWriter writer = null;
   try {
     writer = response.getWriter();
     writer.write(result);
     writer.flush();
     writer.close();
   } catch (IOException e) {
     LOG.error("/importOrder.do");
     LOG.error("method=importOrderFromExcel");
     LOG.error("单据导入出错");
     LOG.error(e.getMessage(), e);
   } catch (Exception e) {
     LOG.error("/importOrder.do");
     LOG.error("method=importOrderFromExcel");
     LOG.error("单据导入出错");
     LOG.error(e.getMessage(), e);
   }
 }
Beispiel #5
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 #6
0
  /**
   * 导入前: 1.读取excel文件表头 2.保存导入记录(文件)到数据库
   *
   * @param request
   * @return
   */
  @RequestMapping(params = "method=uploadExcel")
  public void getExcelHeader(HttpServletRequest request, HttpServletResponse response) {
    IImportService importService = ServiceManager.getService(IImportService.class);
    IPrivilegeService privilegeService = ServiceManager.getService(IPrivilegeService.class);
    Map result = new HashMap();
    try {
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
      MultipartFile multipartFile = multipartRequest.getFile("selectfile");
      String fileName = multipartFile.getOriginalFilename();
      if (!validateOrderType(fileName)) { // todo 不起作用
        response.setHeader("Charset", "UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter writer = response.getWriter();
        result.put("orderImportMsg", "上传文件名无法识别,请使用标准模板名!");
        String resultStr = JsonUtil.mapToJson(result);
        writer.write(resultStr);
        writer.flush();
        writer.close();
        return;
      }
      InputStream inputStream = multipartFile.getInputStream();
      if (inputStream.available() > ImportConstants.UPLOAD_FILE_MAX_SIZE) {
        PrintWriter writer = response.getWriter();
        writer.write(
            "上传文件大小不能超过" + NumberUtil.byteToMillion(ImportConstants.UPLOAD_FILE_MAX_SIZE) + "M!");
        writer.flush();
        writer.close();
        return;
      }
      byte[] fileContent = IOUtil.readFromStream(inputStream);
      // 先读取表头
      ImportContext importContext = new ImportContext();
      importContext.setFileContent(fileContent);
      importContext.setFileName(fileName);
      List<String> headList = importService.parseHead(importContext);
      if (headList == null || headList.isEmpty()) {
        result.put("message", "解析导入文件头部失败!");
      } else {
        result.put("headList", headList);
      }

      // 再存入数据库
      ImportRecordDTO importRecordDTO = new ImportRecordDTO();
      importRecordDTO.setShopId(WebUtil.getShopId(request));
      importRecordDTO.setStatus(ImportConstants.Status.STATUS_WAITING);
      importRecordDTO.setType(ImportConstants.Type.TYPE_ORDER);
      importRecordDTO.setFileName(fileName);
      importRecordDTO.setFileContent(fileContent);
      importRecordDTO = importService.createImportRecord(importRecordDTO);
      if (importRecordDTO == null || importRecordDTO.getId() == null) {
        result.put("message", "保存导入记录出错!");
      } else {
        result.put("importRecordId", String.valueOf(importRecordDTO.getId()));
      }
      result.put(
          "systemFieldList",
          getOrderFieldList(
              PrivilegeRequestProxy.verifierShopVersionResourceProxy(
                  request, LogicResource.WEB_VERSION_WHOLESALERS)));
      String resultStr = JsonUtil.mapToJson(result);
      response.setHeader("Charset", "UTF-8");
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter writer = response.getWriter();
      writer.write(resultStr);
      writer.flush();
      writer.close();
    } catch (Exception e) {
      LOG.error("上传文件出现异常!");
      LOG.error(e.getMessage(), e);
    }
  }
Beispiel #7
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);
    }
  }
Beispiel #8
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);
    }
  }
  /**
   * 根据前台查询条件获得某个具体的标准产品各个店铺的采购统计
   *
   * @param request
   * @param response
   * @param productSearchCondition
   * @return
   */
  @RequestMapping(params = "method=getNormalProductStatDetailByNormalProductId")
  @ResponseBody
  public Object getNormalProductStatDetailByNormalProductId(
      HttpServletRequest request,
      HttpServletResponse response,
      ProductSearchCondition productSearchCondition) {

    try {
      Long shopId = WebUtil.getShopId(request);
      if (shopId == null) throw new Exception("shopId is null!");
      productSearchCondition.setShopId(shopId);
      if (productSearchCondition == null
          || productSearchCondition.getNormalProductStatType() == null
          || !NumberUtil.isNumber(productSearchCondition.getNormalProductIdStr())) {
        return null;
      }
      INormalProductStatService normalProductStatService =
          ServiceManager.getService(INormalProductStatService.class);
      Pager pager = new Pager();
      pager.setRowStart(productSearchCondition.getStart());
      pager.setPageSize(productSearchCondition.getLimit());

      List<Long> shopIdList = null;
      if (StringUtil.isNotEmpty(productSearchCondition.getShopVersion())
          || productSearchCondition.getProvinceId() != null
          || productSearchCondition.getCityId() != null
          || productSearchCondition.getRegionId() != null) {
        IConfigService configService = ServiceManager.getService(IConfigService.class);

        List<Long> shopVersionIds = new ArrayList<Long>();

        if ("REPAIR_VERSION".equals(productSearchCondition.getShopVersion())) {
          shopVersionIds.add(10000010017531654L);
          shopVersionIds.add(10000010017531655L);
          shopVersionIds.add(10000010039823882L);
        } else if ("WHOLESALER_VERSION".equals(productSearchCondition.getShopVersion())) {
          shopVersionIds.add(10000010017531657L);
          shopVersionIds.add(10000010037193619L);
          shopVersionIds.add(10000010037193620L);
          shopVersionIds.add(10000010017531653L);
        }

        shopIdList =
            configService.getShopByShopVersionAndArea(
                shopVersionIds.toArray(new Long[shopVersionIds.size()]),
                productSearchCondition.getProvinceId(),
                productSearchCondition.getCityId(),
                productSearchCondition.getRegionId());
        if (CollectionUtils.isEmpty(shopIdList)) {
          return null;
        }
      } else {
        shopIdList = new ArrayList<Long>();
      }

      NormalProductStatSearchResult normalProductStatSearchResult =
          normalProductStatService.getStatDetailByCondition(
              shopIdList.toArray(new Long[shopIdList.size()]),
              Long.valueOf(productSearchCondition.getNormalProductIdStr()),
              productSearchCondition.getNormalProductStatType(),
              pager);
      return normalProductStatSearchResult;
    } catch (Exception e) {
      LOG.error("normalProductStat.do method=getNormalProductStatByCondition");
      LOG.error("normalProductIdStr" + productSearchCondition.getNormalProductIdStr());
      LOG.error(e.getMessage(), e);
    }
    return null;
  }
  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());
  }
  /**
   * 客户 供应商 名称 联系人 车牌号 用左右模糊 词的意义不大 不做分词 所以对应的拼音也不做分词
   *
   * @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;
  }