package com.yanzhu.jh.project.service.impl;

import java.util.List;

import com.ruoyi.common.enums.PublicStateEnum;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.jh.project.mapper.SurProjectMeasureMapper;
import com.yanzhu.jh.project.domain.SurProjectMeasure;
import com.yanzhu.jh.project.service.ISurProjectMeasureService;
import com.ruoyi.common.utils.SecurityUtils;
/**
 * 实测实量Service业务层处理
 * 
 * @author JiangYuQi
 * @date 2023-08-22
 */
@Service
public class SurProjectMeasureServiceImpl implements ISurProjectMeasureService 
{
    @Autowired
    private SurProjectMeasureMapper surProjectMeasureMapper;

    /**
     * 查询实测实量
     * 
     * @param id 实测实量主键
     * @return 实测实量
     */
    @Override
    public SurProjectMeasure selectSurProjectMeasureById(Long id)
    {
        return surProjectMeasureMapper.selectSurProjectMeasureById(id);
    }

    /**
     * 查询实测实量列表
     * 
     * @param surProjectMeasure 实测实量
     * @return 实测实量
     */
    @Override
    public List<SurProjectMeasure> selectSurProjectMeasureList(SurProjectMeasure surProjectMeasure)
    {
        return surProjectMeasureMapper.selectSurProjectMeasureList(surProjectMeasure);
    }

    /**
     * 新增实测实量
     * 
     * @param surProjectMeasure 实测实量
     * @return 结果
     */
    @Override
    public int insertSurProjectMeasure(SurProjectMeasure surProjectMeasure)
    {
        surProjectMeasure.setMainImage(surProjectMeasure.getImageUrls().split(",")[0]);
        surProjectMeasure.setIsDel(PublicStateEnum.OK.getCode());
        surProjectMeasure.setCreateBy(SecurityUtils.getUsername());
        surProjectMeasure.setCreateTime(DateUtils.getNowDate());
        return surProjectMeasureMapper.insertSurProjectMeasure(surProjectMeasure);
    }

    /**
     * 修改实测实量
     * 
     * @param surProjectMeasure 实测实量
     * @return 结果
     */
    @Override
    public int updateSurProjectMeasure(SurProjectMeasure surProjectMeasure)
    {
        surProjectMeasure.setMainImage(surProjectMeasure.getImageUrls().split(",")[0]);
        surProjectMeasure.setUpdateBy(SecurityUtils.getUsername());
        surProjectMeasure.setUpdateTime(DateUtils.getNowDate());
        return surProjectMeasureMapper.updateSurProjectMeasure(surProjectMeasure);
    }

    /**
     * 批量删除实测实量
     * 
     * @param ids 需要删除的实测实量主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectMeasureByIds(Long[] ids)
    {
        return surProjectMeasureMapper.deleteSurProjectMeasureByIds(ids);
    }

    /**
     * 删除实测实量信息
     * 
     * @param id 实测实量主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectMeasureById(Long id)
    {
        return surProjectMeasureMapper.deleteSurProjectMeasureById(id);
    }

    @Override
    public List<SurProjectMeasure> groupMeasureInfo(SurProjectMeasure where) {
        return surProjectMeasureMapper.groupMeasureInfo(where);
    }
}
