zero 1 سال پیش
والد
کامیت
37d11b6c14

+ 24 - 0
src/main/java/cn/cslg/pas/common/dto/AddTechnicalCaseDTO.java

@@ -0,0 +1,24 @@
+package cn.cslg.pas.common.dto;
+
+import lombok.Data;
+
+@Data
+public class AddTechnicalCaseDTO {
+
+    private Integer technicalCaseId;
+
+    private Integer projectId;
+
+    private String ipc;
+
+    private String solvedProblem;
+
+    private String technicalField;
+
+    private String remark;
+
+    private String picture;
+
+    private String inventionPoint;
+
+}

+ 11 - 0
src/main/java/cn/cslg/pas/common/dto/TechnicalCaseIdDTO.java

@@ -0,0 +1,11 @@
+package cn.cslg.pas.common.dto;
+
+import lombok.Data;
+
+@Data
+public class TechnicalCaseIdDTO {
+
+    private Integer projectId;
+
+    private Integer technicalCaseId;
+}

+ 24 - 0
src/main/java/cn/cslg/pas/common/vo/QueryNoveltyProjectVO.java

@@ -1,8 +1,10 @@
 package cn.cslg.pas.common.vo;
 
 import cn.cslg.pas.common.model.cronModel.SystemFile;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.util.Date;
 import java.util.List;
 
 @Data
@@ -56,5 +58,27 @@ public class QueryNoveltyProjectVO {
 
     private List<SystemFile> systemFileList;
 
+    private Integer tenantId;
+
+    private String createId;
+
+    private String createName;
+
+    private Date createTime;
+
+    @Schema(description = "委托类型(1客户,2部门)")
+    private Integer entrustType;
+
+    private String entrustId;
+
+    private String entrustName;
+
+    private String departmentId;
+
+    private String departmentName;
+
+    private String headId;
+
+    private String headName;
 
 }

+ 28 - 0
src/main/java/cn/cslg/pas/common/vo/TechnicalCaseVO.java

@@ -0,0 +1,28 @@
+package cn.cslg.pas.common.vo;
+
+import cn.cslg.pas.common.model.cronModel.SystemFile;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TechnicalCaseVO {
+
+    private Integer technicalCaseId;
+
+    private Integer projectId;
+
+    private String ipc;
+
+    private String solvedProblem;
+
+    private String technicalField;
+
+    private String remark;
+
+    private String picture;
+
+    private String inventionPoint;
+
+    private List<SystemFile> systemFileList;
+}

+ 40 - 6
src/main/java/cn/cslg/pas/controller/NoveltyProjectController.java

@@ -1,14 +1,14 @@
 package cn.cslg.pas.controller;
 
 import cn.cslg.pas.common.core.base.Constants;
-import cn.cslg.pas.common.dto.AddNoveltyProjectDTO;
-import cn.cslg.pas.common.dto.NoveltyProjectIdDTO;
-import cn.cslg.pas.common.dto.QueryNoveltyProjectDTO;
+import cn.cslg.pas.common.dto.*;
 import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.utils.Response;
 import cn.cslg.pas.common.vo.QueryNoveltyProjectVO;
+import cn.cslg.pas.common.vo.TechnicalCaseVO;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.service.business.NoveltyProjectService;
+import cn.cslg.pas.service.business.TechnicalCaseService;
 import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -16,9 +16,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.ArrayList;
