コード例 #1
0
ファイル: HopIncBlh.java プロジェクト: dannisliang/scm_weixin
  // 保存
  public void save(BusinessRequest res) {

    HopIncDto dto = super.getDto(HopIncDto.class, res);
    if (dto.getHopInc().getIncId() == null) {
      dto.getHopInc().setIncHospid(Long.valueOf(super.getLoginInfo().get("HOPID").toString()));
    } else {
      List<HopIncAlias> hopIncAlias =
          commonService.findByProperty(
              HopIncAlias.class, "incAliaIncId", dto.getHopInc().getIncId());
      if (hopIncAlias.size() > 0) {
        for (HopIncAlias hopIncAlias2 : hopIncAlias) {
          commonService.delete(hopIncAlias2);
        }
      }
    }
    if (org.apache.commons.lang.StringUtils.isNotBlank(dto.getHopInc().getIncAliaS())) {
      String[] alias = dto.getHopInc().getIncAliaS().split(",");
      for (String alia : alias) {
        HopIncAlias hopIncAlias = new HopIncAlias();
        hopIncAlias.setIncAliasText(alia);
        hopIncAlias.setIncAliaIncId(dto.getHopInc().getIncId());
        commonService.saveOrUpdate(hopIncAlias);
      }
    } else {
      HopIncAlias hopIncAlias = new HopIncAlias();
      hopIncAlias.setIncAliasText(PingYinUtil.getFirstSpell(dto.getHopInc().getIncName()));
      hopIncAlias.setIncAliaIncId(dto.getHopInc().getIncId());
      commonService.saveOrUpdate(hopIncAlias);
    }
    commonService.saveOrUpdate(dto.getHopInc());
  }
コード例 #2
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());
    }
  }
コード例 #3
0
  /**
   * @Title: checkSendQty @Description: TODO(检查供应商发货数量)
   *
   * @param @param res 设定文件
   * @return void 返回类型
   * @throws
   * @author zhouxin
   * @date 2015年3月26日 上午11:35:53
   */
  public void checkSendQty(BusinessRequest res) {

    OrderStateDto dto = super.getDto(OrderStateDto.class, res);
    dto.setOperateResult(new OperateResult());
    try {
      List<OrderDetailSub> orderDetailSubs =
          commonService.findByProperty(
              OrderDetailSub.class, "ordSubDetailId", dto.getOrderDetailSub().getOrdSubDetailId());
      OrderDetail orderDetail =
          commonService.get(OrderDetail.class, dto.getOrderDetailSub().getOrdSubDetailId());
      Long state = orderDetail.getOrderState();
      // 一个订单可以发多次货,保证发货数不大于订单数就可以继续发货
      // 2:确认订单/下载订单
      // 10:部分发货
      // 5:评价
      // 4:收货
      if ((state.longValue() != 2l)
          && (state.longValue() != 10l)
          && (state.longValue() != 4l)
          && (state.longValue() != 5l)) {
        dto.getOperateResult().setResultCode("-1");
        dto.getOperateResult().setResultContent("已发货完成,不能增加批次");
        super.writeJSON(dto.getOperateResult());
        return;
      }
      float devlQty = 0;
      for (OrderDetailSub detailSub : orderDetailSubs) {
        if (detailSub
            .getOrdSubId()
            .toString()
            .equals(dto.getOrderDetailSub().getOrdSubDetailId().toString())) {

        } else {
          devlQty = devlQty + detailSub.getOrderSubQty().floatValue();
        }
      }
      float diffQty = orderDetail.getOrderVenQty() - devlQty;
      if (diffQty > 0) {
        dto.getOperateResult().setResultCode("1");
        dto.getOperateResult().setResultContent(String.valueOf(diffQty));
      }
      super.writeJSON(dto.getOperateResult());
    } catch (Exception e) {
      e.printStackTrace();
      dto.getOperateResult().setResultContent(e.getMessage());
      super.writeJSON(dto.getOperateResult());
    }
  }
コード例 #4
0
  public void saveOrdSub(BusinessRequest res) {

    OrderStateDto dto = super.getDto(OrderStateDto.class, res);
    dto.setOperateResult(new OperateResult());
    // 调用对应的service方法
    try {

      List<OrderDetailSub> orderDetailSubs =
          commonService.findByProperty(
              OrderDetailSub.class, "ordSubDetailId", dto.getOrderDetailSub().getOrdSubDetailId());
      OrderDetail orderDetail =
          commonService.get(OrderDetail.class, dto.getOrderDetailSub().getOrdSubDetailId());
      float devQty = 0;
      if (org.apache.commons.lang.StringUtils.isEmpty(dto.getOrderDetailSub().getOrdSubId())) {
        dto.getOrderDetailSub().setOrdSubId(null);
      } else {
        OrderDetailSub orderDetailSub =
            commonService.get(OrderDetailSub.class, dto.getOrderDetailSub().getOrdSubId());
        dto.getOrderDetailSub().setOrderSubImpId(orderDetailSub.getOrderSubImpId());
      }
      for (OrderDetailSub orderDetailSub : orderDetailSubs) {
        if ((dto.getOrderDetailSub().getOrdSubId() != null)
            && (dto.getOrderDetailSub().getOrdSubId().equals(orderDetailSub.getOrdSubId())))
          continue;
        devQty = devQty + orderDetailSub.getOrderSubQty().floatValue();
      }
      float enableQty = orderDetail.getOrderVenQty().floatValue() - devQty;
      if (enableQty >= dto.getOrderDetailSub().getOrderSubQty()) {
        dto.getOrderDetailSub().setOrdSubDate(new Date());
        dto.getOrderDetailSub()
            .setOrdSubUserId(Long.valueOf(super.getLoginInfo().get("USERID").toString()));
        commonService.saveOrUpdate(dto.getOrderDetailSub());
        dto.getOperateResult().setResultCode("1");
        dto.getOperateResult().setResultContent(dto.getOrderDetailSub().getOrdSubId());
      } else {
        dto.getOperateResult().setResultCode("-1");
        dto.getOperateResult().setResultContent(" 发货数不能大于订单数");
      }
      super.writeJSON(dto.getOperateResult());
    } catch (Exception e) {
      dto.getOperateResult().setResultContent(e.getMessage());
      e.printStackTrace();
      super.writeJSON(dto.getOperateResult());
    }
  }