package com.usky.fire.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usky.common.mybatis.core.AbstractCrudService;
import com.usky.fire.domain.DemEnforceProjectAll;
import com.usky.fire.mapper.DemEnforceProjectAllMapper;
import com.usky.fire.service.DemEnforceProjectAllService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 监督管理项目全表 服务实现类
 * </p>
 *
 * @author JCB
 * @since 2022-10-19
 */
@Service
public class DemEnforceProjectAllServiceImpl extends AbstractCrudService<DemEnforceProjectAllMapper, DemEnforceProjectAll> implements DemEnforceProjectAllService {

    @Override
    public int enforceProjectAllCount(String typeOneLetter, String typeTwoLetter, Date startTime, Date endTime, String unitId, String qualifiedFlag) {
        LambdaQueryWrapper<DemEnforceProjectAll> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(DemEnforceProjectAll::getDeleteFlag, 0)
                .eq(StringUtils.isNotBlank(typeOneLetter), DemEnforceProjectAll::getProjectBranchType1, typeOneLetter)
                    .eq(StringUtils.isNotBlank(typeTwoLetter), DemEnforceProjectAll::getProjectBranchType2, typeTwoLetter)
                .eq(unitId != null && unitId != "", DemEnforceProjectAll::getProjectCompanyId, unitId)
                .eq(StringUtils.isNotBlank(qualifiedFlag), DemEnforceProjectAll::getProjectResult, qualifiedFlag)
                .between(startTime != null && endTime != null, DemEnforceProjectAll::getProjectCreateTime, startTime, endTime);
        int count = this.count(queryWrapper);
        return count;

    }

}
