Prechádzať zdrojové kódy

5.23 整理分析系统接口时修改与添加注释优化代码

chendayu 2 rokov pred
rodič
commit
74ecf24364

+ 0 - 8
PAS/src/main/java/cn/cslg/pas/common/model/vo/ApplicationScenarioEventNumberVO.java

@@ -23,14 +23,6 @@ public class ApplicationScenarioEventNumberVO implements Serializable {
      */
     private String applicationScenarioName;
     /**
-     * 应用场景直接对应的事件数量
-     */
-    //private Integer eventNumberFromEvent;
-    /**
-     * 应用场景对应的专题库中事件的数量
-     */
-    //private Integer eventNumberFromProject;
-    /**
      * 事件数量
      */
     private Integer eventNumber;

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/common/model/vo/EventListItemVO.java

@@ -20,7 +20,7 @@ import java.util.List;
 @Data
 public class EventListItemVO implements Serializable {
     /**
-     * 主键
+     * 事件id
      */
     private Integer id;
     /**

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/common/model/vo/InvestigationTypeProjectNumberVO.java

@@ -13,7 +13,7 @@ import java.io.Serializable;
 @Data
 public class InvestigationTypeProjectNumberVO implements Serializable {
     /**
-     * 调查类型
+     * 调查类型数值
      */
     private Integer investigationType;
     /**

+ 12 - 13
PAS/src/main/java/cn/cslg/pas/common/model/vo/ProductMarketDataTrendVO.java

@@ -4,7 +4,6 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 
 
-
 /**
  * 产品营销数据返回的数据VO
  *
@@ -15,20 +14,20 @@ import lombok.experimental.Accessors;
 @Data
 public class ProductMarketDataTrendVO {
 
-        /**
-         * 时间(季度/月份/年份)
-         */
-        private String marketDate;
+    /**
+     * 时间(季度/月份/年份)
+     */
+    private String marketDate;
 
-        /**
-         * 销售额
-         */
-        private Double saleTotalMoney;
+    /**
+     * 销售额
+     */
+    private Double saleTotalMoney;
 
-        /**
-         * 自定义许可费(销售量 * 自定义许可费率)
-         */
-        private Double customLicenseMoney;
+    /**
+     * 自定义许可费(销售量 * 自定义许可费率)
+     */
+    private Double customLicenseMoney;
 
 
 }

+ 4 - 4
PAS/src/main/java/cn/cslg/pas/controller/EventController.java

@@ -30,10 +30,10 @@ import java.util.List;
 public class EventController {
     private final IEventService eventService;
 
-    @Operation(summary = "新增事件")
+    @Operation(summary = "新增专题库时批量新增新事件(无事件id)")
     @PostMapping("/addNew")
     public String addNew(@RequestBody List<EventAddNewDTO> eventAddNewDTOs) {
-        log.info("开始处理【新增事件】的请求,请求参数为:{}", eventAddNewDTOs);
+        log.info("开始处理【新增专题库时批量新增新事件(无事件id)】的请求,请求参数为:{}", eventAddNewDTOs);
         List<Integer> eventIds;
         try {
             eventIds = eventService.addNew(eventAddNewDTOs);
@@ -43,10 +43,10 @@ public class EventController {
         return Response.success(eventIds);
     }
 
-    @Operation(summary = "专题库中新增事件")
+    @Operation(summary = "新增事件")
     @PostMapping("/addNewEvent")
     public String addNewEvent(@RequestBody ProjectEventAddNewDTO projectEventAddNewDTO) {
-        log.info("开始处理【专题库中新增事件】的请求,请求参数为:{}", projectEventAddNewDTO);
+        log.info("开始处理【新增事件】的请求,请求参数为:{}", projectEventAddNewDTO);
         try {
             eventService.addNewEvent(projectEventAddNewDTO);
         } catch (XiaoShiException e) {

+ 1 - 4
PAS/src/main/java/cn/cslg/pas/controller/PermissionRecordController.java

@@ -70,7 +70,7 @@ public class PermissionRecordController {
 
     @Operation(summary = "根据专利号分页查询许可记录数据信息")
     @PostMapping("/query")
-    public String query(@RequestBody QueryPREntity queryPREntity){
+    public String query(@RequestBody QueryPREntity queryPREntity) {
         List<PermissionRecordVO> queryResult = permissionRecordService.findAllByPage(queryPREntity);
         PageHelperT pageHelperT = new PageHelperT();
         pageHelperT.setList(queryResult);
@@ -80,6 +80,3 @@ public class PermissionRecordController {
         return Response.success(pageHelperT);
     }
 }
-
-
-

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/service/IEventService.java

@@ -18,7 +18,7 @@ import java.util.List;
  */
 public interface IEventService extends IService<Event> {
     /**
-     * 批量新增事件
+     * 新增专题库时批量新增事件(无事件id)
      *
      * @param eventAddNewDTOs 新增事件的DTO类对象集合
      * @return 返回事件eventIds
@@ -27,7 +27,7 @@ public interface IEventService extends IService<Event> {
     List<Integer> addNew(List<EventAddNewDTO> eventAddNewDTOs);
 
     /**
-     * 专题库中新增事件
+     * 新增事件
      *
      * @param projectEventAddNewDTO 专题库新增事件的DTO类对象集合
      */

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

@@ -50,6 +50,7 @@ public interface IProductCategoryService {
 
     /**
      * 查询产品架构趋势图
+     *
      * @param dto
      * @autor lrj
      */

+ 19 - 20
PAS/src/main/java/cn/cslg/pas/service/impl/EventServiceImpl.java

@@ -52,14 +52,14 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
     private final LoginUtils loginUtils;
 
     /**
-     * 新增事件
+     * 新增专题库时批量新增事件中的新事件
      *
      * @param eventAddNewDTOs 新增事件的DTO类对象集合
      * @return 返回事件eventIds
      */
     @Override
     public List<Integer> addNew(List<EventAddNewDTO> eventAddNewDTOs) {
-        log.info("开始处理【批量新增事件】的业务,参数为:{}", eventAddNewDTOs);
+        log.info("开始处理【新增专题库时批量新增事件(无事件id)】的业务,参数为:{}", eventAddNewDTOs);
 
         //获取当前登陆人信息取出登陆人id、登陆人名称、租户id
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
@@ -92,6 +92,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
             List<Integer> applicationScenarios = eventAddNewDTO.getApplicationScenarios();
             //若有应用场景,则将应用场景集合转换成以逗号拼接的字符串,并赋值给实体类对应参数
             if (applicationScenarios != null && applicationScenarios.size() > 0) {
+                //StringBuilder builder = new StringBuilder();
+                //for (Integer applicationScenario : applicationScenarios) {
+                //    builder.append(applicationScenario).append(",");
+                //}
+                //String applicationScenario = builder.substring(0, builder.lastIndexOf(","));
                 String applicationScenario = applicationScenarios.stream().map(String::valueOf).collect(Collectors.joining(","));
                 event.setApplicationScenario(applicationScenario);
             }
@@ -110,13 +115,13 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
     }
 
     /**
-     * 专题库中新增事件
+     * 新增事件
      *
      * @param projectEventAddNewDTO 专题库新增事件的DTO类对象集合
      */
     @Override
     public void addNewEvent(ProjectEventAddNewDTO projectEventAddNewDTO) {
-        log.info("开始处理【专题库中新增事件】的业务,参数为:{}", projectEventAddNewDTO);
+        log.info("开始处理【新增事件】的业务,参数为:{}", projectEventAddNewDTO);
 
         //新增事件
         List<EventAddNewDTO> eventAddNewDTOs = projectEventAddNewDTO.getEventAddNewDTOs();
@@ -124,16 +129,17 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
         List<Integer> eventIds = new ArrayList<>();
         //过滤去除已有事件↓(根据是否有id来过滤,有id则为已有事件无需新增,只做关联)
         List<EventAddNewDTO> oldEventAddNewDTOs = eventAddNewDTOs.stream().filter(item -> item.getId() != null).collect(Collectors.toList());
-        eventAddNewDTOs.removeAll(oldEventAddNewDTOs);
+        //遍历已有事件,将事件id添加进事件ids集合
+        for (EventAddNewDTO oldEventAddNewDTO : oldEventAddNewDTOs) {
+            eventIds.add(oldEventAddNewDTO.getId());
+        }
 
         //过滤后为新事件↓,新事件需要先新增事件,拿到事件ids后再和专题库做关联
+        eventAddNewDTOs.removeAll(oldEventAddNewDTOs);
         if (eventAddNewDTOs.size() > 0) {
             List<Integer> newEventIds = this.addNew(eventAddNewDTOs);
             eventIds.addAll(newEventIds);
         }
-        for (EventAddNewDTO oldEventAddNewDTO : oldEventAddNewDTOs) {
-            eventIds.add(oldEventAddNewDTO.getId());
-        }
         //新增事件和专题库关联
         assoEventProjectService.addNew(eventIds, projectId);
 
@@ -167,6 +173,8 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
         if (current != null && size != null) {
             PageHelper.startPage(current, size);
         }
+
+        //开始查询事件
         List<EventListItemVO> queryResults = eventMapper.queryList(eventQueryPageDTO);
         //将以逗号拼接的字符串应用场景applicationScenario转化为应用场景value集合
         for (EventListItemVO queryResult : queryResults) {
@@ -177,7 +185,6 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
                 for (String n : applicationScenarioArr) {
                     applicationScenarioValues.add(Integer.parseInt(n));
                 }
-                //List<Integer> applicationScenarioIds = Arrays.stream(applicationScenario.split(",")).map(Integer::parseInt).collect(Collectors.toList());
                 queryResult.setApplicationScenarios(applicationScenarioValues);
             }
         }
@@ -193,14 +200,6 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
 
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         Integer tenantId = personnelVO.getTenantId();
-        /*
-         * 原先学到的野方法直接在sql中装载好,只需以下几行代码返回给前台(但是杰哥说这样访问数据库效率降到最低,故舍弃)
-         *         List<ApplicationScenarioEventNumberVO> applicationScenarioEventNumberVOS = eventMapper.queryApplicationScenarioEventNumber(tenantId);
-         *         //遍历给事件数量属性赋上值 (事件数量=应用场景直接对应的事件数量+应用场景对应的专题库对应的事件数量(且该部分事件没有直接应用场景))
-         *         for (ApplicationScenarioEventNumberVO n : applicationScenarioEventNumberVOS) {
-         *             n.setEventNumber(n.getEventNumberFromEvent() + n.getEventNumberFromProject());
-         *         }
-         */
 
         //查询所有应用场景(目前为9个应用场景)
         List<ApplicationScenario> applicationScenarios = eventMapper.queryApplicationScenarios();
@@ -208,7 +207,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
         //查询所有事件(分为两类:1.有应用场景的事件;2.没有应用场景的事件(该部分事件使用它们所属的专题库的应用场景))
         List<EventListItemVO> eventsDirectApplicationScenario = eventMapper.queryEventsDirectApplicationScenario(tenantId);
         List<EventListItemVO> eventsInDirectApplicationScenario = eventMapper.queryEventsInDirectApplicationScenario(tenantId);
-        //装载上述两类事件的应用场景
+        //装载上述两类事件的应用场景
         ArrayList<String> applicationScenarioStrs = new ArrayList<>();
         if (eventsDirectApplicationScenario != null) {
             for (EventListItemVO n : eventsDirectApplicationScenario) {
@@ -221,7 +220,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
             }
         }
 
-        //开始装载9大应用场景分别对应的事件数量
+        //开始装载9大应用场景(应用场景value、应用场景名称、事件数量)↓
         ArrayList<ApplicationScenarioEventNumberVO> results = new ArrayList<>();
         //遍历所有9大应用场景
         for (ApplicationScenario applicationScenario : applicationScenarios) {
@@ -362,7 +361,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
     }
 
     /**
-     * 根据id删除事件
+     * 根据专题库id删除关联的事件
      *
      * @param eventId   事件id
      * @param projectId 专题库id

+ 5 - 4
PAS/src/main/java/cn/cslg/pas/service/impl/PermissionRecordServiceImpl.java

@@ -43,6 +43,7 @@ public class PermissionRecordServiceImpl implements IPermissionRecordService {
     @Override
     public void add(PermissionRecordDTO permissionRecordDTO) {
         log.info("开始处理【新增许可记录】的业务,参数为:{}", permissionRecordDTO);
+
         //DTO赋值给许可记录表实体类
         PermissionRecord permissionRecord = new PermissionRecord();
         BeanUtils.copyProperties(permissionRecordDTO, permissionRecord);
@@ -75,14 +76,14 @@ public class PermissionRecordServiceImpl implements IPermissionRecordService {
         PermissionRecord permissionRecord = new PermissionRecord();
         BeanUtils.copyProperties(permissionRecordUpdateDTO, permissionRecord);
 
-        //根据id修改产品表数据
+        //根据id修改许可记录表数据
         log.info("修改许可记录表数据");
         int rows = permissionRecordMapper.update(permissionRecord);
         if (rows != 1) {
             String message = "修改许可记录失败,服务器忙请稍后再试";
             log.info("修改许可记录表数据失败,{}", message);
         }
-        log.info("产品修改完成");
+        log.info("许可记录修改完成");
     }
 
     /**
@@ -111,10 +112,10 @@ public class PermissionRecordServiceImpl implements IPermissionRecordService {
     }
 
     @Override
-    public Integer countByPatentNo(String patentNo){
+    public Integer countByPatentNo(String patentNo) {
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         Integer tenantId = personnelVO.getTenantId();
-        return  permissionRecordMapper.countByPatentNo(patentNo,tenantId);
+        return permissionRecordMapper.countByPatentNo(patentNo, tenantId);
     }
 
 

+ 17 - 22
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -119,9 +119,11 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     public JsonPage query(ProductCategoryQueryPageDTO productCategoryQueryPageDTO) {
         log.info("开始处理【分页查询产品类别】的业务,参数为:{}", productCategoryQueryPageDTO);
 
+        //获取登陆人信息(取出租户id,控制查询权限)
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         productCategoryQueryPageDTO.setTenantId(personnelVO.getTenantId());
 
+        //分页查询
         Integer current = productCategoryQueryPageDTO.getCurrent();
         Integer size = productCategoryQueryPageDTO.getSize();
         if (current != null && size != null) {
@@ -141,6 +143,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     public void update(ProductCategoryUpdateDTO productCategoryUpdateDTO, List<MultipartFile> files) {
         log.info("开始处理【修改产品类别】的业务,参数为:{}, {}", productCategoryUpdateDTO, files);
 
+        //获取登陆人信息(取出租户id,控制权限)
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         Integer tenantId = personnelVO.getTenantId();
 
@@ -150,18 +153,14 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
         log.info("检查尝试修改的数据是否存在");
         int count = productCategoryMapper.countById(productCategoryId);
         if (count == 0) {
-            String message = "修改产品类别失败,尝试访问的数据已不存在";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("修改产品类别失败,尝试访问的数据已不存在");
         }
 
         //检查尝试修改的产品类别名称是否被占用
         log.info("检查尝试修改的产品类别名称是否被占用");
         count = productCategoryMapper.countByIdAndName(productCategoryId, productCategoryName, tenantId);
         if (count > 0) {
-            String message = "修改产品类别失败,类别名称【" + productCategoryName + "】已存在,请尝试更换名称";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("修改产品类别失败,类别名称【" + productCategoryName + "】已存在,请尝试更换名称");
         }
 
         //产品类别DTO对象赋值给实体类
@@ -171,9 +170,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
         log.info("修改产品类别");
         int rows = productCategoryMapper.updateById(productCategory);
         if (rows != 1) {
-            String message = "修改产品类别失败,服务器忙请稍后再次尝试!";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("修改产品类别失败,服务器忙请稍后再次尝试!");
         }
 
         //先通过产品类别id查询出所有原来的图片文件id
@@ -190,14 +187,16 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
             Integer newOldPictureId = productCategoryPictureUpateDTO.getId();
             newOldPictureIds.add(newOldPictureId);
         }
-        //图片id集合去重,保留下来的即被删除的图片id
+        //集合去重
         oldPictureIds.removeAll(newOldPictureIds);
 
+        //判断若去重后的集合(即被前台删除的图片文件)仍有长度,则根据该图片id集合删除产品类别与图片关联表数据
         if (oldPictureIds.size() > 0) {
             log.info("产品类别图片关联表删除被删除的图片");
             assoProductCategoryPictureMapper.deleteByIds(oldPictureIds);
         }
 
+        //判断若有上传新的图片文件,则上传图片并入库
         if (files != null && files.size() != 0) {
             ArrayList<AssoProductCategoryPicture> assoProductCategoryPictures = new ArrayList<>();
             for (MultipartFile file : files) {
@@ -236,9 +235,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
             log.info("产品类别图片关联表删除数据");
             int rows = assoProductCategoryPictureMapper.deleteByProductCategoryId(id);
             if (rows != count) {
-                String message = "删除产品类别失败,产品类别图片关联表删除数据失败,服务器忙请稍后再试!";
-                log.info("{}", message);
-                throw new XiaoShiException(message);
+                ThrowException.throwXiaoShiException("删除产品类别失败,产品类别图片关联表删除数据失败,服务器忙请稍后再试!");
             }
         }
 
@@ -246,9 +243,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
         log.info("删除产品类别");
         int rows = productCategoryMapper.deleteById(id);
         if (rows != 1) {
-            String message = "删除产品类别失败,服务器忙请稍后再试!";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("删除产品类别失败,服务器忙请稍后再试!");
         }
 
         log.info("删除产品类别完成");
@@ -258,20 +253,20 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     //返回总的营销数据以及每个的营销数据
     @Override
     public List<ProductCategoryTrendVO> showTrend(ProductCategoryDTO dto) {
-        //判断架构id是否有内容,没有的话直接返回null
+        //判断产品类别id是否有内容,没有的话直接返回null
         if (dto.getCategoryId() == null || dto.getCategoryId() == 0) {
             return null;
         }
-        //存储各个产品信息和营销数据
+        //存储每个产品类别信息和营销数据
         List<ProductCategoryTrendVO> trendVOS = new ArrayList<>();
-        //存储所有产品营销数据
+        //存储所有产品类别营销数据
         List<ProductMarketDataTrendVO> saleVOS = new ArrayList<>();
         //存储所有
         ProductCategoryTrendVO totalTrendVO = new ProductCategoryTrendVO();
         //返回总的营销数据 将id设为0
         totalTrendVO.setProductId(0);
         totalTrendVO.setProductName("总产品");
-        //查询架构id返回的总体营销数据
+        //查询产品类别id返回的总体营销数据
         List<ProductMarketDataTrendVO> totalSaleVOS = new ArrayList<>();
         if (dto.getTimeUnit() == 2) {//按照年份返回营销数据
             totalSaleVOS = productCategoryMapper.categoryQueryByYear(dto.getCategoryId(), dto.getCategoryArea(), dto.getCompanyName());
@@ -286,7 +281,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
         //根据传入的类别id、公司名称以及营销地区查询产品id
         List<ProductIdAndNameVO> idNameVOS = new ArrayList<>();
         idNameVOS = productCategoryMapper.queryProductIdAndNameByCategoryId(dto.getCategoryId(), dto.getCompanyName());
-        //返回根据架构id查询到的每个产品id的营销数据
+        //返回根据产品类别id查询到的每个产品id的营销数据
         //遍历
         for (ProductIdAndNameVO idNameVO : idNameVOS) {//遍历类取得id和名称
             ProductCategoryTrendVO trendVO = new ProductCategoryTrendVO();
@@ -321,7 +316,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     public List<String> getCompanyList(Integer id) {
 
         List<String> areaList = new ArrayList<>();
-        //根据架构id获得产品
+        //根据产品类别id获得产品
         LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
         productWrapper.eq(Product::getProductCategoryId, id);
         List<Product> products = productService.list(productWrapper);