package com.ruoyi.postCheck.service.impl;

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

import com.ruoyi.postCheck.domain.PostCheckedProblem;
import com.ruoyi.postCheck.service.IPostCheckedProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.postCheck.mapper.PostPlanMapper;
import com.ruoyi.postCheck.domain.join.PostPlanJoinProblem;
import com.ruoyi.postCheck.service.IPostPlanJoinProblemService;
import org.springframework.util.CollectionUtils;

/**
 * 岗检问题录入列表Service业务层处理
 *
 * @author csg
 * @date 2023-12-22
 */
@Service
public class PostPlanJoinProblemServiceImpl implements IPostPlanJoinProblemService {
    @Autowired
    private PostPlanMapper postPlanMapper;
    @Autowired
    private IPostCheckedProblemService postCheckedProblemService;

    /**
     * 查询岗检问题录入列表
     *
     * @param id 岗检问题录入列表主键
     * @return 岗检问题录入列表
     @Override public PostPlanJoinProblem selectPostPlanJoinProblemById(Long id)
     {
     return postPlanMapper.selectPostPlanJoinProblemById(id);
     }
     */

    /**
     * 查询岗检问题录入列表列表
     *
     * @param postPlanJoinProblem 岗检问题录入列表
     * @return 岗检问题录入列表
     */
    @Override
    public List<PostPlanJoinProblem> selectPostPlanJoinProblemList(PostPlanJoinProblem postPlanJoinProblem) {
        List<PostPlanJoinProblem> data = postPlanMapper.selectPostPlanJoinProblemList(postPlanJoinProblem);
        if (!CollectionUtils.isEmpty(data)) {
//            List<Long> ids = orderList.stream().map(OrderDO::getId).collect(Collectors.toList());
            for (PostPlanJoinProblem postPlanJoinProblemDB : data) {
                Date checkTime = postPlanJoinProblemDB.getCheckTime();
                Long checkedDeptId = postPlanJoinProblemDB.getCheckedDeptId();
                if (checkTime != null && checkedDeptId != null) {
                    PostCheckedProblem param = new PostCheckedProblem();
                    param.setCheckTime(checkTime);
                    param.setCheckedDeptId(checkedDeptId);
                    List<PostCheckedProblem> children = postCheckedProblemService.selectPostCheckedProblemList(param);
                    postPlanJoinProblemDB.setChildren(children);
                }
            }
        }
        return data;
    }

    /**
     * 新增岗检问题录入列表
     *
     * @param postPlanJoinProblem 岗检问题录入列表
     * @return 结果
     @Override public int insertPostPlanJoinProblem(PostPlanJoinProblem postPlanJoinProblem)
     {
     return postPlanMapper.insertPostPlanJoinProblem(postPlanJoinProblem);
     }
     */

    /**
     * 修改岗检问题录入列表
     *
     * @param postPlanJoinProblem 岗检问题录入列表
     * @return 结果
     @Override public int updatePostPlanJoinProblem(PostPlanJoinProblem postPlanJoinProblem) {
     return 0;
     }
     */

    /**
     * 批量删除岗检问题录入列表
     *
     * @param ids 需要删除的岗检问题录入列表主键
     * @return 结果
     @Override public int deletePostPlanJoinProblemByIds(Long[] ids)
     {
     return postPlanMapper.deletePostPlanJoinProblemByIds(ids);
     }
     */

    /**
     * 删除岗检问题录入列表信息
     *
     * @param id 岗检问题录入列表主键
     * @return 结果
     @Override public int deletePostPlanJoinProblemById(Long id)
     {
     return postPlanMapper.deletePostPlanJoinProblemById(id);
     }
     */
}
