예제 #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
  /**
   * 一个黄单号对应多个主单号计算超重方法
   *
   * @param array
   */
  public void oneFlightToManyFax(List<FiDeliverycost> array) {
    FiDeliverycost fiDeliverycost = array.get(0);
    double diffWeight =
        DoubleUtil.sub(fiDeliverycost.getFlightWeight(), fiDeliverycost.getFaxWeight());
    if (diffWeight > 0.0) {
      // 主单超重处理   这里计了多次,在超重处理时,必须得判断一下
      List<Long> list = getPksByIds(fiDeliverycost.getFaxId());
      for (int j = 0; j < list.size(); j++) {
        List<OprFaxIn> listMain =
            oprFaxInDao.find(
                "from OprFaxIn oi where oi.faxMainId=?  and oi.status=1  ", list.get(j));
        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(fiDeliverycost.getFlightWeight());
          oprOverweight.setAmount(
              Math.ceil(DoubleUtil.mul(diffWeight, cusMan.getOverweightRate())));
          oprOverweight.setRate(cusMan.getOverweightRate());
          oprOverweight.setStatus(1l);
          cusOverWeightService.save(oprOverweight);
        }
      }
    }
  }