|
|
|
@ -2,7 +2,10 @@ package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.Modev;
|
|
|
|
|
import com.xydl.cac.entity.ModevType;
|
|
|
|
|
import com.xydl.cac.entity.Zsb;
|
|
|
|
|
import com.xydl.cac.repository.ModevRepository;
|
|
|
|
|
import com.xydl.cac.repository.ModevTypeRepository;
|
|
|
|
|
import com.xydl.cac.repository.ZsbRepository;
|
|
|
|
|
import com.xydl.cac.service.ModevService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -10,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
@ -21,9 +25,26 @@ public class ModevServiceImpl implements ModevService {
|
|
|
|
|
@Resource
|
|
|
|
|
ModevRepository repository;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
ModevTypeRepository modevTypeRepository;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
ZsbRepository zsbRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Modev> listAll(Integer zsbid) {
|
|
|
|
|
return repository.findByZsbid(zsbid);
|
|
|
|
|
List<Modev> byZsbid = repository.findByZsbid(zsbid);
|
|
|
|
|
Optional<Zsb> byId = zsbRepository.findById(zsbid);
|
|
|
|
|
List<ModevType> all = modevTypeRepository.findAll();
|
|
|
|
|
HashMap<Integer,String> map = new HashMap();
|
|
|
|
|
for (ModevType tit:all) {
|
|
|
|
|
map.put(tit.getId(), tit.getMc());
|
|
|
|
|
}
|
|
|
|
|
for (Modev it : byZsbid) {
|
|
|
|
|
it.setModevtname(map.get(it.getModevtid()));
|
|
|
|
|
it.setZsbname(byId.get().getMc());
|
|
|
|
|
}
|
|
|
|
|
return byZsbid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -41,7 +62,7 @@ public class ModevServiceImpl implements ModevService {
|
|
|
|
|
List<Modev> byMc = repository.findByZsbidAndName(item.getZsbid(), item.getName());
|
|
|
|
|
if (!CollectionUtils.isEmpty(byMc)) {
|
|
|
|
|
for (Modev it : byMc) {
|
|
|
|
|
if (it.getId() != item.getId()) {
|
|
|
|
|
if (it.getId().intValue() != item.getId().intValue()) {
|
|
|
|
|
throw new Exception("该监测装置类型已存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|