package com.testor.module.hazard.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.testor.module.emergency.model.vo.TContingencyPlanVO;
import com.testor.module.hazard.dao.THazardWorkPlanCheckDao;
import com.testor.module.hazard.model.domain.THazardWorkPlan;
import com.testor.module.hazard.model.domain.THazardWorkPlanCheck;
import com.testor.module.hazard.model.dto.THazardWorkPlanCheckParam;
import com.testor.module.hazard.service.THazardWorkPlanCheckService;
import com.tongtech.tfw.backend.core.helper.IdHelper;
import com.tongtech.tfw.backend.core.helper.ObjectHelper;
import com.tongtech.tfw.backend.core.helper.bean.BeanHelper;
import org.springframework.stereotype.Service;
import com.tongtech.tfw.backend.common.models.supers.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collections;
import java.util.List;

/**
 * 危险作业计划监督检查Service业务层处理
 * 
 * @author testor-framework
 * @date 2025-04-16 10:09:22
 */
@Service
public class THazardWorkPlanCheckServiceImpl extends SuperServiceImpl<THazardWorkPlanCheckDao, THazardWorkPlanCheck> implements THazardWorkPlanCheckService
{
    @Autowired(required = false)
    private THazardWorkPlanCheckDao tHazardWorkPlanCheckDao;

    @Override
    public Page<THazardWorkPlanCheck> selectTHazardWorkPlanCheckList(THazardWorkPlanCheckParam tHazardWorkPlanCheckParam) {
        IPage<THazardWorkPlanCheck> page = new Page<>(Long.valueOf(tHazardWorkPlanCheckParam.getPage()), Long.valueOf(tHazardWorkPlanCheckParam.getLimit()));
        return this.baseMapper.selectTHazardWorkPlanCheckList(page,tHazardWorkPlanCheckParam);
    }

    @Override
    public Page<THazardWorkPlanCheck> selectAppTHazardWorkPlanCheckList(THazardWorkPlanCheckParam tHazardWorkPlanCheckParam) {
        IPage<THazardWorkPlanCheck> page = new Page<>(Long.valueOf(tHazardWorkPlanCheckParam.getPage()), Long.valueOf(tHazardWorkPlanCheckParam.getLimit()));
        return this.baseMapper.selectAppTHazardWorkPlanCheckList(page,tHazardWorkPlanCheckParam);
    }

    @Override
    public THazardWorkPlanCheck addEntity(THazardWorkPlanCheck addRequest) {
        if(ObjectHelper.isNotEmpty(addRequest)){
            // TODO 按需求添加数据去重，特殊值设定，业务异常
            String id = IdHelper.getId32bit();
            THazardWorkPlanCheck data= BeanHelper.beanToBean(addRequest,  THazardWorkPlanCheck.class);
            data.setId(id);
            boolean result= this.save(data);
            if(result){
                THazardWorkPlanCheck newEntity = new THazardWorkPlanCheck();
                newEntity.setId(id);
                return newEntity;
            }
		}
        return null;
    }

    @Override
    public THazardWorkPlanCheck detail(String id) {
        return this.baseMapper.detail(id);
    }


}
