Przeglądaj źródła

4/25 修改的多个bug 未返回创建人

chendayu 2 lat temu
rodzic
commit
f9020d1d3c

+ 12 - 8
PAS/src/main/java/cn/cslg/pas/domain/ProjectImport.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -14,16 +15,21 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * 专题库数据导入记录
+ *
  * @TableName os_thematic_import
  */
 @Data
-@TableName(value ="os_thematic_import")
+@TableName(value = "os_thematic_import")
 public class ProjectImport extends BaseEntity<ProjectImport> {
-
     /**
-     * 创建
+     * 创建人id
      */
     private Integer createBy;
+    /**
+     * 创建人名称
+     */
+    @TableField(exist = false)
+    private String createName;
 
     /**
      * 创建时间
@@ -38,20 +44,18 @@ public class ProjectImport extends BaseEntity<ProjectImport> {
     private Long fileSize;
 
     /**
-     * 
+     *
      */
     private String url;
 
     /**
-     * 
+     *
      */
     private String fileName;
 
     /**
-     * 
+     *
      */
     private String oldName;
 
-    @TableField(exist = false)
-    private String createName;
 }

+ 4 - 0
PAS/src/main/java/cn/cslg/pas/domain/asso/AssoStructurePatent.java

@@ -33,5 +33,9 @@ public class AssoStructurePatent implements Serializable {
      * 专题库id
      */
     private Integer projectId;
+    /**
+     * 架构路径
+     */
+    private String path;
 
 }

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/mapper/ProductCategoryMapper.java

