package com.huashe.park.core.service.impl;

import java.util.List;

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

import com.huashe.park.common.DateTimeUtil;
import com.huashe.park.core.mapper.PileHoleIndexRealtimeMapper;
import com.huashe.park.core.service.IPileHoleIndexRealtimeService;
import com.huashe.park.domain.entity.PileHoleIndexRealtime;

/**
 * 桩点最新指标Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-02-28
 */
@Service
public class PileHoleIndexRealtimeServiceImpl implements IPileHoleIndexRealtimeService {
    @Autowired
    private PileHoleIndexRealtimeMapper pileHoleIndexRealtimeMapper;

    /**
     * 查询桩点最新指标
     * 
     * @param id 桩点最新指标主键
     * @return 桩点最新指标
     */
    @Override
    public PileHoleIndexRealtime selectPileHoleIndexRealtimeById(Long id) {
        return pileHoleIndexRealtimeMapper.selectPileHoleIndexRealtimeById(id);
    }

    /**
     * 查询桩点最新指标列表
     * 
     * @param pileHoleIndexRealtime 桩点最新指标
     * @return 桩点最新指标
     */
    @Override
    public List<PileHoleIndexRealtime> selectPileHoleIndexRealtimeList(PileHoleIndexRealtime pileHoleIndexRealtime) {
        return pileHoleIndexRealtimeMapper.selectPileHoleIndexRealtimeList(pileHoleIndexRealtime);
    }

    /**
     * 新增桩点最新指标
     * 
     * @param pileHoleIndexRealtime 桩点最新指标
     * @return 结果
     */
    @Override
    public int insertPileHoleIndexRealtime(PileHoleIndexRealtime pileHoleIndexRealtime) {
        return pileHoleIndexRealtimeMapper.insertPileHoleIndexRealtime(pileHoleIndexRealtime);
    }

    /**
     * 修改桩点最新指标
     * 
     * @param pileHoleIndexRealtime 桩点最新指标
     * @return 结果
     */
    @Override
    public int updatePileHoleIndexRealtime(PileHoleIndexRealtime pileHoleIndexRealtime) {
        return pileHoleIndexRealtimeMapper.updatePileHoleIndexRealtime(pileHoleIndexRealtime);
    }

    @Override
    public int updatePileHoleIndexRealtimeByHoleIdAndMachineId(PileHoleIndexRealtime pileHoleIndexRealtime) {
        return pileHoleIndexRealtimeMapper.updatePileHoleIndexRealtimeByHoleIdAndMachineId(pileHoleIndexRealtime);
    }

    /**
     * 批量删除桩点最新指标
     * 
     * @param ids 需要删除的桩点最新指标主键
     * @return 结果
     */
    @Override
    public int deletePileHoleIndexRealtimeByIds(Long[] ids) {
        return pileHoleIndexRealtimeMapper.deletePileHoleIndexRealtimeByIds(ids);
    }

    /**
     * 删除桩点最新指标信息
     * 
     * @param id 桩点最新指标主键
     * @return 结果
     */
    @Override
    public int deletePileHoleIndexRealtimeById(Long id) {
        return pileHoleIndexRealtimeMapper.deletePileHoleIndexRealtimeById(id);
    }

    @Override
    public int cntMachineConstructingPileHole(Long machineId) {
        String date = DateTimeUtil.minusMinute(60L);
        return pileHoleIndexRealtimeMapper.selectMachineConstingPileHole(machineId, date);
    }

    @Override
    public PileHoleIndexRealtime selectMachineLatestIndex(Long machineId) {
        return pileHoleIndexRealtimeMapper.selectMachineLatestIndex(machineId);
    }
}
