package cn.cslg.pas.controller; import cn.cslg.pas.common.core.base.Constants; import cn.cslg.pas.common.dto.QueryPatentDigProjectFilesDTO; import cn.cslg.pas.common.dto.business.PatentDigProjectFilesDTO; import cn.cslg.pas.common.model.cronModel.Records; import cn.cslg.pas.common.model.request.StringRequest; import cn.cslg.pas.common.utils.Response; import cn.cslg.pas.common.vo.business.PatentDigProjectFilesVO; import cn.cslg.pas.exception.ConditionException; import cn.cslg.pas.exception.UnLoginException; import cn.cslg.pas.exception.XiaoShiException; import cn.cslg.pas.factorys.businessFactory.Business; import cn.cslg.pas.factorys.businessFactory.BusinessFactory; import cn.cslg.pas.service.business.PatentDigProjectFilesService; import io.swagger.v3.oas.annotations.Operation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.util.List; import java.util.Map; /** * 专利挖掘文件Controller层 * @Author xiexiang * @Date 2023/11/24 */ @Slf4j @RequestMapping(Constants.API_XiaoSHI + "/patentDigProjectFiles") @RestController public class PatentDigProjectFilesController { @Autowired private BusinessFactory businessFactory; @Autowired private PatentDigProjectFilesService patentDigProjectFilesService; @Operation(summary = "查询专利挖掘项目文件") @PostMapping("/queryPatentDigProjectFiles") public Response queryPatentDigProjectFiles(@RequestBody StringRequest stringRequest) throws Exception { Business business = businessFactory.getClass("patentDigProjectFilesService"); Records records = (Records) business.queryMessage(stringRequest); return Response.success(records); } @Operation(summary = "新增专利挖掘项目文件") @PostMapping("/addPatentDigProjectFiles") public Response addPatentDigProjectFiles(@RequestBody PatentDigProjectFilesDTO patentDigProjectFilesDTO){ Business business = businessFactory.getClass("patentDigProjectFilesService"); Integer id = null; try { id = (Integer) business.addMessage(patentDigProjectFilesDTO); } catch (Exception e) { if (e instanceof XiaoShiException) { return Response.error(e.getMessage()); } else if (e instanceof UnLoginException) { return Response.unLogin(e.getMessage()); } else if (e instanceof ConditionException) { return Response.conditionError(e.getMessage()); } } return Response.success(id); } @Operation(summary = "删除专利挖掘项目文件") @PostMapping("/deletePatentDigProjectFiles") public String deletePatentDigProjectFiles(@RequestBody List ids) throws IOException { Business business = businessFactory.getClass("patentDigProjectFilesService"); business.deleteMessage(ids); return Response.success(); } @Operation(summary = "上传文件后的提交审核") @PostMapping("/addPDProjectFilesTask") public Response addPDProjectFilesTask(@RequestBody PatentDigProjectFilesDTO patentDigProjectFilesDTO){ Integer taskId = patentDigProjectFilesService.addPDProjectFilesTask(patentDigProjectFilesDTO); return Response.success(taskId); } @Operation(summary = "查询所属流程的任务与文件数量") @GetMapping("/getCountOfProcess") public Response getCountOfProcess(Integer projectId){ Map> countMap = patentDigProjectFilesService.getProcessInfo(projectId); return Response.success(countMap); } @Operation(summary = "查询专利挖掘项目文件") @PostMapping("/query") public Response query(@RequestBody QueryPatentDigProjectFilesDTO queryPatentDigProjectFilesDTO) throws Exception { List patentDigProjectFilesVOS = patentDigProjectFilesService.getPatentDigProjectFiles(queryPatentDigProjectFilesDTO); Records records = new Records(); records.setData(patentDigProjectFilesVOS); return Response.success(records); } @Operation(summary = "删除专利挖掘项目文件") @GetMapping("/delete") public Response delete(Integer source, String fileGuid) throws Exception { patentDigProjectFilesService.delete(source, fileGuid); Records records = new Records(); records.setData("success"); return Response.success(records); } }