xiexiang 2 年之前
父節點
當前提交
b4bd13e304

+ 35 - 0
PAS/src/main/java/cn/cslg/pas/common/model/vo/PatentNoTrendVO.java

@@ -0,0 +1,35 @@
+package cn.cslg.pas.common.model.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 根据专利号查询出来的总的数据
+ *
+ * @Author xiexiang
+ * @Date 2023/3/31
+ */
+@Accessors(chain = true)
+@Data
+public class PatentNoTrendVO {
+    /**
+     * 时间(季度/月份/年份)
+     */
+    private String marketDate;
+
+    /**
+     * 销售额
+     */
+    private Double saleTotalMoney;
+
+    /**
+     * 自定义许可费(销售量 * 自定义许可费率)
+     */
+    private Double customLicenseMoney;
+
+    /**
+     * 许可历史费用
+     */
+    private Double licenseFee;
+
+}

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/common/model/vo/PatentTrendVO.java

@@ -5,7 +5,7 @@ import lombok.Data;
 import java.util.List;
 
 /**
- * 联合专利号总体返回单篇专利价值曲线的VO类
+ * 联合专利号总体返回专利价值曲线的VO类
  *
  * @Author xiexiang
  * @Date 2023/3/15
@@ -20,5 +20,5 @@ public class PatentTrendVO {
     /**
      * 返回类
      */
-    private List<ProductMarketDataTrendVO> saleVOS;
+    private List<PatentNoTrendVO> saleVOS;
 }

+ 25 - 0
PAS/src/main/java/cn/cslg/pas/common/model/vo/PermissionRecordTrendVO.java

@@ -0,0 +1,25 @@
+package cn.cslg.pas.common.model.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 许可历史 许可费用
+ *
+ * @Author xiexiang
+ * @Date 2023/3/31
+ */
+@Accessors(chain = true)
+@Data
+public class PermissionRecordTrendVO {
+
+    /**
+     * 时间(季度/月份/年份)
+     */
+    private String marketDate;
+
+    /**
+     * 许可历史费用
+     */
+    private Double licenseFee;
+}

+ 2 - 0
PAS/src/main/java/cn/cslg/pas/common/model/vo/ProductMarketDataTrendVO.java

@@ -29,6 +29,8 @@ public class ProductMarketDataTrendVO {
          * 自定义许可费(销售量 * 自定义许可费率)
          */
         private Double customLicenseMoney;
+
+
 }
 
 

+ 12 - 0
PAS/src/main/java/cn/cslg/pas/mapper/PatentMarketDataMapper.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.mapper;
 
+import cn.cslg.pas.common.model.vo.PermissionRecordTrendVO;
 import cn.cslg.pas.common.model.vo.ProductMarketDataTrendVO;
 import org.springframework.stereotype.Repository;
 
@@ -27,4 +28,15 @@ public interface PatentMarketDataMapper {
 
     List<ProductMarketDataTrendVO> patentQueryByMonth(List patentNoList, String saleArea);
 
+    /**
+     * 传入专利号,查询时间和许可历史费用
+     * @param patentNoList 专利号(必需)
+     * @return 返回查询到的数据
+     */
+    List<PermissionRecordTrendVO> PRDataQueryByYear(List patentNoList);
+
+    List<PermissionRecordTrendVO> PRDataQueryBySeason(List patentNoList);
+
+    List<PermissionRecordTrendVO> PRDataQueryByMonth(List patentNoList);
+
 }

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

@@ -1,6 +1,7 @@
 package cn.cslg.pas.service;
 
 import cn.cslg.pas.common.model.dto.PatentMarketDataDTO;
+import cn.cslg.pas.common.model.vo.PatentNoTrendVO;
 import cn.cslg.pas.common.model.vo.PatentTrendVO;
 import org.springframework.transaction.annotation.Transactional;
 

+ 54 - 7
PAS/src/main/java/cn/cslg/pas/service/impl/PatentMarketDataServiceImpl.java

@@ -1,7 +1,9 @@
 package cn.cslg.pas.service.impl;
 
 import cn.cslg.pas.common.model.dto.PatentMarketDataDTO;
+import cn.cslg.pas.common.model.vo.PatentNoTrendVO;
 import cn.cslg.pas.common.model.vo.PatentTrendVO;
