PatentDigProjectController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package cn.cslg.pas.controller;
  2. import cn.cslg.pas.common.core.base.Constants;
  3. import cn.cslg.pas.common.dto.business.EventDTO;
  4. import cn.cslg.pas.common.dto.business.PatentDigProjectDTO;
  5. import cn.cslg.pas.common.dto.business.PatentDigProjectUpdateDTO;
  6. import cn.cslg.pas.common.dto.business.UpdateEventDTO;
  7. import cn.cslg.pas.common.model.cronModel.Records;
  8. import cn.cslg.pas.common.model.request.StringGroupRequest;
  9. import cn.cslg.pas.common.model.request.StringRequest;
  10. import cn.cslg.pas.common.utils.Response;
  11. import cn.cslg.pas.common.vo.RdProjectVO;
  12. import cn.cslg.pas.domain.business.RdProject;
  13. import cn.cslg.pas.exception.ConditionException;
  14. import cn.cslg.pas.exception.UnLoginException;
  15. import cn.cslg.pas.exception.XiaoShiException;
  16. import cn.cslg.pas.factorys.businessFactory.Business;
  17. import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
  18. import cn.cslg.pas.service.business.PatentDigProjectService;
  19. import com.alibaba.fastjson.JSONObject;
  20. import io.swagger.v3.oas.annotations.Operation;
  21. import lombok.extern.slf4j.Slf4j;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.web.bind.annotation.PostMapping;
  24. import org.springframework.web.bind.annotation.RequestBody;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import org.springframework.web.multipart.MultipartFile;
  28. import java.util.List;
  29. /**
  30. * @author 李仁杰
  31. * @date 2023/11/2
  32. */
  33. @Slf4j
  34. @RequestMapping(Constants.API_XiaoSHI + "/patentDigProject")
  35. @RestController
  36. public class PatentDigProjectController {
  37. @Autowired
  38. private BusinessFactory businessFactory;
  39. @Operation(summary = "查询专利挖掘项目")
  40. @PostMapping("/queryPatentDigProject")
  41. public Response queryPatentDigProject(@RequestBody StringRequest stringRequest) throws Exception {
  42. Business business = businessFactory.getClass("patentDigProjectService");
  43. Records records = (Records) business.queryMessage(stringRequest);
  44. return Response.success(records);
  45. }
  46. @Operation(summary = "添加专利挖掘项目")
  47. @PostMapping("/addPatentDigProject")
  48. public Response addPatentDigProject(@RequestBody PatentDigProjectDTO patentDigProjectDTO) throws Exception {
  49. if (patentDigProjectDTO != null) {
  50. Business business = businessFactory.getClass("patentDigProjectService");
  51. Integer id = null;
  52. try {
  53. id = (Integer) business.addMessage(patentDigProjectDTO);
  54. } catch (Exception e) {
  55. if (e instanceof XiaoShiException) {
  56. return Response.error(e.getMessage());
  57. } else if (e instanceof UnLoginException) {
  58. return Response.unLogin(e.getMessage());
  59. } else if (e instanceof ConditionException) {
  60. return Response.conditionError(e.getMessage());
  61. }
  62. }
  63. return Response.success(id);
  64. } else {
  65. return Response.error("参数错误");
  66. }
  67. }
  68. @Operation(summary = "更新专利挖掘项目")
  69. @PostMapping("/updatePatentDigProject")
  70. public Response updatePatentDigProject(@RequestBody PatentDigProjectUpdateDTO patentDigProjectUpdateDTO) throws Exception {
  71. if (patentDigProjectUpdateDTO != null) {
  72. Business business = businessFactory.getClass("patentDigProjectService");
  73. business.updateMessage(patentDigProjectUpdateDTO);
  74. return Response.success(1);
  75. }
  76. else {
  77. return Response.error("参数错误");
  78. }
  79. }
  80. @Operation(summary = "删除专利挖掘项目")
  81. @PostMapping("/deletePatentDigProject")
  82. public Response deletePatentDigProject(@RequestBody List<Integer> ids) throws Exception {
  83. Business business = businessFactory.getClass("patentDigProjectService");
  84. business.deleteMessage(ids);
  85. return Response.success(ids);
  86. }
  87. @Operation(summary = "分组专利挖掘项目")
  88. @PostMapping("/groupPatentDigProject")
  89. public Response groupPatentDigProject(@RequestBody StringGroupRequest stringGroupRequest) throws Exception {
  90. Business business = businessFactory.getClass("patentDigProjectService");
  91. Records records = (Records)business.getGroup(stringGroupRequest,"patentDigProject");
  92. return Response.success(records);
  93. }
  94. @Operation(summary = "查询研发项目")
  95. @PostMapping("/getRdProjectByNumber")
  96. public Response getRdProjectByNumber( @RequestBody StringRequest stringRequest) throws Exception {
  97. Business business = businessFactory.getClass("patentDigProjectService");
  98. PatentDigProjectService projectService =(PatentDigProjectService)business;
  99. Records records= projectService.getRdProjectByNumber(stringRequest);
  100. return Response.success(records);
  101. }
  102. }