Ejemplo n.º 1
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;
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 3
0
  // 审核
  @ModuleName(value = "提货成本管理会计审核", logType = LogType.fi)
  public void saveFiAudit(List<FiDeliverycost> list, User user) throws Exception {
    List<Long> fiDelivAll = new ArrayList<Long>(); // 审核的ID集合
    for (FiDeliverycost fd : list) {
      fiDelivAll.add(fd.getId());
    }

    List<FiDeliverycost> listDliv = new ArrayList<FiDeliverycost>();
    for (FiDeliverycost fiDeliverycost : list) {
      FiDeliverycost fiDeliverycost2 = get(fiDeliverycost.getId());
      fiDeliverycost2.setTs(fiDeliverycost.getTs());
      //	save(fiDeliverycost2);                               //验证时间戳
      listDliv.add(fiDeliverycost2);
    }

    FiDeliverycost fiDecost = get(list.get(0).getId());
    if (fiDecost == null) {
      throw new ServiceException("记录已不存在");
    }
    Long cusLong = fiDecost.getCustomerId();
    String cusString = fiDecost.getCustomerName();
    Long batchNo = fiDeliverycostExcelService.getBatchNO(1l);
    Double totalMoney = 0.0;

    for (FiDeliverycost fiDeliverycost : listDliv) {
      if (fiDeliverycost == null) {
        throw new ServiceException("记录已不存在");
      }
      if (fiDeliverycost.getMatStatus() == null || fiDeliverycost.getMatStatus() == 0) {
        throw new ServiceException("存在未匹配的数据,不能审核");
      }
      if (!cusLong.equals(fiDeliverycost.getCustomerId())) {
        throw new ServiceException("不同提货公司不能一起审核");
      }
      if (fiDeliverycost.getStatus() != null && fiDeliverycost.getStatus() == 1l) {
        throw new ServiceException("存在记录已审核,请重新查询后再提交记录审核");
      } else {
        totalMoney = DoubleUtil.add(fiDeliverycost.getAmount(), totalMoney);
        fiDeliverycost.setReviewDept(user.get("departName").toString());
        fiDeliverycost.setReviewDate(new Date());
        fiDeliverycost.setReviewUser(user.get("name").toString());
        fiDeliverycost.setBatchNo(batchNo);
        fiDeliverycost.setStatus(1l);
        save(fiDeliverycost); // 更新会计审核信息

        List<Long> listFid = getPksByIds(fiDeliverycost.getFaxId());
        if (listFid.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("存在多条黄单记录匹配一条主单号的记录,请一起审核");
          }
        }

        // 主单处理
        for (Long faxIdLong : listFid) {
          OprFaxMain fiMain = oprFaxMainService.get(faxIdLong);
          // 标记此主单的成本已分摊
          if (fiMain.getCostAuditStatus() == 1l) {
            continue;
          } else {
            fiMain.setCostAuditStatus(1l);
          }
          oprFaxMainService.save(fiMain);

          List<OprFaxIn> listFax =
              oprFaxInDao.find(
                  " from OprFaxIn o where o.faxMainId=?  and o.status=1 ", fiMain.getId());
          double doubv = fiDeliverycost.getAmount();
          // 保存到成本表中
          for (int i = 0; i < listFax.size(); i++) {
            OprFaxIn oprFaxIn = listFax.get(i);
            FiCost fiCost = new FiCost();
            fiCost.setDno(oprFaxIn.getDno());
            fiCost.setCostType("提货成本");
            fiCost.setCostTypeDetail(oprFaxIn.getTakeMode());
            if ((listFax.size() - 1) == i) {
              fiCost.setCostAmount(doubv);

              oprHistoryService.saveLog(
                  oprFaxIn.getDno(), "提货成本审核,审核支付金额:" + doubv, log_auditCost); // 操作日志
            } else {
              double dou2 = DoubleUtil.div(fiDeliverycost.getAmount(), listFax.size(), 2);
              fiCost.setCostAmount(dou2);
              oprHistoryService.saveLog(
                  oprFaxIn.getDno(), "提货成本审核,审核支付金额:" + dou2, log_auditCost); // 操作日志

              doubv = DoubleUtil.sub(doubv, dou2);
            }
            fiCost.setSourceSignNo(fiDeliverycost.getId() + "");
            fiCost.setDataSource("提货成本");
            fiCostService.save(fiCost);
          }
        }
      }
    }

    /*
    //财务接口
    List<FiInterfaceProDto> listfiInterfaceDto =new ArrayList<FiInterfaceProDto>();
    FiInterfaceProDto fiIn = new FiInterfaceProDto();
    fiIn.setCustomerId(cusLong);
    fiIn.setCustomerName(cusString);
    fiIn.setDistributionMode("客商");
    fiIn.setSettlementType(2l);
    fiIn.setDocumentsType("成本");
    fiIn.setDocumentsSmalltype("提货对账单");
    fiIn.setDocumentsNo(batchNo);
    fiIn.setAmount(totalMoney);
    fiIn.setCostType("对账");
    fiIn.setDepartId(Long.parseLong(user.get("departId")+""));
    fiIn.setSourceData("提货成本");
    fiIn.setSourceNo(batchNo);
    fiIn.setCreateRemark("支付"+cusString+"提货费"+totalMoney+"元");
    listfiInterfaceDto.add(fiIn);
    fiInterfaceImpl.reconciliationToFiPayment(listfiInterfaceDto);*/
    // fiInterfaceImpl.addFinanceInfo(listPro);
  }