コード例 #1
0
  /**
   * 多个黄单号对应-个主单号计算超重方法
   *
   * @param array
   */
  public void manyFlightToOneFax(List<FiDeliverycost> array, double totalFdWeight) {
    double diffWeight = DoubleUtil.sub(totalFdWeight, array.get(0).getFaxWeight());

    FiDeliverycost fiDeliverycost = array.get(0); // 多票匹配放在第一个黄单记录里面
    fiDeliverycost.setDiffWeight(diffWeight);
    fiDeliverycost.setDiffAmount(
        Math.ceil(DoubleUtil.mul(fiDeliverycost.getDiffWeight(), fiDeliverycost.getPrice())));
    save(fiDeliverycost);

    if (diffWeight > 0.0) {
      // 主单超重处理
      List<OprFaxIn> listMain =
          oprFaxInDao.find(
              "from OprFaxIn oi where oi.faxMainId=?  and oi.status=1   ",
              Long.parseLong(array.get(0).getFaxId()));
      if (listMain.size() > 0) {
        OprFaxIn oprFaxIn = listMain.get(0);
        CusOverweightManager cusMan = null;
        List<CusOverweightManager> cuslist =
            this.cusOverManagerService.findBy("cusId", oprFaxIn.getCusId());
        if (cuslist.size() == 0) {
          List<CusOverweightManager> listM =
              cusOverManagerService.find("from CusOverweightManager cs where cs.cusId is null ");
          if (listM.size() == 0) {
            throw new ServiceException("请在主单超重模块录入主单超重相关信息");
          } else {
            cusMan = listM.get(0);
          }
        } else {
          cusMan = cuslist.get(0);
        }

        if (diffWeight > cusMan.getLowWeight()) { // 写入主单超重表
          OprOverweight oprOverweight = new OprOverweight();
          oprOverweight.setCustomerId(oprFaxIn.getCusId());
          oprOverweight.setCustomerName(oprFaxIn.getCpName());
          oprOverweight.setWeight(diffWeight);
          oprOverweight.setFlightMainNo(array.get(0).getFaxMainNo());
          oprOverweight.setDepartId(array.get(0).getDepartId());
          oprOverweight.setDepartName(array.get(0).getDepartName());
          oprOverweight.setFaxWeight(array.get(0).getFaxWeight());
          oprOverweight.setFlightWeight(totalFdWeight);
          oprOverweight.setAmount(
              Math.ceil(DoubleUtil.mul(diffWeight, cusMan.getOverweightRate())));
          oprOverweight.setRate(cusMan.getOverweightRate());
          oprOverweight.setStatus(1l);
          cusOverWeightService.save(oprOverweight);
        }
      }
    }
  }
コード例 #2
0
  // 匹配保存
  @ModuleName(value = "提货成本管理匹配保存", logType = LogType.fi)
  public void saveMat(List<FiDeliverycost> aa) throws Exception {
    List<FiDeliverycost> arrayFide = new ArrayList<FiDeliverycost>();
    double totalFdWeight = 0.0;
    for (FiDeliverycost fiDeliver : aa) {
      FiDeliverycost fiDeliverycost = get(fiDeliver.getId());
      fiDeliverycost.setTs(fiDeliver.getTs());
      if (fiDeliverycost == null) {
        throw new ServiceException("这黄单号记录可能已经删除,无法手工匹配");
      } else if (fiDeliverycost.getMatStatus() == 1l
          || fiDeliverycost.getMatStatus() == 2l
          || fiDeliverycost.getMatStatus() == 3l) {
        throw new ServiceException("这黄单号记录已经系统匹配,不能匹配多次");
      }

      fiDeliverycost.setFaxId(fiDeliver.getFaxId());

      String longFaxId = fiDeliver.getFaxId();
      List<Long> list = getPksByIds(longFaxId);
      if (aa.size() > 1 || list.size() > 1) {
        fiDeliverycost.setMatStatus(3l);
      } else {
        fiDeliverycost.setMatStatus(2l);
      }
      if (list.size() == 0) {
        throw new ServiceException("匹配时出错了");
      }
      double totalWeight = 0.0;
      long totalPiece = 0l;
      StringBuffer sb = new StringBuffer("");
      for (int i = 0; i < list.size(); i++) {
        OprFaxMain fiMain = oprFaxMainService.get(list.get(i));
        fiMain.setMatchStatus(1l);
        totalWeight += fiMain.getTotalWeight();
        totalPiece += fiMain.getTotalPiece();
        if (i != (list.size() - 1)) {
          sb.append(fiMain.getFlightMainNo()).append(",");
        } else {
          sb.append(fiMain.getFlightMainNo());
        }
        oprFaxMainService.save(fiMain);
      }

      fiDeliverycost.setFaxMainNo(sb.toString());
      fiDeliverycost.setFaxPiece(totalPiece);
      fiDeliverycost.setFaxWeight(totalWeight);
      if (aa.size() == 1) { // 正常匹配写入重量差异 多票黄单匹配在后面处理
        fiDeliverycost.setDiffWeight(
            DoubleUtil.sub(fiDeliverycost.getFlightWeight(), fiDeliverycost.getFaxWeight()));
        fiDeliverycost.setDiffAmount(
            Math.ceil(DoubleUtil.mul(fiDeliverycost.getDiffWeight(), fiDeliverycost.getPrice())));
      }
      save(fiDeliverycost);
      totalFdWeight = DoubleUtil.add(fiDeliverycost.getFlightWeight(), totalFdWeight);
      arrayFide.add(fiDeliverycost);
    }

    if (aa.size() == 1) {
      oneFlightToManyFax(arrayFide);
    } else {
      manyFlightToOneFax(arrayFide, totalFdWeight);
    }
  }