Pārlūkot izejas kodu

修改返回地区和产品趋势图bug

lwhhszx 2 gadi atpakaļ
vecāks
revīzija
7d6084a3a3

+ 4 - 0
PAS/src/main/java/cn/cslg/pas/common/model/dto/GetAreaListDTO.java

@@ -26,4 +26,8 @@ public class GetAreaListDTO {
      * 专利号集合
      */
     private List<String> patentNoList;
+    /**
+     * 租户id
+     */
+    private Integer tenantId;
 }

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

@@ -22,21 +22,21 @@ public interface PatentMarketDataMapper {
      * @param patentNoList 专利号(必需)
      * @return 返回查询到的数据
      */
-    List<ProductMarketDataTrendVO> patentQueryByYear(List patentNoList, String saleArea);
+    List<ProductMarketDataTrendVO> patentQueryByYear(List patentNoList, String saleArea,Integer tenantId);
 
-    List<ProductMarketDataTrendVO> patentQueryBySeason(List patentNoList, String saleArea);
+    List<ProductMarketDataTrendVO> patentQueryBySeason(List patentNoList, String saleArea,Integer tenantId);
 
-    List<ProductMarketDataTrendVO> patentQueryByMonth(List patentNoList, String saleArea);
+    List<ProductMarketDataTrendVO> patentQueryByMonth(List patentNoList, String saleArea,Integer tenantId);
 
     /**
      * 传入专利号,查询时间和许可历史费用
      * @param patentNoList 专利号(必需)
      * @return 返回查询到的数据
      */
-    List<PermissionRecordTrendVO> PRDataQueryByYear(List patentNoList);
+    List<PermissionRecordTrendVO> PRDataQueryByYear(List patentNoList,Integer tenantId);
 
-    List<PermissionRecordTrendVO> PRDataQueryBySeason(List patentNoList);
+    List<PermissionRecordTrendVO> PRDataQueryBySeason(List patentNoList,Integer tenantId);
 
-    List<PermissionRecordTrendVO> PRDataQueryByMonth(List patentNoList);
+    List<PermissionRecordTrendVO> PRDataQueryByMonth(List patentNoList,Integer tenantId);
 
 }

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

@@ -1,10 +1,13 @@
 package cn.cslg.pas.service.impl;
 
+import cn.cslg.pas.common.model.PersonnelVO;
 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.common.utils.CacheUtils;
+import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.pas.mapper.PatentMarketDataMapper;
 import cn.cslg.pas.service.IPatentMarketDataService;
 import lombok.RequiredArgsConstructor;
