PatentDigProjectFilesController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package cn.cslg.pas.controller;
  2. import cn.cslg.pas.common.core.base.Constants;
  3. import cn.cslg.pas.common.dto.QueryPatentDigProjectFilesDTO;
  4. import cn.cslg.pas.common.dto.business.PatentDigProjectFilesDTO;
  5. import cn.cslg.pas.common.model.cronModel.Records;
  6. import cn.cslg.pas.common.model.request.StringRequest;
  7. import cn.cslg.pas.common.utils.Response;
  8. import cn.cslg.pas.common.vo.business.PatentDigProjectFilesVO;
  9. import cn.cslg.pas.exception.ConditionException;
  10. import cn.cslg.pas.exception.UnLoginException;
  11. import cn.cslg.pas.exception.XiaoShiException;
  12. import cn.cslg.pas.factorys.businessFactory.Business;
  13. import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
  14. import cn.cslg.pas.service.business.PatentDigProjectFilesService;
  15. import io.swagger.v3.oas.annotations.Operation;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.web.bind.annotation.*;
  19. import java.io.IOException;
  20. import java.util.List;
  21. import java.util.Map;
  22. /**
  23. * 专利挖掘文件Controller层
  24. * @Author xiexiang
  25. * @Date 2023/11/24
  26. */
  27. @Slf4j
  28. @RequestMapping(Constants.API_XiaoSHI + "/patentDigProjectFiles")
  29. @RestController
  30. public class PatentDigProjectFilesController {
  31. @Autowired
  32. private BusinessFactory businessFactory;
  33. @Autowired
  34. private PatentDigProjectFilesService patentDigProjectFilesService;
  35. @Operation(summary = "查询专利挖掘项目文件")
  36. @PostMapping("/queryPatentDigProjectFiles")
  37. public Response queryPatentDigProjectFiles(@RequestBody StringRequest stringRequest) throws Exception {
  38. Business business = businessFactory.getClass("patentDigProjectFilesService");
  39. Records records = (Records) business.queryMessage(stringRequest);
  40. return Response.success(records);
  41. }
  42. @Operation(summary = "新增专利挖掘项目文件")
  43. @PostMapping("/addPatentDigProjectFiles")
  44. public Response addPatentDigProjectFiles(@RequestBody PatentDigProjectFilesDTO patentDigProjectFilesDTO){
  45. Business business = businessFactory.getClass("patentDigProjectFilesService");
  46. Integer id = null;
  47. try {
  48. id = (Integer) business.addMessage(patentDigProjectFilesDTO);
  49. } catch (Exception e) {
  50. if (e instanceof XiaoShiException) {
  51. return Response.error(e.getMessage());
  52. } else if (e instanceof UnLoginException) {
  53. return Response.unLogin(e.getMessage());
  54. } else if (e instanceof ConditionException) {
  55. return Response.conditionError(e.getMessage());
  56. }
  57. }
  58. return Response.success(id);
  59. }
  60. @Operation(summary = "删除专利挖掘项目文件")
  61. @PostMapping("/deletePatentDigProjectFiles")
  62. public String deletePatentDigProjectFiles(@RequestBody List<Integer> ids) throws IOException {
  63. Business business = businessFactory.getClass("patentDigProjectFilesService");
  64. business.deleteMessage(ids);
  65. return Response.success();
  66. }
  67. @Operation(summary = "上传文件后的提交审核")
  68. @PostMapping("/addPDProjectFilesTask")
  69. public Response addPDProjectFilesTask(@RequestBody PatentDigProjectFilesDTO patentDigProjectFilesDTO){
  70. Integer taskId = patentDigProjectFilesService.addPDProjectFilesTask(patentDigProjectFilesDTO);
  71. return Response.success(taskId);
  72. }
  73. @Operation(summary = "查询所属流程的任务与文件数量")
  74. @GetMapping("/getCountOfProcess")
  75. public Response getCountOfProcess(Integer projectId){
  76. Map<Integer, Map<String, Integer>> countMap = patentDigProjectFilesService.getProcessInfo(projectId);
  77. return Response.success(countMap);
  78. }
  79. @Operation(summary = "查询专利挖掘项目文件")
  80. @PostMapping("/query")
  81. public Response query(@RequestBody QueryPatentDigProjectFilesDTO queryPatentDigProjectFilesDTO) throws Exception {
  82. List<PatentDigProjectFilesVO> patentDigProjectFilesVOS = patentDigProjectFilesService.getPatentDigProjectFiles(queryPatentDigProjectFilesDTO);
  83. Records records = new Records();
  84. records.setData(patentDigProjectFilesVOS);
  85. return Response.success(records);
  86. }
  87. @Operation(summary = "删除专利挖掘项目文件")
  88. @GetMapping("/delete")
  89. public Response delete(Integer source, String fileGuid) throws Exception {
  90. patentDigProjectFilesService.delete(source, fileGuid);
  91. Records records = new Records();
  92. records.setData("success");
  93. return Response.success(records);
  94. }
  95. }