package com.ruoyi.web.controller.file; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.FileType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.invest.domain.TProjectInformation; import com.ruoyi.invest.service.ITProjectCirculationService; import com.ruoyi.invest.service.ITProjectInformationService; import com.ruoyi.system.service.ISysDictDataService; import com.ruoyi.tool.service.ITUnifyFileService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.stream.Collectors; /** * 法务评估报告Controller * * @author ruoyi * @date 2024-02-26 */ @Api(tags = "研究资料管理-法务评估报告") @RestController @RequestMapping("/file/legalDueDiligence") public class LegalDueDiligenceController extends BaseController { @Autowired private ITProjectInformationService tProjectInformationService; @Autowired private ITProjectCirculationService tProjectCirculationService; @Autowired private ITUnifyFileService tUnifyFileService; @Autowired private ISysDictDataService dictDataService; /** * 查询立项申请报告列表 */ @ApiOperation("查询立项申请报告列表") @GetMapping("/list") public TableDataInfo list(TProjectInformation tProjectInformation) { startPage(); tProjectInformation.setFileType("p"); List list = tProjectInformationService.selectTProjectInformationList(tProjectInformation); return getDataTable(list); } /** * 导出立项申请报告列表 */ @ApiOperation("导出立项申请报告列表") @Log(title = "立项申请报告", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TProjectInformation tProjectInformation) { tProjectInformation.setFileType("p"); List list = tProjectInformationService.selectTProjectInformationList(tProjectInformation) .stream().map(n -> { n.setProjectPoolId(n.gettProjectPool().getProjectName()); n.setFileType(dictDataService.selectDictLabel("file_type",n.getFileType())); n.setProjectStage(dictDataService.selectDictLabel("project_stage",n.getProjectStage())); return n; }) .collect(Collectors.toList()); ExcelUtil util = new ExcelUtil(TProjectInformation.class); util.exportExcel(response, list, "立项申请报告数据"); } /** * 获取立项申请报告详细信息 */ @ApiOperation("获取立项申请报告详细信息") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") String id) { return success(tProjectInformationService.selectTProjectInformationById(id)); } /** * 新增立项申请报告 */ @ApiOperation("新增立项申请报告") @Log(title = "立项申请报告", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TProjectInformation tProjectInformation) { tProjectInformation.setId(IdUtils.fastSimpleUUID()); tProjectInformation.setCreateBy(getNickName()); // todo 保存附件信息 tUnifyFileService.insertTUnifyFileList(tProjectInformation.getListFile(), tProjectInformation.getProjectPoolId(), tProjectInformation.getId(),//立项申请报告ID String.valueOf(FileType.INFORMATION.ordinal()),//文件类型:立项申请报告 getNickName()); // todo 增加文件创建记录 tProjectCirculationService.insertTProjectCirculation(tProjectInformation.getProjectPoolId(),tProjectInformation.getFileName()+"(立项申请报告)",getNickName()); return toAjax(tProjectInformationService.insertTProjectInformation(tProjectInformation)); } /** * 修改立项申请报告 */ @ApiOperation("修改立项申请报告") @Log(title = "立项申请报告", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TProjectInformation tProjectInformation) { // todo 保存附件信息 tUnifyFileService.insertTUnifyFileList(tProjectInformation.getListFile(), tProjectInformation.getProjectPoolId(), tProjectInformation.getId(),//立项申请报告ID String.valueOf(FileType.INFORMATION.ordinal()),//文件类型:立项申请报告 getNickName()); return toAjax(tProjectInformationService.updateTProjectInformation(tProjectInformation)); } /** * 删除立项申请报告 */ @ApiOperation("删除立项申请报告") @Log(title = "立项申请报告", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable String[] ids) { //删除附件 tUnifyFileService.updateTUnifyFileBusinessIds(ids); return toAjax(tProjectInformationService.updateTProjectInformationByIds(ids)); } /** * 根据项目ID获取会议记录 */ @ApiOperation("根据项目ID获取会议记录") @GetMapping(value = "/listProjectPoolId") public AjaxResult listProjectPoolId(String projectPoolId) { return success(tProjectInformationService.listProjectPoolId(projectPoolId)); } }