|
|
@ -1,6 +1,8 @@
|
|
|
|
package com.xydl.cac.service.impl;
|
|
|
|
package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.Bdz;
|
|
|
|
import com.xydl.cac.entity.Jg;
|
|
|
|
import com.xydl.cac.entity.Jg;
|
|
|
|
|
|
|
|
import com.xydl.cac.repository.BdzRepository;
|
|
|
|
import com.xydl.cac.repository.JgRepository;
|
|
|
|
import com.xydl.cac.repository.JgRepository;
|
|
|
|
import com.xydl.cac.service.JgService;
|
|
|
|
import com.xydl.cac.service.JgService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@ -9,6 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
@ -17,6 +20,8 @@ public class JgServiceImpl implements JgService {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
JgRepository repository;
|
|
|
|
JgRepository repository;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
BdzRepository bdzRepository;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Jg> listAll(Integer bdzid) {
|
|
|
|
public List<Jg> listAll(Integer bdzid) {
|
|
|
@ -28,8 +33,12 @@ public class JgServiceImpl implements JgService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Jg add(Jg item) {
|
|
|
|
public Jg add(Jg item) throws Exception {
|
|
|
|
item.setId(null);
|
|
|
|
item.setId(null);
|
|
|
|
|
|
|
|
Optional<Bdz> optional = bdzRepository.findById(item.getBdzid());
|
|
|
|
|
|
|
|
if (!optional.isPresent()) {
|
|
|
|
|
|
|
|
throw new Exception("未找到该变电站");
|
|
|
|
|
|
|
|
}
|
|
|
|
return repository.save(item);
|
|
|
|
return repository.save(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -42,4 +51,13 @@ public class JgServiceImpl implements JgService {
|
|
|
|
public void delete(Integer id) {
|
|
|
|
public void delete(Integer id) {
|
|
|
|
repository.deleteById(id);
|
|
|
|
repository.deleteById(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Jg detail(Integer id) throws Exception {
|
|
|
|
|
|
|
|
Optional<Jg> optional = repository.findById(id);
|
|
|
|
|
|
|
|
if (!optional.isPresent()) {
|
|
|
|
|
|
|
|
throw new Exception("未找到该区域");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|