Prechádzať zdrojové kódy

根据code码获得任务信息

lwhhszx 1 rok pred
rodič
commit
596d783402

+ 6 - 1
src/main/java/cn/cslg/pas/common/dto/ComparedPatentVO.java

@@ -2,6 +2,7 @@ package cn.cslg.pas.common.dto;
 
 import cn.cslg.pas.domain.es.PatentPerson;
 import cn.cslg.pas.domain.es.Priorities;
+import cn.cslg.pas.domain.es.Text;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
@@ -36,6 +37,10 @@ public class ComparedPatentVO {
     private String simpleStatus;
     private String simpleStatusStr;
     private List<String> InpadocFamilyNos;
-
+    /**
+     * 标题
+     */
+    @JsonProperty("title")
+    private List<Text> title;
 
 }

+ 3 - 1
src/main/java/cn/cslg/pas/common/dto/FollowUpUpdateDTO.java

@@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -47,5 +48,6 @@ public class FollowUpUpdateDTO {
 
     private String   description;
     private Integer projectId;
-
+    private List<String> fileGuids;
+    private String conclusion;
 }

+ 1 - 0
src/main/java/cn/cslg/pas/common/vo/FieldValueVO.java

@@ -7,4 +7,5 @@ public class FieldValueVO {
     private Integer valueId;
     private String  value;
     private String path;
+    private Integer num;
 }

+ 17 - 2
src/main/java/cn/cslg/pas/common/vo/business/FollowUpVO.java

@@ -1,12 +1,15 @@
 package cn.cslg.pas.common.vo.business;
 
+import cn.cslg.pas.common.model.cronModel.SystemFile;
 import cn.cslg.pas.domain.BaseEntity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -19,8 +22,8 @@ import java.util.Date;
 @Data
 /*数据库中的表对应的类
  */
