package com.zd.laboratory.service.impl;

import java.util.List;

import com.zd.common.core.domain.R;
import com.zd.common.core.utils.StringUtils;
import com.zd.laboratory.domain.LabViolationSite;
import com.zd.laboratory.mapper.LabViolationSiteMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.laboratory.mapper.LabViolationScoreSiteMapper;
import com.zd.laboratory.domain.LabViolationScoreSite;
import com.zd.laboratory.service.ILabViolationScoreSiteService;

/**
 * 违规项扣分设置Service业务层处理
 *
 * @author zd
 * @date 2021-12-13
 */
@Service
public class LabViolationScoreSiteServiceImpl implements ILabViolationScoreSiteService
{
    @Autowired
    private LabViolationScoreSiteMapper labViolationScoreSiteMapper;

    @Autowired
    private LabViolationSiteMapper siteMapper;

    /**
     * 查询违规项扣分设置
     *
     * @param id 违规项扣分设置主键
     * @return 违规项扣分设置
     */
    @Override
    public LabViolationScoreSite selectLabViolationScoreSiteById(Long id)
    {
        return labViolationScoreSiteMapper.selectLabViolationScoreSiteById(id);
    }

    /**
     * 查询违规项扣分设置列表
     *
     * @param labViolationScoreSite 违规项扣分设置
     * @return 违规项扣分设置
     */
    @Override
    public List<LabViolationScoreSite> selectLabViolationScoreSiteList(LabViolationScoreSite labViolationScoreSite)
    {
        return labViolationScoreSiteMapper.selectLabViolationScoreSiteList(labViolationScoreSite);
    }

    /**
     * 查询违规项字典列表
     *
     * @return 违规项扣分设置
     */
    @Override
    public List<LabViolationScoreSite> selectLabScoreSiteList()
    {
        return labViolationScoreSiteMapper.selectLabScoreSiteList();
    }

    /**
     * 新增违规项扣分设置
     *
     * @param labViolationScoreSite 违规项扣分设置
     * @return 结果
     */
    @Override
    public int insertLabViolationScoreSite(LabViolationScoreSite labViolationScoreSite)
    {

        return labViolationScoreSiteMapper.insertLabViolationScoreSite(labViolationScoreSite);
    }

    /**
     * 修改违规项扣分设置
     *
     * @param labViolationScoreSite 违规项扣分设置
     * @return 结果
     */
    @Override
    public int updateLabViolationScoreSite(LabViolationScoreSite labViolationScoreSite)
    {
        return labViolationScoreSiteMapper.updateLabViolationScoreSite(labViolationScoreSite);
    }

    /**
     * 批量删除违规项扣分设置
     *
     * @param ids 需要删除的违规项扣分设置主键
     * @return 结果
     */
    @Override
    public int deleteLabViolationScoreSiteByIds(Long[] ids)
    {
        return labViolationScoreSiteMapper.deleteLabViolationScoreSiteByIds(ids);
    }

    /**
     * 删除违规项扣分设置信息
     *
     * @param id 违规项扣分设置主键
     * @return 结果
     */
    @Override
    public int deleteLabViolationScoreSiteById(Long id)
    {
        return labViolationScoreSiteMapper.deleteLabViolationScoreSiteById(id);
    }


    @Override
    public List<LabViolationScoreSite> selectLabViolationScore() {
        return labViolationScoreSiteMapper.selectLabViolationScore();
    }

    @Override
    public int delScoreSiteAll() {
        return labViolationScoreSiteMapper.delScoreSiteAll();
    }

    @Override
    public R getSiteCount() {
        List<LabViolationSite> violationSites = siteMapper.selectLabViolationSite();
        if (violationSites.size()> 0 && violationSites!=null)
            return R.ok(violationSites.get(0).getRemake());
        return R.fail();
    }
}
