package com.dcsoft.system.visitor.service.impl;

import com.dcsoft.common.core.constant.Constants;
import com.dcsoft.common.core.enums.ExamineEnum;
import com.dcsoft.common.security.utils.SecurityUtils;
import com.dcsoft.system.api.model.LoginUser;
import com.dcsoft.system.visitor.domain.*;
import com.dcsoft.system.visitor.mapper.VisCarryStuffMapper;
import com.dcsoft.system.visitor.mapper.VisitorMapper;
import com.dcsoft.system.visitor.service.IVisCarryStuffService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class VisCarryStuffImpl implements IVisCarryStuffService {

    @Resource
    private VisCarryStuffMapper visCarryStuffMapper;

    @Resource
    private VisitorMapper visitorMapper;

    @Override
    public List<VisExitOutVo> selectList(VisExitOutVo vo) {
        return visCarryStuffMapper.selectList(vo);
    }

    @Override
    public void insertVisExitOut(VisExitOutVo vo) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        vo.setCreateBy(loginUser.getUsername());
        vo.setUserId(loginUser.getUserid());
        vo.setExamineState(ExamineEnum.IN_REVIEW.getCode());
        visCarryStuffMapper.insertVisExitOut(vo);
    }

    @Override
    public void insertVisStuffInfo(List<VisStuffInfoVo> visStuffInfoList) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        visStuffInfoList.forEach(vo -> vo.setCreateBy(loginUser.getUsername()));
        visCarryStuffMapper.insertVisStuffInfo(visStuffInfoList);
    }

    @Override
    public List<VisStuffInfoVo> selectStuffList(VisStuffInfoVo visStuffInfoVo) {
        return visCarryStuffMapper.selectStuffList(visStuffInfoVo);
    }

    @Override
    public List<VisStuffInfoExportVo> selectVisitorList(VisExitOutVo vo) {
        return visCarryStuffMapper.selectVisitorList(vo);
    }

    @Override
    public VisExitOutVo selectVisExitOutById(Long id) {
        return visCarryStuffMapper.selectVisExitOutById(id);
    }

    @Override
    public CheckCodeVo selectStuffCheckCode(Long id) {
        return visCarryStuffMapper.selectStuffCheckCode(id);
    }

    @Override
    public void updateStaff(VisExitOutVo vo) {
        visCarryStuffMapper.updateStaff(vo);
    }

    @Override
    public List<VisitorReviewProcessVo> queryVisitorReviewProcessList(Long id) {
        return visCarryStuffMapper.queryVisitorReviewProcessList(id);
    }

    @Override
    public void saveVisitorReviewProcess(VisExitOutVo vo) {
        visCarryStuffMapper.saveVisitorReviewProcess(vo);
    }

    @Override
    public VisitorReviewProcessVo queryReviewProcessNew(VisExitOutVo stuffVo) {
        return visCarryStuffMapper.queryReviewProcessNew(stuffVo);
    }
}
