package com.ruoyi.enterprise.service.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.enterprise.domain.CIndicationEnterprise;
import com.ruoyi.enterprise.mapper.CIndicationEnterpriseMapper;
import com.ruoyi.enterprise.service.ICIndicationEnterpriseService;
import com.ruoyi.report.vo.LastSumDTO;
import com.ruoyi.report.vo.SumItem;

/**
 * 地理标志核准企业Service业务层处理
 *
 * @author ruoyi
 * @date 2023-04-28
 */
@Service
public class CIndicationEnterpriseServiceImpl extends ServiceImpl<CIndicationEnterpriseMapper, CIndicationEnterprise> implements ICIndicationEnterpriseService {

	@Autowired
	private CIndicationEnterpriseMapper indicationEnterpriseMapper;
	
	private String getStr(Map map, String key) {
		if (map == null || key == null || !map.containsKey(key)) {
			return "";
		}
		return map.get(key).toString();
	}

	private int getInt(Map map, String key) {
		if (map == null || key == null || !map.containsKey(key)) {
			return 0;
		}
		return Integer.parseInt(map.get(key).toString());
	}

	private long getLong(Map map, String key) {
		if (map == null || key == null || !map.containsKey(key)) {
			return 0;
		}
		return Long.parseLong(map.get(key).toString());
	}

	
    /**
     * 查询地理标志核准企业列表
     *
     * @param cIndicationEnterprise 地理标志核准企业
     * @return 地理标志核准企业集合
     * @date 2023-04-28
     */
    @Override
    public List<CIndicationEnterprise> queryList(CIndicationEnterprise cIndicationEnterprise) {
        QueryWrapper<CIndicationEnterprise> queryWrapper = Wrappers.query();
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getPron())  ){
                    queryWrapper.eq("pron", cIndicationEnterprise.getPron());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHzn())  ){
                    queryWrapper.eq("hzn", cIndicationEnterprise.getHzn());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHznm())  ){
                    queryWrapper.eq("hznm", cIndicationEnterprise.getHznm());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHzno())  ){
                    queryWrapper.eq("hzno", cIndicationEnterprise.getHzno());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHzaddr())  ){
                    queryWrapper.eq("hzaddr", cIndicationEnterprise.getHzaddr());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHzdt())  ){
                    queryWrapper.eq("hzdt", cIndicationEnterprise.getHzdt());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHzdtYear())  ){
                    queryWrapper.eq("hzdt_year", cIndicationEnterprise.getHzdtYear());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHzgz())  ){
                    queryWrapper.eq("hzgz", cIndicationEnterprise.getHzgz());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getHzpro())  ){
                    queryWrapper.eq("hzpro", cIndicationEnterprise.getHzpro());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getPdw())  ){
                    queryWrapper.eq("pdw", cIndicationEnterprise.getPdw());
                }
                if (  StringUtils.isNotNull(cIndicationEnterprise.getPt())){
                    queryWrapper.eq("pt", cIndicationEnterprise.getPt());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getTimeCreate())  ){
                    queryWrapper.eq("time_create", cIndicationEnterprise.getTimeCreate());
                }
                if ( StringUtils.isNotEmpty(cIndicationEnterprise.getTimeUpdate())  ){
                    queryWrapper.eq("time_update", cIndicationEnterprise.getTimeUpdate());
                }
                if (  StringUtils.isNotNull(cIndicationEnterprise.getStatus())){
                    queryWrapper.eq("status", cIndicationEnterprise.getStatus());
                }
                if (  StringUtils.isNotNull(cIndicationEnterprise.getSysFileId())){
                    queryWrapper.eq("sys_file_id", cIndicationEnterprise.getSysFileId());
                }
        queryWrapper.orderByDesc("id");
        return this.list(queryWrapper);
    }
}
