package com.ruoyi.inspection.service.impl;

import java.util.List;

import com.ruoyi.inspection.domain.InspectionRecordTable;
import com.ruoyi.inspection.mapper.InspectionManageTableMapper;
import com.ruoyi.inspection.domain.InspectionManageTable;
import com.ruoyi.inspection.mapper.InspectionRecordTableMapper;
import com.ruoyi.inspection.service.IInspectionManageTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 巡检点管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-08-29
 */
@Service
public class InspectionManageTableServiceImpl implements IInspectionManageTableService 
{
    @Autowired
    private InspectionManageTableMapper inspectionManageTableMapper;

    @Autowired
    private InspectionRecordTableMapper inspectionRecordTableMapper;
    /**
     * 查询巡检点管理
     *
     * @param id 巡检点管理主键
     * @return 巡检点管理
     */
    @Override
    public InspectionManageTable selectInspectionManageTableById(Long id)
    {
        return inspectionManageTableMapper.selectInspectionManageTableById(id);
    }

    /**
     * 查询巡检点管理列表
     * 
     * @param inspectionManageTable 巡检点管理
     * @return 巡检点管理
     */
    @Override
    public List<InspectionManageTable> selectInspectionManageTableList(InspectionManageTable inspectionManageTable)
    {
        List<InspectionManageTable> result=inspectionManageTableMapper.selectInspectionManageTableList(inspectionManageTable);

        result.forEach(item ->{
            InspectionRecordTable recordTable = new InspectionRecordTable();
            List<InspectionRecordTable>  recordTables = inspectionRecordTableMapper.selectInspectionRecordTableList(recordTable);
            item.setInspectionCount(recordTables.size());
        });
//        inspectionCount

        return result ;
    }

    /**
     * 新增巡检点管理
     * 
     * @param inspectionManageTable 巡检点管理
     * @return 结果
     */
    @Override
    public int insertInspectionManageTable(InspectionManageTable inspectionManageTable)
    {
        return inspectionManageTableMapper.insertInspectionManageTable(inspectionManageTable);
    }

    /**
     * 修改巡检点管理
     * 
     * @param inspectionManageTable 巡检点管理
     * @return 结果
     */
    @Override
    public int updateInspectionManageTable(InspectionManageTable inspectionManageTable)
    {
        return inspectionManageTableMapper.updateInspectionManageTable(inspectionManageTable);
    }

    /**
     * 批量删除巡检点管理
     * 
     * @param ids 需要删除的巡检点管理主键
     * @return 结果
     */
    @Override
    public int deleteInspectionManageTableByIds(Long[] ids)
    {
        return inspectionManageTableMapper.deleteInspectionManageTableByIds(ids);
    }

    /**
     * 删除巡检点管理信息
     * 
     * @param id 巡检点管理主键
     * @return 结果
     */
    @Override
    public int deleteInspectionManageTableById(Long id)
    {
        return inspectionManageTableMapper.deleteInspectionManageTableById(id);
    }
}