+import cn.cslg.pas.common.model.vo.PermissionRecordTrendVO;
 import cn.cslg.pas.common.model.vo.ProductMarketDataTrendVO;
 import cn.cslg.pas.mapper.PatentMarketDataMapper;
 import cn.cslg.pas.service.IPatentMarketDataService;
@@ -27,26 +29,71 @@ public class PatentMarketDataServiceImpl implements IPatentMarketDataService {
 
     @Override
     public List<PatentTrendVO> showTrend(PatentMarketDataDTO dto) {
-        //存储专利号以及各专利号对应的营销数据
+        //存储专利号,以及专利号查询出来的信息
         List<PatentTrendVO> trendVOS = new ArrayList<>();
-        //存储产品id查询到的营销数据
-        List<ProductMarketDataTrendVO> saleVOS = new ArrayList<>();
+        //存储专利号查询出来的所有信息
+        List<PatentNoTrendVO> saleVOS = new ArrayList<>();
+        //存储根据专利号查询出来的营销数据部分的信息
+        List<ProductMarketDataTrendVO> pmdVOS = new ArrayList<>();
+        //存储根据专利号查询出来的许可记录部分的信息
+        List<PermissionRecordTrendVO> prVOS = new ArrayList<>();
         //判断专利号集合内是否有内容,没有的话直接返回null
         if(dto.getPatentNoList() == null && dto.getPatentNoList().size() == 0) {
             return null;
         }
         if (dto.getTimeUnit() == 2) {//按照年份返回营销数据
-            saleVOS = patentMarketDataMapper.patentQueryByYear(dto.getPatentNoList(), dto.getSaleArea());
+            pmdVOS = patentMarketDataMapper.patentQueryByYear(dto.getPatentNoList(), dto.getSaleArea());
+            prVOS = patentMarketDataMapper.PRDataQueryByYear(dto.getPatentNoList());
         } else if (dto.getTimeUnit() == 1) {//按照季度返回营销数据
-            saleVOS = patentMarketDataMapper.patentQueryBySeason(dto.getPatentNoList(), dto.getSaleArea());
+            pmdVOS = patentMarketDataMapper.patentQueryBySeason(dto.getPatentNoList(), dto.getSaleArea());
+            prVOS = patentMarketDataMapper.PRDataQueryBySeason(dto.getPatentNoList());
         } else if (dto.getTimeUnit() == null || dto.getTimeUnit() == 0) {//按照月份返回营销数据
-            saleVOS = patentMarketDataMapper.patentQueryByMonth(dto.getPatentNoList(), dto.getSaleArea());
+            pmdVOS = patentMarketDataMapper.patentQueryByMonth(dto.getPatentNoList(), dto.getSaleArea());
+            prVOS = patentMarketDataMapper.PRDataQueryByMonth(dto.getPatentNoList());
         }
+
+        //遍历查询到的许可历史费用
+        for (PermissionRecordTrendVO prVO : prVOS) {
+            //new一个要返回的类
+            PatentNoTrendVO temVO = new PatentNoTrendVO();
+            //将prVOS的数据插入到空的retList中
+            temVO.setMarketDate(prVO.getMarketDate());
+            temVO.setLicenseFee(prVO.getLicenseFee());
+            saleVOS.add(temVO);
+        }
+
+        //遍历专利营销数据费用
+        for(ProductMarketDataTrendVO pmdVO:pmdVOS){
+            //设置一个标志
+            boolean isExistInReturnList = false;
+            //遍历返回的retList
+            for(PatentNoTrendVO ptVO:saleVOS){
+                if(ptVO.getMarketDate().equals(pmdVO.getMarketDate())){
+                    //如果找到了pmdVO中和retList中相同的时间
+                    isExistInReturnList = true;
+                    //将专利营销数据费用赋值给要返回的retList
+                    ptVO.setSaleTotalMoney(pmdVO.getSaleTotalMoney());
+                    ptVO.setCustomLicenseMoney(pmdVO.getCustomLicenseMoney());
+                    break;
+                }
+            }
+
+            //如果没有找到
+            if(!isExistInReturnList){
+                PatentNoTrendVO temVO  = new PatentNoTrendVO();
+                temVO.setMarketDate(pmdVO.getMarketDate());
+                temVO.setSaleTotalMoney(pmdVO.getSaleTotalMoney());
+                temVO.setCustomLicenseMoney(pmdVO.getCustomLicenseMoney());
+                saleVOS.add(temVO);
+            }else{
+                isExistInReturnList = false;
+            }
+        }
+
         PatentTrendVO trendVO = new PatentTrendVO();
         trendVO.setPatentNoList(dto.getPatentNoList());
         trendVO.setSaleVOS(saleVOS);
         trendVOS.add(trendVO);
         return trendVOS;
     }
-
 }

