Переглянути джерело

Merge remote-tracking branch 'origin/dev' into dev

chendayu 2 роки тому
батько
коміт
0ae81c5f49

+ 5 - 2
PAS/src/main/java/cn/cslg/pas/common/model/dto/ProductCategoryDTO.java

@@ -12,17 +12,20 @@ import java.io.Serializable;
 @Data
 public class ProductCategoryDTO implements Serializable {
     /**
-     * 产品类别Id
+     * 产品类别Id(必填)
      */
     private Integer categoryId;
+
     /**
      * 产品地区
      */
     private String categoryArea;
+
     /**
-     * 时间单位(0月份,1季度,不传为月份)
+     * 时间单位(0月份,1季度,2年份,不传为月份)
      */
     private Integer timeUnit;
+
     /**
      * 公司名称
      */

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

@@ -16,10 +16,12 @@ public class PMDTrendVO {
      * 产品id
      */
     private Integer productId;
+
     /**
      * 产品名称
      */
     private String productName;
+
     /**
      * 返回类
      */

+ 5 - 17
PAS/src/main/java/cn/cslg/pas/common/model/vo/ProductCategoryTrendVO.java

@@ -11,7 +11,7 @@ import java.util.List;
  */
 @Accessors(chain = true)
 @Data
-public class ProductCategoryTrendVO implements Serializable {
+public class ProductCategoryTrendVO {
     /**
      * 产品id
      */
@@ -20,21 +20,9 @@ public class ProductCategoryTrendVO implements Serializable {
      * 产品名称
      */
     private String productName;
-    private List<saleVO> saleVOS;
-
-    @Data
-    @Accessors(chain = true)
-    public static class saleVO {
-        /**
-         * 时间(季度或者月份)
-         */
-        private String marketDate;
-
-        /**
-         * 销售额
-         */
-        private Double saleTotalMoney;
-
-    }
+    /**
+     * 返回类
+     */
+    private List<ProductMarketDataTrendVO> saleVOS;
 
 }

+ 20 - 0
PAS/src/main/java/cn/cslg/pas/common/model/vo/ProductIdAndNameVO.java

@@ -0,0 +1,20 @@
+package cn.cslg.pas.common.model.vo;
+
+import lombok.Data;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/3/22
+ */
+@Data
+public class ProductIdAndNameVO {
+    /**
+     * 产品id
+     */
+    private Integer productId;
+
+    /**
+     * 产品名称
+     */
+    private String productName;
+}

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

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

+ 6 - 1
PAS/src/main/java/cn/cslg/pas/controller/ProductCategoryController.java

@@ -86,7 +86,12 @@ public class ProductCategoryController {
     @Operation(summary = "查询产品架构趋势图")
     @PostMapping("/showTrend")
     public String showTrend(@RequestBody ProductCategoryDTO dto) {
-        return Response.success(productCategoryService.showTrend(dto));
+        List<ProductCategoryTrendVO> queryResult = productCategoryService.showTrend(dto);
+        if (queryResult != null){
+            return Response.success(queryResult);
+        } else {
+            return Response.error("查询失败");
+        }
     }
 
     @Operation(summary = "获得架构的地区集合")

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

@@ -15,7 +15,7 @@ import java.util.List;
 public interface PatentMarketDataMapper {
 
     /**
-     * 传入的营销地区saleArea,且timeUnit为2,按照年份返回数据
+     * 传入专利号、营销地区saleArea,返回数据
      *
      * @param saleArea 营销地区
      * @param patentNoList 专利号(必需)

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

@@ -3,6 +3,8 @@ package cn.cslg.pas.mapper;
 import cn.cslg.pas.common.model.dto.GetAreaListDTO;
 import cn.cslg.pas.common.model.dto.ProductCategoryQueryPageDTO;
 import cn.cslg.pas.common.model.vo.ProductCategoryVO;
+import cn.cslg.pas.common.model.vo.ProductIdAndNameVO;
+import cn.cslg.pas.common.model.vo.ProductMarketDataTrendVO;
 import cn.cslg.pas.domain.ProductCategory;
 import org.springframework.stereotype.Repository;
 
@@ -65,14 +67,45 @@ public interface ProductCategoryMapper {
     List<ProductCategoryVO> query(ProductCategoryQueryPageDTO productCategoryQueryPageDTO);
 
     /**
-     * 查询地区列表
-     *
-     * @return 返回查询到的地区集合
+     * 根据架构id、营销地区、时间单位和公司名称查询营销数据
+     * @param categoryId 架构id(必需)
+     * @param categoryArea 营销地区
+     * @param companyName 公司名称
+     * @return 返回查询到的营销数据
      */
-    List<String> getAreaList(GetAreaListDTO dto);
+    List<ProductMarketDataTrendVO> categoryQueryByYear(Integer categoryId,String categoryArea,String companyName);
+
+    List<ProductMarketDataTrendVO> categoryQueryBySeason(Integer categoryId,String categoryArea,String companyName);
+
+    List<ProductMarketDataTrendVO> categoryQueryByMonth(Integer categoryId,String categoryArea,String companyName);
+
+    /**
+     * 根据产品id查询营销数据
+     * @param productId 产品id
+     * @param categoryArea 营销地区
+     * @return 返回查询到的营销数据
+     */
+    List<ProductMarketDataTrendVO> queryByYear(Integer productId, String categoryArea);
 
+    List<ProductMarketDataTrendVO> queryBySeason(Integer productId, String categoryArea);
 
+    List<ProductMarketDataTrendVO> queryByMonth(Integer productId, String categoryArea);
 
 
+    /**
+     * 根据架构id查询产品id和名称
+     * @param categoryId 架构id(必需)
+     * @param companyName 公司名
+     * @return productId 产品id
+     * @return productName 产品名称
+     */
+    List<ProductIdAndNameVO> queryProductIdAndNameByCategoryId(Integer categoryId,String companyName);
+
+    /**
+     * 查询地区列表
+     *
+     * @return 返回查询到的地区集合
+     */
+    List<String> getAreaList(GetAreaListDTO dto);
 
 }

+ 38 - 99
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -3,9 +3,7 @@ package cn.cslg.pas.service.impl;
 import cn.cslg.pas.common.JsonPage;
 import cn.cslg.pas.common.model.PersonnelVO;
 import cn.cslg.pas.common.model.dto.*;
-import cn.cslg.pas.common.model.vo.ProductCategoryPictureVO;
-import cn.cslg.pas.common.model.vo.ProductCategoryTrendVO;
-import cn.cslg.pas.common.model.vo.ProductCategoryVO;
+import cn.cslg.pas.common.model.vo.*;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.FileUtils;
 import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
@@ -249,116 +247,57 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
         log.info("删除产品类别完成");
 
     }
-
+    //返回总的营销数据
     @Override
     public List<ProductCategoryTrendVO> showTrend(ProductCategoryDTO dto) {
-        //存储各个产品信息和营销数据信息
+        //判断架构id是否有内容,没有的话直接返回null
+        if(dto.getCategoryId() == null && dto.getCategoryId() == 0) {
+            return null;
+        }
+        //存储各个产品信息和营销数据
         List<ProductCategoryTrendVO> trendVOS = new ArrayList<>();
-        //存储所有产品的营销数据
-        List<ProductMarketData> marketData = new ArrayList<>();
+        //存储所有产品营销数据
+        List<ProductMarketDataTrendVO> saleVOS = new ArrayList<>();
         //存储所有
-        ProductCategoryTrendVO trendAllVO = new ProductCategoryTrendVO();
-        trendAllVO.setProductId(0);
-
-        trendAllVO.setProductName("总产品");
-        Map<String, Object> allMarketDataMap = new HashMap<>();
-        //根据产品类别ID获得产品id和产品名称
-        LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
-        productWrapper.eq(Product::getProductCategoryId, dto.getCategoryId());
-        if (dto.getCompanyName() != null && dto.getCompanyName() != "") {
-            productWrapper.eq(Product::getCompanyName, dto.getCompanyName());
+        ProductCategoryTrendVO totalTrendVO = new ProductCategoryTrendVO();
+        totalTrendVO.setProductId(0);
+        totalTrendVO.setProductName("总产品");
+        //查询架构id返回的总体营销数据
+        List<ProductMarketDataTrendVO> totalSaleVOS = new ArrayList<>();
+        if (dto.getTimeUnit() == 2) {//按照年份返回营销数据
+            totalSaleVOS = productCategoryMapper.categoryQueryByYear(dto.getCategoryId(),dto.getCategoryArea(),dto.getCompanyName());
+        } else if (dto.getTimeUnit() == 1) {//按照季度返回营销数据
+            totalSaleVOS = productCategoryMapper.categoryQueryBySeason(dto.getCategoryId(),dto.getCategoryArea(),dto.getCompanyName());
+        } else if (dto.getTimeUnit() == null || dto.getTimeUnit() == 0) {//按照月份返回营销数据
+            totalSaleVOS = productCategoryMapper.categoryQueryByMonth(dto.getCategoryId(),dto.getCategoryArea(),dto.getCompanyName());
         }
-        List<Product> products = productService.list(productWrapper);
-        if (products.size() != 0) {
-            List<Integer> productIds = products.stream().map(Product::getId).collect(Collectors.toList());
-            if (productIds.size() > 0) {
-                //根据产品Id获得产品营销数据
-                LambdaQueryWrapper<ProductMarketData> market = new LambdaQueryWrapper<>();
-                market.in(ProductMarketData::getProductId, productIds);
-                marketData = productMarketDataIService.list(market);
-            }
-        }
-        for (Product product : products) {
+        totalTrendVO.setSaleVOS(totalSaleVOS);
+        trendVOS.add(totalTrendVO);
+        //根据传入的架构id、公司名称以及营销地区查询产品id
+        List<ProductIdAndNameVO> idNameVOS = new ArrayList<>();
+        idNameVOS = productCategoryMapper.queryProductIdAndNameByCategoryId(dto.getCategoryId(), dto.getCompanyName());
+        //返回根据架构id查询到的每个产品id的营销数据
+        for(ProductIdAndNameVO idNameVO:idNameVOS){
             ProductCategoryTrendVO trendVO = new ProductCategoryTrendVO();
-            trendVO.setProductId(product.getId());
-            trendVO.setProductName(product.getProductName());
-            //获得产品的营销数据
-            // 如果地区不为空
-            List<ProductMarketData> temMarketData = new ArrayList<>();
-            if (dto.getCategoryArea() != null && dto.getCategoryArea() != "") {
-                temMarketData = marketData.stream().filter(item -> item.getProductId().equals(product.getId()) && item.getSaleArea().equals(dto.getCategoryArea())).collect(Collectors.toList());
-            } else {
-                temMarketData = marketData.stream().filter(item -> item.getProductId().equals(product.getId())).collect(Collectors.toList());
-            }
-            Map<String, Object> marketDataMap = new HashMap<>();
-            //营销数据遍历
-            temMarketData.forEach(item -> {
-                        //获得营销数据的时间
-                        String date = item.getSaleTime();
-                        double saleCount = item.getSaleMoney();
-                        if (dto.getTimeUnit() == 1) {
-                            try {
-                                Date dateForm = new SimpleDateFormat("yyyy-MM").parse(date);
-                                Calendar ca = Calendar.getInstance();
-                                ca.setTime(dateForm);
-                                int month = ca.get(Calendar.MONTH);//第几个月
-                                int year = ca.get(Calendar.YEAR);//年份数值
-                                int season = (month - 1) / 3 + 1;
-                                date = year + "-" + season;
-                            } catch (ParseException e) {
-                                e.printStackTrace();
-                            }
-                        } else if (dto.getTimeUnit() == 2) {
-                            try {
-                                Date dateForm = new SimpleDateFormat("yyyy-MM").parse(date);
-                                Calendar ca = Calendar.getInstance();
-                                ca.setTime(dateForm);
-                                int year = ca.get(Calendar.YEAR);//年份数值
-                                date = year + "";
-                            } catch (ParseException e) {
-                                e.printStackTrace();
-                            }
-                        }
-                        //计算销售额
-                        if (marketDataMap.get(date) != null) {
-                            saleCount += Double.parseDouble(marketDataMap.get(date).toString());
-                        }
-                        marketDataMap.put(date, saleCount);
-
-                        //产品总体部分
-                        if (allMarketDataMap.get(date) != null) {
-                            saleCount += Double.parseDouble(allMarketDataMap.get(date).toString());
-                        }
-                        allMarketDataMap.put(date, saleCount);
-                    }
-            );
-            Set keyset = marketDataMap.keySet();
-            List<ProductCategoryTrendVO.saleVO> saleVOS = new ArrayList<>();
-            for (Object key : keyset) {
-                ProductCategoryTrendVO.saleVO saleVO = new ProductCategoryTrendVO.saleVO();
-                saleVO.setMarketDate(key.toString());
-                saleVO.setSaleTotalMoney(Double.parseDouble(marketDataMap.get(key).toString()));
-                saleVOS.add(saleVO);
+            trendVO.setProductId(idNameVO.getProductId());
+            trendVO.setProductName(idNameVO.getProductName());
+            List<ProductMarketDataTrendVO> temSaleVOS = new ArrayList<>();
+            if (dto.getTimeUnit() == 2) {//按照年份返回营销数据
+                temSaleVOS = productCategoryMapper.queryByYear(idNameVO.getProductId(),dto.getCategoryArea());
+            } else if (dto.getTimeUnit() == 1) {//按照季度返回营销数据
+                temSaleVOS = productCategoryMapper.queryBySeason(idNameVO.getProductId(),dto.getCategoryArea());
+            } else if (dto.getTimeUnit() == null || dto.getTimeUnit() == 0) {//按照月份返回营销数据
+                temSaleVOS = productCategoryMapper.queryByMonth(idNameVO.getProductId(),dto.getCategoryArea());
             }
-            trendVO.setSaleVOS(saleVOS);
+            trendVO.setSaleVOS(temSaleVOS);
             trendVOS.add(trendVO);
         }
-        Set keyset = allMarketDataMap.keySet();
-        List<ProductCategoryTrendVO.saleVO> saleVOS = new ArrayList<>();
-        for (Object key : keyset) {
-            ProductCategoryTrendVO.saleVO saleVO = new ProductCategoryTrendVO.saleVO();
-            saleVO.setMarketDate(key.toString());
-            saleVO.setSaleTotalMoney(Double.parseDouble(allMarketDataMap.get(key).toString()));
-            saleVOS.add(saleVO);
-        }
-        trendAllVO.setSaleVOS(saleVOS);
-        trendVOS.add(trendAllVO);
         return trendVOS;
     }
 
+
     @Override
     public List<String> getAreaList(GetAreaListDTO dto) {
-
         List<String> areaList = new ArrayList<>();
         areaList = productCategoryMapper.getAreaList(dto);
         return areaList;

+ 17 - 9
PAS/src/main/resources/mapper/PatentMarkerDataMapper.xml

@@ -5,13 +5,16 @@
     <resultMap id="queryByDateMap" type="cn.cslg.pas.common.model.vo.ProductMarketDataTrendVO">
         <result column="market_date" property="marketDate"/>
         <result column="sale_total_money" property="saleTotalMoney"/>
+        <result column="custom_license_money" property="customLicenseMoney"/>
     </resultMap>
 
     <!--传入了地区-->
     <!--按照年为单位返回查询到的营销数据-->
     <select id="patentQueryByYear" resultMap="queryByDateMap">
-        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'年') AS market_date,sum(sale_money) AS sale_total_money
-        FROM product_market_data
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'年') 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
                 (SELECT product_id FROM asso_structure_patent WHERE patent_no IN
                 <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
@@ -23,7 +26,7 @@
                     #{patentNo}
                 </foreach>
                 )
-                <if test="saleArea !=null and saleArea != ''">
+                <if test="saleArea != null and saleArea != ''">
                     AND sale_area = #{saleArea}
                 </if>
         GROUP BY market_date
@@ -31,8 +34,11 @@
     <!--传入了地区-->
     <!--按照季度为单位返回查询到的营销数据-->
     <select id="patentQueryBySeason" 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,sum(sale_money) AS sale_total_money
-        FROM product_market_data
+        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,
+            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
                 (SELECT product_id FROM asso_structure_patent WHERE patent_no IN
                 <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
@@ -44,7 +50,7 @@
                     #{patentNo}
                 </foreach>
                 )
-                <if test="saleArea !=null and saleArea != ''">
+                <if test="saleArea != null and saleArea != ''">
                     AND sale_area = #{saleArea}
                 </if>
         GROUP BY market_date
@@ -52,7 +58,10 @@
     <!--传入了地区-->
     <!--按照月份为单位返回查询到的营销数据-->
     <select id="patentQueryByMonth" 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,sum(sale_money) AS sale_total_money
+        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,
+            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
                 (SELECT product_id FROM asso_structure_patent WHERE patent_no IN
@@ -65,10 +74,9 @@
                     #{patentNo}
                 </foreach>
                 )
-                <if test="saleArea !=null and saleArea != ''">
+                <if test="saleArea != null and saleArea != ''">
                     AND sale_area = #{saleArea}
                 </if>
         GROUP BY market_date
     </select>
-
 </mapper>

+ 119 - 0
PAS/src/main/resources/mapper/ProductCategoryMapper.xml

@@ -106,6 +106,125 @@
         <result column="url" property="url"/>
     </resultMap>
 
+    <resultMap id="queryByDateMap" type="cn.cslg.pas.common.model.vo.ProductMarketDataTrendVO">
+        <result column="market_date" property="marketDate"/>
+        <result column="sale_total_money" property="saleTotalMoney"/>
+        <result column="custom_license_money" property="customLicenseMoney"/>
+    </resultMap>
+
+    <!--根据产品架构id、公司名称、营销地区、时间单位查询产品类别营销数据-->
+    <!--按照月份返回总体-->
+    <select id="categoryQueryByMonth" 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,
+               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(SELECT id AS product_id
+                            FROM product
+                            WHERE product_category_id = #{categoryId}
+                            <if test="companyName != null and companyName != ''">
+                                AND company_name = #{companyName}
+                            </if>)
+                <if test="categoryArea != null and categoryArea != ''">
+                    AND sale_area = #{categoryArea}
+                </if>
+        GROUP BY market_date
+    </select>
+
+    <!--按照季度返回总体-->
+    <select id="categoryQueryBySeason" 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,
+               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(SELECT id AS product_id
+                            FROM product
+                            WHERE product_category_id = #{categoryId}
+                            <if test="companyName != null and companyName != ''">
+                                AND company_name = #{companyName}
+                            </if>)
+        <if test="categoryArea != null and categoryArea != ''">
+            AND sale_area = #{categoryArea}
+        </if>
+        GROUP BY market_date
+    </select>
+    <!--按照年度返回总体-->
+    <select id="categoryQueryByYear" resultMap="queryByDateMap">
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'年') 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(SELECT id AS product_id
+                            FROM product
+                            WHERE product_category_id = #{categoryId}
+                            <if test="companyName != null and companyName != ''">
+                                AND company_name = #{companyName}
+                            </if>)
+        <if test="categoryArea != null and categoryArea != ''">
+            AND sale_area = #{categoryArea}
+        </if>
+        GROUP BY market_date
+    </select>
+
+    <!--按照年度返回每个-->
+    <select id="queryByYear" resultMap="queryByDateMap">
+        SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'年') 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 = #{productId}
+        <if test="categoryArea != null and categoryArea != ''">
+            AND sale_Area = #{categoryArea}
+        </if>
+        GROUP BY market_date
+    </select>
+
+    <!--按照季度返回每个-->
+    <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,
+                      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 = #{productId}
+        <if test="categoryArea != null and categoryArea != ''">
+            AND sale_Area = #{categoryArea}
+        </if>
+        GROUP BY market_date
+    </select>
+
+    <!--按照月份返回每个-->
+    <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,
+                      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 = #{productId}
+        <if test="categoryArea != null and categoryArea != ''">
+            AND sale_Area = #{categoryArea}
+        </if>
+        GROUP BY market_date
+    </select>
+
+    <!--根据架构id查询产品id和名称-->
+    <resultMap id="idNameMap" type="cn.cslg.pas.common.model.vo.ProductIdAndNameVO">
+        <result column="product_id" property="productId"/>
+        <result column="product_name" property="productName"/>
+    </resultMap>
+
+    <select id="queryProductIdAndNameByCategoryId" resultMap="idNameMap">
+        SELECT id AS product_id,product_name
+        FROM  product
+        WHERE product_category_id = #{categoryId}
+        <if test="companyName != null and companyName != ''">
+          AND company_name = #{companyName}
+        </if>
+    </select>
+
+
     <!--根据产品id、架构id和专利号集合三者其一查询地区集合-->
     <resultMap id="getAreaListMap" type="String">
         <result column="sale_area" property="saleArea"/>

+ 7 - 3
PAS/src/main/resources/mapper/ProductMarketDataMapper.xml

@@ -112,11 +112,13 @@
     <resultMap id="queryByDateMap" type="cn.cslg.pas.common.model.vo.ProductMarketDataTrendVO">
         <result column="market_date" property="marketDate"/>
         <result column="sale_total_money" property="saleTotalMoney"/>
+        <result column="custom_license_money" property="customLicenseMoney"/>
     </resultMap>
 
     <select id="queryByYear" resultMap="queryByDateMap">
         SELECT CONCAT(CAST(YEAR(STR_TO_DATE(sale_time,'%Y-%m')) as CHAR),'年') AS market_date,
-               sum(sale_money) AS sale_total_money
+            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 = #{productId}
         <if test="saleArea != null and saleArea != ''">
@@ -128,7 +130,8 @@
     <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,
-               sum(sale_money) AS sale_total_money
+            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 = #{productId}
         <if test="saleArea != null and saleArea != ''">
@@ -140,7 +143,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,
-               sum(sale_money) AS sale_total_money
+            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 = #{productId}
         <if test="saleArea != null and saleArea != ''">