@@ -55,7 +55,7 @@ public interface ProductCategoryMapper {
      *
      * @param id                  id
      * @param productCategoryName 名称
-     * @return
+     * @return 返回统计到的数量
      */
     int countByIdAndName(Integer id, String productCategoryName);
 

+ 1 - 0
PAS/src/main/java/cn/cslg/pas/service/ProjectFileService.java

@@ -43,6 +43,7 @@ public class ProjectFileService extends ServiceImpl<ProjectFileMapper, ProjectFi
 
     private final FileUtils fileUtils;
     private final LoginUtils loginUtils;
+
     public IPage<ProjectFile> getPageList(ProjectFileVO params) {
         IPage<ProjectFile> pageList = baseMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
 

+ 24 - 20
PAS/src/main/java/cn/cslg/pas/service/ProjectImportService.java

@@ -26,17 +26,14 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
-* @author Administrator
-* @description 针对表【os_thematic_import(专题库数据导入记录)】的数据库操作Service
-* @createDate 2022-05-19 10:55:10
-*/
+ * @author Administrator
+ * @description 针对表【os_thematic_import(专题库数据导入记录)】的数据库操作Service
+ * @createDate 2022-05-19 10:55:10
+ */
 @Service
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class ProjectImportService extends ServiceImpl<ProjectImportMapper, ProjectImport> {
@@ -46,19 +43,21 @@ public class ProjectImportService extends ServiceImpl<ProjectImportMapper, Proje
     private final PatentMapper patentMapper;
     private final ProjectPatentLinkService projectPatentLinkService;
     private final RequestService requestService;
+
     public IPage<ProjectImport> getPageList(ProjectImportVO params) throws IOException {
         //当查询使用发起人名称时
-        if (params.getCreateName() != null && params.getCreateName() != "") {
+        if (params.getCreateName() != null && !params.getCreateName().equals("")) {
             String res = requestService.getPersonIdByNamePCS(params.getCreateName());
             List<Integer> createIds = JSONArray.parseArray(res, Integer.class);
             params.setCreateIds(createIds);
             //当未查询到时直接返回空页
             if (createIds == null || createIds.size() == 0) {
-                params.setCreateIds(Arrays.asList(-1));
+                //params.setCreateIds(Arrays.asList(-1));
+                params.setCreateIds(Collections.singletonList(-1));
             }
         }
         IPage<ProjectImport> pageList = baseMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
-         this.setDataList(pageList.getRecords());
+        this.setDataList(pageList.getRecords());
         return pageList;
     }
 
@@ -96,16 +95,16 @@ public class ProjectImportService extends ServiceImpl<ProjectImportMapper, Proje
             if (!patentDTO.getPatentNo().equals("")) {
                 String[] strs = patentDTO.getPatentNo().split("\\|");
                 orgPatentNos = new ArrayList<>(Arrays.asList(strs));
-                QueryPatentVO params =new QueryPatentVO();
+                QueryPatentVO params = new QueryPatentVO();
                 params.setPatentNo(patentDTO.getPatentNo());
                 params.setPatentNos(orgPatentNos);
-                List<Patent> patents =patentMapper.getConPantents(params);
-                List<String> patentNos =patents.stream().map(Patent::getPatentNo).collect(Collectors.toList());
+                List<Patent> patents = patentMapper.getConPantents(params);
+                List<String> patentNos = patents.stream().map(Patent::getPatentNo).collect(Collectors.toList());
                 orgPatentNos.removeAll(patentNos);
                 if (patents.size() > 0) {
-                    List<ProjectPatentLink> projectPatentLinkList =new ArrayList<>();
-                    patents.forEach(item->{
-                        ProjectPatentLink projectPatentLink =new ProjectPatentLink();
+                    List<ProjectPatentLink> projectPatentLinkList = new ArrayList<>();
+                    patents.forEach(item -> {
+                        ProjectPatentLink projectPatentLink = new ProjectPatentLink();
                         projectPatentLink.setProjectId(patentDTO.getProjectId());
                         projectPatentLink.setPatentId(item.getId());
                         projectPatentLinkList.add(projectPatentLink);
@@ -119,15 +118,20 @@ public class ProjectImportService extends ServiceImpl<ProjectImportMapper, Proje
 
     private void setDataList(List<ProjectImport> importList) throws IOException {
         //获得创建人的id集合
-        List<Integer> createIds =importList.stream().map(ProjectImport::getCreateBy).collect(Collectors.toList());
+        //List<Integer> createIds = importList.stream().map(ProjectImport::getCreateBy).collect(Collectors.toList());
+        ArrayList<Integer> createPersonIds = new ArrayList<>();
+        for (ProjectImport projectImport : importList) {
+            createPersonIds.add(projectImport.getCreateBy());
+        }
+
         //获取专题库负责人对应信息
-        String jsonObject1 = requestService.getPersonnelFromPCS(createIds);
+        String jsonObject1 = requestService.getPersonnelFromPCS(createPersonIds);
         JSONArray jsonArray = JSON.parseArray(jsonObject1);
         List<ProjectVO.Personnel> personnelList = jsonArray.toJavaList(ProjectVO.Personnel.class);
         for (ProjectImport projectImport : importList) {
             for (ProjectVO.Personnel personnel : personnelList) {
                 //装载创建人名
-                if(projectImport.getCreateBy()!=null){
+                if (projectImport.getCreateBy() != null) {
                     if (projectImport.getCreateBy().equals(personnel.getId())) {
                         projectImport.setCreateName(personnel.getPersonnelName());
                     }

+ 11 - 9
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -54,31 +54,33 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     public void addNew(ProductCategoryAddNewDTO productCategoryAddNewDTO, List<MultipartFile> files) {
         log.info("开始处理【新增产品类别】的业务,参数为:{}, {}", productCategoryAddNewDTO, files);
 
+        //获取当前登陆人信息
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         Integer tenantId = personnelVO.getTenantId();
+        Integer createPersonId = personnelVO.getId();
+        String createPersonName = personnelVO.getName();
 
-        //检查产品类别名称是否被占用
+        //1.检查当前租户下该产品类别名称是否被占用
         String productCategoryName = productCategoryAddNewDTO.getProductCategoryName();
-        log.info("检查产品类别名称是否被占用");
+        log.info("检查当前租户下该产品类别名称是否被占用");
         int count = productCategoryMapper.countByProductCategoryName(productCategoryName, tenantId);
         if (count > 0) {
-            ThrowException.throwXiaoShiException("新增产品类别失败,产品类别名称【" + productCategoryName + "】已存在,请尝试更换名称");
+            ThrowException.throwXiaoShiException("新增产品类别失败,当前租户下产品类别名称【" + productCategoryName + "】已存在,请尝试更换名称");
         }
 
-        //检查许可费率数值是否合法
+        //2.检查许可费率数值是否合法
         Double licenseRate = productCategoryAddNewDTO.getLicenseRate();
         if (licenseRate != null && (licenseRate < 0 || licenseRate > 1)) {
             ThrowException.throwXiaoShiException("新增产品类别失败,许可费率不合法,请填写正确数值");
         }
 
-        //新增产品类别DTO对象赋值给产品类别表实体类
+        //DTO对象赋值给实体类
         ProductCategory productCategory = new ProductCategory();
         BeanUtils.copyProperties(productCategoryAddNewDTO, productCategory);
-        //获取当前登陆人信息
         productCategory
-                .setCreatePersonId(personnelVO.getId())
-                .setCreatePersonName(personnelVO.getName())
-                .setTenantId(tenantId);
+                .setTenantId(tenantId)
+                .setCreatePersonId(createPersonId)
+                .setCreatePersonName(createPersonName);
 
         //数据入产品类别表
         log.info("数据入产品类别表");

+ 10 - 1
PAS/src/main/java/cn/cslg/pas/service/impl/StructurePatentServiceImpl.java

@@ -5,8 +5,10 @@ import cn.cslg.pas.common.model.dto.AssoStructurePatentQueryDTO;
 import cn.cslg.pas.common.model.dto.AssoStructurePatentUpdateDTO;
 import cn.cslg.pas.common.model.dto.StructureAndProductIds;
 import cn.cslg.pas.common.model.vo.AssoStructurePatentVO;
+import cn.cslg.pas.domain.Structure;
 import cn.cslg.pas.domain.asso.AssoStructurePatent;
 import cn.cslg.pas.exception.XiaoShiException;
+import cn.cslg.pas.mapper.StructureMapper;
 import cn.cslg.pas.mapper.asso.AssoStructurePatentMapper;
 import cn.cslg.pas.service.IStructurePatentService;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -30,6 +32,7 @@ import java.util.List;
 @Service
 public class StructurePatentServiceImpl extends ServiceImpl<AssoStructurePatentMapper, AssoStructurePatent> implements IStructurePatentService {
     private final AssoStructurePatentMapper assoStructurePatentMapper;
+    private final StructureMapper structureMapper;
 
     /**
      * 更新标引(新增或删除)
@@ -41,10 +44,15 @@ public class StructurePatentServiceImpl extends ServiceImpl<AssoStructurePatentM
         log.info("开始处理【更新标引】的业务,参数为:{}", assoStructurePatentUpdateDTO);
 
         //获取DTO中的updateType类型,true则为新增标引,false则为删除标引
+        Integer structureId = assoStructurePatentUpdateDTO.getStructureId();
         Boolean updateType = assoStructurePatentUpdateDTO.getUpdateType();
         //DTO对象赋值给实体类
         AssoStructurePatent assoStructurePatent = new AssoStructurePatent();
         BeanUtils.copyProperties(assoStructurePatentUpdateDTO, assoStructurePatent);
+        //获取架构路径path,赋值给实体类
+        Structure structure = structureMapper.getStandardById(structureId);
+        assoStructurePatent.setPath(structure.getPath());
+
         //true则新增标引,false则删除标引
         if (updateType) {
             log.info("架构专利关联表新增数据");
@@ -92,7 +100,8 @@ public class StructurePatentServiceImpl extends ServiceImpl<AssoStructurePatentM
                         .setProjectId(projectId)
                         .setPatentNo(patentNo)
                         .setStructureId(structureAndProductId.getStructureId())
-                        .setProductId(structureAndProductId.getProductId());
+                        .setProductId(structureAndProductId.getProductId())
+                        .setPath(structureMapper.getStandardById(structureAndProductId.getStructureId()).getPath());
                 newAssoStructurePatents.add(assoStructurePatent);
             }
         }

+ 7 - 16
PAS/src/main/resources/mapper/AssoStructurePatentMapper.xml

@@ -5,8 +5,8 @@
     <!--插入数据-->
     <!--int insert(AssoStructurePatent assoStructurePatent);-->
     <insert id="insert" useGeneratedKeys="true" keyProperty="id">
-        insert into asso_structure_patent (structure_id, patent_no, product_Id, project_id)
-        values (#{structureId}, #{patentNo}, #{productId}, #{projectId});
+        insert into asso_structure_patent (structure_id, patent_no, product_Id, project_id, path)
+        values (#{structureId}, #{patentNo}, #{productId}, #{projectId}, #{path});
     </insert>
 
     <!--删除标引数据-->
@@ -14,20 +14,11 @@
     <delete id="delete">
         delete
         from asso_structure_patent
-        <where>
-            <if test="projectId != null">
-                and project_id = #{projectId}
-            </if>
-            <if test="patentNo != null">
-                and patent_no = #{patentNo}
-            </if>
-            <if test="structureId != null">
-                and structure_id = #{structureId}
-            </if>
-            <if test="productId != null">
-                and product_Id = #{productId}
-            </if>
-        </where>
+        where project_id = #{projectId}
+          and patent_no = #{patentNo}
+          and structure_id = #{structureId}
+          and product_Id = #{productId}
+          and path = #{path}
     </delete>
 
     <!--根据产品id统计数量-->