+ 42 - 0
PAS/src/main/resources/mapper/PatentMarkerDataMapper.xml

@@ -79,4 +79,46 @@
                 </if>
         GROUP BY market_date
     </select>
+
+
+    <!--根据专利号集合查询许可历史的信息-->
+    <resultMap id="PRDataQueryByDateMap" type="cn.cslg.pas.common.model.vo.PermissionRecordTrendVO">
+        <result column="market_date" property="marketDate"/>
+        <result column="license_fee" property="licenseFee"/>
+    </resultMap>
+    <!--按照年份返回查询到的信息-->
+    <select id="PRDataQueryByYear" resultMap="PRDataQueryByDateMap">
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m')) as CHAR),'年') AS market_date,
+                SUM(license_fee) AS license_fee
+        FROM permission_record
+        WHERE PATENT_NO IN
+                <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
+                    #{patentNo}
+                </foreach>
+        GROUP BY market_date
+    </select>
+    <!--按照季度返回查询到的信息-->
+    <select id="PRDataQueryBySeason" resultMap="PRDataQueryByDateMap">
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m')) as CHAR),'年',
+        '第',CAST(QUARTER(STR_TO_DATE(license_time,'%Y-%m')) as CHAR),'季度') AS market_date,
+                SUM(license_fee) AS license_fee
+        FROM permission_record
+        WHERE PATENT_NO IN
+                <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
+                    #{patentNo}
+                </foreach>
+        GROUP BY market_date
+    </select>
+    <!--按照月份返回查询到的信息-->
+    <select id="PRDataQueryByMonth" resultMap="PRDataQueryByDateMap">
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m')) AS CHAR),'-',
+                      CAST(MONTH(STR_TO_DATE(license_time,'%Y-%m')) AS CHAR)) AS market_date,
+               SUM(license_fee) AS license_fee
+        FROM permission_record
+        WHERE PATENT_NO IN
+              <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
+                    #{patentNo}
+              </foreach>
+        GROUP BY market_date
+    </select>
 </mapper>

+ 4 - 5
PAS/src/main/resources/mapper/ProductCategoryMapper.xml

@@ -179,7 +179,7 @@
 
     <!--按照年度返回每个-->
     <select id="queryByYear" resultMap="queryByDateMap">
-        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'年') AS market_date,
+        SELECT CONCAT(YEAR(CONCAT(sale_time,'-02')),'年') AS market_date,
         sum(sale_money) AS sale_total_money,
         CAST(sum(custom_license_rate * sale_money) AS DECIMAL (19, 2)) AS custom_license_money
         FROM product_market_data
@@ -192,8 +192,7 @@
 
     <!--按照季度返回每个-->
     <select id="queryBySeason" resultMap="queryByDateMap">
-        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'年',
-        '第',CAST(QUARTER(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'季度') AS market_date,
+        SELECT CONCAT(YEAR(CONCAT(sale_time,'-02')),'年','第',QUARTER(CONCAT(sale_time,'-02')),'季度') AS market_date,
         sum(sale_money) AS sale_total_money,
         CAST(sum(custom_license_rate * sale_money) AS DECIMAL (19, 2)) AS custom_license_money
         FROM product_market_data
@@ -206,8 +205,8 @@
 
     <!--按照月份返回每个-->
     <select id="queryByMonth" resultMap="queryByDateMap">
-        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) AS CHAR),'-',
-        CAST(MONTH(STR_TO_DATE(sale_time,'%Y-%m')) AS CHAR)) AS market_date,
+        SELECT CONCAT(YEAR(CONCAT(sale_time,'-02')),'-',
+        MONTH(CONCAT(sale_time,'-02'))) AS market_date,
         sum(sale_money) AS sale_total_money,
         CAST(sum(custom_license_rate * sale_money) AS DECIMAL (19, 2)) AS custom_license_money
         FROM product_market_data