package com.dayou.service.workflow;

import com.dayou.entity.WorkFlowLog;
import com.dayou.mapper.WorkFlowLogMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dayou.utils.DateUtils;
import com.dayou.vo.WorkLogVO;
import com.dayou.vo.WorkflowLogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;

/**
 * <p>
 * 实例节点流水表 服务实现类
 * </p>
 *
 * @author wucl
 * @since 2023-10-17
 */
@Service
public class WorkFlowLogServiceImpl extends ServiceImpl<WorkFlowLogMapper, WorkFlowLog> implements IWorkFlowLogService {


    @Autowired
    private WorkFlowLogMapper workFlowLogMapper;
    @Override
    @SuppressWarnings("unchecked")
    public Page<WorkFlowLog> selectPage(Page page,WorkFlowLog workFlowLog){
        return this.page(page, new QueryWrapper<WorkFlowLog>(workFlowLog));
    }


    @Override
    public WorkFlowLog detail(Long id){
        return this.getById(id);
    }

    @Override
    public Boolean add(WorkFlowLog workFlowLog){
        return  this.save(workFlowLog);
    }

    @Override
    public List<WorkflowLogVO> getList(WorkFlowLog workFlowLog) {
        List<WorkflowLogVO> list = workFlowLogMapper.getList(workFlowLog.getBusinessId(),workFlowLog.getBusinessSubId(),workFlowLog.getBusinessMinId(),workFlowLog.getBusinessType());
        list.stream().forEach(x->{
            x.setLongTime(DateUtils.getTimeLong(x.getHandingTime()==null?0L:x.getHandingTime()));
        });
        return list;
    }

    @Override
    public WorkFlowLog getRefuse(Long businessId, String businessType) {
        return workFlowLogMapper.getRefuse(businessId,businessType);
    }


}
