예제 #1
0
  @Transactional(rollbackFor = MYException.class)
  public boolean updateBean(BlackRuleBean bean, User user) throws MYException {

    BlackRuleBean oldBean = blackRuleDAO.find(bean.getId());

    if (null == oldBean) {
      throw new MYException("数据错误,原单不存在");
    }

    List<BlackRuleProductBean> productList = bean.getProductList();

    List<BlackRuleStafferBean> stafferList = bean.getStafferList();

    String id = bean.getId();

    blackRuleDAO.updateEntityBean(bean);

    blackRuleProductDAO.deleteEntityBeansByFK(id);

    blackRuleStafferDAO.deleteEntityBeansByFK(id);

    for (BlackRuleProductBean each : productList) {
      each.setRefId(id);

      blackRuleProductDAO.saveEntityBean(each);
    }

    for (BlackRuleStafferBean each1 : stafferList) {
      each1.setRefId(id);

      blackRuleStafferDAO.saveEntityBean(each1);
    }

    return true;
  }
예제 #2
0
  @Transactional(rollbackFor = MYException.class)
  public boolean addBean(BlackRuleBean bean, User user) throws MYException {

    Expression exp = new Expression(bean, this);

    exp.check("#name &unique @blackRuleDAO", "名称已经存在");

    List<BlackRuleProductBean> productList = bean.getProductList();

    List<BlackRuleStafferBean> stafferList = bean.getStafferList();

    String id = commonDAO.getSquenceString20();

    bean.setId(id);

    blackRuleDAO.saveEntityBean(bean);

    for (BlackRuleProductBean each : productList) {
      each.setRefId(id);

      blackRuleProductDAO.saveEntityBean(each);
    }

    for (BlackRuleStafferBean each1 : stafferList) {
      each1.setRefId(id);

      blackRuleStafferDAO.saveEntityBean(each1);
    }

    return true;
  }
예제 #3
0
  /**
   * @param outId
   * @param productIdSet
   * @param eachRuleBean
   * @param ruleProductList
   */
  private void getExceptProduct(
      String outId,
      Set<String> productIdSet,
      BlackRuleBean eachRuleBean,
      List<BlackRuleProductBean> ruleProductList,
      List<BaseBean> baseList) {

    for (BaseBean eachBase : baseList) {
      String productId = eachBase.getProductId();

      if (!ListTools.isEmptyOrNull(ruleProductList)) {
        for (BlackRuleProductBean eachRuleProduct : ruleProductList) {
          if (productId.equals(eachRuleProduct.getProductId())) {
            if (!productIdSet.contains(productId)) {
              productIdSet.add(productId);
            }
          }
        }
      }

      if (!StringTools.isNullOrNone(eachRuleBean.getProductType())) {
        ProductBean productBean = productDAO.find(productId);

        if (null == productBean) {
          continue;
        } else {
          String pType = String.valueOf(productBean.getType());

          if (eachRuleBean.getProductType().indexOf(pType) != -1) {
            if (!productIdSet.contains(productId)) {
              productIdSet.add(productId);
            }
          }
        }
      }
    }
  }