Ejemplo n.º 1
0
  /**
   * @Title: saveOrd @Description: TODO(这里用一句话描述这个方法的作用)
   *
   * @param @param res 设定文件
   * @return void 返回类型
   * @throws
   * @author zhouxin
   * @date 2015年6月4日 上午10:40:46
   */
  public void saveOrd(BusinessRequest res) {

    OrderStateDto dto = super.getDto(OrderStateDto.class, res);
    dto.setOperateResult(new OperateResult());
    // 调用对应的service方法
    dto.getOperateResult().setResultCode("1");
    try {
      List<OrderDetailSub> orderDetailSubs =
          JsonUtils.toObject(dto.getOrderIdStr(), new TypeReference<List<OrderDetailSub>>() {});
      for (OrderDetailSub orderDetailSub : orderDetailSubs) {
        OrderDetail orderDetail =
            commonService.get(OrderDetail.class, orderDetailSub.getOrdSubDetailId());
        float ordqty = orderDetail.getOrderVenQty().floatValue();
        ordqty = ordqty - orderDetailSub.getOrderSubQty().floatValue();
        if ((!orderDetail.getOrderState().toString().equals("2"))
            && (!orderDetail.getOrderState().toString().equals("10"))) {
          dto.getOperateResult().setResultCode("-1");
          dto.getOperateResult().setResultContent("有明细以发货,不能修改!<br>");
          continue;
        }
        List<OrderDetailSub> orderDetailSubs2 =
            commonService.findByProperty(
                OrderDetailSub.class, "ordSubDetailId", orderDetailSub.getOrdSubDetailId());
        for (OrderDetailSub orderDetailSub2 : orderDetailSubs2) {
          if ((orderDetailSub.getOrdSubId() != null)
              && (orderDetailSub
                  .getOrdSubId()
                  .toString()
                  .equals(orderDetailSub2.getOrdSubId().toString()))) {

          } else {
            ordqty = ordqty - orderDetailSub2.getOrderSubQty().floatValue();
          }
        }
        if (ordqty < 0) {
          dto.getOperateResult().setResultCode("-1");
          dto.getOperateResult()
              .setResultContent("单号:" + orderDetail.getOrderNo() + ",订单数大于发货数!<br>");
        }
      }
      if (dto.getOperateResult().getResultCode().equals("1")) {
        for (OrderDetailSub orderDetailSub : orderDetailSubs) {
          orderDetailSub.setOrdSubDate(new Date());
          orderDetailSub.setOrdSubUserId(
              Long.valueOf(super.getLoginInfo().get("USERID").toString()));
          commonService.saveOrUpdate(orderDetailSub);
        }
      }
      super.writeJSON(dto.getOperateResult());
    } catch (Exception e) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent(e.getMessage());
      e.printStackTrace();
      super.writeJSON(dto.getOperateResult());
    }
  }
Ejemplo n.º 2
0
  public void deliverSub(OrderStateDto dto) {

    if (dto.getDeliveritms() == null) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("入参为空");
      return;
    }
    if (dto.getDeliveritms().size() == 0) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("入参为空");
      return;
    }

    List<OrderDetailSub> detailSubs = new ArrayList<OrderDetailSub>();
    int num = 0;
    // 按订单拆分发货单
    for (VenDeliveritm tmpVenDeliveritm : dto.getDeliveritms()) {
      num++;
      if (StringUtils.isNullOrEmpty(tmpVenDeliveritm.getDeliveritmInvnoe())) {
        dto.getOperateResult().setResultCode("-2");
        dto.getOperateResult().setResultContent("第" + num + "行发票号不能为空");
        continue;
      }
      if (tmpVenDeliveritm.getDeliveritmQty() == null) {
        dto.getOperateResult().setResultCode("-3");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,发货数量不能为空");
        continue;
      }
      if (tmpVenDeliveritm.getDeliveritmRp() == null) {
        dto.getOperateResult().setResultCode("-4");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,进价不能为空");
        continue;
      }
      if (tmpVenDeliveritm.getDeliveritmOrderitmid() == null) {
        dto.getOperateResult().setResultCode("-5");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,没有订单明细ID");
        continue;
      }

      OrderDetail orderItm =
          commonService.get(OrderDetail.class, tmpVenDeliveritm.getDeliveritmOrderitmid());
      if (orderItm == null) {
        dto.getOperateResult().setResultCode("-6");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,订单明细ID错误");
        continue;
      }
      if (orderItm.getOrderState().longValue() != 2) {
        dto.getOperateResult().setResultCode("-7");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,订单状态错误");
        continue;
      }
      OrderDetailSub orderDetailSub = new OrderDetailSub();
      orderDetailSub.setOrderSubQty(tmpVenDeliveritm.getDeliveritmQty());
      orderDetailSub.setOrderSubRp(tmpVenDeliveritm.getDeliveritmRp());
      orderDetailSub.setOrderSubRpAmt(tmpVenDeliveritm.getDeliveritmRpamt());
      orderDetailSub.setOrdSubBatNo(tmpVenDeliveritm.getDeliveritmBatno());
      orderDetailSub.setOrdSubDate(new Date());
      orderDetailSub.setOrdSubDetailId(tmpVenDeliveritm.getDeliveritmOrderitmid());
      orderDetailSub.setOrdSubInvNo(tmpVenDeliveritm.getDeliveritmInvnoe());
      orderDetailSub.setOrdSubExpDate(tmpVenDeliveritm.getDeliveritmExpdate());
      detailSubs.add(orderDetailSub);
    }

    // 明细有错吴
    if (!dto.getOperateResult().getResultCode().equals("0")) {
      return;
    }
    for (OrderDetailSub orderDetailSub : detailSubs) {
      OrderDetail orderDetail =
          commonService.get(OrderDetail.class, orderDetailSub.getOrdSubDetailId());
      orderDetail.setOrderState(3l);
      commonService.saveOrUpdate(orderDetail);
      commonService.saveOrUpdate(orderDetailSub);
      ExeState exeState = new ExeState();
      exeState.setStateId(Long.valueOf(2));
      exeState.setOrdId(orderDetailSub.getOrdSubDetailId());
      exeState.setRemark("webservice 回传发票");
      exeState.setExedate(new java.sql.Timestamp(new Date().getTime()));
      commonService.saveOrUpdate(exeState);
    }
  }