123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.cslg.pas.mapper.ProductCategoryMapper">
- <!--插入数据-->
- <!--int insert(ProductCategory productCategory);-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="id">
- insert into product_category (product_category_name, remark, license_rate, tenant_id, create_person_id,
- create_person_name)
- values (#{productCategoryName}, #{remark}, #{licenseRate}, #{tenantId}, #{createPersonId},
- #{createPersonName})
- </insert>
- <!--根据id删除数据-->
- <!--int deleteById(Integer id);-->
- <delete id="deleteById">
- delete
- from product_category
- where id = #{id}
- </delete>
- <!--根据id修改数据-->
- <!--int updateById(ProductCategory productCategory);-->
- <update id="updateById">
- update product_category
- <set>
- <if test="productCategoryName != null">
- product_category_name = #{productCategoryName},
- </if>
- <if test="remark != null">
- remark = #{remark},
- </if>
- <if test="licenseRate != null">
- license_rate = #{licenseRate},
- </if>
- </set>
- where id = #{id}
- </update>
- <!--根据产品类别名称统计数量-->
- <!--int countByProductCategoryName(String productCategoryName);-->
- <select id="countByProductCategoryName" resultType="int">
- select count(*)
- from product_category
- where product_category_name = #{productCategoryName}
- and tenant_id = #{tenantId}
- </select>
- <!--根据id和名称统计数量-->
- <!--int countByIdAndName(Integer id, String productCategoryName, Integer tenantId);-->
- <select id="countByIdAndName" resultType="int">
- select count(*)
- from product_category
- where product_category_name = #{productCategoryName}
- and tenant_id = #{tenantId}
- and id != #{id}
- </select>
- <!--根据id统计数量-->
- <!--int countById(Integer id);-->
- <select id="countById" resultType="int">
- select count(*)
- from product_category
- where id = #{id}
- </select>
- <!--分页查询产品类别和图片-->
- <!--List<ProductCategoryVO> query(ProductCategoryQueryPageDTO productCategoryQueryPageDTO);-->
- <select id="query" resultMap="queryMap">
- select
- id pc_id,
- product_category_name,
- remark,
- license_rate,
- create_person_name
- from product_category
- <where>
- <if test="productCategoryName != null">
- and product_category_name like '%${productCategoryName}%'
- </if>
- <if test="createPersonName != null">
- and create_person_id in (select id from pcs_test.personnel where personnel_name like
- '%${createPersonName}%')
- </if>
- <if test="productName != null">
- and id in (select product_category_id from product where product_name like '%${productName}%')
- </if>
- <if test="patentNo != null">
- and id in (select product_category_id from product where id in (select product_id from
- asso_product_patent where patent_no = #{patentNo} union select product_id from
- asso_structure_patent where patent_no = #{patentNo}))
- </if>
- <if test="true">
- and tenant_id = #{tenantId}
- </if>
- </where>
- order by pc_id
- </select>
- <resultMap id="queryMap" type="cn.cslg.pas.common.model.vo.ProductCategoryVO">
- <id column="pc_id" property="id"/>
- <result column="product_category_name" property="productCategoryName"/>
- <result column="remark" property="remark"/>
- <result column="license_rate" property="licenseRate"/>
- <result column="create_person_name" property="createPersonName"/>
- <collection property="pictures" ofType="cn.cslg.pas.common.model.vo.ProductCategoryPictureVO"
- select="query2" column="pc_id">
- </collection>
- </resultMap>
- <select id="query2" resultMap="queryMap2">
- select id, product_category_id, name, suffix, url
- from asso_product_category_picture
- where product_category_id = #{pc_id}
- </select>
- <resultMap id="queryMap2" type="cn.cslg.pas.common.model.vo.ProductCategoryPictureVO">
- <id column="id" property="id"/>
- <result column="product_category_id" property="productCategoryId"/>
- <result column="name" property="name"/>
- <result column="suffix" property="suffix"/>
- <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(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(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(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
- 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(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(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(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 = #{productId}
- <if test="categoryArea != null and categoryArea != ''">
- AND sale_Area = #{categoryArea}
- </if>
- GROUP BY market_date
- </select>
- <!--按照季度返回每个-->
- <select id="queryBySeason" resultMap="queryByDateMap">
- 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
- 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(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 = #{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"/>
- </resultMap>
- <select id="getAreaList" resultMap="getAreaListMap">
- SELECT DISTINCT sale_area
- FROM product_market_data a left join product b on a.product_id =b.id
- <where>
- <if test="productId != null and productId != ''">
- a.product_id = #{productId} and b.tenant_id=#{tenantId}
- </if>
- <if test="categoryId !=null and categoryId != ''">
- product_id
- IN(
- SELECT id
- 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_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>
|