package com.zjrs.ggfw.rlzysc.bpo.impl;

import org.apache.commons.lang.StringUtils;
import org.mohrss.leaf.core.framework.persistens.PageResult;
import com.zjrs.ggfw.rlzysc.blo.SyBLO;
import com.zjrs.ggfw.rlzysc.bpo.SyBPO;
import com.zjrs.ggfw.rlzysc.dto.JyzxQueryDTO;
import com.zjrs.ggfw.rlzysc.dto.SyZwxxQueryDTO;
import com.zjrs.ggfw.rlzysc.dto.ZphglQueryDTO;
import com.zjrs.ggfw.rlzysc.dto.ZwxxListDTO;
import com.zjrs.ggfw.rlzysc.dto.grzxjlxx.SyMapQyQueryDTO;
import com.zjrs.ggfw.rlzysc.dto.grzxjlxx.ZjDTO;
import com.zjrs.ggfw.rlzysc.po.RsRlzyLbggPO;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SyBPOImpl implements SyBPO {
    @Resource
    private SyBLO syBLO;

    @Override
    public List<RsRlzyLbggPO> getLbggList() {
        return this.syBLO.getLbggList();
    }

    @Override
    public List getZyxxList() {
        return this.syBLO.getZyxxList();
    }

    @Override
    public List<ZwxxListDTO> getZwtjList(SyZwxxQueryDTO dto) {
        return this.syBLO.getZwtjList(dto);
    }

    @Override
    public List getQytjList() {
        return this.syBLO.getQytjList();

    }

    @Override
    public List getZyxxList(String id) {
        return this.syBLO.getZyxxList(id);
    }

    @Override
    public PageResult getFwggList(JyzxQueryDTO jyzxlx, int page, int rows) {
        return this.syBLO.getFwggList(jyzxlx, page, rows);
    }

    @Override
    public PageResult getXyzpxxList(int page, int rows) {
        return this.syBLO.getXyzpxxList(page, rows);
    }

    @Override
    public PageResult getZxscZphxx(ZphglQueryDTO dto) {
        return this.syBLO.getZxscZphxx(dto);
    }

    @Override
    public List<Map<String, Object>> getZphCalendarList() {
        return this.syBLO.getZphCalendarList();
    }

    @Override
    public Map<String, Object> getMapQy(ZjDTO dto) {
        Map<String, Object> result = new HashMap<String, Object>();
        List<Map<String, Object>> list = this.syBLO.getMapQy(dto);
        if (list!=null && list.size()>0){
            result.put("aae004",list.get(0).get("aae004"));
            result.put("aae005",list.get(0).get("aae005"));
            result.put("aae006",list.get(0).get("aae006"));
            result.put("aab004",list.get(0).get("aab004"));
            result.put("zwlist",list);
        }
        return result;
    }

    @Override
    public Map<String, Object> getMapZw(SyMapQyQueryDTO dto) {
        Map<String, Object> result = new HashMap<String, Object>();
        List<Map<String, Object>> MapZwList = this.syBLO.getMapZw(dto);
        List<String> qylshList = new ArrayList<String>();
        List<Map<String, Object>> qyxxList = new ArrayList<>();
        for (Map<String, Object> map : MapZwList) {
            String qylsh = (String) map.get("rsrlzyqyxxlsh");
            if (StringUtils.isNotBlank(qylsh)){
                if (qylshList.contains(qylsh)){
                    continue;
                } else {
                    qylshList.add(qylsh);
                    Map<String, Object> qymap = new HashMap<String, Object>();
                    qymap.put("rsrlzyqyxxlsh",map.get("rsrlzyqyxxlsh"));
                    qymap.put("lng",map.get("lng"));
                    qymap.put("lat",map.get("lat"));
                    qyxxList.add(qymap);
                }
            }

        }
        result.put("zw",MapZwList);
        result.put("qy",qyxxList);
        return result;
    }
}

