Пример #1
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);
    }
  }
Пример #2
0
  // 取消匹配
  @ModuleName(value = "提货成本管理取消匹配", logType = LogType.fi)
  public String qxAudit(List<FiDeliverycost> aa) throws Exception {
    List<Long> fiDelivAll = new ArrayList<Long>(); // 取消匹配的ID集合
    for (FiDeliverycost fd : aa) {
      fiDelivAll.add(fd.getId());
    }

    for (FiDeliverycost fiDeliv : aa) {
      FiDeliverycost fiDeliverycost = fiDeliverycostDao.get(fiDeliv.getId());
      fiDeliverycost.setTs(fiDeliv.getTs());

      if (fiDeliverycost.getStatus() == 1l) {
        throw new ServiceException("已审核数据不能进行取消匹配操作");
      }

      if (fiDeliverycost.getMatStatus() == null || fiDeliverycost.getMatStatus() == 0l) {
        throw new ServiceException("未匹配的数据不能进行取消匹配操作");
      }
      List<Long> list = getPksByIds(fiDeliverycost.getFaxId());
      for (Long faxIdLong : list) {
        OprFaxMain fiMain = oprFaxMainService.get(faxIdLong);
        fiMain.setMatchStatus(0l);
        oprFaxMainService.save(fiMain);

        // 超重删除
        List<OprOverweight> list2 =
            cusOverWeightService.find(
                "from OprOverweight oo where oo.departId=? and oo.flightMainNo=?  and oo.status=1 ",
                fiDeliverycost.getDepartId(),
                fiMain.getFlightMainNo());
        for (OprOverweight oprOverweight : list2) {
          oprOverweight.setStatus(0l);
          cusOverWeightService.save(oprOverweight);
        }
      }

      if (list.size() == 1) { // 保存黄单多对一的ID集合,用来判断是否一次全部取消匹配
        List<FiDeliverycost> lisd =
            find(
                "from FiDeliverycost  fd where fd.departId=? and fd.faxId=? and  fd.id<> ? ",
                fiDeliverycost.getDepartId(),
                fiDeliverycost.getFaxId(),
                fiDeliverycost.getId());
        List<Long> idsLongList = new ArrayList<Long>();
        for (FiDeliverycost fiDt2 : lisd) {
          idsLongList.add(fiDt2.getId());
        }
        if (!fiDelivAll.containsAll(idsLongList)) {
          throw new ServiceException("存在多条黄单记录匹配一条主单号的记录,请全部取消匹配");
        }
      }

      if (fiDeliverycost.getStatus() != null && fiDeliverycost.getStatus() == 1l) {
        throw new ServiceException("数据已审核,不能撤销手工匹配");
      }

      fiDeliverycost.setMatStatus(0l);
      fiDeliverycost.setFaxMainNo(null);
      fiDeliverycost.setFaxPiece(0l);
      fiDeliverycost.setFaxWeight(0.0);
      fiDeliverycost.setDiffAmount(0.0);
      fiDeliverycost.setDiffWeight(0.0);
      fiDeliverycost.setFaxId(null);
      fiDeliverycostDao.save(fiDeliverycost); // 撤销手工匹配
    }
    return null;
  }