xiexiang 1 år sedan
förälder
incheckning
acc8de629e

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/business/OtherReferencesDTO.java

@@ -12,6 +12,8 @@ import java.util.List;
 public class OtherReferencesDTO {
     private Integer id;
 
+    private String patentNo;
+
     private Integer projectId;
 
     private String remark;

+ 48 - 0
src/main/java/cn/cslg/pas/common/vo/business/OtherReferencesVO.java

@@ -0,0 +1,48 @@
+package cn.cslg.pas.common.vo.business;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author xiexiang
+ * @Date 2024/1/17
+ */
+@Data
+public class OtherReferencesVO {
+    private Integer id;
+    /**
+     * 报告/专题库id
+     */
+    private Integer projectId;
+
+    private String patentNo;
+
+    /**
+     * 说明
+     */
+    private String remark;
+
+    /**
+     * 其他参考资料名称
+     */
+    private String referencesName;
+
+    private String referenceUrl;
+
+    /**
+     * 创建人id
+     */
+    private String createId;
+
+    private List<String> fileGuids;
+
+    private String createName;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+}

+ 54 - 0
src/main/java/cn/cslg/pas/controller/OtherReferencesController.java

@@ -0,0 +1,54 @@
+package cn.cslg.pas.controller;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.business.OtherReferencesDTO;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.vo.business.OtherReferencesVO;
+import cn.cslg.pas.service.business.OtherReferencesService;
+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.util.List;
+
+/**
+ * 其他参考资料
+ * @Author xiexiang
+ * @Date 2024/1/17
+ */
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/otherReferences")
+@RestController
+public class OtherReferencesController {
+    @Autowired
+    private OtherReferencesService otherReferencesService;
+
+    @Operation(summary = "添加or更新其他参考资料")
+    @PostMapping("/saveOrUpdate")
+    public Response saveOrUpdate(@RequestBody OtherReferencesDTO otherReferencesDTO){
+        Integer id = otherReferencesService.saveOrUpdate(otherReferencesDTO);
+        Records records = new Records();
+        records.setData(id);
+        return Response.success(records);
+    }
+
+    @Operation(summary = "查询其他参考资料")
+    @GetMapping("/query")
+    public Response queryOtherReferences(String patentNo) throws Exception {
+        List<OtherReferencesVO> otherReferencesVOS = otherReferencesService.getOtherReferences(patentNo);
+        Records records = new Records();
+        records.setData(otherReferencesVOS);
+        return Response.success(records);
+    }
+
+    @Operation(summary = "删除其他参考资料")
+    @PostMapping("/delete")
+    public Response delete(@RequestBody List<Integer> ids) throws Exception {
+        List<Integer> deleteIds = otherReferencesService.deleteOtherReferences(ids);
+        Records records = new Records();
+        records.setData(deleteIds);
+        return Response.success(records);
+    }
+}

+ 4 - 0
src/main/java/cn/cslg/pas/domain/business/OtherReferences.java

@@ -8,12 +8,16 @@ import lombok.Data;
 import java.util.Date;
 
 /**
+ * 其他参考资料
  * @Author xiexiang
  * @Date 2024/1/17
  */
 @Data
 @TableName("other_references")
 public class OtherReferences extends BaseEntity<OtherReferences> {
+    @TableField(value = "patent_no")
+    private String patentNo;
+
     /**
      * 报告/专题库id
      */

+ 73 - 0
src/main/java/cn/cslg/pas/service/business/OtherReferencesService.java

@@ -1,15 +1,20 @@
 package cn.cslg.pas.service.business;
 
 import cn.cslg.pas.common.dto.business.OtherReferencesDTO;
+import cn.cslg.pas.common.model.cronModel.Personnel;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
+import cn.cslg.pas.common.utils.StringUtils;
+import cn.cslg.pas.common.vo.business.LitigationHistoryVO;
+import cn.cslg.pas.common.vo.business.OtherReferencesVO;
 import cn.cslg.pas.domain.business.AssoOtherReferencesFile;
 import cn.cslg.pas.domain.business.LitigationHistory;
 import cn.cslg.pas.domain.business.OtherReferences;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.OtherReferencesMapper;
 import cn.cslg.pas.service.permissions.PermissionService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
@@ -17,8 +22,10 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 其他参考资料
@@ -96,4 +103,70 @@ public class OtherReferencesService extends ServiceImpl<OtherReferencesMapper, O
         }
         return ids;
     }
+
+    /**
+     * 查询
+     * @param patentNo
+     * @return
+     * @throws IOException
+     */
+    public List<OtherReferencesVO> getOtherReferences(String patentNo) throws IOException {
+        if (patentNo == null || StringUtils.isEmpty(patentNo)) {
+            throw new XiaoShiException("入参为空");
+        }
+        List<OtherReferencesVO> otherReferencesVOS = new ArrayList<>();
+        LambdaQueryWrapper<OtherReferences> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(OtherReferences::getPatentNo, patentNo);
+        List<OtherReferences> otherReferencesList = this.list(queryWrapper);
+
+        if (!otherReferencesList.isEmpty()) {
+            otherReferencesList.forEach(item -> {
+                OtherReferencesVO otherReferencesVO = new OtherReferencesVO();
+                BeanUtils.copyProperties(item, otherReferencesVO);
+                otherReferencesVOS.add(otherReferencesVO);
+            });
+            this.loadOtherReferencesVOS(otherReferencesVOS);
+        }
+        return otherReferencesVOS;
+    }
+
+    public void loadOtherReferencesVOS(List<OtherReferencesVO> otherReferencesVOS) throws IOException {
+        List<String> createIds = new ArrayList<>();
+        otherReferencesVOS.forEach(item -> {
+            if (item.getCreateId() != null) {
+                createIds.add(item.getCreateId());
+            }
+        });
+        List<Personnel> personnels = new ArrayList<>();
+        //查询发起人名称
+        if (createIds.size() != 0) {
+            String res = permissionService.getPersonnelByIdsFromPCS(createIds);
+            JSONObject jsonObject = JSONObject.parseObject(res);
+            personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
+        }
+        //装载信息
+        for (OtherReferencesVO otherReferencesVO : otherReferencesVOS) {
+            //装载人员信息
+            Personnel personnel = personnels.stream().filter(item -> item.getId().equals(otherReferencesVO.getCreateId())).findFirst().orElse(null);
+            if (personnel != null) {
+                otherReferencesVO.setCreateName(personnel.getPersonnelName());
+            }
+            LambdaQueryWrapper<AssoOtherReferencesFile> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(AssoOtherReferencesFile::getOtherReferencesId, otherReferencesVO.getId());
+            List<AssoOtherReferencesFile> assoOtherReferencesFiles = assoReferencesFileService.list(queryWrapper);
+            if (!assoOtherReferencesFiles.isEmpty()) {
+                List<String> fileGuids = assoOtherReferencesFiles.stream().map(AssoOtherReferencesFile::getFileGuid).collect(Collectors.toList());
+                otherReferencesVO.setFileGuids(fileGuids);
+            }
+        }
+
+    }
+
+    public List<Integer> deleteOtherReferences(List<Integer> ids) {
+        if (!ids.isEmpty()) {
+            this.removeBatchByIds(ids);
+        }
+        return ids;
+    }
+
 }