-public class FollowUpVO  {
-   private Integer id;
+public class FollowUpVO {
+    private Integer id;
     private Integer projectId;
     /**
      * 名称
@@ -54,6 +57,10 @@ public class FollowUpVO  {
     /**
      * 创建时间
      */
+    @JsonFormat(
+            pattern = "yyyy-MM-dd",
+            timezone = "GMT+8"
+    )
     private Date createTime;
 
     private String statusStr;
@@ -63,4 +70,12 @@ public class FollowUpVO  {
      */
 
     private String description;
+
+    private List<SystemFile> systemFileList;
+    private String conclusion;
+    @JsonFormat(
+            pattern = "yyyy-MM-dd",
+            timezone = "GMT+8"
+    )
+    private Date finishTime;
 }

+ 11 - 0
src/main/java/cn/cslg/pas/controller/FollowUpController.java

@@ -3,6 +3,7 @@ package cn.cslg.pas.controller;
 import cn.cslg.pas.common.core.base.Constants;
 import cn.cslg.pas.common.dto.FollowUpQueryDTO;
 import cn.cslg.pas.common.dto.FollowUpUpdateDTO;
+import cn.cslg.pas.common.dto.RegisterDTO;
 import cn.cslg.pas.common.dto.business.EventDTO;
 import cn.cslg.pas.common.dto.business.FollowUpDTO;
 import cn.cslg.pas.common.dto.business.UpdateEventDTO;
@@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.text.ParseException;
 import java.util.List;
 
 /**
@@ -80,5 +82,14 @@ public class FollowUpController {
         return Response.error("请求参数为null");
     }
 
+    @Operation(summary = "登记结果")
+    @PostMapping("/register")
+    public Response register(@RequestBody RegisterDTO register) throws ParseException {
+        if (register != null) {
+         Integer id =   followUpService.register(register);
+            return Response.success(id);
+        }
+        return Response.error("参数不可为空");
+    }
 
 }

+ 56 - 0
src/main/java/cn/cslg/pas/controller/outApi/OutSidersController.java

@@ -0,0 +1,56 @@
+package cn.cslg.pas.controller.outApi;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.domain.business.ProjectTask;
+import cn.cslg.pas.domain.business.ReportProject;
+import cn.cslg.pas.domain.business.TaskCode;
+import cn.cslg.pas.service.business.ProjectTaskService;
+import cn.cslg.pas.service.business.ReportProjectService;
+import cn.cslg.pas.service.business.TaskCodeService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+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;
+
+import java.io.IOException;
+
+import java.util.List;
+
+
+
+@SuppressWarnings({"all"})
+@Tag(name = "外部人员调用接口")
+@RestController
+@RequestMapping(Constants.API_XiaoSHI + "/outSiders")
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+
+public class OutSidersController {
+    private final TaskCodeService taskCodeService;
+    private final ProjectTaskService projectTaskService;
+    private final ReportProjectService reportService;
+    @RequestMapping(value = "/getTaskByCode", method = RequestMethod.GET)
+    @Operation(summary = "根据code码获得任务信息")
+    public Response getTaskByCode(String code) throws IOException {
+        //根据code码获得taskId
+        LambdaQueryWrapper<TaskCode> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(TaskCode::getCodeNum, code);
+        List<TaskCode> taskCodes = taskCodeService.list(queryWrapper);
+        if (taskCodes.size() != 0) {
+            TaskCode syneryCode = taskCodes.get(0);
+            //根据taskId获得task信息
+            ProjectTask task = projectTaskService.getById(syneryCode.getTaskId());
+            LambdaQueryWrapper<ReportProject> queryWrapper1 =new LambdaQueryWrapper<>();
+            queryWrapper1.eq(ReportProject::getProjectId,task.getProjectId());
+            ReportProject report =reportService.getOne(queryWrapper1);
+            task.setReportType(report.getReportType());
+            return Response.success(task);
+        }
+        return Response.error("code码输入错误");
+    }
+
+}

+ 26 - 0
src/main/java/cn/cslg/pas/domain/business/AssoFollowUpFile.java

@@ -0,0 +1,26 @@
+package cn.cslg.pas.domain.business;
+
+import cn.cslg.pas.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.joda.time.DateTime;
+
+/**
+ * <p>
+ * 事件表
+ * </p>
+ *
+ * @author 李仁杰
+ * @since 2022-10-20
+ */
+@Data
+@TableName("asso_follow_up_file")
+/*数据库中的表对应的类
+ */
+public class AssoFollowUpFile extends BaseEntity<AssoFollowUpFile> {
+    @TableField(value = "file_guid")
+    private String fileGuid;
+    @TableField(value = "follow_up_id")
+    private Integer followUpId;
+}

+ 1 - 1
src/main/java/cn/cslg/pas/domain/business/FollowUp.java

@@ -67,7 +67,7 @@ public class FollowUp extends BaseEntity<FollowUp> {
     @TableField(value = "description")
     private String description;
 
-    @TableField(value = "description")
+    @TableField(value = "conclusion")
     private String conclusion;
 
     @TableField(value = "finish_time")

+ 3 - 0
src/main/java/cn/cslg/pas/domain/business/ProjectTask.java

@@ -116,4 +116,7 @@ public class ProjectTask extends BaseEntity<ProjectTask> {
      */
     @TableField(value = "create_time")
     private Date createTime;
+
+    @TableField(exist = false)
+    private Integer reportType;
 }

+ 16 - 0
src/main/java/cn/cslg/pas/mapper/AssoFollowUpFileMapper.java

@@ -0,0 +1,16 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.domain.business.AssoEventFile;
+import cn.cslg.pas.domain.business.AssoFollowUpFile;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ *
+ *
+ * @author
+ * @date 2023/10/20
+ */
+@Repository
+public interface AssoFollowUpFileMapper extends BaseMapper<AssoFollowUpFile> {
+}

+ 26 - 40
src/main/java/cn/cslg/pas/service/ReportExportService.java

@@ -1,6 +1,7 @@
 package cn.cslg.pas.service;
 
 import cn.cslg.pas.common.dto.PatentDetailDTO;
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
 import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
 import cn.cslg.pas.common.model.SystemMO;
 import cn.cslg.pas.common.utils.DateUtils;
@@ -22,6 +23,7 @@ import cn.cslg.pas.service.business.ReportProjectService;
 import cn.cslg.pas.service.business.TemplateConfigService;
 import cn.cslg.pas.service.business.TempleService;
 import cn.cslg.pas.service.business.es.EsPatentService;
+import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.hutool.core.util.IdUtil;
 import com.alibaba.fastjson.JSON;
@@ -66,7 +68,8 @@ public class ReportExportService {
     private TemplateConfigService templateConfigService;
     @Autowired
     private CustomFieldService customFieldService;
-    ;
+    @Autowired
+    private EsService esService;
 
     /**
      * @param projectId
@@ -351,37 +354,33 @@ public class ReportExportService {
 
 
     /**
-     * @param reportId
+     * @param projectId
      * @param filePath
      * @return
      * @description 装载FTO模板
      */
-    private XWPFTemplate FTOTemplate(Integer reportId, String filePath, Integer templateId) throws IOException {
+    private XWPFTemplate FTOTemplate(Integer projectId, String filePath, Integer templateId) throws IOException {
         //根据报告ID获得自定义字段值的信息
-//        List<Map<String, Object>> fieldMaps = reportFieldService.getFieldsMap(reportId);
-//        //获得模板的配置信息
-//        LambdaQueryWrapper<TemplateConfig> templateConfigWrapper = new LambdaQueryWrapper<TemplateConfig>();
-//        templateConfigWrapper.eq(TemplateConfig::getTemplateId, templateId);
-//        List<TemplateConfig> templateConfigs = templateConfigService.list(templateConfigWrapper);
-//        List<Map<String, Object>> loadMaps = new ArrayList<>();
-//
-//
-//        //根据配置信息装载
-//        for (TemplateConfig item : templateConfigs) {
-//            for (Map<String, Object> map : fieldMaps) {
-//                //如果自定义字段的值映射到配置则装载
-//                if (map.get("CName").toString().equals(item.getValueName())) {
-//                    //装载
-//                    map.put("CName", item.getMapName());
-//                    map.put("order", item.getOrderNum());
-//                    loadMaps.add(map);
-//                }
-//            }
-//        }
-//        //
-//        List<Map<String, Object>> classifyMaps = new ArrayList<>();
-//        //装载信息
-//        for (Map<String, Object> map : loadMaps) {
+
+        //获得模板的配置信息
+        LambdaQueryWrapper<TemplateConfig> templateConfigWrapper = new LambdaQueryWrapper<TemplateConfig>();
+        templateConfigWrapper.eq(TemplateConfig::getTemplateId, templateId);
+        List<TemplateConfig> templateConfigs = templateConfigService.list(templateConfigWrapper);
+
+        for (TemplateConfig templateConfig : templateConfigs) {
+            String value = templateConfig.getValueName();
+            //根据value 查询专利
+            List<EsCustomFieldDTO> esCustomFieldDTOS = customFieldService.getCustomFieldByValueName(value,projectId);
+            if(esCustomFieldDTOS.size()!=0){
+
+
+            }
+        }
+
+        //
+        List<Map<String, Object>> classifyMaps = new ArrayList<>();
+        //装载信息
+//        for (TemplateConfig templateConfig : templateConfigs) {
 //            Map<String, Object> classifyMap = new HashMap<>();
 //            classifyMap.put("classify", map.get("CName"));
 //            //根据自定义字段ID和值Id查询专利号
@@ -482,18 +481,5 @@ public class ReportExportService {
         return null;
     }
 
-    /**
-     * 根据名称获得标引栏位以及标引值
-     * @param name
-     * @param projectId
-     */
-    public void re(String name, Integer projectId) {
-        //根据名称获得标引栏位以及标引值
-        LambdaQueryWrapper<CustomField> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.in(CustomField::getType,Arrays.asList(4,5,6))
-                .eq(CustomField::getProjectId,projectId);
-        List<CustomField> customFields =customFieldService.list(queryWrapper);
 
-
-    }
 }

+ 33 - 0
src/main/java/cn/cslg/pas/service/business/AssoFollowUpFileService.java

@@ -0,0 +1,33 @@
+package cn.cslg.pas.service.business;
+
+
+import cn.cslg.pas.domain.business.AssoEventFile;
+import cn.cslg.pas.domain.business.AssoFollowUpFile;
+import cn.cslg.pas.mapper.AssoEventFileMapper;
+import cn.cslg.pas.mapper.AssoFollowUpFileMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+@Service
+public class AssoFollowUpFileService extends ServiceImpl<AssoFollowUpFileMapper, AssoFollowUpFile> {
+
+  public void addBatch(Integer followUpId, List<String> fileGuids){
+      if(fileGuids==null||followUpId==null||fileGuids.size()==0){
+          return;
+      }
+      List<AssoFollowUpFile> assoFollowUpFiles =new ArrayList<>();
+      for(String guid:fileGuids){
+          AssoFollowUpFile assoFollowUpFile =new AssoFollowUpFile();
+          assoFollowUpFile.setFollowUpId(followUpId);
+          assoFollowUpFile.setFileGuid(guid);
+          assoFollowUpFiles.add(assoFollowUpFile);
+      }
+      this.saveBatch(assoFollowUpFiles);
+  }
+
+}

+ 76 - 11
src/main/java/cn/cslg/pas/service/business/CustomFieldService.java

@@ -39,6 +39,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -297,14 +298,13 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
     }
 
     /**
-     *
      * @param taskId
      * @return
      */
     public List<AllCustomFieldVO> getAllTaskCustomField(Integer taskId) {
         Integer order = 0;
         List<AllCustomFieldVO> allCustomFieldVOS = cacheUtils.getTaskCustomField(taskId);
-        if(allCustomFieldVOS==null||allCustomFieldVOS.size()==0) {
+        if (allCustomFieldVOS == null || allCustomFieldVOS.size() == 0) {
             allCustomFieldVOS = new ArrayList<>();
 
             //根据任务id查询
@@ -384,16 +384,17 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
             }
             cacheUtils.addTaskCustomField(taskId, allCustomFieldVOS);
         }
-    allCustomFieldVOS =    allCustomFieldVOS.stream().sorted(Comparator.comparing(AllCustomFieldVO::getSysOrder)).collect(Collectors.toList());
+        allCustomFieldVOS = allCustomFieldVOS.stream().sorted(Comparator.comparing(AllCustomFieldVO::getSysOrder)).collect(Collectors.toList());
         return allCustomFieldVOS;
     }
 
 
     public Records getCustomFieldValues(QueryEsCustomFieldDTO queryEsCustomFieldDTO) throws Exception {
+
         List<FieldValueVO> fieldValueVOS = new ArrayList<>();
         Integer type = queryEsCustomFieldDTO.getFieldType();
 
-        EsCustomFieldDTO esCustomFieldDTO =new EsCustomFieldDTO();
+        EsCustomFieldDTO esCustomFieldDTO = new EsCustomFieldDTO();
         esCustomFieldDTO.setFieldId(queryEsCustomFieldDTO.getFieldId());
         esCustomFieldDTO.setProjectId((queryEsCustomFieldDTO.getProjectId()));
         esCustomFieldDTO.setTaskId(queryEsCustomFieldDTO.getTaskId());
@@ -401,7 +402,7 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
         esCustomFieldDTO.setFieldType(queryEsCustomFieldDTO.getFieldType());
 
         PatentWithIdVO patentVO = esCustomFieldService.getEsCustomField(esCustomFieldDTO);
-        if (patentVO != null){
+        if (patentVO != null) {
             List<String> value = patentVO.getPatent().getESCustomField().getFieldValue();
             switch (type) {
                 case 0:
@@ -420,7 +421,7 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
                 case 4:
 
                 case 5:
-                    if (value!=null&&value.size() > 0) {
+                    if (value != null && value.size() > 0) {
                         List<Integer> ids = FormatUtil.StringTOIntegerList(value);
                         LambdaQueryWrapper<CustomOption> queryWrapper = new LambdaQueryWrapper<>();
                         queryWrapper.in(CustomOption::getId, ids);
@@ -438,7 +439,7 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
                 case 8:
 
                 case 9:
-                    if (value!=null&&value.size() > 0) {
+                    if (value != null && value.size() > 0) {
                         List<Integer> ids = FormatUtil.StringTOIntegerList(value);
                         LambdaQueryWrapper<TreeNode> queryWrapper = new LambdaQueryWrapper<>();
                         queryWrapper.in(TreeNode::getId, ids);
@@ -464,10 +465,9 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
     public Records addAllPatentCustomFieldOrder(AllFieldOrderDTO allFieldOrderDTO) {
         Integer projectId = allFieldOrderDTO.getProjectId();
         List<AllCustomFieldVO> allCustomFieldVOS = allFieldOrderDTO.getAllCustomFieldVOs();
-        if(allFieldOrderDTO.getTaskId()!=null){
-            cacheUtils.addTaskCustomField(allFieldOrderDTO.getTaskId(),allCustomFieldVOS);
-        }
-        else {
+        if (allFieldOrderDTO.getTaskId() != null) {
+            cacheUtils.addTaskCustomField(allFieldOrderDTO.getTaskId(), allCustomFieldVOS);
+        } else {
             cacheUtils.addPatentCustomField(projectId, allCustomFieldVOS);
         }
         Records records = new Records();
@@ -475,4 +475,69 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
         return records;
     }
 
+
+    /**
+     * 根据名称获得标引栏位以及标引值
+     *
+     * @param name
+     * @param projectId
+     */
+    public List<EsCustomFieldDTO> getCustomFieldByValueName(String name, Integer projectId) {
+        List<EsCustomFieldDTO> esCustomFieldDTOS = new ArrayList<>();
+        //根据名称获得标引栏位以及标引值
+        LambdaQueryWrapper<CustomField> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(CustomField::getType, Arrays.asList(4, 5, 6))
+                .eq(CustomField::getProjectId, projectId);
+        List<CustomField> customFields = this.list(queryWrapper);
+        List<Integer> ids = customFields.stream().map(CustomField::getId).collect(Collectors.toList());
+        if (ids.size() == 0) {
+            return esCustomFieldDTOS;
+        }
+        //从option 查询名称相同的选项
+        LambdaQueryWrapper<CustomOption> optionWrapper = new LambdaQueryWrapper<>();
+        optionWrapper.eq(CustomOption::getName, name)
+                .in(CustomOption::getCustomFieldId, ids);
+        List<CustomOption> options = customOptionService.list(optionWrapper);
+        // 从 treeNode 查询名称相同的节点
+        LambdaQueryWrapper<TreeNode> treeNodeWrapper = new LambdaQueryWrapper<>();
+        treeNodeWrapper.eq(TreeNode::getName, name)
+                .eq(TreeNode::getType, 4)
+                .in(TreeNode::getTypeId,ids);
+        List<TreeNode> treeNodes = treeNodeService.list(treeNodeWrapper);
+
+        if (options != null && options.size() != 0) {
+            options.forEach(item -> {
+                EsCustomFieldDTO esCustomFieldDTO = esCustomFieldDTOS.stream()
+                        .filter(i -> i.getFieldId()
+                                .equals(item.getCustomFieldId()))
+                        .findFirst().orElse(null);
+                if (esCustomFieldDTO == null) {
+                    esCustomFieldDTO.setFieldId(item.getCustomFieldId().toString());
+                    List<String> values = new ArrayList<>();
+                    values.add(item.getId().toString());
+                    esCustomFieldDTO.setFieldValue(values);
+                } else {
+                    esCustomFieldDTO.getFieldValue().add(item.getId().toString());
+                }
+            });
+        }
+
+        if (treeNodes != null && treeNodes.size() != 0) {
+            treeNodes.forEach(item -> {
+                EsCustomFieldDTO esCustomFieldDTO = esCustomFieldDTOS.stream()
+                        .filter(i -> i.getFieldId()
+                                .equals(item.getTypeId()))
+                        .findFirst().orElse(null);
+                if (esCustomFieldDTO == null) {
+                    esCustomFieldDTO.setFieldId(item.getTypeId().toString());
+                    List<String> values = new ArrayList<>();
+                    values.add(item.getId().toString());
+                    esCustomFieldDTO.setFieldValue(values);
+                } else {
+                    esCustomFieldDTO.getFieldValue().add(item.getId().toString());
+                }
+            });
+        }
+        return esCustomFieldDTOS;
+    }
 }

+ 1 - 1
src/main/java/cn/cslg/pas/service/business/FTOCompareRecordService.java

@@ -870,7 +870,7 @@ public class FTOCompareRecordService extends ServiceImpl<FTOCompareRecordMapper,
 
 
                     SystemDict systemDict = systemDicts.stream().filter(i -> i.getValue().equals(item.getSimpleStatus())).findFirst().orElse(null);
-                    if(systemDict!=null){
+                    if (systemDict != null) {
                         comparedPatentVO.setSimpleStatusStr(systemDict.getLabel());
                     }
                     comparedPatentVOS.add(comparedPatentVO);

+ 70 - 16
src/main/java/cn/cslg/pas/service/business/FollowUpService.java

@@ -7,18 +7,22 @@ import cn.cslg.pas.common.dto.business.FollowUpDTO;
 import cn.cslg.pas.common.model.cronModel.Personnel;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
 import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.model.cronModel.SystemFile;
 import cn.cslg.pas.common.model.request.GroupRequest;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.common.vo.business.FollowUpVO;
 import cn.cslg.pas.common.vo.business.ReportProjectVO;
+import cn.cslg.pas.domain.business.AssoEventFile;
+import cn.cslg.pas.domain.business.AssoFollowUpFile;
 import cn.cslg.pas.domain.business.FollowUp;
 import cn.cslg.pas.domain.business.RdProject;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.mapper.FollowUpMapper;
 import cn.cslg.pas.mapper.RdProjectMapper;
+import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.fastjson.JSONObject;
@@ -51,6 +55,10 @@ public class FollowUpService extends ServiceImpl<FollowUpMapper, FollowUp> {
     private CacheUtils cacheUtils;
     @Autowired
     private LoginUtils loginUtils;
+    @Autowired
+    private AssoFollowUpFileService assoFollowUpFileService;
+    @Autowired
+    private FileManagerService fileManagerService;
 
     /**
      * 新增后续事项
@@ -95,7 +103,15 @@ public class FollowUpService extends ServiceImpl<FollowUpMapper, FollowUp> {
                 BeanUtils.copyProperties(followUpUpdateDTO, followUp);
                 //根据id修改后续事项表数据
                 followUp.updateById();
+
+                LambdaQueryWrapper<AssoFollowUpFile> removeWrapper = new LambdaQueryWrapper<>();
+                removeWrapper.eq(AssoFollowUpFile::getFollowUpId, followUp.getId());
+                assoFollowUpFileService.remove(removeWrapper);
+                //新增文件
+                assoFollowUpFileService.addBatch(followUp.getId(), followUpUpdateDTO.getFileGuids());
             }
+
+
         }
     }
 
@@ -143,8 +159,11 @@ public class FollowUpService extends ServiceImpl<FollowUpMapper, FollowUp> {
     private List<FollowUpVO> loadFollowUps(List<FollowUp> followUps) {
         List<FollowUpVO> followUpVOS = new ArrayList<>();
         List<String> createIds = followUps.stream().map(FollowUp::getCreateId).collect(Collectors.toList());
-
+        List<Integer> ids = followUps.stream().map(FollowUp::getId).collect(Collectors.toList());
         List<Personnel> personnels = new ArrayList<>();
+        List<AssoFollowUpFile> assoFollowUpFiles = new ArrayList<>();
+        List<String> guids = new ArrayList<>();
+        List<SystemFile> systemFiles = new ArrayList<>();
         //查询创建人名称
         if (createIds.size() != 0) {
             try {
@@ -155,16 +174,55 @@ public class FollowUpService extends ServiceImpl<FollowUpMapper, FollowUp> {
                 throw new XiaoShiException("装载错误");
             }
         }
+
+        if (ids.size() != 0) {
+            //根据事件id获得事件文件关联表
+            LambdaQueryWrapper<AssoFollowUpFile> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(AssoFollowUpFile::getFollowUpId, ids);
+            assoFollowUpFiles = assoFollowUpFileService.list(queryWrapper);
+            guids = assoFollowUpFiles.stream().map(AssoFollowUpFile::getFileGuid).collect(Collectors.toList());
+        }
+
+        //查询文件
+        if (guids.size() != 0) {
+            try {
+                String res = fileManagerService.getSystemFileFromFMS(guids);
+                if (res != null && !res.trim().equals("")) {
+                    systemFiles = JSONObject.parseArray(res, SystemFile.class);
+                }
+            } catch (Exception e) {
+                throw new XiaoShiException("装载错误");
+            }
+        }
         for (FollowUp followUp : followUps) {
             FollowUpVO followUpVO = new FollowUpVO();
             BeanUtils.copyProperties(followUp, followUpVO);
+
+            //装载创建人
             Personnel personnel = personnels.stream().filter(item -> item.getId().equals(followUp.getCreateId())).findFirst().orElse(null);
             if (personnel != null) {
                 followUpVO.setCreateName(personnel.getPersonnelName());
             }
+
+            //装载状态
             if (followUp.getStatus().equals(0)) {
                 followUpVO.setStatusStr("进行中");
+            } else if (followUp.getStatus().equals(1)) {
+                followUpVO.setStatusStr("完成");
+            }
+
+            //装载文件信息
+            List<AssoFollowUpFile> assoFollowUpFilesTemp = assoFollowUpFiles.stream().filter(item -> item.getFollowUpId().equals(followUp.getId())).collect(Collectors.toList());
+            if (assoFollowUpFilesTemp.size() != 0) {
+                List<String> guidTemp = assoFollowUpFilesTemp.stream().map(AssoFollowUpFile::getFileGuid).collect(Collectors.toList());
+                if (guidTemp.size() != 0) {
+                    List<SystemFile> systemFileTemp = systemFiles.stream().filter(item -> guidTemp.contains(item.getGuid())).collect(Collectors.toList());
+                    if (systemFileTemp.size() != 0) {
+                        followUpVO.setSystemFileList(systemFileTemp);
+                    }
+                }
             }
+
             followUpVOS.add(followUpVO);
         }
         return followUpVOS;
@@ -175,38 +233,34 @@ public class FollowUpService extends ServiceImpl<FollowUpMapper, FollowUp> {
      * 登记结果
      *
      * @param register
-     * @param files
      */
-    public void register(RegisterDTO register, List<MultipartFile> files) throws ParseException {
+    public Integer register(RegisterDTO register) throws ParseException {
         //获取当前时间
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
         String date = dateFormat.format(new Date());//date为当前时间 是String类型的时间
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date finishTime = simpleDateFormat.parse(date);//转换为Date类型
-        System.out.println("等级结果当前完成时间" + finishTime);
-
-        FollowUp followUp = new FollowUp();
+        Integer followUpId = register.getFollowUpId();
+        //更新操作 将conclusion更新进入表
+        FollowUp followUp = this.getById(followUpId);
         //从registerDTO中取出后续事项id进行对应的操作
         followUp.setId(register.getFollowUpId());
         followUp.setStatus(1);
         followUp.setConclusion(register.getConclusion());
         followUp.setFinishTime(finishTime);
-        //更新操作 将conclusion更新进入表
-
-
-        //删除
-
-        //简化定义后续事项id
-        int followUpId = register.getFollowUpId();
+        followUp.updateById();
+        List<String> guids = register.getFileGuids();
         //根据后续事项id查询关联表找出所有fileId
-
+        LambdaQueryWrapper<AssoFollowUpFile> removeWrapper = new LambdaQueryWrapper<>();
+        removeWrapper.eq(AssoFollowUpFile::getFollowUpId, followUpId);
+        assoFollowUpFileService.remove(removeWrapper);
         //新增文件
-
-        //上传附件 进行关联绑定
+        assoFollowUpFileService.addBatch(followUpId, guids);
 
         //批量新增后续事项
         if (register.getFollowUps() != null && register.getFollowUps().size() > 0) {
             this.add(register.getFollowUps());
         }
+        return  followUpId;
     }
 }