-import java.util.List;
-
 @RequestMapping(Constants.API_XiaoSHI + "/noveltyProject")
 @RestController
 public class NoveltyProjectController {
@@ -26,6 +23,9 @@ public class NoveltyProjectController {
     @Autowired
     private NoveltyProjectService noveltyProjectService;
 
+    @Autowired
+    private TechnicalCaseService technicalCaseService;
+
     @Operation(summary = "添加查新检索报告")
     @PostMapping("/addNoveltyProject")
     public Response addNoveltyProject(@RequestBody AddNoveltyProjectDTO noveltyProjectDTO) throws Exception {
@@ -73,4 +73,38 @@ public class NoveltyProjectController {
         return Response.success("删除成功");
     }
 
+    @Operation(summary = "添加或更新技术方案信息")
+    @PostMapping("/addOrUpdateTechnicalCase")
+    public Response addOrUpdateTechnicalCase(@RequestBody AddTechnicalCaseDTO caseDTO) throws Exception {
+        Integer noveltyProjectId = null;
+        try {
+            noveltyProjectId = technicalCaseService.addOrUpdateTechnicalCase(caseDTO);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
+        return Response.success(noveltyProjectId);
+    }
+
+    @Operation(summary = "查询技术方案信息")
+    @PostMapping("/queryTechnicalCase")
+    public Response queryTechnicalCase(@RequestBody TechnicalCaseIdDTO caseIdDTO) throws Exception {
+        TechnicalCaseVO caseVO = new TechnicalCaseVO();
+        try {
+            caseVO = technicalCaseService.queryTechnicalCase(caseIdDTO);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
+        return Response.success(caseVO);
+    }
+
+    @Operation(summary = "删除技术方案信息")
+    @PostMapping("/deleteTechnicalCase")
+    public Response deleteTechnicalCase(@RequestBody TechnicalCaseIdDTO vo) throws Exception {
+        try {
+            technicalCaseService.deleteTechnicalCase(vo);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
+        return Response.success("删除成功");
+    }
 }

+ 2 - 0
src/main/java/cn/cslg/pas/mapper/TechnicalCaseMapper.java

@@ -2,6 +2,8 @@ package cn.cslg.pas.mapper;
 
 import cn.cslg.pas.domain.business.TechnicalCase;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
 
+@Repository
 public interface TechnicalCaseMapper extends BaseMapper<TechnicalCase> {
 }

+ 114 - 22
src/main/java/cn/cslg/pas/service/business/NoveltyProjectService.java

@@ -3,17 +3,19 @@ package cn.cslg.pas.service.business;
 import cn.cslg.pas.common.dto.AddNoveltyProjectDTO;
 import cn.cslg.pas.common.dto.NoveltyProjectIdDTO;
 import cn.cslg.pas.common.dto.QueryNoveltyProjectDTO;
-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.cronModel.*;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
+import cn.cslg.pas.common.vo.DepartmentVO;
 import cn.cslg.pas.common.vo.QueryNoveltyProjectVO;
+import cn.cslg.pas.domain.business.AssoProjectFile;
 import cn.cslg.pas.domain.business.NoveltyProject;
 import cn.cslg.pas.domain.business.Project;
 import cn.cslg.pas.mapper.NoveltyProjectMapper;
 import cn.cslg.pas.mapper.ProjectMapper;
 import cn.cslg.pas.service.common.FileManagerService;
+import cn.cslg.pas.service.permissions.PermissionService;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -32,6 +34,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -44,34 +47,20 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
     private FileManagerService fileManagerService;
 
     @Autowired
+    private PermissionService permissionService;
+
+    @Autowired
     private ProjectMapper projectMapper;
 
     @Autowired
     private NoveltyProjectMapper noveltyProjectMapper;
 
 
-    public Records queryNoveltyProject(QueryNoveltyProjectDTO vo) {
+    public Records queryNoveltyProject(QueryNoveltyProjectDTO vo) throws IOException {
         vo.setCurrent(vo.getCurrent() - 1);
         //查询数据库
         List<QueryNoveltyProjectVO> noveltyProjectVOS = noveltyProjectMapper.queryNoveltyProject(vo);
-        if (!CollectionUtils.isEmpty(noveltyProjectVOS)) {
-            noveltyProjectVOS.forEach(i -> {
-                if (StringUtils.isNotEmpty(i.getPicture())) {
-                    List<String> guids = new ArrayList<>();
-                    guids.add(i.getPicture());
-                    String res = null;
-                    try {
-                        res = fileManagerService.getSystemFileFromFMS(guids);
-                    } catch (IOException e) {
-                        e.printStackTrace();
-                    }
-                    if (StringUtils.isNotEmpty(res)) {
-                        final List<SystemFile> systemFiles = JSONObject.parseArray(res, SystemFile.class);
-                        i.setSystemFileList(systemFiles);
-                    }
-                }
-            });
-        }
+        this.loadNoveltyProjectVOS(noveltyProjectVOS);
         //查询总数
         final Long total = noveltyProjectMapper.queryNoveltyProjectCount(vo);
         Records records = new Records();
@@ -82,6 +71,109 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
         return records;
     }
 
+    public void loadNoveltyProjectVOS(List<QueryNoveltyProjectVO> noveltyProjectVOS) throws IOException {
+        if (!CollectionUtils.isEmpty(noveltyProjectVOS)) {
+            List<String> createIds = new ArrayList<>();
+            List<String> departmentIds = new ArrayList<>();
+            List<Integer> clientIds = new ArrayList<>();
+            List<DepartmentVO> departmentVOS = new ArrayList<>();
+            List<Personnel> personnels = new ArrayList<>();
+            List<Client> clients = new ArrayList<>();
+            noveltyProjectVOS.forEach(item -> {
+                if (item.getCreateId() != null) {
+                    createIds.add(item.getCreateId());
+                }
+
+                if (item.getHeadId() != null) {
+                    createIds.add(item.getHeadId());
+                }
+
+                if (item.getDepartmentId() != null) {
+                    departmentIds.add(item.getDepartmentId());
+                }
+
+                if (item.getEntrustType() != null && item.getEntrustType().equals(2)) {
+                    departmentIds.add(item.getEntrustId());
+                }
+
+                if (item.getEntrustType() != null && item.getEntrustType().equals(1)) {
+                    clientIds.add(Integer.parseInt(item.getEntrustId()));
+                }
+            });
+
+            //查询创建人名称
+            if (!CollectionUtils.isEmpty(createIds)) {
+                String res = permissionService.getPersonnelByIdsFromPCS(createIds);
+                JSONObject jsonObject = JSON.parseObject(res);
+                personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
+            }
+
+            //查询部门名称
+            if (!CollectionUtils.isEmpty(departmentIds)) {
+                String json = permissionService.getDepartmentByIdsFromPCS(departmentIds);
+                departmentVOS = JSON.parseArray(json, DepartmentVO.class);
+            }
+
+            //查询客户名称
+            if (!CollectionUtils.isEmpty(clientIds)) {
+                String res = permissionService.getClientByIdsFromPCS(clientIds);
+                JSONObject jsonObject = JSON.parseObject(res);
+                clients = JSONObject.parseArray(jsonObject.getString("data"), Client.class);
+            }
+
+            List<SystemFile> systemFiles = new ArrayList<>();
+            List<String> guids = noveltyProjectVOS.stream().map(QueryNoveltyProjectVO::getPicture).collect(Collectors.toList());
+            //查询文件
+            if (!CollectionUtils.isEmpty(guids)) {
+                String res = fileManagerService.getSystemFileFromFMS(guids);
+                systemFiles = JSON.parseArray(res, SystemFile.class);
+            }
+
+            for (QueryNoveltyProjectVO noveltyProjectVO : noveltyProjectVOS) {
+                //装载人员信息
+                Personnel personnel = personnels.stream().filter(item -> item.getId().equals(noveltyProjectVO.getCreateId())).findFirst().orElse(null);
+                if (personnel != null) {
+                    noveltyProjectVO.setCreateName(personnel.getPersonnelName());
+                }
+                //装载负责人
+                if (noveltyProjectVO.getHeadId() != null) {
+                    Personnel headPersonnel = personnels.stream().filter(item -> item.getId().equals(noveltyProjectVO.getHeadId())).findFirst().orElse(null);
+                    if (headPersonnel != null) {
+                        noveltyProjectVO.setHeadName(headPersonnel.getPersonnelName());
+                    }
+                }
+                //装载部门
+                if (noveltyProjectVO.getDepartmentId() != null) {
+                    DepartmentVO departmentVO = departmentVOS.stream().filter(item -> item.getDepartId().equals(noveltyProjectVO.getDepartmentId())).findFirst().orElse(null);
+                    if (departmentVO != null) {
+                        noveltyProjectVO.setDepartmentName(departmentVO.getDepartName());
+                    }
+                }
+                //裝载委托方
+                if (noveltyProjectVO.getEntrustType() != null) {
+                    //当委托方为客户时
+                    if (noveltyProjectVO.getEntrustType().equals(1)) {
+                        Client client = clients.stream().filter(item -> item.getId().equals(Integer.parseInt(noveltyProjectVO.getEntrustId()))).findFirst().orElse(null);
+                        if (client != null) {
+                            noveltyProjectVO.setEntrustName(client.getName());
+                        }
+                    } else if (noveltyProjectVO.getEntrustType().equals(2)) {
+                        DepartmentVO departmentVO = departmentVOS.stream().filter(item -> item.getDepartId().equals(noveltyProjectVO.getEntrustId())).findFirst().orElse(null);
+                        if (departmentVO != null) {
+                            noveltyProjectVO.setEntrustName(departmentVO.getDepartName());
+                        }
+                    }
+                }
+                //装载文件信息
+                if (StringUtils.isNotEmpty(noveltyProjectVO.getPicture())) {
+                    SystemFile systemFile = systemFiles.stream().filter(i -> i.getGuid().equals(noveltyProjectVO.getPicture())).findFirst().orElse(null);
+                    List<SystemFile> systemFileList = new ArrayList<>();
+                    systemFileList.add(systemFile);
+                    noveltyProjectVO.setSystemFileList(systemFileList);
+                }
+            }
+        }
+    }
 
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
     public Integer addNoveltyProject(AddNoveltyProjectDTO vo) {

+ 87 - 0
src/main/java/cn/cslg/pas/service/business/TechnicalCaseService.java

@@ -1,16 +1,103 @@
 package cn.cslg.pas.service.business;
 
+import cn.cslg.pas.common.dto.AddNoveltyProjectDTO;
+import cn.cslg.pas.common.dto.AddTechnicalCaseDTO;
+import cn.cslg.pas.common.dto.TechnicalCaseIdDTO;
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.model.cronModel.SystemFile;
+import cn.cslg.pas.common.utils.CacheUtils;
+import cn.cslg.pas.common.utils.LoginUtils;
+import cn.cslg.pas.common.vo.TechnicalCaseVO;
+import cn.cslg.pas.domain.business.NoveltyProject;
+import cn.cslg.pas.domain.business.Project;
 import cn.cslg.pas.domain.business.TechnicalCase;
 import cn.cslg.pas.mapper.TechnicalCaseMapper;
+import cn.cslg.pas.service.common.FileManagerService;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 @Service
 @Slf4j
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class TechnicalCaseService extends ServiceImpl<TechnicalCaseMapper, TechnicalCase> {
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
+
+    @Autowired
+    private FileManagerService fileManagerService;
+
+    @Autowired
+    private TechnicalCaseMapper technicalCaseMapper;
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public Integer addOrUpdateTechnicalCase(AddTechnicalCaseDTO vo) {
+        Integer id = null;
+        if (vo.getTechnicalCaseId() == null) {
+            if (vo.getProjectId() == null) {
+                PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+                Project project = new Project();
+                project.setCreateId(personnelVO.getId());
+                project.setTenantId(personnelVO.getTenantId());
+                project.setCreateTime(new Date());
+                project.insert();
+                vo.setProjectId(project.getId());
+                NoveltyProject noveltyProject = new NoveltyProject();
+                noveltyProject.setProjectId(project.getId());
+                noveltyProject.insert();
+            }
+            TechnicalCase technicalCase = new TechnicalCase();
+            BeanUtils.copyProperties(vo, technicalCase);
+            technicalCase.insert();
+            id = technicalCase.getId();
+        } else {
+            TechnicalCase technicalCase = technicalCaseMapper.selectById(vo.getTechnicalCaseId());
+            BeanUtils.copyProperties(vo, technicalCase);
+            technicalCase.updateById();
+            id = technicalCase.getId();
+        }
+        return id;
+    }
+
+    public TechnicalCaseVO queryTechnicalCase(TechnicalCaseIdDTO vo) {
+        TechnicalCase technicalCase = this.getOne(new LambdaQueryWrapper<TechnicalCase>()
+                .eq(TechnicalCase::getProjectId, vo.getProjectId()));
+        TechnicalCaseVO technicalCaseVO = new TechnicalCaseVO();
+        BeanUtils.copyProperties(technicalCase, technicalCaseVO);
+        technicalCaseVO.setTechnicalCaseId(technicalCase.getId());
+        if (StringUtils.isNotEmpty(technicalCaseVO.getPicture())) {
+            List<String> guids = new ArrayList<>();
+            guids.add(technicalCaseVO.getPicture());
+            String res = null;
+            try {
+                res = fileManagerService.getSystemFileFromFMS(guids);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            if (StringUtils.isNotEmpty(res)) {
+                final List<SystemFile> systemFiles = JSON.parseArray(res, SystemFile.class);
+                technicalCaseVO.setSystemFileList(systemFiles);
+            }
+        }
+        return technicalCaseVO;
+    }
 
+    public void deleteTechnicalCase(TechnicalCaseIdDTO vo) {
+        this.removeById(vo.getTechnicalCaseId());
+    }
 }

+ 7 - 0
src/main/resources/mapper/NoveltyProjectMapper.xml

@@ -4,6 +4,13 @@
 
     <select id="queryNoveltyProject" resultType="cn.cslg.pas.common.vo.QueryNoveltyProjectVO">
         select p.id as projectId,
+        p.entrust_type,
+        p.entrust_id,
+        p.head_id,
+        p.department_id,
+        p.create_id,
+        p.create_time,
+        p.tenant_id,
         np.id as noveltyProjectId,
         tc.id as technicalCaseId,
         np.custom_case_number,