ソースを参照

2022-11-9 15:07 RMS报告管理系统提交 任务模块接口开发 增删改查

沈永艺 2 年 前
コミット
1cd3aaa972

+ 4 - 4
RMS/src/main/java/cn/cslg/report/controller/ReportController.java

@@ -59,12 +59,12 @@ public class ReportController {
     @Operation(summary = "修改报告")
     public String updateReport(@RequestBody Report report) {
         if (report != null) {
-            Boolean flag = reportService.updateById(report);
-            if(flag){
+            boolean flag = reportService.updateById(report);
+            if (flag) {
                 return Response.success("添加成功");
+            } else {
+                return Response.error("添加失败");
             }
-         else{ return Response.error("添加失败");}
-
         } else {
             return Response.error("未检测到报告信息");
         }

+ 51 - 0
RMS/src/main/java/cn/cslg/report/controller/TaskController.java

@@ -0,0 +1,51 @@
+package cn.cslg.report.controller;
+
+
+import cn.cslg.report.common.core.base.Constants;
+import cn.cslg.report.common.model.BaseVO;
+import cn.cslg.report.entity.Task;
+import cn.cslg.report.service.business.TaskService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(Constants.REPORT_API + "/task")
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class TaskController {
+
+    private final TaskService taskService;
+
+    @RequestMapping(value = "/addTask", method = RequestMethod.POST)
+    @Operation(summary = "新增任务")
+    public String addTask(Task task) {
+        return taskService.addTask(task);
+    }
+
+    @RequestMapping(value = "/deleteTask", method = RequestMethod.POST)
+    @Operation(summary = "删除任务")
+    public String deleteTask(Integer id) {
+        return taskService.deleteTask(id);
+    }
+
+    @RequestMapping(value = "/updateTask", method = RequestMethod.POST)
+    @Operation(summary = "修改任务")
+    public String updateTask(Task task) {
+        return taskService.updateTask(task);
+    }
+
+    @RequestMapping(value = "/queryPageList", method = RequestMethod.GET)
+    @Operation(summary = "分页查询任务列表")
+    public String queryPageList(Task task, BaseVO baseVO) {
+        return taskService.queryPageList(task, baseVO);
+    }
+
+    @RequestMapping(value = "/getAllTask", method = RequestMethod.GET)
+    @Operation(summary = "获取所有任务")
+    public String getAllTask() {
+        return taskService.getAllTask();
+    }
+}

+ 9 - 0
RMS/src/main/java/cn/cslg/report/mapper/TaskMapper.java

@@ -0,0 +1,9 @@
+package cn.cslg.report.mapper;
+
+import cn.cslg.report.entity.Task;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface TaskMapper extends BaseMapper<Task> {
+}

+ 81 - 94
RMS/src/main/java/cn/cslg/report/service/business/FeatureService.java

@@ -1,9 +1,7 @@
 package cn.cslg.report.service.business;
 
 import cn.cslg.report.common.model.vo.PatentRightVo;
-import cn.cslg.report.common.model.vo.PersonnelVO;
 import cn.cslg.report.common.utils.Response;
-import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.report.entity.Features;
 import cn.cslg.report.entity.PatentRight;
 import cn.cslg.report.mapper.FeatureMapper;
@@ -27,105 +25,94 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
 
-    private  final OutInterfaceService outInterfaceService;
+    private final OutInterfaceService outInterfaceService;
+
     //从PAS系统上获得权要并拆分
-public String splitPatentRight(String patentNo,Integer splitType ,Integer splitBy,Integer reportId) throws IOException {
-    //权要(带拆分的特征)列表
-    List<PatentRightVo> patentRightVos =new ArrayList<>();
-  String resBody=  outInterfaceService.getPatentRightFromPAS(patentNo);
-    JSONObject jsonObject = JSONObject.parseObject(resBody);
-    List<PatentRight> patentRights = JSON.parseArray(jsonObject.getString("data"),PatentRight.class);
-List<String> flags =new ArrayList<>();
-    List<PatentRight> mainRights =new ArrayList<>();
-    if(splitType==0)
-    { mainRights=patentRights.stream().filter(item->item.getType()==1).collect(Collectors.toList());
-        if(mainRights==null)
-        {
-            mainRights=new ArrayList<>();
+    public String splitPatentRight(String patentNo, Integer splitType, Integer splitBy, Integer reportId) throws IOException {
+        //权要(带拆分的特征)列表
+        List<PatentRightVo> patentRightVos = new ArrayList<>();
+        String resBody = outInterfaceService.getPatentRightFromPAS(patentNo);
+        JSONObject jsonObject = JSONObject.parseObject(resBody);
+        List<PatentRight> patentRights = JSON.parseArray(jsonObject.getString("data"), PatentRight.class);
+        List<String> flags = new ArrayList<>();
+        List<PatentRight> mainRights = new ArrayList<>();
+        if (splitType == 0) {
+            mainRights = patentRights.stream().filter(item -> item.getType() == 1).collect(Collectors.toList());
+            // TODO: 2022/11/9 这个地方的判断条件应该是 mainRights.size() == 0 吧 如果是为null的话 这个地方一直都是 false的
+            if (mainRights == null) {
+                mainRights = new ArrayList<>();
+            }
+        } else if (splitType == 1) {
+            mainRights = patentRights;
         }
-    }
-    else if(splitType==1)
-    {
-        mainRights=patentRights;
-    }
-    if(splitBy==0)
-    {   flags.add(",");
-
-    }
-    else if(splitBy==1)
-    {
-        flags.add(";");
-    }
-    else if(splitBy==2){
-
-        flags.add(",");
-        flags.add(";");
-    }
-    List<Features> featuresListToDb = new ArrayList<>();
-    for(int i=0;i<mainRights.size();i++) {
-        List<String> contentOuts = this.splitStringByFlags(mainRights.get(i).getContentOut(), flags);
-        List<String> contents  =this.splitStringByFlags(mainRights.get(i).getContent(),flags);
-        List<Features> featuresList = new ArrayList<>();
-        for (int t = 0; t < contentOuts.size(); t++)
-        { Features features =new Features();
-            features.setRight(mainRights.get(i).getContentOut());
-            features.setRightId(mainRights.get(i).getId());
-            features.setIsFinal(0);
-            features.setSignPatentNo(patentNo);
-            features.setReportId(reportId);
-            features.setContentOut(contentOuts.get(t));
-            String  content=  contents.size()-1>=t ? contents.get(t):"";
-            features.setContent(content);
-//            features.setPartnerId(LoginUtils.getToken());
-            featuresList.add(features);
-            featuresListToDb.add(features);
+        if (splitBy == 0) {
+            flags.add(",");
+        } else if (splitBy == 1) {
+            flags.add(";");
+        } else if (splitBy == 2) {
+            flags.add(",");
+            flags.add(";");
+        }
+        List<Features> featuresListToDb = new ArrayList<>();
+        for (PatentRight mainRight : mainRights) {
+            List<String> contentOuts = this.splitStringByFlags(mainRight.getContentOut(), flags);
+            List<String> contents = this.splitStringByFlags(mainRight.getContent(), flags);
+            List<Features> featuresList = new ArrayList<>();
+            for (int t = 0; t < contentOuts.size(); t++) {
+                Features features = new Features();
+                features.setRight(mainRight.getContentOut());
+                features.setRightId(mainRight.getId());
+                features.setIsFinal(0);
+                features.setSignPatentNo(patentNo);
+                features.setReportId(reportId);
+                features.setContentOut(contentOuts.get(t));
+                String content = contents.size() - 1 >= t ? contents.get(t) : "";
+                features.setContent(content);
+//              features.setPartnerId(LoginUtils.getToken());
+                featuresList.add(features);
+                // TODO: 2022/11/9 这段添加代码是做什么的? featuresListToDb 这个List在装填完数据后没有调用啊
+                featuresListToDb.add(features);
+            }
+            PatentRightVo patentRightVo = new PatentRightVo();
+            patentRightVo.setPatentId(mainRight.getPatentId());
+            patentRightVo.setFeatures(featuresList);
+            patentRightVo.setContent(mainRight.getContent());
+            patentRightVo.setSort(mainRight.getSort());
+            patentRightVo.setType(mainRight.getType());
+            patentRightVo.setContentOut(mainRight.getContentOut());
+            patentRightVos.add(patentRightVo);
+        }
+        if (splitType == 0) {
+            List<PatentRight> rights = patentRights.stream().filter(item -> item.getType() == 0).collect(Collectors.toList());
+            for (PatentRight right : rights) {
+                PatentRightVo patentRightVo = new PatentRightVo();
+                patentRightVo.setPatentId(right.getPatentId());
+                patentRightVo.setFeatures(null);
+                patentRightVo.setContent(right.getContent());
+                patentRightVo.setSort(right.getSort());
+                patentRightVo.setType(right.getType());
+                patentRightVo.setContentOut(right.getContentOut());
+                patentRightVos.add(patentRightVo);
+            }
         }
-     PatentRightVo patentRightVo =new PatentRightVo();
-        patentRightVo.setPatentId(mainRights.get(i).getPatentId());
-        patentRightVo.setFeatures(featuresList);
-        patentRightVo.setContent(mainRights.get(i).getContent());
-        patentRightVo.setSort(mainRights.get(i).getSort());
-        patentRightVo.setType(mainRights.get(i).getType());
-        patentRightVo.setContentOut(mainRights.get(i).getContentOut());
-        patentRightVos.add(patentRightVo);
-    }
-   if(splitType==0){
-       List<PatentRight> rights =patentRights.stream().filter(item->item.getType()==0).collect(Collectors.toList());
-       for(int i=0;i<rights.size();i++) {
-           PatentRightVo patentRightVo =new PatentRightVo();
-           patentRightVo.setPatentId(rights.get(i).getPatentId());
-           patentRightVo.setFeatures(null);
-           patentRightVo.setContent(rights.get(i).getContent());
-           patentRightVo.setSort(rights.get(i).getSort());
-           patentRightVo.setType(rights.get(i).getType());
-           patentRightVo.setContentOut(rights.get(i).getContentOut());
-           patentRightVos.add(patentRightVo);
-
-       }
-
-
-   }
-
-
-    return Response.success(patentRightVos);
 
-}
+        return Response.success(patentRightVos);
+    }
 
 
-public List<String> splitStringByFlags(String sentence,List<String> flags){
-List<String> sectences =new ArrayList<>();
-sectences.add(sentence);
-for(int i=0;i<flags.size();i++)
-{  List<String> tem =new ArrayList<>();
-  for(int t=0;t<sectences.size();t++)
-  {
-    tem.addAll(Arrays.asList(sentence.split(flags.get(i))));
-  }
-sectences=tem;
+    public List<String> splitStringByFlags(String sentence, List<String> flags) {
+        List<String> sentenceList = new ArrayList<>();
+        sentenceList.add(sentence);
+        for (String flag : flags) {
+            List<String> tem = new ArrayList<>();
+            for (int t = 0; t < sentenceList.size(); t++) {
+                tem.addAll(Arrays.asList(sentence.split(flag)));
+            }
+            sentenceList = tem;
 
-}
-return sectences;
+        }
 
-}
+        return sentenceList;
+    }
 
 }

+ 2 - 1
RMS/src/main/java/cn/cslg/report/service/business/ReportService.java

@@ -17,8 +17,8 @@ import java.util.Date;
 public class ReportService extends ServiceImpl<ReportMapper, Report> {
 
     /**
-     * @author 沈永艺
      * @param report 报告类
+     * @author 沈永艺
      */
     @Transactional(rollbackFor = Exception.class)
     public Integer addReport(Report report) {
@@ -41,4 +41,5 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
             System.out.println("报告新增结束");
         }
     }
+
 }

+ 54 - 0
RMS/src/main/java/cn/cslg/report/service/business/TaskService.java

@@ -0,0 +1,54 @@
+package cn.cslg.report.service.business;
+
+import cn.cslg.report.common.model.BaseVO;
+import cn.cslg.report.common.utils.DataUtils;
+import cn.cslg.report.common.utils.Response;
+import cn.cslg.report.entity.Task;
+import cn.cslg.report.mapper.TaskMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class TaskService extends ServiceImpl<TaskMapper, Task> {
+
+    public String addTask(Task task) {
+        this.save(task);
+        return Response.success();
+    }
+
+    public String deleteTask(Integer id) {
+        this.removeById(id);
+        return Response.success();
+    }
+
+    public String updateTask(Task task) {
+        this.updateById(task);
+        return Response.success();
+    }
+
+    public String queryPageList(Task task, BaseVO baseVO) {
+        LambdaQueryWrapper<Task> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        if (task.getType() != null) {
+            lambdaQueryWrapper.eq(Task::getType, task.getType());
+        }
+
+        List<Task> taskList;
+        if (baseVO.getCurrent() != null && baseVO.getSize() != null) {
+            taskList = this.page(new Page<>(baseVO.getCurrent(), baseVO.getSize()), lambdaQueryWrapper).getRecords();
+            return Response.success(taskList, DataUtils.setPageColumn(baseVO.getSize(), baseVO.getCurrent(), Math.toIntExact(this.count(lambdaQueryWrapper))));
+        } else {
+            taskList = this.list(lambdaQueryWrapper);
+            return Response.success(taskList);
+        }
+
+    }
+
+    public String getAllTask() {
+        List<Task> taskList = this.list();
+        return Response.success(taskList);
+    }
+}