Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/systemsetting/service/HttpOptionManagerSSTSImpl.java =================================================================== diff -u -r38404 -r38406 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/systemsetting/service/HttpOptionManagerSSTSImpl.java (.../HttpOptionManagerSSTSImpl.java) (revision 38404) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/systemsetting/service/HttpOptionManagerSSTSImpl.java (.../HttpOptionManagerSSTSImpl.java) (revision 38406) @@ -853,22 +853,25 @@ } @Override public synchronized void saveOrUpdateHttpOption(HttpOption httpOption){ + StringBuffer countSql = new StringBuffer(); + countSql.append("select count(*) from "); + countSql.append(HttpOption.class.getSimpleName()); + countSql.append(" po where 1=1 "); + if(DatabaseUtil.isPoIdValid(httpOption.getId())){ + countSql.append(" and po.id<>").append(httpOption.getId()); + } + countSql.append(" and po.optionListId='"); + countSql.append(httpOption.getOptionListId()); + countSql.append("' and po.optionText='"); + countSql.append(httpOption.getOptionText()); + countSql.append("'"); + int count = objectDao.countBySql(countSql.toString()); + if(count > 0){ + throw new SystemException(httpOption.getOptionText()+"已存在,不可重复添加"); + } if(!DatabaseUtil.isPoIdValid(httpOption.getId())){ - HttpOption checkHttpOption = get(httpOption.getOptionListId(), httpOption.getOptionText()); - if(checkHttpOption != null){ - throw new SystemException(checkHttpOption.getOptionText()+"已存在,不可重复添加"); - } int maxSequence = getMaxSequence(httpOption.getOptionListId()); httpOption.setSequence(maxSequence + 1); - }else{ - int count = objectDao.countBySql("select count(*) from " - +HttpOption.class.getSimpleName() - + " po where po.id<>"+ httpOption.getId() - + " and po.optionListId='" + httpOption.getOptionListId() - + "' and po.optionText='" + httpOption.getOptionText() + "'"); - if(count > 0){ - throw new SystemException(httpOption.getOptionText()+"已存在,不可重复添加"); - } } saveOrUpdate(httpOption); }