package cn.cecep.talroad.service.impl.effective;

import cn.cecep.talroad.vo.query.effective.MAiControlDelayAssessmentQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.cecep.talroad.domain.effective.MAiControlDelayAssessment;
import cn.cecep.talroad.mapper.effective.MAiControlDelayAssessmentMapper;
import cn.cecep.talroad.service.effective.MAiControlDelayAssessmentService;
@Service
public class MAiControlDelayAssessmentServiceImpl extends ServiceImpl<MAiControlDelayAssessmentMapper, MAiControlDelayAssessment> implements MAiControlDelayAssessmentService {

    @Override
    public int updateBatch(List<MAiControlDelayAssessment> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<MAiControlDelayAssessment> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<MAiControlDelayAssessment> list) {
        return baseMapper.batchInsert(list);
    }

    @Override
    public Map<String, Object> getMapService(MAiControlDelayAssessmentQuery query) {
        QueryWrapper<MAiControlDelayAssessment> wrapper =
                MAiControlDelayAssessmentQuery.createLambdaQueryWrapper(query).select(
                        "site_name","factory_name","estimated_time");
        List<MAiControlDelayAssessment> list = list(wrapper);
        Map<String,Object> map=new HashMap<>();
        List<String> xList=new ArrayList<>();
        List<String> yList=new ArrayList<>();
        List<List<Object>> dataList=new ArrayList<>();
        for (MAiControlDelayAssessment assessment : list) {
            List<Object> stringList=new ArrayList<>();
            xList.add(assessment.getSiteName());
            yList.add(assessment.getFactoryName());
            stringList.add(assessment.getSiteName());
            stringList.add(assessment.getFactoryName());
            stringList.add(assessment.getEstimatedTime());
            dataList.add(stringList);
        }
        map.put("xlist",xList);
        map.put("yList",yList);
        map.put("dataList",dataList);
        return map;
    }
}
