package com.mosty.rzzx.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mosty.base.model.query.rzzx.TbRzHjQueryDto;
import com.mosty.common.token.UserInfoManager;
import com.mosty.common.util.PermissionsUtil;
import com.mosty.rzzx.mapper.RzzxStatisticsMapper;
import com.mosty.rzzx.remote.TbBaseAdaptRemoteService;
import com.mosty.rzzx.service.RzzxStatisticsService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

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

@Service
@AllArgsConstructor
public class RzzxStatisticsServiceImpl implements RzzxStatisticsService {

    private final RzzxStatisticsMapper rzzxStatisticsMapper;
    private final TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
    @Override
    public List<Map<String, Object>> sjfktj() {
//        Map<String, Object> map = new HashMap<>();
        String ssbmdm = this.tbBaseAdaptRemoteService.getSsbm(null, null);
//        map.put("useSql", PermissionsUtil.createSql("", UserInfoManager.get()));
        return this.rzzxStatisticsMapper.sjfktj(ssbmdm);
    }

    @Override
    public List<Map<String, Object>> xjfktj() {
        Map<String, Object> map = new HashMap<>();
//        map.put("useSql", PermissionsUtil.createSql("", UserInfoManager.get()));
        String ssbmdm = this.tbBaseAdaptRemoteService.getSsbm(null, null);
        return this.rzzxStatisticsMapper.xjfktj(ssbmdm);
    }

    @Override
    public List<Map<String, Object>> glfktj() {
        Map<String, Object> map = new HashMap<>();
        String ssbmdm = this.tbBaseAdaptRemoteService.getSsbm(null, null);
//        map.put("useSql", PermissionsUtil.createSql("", UserInfoManager.get()));
        return this.rzzxStatisticsMapper.glfktj(ssbmdm);
    }

    @Override
    public List<Map<String, Object>> gxtfktj() {
        Map<String, Object> map = new HashMap<>();
//        map.put("useSql", PermissionsUtil.createSql("", UserInfoManager.get()));
        String ssbmdm = this.tbBaseAdaptRemoteService.getSsbm(null, null);
        return this.rzzxStatisticsMapper.gxtfktj(ssbmdm);
    }

    @Override
    public IPage<Map<String, Object>> lbcx(TbRzHjQueryDto dto) {
        Map<String, Object> map = new HashMap<>();
        map.put("pageIndex", (dto.getPageNum() - 1) * dto.getPageSize());
        map.put("pageSize", dto.getPageSize());
//        map.put("useSql", PermissionsUtil.createSql("", UserInfoManager.get()));
        String ssbmdm = this.tbBaseAdaptRemoteService.getSsbm(null, null);
        map.put("ssbmdm",ssbmdm);
        int count = this.rzzxStatisticsMapper.lbcxCount(map);
        List<Map<String, Object>> list = this.rzzxStatisticsMapper.lbcxList(map);
        IPage<Map<String, Object>> page = new Page<>(dto.getPageNum(), dto.getPageSize());
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }
}
