package com.hotent.project.manager.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hotent.project.model.CostProjectTaskDocumentData;
import com.hotent.project.dao.CostProjectTaskDocumentDataDao;
import com.hotent.project.manager.CostProjectTaskDocumentDataManager;
import com.hotent.base.manager.impl.BaseManagerImpl;
import com.hotent.uc.exception.BaseException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;

import com.hotent.base.util.BeanUtils;


/**
 * 任务定制-监审项目文书表 服务实现类
 *
 * @author 超级管理员
 * @company 山西清众科技股份有限公司
 * @since 2025-10-09
 */
@Service
public class CostProjectTaskDocumentDataManagerImpl extends BaseManagerImpl<CostProjectTaskDocumentDataDao, CostProjectTaskDocumentData> implements CostProjectTaskDocumentDataManager {

    @Override
    public CostProjectTaskDocumentData getDetail(String id) {
        CostProjectTaskDocumentData costProjectTaskDocumentData = this.get(id);


        return costProjectTaskDocumentData;
    }

    @Override
    @Transactional
    public void createOrUpdate(CostProjectTaskDocumentData costProjectTaskDocumentData) {
        //新建或更新
        this.saveOrUpdate(costProjectTaskDocumentData);
    }

    @Override
    public Map<String, List<CostProjectTaskDocumentData>> getListByProjectId(String projectId) {
        LambdaQueryWrapper<CostProjectTaskDocumentData> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CostProjectTaskDocumentData::getProjectId, projectId);
        List<CostProjectTaskDocumentData> list = this.list(queryWrapper);
        if (ObjectUtil.isEmpty(list)) {
            throw new BaseException("没有找到文档关联数据");
        }
        return list.stream().collect(Collectors.groupingBy(CostProjectTaskDocumentData::getTaskId));
    }
}
