luohairen
2024-11-29 c77cab7ca85f219df136ec2aac24a22efa7837f8
business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -8,6 +8,7 @@
import com.ycl.common.utils.SecurityUtils;
import com.ycl.domain.entity.File;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.domain.form.DocumentInfoForm;
import com.ycl.domain.form.ProjectInfoForm;
import com.ycl.domain.query.ProjectInfoQuery;
import com.ycl.domain.vo.*;
@@ -22,10 +23,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -63,7 +61,7 @@
            item.setType(FileTypeEnum.PROJECT_INFO);
        });
        fileService.saveBatch(fileList);
        return Result.ok("添加成功");
        return Result.ok("添加成功").data(entity.getId());
    }
    /**
@@ -81,7 +79,8 @@
        ProjectInfoForm.getEntityByForm(form,entity);
        Long userId = SecurityUtils.getUserId();
        entity.setUpdateBy(userId);
        //更新项目信息
        baseMapper.updateById(entity);
        List<File> fileList = form.getFileList();
        fileList.forEach(item->{
            item.setBusId(entity.getId());
@@ -94,8 +93,6 @@
        fileMapper.delete(fileQueryWrapper);
        //替换成现有
        fileService.saveBatch(fileList);
        //更新项目信息
        baseMapper.updateById(entity);
        return Result.ok("修改成功");
    }
@@ -211,4 +208,47 @@
        map.put("processExceptionProject", 0);
        return map;
    }
    @Override
    public Result docDetail(Integer id) {
        DocumentInfoForm documentInfoForm = new DocumentInfoForm();
        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
        fileQueryWrapper.eq("type",FileTypeEnum.DOCUMENT_INFO.getType());
        fileQueryWrapper.eq("bus_id",id);
        List<File> files = fileMapper.selectList(fileQueryWrapper);
        documentInfoForm.setFileList(files);
        return Result.ok().data(documentInfoForm);
    }
    @Override
    public Result addDoc(DocumentInfoForm form) {
        List<File> fileList = form.getFileList();
        fileList.forEach(item->{
            item.setBusId(form.getProjectId());
            item.setType(FileTypeEnum.DOCUMENT_INFO);
        });
        //删除原有文件
        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
        fileQueryWrapper.eq("type",FileTypeEnum.DOCUMENT_INFO.getType());
        fileQueryWrapper.eq("bus_id",form.getProjectId());
        fileMapper.delete(fileQueryWrapper);
        //替换成现有
        fileService.saveBatch(fileList);
        return Result.ok();
    }
    @Override
    public Result getManagerFlag(Integer recordId) {
        ProjectInfo projectInfo = baseMapper.selectById(recordId);
        // 判断当前用户id是否在主管列表中
        String competentDepartment = projectInfo.getCompetentDepartment();
        List<String> list = Arrays.asList(competentDepartment.split(","));
        // 获得当前用户id
        Long userId = SecurityUtils.getUserId();
        if (list.contains(userId.toString())) {
            return Result.ok().data(true);
        } else {
            return Result.ok().data(false);
        }
    }
}