pert: 增加区域和主设备名称校验

iec104
huangfeng 1 year ago
parent c16a02bf87
commit 9ece185498

@ -10,5 +10,10 @@ import java.util.List;
@Repository
public interface JgRepository extends JpaRepository<Jg, Integer>, JpaSpecificationExecutor<Jg> {
List<Jg> findByBdzid(Integer bdzId);
List<Jg> findByBdzidAndMc(Integer bdzId, String mc);
List<Jg> findByBdzidAndMcAndIdIsNot(Integer bdzId, String mc, Integer id);
}

@ -10,5 +10,10 @@ import java.util.List;
@Repository
public interface ZsbRepository extends JpaRepository<Zsb, Integer>, JpaSpecificationExecutor<Zsb> {
List<Zsb> findByJgid(Integer jgid);
List<Zsb> findByJgidAndMc(Integer jgid, String mc);
List<Zsb> findByJgidAndMcAndIdIsNot(Integer jgid, String mc, Integer id);
}

@ -67,6 +67,10 @@ public class JgServiceImpl implements JgService {
if (!optionalBdz.isPresent()) {
throw new Exception("未找到该变电站");
}
List<Jg> list = repository.findByBdzidAndMc(item.getBdzid(), item.getMc());
if (!CollectionUtils.isEmpty(list)) {
throw new Exception("该名称已被使用");
}
return repository.save(item);
}
@ -76,6 +80,10 @@ public class JgServiceImpl implements JgService {
if (!optionalBdz.isPresent()) {
throw new Exception("未找到该变电站");
}
List<Jg> list = repository.findByBdzidAndMcAndIdIsNot(item.getBdzid(), item.getMc(), item.getId());
if (!CollectionUtils.isEmpty(list)) {
throw new Exception("该名称已被使用");
}
repository.save(item);
}

@ -87,6 +87,10 @@ public class ZsbServiceImpl implements ZsbService {
if (!optionalLx.isPresent()) {
throw new Exception("未找到该设备类型");
}
List<Zsb> list = repository.findByJgidAndMc(item.getJgid(), item.getMc());
if (!CollectionUtils.isEmpty(list)) {
throw new Exception("该名称已被使用");
}
return repository.save(item);
}
@ -98,6 +102,10 @@ public class ZsbServiceImpl implements ZsbService {
if (!optionalLx.isPresent()) {
throw new Exception("未找到该设备类型");
}
List<Zsb> list = repository.findByJgidAndMcAndIdIsNot(item.getJgid(), item.getMc(), item.getId());
if (!CollectionUtils.isEmpty(list)) {
throw new Exception("该名称已被使用");
}
repository.save(item);
}

Loading…
Cancel
Save