|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.Jg;
|
|
|
|
|
import com.xydl.cac.entity.Lx;
|
|
|
|
|
import com.xydl.cac.entity.Zsb;
|
|
|
|
|
import com.xydl.cac.repository.LxRepository;
|
|
|
|
|
import com.xydl.cac.repository.ZsbRepository;
|
|
|
|
|
import com.xydl.cac.service.JgService;
|
|
|
|
|
import com.xydl.cac.service.ZsbService;
|
|
|
|
@ -11,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
@ -21,6 +24,8 @@ public class ZsbServiceImpl implements ZsbService {
|
|
|
|
|
ZsbRepository repository;
|
|
|
|
|
@Resource
|
|
|
|
|
JgService jgService;
|
|
|
|
|
@Resource
|
|
|
|
|
LxRepository lxRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Zsb> listAll(Integer jgid) {
|
|
|
|
@ -36,6 +41,10 @@ public class ZsbServiceImpl implements ZsbService {
|
|
|
|
|
item.setId(null);
|
|
|
|
|
Jg jg = jgService.detail(item.getJgid());
|
|
|
|
|
item.setBdzid(jg.getBdzid());
|
|
|
|
|
Optional<Lx> optional = lxRepository.findById(item.getLxid());
|
|
|
|
|
if (!optional.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该设备类型");
|
|
|
|
|
}
|
|
|
|
|
return repository.save(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -43,6 +52,10 @@ public class ZsbServiceImpl implements ZsbService {
|
|
|
|
|
public void update(Zsb item) throws Exception {
|
|
|
|
|
Jg jg = jgService.detail(item.getJgid());
|
|
|
|
|
item.setBdzid(jg.getBdzid());
|
|
|
|
|
Optional<Lx> optional = lxRepository.findById(item.getLxid());
|
|
|
|
|
if (!optional.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该设备类型");
|
|
|
|
|
}
|
|
|
|
|
repository.save(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|