气象预警查询,解决咸安区预警时区县仍是咸宁问题
parent
a69a9774eb
commit
ae3f7eca91
|
|
@ -4,17 +4,31 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.whdc.mapper.QXWarningMapper;
|
||||
import com.whdc.model.dto.GroupWarningDto;
|
||||
import com.whdc.model.entity.Adinfo;
|
||||
import com.whdc.model.entity.QXWarning;
|
||||
import com.whdc.model.vo.QXWarningVO;
|
||||
import com.whdc.service.IAdinfoService;
|
||||
import com.whdc.service.IQXWarningService;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class QXWarningServiceImpl extends ServiceImpl<QXWarningMapper, QXWarning> implements IQXWarningService {
|
||||
|
||||
@Autowired
|
||||
private IAdinfoService adinfoService;
|
||||
|
||||
@Override
|
||||
public List<QXWarningVO> find() {
|
||||
return getBaseMapper().findByMsgIsNull();
|
||||
|
|
@ -22,8 +36,38 @@ public class QXWarningServiceImpl extends ServiceImpl<QXWarningMapper, QXWarnin
|
|||
|
||||
@Override
|
||||
public IPage<QXWarning> page(GroupWarningDto dto) {
|
||||
return getBaseMapper().page(dto.getPage(),dto);
|
||||
IPage page = getBaseMapper().page(dto.getPage(), dto);
|
||||
if (page.getTotal() > 0){
|
||||
List<QXWarningVO> list = page.getRecords();
|
||||
List<String> adinfos = getXNCnnm();
|
||||
for(QXWarningVO vo : list){
|
||||
String cnnm = vo.getCnnm();
|
||||
String content = vo.getContent();
|
||||
if("咸宁".equals(cnnm) && CollectionUtils.isNotEmpty(adinfos)){
|
||||
Optional<String> first = adinfos.stream()
|
||||
.filter(content::contains)
|
||||
.findFirst();
|
||||
if (first.isPresent()){
|
||||
vo.setCnnm(first.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
private List<String> getXNCnnm() {
|
||||
List<Adinfo> list = adinfoService.lambdaQuery()
|
||||
.likeRight(Adinfo::getAdcd, "4212")
|
||||
.likeLeft(Adinfo::getAdcd, "000000000")
|
||||
.ne(Adinfo::getAdcd,"421200000000000")
|
||||
.list();
|
||||
if (CollectionUtils.isNotEmpty(list)){
|
||||
return list.stream().map(o->o.getAdnm().substring(0,2)).collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QXWarning> list(GroupWarningDto dto) {
|
||||
return getBaseMapper().list(dto);
|
||||
|
|
|
|||
Loading…
Reference in New Issue