package com.tofly.feesapi.bmgl.controller.common;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tofly.feesapi.bjgl.entity.YhCbkxx;
import com.tofly.feesapi.bjgl.service.YhCbkxxService;
import com.tofly.feesapi.bmgl.entity.BmSj;
import com.tofly.feesapi.bmgl.service.BmSjService;
import com.tofly.feesapi.cbgl.entity.YyCblr;
import com.tofly.feesapi.cbgl.mapper.YyCblrMapper;
import com.tofly.feesapi.cbgl.service.YyCblrService;
import com.tofly.feesapi.sfgl.entity.YySspjxx;
import com.tofly.feesapi.sfgl.mapper.YySspjxxMapper;
import com.tofly.feesapi.sfgl.service.YySspjxxService;
import com.tofly.feesapi.yhgl.entity.YhKhjbxx;
import com.tofly.feesapi.yhgl.service.YhKhjbxxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * @author lihaoli
 * @date 2024/6/4
 */
@Configuration
public class bmscyz {
    @Autowired
    private YhKhjbxxService yhKhjbxxService;
    @Autowired
    private YhCbkxxService yhCbkxxService;
    @Autowired
    private YyCblrService yyCblrService;
    @Autowired
    private YyCblrMapper yyCblrMapper;
    @Autowired
    private YySspjxxService yySspjxxService;
    @Autowired
    private YySspjxxMapper yySspjxxMapper;
    @Autowired
    private BmSjService bmSjService;

    public boolean Isczkhsy(bmscyzselectVo bmscyzselectvo) {
        YhKhjbxx yhKhjbxx = JSONObject.parseObject(JSON.toJSONString(bmscyzselectvo), YhKhjbxx.class);
//        QueryWrapper<YhKhjbxx> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("", ""); // 添加查询条件
        if (yhKhjbxxService.count(new QueryWrapper<>(yhKhjbxx)) > 0)
            return true;
        return false;
    }

    public boolean Isczcbsy(bmscyzselectVo bmscyzselectvo) {
        YhCbkxx yhCbkxx = JSONObject.parseObject(JSON.toJSONString(bmscyzselectvo), YhCbkxx.class);
        if (yhCbkxxService.count(new QueryWrapper<>(yhCbkxx)) > 0)
            return true;
        return false;
    }

    public boolean Isczkhsy(String column, String val) {
        QueryWrapper<YhKhjbxx> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(column, Arrays.asList(val.split(",")));
        if (yhKhjbxxService.count(queryWrapper) > 0)
            return true;
        return false;
    }

    public boolean Isczcbsy(String column, String val) {
        QueryWrapper<YhCbkxx> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(column, Arrays.asList(val.split(",")));
        if (yhCbkxxService.count(queryWrapper) > 0)
            return true;
        return false;
    }

    public boolean Isczcblrsy(String column, String val) {
        QueryWrapper<YyCblr> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(column, Arrays.asList(val.split(",")));
        if (yyCblrService.count(queryWrapper) > 0)
            return true;
        if (yyCblrMapper.cblrlsCBFS(Arrays.asList(val.split(","))) > 0)
            return true;
        return false;
    }

    public boolean IsczSSPJsy(String column, String val) {
        QueryWrapper<YySspjxx> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(column, Arrays.asList(val.split(",")));
        if (yySspjxxService.count(queryWrapper) > 0)
            return true;
        if (column.equals("sflx")) {
            if (yySspjxxMapper.sspjSFLX(Arrays.asList(val.split(","))) > 0)
                return true;
        }
        if (column.equals("fffs"))
            if (yySspjxxMapper.sspjFFFS(Arrays.asList(val.split(","))) > 0)
                return true;
        if (column.equals("jfqd"))
            if (yySspjxxMapper.sspjJFQD(Arrays.asList(val.split(","))) > 0)
                return true;
        return false;
    }

    public boolean IsczSJsy(String column, String val) {
        QueryWrapper<BmSj> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(column, Arrays.asList(val.split(",")));
        if (bmSjService.count(queryWrapper) > 0) {
            return true;
        }
        return false;
    }
}
