package com.ruoyi.postCheck.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.postCheck.domain.PostPlanInfo;
import com.ruoyi.postCheck.mapper.PostPlanInfoMapper;
import com.ruoyi.postCheck.mapper.PostPlanMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import com.ruoyi.postCheck.domain.join.PostPlanJoinChecked;
import com.ruoyi.postCheck.service.IPostPlanJoinCheckedService;

/**
 * 岗检记录上传列表Service业务层处理
 *
 * @author csg
 * @date 2023-12-22
 */
@Service
public class PostPlanJoinCheckedServiceImpl implements IPostPlanJoinCheckedService {
    @Autowired
    private PostPlanMapper postPlanMapper;

    @Autowired
    private PostPlanInfoMapper postPlanInfoMapper;

    /**
     * 查询岗检记录上传列表
     *
     * @param id 岗检记录上传列表主键
     * @return 岗检记录上传列表
     @Override public PostPlanJoinChecked selectPostPlanJoinCheckedById(Long id)
     {
     return null;
     }
     */

    /**
     * 查询岗检记录上传列表列表
     *
     * @param postPlanJoinChecked 岗检记录上传列表
     * @return 岗检记录上传列表
     */
    @Override
    public List<PostPlanJoinChecked> selectPostPlanJoinCheckedList(PostPlanJoinChecked postPlanJoinChecked) {
        return postPlanMapper.selectPostPlanJoinCheckedList(postPlanJoinChecked);
    }


    /**
     * 岗检完成确认
     *
     * @param planInfoId    岗检计划明细ID
     * @param checkedUserId 检查人ID
     * @param checkedTime   检查时间
     * @param checkedImg    检查表照片
     * @return 结果
     */
    @Override
    public int checked(Long planInfoId, Long checkedUserId, Date checkedTime, String checkedImg) {

        if (planInfoId == null || checkedUserId == null || checkedTime == null) {
            return 0;
        }

        PostPlanInfo postPlanInfo = new PostPlanInfo();
        postPlanInfo.setId(planInfoId);
        postPlanInfo.setCheckedUserId(checkedUserId);
        postPlanInfo.setCheckedTime(checkedTime);
        postPlanInfo.setCheckedImg(checkedImg);

        return postPlanInfoMapper.updatePostPlanInfo(postPlanInfo);
    }


    /**
     * 岗检完成确认后重新上传检查表照片
     *
     * @param planInfoId 岗检计划明细ID
     * @param checkedImg 检查表照片
     * @return 结果
     */
    @Override
    public int imgReUpload(Long planInfoId, String checkedImg) {

        if (planInfoId == null || StringUtils.isBlank(checkedImg)) {
            return 0;
        }

        PostPlanInfo postPlanInfo = new PostPlanInfo();
        postPlanInfo.setId(planInfoId);
        postPlanInfo.setCheckedImg(checkedImg);

        return postPlanInfoMapper.updatePostPlanInfo(postPlanInfo);
    }


}