@@ -25,10 +28,13 @@ import java.util.List;
 @RequiredArgsConstructor
 public class PatentMarketDataServiceImpl implements IPatentMarketDataService {
     private final PatentMarketDataMapper patentMarketDataMapper;
-
+    private final CacheUtils cacheUtils;
+    private final LoginUtils loginUtils;
 
     @Override
     public List<PatentTrendVO> showTrend(PatentMarketDataDTO dto) {
+        PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
+        Integer tenantId =personnelVO.getTenantId();
         //存储专利号,以及专利号查询出来的信息
         List<PatentTrendVO> trendVOS = new ArrayList<>();
         //存储专利号查询出来的所有信息
@@ -42,14 +48,14 @@ public class PatentMarketDataServiceImpl implements IPatentMarketDataService {
             return null;
         }
         if (dto.getTimeUnit() == 2) {//按照年份返回营销数据
-            pmdVOS = patentMarketDataMapper.patentQueryByYear(dto.getPatentNoList(), dto.getSaleArea());
-            prVOS = patentMarketDataMapper.PRDataQueryByYear(dto.getPatentNoList());
+            pmdVOS = patentMarketDataMapper.patentQueryByYear(dto.getPatentNoList(), dto.getSaleArea(),tenantId);
+            prVOS = patentMarketDataMapper.PRDataQueryByYear(dto.getPatentNoList(),tenantId);
         } else if (dto.getTimeUnit() == 1) {//按照季度返回营销数据
-            pmdVOS = patentMarketDataMapper.patentQueryBySeason(dto.getPatentNoList(), dto.getSaleArea());
-            prVOS = patentMarketDataMapper.PRDataQueryBySeason(dto.getPatentNoList());
+            pmdVOS = patentMarketDataMapper.patentQueryBySeason(dto.getPatentNoList(), dto.getSaleArea(),tenantId);
+            prVOS = patentMarketDataMapper.PRDataQueryBySeason(dto.getPatentNoList(),tenantId);
         } else if (dto.getTimeUnit() == null || dto.getTimeUnit() == 0) {//按照月份返回营销数据
-            pmdVOS = patentMarketDataMapper.patentQueryByMonth(dto.getPatentNoList(), dto.getSaleArea());
-            prVOS = patentMarketDataMapper.PRDataQueryByMonth(dto.getPatentNoList());
+            pmdVOS = patentMarketDataMapper.patentQueryByMonth(dto.getPatentNoList(), dto.getSaleArea(),tenantId);
+            prVOS = patentMarketDataMapper.PRDataQueryByMonth(dto.getPatentNoList(),tenantId);
         }
 
         //遍历查询到的许可历史费用

+ 2 - 0
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -307,6 +307,8 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
 
     @Override
     public List<String> getAreaList(GetAreaListDTO dto) {
+        PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
+        dto.setTenantId(personnelVO.getTenantId());
         List<String> areaList = productCategoryMapper.getAreaList(dto);
         return areaList;
 

+ 19 - 10
PAS/src/main/resources/mapper/PatentMarkerDataMapper.xml

@@ -14,8 +14,9 @@
         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
-        WHERE product_id IN
+        FROM  product_market_data a left join  product b on a.product_id =b.id
+        <where>
+         product_id IN
                 (
                 SELECT product_id FROM asso_product_patent WHERE patent_no IN
                 <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
@@ -25,7 +26,9 @@
                 <if test="saleArea != null and saleArea != ''">
                     AND sale_area = #{saleArea}
                 </if>
+            AND b.tenant_id =#{tenantId}
         GROUP BY market_date
+        </where>
     </select>
     <!--传入了地区-->
     <!--按照季度为单位返回查询到的营销数据-->
@@ -33,7 +36,7 @@
         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
+        FROM  product_market_data a left join  product b on a.product_id =b.id
         WHERE product_id IN
                 (
                 SELECT product_id FROM asso_product_patent WHERE patent_no IN
@@ -44,6 +47,7 @@
                 <if test="saleArea != null and saleArea != ''">
                     AND sale_area = #{saleArea}
                 </if>
+        AND b.tenant_id =#{tenantId}
         GROUP BY market_date
     </select>
     <!--传入了地区-->
@@ -52,17 +56,19 @@
         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
-        WHERE product_id IN
+        FROM product_market_data a left join  product b on a.product_id =b.id
+        WHERE a.product_id IN
                 (
                 SELECT product_id FROM asso_product_patent WHERE patent_no IN
                 <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
                     #{patentNo}
                 </foreach>
+
                 )
                 <if test="saleArea != null and saleArea != ''">
                     AND sale_area = #{saleArea}
                 </if>
+        AND b.tenant_id =#{tenantId}
         GROUP BY market_date
     </select>
 
@@ -74,37 +80,40 @@
     </resultMap>
     <!--按照年份返回查询到的信息-->
     <select id="PRDataQueryByYear" resultMap="PRDataQueryByDateMap">
-        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m')) as CHAR),'年') AS market_date,
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m-%d')) 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>
+        and tenant_id =#{tenantId}
         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,
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m-%d')) as CHAR),'年',
+        '第',CAST(QUARTER(STR_TO_DATE(license_time,'%Y-%m-%d')) 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>
+        and tenant_id =#{tenantId}
         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,
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m-%d')) AS CHAR),'-',
+                      CAST(MONTH(STR_TO_DATE(license_time,'%Y-%m-%d')) 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>
+        and tenant_id =#{tenantId}
         GROUP BY market_date
     </select>
 </mapper>

+ 8 - 12
PAS/src/main/resources/mapper/ProductCategoryMapper.xml

@@ -245,10 +245,10 @@
 
     <select id="getAreaList" resultMap="getAreaListMap">
         SELECT DISTINCT sale_area
-        FROM product_market_data
-        WHERE
+        FROM product_market_data a left join  product b on a.product_id =b.id
+        <where>
         <if test="productId != null and productId != ''">
-            product_id = #{productId}
+            a.product_id = #{productId} and b.tenant_id=#{tenantId}
         </if>
         <if test="categoryId !=null and categoryId != ''">
             product_id
@@ -257,23 +257,19 @@
             FROM product
             WHERE
             product_category_id = #{categoryId})
+            and tenant_id=#{tenantId}
         </if>
         <if test="patentNoList != null and patentNoList.size() > 0 ">
             product_id IN(
             SELECT product_id
-            FROM asso_structure_patent
-            WHERE patent_no IN
-            <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
-                #{patentNo}
-            </foreach>
-            UNION
-            SELECT product_id
-            FROM asso_product_patent
-            WHERE patent_no IN
+            FROM asso_product_patent c  left join  product d on c.product_id =d.id
+            WHERE c.patent_no IN
             <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
                 #{patentNo}
             </foreach>
+            and d.tenant_id=#{tenantId}
             )
         </if>
+        </where>
     </select>
 </mapper>