@Override
  public void save(OprEnterPortStandard entity) {
    User user = WebRalasafe.getCurrentUser(ServletActionContext.getRequest());
    String userName = user.get("name") + "";
    entity.setLastCountName(userName);
    entity.setLastCountTime(new Date());

    Query query = null;
    if (null != entity.getId() && entity.getId() > 0) {
      query =
          this.enterPortStandardDao.createQuery(
              "from OprEnterPortStandard where deptId=? and id!=?",
              entity.getDeptId(),
              entity.getId());
    } else {
      query =
          this.enterPortStandardDao.createQuery(
              "from OprEnterPortStandard where deptId=? ", entity.getDeptId());
    }
    List<OprEnterPortStandard> list = query.list();

    if (null == list || list.size() == 0) {
      super.save(entity);
    } else {
      throw new ServiceException("该部门已经存在!");
    }
  }
Esempio n. 2
0
 @Override
 public void save(CtTmD entity) {
   List<CtTmD> list = this.ctTmDDao.findBy("DNo", entity.getDNo());
   if (null != list && list.size() > 0) { // 如果存在此配送单号,则删除
     for (int i = 0; i < list.size(); i++) {
       this.ctTmDDao.delete(list.get(i));
     }
   }
   super.save(entity);
 }