|
|
|
@ -6,6 +6,7 @@ import com.xydl.cac.entity.Zsb;
|
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
|
import com.xydl.cac.repository.BdzRepository;
|
|
|
|
|
import com.xydl.cac.repository.JgRepository;
|
|
|
|
|
import com.xydl.cac.repository.NSensorRepository;
|
|
|
|
|
import com.xydl.cac.repository.ZsbRepository;
|
|
|
|
|
import com.xydl.cac.service.JgService;
|
|
|
|
|
import com.xydl.cac.task.CacheTask;
|
|
|
|
@ -15,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
@ -29,6 +31,8 @@ public class JgServiceImpl implements JgService {
|
|
|
|
|
BdzRepository bdzRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
ZsbRepository zsbRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
NSensorRepository sensorRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Jg> listAll(Integer bdzid) {
|
|
|
|
@ -50,6 +54,38 @@ public class JgServiceImpl implements JgService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Jg> sensorCount(Integer bdzid) {
|
|
|
|
|
List<Jg> result;
|
|
|
|
|
if (bdzid == null) {
|
|
|
|
|
if (CacheTask.jg_Cache == null) {
|
|
|
|
|
CacheTask.jg_Cache = repository.findAll();
|
|
|
|
|
this.fillBdzName(CacheTask.jg_Cache);
|
|
|
|
|
}
|
|
|
|
|
result = CacheTask.jg_Cache;
|
|
|
|
|
} else {
|
|
|
|
|
result = repository.findByBdzid(bdzid);
|
|
|
|
|
Optional<Bdz> optional = bdzRepository.findById(bdzid);
|
|
|
|
|
if (optional.isPresent() && !CollectionUtils.isEmpty(result)) {
|
|
|
|
|
for (Jg jg : result) {
|
|
|
|
|
jg.setBdzName(optional.get().getMc());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (Jg jg : result) {
|
|
|
|
|
List<Zsb> zsbList = zsbRepository.findByJgid(jg.getId());
|
|
|
|
|
List<Integer> idList = new ArrayList<>();
|
|
|
|
|
for (Zsb zsb : zsbList) {
|
|
|
|
|
idList.add(zsb.getId());
|
|
|
|
|
}
|
|
|
|
|
if (idList.size() > 0) {
|
|
|
|
|
long count = sensorRepository.countByZsbIdIn(idList);
|
|
|
|
|
jg.setSensorCount(count);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillBdzName(List<Jg> list) {
|
|
|
|
|
List<Bdz> bdzList = bdzRepository.findAll();
|
|
|
|
|
if (!CollectionUtils.isEmpty(list) && !CollectionUtils.isEmpty(bdzList)) {
|
|
|
|
|