package com.huatek.busi.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.huatek.busi.entity.GisEvaluateStatus;
import com.huatek.busi.mapper.GisEvaluateMapper;
import com.huatek.busi.service.GisEvaluateService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
@Slf4j
@Component
@Service(interfaceClass = GisEvaluateService.class)
@Transactional(rollbackFor = Exception.class)
public class GisEvaluateServiceImpl implements GisEvaluateService {

    @Autowired
    GisEvaluateMapper gisEvaluateMapper;

    @Override
    public List<GisEvaluateStatus> findEvaluateStatus() {
        List<GisEvaluateStatus> findStatus = gisEvaluateMapper.findEvaluateStatus();
        List<GisEvaluateStatus> findStatus_remove = new ArrayList<>();
        for (GisEvaluateStatus gisEvaluateStatus:findStatus) {
            if (StringUtils.isEmpty(gisEvaluateStatus.getHealthLevel()) ||
                StringUtils.isEmpty(gisEvaluateStatus.getHealthScore())){
                //将要删除的对象添加到新数组中统一删除
                findStatus_remove.add(gisEvaluateStatus);
            }
        }
        //统一删除
        findStatus.removeAll(findStatus_remove);
        return findStatus;
    }
}
